madspof Posted June 27, 2007 Share Posted June 27, 2007 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"; ?> Quote Link to comment Share on other sites More sharing options...
.Stealth Posted June 27, 2007 Share Posted June 27, 2007 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"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.