Web Analytics Made Easy -
StatCounter i need a script - CodingForum

Announcement

Collapse
No announcement yet.

i need a script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • i need a script

    i need a script to show all the files in a folder except one whiich that file name is processFiles.php
    can anyone gimme that script plz?

  • #2
    i got this script from a guy and it has this parse error on line 8
    can some one fix it?
    here is the script
    PHP Code:
    <?php
    function DirOpen($dir "./") {
            if(!(
    $dp opendir($dir))) die("Cannot open $dir.");
            while(
    $file readdir($dp)) $filenames[] = $file;
            
    closedir($dp);
            
    sort($filenames);
            return 
    $filenames
        
    }
    function 
    Show($files) {
        echo 
    '        
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
            <head>
            <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
            <title>Directory listing</title>
            <style type="text/css" media="screen">
            body {
                background-color: #FFF;
                color: #000;
                font-family: Geneva, Arial, sans-serif;
                font-size: 100%;
                line-height: 140%;
            }
            a {
            text-decoration: none;
            }
            a:hover {
            text-decoration:none;
            color: red;
            }
            .grey1 { background-color: #CCC; }
            .grey2 { background-color: #DDD; }
            </style>
            </head>
            <body>
            <table border="0" cellspacing="2" cellpadding="2">
        '
    ;

        
    //Show's Folders
        
    echo "<tr><th>Folders</th></tr>\n";
        for(
    $i=0$i count($filenames); $i++) {
            if (
    is_dir($filenames[$i]) && !preg_match('/^\./',$filenames[$i]))
            
    //do show directories but not files and exclude everything that starts with a dot
               
    if(preg_match('/^\~/',$filenames[$i])) {
                    
    $name substr($filenames[$i], 1);
                    echo 
    "<tr><td><a href=\"" rawurlencode($filenames[$i]) . "\">". $name . "</a></td></tr>\n";
               }
        }
        //Show's Files
        echo "
    <tr><th>Files</th></tr>\n";
        for(
    $i=0; $i < count($filenames); $i++) {
            if(!preg_match('/^\./',
    $filenames[$i]) && !is_dir($filenames[$i]))
            // don't show directories, listing.php and files that start with a dot
            //Don't show somefile.php
            if(
    $filenames[$i] == "somefile.php")
                unset(
    $filenames[$i]);
              echo "
    <tr><td><a href=\"" rawurlencode($filenames[$i]) . "\">". wordwrap($filenames[$i], 60) . "</a></td></tr>\n";
        }
        
        echo "
            
    </table>
            </
    body>
            </
    html>
        
    ";
    }
    Show(DirOpen("
    directory/"))
    ?>

    Comment


    • #3
      PHP Code:
      <?

      //define the path as relative
      $path "/home/yoursite/public_html/whatever";

      //using the opendir function
      $dir_handle = @opendir($path) or die("Unable to open $path");

      echo 
      "Directory Listing of $path<br/>";

      //running the while loop
      while ($file readdir($dir_handle)) 
      {
      //I've also left out the current dir and parent dir "file"
      if($file!="." && $file!=".." && $file!="processFiles.php") echo "<a href='$file'>$file</a><br/>";
      }

      //closing the directory
      closedir($dir_handle);

      ?>
      from Spoono.
      [edit]put a semicolon( ; ) after "return $filenames"
      CATdude about IE6: "All your box-model are belong to us"

      Comment


      • #4
        Unable to open files Unable to open www/pykerclan.farvista.net/files

        what do i do with this part
        PHP Code:
        //define the path as relative 
        $path "files"
        i just put files it in becaues that is the file up
        do i need to put
        PHP Code:
        //define the path as relative 
        $path "/files/"
        ?
        i tried adding this www/pykerclan.farvista.net/files
        in the path thingy but it still wont work
        Last edited by rayray123105; Aug 2, 2005, 09:21 PM.

        Comment


        • #5
          if($filenames[$i] == "processFiles.php");
          there is a parse error in this
          can u fix it also?
          Parse error: parse error, expecting `','' or `';'' in /home/www/pykerclan.farvista.net/listing.php on line 58

          Comment


          • #6
            There's this button called "edit" which you use to edit your post if you want to add something. Just thought I'd let you know because it saves space. ^^

            For the path, its usually something like /home/user/www/files/. Ask your host, they should know. I think you can find out with php by echoing $DOCUMENT_ROOT.

            I think with the parse error, its because you have a ; on there. It should just be
            PHP Code:
            if($filenames[$i] == "processFiles.php"
            I lost my signature, have you seen it?
            I have the power to erase you...

            Comment

            Working...
            X