-
Notifications
You must be signed in to change notification settings - Fork 71
/
index.php
106 lines (94 loc) · 2.92 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
require __DIR__.'/init.php';
/**
* 程序安装
*/
//选择OD国际版?世纪互联版。
if (config('area')!=="cn"){
onedrive::$api_url = 'https://graph.microsoft.com/v1.0';
onedrive::$oauth_url = 'https://login.microsoftonline.com/common/oauth2/v2.0';
}else{
onedrive::$api_url = "https://microsoftgraph.chinacloudapi.cn/v1.0";
onedrive::$oauth_url = "https://login.partner.microsoftonline.cn/common/oauth2/v2.0";
}
if( empty( config('refresh_token') ) ){
route::any('/','AdminController@install');
}
/**
* 系统后台
*/
route::group(function(){
return ($_COOKIE['admin'] == md5(config('password').config('refresh_token')) );
},function(){
route::get('/logout','AdminController@logout');
route::any('/admin/','AdminController@settings');
route::any('/admin/cache','AdminController@cache');
route::any('/admin/show','AdminController@show');
route::any('/admin/setpass','AdminController@setpass');
route::any('/admin/images','AdminController@images');
route::any('/admin/offline','AdminController@offline');
route::any('/admin/upload','UploadController@index');
//守护进程
route::any('/admin/upload/run','UploadController@run');
//上传进程
route::post('/admin/upload/task','UploadController@task');
});
//登陆
route::any('/login','AdminController@login');
//onedrive操作
route::any('/offline','CommonController@offline');
route::any('/onlinefileupload','CommonController@onlinefileupload');
route::any('/create_folder','CommonController@create_folder');
route::any('/rename','CommonController@rename');
route::any('/deleteitems','CommonController@deleteitems');
route::any('/search','CommonController@search');
route::any('/paste','CommonController@paste');
route::any('/upload_url','CommonController@upload_url');
//跳转到登陆
route::any('/admin/',function(){
return view::direct(get_absolute_path(dirname($_SERVER['SCRIPT_NAME'])).'?/login');
});
define('VIEW_PATH', ROOT.'view/themes/'.(config('style')?config('style'):'material').'/');
/**
* OneImg
*/
$images = config('images@base');
if( ($_COOKIE['admin'] == md5(config('password').config('refresh_token')) || $images['public']) ){
route::any('/images','ImagesController@index');
if($images['home']){
route::any('/','ImagesController@index');
}
}
/**
* 列目录
*/
route::group(function () {
$hotlink = config('onedrive_hotlink');
// 未启用防盗链
if (!$hotlink) {
return true;
}
// referer 不存在
if (!isset($_SERVER['HTTP_REFERER'])) {
return true;
}
$referer_domain = get_domain($_SERVER['HTTP_REFERER']);
// 当前域本身
if (str_is(get_domain(), $referer_domain)) {
return true;
}
// 白名单
$hotlinks = explode(';', $hotlink);
$referer = false;
foreach ($hotlinks as $_hotlink) {
if (str_is(trim($_hotlink), $referer_domain)) {
$referer = true;
}
}
if (!$referer) {
header('HTTP/1.1 403 Forbidden');
}
return $referer;
}, function() {
route::any('{path:#all}','IndexController@index');
});