├── .gitignore ├── README.md ├── cache └── abc ├── config └── README.md ├── controller ├── AdminController.php ├── CommonController.php ├── ImagesController.php ├── IndexController.php └── UploadController.php ├── demo └── demo.png ├── index.php ├── init.php ├── lib ├── Parsedown.php ├── cache.php ├── cache │ ├── filecache_.php │ ├── memcache_.php │ ├── redis_.php │ └── secache_.php ├── fetch.php ├── onedrive.php ├── oneindex.php ├── route.php ├── sqlite.php └── view.php ├── one.php ├── statics ├── common │ ├── offline │ │ ├── css │ │ │ ├── bootstrap-responsive.min.css │ │ │ ├── bootstrap.min.css │ │ │ └── main.css │ │ └── js │ │ │ ├── aria2.js │ │ │ ├── bootstrap.min.js │ │ │ ├── jquery-1.7.2.min.js │ │ │ ├── jquery.Storage.js │ │ │ ├── jquery.base64.min.js │ │ │ ├── jquery.jsonrpc.js │ │ │ ├── mustache.js │ │ │ ├── peerid.js │ │ │ └── yaaw-1.1.js │ └── search │ │ └── js │ │ └── search.js └── themes │ └── nexmoe │ ├── IMG │ └── OneIndexM.svg │ ├── css │ └── forkGh.css │ └── js │ ├── Meting.min.js │ ├── mdui.min.js │ ├── nexmoe.js │ └── personjs.js ├── view ├── admin │ ├── cache.php │ ├── images.php │ ├── install │ │ ├── install_0.php │ │ ├── install_1.php │ │ ├── install_2.php │ │ ├── install_3.php │ │ └── layout.php │ ├── layout.php │ ├── login.php │ ├── offline.php │ ├── setpass.php │ ├── settings.php │ ├── show.php │ └── upload.php ├── common │ ├── offline.php │ ├── search.php │ └── tips.php └── themes │ ├── classic │ ├── 404.php │ ├── layout.php │ └── list.php │ ├── material │ ├── 404.php │ ├── images │ │ ├── index.php │ │ └── layout.php │ ├── layout.php │ ├── list.php │ ├── password.php │ └── show │ │ ├── audio.php │ │ ├── code.php │ │ ├── doc.php │ │ ├── image.php │ │ ├── pdf.php │ │ ├── stream.php │ │ ├── video.php │ │ ├── video2.php │ │ └── video5.php │ └── nexmoe │ ├── 404.php │ ├── images │ ├── index.php │ └── layout.php │ ├── layout.php │ ├── list.php │ ├── password.php │ ├── readme.html │ └── show │ ├── audio.php │ ├── code.php │ ├── doc.php │ ├── image.php │ ├── pdf.php │ ├── stream.php │ ├── video.php │ ├── video2.php │ └── video5.php └── 使用及免责协议.md /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 简介 2 | 3 | 本项目是基于: 4 | 5 | - Oneindex 6 | 7 | - OneindexN项目地址:https://github.com/xieqifei/OneindexN 8 | 9 | 详细安装教程: 10 | - [基于Onedrive和Server搭建下载站/网盘](https://www.mintimate.cn/2020/09/22/oneindex) 11 | 12 | 教程视频: 13 | - [8分钟利用OneDrive搭建不限速的OneIndex分享网盘](https://www.bilibili.com/video/BV1ph41197aa) 14 | 15 | 16 | 打赏 17 | - 爱发电:[Mintimate的电圈](https://www.afdian.net/@mintimate/plan) 18 | 19 | ![](https://cdn.jsdelivr.net/gh/Mintimate/OneindexM/demo/demo.png) 20 | 21 | ### 特别注意 22 | OneindexM的默认密码为:**MintimateBlog** 23 | 24 | ## 修改功能: 25 | 26 | ### 后台: 27 | 28 | - 选择安装世纪互联/国际版(如需修改版本,需要删除config文件夹里的文件后重新进入安装程序) 29 | - 指定文件夹/全部文件夹,关闭Readme.md、index.html、head.md渲染(如果开启游客离线上传,可以关闭此路径的渲染,避免游客上传会被渲染的文件。) 30 | 31 | ### 前台 32 | 33 | 以下功能仅支持nexmoe主题 34 | - 搜索功能:全局搜索/当前页过滤 35 | - 文件操作:删除/新建/重命名/剪切/复制/分享等。仅管理员可用 36 | - 文件上传:4M以下的文件在线上传。url远程上传,仅onedrive个人版支持。aria2离线上传,需自行安装在vps上安装aria2并完成相关配置。 37 | - 外部视频播放器播放接口。需要安装对应播放器。 38 | - 管理员登陆后,查看加密文件夹无需密码。 39 | 40 | ## 更新日志 41 | - 2021.12.03:修复PHP7.x查询函数警告问题;修复文件过滤、查询出错问题;修复排序不可用问题;移除Jq、Bootstrap;调整部分UI 42 | - 2021.08.03:修复Cookies循环问题、修复世纪互联版本部分情况不可用问题。 43 | - 2021.07.01:修复因为Onedrive接口更换,而导致的无法部署。 44 | - 2021.06.25:更换重写URL服务器。 45 | 46 | ## 部署网站 47 | 48 | 网站环境尽量使用Nginx或Apache,配合PHP5.7+版本。 49 | 50 | 建议参考文章: 51 | ![基于Onedrive和Server搭建下载站/网盘](https://www.mintimate.cn/2020/09/22/oneindex) 52 | 53 |
54 | 55 | **以下是上游Readme.md内容** 56 | 57 | ## 功能 58 | 59 | 不占用服务器空间,不走服务器流量, 60 | 61 | 直接列出 OneDrive 目录,文件直链下载。 62 | 63 | ## 使用及免责协议 64 | 65 | [使用及免责协议](./使用及免责协议.md) 66 | 67 | ## 安装运行 68 | 69 | ### 需求: 70 | 71 | 1、PHP空间,PHP 5.6+ 需打开curl支持 72 | 2、OneDrive 账号 (个人、企业版或教育版/工作或学校帐户) 73 | 3、OneIndex 程序 74 | 75 | ### 计划任务   76 | 77 | [可选]**推荐配置**,非必需。后台定时刷新缓存,可增加前台访问的速度。 78 | 79 | ``` 80 | # 每小时刷新一次token 81 | 0 * * * * /具体路径/php /程序具体路径/one.php token:refresh 82 | 83 | # 每十分钟后台刷新一遍缓存 84 | */10 * * * * /具体路径/php /程序具体路径/one.php cache:refresh 85 | ``` 86 | 87 | ### Docker 安装运行 88 | 89 | - 请参考[TimeBye/oneindex](https://github.com/TimeBye/oneindex) 90 | 91 | ## 特殊文件实现功能   92 | 93 | ` README.md `、`HEAD.md` 、 `.password`特殊文件使用 94 | 95 | 可以参考[https://github.com/donwa/oneindex/tree/files](https://github.com/donwa/oneindex/tree/files) 96 | 97 | **在文件夹底部添加说明:**   98 | 99 | >在 OneDrive 的文件夹中添加` README.md `文件,使用 Markdown 语法。 100 | 101 | **在文件夹头部添加说明:**   102 | 103 | >在 OneDrive 的文件夹中添加`HEAD.md` 文件,使用 Markdown 语法。 104 | 105 | **加密文件夹:**   106 | 107 | >在 OneDrive 的文件夹中添加`.password`文件,填入密码,密码不能为空。   108 | 109 | **直接输出网页:** 110 | 111 | >在 OneDrive 的文件夹中添加`index.html` 文件,程序会直接输出网页而不列目录。 112 | >配合 文件展示设置-直接输出 效果更佳。 113 | 114 | ## 命令行功能   115 | 116 | 仅能在PHP CLI模式下运行 117 | 118 | **清除缓存:**   119 | 120 | ``` 121 | php one.php cache:clear 122 | ``` 123 | 124 | **刷新缓存:**   125 | 126 | ``` 127 | php one.php cache:refresh 128 | ``` 129 | 130 | **刷新令牌:**   131 | 132 | ``` 133 | php one.php token:refresh 134 | ``` 135 | 136 | **上传文件:**   137 | 138 | ``` 139 | php one.php upload:file 本地文件 [OneDrive文件] 140 | ``` 141 | 142 | **上传文件夹:** 143 | 144 | ``` 145 | php one.php upload:folder 本地文件夹 [OneDrive文件夹] 146 | ``` 147 | 148 | 例如: 149 | 150 | ``` 151 | //上传demo.zip 到OneDrive 根目录 152 | php one.php upload:file demo.zip 153 | 154 | //上传demo.zip 到OneDrive /test/目录 155 | php one.php upload:file demo.zip /test/ 156 | 157 | //上传demo.zip 到OneDrive /test/目录并将其命名为 d.zip 158 | php one.php upload:file demo.zip /test/d.zip 159 | 160 | //上传up/ 到OneDrive /test/ 目录 161 | php one.php upload:file up/ /test/ 162 | ``` 163 | 164 | ## 使用Aria2 165 | 166 | Nginx添加反向代理 167 | 168 | ``` 169 | location /jsonrpc { 170 | proxy_pass http://localhost:6800/jsonrpc; 171 | proxy_redirect off; 172 | proxy_set_header X-Real-IP $remote_addr; 173 | proxy_set_header X-Forwarded-For 174 | $proxy_add_x_forwarded_for; 175 | proxy_set_header Host $host; 176 | } 177 | ``` 178 | 179 | nginx会监听发送给`http://yoursite/jsonrpc`的消息,然后将他转发给`http:localhost:6800/jsonrpc`,相当于你在yaaw中设置rpc时,只需要将其设置为`http://yoursite/jsonrpc`或者`https://yoursite/jsonrpc`,省略的端口信息为http对应80,https对应443,这些端口浏览器会自动转发,不用在设置中指定。如果你设置了反向代理,那么使用前台yaaw时,就不用在做rpc设置了。否则你需要去重新设置。 180 | 181 | ![](https://i.loli.net/2020/06/25/9cY2PiBr6usqXen.png) 182 | 183 | **关闭aria2远程RPC** 184 | 185 | 仅vps本地也就是nginx转发的请求能到达6800。其他主机不能访问6800端口。 186 | 187 | ```shell 188 | vim /root/.aria2c/aria2.conf 189 | ``` 190 | 191 | 修改aria2配置内容 192 | 193 | ``` 194 | # 启用RPC, 默认:false 195 | enable-rpc=true 196 | # 接受所有远程请求, 默认:false 197 | rpc-allow-origin-all=false 198 | # 允许外部访问, 默认:false 199 | rpc-listen-all=false 200 | # RPC监听端口, 端口被占用时可以修改, 默认:6800 201 | rpc-listen-port=6800 202 | ``` 203 | 204 | > 请注意,关闭远程请求并不能阻止其他主机向aria2发送请求,在不设置token时,任何人都可以通过直接向`http://yoursite/jsonrpc`这个地址发送请求连接aria2。如果你开启游客离线下载可以这么设置。如果你不希望有人通过其他aria2前端连接你的aria2,请你务必设置token,但是这样做,你也必须在使用的时候修改rpc设置,好在,第一次修改设置后,之后浏览器都会记住这个设置。 205 | 206 | > 博客:https://sci.ci 207 | > 208 | > 如果应用有bug,或者你有好的修改建议,可以通过邮箱联系我:im@xieqifei.com 209 | 210 | ## 参考资料 211 | 212 | 《[github YAAW项目](https://github.com/binux/yaaw)》 213 | 214 | 《[Issue:一旦使用HTTPS协议就无法连接](https://github.com/mayswind/AriaNg/issues/62)》 215 | 216 | 《[Nginx 反向代理 Aria2 JSONRPC](https://kenvix.com/post/nginx-proxy-aria2/)》 217 | -------------------------------------------------------------------------------- /cache/abc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /config/README.md: -------------------------------------------------------------------------------- 1 | # oneindex 2 | OneDrive Directory Index 3 | -------------------------------------------------------------------------------- /controller/AdminController.php: -------------------------------------------------------------------------------- 1 | 'OneIndex', 6 | 'site_name_small' =>'', 7 | 'password' => 'MintimateBlog', 8 | 'style'=>'nexmoe', 9 | 'onedrive_root' =>'', 10 | 'except_path' =>'', 11 | 'cache_type'=>'secache', 12 | 'cache_expire_time' => 10, 13 | 'cache_refresh_time' => 600, 14 | 'root_path' => '?', 15 | 'show'=> array ( 16 | 'stream'=>['txt'], 17 | 'image' => ['bmp','jpg','jpeg','png','gif'], 18 | 'video5'=>['mp4','webm','mkv'], 19 | 'video'=>[], 20 | 'video2'=>['avi','mpg', 'mpeg', 'rm', 'rmvb', 'mov', 'wmv', 'asf', 'ts', 'flv'], 21 | 'audio'=>['ogg','mp3','wav'], 22 | 'code'=>['html','htm','php', 'css', 'go','java','js','json','txt','sh','md'], 23 | 'doc'=>['csv','doc','docx','odp','ods','odt','pot','potm','potx','pps','ppsx','ppsxm','ppt','pptm','pptx','rtf','xls','xlsx'] 24 | ), 25 | 'images'=>['home'=>false,'public'=>false, 'exts'=>['jpg','png','gif','bmp']], 26 | 'offline'=>array( 27 | 'offline'=>false, 28 | 'online'=>false, 29 | 'upload_path'=>'/upload/' 30 | ) 31 | ); 32 | 33 | function __construct(){ 34 | } 35 | 36 | function login(){ 37 | if(!empty($_POST['password']) && $_POST['password'] == config('password')){ 38 | setcookie('admin', md5(config('password').config('refresh_token')) ); 39 | return view::direct(get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).'?/admin/'); 40 | } 41 | return view::load('login')->with('title', '系统管理'); 42 | } 43 | 44 | function logout(){ 45 | setcookie('admin', '' ); 46 | return view::direct(get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).'?/login'); 47 | } 48 | 49 | function settings(){ 50 | $message = false; 51 | 52 | if($_POST){ 53 | 54 | if ($this->cache_exists($_POST['cache_type'])) { 55 | $message = '保存成功'; 56 | config('cache_type', $_POST['cache_type']); 57 | } else { 58 | $message = '缓存类型不可用,请确认已经安装了该拓展。'; 59 | config('cache_type', 'secache'); 60 | } 61 | //判断不渲染目录是否为全部不渲染 62 | if($_POST['except_path']){ 63 | $except_path=(strcmp($_POST['except_path'],'all')==0?'all':get_absolute_path($_POST['except_path'])); 64 | }else{ 65 | $except_path=''; 66 | } 67 | config('site_name', $_POST['site_name']); 68 | config('style', $_POST['style']); 69 | config('onedrive_root', get_absolute_path($_POST['onedrive_root'])); 70 | config('except_path',$except_path); 71 | config('onedrive_hide', $_POST['onedrive_hide']); 72 | config('onedrive_hotlink', $_POST['onedrive_hotlink']); 73 | config('cache_expire_time', intval($_POST['cache_expire_time'])); 74 | $_POST['root_path'] = empty($_POST['root_path'])?'?':''; 75 | config('root_path', $_POST['root_path']); 76 | } 77 | 78 | $config = config('@base'); 79 | 80 | return view::load('settings')->with('config', $config)->with('message', $message); 81 | } 82 | 83 | function offline(){ 84 | if($_POST){ 85 | $config['offline'] = empty($_POST['offline'])?false:true; 86 | $config['online'] = empty($_POST['online'])?false:true; 87 | $config['upload_path'] = empty($_POST['upload_path']) ? '/' : get_absolute_path($_POST['upload_path']); 88 | config('offline@base',$config); 89 | } 90 | $config = config('offline@base'); 91 | return view::load('offline')->with('config',$config); 92 | } 93 | 94 | /** 95 | * 判断缓存类型 96 | * 97 | * @param string $cache_type 缓存类型 98 | * @return void 99 | */ 100 | function cache_exists($cache_type){ 101 | // 需要判断环境的缓存类型 102 | $_cache_type = [ 103 | 'redis', 104 | 'memcache', 105 | ]; 106 | 107 | if (in_array($cache_type, $_cache_type)) { 108 | return class_exists(ucfirst($cache_type)); 109 | } 110 | 111 | return true; 112 | } 113 | 114 | function cache(){ 115 | if(!is_null($_POST['clear'])){ 116 | cache::clear(); 117 | $message = "清除缓存成功"; 118 | }elseif ( !is_null($_POST['refresh']) ){ 119 | oneindex::refresh_cache(get_absolute_path(config('onedrive_root'))); 120 | $message = "重建缓存成功"; 121 | } 122 | return view::load('cache')->with('message', $message); 123 | } 124 | 125 | function images(){ 126 | if($_POST){ 127 | $config['home'] = empty($_POST['home'])?false:true; 128 | $config['public'] = empty($_POST['public'])?false:true; 129 | $config['exts'] = explode(" ", $_POST['exts']); 130 | config('images@base',$config); 131 | } 132 | $config = config('images@base'); 133 | return view::load('images')->with('config', $config);; 134 | } 135 | 136 | 137 | function show(){ 138 | if(!empty($_POST) ){ 139 | foreach($_POST as $n=>$ext){ 140 | $show[$n] = explode(' ', $ext); 141 | } 142 | config('show', $show); 143 | } 144 | $names = [ 145 | 'stream'=>'直接输出(<5M),走本服务器流量(stream)', 146 | 'image' =>'图片(image)', 147 | 'video'=>'Dplayer 视频(video)', 148 | 'video2'=>'Dplayer DASH 视频(video2)/个人版账户不支持', 149 | 'video5'=>'html5视频(video5)', 150 | 'audio'=>'音频播放(audio)', 151 | 'code'=>'文本/代码(code)', 152 | 'doc'=>'文档(doc)' 153 | ]; 154 | $show = config('show'); 155 | return view::load('show')->with('names', $names)->with('show', $show); 156 | } 157 | 158 | function setpass(){ 159 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ 160 | if($_POST['old_pass'] == config('password')){ 161 | if($_POST['password'] == $_POST['password2']){ 162 | config('password', $_POST['password']); 163 | $message = "修改成功"; 164 | }else{ 165 | $message = "两次密码不一致,修改失败"; 166 | } 167 | }else{ 168 | $message = "原密码错误,修改失败"; 169 | } 170 | } 171 | return view::load('setpass')->with('message', $message); 172 | } 173 | 174 | function install(){ 175 | if(!empty($_GET['code'])){ 176 | return $this->install_3(); 177 | } 178 | switch ( intval($_GET['step']) ){ 179 | case 1: 180 | return $this->install_1(); 181 | case 2: 182 | return $this->install_2(); 183 | default: 184 | return $this->install_0(); 185 | } 186 | } 187 | 188 | function install_0(){ 189 | $check['php'] = version_compare(PHP_VERSION,'5.5.0','ge'); 190 | $check['curl'] = function_exists('curl_init'); 191 | $check['config'] = is_writable(ROOT.'config/'); 192 | $check['cache'] = is_writable(ROOT.'cache/'); 193 | 194 | return view::load('install/install_0')->with('title','系统安装') 195 | ->with('check', $check); 196 | } 197 | 198 | function install_1(){ 199 | if(!empty($_POST['client_secret']) && !empty($_POST['client_id']) && !empty($_POST['redirect_uri']) && !empty($_POST['area'])){ 200 | config('@base', self::$default_config); 201 | config('client_secret',$_POST['client_secret']); 202 | config('client_id',$_POST['client_id']); 203 | config('redirect_uri',$_POST['redirect_uri']); 204 | config('area',$_POST['area']); 205 | return view::direct('?step=2'); 206 | } 207 | if($_SERVER['HTTP_HOST'] == 'localhost'){ 208 | $redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].get_absolute_path(dirname($_SERVER['PHP_SELF'])); 209 | }else{ 210 | // 非https,调用ju.tn中转 211 | $redirect_uri = 'https://tool.mintimate.cn/oneindexM/'; 212 | } 213 | 214 | $ru = "https://developer.microsoft.com/en-us/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl={$redirect_uri}&platform=option-php"; 215 | $deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=oneindex&redirectUrl={$redirect_uri}&allowImplicitFlow=false&ru=".urlencode($ru); 216 | $app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink); 217 | return view::load('install/install_1')->with('title','系统安装') 218 | ->with('redirect_uri', $redirect_uri) 219 | ->with('app_url', $app_url); 220 | } 221 | 222 | function install_2(){ 223 | return view::load('install/install_2')->with('title','系统安装'); 224 | } 225 | 226 | function install_3(){ 227 | $data = onedrive::authorize($_GET['code']); 228 | if(!empty($data['refresh_token'])){ 229 | config('refresh_token',$data['refresh_token']); 230 | config('@token', $data); 231 | } 232 | return view::load('install/install_3')->with('refresh_token',$data['refresh_token']); 233 | 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /controller/CommonController.php: -------------------------------------------------------------------------------- 1 | with('tip','管理员未授权使用'); 14 | } 15 | } 16 | 17 | //搜索 18 | function search(){ 19 | if(is_login()){ 20 | if($_POST['keyword']){ 21 | $keyword=$_POST['keyword']; 22 | $items = onedrive::search($keyword); 23 | if(!$items){ 24 | return view::load('common/tips')->with('tip','没有找到与“'.$_POST['keyword'].'”有关的内容'); 25 | } 26 | $searchinfo['keyword']=$keyword; 27 | $searchinfo['count']=count($items); 28 | return view::load('common/search')->with('items',$items)->with('searchinfo',$searchinfo); 29 | }else{ 30 | return '参数错误'; 31 | } 32 | } 33 | else{ 34 | return '请登陆后尝试'; 35 | } 36 | } 37 | //新建文件夹 38 | //post参数:uploadurl,当前url的路径 39 | function create_folder(){ 40 | if(is_login()){ 41 | $urlinfo=parse_url($_POST['uploadurl']); 42 | if(stristr($_POST['uploadurl'],'?')){ 43 | $paths = explode('/', rawurldecode($urlinfo['query'])); 44 | }else{ 45 | $paths = explode('/', rawurldecode($urlinfo['path'])); 46 | } 47 | $paths=array_values($paths); 48 | $remotepath = get_absolute_path(join('/', $paths)); 49 | $data = onedrive::create_folder(str_replace('//','/',config('onedrive_root').$remotepath),$_POST['foldername']); 50 | oneindex::refresh_cache(get_absolute_path(config('onedrive_root'))); 51 | return $data; 52 | } 53 | else{ 54 | return '未登录无法新建文件夹'; 55 | } 56 | } 57 | //重命名 58 | //post参数:name:新名称;itemid:itemid 59 | function rename(){ 60 | if(is_login()){ 61 | $newname=$_POST['name']; 62 | $itemid=$_POST['itemid']; 63 | $resp=onedrive::rename($itemid,$newname); 64 | oneindex::refresh_cache(get_absolute_path(config('onedrive_root'))); 65 | return $resp; 66 | } 67 | else{ 68 | return '未登录无法重命名'; 69 | } 70 | } 71 | //删除 72 | //传入一个stringfy后的itemid的数组 73 | function deleteitems(){ 74 | if(is_login()){ 75 | $data = file_get_contents( "php://input" ); 76 | $items = json_decode( $data ); 77 | $resp=onedrive::delete($items); 78 | oneindex::refresh_cache(get_absolute_path(config('onedrive_root'))); 79 | return $resp; 80 | } 81 | else{ 82 | return '未登录无法删除'; 83 | } 84 | } 85 | //url上传 86 | function upload_url(){ 87 | if(is_login()){ 88 | if($_POST['file_url']&&$_POST['path_url']){ 89 | $file_url=$_POST['file_url']; 90 | $path_url=$_POST['path_url']; 91 | if($_POST['file_name']){ 92 | $file_name = $_POST['file_name']; 93 | } 94 | else{ 95 | $file_name = pathinfo(parse_url($file_url,PHP_URL_PATH),PATHINFO_BASENAME); 96 | } 97 | $path = str_replace('//','/',$this->url2path($path_url).'/'.$file_name); 98 | $process_url = onedrive::upload_url($path , $file_url); 99 | if($process_url){ 100 | return $process_url; 101 | } 102 | else{ 103 | return 0; 104 | } 105 | }else{ 106 | return '参数错误'; 107 | } 108 | }else{ 109 | return '未登录'; 110 | } 111 | } 112 | 113 | //在线上传,大小限制在4M 114 | //post参数:onlinefile:一个文件;uploadurl:当前url路径 115 | function onlinefileupload() 116 | { 117 | 118 | if($this->uploadcondition($_FILES["onlinefile"]) ){ 119 | $filename = $_FILES["onlinefile"]['name']; 120 | $content = file_get_contents( $_FILES["onlinefile"]['tmp_name']); 121 | //管理员不受上传目录限制 122 | if(is_login()){ 123 | //获取路径 124 | $paths = explode('/', rawurldecode($_POST['uploadurl'])); 125 | if(strcmp($paths[1],'?')==0){ 126 | array_shift($paths); 127 | array_shift($paths); 128 | } 129 | //$paths=array_shift($paths); 130 | $remotepath = get_absolute_path(join('/', $paths)); 131 | } 132 | //游客只能上传到指定目录 133 | else{ 134 | $remotepath = config('offline')['upload_path']; 135 | } 136 | $remotefile = $remotepath.$filename; 137 | $result = onedrive::upload(str_replace('//','/',config('onedrive_root').$remotefile), $content); 138 | 139 | if($result){ 140 | $root = get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).config('root_path'); 141 | $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; 142 | $url = $_SERVER['HTTP_HOST'].$root.'/'.$remotepath.rawurldecode($filename).((config('root_path') == '?')?'&s':'?s'); 143 | $url = $http_type.str_replace('//','/', $url); 144 | $result['path']=$url; 145 | // view::direct($url); 146 | return json_encode($result); 147 | } 148 | }else{ 149 | return '未登录或文件过大'; 150 | } 151 | 152 | } 153 | //上传文件的条件判断 154 | function uploadcondition($file){ 155 | 156 | if($file['size'] > 4485760 || $file['size'] == 0){ 157 | return false; 158 | } 159 | if(config('offline')['online']==false&&!is_login()){ 160 | return false; 161 | } 162 | 163 | return true; 164 | } 165 | //粘贴 166 | function paste(){ 167 | if(is_login()){ 168 | $data = file_get_contents( "php://input" ); 169 | $jsondata = json_decode($data);//字符串转对象。 170 | if($jsondata->cutitems){ 171 | $cutitems=$jsondata->cutitems; 172 | $url=$jsondata->url; 173 | return $this->cut($cutitems,$url); 174 | } 175 | if($jsondata->copyitems){ 176 | $copyitems=$jsondata->copyitems; 177 | $url=$jsondata->url; 178 | return $this->copy($copyitems,$url); 179 | } 180 | return '操作失误,请重新尝试!'; 181 | } 182 | else{ 183 | return '未登录无法重命名'; 184 | } 185 | } 186 | //移动或剪切 187 | function cut($cutitems,$url){ 188 | $itemid=$this->url2id($url); 189 | $resp=onedrive::move($cutitems,$itemid); 190 | oneindex::refresh_cache(get_absolute_path(config('onedrive_root'))); 191 | return json_encode(json_decode(json_encode($resp)));//decode去掉字符串中的转义字符再 192 | } 193 | //复制 194 | function copy($copyitems,$url){ 195 | $itemid=$this->url2id($url); 196 | $resp=onedrive::copy($copyitems,$itemid); 197 | oneindex::refresh_cache(get_absolute_path(config('onedrive_root'))); 198 | return $resp; 199 | } 200 | //url转路径 201 | function url2path($url){ 202 | $paths=array(); 203 | $urlinfo=parse_url($url); 204 | if(stristr($url,'?')){ 205 | $paths = explode('/', rawurldecode($urlinfo['query'])); 206 | }else{ 207 | $paths = explode('/', rawurldecode($urlinfo['path'])); 208 | } 209 | if(strcmp($paths[1],'?')==0){ 210 | array_shift($paths); 211 | array_shift($paths); 212 | } 213 | $remotepath = get_absolute_path(join('/', $paths)); 214 | $path = str_replace('//','/',config('onedrive_root').$remotepath); 215 | return $path; 216 | } 217 | 218 | //url转id 219 | function url2id($url){ 220 | $urlinfo=parse_url($url); 221 | if(stristr($url,'?')){ 222 | $paths = explode('/', rawurldecode($urlinfo['query'])); 223 | }else{ 224 | $paths = explode('/', rawurldecode($urlinfo['path'])); 225 | } 226 | $paths=array_values($paths); 227 | $totalpath = str_replace('//','/',config('onedrive_root').get_absolute_path(join('/', $paths))); 228 | $itemid=onedrive::path2id($totalpath); 229 | return $itemid; 230 | } 231 | 232 | } 233 | -------------------------------------------------------------------------------- /controller/ImagesController.php: -------------------------------------------------------------------------------- 1 | is_image($_FILES["file"]) ){ 15 | $filename = $_FILES["file"]['name']; 16 | $content = file_get_contents( $_FILES["file"]['tmp_name']); 17 | $remotepath = 'images/'.date('Y/m/d/').$this->generateRandomString(10).'/'; 18 | $remotefile = $remotepath.$filename; 19 | $result = onedrive::upload(config('onedrive_root').$remotefile, $content); 20 | 21 | if($result){ 22 | $root = get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).config('root_path'); 23 | $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; 24 | $url = $_SERVER['HTTP_HOST'].$root.'/'.$remotepath.rawurldecode($filename).((config('root_path') == '?')?'&s':'?s'); 25 | $url = $http_type.str_replace('//','/', $url); 26 | view::direct($url); 27 | } 28 | } 29 | return view::load('images/index'); 30 | } 31 | 32 | function is_image($file){ 33 | $config = config('images@base'); 34 | $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); 35 | if(!in_array($ext,$config['exts'])){ 36 | return false; 37 | } 38 | if($file['size'] > 10485760 || $file['size'] == 0){ 39 | return false; 40 | } 41 | 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /controller/IndexController.php: -------------------------------------------------------------------------------- 1 | name = array_pop($paths); 14 | } 15 | $this->url_path = get_absolute_path(join('/', $paths)); 16 | $this->path = get_absolute_path(config('onedrive_root').$this->url_path); 17 | //获取文件夹下所有元素 18 | $this->items = $this->items($this->path); 19 | } 20 | 21 | 22 | function index(){ 23 | //是否404 24 | $this->is404(); 25 | 26 | $this->is_password(); 27 | 28 | header("Expires:-1"); 29 | header("Cache-Control:no_cache"); 30 | header("Pragma:no-cache"); 31 | 32 | if(!empty($this->name)){//file 33 | return $this->file(); 34 | }else{//dir 35 | return $this->dir(); 36 | } 37 | } 38 | 39 | //判断是否加密 40 | function is_password(){ 41 | if(empty($this->items['.password'])){ 42 | return false; 43 | }else{ 44 | $this->items['.password']['path'] = get_absolute_path($this->path).'.password'; 45 | } 46 | 47 | $password = $this->get_content($this->items['.password']); 48 | list($password) = explode("\n",$password); 49 | $password = trim($password); 50 | unset($this->items['.password']); 51 | if(!empty($password) && strcmp($password, $_COOKIE[md5($this->path)]) === 0||$_COOKIE['admin'] == md5(config('password').config('refresh_token'))){ 52 | return true; 53 | } 54 | 55 | $this->password($password); 56 | 57 | } 58 | 59 | function password($password){ 60 | if(!empty($_POST['password']) && strcmp($password, $_POST['password']) === 0){ 61 | setcookie(md5($this->path), $_POST['password']); 62 | return true; 63 | } 64 | $navs = $this->navs(); 65 | echo view::load('password')->with('navs',$navs); 66 | exit(); 67 | } 68 | 69 | //文件 70 | function file(){ 71 | $item = $this->items[$this->name]; 72 | if ($item['folder']) {//是文件夹 73 | $url = $_SERVER['REQUEST_URI'].'/'; 74 | }elseif(!is_null($_GET['t']) ){//缩略图 75 | $url = $this->thumbnail($item); 76 | }elseif($_SERVER['REQUEST_METHOD'] == 'POST' || !is_null($_GET['s']) ){ 77 | return $this->show($item); 78 | }else{//返回下载链接 79 | $url = $item['downloadUrl']; 80 | } 81 | header('Location: '.$url); 82 | } 83 | 84 | 85 | 86 | //文件夹 87 | function dir(){ 88 | $root = get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).config('root_path'); 89 | $navs = $this->navs(); 90 | //以'/'拆分路径,并重新连接 91 | $except_paths_buffer = explode('/', config('except_path')); 92 | $except_path_buffer = get_absolute_path(join('/', $except_paths_buffer)); 93 | $upload_paths_buffer = explode('/', config('offline')['upload_path']); 94 | $upload_path_buffer = get_absolute_path(join('/', $upload_paths_buffer)); 95 | $online = config('offline')['online']; 96 | //定义变脸,表示是否渲染此目录下的文件 97 | $iscolorbar = true; 98 | //不渲染设置为all,或者当前路径与指定不渲染路径相同,则不渲染。如果设置为空,则渲染 99 | if(strcmp(config('except_path'),'all')==0||strcmp(get_absolute_path($this->path), get_absolute_path(config('onedrive_root').$except_path_buffer))==0){ 100 | $iscolorbar = false; 101 | }else if(empty(config('except_path'))){ 102 | $iscolorbar = true; 103 | } 104 | //指定的游客在线上传路径是否和当前路径一致,相同则不渲染。 105 | if(strcmp(get_absolute_path($this->path),get_absolute_path(config('onedrive_root').$upload_path_buffer))==0){ 106 | $iscolorbar = false; 107 | } 108 | 109 | if($iscolorbar) 110 | { 111 | if($this->items['index.html']){ 112 | $this->items['index.html']['path'] = get_absolute_path($this->path).'index.html'; 113 | $index = $this->get_content($this->items['index.html']); 114 | header('Content-type: text/html'); 115 | echo $index; 116 | exit(); 117 | } 118 | 119 | if($this->items['README.md']){ 120 | $this->items['README.md']['path'] = get_absolute_path($this->path).'README.md'; 121 | $readme = $this->get_content($this->items['README.md']); 122 | $Parsedown = new Parsedown(); 123 | $readme = $Parsedown->text($readme); 124 | //不在列表中展示 125 | unset($this->items['README.md']); 126 | } 127 | 128 | if($this->items['HEAD.md']){ 129 | $this->items['HEAD.md']['path'] = get_absolute_path($this->path).'HEAD.md'; 130 | $head = $this->get_content($this->items['HEAD.md']); 131 | $Parsedown = new Parsedown(); 132 | $head = $Parsedown->text($head); 133 | //不在列表中展示 134 | unset($this->items['HEAD.md']); 135 | } 136 | } 137 | 138 | //在线上传条件,后台开启或者登陆为管理员 139 | if(config('offline')['online']||is_login()){ 140 | $manager['online']=true; 141 | } 142 | else{ 143 | $manager['online']=false; 144 | } 145 | 146 | if(config('offline')['offline']||is_login()){ 147 | $manager['offline']=true; 148 | }else{ 149 | $manager['offline']=false; 150 | } 151 | 152 | if(is_login()){ 153 | $manager['create_folder']=true; 154 | }else{ 155 | $manager['create_folder']=false; 156 | } 157 | return view::load('list')->with('title', empty(str_replace("/","",urldecode($this->url_path)))?"根目录":str_replace("/","",urldecode($this->url_path))) 158 | ->with('navs', $navs) 159 | ->with('path',join("/", array_map("rawurlencode", explode("/", $this->url_path))) ) 160 | ->with('root', $root) 161 | ->with('items', $this->items) 162 | ->with('head',$head) 163 | ->with('readme',$readme) 164 | ->with('manager',$manager); 165 | } 166 | 167 | function show($item){ 168 | $root = get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).(config('root_path')?'?/':''); 169 | $ext = strtolower(pathinfo($item['name'], PATHINFO_EXTENSION)); 170 | $data['title'] = $item['name']; 171 | $data['navs'] = $this->navs(); 172 | $data['item'] = $item; 173 | $data['ext'] = $ext; 174 | $data['item']['path'] = get_absolute_path($this->path).$this->name; 175 | $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; 176 | $uri = onedrive::urlencode(get_absolute_path($this->url_path.'/'.$this->name)); 177 | $data['url'] = $http_type.$_SERVER['HTTP_HOST'].$root.$uri; 178 | 179 | 180 | $show = config('show'); 181 | foreach($show as $n=>$exts){ 182 | if(in_array($ext,$exts)){ 183 | return view::load('show/'.$n)->with($data); 184 | } 185 | } 186 | 187 | header('Location: '.$item['downloadUrl']); 188 | } 189 | //缩略图 190 | function thumbnail($item){ 191 | if(!empty($_GET['t'])){ 192 | list($width, $height) = explode('|', $_GET['t']); 193 | }else{ 194 | //800 176 96 195 | $width = $height = 800; 196 | } 197 | $item['thumb'] = onedrive::thumbnail($this->path.$this->name); 198 | list($item['thumb'],$tmp) = explode('&width=', $item['thumb']); 199 | $item['thumb'] .= strpos($item['thumb'], '?')?'&':'?'; 200 | return $item['thumb']."width={$width}&height={$height}"; 201 | } 202 | 203 | //文件夹下元素 204 | function items($path, $fetch=false){ 205 | $items = cache::get('dir_'.$this->path, function(){ 206 | return onedrive::dir($this->path); 207 | }, config('cache_expire_time')); 208 | return $items; 209 | } 210 | 211 | function navs(){ 212 | $root = get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).config('root_path'); 213 | $navs['/'] = get_absolute_path($root.'/'); 214 | foreach(explode('/',$this->url_path) as $v){ 215 | if(empty($v)){ 216 | continue; 217 | } 218 | $navs[rawurldecode($v)] = end($navs).$v.'/'; 219 | } 220 | if(!empty($this->name)){ 221 | $navs[$this->name] = end($navs).urlencode($this->name); 222 | } 223 | 224 | return $navs; 225 | } 226 | 227 | static function get_content($item){ 228 | $content = cache::get('content_'.$item['path'], function() use ($item){ 229 | $resp = fetch::get($item['downloadUrl']); 230 | if($resp->http_code == 200){ 231 | return $resp->content; 232 | } 233 | }, config('cache_expire_time') ); 234 | return $content; 235 | } 236 | 237 | 238 | 239 | //时候404 240 | function is404(){ 241 | if(!empty($this->items[$this->name]) || (empty($this->name) && is_array($this->items)) ){ 242 | return false; 243 | } 244 | 245 | http_response_code(404); 246 | view::load('404')->show(); 247 | die(); 248 | } 249 | 250 | function __destruct(){ 251 | if (!function_exists("fastcgi_finish_request")) { 252 | return; 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /controller/UploadController.php: -------------------------------------------------------------------------------- 1 | add_task($local, $remotepath); 12 | $message = "文件".$local."已添加到队列"; 13 | }elseif(is_dir($local)){ 14 | $this->scan_dir($local, $remotepath); 15 | $message = "文件夹".$local."已添加到队列"; 16 | }elseif($local == realpath('.')){ 17 | $message = "因为安全原因,程序文件夹根目录不能上传"; 18 | }else{ 19 | $message = "文件不存在"; 20 | } 21 | $request = $this->task_request(); 22 | $request['url'] = substr($request['url'],0,-4).'run'; 23 | fetch::post($request); 24 | }elseif(!empty($_POST['begin_task'])){ 25 | $this->task($_POST['begin_task']); 26 | }elseif(!empty($_POST['delete_task'])){ 27 | unset($_POST['delete_task']); 28 | config('@upload', (array)$uploads); 29 | }elseif(!empty($_POST['empty_uploaded'])){ 30 | config('@uploaded', array()); 31 | } 32 | $uploading = config('@upload'); 33 | $uploaded = array_reverse((array)config('@uploaded')); 34 | return view::load('upload')->with('uploading', $uploading)->with('uploaded', $uploaded)->with('message', $message); 35 | } 36 | 37 | //扫描文件夹,添加到任务队列 38 | private function scan_dir($localpath, $remotepath){ 39 | $files = scandir($localpath); 40 | foreach ($files as $file) { 41 | if ($file == '.' || $file == '..') { 42 | continue; 43 | } 44 | if (is_dir($localpath . '/' . $file)) { 45 | $this->scan_dir($localpath . '/' . $file, $remotepath.$file.'/'); 46 | }else{ 47 | $localfile = realpath($localpath . '/' . $file); 48 | $remotefile = $remotepath.$file; 49 | $this->add_task($localfile, $remotefile); 50 | } 51 | } 52 | } 53 | 54 | private function add_task($localfile, $remotefile){ 55 | $task = array( 56 | 'localfile'=>$localfile, 57 | 'remotepath' => $remotefile, 58 | 'filesize'=>onedrive::_filesize($localfile), 59 | 'upload_type'=>'web', 60 | 'update_time'=>0, 61 | ); 62 | 63 | $uploads = (array)config('@upload'); 64 | if(empty($uploads[$remotefile])){ 65 | $uploads[$remotefile] = $task; 66 | config('@upload', $uploads); 67 | } 68 | } 69 | 70 | //运行队列中的任务 71 | function run(){ 72 | $uploads = (array)config('@upload'); 73 | $time = time(); 74 | $runing = 0; 75 | foreach($uploads as $task){ 76 | if($time < ($task['update_time']+60) AND $task['type']=='web' ){ 77 | $runing = $runing +1; 78 | } 79 | if($runing > 5)break; 80 | } 81 | 82 | foreach($uploads as $remotepath=>$task){ 83 | if($time < ($task['update_time']+60) OR !is_array($task) ){ 84 | continue; 85 | } 86 | $runing = $runing +1; 87 | print $remotepath.PHP_EOL; 88 | fetch::post($this->task_request($remotepath)); 89 | if($runing > 5)break; 90 | } 91 | 92 | if(count($uploads) > 5){ 93 | set_time_limit(100); 94 | sleep(60); 95 | $request = $this->task_request(); 96 | $request['url'] = substr($request['url'],0,-4).'run'; 97 | fetch::get($request); 98 | } 99 | } 100 | 101 | private function task_request($remotepath=''){ 102 | $request['headers'] = "Cookie: admin=".md5(config('password').config('refresh_token')).PHP_EOL; 103 | $request['headers'] .= "Host: ".$_SERVER['HTTP_HOST']; 104 | $request['curl_opt']=[CURLOPT_CONNECTTIMEOUT => 1,CURLOPT_TIMEOUT=>1,CURLOPT_FOLLOWLOCATION=>true]; 105 | $http_type = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; 106 | $request['url'] = $http_type.'127.0.0.1'.get_absolute_path(dirname($_SERVER['PHP_SELF'])).'?/admin/upload/task'; 107 | $request['post_data'] = 'remotepath='.urlencode($remotepath); 108 | return $request; 109 | } 110 | 111 | //执行任务 112 | function task($remotepath=null){ 113 | $remotepath = is_null($remotepath)?$_POST['remotepath']:$remotepath; 114 | //file_put_contents('log.txt',$remotepath.PHP_EOL, FILE_APPEND); 115 | $uploads = config('@upload'); 116 | $task = $uploads[$remotepath]; 117 | 118 | if(empty($task)){ 119 | return; 120 | } 121 | if($task['filesize'] < 10485760){ 122 | @onedrive::upload($task['remotepath'], file_get_contents($task['localfile'])); 123 | unset($uploads[$remotepath]); 124 | 125 | config('@upload', (array)$uploads); 126 | config($remotepath.'@uploaded','success'); 127 | }else{ 128 | $uploads[$remotepath]['update_time'] = time(); 129 | config('@upload', (array)$uploads); 130 | $this->upload_large_file($task); 131 | } 132 | } 133 | 134 | function upload_large_file($task){ 135 | //创建上传会话 136 | if(empty($task['url'])){ 137 | $data = onedrive::create_upload_session($task['remotepath']); 138 | if(!empty($data['uploadUrl'])){ 139 | $task['url'] = $data['uploadUrl']; 140 | $task['offset'] = 0; 141 | $task['length'] = 327680; 142 | $task['update_time'] = time(); 143 | config($task['remotepath'].'@upload',$task); 144 | }elseif ( $data === false ){ 145 | $uploads = config('@upload'); 146 | unset($uploads[$task['remotepath']]); 147 | config('@upload', $uploads); 148 | config($task['remotepath'].'@uploaded','exists'); 149 | } 150 | }else{ 151 | $begin_time = microtime(true); 152 | set_time_limit(0); 153 | $data = onedrive::upload_session($task['url'], $task['localfile'], $task['offset'], $task['length']); 154 | if(!empty($data['nextExpectedRanges'])){ 155 | //继续上传 156 | $upload_time = microtime(true) - $begin_time; 157 | $task['speed'] = $task['length']/$upload_time; 158 | $task['length'] = intval($task['length']/$upload_time/32768*2)*327680; 159 | $task['length'] = ($task['length']>104857600)?104857600:$task['length']; 160 | list($offset, $filesize) = explode('-',$data['nextExpectedRanges'][0]); 161 | $task['offset'] = intval($offset); 162 | $info['update_time'] = time(); 163 | config($task['remotepath'].'@upload',$task); 164 | }elseif(!empty($data['@content.downloadUrl']) || !empty($data['id'])){ 165 | //上传完成 166 | unset($uploads[$task['remotepath']]); 167 | config('@upload', $uploads); 168 | config($task['remotepath'].'@uploaded','success'); 169 | return; 170 | }else{ 171 | //失败,重新获取信息 172 | echo "re get url"; 173 | $data = onedrive::upload_session_status($task['url']); 174 | if(empty($data)|| $info['length']<100){ 175 | onedrive::delete_upload_session($task['url']); 176 | unset($task['url']); 177 | config($task['remotepath'].'@upload', $task); 178 | }elseif(!empty($data['nextExpectedRanges'])){ 179 | list($offset, $filesize) = explode('-',$data['nextExpectedRanges'][0]); 180 | $task['offset'] = intval($offset); 181 | $task['length'] = $task['length']/1.5; 182 | config($task['remotepath'].'@upload', $task); 183 | } 184 | } 185 | } 186 | $request= $this->task_request($task['remotepath']); 187 | $resp = fetch::post($request); 188 | //var_dump($resp); 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /demo/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mintimate/OneindexM/ee9c63a9681deab30a0f2f92ca59fae51f466e10/demo/demo.png -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | get($key); 29 | if(!is_null($value)){ 30 | return $value; 31 | }elseif(is_callable($default)){ 32 | $value = $default(); 33 | self::set($key, $value, $expire); 34 | return $value; 35 | }elseif(!is_null($default)){ 36 | self::set($key, $default, $expire); 37 | return $default; 38 | } 39 | } 40 | 41 | // 设置缓存 42 | static function set($key, $value, $expire=99999999){ 43 | return self::c()->set($key, $value, $expire); 44 | } 45 | 46 | // 清空缓存 47 | static function clear(){ 48 | return self::c()->clear(); 49 | } 50 | 51 | // 删除缓存 52 | static function del($key){ 53 | return self::set($key, null); 54 | } 55 | 56 | // 判断缓存是否设置 57 | static function has($key){ 58 | if(is_null(self::get($key))){ 59 | return false; 60 | }else{ 61 | return true; 62 | } 63 | } 64 | // 读取并删除缓存 65 | static function pull($key){ 66 | $value = self::get($key); 67 | self::del($key); 68 | return $value; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/cache/filecache_.php: -------------------------------------------------------------------------------- 1 | cache_path = $cache_path; 10 | } 11 | 12 | function get($key){ 13 | $file = $this->cache_path . md5($key) . '.php'; 14 | $data = @include $file; 15 | if( is_array($data) && $data['expire'] > time() && !is_null($data['data']) ){ 16 | return $data['data']; 17 | }else{ 18 | return null; 19 | } 20 | } 21 | 22 | function set($key, $value=null, $expire=99999999){ 23 | $file = $this->cache_path . md5($key) . '.php'; 24 | $data['expire'] = time() + $expire; 25 | $data['data'] = $value; 26 | return @file_put_contents($file, "cache_path.'*.php')); 31 | } 32 | } -------------------------------------------------------------------------------- /lib/cache/memcache_.php: -------------------------------------------------------------------------------- 1 | m = new Memcache(); 7 | if(empty($config)){ 8 | $config = 'localhost:11211'; 9 | } 10 | list($host, $port) = explode(':', $config, 2); 11 | $this->m->addServer($host, $port); 12 | } 13 | 14 | function get($key){ 15 | $data = $this->m->get($key); 16 | if( is_array($data) && $data['expire'] > time() && !is_null($data['data']) ){ 17 | return $data['data']; 18 | }else{ 19 | return null; 20 | } 21 | } 22 | 23 | function set($key, $value=null, $expire=99999999){ 24 | $data['expire'] = time() + $expire; 25 | $data['data'] = $value; 26 | return $this->m->set($key, $data); 27 | } 28 | 29 | function clear(){ 30 | $this->m->flush(10); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/cache/redis_.php: -------------------------------------------------------------------------------- 1 | redis = new Redis(); 7 | if(empty($config)){ 8 | $config = 'localhost:6379'; 9 | } 10 | list($host, $port) = explode(':', $config, 2); 11 | $this->redis->pconnect($host, $port); 12 | } 13 | 14 | function get($key){ 15 | $gRefreshTime = $this->redis->get("OneIndex_gRefreshTime"); 16 | $key = "OneIndex_$gRefreshTime\_" . $key; 17 | $data = $this->redis->get($key); 18 | return unserialize($data) ?: null; 19 | } 20 | 21 | function set($key, $value=null, $expire=600){ 22 | $gRefreshTime = $this->redis->get("OneIndex_gRefreshTime"); 23 | if (empty($gRefreshTime)) { 24 | $gRefreshTime = time(); 25 | $this->redis->set("OneIndex_gRefreshTime", $gRefreshTime); 26 | } 27 | $key = "OneIndex_$gRefreshTime\_" . $key; 28 | return $this->redis->set($key, serialize($value), $expire); 29 | } 30 | 31 | function clear(){ 32 | $this->redis->set("OneIndex_gRefreshTime", $gRefreshTime); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/fetch.php: -------------------------------------------------------------------------------- 1 | 1, //true, $head 有请求的返回值 13 | CURLOPT_BINARYTRANSFER => true, //返回原生的Raw输出 14 | CURLOPT_HEADER => true, //启用时会将头文件的信息作为数据流输出。 15 | CURLOPT_FAILONERROR => true, //显示HTTP状态码,默认行为是忽略编号小于等于400的HTTP信息。 16 | CURLOPT_AUTOREFERER => true, //当根据Location:重定向时,自动设置header中的Referer:信息。 17 | CURLOPT_FOLLOWLOCATION => false, //跳转 18 | CURLOPT_CONNECTTIMEOUT => 3, //在发起连接前等待的时间,如果设置为0,则无限等待。 19 | CURLOPT_TIMEOUT => 5, //设置cURL允许执行的最长秒数。 20 | CURLOPT_ENCODING => 'gzip,deflate', 21 | CURLOPT_SSL_VERIFYHOST => false, 22 | CURLOPT_SSL_VERIFYPEER => false, 23 | ); 24 | foreach ($opt as $k => $v) { 25 | self::$curl_opt[$k] = $v; 26 | } 27 | } 28 | 29 | /** 30 | * fetch::get('http://www.google.com/'); 31 | * fetch::post('http://www.google.com/', array('name'=>'foo')); 32 | */ 33 | public static function __callstatic($method, $args) { 34 | if (is_null(self::$curl_opt)) { 35 | self::init(); 36 | } 37 | @list($request, $post_data, $callback) = $args; 38 | if (is_callable($post_data)) { 39 | $callback = $post_data; 40 | $post_data = null; 41 | } 42 | 43 | //single_curl 44 | if (is_string($request) || !empty($request['url'])) { 45 | $request = self::bulid_request($request, $method, $post_data, $callback); 46 | return self::single_curl($request); 47 | } elseif (is_array($request)) { 48 | //rolling_curl 49 | foreach ($request as $k => $r) { 50 | $requests[$k] = self::bulid_request($r, $method, $post_data, $callback); 51 | } 52 | return self::rolling_curl($requests); 53 | } 54 | } 55 | 56 | private static function bulid_request($request, $method = 'GET', $post_data = null, $callback = null) { 57 | //url 58 | if (is_string($request)) { 59 | $request = array('url' => $request); 60 | } 61 | empty($request['method']) && $request['method'] = $method; 62 | empty($request['post_data']) && $request['post_data'] = $post_data; 63 | empty($request['callback']) && $request['callback'] = $callback; 64 | return $request; 65 | } 66 | 67 | private static function bulid_ch(&$request) { 68 | // url 69 | $ch = curl_init($request['url']); 70 | // curl_opt 71 | $curl_opt = empty($request['curl_opt']) ? array() : $request['curl_opt']; 72 | $curl_opt = $curl_opt + (array) self::$curl_opt; 73 | // method 74 | $curl_opt[CURLOPT_CUSTOMREQUEST] = strtoupper($request['method']); 75 | // post_data 76 | if (!empty($request['post_data'])) { 77 | $curl_opt[CURLOPT_POST] = true; 78 | $curl_opt[CURLOPT_POSTFIELDS] = $request['post_data']; 79 | } 80 | // header 81 | $headers = @self::bulid_request_header($request['headers'], $cookies); 82 | $curl_opt[CURLOPT_HTTPHEADER] = $headers; 83 | 84 | // cookies 85 | $request['cookies'] = empty($request['cookies']) ? fetch::$cookies : $request['cookies']; 86 | $cookies = empty($request['cookies']) ? $cookies : self::cookies_arr2str($request['cookies']); 87 | if (!empty($cookies)) { 88 | $curl_opt[CURLOPT_COOKIE] = $cookies; 89 | } 90 | 91 | //proxy 92 | $proxy = empty($request['proxy']) ? self::$proxy : $request['proxy']; 93 | if (!empty($proxy)) { 94 | $curl_opt[CURLOPT_PROXY] = $proxy; 95 | } 96 | 97 | //setopt 98 | curl_setopt_array($ch, $curl_opt); 99 | 100 | $request['curl_opt'] = $curl_opt; 101 | $request['ch'] = $ch; 102 | 103 | return $ch; 104 | } 105 | 106 | private static function response($raw, $ch) { 107 | $response = (object) curl_getinfo($ch); 108 | $response->raw = $raw; 109 | //$raw = fetch::iconv($raw, $response->content_type); 110 | $response->headers = substr($raw, 0, $response->header_size); 111 | $response->cookies = fetch::get_respone_cookies($response->headers); 112 | fetch::$cookies = array_merge((array) fetch::$cookies, $response->cookies); 113 | $response->content = substr($raw, $response->header_size); 114 | return $response; 115 | } 116 | 117 | private static function single_curl($request) { 118 | $ch = self::bulid_ch($request); 119 | $raw = curl_exec($ch); 120 | $response = self::response($raw, $ch); 121 | curl_close($ch); 122 | if (is_callable($request['callback'])) { 123 | call_user_func($request['callback'], $response, $request); 124 | } 125 | return $response; 126 | } 127 | 128 | private static function rolling_curl($requests) { 129 | $master = curl_multi_init(); 130 | $map = array(); 131 | // start the first batch of requests 132 | do { 133 | $k = key($requests); 134 | $request = current($requests); 135 | next($requests); 136 | $ch = self::bulid_ch($request); 137 | curl_multi_add_handle($master, $ch); 138 | $key = (string) $ch; 139 | $map[$key] = array($k, $request['callback']); 140 | } while (count($map) < self::$max_connect && count($map) < count($requests)); 141 | 142 | do { 143 | while (($execrun = curl_multi_exec($master, $running)) == CURLM_CALL_MULTI_PERFORM); 144 | if ($execrun != CURLM_OK) { 145 | break; 146 | } 147 | 148 | // a request was just completed -- find out which one 149 | while ($done = curl_multi_info_read($master)) { 150 | $key = (string) $done['handle']; 151 | 152 | list($k, $callback) = $map[$key]; 153 | 154 | // get the info and content returned on the request 155 | $raw = curl_multi_getcontent($done['handle']); 156 | $response = self::response($raw, $done['handle']); 157 | $responses[$k] = $response; 158 | 159 | // send the return values to the callback function. 160 | if (is_callable($callback)) { 161 | $key = (string) $done['handle']; 162 | unset($map[$key]); 163 | call_user_func($callback, $response, $requests[$k], $k); 164 | } 165 | 166 | // start a new request (it's important to do this before removing the old one) 167 | $k = key($requests); 168 | if (!empty($k)) { 169 | $k = key($requests); 170 | $request = current($requests); 171 | next($requests); 172 | $ch = self::bulid_ch($request); 173 | curl_multi_add_handle($master, $ch); 174 | $key = (string) $ch; 175 | $map[$key] = array($k, $request['callback']); 176 | curl_multi_exec($master, $running); 177 | } 178 | 179 | // remove the curl handle that just completed 180 | curl_multi_remove_handle($master, $done['handle']); 181 | } 182 | 183 | // Block for data in / output; error handling is done by curl_multi_exec 184 | if ($running) { 185 | curl_multi_select($master, 10); 186 | } 187 | 188 | } while ($running); 189 | 190 | return $responses; 191 | } 192 | 193 | private static function bulid_request_header($headers, &$cookies) { 194 | if (is_array($headers)) { 195 | $headers = join(PHP_EOL, $headers); 196 | } 197 | if (is_array(self::$headers)) { 198 | self::$headers = join(PHP_EOL, self::$headers); 199 | } 200 | $headers = self::$headers.PHP_EOL .$headers; 201 | 202 | foreach (explode(PHP_EOL, $headers) as $k => $v) { 203 | @list($k, $v) = explode(':', $v, 2); 204 | if (empty($k) || empty($v)) { 205 | continue; 206 | } 207 | $k = implode('-', array_map('ucfirst', explode('-', $k))); 208 | $tmp[$k] = $v; 209 | } 210 | 211 | foreach ((array) $tmp as $k => $v) { 212 | if ($k == 'Cookie') { 213 | $cookies = $v; 214 | } else { 215 | $return[] = $k . ':' . $v; 216 | } 217 | } 218 | return (array) $return; 219 | } 220 | 221 | public static function iconv(&$raw, $content_type) { 222 | @list($tmp, $charset) = explode('CHARSET=', strtoupper($content_type)); 223 | 224 | if (empty($charset) && stripos($content_type, 'html') > 0) { 225 | preg_match('@\ $v) { 255 | $str .= $k . "=" . $v . "; "; 256 | } 257 | return $str; 258 | } 259 | } -------------------------------------------------------------------------------- /lib/oneindex.php: -------------------------------------------------------------------------------- 1 | 10485760){ 67 | return false; 68 | } 69 | 70 | return cache::get('content_'.$item['path'], function() use ($item){ 71 | $resp = fetch::get($item['downloadUrl']); 72 | if($resp->http_code == 200){ 73 | return $resp->content; 74 | } 75 | }, config('cache_expire_time') ); 76 | } 77 | 78 | 79 | 80 | //缩略图 81 | static function thumb($path,$width=800,$height=800){ 82 | $path = self::get_absolute_path($path); 83 | if(empty(self::$thumb[$path])){ 84 | self::$thumb[$path] = cache::get('thumb_'.$path, function() use ($path){ 85 | $url = onedrive::thumbnail($path); 86 | list($url,$tmp) = explode('&width=', $url); 87 | return $url; 88 | }, config('cache_expire_time')); 89 | } 90 | 91 | self::$thumb[$path] .= strpos(self::$thumb[$path], '?')?'&':'?'; 92 | return self::$thumb[$path]."width={$width}&height={$height}"; 93 | } 94 | 95 | //获取下载链接 96 | static function download_url($path){ 97 | $item = self::file($path); 98 | if(!empty($item['downloadUrl'])){ 99 | return $item['downloadUrl']; 100 | } 101 | return false; 102 | } 103 | 104 | static function web_url($path){ 105 | $path = self::get_absolute_path($path); 106 | $path = rtrim($path, '/'); 107 | 108 | if(!empty(config($path.'@weburl'))){ 109 | return config($path.'@weburl'); 110 | }else{ 111 | $share = onedrive::share($path); 112 | if(!empty($share['link']['webUrl'])){ 113 | config($path.'@weburl', $share['link']['webUrl']); 114 | return $share['link']['webUrl']; 115 | } 116 | } 117 | } 118 | 119 | static function direct_link($path){ 120 | $web_url = self::web_url($path); 121 | if(!empty($web_url)){ 122 | $arr = explode('/', $web_url); 123 | if( strpos($arr[2],'sharepoint.com') >0 ){ 124 | $k = array_pop($arr); 125 | unset($arr[3]); 126 | unset($arr[4]); 127 | return join('/', $arr).'/_layouts/15/download.aspx?share='.$k; 128 | }elseif ( strpos($arr[2],'1drv.ms') >0 ){ 129 | # code... 130 | } 131 | } 132 | } 133 | 134 | 135 | //工具函数获取绝对路径 136 | static function get_absolute_path($path) { 137 | $path = str_replace(array('/', '\\', '//'), '/', $path); 138 | $parts = array_filter(explode('/', $path), 'strlen'); 139 | $absolutes = array(); 140 | foreach ($parts as $part) { 141 | if ('.' == $part) continue; 142 | if ('..' == $part) { 143 | array_pop($absolutes); 144 | } else { 145 | $absolutes[] = $part; 146 | } 147 | } 148 | return str_replace('//','/','/'.implode('/', $absolutes).'/'); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /lib/route.php: -------------------------------------------------------------------------------- 1 | '[^/]+', 10 | '#num' => '[0-9]+', 11 | '#all' => '.*', 12 | ); 13 | 14 | public static function __callstatic($method, $args) { 15 | if (self::$runed) { 16 | return; 17 | } 18 | 19 | if (empty(self::$method)) { 20 | self::init(); 21 | } 22 | 23 | $method = strtoupper($method); 24 | if ($method != self::$method && !in_array($method, ['ANY', 'ERROR', 'ON'])) { 25 | return; 26 | } 27 | $pattern = trim(array_shift($args), '\/'); 28 | $pattern = self::$root . $pattern; 29 | 30 | if (self::uri_match($pattern, self::$uri)) { 31 | if (is_string($args[0]) && strpos($args[0], '@') > 0) { 32 | list($class, $action) = explode('@', $args[0]); 33 | $object = new $class(); 34 | $args[0] = array($object, $action); 35 | } 36 | 37 | $return = call_user_func($args[0]); 38 | if (is_array($return)) { 39 | print json_encode($return); 40 | } else { 41 | print (string) $return; 42 | } 43 | self::$runed = true; 44 | } 45 | } 46 | 47 | public static function init() { 48 | if (!empty(self::$method)) {return;} 49 | self::$uri = self::get_uri(); 50 | self::$method = empty($_POST['_METHOD']) ? $_SERVER['REQUEST_METHOD'] : $_POST['_METHOD']; 51 | if (defined('CONTROLLER_PATH')) { 52 | spl_autoload_register(function ($class) { 53 | $file = CONTROLLER_PATH . $class . '.php'; 54 | if (file_exists($file)) { 55 | include $file; 56 | } 57 | }); 58 | } 59 | } 60 | 61 | public static function auto($controller_path) { 62 | self::init(); 63 | $uri = self::get_uri(); 64 | list($tmp, $controller, $action) = explode('/', $uri); 65 | $controller = empty($controller) ? 'IndexController' : ucfirst($controller) . 'Controller'; 66 | $action = empty($action) ? 'index' : $action; 67 | $file = $controller_path . $controller . '.php'; 68 | if (file_exists($file)) { 69 | include $file; 70 | if (is_callable(array($controller, $action))) { 71 | $obj = new $controller(); 72 | print (string) $obj->$action(); 73 | return; 74 | } 75 | } 76 | } 77 | 78 | public static function group($middleware, $callback){ 79 | self::init(); 80 | if (is_string($middleware) && strpos($middleware, '@') > 0) { 81 | list($class, $action) = explode('@', $middleware); 82 | $object = new $class(); 83 | $result = $object->$action(); 84 | }elseif(is_callable($middleware)){ 85 | $result = $middleware(); 86 | } 87 | 88 | if($result == true && is_callable($callback)){ 89 | return $callback(); 90 | } 91 | } 92 | 93 | public static function resource($name, $controller) { 94 | self::get('/' . $name, $controller . '@index'); 95 | self::get('/' . $name . '/add', $controller . '@add'); 96 | self::post('/' . $name, $controller . '@store'); 97 | self::get('/' . $name . '/{id:#num}', $controller . '@show'); 98 | self::get('/' . $name . '/{id:#num}/edit', $controller . '@edit'); 99 | self::post('/' . $name . '/{id:#num}', $controller . '@update'); 100 | self::get('/' . $name . '/{id:#num}/delete', $controller . '@delete'); 101 | } 102 | 103 | public static function uri_match($pattern, $uri) { 104 | $pattern = ($pattern == '/') ? '/' : rtrim($pattern, '\/'); 105 | 106 | $ps = explode('/', $pattern); 107 | 108 | $searches = array_keys(static::$patterns); 109 | $replaces = array_values(static::$patterns); 110 | 111 | foreach($ps as &$p){ 112 | $p = str_replace($searches, $replaces, $p); 113 | $p = preg_replace("`\{(\w+)\:([^\)]+)\}`", '(?P<$1>$2)', $p); 114 | } 115 | 116 | $pattern = join('/',$ps); 117 | 118 | if (preg_match("`^{$pattern}$`", $uri)) { 119 | preg_match_all("`^{$pattern}$`", $uri, $matches, PREG_PATTERN_ORDER); 120 | foreach ($matches as $key => $value) { 121 | if (!is_int($key)) { 122 | $_GET[$key] = $matches[$key][0]; 123 | } 124 | } 125 | return true; 126 | } 127 | } 128 | 129 | public static function get_uri() { 130 | $file = basename($_SERVER['PHP_SELF']); 131 | $path = dirname($_SERVER['PHP_SELF']); 132 | $req_uri = $_SERVER['REQUEST_URI']; 133 | 134 | if ($path != '/' && strpos($req_uri, $path) === 0) { 135 | $req_uri = substr($req_uri, strlen($path)); 136 | } 137 | 138 | if (strpos($req_uri, '/?/') === 0) { 139 | $req_uri = parse_url($req_uri, PHP_URL_QUERY); 140 | list($req_uri) = explode('&', $req_uri); 141 | unset($_GET[$req_uri]); 142 | } 143 | $uri = parse_url($req_uri, PHP_URL_PATH); 144 | return '/' . trim($uri, '\/'); 145 | } 146 | } -------------------------------------------------------------------------------- /lib/sqlite.php: -------------------------------------------------------------------------------- 1 | db = new PDO('sqlite:' . $filename); 18 | $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 19 | $this->name = $name; 20 | $this->createTable(); 21 | } 22 | 23 | /** 24 | * @param string $key key 25 | * 26 | * @throws InvalidArgumentException 27 | * @return string|null 28 | */ 29 | public function get($key) 30 | { 31 | if (!is_string($key)) { 32 | throw new InvalidArgumentException('Expected string as key'); 33 | } 34 | 35 | $stmt = $this->db->prepare( 36 | 'SELECT value FROM ' . $this->name . ' WHERE key = :key;' 37 | ); 38 | $stmt->bindParam(':key', $key, PDO::PARAM_STR); 39 | $stmt->execute(); 40 | 41 | if ($row = $stmt->fetch(PDO::FETCH_OBJ)) { 42 | return $row->value; 43 | } 44 | 45 | return null; 46 | } 47 | 48 | /** 49 | * @param string $key key 50 | * @param string $value value 51 | * 52 | * @throws InvalidArgumentException 53 | */ 54 | public function set($key, $value) 55 | { 56 | if (!is_string($key)) { 57 | throw new InvalidArgumentException('Expected string as key'); 58 | } 59 | 60 | $queryString = 'REPLACE INTO ' . $this->name . ' VALUES (:key, :value);'; 61 | $stmt = $this->db->prepare($queryString); 62 | $stmt->bindParam(':key', $key, \PDO::PARAM_STR); 63 | $stmt->bindParam(':value', $value, \PDO::PARAM_STR); 64 | $stmt->execute(); 65 | } 66 | 67 | /** 68 | * @param string $key key 69 | * 70 | * @return null 71 | */ 72 | public function delete($key) 73 | { 74 | $stmt = $this->db->prepare( 75 | 'DELETE FROM ' . $this->name . ' WHERE key = :key;' 76 | ); 77 | $stmt->bindParam(':key', $key, \PDO::PARAM_STR); 78 | $stmt->execute(); 79 | } 80 | 81 | /** 82 | * Delete all values from store 83 | * 84 | * @return null 85 | */ 86 | public function deleteAll() 87 | { 88 | $stmt = $this->db->prepare('DELETE FROM ' . $this->name); 89 | $stmt->execute(); 90 | $this->data = array(); 91 | } 92 | 93 | /** 94 | * @return int 95 | */ 96 | public function count() 97 | { 98 | return (int) $this->db->query('SELECT COUNT(*) FROM ' . $this->name)->fetchColumn(); 99 | } 100 | 101 | /** 102 | * Create storage table in database if not exists 103 | * 104 | * @return null 105 | */ 106 | private function createTable() 107 | { 108 | $stmt = 'CREATE TABLE IF NOT EXISTS "' . $this->name . '"'; 109 | $stmt.= '(key TEXT PRIMARY KEY, value TEXT);'; 110 | $this->db->exec($stmt); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /lib/view.php: -------------------------------------------------------------------------------- 1 | '', 'data' => array()); 5 | static $_pos = null; 6 | static $_section = null; 7 | 8 | static function load($file, $set = null) { 9 | if (is_int(strripos($file, '..'))) { 10 | die("error view file name:$file"); 11 | } 12 | $file = str_replace('.', '/', $file); 13 | 14 | return new view($file, $set); 15 | } 16 | 17 | public function __construct($file, $set = null) { 18 | if (isset(self::$_pos)) { 19 | $this->_view['parent'] = self::$_pos; 20 | $this->with($this->_view['parent']->_view['data']); 21 | } 22 | $this->_view['file'] = $file; 23 | $this->with($set); 24 | } 25 | 26 | public function with($name, $value = NULL) { 27 | if (is_array($name)) { 28 | $this->_view['data'] = array_merge($this->_view['data'], $name); 29 | } elseif (is_string($name)) { 30 | $this->_view['data'][$name] = $value; 31 | } 32 | return $this; 33 | } 34 | 35 | public function __toString() { 36 | self::$_pos = $this; 37 | 38 | $this->_view['file'] = VIEW_PATH . $this->_view['file'] . '.php'; 39 | if(!file_exists($this->_view['file'])){ 40 | self::to404('404'); 41 | } 42 | 43 | extract($this->_view['data']); 44 | 45 | ob_start(); 46 | include $this->_view['file']; 47 | 48 | if (isset($this->_view['layout'])) { 49 | echo $this->_view['layout'] . ob_get_clean(); 50 | } 51 | 52 | 53 | self::$_pos = isset($this->_view['parent']) ? $this->_view['parent'] : NULL; 54 | 55 | $return_str = ob_get_clean(); 56 | 57 | return $return_str; 58 | } 59 | 60 | public function show() { 61 | echo $this; 62 | } 63 | 64 | 65 | static function layout($file) { 66 | ob_start(); 67 | $view_layout = self::load($file); 68 | self::$_pos->_view['layout'] = $view_layout; 69 | } 70 | 71 | static function section($name) { 72 | if (isset(self::$_pos->_view['section'][$name])) { 73 | echo self::$_pos->_view['section'][$name]; 74 | } elseif (isset(self::$_pos->_view['parent']->_view['section'][$name])) { 75 | echo self::$_pos->_view['parent']->_view['section'][$name]; 76 | } 77 | } 78 | 79 | static function begin($name) { 80 | self::$_section = $name; 81 | ob_start(); 82 | } 83 | 84 | static function end() { 85 | self::$_pos->_view['section'][self::$_section] = ob_get_clean(); 86 | self::$_section = null; 87 | } 88 | 89 | static function direct($loction) { 90 | header("Location:$loction"); 91 | exit(); 92 | } 93 | 94 | static function abort() { 95 | header("HTTP/1.1 502 Bad Gateway"); 96 | exit(); 97 | } 98 | 99 | static function to404(){ 100 | header("HTTP/1.1 404 Not Found"); 101 | exit(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /one.php: -------------------------------------------------------------------------------- 1 | $localfile, 95 | // 'remotepath' => $remotepath, 96 | // 'filesize'=>onedrive::_filesize($localfile), 97 | // 'update_time'=>0 98 | // ); 99 | // $uploads = config('@upload'); 100 | // if(empty($uploads[$remotepath])){ 101 | // $uploads[$remotepath] = $task; 102 | // config('@upload', $uploads); 103 | // } 104 | // } 105 | // } 106 | // } 107 | //} 108 | 109 | 110 | static function upload_large_file($localfile, $remotepath){ 111 | fetch::init([CURLOPT_TIMEOUT=>200]); 112 | $upload = config('@upload'); 113 | $info = $upload[$remotepath]; 114 | if(empty($info['url'])){ 115 | print ' 创建上传会话'.PHP_EOL; 116 | $data = onedrive::create_upload_session($remotepath); 117 | if(!empty($data['uploadUrl'])){ 118 | $info['url'] = $data['uploadUrl']; 119 | $info['localfile'] = $localfile; 120 | $info['remotepath'] = $remotepath; 121 | $info['filesize'] = onedrive::_filesize($localfile); 122 | $info['offset'] = 0; 123 | $info['length'] = 327680; 124 | $info['update_time'] = time(); 125 | $upload[$remotepath] = $info; 126 | config('@upload', $upload); 127 | }elseif ( $data === false ){ 128 | print ' 文件已存在!'.PHP_EOL; 129 | return; 130 | } 131 | } 132 | 133 | if(empty($info['url'])){ 134 | print ' 获取会话失败!'.PHP_EOL; 135 | sleep(3); 136 | return self::upload_large_file($localfile, $remotepath); 137 | } 138 | 139 | print ' 上传分块'.onedrive::human_filesize($info['length']).' '; 140 | $begin_time = microtime(true); 141 | $data = onedrive::upload_session($info['url'], $info['localfile'], $info['offset'], $info['length']); 142 | 143 | if(!empty($data['nextExpectedRanges'])){ 144 | $upload_time = microtime(true) - $begin_time; 145 | $info['speed'] = $info['length']/$upload_time; 146 | 147 | print onedrive::human_filesize($info['speed']).'/s'.' '.round(($info['offset']/$info['filesize'])*100).'% '.PHP_EOL; 148 | $info['length'] = intval($info['length']/$upload_time/32768*2)*327680; 149 | $info['length'] = ($info['length']>104857600)?104857600:$info['length']; 150 | 151 | list($offset, $filesize) = explode('-',$data['nextExpectedRanges'][0]); 152 | $info['offset'] = $offset; 153 | $info['update_time'] = time(); 154 | $upload[$remotepath] = $info; 155 | config('@upload', $upload); 156 | }elseif(!empty($data['@content.downloadUrl']) || !empty($data['id'])){ 157 | unset($upload[$remotepath]); 158 | config('@upload', $upload); 159 | print ' 上传完成!'.PHP_EOL; 160 | return; 161 | }else{ 162 | print ' 失败!'.PHP_EOL; 163 | $data = onedrive::upload_session_status($info['url']); 164 | if(empty($data)|| $info['length']<100){ 165 | onedrive::delete_upload_session($info['url']); 166 | unset($upload[$remotepath]); 167 | config('@upload', $upload); 168 | }elseif(!empty($data['nextExpectedRanges'])){ 169 | list($offset, $filesize) = explode('-',$data['nextExpectedRanges'][0]); 170 | $info['offset'] = $offset; 171 | $info['length'] = $info['length']/1.5; 172 | $upload[$remotepath] = $info; 173 | config('@upload', $upload); 174 | } 175 | } 176 | 177 | return self::upload_large_file($localfile, $remotepath); 178 | 179 | } 180 | 181 | 182 | } 183 | 184 | 185 | array_shift($argv); 186 | $action = str_replace(':', '_',array_shift($argv)); 187 | 188 | if(is_callable(['one',$action])){ 189 | @call_user_func_array(['one',$action], $argv); 190 | exit(); 191 | } 192 | ?> 193 | oneindex commands : 194 | cache 195 | cache:clear clear cache 196 | cache:refresh refresh cache 197 | token 198 | token:refresh refresh token 199 | upload 200 | upload:file upload a file to onedrive 201 | upload:folder upload a folder to onedrive 202 | -------------------------------------------------------------------------------- /statics/common/offline/css/bootstrap-responsive.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Responsive v2.0.3 3 | * 4 | * Copyright 2012 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}@media(max-width:767px){.visible-phone{display:inherit!important}.hidden-phone{display:none!important}.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}}@media(min-width:768px) and (max-width:979px){.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:18px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-group>label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.modal{position:absolute;top:10px;right:10px;left:10px;width:auto;margin:0}.modal.fade.in{top:auto}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:auto;margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.762430939%;*margin-left:2.709239449638298%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:99.999999993%;*width:99.9468085036383%}.row-fluid .span11{width:91.436464082%;*width:91.38327259263829%}.row-fluid .span10{width:82.87292817100001%;*width:82.8197366816383%}.row-fluid .span9{width:74.30939226%;*width:74.25620077063829%}.row-fluid .span8{width:65.74585634900001%;*width:65.6926648596383%}.row-fluid .span7{width:57.182320438000005%;*width:57.129128948638304%}.row-fluid .span6{width:48.618784527%;*width:48.5655930376383%}.row-fluid .span5{width:40.055248616%;*width:40.0020571266383%}.row-fluid .span4{width:31.491712705%;*width:31.4385212156383%}.row-fluid .span3{width:22.928176794%;*width:22.874985304638297%}.row-fluid .span2{width:14.364640883%;*width:14.311449393638298%}.row-fluid .span1{width:5.801104972%;*width:5.747913482638298%}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:714px}input.span11,textarea.span11,.uneditable-input.span11{width:652px}input.span10,textarea.span10,.uneditable-input.span10{width:590px}input.span9,textarea.span9,.uneditable-input.span9{width:528px}input.span8,textarea.span8,.uneditable-input.span8{width:466px}input.span7,textarea.span7,.uneditable-input.span7{width:404px}input.span6,textarea.span6,.uneditable-input.span6{width:342px}input.span5,textarea.span5,.uneditable-input.span5{width:280px}input.span4,textarea.span4,.uneditable-input.span4{width:218px}input.span3,textarea.span3,.uneditable-input.span3{width:156px}input.span2,textarea.span2,.uneditable-input.span2{width:94px}input.span1,textarea.span1,.uneditable-input.span1{width:32px}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:30px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.564102564%;*margin-left:2.510911074638298%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145300001%;*width:91.3997999636383%}.row-fluid .span10{width:82.905982906%;*width:82.8527914166383%}.row-fluid .span9{width:74.358974359%;*width:74.30578286963829%}.row-fluid .span8{width:65.81196581200001%;*width:65.7587743226383%}.row-fluid .span7{width:57.264957265%;*width:57.2117657756383%}.row-fluid .span6{width:48.717948718%;*width:48.6647572286383%}.row-fluid .span5{width:40.170940171000005%;*width:40.117748681638304%}.row-fluid .span4{width:31.623931624%;*width:31.5707401346383%}.row-fluid .span3{width:23.076923077%;*width:23.0237315876383%}.row-fluid .span2{width:14.529914530000001%;*width:14.4767230406383%}.row-fluid .span1{width:5.982905983%;*width:5.929714493638298%}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:1160px}input.span11,textarea.span11,.uneditable-input.span11{width:1060px}input.span10,textarea.span10,.uneditable-input.span10{width:960px}input.span9,textarea.span9,.uneditable-input.span9{width:860px}input.span8,textarea.span8,.uneditable-input.span8{width:760px}input.span7,textarea.span7,.uneditable-input.span7{width:660px}input.span6,textarea.span6,.uneditable-input.span6{width:560px}input.span5,textarea.span5,.uneditable-input.span5{width:460px}input.span4,textarea.span4,.uneditable-input.span4{width:360px}input.span3,textarea.span3,.uneditable-input.span3{width:260px}input.span2,textarea.span2,.uneditable-input.span2{width:160px}input.span1,textarea.span1,.uneditable-input.span1{width:60px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top{position:static;margin-bottom:18px}.navbar-fixed-top .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 9px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#999;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:6px 15px;font-weight:bold;color:#999;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .dropdown-menu a:hover{background-color:#222}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:block;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:9px 15px;margin:9px 0;border-top:1px solid #222;border-bottom:1px solid #222;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}} 10 | -------------------------------------------------------------------------------- /statics/common/offline/js/jquery.Storage.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Storage plugin 3 | * Provides a simple interface for storing data such as user preferences. 4 | * Storage is useful for saving and retreiving data from the user's browser. 5 | * For newer browsers, localStorage is used. 6 | * If localStorage isn't supported, then cookies are used instead. 7 | * Retrievable data is limited to the same domain as this file. 8 | * 9 | * Usage: 10 | * This plugin extends jQuery by adding itself as a static method. 11 | * $.Storage - is the class name, which represents the user's data store, whether it's cookies or local storage. 12 | * if ($.Storage) will tell you if the plugin is loaded. 13 | * $.Storage.set("name", "value") - Stores a named value in the data store. 14 | * $.Storage.set({"name1":"value1", "name2":"value2", etc}) - Stores multiple name/value pairs in the data store. 15 | * $.Storage.get("name") - Retrieves the value of the given name from the data store. 16 | * $.Storage.remove("name") - Permanently deletes the name/value pair from the data store. 17 | * 18 | * @author Dave Schindler 19 | * 20 | * Distributed under the MIT License 21 | * 22 | * Copyright (c) 2010 Dave Schindler 23 | * 24 | * Permission is hereby granted, free of charge, to any person obtaining a copy 25 | * of this software and associated documentation files (the "Software"), to deal 26 | * in the Software without restriction, including without limitation the rights 27 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 28 | * copies of the Software, and to permit persons to whom the Software is 29 | * furnished to do so, subject to the following conditions: 30 | * 31 | * The above copyright notice and this permission notice shall be included in 32 | * all copies or substantial portions of the Software. 33 | * 34 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 36 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 40 | * THE SOFTWARE. 41 | */ 42 | (function($) { 43 | // Private data 44 | var isLS=typeof window.localStorage!=='undefined'; 45 | // Private functions 46 | function wls(n,v){var c;if(typeof n==="string"&&typeof v==="string"){localStorage[n]=v;return true;}else if(typeof n==="object"&&typeof v==="undefined"){for(c in n){if(n.hasOwnProperty(c)){localStorage[c]=n[c];}}return true;}return false;} 47 | function wc(n,v){var dt,e,c;dt=new Date();dt.setTime(dt.getTime()+31536000000);e="; expires="+dt.toGMTString();if(typeof n==="string"&&typeof v==="string"){document.cookie=n+"="+v+e+"; path=/";return true;}else if(typeof n==="object"&&typeof v==="undefined"){for(c in n) {if(n.hasOwnProperty(c)){document.cookie=c+"="+n[c]+e+"; path=/";}}return true;}return false;} 48 | function rls(n){return localStorage[n];} 49 | function rc(n){var nn, ca, i, c;nn=n+"=";ca=document.cookie.split(';');for(i=0;i>16,(b10>>8)&255,b10&255))}switch(pads){case 1:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12)|(_getbyte64(s,i+2)<<6);x.push(String.fromCharCode(b10>>16,(b10>>8)&255));break;case 2:b10=(_getbyte64(s,i)<<18)|(_getbyte64(s,i+1)<<12);x.push(String.fromCharCode(b10>>16));break}return x.join("")}function _getbyte(s,i){var x=s.charCodeAt(i);if(x>255){throw"INVALID_CHARACTER_ERR: DOM Exception 5"}return x}function _encode(s){if(arguments.length!==1){throw"SyntaxError: exactly one argument required"}s=String(s);var i,b10,x=[],imax=s.length-s.length%3;if(s.length===0){return s}for(i=0;i>18));x.push(_ALPHA.charAt((b10>>12)&63));x.push(_ALPHA.charAt((b10>>6)&63));x.push(_ALPHA.charAt(b10&63))}switch(s.length-imax){case 1:b10=_getbyte(s,i)<<16;x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_PADCHAR+_PADCHAR);break;case 2:b10=(_getbyte(s,i)<<16)|(_getbyte(s,i+1)<<8);x.push(_ALPHA.charAt(b10>>18)+_ALPHA.charAt((b10>>12)&63)+_ALPHA.charAt((b10>>6)&63)+_PADCHAR);break}return x.join("")}return{decode:_decode,encode:_encode,VERSION:_VERSION}}(jQuery)); -------------------------------------------------------------------------------- /statics/common/offline/js/jquery.jsonrpc.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | $.extend({ 3 | jsonRPC: { 4 | // RPC Version Number 5 | version: '2.0', 6 | 7 | // End point URL, sets default in requests if not 8 | // specified with the request call 9 | endPoint: null, 10 | 11 | // Default namespace for methods 12 | namespace: null, 13 | 14 | /* 15 | * Provides the RPC client with an optional default endpoint and namespace 16 | * 17 | * @param {object} The params object which can contains 18 | * {string} endPoint The default endpoint for RPC requests 19 | * {string} namespace The default namespace for RPC requests 20 | */ 21 | setup: function(params) { 22 | this._validateConfigParams(params); 23 | this.endPoint = params.endPoint; 24 | this.namespace = params.namespace; 25 | this.auth = this.endPoint.match(/^(?:(?![^:@]+:[^:@\/]*@)[^:\/?#.]+:)?(?:\/\/)?(?:([^:@]*(?::[^:@]*)?)?@)?/)[1]; 26 | return this; 27 | }, 28 | 29 | /* 30 | * Convenience wrapper method to allow you to temporarily set a config parameter 31 | * (endPoint or namespace) and ensure it gets set back to what it was before 32 | * 33 | * @param {object} The params object which can contains 34 | * {string} endPoint The default endpoint for RPC requests 35 | * {string} namespace The default namespace for RPC requests 36 | * @param {function} callback The function to call with the new params in place 37 | */ 38 | withOptions: function(params, callback) { 39 | this._validateConfigParams(params); 40 | // No point in running if there isn't a callback received to run 41 | if(typeof(callback) === 'undefined') throw("No callback specified"); 42 | 43 | origParams = {endPoint: this.endPoint, namespace: this.namespace}; 44 | this.setup(params); 45 | callback.call(this); 46 | this.setup(origParams); 47 | }, 48 | 49 | /* 50 | * Performas a single RPC request 51 | * 52 | * @param {string} method The name of the rpc method to be called 53 | * @param {object} options A collection of object which can contains 54 | * params {array} the params array to send along with the request 55 | * success {function} a function that will be executed if the request succeeds 56 | * error {function} a function that will be executed if the request fails 57 | * url {string} the url to send the request to 58 | * id {string} the provenance id for this request (defaults to 1) 59 | * @return {undefined} 60 | */ 61 | request: function(method, options) { 62 | if(typeof(options) === 'undefined') { 63 | options = { id: 1 }; 64 | } 65 | if (typeof(options.id) === 'undefined') { 66 | options.id = 1; 67 | } 68 | 69 | // Validate method arguments 70 | this._validateRequestMethod(method); 71 | this._validateRequestParams(options.params); 72 | this._validateRequestCallbacks(options.success, options.error); 73 | 74 | // Perform the actual request 75 | this._doRequest(JSON.stringify(this._requestDataObj(method, options.params, options.id)), options); 76 | 77 | return true; 78 | }, 79 | 80 | /* 81 | * Submits multiple requests 82 | * Takes an array of objects that contain a method and params 83 | * 84 | * @params {array} requests an array of request object which can contain 85 | * method {string} the name of the method 86 | * param {object} the params object to be sent with the request 87 | * id {string} the provenance id for the request (defaults to an incrementer starting at 1) 88 | * @param {object} options A collection of object which can contains 89 | * success {function} a function that will be executed if the request succeeds 90 | * error {function} a function that will be executed if the request fails 91 | * url {string} the url to send the request to 92 | * @return {undefined} 93 | */ 94 | batchRequest: function(requests, options) { 95 | if(typeof(options) === 'undefined') { 96 | options = {}; 97 | } 98 | 99 | // Ensure our requests come in as an array 100 | if(!$.isArray(requests) || requests.length === 0) throw("Invalid requests supplied for jsonRPC batchRequest. Must be an array object that contain at least a method attribute"); 101 | 102 | // Make sure each of our request objects are valid 103 | var _that = this; 104 | $.each(requests, function(i, req) { 105 | _that._validateRequestMethod(req.method); 106 | _that._validateRequestParams(req.params); 107 | if (typeof(req.id) === 'undefined') { 108 | req.id = i + 1; 109 | } 110 | }); 111 | this._validateRequestCallbacks(options.success, options.error); 112 | 113 | var data = [], 114 | request; 115 | 116 | // Prepare our request object 117 | for(var i = 0; i 0 && json[0].jsonrpc !== '2.0') || 257 | (!$.isArray(json) && json.jsonrpc !== '2.0')) { 258 | throw 'Version error'; 259 | } 260 | 261 | return json; 262 | } 263 | catch (e) { 264 | return { 265 | error: 'Internal server error: ' + e, 266 | version: '2.0' 267 | } 268 | } 269 | } 270 | } 271 | 272 | } 273 | }); 274 | })(jQuery); 275 | -------------------------------------------------------------------------------- /statics/themes/nexmoe/IMG/OneIndexM.svg: -------------------------------------------------------------------------------- 1 | ONEPHP -------------------------------------------------------------------------------- /statics/themes/nexmoe/css/forkGh.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * "Fork me on GitHub" CSS ribbon v0.2.3 | MIT License 3 | * https://github.com/simonwhitaker/github-fork-ribbon-css 4 | */ 5 | 6 | .github-fork-ribbon { 7 | width: 12.1em; 8 | height: 12.1em; 9 | position: absolute; 10 | overflow: hidden; 11 | top: 0; 12 | right: 0; 13 | z-index: 9999; 14 | pointer-events: none; 15 | font-size: 13px; 16 | text-decoration: none; 17 | text-indent: -999999px; 18 | } 19 | 20 | .github-fork-ribbon.fixed { 21 | position: fixed; 22 | } 23 | 24 | .github-fork-ribbon:hover, .github-fork-ribbon:active { 25 | background-color: rgba(0, 0, 0, 0.0); 26 | } 27 | 28 | .github-fork-ribbon:before, .github-fork-ribbon:after { 29 | /* The right and left classes determine the side we attach our banner to */ 30 | position: absolute; 31 | display: block; 32 | width: 15.38em; 33 | height: 1.54em; 34 | 35 | top: 3.23em; 36 | right: -3.23em; 37 | 38 | -webkit-box-sizing: content-box; 39 | -moz-box-sizing: content-box; 40 | box-sizing: content-box; 41 | 42 | -webkit-transform: rotate(45deg); 43 | -moz-transform: rotate(45deg); 44 | -ms-transform: rotate(45deg); 45 | -o-transform: rotate(45deg); 46 | transform: rotate(45deg); 47 | } 48 | 49 | .github-fork-ribbon:before { 50 | content: ""; 51 | 52 | /* Add a bit of padding to give some substance outside the "stitching" */ 53 | padding: .38em 0; 54 | 55 | /* Set the base colour */ 56 | background-color: #424242; 57 | 58 | /* Set a gradient: transparent black at the top to almost-transparent black at the bottom */ 59 | background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.15))); 60 | background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)); 61 | background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)); 62 | background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)); 63 | background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)); 64 | background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15)); 65 | 66 | /* Add a drop shadow */ 67 | -webkit-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5); 68 | -moz-box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5); 69 | box-shadow: 0 .15em .23em 0 rgba(0, 0, 0, 0.5); 70 | 71 | pointer-events: auto; 72 | } 73 | 74 | .github-fork-ribbon:after { 75 | /* Set the text from the data-ribbon attribute */ 76 | content: attr(data-ribbon); 77 | 78 | /* Set the text properties */ 79 | color: #fff; 80 | font: 700 1em "Helvetica Neue", Helvetica, Arial, sans-serif; 81 | line-height: 1.54em; 82 | text-decoration: none; 83 | text-shadow: 0 -.08em rgba(0, 0, 0, 0.5); 84 | text-align: center; 85 | text-indent: 0; 86 | 87 | /* Set the layout properties */ 88 | padding: .15em 0; 89 | margin: .15em 0; 90 | 91 | /* Add "stitching" effect */ 92 | border-width: .08em 0; 93 | border-style: dotted; 94 | border-color: #fff; 95 | border-color: rgba(255, 255, 255, 0.7); 96 | } 97 | 98 | .github-fork-ribbon.left-top, .github-fork-ribbon.left-bottom { 99 | right: auto; 100 | left: 0; 101 | } 102 | 103 | .github-fork-ribbon.left-bottom, .github-fork-ribbon.right-bottom { 104 | top: auto; 105 | bottom: 0; 106 | } 107 | 108 | .github-fork-ribbon.left-top:before, .github-fork-ribbon.left-top:after, .github-fork-ribbon.left-bottom:before, .github-fork-ribbon.left-bottom:after { 109 | right: auto; 110 | left: -3.23em; 111 | } 112 | 113 | .github-fork-ribbon.left-bottom:before, .github-fork-ribbon.left-bottom:after, .github-fork-ribbon.right-bottom:before, .github-fork-ribbon.right-bottom:after { 114 | top: auto; 115 | bottom: 3.23em; 116 | } 117 | 118 | .github-fork-ribbon.left-top:before, .github-fork-ribbon.left-top:after, .github-fork-ribbon.right-bottom:before, .github-fork-ribbon.right-bottom:after { 119 | -webkit-transform: rotate(-45deg); 120 | -moz-transform: rotate(-45deg); 121 | -ms-transform: rotate(-45deg); 122 | -o-transform: rotate(-45deg); 123 | transform: rotate(-45deg); 124 | } -------------------------------------------------------------------------------- /statics/themes/nexmoe/js/Meting.min.js: -------------------------------------------------------------------------------- 1 | "use strict";function _objectSpread(a){for(var b=1;bb.toUpperCase())}_init(){let a={};for(let b=0;ba.json()).then(a=>this._loadPlayer(a))}_loadPlayer(a){let b={audio:a,mutex:!0,lrcType:this.meta.lrcType||3,storageName:"metingjs"};if(a.length){let a=_objectSpread({},b,this.config);for(let b in a)("true"===a[b]||"false"===a[b])&&(a[b]="true"===a[b]);let c=document.createElement("div");a.container=c,this.appendChild(c),this.aplayer=new APlayer(a)}}}console.log("\n %c MetingJS v2.0.1 %c https://github.com/metowolf/MetingJS \n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;"),window.customElements&&!window.customElements.get("meting-js")&&(window.MetingJSElement=MetingJSElement,window.customElements.define("meting-js",MetingJSElement)); 2 | -------------------------------------------------------------------------------- /statics/themes/nexmoe/js/personjs.js: -------------------------------------------------------------------------------- 1 | var documentWidth=window.screen.availWidth; 2 | var documentHeight=window.screen.availHeight; 3 | if(documentWidth>documentHeight){ 4 | document.getElementsByTagName("body")[0].setAttribute("style","background-size:100% auto") 5 | }else{ 6 | document.getElementsByTagName("body")[0].setAttribute("style","background-size:auto 100%") 7 | } -------------------------------------------------------------------------------- /view/admin/cache.php: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 |
23 | 24 |
25 |

