Jump to content

hi could someone please help me with a listing script


madspof

Recommended Posts

the script below works so that it lists the users files in their folder but I was wondering if it would be possible for someone to comment on what everything does in the script so that i can add a feature that says that there are no files in the users folder if none are present or could some one jsut show me how to do this

 

  <?php

include "../status.php";

$cookie_info = explode("-", $_COOKIE['cookie_info']);

$namecookie = $cookie_info[0];

$files = array();

$dir=opendir("./$namecookie");

while(($file = readdir($dir)) !== false) 

if($file !== '.' && $file !== '..' && !is_dir($file)) 

$files[] = $file; 

closedir($dir);

natcasesort($files);

echo "<ul>\n";

for($i=0; $i<count($files); $i++) 

{

if($files[$i] != "index.php")

echo "<li><a href=\"$namecookie/".$files[$i]."\">".$files[$i]."</a></li>\n";

}

echo "</ul>\n";

?>

Try this:

 

<?php
include "../status.php";
$cookie_info = explode("-", $_COOKIE['cookie_info']);
$namecookie = $cookie_info[0];
$files = array();
$dir=opendir("./$namecookie");
while(($file = readdir($dir)) !== false) 
{ 
   if($file !== '.' && $file !== '..' && !is_dir($file)) 
   { 
      $files[] = $file; 
   } 
} 
closedir($dir);
natcasesort($files);

if(empty($files)){
echo "<p>No files in this directory</p>";
}else{
echo "<ul>\n";
for($i=0; $i<count($files); $i++) 
{
if($files[$i] != "index.php")
   echo "<li><a href=\"$namecookie/".$files[$i]."\">".$files[$i]."[/url]</li>\n";
}
echo "</ul>\n";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.