正在回答 回答被采纳积分+1
7回答
jujijigo
2018-06-30 19:37:15
以下是dir.func.php文件的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <?php header( 'content-type:text/html;charset=utf-8' ); /** * 读取目录下的信息返回 * @method read_directory * @param string $path 目标目录 * @return mixed false|array */ function read_directory(string $path ) { if (! is_dir ( $path )) { return false; } $info = []; $handle = opendir( $path ); while (( $item = @readdir( $handle )) !== false) { if ( $item != '.' && $item != '..' ) { $filePath = $path . DIRECTORY_SEPARATOR . $item ; $info [ 'fileName' ] = $filePath ; $info [ 'showName' ] = $item ; $info [ 'readable' ] = is_readable ( $filePath ) ? true : false; $info [ 'writable' ] = is_writable ( $filePath ) ? true : false; $info [ 'executable' ] = is_executable ( $filePath ) ? true : false; $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 ; } } } closedir ( $handle ); return $arr ; } |
jujijigo
2018-06-30 19:36:38
我是在每个文件都设置了编码格式。以下是index.php的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | <!DOCTYPE html> <html lang= "zh-CN" > <head> <meta charset= "utf-8" > <meta http-equiv= "X-UA-Compatible" content= "IE=edge" > <meta name= "viewport" content= "width=device-width, initial-scale=1" > <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <title>WEB在线文件管理器</title> <!-- Bootstrap --> <link href= "https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel= "stylesheet" > <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询(media queries)功能 --> <!-- 警告:通过 file: // 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 --> <!--[ if lt IE 9]> <script src= "https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js" ></script> <script src= "https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js" ></script> <![ endif ]--> </head> <body> <?php header( 'content-type:text/html;charset=utf-8' ); //读取管理项目,并且展示 require_once 'lib/dir.func.php' ; date_default_timezone_set( "PRC" ); error_reporting (E_ALL&~E_NOTICE); define( 'WEBROOT' , 'webroot' ); $path = $_REQUEST [ 'path' ] ? $_REQUEST [ 'path' ]: WEBROOT ; $info =read_directory( $path ); //print_r($info);exit; if (! is_array ( $info )){ exit ("<script> alert( '读取失败' ); location.href= 'index.php' ; </script>"); } ?> <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= "collapse" data-target= "#bs-example-navbar-collapse-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" aria-hidden= "true" ></span>首页</a> </div> <div class = "collapse navbar-collapse" id= "bs-example-navbar-collapse-1" > <ul class = "nav navbar-nav" > <li class = "active" > <a href= "#" ><span class = "glyphicon glyphicon-folder-open" ></span>新建目录</a> </li> <li> <a href= "#" ><span class = "glyphicon glyphicon-file" aria-hidden= "true" ></span>新建文件</a> </li> <li> <a href= "#" ><span class = "glyphicon glyphicon-upload" aria-hidden= "true" ></span>上传文件</a> </li> <li> <a href= "#" ><span class = "glyphicon glyphicon-info-sign" aria-hidden= "true" ></span>系统信息</a> </li> </ul> <form class = "navbar-form navbar-left" role= "search" > <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-condensed" > <thead> <tr> <th> 类型 </th> <th> 名称 </th> <th> 读/写/执行 </th> <th> 访问时间 </th> <th> 操作 </th> </tr> </thead> <tbody> 提示回答过长后面部分删除了 |
PHP常用技术与ThinkPHP5框架开发
- 参与学习 人
- 提交作业 225 份
- 解答问题 3372 个
掌握用PHP开发互联网网站的必备功能,掌握当下主流的Linux系统开发,并熟练使用热门框架ThinkPhp开发电商团购项目,是通向PHP工程师必经之路。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