页面缓存 清除所有页面缓存

26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | 37 |
38 | 39 |
40 |
41 | 42 |
43 | 47 |
48 |
49 |
50 | 51 |
52 |

crontab定时刷新缓存 能极大提高系统访问性能

53 |

54 | 添加以下命令到crontab
55 | */10 * * * * 56 |

57 |
58 | 59 |
60 | 68 | -------------------------------------------------------------------------------- /view/admin/images.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 |
7 |

图床 OneImages

8 |
9 |
10 |
11 |

作为网站首页

12 | 13 | 17 |
18 |
19 |

允许游客上传图片

20 | 21 | 25 |
26 |
27 |

允许上传文件类型

28 | 29 |
30 |
31 | 34 |
35 |
36 |
37 | -------------------------------------------------------------------------------- /view/admin/install/install_0.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 | 60 | 61 | 62 |
#环境需求当前环境
1PHP > 5.5
2curl 支持
3config/ 目录可读可写
4cache/ 目录可读可写
Tips建议配合Mintimate's Blog文章和视频操作:博客文章、 59 | 视频教程
63 |
64 |

65 | 66 | 67 | 下一步 68 | 69 | 70 | 71 |
72 | 73 | 74 | -------------------------------------------------------------------------------- /view/admin/install/install_1.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |

