Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/06/2008, 10:39
Avatar de OsSk4R
OsSk4R
 
Fecha de Ingreso: octubre-2006
Ubicación: $this->home
Mensajes: 824
Antigüedad: 17 años, 6 meses
Puntos: 74
Inconveniente de buscador...

Saludos, tengo un buscador que lo que hace es buscar archivos html y php segun el texto a buscar. Osea, que no busca en la bd.

Bueno...el inconveniente es que solo busca en el directorio raiz. A mi me gustaria que buscara en 3 carpetas exactamente.

Este es el código:
Código PHP:
<?php



function strong($text$content$long)
{
    
$begin strpos($text$_GET["q"]);
    
$end   $begin strlen($_GET["q"]);
    
    
$begin $long $begin_cut $begin-$long $begin_cut=0;
    
$end $long strlen($text) ? $end_cut $end $long $end_cut strlen($text);
    
    
$strong  htmlentities(substr($content$begin_cut$begin-$begin_cut));
    
$strong .= '<strong>' htmlentities(substr($content$begin$end-$begin)) . '</strong>';
    
$strong .= htmlentities(substr($content$end$end_cut-$end));
    
    
$end_cut strlen($text) ? $strong .= '...' $strong;
    
$begin_cut $strong='...' $strong $strong;
    
    return 
$strong;
}

/* Read the configuration file */
if (file_exists("search.ini.php")) {
    include(
"search.ini.php");
} else {
    die (
'Configuration file missing.');    
}

/* Read the template file */
if (!empty($template) and file_exists($template)) {
    
$template file_get_contents($template);
} else {
    die (
'Template file or file name missing.');    
}

/* Parse the template */
$begin_template substr($template0strpos($template'<!--SearchResultsBegin-->'));
$file_template  substr($templatestrpos($template'<!--SearchResultsBegin-->') + 25strpos($template'<!--SearchResultsEnd-->')-(strpos($template'<!--SearchResultsBegin-->') + 25));
$end_template   substr($templatestrpos($template'<!--SearchResultsEnd-->') + 23);

/* Check the GET variable */
if (isset($_GET["q"])) {

    
/* Clear any html tags from string */
    
$_GET["q"] = strip_tags($_GET["q"]);

    
/* Clear quotes */
    
$_GET["q"] = str_replace('"'''stripslashes($_GET["q"]));

    
/* Replace especial characters */
    
if (is_array($chars)) {
        
$_GET["q"] = str_replace(array_keys($chars), array_values($chars), strtolower($_GET["q"]));
    }

    
/* Set the variables */
    
$results    '';
    
$result     0;
    
$abstract_length = ($abstract_length strlen($_GET["q"])) / 2;
    
    
/* Read the directory */
    
$files opendir('.');
    while (
false != ($file=readdir($files))) {
        
        
/* Check if file is a html file */
        
if (eregi('(htm|html|php)$'$file)) {
            
            
/* Read the file content */
            
$content file_get_contents($file);
            
            
/* Obtain the documment title */
            
$title substr($contentstrpos ($content'<title>') + 7);
            
$title substr($title0strpos ($title'</title>'));
            
            
/* Parse the content for search content */
            
$content substr($contentstrpos ($content'<!--SearchAreaBegin-->') + 22);
            
$content substr($content0strpos ($content'<!--SearchAreaEnd-->'));
            
$content strip_tags($content);
            
$content html_entity_decode($content);
            if (
is_array($chars)) {
                
$text=str_replace(array_keys($chars), array_values($chars), strtolower($content));
            }
            
            
/* Search the string in the content */
            
if (ereg($_GET["q"], $text)) {
                
$replace['<!--FileTitle-->']    = $title;
                
$replace['<!--FileName-->']     = $file;
                
$replace['<!--FileAbstract-->'] = str_replace('\r\n'' 'strong($text$content$abstract_length));

                
$results .= str_replace(array_keys($replace), array_values($replace), $file_template);
                
$result++;
            }
        }
    }
    
    
/* Create a result message */
    
if ($result==0) {
        
$message $noResults;
    } else {
        eval(
"\$message = \"$yesResults\";");
    }
} else {
    
$message $noString;
}

/* Join the documment parts and send it to browser */
$results $begin_template $results $end_template;
$results str_replace('<!--Results-->'$message$results);

echo 
$results;
?>
Sino me equivoco, exactamente en la linea 62:
Código PHP:
 $files opendir('.'); 
Ahí es donde tengo que especificar la carpeta en la que quiero que me busque, intente poniendo solo una carpeta (/ejemplo), (ejemplo), (/ejemplo/), pero nada, no busca.
Por eso acudo a ustedes. Es correcto, es ahí donde tengo que especificar la carpeta??

Y aparte, como dije...¿para que me buscara en 3 carpetas?

Muchas gracias de antemano