亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

小型web文件管理器

原創(chuàng) 2019-02-27 18:25:48 302
摘要:/** *config.php中的代碼 */<?php/** * 配置文件 */include 'function.php';$path = 'file';@$path = $_REQUEST['path'] ? $_REQUEST['path'] : $path;var_dump($path);$data

/**

 *config.php中的代碼

 */

<?php
/**
* 配置文件
*/
include 'function.php';

$path = 'file';

@$path = $_REQUEST['path'] ? $_REQUEST['path'] : $path;

var_dump($path);

$data = read_dir($path);

//var_dump($data);

if(!$data){
   echo '<script>alert("目錄為空")</script>';
}

//判斷點(diǎn)擊操作
@$act = $_REQUEST['act'];

//接受創(chuàng)建的文件名
@$filename = $_REQUEST['filename'];

//接受創(chuàng)建的文件夾名
@$dirname = $_REQUEST['dirname'];

//用于操作完成后跳回首頁(yè)(偽刷新)
$url = "index.php?path={$path}";

?>


/**

 *operration.php中的代碼

 */

<?php
/**
* 操作配置
*/
include 'common.php';

if($act == '創(chuàng)建文件'){
//    var_dump($filename);
   $mes = create_file($path.'/'.$filename);
   alertMes($mes,$url);
}elseif ($act == 'showContent'){
   $content = read_file($filename);
   if(strlen($content)){
       //給字符串添加高亮
       $newContent = highlight_string($content,true);
       //制作顯示表
       $str = <<<HERE
   <table width="100%" bgcolor="pink" cellpadding="5" cellspacing="">
   <tr>
   <td>{$newContent}</td>
</tr>
   
</table>
HERE;
       echo $str;
   }else{
       alertMes('文件為空,請(qǐng)編輯后在查看!',$url);
   }
   //判斷點(diǎn)擊操作
}elseif ($act == 'editContent'){
   //獲取文件內(nèi)容
   $content = file_get_contents($filename);
//    var_dump($filename);
   //制作表單
   $str = <<<HERE
<form action="index.php?act=doEdit" method="post">
   <textarea cols="180" rows="10" name="content">{$content}</textarea>
   <input type="hidden" name="path" value="{$path}" />
   <input type="hidden" name="filename" value="{$filename}" />
   <input type="submit" value="修改內(nèi)容" />
</form>
HERE;
echo $str;
   //判斷操作
}elseif ($act == 'doEdit'){
   //獲取修改內(nèi)容
   $content = $_REQUEST['content'];
//    var_dump($filename);
   //進(jìn)行修改并判斷
   if(file_put_contents($filename, $content)){
       $mes = '文件修改成功';
   }else{
       $mes = '文件修改失敗';
   }
   alertMes($mes,$url);
   //判斷操作
}elseif ($act == 'renameFile'){
   $str = <<<HERE
<form action="index.php?act=doRename" method="post">
   請(qǐng)輸入新文件名稱:<input type="text" name="newName" placeholder="輸入新名稱"/>
   <input type="hidden" name="path" value="{$path}">
   <input type="hidden" name="filename" value="{$filename}">
   <input type="submit" value="重命名">
</form>
HERE;
   echo $str;
   //判斷操作
}elseif ($act == 'doRename'){
   //接受新名稱
   $newName = $_REQUEST['newName'];
   //進(jìn)行修改文件名
   $mes = rename_file($filename, $path.'/'.$newName);
   alertMes($mes, $url);
   //判斷操作
}elseif ($act == 'copyFile'){
   //制作輸入框
   $str = <<<HERE
<form action="index.php?act=doCopyFile" method="post">
   文件復(fù)制到:<input type="text" name="destName" placeholder="將文件復(fù)制到">
   <input type="hidden" name="path" value="{$path}">
   <input type="hidden" name="filename" value="{$filename}">
   <input type="submit" value="復(fù)制文件">
</form>
HERE;
   echo $str;
   //判斷操作
}elseif ($act == 'doCopyFile'){
   //接受目標(biāo)目錄
   $destName = $_REQUEST['destName'];
   //進(jìn)行復(fù)制操作
   $mes = copy_file($filename, $path.'/'.$destName);
   //提示操作
   alertMes($mes, $url);
}elseif ($act == 'cutFile'){
   $str = <<<HERE
<form action="index.php?act=doCutFile" method="post">
   文件剪切到:<input type="text" name="destName" placeholder="將文件剪切到">
   <input type="hidden" name="path" value="{$path}">
   <input type="hidden" name="filename" value="{$filename}">
   <input type="submit" value="剪切文件">
</form>
HERE;
   echo $str;
}elseif ($act == 'doCutFile'){
   $destName = $_REQUEST['destName'];
   $mes = cut_file($filename, $path.'/'.$destName);
   alertMes($mes, $url);
}elseif ($act == 'dowFile'){
   $mes = dow_file($filename);
}elseif ($act == 'delFile'){
   if(unlink($filename)){
       alertMes("文件刪除成功!", $url);
   }else{
       alertMes("文件刪除失敗!", $url);
   }
}elseif ($act == '上傳文件'){
   $fileinfo = $_FILES['myFile'];
   $mes = upload_file($fileinfo, $path);
   alertMes($mes ,$url);
}elseif ($act == '創(chuàng)建文件夾'){
   $mes = create_folder($path.'/'.$dirname);
   alertMes($mes, $url);
}elseif ($act == 'renameFolder'){
   $str = <<<HERE
<form action="index.php?act=doRenameFolder" method="post">
   重命名為:<input type="text" name="newFolderName" placeholder="請(qǐng)輸入文件夾名稱">
   <input type="hidden" name="dirname" value="{$dirname}">
   <input type="hidden" name="path" value="{$path}">
   <input type="submit" value="重命名">
</form>
HERE;
   echo $str;
}elseif ($act == 'doRenameFolder'){
   $newFolderName = $_REQUEST['newFolderName'];
   $mes = rename_dir($dirname, $path.'/'.$newFolderName);
   alertMes($mes, $url);
}elseif ($act == 'copyFolder'){
   $str = <<<HERE
<form action="index.php?act=doCopyFolder" method="post">
   復(fù)制到:<input type="text" name="newFolderName" placeholder="復(fù)制文件夾到">
   <input type="hidden" name="dirname" value="{$dirname}">
   <input type="hidden" name="path" value="{$path}">
   <input type="submit" value="復(fù)制">
</form>
HERE;
   echo $str;
}elseif ($act == 'doCopyFolder'){
   $newFolderName = $_REQUEST['newFolderName'];
   $mes = copy_dir($dirname, $path.'/'.$newFolderName.'/'.basename($dirname));
   alertMes($mes, $url);
}elseif ($act == 'cutFolder'){
   $str = <<<HERE
<form action="index.php?act=doCutFolder" method="post">
   剪切到:<input type="text" name="newFolderName" placeholder="剪切文件夾到">
   <input type="hidden" name="dirname" value="{$dirname}">
   <input type="hidden" name="path" value="{$path}">
   <input type="submit" value="剪切">
</form>
HERE;
   echo $str;
}elseif ($act == 'doCutFolder'){
   $newFolderName = $_REQUEST['newFolderName'];
   $mes = cut_dir($dirname, $path.'/'.$newFolderName);
   alertMes($mes, $url);
}elseif ($act == 'delFolder'){
   $mes = del_folder($dirname);
   alertMes($mes, $url);
}