程序安装 设置应用ID和机密

8 |
9 | 10 |
11 |

12 | 填入client_idclient_secret, 13 | 根据你的Onedrive供应商选择: 14 |

15 |
16 | 17 |
18 | 19 |
20 | 25 | 26 | 31 |
32 |
33 | https 34 | 35 | 36 |
应用机密不能为空
37 |
38 |
39 |
40 | 41 | 42 | 43 |
应用 ID不能为空
44 |
45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
重定向URL不能为空
56 |
57 |
58 | 上一步 59 | 60 |
61 | 62 | 63 |
64 | 65 | -------------------------------------------------------------------------------- /view/admin/install/install_2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |

程序安装 绑定微软账号

8 |
9 | 10 | 11 | 上一步 12 | 绑定账号 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /view/admin/install/install_3.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |

程序安装 完成安装

8 |
9 | 10 | 11 |

程序安装成功!

12 |

13 | 管理后台(初始密码:MintimateBlog) 14 | 访问网站 15 | 16 |

程序安装失败!

17 |

18 | 重新绑定 19 | 20 | 21 | 22 | 23 |
24 | 25 | -------------------------------------------------------------------------------- /view/admin/install/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | OneIndex <?php e($title);?> 9 | 10 | 11 | 67 | 68 | 69 |
70 |
71 | OneIndex 72 | $l):?> 73 | chevron_right 74 | 75 | 76 | 77 |
78 |
79 | 80 |
81 | 82 |
83 | 84 | 85 | -------------------------------------------------------------------------------- /view/admin/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | OneIndex 系统管理 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | menu 18 | OneIndex 19 |
20 | 登出 21 |
22 |
23 | 67 | 68 | 69 | 70 |
71 | 72 |
73 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /view/admin/login.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |

