SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, I'm writing a script now who list a whole dir...
    One problem, a have a txt file with the description of the file with the realname of the file.
    I want the description of a file appears below the file, this works fine now, but only for 1 file...
    look at this:

    PHP Code:
    <?

    echo "<title>Bestanden voor het $jaar e jaar</title>\n</head>\n<body>";

    if (empty(
    $dir)){
    $dir ".";
    }
    $handle=@opendir("$dir") or die ("<center>\n<p>&nbsp;</p>\n<h1>Fatal Error</h1>\n<p>&nbsp;</p>\n<p>&nbsp;</p>\n<font face=\"Verdana\" size=\"2\"><b>Access Denied</b></font><br>\n$dir<br>\n<p>&nbsp;</p>\n<p>&nbsp;</p>\n<font face=\"Verdana\" size=\"2\">Sorry ;)</font>\n</center>\n");

    if (!
    ereg("(.*)/$",$dir)) $dir.="/";

    //table hieronder (opmaak zonder vars)
    ?>
    <table border='0' cellspacing='1' width='100%' bgcolor='#FF9933'>
    <tr>
     <td bgcolor='#FFFFFF' colspan='4'><center><font face='MS Sans Serif' size='1' color='#000070'>Index of <? echo $dir?></font></center></td>
    </tr>
    <tr>
     <td bgcolor='#EEEEEE' width='3%' align='center'><b><font face='Verdana' size='1' color='#000080'>-</font></b></td>
     <td bgcolor='#EEEEEE' width='43%' ><b><font face='Verdana' size='1' color='#000080'>&nbsp;Naam bestand</font></b></td>
     <td bgcolor='#EEEEEE' width='22%' align='center'><b><font face='Verdana' size='1' color='#000080'>Grootte</font></b></td>
     <td bgcolor='#EEEEEE' width='32%' align='center'><b><font face='Verdana' size='1' color='#000080'>Datum uploaden</font></b></td>
    </tr>
    <?
    while ($file = @readdir($handle)) { 
    $path $dir $file;
    $qwe[] = $file;
    if(
    $file == ".." OR $file =="." OR $file =="index.php"){ echo"<!-- normal dir -->"; }
    else{
    $num "<center><img src='http://www.collegediksmuide.be/img/file.gif' border='0'></center>";
    if (
    is_dir("$path")) {
    if (
    strstr($path"..")){
    $href "<a href=\"wpc.php?dir=" dirname($dir) . "\">";
    $size "<font color=\"#500000\">&lt; UpDIR &gt;</font>";
    $time "-";
    } else {
    $size "<font color=\"#000070\">&lt; DIR &gt;</font>";
    $time "<font color=\"#000070\">" . @date("d M Y H:i"filemtime($path) - 25200) . "</font>";
    }
    } else {
    $href "<a href=\"$path\" target=\"_top\">";
    $size = @filesize($path);
    // size in kb
    $size $size/1024;
    // time
    $time2 = @date("d M Y H:i"filemtime($path) - 25200);

    }

    echo 
    "<tr>\n <td width='3%' align='right' bgcolor='#FFFFFF'>&nbsp;" $num "</font>&nbsp;</a></td> \n <td width='43%' bgcolor='#FFFFFF'>&nbsp;&nbsp;$href$file "</a><br>";

    // |||||||||||||||||||||||||||||||||||||||   THE FILE
    $filename $files_txt;
    $fd fopen$filename"r" );
    $content fgets$fd100000);
    $ex explode("||",$content);
    $leerjaar $ex[0];
    $filename $ex[1];
    $opmerking $ex[2];
    $leerkracht $ex[3];
    if(
    ereg($file,$filename))
    {
    echo
    "<li>$leerkracht</li><br><li>$opmerking</li>";
    }


    $mnt=array("januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december");
    $time = @date("d"). " " $mnt[date("m")-1] . " " .date("Y H:i"filemtime($path) - 25200);
    echo
    "</font></td>\n <td width='22%' align='center' bgcolor='#FFFFFF'>";
    printf ("%.2f kB",$size);
    echo
    "</font></td>\n <td width='32%' align='center' bgcolor='#FFFFFF'>" $time "</td>\n</tr>\n";
    }
    }
    $today = @date("d"). " " $mnt[date("m")-1] . " " .date("Y H:i"time() - 25200);
    $today2 date("d M Y H:i",time() - 25200);
    ?>
    <tr>
     <td bgcolor="#FFFFFF" width="100%" colspan="4" align="center"><? echo $today ?></td>
    </tr>
    </table>
    Does somebody have a solution?

  2. #2
    SitePoint Member
    Join Date
    Mar 2001
    Location
    Indiana
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe if you add

    chdir($dir) before the opendir?

    Had some problems myself with opendir, think it might have
    to do with filepermissions so I used dir()

    $d = dir("$path");
    while($entry=$d->read()) {

    }
    $d->close();

  3. #3
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, that's not really my problem...
    I can open my dir, but I can't combine the data of the txt file with the contenu of the dir...

  4. #4
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does somebody have an idea?


Bookmarks

Posting Permissions

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