/**

 *common.php中的代碼

 */

<?php
/**
* 公共提示信息
*/

function alertMes($mes, $url)
{
   echo '<script>alert("'.$mes.'");'.'location.href="'.$url.'"</script>';
}

?>

/**

 *index.php中的代碼

 */

<?php
include 'config.php';
include 'operation.php';
?>
<!doctype html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>PHP中文網(wǎng)—Web在線文件管理器</title>
   <link rel="stylesheet" href="css/cikonss.css"/>
   <link rel="stylesheet" href="css/style.css"/>
   <link rel="stylesheet" href="css/jquery-ui-1.10.4.custom.css" type="text/css"/>
   <script src="js/jquery-1.10.2.js"></script>
   <script src="js/jquery-ui-1.10.4.custom.js"></script>
   <script src="js/action.js"></script>
</head>
<body>
<h1 align="center">PHP中文網(wǎng)—Web在線文件管理器</h1>
<div id="showDetail" style="display:none"><img src="" id="showImg" alt=""/></div>
<div id="top">
   <ul id="navi">
       <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>
<?php
$back = $data == 'file' ? 'file' : dirname($path);
?>
<li><a href="#" title="返回上級(jí)目錄" 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>
   </ul>
</div>
<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;">
           <td>請(qǐng)輸入文件夾名稱</td>
           <td>
               <input type="text" name="dirname"/>
               <input type="hidden" name="path" value="<?php echo $path;?>"/>
               <input type="submit" name="act" value="創(chuàng)建文件夾"/>
           </td>
       </tr>
       <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="submit" name="act" value="創(chuàng)建文件"/>
           </td>
       </tr>
       <tr id="uploadFile" style="display:none;">
           <td>請(qǐng)選擇要上傳的文件</td>
           <td><input type="file" name="myFile"/>
               <input type="submit" name="act" value="上傳文件"/>
           </td>
       </tr>
   </table>