系统管理

8 |
9 |
10 | https 11 | 12 | 13 |
14 |
15 | 19 |
20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /view/admin/offline.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 |
7 |

上传管理游客前台离线和在线上传

8 |
9 |
10 |
11 |

允许游客离线上传(需安装aria2和rclone,输入远程url即可上传)

12 | 13 | 17 |
18 |
19 |
20 |

允许游客在线上传 (上传游客计算机里的文件)

21 | 22 | 26 |
27 |
28 |
29 |

游客在线上传目录限制(注意:管理员不受此限制)

30 | 31 | 此目录下的readme index head文件无法被渲染 32 |
33 | 36 |
37 |
38 | -------------------------------------------------------------------------------- /view/admin/setpass.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 | 28 |
29 |
30 | -------------------------------------------------------------------------------- /view/admin/settings.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 |
7 |

基本设置 设置OneIndex基本参数

8 |
9 |
10 |
11 |

网站名称

12 | 13 |
14 | 15 |
16 |

网站主题

17 | 30 |
31 | 32 |
33 |

OneDrive起始目录(空为根目录)例:仅共享share目录 /share

34 | 35 |
36 | 37 |
38 |

不渲染目录 该目录下index.html、readme.md、head.md文件不会被渲染

39 | 40 | 设置所有目录都不渲染输入all,设置名为all的目录不渲染,输入/all 41 |
42 | 43 |
44 |

