Contate o administrador deste site."; $err_index = "Arquivo index não pode ser aberto.
Verifique diretório, permissões e tente novamente."; $index_complete = "Site indexado."; $index_cleared = "Arquivo index apagado.
Nenhum resultado será fornecido enquanto o site não for re-indexado."; $no_files = "Nenhum arquivo foi encontrado neste diretório para indexar."; $no_dir = "Diretório especificado não encontrado."; $err_index_empty = "Arquivo index encontrado, más está vazio."; // Sets the version. $version = "1.0.0"; // Sets start time. $timeparts = explode(" ",microtime()); $starttime = $timeparts[1].substr($timeparts[0],1); if (isset($query)) s_control($query); elseif (substr($QUERY_STRING,0,5) == "index") i_control(); else s_print_search_form(""); c_print_footer(); function s_control($q) { $orig = $q; $result_arr = s_search($q); $result_count = sizeof($result_arr); if ($result_count < 1) { echo "

$GLOBALS[err_no_results]

"; s_print_search_form($q); } else { echo "

Resultados da Busca

Resultados: 1 - $result_count para \"$orig\"

"; s_print_search_form($orig); } } function s_search($query) { // Searches for query in the index file. // Multiple word search originally contributed by Matthew Furister $query = trim(strtolower(c_strip_chars($query))); $search_data = @file($GLOBALS[index_file]) or die("

$GLOBALS[err_no_search_db]

