Results 1 to 3 of 3

Thread: can some one look at this?

  1. #1

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144

    can some one look at this?

    I have got a code that searches through the meta tags of pages in a directory, but does can someone show me how i could use an array to search multible directories. I think i have added an array at the right place but i am not sure.

    -> code

    PHP Code:
    <?
    $ext = array("html", "htm", "txt", "php", "jsp");

    $_GET[q]=str_replace("<","&lt;",$_GET[q]);
    $_GET[q]=str_replace(">","&gt;",$_GET[q]);

    $ar = Array();
    $qr = explode(" ", $_GET[q]);
    $cnt=0;


    $mt = explode(' ', microtime()); 
    $script_start_time = $mt[0] + $mt[1];

    $ar = dfil();

    $h=count($ar);
    $n=0;
    while($n <= $h) {
    if($ar[$n] != "") { srch($ar[$n]); }
    $n=$n+1;
    }

    function dfil() {
    global $ext;
    $tr = Array();     <----------------- this is the place i think :S
    $handle = opendir("./");    
    while($file = readdir($handle)) {
    if( $file != "." && $file != ".." && $file) {
    list($a,$b) = explode(".", $file);

    $n=0;
    $k = count($ext);
    while($n <= $k) {
    if($b == $ext[$n] && $b != "") { array_push($tr, $file); }
    $n=$n+1;
    } } }
    closedir($handle);
    return $tr;
    }


    function srch($fls) {
    global $qr; global $cnt;
    $ar = @fread(fopen("$fls", "r"), 2000);
    $ar = strip_tags($ar, "<meta><title>");
    $br = $ar;
    $ar = strtolower($ar);
    $ar = str_replace("\"", "", $ar);

    list($t1, $t2) = explode("<meta name='keywords' content=", $ar);
    list($keys, $t4) = explode(">", $t2);

    $x=count($qr);
    $y=0;

    while($y <= $x) {
    if(strpos($keys, $qr[$y])) {

    list($t5, $t6) = explode("<meta name='description' content=", $ar);
    list($desc, $t7) = explode(">", $t6);

    $title = strip_tags($br, "<title>");
    list($title, $t45) = explode("</", $br);
    $title = preg_replace('/<.+?>/','',$title); 

    $dc=mBold($desc);
    $o=<<<EOF
    <a href="$fls"><font size="2" face="Verdana">$title</font></a>
    <font size="2" face="Verdana"><br>$dc</font><br><br>

    EOF;
    $cnt=$cnt+1;
    echo $o;
    return 0;
    }
    $y=$y+1;
    } }

    function mBold($dta) {
    global $qr;
    $z=0;
    $t=count($qr);
    while($z <= $t) {
    $dta=str_replace($qr[$z], "<B>$qr[$z]</B>", $dta);
    $z=$z+1;
    }
    return $dta;
    }

    if($cnt==0) {
    $no=<<<EOF
    <font face=verdana color=navy size=2>
    Deine suche für <b>$_GET[q]</b> wurde nichts gefunden</b></font>
    EOF;
    echo $no;
    }

    $mt = explode(' ', microtime()); 
    $script_end_time = $mt[0] + $mt[1]; 
    echo "<hr color=#C6C6DA><font face=arial size=1>$cnt Resultaten in ". round($script_end_time - $script_start_time, 5)." Sekunden</font>";
    ?>


    Msn Messenger is the Best

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: can some one look at this?

    Do you want the function to decend into all subdirectories and all their subdirectories? If so, you need to have the function call itsself.

    If you explain what exaclty that code does then I can tell you how to write a function which calls itself to search subdirectories.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Addicted Member Tommy101's Avatar
    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    144

    Re: can some one look at this?

    the code gets the meta tags at the top of html, jsp, txt, php files and will display results to what you have given in.

    if you copy the code into a php file and then enter the url + q=your search term
    and you have file with meta tags (description/keywords) it will display results if part of the search term is found in the tag.

    P.S. its hard to explain


    Msn Messenger is the Best

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width