Search script

Discussion in 'PHP' started by crazyryan, Nov 23, 2006.

  1. #1
    I was wondering if anyone knew a script or could write me a script that searches a directory like mydomain.com/replays/ and searches all the file names and if it's found it shows the links to the files?

    e.g.

    Index of /replays
    replay1.gzr
    replay2.gzr

    searching replay2 would present a link to replay2.gzr

    thanks!
     
    crazyryan, Nov 23, 2006 IP
  2. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #2
    adsblog, Nov 23, 2006 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    I was originally going to use that but I don't think it looks at the filename.
     
    crazyryan, Nov 23, 2006 IP
  4. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Actually, as long as you are using it on your local server you are more then welcome to read your own files/directories/structures because you have permission to them :)


    
    // This small block of code also removes the "." and ".." of the file list
    if ($handle = opendir('/home/username/public_html/path/to/dir')) {
       while (false !== ($file = readdir($handle))) {
           if ($file != "." && $file != "..") {
               echo "$file\n";
           }
       }
       closedir($handle);
    }
    
    PHP:
     
    drewbe121212, Nov 23, 2006 IP