\n"; $inframe=0; if ($output == "fi") { $output="n"; $inframe=1;} if ($output == "") $output="n"; if ($output == "n") { ?>

Star Trek Chronology

Search Results

= $syear and "; if ($eyear || $eyear == "0") $query_eng .= "Date: $syear - $eyear; "; else $query_eng .= "Date: $year - end; "; } if ($smonth) $q .= " (month_ >= $smonth or month = 0) and "; if ($sday ) $q .= " (day_ >= $sday or day = 0) and "; if ($eyear || $eyear == "0") { $eyear = abs($eyear)*$eacbc; $q .= " year_ <= $eyear and "; if (!$eyear and $eyear <> "0") $query_eng .= "Date: beginning - $eyear; "; } if ($emonth) $q .= " (month_ <= $emonth or month = 0) and "; if ($eday ) $q .= " (day_ <= $eday or day = 0) and "; if ($lim_groups <> 0) { $qhn = 1; $q .= " ( "; if ($lim_groups == 1) { $query_eng .= "Sources: "; $q .= " group_id in ("; for ($i = 0; $i < count($groups); $i++) { $q .= "\"$groups[$i]\","; $query_eng .= "$groups[$i],"; } $q = substr($q, 0, strlen($q)-1); // remove last , $q .= ") "; $query_eng = substr($query_eng, 0, strlen($query_eng)-1); $query_eng .= "; "; } else { $q .= " group_id in ('DS9','VOY','TNG','TOS','MOV') "; $query_eng .= "Sources: TOS,MOV,TNG,DS9,VOY; "; } $q .= " ) and "; } if ($query) { $qhn = 2; $q= " $query "; $query_eng = $query; } $where = substr($q, 0, strlen($q)-5); $q = "$qh[$qhn]$q"; $q = substr($q, 0, strlen($q)-5); $q.= " order by id"; $where = ereg_replace("\\\\","\\\\\\\\",$where); $where = ereg_replace("'" ,"\'",$where); $query_eng = substr($query_eng, 0, strlen($query_eng)-2); unset($ret); $host_ip = GetEnv("REMOTE_HOST"); exec("nslookup $host_ip",&$ret); $host = ereg_replace("Name:[ ].","",$ret[3]); $host = ereg_replace("^.*find[ ].","",$host); $host = ereg_replace(":.*$","",$host); if (!$host) $host = $host_ip; if ((int) $res_page <= 0) $res_page = 100; mysql("usenet-i", "insert into jobs values (0,null,0,$res_page,'$query_eng','$where','$host',null,'$host_ip')"); $unique_id = mysql_insert_id(); $job_id = $unique_id; if ($where=="" && $res_page == 100) { $job_id = 3; $num = 6818; } else { mysql("usenet-i", "insert into q_results select distinct $job_id, 1, id $q"); $num = mysql_affected_rows(); } $fp = fopen("search.log","a"); $date = date("Y/m/d H:i:s"); fputs ($fp, "$date\t$unique_id\t$job_id\t$query_eng\t$res_page\t$num\t$host\t$host_ip\n"); fclose($fp); mysql("usenet-i", "update jobs set job_id = $job_id, num_res = $num where unique_id = $unique_id"); $page = 1; if ($num > $res_page && $job_id > 100) { $result = mysql("usenet-i", "select id_match from q_results where job_lookup = $job_id order by id_match"); $start = mysql_result($result, $res_page, "id_match"); do { $page++; $i = $res_page*$page; if ($i < $num) $end = mysql_result($result, $i, "id_match"); else $end = 7000; mysql("usenet-i", "update q_results set page_num = $page where job_lookup = $job_id and id_match >= $start and id_match < $end"); $start = $end; } while ($i < $num); $page = 1; } } $inforesult = mysql("usenet-i","select * from jobs where unique_id = $job_id"); $num = mysql_Result($inforesult, 0, "num_res"); $res_page = mysql_Result($inforesult, 0, "res_page"); $prev = $page - 1; if ($prev < 1) $prev = 0; $next = $page + 1; if (($next-1) * $res_page >= $num) $next = 0; if ($output == "n") { if ($inframe) { echo ""; } $qe = mysql_Result($inforesult, 0, "query_eng"); $result = mysql("usenet-i", "select date_, data_, sources, id, year_ from timeline, q_results where id = id_match and job_lookup = $job_id and page_num = $page order by id"); $where = mysql_Result($inforesult, 0, "where_clause"); $query_eng = mysql_Result($inforesult, 0, "query_eng"); $num2 = mysql_numrows($result); $first = ($page-1)*$res_page+1; $last = $page*$res_page; if ( $last > $num ) $last = $num; if ($num <> 0) { echo "

$num records found"; if ($query_eng) echo " for \"$query_eng\""; echo ".
\n"; echo "Displaying results $first-$last from years ", yearl(mysql_result($result,0,"year_")), " to ", yearl(mysql_result($result,$num2-1,"year_")),".
\n"; if (!$inframe) echo "To find out what the abbreviations mean please see the abbreviation key.
\n"; } else { echo "
Sorry No records where found"; if ($query_eng) echo " for \"$query_eng\""; echo ". Please try again.\n"; } echo "


"; echo "
"; for ($i = 0; $i < $num2; $i++) { echo "\n
\n"; echo mysql_result($result, $i, "date_"); echo "\n
\n"; echo mysql_result($result, $i, "data_"); echo " "; echo ""; if ($inframe) { echo ""; } echo "[" . mysql_result($result, $i, "sources") . "]"; if ($inframe) echo ""; echo ""; } echo "\n
\n"; echo "

WHERE clause: $where


\n

"; echo "Back | "; if (!$inframe) { $outpput = "n"; } else { $outpput = "fi"; } if ($prev) { echo "Prev Page | "; } if ($next) { echo "Next Page | "; } ?> Abrv Key | Notes | Feedback