<?php$path='./';if(isset($_GET['dir'])){$path=$path.$_GET['dir'];}$dh=opendir($path);if($dh===false){echo'打开出错';exit;}while(($item=readdir($dh))!==false){$list[]=$item;}print_r($list);closedir($dh);print_r($_SERVER);?><!DOCTYPEhtml><html><head><metacharset="UTF-8"><title></title></head><body><h2>文件管理系统</h2><table><tr><td>序号</td><td>文件名</td><td>操作</td></tr><?phpforeach($listas$key=>$value){?><tr><td><?phpecho$key?></td><td><?phpecho$value?></td><td><?phpif(is_dir($path.$value)&&($value=='.')){echo'<ahref="new1.php?dir=',$value,'/">浏览</a>';}elseif(is_dir($path.$value)){echo'<ahref="new1.php?dir=',$value,'">浏览</a>';}elseif(!(is_dir($path.$value))){echo'<ahref="./',$value,'">查看</a>';}?></td></tr><?php}?></table></body></html>