圖片無(wú)法查看啊,老鐵,沒(méi)毛病??!
<?php
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
$path = "file";
$act = $_REQUEST['act'];
$filename = $_REQUEST['filename'];
$info = readDirectory($path);
// print_r($info);
$redirect = "index.php?path={$path}";
if ($act == "createFile") {
? ? // 創(chuàng)建文件 查看文件 ?修改文件
? ? // echo $path;
? ? // echo $filename;
? ? $mes = createFile($path . "/" . $filename);
? ? alertMes($mes, $redirect);
} else if ($act == "showContent") {
? ? ? ? // 查看文件內(nèi)容
? ? ? ? $content = file_get_contents($filename);
? ? ? ? // cho "<textarea readonly='raedonly' clos='100' rows='20'>$c</textarea>" ;
? ? ? ? // 高亮顯示PHP代碼
? ? ? ? if (strlen($content)) {
? ? ? ? ? ? // 高亮顯示字符串中的PHP代碼
? ? ? ? ? ? $newContent = highlight_string($content, true);
? ? ? ? ? ? // 高亮顯示文件中的PHP代碼
? ? ? ? ? ? // highlight_file($filename);
? ? ? ? ? ? $str = <<<XGG
? ? ? ? ? ? ? ? ? ? <table ?width="100%" height="10%" bgcolor="pink">
? ? ? ? ? ? ? ? ? ? ? ? <tr><td>{$newContent}</td></tr>
? ? ? ? ? ? ? ? ? ? </table>
XGG;
? ? ? ? ? ? ?echo $str;
? ? ? ? } else {
? ? ? ? ? ? alertMes("這個(gè)文件沒(méi)有內(nèi)容,請(qǐng)編輯再查看!", "$redirect");
? ? ? ? }
}else if($act=='editContent'){
? ? //修改文件內(nèi)容
? ? ? ? //echo ?"編輯文件";
? ? //得到文件內(nèi)容
? ? $content=file_get_contents($filename);
? ? $str=<<<XGG
? ? <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="submit" value="修改文件內(nèi)容" />
? ? </form>
XGG;
? ? echo $str;
}else if ($act=="doEdit"){
? ? //修改文件內(nèi)容的操作
? ? $content=$_REQUEST['content'];
? ? if(file_put_contents($filename,$content)){
? ? ? ? $mes="文件修改成功";
? ? }else {
? ? ? ? $mes="文件修改失敗";
? ? }
? ? alertMes($mes, $redirect);
}
?>
<!DOCTYPE html >
<html>
<meta http-equiv="Content-Type" content="text/html" charset="GB2312">
<title>Insert title here</title>
<link type="text/css" rel="stylesheet" href="style.css"></link>
<--從官網(wǎng)下載到本地的文件加載的-->
<script type="text/javascript" src="jquery-ui-1.12.1.custom/jquery-ui.js"></script>
<script type="text/javascript" src="jquery-ui-1.12.1.custom/external/jquery/jquery.js"></script>
<script type="text/javascript" src="jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
</head>
<body>
<h1>在線文件管理器</h1>
<div>
<ul>
<li><a href="index.php" title="主目錄"><span style="margin-left: 8px, margin-top:0px"></span><img alt="" src="images/zhuye.png" /></a></li>
<li><a href="#" onclick="show('createFile')" title="新建文件"><span style="margin-left: 5px;"></span><img alt="" src="images/xinjianwenjian.png" /></a></li>
<li><a href="#" onclick="show('createFolder')" title="新建文件夾"><span style="margin-left: 5px;"></span><img alt="" src="images/xinjianwenjianjia.png" /></a></li>
<li><a href="#" onclick="show('uploadFile')" title="上傳文件"><span style="margin-left: 5px;"></span><img alt="" src="images/shangchuan.png" /></a></li>
<li><a href="#" title="返回上級(jí)目錄" onclick="back('<?php //echo $back;?>')"><span style="margin-left: 5px;"></span><img alt="" src="images/fanhui.png" /></a></li>
</ul>
</div>
<script type="text/javascript">
function show(dis){
document.getElementById(dis).style.display="block";
}
function delFile(path,filename){
if(window.confirm("刪除之后無(wú)法恢復(fù),您確定要?jiǎng)h除嗎?")){
location.href="index.pnp?act=delFile&path="+path+"&filename="+filename;
}
}
function showDetail(t,filename){
? ? $("showImg").attr("src",filename);
? ? $("showDetail").dialog({
? ? ? ? height:"auto",
? ? ? ? width:"auto",
? ? ? ? position:{my:"center",at:"center",collision:"fit"},
? ? ? ? modal:false,//是否模式對(duì)話框
? ? ? ? draggable:true,//是否允許拖拽
? ? ? ? resizable:true,//是否允許拖動(dòng)
? ? ? ? title:t,//對(duì)話框標(biāo)題
? ? ? ? show:"slide",
? ? ? ? hide:"explode"
? ? });
}
</script>
<form action="index.php" method="post">
<table>
<tr id="createFile" style="display: none">
<td>請(qǐng)輸入文件名稱</td>
<td><input type="text" name="filename" /> <input type="hidden" name="path" value="<?php echo $path?>" /> <input type="hidden"
name="act" value="createFile" /> <input type="submit" value="創(chuàng)建文件" />
</td>
</tr>
<tr id="createFolder" style="display: none">
<td>請(qǐng)輸入文件夾名稱</td>
<td><input type="text" name="dirname" /> <input type="submit" name="act" value="創(chuàng)建文件夾" /></td>
</tr>
<tr id="uploadFile" style="display: none">
<td>請(qǐng)選擇要上傳的文件</td>
<td><input type="file" name="filename" /> <input type="submit" name="act" value="上傳文件" /></td>
</tr>
<tr>
<td>編號(hào)</td>
<td>名稱</td>
<td>類型</td>
<td>大小</td>
<td>可讀</td>
<td>可寫</td>
<td>可執(zhí)行</td>
<td>創(chuàng)建時(shí)間</td>
<td>修改時(shí)間</td>
<td>訪問(wèn)時(shí)間</td>
<td>操作</td>
</tr>
<?php
if ($info ['file']) {
? ? $i = 1;
? ? foreach ($info ['file'] as $val) {
? ? ? ? $p = $path . "/" . $val;
?>
<tr>
<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
src="images/<?php echo $src; ?>" alt=" " /></td>
<td><?php $src=is_writable($p)?"correct.png":"error.png";?><img
src="images/<?php echo $src; ?>" alt=" " /></td>
<td><?php $src=is_executable($p)?"correct.png":"error.png";?><img
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>
<td>
<?php
$tmp_name=explode(".", $val);
? ? ? ? $ext = strtolower(end($tmp_name));
? ? ? ? $imageExt = array(
? ? ? ? ? ? "gif",
? ? ? ? ? ? "jpg",
? ? ? ? ? ? "jpeg",
? ? ? ? ? ? "png"
? ? ? ? );
? ? ? ? if (in_array($ext, $imageExt)) {
? ? ? ? ? ? ?>
? ?<a href="#"
onclick="showDetail('<?php echo $val;?>','<?php echo $p;?>')"><img
alt="" src="images/show.png" title="查看" /></a>
<?php
? ? ? ? } else {
? ? ? ? ? ? ?>
<a href="index.php?act=showContent&filename=<?php echo $p;?>"><img
alt="" src="images/show.png" title="查看" /></a>
<?php }?>
<a href="index.php?act=editContent&filename=<?php echo $p;?>"><img
alt="" src="images/edit.png" title="修改" /></a> <a
href="index.php?act=renameFile&path=<?php echo $p;?>"><img alt=""
src="images/rename.png" title="重命名" /></a> <a
href="index.php?act=copyFile&path=<?php echo $p;?>"><img alt=""
src="images/copy.png" title="復(fù)制" /></a> <a
href="index.php?act=moveFile&path=<?php echo $p;?>"><img alt=""
src="images/cut.png" title="剪切" /></a> <a href="#"
onclick="delFile('<?php echo $p;?>','<?php echo $p.'/'.$val;?>')"><img
alt="" src="images/delete.png" title="刪除" /></a> <a
href="index.php?act=downFile&path=<?php echo $p;?>&filename<?php echo $p.'/'.$val;?>"><img
alt="" src="images/download.png" title="下載" /></a>
</td>
</tr>
<?php
? ? ? ? $i ++;
? ? }
}
?>
</table>
</form>
</body>
</html>
2017-02-25
少寫了這個(gè)代碼,用來(lái)顯示圖片的框:<div id="showDetail" ?style="display:none"><img src="" id="showImg" alt=""/></div>