Directory listing(help!)

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

    Directory listing(help!)

    Hello

    I'm using this code for directory listing in a college project

    PHP Code:
    <?php
    $mode 
    $_GET['mode'];
    $dir $user."/".$mode;

    if(
    $handle = @opendir($dir))

        while(
    $file readdir($handle))
        { 
            if(
    is_file($dir.'/'.$file)) 
                
    //$time = filemtime($file);
                
    echo "<tr><td width='80%'><div class='sub_alt'><img src='bg/Message.png'/>&nbsp;<a href='read.php?mode=".$mode."&amp;user=".$user."&amp;token=".$pass."&amp;message=".$file."'><b>".ucfirst(basename($file,'.html'))."</b></a></div></td><td><a href='del.php?mode=".$mode."&amp;user=".$user."&amp;token=".$pass."&amp;message=".$file."'><div class='footer'><font color='red'><b>(x)</b></font></a></td></tr>";
            }
            
        
    closedir($handle);

    ?>
    I'm getting errors while using filemtime() or filectime() functions,how to correct the errors?
    I need some facebook likes, can you please help me
    http://facebook.com/softwarefreakin
    I noticed social media is really powerful
    Well DONE is better than well SAID

    #2
    what error message are you getting?

    Comment


      #3
      U need to format the time stamp for example like this:
      PHP Code:
      echo 'Moded at '.date('F d Y H:i'filemtime($file)); 
      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

      Comment


        #4
        Hello Arnage & something else

        Please look here Demo project

        My problem is with main.php
        I need some facebook likes, can you please help me
        http://facebook.com/softwarefreakin
        I noticed social media is really powerful
        Well DONE is better than well SAID

        Comment


          #5
          Can u please explain the problem?
          I don't see main.php page from Demo project and don't want to register anywhere. Or at least make a screen shot.
          <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

          Comment


            #6
            Bro,dis link main.php

            Demo project

            I wana sort the files wid time & also to show the time beside filenames

            I've used the filemtime() as u've said but getting errors

            Warning: filemtime() [function.filemtime]: stat failed for hey.html in C:\wamp\www\codes\login\main.php on line 15
            Last edited by softwarefreak; 17.11.11, 18:06.
            I need some facebook likes, can you please help me
            http://facebook.com/softwarefreakin
            I noticed social media is really powerful
            Well DONE is better than well SAID

            Comment


              #7
              Well as for that it basicly goes like this,

              first to read content of the folder and create the array of files:

              PHP Code:
              $handle = @opendir($folder);
              while (
              $file readdir($handle)) {
              if (
              is_file($dir.'/'.$file) {
              $filesarray[] = $file;
              }
              }
              closedir($handle); 
              ... and here in $filesarray are the files. Now to sort the array how u want use sort(), ksort() or with their flags like SORT_NUMERIC, u choose what. For example:

              PHP Code:
              sort($filesarraySORT_NUMERIC); 
              .. and now is just left to loop and display files:

              PHP Code:
              foreach ($filesarray as $key => $file) {
                  echo 
              '#'.$key.'. File: '.$file.', Moded at '.date('F d Y H:i'filemtime($file));

              But in the first post there are some issues, basename() used for example and looking those vars like $mode, $user, $pass in combination with this ain't gonna work how it should so if i get it right u will need some different slightly complicated way.
              <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

              Comment

              Working...
              X