</form>
<table width="100%" border="1" cellpadding="5" cellspacing="0" bgcolor="#ABCDEF" align="center">
   <tr>
       <th>編號(hào)</th>
       <th>名稱</th>
       <th>類型</th>
       <th>大小</th>
       <th>可讀</th>
       <th>可寫</th>
       <th>可執(zhí)行</th>
       <th>創(chuàng)建時(shí)間</th>
       <th>修改時(shí)間</th>
       <th>訪問(wèn)時(shí)間</th>
       <th>操作</th>
   </tr>
<?php
       if(@$data['file']){
$i = 1;
foreach ($data['file'] as $v) {
$p = $path.'/'.$v;
//                var_dump($p);
?>
<tr>
       <td><?php echo $i;?></td>
       <td><?php echo $v;?></td>
       <td><?php $src = filetype($p) == 'file' ? 'file_ico.png' : 'folder_ico.png';?><img src="images/<?php echo $src;?>" title="文件"></td>
       <td><?php echo trans_byte(filesize($p));?></td>
       <td><?php $src = is_readable($p) ? 'correct.png' : 'error.png';?><img class="small" src="images/<?php echo $src;?>"></td>
       <td><?php $src = is_writable($p) ? 'correct.png' : 'error.png';?><img class="small" src="images/<?php echo $src;?>"></td>
       <td><?php $src = is_executable($p) ? 'correct.png' : 'error.png';?><img class="small" src="images/<?php echo $src;?>"></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
$ext = strtolower(pathinfo($v,PATHINFO_EXTENSION));
$imagesExt = ['jpeg','png','jpg','gif'];
if(in_array($ext, $imagesExt)){
?>
<a href="#" onclick="showDetail('<?php echo $v;?>','<?php echo $p;?>')"><img class="small" src="images/show.png" alt="" title="查看"/></a>
<?php
}else{
?>
<a href="index.php?act=showContent&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/show.png" alt="" title="查看"/></a>
<?php
}
?>
<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="復(fù)制"/></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="index.php?act=dowFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/download.png" alt="" title="下載"/></a>
           <a href="#" onclick="delFile('<?php echo $p;?>','=<?php echo $path;?>')"><img class="small" src="images/delete.png" alt="" title="刪除"/></a>
       </td>
   </tr>
<?php
$i++;
}
       }

if(@$data['dir']) {
$i = 1;
foreach ($data['dir'] as $v) {
$p = $path . '/' . $v;
//                var_dump($p);
?>
<tr>
       <td><?php echo $i;?></td>
       <td><?php echo $v;?></td>
       <td><?php $src = filetype($p) == 'dir' ? 'folder_ico.png' : 'file_ico.png'?><img src="images/<?php echo $src;?>" title="文件夾"></td>
       <td><?php $sum = 0; echo trans_byte(dir_size($p));?></td>
       <td><?php $src = is_readable($p) ? 'correct.png' : 'error.png';?><img class="small" src="images/<?php echo $src;?>"></td>
       <td><?php $src = is_writable($p) ? 'correct.png' : 'error.png';?><img class="small" src="images/<?php echo $src;?>"></td>
       <td><?php $src = is_executable($p) ? 'correct.png' : 'error.png';?><img class="small" src="images/<?php echo $src;?>"></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>
           <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="復(fù)制"/></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>
       </td>
   </tr>
<?php
$i++;
}
       }
?>
</table>
</body>
</html>

批改老師:韋小寶批改時(shí)間:2019-02-28 09:16:33
老師總結(jié):寫的很完成 下次這種記得附上個(gè)結(jié)果圖片哦

發(fā)布手記

熱門詞條