от 76 до 140.
CODE:function get_results($inforum,$wholeword,$querymode,$query_arr,&$allres) {
global $_SEARCH;
$HASH = 'search/db/'.$inforum.'_hash';
$HASHWORDS = 'search/db/'.$inforum.'_hashwords';
$SITEWORDS = 'search/db/'.$inforum.'_sitewords';
$WORD_IND = 'search/db/'.$inforum.'_word_ind';
if (!file_exists($HASH) || !file_exists($HASHWORDS) || !file_exists($SITEWORDS) || !file_exists($WORD_IND)) return;
$fp_HASH = fopen($HASH, "rb");
$fp_HASHWORDS = fopen($HASHWORDS, "rb");
$fp_SITEWORDS = fopen($SITEWORDS, "rb");
$fp_WORD_IND = fopen($WORD_IND, "rb");
for ($j=0; $j < count($query_arr); $j++) {
$query = $query_arr[$j];
$allres[$j] = array();
if ($_SEARCH['INDEXING_SCHEME'] == 1) {
$substring_length = strlen($query);
} else {
$substring_length = 4;
}
$hash_value = abs(exbb_hash(substr($query,0,$substring_length)) % $_SEARCH['HASHSIZE']);
fseek($fp_HASH,$hash_value*4,0);
$dum = fread($fp_HASH,4);
$dum = unpack("Ndum", $dum);
fseek($fp_HASHWORDS,$dum['dum'],0);
$dum = fread($fp_HASHWORDS,4);
$dum1 = unpack("Ndum", $dum);
for ($i=0; $i<$dum1['dum']; $i++) {
$dum = fread($fp_HASHWORDS,8);
$arr_dum = unpack("Nwordpos/Nfilepos",$dum);
fseek($fp_SITEWORDS,$arr_dum['wordpos'],0);
$word = fgets($fp_SITEWORDS,1024);
$word = preg_replace("/\x0A/","",$word);
$word = preg_replace("/\x0D/","",$word);
if (array_key_exists($j,$wholeword) && ($wholeword[$j]==1) && ($word != $query)) {
$word = '';
}
$pos = strpos($word, $query);
if ($pos !== false) {
fseek($fp_WORD_IND,$arr_dum['filepos'],0);
$dum = fread($fp_WORD_IND,4);
$dum2 = unpack("Ndum",$dum);
$dum = fread($fp_WORD_IND,$dum2['dum']*4);
for($k=0; $k < $dum2['dum']; $k++){
$zzz = unpack("Ndum",substr($dum,$k*4,4));
$allres[$j][$zzz['dum']] = 1;
}
}
}
}
fclose($fp_HASH);
fclose($fp_HASHWORDS);
fclose($fp_SITEWORDS);
fclose($fp_WORD_IND);
}
123 строка fseek($fp_WORD_IND,$arr_dum['filepos'],0);
|