Use the form below to search through the files at The Negotiation Skills Company website
error_reporting(E_ALL);
/**
* RiSearch PHP
*
* web search engine, version 0.2
* (c) Sergej Tarasov, 2000-2004
*
* Homepage: http://risearch.org/
* email: risearch@risearch.org
*/
include "config.php";
include "common_lib.php";
$time1 = getmicrotime();
read_template("template.htm");
$stpos = 0;
$stype = "AND";
$query = "";
$abort = 0;
get_query();
if (count($query_arr) > 0) {
get_results();
$time3 = getmicrotime();
$time = $time3-$time1;
# print " get_results() took $time sec. ";
boolean();
$time4 = getmicrotime();
$time = $time4-$time3;
$search_time = $time4-$time1;
$search_time = sprintf("%2.4f", $search_time);
# print " boolean() took $time sec. ";
}
print print_template("header");
if (count($query_arr) > 0) {
if ($rescount>0) {
print print_template("results_header");
print_results();
print print_template("results_footer");
} else {
print print_template("no_results");
}
} else {
print print_template("empty_query");
}
print print_template("footer");
#=====================================================================
#
# Function get_query()
# Last modified: 14.05.2004 16:32
#
#=====================================================================
function get_query() {
global $HTTP_GET_VARS;
global $query, $stpos, $stype, $query_arr, $wholeword, $querymode, $stop_words_array;
global $min_length;
global $numbers;
$query = @$HTTP_GET_VARS["query"];
$stpos = @$HTTP_GET_VARS["stpos"];
$stype = @$HTTP_GET_VARS["stype"];
$query = strtolower($query);
$query = preg_replace("/[^a-zą-’$numbers +!-]/"," ",$query);
$query_arr_dum = preg_split("/\s+/",$query);
foreach($query_arr_dum as $word) {
if (strlen($word) < $min_length) { continue; }
if (array_key_exists($word,$stop_words_array)) { continue; }
$query_arr[] = $word;
}
for ($i=0; $i $v) {
if ($k) {
$res .= pack("N",$k);
}
}
$rescount = intval(strlen($res)/4);
unset($allres);
return;
} else {
if ($stype == "AND") {
for ($i=0; $i $v) {
if (array_key_exists($k,$allres[$i])) {
} else {
unset($allres[$min][$k]);
}
}
} else {
foreach ($allres[$min] as $k => $v) {
if (array_key_exists($k,$allres[$i])) {
unset($allres[$min][$k]);
}
}
}
}
foreach ($allres[$min] as $k => $v) {
if ($k) {
$res .= pack("N",$k);
}
}
$rescount = intval(strlen($res)/4);
return;
}
if ($stype == "OR") {
for ($i=0; $i count($allres[$max]) && $querymode[$i] != 1) {
$max = $i;
}
}
for ($i=0; $i $v) {
$allres[$max][$k] = 1;
}
} else {
foreach ($allres[$i] as $k => $v) {
if (array_key_exists($k,$allres[$max])) {
unset($allres[$max][$k]);
}
}
}
}
foreach ($allres[$max] as $k => $v) {
if ($k) {
$res .= pack("N",$k);
}
}
$rescount = intval(strlen($res)/4);
return;
}
}
}
#=====================================================================
#
# Function print_results()
# Last modified: 16.04.2004 17:54
#
#=====================================================================
function print_results() {
global $FINFO, $FINFO_IND, $query, $stpos, $stype, $res_num, $res;
global $url, $title, $size, $description, $rescount, $next_results;
global $query_arr;
$time1 = getmicrotime();
$fp_FINFO = fopen ("$FINFO", "rb") or die("No index file is found! Please run indexing script again.");
for ($i=$stpos; $i<$stpos+$res_num; $i++) {
if ($i >= strlen($res)/4) {break;};
$strpos = unpack("Npos",substr($res,$i*4,4));
fseek($fp_FINFO,$strpos['pos'],0);
$dum = fgets($fp_FINFO,4024);
list($url, $size, $title, $description) = explode("::",$dum);
for ($j=0; $j$1", $description);
}
print print_template("results");
}; # for
if ($rescount <= $res_num) {$next_results = ""; return 1;}
$mhits = 20 * $res_num;
$pos2 = $stpos - $stpos % $mhits;
$pos1 = $pos2 - $mhits;
$pos3 = $pos2 + $mhits;
if ($pos1 < 0) { $prev = ""; }
else {
$prev = " $rescount) { $next = ""; }
else {
$next = " = $rescount) {break;}
$page_number = $i/$res_num+1;
if ( $i != $stpos ) {
$next_results .= " |\n";
} else {
$next_results .= $page_number." |\n";
}
}
$next_results .= $next;
}
#=====================================================================
#
# Function read_template($filename)
# Last modified: 16.04.2004 17:54
#
#=====================================================================
function read_template($filename) {
$size = filesize($filename);
$fd = @fopen ($filename, "rb") or die(check_file_priv($filename));
$template = fread ($fd, $size);
fclose ($fd);
global $templates;
$count = preg_match_all("/(.*?)/s", $template, $matches, PREG_SET_ORDER);
for($i=0; $i < count($matches); $i++) {
$templates[$matches[$i][1]] = $matches[$i][2];
}
}
#=====================================================================
#
# Function print_template($part)
# Last modified: 16.04.2004 17:54
#
#=====================================================================
function print_template($part) {
global $templates;
global $query, $search_time, $query_statistics, $stpos, $url, $title, $size, $description, $rescount, $next_results;
$template = $templates[$part];
$template = preg_replace("/%query%/s","$query",$template);
$template = preg_replace("/%search_time%/s","$search_time",$template);
$template = preg_replace("/%query_statistics%/s","$query_statistics",$template);
$template = preg_replace("/%stpos%/s",$stpos+1,$template);
$template = preg_replace("/%url%/s","$url",$template);
$template = preg_replace("/%title%/s","$title",$template);
$template = preg_replace("/%size%/s","$size",$template);
$template = preg_replace("/%description%/s","$description",$template);
$template = preg_replace("/%rescount%/s","$rescount",$template);
$template = preg_replace("/%next_results%/s","$next_results",$template);
return $template;
}
#===================================================================
?>
|