"); $pages_found = " "; foreach ($search_data as $search_page) { $page_arr = explode("|", $search_page); $found_count = 0; $qry_array = split('[, ]+',trim(strtolower($query))); foreach ($qry_array as $qry) { if (in_array($qry, $page_arr)) { ++$found_count; $pages_found .= $page_arr[0] . " "; } } if ($found_count == count($qry_array)) $result_arr[] = $page_arr[0]; } return $result_arr; } function s_print_title_desc($file_n) { $file = @file($file_n); if ($file) { $line_complete = implode('', $file); eregi("(.*)", $line_complete, $out); $title = trim($out[1]); if($title) $line_complete = str_replace($title, "", $line_complete); $line_complete = strip_tags($line_complete); $line_complete = trim($line_complete); $line_complete = trim(substr($line_complete, 0, 250)); echo "
  • "; echo ""; echo " "; if (isset($title)) echo "$title - $file_n"; else echo "$file_n"; echo "
    $line_complete...\n
     "; } else { echo "
  • $file_n
    ..."; } } function s_print_search_form($query) { // Function to print the search form. ?>

    Digite os dados à serem encontrados:

    >

    A operação selecionada indexará o site

    Há duas formas de Indexação \"por Palavras Chave\" ou \"Indexação Completa\" .
    Recomenda-se a indexação completa.

    "; } else { if (is_dir($GLOBALS[file_root])) { $file_array = i_get_files($GLOBALS[file_root]); $file_array = i_strip_extentions($file_array); $file_array = i_strip_files($file_array); if(is_array($file_array)) { set_time_limit(0); $fd = @fopen($GLOBALS[index_file], "w") or die("

    $GLOBALS[err_index]

    "); foreach ($file_array as $file) { if (($GLOBALS[s] == "submit_full") || (substr($file, -3) == "txt")) $line = i_full_index_file($file); elseif ($GLOBALS[s] == "submit_meta")$line = i_meta_index_file($file); if (substr_count($line, "|") > 1) fputs($fd, "$line\n"); } fclose($fd); echo "

    $GLOBALS[index_complete]

    "; } else { echo "

    $GLOBALS[no_files]

    "; } } else { echo "

    $GLOBALS[no_dir]

    "; } } } function i_full_index_file($file_name) { // Retrieves a list of keywords from a file. global $http_root, $file_root; $file_contents = @file($file_name); if ($file_contents) { $URL = str_replace($file_root, $http_root , $file_name); $keywords = "$URL|"; $file_contents = implode(" ", $file_contents); $file_contents = strip_tags($file_contents); $file_contents = strtolower($file_contents); $file_contents = str_replace("\n", "", $file_contents); $file_contents = c_strip_chars($file_contents); $file_contents = str_replace(",", "", $file_contents); $file_contents = explode(" ", $file_contents); foreach($file_contents as $word) { $word = trim($word); if ($word != "") { $keywords .= "$word|"; } } } $complete = str_replace("|||", "|", $keywords); $complete = str_replace("||", "|", $complete); $complete = i_strip_words($complete); return $complete; } function i_meta_index_file($file) { // Indexes a page by it's meta tags. global $index_file, $http_root, $file_root; $URL = str_replace($file_root, $http_root , $file); $mt = @get_meta_tags($file); $line = $mt[keywords]; if ($line) { $line = explode(",", $line); foreach ($line as $word) { $word = trim($word); if ($word != "") { $keywords .= "$word|"; } } $keyword = str_replace(",", "", $keywords); $keywords = c_strip_chars($keywords); $keywords = i_strip_words($keywords); $keywords = "$URL|$keywords"; return $keywords; } else { return "$URL|"; } } function i_get_files($dirname) { // Navigates through the directories recurrsively and retrieves a listing in an array. // File permission bit by Abhay Jain if($dirname[strlen($dirname)-1] != "/") $dirname.="/"; static $result_array = array(); $mode = fileperms($dirname); if(($mode & 0x4000) == 0x4000 && ($mode & 0x00004) == 0x00004) { chdir($dirname); $handle = @opendir($dirname); } if($handle) { while ($file = readdir($handle)) { if($file=='.'||$file=='..') continue; if(is_dir($dirname.$file)) i_get_files($dirname.$file.'/'); else $result_array[] = $dirname.$file; } closedir($handle); } return $result_array; } function i_strip_extentions($array) { // Runs through the extention array and // returns all files with the selected extentions. global $include_extentions; if(is_array($array)) { foreach ($include_extentions as $ext) { $str_len = strlen($ext); foreach ($array as $file) { if (substr($file, -$str_len) == $ext) $result_array[] = $file; } } return $result_array; } else return $array; } function i_strip_files($array) { // Reads the exclude file removed unwanted file form the array. // Filtering and regex added by: // Timo Haberkern 10/10/01 global $file_root, $exclude_files; if(is_array($array)) { $exclude = @file($exclude_files); if ($exclude) { // Create the filter lists foreach($exclude as $exc_file) { $exc_file = trim($exc_file); // Is it a filter? if ($exc_file[0] == "/") { $file[] = $exc_file; } else { $filter[] = $exc_file; } } // Do the filtering foreach ($array as $act_file) { $act_file = str_replace($file_root, "", $act_file); $bMatchedFilter = false; $bFoundInExcludingList = false; // Test the filters first foreach ($filter as $curFilter) { if (eregi($curFilter, $act_file) == true) { $bMatchedFilter = true; break; } } // Test for excluding if ($bMatchedFilter == false) { // Test only if the file list is not empty if (sizeof($file) != 0) { if (in_array($act_file, $file)) { $bFoundInExcludingList = true; break; } } } if (!$bFoundInExcludingList AND !$bMatchedFilter) $result_array[] = "$file_root$act_file"; } return $result_array; } else return $array; } else return $array; } function i_strip_words($line) { $file = @file($GLOBALS['exclude_words']); if ($file) { foreach ($file as $word) { $word = trim($word); $word = "|$word|"; $line = str_replace("$word", "|", $line); } } return $line; } function i_clear_index() { // Checks for a confirmation and then clears the index file. global $username, $password; if ($GLOBALS['s'] == "submit") { $fd = @fopen($GLOBALS[index_file], "w") or die("

    $GLOBALS[err_index]

    "); fclose($fd); echo "

    $GLOBALS[index_cleared]

    "; } else { echo "
    A operação selecionada apagará o arquivo de indexação do sistema de busca
    Nenhum resultado será exibido até que o sistema seje re-indexado.
    Tem certeza?
    "; } } function i_view_index() { // Displays the index file in a table. if (file_exists($file)) { $file = @file($GLOBALS[index_file]); if($file) { echo "

    Your index file:

    "; foreach ($file as $key => $line) { $exp_line = explode("|", $line); $key = $key + 1; echo " \n"; foreach ($exp_line as $key => $word) { if ($key == 0) { echo " \n "; } else { echo ""; } } echo " \n\n"; } echo "
    # URL Keywords
    $key$word$word
    "; } else { echo "

    $GLOBALS[err_index_empty]

    "; } } else { echo "

    $GLOBALS[err_index]

    "; } } function i_print_options() { // Prints the indexer options. global $username, $password; echo "

    Opções:
    Criar
    Visualizar
    Excluir
    "; } function i_print_logon($msg) { // Prints the indexer logon. echo "
    $msg

    Área Restrita - Autenticação Necessária:
    Usuário:
    Senha:
    "; } function c_strip_chars($line) { // Strips various characters from $line. $line = str_replace(".", " ", $line); $line = str_replace("\"", " ", $line); $line = str_replace("'", "", $line); $line = str_replace("+", " ", $line); $line = str_replace("-", " ", $line); $line = str_replace("*", " ", $line); $line = str_replace("/", " ", $line); $line = str_replace("!", " ", $line); $line = str_replace("%", " ", $line); $line = str_replace(">", " ", $line); $line = str_replace("<", " ", $line); $line = str_replace("^", " ", $line); $line = str_replace("(", " ", $line); $line = str_replace(")", " ", $line); $line = str_replace("[", " ", $line); $line = str_replace("]", " ", $line); $line = str_replace("{", " ", $line); $line = str_replace("}", " ", $line); $line = str_replace("\\", " ", $line); $line = str_replace("=", " ", $line); $line = str_replace("$", " ", $line); $line = str_replace("#", " ", $line); $line = str_replace("?", " ", $line); $line = str_replace("~", " ", $line); $line = str_replace(":", " ", $line); $line = str_replace(";", " ", $line); $line = str_replace("_", " ", $line); $line = str_replace(" ", " ", $line); $line = str_replace("&", " ", $line); $line = str_replace("©", " ", $line); $line = str_replace(" ", " ", $line); $line = str_replace(""", " ", $line); $line = str_replace("&", " ", $line); $line = str_replace("\n", " ", $line); $line = str_replace("á", "a", $line); $line = str_replace("à", "a", $line); $line = str_replace("ã", "a", $line); $line = str_replace("â", "a", $line); $line = str_replace("é", "e", $line); $line = str_replace("è", "e", $line); $line = str_replace("ê", "e", $line); $line = str_replace("í", "i", $line); $line = str_replace("ì", "i", $line); $line = str_replace("î", "i", $line); $line = str_replace("ó", "o", $line); $line = str_replace("ò", "o", $line); $line = str_replace("õ", "o", $line); $line = str_replace("ô", "o", $line); $line = str_replace("ú", "u", $line); $line = str_replace("ù", "u", $line); $line = str_replace("û", "u", $line); $line = str_replace("ç", "c", $line); return $line; } function c_print_footer() { // Prints the footer of the page. echo ""; } // Display time taken. if(isset($query)) { if($show_time_search) { $timeparts = explode(" ",microtime()); $total_time = ($timeparts[1].substr($timeparts[0],1)) - $starttime; echo "
    Tempo da Busca: ".substr($total_time,0,4)." segundos.
    "; } } elseif (substr($QUERY_STRING,0,5) == "index") { if($show_time_index) { $timeparts = explode(" ",microtime()); $total_time = ($timeparts[1].substr($timeparts[0],1)) - $starttime; echo "
    Tempo da Operação: ".substr($total_time,0,4)." segundos.
    "; } } ?>