<?php
/****
Author:Raphael
****/
header("Content-type: text/html; charset=utf-8");
$path = './';
$url = $_SERVER['REQUEST_URI'];
if(isset($_GET['dir']))
{
$path = $path.'/'.$_GET['dir'].'/';
}
else
{
$url = $url . '?dir=';
}
$dh = opendir($path);
if($dh === false)
{
echo '打开出错';
exit;
}
$list = array();
while(($item = readdir($dh)) !== false)
{
$list[] = $item;
}
closedir($dh);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>新建网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
td{
border:1px solid gray;
}
</style>
</head>
<body>
<h1>文件管理系统</h1>
<table>
<tr>
<td>序号</td>
<td>文件名</td>
<td>操作</td>
</tr>
<?php foreach ($list as $k => $v) { ?>
<tr>
<td><?php echo $k ?></td>
<td><?php echo $v ?></td>
<td><?php
if(is_dir($path.'./'.$v)) //这行不懂,$path 前面不是赋值过了?和 ./ 这两个不是重复了吗?
{
echo '<a href="',$url.'/',$v,'">浏览</a>';
}
else
{
echo '<a href="',$path,$v,'">查看</a>';
}
?>
</td>
</tr>
<?php } ?>
</table>
</body>
</html>
林逸舟丶