效果图
<?php//读取管理项目,并且展示require_once 'lib/dir.func.php';require_once 'lib/file.func.php';date_default_timezone_t("prc");error_reporting(e_all&~e_notice);define('webroot','webroot');$path=$_request['path']?$_request['path']:webroot;$act=$_request['act']?$_request['act']:'';$dirname=$_request['dirname']?$_request['dirname']:'';$filename=$_request['filename']?$_request['filename']:'';$info=read_directory($path);// print_r($info);exit;if(!is_array($info)){exit("<script>alert('读取失败');location.href='index.php';</script>");}//根据不同请求完成不同操作switch($act){ca 'createdir':// echo $dirname;exit;$res=create_dir($path.directory_parator.$dirname);if($res===true){$result['msg']=baname($dirname).'创建成功';$result['icon']=1;}el{$result['msg']=$res;$result['icon']=2;}exit(json_encode($result));break;ca 'renamedir':$newname=$path.directory_parator.$dirname;$res=rename_dir($filename,$newname);if($res===true){$result['msg']=$filename.'重命名成功';$result['icon']=1;}el{$result['msg']=$res;$result['icon']=2;}exit(json_encode($result));break;ca 'deldir':$res=del_dir($filename);if($res===true){$result['msg']=baname($filename).'删除成功';$result['icon']=1;}el{$result['msg']=$res;$result['icon']=2;}exit(json_encode($result));break;//文件部分ca 'createfile':$res=create_file($path.directory_parator.$filename);if($res===true){$result['msg']=baname($filename).'文件新建成功';$result['icon']=1;}el{$result['msg']=$res;$result['icon']=2;}exit(json_encode($result));break;ca 'showcontents':$res=show_contents($filename);exit($res);break;}?><!doctype html><html lang="zh-cn"><head><meta chart="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><title>web在线文件管理器</title><!-- bootstrap --><link href="css/bootstrap.min.css" rel="stylesheet"><!-- html5 shim and respond.js for ie8 support of html5 elements and media queries --><!-- warning: respond.js doesn't work if you view the page via file:// --><!--[if lt ie 9]><script src=一瞬间近义词"http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script><script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script><![endif]--></head><body><div class="container"><div class="row clearfix"><div class="col-md-12 column"><nav class="navbar navbar-default" role="navigation"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collap" data-target="#bs-example-navbar-collap-1"> <span class="sr-only">切换导航</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button> <a class="navbar-brand" href="index.php"><span class="glyphicon glyphicon-home"></span>首页</a></div><div class="c音乐欣赏心得ollap navbar-collap" id="bs-example-navbar-collap-1"><ul class="nav navbar-nav"><li class="active"><a href="javascript:void(0)" class='createdir' data-url="index.php?act=createdir&path=<?php echo $path;?>"><span class="glyphicon glyphicon-folder-open"></span>新建目录</a></li><li><a href="javascript:void(0)" class="createfile" data-url="index.php?act=createfile&path=<?php echo $path;?>"><span class="glyphicon glyphicon-file"></span>新建文件</a></li><li><a href="#"><span class="glyphicon glyphicon-upload"></span>上传文件</a></li><li><a href="#"><span class="glyphicon glyphicon-info-sign"></span>系统信息</a></li></ul></li></ul><form class="navbar-form navbar-left" role="arch"><div class="form-group"><input type="text" class="form-control" /></div> <button type="submit" class="btn btn-default">搜索</button></form></div></nav><div class="jumbotron nofollow"><h1>web在线文件管理器</h1><p>web在线文件管理器主要是用于管理项目文件,实现在线编辑、修改、删除等操作。</p><p><a class="btn btn-primary btn-large" href="#">查看更多 »</a></p></div><table class="table table-bordered table-hover table-condend"><thead><tr><th>类型</th><th>名称</th><th>读/写/执行</th><th>访问时间</th><th>操作</th></tr></thead><tbody><!-- 目录部分 --><?phpif(is_array($info['dir'])){foreach($info['dir'] as $val){?><tr class="success"><td><span class="glyphicon glyphicon-folder-clo"></span></td><td><?php echo $val['showname'];?></td><td><span class="glyphicon <?php echo $val['readable']?'glyphicon-ok':'glyphicon-remove';?>"></span><span class="glyphicon <?php echo $val['writable']?'glyphicon-ok':'glyphicon-remove';?>"></span><span class="glyphicon <?php echo $val['executable']?'glyphicon-ok':'glyphicon-remove';?>"></span></td><td><?php echo $val['atime'];?></td><td><a href="index.php?path=<?php echo $val['filename'];?>" class='btn btn-primary btn-sm'>打开</a><a href="javascript兰亭序歌词:void(0)" class='btn btn-primary btn-sm renamedir' data-url='index.php?act=renamedir&filename=<?php echo $val['filename'];?>&path=<?php echo $path;?>' data-showname='<?php echo $val['showname'];?>'>重命名</a><a href="#" class='btn btn-primary btn-sm'>剪切</a><a href="#" class='btn btn-primary btn-sm'>复制</a><a href="javascript:void(0)" class='btn btn-danger btn-sm deldir' data-url='index.php?act=deldir&filename=<?php echo $val['filename'];?>&path=<?php echo $path;?>' data-showname='<?php echo $val['showname'];?>'>删除</a></td></tr><?php}}?><!-- 文件部分 --><?phpif(is_array($info['file'])){foreach($info['file'] as $val){?><tr class="warning"><td><span class="glyphicon glyphicon-file"></span></td><td><?php echo $val['showname'];?></td><td><span class="glyphicon <?php echo $val['readable']?'glyphicon-ok':'glyphicon-remove';?>"></span><span class="glyphicon <?php echo $val['writable']?'glyphicon-ok':'glyphicon-remove';?>"></span><span class="glyphicon <?php echo $val['executable']?'glyphicon-ok':'glyphicon-remove';?>"></span></td><td><?php echo $val['atime'];?></td><td><a href="#" class='btn btn-primary btn-sm showcontents' data-url="index.php?act=showcontents&filename=<?php echo $val['filename'];?>&path=<?php echo $path;?>">查看</成都银杏酒店管理学院a><a href="#" class='btn btn-primary btn-sm'>编辑</a><a href="#" class='btn btn-primary btn-sm'>下载</a><a href="#" class='btn btn-primary btn-sm'>重命名</a><a href="#" class='btn btn-primary btn-sm'>剪切</a><a href="#" class='btn btn-primary btn-sm'>复制</a><a href="#" class='btn btn-danger btn-sm'>删除</a></td></tr><?php}}?></tbody></table></div></div></div><!-- jquery (necessary for bootstrap's javascript plugins) --><script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script><三八短信祝福!-- include all compiled plugins (below), or include individual files as needed --><script src="js/bootstrap.min.js"></script><script src="layer/layer.js"></script><script src="js/dir.js"></script><script src="js/file.js"></script></body></html>
目录函数文件dir.func.php
<?php/*** 读取目录下的信息返回* @method read_directory* @param string $path 目标目录* @return mixed fal|array*/function read_directory(string $path){if(!is_dir($path)){return fal;}$info=[];$handle=opendir($path);while(($item=@readdir($handle))!==fal){if($item!='.'&&$item!='..'){$filepath=$path.directory_parator.$item;$info['filename']=$filepath;$info['showname']=$item;$info['readable']=is_readable($filepath)?true:fal;$info['writable']=is_writable($filepath)?true:fal;$info['executable']=is_executable($filepath)?true:fal;$info['atime']=date('y/m/d h:i:s',fileatime($filepath));if(is_file($filepath)){$arr['file'][]=$info;}if(is_dir($filepath)){$arr['dir'][]=$info;}}}clodir($handle);return $arr;}/*** 创建目录* @method create_dir* @param string $path 目录名称* @return mixed true|string*/function create_dir(string $path){if(is_dir($path)){return $path.'当前目录已存在同名文件';}if(!mkdir($path,755,true)){return $path.'目录创建失败';}return true;}/*** 重命名目录* @method rename_dir* @param string $oldname 原目录* @param string $newname 新名称* @return mixed string|true*/function rename_dir(string $oldname,string $newname){if(!is_dir($oldname)){return '原目录不存在';}if(is_dir($newname)){return '当前目录下存在同名文件';}if(!rename($oldname,$newname)){return '重命名失败';}return true;}/*** 删除目录* @method del_dir* @param string $path 目录名称* @return mixed true|string*/function del_dir(string $path){if(!is_dir($path)){return '目录不存在';}$handle=opendir($path);while(($item=@readdir($handle))!==fal){if($item!='.'&&$item!='..'){$pathname=$path.directory_parator.$item;if(is_file($pathname)){@unlink($pathname);}if(is_dir($pathname)){$func=__function__;$func($pathname);}}}clodir($handle);rmdir($path);return true;}
文件函数file.func.php
<?php/*** 创建文件* @method create_file* @param string $filename 文件名称* @param array $allowext 允许的文件类型* @return mixed true|string*/function create_file(string $filename,$allowext=array('txt','html','php')){if(is_file($filename)){return '当前目录下存在同名文件';}$ext=strtolower(pathinfo($filename,pathinfo_extension));if(!in_array($ext,$allowext)){return '非法文件类型';}if(!touch($filename)){return '文件创建失败';}return true;}/*** 查看文件内容* @method show_contents* @param string $filename 文件名称* @param array $allowext 允许的类型* @return string 文件内容*/function show_contents(string $filename,$allowext=array('jpg','jpeg','png','gif','txt','html','php')){if(!is_file($filename)){return '文件不存在';}$ext=strtolower(pathinfo($filename,pathinfo_extension));if(!in_array($ext,$allowext)){return '非法文件类型';}//检测是否是真实图片if(getimagesize($filename)){$res="<img src='{$filename}' class='img-responsive'/>";}el{$str=file_get_contents($filename);if(strlen($str)>0){$res=highlight_string($str,true);}el{$res='文件中没有内容';}}return $res;}
本文发布于:2023-04-08 03:03:58,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/b1399d32dbb889c2734cfb9aebbd18ea.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:文件管理系统.doc
本文 PDF 下载地址:文件管理系统.pdf
留言与评论(共有 0 条评论) |