sitimania

Cerca

Vai ai contenuti

") + 7; $endtitle = strpos($file_content,""); if(($starttitle != false) && ($endtitle != false)) { foreach($queries as $query) { $title = substr($file_content,$starttitle,$endtitle-$starttitle); while (($title = stristr($title, $query)) !== false) { $weight += 4; $title = substr($title,strlen($query)); } } } $page_pos = strpos($file_content,"")+19; $page_end = strpos($file_content,""); if($page_pos != false && $page_end != false) $file_content = substr($file_content,$page_pos, $page_end-$page_pos); $file_content = strip_tags($file_content); foreach($queries as $query) { $file = $file_content; while (($file = stristr($file, $query)) !== false) { $count++; $weight++; $file = substr($file,strlen($query)); } } if($count > 0) { $found_count[$filename] = $count; $found_weight[$filename] = $weight; } } if($found_count != null) { arsort($found_weight); $i = 0; $pagine = ceil(count($found_count)/10); if(($page >= $pagine) || ($page < 0)) $page = 0; echo "
Risultati della ricerca per ". $search ."
" . ($page*10+1) . "-" . (count($found_count)<($page+1)*10? count($found_count):($page+1)*10) . " su " . count($found_count) . "
\n"; foreach($found_weight as $name => $weight) { $count = $found_count[$name]; $i++; if(($i > $page*10) && ($i <= ($page+1)*10)) { $file = implode(" ",file($name)); $starttitle = strpos($file,"") + 7; $endtitle = strpos($file,""); if(($starttitle != false) && ($endtitle != false)) $title = substr($file,$starttitle,$endtitle-$starttitle); else $title = $name; $page_pos = strpos($file,"")+19; $page_end = strpos($file,""); if($page_pos != false && $page_end != false) $file = substr($file,$page_pos, $page_end-$page_pos); $file = strip_tags($file); $ap = 0; $filelen = strlen($file); $text = ""; for($j=0;$j<($count > 6 ? 6 : $count);$j++) { $minpos = $filelen; foreach($queries as $query) { if(($pos = strpos(strtoupper($file),strtoupper($query),$ap)) !== false) { if($pos < $minpos) { $minpos = $pos; $word = $query; } } } $prev = explode(" ",substr($file,$ap,$minpos-$ap)); if(count($prev) > ($ap > 0 ? 9 : 8)) $prev = ($ap > 0 ? implode(" ",array_slice($prev,0,8)) : "") . " ... " . implode(" ",array_slice($prev,-8)); else $prev = implode(" ",$prev); $text .= $prev . "" . substr($file,$minpos,strlen($word)) . " "; $ap = $minpos + strlen($word); } $next = explode(" ",substr($file,$ap)); if(count($next) > 9) $text .= implode(" ",array_slice($next,0,8)) . "..."; else $text .= implode(" ",$next); echo "
" . $title . " (" . $count . " " . ($count > 1 ? "Risultati" : "Risultato") . ")
" . $text . "\n"; } } echo "
 
\n"; if ($pagine > 1) { echo " Pagina "; for($i = 1; $i <= $pagine; $i++) if($i != $page+1) echo "" . $i . " "; else echo "" . $i . " "; echo "\n"; } } else echo "
Nessun risultato trovato
\n"; } ?>


Torna ai contenuti | Torna al menu