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"; ?> Link to comment https://forums.phpfreaks.com/topic/57392-hi-could-someone-please-help-me-with-a-listing-script/ 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/57392-hi-could-someone-please-help-me-with-a-listing-script/#findComment-283917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.