├── _dir
├── data
│ └── .gitkeep
├── static
│ ├── images
│ │ ├── logo.png
│ │ └── music.png
│ ├── css
│ │ ├── editor.css
│ │ └── style.css
│ └── js
│ │ ├── clipBoard.min.js
│ │ ├── admin.js
│ │ └── main.js
├── page
│ ├── audio.php
│ ├── video.php
│ ├── footer.php
│ ├── text.php
│ ├── markdown.php
│ ├── login.php
│ ├── header.php
│ ├── editor.php
│ ├── editor2.php
│ ├── upload.php
│ ├── admin.php
│ └── home.php
├── inc.php
├── Cache.class.php
├── functions.php
├── FileMgr.class.php
├── DirList.class.php
└── Parsedown.class.php
├── README.md
└── index.php
/_dir/data/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/_dir/static/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netcccyun/dirlist/HEAD/_dir/static/images/logo.png
--------------------------------------------------------------------------------
/_dir/static/images/music.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/netcccyun/dirlist/HEAD/_dir/static/images/music.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 彩虹目录列表
2 |
3 | 彩虹目录列表是一款用PHP开发的目录列表程序,无需数据库,安装简单,使用方便。
4 |
5 | ### 功能特点
6 |
7 | - 在线预览图片、视频、音频、文本文件、Markdown文件、Office文档等
8 | - 自动识别目录下的README.md文件并展示(类GitHub)
9 | - 后台管理可设置网站标题、公告、底部代码等信息
10 | - 文件搜索功能,支持缓存文件索引
11 | - 自带全新的文件管理功能
12 | - 支持中文文件名编码设置,解决乱码问题
13 | - 支持安装在子目录
14 |
15 | ### 演示地址
16 | - http://file.cccyun.cc/
17 |
18 | ### 部署方法
19 |
20 | - 上传后直接访问即可使用,后台默认管理员账号密码:admin/123456
21 |
22 | ### 官方网站
23 |
24 | - https://blog.cccyun.cn/
25 |
--------------------------------------------------------------------------------
/_dir/static/css/editor.css:
--------------------------------------------------------------------------------
1 | #file_content {
2 | border-top: 1px solid #c9c6c6;
3 | border-bottom: 1px solid #c9c6c6;
4 | height:500px;
5 | width:100%;
6 | }
7 | .input_button {
8 | line-height: 16px;
9 | padding: 4px 10px;
10 | border-radius: 5px;
11 | background: #f3f3f3;
12 | background-image: linear-gradient(-189deg, #ffffff 49%,#eeeeee 81%);
13 | border: 1px solid #b6b6b6;
14 | cursor: pointer;
15 | margin-right: 2px;
16 | color: #202020;
17 | font-size: 12px;
18 | }
19 | .input_button:hover {
20 | background-image: linear-gradient(-217deg, #ffffff 49%,#eeeeee 81%);
21 | }
22 | .input_primary {
23 | background: #99AFDA;
24 | background-image: linear-gradient(154deg, #99AFDA 62%, #7592c9 107%);
25 | color: #f3f3f3;
26 | border: 1px solid #878D96;
27 | font-weight: bold;
28 | line-height: 23px;
29 | font-size: 14px;
30 | padding: 4px 26px;
31 | }
32 | .input_primary:hover {
33 | background-image: linear-gradient(35deg, #99AFDA -45%, #819ccf 100%);
34 | background-color: #a5b9df;
35 | }
--------------------------------------------------------------------------------
/_dir/page/audio.php:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | 音频播放器
10 |
11 |
12 |
13 |
14 |
15 |
16 |
28 |
29 |
--------------------------------------------------------------------------------
/_dir/page/video.php:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | 视频播放器
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
30 |
31 |
--------------------------------------------------------------------------------
/_dir/page/footer.php:
--------------------------------------------------------------------------------
1 |
4 |
5 |
8 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/_dir/page/text.php:
--------------------------------------------------------------------------------
1 | get_view_type($ext);
5 | if($view_type!='text') sysmsg('不支持的文件格式');
6 |
7 | if(filesize($path) > 1024 * 1024 * 10) sysmsg('文件超过10M无法查看');
8 |
9 | $content = file_get_contents($path);
10 | if($content===false) sysmsg('文件读取失败');
11 |
12 | $coding = mb_detect_encoding($content,"UTF-8,GBK,GB2312");
13 | if($coding != 'UTF-8'){
14 | $content = mb_convert_encoding($content, 'UTF-8', $coding);
15 | }
16 |
17 | $content = htmlspecialchars($content);
18 |
19 | header('Content-Type: text/html; charset=UTF-8');
20 | ?>
21 |
22 |
23 |
24 | 文本查看器
25 |
26 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/_dir/inc.php:
--------------------------------------------------------------------------------
1 | get('config');
18 | if(!$conf){
19 | if(!$CACHE->set('config', ['admin_username'=>'admin','admin_password'=>md5('123456'),'title'=>'彩虹目录列表', 'keywords'=>'彩虹目录列表,Directory Lister目录列表,目录索引','description'=>'彩虹目录列表程序','announce'=>'','footer'=>'', 'name_encode'=>'utf8', 'file_hash'=>'1', 'cache_indexes'=>'0', 'footer_bar'=>'1', 'readme_md'=>'1', 'auth'=>'0', 'nav'=>'音乐搜索*http://music.hi.cn/|图片压缩*https://tinypng.com/|今日热榜*https://tophub.today/'])){
20 | sysmsg('配置项初始化失败,可能无文件写入权限');
21 | }
22 | $conf = $CACHE->get('config');
23 | }
24 |
25 | $scriptpath=str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
26 | $sitepath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
27 | $siteurl = (is_https() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$sitepath.'/';
28 |
29 | $cdnpublic = 'https://s4.zstatic.net/ajax/libs/';
30 |
31 | if(isset($_COOKIE["admin_session"]))
32 | {
33 | if($conf['admin_session']===$_COOKIE["admin_session"]) {
34 | $islogin=1;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/_dir/page/markdown.php:
--------------------------------------------------------------------------------
1 | get_view_type($ext);
5 | if($view_type!='markdown') sysmsg('不支持的文件格式');
6 |
7 | if(filesize($path) > 1024 * 1024 * 10) sysmsg('文件超过10M无法查看');
8 |
9 | $content = file_get_contents($path);
10 | if($content===false) sysmsg('文件读取失败');
11 |
12 | require SYSTEM_ROOT.'Parsedown.class.php';
13 | $Parsedown = new Parsedown();
14 | $content = $Parsedown->text($content);
15 | $content = str_replace('[x]','',$content);
16 | $content = str_replace('[ ]','',$content);
17 |
18 | header('Content-Type: text/html; charset=UTF-8');
19 | ?>
20 |
21 |
22 |
23 |
24 | MDtoHTML
25 |
26 |
27 |
43 |
44 |
45 |
54 |
55 |
--------------------------------------------------------------------------------
/_dir/static/js/clipBoard.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * clipboard.js
3 | * width clipboard.js, you can copy cut and paste clipboard data
4 | * the main methods ard execCommand for modern browser and clipboardData for ie
5 | * @author ganzw@gmail.com
6 | * @url https://github.com/baixuexiyang/clipBoard.js
7 | */
8 | !function(t,e){"undefined"!=typeof module&&module.exports?module.exports=e():"function"==typeof define&&define.amd?define(e):this[t]=e()}("clipBoard",function(){"use strict";function t(t,e){this.options=e||{},this.tar=t[0]||t,this.options.copy&&this.copyd(),this.options.cut&&this.cut(),this.options.paste&&this.paste()}return t.prototype.copyd=function(t){if(this.options.beforeCopy&&this.options.beforeCopy(),t=t||this.tar.value||this.tar.innerText,this.options.copy&&(t=this.options.copy()),document.execCommand){var e=document.createElement("SPAN");if(e.textContent=t,document.body.appendChild(e),document.selection){var o=document.body.createTextRange();o.moveToElementText(e),o.select()}else if(window.getSelection){var o=document.createRange();o.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(o)}document.execCommand("copy"),e.remove?e.remove():e.removeNode(!0)}window.clipboardData&&window.clipboardData.setData("text",t),this.options.afterCopy&&this.options.afterCopy()},t.prototype.cut=function(){if("text"===this.tar.type||"textarea"===this.tar.type){if(this.options.beforeCut&&this.options.beforeCut(),document.execCommand){var t=this.tar;if(document.selection){var e=document.body.createTextRange();e.moveToElementText(t),e.select()}else window.getSelection&&t.select();document.execCommand("cut")}window.clipboardData&&(window.clipboardData.setData("text",this.tar.value),this.tar.value=""),this.options.afterCut&&this.options.afterCut()}},t.prototype.paste=function(){if("text"===this.tar.type||"textarea"===this.tar.type){if(this.options.beforePaste&&this.options.beforePaste(),document.execCommand){var t=this.tar;if(t.setSelectionRange)t.focus(),t.setSelectionRange(t.value.length,t.value.length);else if(t.createTextRange){var e=t.createTextRange();e.collapse(!0),e.moveEnd("character",t.value.length),e.moveStart("character",t.value.length),e.select()}document.execCommand("paste")}!document.execCommand&&window.clipboardData&&(this.tar.value+=window.clipboardData.getData("text")),this.options.afterPaste&&this.options.afterPaste()}},t});
9 |
--------------------------------------------------------------------------------
/_dir/Cache.class.php:
--------------------------------------------------------------------------------
1 | getCacheKey($name);
14 |
15 | if (!is_file($filename)) return;
16 |
17 | $content = @file_get_contents($filename);
18 | if (false === $content) return;
19 |
20 | $expire = (int) substr($content, 8, 12);
21 | if (0 != $expire && time() - $expire > filemtime($filename)) {
22 | //缓存过期删除缓存文件
23 | $this->unlink($filename);
24 | return;
25 | }
26 |
27 | $content = substr($content, 32);
28 |
29 | return is_string($content) ? $content : null;
30 | }
31 |
32 | public function has($name){
33 | return $this->getRaw($name) !== null;
34 | }
35 |
36 | public function get($name, $default = null){
37 | $raw = $this->getRaw($name);
38 |
39 | if (is_null($raw)){
40 | return $default;
41 | } elseif (is_numeric($raw)) {
42 | return $raw;
43 | } else {
44 | return unserialize($raw);
45 | }
46 | }
47 |
48 | public function set($name, $value, $expire = null){
49 | if (is_null($expire)) $expire = self::Expire;
50 |
51 | $filename = $this->getCacheKey($name);
52 |
53 | if (is_numeric($value)) {
54 | $data = (string) $value;
55 | } else {
56 | $data = serialize($value);
57 | }
58 |
59 | $data = "\n" . $data;
60 | $result = file_put_contents($filename, $data);
61 |
62 | if ($result) {
63 | clearstatcache();
64 | return true;
65 | }
66 |
67 | return false;
68 | }
69 |
70 | public function delete($name){
71 | $filename = $this->getCacheKey($name);
72 | $this->unlink($filename);
73 | return true;
74 | }
75 |
76 | private function unlink($path)
77 | {
78 | try {
79 | return is_file($path) && unlink($path);
80 | } catch (\Exception $e) {
81 | return false;
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/_dir/page/login.php:
--------------------------------------------------------------------------------
1 | -1, 'msg'=>'用户名或密码不能为空']);
11 | }
12 | if($username === $conf['admin_username'] && md5($password) === $conf['admin_password']){
13 | $conf['admin_session'] = getSid();
14 | $conf['admin_lastlogin'] = date('Y-m-d H:i:s');
15 | if($CACHE->set('config', $conf)){
16 | setcookie("admin_session", $conf['admin_session'], time() + 2592000);
17 | echo_json(['code'=>0]);
18 | }else{
19 | echo_json(['code'=>-1, 'msg'=>'登录失败,可能无文件写入权限']);
20 | }
21 | }else{
22 | echo_json(['code'=>-1, 'msg'=>'用户名或密码错误']);
23 | }
24 | }
25 |
26 | header('Content-Type: text/html; charset=UTF-8');
27 |
28 | if($islogin) exit("");
29 |
30 | include PAGE_ROOT.'header.php';
31 | ?>
32 |
33 |
34 |
67 |
68 |
69 |
70 |