Newest 10 Files in a Directory

  • N2S
  • Beginner
  • Beginner
  • User avatar
  • Joined: Oct 07, 2008
  • Posts: 48
  • Status: Offline

Post February 23rd, 2009, 12:00 pm

I found this pretty neat code on the web the other day.. It lists all the files in a directory pretty nice..

maybe you can figure out how to take this script apart and limit it..

Code: [ Select ]
<?php
if ($handle = opendir('.')) {
$ignore_files = array('.', '..', '.htaccess', '.htpasswd', 'index.php');
while (false !== ($file = readdir($handle)))
     {
         if (!in_array($file, $ignore_files))
    {
            $thelist .= '<a href="'.$file.'">'.$file.'</a>'.'<br>';
         }
     }
closedir($handle);
}
?>
<p style="font-weight: bold; font-size: 10pt">List of files:</p>
<p style="font-weight: bold; font-size: 10pt; color: #560D1C"><?=$thelist?></p>
  1. <?php
  2. if ($handle = opendir('.')) {
  3. $ignore_files = array('.', '..', '.htaccess', '.htpasswd', 'index.php');
  4. while (false !== ($file = readdir($handle)))
  5.      {
  6.          if (!in_array($file, $ignore_files))
  7.     {
  8.             $thelist .= '<a href="'.$file.'">'.$file.'</a>'.'<br>';
  9.          }
  10.      }
  11. closedir($handle);
  12. }
  13. ?>
  14. <p style="font-weight: bold; font-size: 10pt">List of files:</p>
  15. <p style="font-weight: bold; font-size: 10pt; color: #560D1C"><?=$thelist?></p>
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 23rd, 2009, 12:00 pm

Post Information

  • Total Posts in this topic: 16 posts
  • Users browsing this forum: No registered users and 150 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.