需要隐藏的目录 不需要列出的目录(一行一个) 清空缓存后生效

45 | 46 | 这里是通配识别,就是存在以上字符文件夹一律会隐藏 47 |
48 | 49 | 50 |
51 |

防盗链(白名单) 不填写则不启用, 多个用英文 ; 分割

52 | 53 | 支持通配符 例: *.domain.com 54 |
55 | 56 |
57 |

缓存类型

58 | 65 |
66 | 67 |
68 |

缓存过期时间(秒)

69 | 70 |
71 | 72 |
73 |

去掉地址栏中的/?/ (需配合伪静态使用!!)

74 | 75 | 79 |
80 | 81 | 82 | 83 | 84 | 87 |
88 |
89 | 90 | -------------------------------------------------------------------------------- /view/admin/show.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 |
7 |

文件展示设置 根据不同后缀进行展示。无设置后缀,直连下载

8 |
9 |
10 | $ext):?> 11 |
12 |

13 | 14 |
15 | 16 | 17 | 20 |
21 |
22 | -------------------------------------------------------------------------------- /view/admin/upload.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 | 28 |
29 |
30 |
31 |
32 |
33 |
上传进度
34 |
35 | 36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | $task ):?> 50 | 51 | 52 | 53 | 54 | 55 | 58 | 61 | ($task['update_time']+60)):?> 62 | 63 | 66 | 67 | 68 | 71 | 72 | 73 | 74 | 75 | 76 |
远程路径上传速度进度状态操作
56 | 等待上传中 57 | 59 | 60 | 已暂停 64 | 65 | 上传中 69 | 70 |
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 | $status ):?> 102 | 103 | 104 | 105 | 106 | 107 |
远程路径状态
108 |
109 | 110 |
111 | 114 | -------------------------------------------------------------------------------- /view/common/search.php: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 | 30 | 31 | 32 |
33 | 79 | 80 |
81 |
82 | 139 |
140 |
141 |
142 | 143 | 144 |
145 |
146 |
147 |
148 |
149 | 150 | 151 |
152 |
153 |
154 | 155 |
156 |
157 |
158 |
159 |
160 | 161 |
162 | 163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 | 171 | 172 |
173 |
174 |
175 |
176 | 177 | -------------------------------------------------------------------------------- /view/common/tips.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | -------------------------------------------------------------------------------- /view/themes/classic/404.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 404 Not Found 6 | 7 | 10 | 11 | 12 |

