diff --git a/function/common.php b/function/common.php index 973b410..35b7672 100644 --- a/function/common.php +++ b/function/common.php @@ -614,7 +614,20 @@ function main($path) } else return output(json_encode($exts['img']),400); } else return output('',401); } + $files = list_files($path); + //echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT); + if (isset($_GET['random'])&&$_GET['random']!=='') { + if ($_SERVER['ishidden']<4) { + $tmp = []; + foreach (array_keys($files['children']) as $filename) { + if (strtolower(splitlast($filename,'.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['children'][$filename]['@microsoft.graph.downloadUrl']; + } + $tmp = array_values($tmp); + if (count($tmp)>0) return output('', 302, [ 'Location' => $tmp[rand(0,count($tmp)-1)] ]); + else return output('',404); + } else return output('',401); + } if (isset($files['file']) && !$_GET['preview']) { // is file && not preview mode if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]); @@ -927,6 +940,13 @@ function fetch_files($path = '/') $files=fetch_files_children($files, $path1, $page); } else { // files num < 200 , then cache + if (isset($files['children'])) { + $tmp = []; + foreach ($files['children'] as $file) { + $tmp[$file['name']] = $file; + } + $files['children'] = $tmp; + } savecache('path_' . $path, $files); } } @@ -938,6 +958,7 @@ function fetch_files($path = '/') $files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true); } } + return $files; } diff --git a/readme.md b/readme.md index 6de9882..689958b 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ -QQ Group: 943919989 -Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw +Install program first, then add onedrive in setup after login. +先安装程序,登录后在设置中添加onedrive。 # Deploy to heroku Official: https://heroku.com @@ -20,13 +20,14 @@ How to Install: 让代码中的config.php文件程序可读写,推荐chmod 666 config.php。 5.View the website in chrome or other. 在浏览器中访问。 - 6.Follow the guide, bind your onedrive. - 根据引导,绑定你的OneDrive。 # Deploy to SCF Official: https://cloud.tencent.com/product/scf -How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview +~~How to Install: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/%E6%97%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%87%BD%E6%95%B0SCF%E6%90%AD%E5%BB%BAOneDrive.mp4?preview~~ + +先在环境变量添加Region,ap-hongkong或ap-guangzhou之类,再安装。 +添加网盘时,SCF反应不过来,会添加失败,请不要删除,再添加一次相同的就可以了。 DEMO: https://service-pgxgvop2-1258064400.ap-hongkong.apigateway.myqcloud.com/test/abcdef/ @@ -39,7 +40,7 @@ The XXX_path in setting is the path in Onedrive, not in url, program will find t 设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。 LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited. 网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。 -Program will show content of 'readme.md' under file list. +Program will show content of 'readme.md' & 'head.md'. 可以在文件列表下面显示readme.md文件的内容。 guest up path, is a folder that the guest can upload files, but can not be list (exclude admin). 游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。 @@ -48,3 +49,5 @@ If there is 'index.html' file, program will only show the content of 'index.html Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort. 点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。 +QQ Group: 943919989 +Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw