2020-01-18 12:12:21 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2020-08-04 06:38:20 +00:00
|
|
|
|
global $Base64Env;
|
|
|
|
|
global $CommonEnv;
|
|
|
|
|
global $ShowedCommonEnv;
|
|
|
|
|
global $InnerEnv;
|
|
|
|
|
global $ShowedInnerEnv;
|
|
|
|
|
global $Base64Env;
|
2020-08-16 03:37:28 +00:00
|
|
|
|
global $timezones;
|
2020-08-04 06:38:20 +00:00
|
|
|
|
|
2020-02-29 04:58:31 +00:00
|
|
|
|
$Base64Env = [
|
|
|
|
|
//'APIKey', // used in heroku.
|
|
|
|
|
//'SecretId', // used in SCF.
|
|
|
|
|
//'SecretKey', // used in SCF.
|
2020-06-07 10:43:47 +00:00
|
|
|
|
//'AccessKeyID', // used in FC.
|
|
|
|
|
//'AccessKeySecret', // used in FC.
|
2020-07-13 09:33:47 +00:00
|
|
|
|
//'HW_urn', // used in FG.
|
|
|
|
|
//'HW_key', // used in FG.
|
|
|
|
|
//'HW_secret', // used in FG.
|
2020-02-29 04:58:31 +00:00
|
|
|
|
//'admin',
|
|
|
|
|
//'adminloginpage',
|
2020-08-17 09:31:51 +00:00
|
|
|
|
//'autoJumpFirstDisk',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
'background',
|
2020-08-16 04:18:14 +00:00
|
|
|
|
'backgroundm',
|
2020-03-04 02:42:01 +00:00
|
|
|
|
'diskname',
|
2020-05-24 11:15:09 +00:00
|
|
|
|
//'disableShowThumb',
|
2020-06-23 07:42:57 +00:00
|
|
|
|
//'disableChangeTheme',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
//'disktag',
|
2020-03-04 02:42:01 +00:00
|
|
|
|
//'downloadencrypt',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
//'function_name', // used in heroku.
|
2020-03-17 03:39:16 +00:00
|
|
|
|
//'hideFunctionalityFile',
|
2020-04-05 05:45:28 +00:00
|
|
|
|
//'timezone',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
//'passfile',
|
|
|
|
|
'sitename',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'customScript',
|
|
|
|
|
'customCss',
|
2020-05-24 07:07:56 +00:00
|
|
|
|
'customTheme',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
//'theme',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//'Drive_ver',
|
|
|
|
|
//'Drive_custom',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
//'client_id',
|
|
|
|
|
'client_secret',
|
|
|
|
|
'domain_path',
|
|
|
|
|
'guestup_path',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//'usesharepoint',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'sharepointSiteAddress',
|
2020-04-01 10:44:50 +00:00
|
|
|
|
'shareurl',
|
2020-04-04 05:50:29 +00:00
|
|
|
|
//'sharecookie',
|
2020-04-01 10:44:50 +00:00
|
|
|
|
'shareapiurl',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//'siteid',
|
2020-06-07 10:43:47 +00:00
|
|
|
|
'domainforproxy',
|
2020-02-29 04:58:31 +00:00
|
|
|
|
'public_path',
|
|
|
|
|
//'refresh_token',
|
|
|
|
|
//'token_expires',
|
|
|
|
|
];
|
|
|
|
|
|
2020-02-24 14:54:16 +00:00
|
|
|
|
$CommonEnv = [
|
|
|
|
|
'APIKey', // used in heroku.
|
|
|
|
|
'SecretId', // used in SCF.
|
|
|
|
|
'SecretKey', // used in SCF.
|
2020-06-07 10:43:47 +00:00
|
|
|
|
'AccessKeyID', // used in FC.
|
|
|
|
|
'AccessKeySecret', // used in FC.
|
2020-07-13 09:33:47 +00:00
|
|
|
|
'HW_urn', // used in FG.
|
|
|
|
|
'HW_key', // used in FG.
|
|
|
|
|
'HW_secret', // used in FG.
|
2020-02-24 14:54:16 +00:00
|
|
|
|
'admin',
|
|
|
|
|
'adminloginpage',
|
2020-08-17 09:31:51 +00:00
|
|
|
|
'autoJumpFirstDisk',
|
2020-02-24 14:54:16 +00:00
|
|
|
|
'background',
|
2020-08-16 04:18:14 +00:00
|
|
|
|
'backgroundm',
|
2020-02-24 14:54:16 +00:00
|
|
|
|
'disktag',
|
2020-05-24 11:15:09 +00:00
|
|
|
|
'disableShowThumb',
|
2020-06-23 07:42:57 +00:00
|
|
|
|
'disableChangeTheme',
|
2020-02-24 14:54:16 +00:00
|
|
|
|
'function_name', // used in heroku.
|
2020-03-17 03:39:16 +00:00
|
|
|
|
'hideFunctionalityFile',
|
2020-04-05 05:45:28 +00:00
|
|
|
|
'timezone',
|
2020-02-24 14:54:16 +00:00
|
|
|
|
'passfile',
|
|
|
|
|
'sitename',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'customScript',
|
|
|
|
|
'customCss',
|
2020-05-24 07:07:56 +00:00
|
|
|
|
'customTheme',
|
2020-02-24 14:54:16 +00:00
|
|
|
|
'theme',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$ShowedCommonEnv = [
|
2020-02-23 04:51:39 +00:00
|
|
|
|
//'APIKey', // used in heroku.
|
|
|
|
|
//'SecretId', // used in SCF.
|
|
|
|
|
//'SecretKey', // used in SCF.
|
2020-06-07 10:43:47 +00:00
|
|
|
|
//'AccessKeyID', // used in FC.
|
|
|
|
|
//'AccessKeySecret', // used in FC.
|
2020-07-13 09:33:47 +00:00
|
|
|
|
//'HW_urn', // used in FG.
|
|
|
|
|
//'HW_key', // used in FG.
|
|
|
|
|
//'HW_secret', // used in FG.
|
2020-02-23 04:51:39 +00:00
|
|
|
|
//'admin',
|
|
|
|
|
'adminloginpage',
|
2020-08-17 09:31:51 +00:00
|
|
|
|
'autoJumpFirstDisk',
|
2020-02-23 04:51:39 +00:00
|
|
|
|
'background',
|
2020-08-16 04:18:14 +00:00
|
|
|
|
'backgroundm',
|
2020-02-23 04:51:39 +00:00
|
|
|
|
//'disktag',
|
2020-05-24 11:15:09 +00:00
|
|
|
|
'disableShowThumb',
|
2020-06-23 07:42:57 +00:00
|
|
|
|
'disableChangeTheme',
|
2020-02-23 04:51:39 +00:00
|
|
|
|
//'function_name', // used in heroku.
|
2020-03-17 03:39:16 +00:00
|
|
|
|
'hideFunctionalityFile',
|
2020-04-05 05:45:28 +00:00
|
|
|
|
'timezone',
|
2020-02-23 04:51:39 +00:00
|
|
|
|
'passfile',
|
|
|
|
|
'sitename',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'customScript',
|
|
|
|
|
'customCss',
|
2020-05-24 07:07:56 +00:00
|
|
|
|
'customTheme',
|
2020-02-23 04:51:39 +00:00
|
|
|
|
'theme',
|
|
|
|
|
];
|
|
|
|
|
|
2020-02-24 14:54:16 +00:00
|
|
|
|
$InnerEnv = [
|
2020-03-25 16:03:35 +00:00
|
|
|
|
'Drive_ver',
|
|
|
|
|
'Drive_custom',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'client_id',
|
|
|
|
|
'client_secret',
|
2020-03-04 02:42:01 +00:00
|
|
|
|
'diskname',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'domain_path',
|
2020-03-04 02:42:01 +00:00
|
|
|
|
'downloadencrypt',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'guestup_path',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
'usesharepoint',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'sharepointSiteAddress',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
'siteid',
|
2020-04-01 10:44:50 +00:00
|
|
|
|
'shareurl',
|
2020-04-04 05:50:29 +00:00
|
|
|
|
//'sharecookie',
|
2020-04-01 10:44:50 +00:00
|
|
|
|
'shareapiurl',
|
2020-06-07 10:43:47 +00:00
|
|
|
|
'domainforproxy',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'public_path',
|
|
|
|
|
'refresh_token',
|
|
|
|
|
'token_expires',
|
|
|
|
|
];
|
|
|
|
|
|
2020-02-24 14:54:16 +00:00
|
|
|
|
$ShowedInnerEnv = [
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//'Drive_ver',
|
|
|
|
|
//'Drive_custom',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
//'client_id',
|
|
|
|
|
//'client_secret',
|
2020-03-04 02:42:01 +00:00
|
|
|
|
'diskname',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'domain_path',
|
2020-03-04 02:42:01 +00:00
|
|
|
|
'downloadencrypt',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'guestup_path',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//'usesharepoint',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
//'sharepointSiteAddress',
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//'siteid',
|
2020-04-01 10:44:50 +00:00
|
|
|
|
//'shareurl',
|
|
|
|
|
//'sharecookie',
|
|
|
|
|
//'shareapiurl',
|
2020-06-07 10:43:47 +00:00
|
|
|
|
'domainforproxy',
|
2020-02-20 04:07:51 +00:00
|
|
|
|
'public_path',
|
|
|
|
|
//'refresh_token',
|
|
|
|
|
//'token_expires',
|
|
|
|
|
];
|
|
|
|
|
|
2020-04-05 06:32:23 +00:00
|
|
|
|
$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'
|
|
|
|
|
);
|
|
|
|
|
|
2020-04-01 10:44:50 +00:00
|
|
|
|
function main($path)
|
|
|
|
|
{
|
|
|
|
|
global $exts;
|
|
|
|
|
global $constStr;
|
|
|
|
|
|
2020-05-14 10:05:43 +00:00
|
|
|
|
$_SERVER['php_starttime'] = microtime(true);
|
2020-05-11 05:11:07 +00:00
|
|
|
|
$path = path_format($path);
|
2020-04-04 05:50:29 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-02 10:18:08 +00:00
|
|
|
|
if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language'];
|
2020-04-01 10:44:50 +00:00
|
|
|
|
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
|
|
|
|
$_SERVER['language'] = $constStr['language'];
|
2020-04-05 05:45:28 +00:00
|
|
|
|
$_SERVER['timezone'] = getConfig('timezone');
|
|
|
|
|
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
|
|
|
|
|
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$_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')) {
|
2020-08-21 08:44:55 +00:00
|
|
|
|
return adminform('admin', pass2cookie('admin', $_POST['password1']), $url);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
} else return adminform();
|
|
|
|
|
} else {
|
|
|
|
|
return output('', 302, [ 'Location' => $url ]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if ( isset($_COOKIE['admin'])&&$_COOKIE['admin']==pass2cookie('admin', getConfig('admin')) ) {
|
|
|
|
|
$_SERVER['admin']=1;
|
|
|
|
|
$_SERVER['needUpdate'] = needUpdate();
|
|
|
|
|
} else {
|
|
|
|
|
$_SERVER['admin']=0;
|
|
|
|
|
}
|
2020-04-01 10:44:50 +00:00
|
|
|
|
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 ]);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-04 06:38:20 +00:00
|
|
|
|
$_SERVER['sitename'] = getConfig('sitename');
|
|
|
|
|
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$_SERVER['base_disk_path'] = $_SERVER['base_path'];
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$disktags = explode("|", getConfig('disktag'));
|
2020-04-01 10:44:50 +00:00
|
|
|
|
// echo 'count$disk:'.count($disktags);
|
|
|
|
|
if (count($disktags)>1) {
|
2020-08-04 06:38:20 +00:00
|
|
|
|
if ($path=='/'||$path=='') {
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
|
|
|
|
|
$files['showname'] = 'root';
|
2020-08-17 09:31:51 +00:00
|
|
|
|
$files['folder']['childCount'] = count($disktags);
|
|
|
|
|
foreach ($disktags as $disktag) {
|
|
|
|
|
$files['children'][$disktag]['folder'] = 1;
|
|
|
|
|
$files['children'][$disktag]['name'] = $disktag;
|
2020-08-23 05:00:16 +00:00
|
|
|
|
$files['children'][$disktag]['showname'] = getConfig('diskname', $disktag);
|
2020-08-17 09:31:51 +00:00
|
|
|
|
}
|
2020-08-04 06:38:20 +00:00
|
|
|
|
if ($_GET['json']) {
|
|
|
|
|
// return a json
|
|
|
|
|
return files_json($files);
|
2020-08-17 09:31:51 +00:00
|
|
|
|
}
|
2020-09-03 03:19:50 +00:00
|
|
|
|
} else {
|
|
|
|
|
$_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0];
|
|
|
|
|
//$pos = strpos($path, '/');
|
|
|
|
|
//if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
|
|
|
|
|
if (!in_array($_SERVER['disktag'], $disktags)) {
|
|
|
|
|
$tmp = path_format($_SERVER['base_path'] . '/' . $disktags[0] . '/' . $path);
|
|
|
|
|
if (!!$_GET) {
|
|
|
|
|
$tmp .= '?';
|
|
|
|
|
foreach ($_GET as $k => $v) {
|
|
|
|
|
if ($v === true) $tmp .= $k . '&';
|
|
|
|
|
else $tmp .= $k . '=' . $v . '&';
|
|
|
|
|
}
|
|
|
|
|
$tmp = substr($tmp, 0, -1);
|
|
|
|
|
}
|
|
|
|
|
return output('Please visit <a href="' . $tmp . '">' . $tmp . '</a>.', 302, [ 'Location' => $tmp ]);
|
|
|
|
|
//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'] . '/');
|
2020-05-11 05:11:07 +00:00
|
|
|
|
}
|
2020-04-01 10:44:50 +00:00
|
|
|
|
} 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;
|
|
|
|
|
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if ($_SERVER['admin']) if (isset($_GET['AddDisk'])) return get_refresh_token();
|
|
|
|
|
|
|
|
|
|
if ($files['showname'] == 'root') return render_list($path, $files);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
config_oauth();
|
|
|
|
|
$refresh_token = getConfig('refresh_token');
|
|
|
|
|
if (!$refresh_token) {
|
|
|
|
|
return render_list();
|
|
|
|
|
} else {
|
|
|
|
|
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$response = get_access_token($refresh_token);
|
|
|
|
|
if (isset($response['stat'])) return message($response['body'], 'Error', $response['stat']);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($_SERVER['ajax']) {
|
2020-05-03 10:17:18 +00:00
|
|
|
|
if ($_GET['action']=='del_upload_cache') {
|
2020-04-01 10:44:50 +00:00
|
|
|
|
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
|
|
|
|
error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$tmp = splitlast($_GET['filename'], '/');
|
|
|
|
|
if ($tmp[1]!='') {
|
|
|
|
|
$filename = $tmp[0] . '/.' . $_GET['filelastModified'] . '_' . $_GET['filesize'] . '_' . $tmp[1] . '.tmp';
|
|
|
|
|
} else {
|
|
|
|
|
$filename = '.' . $_GET['filelastModified'] . '_' . $_GET['filesize'] . '_' . $_GET['filename'] . '.tmp';
|
|
|
|
|
}
|
|
|
|
|
$filename = path_format( path_format($_SERVER['list_path'] . path_format($path)) . '/' . spurlencode($filename, '/') );
|
|
|
|
|
$tmp = MSAPI('DELETE', $filename, '', $_SERVER['access_token']);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$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));
|
2020-05-30 07:05:23 +00:00
|
|
|
|
//$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
|
|
|
|
|
$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$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'])) {
|
2020-05-24 10:15:31 +00:00
|
|
|
|
return get_thumbnails_url($path, $_GET['location']);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
} 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);
|
2020-06-07 10:43:47 +00:00
|
|
|
|
if ($_GET['json']) {
|
|
|
|
|
// return a json
|
|
|
|
|
return files_json($files);
|
|
|
|
|
}
|
2020-04-01 10:44:50 +00:00
|
|
|
|
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) {
|
2020-06-07 10:43:47 +00:00
|
|
|
|
$url = $tmp[rand(0,count($tmp)-1)];
|
|
|
|
|
if (isset($_GET['url'])) return output($url, 200);
|
|
|
|
|
$domainforproxy = '';
|
|
|
|
|
$domainforproxy = getConfig('domainforproxy');
|
|
|
|
|
if ($domainforproxy!='') {
|
|
|
|
|
$url = proxy_replace_domain($url, $domainforproxy);
|
|
|
|
|
}
|
|
|
|
|
return output('', 302, [ 'Location' => $url ]);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
} else return output('',404);
|
|
|
|
|
} else return output('',401);
|
|
|
|
|
}
|
|
|
|
|
if (isset($files['file']) && !isset($_GET['preview'])) {
|
|
|
|
|
// is file && not preview mode
|
2020-06-07 10:43:47 +00:00
|
|
|
|
if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) {
|
|
|
|
|
$url = $files[$_SERVER['DownurlStrName']];
|
|
|
|
|
$domainforproxy = '';
|
|
|
|
|
$domainforproxy = getConfig('domainforproxy');
|
|
|
|
|
if ($domainforproxy!='') {
|
|
|
|
|
$url = proxy_replace_domain($url, $domainforproxy);
|
|
|
|
|
}
|
|
|
|
|
if ( strtolower(splitlast($files['name'],'.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']);
|
2020-08-21 08:44:55 +00:00
|
|
|
|
else {
|
|
|
|
|
if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE'];
|
|
|
|
|
$header['Location'] = $url;
|
|
|
|
|
return output('', 302, $header);
|
|
|
|
|
}
|
2020-06-07 10:43:47 +00:00
|
|
|
|
}
|
2020-04-01 10:44:50 +00:00
|
|
|
|
}
|
|
|
|
|
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']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 08:44:55 +00:00
|
|
|
|
function pass2cookie($name, $pass)
|
|
|
|
|
{
|
|
|
|
|
return md5($name . ':' . md5($pass));
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-07 10:43:47 +00:00
|
|
|
|
function proxy_replace_domain($url, $domainforproxy)
|
|
|
|
|
{
|
|
|
|
|
$tmp = splitfirst($url, '//');
|
|
|
|
|
$http = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '/');
|
|
|
|
|
$domain = $tmp[0];
|
|
|
|
|
$uri = $tmp[1];
|
|
|
|
|
if (substr($domainforproxy, 0, 7)=='http://' || substr($domainforproxy, 0, 8)=='https://') $aim = $domainforproxy;
|
|
|
|
|
else $aim = $http . '//' . $domainforproxy;
|
|
|
|
|
if (substr($aim, -1)=='/') $aim = substr($aim, 0, -1);
|
|
|
|
|
return $aim . '/' . $uri . '&Origindomain=' . $domain;
|
|
|
|
|
//$url = str_replace($tmp, $domainforproxy, $url).'&Origindomain='.$tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function files_json($files)
|
|
|
|
|
{
|
|
|
|
|
//$tmp = '';
|
|
|
|
|
if (isset($files['file'])) {
|
|
|
|
|
$tmp['file']['type'] = 0;
|
|
|
|
|
$tmp['file']['id'] = $files['id'];
|
|
|
|
|
$tmp['file']['name'] = $files['name'];
|
|
|
|
|
$tmp['file']['time'] = $files['lastModifiedDateTime'];
|
|
|
|
|
$tmp['file']['size'] = $files['size'];
|
|
|
|
|
$tmp['file']['mime'] = $files['file']['mimeType'];
|
|
|
|
|
$tmp['file']['url'] = $files[$_SERVER['DownurlStrName']];
|
|
|
|
|
$tmp['url'] = $files[$_SERVER['DownurlStrName']];
|
|
|
|
|
} elseif (isset($files['folder'])) {
|
|
|
|
|
$tmp['list'] = [];
|
|
|
|
|
foreach ($files['children'] as $file) {
|
|
|
|
|
$tmp1 = null;
|
|
|
|
|
$tmp1 = [];
|
|
|
|
|
if (isset($file['file'])) {
|
|
|
|
|
$tmp1['type'] = 0;
|
|
|
|
|
$tmp1['url'] = $file[$_SERVER['DownurlStrName']];
|
|
|
|
|
} elseif (isset($file['folder'])) {
|
|
|
|
|
$tmp1['type'] = 1;
|
|
|
|
|
}
|
|
|
|
|
$tmp1['id'] = $file['id'];
|
|
|
|
|
$tmp1['name'] = $file['name'];
|
|
|
|
|
$tmp1['time'] = $file['lastModifiedDateTime'];
|
|
|
|
|
$tmp1['size'] = $file['size'];
|
|
|
|
|
$tmp1['mime'] = $file['file']['mimeType'];
|
|
|
|
|
array_push($tmp['list'], $tmp1);
|
|
|
|
|
}
|
2020-09-03 03:19:50 +00:00
|
|
|
|
} else return output(var_dump($files), 404);
|
2020-07-23 06:26:37 +00:00
|
|
|
|
return output(json_encode($tmp), 200, ['Content-Type' => 'application/json']);
|
2020-06-07 10:43:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 10:44:50 +00:00
|
|
|
|
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");
|
2020-04-02 10:18:08 +00:00
|
|
|
|
error_log('failed to get share access_token. response' . json_encode($ret));
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$response['body'] .= '\nfailed to get shareurl access_token.';
|
|
|
|
|
return $response;
|
|
|
|
|
//throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
}
|
2020-07-13 09:33:47 +00:00
|
|
|
|
$tmp = $ret;
|
|
|
|
|
$tmp['access_token'] = '******';
|
|
|
|
|
error_log('['.$_SERVER['disktag'].'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
|
2020-04-01 10:44:50 +00:00
|
|
|
|
savecache('access_token', $_SERVER['access_token']);
|
2020-07-13 09:33:47 +00:00
|
|
|
|
$tmp1 = [];
|
|
|
|
|
$tmp1['shareapiurl'] = $_SERVER['api_url'];
|
|
|
|
|
if (getConfig('shareapiurl')=='') setConfig($tmp1);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
} else {
|
2020-07-13 09:33:47 +00:00
|
|
|
|
$p=0;
|
|
|
|
|
while ($response['stat']==0&&$p<3) {
|
|
|
|
|
$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 );
|
|
|
|
|
$p++;
|
|
|
|
|
}
|
2020-04-01 10:44:50 +00:00
|
|
|
|
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
|
|
|
|
if (!isset($ret['access_token'])) {
|
2020-07-13 09:33:47 +00:00
|
|
|
|
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=' . substr($refresh_token, 0, 20) . '******' . substr($refresh_token, -20));
|
2020-05-24 12:08:36 +00:00
|
|
|
|
error_log('failed to get ['.$_SERVER['disktag'].'] access_token. response' . json_encode($ret));
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$response['body'] .= '\nfailed to get ['.$_SERVER['disktag'].'] access_token.';
|
|
|
|
|
return $response;
|
|
|
|
|
//throw new Exception($response['stat'].', failed to get ['.$_SERVER['disktag'].'] access_token.'.$response['body']);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
}
|
2020-07-13 09:33:47 +00:00
|
|
|
|
$tmp = $ret;
|
|
|
|
|
$tmp['access_token'] = '******';
|
|
|
|
|
$tmp['refresh_token'] = '******';
|
|
|
|
|
error_log('['.$_SERVER['disktag'].'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$_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 ]);
|
|
|
|
|
}
|
2020-09-03 03:19:50 +00:00
|
|
|
|
return 0;
|
2020-04-01 10:44:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-17 03:39:16 +00:00
|
|
|
|
function isHideFile($name)
|
|
|
|
|
{
|
|
|
|
|
$FunctionalityFile = [
|
|
|
|
|
'head.md',
|
|
|
|
|
'readme.md',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'head.omf',
|
|
|
|
|
'foot.omf',
|
2020-03-17 03:39:16 +00:00
|
|
|
|
'favicon.ico',
|
2020-05-03 10:17:18 +00:00
|
|
|
|
'index.html',
|
2020-03-17 03:39:16 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ($name == getConfig('passfile')) return true;
|
|
|
|
|
if (substr($name,0,1) == '.') return true;
|
|
|
|
|
if (getConfig('hideFunctionalityFile')) if (in_array(strtolower($name), $FunctionalityFile)) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
function getcache($str)
|
|
|
|
|
{
|
2020-08-17 08:26:22 +00:00
|
|
|
|
$cache = filecache();
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return $cache->fetch($str);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-11 06:05:21 +00:00
|
|
|
|
function savecache($key, $value, $exp = 1800)
|
2020-01-18 12:12:21 +00:00
|
|
|
|
{
|
2020-08-17 08:26:22 +00:00
|
|
|
|
$cache = filecache();
|
|
|
|
|
return $cache->save($key, $value, $exp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function filecache()
|
|
|
|
|
{
|
|
|
|
|
$dir = sys_get_temp_dir();
|
|
|
|
|
if (!is_writable($dir)) {
|
2020-08-28 05:20:47 +00:00
|
|
|
|
$tmp = __DIR__ . '/tmp/';
|
|
|
|
|
if (file_exists($tmp)) {
|
|
|
|
|
if ( is_writable($tmp) ) $dir = $tmp;
|
|
|
|
|
} elseif ( mkdir($tmp) ) $dir = $tmp;
|
2020-08-17 08:26:22 +00:00
|
|
|
|
}
|
|
|
|
|
$tag = __DIR__ . '/OneManager/' . $_SERVER['disktag'];
|
|
|
|
|
while (strpos($tag, '/')>-1) $tag = str_replace('/', '_', $tag);
|
2020-08-18 07:48:32 +00:00
|
|
|
|
if (strpos($tag, ':')>-1) {
|
|
|
|
|
while (strpos($tag, ':')>-1) $tag = str_replace(':', '_', $tag);
|
|
|
|
|
while (strpos($tag, '\\')>-1) $tag = str_replace('\\', '_', $tag);
|
|
|
|
|
}
|
2020-08-17 08:26:22 +00:00
|
|
|
|
// error_log('DIR:' . $dir . ' TAG: ' . $tag);
|
|
|
|
|
$cache = new \Doctrine\Common\Cache\FilesystemCache($dir, $tag);
|
|
|
|
|
return $cache;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getconstStr($str)
|
|
|
|
|
{
|
|
|
|
|
global $constStr;
|
|
|
|
|
if ($constStr[$str][$constStr['language']]!='') return $constStr[$str][$constStr['language']];
|
|
|
|
|
return $constStr[$str]['en-us'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function config_oauth()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
2020-04-01 10:44:50 +00:00
|
|
|
|
if (getConfig('Drive_ver')=='shareurl') {
|
|
|
|
|
$_SERVER['api_url'] = getConfig('shareapiurl');
|
|
|
|
|
$_SERVER['sharecookie'] = getConfig('sharecookie');
|
|
|
|
|
$_SERVER['DownurlStrName'] = '@content.downloadUrl';
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-03-25 16:03:35 +00:00
|
|
|
|
if (getConfig('Drive_ver')=='MS') {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// MS
|
|
|
|
|
// https://portal.azure.com
|
2020-03-25 16:03:35 +00:00
|
|
|
|
//$_SERVER['client_id'] = '4da3e7f2-bf6d-467c-aaf0-578078f0bf7c';
|
|
|
|
|
//$_SERVER['client_secret'] = '7/+ykq2xkfx:.DWjacuIRojIaaWL0QI6';
|
|
|
|
|
$_SERVER['client_id'] = '734ef928-d74c-4555-8d1b-d942fa0a1a41';
|
|
|
|
|
$_SERVER['client_secret'] = ':EK[e0/4vQ@mQgma8LmnWb6j4_C1CSIW';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$_SERVER['oauth_url'] = 'https://login.microsoftonline.com/common/oauth2/v2.0/';
|
|
|
|
|
$_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/me/drive/root';
|
|
|
|
|
$_SERVER['scope'] = 'https://graph.microsoft.com/Files.ReadWrite.All offline_access';
|
2020-03-25 16:03:35 +00:00
|
|
|
|
if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/sites/' . getConfig('siteid') . '/drive/root';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-03-25 16:03:35 +00:00
|
|
|
|
if (getConfig('Drive_ver')=='CN') {
|
2020-08-26 09:58:45 +00:00
|
|
|
|
// CN 21Vianet
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// https://portal.azure.cn
|
2020-08-28 05:20:47 +00:00
|
|
|
|
//$_SERVER['client_id'] = '04c3ca0b-8d07-4773-85ad-98b037d25631';
|
|
|
|
|
//$_SERVER['client_secret'] = 'h8@B7kFVOmj0+8HKBWeNTgl@pU/z4yLB'; // expire 20200902
|
|
|
|
|
$_SERVER['client_id'] = 'b15f63f5-8b72-48b5-af69-8cab7579bff7';
|
|
|
|
|
$_SERVER['client_secret'] = '0IIuZ1Kcq_YI3NrkZFwsniEo~BoP~8_M22';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$_SERVER['oauth_url'] = 'https://login.partner.microsoftonline.cn/common/oauth2/v2.0/';
|
|
|
|
|
$_SERVER['api_url'] = 'https://microsoftgraph.chinacloudapi.cn/v1.0/me/drive/root';
|
|
|
|
|
$_SERVER['scope'] = 'https://microsoftgraph.chinacloudapi.cn/Files.ReadWrite.All offline_access';
|
2020-03-25 16:03:35 +00:00
|
|
|
|
if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/' . getConfig('siteid') . '/drive/root';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-03-25 16:03:35 +00:00
|
|
|
|
|
|
|
|
|
if (getConfig('Drive_custom')=='on') {
|
|
|
|
|
// Customer
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$_SERVER['client_id'] = getConfig('client_id');
|
2020-02-29 04:58:31 +00:00
|
|
|
|
$_SERVER['client_secret'] = getConfig('client_secret');
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
$_SERVER['client_secret'] = urlencode($_SERVER['client_secret']);
|
|
|
|
|
$_SERVER['scope'] = urlencode($_SERVER['scope']);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$_SERVER['DownurlStrName'] = '@microsoft.graph.downloadUrl';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-25 16:03:35 +00:00
|
|
|
|
function get_siteid($access_token)
|
|
|
|
|
{
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$sharepointSiteAddress = getConfig('sharepointSiteAddress');
|
|
|
|
|
while (substr($sharepointSiteAddress, -1)=='/') $sharepointSiteAddress = substr($sharepointSiteAddress, 0, -1);
|
|
|
|
|
$tmp = splitlast($sharepointSiteAddress, '/');
|
|
|
|
|
$sharepointname = $tmp[1];
|
|
|
|
|
$tmp = splitlast($tmp[0], '/');
|
|
|
|
|
$sharepointname = $tmp[1] . '/' . $sharepointname;
|
|
|
|
|
if (getConfig('Drive_ver')=='MS') $url = 'https://graph.microsoft.com/v1.0/sites/root:/'.$sharepointname;
|
|
|
|
|
if (getConfig('Drive_ver')=='CN') $url = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/root:/'.$sharepointname;
|
|
|
|
|
|
2020-03-25 16:03:35 +00:00
|
|
|
|
$i=0;
|
|
|
|
|
$response = [];
|
2020-03-26 12:40:50 +00:00
|
|
|
|
while ($url!=''&&$response['stat']!=200&&$i<4) {
|
|
|
|
|
$response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
|
2020-03-25 16:03:35 +00:00
|
|
|
|
$i++;
|
2020-03-26 12:40:50 +00:00
|
|
|
|
}
|
|
|
|
|
if ($response['stat']!=200) {
|
|
|
|
|
error_log('failed to get siteid. response' . json_encode($response));
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$response['body'] .= '\nfailed to get siteid.';
|
|
|
|
|
return $response;
|
|
|
|
|
//throw new Exception($response['stat'].', failed to get siteid.'.$response['body']);
|
2020-03-25 16:03:35 +00:00
|
|
|
|
}
|
|
|
|
|
return json_decode($response['body'],true)['id'];
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
function getListpath($domain)
|
|
|
|
|
{
|
2020-01-20 05:23:52 +00:00
|
|
|
|
$domain_path1 = getConfig('domain_path');
|
|
|
|
|
$public_path = getConfig('public_path');
|
|
|
|
|
$tmp_path='';
|
|
|
|
|
if ($domain_path1!='') {
|
|
|
|
|
$tmp = explode("|",$domain_path1);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
foreach ($tmp as $multidomain_paths){
|
|
|
|
|
$pos = strpos($multidomain_paths,":");
|
2020-01-20 10:47:08 +00:00
|
|
|
|
if ($pos>0) {
|
|
|
|
|
$domain1 = substr($multidomain_paths,0,$pos);
|
|
|
|
|
$tmp_path = path_format(substr($multidomain_paths,$pos+1));
|
|
|
|
|
$domain_path[$domain1] = $tmp_path;
|
|
|
|
|
if ($public_path=='') $public_path = $tmp_path;
|
2020-01-20 05:23:52 +00:00
|
|
|
|
//if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path;
|
2020-01-20 10:47:08 +00:00
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-01-20 05:23:52 +00:00
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain],'/');
|
2020-01-20 05:23:52 +00:00
|
|
|
|
return spurlencode($public_path,'/');
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function path_format($path)
|
|
|
|
|
{
|
|
|
|
|
$path = '/' . $path;
|
|
|
|
|
while (strpos($path, '//') !== FALSE) {
|
|
|
|
|
$path = str_replace('//', '/', $path);
|
|
|
|
|
}
|
|
|
|
|
return $path;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-03 03:19:50 +00:00
|
|
|
|
function spurlencode($str, $split='')
|
2020-01-18 12:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
$str = str_replace(' ', '%20',$str);
|
|
|
|
|
$tmp='';
|
2020-02-22 08:52:38 +00:00
|
|
|
|
if ($split!='') {
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$tmparr=explode($split, $str);
|
|
|
|
|
foreach ($tmparr as $str1) {
|
|
|
|
|
$tmp .= urlencode($str1) . $split;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$tmp = substr($tmp, 0, -strlen($split));
|
2020-01-18 12:12:21 +00:00
|
|
|
|
} else {
|
|
|
|
|
$tmp = urlencode($str);
|
|
|
|
|
}
|
|
|
|
|
$tmp = str_replace('%2520', '%20',$tmp);
|
|
|
|
|
return $tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-30 02:01:15 +00:00
|
|
|
|
function base64y_encode($str)
|
|
|
|
|
{
|
|
|
|
|
$str = base64_encode($str);
|
|
|
|
|
while (substr($str,-1)=='=') $str=substr($str,0,-1);
|
|
|
|
|
while (strpos($str, '+')!==false) $str = str_replace('+', '-', $str);
|
|
|
|
|
while (strpos($str, '/')!==false) $str = str_replace('/', '_', $str);
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function base64y_decode($str)
|
|
|
|
|
{
|
|
|
|
|
while (strpos($str, '_')!==false) $str = str_replace('_', '/', $str);
|
|
|
|
|
while (strpos($str, '-')!==false) $str = str_replace('-', '+', $str);
|
|
|
|
|
while (strlen($str)%4) $str .= '=';
|
|
|
|
|
$str = base64_decode($str);
|
|
|
|
|
if (strpos($str, '%')!==false) $str = urldecode($str);
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-20 04:07:51 +00:00
|
|
|
|
function equal_replace($str, $add = false)
|
|
|
|
|
{
|
|
|
|
|
if ($add) {
|
|
|
|
|
while(strlen($str)%4) $str .= '=';
|
2020-02-29 06:02:13 +00:00
|
|
|
|
$str = urldecode(base64_decode($str));
|
2020-02-20 04:07:51 +00:00
|
|
|
|
} else {
|
2020-02-29 06:02:13 +00:00
|
|
|
|
$str = base64_encode(urlencode($str));
|
2020-02-20 04:07:51 +00:00
|
|
|
|
while(substr($str,-1)=='=') $str=substr($str,0,-1);
|
|
|
|
|
}
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
function is_guestup_path($path)
|
|
|
|
|
{
|
2020-04-02 10:23:58 +00:00
|
|
|
|
$a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/');
|
|
|
|
|
$a2 = path_format(path_format(getConfig('guestup_path')).'/');
|
2020-04-02 10:18:08 +00:00
|
|
|
|
if (getConfig('guestup_path')!=''&&strtolower($a1)==strtolower($a2)) return 1;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-15 08:53:15 +00:00
|
|
|
|
function array_value_isnot_null($arr)
|
|
|
|
|
{
|
|
|
|
|
return $arr!=='';
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-16 03:37:28 +00:00
|
|
|
|
function curl($method, $url, $data = '', $headers = [], $returnheader = 0)
|
|
|
|
|
{
|
|
|
|
|
//if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
|
|
|
|
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;
|
|
|
|
|
//if (!isset($headers['Content-Type'])) $headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
|
|
|
$sendHeaders = array();
|
|
|
|
|
foreach ($headers as $headerName => $headerVal) {
|
|
|
|
|
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
|
|
|
|
}
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
|
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, $returnheader);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
|
|
|
|
|
//$response['body'] = curl_exec($ch);
|
|
|
|
|
if ($returnheader) {
|
|
|
|
|
list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch));
|
|
|
|
|
foreach (explode("\r\n", $returnhead) as $head) {
|
|
|
|
|
$tmp = explode(': ', $head);
|
|
|
|
|
$heads[$tmp[0]] = $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$response['returnhead'] = $heads;
|
|
|
|
|
} else {
|
|
|
|
|
$response['body'] = curl_exec($ch);
|
|
|
|
|
}
|
|
|
|
|
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 03:53:36 +00:00
|
|
|
|
function curl_request($url, $data = false, $headers = [], $returnheader = 0)
|
2020-01-18 12:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
2020-02-22 08:52:38 +00:00
|
|
|
|
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if (!isset($headers['Content-Type'])) $headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
|
|
|
$sendHeaders = array();
|
|
|
|
|
foreach ($headers as $headerName => $headerVal) {
|
|
|
|
|
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
|
|
|
|
}
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
if ($data !== false) {
|
|
|
|
|
curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
|
}
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
|
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
2020-03-27 03:53:36 +00:00
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, $returnheader);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
|
2020-03-27 03:53:36 +00:00
|
|
|
|
//$response['body'] = curl_exec($ch);
|
|
|
|
|
if ($returnheader) {
|
|
|
|
|
list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch));
|
|
|
|
|
foreach (explode("\r\n", $returnhead) as $head) {
|
|
|
|
|
$tmp = explode(': ', $head);
|
|
|
|
|
$heads[$tmp[0]] = $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$response['returnhead'] = $heads;
|
|
|
|
|
} else {
|
|
|
|
|
$response['body'] = curl_exec($ch);
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
|
|
|
|
|
{
|
|
|
|
|
for ($page=$page1+1;$page<$maxpage;$page++) {
|
|
|
|
|
$pageinfocache['nextlink_' . $path . '_page_' . $page] = '';
|
|
|
|
|
}
|
2020-02-15 08:53:15 +00:00
|
|
|
|
$pageinfocache = array_filter($pageinfocache, 'array_value_isnot_null');
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return $pageinfocache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function comppass($pass)
|
|
|
|
|
{
|
|
|
|
|
if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass ) {
|
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
|
$_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour'));
|
2020-04-05 05:45:28 +00:00
|
|
|
|
date_default_timezone_set(get_timezone($_SERVER['timezone']));
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3;
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function encode_str_replace($str)
|
|
|
|
|
{
|
|
|
|
|
$str = str_replace('&','&',$str);
|
|
|
|
|
$str = str_replace('+','%2B',$str);
|
|
|
|
|
$str = str_replace('#','%23',$str);
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function gethiddenpass($path,$passfile)
|
|
|
|
|
{
|
2020-03-03 07:17:38 +00:00
|
|
|
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
2020-03-22 11:32:42 +00:00
|
|
|
|
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
2020-03-03 09:45:33 +00:00
|
|
|
|
$password=getcache('path_' . $path1 . '/?password');
|
2020-02-03 12:03:04 +00:00
|
|
|
|
if ($password=='') {
|
2020-03-24 15:02:41 +00:00
|
|
|
|
$ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
|
|
|
|
|
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
|
|
|
|
|
if (isset($ispassfile['file'])) {
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$arr = curl_request($ispassfile[$_SERVER['DownurlStrName']]);
|
2020-03-24 15:02:41 +00:00
|
|
|
|
if ($arr['stat']==200) {
|
|
|
|
|
$passwordf=explode("\n",$arr['body']);
|
|
|
|
|
$password=$passwordf[0];
|
|
|
|
|
if ($password!='') $password=md5($password);
|
|
|
|
|
savecache('path_' . $path1 . '/?password', $password);
|
|
|
|
|
return $password;
|
|
|
|
|
} else {
|
|
|
|
|
//return md5('DefaultP@sswordWhenNetworkError');
|
|
|
|
|
return md5( md5(time()).rand(1000,9999) );
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
} else {
|
2020-03-24 15:02:41 +00:00
|
|
|
|
savecache('path_' . $path1 . '/?password', 'null');
|
|
|
|
|
if ($path !== '' ) {
|
|
|
|
|
$path = substr($path,0,strrpos($path,'/'));
|
|
|
|
|
return gethiddenpass($path,$passfile);
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-02-03 12:03:04 +00:00
|
|
|
|
} elseif ($password==='null') {
|
|
|
|
|
if ($path !== '' ) {
|
|
|
|
|
$path = substr($path,0,strrpos($path,'/'));
|
|
|
|
|
return gethiddenpass($path,$passfile);
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
} else return $password;
|
|
|
|
|
// return md5('DefaultP@sswordWhenNetworkError');
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_timezone($timezone = '8')
|
|
|
|
|
{
|
2020-04-05 06:32:23 +00:00
|
|
|
|
global $timezones;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if ($timezone=='') $timezone = '8';
|
|
|
|
|
return $timezones[$timezone];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function message($message, $title = 'Message', $statusCode = 200)
|
|
|
|
|
{
|
2020-02-23 05:39:11 +00:00
|
|
|
|
return output('
|
2020-03-03 05:27:18 +00:00
|
|
|
|
<html lang="' . $_SERVER['language'] . '">
|
2020-02-23 05:39:11 +00:00
|
|
|
|
<html>
|
|
|
|
|
<meta charset=utf-8>
|
2020-03-08 04:37:10 +00:00
|
|
|
|
<meta name=viewport content="width=device-width,initial-scale=1">
|
2020-02-23 05:39:11 +00:00
|
|
|
|
<body>
|
|
|
|
|
<h1>' . $title . '</h1>
|
|
|
|
|
<p>
|
2020-09-13 05:04:58 +00:00
|
|
|
|
|
2020-02-23 05:39:11 +00:00
|
|
|
|
' . $message . '
|
2020-09-13 05:04:58 +00:00
|
|
|
|
|
2020-02-23 05:39:11 +00:00
|
|
|
|
</p>
|
|
|
|
|
</body>
|
2020-03-13 02:53:19 +00:00
|
|
|
|
</html>
|
|
|
|
|
', $statusCode);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function needUpdate()
|
|
|
|
|
{
|
2020-09-13 05:04:58 +00:00
|
|
|
|
$slash = '/';
|
|
|
|
|
if (strpos(__DIR__, ':')) $slash = '\\';
|
|
|
|
|
$current_version = file_get_contents(__DIR__ . $slash . 'version');
|
2020-08-28 06:16:16 +00:00
|
|
|
|
$current_ver = substr($current_version, strpos($current_version, '.')+1);
|
2020-01-22 15:35:52 +00:00
|
|
|
|
$current_ver = explode(urldecode('%0A'),$current_ver)[0];
|
|
|
|
|
$current_ver = explode(urldecode('%0D'),$current_ver)[0];
|
2020-08-28 06:16:16 +00:00
|
|
|
|
$split = splitfirst($current_version, '.' . $current_ver)[0] . '.' . $current_ver;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
//$github_version = file_get_contents('https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version');
|
|
|
|
|
$tmp = curl_request('https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version');
|
|
|
|
|
if ($tmp['stat']==0) return 0;
|
|
|
|
|
$github_version = $tmp['body'];
|
2020-01-22 15:35:52 +00:00
|
|
|
|
$github_ver = substr($github_version, strpos($github_version, '.')+1);
|
|
|
|
|
$github_ver = explode(urldecode('%0A'),$github_ver)[0];
|
|
|
|
|
$github_ver = explode(urldecode('%0D'),$github_ver)[0];
|
|
|
|
|
if ($current_ver != $github_ver) {
|
2020-08-28 06:16:16 +00:00
|
|
|
|
//$_SERVER['github_version'] = $github_version;
|
|
|
|
|
$_SERVER['github_ver_new'] = splitfirst($github_version, $split)[0];
|
|
|
|
|
$_SERVER['github_ver_old'] = splitfirst($github_version, $_SERVER['github_ver_new'])[1];
|
2020-01-22 15:35:52 +00:00
|
|
|
|
return 1;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false)
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'isBase64Encoded' => $isBase64Encoded,
|
|
|
|
|
'statusCode' => $statusCode,
|
|
|
|
|
'headers' => $headers,
|
|
|
|
|
'body' => $body
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function passhidden($path)
|
|
|
|
|
{
|
|
|
|
|
$path = str_replace('+','%2B',$path);
|
|
|
|
|
$path = str_replace('&','&', path_format(urldecode($path)));
|
|
|
|
|
if (getConfig('passfile') != '') {
|
2020-03-03 09:45:33 +00:00
|
|
|
|
$path = spurlencode($path,'/');
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
|
|
|
|
$hiddenpass=gethiddenpass($path,getConfig('passfile'));
|
|
|
|
|
if ($hiddenpass != '') {
|
|
|
|
|
return comppass($hiddenpass);
|
|
|
|
|
} else {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function size_format($byte)
|
|
|
|
|
{
|
|
|
|
|
$i = 0;
|
|
|
|
|
while (abs($byte) >= 1024) {
|
|
|
|
|
$byte = $byte / 1024;
|
|
|
|
|
$i++;
|
|
|
|
|
if ($i == 3) break;
|
|
|
|
|
}
|
|
|
|
|
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
|
|
|
|
$ret = round($byte, 2);
|
|
|
|
|
return ($ret . ' ' . $units[$i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function time_format($ISO)
|
|
|
|
|
{
|
2020-08-23 11:25:36 +00:00
|
|
|
|
if ($ISO=='') return date('Y-m-d H:i:s');
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$ISO = str_replace('T', ' ', $ISO);
|
|
|
|
|
$ISO = str_replace('Z', ' ', $ISO);
|
|
|
|
|
return date('Y-m-d H:i:s',strtotime($ISO . " UTC"));
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-24 10:15:31 +00:00
|
|
|
|
function get_thumbnails_url($path = '/', $location = 0)
|
2020-01-18 12:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
$path1 = path_format($path);
|
|
|
|
|
$path = path_format($_SERVER['list_path'] . path_format($path));
|
2020-03-22 11:32:42 +00:00
|
|
|
|
if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
|
|
|
|
|
$thumb_url = getcache('thumb_'.$path);
|
2020-05-24 10:15:31 +00:00
|
|
|
|
if ($thumb_url=='') {
|
|
|
|
|
$url = $_SERVER['api_url'];
|
|
|
|
|
if ($path !== '/') {
|
|
|
|
|
$url .= ':' . $path;
|
|
|
|
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
|
|
|
|
}
|
|
|
|
|
$url .= ':/thumbnails/0/medium';
|
|
|
|
|
$files = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
|
|
|
|
if (isset($files['url'])) {
|
|
|
|
|
savecache('thumb_'.$path, $files['url']);
|
|
|
|
|
$thumb_url = $files['url'];
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-05-24 10:15:31 +00:00
|
|
|
|
if ($thumb_url!='') {
|
2020-06-07 10:43:47 +00:00
|
|
|
|
if ($location) {
|
|
|
|
|
$url = $thumb_url;
|
|
|
|
|
$domainforproxy = '';
|
|
|
|
|
$domainforproxy = getConfig('domainforproxy');
|
|
|
|
|
if ($domainforproxy!='') {
|
|
|
|
|
$url = proxy_replace_domain($url, $domainforproxy);
|
|
|
|
|
}
|
|
|
|
|
return output('', 302, [ 'Location' => $url ]);
|
|
|
|
|
} else return output($thumb_url);
|
2020-02-03 12:03:04 +00:00
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return output('', 404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bigfileupload($path)
|
|
|
|
|
{
|
|
|
|
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
|
|
|
|
if (substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
|
|
|
|
if ($_GET['upbigfilename']!=''&&$_GET['filesize']>0) {
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$tmp = splitlast($_GET['upbigfilename'], '/');
|
|
|
|
|
if ($tmp[1]!='') {
|
|
|
|
|
$fileinfo['name'] = $tmp[1];
|
|
|
|
|
$fileinfo['path'] = $tmp[0];
|
|
|
|
|
} else {
|
|
|
|
|
$fileinfo['name'] = $_GET['upbigfilename'];
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$fileinfo['size'] = $_GET['filesize'];
|
|
|
|
|
$fileinfo['lastModified'] = $_GET['lastModified'];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$filename = spurlencode($_GET['upbigfilename'],'/');
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if ($fileinfo['size']>10*1024*1024) {
|
|
|
|
|
$cachefilename = spurlencode( $fileinfo['path'] . '/.' . $fileinfo['lastModified'] . '_' . $fileinfo['size'] . '_' . $fileinfo['name'] . '.tmp', '/');
|
|
|
|
|
$getoldupinfo=fetch_files(path_format($path . '/' . $cachefilename));
|
|
|
|
|
//echo json_encode($getoldupinfo, JSON_PRETTY_PRINT);
|
|
|
|
|
if (isset($getoldupinfo['file'])&&$getoldupinfo['size']<5120) {
|
|
|
|
|
$getoldupinfo_j = curl_request($getoldupinfo[$_SERVER['DownurlStrName']]);
|
|
|
|
|
$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']);
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-05-30 07:05:23 +00:00
|
|
|
|
//if (!$_SERVER['admin']) $filename = spurlencode( $fileinfo['name'] ) . '.scfupload';
|
2020-09-03 03:19:50 +00:00
|
|
|
|
$response = MSAPI('createUploadSession', path_format($path1 . '/' . $filename), '{"item": { "@microsoft.graph.conflictBehavior": "fail" }}', $_SERVER['access_token']);
|
|
|
|
|
if ($response['stat']<500) {
|
|
|
|
|
$responsearry = json_decode($response['body'],true);
|
|
|
|
|
if (isset($responsearry['error'])) return output($response['body'], $response['stat']);
|
|
|
|
|
$fileinfo['uploadUrl'] = $responsearry['uploadUrl'];
|
|
|
|
|
if ($fileinfo['size']>10*1024*1024) MSAPI('PUT', path_format($path1 . '/' . $cachefilename), json_encode($fileinfo, JSON_PRETTY_PRINT), $_SERVER['access_token']);
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return output($response['body'], $response['stat']);
|
|
|
|
|
}
|
|
|
|
|
return output('error', 400);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function adminform($name = '', $pass = '', $path = '')
|
|
|
|
|
{
|
2020-08-24 01:13:27 +00:00
|
|
|
|
$html = '<html><head><title>' . getconstStr('AdminLogin') . '</title><meta charset=utf-8></head>';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if ($name!=''&&$pass!='') {
|
2020-08-24 01:13:27 +00:00
|
|
|
|
$html .= '<meta http-equiv="refresh" content="3;URL=' . $path . '"><body>' . getconstStr('LoginSuccess') . '</body></html>';
|
2020-08-26 02:27:20 +00:00
|
|
|
|
$statusCode = 201;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
|
$header = [
|
2020-08-24 01:13:27 +00:00
|
|
|
|
'Set-Cookie' => $name . '=' . $pass . '; path=/; expires=' . date(DATE_COOKIE, strtotime('+1hour')),
|
|
|
|
|
//'Location' => $path,
|
2020-01-18 12:12:21 +00:00
|
|
|
|
'Content-Type' => 'text/html'
|
|
|
|
|
];
|
2020-08-24 01:13:27 +00:00
|
|
|
|
return output($html, $statusCode, $header);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-08-24 01:13:27 +00:00
|
|
|
|
$statusCode = 401;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$html .= '
|
|
|
|
|
<body>
|
|
|
|
|
<div>
|
2020-08-24 01:13:27 +00:00
|
|
|
|
<center><h4>' . getconstStr('InputPassword') . '</h4>
|
2020-01-18 12:12:21 +00:00
|
|
|
|
<form action="" method="post">
|
|
|
|
|
<div>
|
|
|
|
|
<input name="password1" type="password"/>
|
2020-08-24 01:13:27 +00:00
|
|
|
|
<input type="submit" value="' . getconstStr('Login') . '">
|
2020-01-18 12:12:21 +00:00
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</center>
|
|
|
|
|
</div>
|
|
|
|
|
';
|
|
|
|
|
$html .= '</body></html>';
|
2020-08-24 01:13:27 +00:00
|
|
|
|
return output($html, $statusCode);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function adminoperate($path)
|
|
|
|
|
{
|
|
|
|
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
|
|
|
|
if (substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
|
|
|
|
$tmparr['statusCode'] = 0;
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_GET['rename_newname'])&&$_GET['rename_newname']!=$_GET['rename_oldname'] && $_GET['rename_newname']!='') {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// rename 重命名
|
|
|
|
|
$oldname = spurlencode($_GET['rename_oldname']);
|
|
|
|
|
$oldname = path_format($path1 . '/' . $oldname);
|
|
|
|
|
$data = '{"name":"' . $_GET['rename_newname'] . '"}';
|
|
|
|
|
//echo $oldname;
|
|
|
|
|
$result = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
|
|
|
|
|
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
|
|
|
return output($result['body'], $result['stat']);
|
|
|
|
|
}
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_GET['delete_name'])) {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// delete 删除
|
|
|
|
|
$filename = spurlencode($_GET['delete_name']);
|
|
|
|
|
$filename = path_format($path1 . '/' . $filename);
|
|
|
|
|
//echo $filename;
|
|
|
|
|
$result = MSAPI('DELETE', $filename, '', $_SERVER['access_token']);
|
|
|
|
|
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
|
|
|
return output($result['body'], $result['stat']);
|
|
|
|
|
}
|
2020-05-04 04:34:08 +00:00
|
|
|
|
if (isset($_GET['operate_action'])&&$_GET['operate_action']==getconstStr('Encrypt')) {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// encrypt 加密
|
|
|
|
|
if (getConfig('passfile')=='') return message(getconstStr('SetpassfileBfEncrypt'),'',403);
|
|
|
|
|
if ($_GET['encrypt_folder']=='/') $_GET['encrypt_folder']=='';
|
|
|
|
|
$foldername = spurlencode($_GET['encrypt_folder']);
|
|
|
|
|
$filename = path_format($path1 . '/' . $foldername . '/' . getConfig('passfile'));
|
|
|
|
|
//echo $foldername;
|
|
|
|
|
$result = MSAPI('PUT', $filename, $_GET['encrypt_newpass'], $_SERVER['access_token']);
|
2020-03-03 09:45:33 +00:00
|
|
|
|
$path1 = path_format($path1 . '/' . $foldername );
|
2020-03-24 15:02:41 +00:00
|
|
|
|
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
2020-03-03 09:45:33 +00:00
|
|
|
|
savecache('path_' . $path1 . '/?password', '', 1);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return output($result['body'], $result['stat']);
|
|
|
|
|
}
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_GET['move_folder'])) {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// move 移动
|
|
|
|
|
$moveable = 1;
|
|
|
|
|
if ($path == '/' && $_GET['move_folder'] == '/../') $moveable=0;
|
|
|
|
|
if ($_GET['move_folder'] == $_GET['move_name']) $moveable=0;
|
|
|
|
|
if ($moveable) {
|
|
|
|
|
$filename = spurlencode($_GET['move_name']);
|
|
|
|
|
$filename = path_format($path1 . '/' . $filename);
|
|
|
|
|
$foldername = path_format('/'.urldecode($path1).'/'.$_GET['move_folder']);
|
|
|
|
|
$data = '{"parentReference":{"path": "/drive/root:'.$foldername.'"}}';
|
|
|
|
|
$result = MSAPI('PATCH', $filename, $data, $_SERVER['access_token']);
|
|
|
|
|
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
|
|
|
if ($_GET['move_folder'] == '/../') $path2 = path_format( substr($path1, 0, strrpos($path1, '/')) . '/' );
|
|
|
|
|
else $path2 = path_format( $path1 . '/' . $_GET['move_folder'] . '/' );
|
2020-03-22 11:32:42 +00:00
|
|
|
|
if ($path2!='/'&&substr($path2,-1)=='/') $path2=substr($path2,0,-1);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
savecache('path_' . $path2, json_decode('{}',true), 1);
|
|
|
|
|
return output($result['body'], $result['stat']);
|
|
|
|
|
} else {
|
2020-02-20 04:07:51 +00:00
|
|
|
|
return output('{"error":"'.getconstStr('CannotMove').'"}', 403);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_GET['copy_name'])) {
|
2020-02-22 08:52:38 +00:00
|
|
|
|
// copy 复制
|
|
|
|
|
$filename = spurlencode($_GET['copy_name']);
|
|
|
|
|
$filename = path_format($path1 . '/' . $filename);
|
|
|
|
|
$namearr = splitlast($_GET['copy_name'], '.');
|
|
|
|
|
if ($namearr[0]!='') {
|
|
|
|
|
$newname = $namearr[0] . ' (' . getconstStr('Copy') . ')';
|
|
|
|
|
if ($namearr[1]!='') $newname .= '.' . $namearr[1];
|
|
|
|
|
} else {
|
|
|
|
|
$newname = '.' . $namearr[1] . ' (' . getconstStr('Copy') . ')';
|
|
|
|
|
}
|
|
|
|
|
//$newname = spurlencode($newname);
|
|
|
|
|
//$foldername = path_format('/'.urldecode($path1).'/./');
|
|
|
|
|
//$data = '{"parentReference":{"path": "/drive/root:'.$foldername.'"}}';
|
|
|
|
|
$data = '{ "name": "' . $newname . '" }';
|
|
|
|
|
$result = MSAPI('copy', $filename, $data, $_SERVER['access_token']);
|
|
|
|
|
$num = 0;
|
|
|
|
|
while ($result['stat']==409 && json_decode($result['body'], true)['error']['code']=='nameAlreadyExists') {
|
|
|
|
|
$num++;
|
|
|
|
|
if ($namearr[0]!='') {
|
|
|
|
|
$newname = $namearr[0] . ' (' . getconstStr('Copy') . ' ' . $num . ')';
|
|
|
|
|
if ($namearr[1]!='') $newname .= '.' . $namearr[1];
|
|
|
|
|
} else {
|
|
|
|
|
$newname = '.' . $namearr[1] . ' ('.getconstStr('Copy'). ' ' . $num .')';
|
|
|
|
|
}
|
|
|
|
|
//$newname = spurlencode($newname);
|
|
|
|
|
$data = '{ "name": "' . $newname . '" }';
|
|
|
|
|
$result = MSAPI('copy', $filename, $data, $_SERVER['access_token']);
|
|
|
|
|
}
|
|
|
|
|
//echo $result['stat'].$result['body'];
|
|
|
|
|
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
|
|
|
//if ($_GET['move_folder'] == '/../') $path2 = path_format( substr($path1, 0, strrpos($path1, '/')) . '/' );
|
|
|
|
|
//else $path2 = path_format( $path1 . '/' . $_GET['move_folder'] . '/' );
|
|
|
|
|
//savecache('path_' . $path2, json_decode('{}',true), 1);
|
2020-03-24 15:02:41 +00:00
|
|
|
|
return output($result['body'], $result['stat']);
|
2020-02-22 08:52:38 +00:00
|
|
|
|
}
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_POST['editfile'])) {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// edit 编辑
|
|
|
|
|
$data = $_POST['editfile'];
|
|
|
|
|
/*TXT一般不会超过4M,不用二段上传
|
|
|
|
|
$filename = $path1 . ':/createUploadSession';
|
|
|
|
|
$response=MSAPI('POST',$filename,'{"item": { "@microsoft.graph.conflictBehavior": "replace" }}',$_SERVER['access_token']);
|
|
|
|
|
$uploadurl=json_decode($response,true)['uploadUrl'];
|
|
|
|
|
echo MSAPI('PUT',$uploadurl,$data,$_SERVER['access_token']);*/
|
|
|
|
|
$result = MSAPI('PUT', $path1, $data, $_SERVER['access_token'])['body'];
|
|
|
|
|
//echo $result;
|
|
|
|
|
$resultarry = json_decode($result,true);
|
2020-02-20 04:07:51 +00:00
|
|
|
|
if (isset($resultarry['error'])) return message($resultarry['error']['message']. '<hr><a href="javascript:history.back(-1)">'.getconstStr('Back').'</a>','Error',403);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_GET['create_name'])) {
|
2020-01-18 12:12:21 +00:00
|
|
|
|
// create 新建
|
|
|
|
|
if ($_GET['create_type']=='file') {
|
|
|
|
|
$filename = spurlencode($_GET['create_name']);
|
|
|
|
|
$filename = path_format($path1 . '/' . $filename);
|
|
|
|
|
$result = MSAPI('PUT', $filename, $_GET['create_text'], $_SERVER['access_token']);
|
|
|
|
|
}
|
|
|
|
|
if ($_GET['create_type']=='folder') {
|
|
|
|
|
$data = '{ "name": "' . $_GET['create_name'] . '", "folder": { }, "@microsoft.graph.conflictBehavior": "rename" }';
|
|
|
|
|
$result = MSAPI('children', $path1, $data, $_SERVER['access_token']);
|
|
|
|
|
}
|
|
|
|
|
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
|
|
|
|
return output($result['body'], $result['stat']);
|
|
|
|
|
}
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_GET['RefreshCache'])) {
|
2020-03-03 07:17:38 +00:00
|
|
|
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
2020-03-22 11:32:42 +00:00
|
|
|
|
if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
|
2020-03-03 05:27:18 +00:00
|
|
|
|
savecache('path_' . $path1 . '/?password', '', 1);
|
2020-05-24 07:07:56 +00:00
|
|
|
|
savecache('customTheme', '', 1);
|
2020-02-12 03:37:54 +00:00
|
|
|
|
return message('<meta http-equiv="refresh" content="2;URL=./">', getconstStr('RefreshCache'), 302);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
return $tmparr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-02 10:18:08 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 08:52:38 +00:00
|
|
|
|
function splitlast($str, $split)
|
|
|
|
|
{
|
2020-04-02 10:18:08 +00:00
|
|
|
|
$len = strlen($split);
|
2020-02-22 08:52:38 +00:00
|
|
|
|
$pos = strrpos($str, $split);
|
|
|
|
|
if ($pos===false) {
|
|
|
|
|
$tmp[0] = $str;
|
|
|
|
|
$tmp[1] = '';
|
|
|
|
|
} elseif ($pos>0) {
|
|
|
|
|
$tmp[0] = substr($str, 0, $pos);
|
2020-04-02 10:18:08 +00:00
|
|
|
|
$tmp[1] = substr($str, $pos+$len);
|
2020-02-22 08:52:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
$tmp[0] = '';
|
2020-04-02 10:18:08 +00:00
|
|
|
|
$tmp[1] = substr($str, $len);
|
2020-02-22 08:52:38 +00:00
|
|
|
|
}
|
|
|
|
|
return $tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
function MSAPI($method, $path, $data = '', $access_token)
|
|
|
|
|
{
|
|
|
|
|
if (substr($path,0,7) == 'http://' or substr($path,0,8) == 'https://') {
|
|
|
|
|
$url=$path;
|
|
|
|
|
$lenth=strlen($data);
|
|
|
|
|
$headers['Content-Length'] = $lenth;
|
|
|
|
|
$lenth--;
|
|
|
|
|
$headers['Content-Range'] = 'bytes 0-' . $lenth . '/' . $headers['Content-Length'];
|
|
|
|
|
} else {
|
|
|
|
|
$url = $_SERVER['api_url'];
|
|
|
|
|
if ($path=='' or $path=='/') {
|
|
|
|
|
$url .= '/';
|
|
|
|
|
} else {
|
|
|
|
|
$url .= ':' . $path;
|
|
|
|
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
|
|
|
|
}
|
|
|
|
|
if ($method=='PUT') {
|
|
|
|
|
if ($path=='' or $path=='/') {
|
|
|
|
|
$url .= 'content';
|
|
|
|
|
} else {
|
|
|
|
|
$url .= ':/content';
|
|
|
|
|
}
|
|
|
|
|
$headers['Content-Type'] = 'text/plain';
|
|
|
|
|
} elseif ($method=='PATCH') {
|
|
|
|
|
$headers['Content-Type'] = 'application/json';
|
|
|
|
|
} elseif ($method=='POST') {
|
|
|
|
|
$headers['Content-Type'] = 'application/json';
|
|
|
|
|
} elseif ($method=='DELETE') {
|
|
|
|
|
$headers['Content-Type'] = 'application/json';
|
|
|
|
|
} else {
|
|
|
|
|
if ($path=='' or $path=='/') {
|
|
|
|
|
$url .= $method;
|
|
|
|
|
} else {
|
|
|
|
|
$url .= ':/' . $method;
|
|
|
|
|
}
|
|
|
|
|
$method='POST';
|
|
|
|
|
$headers['Content-Type'] = 'application/json';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$headers['Authorization'] = 'Bearer ' . $access_token;
|
|
|
|
|
if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
|
2020-02-22 08:52:38 +00:00
|
|
|
|
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;*
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$sendHeaders = array();
|
|
|
|
|
foreach ($headers as $headerName => $headerVal) {
|
|
|
|
|
$sendHeaders[] = $headerName . ': ' . $headerVal;
|
|
|
|
|
}
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,$method);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
|
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
2020-02-22 08:52:38 +00:00
|
|
|
|
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
|
|
|
|
|
$response['body'] = curl_exec($ch);
|
|
|
|
|
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
2020-02-22 08:52:38 +00:00
|
|
|
|
//$response['Location'] = curl_getinfo($ch);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
curl_close($ch);
|
|
|
|
|
error_log($response['stat'].'
|
|
|
|
|
'.$response['body'].'
|
|
|
|
|
');
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fetch_files($path = '/')
|
|
|
|
|
{
|
2020-03-21 06:27:25 +00:00
|
|
|
|
global $exts;
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$path1 = path_format($path);
|
|
|
|
|
$path = path_format($_SERVER['list_path'] . path_format($path));
|
2020-03-22 07:50:21 +00:00
|
|
|
|
if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if (!($files = getcache('path_' . $path))) {
|
|
|
|
|
// https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0
|
|
|
|
|
// https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
|
|
|
|
|
// https://developer.microsoft.com/zh-cn/graph/graph-explorer
|
2020-03-21 10:12:59 +00:00
|
|
|
|
$pos = splitlast($path, '/');
|
|
|
|
|
$parentpath = $pos[0];
|
2020-03-22 11:32:42 +00:00
|
|
|
|
if ($parentpath=='') $parentpath = '/';
|
2020-03-21 10:12:59 +00:00
|
|
|
|
$filename = $pos[1];
|
2020-03-22 07:31:29 +00:00
|
|
|
|
if ($parentfiles = getcache('path_' . $parentpath)) {
|
2020-04-01 10:44:50 +00:00
|
|
|
|
if (isset($parentfiles['children'][$filename][$_SERVER['DownurlStrName']])) {
|
2020-03-21 10:12:59 +00:00
|
|
|
|
if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
|
|
|
|
|
if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$content1 = curl_request($parentfiles['children'][$filename][$_SERVER['DownurlStrName']]);
|
2020-03-21 10:12:59 +00:00
|
|
|
|
$parentfiles['children'][$filename]['content'] = $content1;
|
2020-03-22 07:31:29 +00:00
|
|
|
|
savecache('path_' . $parentpath, $parentfiles);
|
2020-03-21 06:27:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-21 10:12:59 +00:00
|
|
|
|
return $parentfiles['children'][$filename];
|
2020-03-21 06:27:25 +00:00
|
|
|
|
}
|
2020-02-21 04:43:24 +00:00
|
|
|
|
}
|
2020-03-21 10:12:59 +00:00
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$url = $_SERVER['api_url'];
|
|
|
|
|
if ($path !== '/') {
|
|
|
|
|
$url .= ':' . $path;
|
|
|
|
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
|
|
|
|
}
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$url .= '?expand=children(select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'].')';
|
2020-03-21 06:27:25 +00:00
|
|
|
|
$retry = 0;
|
|
|
|
|
$arr = [];
|
2020-03-18 10:47:16 +00:00
|
|
|
|
while ($retry<3&&!$arr['stat']) {
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']],1);
|
2020-03-18 10:47:16 +00:00
|
|
|
|
$retry++;
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if ($arr['stat']<500) {
|
|
|
|
|
$files = json_decode($arr['body'], true);
|
2020-04-01 10:44:50 +00:00
|
|
|
|
//echo $path . '<br><pre>' . json_encode($arr, JSON_PRETTY_PRINT) . '</pre>';
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if (isset($files['folder'])) {
|
|
|
|
|
if ($files['folder']['childCount']>200) {
|
2020-03-15 12:50:29 +00:00
|
|
|
|
// files num > 200 , then get nextlink
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$page = $_POST['pagenum']==''?1:$_POST['pagenum'];
|
2020-03-15 12:50:29 +00:00
|
|
|
|
if ($page>1) $files=fetch_files_children($files, $path1, $page);
|
|
|
|
|
$files['children'] = children_name($files['children']);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
/*$url = $_SERVER['api_url'];
|
|
|
|
|
if ($path !== '/') {
|
|
|
|
|
$url .= ':' . $path;
|
|
|
|
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
|
|
|
|
$url .= ':/children?$top=9999&$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
|
|
|
|
|
} else {
|
|
|
|
|
$url .= '/children?$top=9999&$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
|
|
|
|
|
}
|
|
|
|
|
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
|
|
|
|
$files['children'] = $children['value'];*/
|
2020-01-18 12:12:21 +00:00
|
|
|
|
} else {
|
|
|
|
|
// files num < 200 , then cache
|
2020-03-15 12:50:29 +00:00
|
|
|
|
//if (isset($files['children'])) {
|
|
|
|
|
$files['children'] = children_name($files['children']);
|
|
|
|
|
//}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
savecache('path_' . $path, $files);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-10 02:40:18 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-18 12:12:21 +00:00
|
|
|
|
if (isset($files['error'])) {
|
|
|
|
|
$files['error']['stat'] = $arr['stat'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2020-03-18 10:47:16 +00:00
|
|
|
|
//error_log($arr['body']);
|
|
|
|
|
$files = json_decode($arr['body'], true);
|
|
|
|
|
if (isset($files['error'])) {
|
|
|
|
|
$files['error']['stat'] = $arr['stat'];
|
|
|
|
|
} else {
|
|
|
|
|
$files['error']['stat'] = 503;
|
|
|
|
|
$files['error']['code'] = 'unknownError';
|
|
|
|
|
$files['error']['message'] = 'unknownError';
|
|
|
|
|
}
|
|
|
|
|
//$files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
|
|
|
|
|
//error_log(json_encode($files, JSON_PRETTY_PRINT));
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-09 10:55:17 +00:00
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return $files;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-15 12:50:29 +00:00
|
|
|
|
function children_name($children)
|
|
|
|
|
{
|
|
|
|
|
$tmp = [];
|
|
|
|
|
foreach ($children as $file) {
|
2020-03-21 06:27:25 +00:00
|
|
|
|
$tmp[strtolower($file['name'])] = $file;
|
2020-03-15 12:50:29 +00:00
|
|
|
|
}
|
|
|
|
|
return $tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-18 12:12:21 +00:00
|
|
|
|
function fetch_files_children($files, $path, $page)
|
|
|
|
|
{
|
2020-02-22 08:52:38 +00:00
|
|
|
|
$path1 = path_format($path);
|
|
|
|
|
$path = path_format($_SERVER['list_path'] . path_format($path));
|
2020-03-22 11:32:42 +00:00
|
|
|
|
if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$cachefilename = '.SCFcache_'.$_SERVER['function_name'];
|
|
|
|
|
$maxpage = ceil($files['folder']['childCount']/200);
|
|
|
|
|
if (!($files['children'] = getcache('files_' . $path . '_page_' . $page))) {
|
|
|
|
|
// down cache file get jump info. 下载cache文件获取跳页链接
|
|
|
|
|
$cachefile = fetch_files(path_format($path1 . '/' .$cachefilename));
|
|
|
|
|
if ($cachefile['size']>0) {
|
2020-04-01 10:44:50 +00:00
|
|
|
|
$pageinfo = curl_request($cachefile[$_SERVER['DownurlStrName']])['body'];
|
2020-01-18 12:12:21 +00:00
|
|
|
|
$pageinfo = json_decode($pageinfo,true);
|
|
|
|
|
for ($page4=1;$page4<$maxpage;$page4++) {
|
|
|
|
|
savecache('nextlink_' . $path . '_page_' . $page4, $pageinfo['nextlink_' . $path . '_page_' . $page4]);
|
|
|
|
|
$pageinfocache['nextlink_' . $path . '_page_' . $page4] = $pageinfo['nextlink_' . $path . '_page_' . $page4];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$pageinfochange=0;
|
|
|
|
|
for ($page1=$page;$page1>=1;$page1--) {
|
|
|
|
|
$page3=$page1-1;
|
|
|
|
|
$url = getcache('nextlink_' . $path . '_page_' . $page3);
|
|
|
|
|
if ($url == '') {
|
|
|
|
|
if ($page1==1) {
|
|
|
|
|
$url = $_SERVER['api_url'];
|
|
|
|
|
if ($path !== '/') {
|
|
|
|
|
$url .= ':' . $path;
|
|
|
|
|
if (substr($url,-1)=='/') $url=substr($url,0,-1);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$url .= ':/children?$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
|
2020-01-18 12:12:21 +00:00
|
|
|
|
} else {
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$url .= '/children?$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
$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>';
|
|
|
|
|
savecache('files_' . $path . '_page_' . $page1, $children['value']);
|
|
|
|
|
$nextlink=getcache('nextlink_' . $path . '_page_' . $page1);
|
|
|
|
|
if ($nextlink!=$children['@odata.nextLink']) {
|
|
|
|
|
savecache('nextlink_' . $path . '_page_' . $page1, $children['@odata.nextLink']);
|
|
|
|
|
$pageinfocache['nextlink_' . $path . '_page_' . $page1] = $children['@odata.nextLink'];
|
|
|
|
|
$pageinfocache = clearbehindvalue($path,$page1,$maxpage,$pageinfocache);
|
|
|
|
|
$pageinfochange = 1;
|
|
|
|
|
}
|
|
|
|
|
$url = $children['@odata.nextLink'];
|
|
|
|
|
for ($page2=$page1+1;$page2<=$page;$page2++) {
|
|
|
|
|
sleep(1);
|
|
|
|
|
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
|
|
|
|
savecache('files_' . $path . '_page_' . $page2, $children['value']);
|
|
|
|
|
$nextlink=getcache('nextlink_' . $path . '_page_' . $page2);
|
|
|
|
|
if ($nextlink!=$children['@odata.nextLink']) {
|
|
|
|
|
savecache('nextlink_' . $path . '_page_' . $page2, $children['@odata.nextLink']);
|
|
|
|
|
$pageinfocache['nextlink_' . $path . '_page_' . $page2] = $children['@odata.nextLink'];
|
|
|
|
|
$pageinfocache = clearbehindvalue($path,$page2,$maxpage,$pageinfocache);
|
|
|
|
|
$pageinfochange = 1;
|
|
|
|
|
}
|
|
|
|
|
$url = $children['@odata.nextLink'];
|
|
|
|
|
}
|
|
|
|
|
//echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
|
|
|
|
$files['children'] = $children['value'];
|
|
|
|
|
$files['folder']['page']=$page;
|
|
|
|
|
$pageinfocache['filenum'] = $files['folder']['childCount'];
|
|
|
|
|
$pageinfocache['dirsize'] = $files['size'];
|
|
|
|
|
$pageinfocache['cachesize'] = $cachefile['size'];
|
|
|
|
|
$pageinfocache['size'] = $files['size']-$cachefile['size'];
|
|
|
|
|
if ($pageinfochange == 1) MSAPI('PUT', path_format($path.'/'.$cachefilename), json_encode($pageinfocache, JSON_PRETTY_PRINT), $_SERVER['access_token'])['body'];
|
|
|
|
|
return $files;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for ($page2=$page3+1;$page2<=$page;$page2++) {
|
|
|
|
|
sleep(1);
|
|
|
|
|
$children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
|
|
|
|
|
savecache('files_' . $path . '_page_' . $page2, $children['value'], 3300);
|
|
|
|
|
$nextlink=getcache('nextlink_' . $path . '_page_' . $page2);
|
|
|
|
|
if ($nextlink!=$children['@odata.nextLink']) {
|
|
|
|
|
savecache('nextlink_' . $path . '_page_' . $page2, $children['@odata.nextLink'], 3300);
|
|
|
|
|
$pageinfocache['nextlink_' . $path . '_page_' . $page2] = $children['@odata.nextLink'];
|
|
|
|
|
$pageinfocache = clearbehindvalue($path,$page2,$maxpage,$pageinfocache);
|
|
|
|
|
$pageinfochange = 1;
|
|
|
|
|
}
|
|
|
|
|
$url = $children['@odata.nextLink'];
|
|
|
|
|
}
|
|
|
|
|
//echo $url . '<br><pre>' . json_encode($children, JSON_PRETTY_PRINT) . '</pre>';
|
|
|
|
|
$files['children'] = $children['value'];
|
|
|
|
|
$files['folder']['page']=$page;
|
|
|
|
|
$pageinfocache['filenum'] = $files['folder']['childCount'];
|
|
|
|
|
$pageinfocache['dirsize'] = $files['size'];
|
|
|
|
|
$pageinfocache['cachesize'] = $cachefile['size'];
|
|
|
|
|
$pageinfocache['size'] = $files['size']-$cachefile['size'];
|
|
|
|
|
if ($pageinfochange == 1) MSAPI('PUT', path_format($path.'/'.$cachefilename), json_encode($pageinfocache, JSON_PRETTY_PRINT), $_SERVER['access_token'])['body'];
|
|
|
|
|
return $files;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$files['folder']['page']=$page;
|
|
|
|
|
for ($page4=1;$page4<=$maxpage;$page4++) {
|
|
|
|
|
if (!($url = getcache('nextlink_' . $path . '_page_' . $page4))) {
|
|
|
|
|
if ($files['folder'][$path.'_'.$page4]!='') savecache('nextlink_' . $path . '_page_' . $page4, $files['folder'][$path.'_'.$page4]);
|
|
|
|
|
} else {
|
|
|
|
|
$files['folder'][$path.'_'.$page4] = $url;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $files;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 10:45:10 +00:00
|
|
|
|
function get_refresh_token()
|
2020-01-18 12:12:21 +00:00
|
|
|
|
{
|
|
|
|
|
global $constStr;
|
2020-05-07 10:45:10 +00:00
|
|
|
|
global $CommonEnv;
|
2020-08-23 04:44:55 +00:00
|
|
|
|
config_oauth();
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$envs = '';
|
|
|
|
|
foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', ';
|
|
|
|
|
$url = path_format($_SERVER['PHP_SELF'] . '/');
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if (isset($_GET['install2']) && isset($_GET['code'])) {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$_SERVER['disktag'] = $_COOKIE['disktag'];
|
|
|
|
|
config_oauth();
|
|
|
|
|
$tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']);
|
|
|
|
|
if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true);
|
|
|
|
|
if (isset($ret['refresh_token'])) {
|
|
|
|
|
$refresh_token = $ret['refresh_token'];
|
|
|
|
|
$str = '
|
|
|
|
|
refresh_token :<br>';
|
|
|
|
|
$str .= '
|
|
|
|
|
<textarea readonly style="width: 95%">' . $refresh_token . '</textarea><br><br>
|
|
|
|
|
'.getconstStr('SavingToken').'
|
|
|
|
|
<script>
|
|
|
|
|
var texta=document.getElementsByTagName(\'textarea\');
|
|
|
|
|
for(i=0;i<texta.length;i++) {
|
|
|
|
|
texta[i].style.height = texta[i].scrollHeight + \'px\';
|
2020-04-04 05:50:29 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
document.cookie=\'language=; path=/\';
|
|
|
|
|
document.cookie=\'disktag=; path=/\';
|
|
|
|
|
</script>';
|
|
|
|
|
$tmptoken['refresh_token'] = $refresh_token;
|
|
|
|
|
$tmptoken['token_expires'] = time()+7*24*60*60;
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if (getConfig('usesharepoint')=='on') {
|
|
|
|
|
$tmp1 = get_siteid($ret['access_token']);
|
|
|
|
|
if (isset($tmp1['stat'])) return message($tmp1['body'], 'Error', $tmp1['stat']);
|
|
|
|
|
$tmptoken['siteid'] = $tmp1;
|
|
|
|
|
}
|
2020-08-06 10:41:24 +00:00
|
|
|
|
$response = setConfigResponse( setConfig($tmptoken, $_COOKIE['disktag']) );
|
|
|
|
|
if (api_error($response)) {
|
|
|
|
|
$html = api_error_msg($response);
|
|
|
|
|
$title = 'Error';
|
|
|
|
|
return message($html, $title, 201);
|
|
|
|
|
} else {
|
|
|
|
|
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
|
|
|
|
|
$str .= '
|
|
|
|
|
<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
|
|
|
|
return message($str, getconstStr('WaitJumpIndex'));
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
return message('<pre>' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . '</pre>', $tmp['stat']);
|
|
|
|
|
//return message('<pre>' . json_encode($ret, JSON_PRETTY_PRINT) . '</pre>', 500);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['install1'])) {
|
|
|
|
|
$_SERVER['disktag'] = $_COOKIE['disktag'];
|
|
|
|
|
config_oauth();
|
|
|
|
|
if (getConfig('Drive_ver')=='MS' || getConfig('Drive_ver')=='CN') {
|
|
|
|
|
return message('
|
|
|
|
|
<a href="" id="a1">'.getconstStr('JumptoOffice').'</a>
|
|
|
|
|
<script>
|
|
|
|
|
url=location.protocol + "//" + location.host + "'.$url.'";
|
|
|
|
|
url="'. $_SERVER['oauth_url'] .'authorize?scope='. $_SERVER['scope'] .'&response_type=code&client_id='. $_SERVER['client_id'] .'&redirect_uri='. $_SERVER['redirect_uri'] . '&state=' .'"+encodeURIComponent(url);
|
|
|
|
|
document.getElementById(\'a1\').href=url;
|
|
|
|
|
//window.open(url,"_blank");
|
|
|
|
|
location.href = url;
|
|
|
|
|
</script>
|
|
|
|
|
', getconstStr('Wait').' 1s', 201);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
} else {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
return message('Something error, retry after a few seconds.', 'retry', 201);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['install0'])) {
|
|
|
|
|
if ($_POST['disktag_add']!='') {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
$_SERVER['disktag'] = $_COOKIE['disktag'];
|
|
|
|
|
$tmp['disktag_add'] = $_POST['disktag_add'];
|
|
|
|
|
$tmp['diskname'] = $_POST['diskname'];
|
|
|
|
|
$tmp['Drive_ver'] = $_POST['Drive_ver'];
|
|
|
|
|
if ($_POST['Drive_ver']=='shareurl') {
|
|
|
|
|
$tmp['shareurl'] = $_POST['shareurl'];
|
|
|
|
|
$tmp['refresh_token'] = 1;
|
2020-04-04 05:50:29 +00:00
|
|
|
|
} else {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
if ($_POST['Drive_custom']=='on') {
|
|
|
|
|
$tmp['Drive_custom'] = $_POST['Drive_custom'];
|
|
|
|
|
$tmp['client_id'] = $_POST['client_id'];
|
|
|
|
|
$tmp['client_secret'] = $_POST['client_secret'];
|
2020-05-14 10:25:52 +00:00
|
|
|
|
} else {
|
|
|
|
|
$tmp['Drive_custom'] = '';
|
|
|
|
|
$tmp['client_id'] = '';
|
|
|
|
|
$tmp['client_secret'] = '';
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
if ($_POST['usesharepoint']=='on') {
|
|
|
|
|
$tmp['usesharepoint'] = $_POST['usesharepoint'];
|
|
|
|
|
$tmp['sharepointSiteAddress'] = $_POST['sharepointSiteAddress'];
|
2020-05-14 10:25:52 +00:00
|
|
|
|
} else {
|
|
|
|
|
$tmp['usesharepoint'] = '';
|
|
|
|
|
$tmp['sharepointSiteAddress'] = '';
|
2020-04-04 05:50:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$response = setConfigResponse( setConfig($tmp, $_COOKIE['disktag']) );
|
|
|
|
|
if (api_error($response)) {
|
|
|
|
|
$html = api_error_msg($response);
|
|
|
|
|
$title = 'Error';
|
|
|
|
|
} else {
|
|
|
|
|
$title = getconstStr('MayinEnv');
|
|
|
|
|
$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);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-03 10:17:18 +00:00
|
|
|
|
|
2020-07-23 06:26:37 +00:00
|
|
|
|
//if ($constStr['language']!='zh-cn') {
|
|
|
|
|
// $linklang='en-us';
|
|
|
|
|
//} else $linklang='zh-cn';
|
|
|
|
|
//$ru = "https://developer.microsoft.com/".$linklang."/graph/quick-start?appID=_appId_&appName=_appName_&redirectUrl=".$_SERVER['redirect_uri']."&platform=option-php";
|
|
|
|
|
//$deepLink = "/quickstart/graphIO?publicClientSupport=false&appName=OneManager&redirectUrl=".$_SERVER['redirect_uri']."&allowImplicitFlow=false&ru=".urlencode($ru);
|
|
|
|
|
//$app_url = "https://apps.dev.microsoft.com/?deepLink=".urlencode($deepLink);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html = '
|
|
|
|
|
<div>
|
|
|
|
|
<form action="?AddDisk&install0" method="post" onsubmit="return notnull(this);">
|
|
|
|
|
'.getconstStr('OnedriveDiskTag').': ('.getConfig('disktag').')<input type="text" name="disktag_add" placeholder="' . getconstStr('EnvironmentsDescription')['disktag'] . '" style="width:100%"><br>
|
|
|
|
|
'.getconstStr('OnedriveDiskName').':<input type="text" name="diskname" placeholder="' . getconstStr('EnvironmentsDescription')['diskname'] . '" style="width:100%"><br>
|
|
|
|
|
<br>
|
|
|
|
|
<div>
|
2020-07-23 06:26:37 +00:00
|
|
|
|
<label><input type="radio" name="Drive_ver" value="MS" onclick="document.getElementById(\'morecustom\').style.display=\'\';document.getElementById(\'inputshareurl\').style.display=\'none\';">MS: '.getconstStr('DriveVerMS').'</label><br>
|
2020-05-07 10:45:10 +00:00
|
|
|
|
<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>
|
|
|
|
|
<br>
|
|
|
|
|
<div id="inputshareurl" style="display:none;margin:10px 35px">
|
|
|
|
|
'.getconstStr('UseShareLink').'
|
|
|
|
|
<input type="text" name="shareurl" style="width:100%" placeholder="https://xxxx.sharepoint.com/:f:/g/personal/xxxxxxxx/mmmmmmmmm?e=XXXX"><br>
|
|
|
|
|
</div>
|
2020-07-23 06:26:37 +00:00
|
|
|
|
<div id="morecustom" style="display:none;">
|
2020-05-07 10:45:10 +00:00
|
|
|
|
<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">
|
2020-07-23 06:26:37 +00:00
|
|
|
|
return uri: https://scfonedrive.github.io/<br>
|
|
|
|
|
client_id:<input type="text" name="client_id" placeholder="a1b2c345-90ab-cdef-ghij-klmnopqrstuv"><br>
|
2020-05-07 10:45:10 +00:00
|
|
|
|
client_secret:<input type="text" name="client_secret"><br>
|
|
|
|
|
</div>
|
|
|
|
|
<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">
|
|
|
|
|
'.getconstStr('GetSharepointSiteAddress').'<br>
|
|
|
|
|
<input type="text" name="sharepointSiteAddress" style="width:100%" placeholder="'.getconstStr('InputSharepointSiteAddress').'"><br>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<br>
|
|
|
|
|
<input type="submit" value="'.getconstStr('Submit').'">
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<script>
|
|
|
|
|
function notnull(t)
|
|
|
|
|
{
|
|
|
|
|
if (t.disktag_add.value==\'\') {
|
|
|
|
|
alert(\''.getconstStr('OnedriveDiskTag').'\');
|
|
|
|
|
return false;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
envs = [' . $envs . '];
|
|
|
|
|
if (envs.indexOf(t.disktag_add.value)>-1) {
|
|
|
|
|
alert("Do not input ' . $envs . '");
|
|
|
|
|
return false;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
var reg = /^[a-zA-Z]([-_a-zA-Z0-9]{1,20})$/;
|
|
|
|
|
if (!reg.test(t.disktag_add.value)) {
|
|
|
|
|
alert(\''.getconstStr('TagFormatAlert').'\');
|
|
|
|
|
return false;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
if (t.Drive_ver.value==\'shareurl\') {
|
|
|
|
|
if (t.shareurl.value==\'\') {
|
|
|
|
|
alert(\'shareurl\');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (t.Drive_custom.checked==true) {
|
|
|
|
|
if (t.client_secret.value==\'\'||t.client_id.value==\'\') {
|
|
|
|
|
alert(\'client_id & client_secret\');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (t.usesharepoint.checked==true) {
|
|
|
|
|
if (t.sharepointSiteAddress.value==\'\') {
|
|
|
|
|
alert(\''.getconstStr('InputSharepointSiteAddress').'\');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-07-13 09:33:47 +00:00
|
|
|
|
var expd = new Date();
|
|
|
|
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
|
|
|
|
var expires = "expires="+expd.toGMTString();
|
|
|
|
|
document.cookie=\'disktag=\'+t.disktag_add.value+\'; path=/; \'+expires;
|
2020-05-07 10:45:10 +00:00
|
|
|
|
return true;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
</script>';
|
|
|
|
|
$title = 'Bind Disk';
|
|
|
|
|
return message($html, $title, 201);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function EnvOpt($needUpdate = 0)
|
|
|
|
|
{
|
|
|
|
|
global $constStr;
|
|
|
|
|
global $ShowedCommonEnv;
|
|
|
|
|
global $ShowedInnerEnv;
|
|
|
|
|
global $timezones;
|
|
|
|
|
asort($ShowedCommonEnv);
|
|
|
|
|
asort($ShowedInnerEnv);
|
|
|
|
|
$html = '<title>OneManager '.getconstStr('Setup').'</title>';
|
|
|
|
|
if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) {
|
2020-08-04 06:38:20 +00:00
|
|
|
|
$response = setConfigResponse(OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch']));
|
2020-05-07 10:45:10 +00:00
|
|
|
|
if (api_error($response)) {
|
|
|
|
|
$html = api_error_msg($response);
|
|
|
|
|
$title = 'Error';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
} else {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
//WaitSCFStat();
|
|
|
|
|
$html .= getconstStr('UpdateSuccess') . '<br>
|
|
|
|
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
|
|
|
|
$title = getconstStr('Setup');
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
return message($html, $title);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_POST['submit1'])) {
|
|
|
|
|
$_SERVER['disk_oprating'] = '';
|
|
|
|
|
foreach ($_POST as $k => $v) {
|
|
|
|
|
if (in_array($k, $ShowedCommonEnv)||in_array($k, $ShowedInnerEnv)||$k=='disktag_del' || $k=='disktag_add') {
|
|
|
|
|
$tmp[$k] = $v;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
if ($k == 'disk') $_SERVER['disk_oprating'] = $v;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
/*if ($tmp['domain_path']!='') {
|
|
|
|
|
$tmp1 = explode("|",$tmp['domain_path']);
|
|
|
|
|
$tmparr = [];
|
|
|
|
|
foreach ($tmp1 as $multidomain_paths){
|
|
|
|
|
$pos = strpos($multidomain_paths,":");
|
|
|
|
|
if ($pos>0) $tmparr[substr($multidomain_paths, 0, $pos)] = path_format(substr($multidomain_paths, $pos+1));
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp['domain_path'] = $tmparr;
|
|
|
|
|
}*/
|
|
|
|
|
$response = setConfigResponse( setConfig($tmp, $_SERVER['disk_oprating']) );
|
|
|
|
|
if (api_error($response)) {
|
2020-06-07 10:43:47 +00:00
|
|
|
|
$html = api_error_msg($response);
|
|
|
|
|
$title = 'Error';
|
|
|
|
|
} else {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
//WaitSCFStat();
|
|
|
|
|
$html .= getconstStr('Success') . '!<br>
|
|
|
|
|
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
|
|
|
|
|
$title = getconstStr('Setup');
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
return message($html, $title);
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['preview'])) {
|
|
|
|
|
$preurl = $_SERVER['PHP_SELF'] . '?preview';
|
|
|
|
|
} else {
|
|
|
|
|
$preurl = path_format($_SERVER['PHP_SELF'] . '/');
|
|
|
|
|
}
|
|
|
|
|
$html .= '
|
|
|
|
|
<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>';
|
|
|
|
|
|
|
|
|
|
$html .= '
|
|
|
|
|
<table border=1 width=100%>
|
|
|
|
|
<form name="common" action="" method="post">
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="2">'.getconstStr('PlatformConfig').'</td>
|
|
|
|
|
</tr>';
|
|
|
|
|
foreach ($ShowedCommonEnv as $key) {
|
|
|
|
|
if ($key=='timezone') {
|
|
|
|
|
$html .= '
|
|
|
|
|
<tr>
|
|
|
|
|
<td><label>' . $key . '</label></td>
|
|
|
|
|
<td width=100%>
|
|
|
|
|
<select name="' . $key .'">';
|
|
|
|
|
foreach (array_keys($timezones) as $zone) {
|
|
|
|
|
$html .= '
|
|
|
|
|
<option value="'.$zone.'" '.($zone==getConfig($key)?'selected="selected"':'').'>'.$zone.'</option>';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= '
|
|
|
|
|
</select>
|
2020-05-24 07:42:19 +00:00
|
|
|
|
'.getconstStr('EnvironmentsDescription')[$key].'
|
2020-05-07 10:45:10 +00:00
|
|
|
|
</td>
|
|
|
|
|
</tr>';
|
|
|
|
|
} elseif ($key=='theme') {
|
2020-09-13 05:21:02 +00:00
|
|
|
|
$slash = '/';
|
|
|
|
|
if (strpos(__DIR__, ':')) $slash = '\\';
|
|
|
|
|
$theme_arr = scandir(__DIR__ . $slash . 'theme');
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= '
|
|
|
|
|
<tr>
|
|
|
|
|
<td><label>' . $key . '</label></td>
|
|
|
|
|
<td width=100%>
|
|
|
|
|
<select name="' . $key .'">
|
|
|
|
|
<option value=""></option>';
|
|
|
|
|
foreach ($theme_arr as $v1) {
|
|
|
|
|
if ($v1!='.' && $v1!='..') $html .= '
|
|
|
|
|
<option value="'.$v1.'" '.($v1==getConfig($key)?'selected="selected"':'').'>'.$v1.'</option>';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= '
|
|
|
|
|
</select>
|
2020-05-24 07:42:19 +00:00
|
|
|
|
'.getconstStr('EnvironmentsDescription')[$key].'
|
2020-05-07 10:45:10 +00:00
|
|
|
|
</td>
|
|
|
|
|
</tr>';
|
|
|
|
|
} /*elseif ($key=='domain_path') {
|
|
|
|
|
$tmp = getConfig($key);
|
|
|
|
|
$domain_path = '';
|
|
|
|
|
foreach ($tmp as $k1 => $v1) {
|
|
|
|
|
$domain_path .= $k1 . ':' . $v1 . '|';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$domain_path = substr($domain_path, 0, -1);
|
|
|
|
|
$html .= '
|
|
|
|
|
<tr>
|
|
|
|
|
<td><label>' . $key . '</label></td>
|
|
|
|
|
<td width=100%><input type="text" name="' . $key .'" value="' . $domain_path . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
|
|
|
|
</tr>';
|
|
|
|
|
}*/ else $html .= '
|
|
|
|
|
<tr>
|
|
|
|
|
<td><label>' . $key . '</label></td>
|
|
|
|
|
<td width=100%><input type="text" name="' . $key .'" value="' . htmlspecialchars(getConfig($key)) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
|
|
|
|
</tr>';
|
|
|
|
|
}
|
|
|
|
|
$html .= '
|
|
|
|
|
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
|
|
|
|
|
</form>
|
|
|
|
|
</table><br>';
|
|
|
|
|
foreach (explode("|",getConfig('disktag')) as $disktag) {
|
|
|
|
|
if ($disktag!='') {
|
|
|
|
|
$html .= '
|
|
|
|
|
<table border=1 width=100%>
|
|
|
|
|
<form action="" method="post">
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="2">'.$disktag.':
|
2020-07-13 09:33:47 +00:00
|
|
|
|
<input type="hidden" name="disktag_del" value="'.$disktag.'">
|
|
|
|
|
<input type="submit" name="submit1" value="'.getconstStr('DelDisk').'">
|
2020-05-07 10:45:10 +00:00
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</form>';
|
|
|
|
|
if (getConfig('refresh_token', $disktag)!='') {
|
|
|
|
|
$html .= '
|
|
|
|
|
<form name="'.$disktag.'" action="" method="post">
|
|
|
|
|
<input type="hidden" name="disk" value="'.$disktag.'">';
|
|
|
|
|
foreach ($ShowedInnerEnv as $key) {
|
|
|
|
|
$html .= '
|
|
|
|
|
<tr>
|
|
|
|
|
<td><label>' . $key . '</label></td>
|
|
|
|
|
<td width=100%><input type="text" name="' . $key .'" value="' . getConfig($key, $disktag) . '" placeholder="' . getconstStr('EnvironmentsDescription')[$key] . '" style="width:100%"></td>
|
|
|
|
|
</tr>';
|
|
|
|
|
}
|
|
|
|
|
$html .= '
|
|
|
|
|
<tr><td><input type="submit" name="submit1" value="'.getconstStr('Setup').'"></td></tr>
|
|
|
|
|
</form>';
|
2020-07-13 09:33:47 +00:00
|
|
|
|
} else {
|
|
|
|
|
$html .= '
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="2">Please add this disk again.</td>
|
|
|
|
|
</tr>';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= '
|
|
|
|
|
</table><br>';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
$html .= '
|
|
|
|
|
<a href="?AddDisk">'.getconstStr('AddDisk').'</a><br><br>';
|
2020-06-07 10:43:47 +00:00
|
|
|
|
|
|
|
|
|
$canOneKeyUpate = 0;
|
|
|
|
|
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
|
|
|
|
$canOneKeyUpate = 1;
|
|
|
|
|
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
|
|
|
|
$canOneKeyUpate = 1;
|
|
|
|
|
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
|
|
|
|
$canOneKeyUpate = 1;
|
2020-08-16 03:37:28 +00:00
|
|
|
|
} elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
|
|
|
|
|
$canOneKeyUpate = 1;
|
2020-07-13 09:33:47 +00:00
|
|
|
|
} elseif ($_SERVER['_APP_SHARE_DIR']==='/var/share/CFF/processrouter') {
|
|
|
|
|
$canOneKeyUpate = 1;
|
2020-06-07 10:43:47 +00:00
|
|
|
|
} else {
|
|
|
|
|
$tmp = time();
|
|
|
|
|
if ( mkdir(''.$tmp, 0777) ) {
|
|
|
|
|
rmdir(''.$tmp);
|
|
|
|
|
$canOneKeyUpate = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!$canOneKeyUpate) {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= '
|
2020-06-07 10:43:47 +00:00
|
|
|
|
'.getconstStr('CannotOneKeyUpate').'<br>';
|
2020-05-07 10:45:10 +00:00
|
|
|
|
} else {
|
|
|
|
|
$html .= '
|
|
|
|
|
<form name="updateform" action="" method="post">
|
2020-06-07 10:43:47 +00:00
|
|
|
|
<input type="text" name="auth" size="6" placeholder="auth" value="qkqpttgf">
|
|
|
|
|
<input type="text" name="project" size="12" placeholder="project" value="OneManager-php">
|
|
|
|
|
<button name="QueryBranchs" onclick="querybranchs();return false">'.getconstStr('QueryBranchs').'</button>
|
2020-05-07 10:45:10 +00:00
|
|
|
|
<select name="branch">
|
|
|
|
|
<option value="master">master</option>
|
|
|
|
|
</select>
|
|
|
|
|
<input type="submit" name="updateProgram" value="'.getconstStr('updateProgram').'">
|
|
|
|
|
</form>
|
|
|
|
|
<script>
|
|
|
|
|
function querybranchs()
|
|
|
|
|
{
|
|
|
|
|
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) {
|
|
|
|
|
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;
|
|
|
|
|
});
|
2020-06-07 10:43:47 +00:00
|
|
|
|
document.updateform.QueryBranchs.style.display="none";
|
2020-05-07 10:45:10 +00:00
|
|
|
|
} else {
|
|
|
|
|
alert(xhr.responseText+"\n"+xhr.status);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
xhr.onerror = function(e){
|
|
|
|
|
alert("Network Error "+xhr.status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
';
|
|
|
|
|
}
|
|
|
|
|
if ($needUpdate) {
|
2020-08-28 06:16:16 +00:00
|
|
|
|
$html .= '<div style="position: relative; word-wrap: break-word;">
|
|
|
|
|
' . str_replace("\r", '<br>', $_SERVER['github_ver_new']) . '
|
|
|
|
|
</div>
|
|
|
|
|
<button onclick="document.getElementById(\'github_ver_old\').style.display=(document.getElementById(\'github_ver_old\').style.display==\'none\'?\'\':\'none\');">More...</button>
|
|
|
|
|
<div id="github_ver_old" style="position: relative; word-wrap: break-word; display: none">
|
|
|
|
|
' . str_replace("\r", '<br>', $_SERVER['github_ver_old']) . '
|
2020-05-07 10:45:10 +00:00
|
|
|
|
</div>';
|
2020-06-07 10:43:47 +00:00
|
|
|
|
}/* else {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= getconstStr('NotNeedUpdate');
|
2020-06-07 10:43:47 +00:00
|
|
|
|
}*/
|
2020-05-07 10:45:10 +00:00
|
|
|
|
return message($html, getconstStr('Setup'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function render_list($path = '', $files = '')
|
|
|
|
|
{
|
|
|
|
|
global $exts;
|
|
|
|
|
global $constStr;
|
|
|
|
|
|
2020-09-13 05:21:02 +00:00
|
|
|
|
$slash = '/';
|
|
|
|
|
if (strpos(__DIR__, ':')) $slash = '\\';
|
|
|
|
|
|
2020-05-07 10:45:10 +00:00
|
|
|
|
if (isset($files['children']['index.html']) && !$_SERVER['admin']) {
|
|
|
|
|
$htmlcontent = fetch_files(spurlencode(path_format(urldecode($path) . '/index.html'),'/'))['content'];
|
|
|
|
|
return output($htmlcontent['body'], $htmlcontent['stat']);
|
|
|
|
|
}
|
|
|
|
|
$path = str_replace('%20','%2520',$path);
|
|
|
|
|
$path = str_replace('+','%2B',$path);
|
|
|
|
|
$path = str_replace('&','&',path_format(urldecode($path))) ;
|
|
|
|
|
$path = str_replace('%20',' ',$path);
|
|
|
|
|
$path = str_replace('#','%23',$path);
|
|
|
|
|
$p_path='';
|
|
|
|
|
if ($path !== '/') {
|
|
|
|
|
if (isset($files['file'])) {
|
|
|
|
|
$pretitle = str_replace('&','&', $files['name']);
|
|
|
|
|
$n_path = $pretitle;
|
|
|
|
|
$tmp = splitlast(splitlast($path,'/')[0],'/');
|
|
|
|
|
if ($tmp[1]=='') {
|
|
|
|
|
$p_path = $tmp[0];
|
|
|
|
|
} else {
|
|
|
|
|
$p_path = $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (substr($path, 0, 1)=='/') $pretitle = substr($path, 1);
|
|
|
|
|
if (substr($path, -1)=='/') $pretitle = substr($pretitle, 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];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$pretitle = getconstStr('Home');
|
|
|
|
|
$n_path=$pretitle;
|
|
|
|
|
}
|
|
|
|
|
$n_path=str_replace('&','&',$n_path);
|
|
|
|
|
$p_path=str_replace('&','&',$p_path);
|
|
|
|
|
$pretitle = str_replace('%23','#',$pretitle);
|
|
|
|
|
$statusCode=200;
|
|
|
|
|
date_default_timezone_set(get_timezone($_SERVER['timezone']));
|
|
|
|
|
$authinfo = '<!--
|
|
|
|
|
OneManager: An index & manager of Onedrive auth by ysun.
|
2020-05-14 10:05:43 +00:00
|
|
|
|
Github: https://github.com/qkqpttgf/OneManager-php
|
2020-05-07 10:45:10 +00:00
|
|
|
|
-->';
|
2020-06-07 10:43:47 +00:00
|
|
|
|
//$authinfo = $path . '<br><pre>' . json_encode($files, JSON_PRETTY_PRINT) . '</pre>';
|
2020-05-07 10:45:10 +00:00
|
|
|
|
|
2020-05-24 07:07:56 +00:00
|
|
|
|
if (isset($_COOKIE['theme'])&&$_COOKIE['theme']!='') $theme = $_COOKIE['theme'];
|
2020-09-13 05:21:02 +00:00
|
|
|
|
if ( !file_exists(__DIR__ . $slash .'theme' . $slash . $theme) ) $theme = '';
|
2020-05-24 07:07:56 +00:00
|
|
|
|
if ( $theme=='' ) {
|
|
|
|
|
$tmp = getConfig('customTheme');
|
|
|
|
|
if ( $tmp!='' ) $theme = $tmp;
|
|
|
|
|
}
|
|
|
|
|
if ( $theme=='' ) {
|
|
|
|
|
$theme = getConfig('theme');
|
2020-09-13 05:21:02 +00:00
|
|
|
|
if ( $theme=='' || !file_exists(__DIR__ . $slash .'theme' . $slash . $theme) ) $theme = 'classic.html';
|
2020-05-24 07:07:56 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
if (substr($theme,-4)=='.php') {
|
|
|
|
|
@ob_start();
|
|
|
|
|
include 'theme/'.$theme;
|
|
|
|
|
$html = ob_get_clean();
|
|
|
|
|
} else {
|
2020-09-13 05:21:02 +00:00
|
|
|
|
if (file_exists(__DIR__ . $slash .'theme' . $slash . $theme)) {
|
|
|
|
|
$file_path = __DIR__ . $slash .'theme' . $slash . $theme;
|
2020-05-24 07:07:56 +00:00
|
|
|
|
$html = file_get_contents($file_path);
|
|
|
|
|
} else {
|
|
|
|
|
if (!($html = getcache('customTheme'))) {
|
|
|
|
|
$file_path = $theme;
|
|
|
|
|
$tmp = curl_request($file_path, false, [], 1);
|
|
|
|
|
if ($tmp['stat']==302) {
|
|
|
|
|
error_log(json_encode($tmp));
|
|
|
|
|
$tmp = curl_request($tmp["returnhead"]["Location"]);
|
|
|
|
|
}
|
|
|
|
|
if (!!$tmp['body']) $html = $tmp['body'];
|
|
|
|
|
savecache('customTheme', $html, 9999);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--IconValuesStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IconValuesEnd-->');
|
|
|
|
|
$IconValues = json_decode($tmp[0], true);
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
if (!$files) {
|
|
|
|
|
//$html = '<pre>'.json_encode($files, JSON_PRETTY_PRINT).'</pre>' . $html;
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFileStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFileEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFolderStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFolderEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--ListStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--ListEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
while (strpos($html, '<!--GuestUploadStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--GuestUploadStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--GuestUploadEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
while (strpos($html, '<!--EncryptedStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptedStart-->');
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html = $tmp[0];
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptedEnd-->');
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html .= $tmp[1];
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($_SERVER['admin']) {
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--LoginStart-->');
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html = $tmp[0];
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--LoginEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-05-10 07:17:52 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--GuestStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--GuestEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
while (strpos($html, '<!--AdminStart-->')) {
|
|
|
|
|
$html = str_replace('<!--AdminStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--AdminEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--constStr@Operate-->')) $html = str_replace('<!--constStr@Operate-->', getconstStr('Operate'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Create-->')) $html = str_replace('<!--constStr@Create-->', getconstStr('Create'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Encrypt-->')) $html = str_replace('<!--constStr@Encrypt-->', getconstStr('Encrypt'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@RefreshCache-->')) $html = str_replace('<!--constStr@RefreshCache-->', getconstStr('RefreshCache'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Setup-->')) $html = str_replace('<!--constStr@Setup-->', getconstStr('Setup'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Logout-->')) $html = str_replace('<!--constStr@Logout-->', getconstStr('Logout'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Rename-->')) $html = str_replace('<!--constStr@Rename-->', getconstStr('Rename'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Submit-->')) $html = str_replace('<!--constStr@Submit-->', getconstStr('Submit'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Delete-->')) $html = str_replace('<!--constStr@Delete-->', getconstStr('Delete'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Copy-->')) $html = str_replace('<!--constStr@Copy-->', getconstStr('Copy'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Move-->')) $html = str_replace('<!--constStr@Move-->', getconstStr('Move'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Folder-->')) $html = str_replace('<!--constStr@Folder-->', getconstStr('Folder'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@File-->')) $html = str_replace('<!--constStr@File-->', getconstStr('File'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Name-->')) $html = str_replace('<!--constStr@Name-->', getconstStr('Name'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Content-->')) $html = str_replace('<!--constStr@Content-->', getconstStr('Content'), $html);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--AdminStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--AdminEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
if (getConfig('adminloginpage')=='') {
|
|
|
|
|
while (strpos($html, '<!--LoginStart-->')) $html = str_replace('<!--LoginStart-->', '', $html);
|
|
|
|
|
while (strpos($html, '<!--LoginEnd-->')) $html = str_replace('<!--LoginEnd-->', '', $html);
|
|
|
|
|
} else {
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--LoginStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--LoginEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-10 07:17:52 +00:00
|
|
|
|
while (strpos($html, '<!--GuestStart-->')) $html = str_replace('<!--GuestStart-->', '', $html);
|
|
|
|
|
while (strpos($html, '<!--GuestEnd-->')) $html = str_replace('<!--GuestEnd-->', '', $html);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-13 09:44:24 +00:00
|
|
|
|
if ($_SERVER['ishidden']==4) {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFileStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFileEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFolderStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFolderEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
/*$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--ListStart-->');
|
2020-05-08 08:18:28 +00:00
|
|
|
|
$html = $tmp[0];
|
2020-06-13 09:44:24 +00:00
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--ListEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}*/
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsNotHiddenStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsNotHiddenEnd-->');
|
2020-05-08 08:18:28 +00:00
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
while (strpos($html, '<!--EncryptedStart-->')) {
|
|
|
|
|
$html = str_replace('<!--EncryptedStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--EncryptedEnd-->', '', $html);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
2020-06-13 09:44:24 +00:00
|
|
|
|
$tmp = splitfirst($html, '<!--GuestUploadStart-->');
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html = $tmp[0];
|
2020-06-13 09:44:24 +00:00
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--GuestUploadEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--IsNotHiddenStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsNotHiddenStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsNotHiddenEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
while (strpos($html, '<!--EncryptedStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptedStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptedEnd-->');
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
while (strpos($html, '<!--IsNotHiddenStart-->')) {
|
|
|
|
|
$html = str_replace('<!--IsNotHiddenStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--IsNotHiddenEnd-->', '', $html);
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
while (strpos($html, '<!--constStr@Download-->')) $html = str_replace('<!--constStr@Download-->', getconstStr('Download'), $html);
|
|
|
|
|
|
|
|
|
|
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFileStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFileEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFolderStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFolderEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
while (strpos($html, '<!--GuestUploadStart-->')) {
|
|
|
|
|
$html = str_replace('<!--GuestUploadStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--GuestUploadEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--IsNotHiddenStart-->')) {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$tmp = splitfirst($html, '<!--IsNotHiddenStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsNotHiddenEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
while (strpos($html, '<!--GuestUploadStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--GuestUploadStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--GuestUploadEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--IsNotHiddenStart-->')) {
|
|
|
|
|
$html = str_replace('<!--IsNotHiddenStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--IsNotHiddenEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($_SERVER['is_guestup_path']||( $_SERVER['admin']&&isset($files['folder'])&&$_SERVER['ishidden']<4 )) {
|
|
|
|
|
while (strpos($html, '<!--UploadJsStart-->')) {
|
|
|
|
|
while (strpos($html, '<!--UploadJsStart-->')) $html = str_replace('<!--UploadJsStart-->', '', $html);
|
|
|
|
|
while (strpos($html, '<!--UploadJsEnd-->')) $html = str_replace('<!--UploadJsEnd-->', '', $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Calculate-->')) $html = str_replace('<!--constStr@Calculate-->', getconstStr('Calculate'), $html);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
2020-06-13 09:44:24 +00:00
|
|
|
|
} else {
|
2020-05-12 06:13:46 +00:00
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
2020-06-13 09:44:24 +00:00
|
|
|
|
$tmp = splitfirst($html, '<!--UploadJsStart-->');
|
2020-05-12 06:13:46 +00:00
|
|
|
|
$html = $tmp[0];
|
2020-06-13 09:44:24 +00:00
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--UploadJsEnd-->');
|
2020-05-12 06:13:46 +00:00
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
2020-05-26 01:49:13 +00:00
|
|
|
|
|
2020-07-13 09:33:47 +00:00
|
|
|
|
if (isset($files['file'])) {
|
|
|
|
|
while (strpos($html, '<!--GuestUploadStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--GuestUploadStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--GuestUploadEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptedStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptedEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFolderStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFolderEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--IsFileStart-->')) {
|
|
|
|
|
$html = str_replace('<!--IsFileStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--IsFileEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
$html = str_replace('<!--FileEncodeUrl-->', str_replace('%2523', '%23', str_replace('%26amp%3B','&',spurlencode(path_format($_SERVER['base_disk_path'] . '/' . $path), '/'))), $html);
|
|
|
|
|
$html = str_replace('<!--FileUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path), $html);
|
|
|
|
|
|
|
|
|
|
$ext = strtolower(substr($path, strrpos($path, '.') + 1));
|
|
|
|
|
if (in_array($ext, $exts['img'])) $ext = 'img';
|
|
|
|
|
elseif (in_array($ext, $exts['video'])) $ext = 'video';
|
|
|
|
|
elseif (in_array($ext, $exts['music'])) $ext = 'music';
|
|
|
|
|
//elseif (in_array($ext, $exts['pdf'])) $ext = 'pdf';
|
|
|
|
|
elseif ($ext=='pdf') $ext = 'pdf';
|
|
|
|
|
elseif (in_array($ext, $exts['office'])) $ext = 'office';
|
|
|
|
|
elseif (in_array($ext, $exts['txt'])) $ext = 'txt';
|
|
|
|
|
else $ext = 'Other';
|
|
|
|
|
$previewext = ['img', 'video', 'music', 'pdf', 'office', 'txt', 'Other'];
|
|
|
|
|
$previewext = array_diff($previewext, [ $ext ]);
|
|
|
|
|
foreach ($previewext as $ext1) {
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--Is'.$ext1.'FileStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--Is'.$ext1.'FileEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--Is'.$ext.'FileStart-->')) {
|
|
|
|
|
$html = str_replace('<!--Is'.$ext.'FileStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--Is'.$ext.'FileEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
//while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', $files[$_SERVER['DownurlStrName']], $html);
|
|
|
|
|
while (strpos($html, '<!--FileDownUrl-->')) $html = str_replace('<!--FileDownUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path), $html);
|
|
|
|
|
while (strpos($html, '<!--FileEncodeReplaceUrl-->')) $html = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path), $html);
|
|
|
|
|
while (strpos($html, '<!--FileName-->')) $html = str_replace('<!--FileName-->', $files['name'], $html);
|
|
|
|
|
$html = str_replace('<!--FileEncodeDownUrl-->', urlencode($files[$_SERVER['DownurlStrName']]), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@ClicktoEdit-->', getconstStr('ClicktoEdit'), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@CancelEdit-->', getconstStr('CancelEdit'), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@Save-->', getconstStr('Save'), $html);
|
|
|
|
|
while (strpos($html, '<!--TxtContent-->')) $html = str_replace('<!--TxtContent-->', htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@FileNotSupport-->', getconstStr('FileNotSupport'), $html);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//$html = str_replace('<!--constStr@File-->', getconstStr('File'), $html);
|
|
|
|
|
} elseif (isset($files['children'])) {
|
2020-05-07 10:45:10 +00:00
|
|
|
|
while (strpos($html, '<!--GuestUploadStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--GuestUploadStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--GuestUploadEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptedStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptedEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--IsFileStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--IsFileEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
while (strpos($html, '<!--IsFolderStart-->')) {
|
|
|
|
|
$html = str_replace('<!--IsFolderStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--IsFolderEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
$html = str_replace('<!--constStr@File-->', getconstStr('File'), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@ShowThumbnails-->', getconstStr('ShowThumbnails'), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@CopyAllDownloadUrl-->', getconstStr('CopyAllDownloadUrl'), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@EditTime-->', getconstStr('EditTime'), $html);
|
|
|
|
|
$html = str_replace('<!--constStr@Size-->', getconstStr('Size'), $html);
|
|
|
|
|
|
|
|
|
|
$filenum = 0;
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--FolderListStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--FolderListEnd-->');
|
|
|
|
|
$FolderList = $tmp[0];
|
|
|
|
|
foreach ($files['children'] as $file) {
|
|
|
|
|
if (isset($file['folder'])) {
|
|
|
|
|
if ($_SERVER['admin'] or !isHideFile($file['name'])) {
|
|
|
|
|
$filenum++;
|
|
|
|
|
$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList);
|
2020-08-23 05:00:16 +00:00
|
|
|
|
$FolderListStr = str_replace('<!--FileEncodeReplaceName-->', str_replace('&','&', $file['showname']?$file['showname']:$file['name']), $FolderListStr);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$FolderListStr = str_replace('<!--lastModifiedDateTime-->', time_format($file['lastModifiedDateTime']), $FolderListStr);
|
|
|
|
|
$FolderListStr = str_replace('<!--size-->', size_format($file['size']), $FolderListStr);
|
|
|
|
|
while (strpos($FolderListStr, '<!--filenum-->')) $FolderListStr = str_replace('<!--filenum-->', $filenum, $FolderListStr);
|
|
|
|
|
$html .= $FolderListStr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--FileListStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--FileListEnd-->');
|
|
|
|
|
$FolderList = $tmp[0];
|
|
|
|
|
foreach ($files['children'] as $file) {
|
|
|
|
|
if (isset($file['file'])) {
|
|
|
|
|
if ($_SERVER['admin'] or !isHideFile($file['name'])) {
|
|
|
|
|
$filenum++;
|
|
|
|
|
$ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1));
|
|
|
|
|
$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList);
|
2020-05-26 01:49:13 +00:00
|
|
|
|
$FolderListStr = str_replace('<!--FileExt-->', $ext, $FolderListStr);
|
|
|
|
|
if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('<!--FileExtType-->', 'audio', $FolderListStr);
|
|
|
|
|
elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('<!--FileExtType-->', 'iframe', $FolderListStr);
|
|
|
|
|
else $FolderListStr = str_replace('<!--FileExtType-->', '', $FolderListStr);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
$FolderListStr = str_replace('<!--FileEncodeReplaceName-->', str_replace('&','&', $file['name']), $FolderListStr);
|
|
|
|
|
//$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&', $file['name'])), $FolderListStr);
|
|
|
|
|
$FolderListStr = str_replace('<!--lastModifiedDateTime-->', time_format($file['lastModifiedDateTime']), $FolderListStr);
|
|
|
|
|
$FolderListStr = str_replace('<!--size-->', size_format($file['size']), $FolderListStr);
|
2020-05-24 07:07:56 +00:00
|
|
|
|
if (!!$IconValues) {
|
|
|
|
|
foreach ($IconValues as $key1 => $value1) {
|
|
|
|
|
if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) {
|
|
|
|
|
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr);
|
|
|
|
|
}
|
|
|
|
|
if ($ext==$key1) {
|
|
|
|
|
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr);
|
|
|
|
|
}
|
|
|
|
|
//error_log('file:'.$file['name'].':'.$key1);
|
|
|
|
|
if (!strpos($FolderListStr, '<!--IconValue-->')) break;
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
2020-05-24 07:07:56 +00:00
|
|
|
|
if (strpos($FolderListStr, '<!--IconValue-->')) $FolderListStr = str_replace('<!--IconValue-->', $IconValues['default'], $FolderListStr);
|
2020-05-07 10:45:10 +00:00
|
|
|
|
}
|
|
|
|
|
while (strpos($FolderListStr, '<!--filenum-->')) $FolderListStr = str_replace('<!--filenum-->', $filenum, $FolderListStr);
|
|
|
|
|
$html .= $FolderListStr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
while (strpos($html, '<!--maxfilenum-->')) $html = str_replace('<!--maxfilenum-->', $filenum, $html);
|
|
|
|
|
|
|
|
|
|
if ($files['folder']['childCount']>200) {
|
|
|
|
|
while (strpos($html, '<!--MorePageStart-->')) $html = str_replace('<!--MorePageStart-->', '', $html);
|
|
|
|
|
while (strpos($html, '<!--MorePageEnd-->')) $html = str_replace('<!--MorePageEnd-->', '', $html);
|
|
|
|
|
|
|
|
|
|
$pagenum = $files['folder']['page'];
|
|
|
|
|
if ($pagenum=='') $pagenum = 1;
|
|
|
|
|
$maxpage = ceil($files['folder']['childCount']/200);
|
|
|
|
|
|
|
|
|
|
if ($pagenum!=1) {
|
|
|
|
|
$html = str_replace('<!--PrePageStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--PrePageEnd-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--constStr@PrePage-->', getconstStr('PrePage'), $html);
|
|
|
|
|
$html = str_replace('<!--PrePageNum-->', $pagenum-1, $html);
|
|
|
|
|
} else {
|
|
|
|
|
$tmp = splitfirst($html, '<!--PrePageStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--PrePageEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
//$html .= json_encode($files['folder']);
|
|
|
|
|
if ($pagenum!=$maxpage) {
|
|
|
|
|
$html = str_replace('<!--NextPageStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--NextPageEnd-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--constStr@NextPage-->', getconstStr('NextPage'), $html);
|
|
|
|
|
$html = str_replace('<!--NextPageNum-->', $pagenum+1, $html);
|
|
|
|
|
} else {
|
|
|
|
|
$tmp = splitfirst($html, '<!--NextPageStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--NextPageEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$tmp = splitfirst($html, '<!--MorePageListNowStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MorePageListNowEnd-->');
|
|
|
|
|
$MorePageListNow = str_replace('<!--PageNum-->', $pagenum, $tmp[0]);
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--MorePageListStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MorePageListEnd-->');
|
|
|
|
|
$MorePageList = $tmp[0];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
for ($page=1;$page<=$maxpage;$page++) {
|
|
|
|
|
if ($page == $pagenum) {
|
|
|
|
|
$MorePageListStr = $MorePageListNow;
|
|
|
|
|
} else {
|
|
|
|
|
$MorePageListStr = str_replace('<!--PageNum-->', $page, $MorePageList);
|
|
|
|
|
$MorePageListStr = str_replace('<!--PageNum-->', $page, $MorePageListStr);
|
|
|
|
|
}
|
|
|
|
|
$html .= $MorePageListStr;
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
2020-05-24 10:15:31 +00:00
|
|
|
|
while (strpos($html, '<!--MaxPageNum-->')) $html = str_replace('<!--MaxPageNum-->', $maxpage, $html);
|
|
|
|
|
|
2020-05-03 10:17:18 +00:00
|
|
|
|
} else {
|
|
|
|
|
while (strpos($html, '<!--MorePageStart-->')) {
|
|
|
|
|
$tmp = splitfirst($html, '<!--MorePageStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MorePageEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$html = str_replace('<!--constStr@language-->', $constStr['language'], $html);
|
|
|
|
|
|
|
|
|
|
$title = $pretitle;
|
|
|
|
|
if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) {
|
|
|
|
|
if (getConfig('diskname')!='') $diskname = getConfig('diskname');
|
|
|
|
|
else $diskname = $_SERVER['disktag'];
|
|
|
|
|
$title .= ' - ' . $diskname;
|
|
|
|
|
}
|
|
|
|
|
$title .= ' - ' . $_SERVER['sitename'];
|
|
|
|
|
$html = str_replace('<!--Title-->', $title, $html);
|
|
|
|
|
|
|
|
|
|
$keywords = $n_path;
|
2020-05-15 12:22:35 +00:00
|
|
|
|
if ($p_path!='') $keywords .= ', ' . $p_path;
|
|
|
|
|
if ($_SERVER['sitename']!='OneManager') $keywords .= ', ' . $_SERVER['sitename'] . ', OneManager';
|
|
|
|
|
else $keywords .= ', OneManager';
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html = str_replace('<!--Keywords-->', $keywords, $html);
|
|
|
|
|
|
2020-05-15 12:22:35 +00:00
|
|
|
|
if ($_GET['preview']) {
|
|
|
|
|
$description = $n_path.', '.getconstStr('Preview');//'Preview of '.
|
|
|
|
|
} elseif (isset($files['folder'])) {
|
|
|
|
|
$description = $n_path.', '.getconstStr('List');//'List of '.$n_path.'. ';
|
|
|
|
|
}
|
|
|
|
|
//$description .= 'In '.$_SERVER['sitename'];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html = str_replace('<!--Description-->', $description, $html);
|
|
|
|
|
|
2020-05-30 07:05:23 +00:00
|
|
|
|
while (strpos($html, '<!--base_disk_path-->')) $html = str_replace('<!--base_disk_path-->', (substr($_SERVER['base_disk_path'],-1)=='/'?substr($_SERVER['base_disk_path'],0,-1):$_SERVER['base_disk_path']), $html);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
while (strpos($html, '<!--base_path-->')) $html = str_replace('<!--base_path-->', $_SERVER['base_path'], $html);
|
2020-06-07 10:43:47 +00:00
|
|
|
|
while (strpos($html, '<!--Path-->')) $html = str_replace('<!--Path-->', str_replace('%23', '#', str_replace('&','&', path_format($path.'/'))), $html);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
while (strpos($html, '<!--constStr@Home-->')) $html = str_replace('<!--constStr@Home-->', getconstStr('Home'), $html);
|
2020-05-12 06:13:46 +00:00
|
|
|
|
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html = str_replace('<!--customCss-->', getConfig('customCss'), $html);
|
|
|
|
|
$html = str_replace('<!--customScript-->', getConfig('customScript'), $html);
|
|
|
|
|
|
2020-05-04 03:41:31 +00:00
|
|
|
|
while (strpos($html, '<!--constStr@Login-->')) $html = str_replace('<!--constStr@Login-->', getconstStr('Login'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Close-->')) $html = str_replace('<!--constStr@Close-->', getconstStr('Close'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@InputPassword-->')) $html = str_replace('<!--constStr@InputPassword-->', getconstStr('InputPassword'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@InputPasswordUWant-->')) $html = str_replace('<!--constStr@InputPasswordUWant-->', getconstStr('InputPasswordUWant'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Submit-->')) $html = str_replace('<!--constStr@Submit-->', getconstStr('Submit'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Success-->')) $html = str_replace('<!--constStr@Success-->', getconstStr('Success'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@GetUploadLink-->')) $html = str_replace('<!--constStr@GetUploadLink-->', getconstStr('GetUploadLink'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UpFileTooLarge-->')) $html = str_replace('<!--constStr@UpFileTooLarge-->', getconstStr('UpFileTooLarge'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UploadStart-->')) $html = str_replace('<!--constStr@UploadStart-->', getconstStr('UploadStart'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UploadStartAt-->')) $html = str_replace('<!--constStr@UploadStartAt-->', getconstStr('UploadStartAt'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@LastUpload-->')) $html = str_replace('<!--constStr@LastUpload-->', getconstStr('LastUpload'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@ThisTime-->')) $html = str_replace('<!--constStr@ThisTime-->', getconstStr('ThisTime'), $html);
|
|
|
|
|
|
|
|
|
|
while (strpos($html, '<!--constStr@Upload-->')) $html = str_replace('<!--constStr@Upload-->', getconstStr('Upload'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@AverageSpeed-->')) $html = str_replace('<!--constStr@AverageSpeed-->', getconstStr('AverageSpeed'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@CurrentSpeed-->')) $html = str_replace('<!--constStr@CurrentSpeed-->', getconstStr('CurrentSpeed'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@Expect-->')) $html = str_replace('<!--constStr@Expect-->', getconstStr('Expect'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UploadErrorUpAgain-->')) $html = str_replace('<!--constStr@UploadErrorUpAgain-->', getconstStr('UploadErrorUpAgain'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@EndAt-->')) $html = str_replace('<!--constStr@EndAt-->', getconstStr('EndAt'), $html);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
|
2020-05-04 03:41:31 +00:00
|
|
|
|
while (strpos($html, '<!--constStr@UploadComplete-->')) $html = str_replace('<!--constStr@UploadComplete-->', getconstStr('UploadComplete'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@CopyUrl-->')) $html = str_replace('<!--constStr@CopyUrl-->', getconstStr('CopyUrl'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UploadFail23-->')) $html = str_replace('<!--constStr@UploadFail23-->', getconstStr('UploadFail23'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@GetFileNameFail-->')) $html = str_replace('<!--constStr@GetFileNameFail-->', getconstStr('GetFileNameFail'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UploadFile-->')) $html = str_replace('<!--constStr@UploadFile-->', getconstStr('UploadFile'), $html);
|
|
|
|
|
while (strpos($html, '<!--constStr@UploadFolder-->')) $html = str_replace('<!--constStr@UploadFolder-->', getconstStr('UploadFolder'), $html);
|
2020-05-20 09:20:10 +00:00
|
|
|
|
while (strpos($html, '<!--constStr@FileSelected-->')) $html = str_replace('<!--constStr@FileSelected-->', getconstStr('FileSelected'), $html);
|
2020-05-04 03:41:31 +00:00
|
|
|
|
while (strpos($html, '<!--IsPreview?-->')) $html = str_replace('<!--IsPreview?-->', (isset($_GET['preview'])?'?preview&':'?'), $html);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--BackgroundStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--BackgroundEnd-->');
|
|
|
|
|
if (getConfig('background')) {
|
2020-08-16 04:14:13 +00:00
|
|
|
|
$html .= str_replace('<!--BackgroundUrl-->', getConfig('background'), $tmp[0]);
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--BackgroundMStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--BackgroundMEnd-->');
|
|
|
|
|
if (getConfig('backgroundm')) {
|
|
|
|
|
$html .= str_replace('<!--BackgroundMUrl-->', getConfig('backgroundm'), $tmp[0]);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
}
|
2020-08-16 04:14:13 +00:00
|
|
|
|
$html .= $tmp[1];
|
2020-05-22 08:05:12 +00:00
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--PathArrayStart-->');
|
|
|
|
|
$html = $tmp[0];
|
2020-09-03 03:19:50 +00:00
|
|
|
|
if ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--PathArrayEnd-->');
|
|
|
|
|
$PathArrayStr = $tmp[0];
|
|
|
|
|
$tmp_url = $_SERVER['base_disk_path'];
|
|
|
|
|
$tmp_path = str_replace('&','&', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url)));
|
|
|
|
|
while ($tmp_path!='') {
|
|
|
|
|
$tmp1 = splitfirst($tmp_path, '/');
|
|
|
|
|
$folder1 = $tmp1[0];
|
|
|
|
|
if ($folder1!='') {
|
|
|
|
|
$tmp_url .= $folder1 . '/';
|
|
|
|
|
$PathArrayStr1 = str_replace('<!--PathArrayLink-->', ($folder1==$files['name']?'':$tmp_url), $PathArrayStr);
|
|
|
|
|
$PathArrayStr1 = str_replace('<!--PathArrayName-->', $folder1, $PathArrayStr1);
|
|
|
|
|
$html .= $PathArrayStr1;
|
|
|
|
|
}
|
|
|
|
|
$tmp_path = $tmp1[1];
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--DiskPathArrayStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
if ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--DiskPathArrayEnd-->');
|
|
|
|
|
$PathArrayStr = $tmp[0];
|
|
|
|
|
$tmp_url = $_SERVER['base_path'];
|
|
|
|
|
$tmp_path = str_replace('&','&', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url)));
|
|
|
|
|
while ($tmp_path!='') {
|
|
|
|
|
$tmp1 = splitfirst($tmp_path, '/');
|
|
|
|
|
$folder1 = $tmp1[0];
|
|
|
|
|
if ($folder1!='') {
|
|
|
|
|
$tmp_url .= $folder1 . '/';
|
|
|
|
|
$PathArrayStr1 = str_replace('<!--PathArrayLink-->', ($folder1==$files['name']?'':$tmp_url), $PathArrayStr);
|
|
|
|
|
$PathArrayStr1 = str_replace('<!--PathArrayName-->', ($folder1==$_SERVER['disktag']?(getConfig('diskname')==''?$_SERVER['disktag']:getConfig('diskname')):$folder1), $PathArrayStr1);
|
|
|
|
|
$html .= $PathArrayStr1;
|
|
|
|
|
}
|
|
|
|
|
$tmp_path = $tmp1[1];
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
2020-05-22 08:05:12 +00:00
|
|
|
|
}
|
2020-05-03 10:17:18 +00:00
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--SelectLanguageStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--SelectLanguageEnd-->');
|
|
|
|
|
$SelectLanguage = $tmp[0];
|
|
|
|
|
foreach ($constStr['languages'] as $key1 => $value1) {
|
|
|
|
|
$SelectLanguageStr = str_replace('<!--SelectLanguageKey-->', $key1, $SelectLanguage);
|
|
|
|
|
$SelectLanguageStr = str_replace('<!--SelectLanguageValue-->', $value1, $SelectLanguageStr);
|
|
|
|
|
$SelectLanguageStr = str_replace('<!--SelectLanguageSelected-->', ($key1==$constStr['language']?'selected="selected"':''), $SelectLanguageStr);
|
|
|
|
|
$html .= $SelectLanguageStr;
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--NeedUpdateStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--NeedUpdateEnd-->');
|
|
|
|
|
$NeedUpdateStr = $tmp[0];
|
|
|
|
|
if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) $NeedUpdateStr = str_replace('<!--constStr@NeedUpdate-->', getconstStr('NeedUpdate'), $NeedUpdateStr);
|
|
|
|
|
else $NeedUpdateStr ='';
|
|
|
|
|
$html .= $NeedUpdateStr . $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--BackArrowStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--BackArrowEnd-->');
|
2020-08-30 02:01:15 +00:00
|
|
|
|
$current_url = path_format($_SERVER['PHP_SELF'] . '/');
|
|
|
|
|
if ($current_url !== $_SERVER['base_path']) {
|
2020-05-03 10:17:18 +00:00
|
|
|
|
while (substr($current_url, -1) === '/') {
|
|
|
|
|
$current_url = substr($current_url, 0, -1);
|
|
|
|
|
}
|
|
|
|
|
if (strpos($current_url, '/') !== FALSE) {
|
|
|
|
|
$parent_url = substr($current_url, 0, strrpos($current_url, '/'));
|
|
|
|
|
} else {
|
|
|
|
|
$parent_url = $current_url;
|
|
|
|
|
}
|
|
|
|
|
$BackArrow = str_replace('<!--BackArrowUrl-->', $parent_url.'/', $tmp[0]);
|
|
|
|
|
}
|
|
|
|
|
$html .= $BackArrow . $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--ShowThumbnailsStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--ShowThumbnailsEnd-->');
|
2020-05-24 11:15:09 +00:00
|
|
|
|
//if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) {
|
|
|
|
|
if (!getConfig('disableShowThumb')) {
|
2020-05-15 12:22:35 +00:00
|
|
|
|
$html .= str_replace('<!--constStr@OriginalPic-->', getconstStr('OriginalPic'), $tmp[0]) . $tmp[1];
|
2020-05-03 10:17:18 +00:00
|
|
|
|
} else $html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
$imgextstr = '';
|
|
|
|
|
foreach ($exts['img'] as $imgext) $imgextstr .= '\''.$imgext.'\', ';
|
|
|
|
|
$html = str_replace('<!--ImgExts-->', $imgextstr, $html);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$html = str_replace('<!--Sitename-->', $_SERVER['sitename'], $html);
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--MultiDiskAreaStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MultiDiskAreaEnd-->');
|
|
|
|
|
$disktags = explode("|",getConfig('disktag'));
|
|
|
|
|
if (count($disktags)>1) {
|
|
|
|
|
$tmp1 = $tmp[1];
|
|
|
|
|
$tmp = splitfirst($tmp[0], '<!--MultiDisksStart-->');
|
|
|
|
|
$MultiDiskArea = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MultiDisksEnd-->');
|
|
|
|
|
$MultiDisks = $tmp[0];
|
|
|
|
|
foreach ($disktags as $disk) {
|
|
|
|
|
$diskname = getConfig('diskname', $disk);
|
|
|
|
|
if ($diskname=='') $diskname = $disk;
|
|
|
|
|
$MultiDisksStr = str_replace('<!--MultiDisksUrl-->', path_format($_SERVER['base_path'].'/'.$disk.'/'), $MultiDisks);
|
|
|
|
|
$MultiDisksStr = str_replace('<!--MultiDisksNow-->', ($_SERVER['disktag']==$disk?' now':''), $MultiDisksStr);
|
|
|
|
|
$MultiDisksStr = str_replace('<!--MultiDisksName-->', $diskname, $MultiDisksStr);
|
|
|
|
|
$MultiDiskArea .= $MultiDisksStr;
|
|
|
|
|
}
|
|
|
|
|
$MultiDiskArea .= $tmp[1];
|
|
|
|
|
$tmp[1] = $tmp1;
|
|
|
|
|
}
|
|
|
|
|
$html .= $MultiDiskArea . $tmp[1];
|
2020-05-20 09:20:10 +00:00
|
|
|
|
$diskname = getConfig('diskname');
|
|
|
|
|
if ($diskname=='') $diskname = $_SERVER['disktag'];
|
2020-05-30 07:05:23 +00:00
|
|
|
|
//if (strlen($diskname)>15) $diskname = substr($diskname, 0, 12).'...';
|
2020-05-20 09:20:10 +00:00
|
|
|
|
while (strpos($html, '<!--DiskNameNow-->')) $html = str_replace('<!--DiskNameNow-->', $diskname, $html);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--HeadomfStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--HeadomfEnd-->');
|
|
|
|
|
if (isset($files['children']['head.omf'])) {
|
|
|
|
|
$headomf = str_replace('<!--HeadomfContent-->', fetch_files(spurlencode(path_format(urldecode($path) . '/head.omf'),'/'))['content']['body'], $tmp[0]);
|
|
|
|
|
}
|
|
|
|
|
$html .= $headomf . $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--HeadmdStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--HeadmdEnd-->');
|
|
|
|
|
if (isset($files['children']['head.md'])) {
|
|
|
|
|
$headmd = str_replace('<!--HeadmdContent-->', fetch_files(spurlencode(path_format(urldecode($path) . '/head.md'),'/'))['content']['body'], $tmp[0]);
|
|
|
|
|
$html .= $headmd . $tmp[1];
|
|
|
|
|
while (strpos($html, '<!--HeadmdStart-->')) {
|
|
|
|
|
$html = str_replace('<!--HeadmdStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--HeadmdEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--HeadmdStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--HeadmdEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--ListStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--ListEnd-->');
|
|
|
|
|
$html_aft = $tmp[1];
|
|
|
|
|
if ($files) {
|
|
|
|
|
$listarea = $tmp[0];
|
|
|
|
|
}
|
|
|
|
|
$html .= $listarea . $html_aft;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--ReadmemdStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--ReadmemdEnd-->');
|
|
|
|
|
if (isset($files['children']['readme.md'])) {
|
|
|
|
|
$Readmemd = str_replace('<!--ReadmemdContent-->', fetch_files(spurlencode(path_format(urldecode($path) . '/readme.md'),'/'))['content']['body'], $tmp[0]);
|
|
|
|
|
$html .= $Readmemd . $tmp[1];
|
|
|
|
|
while (strpos($html, '<!--ReadmemdStart-->')) {
|
|
|
|
|
$html = str_replace('<!--ReadmemdStart-->', '', $html);
|
|
|
|
|
$html = str_replace('<!--ReadmemdEnd-->', '', $html);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
$tmp[1] = 'a';
|
|
|
|
|
while ($tmp[1]!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--ReadmemdStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--ReadmemdEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--FootomfStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--FootomfEnd-->');
|
|
|
|
|
if (isset($files['children']['foot.omf'])) {
|
|
|
|
|
$Footomf = str_replace('<!--FootomfContent-->', fetch_files(spurlencode(path_format(urldecode($path) . '/foot.omf'),'/'))['content']['body'], $tmp[0]);
|
|
|
|
|
}
|
|
|
|
|
$html .= $Footomf . $tmp[1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--MdRequireStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MdRequireEnd-->');
|
|
|
|
|
if (isset($files['children']['head.md'])||isset($files['children']['readme.md'])) {
|
|
|
|
|
$html .= $tmp[0] . $tmp[1];
|
|
|
|
|
} else $html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
if (getConfig('passfile')!='') {
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptBtnStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptBtnEnd-->');
|
|
|
|
|
$html .= str_replace('<!--constStr@Encrypt-->', getconstStr('Encrypt'), $tmp[0]) . $tmp[1];
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptAlertStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptAlertEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
} else {
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptAlertStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptAlertEnd-->');
|
|
|
|
|
$html .= str_replace('<!--constStr@SetpassfileBfEncrypt-->', getconstStr('SetpassfileBfEncrypt'), $tmp[0]) . $tmp[1];
|
|
|
|
|
$tmp = splitfirst($html, '<!--EncryptBtnStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--EncryptBtnEnd-->');
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--MoveRootStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MoveRootEnd-->');
|
|
|
|
|
if ($path != '/') {
|
|
|
|
|
$html .= str_replace('<!--constStr@ParentDir-->', getconstStr('ParentDir'), $tmp[0]) . $tmp[1];
|
|
|
|
|
} else $html .= $tmp[1];
|
|
|
|
|
|
|
|
|
|
$tmp = splitfirst($html, '<!--MoveDirsStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--MoveDirsEnd-->');
|
|
|
|
|
$MoveDirs = $tmp[0];
|
|
|
|
|
if (isset($files['children'])) {
|
|
|
|
|
foreach ($files['children'] as $file) {
|
|
|
|
|
if (isset($file['folder'])) {
|
|
|
|
|
$MoveDirsStr = str_replace('<!--MoveDirsValue-->', str_replace('&','&', $file['name']), $MoveDirs);
|
|
|
|
|
$MoveDirsStr = str_replace('<!--MoveDirsValue-->', str_replace('&','&', $file['name']), $MoveDirsStr);
|
|
|
|
|
$html .= $MoveDirsStr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
|
2020-05-12 06:13:46 +00:00
|
|
|
|
$tmp = splitfirst($html, '<!--WriteTimezoneStart-->');
|
|
|
|
|
$html = $tmp[0];
|
|
|
|
|
$tmp = splitfirst($tmp[1], '<!--WriteTimezoneEnd-->');
|
|
|
|
|
if (!isset($_COOKIE['timezone'])) $html .= str_replace('<!--timezone-->', $_SERVER['timezone'], $tmp[0]);
|
|
|
|
|
$html .= $tmp[1];
|
|
|
|
|
while (strpos($html, '<!--timezone-->')) $html = str_replace('<!--timezone-->', $_SERVER['timezone'], $html);
|
2020-05-03 10:17:18 +00:00
|
|
|
|
|
2020-05-30 07:05:23 +00:00
|
|
|
|
while (strpos($html, '{{.RawData}}')) {
|
|
|
|
|
$str = '[';
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($files['children'] as $file) if ($_SERVER['admin'] or !isHideFile($file['name'])) {
|
|
|
|
|
$tmp = [];
|
|
|
|
|
$tmp['name'] = $file['name'];
|
|
|
|
|
$tmp['size'] = size_format($file['size']);
|
|
|
|
|
$tmp['date'] = time_format($file['lastModifiedDateTime']);
|
|
|
|
|
$tmp['@time'] = $file['date'];
|
|
|
|
|
$tmp['@type'] = isset($file['folder'])?'folder':'file';
|
|
|
|
|
$str .= json_encode($tmp).',';
|
|
|
|
|
}
|
|
|
|
|
if ($str == '[') {
|
|
|
|
|
$str = '';
|
|
|
|
|
} else $str = substr($str, 0, -1).']';
|
|
|
|
|
$html = str_replace('{{.RawData}}', base64_encode($str), $html);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-21 10:05:18 +00:00
|
|
|
|
// 最后清除换行
|
|
|
|
|
while (strpos($html, "\r\n\r\n")) $html = str_replace("\r\n\r\n", "\r\n", $html);
|
2020-06-13 09:44:24 +00:00
|
|
|
|
//while (strpos($html, "\r\r")) $html = str_replace("\r\r", "\r", $html);
|
|
|
|
|
while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html);
|
2020-05-21 10:05:18 +00:00
|
|
|
|
//while (strpos($html, PHP_EOL.PHP_EOL)) $html = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $html);
|
|
|
|
|
|
|
|
|
|
$exetime = round(microtime(true)-$_SERVER['php_starttime'],3);
|
2020-06-13 09:44:24 +00:00
|
|
|
|
$html = str_replace('<!--FootStr-->', date("Y-m-d H:i:s")." ".getconstStr('Week')[date("w")]." ".$_SERVER['REMOTE_ADDR'].' Runningtime:'.$exetime.'s Mem:'.size_format(memory_get_usage()), $html);
|
2020-05-21 10:05:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-23 07:42:57 +00:00
|
|
|
|
if ($_SERVER['admin']||!getConfig('disableChangeTheme')) {
|
2020-09-13 05:21:02 +00:00
|
|
|
|
$theme_arr = scandir(__DIR__ . $slash . 'theme');
|
2020-06-23 07:42:57 +00:00
|
|
|
|
$html .= '
|
2020-05-21 09:56:45 +00:00
|
|
|
|
<div style="position: fixed;right: 10px;bottom: 10px;/*color: rgba(247,247,249,0);*/">
|
|
|
|
|
<select name="theme" onchange="changetheme(this.options[this.options.selectedIndex].value)">
|
|
|
|
|
<option value="">'.getconstStr('Theme').'</option>';
|
2020-06-23 07:42:57 +00:00
|
|
|
|
foreach ($theme_arr as $v1) {
|
|
|
|
|
if ($v1!='.' && $v1!='..') $html .= '
|
2020-07-13 09:33:47 +00:00
|
|
|
|
<option value="'.$v1.'"'.($v1==$theme?' selected="selected"':'').'>'.$v1.'</option>';
|
2020-06-23 07:42:57 +00:00
|
|
|
|
}
|
|
|
|
|
$html .= '
|
2020-06-13 09:44:24 +00:00
|
|
|
|
</select>
|
2020-05-21 09:56:45 +00:00
|
|
|
|
</div>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
function changetheme(str)
|
|
|
|
|
{
|
2020-05-24 11:15:09 +00:00
|
|
|
|
var expd = new Date();
|
|
|
|
|
expd.setTime(expd.getTime()+(2*60*60*1000));
|
|
|
|
|
var expires = "expires="+expd.toGMTString();
|
|
|
|
|
document.cookie=\'theme=\'+str+\'; path=/; \'+expires;
|
2020-05-21 09:56:45 +00:00
|
|
|
|
location.href = location.href;
|
|
|
|
|
}
|
|
|
|
|
</script>';
|
2020-06-23 07:42:57 +00:00
|
|
|
|
}
|
2020-05-21 09:56:45 +00:00
|
|
|
|
|
2020-05-03 10:17:18 +00:00
|
|
|
|
$html = $authinfo . $html;
|
2020-03-13 12:48:40 +00:00
|
|
|
|
if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
|
2020-01-18 12:12:21 +00:00
|
|
|
|
return output($html,$statusCode);
|
|
|
|
|
}
|