is not found.

13 | 14 | -------------------------------------------------------------------------------- /view/themes/classic/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <?php _($title);?> 6 | 7 | 8 | 31 | 32 | 33 |
34 |
35 | oneindex 36 | chevron_right 37 | admin 38 | chevron_right 39 | setpass 40 |
41 | refresh 42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /view/themes/classic/list.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Index of <?php echo urldecode($path);?> 5 | 6 | 9 | 10 | 11 |

Index of

12 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
NameSizeDate CreatedDate Modified
17 | .. 18 |
/
39 | 40 | -------------------------------------------------------------------------------- /view/themes/material/404.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
404 not found.
5 | -------------------------------------------------------------------------------- /view/themes/material/images/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 |
8 |
OneImages
9 |
10 | 11 | 12 |
13 |
14 | 15 | 16 | 17 |
18 |
19 |
20 | 21 |
22 |
23 | 24 |
25 |
26 | 27 |
28 | 29 | -------------------------------------------------------------------------------- /view/themes/material/images/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php e($title.' - '.config('site_name'));?> 7 | 8 | 9 | 65 | 66 | 67 |
68 |
69 | 70 | $l):?> 71 | chevron_right 72 | 73 | 74 | 75 |
76 |
77 | 78 |
79 | 80 |
81 | 82 | -------------------------------------------------------------------------------- /view/themes/material/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php e($title.' - '.config('site_name'));?> 7 | s 8 | 9 | 65 | 66 | 67 |
68 |
69 | 70 | $l):?> 71 | chevron_right 72 | 73 | 74 | 75 |
76 |
77 | 78 |
79 | 80 |
81 | 82 | -------------------------------------------------------------------------------- /view/themes/material/list.php: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 |
30 | 76 |
77 | 78 |
79 |
80 | face 81 | README.md 82 |
83 | 84 |
85 | 86 |
87 | 140 |
141 | 145 |
146 | 148 | 150 | 152 |
153 |
154 | 157 | 158 | -------------------------------------------------------------------------------- /view/themes/material/password.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |

这是一个受保护的文件夹,您需要提供访问密码才能查看。

8 |
9 |
10 | https 11 | 12 | 13 |
14 |
15 | 19 |
20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /view/themes/material/show/audio.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |
8 |
9 | 10 |
11 |
12 | 13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 | file_download 23 | 24 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /view/themes/material/show/code.php: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 28 |
29 |
30 |
31 |
32 | 33 | 34 |
35 | file_download 36 | 37 | 38 | 39 | 53 | -------------------------------------------------------------------------------- /view/themes/material/show/doc.php: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /view/themes/material/show/image.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 | 8 |
9 |
10 | 11 | 12 |
13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 |
23 | file_download 24 | 25 | -------------------------------------------------------------------------------- /view/themes/material/show/pdf.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | file_download 14 | 30 | -------------------------------------------------------------------------------- /view/themes/material/show/stream.php: -------------------------------------------------------------------------------- 1 | 'application/octet-stream', 5 | 'ppt'=>'application/vnd.ms-powerpoint', 6 | 'xls'=>'application/vnd.ms-excel', 7 | 'doc'=>'application/msword', 8 | 'exe'=>'application/octet-stream', 9 | 'rar'=>'application/octet-stream', 10 | 'js'=>"javascrīpt/js", 11 | 'css'=>"text/css", 12 | 'hqx'=>"application/mac-binhex40", 13 | 'bin'=>"application/octet-stream", 14 | 'oda'=>"application/oda", 15 | 'pdf'=>"application/pdf", 16 | 'ai'=>"application/postsrcipt", 17 | 'eps'=>"application/postsrcipt", 18 | 'es'=>"application/postsrcipt", 19 | 'rtf'=>"application/rtf", 20 | 'mif'=>"application/x-mif", 21 | 'csh'=>"application/x-csh", 22 | 'dvi'=>"application/x-dvi", 23 | 'hdf'=>"application/x-hdf", 24 | 'nc'=>"application/x-netcdf", 25 | 'cdf'=>"application/x-netcdf", 26 | 'latex'=>"application/x-latex", 27 | 'ts'=>"application/x-troll-ts", 28 | 'src'=>"application/x-wais-source", 29 | 'zip'=>"application/zip", 30 | 'bcpio'=>"application/x-bcpio", 31 | 'cpio'=>"application/x-cpio", 32 | 'gtar'=>"application/x-gtar", 33 | 'shar'=>"application/x-shar", 34 | 'sv4cpio'=>"application/x-sv4cpio", 35 | 'sv4crc'=>"application/x-sv4crc", 36 | 'tar'=>"application/x-tar", 37 | 'ustar'=>"application/x-ustar", 38 | 'man'=>"application/x-troff-man", 39 | 'sh'=>"application/x-sh", 40 | 'tcl'=>"application/x-tcl", 41 | 'tex'=>"application/x-tex", 42 | 'texi'=>"application/x-texinfo", 43 | 'texinfo'=>"application/x-texinfo", 44 | 't'=>"application/x-troff", 45 | 'tr'=>"application/x-troff", 46 | 'roff'=>"application/x-troff", 47 | 'shar'=>"application/x-shar", 48 | 'me'=>"application/x-troll-me", 49 | 'ts'=>"application/x-troll-ts", 50 | 'gif'=>"image/gif", 51 | 'jpeg'=>"image/pjpeg", 52 | 'jpg'=>"image/pjpeg", 53 | 'jpe'=>"image/pjpeg", 54 | 'ras'=>"image/x-cmu-raster", 55 | 'pbm'=>"image/x-portable-bitmap", 56 | 'ppm'=>"image/x-portable-pixmap", 57 | 'xbm'=>"image/x-xbitmap", 58 | 'xwd'=>"image/x-xwindowdump", 59 | 'ief'=>"image/ief", 60 | 'tif'=>"image/tiff", 61 | 'tiff'=>"image/tiff", 62 | 'pnm'=>"image/x-portable-anymap", 63 | 'pgm'=>"image/x-portable-graymap", 64 | 'rgb'=>"image/x-rgb", 65 | 'xpm'=>"image/x-xpixmap", 66 | 'txt'=>"text/plain", 67 | 'c'=>"text/plain", 68 | 'cc'=>"text/plain", 69 | 'h'=>"text/plain", 70 | 'html'=>"text/html", 71 | 'htm'=>"text/html", 72 | 'htl'=>"text/html", 73 | 'txt'=>"text/html", 74 | 'php'=>"text/html", 75 | 'rtx'=>"text/richtext", 76 | 'etx'=>"text/x-setext", 77 | 'tsv'=>"text/tab-separated-values", 78 | 'mpeg'=>"video/mpeg", 79 | 'mpg'=>"video/mpeg", 80 | 'mpe'=>"video/mpeg", 81 | 'avi'=>"video/x-msvideo", 82 | 'qt'=>"video/quicktime", 83 | 'mov'=>"video/quicktime", 84 | 'moov'=>"video/quicktime", 85 | 'movie'=>"video/x-sgi-movie", 86 | 'au'=>"audio/basic", 87 | 'snd'=>"audio/basic", 88 | 'wav'=>"audio/x-wav", 89 | 'aif'=>"audio/x-aiff", 90 | 'aiff'=>"audio/x-aiff", 91 | 'aifc'=>"audio/x-aiff", 92 | 'swf'=>"application/x-shockwave-flash", 93 | 'myz'=>"application/myz" 94 | ]; 95 | //大于 5M 跳转为直连下载 96 | if($item['size'] > 5242880){ 97 | header('Location: '.$item['downloadUrl']);exit(); 98 | } 99 | $type = empty($types[$ext])?"application/octet-stream":$types[$ext]; 100 | $content = IndexController::get_content($item); 101 | 102 | header('Content-type: '.$type); 103 | echo $content; 104 | exit(); 105 | ?> 106 | -------------------------------------------------------------------------------- /view/themes/material/show/video.php: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 |
8 |
9 |
10 |
11 | 12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 | '); } ?> 22 | 23 | 34 | file_download 35 | 36 | -------------------------------------------------------------------------------- /view/themes/material/show/video2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | 21 |
22 | 23 | 24 |
25 |
26 | 27 | 28 |
29 |
30 | 41 | file_download 42 | -------------------------------------------------------------------------------- /view/themes/material/show/video5.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 |
9 |
10 | 13 |
14 | 15 |
16 | 17 | 18 |
19 |
20 | 21 | 22 |
23 |
24 | file_download 25 | -------------------------------------------------------------------------------- /view/themes/nexmoe/404.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
404 not found.
5 | -------------------------------------------------------------------------------- /view/themes/nexmoe/images/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 |
8 |
OneImages
9 | 10 |
11 | 12 | 13 | 14 |
15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /view/themes/nexmoe/images/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php e($title.' - '.config('site_name'));?> 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 | 15 | $l):?> 16 | chevron_right 17 | 18 | 19 | 20 |
21 |
22 | 23 |
24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /view/themes/nexmoe/layout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?php e($title.' - '.config('site_name'));?> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 143 | 144 | 145 | 146 | 147 | Fork me on GitHub 149 |
150 |
151 |
152 | 153 | $l):?> 154 | chevron_right 155 | 156 | 157 | 158 |
159 |
160 | 161 |
162 | 163 | 164 | 165 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /view/themes/nexmoe/password.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |

