buscar

search

     


HTML; echo $html; function textpart($body, $search) { // Displays the text after the title $length = 30; $text = substr($body, max(stripos($body,$search) - $length, 0), strripos($body,$search) - stripos($body,$search) + strlen($search) + 2 * $length); if (strripos($text, " ") < strripos($text,$search)) { $text = $text . " "; } if (stripos($text, " ") != strripos($text, " ")) { $text = substr($text, stripos($text, " "), strripos($text, " ") - stripos($text, " ")); } $temp = $text; $stop = substr($text, strripos($text, $search) + strlen($search)); if (strlen($stop) > $length) { $stop = substr($text, strripos($text, $search) + strlen($search), $length); $stop = substr($stop, 0, strripos($stop, " ")); } $text = "... "; while (stripos($temp,$search)) { $temp = substr_replace($temp, "", stripos($temp, $search), 0); $temp = substr_replace($temp, "", stripos($temp, $search) + strlen($search), 0); $text = $text . substr($temp, 0, stripos($temp, "") + 4); $temp = substr($temp, stripos($temp, "") + 4); if(stripos($temp, $search) > (2 * $length)) { $text = $text . substr($temp, 0, $length); $text = substr($text, 0, strripos($text, " ")) . " ... "; $temp = substr($temp, stripos($temp, $search) - $length); $temp = substr($temp, stripos($temp, " ")); } } $text = $text . $stop . " ... "; echo $text; return; } function compress($string, $first, $last) { // Removes everything in $string from $first to $last including $first and $last while(stripos($string,$first) && stripos($string,$last)) { $string = substr_replace($string, "", stripos($string,$first), stripos($string,$last) - stripos($string,$first) + strlen($last)); } return $string; } function directoryToArray($directory, $recursive) { // This function by XoloX was downloaded from http://snippets.dzone.com/user/XoloX $array_items = array(); if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($directory. "/" . $file)) { if($recursive) { $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive)); } } else { $file = $directory . "/" . $file; $array_items[] = preg_replace("/\/\//si", "/", $file); } } } closedir($handle); } return $array_items; } function filewalk($file, $search, $counter, $webpath) { // Selects and treats files with the extension .htm and .html and .asp and .php if (strtolower(substr($file, stripos($file, ".htm"))) == ".htm" || strtolower(substr($file, stripos($file, ".html"))) == ".html" || strtolower(substr($file, stripos($file, ".asp"))) == ".asp" || strtolower(substr($file, stripos($file, ".php"))) == ".php") { $all = file_get_contents($file); $body = substr($all, stripos($all,"") - stripos($all,"/i', ' ', $body); $body = preg_replace('/
/i', ' ', $body); $body = compress($body,""); $body = compress($body,""); $body = compress($body,""); $body = compress($body,""); $body = strip_tags($body); $body = html_entity_decode($body, ENT_QUOTES); $body = preg_replace('/\s+/', ' ', $body); // Scans and displays the results if (stripos($body, $search)) { $title = substr($all, stripos($all,"") + 7,stripos($all,"") - stripos($all,"") - 7); $title = html_entity_decode($title, ENT_QUOTES); $title = preg_replace('/\s+/', ' ', $title); echo '<p class="espanol_txt"><a href="' . $file . '" target="_blank">' . $title . '</a></br>'; echo '<span class="website" id="webpath">' . $webpath . substr($file, stripos($file, "/")) . '</span><br />'; echo textpart($body, $search) . '</p>'; $counter = $counter + 1; } } return $counter; } // Reads the search text from the page's URL $url = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; $url .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"] : $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (stripos($url,"?search=")) $search = $_GET['search']; $webpath = dirname($url); // Starts searching if (strlen($search) < 2 && trim($search) <> "") { echo '<p>' . $to_small . '!</p>'; $search = ""; } if (trim($search) <> "") { echo "<p>" . $search_at . " '<b><i>" . $search . "</i></b>' " . $search_result . ".</p>"; $counter = 0; // Path to the folder containing this file $curdir = getcwd(); // Opens the folder and read its contents if ($dir = opendir($curdir)) { $files = directoryToArray("./", $recursive); foreach ($files as $file) { $counter = filewalk($file, $search, $counter, $webpath); } closedir($dir); } echo "<p>" . $pages . ": " . $counter . "</p>"; } ?> </div></td> </tr> <tr> <td colspan="3" valign="top"></td> </tr> <tr> <td colspan="3" valign="top"><div align="right"> </div> <p align="center" style="border-top:1px solid #666666; padding:10px 0 5px;"> <span class="espanol_txt">PHP Desarrollado por</span> | <span class="ingles_txt"> PHP Powered by </span><br> <a href="http://www.christersvensson.com/easy/" target="_blank" class="asterisco">      Christer Svensson</a></p> </td> </tr> </table> <p align="center"> </p> <p align="center"> </p> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="65" align="left" class="menudiv"><ul id="menupics"> <li id="home"><a href="index.htm"></a></li> <li id="search"><a href="../search.htm"></a></li> <li id="contact"><a href="contact.htm"></a></li> </ul> <br class="clear"> </td> <td width="150" class="menudiv"><div id='cssmenu_esp'> <ul> <li class='has-sub'><a href='#'>ESPAÑOL</a> <ul> <li><a href='galeria/galeria.htm'>dibujos</a></li> <li><a href='manos/manos.htm'>juegos de manos</a></li> <li><a href='digital/digital.htm'>arte digital</a></li> <li><a href='fotos/fotos.htm'>fotografías</a></li> <li><a href='design/design.htm'>diseño gráfico</a></li> <li><a href='bio/bio.htm'>¿quién es cocuyoverde?</a></li> <li><a href='gis/gis.htm'>el rincón de mi costilla</a></li> <li><a href='guestbook/index.php'>libro de visitas</a></li> </ul> </li> </ul> </div></td> <td width="150" class="menudiv"><div id='cssmenu_eng'> <ul> <li class='has-sub'><a href='#'>ENGLISH</a> <ul> <li><a href='galeria/galeria.htm'>drawings</a></li> <li><a href='manos/manos.htm'>sleight of hands</a></li> <li><a href='digital/digital.htm'>computer art</a></li> <li><a href='fotos/fotos.htm'>photographies</a></li> <li><a href='design/design.htm'>graphic design</a></li> <li><a href='bio/bio.htm'>who's cocuyoverde?</a></li> <li><a href='gis/gis.htm'>my rib's<br/> corner</a></li> <li><a href='guestbook/index.php'>guestbook</a></li> </ul> </li> </ul> </div></td> </tr> </table> <p></p><p align="center" class="asterisco"><strong>copyright Julio A. Baisre Hernández © 2001-<?php echo date("Y"); ?></strong></p><p></p> <div id="bottom"></div> </body> </html>