dezkit Posted March 22, 2008 Share Posted March 22, 2008 how do i make an index of a subdirectory, where it shows all the files in the directory? Quote Link to comment Share on other sites More sharing options...
Orio Posted March 22, 2008 Share Posted March 22, 2008 Add to that directory a .htaccess file containing: Options Indexes That would create the list (if you don't have an index page). Orio. Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted March 22, 2008 Share Posted March 22, 2008 Or Simply put.. may want to change the colors around a bit.. but over all.. this should do the trick. can alter it over all to look like the Indexes Option.. but if you want more control over what the public may see then I would go with this.. but thats me.. (mind you if you have this for public viewing and not in a exclusively access able area you may want to remove the bit that contains code to delete listed files..) <table border="0" cellpadding="3" cellspacing="3"> <tr><td bgcolor='#789ABC'><font color="#000000" size="2" face="Verdana"><a href='index.php?sortwhat=name' title='sort by name'><b>Name</b></a></font></td> <td bgcolor='#BAA978'><font color="#000000" size="2" face="Verdana"><a href='index.php?sortwhat=size' title='sort by size'><b>Size</b></a></font></td> <td bgcolor='#78CD9A'><font color="#000000" size="2" face="Verdana"><a href='index.php' title='sort by date/time'><b>Date/Time</b></a></font></td> <? $maindir = "../"; $mydir = opendir($maindir); while($fn = readdir($mydir)){ if ($fn == "." || $fn == ".." || $fn == "index.php"){continue;} else { $x++; $afn[$x]=$fn; if($sortwhat==""){$aft[$x]=filemtime($maindir.$fn);} if($sortwhat=="size"){$aft[$x]=filesize($maindir.$fn);} if($sortwhat=="name"){$aft[$x]=$fn;} } } arsort($aft, SORT_NUMERIC); foreach ( $aft as $key => $value ) { $fpn = $maindir.$afn[$key]; if ($afn[$key] == "images") { echo "<tr><td bgcolor='#ABCDEF'><font size='1' face='Verdana'>".$afn[$key]."</font></td><td bgcolor='#FEDCBA'><font size='1' face='Verdana'> ---- </font></td><td bgcolor='#ABEFCD'><font size='1' face='Verdana'> File Marker </font></td></tr>"; } else { echo "<tr><td bgcolor='#ABCDEF'><font size='1' face='Verdana'><a href=".$fpn.">".$afn[$key]."</a></font></td><td bgcolor='#FEDCBA'><font size='1' face='Verdana'>".fsize($fpn)."</font></td><td bgcolor='#ABEFCD'><font size='1' face='Verdana'>".tdatetime(filectime($fpn))."</font></td><td><a href='index.php?loc=1&area=delhappic&pic=".$afn[$key]."'><font size='1' face='Verdana'>Delete</font></a></td></tr>"; } } closedir($mydir); function tdatetime($ts){return date("F d Y H:i:s", $ts);} function fsize($file){ $a = array("B", "KB", "MB", "GB", "TB", "PB"); $pos = 0; $size = filesize($file); while ($size >= 1024) { $size /= 1024; $pos++; } return round($size,2)." ".$a[$pos]; } function foldersize($path){ $size = 0; $dir = opendir($path); while ($file = readdir($dir)){ if (is_file($path.$file)){$size=$size+filesize($path.$file);} } return $size; } echo "<tr><td bgcolor='#BBBBBB'><font size='1' face='Verdana'><b>Foldersize: </b></font></td><td bgcolor='#BBBBBB'><font size='1' face='Verdana'><b>".round((foldersize($maindir)/1024/1024),3)." MB</b></font></td><td bgcolor='#BBBBBB'><font size='1' face='Verdana'>......</font></td></tr>"; ?> </table> if you should want to block specifics alter this piece to your needs in the above... while($fn = readdir($mydir)){ if ($fn == "." || $fn == ".." || $fn == "index.php"){continue;} else example.. change index.php to what ever specific you want not shown.. or just add something to the line.. after "index.php" just put || $fn == "file.ext" its a crude method I suppose but its worked for me for some time when I need to use it.. Quote Link to comment Share on other sites More sharing options...
dezkit Posted March 22, 2008 Author Share Posted March 22, 2008 thanks guys but its not what i wanted here is my website i created a subdirectory (a) i made a blank index.php (so u guys can give me the code) i created a subdirectory (b) in that subdirectory, i made 2 random html files, how do i look whats in subdirectory(b) by the index.php in subdirectory(a) ? Quote Link to comment Share on other sites More sharing options...
dezkit Posted March 22, 2008 Author Share Posted March 22, 2008 like this, i want an uploader on one page (http://phishcave.com/upload/), then click to view all uploaded files, i have the uploader code, but how do i make like this (http://phishcave.com/r/) Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted March 22, 2008 Share Posted March 22, 2008 with the code i posted above.. alter $maindir = "../"; and put $maindir = "../subdirectoryb/"; Quote Link to comment Share on other sites More sharing options...
dezkit Posted March 22, 2008 Author Share Posted March 22, 2008 doesn't seem to work :/ Quote Link to comment Share on other sites More sharing options...
dezkit Posted March 22, 2008 Author Share Posted March 22, 2008 nevermind, works perfectly now, thanks!!! 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.