Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
443348f822 | ||
|
|
bb943b8551 | ||
|
|
2a1b9af033 | ||
|
|
caa73378e1 | ||
|
|
0b6cb4ba66 | ||
|
|
09270d47cd | ||
|
|
52afcecb0d | ||
|
|
e9743c648f | ||
|
|
064da3da9c | ||
|
|
a1abd4d5ca | ||
|
|
0377867200 | ||
|
|
acb0ac3913 | ||
|
|
cf5aa37633 | ||
|
|
97735aec43 | ||
|
|
a244fb7ffb | ||
|
|
5051a05adf | ||
|
|
89daee97cf | ||
|
|
f1a6d2821e | ||
|
|
00023986b3 | ||
|
|
23ee2630ef | ||
|
|
8ca9a9d628 | ||
|
|
286046b82a | ||
|
|
a868d5df44 | ||
|
|
0a78999463 | ||
|
|
a6211d3382 | ||
|
|
2dc44a92d3 | ||
|
|
925ff9fe90 | ||
|
|
989de97dde | ||
|
|
0d9996c6c8 | ||
|
|
cd56380d39 | ||
|
|
6bd47b2a13 | ||
|
|
bd91e82552 |
+435
-280
@@ -13,7 +13,7 @@ $Base64Env = [
|
|||||||
//'downloadencrypt',
|
//'downloadencrypt',
|
||||||
//'function_name', // used in heroku.
|
//'function_name', // used in heroku.
|
||||||
//'hideFunctionalityFile',
|
//'hideFunctionalityFile',
|
||||||
//'language',
|
//'timezone',
|
||||||
//'passfile',
|
//'passfile',
|
||||||
'sitename',
|
'sitename',
|
||||||
//'theme',
|
//'theme',
|
||||||
@@ -25,6 +25,9 @@ $Base64Env = [
|
|||||||
'guestup_path',
|
'guestup_path',
|
||||||
//'usesharepoint',
|
//'usesharepoint',
|
||||||
'sharepointname',
|
'sharepointname',
|
||||||
|
'shareurl',
|
||||||
|
//'sharecookie',
|
||||||
|
'shareapiurl',
|
||||||
//'siteid',
|
//'siteid',
|
||||||
'public_path',
|
'public_path',
|
||||||
//'refresh_token',
|
//'refresh_token',
|
||||||
@@ -42,7 +45,7 @@ $CommonEnv = [
|
|||||||
'disktag',
|
'disktag',
|
||||||
'function_name', // used in heroku.
|
'function_name', // used in heroku.
|
||||||
'hideFunctionalityFile',
|
'hideFunctionalityFile',
|
||||||
'language',
|
'timezone',
|
||||||
'passfile',
|
'passfile',
|
||||||
'sitename',
|
'sitename',
|
||||||
'theme',
|
'theme',
|
||||||
@@ -59,7 +62,7 @@ $ShowedCommonEnv = [
|
|||||||
//'disktag',
|
//'disktag',
|
||||||
//'function_name', // used in heroku.
|
//'function_name', // used in heroku.
|
||||||
'hideFunctionalityFile',
|
'hideFunctionalityFile',
|
||||||
'language',
|
'timezone',
|
||||||
'passfile',
|
'passfile',
|
||||||
'sitename',
|
'sitename',
|
||||||
'theme',
|
'theme',
|
||||||
@@ -77,6 +80,9 @@ $InnerEnv = [
|
|||||||
'usesharepoint',
|
'usesharepoint',
|
||||||
'sharepointname',
|
'sharepointname',
|
||||||
'siteid',
|
'siteid',
|
||||||
|
'shareurl',
|
||||||
|
//'sharecookie',
|
||||||
|
'shareapiurl',
|
||||||
'public_path',
|
'public_path',
|
||||||
'refresh_token',
|
'refresh_token',
|
||||||
'token_expires',
|
'token_expires',
|
||||||
@@ -94,11 +100,283 @@ $ShowedInnerEnv = [
|
|||||||
//'usesharepoint',
|
//'usesharepoint',
|
||||||
//'sharepointname',
|
//'sharepointname',
|
||||||
//'siteid',
|
//'siteid',
|
||||||
|
//'shareurl',
|
||||||
|
//'sharecookie',
|
||||||
|
//'shareapiurl',
|
||||||
'public_path',
|
'public_path',
|
||||||
//'refresh_token',
|
//'refresh_token',
|
||||||
//'token_expires',
|
//'token_expires',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$timezones = array(
|
||||||
|
'-12'=>'Pacific/Kwajalein',
|
||||||
|
'-11'=>'Pacific/Samoa',
|
||||||
|
'-10'=>'Pacific/Honolulu',
|
||||||
|
'-9'=>'America/Anchorage',
|
||||||
|
'-8'=>'America/Los_Angeles',
|
||||||
|
'-7'=>'America/Denver',
|
||||||
|
'-6'=>'America/Mexico_City',
|
||||||
|
'-5'=>'America/New_York',
|
||||||
|
'-4'=>'America/Caracas',
|
||||||
|
'-3.5'=>'America/St_Johns',
|
||||||
|
'-3'=>'America/Argentina/Buenos_Aires',
|
||||||
|
'-2'=>'America/Noronha',
|
||||||
|
'-1'=>'Atlantic/Azores',
|
||||||
|
'0'=>'UTC',
|
||||||
|
'1'=>'Europe/Paris',
|
||||||
|
'2'=>'Europe/Helsinki',
|
||||||
|
'3'=>'Europe/Moscow',
|
||||||
|
'3.5'=>'Asia/Tehran',
|
||||||
|
'4'=>'Asia/Baku',
|
||||||
|
'4.5'=>'Asia/Kabul',
|
||||||
|
'5'=>'Asia/Karachi',
|
||||||
|
'5.5'=>'Asia/Calcutta', //Asia/Colombo
|
||||||
|
'6'=>'Asia/Dhaka',
|
||||||
|
'6.5'=>'Asia/Rangoon',
|
||||||
|
'7'=>'Asia/Bangkok',
|
||||||
|
'8'=>'Asia/Shanghai',
|
||||||
|
'9'=>'Asia/Tokyo',
|
||||||
|
'9.5'=>'Australia/Darwin',
|
||||||
|
'10'=>'Pacific/Guam',
|
||||||
|
'11'=>'Asia/Magadan',
|
||||||
|
'12'=>'Asia/Kamchatka'
|
||||||
|
);
|
||||||
|
|
||||||
|
function main($path)
|
||||||
|
{
|
||||||
|
global $exts;
|
||||||
|
global $constStr;
|
||||||
|
|
||||||
|
if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) {
|
||||||
|
$constStr['language'] = $_SERVER['firstacceptlanguage'];
|
||||||
|
} else {
|
||||||
|
$prelang = splitfirst($_SERVER['firstacceptlanguage'], '-')[0];
|
||||||
|
foreach ( array_keys($constStr['languages']) as $lang) {
|
||||||
|
if ($prelang == splitfirst($lang, '-')[0]) {
|
||||||
|
$constStr['language'] = $lang;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language'];
|
||||||
|
//if (!$constStr['language']) $constStr['language'] = getConfig('language');
|
||||||
|
/*echo 'firstacceptlanguage:'.$_SERVER['firstacceptlanguage'].'
|
||||||
|
'.'lan:'.$constStr['language'];*/
|
||||||
|
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||||
|
$_SERVER['language'] = $constStr['language'];
|
||||||
|
$_SERVER['timezone'] = getConfig('timezone');
|
||||||
|
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
|
||||||
|
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
|
||||||
|
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||||
|
|
||||||
|
if (getConfig('admin')=='') return install();
|
||||||
|
if (getConfig('adminloginpage')=='') {
|
||||||
|
$adminloginpage = 'admin';
|
||||||
|
} else {
|
||||||
|
$adminloginpage = getConfig('adminloginpage');
|
||||||
|
}
|
||||||
|
if (isset($_GET[$adminloginpage])) {
|
||||||
|
if (isset($_GET['preview'])) {
|
||||||
|
$url = $_SERVER['PHP_SELF'] . '?preview';
|
||||||
|
} else {
|
||||||
|
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||||
|
}
|
||||||
|
if (getConfig('admin')!='') {
|
||||||
|
if ($_POST['password1']==getConfig('admin')) {
|
||||||
|
return adminform('admin',md5($_POST['password1']),$url);
|
||||||
|
} else return adminform();
|
||||||
|
} else {
|
||||||
|
return output('', 302, [ 'Location' => $url ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getConfig('admin')!='')
|
||||||
|
if ( isset($_COOKIE['admin'])&&$_COOKIE['admin']==md5(getConfig('admin')) ) {
|
||||||
|
$_SERVER['admin']=1;
|
||||||
|
$_SERVER['needUpdate'] = needUpdate();
|
||||||
|
} else {
|
||||||
|
$_SERVER['admin']=0;
|
||||||
|
}
|
||||||
|
if (isset($_GET['setup']))
|
||||||
|
if ($_SERVER['admin']) {
|
||||||
|
// setup Environments. 设置,对环境变量操作
|
||||||
|
return EnvOpt($_SERVER['needUpdate']);
|
||||||
|
} else {
|
||||||
|
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
||||||
|
return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SERVER['base_disk_path'] = $_SERVER['base_path'];
|
||||||
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
|
// echo 'count$disk:'.count($disktags);
|
||||||
|
if (count($disktags)>1) {
|
||||||
|
if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
|
||||||
|
$_SERVER['disktag'] = $path;
|
||||||
|
$pos = strpos($path, '/');
|
||||||
|
if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
|
||||||
|
if (!in_array($_SERVER['disktag'], $disktags)) return message('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', 'Error', 404);
|
||||||
|
$path = substr($path, strlen('/'.$_SERVER['disktag']));
|
||||||
|
if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/');
|
||||||
|
} else $_SERVER['disktag'] = $disktags[0];
|
||||||
|
// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.'
|
||||||
|
//';
|
||||||
|
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
|
||||||
|
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
|
||||||
|
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||||
|
$_SERVER['ajax']=0;
|
||||||
|
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
|
||||||
|
|
||||||
|
config_oauth();
|
||||||
|
if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token();
|
||||||
|
$refresh_token = getConfig('refresh_token');
|
||||||
|
//if (!$refresh_token) return get_refresh_token();
|
||||||
|
if (!$refresh_token) {
|
||||||
|
return render_list();
|
||||||
|
} else {
|
||||||
|
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
||||||
|
get_access_token($refresh_token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SERVER['ajax']) {
|
||||||
|
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
||||||
|
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
||||||
|
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
|
||||||
|
$tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['filename']) ),'',$_SERVER['access_token']);
|
||||||
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||||
|
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
||||||
|
savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||||
|
return output($tmp['body'],$tmp['stat']);
|
||||||
|
}
|
||||||
|
if ($_GET['action']=='uploaded_rename') {
|
||||||
|
// rename .scfupload file without login.
|
||||||
|
// 无需登录即可重命名.scfupload后缀文件,filemd5为用户提交,可被构造,问题不大,以后处理
|
||||||
|
$oldname = spurlencode($_GET['filename']);
|
||||||
|
$pos = strrpos($oldname, '.');
|
||||||
|
if ($pos>0) $ext = strtolower(substr($oldname, $pos));
|
||||||
|
$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
|
||||||
|
$data = '{"name":"' . $_GET['filemd5'] . $ext . '"}';
|
||||||
|
//echo $oldname .'<br>'. $data;
|
||||||
|
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
|
||||||
|
if ($tmp['stat']==409) {
|
||||||
|
MSAPI('DELETE',$oldname,'',$_SERVER['access_token']);
|
||||||
|
$tmpbody = json_decode($tmp['body'], true);
|
||||||
|
$tmpbody['name'] = $_GET['filemd5'] . $ext;
|
||||||
|
$tmp['body'] = json_encode($tmpbody);
|
||||||
|
}
|
||||||
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||||
|
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
||||||
|
savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||||
|
return output($tmp['body'],$tmp['stat']);
|
||||||
|
}
|
||||||
|
if ($_GET['action']=='upbigfile') return bigfileupload($path);
|
||||||
|
}
|
||||||
|
if ($_SERVER['admin']) {
|
||||||
|
$tmp = adminoperate($path);
|
||||||
|
if ($tmp['statusCode'] > 0) {
|
||||||
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||||
|
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
||||||
|
savecache('path_' . $path1, json_decode('{}',true), 1);
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401);
|
||||||
|
}
|
||||||
|
$_SERVER['ishidden'] = passhidden($path);
|
||||||
|
if (isset($_GET['thumbnails'])) {
|
||||||
|
if ($_SERVER['ishidden']<4) {
|
||||||
|
if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) {
|
||||||
|
return get_thumbnails_url($path);
|
||||||
|
} else return output(json_encode($exts['img']),400);
|
||||||
|
} else return output('',401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = list_files($path);
|
||||||
|
//echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT);
|
||||||
|
if (isset($_GET['random'])&&$_GET['random']!=='') {
|
||||||
|
if ($_SERVER['ishidden']<4) {
|
||||||
|
$tmp = [];
|
||||||
|
foreach (array_keys($files['children']) as $filename) {
|
||||||
|
if (strtolower(splitlast($filename,'.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['children'][$filename][$_SERVER['DownurlStrName']];
|
||||||
|
}
|
||||||
|
$tmp = array_values($tmp);
|
||||||
|
if (count($tmp)>0) {
|
||||||
|
if (isset($_GET['url'])) return output($tmp[rand(0,count($tmp)-1)], 200);
|
||||||
|
return output('', 302, [ 'Location' => $tmp[rand(0,count($tmp)-1)] ]);
|
||||||
|
} else return output('',404);
|
||||||
|
} else return output('',401);
|
||||||
|
}
|
||||||
|
if (isset($files['file']) && !isset($_GET['preview'])) {
|
||||||
|
// is file && not preview mode
|
||||||
|
if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files[$_SERVER['DownurlStrName']] ]);
|
||||||
|
}
|
||||||
|
if ( isset($files['folder']) || isset($files['file']) ) {
|
||||||
|
return render_list($path, $files);
|
||||||
|
} else {
|
||||||
|
if (!isset($files['error'])) {
|
||||||
|
$files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT);
|
||||||
|
$files['error']['code'] = 'unknownError';
|
||||||
|
$files['error']['stat'] = 500;
|
||||||
|
}
|
||||||
|
return message('<a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><div style="margin:8px;"><pre>' . $files['error']['message'] . '</pre></div><a href="javascript:history.back(-1)">'.getconstStr('Back').'</a>', $files['error']['code'], $files['error']['stat']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_access_token($refresh_token)
|
||||||
|
{
|
||||||
|
if (getConfig('Drive_ver')=='shareurl') {
|
||||||
|
$shareurl = getConfig('shareurl');
|
||||||
|
$tmp1 = splitlast($shareurl, '/')[0];
|
||||||
|
$account = splitlast($tmp1, '/')[1];
|
||||||
|
$tmp1 = splitlast($shareurl, ':')[0];
|
||||||
|
$domain = splitlast($tmp1, '/')[0];
|
||||||
|
if (!isset($_SERVER['sharecookie'])||$_SERVER['sharecookie']=='') $_SERVER['sharecookie'] = curl_request($shareurl,false, [],1)['returnhead']['Set-Cookie'];
|
||||||
|
$response = curl_request(
|
||||||
|
$domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE",
|
||||||
|
'{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}',
|
||||||
|
[ 'Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => $domain, 'Cookie' => $_SERVER['sharecookie'] ]
|
||||||
|
);
|
||||||
|
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||||
|
$_SERVER['access_token'] = splitlast($ret['ListSchema']['.driveAccessToken'],'=')[1];
|
||||||
|
$_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root';
|
||||||
|
if (!$_SERVER['access_token']) {
|
||||||
|
error_log($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
|
||||||
|
error_log('failed to get share access_token. response' . json_encode($ret));
|
||||||
|
throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']);
|
||||||
|
}
|
||||||
|
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
|
||||||
|
savecache('access_token', $_SERVER['access_token']);
|
||||||
|
$tmp = [];
|
||||||
|
$tmp['shareapiurl'] = $_SERVER['api_url'];
|
||||||
|
if (getConfig('shareapiurl')=='') setConfig($tmp);
|
||||||
|
} else {
|
||||||
|
$response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token );
|
||||||
|
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||||
|
if (!isset($ret['access_token'])) {
|
||||||
|
error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token);
|
||||||
|
error_log('failed to get access_token. response' . json_encode($ret));
|
||||||
|
throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
|
||||||
|
}
|
||||||
|
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
|
||||||
|
$_SERVER['access_token'] = $ret['access_token'];
|
||||||
|
savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300);
|
||||||
|
if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function list_files($path)
|
||||||
|
{
|
||||||
|
$path = path_format($path);
|
||||||
|
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
||||||
|
$files = json_decode('{"folder":{}}', true);
|
||||||
|
} elseif (!getConfig('downloadencrypt')) {
|
||||||
|
if ($_SERVER['ishidden']==4) $files = json_decode('{"folder":{}}', true);
|
||||||
|
else $files = fetch_files($path);
|
||||||
|
} else {
|
||||||
|
$files = fetch_files($path);
|
||||||
|
}
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
function isHideFile($name)
|
function isHideFile($name)
|
||||||
{
|
{
|
||||||
$FunctionalityFile = [
|
$FunctionalityFile = [
|
||||||
@@ -115,14 +393,12 @@ function isHideFile($name)
|
|||||||
|
|
||||||
function getcache($str)
|
function getcache($str)
|
||||||
{
|
{
|
||||||
//$cache = null;
|
|
||||||
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
||||||
return $cache->fetch($str);
|
return $cache->fetch($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function savecache($key, $value, $exp = 1800)
|
function savecache($key, $value, $exp = 1800)
|
||||||
{
|
{
|
||||||
//$cache = null;
|
|
||||||
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
||||||
$cache->save($key, $value, $exp);
|
$cache->save($key, $value, $exp);
|
||||||
}
|
}
|
||||||
@@ -139,6 +415,12 @@ function config_oauth()
|
|||||||
$_SERVER['sitename'] = getConfig('sitename');
|
$_SERVER['sitename'] = getConfig('sitename');
|
||||||
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
|
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
|
||||||
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
||||||
|
if (getConfig('Drive_ver')=='shareurl') {
|
||||||
|
$_SERVER['api_url'] = getConfig('shareapiurl');
|
||||||
|
$_SERVER['sharecookie'] = getConfig('sharecookie');
|
||||||
|
$_SERVER['DownurlStrName'] = '@content.downloadUrl';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (getConfig('Drive_ver')=='MS') {
|
if (getConfig('Drive_ver')=='MS') {
|
||||||
// MS
|
// MS
|
||||||
// https://portal.azure.com
|
// https://portal.azure.com
|
||||||
@@ -169,6 +451,7 @@ function config_oauth()
|
|||||||
}
|
}
|
||||||
$_SERVER['client_secret'] = urlencode($_SERVER['client_secret']);
|
$_SERVER['client_secret'] = urlencode($_SERVER['client_secret']);
|
||||||
$_SERVER['scope'] = urlencode($_SERVER['scope']);
|
$_SERVER['scope'] = urlencode($_SERVER['scope']);
|
||||||
|
$_SERVER['DownurlStrName'] = '@microsoft.graph.downloadUrl';
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_siteid($access_token)
|
function get_siteid($access_token)
|
||||||
@@ -180,8 +463,6 @@ function get_siteid($access_token)
|
|||||||
while ($url!=''&&$response['stat']!=200&&$i<4) {
|
while ($url!=''&&$response['stat']!=200&&$i<4) {
|
||||||
$response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
|
$response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
|
||||||
$i++;
|
$i++;
|
||||||
//echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].'
|
|
||||||
//';
|
|
||||||
}
|
}
|
||||||
if ($response['stat']!=200) {
|
if ($response['stat']!=200) {
|
||||||
error_log('failed to get siteid. response' . json_encode($response));
|
error_log('failed to get siteid. response' . json_encode($response));
|
||||||
@@ -251,7 +532,9 @@ function equal_replace($str, $add = false)
|
|||||||
|
|
||||||
function is_guestup_path($path)
|
function is_guestup_path($path)
|
||||||
{
|
{
|
||||||
if (path_format('/'.path_format(urldecode($_SERVER['list_path'].path_format($path))).'/')==path_format('/'.path_format(getConfig('guestup_path')).'/')&&getConfig('guestup_path')!='') return 1;
|
$a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/');
|
||||||
|
$a2 = path_format(path_format(getConfig('guestup_path')).'/');
|
||||||
|
if (getConfig('guestup_path')!=''&&strtolower($a1)==strtolower($a2)) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +595,7 @@ function comppass($pass)
|
|||||||
if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass ) {
|
if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass ) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
$_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour'));
|
$_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour'));
|
||||||
date_default_timezone_set(get_timezone($_COOKIE['timezone']));
|
date_default_timezone_set(get_timezone($_SERVER['timezone']));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3;
|
if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3;
|
||||||
@@ -336,7 +619,7 @@ function gethiddenpass($path,$passfile)
|
|||||||
$ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
|
$ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
|
||||||
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
|
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
|
||||||
if (isset($ispassfile['file'])) {
|
if (isset($ispassfile['file'])) {
|
||||||
$arr = curl_request($ispassfile['@microsoft.graph.downloadUrl']);
|
$arr = curl_request($ispassfile[$_SERVER['DownurlStrName']]);
|
||||||
if ($arr['stat']==200) {
|
if ($arr['stat']==200) {
|
||||||
$passwordf=explode("\n",$arr['body']);
|
$passwordf=explode("\n",$arr['body']);
|
||||||
$password=$passwordf[0];
|
$password=$passwordf[0];
|
||||||
@@ -369,39 +652,7 @@ function gethiddenpass($path,$passfile)
|
|||||||
|
|
||||||
function get_timezone($timezone = '8')
|
function get_timezone($timezone = '8')
|
||||||
{
|
{
|
||||||
$timezones = array(
|
global $timezones;
|
||||||
'-12'=>'Pacific/Kwajalein',
|
|
||||||
'-11'=>'Pacific/Samoa',
|
|
||||||
'-10'=>'Pacific/Honolulu',
|
|
||||||
'-9'=>'America/Anchorage',
|
|
||||||
'-8'=>'America/Los_Angeles',
|
|
||||||
'-7'=>'America/Denver',
|
|
||||||
'-6'=>'America/Mexico_City',
|
|
||||||
'-5'=>'America/New_York',
|
|
||||||
'-4'=>'America/Caracas',
|
|
||||||
'-3.5'=>'America/St_Johns',
|
|
||||||
'-3'=>'America/Argentina/Buenos_Aires',
|
|
||||||
'-2'=>'America/Noronha',
|
|
||||||
'-1'=>'Atlantic/Azores',
|
|
||||||
'0'=>'UTC',
|
|
||||||
'1'=>'Europe/Paris',
|
|
||||||
'2'=>'Europe/Helsinki',
|
|
||||||
'3'=>'Europe/Moscow',
|
|
||||||
'3.5'=>'Asia/Tehran',
|
|
||||||
'4'=>'Asia/Baku',
|
|
||||||
'4.5'=>'Asia/Kabul',
|
|
||||||
'5'=>'Asia/Karachi',
|
|
||||||
'5.5'=>'Asia/Calcutta', //Asia/Colombo
|
|
||||||
'6'=>'Asia/Dhaka',
|
|
||||||
'6.5'=>'Asia/Rangoon',
|
|
||||||
'7'=>'Asia/Bangkok',
|
|
||||||
'8'=>'Asia/Shanghai',
|
|
||||||
'9'=>'Asia/Tokyo',
|
|
||||||
'9.5'=>'Australia/Darwin',
|
|
||||||
'10'=>'Pacific/Guam',
|
|
||||||
'11'=>'Asia/Magadan',
|
|
||||||
'12'=>'Asia/Kamchatka'
|
|
||||||
);
|
|
||||||
if ($timezone=='') $timezone = '8';
|
if ($timezone=='') $timezone = '8';
|
||||||
return $timezones[$timezone];
|
return $timezones[$timezone];
|
||||||
}
|
}
|
||||||
@@ -427,7 +678,7 @@ function message($message, $title = 'Message', $statusCode = 200)
|
|||||||
|
|
||||||
function needUpdate()
|
function needUpdate()
|
||||||
{
|
{
|
||||||
$current_ver = file_get_contents(__DIR__ . '/../version');
|
$current_ver = file_get_contents(__DIR__ . '/version');
|
||||||
$current_ver = substr($current_ver, strpos($current_ver, '.')+1);
|
$current_ver = substr($current_ver, strpos($current_ver, '.')+1);
|
||||||
$current_ver = explode(urldecode('%0A'),$current_ver)[0];
|
$current_ver = explode(urldecode('%0A'),$current_ver)[0];
|
||||||
$current_ver = explode(urldecode('%0D'),$current_ver)[0];
|
$current_ver = explode(urldecode('%0D'),$current_ver)[0];
|
||||||
@@ -526,7 +777,7 @@ function bigfileupload($path)
|
|||||||
$getoldupinfo=fetch_files(path_format($path . '/' . $cachefilename));
|
$getoldupinfo=fetch_files(path_format($path . '/' . $cachefilename));
|
||||||
//echo json_encode($getoldupinfo, JSON_PRETTY_PRINT);
|
//echo json_encode($getoldupinfo, JSON_PRETTY_PRINT);
|
||||||
if (isset($getoldupinfo['file'])&&$getoldupinfo['size']<5120) {
|
if (isset($getoldupinfo['file'])&&$getoldupinfo['size']<5120) {
|
||||||
$getoldupinfo_j = curl_request($getoldupinfo['@microsoft.graph.downloadUrl']);
|
$getoldupinfo_j = curl_request($getoldupinfo[$_SERVER['DownurlStrName']]);
|
||||||
$getoldupinfo = json_decode($getoldupinfo_j['body'], true);
|
$getoldupinfo = json_decode($getoldupinfo_j['body'], true);
|
||||||
if ( json_decode( curl_request($getoldupinfo['uploadUrl'])['body'], true)['@odata.context']!='' ) return output($getoldupinfo_j['body'], $getoldupinfo_j['stat']);
|
if ( json_decode( curl_request($getoldupinfo['uploadUrl'])['body'], true)['@odata.context']!='' ) return output($getoldupinfo_j['body'], $getoldupinfo_j['stat']);
|
||||||
}
|
}
|
||||||
@@ -541,194 +792,6 @@ function bigfileupload($path)
|
|||||||
return output('error', 400);
|
return output('error', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
function main($path)
|
|
||||||
{
|
|
||||||
global $exts;
|
|
||||||
global $constStr;
|
|
||||||
//echo 'main.enterpath:'.$path.'
|
|
||||||
//';
|
|
||||||
if (isset($_COOKIE['language'])) $constStr['language'] = $_COOKIE['language'];
|
|
||||||
if (!$constStr['language']) $constStr['language'] = getConfig('language');
|
|
||||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
|
||||||
$_SERVER['language'] = $constStr['language'];
|
|
||||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
|
||||||
|
|
||||||
if (getConfig('admin')=='') return install();
|
|
||||||
if (getConfig('adminloginpage')=='') {
|
|
||||||
$adminloginpage = 'admin';
|
|
||||||
} else {
|
|
||||||
$adminloginpage = getConfig('adminloginpage');
|
|
||||||
}
|
|
||||||
if (isset($_GET[$adminloginpage])) {
|
|
||||||
if (isset($_GET['preview'])) {
|
|
||||||
$url = $_SERVER['PHP_SELF'] . '?preview';
|
|
||||||
} else {
|
|
||||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
|
||||||
}
|
|
||||||
if (getConfig('admin')!='') {
|
|
||||||
if ($_POST['password1']==getConfig('admin')) {
|
|
||||||
return adminform('admin',md5($_POST['password1']),$url);
|
|
||||||
} else return adminform();
|
|
||||||
} else {
|
|
||||||
return output('', 302, [ 'Location' => $url ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getConfig('admin')!='')
|
|
||||||
if ( (isset($_COOKIE['admin'])&&$_COOKIE['admin']==md5(getConfig('admin'))) || (isset($_POST['password1'])&&$_POST['password1']==getConfig('admin')) ) {
|
|
||||||
$_SERVER['admin']=1;
|
|
||||||
$_SERVER['needUpdate'] = needUpdate();
|
|
||||||
} else {
|
|
||||||
$_SERVER['admin']=0;
|
|
||||||
}
|
|
||||||
if (isset($_GET['setup']))
|
|
||||||
if ($_SERVER['admin']) {
|
|
||||||
// setup Environments. 设置,对环境变量操作
|
|
||||||
return EnvOpt($_SERVER['needUpdate']);
|
|
||||||
} else {
|
|
||||||
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
|
||||||
return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SERVER['base_disk_path'] = $_SERVER['base_path'];
|
|
||||||
$disktags = explode("|",getConfig('disktag'));
|
|
||||||
// echo 'count$disk:'.count($disktags);
|
|
||||||
if (count($disktags)>1) {
|
|
||||||
if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
|
|
||||||
$_SERVER['disktag'] = $path;
|
|
||||||
$pos = strpos($path, '/');
|
|
||||||
if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
|
|
||||||
if (!in_array($_SERVER['disktag'], $disktags)) return message('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', 'Error', 404);
|
|
||||||
$path = substr($path, strlen('/'.$_SERVER['disktag']));
|
|
||||||
if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/');
|
|
||||||
} else $_SERVER['disktag'] = $disktags[0];
|
|
||||||
// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.'
|
|
||||||
//';
|
|
||||||
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
|
|
||||||
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
|
|
||||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
|
||||||
$_SERVER['ajax']=0;
|
|
||||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
|
|
||||||
|
|
||||||
config_oauth();
|
|
||||||
if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token();
|
|
||||||
$refresh_token = getConfig('refresh_token');
|
|
||||||
//if (!$refresh_token) return get_refresh_token();
|
|
||||||
if (!$refresh_token) {
|
|
||||||
return render_list();
|
|
||||||
} else {
|
|
||||||
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
|
||||||
$response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token );
|
|
||||||
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
|
||||||
if (!isset($ret['access_token'])) {
|
|
||||||
error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token);
|
|
||||||
error_log('failed to get access_token. response' . json_encode($ret));
|
|
||||||
throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
|
|
||||||
}
|
|
||||||
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
|
|
||||||
$_SERVER['access_token'] = $ret['access_token'];
|
|
||||||
savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300);
|
|
||||||
if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_SERVER['ajax']) {
|
|
||||||
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
|
||||||
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
|
||||||
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
|
|
||||||
$tmp = MSAPI('DELETE',path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($_GET['filename']) ),'',$_SERVER['access_token']);
|
|
||||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
|
||||||
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
|
||||||
savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
||||||
return output($tmp['body'],$tmp['stat']);
|
|
||||||
}
|
|
||||||
if ($_GET['action']=='uploaded_rename') {
|
|
||||||
// rename .scfupload file without login.
|
|
||||||
// 无需登录即可重命名.scfupload后缀文件,filemd5为用户提交,可被构造,问题不大,以后处理
|
|
||||||
$oldname = spurlencode($_GET['filename']);
|
|
||||||
$pos = strrpos($oldname, '.');
|
|
||||||
if ($pos>0) $ext = strtolower(substr($oldname, $pos));
|
|
||||||
$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
|
|
||||||
$data = '{"name":"' . $_GET['filemd5'] . $ext . '"}';
|
|
||||||
//echo $oldname .'<br>'. $data;
|
|
||||||
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
|
|
||||||
if ($tmp['stat']==409) {
|
|
||||||
MSAPI('DELETE',$oldname,'',$_SERVER['access_token']);
|
|
||||||
$tmpbody = json_decode($tmp['body'], true);
|
|
||||||
$tmpbody['name'] = $_GET['filemd5'] . $ext;
|
|
||||||
$tmp['body'] = json_encode($tmpbody);
|
|
||||||
}
|
|
||||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
|
||||||
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
|
||||||
savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
||||||
return output($tmp['body'],$tmp['stat']);
|
|
||||||
}
|
|
||||||
if ($_GET['action']=='upbigfile') return bigfileupload($path);
|
|
||||||
}
|
|
||||||
if ($_SERVER['admin']) {
|
|
||||||
$tmp = adminoperate($path);
|
|
||||||
if ($tmp['statusCode'] > 0) {
|
|
||||||
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
|
||||||
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
|
||||||
savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
||||||
return $tmp;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401);
|
|
||||||
}
|
|
||||||
$_SERVER['ishidden'] = passhidden($path);
|
|
||||||
if (isset($_GET['thumbnails'])) {
|
|
||||||
if ($_SERVER['ishidden']<4) {
|
|
||||||
if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) {
|
|
||||||
return get_thumbnails_url($path);
|
|
||||||
} else return output(json_encode($exts['img']),400);
|
|
||||||
} else return output('',401);
|
|
||||||
}
|
|
||||||
|
|
||||||
$files = list_files($path);
|
|
||||||
//echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT);
|
|
||||||
if (isset($_GET['random'])&&$_GET['random']!=='') {
|
|
||||||
if ($_SERVER['ishidden']<4) {
|
|
||||||
$tmp = [];
|
|
||||||
foreach (array_keys($files['children']) as $filename) {
|
|
||||||
if (strtolower(splitlast($filename,'.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['children'][$filename]['@microsoft.graph.downloadUrl'];
|
|
||||||
}
|
|
||||||
$tmp = array_values($tmp);
|
|
||||||
if (count($tmp)>0) {
|
|
||||||
if (isset($_GET['url'])) return output($tmp[rand(0,count($tmp)-1)], 200);
|
|
||||||
return output('', 302, [ 'Location' => $tmp[rand(0,count($tmp)-1)] ]);
|
|
||||||
} else return output('',404);
|
|
||||||
} else return output('',401);
|
|
||||||
}
|
|
||||||
if (isset($files['file']) && !isset($_GET['preview'])) {
|
|
||||||
// is file && not preview mode
|
|
||||||
if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
|
|
||||||
}
|
|
||||||
if ( isset($files['folder']) || isset($files['file']) ) {
|
|
||||||
return render_list($path, $files);
|
|
||||||
} else {
|
|
||||||
if (!isset($files['error'])) {
|
|
||||||
$files['error']['message'] = json_encode($files, JSON_PRETTY_PRINT);
|
|
||||||
$files['error']['code'] = 'unknownError';
|
|
||||||
$files['error']['stat'] = 500;
|
|
||||||
}
|
|
||||||
return message('<a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><div style="margin:8px;"><pre>' . $files['error']['message'] . '</pre></div><a href="javascript:history.back(-1)">'.getconstStr('Back').'</a>', $files['error']['code'], $files['error']['stat']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function list_files($path)
|
|
||||||
{
|
|
||||||
$path = path_format($path);
|
|
||||||
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
|
||||||
$files = json_decode('{"folder":{}}', true);
|
|
||||||
} elseif (!getConfig('downloadencrypt')) {
|
|
||||||
if ($_SERVER['ishidden']==4) $files = json_decode('{"folder":{}}', true);
|
|
||||||
else $files = fetch_files($path);
|
|
||||||
} else {
|
|
||||||
$files = fetch_files($path);
|
|
||||||
}
|
|
||||||
return $files;
|
|
||||||
}
|
|
||||||
|
|
||||||
function adminform($name = '', $pass = '', $path = '')
|
function adminform($name = '', $pass = '', $path = '')
|
||||||
{
|
{
|
||||||
$statusCode = 401;
|
$statusCode = 401;
|
||||||
@@ -891,18 +954,36 @@ function adminoperate($path)
|
|||||||
return $tmparr;
|
return $tmparr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function splitfirst($str, $split)
|
||||||
|
{
|
||||||
|
$len = strlen($split);
|
||||||
|
$pos = strpos($str, $split);
|
||||||
|
if ($pos===false) {
|
||||||
|
$tmp[0] = $str;
|
||||||
|
$tmp[1] = '';
|
||||||
|
} elseif ($pos>0) {
|
||||||
|
$tmp[0] = substr($str, 0, $pos);
|
||||||
|
$tmp[1] = substr($str, $pos+$len);
|
||||||
|
} else {
|
||||||
|
$tmp[0] = '';
|
||||||
|
$tmp[1] = substr($str, $len);
|
||||||
|
}
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
function splitlast($str, $split)
|
function splitlast($str, $split)
|
||||||
{
|
{
|
||||||
|
$len = strlen($split);
|
||||||
$pos = strrpos($str, $split);
|
$pos = strrpos($str, $split);
|
||||||
if ($pos===false) {
|
if ($pos===false) {
|
||||||
$tmp[0] = $str;
|
$tmp[0] = $str;
|
||||||
$tmp[1] = '';
|
$tmp[1] = '';
|
||||||
} elseif ($pos>0) {
|
} elseif ($pos>0) {
|
||||||
$tmp[0] = substr($str, 0, $pos);
|
$tmp[0] = substr($str, 0, $pos);
|
||||||
$tmp[1] = substr($str, $pos+1);
|
$tmp[1] = substr($str, $pos+$len);
|
||||||
} else {
|
} else {
|
||||||
$tmp[0] = '';
|
$tmp[0] = '';
|
||||||
$tmp[1] = substr($str, 1);
|
$tmp[1] = substr($str, $len);
|
||||||
}
|
}
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
@@ -990,10 +1071,10 @@ function fetch_files($path = '/')
|
|||||||
if ($parentpath=='') $parentpath = '/';
|
if ($parentpath=='') $parentpath = '/';
|
||||||
$filename = $pos[1];
|
$filename = $pos[1];
|
||||||
if ($parentfiles = getcache('path_' . $parentpath)) {
|
if ($parentfiles = getcache('path_' . $parentpath)) {
|
||||||
if (isset($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl'])) {
|
if (isset($parentfiles['children'][$filename][$_SERVER['DownurlStrName']])) {
|
||||||
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
|
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
|
||||||
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
|
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
|
||||||
$content1 = curl_request($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl']);
|
$content1 = curl_request($parentfiles['children'][$filename][$_SERVER['DownurlStrName']]);
|
||||||
$parentfiles['children'][$filename]['content'] = $content1;
|
$parentfiles['children'][$filename]['content'] = $content1;
|
||||||
savecache('path_' . $parentpath, $parentfiles);
|
savecache('path_' . $parentpath, $parentfiles);
|
||||||
}
|
}
|
||||||
@@ -1007,16 +1088,16 @@ function fetch_files($path = '/')
|
|||||||
$url .= ':' . $path;
|
$url .= ':' . $path;
|
||||||
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
||||||
}
|
}
|
||||||
$url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl)';
|
$url .= '?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'].')';
|
||||||
$retry = 0;
|
$retry = 0;
|
||||||
$arr = [];
|
$arr = [];
|
||||||
while ($retry<3&&!$arr['stat']) {
|
while ($retry<3&&!$arr['stat']) {
|
||||||
$arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']]);
|
$arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']],1);
|
||||||
$retry++;
|
$retry++;
|
||||||
}
|
}
|
||||||
if ($arr['stat']<500) {
|
if ($arr['stat']<500) {
|
||||||
$files = json_decode($arr['body'], true);
|
$files = json_decode($arr['body'], true);
|
||||||
// echo $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
|
//echo $path . '<br><pre>' . json_encode($arr, JSON_PRETTY_PRINT) . '</pre>';
|
||||||
if (isset($files['folder'])) {
|
if (isset($files['folder'])) {
|
||||||
if ($files['folder']['childCount']>200) {
|
if ($files['folder']['childCount']>200) {
|
||||||
// files num > 200 , then get nextlink
|
// files num > 200 , then get nextlink
|
||||||
@@ -1031,6 +1112,15 @@ function fetch_files($path = '/')
|
|||||||
savecache('path_' . $path, $files);
|
savecache('path_' . $path, $files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($files['file'])) {
|
||||||
|
if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
|
||||||
|
if (!(isset($files['content'])&&$files['content']['stat']==200)) {
|
||||||
|
$content1 = curl_request($files[$_SERVER['DownurlStrName']]);
|
||||||
|
$files['content'] = $content1;
|
||||||
|
savecache('path_' . $path, $files);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isset($files['error'])) {
|
if (isset($files['error'])) {
|
||||||
$files['error']['stat'] = $arr['stat'];
|
$files['error']['stat'] = $arr['stat'];
|
||||||
}
|
}
|
||||||
@@ -1072,7 +1162,7 @@ function fetch_files_children($files, $path, $page)
|
|||||||
// down cache file get jump info. 下载cache文件获取跳页链接
|
// down cache file get jump info. 下载cache文件获取跳页链接
|
||||||
$cachefile = fetch_files(path_format($path1 . '/' .$cachefilename));
|
$cachefile = fetch_files(path_format($path1 . '/' .$cachefilename));
|
||||||
if ($cachefile['size']>0) {
|
if ($cachefile['size']>0) {
|
||||||
$pageinfo = curl_request($cachefile['@microsoft.graph.downloadUrl'])['body'];
|
$pageinfo = curl_request($cachefile[$_SERVER['DownurlStrName']])['body'];
|
||||||
$pageinfo = json_decode($pageinfo,true);
|
$pageinfo = json_decode($pageinfo,true);
|
||||||
for ($page4=1;$page4<$maxpage;$page4++) {
|
for ($page4=1;$page4<$maxpage;$page4++) {
|
||||||
savecache('nextlink_' . $path . '_page_' . $page4, $pageinfo['nextlink_' . $path . '_page_' . $page4]);
|
savecache('nextlink_' . $path . '_page_' . $page4, $pageinfo['nextlink_' . $path . '_page_' . $page4]);
|
||||||
@@ -1089,9 +1179,9 @@ function fetch_files_children($files, $path, $page)
|
|||||||
if ($path !== '/') {
|
if ($path !== '/') {
|
||||||
$url .= ':' . $path;
|
$url .= ':' . $path;
|
||||||
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
||||||
$url .= ':/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl';
|
$url .= ':/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
|
||||||
} else {
|
} else {
|
||||||
$url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl';
|
$url .= '/children?$select=name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
|
||||||
}
|
}
|
||||||
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
||||||
// echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
// echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
||||||
@@ -1171,7 +1261,7 @@ function render_list($path = '', $files = '')
|
|||||||
global $constStr;
|
global $constStr;
|
||||||
|
|
||||||
if (isset($files['children']['index.html']) && !$_SERVER['admin']) {
|
if (isset($files['children']['index.html']) && !$_SERVER['admin']) {
|
||||||
$htmlcontent = fetch_files(spurlencode(path_format($path . '/index.html'),'/'))['content'];
|
$htmlcontent = fetch_files(spurlencode(path_format(urldecode($path) . '/index.html'),'/'))['content'];
|
||||||
return output($htmlcontent['body'], $htmlcontent['stat']);
|
return output($htmlcontent['body'], $htmlcontent['stat']);
|
||||||
}
|
}
|
||||||
$path = str_replace('%20','%2520',$path);
|
$path = str_replace('%20','%2520',$path);
|
||||||
@@ -1184,14 +1274,27 @@ function render_list($path = '', $files = '')
|
|||||||
if (isset($files['file'])) {
|
if (isset($files['file'])) {
|
||||||
$pretitle = str_replace('&','&', $files['name']);
|
$pretitle = str_replace('&','&', $files['name']);
|
||||||
$n_path = $pretitle;
|
$n_path = $pretitle;
|
||||||
|
$tmp = splitlast(splitlast($path,'/')[0],'/');
|
||||||
|
if ($tmp[1]=='') {
|
||||||
|
$p_path = $tmp[0];
|
||||||
} else {
|
} else {
|
||||||
$pretitle = substr($path,-1)=='/'?substr($path,0,-1):$path;
|
$p_path = $tmp[1];
|
||||||
$n_path=substr($pretitle,strrpos($pretitle,'/')+1);
|
}
|
||||||
$pretitle = substr($pretitle,1);
|
} else {
|
||||||
|
if (substr($path,0,1)=='/') $pretitle = substr($path,1);
|
||||||
|
if (substr($path,-1)=='/') $pretitle = substr($path,0,-1);
|
||||||
|
$tmp=splitlast($pretitle,'/');
|
||||||
|
if ($tmp[1]=='') {
|
||||||
|
$n_path = $tmp[0];
|
||||||
|
} else {
|
||||||
|
$n_path = $tmp[1];
|
||||||
|
$tmp = splitlast($tmp[0],'/');
|
||||||
|
if ($tmp[1]=='') {
|
||||||
|
$p_path = $tmp[0];
|
||||||
|
} else {
|
||||||
|
$p_path = $tmp[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (strrpos($path,'/')!=0) {
|
|
||||||
$p_path=substr($path,0,strrpos($path,'/'));
|
|
||||||
$p_path=substr($p_path,strrpos($p_path,'/')+1);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pretitle = getconstStr('Home');
|
$pretitle = getconstStr('Home');
|
||||||
@@ -1201,7 +1304,7 @@ function render_list($path = '', $files = '')
|
|||||||
$p_path=str_replace('&','&',$p_path);
|
$p_path=str_replace('&','&',$p_path);
|
||||||
$pretitle = str_replace('%23','#',$pretitle);
|
$pretitle = str_replace('%23','#',$pretitle);
|
||||||
$statusCode=200;
|
$statusCode=200;
|
||||||
date_default_timezone_set(get_timezone($_COOKIE['timezone']));
|
date_default_timezone_set(get_timezone($_SERVER['timezone']));
|
||||||
@ob_start();
|
@ob_start();
|
||||||
|
|
||||||
$theme = getConfig('theme');
|
$theme = getConfig('theme');
|
||||||
@@ -1275,7 +1378,7 @@ function get_refresh_token()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($_GET['install0'])) {
|
if (isset($_GET['install0'])) {
|
||||||
if ($_POST['disktag_add']!='' && ($_POST['Drive_ver']=='MS' || $_POST['Drive_ver']=='CN')) {
|
if ($_POST['disktag_add']!='') {
|
||||||
if (in_array($_COOKIE['disktag'], $CommonEnv)) {
|
if (in_array($_COOKIE['disktag'], $CommonEnv)) {
|
||||||
return message('Do not input ' . $envs . '<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button><script>document.cookie=\'disktag=; path=/\';</script>', 'Error', 201);
|
return message('Do not input ' . $envs . '<br><button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button><script>document.cookie=\'disktag=; path=/\';</script>', 'Error', 201);
|
||||||
}
|
}
|
||||||
@@ -1283,6 +1386,10 @@ function get_refresh_token()
|
|||||||
$tmp['disktag_add'] = $_POST['disktag_add'];
|
$tmp['disktag_add'] = $_POST['disktag_add'];
|
||||||
$tmp['diskname'] = $_POST['diskname'];
|
$tmp['diskname'] = $_POST['diskname'];
|
||||||
$tmp['Drive_ver'] = $_POST['Drive_ver'];
|
$tmp['Drive_ver'] = $_POST['Drive_ver'];
|
||||||
|
if ($_POST['Drive_ver']=='shareurl') {
|
||||||
|
$tmp['shareurl'] = $_POST['shareurl'];
|
||||||
|
$tmp['refresh_token'] = 1;
|
||||||
|
} else {
|
||||||
if ($_POST['Drive_custom']=='on') {
|
if ($_POST['Drive_custom']=='on') {
|
||||||
$tmp['Drive_custom'] = $_POST['Drive_custom'];
|
$tmp['Drive_custom'] = $_POST['Drive_custom'];
|
||||||
$tmp['client_id'] = $_POST['client_id'];
|
$tmp['client_id'] = $_POST['client_id'];
|
||||||
@@ -1292,6 +1399,7 @@ function get_refresh_token()
|
|||||||
$tmp['usesharepoint'] = $_POST['usesharepoint'];
|
$tmp['usesharepoint'] = $_POST['usesharepoint'];
|
||||||
$tmp['sharepointname'] = $_POST['sharepointname'];
|
$tmp['sharepointname'] = $_POST['sharepointname'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$response = setConfigResponse( setConfig($tmp, $_COOKIE['disktag']) );
|
$response = setConfigResponse( setConfig($tmp, $_COOKIE['disktag']) );
|
||||||
if (api_error($response)) {
|
if (api_error($response)) {
|
||||||
$html = api_error_msg($response);
|
$html = api_error_msg($response);
|
||||||
@@ -1299,6 +1407,7 @@ function get_refresh_token()
|
|||||||
} else {
|
} else {
|
||||||
$title = getconstStr('MayinEnv');
|
$title = getconstStr('MayinEnv');
|
||||||
$html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?AddDisk&install1">';
|
$html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '?AddDisk&install1">';
|
||||||
|
if ($_POST['Drive_ver']=='shareurl') $html = getconstStr('Wait') . ' 3s<meta http-equiv="refresh" content="3;URL=' . $url . '">';
|
||||||
}
|
}
|
||||||
return message($html, $title, 201);
|
return message($html, $title, 201);
|
||||||
}
|
}
|
||||||
@@ -1317,19 +1426,22 @@ function get_refresh_token()
|
|||||||
'.getconstStr('OnedriveDiskName').':<input type="text" name="diskname" placeholder="' . getconstStr('EnvironmentsDescription')['diskname'] . '" style="width:100%"><br>
|
'.getconstStr('OnedriveDiskName').':<input type="text" name="diskname" placeholder="' . getconstStr('EnvironmentsDescription')['diskname'] . '" style="width:100%"><br>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<label><input type="radio" name="Drive_ver" value="MS" checked>MS: '.getconstStr('DriveVerMS').'</label><br>
|
<label><input type="radio" name="Drive_ver" value="MS" checked onclick="document.getElementById(\'morecustom\').style.display=\'\';document.getElementById(\'inputshareurl\').style.display=\'none\';">MS: '.getconstStr('DriveVerMS').'</label><br>
|
||||||
<label><input type="radio" name="Drive_ver" value="CN">CN: '.getconstStr('DriveVerCN').'</label>
|
<label><input type="radio" name="Drive_ver" value="CN" onclick="document.getElementById(\'morecustom\').style.display=\'\';document.getElementById(\'inputshareurl\').style.display=\'none\';">CN: '.getconstStr('DriveVerCN').'</label><br>
|
||||||
|
<label><input type="radio" name="Drive_ver" value="shareurl" onclick="document.getElementById(\'inputshareurl\').style.display=\'\';document.getElementById(\'morecustom\').style.display=\'none\';">shareurl: '.getconstStr('DriveVerShareurl').'</label><br>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div id="inputshareurl" style="display:none;margin:10px 35px">
|
||||||
<label><input type="checkbox" name="Drive_custom" onclick="document.getElementById(\'secret\').style.display=(this.checked?\'\':\'none\');">'.getconstStr('CustomIdSecret').'</label>
|
'.getconstStr('UseShareLink').'
|
||||||
|
<input type="text" name="shareurl" style="width:100%" placeholder="https://xxxx.sharepoint.com/:f:/g/personal/xxxxxxxx/mmmmmmmmm?e=XXXX"><br>
|
||||||
|
</div>
|
||||||
|
<div id="morecustom">
|
||||||
|
<label><input type="checkbox" name="Drive_custom" onclick="document.getElementById(\'secret\').style.display=(this.checked?\'\':\'none\');">'.getconstStr('CustomIdSecret').'</label><br>
|
||||||
<div id="secret" style="display:none;margin:10px 35px">
|
<div id="secret" style="display:none;margin:10px 35px">
|
||||||
<a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br>
|
<a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br>
|
||||||
client_secret:<input type="text" name="client_secret"><br>
|
client_secret:<input type="text" name="client_secret"><br>
|
||||||
client_id:<input type="text" name="client_id" placeholder="12345678-90ab-cdef-ghij-klmnopqrstuv"><br>
|
client_id:<input type="text" name="client_id" placeholder="12345678-90ab-cdef-ghij-klmnopqrstuv"><br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label><input type="checkbox" name="usesharepoint" onclick="document.getElementById(\'sharepoint\').style.display=(this.checked?\'\':\'none\');">'.getconstStr('UseSharepointInstead').'</label><br>
|
<label><input type="checkbox" name="usesharepoint" onclick="document.getElementById(\'sharepoint\').style.display=(this.checked?\'\':\'none\');">'.getconstStr('UseSharepointInstead').'</label><br>
|
||||||
<div id="sharepoint" style="display:none;margin:10px 35px">
|
<div id="sharepoint" style="display:none;margin:10px 35px">
|
||||||
'.getconstStr('GetSharepointName').'<br>
|
'.getconstStr('GetSharepointName').'<br>
|
||||||
@@ -1357,6 +1469,12 @@ function get_refresh_token()
|
|||||||
alert(\''.getconstStr('TagFormatAlert').'\');
|
alert(\''.getconstStr('TagFormatAlert').'\');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (t.Drive_ver.value==\'shareurl\') {
|
||||||
|
if (t.shareurl.value==\'\') {
|
||||||
|
alert(\'shareurl\');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (t.Drive_custom.checked==true) {
|
if (t.Drive_custom.checked==true) {
|
||||||
if (t.client_secret.value==\'\'||t.client_id.value==\'\') {
|
if (t.client_secret.value==\'\'||t.client_id.value==\'\') {
|
||||||
alert(\'client_id & client_secret\');
|
alert(\'client_id & client_secret\');
|
||||||
@@ -1369,11 +1487,12 @@ function get_refresh_token()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/\';
|
document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/\';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
$title = 'Bind Onedrive';
|
$title = 'Bind Disk';
|
||||||
return message($html, $title, 201);
|
return message($html, $title, 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1382,11 +1501,12 @@ function EnvOpt($needUpdate = 0)
|
|||||||
global $constStr;
|
global $constStr;
|
||||||
global $ShowedCommonEnv;
|
global $ShowedCommonEnv;
|
||||||
global $ShowedInnerEnv;
|
global $ShowedInnerEnv;
|
||||||
|
global $timezones;
|
||||||
asort($ShowedCommonEnv);
|
asort($ShowedCommonEnv);
|
||||||
asort($ShowedInnerEnv);
|
asort($ShowedInnerEnv);
|
||||||
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
||||||
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) {
|
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) {
|
||||||
$response = OnekeyUpate();
|
$response = OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch']);
|
||||||
if (api_error($response)) {
|
if (api_error($response)) {
|
||||||
$html = api_error_msg($response);
|
$html = api_error_msg($response);
|
||||||
$title = 'Error';
|
$title = 'Error';
|
||||||
@@ -1436,22 +1556,7 @@ function EnvOpt($needUpdate = 0)
|
|||||||
$html .= '
|
$html .= '
|
||||||
<a href="'.$preurl.'">'.getconstStr('Back').'</a> <a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
|
<a href="'.$preurl.'">'.getconstStr('Back').'</a> <a href="'.$_SERVER['base_path'].'">'.getconstStr('Back').getconstStr('Home').'</a><br>
|
||||||
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
|
<a href="https://github.com/qkqpttgf/OneManager-php">Github</a><br>';
|
||||||
if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
|
|
||||||
$html .= '
|
|
||||||
In VPS can not update by a click!<br>';
|
|
||||||
} else {
|
|
||||||
$html .= '
|
|
||||||
<form action="" method="post">
|
|
||||||
';
|
|
||||||
if ($needUpdate) {
|
|
||||||
$html .= '<pre>' . $_SERVER['github_version'] . '</pre>';
|
|
||||||
} else {
|
|
||||||
$html .= getconstStr('NotNeedUpdate');
|
|
||||||
}
|
|
||||||
$html .= '
|
|
||||||
<input type="submit" name="updateProgram" value="'.getconstStr('updateProgram').'">
|
|
||||||
</form>';
|
|
||||||
}
|
|
||||||
$html .= '
|
$html .= '
|
||||||
<table border=1 width=100%>
|
<table border=1 width=100%>
|
||||||
<form name="common" action="" method="post">
|
<form name="common" action="" method="post">
|
||||||
@@ -1459,15 +1564,15 @@ In VPS can not update by a click!<br>';
|
|||||||
<td colspan="2">'.getconstStr('PlatformConfig').'</td>
|
<td colspan="2">'.getconstStr('PlatformConfig').'</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
foreach ($ShowedCommonEnv as $key) {
|
foreach ($ShowedCommonEnv as $key) {
|
||||||
if ($key=='language') {
|
if ($key=='timezone') {
|
||||||
$html .= '
|
$html .= '
|
||||||
<tr>
|
<tr>
|
||||||
<td><label>' . $key . '</label></td>
|
<td><label>' . $key . '</label></td>
|
||||||
<td width=100%>
|
<td width=100%>
|
||||||
<select name="' . $key .'">';
|
<select name="' . $key .'">';
|
||||||
foreach ($constStr['languages'] as $key1 => $value1) {
|
foreach (array_keys($timezones) as $zone) {
|
||||||
$html .= '
|
$html .= '
|
||||||
<option value="'.$key1.'" '.($key1==getConfig($key)?'selected="selected"':'').'>'.$value1.'</option>';
|
<option value="'.$zone.'" '.($zone==getConfig($key)?'selected="selected"':'').'>'.$zone.'</option>';
|
||||||
}
|
}
|
||||||
$html .= '
|
$html .= '
|
||||||
</select>
|
</select>
|
||||||
@@ -1543,6 +1648,56 @@ In VPS can not update by a click!<br>';
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$html .= '
|
$html .= '
|
||||||
<a href="?AddDisk">'.getconstStr('AddDisk').'</a>';
|
<a href="?AddDisk">'.getconstStr('AddDisk').'</a><br><br>';
|
||||||
|
if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
|
||||||
|
$html .= '
|
||||||
|
'.getconstStr('VPSnotupdate').'<br>';
|
||||||
|
} else {
|
||||||
|
$html .= '
|
||||||
|
<form name="updateform" action="" method="post">
|
||||||
|
<input type="text" name="auth" placeholder="auth" value="qkqpttgf">
|
||||||
|
<input type="text" name="project" placeholder="project" value="OneManager-php">
|
||||||
|
<button onclick="querybranchs();return false">'.getconstStr('QueryBranchs').'</button>
|
||||||
|
<!--<input type="text" name="branch" placeholder="branch" value="master">-->
|
||||||
|
<select name="branch">
|
||||||
|
<option value="master">master</option>
|
||||||
|
</select>
|
||||||
|
<input type="submit" name="updateProgram" value="'.getconstStr('updateProgram').'">
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
function querybranchs()
|
||||||
|
{
|
||||||
|
//alert(document.updateform.auth.value);
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", "https://api.github.com/repos/"+document.updateform.auth.value+"/"+document.updateform.project.value+"/branches");
|
||||||
|
//xhr.setRequestHeader("User-Agent","qkqpttgf/OneManager");
|
||||||
|
xhr.send(null);
|
||||||
|
xhr.onload = function(e){
|
||||||
|
console.log(xhr.responseText+","+xhr.status);
|
||||||
|
if (xhr.status==200) {
|
||||||
|
document.updateform.branch.options.length=0;
|
||||||
|
JSON.parse(xhr.responseText).forEach( function (e) {
|
||||||
|
//alert(e.name);
|
||||||
|
document.updateform.branch.options.add(new Option(e.name,e.name));
|
||||||
|
if ("master"==e.name) document.updateform.branch.options[document.updateform.branch.options.length-1].selected = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
alert(xhr.responseText+"\n"+xhr.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.onerror = function(e){
|
||||||
|
alert("Network Error "+xhr.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
if ($needUpdate) {
|
||||||
|
$html .= '<div style="position:relative;word-wrap: break-word;">
|
||||||
|
' . str_replace("\r", '<br>',$_SERVER['github_version']) . '
|
||||||
|
</div>';
|
||||||
|
} else {
|
||||||
|
$html .= getconstStr('NotNeedUpdate');
|
||||||
|
}
|
||||||
return message($html, getconstStr('Setup'));
|
return message($html, getconstStr('Setup'));
|
||||||
}
|
}
|
||||||
@@ -633,6 +633,10 @@ $constStr = [
|
|||||||
'ko-kr' => '중국 Onedrive',
|
'ko-kr' => '중국 Onedrive',
|
||||||
'fa' => 'Onedrive در چین',
|
'fa' => 'Onedrive در چین',
|
||||||
],
|
],
|
||||||
|
'UseShareLink' => [
|
||||||
|
'en-us' => 'Share a folder in Onedrive (enable EDIT for everyone), input the link url below.',
|
||||||
|
'zh-cn' => '对一个Onedrive文件夹共享,允许所有人编辑,然后将共享链接填在下方',
|
||||||
|
],
|
||||||
'CustomIdSecret' => [
|
'CustomIdSecret' => [
|
||||||
'en-us' => 'Use custom client id & secret',
|
'en-us' => 'Use custom client id & secret',
|
||||||
'zh-cn' => '自己申请应用ID与机密',
|
'zh-cn' => '自己申请应用ID与机密',
|
||||||
@@ -726,4 +730,12 @@ $constStr = [
|
|||||||
'ko-kr' => '캐시 플러시',
|
'ko-kr' => '캐시 플러시',
|
||||||
'fa' => 'رفرش cache',
|
'fa' => 'رفرش cache',
|
||||||
],
|
],
|
||||||
|
'VPSnotupdate' => [
|
||||||
|
'en-us' => 'In VPS can not update by a click! run update.sh',
|
||||||
|
'zh-cn' => '在VPS中不能一键更新,可以运行update.sh',
|
||||||
|
],
|
||||||
|
'QueryBranchs' => [
|
||||||
|
'en-us' => 'Query Branchs',
|
||||||
|
'zh-cn' => '查询分支',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
include 'vendor/autoload.php';
|
include 'vendor/autoload.php';
|
||||||
include 'conststr.php';
|
include 'conststr.php';
|
||||||
include 'function/common.php';
|
include 'common.php';
|
||||||
|
|
||||||
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
||||||
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
||||||
include 'function/scf.php';
|
include 'platform/scf.php';
|
||||||
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
||||||
include 'function/heroku.php';
|
include 'platform/heroku.php';
|
||||||
$path = getpath();
|
$path = getpath();
|
||||||
//echo 'path:'. $path;
|
//echo 'path:'. $path;
|
||||||
$_GET = getGET();
|
$_GET = getGET();
|
||||||
@@ -20,7 +20,7 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
|||||||
http_response_code($re['statusCode']);
|
http_response_code($re['statusCode']);
|
||||||
echo $re['body'];
|
echo $re['body'];
|
||||||
} else {
|
} else {
|
||||||
include 'function/normal.php';
|
include 'platform/normal.php';
|
||||||
$path = getpath();
|
$path = getpath();
|
||||||
//echo 'path:'. $path;
|
//echo 'path:'. $path;
|
||||||
$_GET = getGET();
|
$_GET = getGET();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
function getpath()
|
function getpath()
|
||||||
{
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||||
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
@@ -106,6 +107,7 @@ function install()
|
|||||||
if ($_POST['admin']!='') {
|
if ($_POST['admin']!='') {
|
||||||
$tmp['admin'] = $_POST['admin'];
|
$tmp['admin'] = $_POST['admin'];
|
||||||
$tmp['language'] = $_POST['language'];
|
$tmp['language'] = $_POST['language'];
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
$APIKey = getConfig('APIKey');
|
$APIKey = getConfig('APIKey');
|
||||||
if ($APIKey=='') {
|
if ($APIKey=='') {
|
||||||
$APIKey = $_POST['APIKey'];
|
$APIKey = $_POST['APIKey'];
|
||||||
@@ -146,6 +148,12 @@ language:<br>';
|
|||||||
<input type="submit" value="'.getconstStr('Submit').'">
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<script>
|
||||||
|
var nowtime= new Date();
|
||||||
|
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||||
function changelanguage(str)
|
function changelanguage(str)
|
||||||
{
|
{
|
||||||
document.cookie=\'language=\'+str+\'; path=/\';
|
document.cookie=\'language=\'+str+\'; path=/\';
|
||||||
@@ -219,9 +227,9 @@ function setHerokuConfig($env, $function_name, $apikey)
|
|||||||
return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
|
return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHerokuapp($function_name, $apikey)
|
function updateHerokuapp($function_name, $apikey, $source)
|
||||||
{
|
{
|
||||||
$tmp['source_blob']['url'] = 'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
$tmp['source_blob']['url'] = $source;
|
||||||
$data = json_encode($tmp);
|
$data = json_encode($tmp);
|
||||||
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
|
return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
|
||||||
}
|
}
|
||||||
@@ -239,9 +247,11 @@ function_name:' . $_SERVER['function_name'] . '<br>
|
|||||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate()
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'))['body'], true);
|
//'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
|
||||||
|
$source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . $branch . '/';
|
||||||
|
return json_decode(updateHerokuapp(getConfig('function_name'), getConfig('APIKey'), $source)['body'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfigResponse($response)
|
function setConfigResponse($response)
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
function getpath()
|
function getpath()
|
||||||
{
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($_SERVER['HTTP_ACCEPT_LANGUAGE'],';')[0],',')[0]);
|
||||||
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
$_SERVER['base_path'] = path_format(substr($_SERVER['SCRIPT_NAME'], 0, -10) . '/');
|
||||||
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
$p = strpos($_SERVER['REQUEST_URI'],'?');
|
||||||
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
if ($p>0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
|
||||||
@@ -119,6 +120,7 @@ function install()
|
|||||||
if ($_POST['admin']!='') {
|
if ($_POST['admin']!='') {
|
||||||
$tmp['admin'] = $_POST['admin'];
|
$tmp['admin'] = $_POST['admin'];
|
||||||
$tmp['language'] = $_COOKIE['language'];
|
$tmp['language'] = $_COOKIE['language'];
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
$response = setConfig($tmp);
|
$response = setConfig($tmp);
|
||||||
if (api_error($response)) {
|
if (api_error($response)) {
|
||||||
$html = api_error_msg($response);
|
$html = api_error_msg($response);
|
||||||
@@ -148,6 +150,12 @@ function install()
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
var nowtime= new Date();
|
||||||
|
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||||
function notnull(t)
|
function notnull(t)
|
||||||
{
|
{
|
||||||
if (t.admin.value==\'\') {
|
if (t.admin.value==\'\') {
|
||||||
@@ -28,6 +28,7 @@ function GetGlobalVariable($event)
|
|||||||
|
|
||||||
function GetPathSetting($event, $context)
|
function GetPathSetting($event, $context)
|
||||||
{
|
{
|
||||||
|
$_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
|
||||||
$_SERVER['function_name'] = $context['function_name'];
|
$_SERVER['function_name'] = $context['function_name'];
|
||||||
$_SERVER['namespace'] = $context['namespace'];
|
$_SERVER['namespace'] = $context['namespace'];
|
||||||
$host_name = $event['headers']['host'];
|
$host_name = $event['headers']['host'];
|
||||||
@@ -131,7 +132,7 @@ function install()
|
|||||||
$tmp['admin'] = $_POST['admin'];
|
$tmp['admin'] = $_POST['admin'];
|
||||||
setConfig($tmp);
|
setConfig($tmp);
|
||||||
if (needUpdate()) {
|
if (needUpdate()) {
|
||||||
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
|
OnekeyUpate();
|
||||||
return message('update to github version, reinstall.<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
return message('update to github version, reinstall.<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
|
||||||
}
|
}
|
||||||
return output('Jump<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
return output('Jump<script>document.cookie=\'language=; path=/\';</script><meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
|
||||||
@@ -140,6 +141,7 @@ function install()
|
|||||||
//if ($_POST['admin']!='') {
|
//if ($_POST['admin']!='') {
|
||||||
$tmp['language'] = $_POST['language'];
|
$tmp['language'] = $_POST['language'];
|
||||||
$tmp['Region'] = $_POST['Region'];
|
$tmp['Region'] = $_POST['Region'];
|
||||||
|
$tmp['timezone'] = $_COOKIE['timezone'];
|
||||||
$SecretId = getConfig('SecretId');
|
$SecretId = getConfig('SecretId');
|
||||||
if ($SecretId=='') {
|
if ($SecretId=='') {
|
||||||
$SecretId = $_POST['SecretId'];
|
$SecretId = $_POST['SecretId'];
|
||||||
@@ -207,6 +209,12 @@ language:<br>';
|
|||||||
<input type="submit" value="'.getconstStr('Submit').'">
|
<input type="submit" value="'.getconstStr('Submit').'">
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<script>
|
||||||
|
var nowtime= new Date();
|
||||||
|
var timezone = 0-nowtime.getTimezoneOffset()/60;
|
||||||
|
var expd = new Date();
|
||||||
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
|
var expires = "expires="+expd.toGMTString();
|
||||||
|
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||||
function changelanguage(str)
|
function changelanguage(str)
|
||||||
{
|
{
|
||||||
document.cookie=\'language=\'+str+\'; path=/\';
|
document.cookie=\'language=\'+str+\'; path=/\';
|
||||||
@@ -369,13 +377,14 @@ function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $S
|
|||||||
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey)
|
function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
|
||||||
{
|
{
|
||||||
WaitSCFStat();
|
WaitSCFStat();
|
||||||
$meth = 'POST';
|
$meth = 'POST';
|
||||||
$host = 'scf.tencentcloudapi.com';
|
$host = 'scf.tencentcloudapi.com';
|
||||||
$tmpdata['Action'] = 'UpdateFunctionCode';
|
$tmpdata['Action'] = 'UpdateFunctionCode';
|
||||||
$tmpdata['Code.GitUrl'] = 'https://github.com/qkqpttgf/OneManager-php';
|
$tmpdata['Code.GitUrl'] = $source['url'];
|
||||||
|
$tmpdata['Code.GitBranch'] = $source['branch'];
|
||||||
$tmpdata['CodeSource'] = 'Git';
|
$tmpdata['CodeSource'] = 'Git';
|
||||||
$tmpdata['FunctionName'] = $function_name;
|
$tmpdata['FunctionName'] = $function_name;
|
||||||
$tmpdata['Handler'] = 'index.main_handler';
|
$tmpdata['Handler'] = 'index.main_handler';
|
||||||
@@ -407,9 +416,11 @@ namespace:' . $_SERVER['namespace'] . '<br>
|
|||||||
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate()
|
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')), true)['Response'];
|
$source['url'] = 'https://github.com/' . $auth . '/' . $project;
|
||||||
|
$source['branch'] = $branch;
|
||||||
|
return json_decode(updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source), true)['Response'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfigResponse($response)
|
function setConfigResponse($response)
|
||||||
@@ -49,5 +49,5 @@ If there is 'index.html' file, program will only show the content of 'index.html
|
|||||||
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
|
Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
|
||||||
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
|
点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
|
||||||
|
|
||||||
QQ Group: 943919989
|
QQ Group: 943919989 (请看完上面的中英双语再加群,谢谢!)
|
||||||
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
|
Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
|
||||||
|
|||||||
+14
-13
@@ -6,7 +6,8 @@
|
|||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<meta http-equiv=X-UA-Compatible content="IE=edge">
|
<meta http-equiv=X-UA-Compatible content="IE=edge">
|
||||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||||
<meta name="keywords" content="<?php echo $n_path;?>,<?php if ($p_path!='') echo $p_path.','; echo $_SERVER['sitename'];?>,OneManager,auth_by_逸笙">
|
<meta name="keywords" content="<?php echo $n_path;?>,<?php if ($p_path!='') echo $p_path.','; echo $_SERVER['sitename'];?>">
|
||||||
|
<meta name="description" content="<?php if ($_GET['preview']) echo 'Preview of '.$n_path; else echo 'List of '.$n_path; ?>. OneManager(An index & manager of Onedrive auth by ysun).">
|
||||||
<link rel="icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
||||||
<link rel="shortcut icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="<?php echo $_SERVER['base_disk_path'];?>favicon.ico" type="image/x-icon" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@@ -166,33 +167,33 @@
|
|||||||
<div style="margin: 12px 4px 4px; text-align: center">
|
<div style="margin: 12px 4px 4px; text-align: center">
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><?php echo str_replace('%2523', '%23', str_replace('%26amp%3B','&',spurlencode(path_format($_SERVER['base_disk_path'] . '/' . $path), '/'))); ?></textarea>
|
<textarea id="url" title="url" rows="1" style="width: 100%; margin-top: 2px;" readonly><?php echo str_replace('%2523', '%23', str_replace('%26amp%3B','&',spurlencode(path_format($_SERVER['base_disk_path'] . '/' . $path), '/'))); ?></textarea>
|
||||||
<a href="<?php echo path_format($_SERVER['base_disk_path'] . '/' . $path);//$files['@microsoft.graph.downloadUrl'] ?>"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <?php echo getconstStr('Download'); ?></a>
|
<a href="<?php echo path_format($_SERVER['base_disk_path'] . '/' . $path);//$files[$_SERVER['DownurlStrName']] ?>"><ion-icon name="download" style="line-height: 16px;vertical-align: middle;"></ion-icon> <?php echo getconstStr('Download'); ?></a>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin: 24px">
|
<div style="margin: 24px">
|
||||||
<?php $ext = strtolower(substr($path, strrpos($path, '.') + 1));
|
<?php $ext = strtolower(substr($path, strrpos($path, '.') + 1));
|
||||||
if (in_array($ext, $exts['img'])) {
|
if (in_array($ext, $exts['img'])) {
|
||||||
echo ' <img src="' . $files['@microsoft.graph.downloadUrl'] . '" alt="' . substr($path, strrpos($path, '/')) . '" onload="if(this.offsetWidth>document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
|
echo ' <img src="' . $files[$_SERVER['DownurlStrName']] . '" alt="' . substr($path, strrpos($path, '/')) . '" onload="if(this.offsetWidth>document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
|
||||||
';
|
';
|
||||||
} elseif (in_array($ext, $exts['video'])) {
|
} elseif (in_array($ext, $exts['video'])) {
|
||||||
//echo '<video src="' . $files['@microsoft.graph.downloadUrl'] . '" controls="controls" style="width: 100%"></video>';
|
//echo '<video src="' . $files[$_SERVER['DownurlStrName']] . '" controls="controls" style="width: 100%"></video>';
|
||||||
$DPvideo=$files['@microsoft.graph.downloadUrl'];
|
$DPvideo=$files[$_SERVER['DownurlStrName']];
|
||||||
echo ' <div id="video-a0"></div>
|
echo ' <div id="video-a0"></div>
|
||||||
';
|
';
|
||||||
} elseif (in_array($ext, $exts['music'])) {
|
} elseif (in_array($ext, $exts['music'])) {
|
||||||
echo ' <audio src="' . $files['@microsoft.graph.downloadUrl'] . '" controls="controls" style="width: 100%"></audio>
|
echo ' <audio src="' . $files[$_SERVER['DownurlStrName']] . '" controls="controls" style="width: 100%"></audio>
|
||||||
';
|
';
|
||||||
} elseif (in_array($ext, ['pdf'])) {
|
} elseif (in_array($ext, ['pdf'])) {
|
||||||
/*echo '
|
/*echo '
|
||||||
<embed src="' . $files['@microsoft.graph.downloadUrl'] . '" type="application/pdf" width="100%" height=800px">
|
<embed src="' . $files[$_SERVER['DownurlStrName']] . '" type="application/pdf" width="100%" height=800px">
|
||||||
';*/
|
';*/
|
||||||
$pdfurl = $files['@microsoft.graph.downloadUrl'];
|
$pdfurl = $files[$_SERVER['DownurlStrName']];
|
||||||
echo ' <div id="pdf-d"></div>
|
echo ' <div id="pdf-d"></div>
|
||||||
';
|
';
|
||||||
} elseif (in_array($ext, $exts['office'])) {
|
} elseif (in_array($ext, $exts['office'])) {
|
||||||
echo ' <iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=' . urlencode($files['@microsoft.graph.downloadUrl']) . '" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
echo ' <iframe id="office-a" src="https://view.officeapps.live.com/op/view.aspx?src=' . urlencode($files[$_SERVER['DownurlStrName']]) . '" style="width: 100%;height: 800px" frameborder="0"></iframe>
|
||||||
';
|
';
|
||||||
} elseif (in_array($ext, $exts['txt'])) {
|
} elseif (in_array($ext, $exts['txt'])) {
|
||||||
$txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
|
$txtstr = htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']);
|
||||||
?>
|
?>
|
||||||
<div id="txt">
|
<div id="txt">
|
||||||
<?php if ($_SERVER['admin']) { ?>
|
<?php if ($_SERVER['admin']) { ?>
|
||||||
@@ -206,7 +207,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php } /*elseif (in_array($ext, ['md'])) {
|
<?php } /*elseif (in_array($ext, ['md'])) {
|
||||||
echo ' <div class="markdown-body" id="readme">
|
echo ' <div class="markdown-body" id="readme">
|
||||||
<textarea id="readme-md" style="display:none;">' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '</textarea>
|
<textarea id="readme-md" style="display:none;">' . curl_request($files[$_SERVER['DownurlStrName']])['body'] . '</textarea>
|
||||||
</div>
|
</div>
|
||||||
';
|
';
|
||||||
}*/ else {
|
}*/ else {
|
||||||
@@ -705,7 +706,7 @@
|
|||||||
tmptextarea.select();
|
tmptextarea.select();
|
||||||
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
|
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
alert(tmptextarea.innerHTML+'<?php echo getconstStr('Success'); ?>');
|
alert(tmptextarea.innerHTML+"<?php echo getconstStr('Success');?>");
|
||||||
}
|
}
|
||||||
var sort=0;
|
var sort=0;
|
||||||
function sortby(string) {
|
function sortby(string) {
|
||||||
@@ -801,7 +802,7 @@
|
|||||||
expd.setTime(expd.getTime()+(2*60*60*1000));
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
||||||
var expires = "expires="+expd.toGMTString();
|
var expires = "expires="+expd.toGMTString();
|
||||||
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
document.cookie="timezone="+timezone+"; path=/; "+expires;
|
||||||
if (timezone!='8') {
|
if (timezone!=<?php echo $_SERVER['timezone']; ?>) {
|
||||||
alert('Your timezone is '+timezone+', reload local timezone.');
|
alert('Your timezone is '+timezone+', reload local timezone.');
|
||||||
location.href=location.protocol + "//" + location.host + "<?php echo path_format($_SERVER['base_path'] . '/' . $path );?>" ;
|
location.href=location.protocol + "//" + location.host + "<?php echo path_format($_SERVER['base_path'] . '/' . $path );?>" ;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
File diff suppressed because one or more lines are too long
+1263
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,68 @@
|
|||||||
#!bash
|
#!bash
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "
|
||||||
|
"$0" -i|u [-b branch]
|
||||||
|
i a new install with empty config.
|
||||||
|
u update use exist config.
|
||||||
|
b install the branch after parameter b, default master
|
||||||
|
|
||||||
|
example:
|
||||||
|
"$0" -i
|
||||||
|
"$0" -u
|
||||||
|
"$0" -b master
|
||||||
|
"$0" -r -b master
|
||||||
|
"$0" -ib test
|
||||||
|
"
|
||||||
|
# exit
|
||||||
|
echo "###############
|
||||||
|
0, new install
|
||||||
|
1, update"
|
||||||
|
read -p "Input:" c
|
||||||
|
[ g"$c" == g"0" ] && install=1
|
||||||
|
[ g"$c" == g"1" ] && update=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
i=0
|
||||||
|
para[$i]=$0
|
||||||
|
for av in "$@"
|
||||||
|
do
|
||||||
|
#echo $av
|
||||||
|
((i++))
|
||||||
|
para[$i]=$av
|
||||||
|
if [ g"${av:0:1}" == g"-" ]; then
|
||||||
|
while [ g"$av" != g"" ]
|
||||||
|
do
|
||||||
|
ag=${av:0:1}
|
||||||
|
av=${av:1}
|
||||||
|
[ g"$ag" == g"b" ] && isbranch=1
|
||||||
|
[ g"$ag" == g"i" ] && install=1
|
||||||
|
[ g"$ag" == g"u" ] && update=1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
if [ g"$isbranch" == g"1" ]; then
|
||||||
|
branch="-b $av"
|
||||||
|
isbranch=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ g"$install" == g"1" -a g"$update" == g"1" ]; then
|
||||||
|
echo "Both install & update, exit"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
if [ g"$install" != g"1" -a g"$update" != g"1" ]; then
|
||||||
|
echo "Not install & Not update, exit"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
gitsource='https://github.com/qkqpttgf/OneManager-php'
|
gitsource='https://github.com/qkqpttgf/OneManager-php'
|
||||||
|
|
||||||
OneManagerPath=`cd $(dirname $0);pwd -P`
|
OneManagerPath=`cd $(dirname $0);pwd -P`
|
||||||
cd ${OneManagerPath}
|
cd ${OneManagerPath}
|
||||||
|
|
||||||
git clone ${gitsource}
|
git clone ${branch} ${gitsource}
|
||||||
\mv -b config.php OneManager-php/
|
[ g"$install" == g"1" ] || \mv -b config.php OneManager-php/
|
||||||
\mv -b OneManager-php/* ./
|
\mv -b OneManager-php/* ./
|
||||||
\mv -b OneManager-php/.[^.]* ./
|
\mv -b OneManager-php/.[^.]* ./
|
||||||
rm -rf *~
|
rm -rf *~
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
20200402-1830.17
|
||||||
|
Oneclick update can select which branch to update. Now use the accept language instead of the language config.
|
||||||
|
一键更新可以选择哪个分支了。现在开始使用浏览器语言,抛弃language设置。
|
||||||
|
|
||||||
20200326-0001.16
|
20200326-0001.16
|
||||||
You can add sharepoint site drive as a disk, <font color=red>you must reinstall after update</font>.
|
You can add sharepoint site drive as a disk, <font color=red>you must reinstall after update</font>.
|
||||||
可以将sharepoint网站添加成一个盘,<font color=red>由于结构改变,升级后只能重装</font>。
|
可以将sharepoint网站添加成一个盘,<font color=red>由于结构改变,升级后只能重装</font>。
|
||||||
|
|
||||||
20200321-1830.15
|
20200321-1830.15
|
||||||
本次更新后,'index.html'功能在其它主题会导致bug。
|
本次更新后,'index.html'功能在其它主题会导致bug。
|
||||||
文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。
|
文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。
|
||||||
|
|||||||
Reference in New Issue
Block a user