请输入密码

8 |
9 |
10 | https 11 | 12 | 13 |
14 |
15 | 19 |
20 |
21 | 22 |
23 | 24 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/audio.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 |
6 | 7 | 9 | 10 |
11 | 12 |
13 | 14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 |
22 | file_download 23 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/code.php: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 28 |
29 |
30 | 31 |
32 | 33 |
34 | 35 | 36 |
37 | 38 |
39 |
40 | file_download 41 | 42 | 43 | 44 | 58 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/doc.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/image.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 | file_download 28 | 29 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/pdf.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | file_download 14 | 30 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/stream.php: -------------------------------------------------------------------------------- 1 | 'application/octet-stream', 5 | 'ppt'=>'application/vnd.ms-powerpoint', 6 | 'xls'=>'application/vnd.ms-excel', 7 | 'doc'=>'application/msword', 8 | 'exe'=>'application/octet-stream', 9 | 'rar'=>'application/octet-stream', 10 | 'js'=>"javascrīpt/js", 11 | 'css'=>"text/css", 12 | 'hqx'=>"application/mac-binhex40", 13 | 'bin'=>"application/octet-stream", 14 | 'oda'=>"application/oda", 15 | 'pdf'=>"application/pdf", 16 | 'ai'=>"application/postsrcipt", 17 | 'eps'=>"application/postsrcipt", 18 | 'es'=>"application/postsrcipt", 19 | 'rtf'=>"application/rtf", 20 | 'mif'=>"application/x-mif", 21 | 'csh'=>"application/x-csh", 22 | 'dvi'=>"application/x-dvi", 23 | 'hdf'=>"application/x-hdf", 24 | 'nc'=>"application/x-netcdf", 25 | 'cdf'=>"application/x-netcdf", 26 | 'latex'=>"application/x-latex", 27 | 'ts'=>"application/x-troll-ts", 28 | 'src'=>"application/x-wais-source", 29 | 'zip'=>"application/zip", 30 | 'bcpio'=>"application/x-bcpio", 31 | 'cpio'=>"application/x-cpio", 32 | 'gtar'=>"application/x-gtar", 33 | 'shar'=>"application/x-shar", 34 | 'sv4cpio'=>"application/x-sv4cpio", 35 | 'sv4crc'=>"application/x-sv4crc", 36 | 'tar'=>"application/x-tar", 37 | 'ustar'=>"application/x-ustar", 38 | 'man'=>"application/x-troff-man", 39 | 'sh'=>"application/x-sh", 40 | 'tcl'=>"application/x-tcl", 41 | 'tex'=>"application/x-tex", 42 | 'texi'=>"application/x-texinfo", 43 | 'texinfo'=>"application/x-texinfo", 44 | 't'=>"application/x-troff", 45 | 'tr'=>"application/x-troff", 46 | 'roff'=>"application/x-troff", 47 | 'shar'=>"application/x-shar", 48 | 'me'=>"application/x-troll-me", 49 | 'ts'=>"application/x-troll-ts", 50 | 'gif'=>"image/gif", 51 | 'jpeg'=>"image/pjpeg", 52 | 'jpg'=>"image/pjpeg", 53 | 'jpe'=>"image/pjpeg", 54 | 'ras'=>"image/x-cmu-raster", 55 | 'pbm'=>"image/x-portable-bitmap", 56 | 'ppm'=>"image/x-portable-pixmap", 57 | 'xbm'=>"image/x-xbitmap", 58 | 'xwd'=>"image/x-xwindowdump", 59 | 'ief'=>"image/ief", 60 | 'tif'=>"image/tiff", 61 | 'tiff'=>"image/tiff", 62 | 'pnm'=>"image/x-portable-anymap", 63 | 'pgm'=>"image/x-portable-graymap", 64 | 'rgb'=>"image/x-rgb", 65 | 'xpm'=>"image/x-xpixmap", 66 | 'txt'=>"text/plain", 67 | 'c'=>"text/plain", 68 | 'cc'=>"text/plain", 69 | 'h'=>"text/plain", 70 | 'html'=>"text/html", 71 | 'htm'=>"text/html", 72 | 'htl'=>"text/html", 73 | 'txt'=>"text/html", 74 | 'php'=>"text/html", 75 | 'rtx'=>"text/richtext", 76 | 'etx'=>"text/x-setext", 77 | 'tsv'=>"text/tab-separated-values", 78 | 'mpeg'=>"video/mpeg", 79 | 'mpg'=>"video/mpeg", 80 | 'mpe'=>"video/mpeg", 81 | 'avi'=>"video/x-msvideo", 82 | 'qt'=>"video/quicktime", 83 | 'mov'=>"video/quicktime", 84 | 'moov'=>"video/quicktime", 85 | 'movie'=>"video/x-sgi-movie", 86 | 'au'=>"audio/basic", 87 | 'snd'=>"audio/basic", 88 | 'wav'=>"audio/x-wav", 89 | 'aif'=>"audio/x-aiff", 90 | 'aiff'=>"audio/x-aiff", 91 | 'aifc'=>"audio/x-aiff", 92 | 'swf'=>"application/x-shockwave-flash", 93 | 'myz'=>"application/myz" 94 | ]; 95 | //大于 5M 跳转为直连下载 96 | if($item['size'] > 5242880){ 97 | header('Location: '.$item['downloadUrl']);exit(); 98 | } 99 | $type = empty($types[$ext])?"application/octet-stream":$types[$ext]; 100 | $content = IndexController::get_content($item); 101 | 102 | header('Content-type: '.$type); 103 | echo $content; 104 | exit(); 105 | ?> -------------------------------------------------------------------------------- /view/themes/nexmoe/show/video.php: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 |
9 |
10 |
11 |
12 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 |
35 |
36 | 37 | 38 |
39 |
40 |
41 | 58 | file_download 59 | 60 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/video2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | 35 | 36 | 37 |
38 | 39 |
40 | 41 | 42 |
43 |
44 | 45 | 46 |
47 |
48 |
49 | 66 | file_download 67 | 68 | -------------------------------------------------------------------------------- /view/themes/nexmoe/show/video5.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 |
9 |
10 | 13 |
14 | 29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 |
37 |
38 | 39 | 40 |
41 |
42 |
43 | 51 | file_download 52 | -------------------------------------------------------------------------------- /使用及免责协议.md: -------------------------------------------------------------------------------- 1 | 用户须知:无论您是个人或组织、盈利与否、用途如何(包括以学习和研究为目的),均需仔细阅读本协议,包括免除oneindex开发者责任的免责条款及对您的权利限制。请您审阅并接受或不接受本服务条款。如您不同意本服务条款及/或oneindex开发者随时对其的修改,您应不使用或主动取消使用本程序。否则,您的任何对本程序的使用和修改等行为将被视为您对本服务条款全部的完全接受,包括接受oneindex开发者对服务条款随时所做的任何修改。 2 | 3 | 在理解、同意、并遵守本协议的全部条款后,方可开始使用本软件。 4 | 5 | I. 前置条件 6 | 您应完全遵守中国大陆和您提供服务地区的相关法律法规,不得将使用本软件以任何形式用于任何违法用途。 7 | 8 | II. 协议许可的权利 9 | 10 | 您可以在完全遵守本许可协议的基础上,将本软件应用于非商业用途。 11 | 12 | 本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。 13 | 14 | 用户出于自愿而使用本软件,您必须了解使用本软件的风险,oneindex开发者不提供任何形式的技术支持、使用担保,也不承担任何因使用本软件而产生问题的相关责任。 15 | 16 | oneindex开发者不对使用本软件构建的网站或者网站中的展示的文件及内容信息承担责任,,oneindex开发者不承担任何直接、间接或者连带的责任,全部责任由您自行承担。 17 | 18 | oneindex开发者无法全面监控您下载的程序完整性,因此不保证应用程序的合法性、安全性、完整性、真实性或品质等;您同意自行判断并承担所有风险。由此对您及第三人可能造成的损失,oneindex开发者不承担任何直接、间接或者连带的责任。 19 | 20 | III. 代码修改和发布 21 | 22 | 基于本程序代码修改和发布的代码、软件、及构建的网站,与oneindex开发者无关,其产生的责任和后果与oneindex开发者无关,oneindex开发者不承担任何责任。 23 | 24 | 一旦您开始安装、使用、修改oneindex,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的权利的同时,受到相关的约束和限制。 25 | --------------------------------------------------------------------------------