require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
$path = $_SERVER['DOCUMENT_ROOT'];
$path = isset($_GET['path']) ? $_GET['path'] : $_SERVER['DOCUMENT_ROOT'];
//$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$act = isset($_REQUEST['act']) ? $_REQUEST['act'] : null;
$filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : null;
$dirname = isset($_REQUEST['dirname']) ? $_REQUEST['dirname'] : null;
$info = readDirectory($path);
echo "<script>alert('没有文件或目录!!!');location.href='index.php';</script>";
$redirect="index.php?path={$path}";
$mes=createFile($path."/".$filename);
alertMes($mes,$redirect);
}elseif($act=="showContent"){
$content=file_get_contents($filename);
//echo "<textarea readonly='readonly' cols='100' rows='10'>{$content}</textarea>";
$newContent=highlight_string($content,true);
//highlight_file($filename);
<table width='100%' bgcolor='pink' cellpadding='5' cellspacing="0" >
alertMes("文件没有内容,请编辑再查看!",$redirect);
}elseif($act=="editContent"){
$content=file_get_contents($filename);
<form action='index.php?act=doEdit' method='post'>
<textarea name='content' cols='190' rows='10'>{$content}</textarea><br/>
<input type='hidden' name='filename' value='{$filename}'/>
<input type="hidden" name="path" value="{$path}" />
<input type="submit" value="修改文件内容"/>
$content=$_REQUEST['content'];
if(file_put_contents($filename,$content)){
alertMes($mes,$redirect);
}elseif($act=="renameFile"){
<form action="index.php?act=doRename" method="post">
请填写新文件名:<input type="text" name="newname" placeholder="重命名"/>
<input type='hidden' name='filename' value='{$filename}' />
<input type="submit" value="重命名"/>
}elseif($act=="doRename"){
$newname=$_REQUEST['newname'];
$mes=renameFile($filename,$newname);
alertMes($mes,$redirect);
}elseif($act=="delFile"){
alertMes($mes,$redirect);
}elseif($act=="downFile"){
$mes=downFile($filename);
$mes=createFolder($path."/".$dirname);
alertMes($mes,$redirect);
}elseif($act=="renameFolder"){
<form action="index.php?act=doRenameFolder" method="post">
请填写新文件夹名称:<input type="text" name="newname" placeholder="重命名"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='dirname' value='{$dirname}' />
<input type="submit" value="重命名"/>
}elseif($act=="doRenameFolder"){
$newname=$_REQUEST['newname'];
//echo $newname,"-",$dirname,"-",$path;
$mes=renameFolder($dirname,$path."/".$newname);
alertMes($mes,$redirect);
}elseif($act=="copyFolder"){
<form action="index.php?act=doCopyFolder" method="post">
将文件夹复制到:<input type="text" name="dstname" placeholder="将文件夹复制到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='dirname' value='{$dirname}' />
<input type="submit" value="复制文件夹"/>
}elseif($act=="doCopyFolder"){
$dstname=$_REQUEST['dstname'];
$mes=copyFolder($dirname,$path."/".$dstname."/".basename($dirname));
alertMes($mes,$redirect);
}elseif($act=="cutFolder"){
<form action="index.php?act=doCutFolder" method="post">
将文件夹剪切到:<input type="text" name="dstname" placeholder="将文件剪切到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='dirname' value='{$dirname}' />
<input type="submit" value="剪切文件夹"/>
}elseif($act=="doCutFolder"){
$dstname=$_REQUEST['dstname'];
$mes=cutFolder($dirname,$path."/".$dstname);
alertMes($mes,$redirect);
}elseif($act=="delFolder"){
$mes=delFolder($dirname);
alertMes($mes,$redirect);
}elseif($act=="copyFile"){
<form action="index.php?act=doCopyFile" method="post">
将文件复制到:<input type="text" name="dstname" placeholder="将文件复制到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='filename' value='{$filename}' />
<input type="submit" value="复制文件"/>
}elseif($act=="doCopyFile"){
$dstname=$_REQUEST['dstname'];
$mes=copyFile($filename,$path."/".$dstname);
alertMes($mes,$redirect);
}elseif($act=="cutFile"){
<form action="index.php?act=doCutFile" method="post">
将文件剪切到:<input type="text" name="dstname" placeholder="将文件剪切到"/>
<input type="hidden" name="path" value="{$path}" />
<input type='hidden' name='filename' value='{$filename}' />
<input type="submit" value="剪切文件"/>
}elseif($act=="doCutFile"){
$dstname=$_REQUEST['dstname'];
$mes=cutFile($filename,$path."/".$dstname);
alertMes($mes,$redirect);
$fileInfo=$_FILES['myFile'];
$mes=uploadFile($fileInfo,$path);
alertMes($mes, $redirect);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>File Manager</title>
<link rel="stylesheet" href="cikonss.css" />
<script src="jquery-ui/js/jquery-1.10.2.js"></script>
<script src="jquery-ui/js/jquery-ui-1.10.4.custom.js"></script>
<script src="jquery-ui/js/jquery-ui-1.10.4.custom.min.js"></script>
<link rel="stylesheet" href="jquery-ui/css/ui-lightness/jquery-ui-1.10.4.custom.css" type="text/css"/>
body,p,div,ul,ol,table,dl,dd,dt{
border:2px solid #ABCDEF;
<script type="text/javascript">
document.getElementById(dis).style.display="block";
function delFile(filename,path){
if(window.confirm("您确定要删除嘛?删除之后无法恢复哟!!!")){
location.href="index.php?act=delFile&filename="+filename+"&path="+path;
function delFolder(dirname,path){
if(window.confirm("您确定要删除嘛?删除之后无法恢复哟!!!")){
location.href="index.php?act=delFolder&dirname="+dirname+"&path="+path;
function showDetail(t,filename){
$("#showImg").attr("src",filename);
$("#showDetail").dialog({
position: {my: "center", at: "center", collision:"fit"},
location.href="index.php?path="+$back;
<div id="showDetail" style="display:none"><img src="" id="showImg" alt=""/></div>
<li><a href="index.php" title="主目录"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-home"></span></span></a></li>
<li><a href="#" onclick="show('createFile')" title="新建文件" ><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-file"></span></span></a></li>
<li><a href="#" onclick="show('createFolder')" title="新建文件夹"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-folder"></span></span></a></li>
<li><a href="#" onclick="show('uploadFile')"title="上传文件"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-upload"></span></span></a></li>
$back=($path=="file")?"file":dirname($path);
<li><a href="#" title="返回上级目录" onclick="goBack('<?php echo $back;?>')"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-arrowLeft"></span></span></a></li>
<form action="index.php" method="post" enctype="multipart/form-data">
<table width="100%" border="1" cellpadding="5" cellspacing="0" bgcolor="#ABCDEF" align="center">
<tr id="createFolder" style="display:none;">
<input type="text" name="dirname" />
<input type="hidden" name="path" value="<?php echo $path;?>"/>
<input type="submit" name="act" value="创建文件夹"/>
<tr id="createFile" style="display:none;">
<input type="text" name="filename" />
<input type="hidden" name="path" value="<?php echo $path;?>"/>
<input type="submit" name="act" value="创建文件" />
<tr id="uploadFile" style="display:none;">
<td ><input type="file" name="myFile" />
<input type="submit" name="act" value="上传文件" />
foreach($info['file'] as $val){
<td><?php echo $i;?></td>
<td><?php echo $val;?></td>
<td><?php $src=filetype($p)=="file"?"file_ico.png":"folder_ico.png";?><img src="images/<?php echo $src;?>" alt="" title="文件"/></td>
<td><?php echo transByte(filesize($p));?></td>
<td><?php $src=is_readable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_writable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php $src=is_executable($p)?"correct.png":"error.png";?><img class="small" src="images/<?php echo $src;?>" alt=""/></td>
<td><?php echo date("Y-m-d H:i:s",filectime($p));?></td>
<td><?php echo date("Y-m-d H:i:s",filemtime($p));?></td>
<td><?php echo date("Y-m-d H:i:s",fileatime($p));?></td>
$extArray = explode(".", $val);
$ext = strtolower(end($extArray));
$imageExt = array("gif", "jpg", "jpeg", "png");
if(in_array($ext,$imageExt)){
<a href="#" onclick="showDetail('<?php echo $val;?>','<?php echo $p;?>')"><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<a href="index.php?act=showContent&path=<?php echo $path;?>&filename=<?php echo $p;?>" ><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<a href="index.php?act=editContent&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/edit.png" alt="" title="修改"/></a>|
<a href="index.php?act=renameFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/rename.png" alt="" title="重命名"/></a>|
<a href="index.php?act=copyFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/copy.png" alt="" title="复制"/></a>|
<a href="index.php?act=cutFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/cut.png" alt="" title="剪切"/></a>|
<a href="#" onclick="delFile('<?php echo $p;?>','<?php echo $path;?>')"><img class="small" src="images/delete.png" alt="" title="删除"/></a>|
<a href="index.php?act=downFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/download.png" alt="" title="下载"/></a>
if (isset($info['dir']) && is_array($info['dir'])) {
$i = $i == null ? 1 : $i;
foreach ($info['dir'] as $val) {
<td><?php echo $i; ?></td>
<td><?php echo $val; ?></td>
<td><?php $src = filetype($p) == "file" ? "file_ico.png" : "folder_ico.png"; ?><img src="images/<?php echo $src; ?>" alt="" title="文件" /></td>
<td><?php $sum = 0; echo transByte(dirSize($p)); ?></td>
<td><?php $src = is_readable($p) ? "correct.png" : "error.png"; ?><img class="small" src="images/<?php echo $src; ?>" alt="" /></td>
<td><?php $src = is_writable($p) ? "correct.png" : "error.png"; ?><img class="small" src="images/<?php echo $src; ?>" alt="" /></td>
<td><?php $src = is_executable($p) ? "correct.png" : "error.png"; ?><img class="small" src="images/<?php echo $src; ?>" alt="" /></td>
<td><?php echo date("Y-m-d H:i:s", filectime($p)); ?></td>
<td><?php echo date("Y-m-d H:i:s", filemtime($p)); ?></td>
<td><?php echo date("Y-m-d H:i:s", fileatime($p)); ?></td>
<a href="index.php?path=<?php echo $p; ?>"><img class="small" src="images/show.png" alt="" title="查看" /></a>|
<a href="index.php?act=renameFolder&path=<?php echo $path; ?>&dirname=<?php echo $p; ?>"><img class="small" src="images/rename.png" alt="" title="重命名" /></a>|
<a href="index.php?act=copyFolder&path=<?php echo $path; ?>&dirname=<?php echo $p; ?>"><img class="small" src="images/copy.png" alt="" title="复制" /></a>|
<a href="index.php?act=cutFolder&path=<?php echo $path; ?>&dirname=<?php echo $p; ?>"><img class="small" src="images/cut.png" alt="" title="剪切" /></a>|
<a href="#" onclick="delFolder('<?php echo $p; ?>','<?php echo $path; ?>')"><img class="small" src="images/delete.png" alt="" title="删除" /></a>|
// Handle the case where 'dir' is not set or is not an array
echo "<tr><td colspan='11'>Directory information is not available.</td></tr>";