Write a relatively bad directory file list program, support multiple systems, can be sorted by time, can enter the multi-level directory, other functions please add yourself!

Source: Internet
Author: User
Tags date functions key
Compare | program | sort PLEASE criticize!!!

<?//list.php
Power by Devchina.com 2oa.net
$Path = ($dir) urldecode ($dir): "D:";/best use Session to set PATH security
$handle =opendir ($Path);
while ($file = Readdir ($handle)) {
$newpath = $Path. " /". $file;
if ($file = = "..." or $file = = ".") {
You can put. Or. Add a connection as a back to the previous layer ";
Continue
}
if (Is_dir ($newpath)) {
$p [Intval (Filemtime ($newpath))]= $file;
}else
{
$f [Intval (Filemtime ($newpath))]= $file;
}
}
echo "Collation: Time <a href=list.php?order=up&dir= $dir > L </a> (oldest file in front) <a Href=list.php?order=down &dir= $dir > Drop </a> (latest file in front) ";
$CD = ($order = = "Up") sizeof (@ksort ($p)): sizeof (@krsort ($p));
$CF = ($order = = "Up") sizeof (@ksort ($f)): sizeof (@krsort ($f));
if ($cd >0) {

while (list ($key, $val) =each ($p)) {

echo "<br>";
echo " <a href=list.php? order= $order &dir= ". UrlEncode ($Path.) /". $val)." > $val </a> ";
echo "Create Time:". @date ("Y-m-j:h:i:s", $key). "";
}
}
Unset ($p);
Unset ($CD);
if ($CF >0) {

while (list ($key, $val) =each ($f)) {
echo "<br>";
echo " $val";
echo "Create Time:". @date ("Y-m-j:h:i:s", $key). "";
}
}
Unset ($f);
Unset ($CF);
Closedir ($handle);

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.