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";

?>

Link to comment
Share on other sites

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";
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.