diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..ef9c0b6
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,16 @@
+# # Apache
+# # LoadModule rewrite_module modules/mod_rewrite.so
+# # AllowOverride All
+RewriteEngine On
+# RewriteCond $1 !^(.well-known)
+RewriteRule ^(.*) index.php?/$1 [L]
+
+###-----------------------------------
+### nginx
+# rewrite ^/(?!.well-known)(.*)$ /index.php?/$1 last;
+#
+### caddy
+# rewrite {
+# to index.php?/$1
+# }
+###-----------------------------------
diff --git a/app.json b/app.json
new file mode 100644
index 0000000..755c2aa
--- /dev/null
+++ b/app.json
@@ -0,0 +1,7 @@
+{
+ "name": "OneManager",
+ "description": "Deploy OneManager to heroku",
+ "website": "https://github.com/qkqpttgf/OneManager-php",
+ "repository": "https://github.com/qkqpttgf/OneManager-php",
+ "success_url": "/"
+}
diff --git a/common.php b/common.php
new file mode 100644
index 0000000..12bad7e
--- /dev/null
+++ b/common.php
@@ -0,0 +1,2886 @@
+'Pacific/Kwajalein',
+ '-11'=>'Pacific/Samoa',
+ '-10'=>'Pacific/Honolulu',
+ '-9'=>'America/Anchorage',
+ '-8'=>'America/Los_Angeles',
+ '-7'=>'America/Denver',
+ '-6'=>'America/Mexico_City',
+ '-5'=>'America/New_York',
+ '-4'=>'America/Caracas',
+ '-3.5'=>'America/St_Johns',
+ '-3'=>'America/Argentina/Buenos_Aires',
+ '-2'=>'America/Noronha',
+ '-1'=>'Atlantic/Azores',
+ '0'=>'UTC',
+ '1'=>'Europe/Paris',
+ '2'=>'Europe/Helsinki',
+ '3'=>'Europe/Moscow',
+ '3.5'=>'Asia/Tehran',
+ '4'=>'Asia/Baku',
+ '4.5'=>'Asia/Kabul',
+ '5'=>'Asia/Karachi',
+ '5.5'=>'Asia/Calcutta', //Asia/Colombo
+ '6'=>'Asia/Dhaka',
+ '6.5'=>'Asia/Rangoon',
+ '7'=>'Asia/Bangkok',
+ '8'=>'Asia/Shanghai',
+ '9'=>'Asia/Tokyo',
+ '9.5'=>'Australia/Darwin',
+ '10'=>'Pacific/Guam',
+ '11'=>'Asia/Magadan',
+ '12'=>'Asia/Kamchatka'
+);
+
+function main($path)
+{
+ global $exts;
+ global $constStr;
+
+ $_SERVER['php_starttime'] = microtime(true);
+ $path = path_format($path);
+ if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) {
+ $constStr['language'] = $_SERVER['firstacceptlanguage'];
+ } else {
+ $prelang = splitfirst($_SERVER['firstacceptlanguage'], '-')[0];
+ foreach ( array_keys($constStr['languages']) as $lang) {
+ if ($prelang == splitfirst($lang, '-')[0]) {
+ $constStr['language'] = $lang;
+ break;
+ }
+ }
+ }
+ if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language'];
+ if ($constStr['language']=='') $constStr['language'] = 'en-us';
+ $_SERVER['language'] = $constStr['language'];
+ $_SERVER['timezone'] = getConfig('timezone');
+ if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
+ if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+
+ if (getConfig('admin')=='') return install();
+ if (getConfig('adminloginpage')=='') {
+ $adminloginpage = 'admin';
+ } else {
+ $adminloginpage = getConfig('adminloginpage');
+ }
+ if (isset($_GET[$adminloginpage])) {
+ if (isset($_GET['preview'])) {
+ $url = $_SERVER['PHP_SELF'] . '?preview';
+ } else {
+ $url = path_format($_SERVER['PHP_SELF'] . '/');
+ }
+ if (getConfig('admin')!='') {
+ if ($_POST['password1']==getConfig('admin')) {
+ return adminform('admin', pass2cookie('admin', $_POST['password1']), $url);
+ } else return adminform();
+ } else {
+ return output('', 302, [ 'Location' => $url ]);
+ }
+ }
+ if ( isset($_COOKIE['admin'])&&$_COOKIE['admin']==pass2cookie('admin', getConfig('admin')) ) {
+ $_SERVER['admin']=1;
+ $_SERVER['needUpdate'] = needUpdate();
+ } else {
+ $_SERVER['admin']=0;
+ }
+ if (isset($_GET['setup']))
+ if ($_SERVER['admin']) {
+ // setup Environments. 设置,对环境变量操作
+ return EnvOpt($_SERVER['needUpdate']);
+ } else {
+ $url = path_format($_SERVER['PHP_SELF'] . '/');
+ return output('', 302, [ 'Location' => $url ]);
+ }
+
+ $_SERVER['sitename'] = getConfig('sitename');
+ if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
+ $_SERVER['base_disk_path'] = $_SERVER['base_path'];
+ $disktags = explode("|", getConfig('disktag'));
+// echo 'count$disk:'.count($disktags);
+ if (count($disktags)>1) {
+ if ($path=='/'||$path=='') {
+ if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
+ $files['showname'] = 'root';
+ $files['folder']['childCount'] = count($disktags);
+ foreach ($disktags as $disktag) {
+ $files['children'][$disktag]['folder'] = 1;
+ $files['children'][$disktag]['name'] = $disktag;
+ $files['children'][$disktag]['showname'] = getConfig('diskname', $disktag);
+ }
+ if ($_GET['json']) {
+ // return a json
+ return files_json($files);
+ }
+ } 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 ' . $tmp . ' .', 302, [ 'Location' => $tmp ]);
+ //return message(' Please visit from Home Page .', 'Error', 404);
+ }
+ $path = substr($path, strlen('/' . $_SERVER['disktag']));
+ if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path'] . '/' . $_SERVER['disktag'] . '/');
+ }
+ } else $_SERVER['disktag'] = $disktags[0];
+// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.'
+//';
+ $_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
+ if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['ajax']=0;
+ if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
+
+ if ($_SERVER['admin']) if (isset($_GET['AddDisk'])) return get_refresh_token();
+
+ if ($files['showname'] == 'root') return render_list($path, $files);
+ config_oauth();
+ $refresh_token = getConfig('refresh_token');
+ if (!$refresh_token) {
+ return render_list();
+ } else {
+ if (!($_SERVER['access_token'] = getcache('access_token'))) {
+ $response = get_access_token($refresh_token);
+ if (isset($response['stat'])) return message($response['body'], 'Error', $response['stat']);
+ }
+
+ if ($_SERVER['ajax']) {
+ if ($_GET['action']=='del_upload_cache') {
+ // del '.tmp' without login. 无需登录即可删除.tmp后缀文件
+ error_log('del.tmp:GET,'.json_encode($_GET,JSON_PRETTY_PRINT));
+ $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']);
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1, json_decode('{}',true), 1);
+ return output($tmp['body'],$tmp['stat']);
+ }
+ if ($_GET['action']=='uploaded_rename') {
+ // rename .scfupload file without login.
+ // 无需登录即可重命名.scfupload后缀文件,filemd5为用户提交,可被构造,问题不大,以后处理
+ $oldname = spurlencode($_GET['filename']);
+ $pos = strrpos($oldname, '.');
+ if ($pos>0) $ext = strtolower(substr($oldname, $pos));
+ //$oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname . '.scfupload' );
+ $oldname = path_format(path_format($_SERVER['list_path'] . path_format($path)) . '/' . $oldname);
+ $data = '{"name":"' . $_GET['filemd5'] . $ext . '"}';
+ //echo $oldname .' '. $data;
+ $tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
+ if ($tmp['stat']==409) {
+ MSAPI('DELETE',$oldname,'',$_SERVER['access_token']);
+ $tmpbody = json_decode($tmp['body'], true);
+ $tmpbody['name'] = $_GET['filemd5'] . $ext;
+ $tmp['body'] = json_encode($tmpbody);
+ }
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1, json_decode('{}',true), 1);
+ return output($tmp['body'],$tmp['stat']);
+ }
+ if ($_GET['action']=='upbigfile') return bigfileupload($path);
+ }
+ if ($_SERVER['admin']) {
+ $tmp = adminoperate($path);
+ if ($tmp['statusCode'] > 0) {
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1, json_decode('{}',true), 1);
+ return $tmp;
+ }
+ } else {
+ if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401);
+ }
+ $_SERVER['ishidden'] = passhidden($path);
+ if (isset($_GET['thumbnails'])) {
+ if ($_SERVER['ishidden']<4) {
+ if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) {
+ return get_thumbnails_url($path, $_GET['location']);
+ } else return output(json_encode($exts['img']),400);
+ } else return output('',401);
+ }
+
+ $files = list_files($path);
+ //echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT);
+ if ($_GET['json']) {
+ // return a json
+ return files_json($files);
+ }
+ 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) {
+ $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 ]);
+ } else return output('',404);
+ } else return output('',401);
+ }
+ if (isset($files['file']) && !isset($_GET['preview'])) {
+ // is file && not preview mode
+ if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) {
+ $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']);
+ else {
+ if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE'];
+ $header['Location'] = $url;
+ return output('', 302, $header);
+ }
+ }
+ }
+ 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(''.getconstStr('Back').getconstStr('Home').'
' . $files['error']['message'] . ' '.getconstStr('Back').' ', $files['error']['code'], $files['error']['stat']);
+ }
+ }
+}
+
+function pass2cookie($name, $pass)
+{
+ return md5($name . ':' . md5($pass));
+}
+
+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);
+ }
+ } else return output(var_dump($files), 404);
+ return output(json_encode($tmp), 200, ['Content-Type' => 'application/json']);
+}
+
+function get_access_token($refresh_token)
+{
+ if (getConfig('Drive_ver')=='shareurl') {
+ $shareurl = getConfig('shareurl');
+ $tmp1 = splitlast($shareurl, '/')[0];
+ $account = splitlast($tmp1, '/')[1];
+ $tmp1 = splitlast($shareurl, ':')[0];
+ $domain = splitlast($tmp1, '/')[0];
+ if (!isset($_SERVER['sharecookie'])||$_SERVER['sharecookie']=='') $_SERVER['sharecookie'] = curl_request($shareurl,false, [],1)['returnhead']['Set-Cookie'];
+ $response = curl_request(
+ $domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE",
+ '{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}',
+ [ 'Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => $domain, 'Cookie' => $_SERVER['sharecookie'] ]
+ );
+ if ($response['stat']==200) $ret = json_decode($response['body'], true);
+ $_SERVER['access_token'] = splitlast($ret['ListSchema']['.driveAccessToken'],'=')[1];
+ $_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root';
+ if (!$_SERVER['access_token']) {
+ error_log($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
+ error_log('failed to get share access_token. response' . json_encode($ret));
+ $response['body'] .= '\nfailed to get shareurl access_token.';
+ return $response;
+ //throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']);
+ }
+ $tmp = $ret;
+ $tmp['access_token'] = '******';
+ error_log('['.$_SERVER['disktag'].'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
+ savecache('access_token', $_SERVER['access_token']);
+ $tmp1 = [];
+ $tmp1['shareapiurl'] = $_SERVER['api_url'];
+ if (getConfig('shareapiurl')=='') setConfig($tmp1);
+ } else {
+ $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++;
+ }
+ if ($response['stat']==200) $ret = json_decode($response['body'], true);
+ if (!isset($ret['access_token'])) {
+ error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . substr($refresh_token, 0, 20) . '******' . substr($refresh_token, -20));
+ error_log('failed to get ['.$_SERVER['disktag'].'] access_token. response' . json_encode($ret));
+ $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']);
+ }
+ $tmp = $ret;
+ $tmp['access_token'] = '******';
+ $tmp['refresh_token'] = '******';
+ error_log('['.$_SERVER['disktag'].'] Get access token:'.json_encode($tmp, JSON_PRETTY_PRINT));
+ $_SERVER['access_token'] = $ret['access_token'];
+ savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300);
+ if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]);
+ }
+ return 0;
+}
+
+function list_files($path)
+{
+ $path = path_format($path);
+ if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
+ $files = json_decode('{"folder":{}}', true);
+ } elseif (!getConfig('downloadencrypt')) {
+ if ($_SERVER['ishidden']==4) $files = json_decode('{"folder":{}}', true);
+ else $files = fetch_files($path);
+ } else {
+ $files = fetch_files($path);
+ }
+ return $files;
+}
+
+function isHideFile($name)
+{
+ $FunctionalityFile = [
+ 'head.md',
+ 'readme.md',
+ 'head.omf',
+ 'foot.omf',
+ 'favicon.ico',
+ 'index.html',
+ ];
+
+ 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;
+}
+
+function getcache($str)
+{
+ $cache = filecache();
+ return $cache->fetch($str);
+}
+
+function savecache($key, $value, $exp = 1800)
+{
+ $cache = filecache();
+ return $cache->save($key, $value, $exp);
+}
+
+function filecache()
+{
+ $dir = sys_get_temp_dir();
+ if (!is_writable($dir)) {
+ $tmp = __DIR__ . '/tmp/';
+ if (file_exists($tmp)) {
+ if ( is_writable($tmp) ) $dir = $tmp;
+ } elseif ( mkdir($tmp) ) $dir = $tmp;
+ }
+ $tag = __DIR__ . '/OneManager/' . $_SERVER['disktag'];
+ while (strpos($tag, '/')>-1) $tag = str_replace('/', '_', $tag);
+ if (strpos($tag, ':')>-1) {
+ while (strpos($tag, ':')>-1) $tag = str_replace(':', '_', $tag);
+ while (strpos($tag, '\\')>-1) $tag = str_replace('\\', '_', $tag);
+ }
+ // error_log('DIR:' . $dir . ' TAG: ' . $tag);
+ $cache = new \Doctrine\Common\Cache\FilesystemCache($dir, $tag);
+ return $cache;
+}
+
+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';
+ if (getConfig('Drive_ver')=='shareurl') {
+ $_SERVER['api_url'] = getConfig('shareapiurl');
+ $_SERVER['sharecookie'] = getConfig('sharecookie');
+ $_SERVER['DownurlStrName'] = '@content.downloadUrl';
+ return 0;
+ }
+ if (getConfig('Drive_ver')=='MS') {
+ // MS
+ // https://portal.azure.com
+ //$_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';
+ $_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';
+ if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/sites/' . getConfig('siteid') . '/drive/root';
+ }
+ if (getConfig('Drive_ver')=='CN') {
+ // CN 21Vianet
+ // https://portal.azure.cn
+ //$_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';
+ $_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';
+ if (getConfig('usesharepoint')=='on') $_SERVER['api_url'] = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/' . getConfig('siteid') . '/drive/root';
+ }
+
+ if (getConfig('Drive_custom')=='on') {
+ // Customer
+ $_SERVER['client_id'] = getConfig('client_id');
+ $_SERVER['client_secret'] = getConfig('client_secret');
+ }
+ $_SERVER['client_secret'] = urlencode($_SERVER['client_secret']);
+ $_SERVER['scope'] = urlencode($_SERVER['scope']);
+ $_SERVER['DownurlStrName'] = '@microsoft.graph.downloadUrl';
+}
+
+function get_siteid($access_token)
+{
+ $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;
+
+ $i=0;
+ $response = [];
+ while ($url!=''&&$response['stat']!=200&&$i<4) {
+ $response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
+ $i++;
+ }
+ if ($response['stat']!=200) {
+ error_log('failed to get siteid. response' . json_encode($response));
+ $response['body'] .= '\nfailed to get siteid.';
+ return $response;
+ //throw new Exception($response['stat'].', failed to get siteid.'.$response['body']);
+ }
+ return json_decode($response['body'],true)['id'];
+}
+
+function getListpath($domain)
+{
+ $domain_path1 = getConfig('domain_path');
+ $public_path = getConfig('public_path');
+ $tmp_path='';
+ if ($domain_path1!='') {
+ $tmp = explode("|",$domain_path1);
+ foreach ($tmp as $multidomain_paths){
+ $pos = strpos($multidomain_paths,":");
+ 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;
+ //if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path;
+ }
+ }
+ }
+ if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain],'/');
+ return spurlencode($public_path,'/');
+}
+
+function path_format($path)
+{
+ $path = '/' . $path;
+ while (strpos($path, '//') !== FALSE) {
+ $path = str_replace('//', '/', $path);
+ }
+ return $path;
+}
+
+function spurlencode($str, $split='')
+{
+ $str = str_replace(' ', '%20',$str);
+ $tmp='';
+ if ($split!='') {
+ $tmparr=explode($split, $str);
+ foreach ($tmparr as $str1) {
+ $tmp .= urlencode($str1) . $split;
+ }
+ $tmp = substr($tmp, 0, -strlen($split));
+ } else {
+ $tmp = urlencode($str);
+ }
+ $tmp = str_replace('%2520', '%20',$tmp);
+ return $tmp;
+}
+
+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;
+}
+
+function equal_replace($str, $add = false)
+{
+ if ($add) {
+ while(strlen($str)%4) $str .= '=';
+ $str = urldecode(base64_decode($str));
+ } else {
+ $str = base64_encode(urlencode($str));
+ while(substr($str,-1)=='=') $str=substr($str,0,-1);
+ }
+ return $str;
+}
+
+function is_guestup_path($path)
+{
+ $a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/');
+ $a2 = path_format(path_format(getConfig('guestup_path')).'/');
+ if (getConfig('guestup_path')!=''&&strtolower($a1)==strtolower($a2)) return 1;
+ return 0;
+}
+
+function array_value_isnot_null($arr)
+{
+ return $arr!=='';
+}
+
+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;
+}
+
+function curl_request($url, $data = false, $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);
+ 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);
+ 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;
+}
+
+function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
+{
+ for ($page=$page1+1;$page<$maxpage;$page++) {
+ $pageinfocache['nextlink_' . $path . '_page_' . $page] = '';
+ }
+ $pageinfocache = array_filter($pageinfocache, 'array_value_isnot_null');
+ 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'));
+ date_default_timezone_set(get_timezone($_SERVER['timezone']));
+ 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)
+{
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ $password=getcache('path_' . $path1 . '/?password');
+ if ($password=='') {
+ $ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
+ //echo $path . '' . json_encode($ispassfile, JSON_PRETTY_PRINT) . ' ';
+ if (isset($ispassfile['file'])) {
+ $arr = curl_request($ispassfile[$_SERVER['DownurlStrName']]);
+ 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) );
+ }
+ } else {
+ savecache('path_' . $path1 . '/?password', 'null');
+ if ($path !== '' ) {
+ $path = substr($path,0,strrpos($path,'/'));
+ return gethiddenpass($path,$passfile);
+ } else {
+ return '';
+ }
+ }
+ } elseif ($password==='null') {
+ if ($path !== '' ) {
+ $path = substr($path,0,strrpos($path,'/'));
+ return gethiddenpass($path,$passfile);
+ } else {
+ return '';
+ }
+ } else return $password;
+ // return md5('DefaultP@sswordWhenNetworkError');
+}
+
+function get_timezone($timezone = '8')
+{
+ global $timezones;
+ if ($timezone=='') $timezone = '8';
+ return $timezones[$timezone];
+}
+
+function message($message, $title = 'Message', $statusCode = 200)
+{
+ return output('
+
+
+
+
+
+ ' . $title . '
+
+' . $message . '
+
+
+
+', $statusCode);
+}
+
+function needUpdate()
+{
+ $current_version = file_get_contents(__DIR__ . '/version');
+ $current_ver = substr($current_version, strpos($current_version, '.')+1);
+ $current_ver = explode(urldecode('%0A'),$current_ver)[0];
+ $current_ver = explode(urldecode('%0D'),$current_ver)[0];
+ $split = splitfirst($current_version, '.' . $current_ver)[0] . '.' . $current_ver;
+ //$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'];
+ $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) {
+ //$_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];
+ return 1;
+ }
+ 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') != '') {
+ $path = spurlencode($path,'/');
+ 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)
+{
+ if ($ISO=='') return date('Y-m-d H:i:s');
+ $ISO = str_replace('T', ' ', $ISO);
+ $ISO = str_replace('Z', ' ', $ISO);
+ return date('Y-m-d H:i:s',strtotime($ISO . " UTC"));
+}
+
+function get_thumbnails_url($path = '/', $location = 0)
+{
+ $path1 = path_format($path);
+ $path = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
+ $thumb_url = getcache('thumb_'.$path);
+ 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'];
+ }
+ }
+ if ($thumb_url!='') {
+ 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);
+ }
+ 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) {
+ $tmp = splitlast($_GET['upbigfilename'], '/');
+ if ($tmp[1]!='') {
+ $fileinfo['name'] = $tmp[1];
+ $fileinfo['path'] = $tmp[0];
+ } else {
+ $fileinfo['name'] = $_GET['upbigfilename'];
+ }
+ $fileinfo['size'] = $_GET['filesize'];
+ $fileinfo['lastModified'] = $_GET['lastModified'];
+ $filename = spurlencode($_GET['upbigfilename'],'/');
+ 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']);
+ }
+ }
+ //if (!$_SERVER['admin']) $filename = spurlencode( $fileinfo['name'] ) . '.scfupload';
+ $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']);
+ }
+ return output($response['body'], $response['stat']);
+ }
+ return output('error', 400);
+}
+
+function adminform($name = '', $pass = '', $path = '')
+{
+ $html = '' . getconstStr('AdminLogin') . ' ';
+ if ($name!=''&&$pass!='') {
+ $html .= ' ' . getconstStr('LoginSuccess') . '';
+ $statusCode = 201;
+ date_default_timezone_set('UTC');
+ $header = [
+ 'Set-Cookie' => $name . '=' . $pass . '; path=/; expires=' . date(DATE_COOKIE, strtotime('+1hour')),
+ //'Location' => $path,
+ 'Content-Type' => 'text/html'
+ ];
+ return output($html, $statusCode, $header);
+ }
+ $statusCode = 401;
+ $html .= '
+
+
+
' . getconstStr('InputPassword') . '
+
+
+
+';
+ $html .= '';
+ return output($html, $statusCode);
+}
+
+function adminoperate($path)
+{
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if (substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ $tmparr['statusCode'] = 0;
+ if (isset($_GET['rename_newname'])&&$_GET['rename_newname']!=$_GET['rename_oldname'] && $_GET['rename_newname']!='') {
+ // 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']);
+ }
+ if (isset($_GET['delete_name'])) {
+ // 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']);
+ }
+ if (isset($_GET['operate_action'])&&$_GET['operate_action']==getconstStr('Encrypt')) {
+ // 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']);
+ $path1 = path_format($path1 . '/' . $foldername );
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1 . '/?password', '', 1);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_GET['move_folder'])) {
+ // 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'] . '/' );
+ if ($path2!='/'&&substr($path2,-1)=='/') $path2=substr($path2,0,-1);
+ savecache('path_' . $path2, json_decode('{}',true), 1);
+ return output($result['body'], $result['stat']);
+ } else {
+ return output('{"error":"'.getconstStr('CannotMove').'"}', 403);
+ }
+ }
+ if (isset($_GET['copy_name'])) {
+ // 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);
+ return output($result['body'], $result['stat']);
+ }
+ if (isset($_POST['editfile'])) {
+ // 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);
+ if (isset($resultarry['error'])) return message($resultarry['error']['message']. ''.getconstStr('Back').' ','Error',403);
+ }
+ if (isset($_GET['create_name'])) {
+ // 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']);
+ }
+ if (isset($_GET['RefreshCache'])) {
+ $path1 = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1);
+ savecache('path_' . $path1 . '/?password', '', 1);
+ savecache('customTheme', '', 1);
+ return message(' ', getconstStr('RefreshCache'), 302);
+ }
+ return $tmparr;
+}
+
+function splitfirst($str, $split)
+{
+ $len = strlen($split);
+ $pos = strpos($str, $split);
+ if ($pos===false) {
+ $tmp[0] = $str;
+ $tmp[1] = '';
+ } elseif ($pos>0) {
+ $tmp[0] = substr($str, 0, $pos);
+ $tmp[1] = substr($str, $pos+$len);
+ } else {
+ $tmp[0] = '';
+ $tmp[1] = substr($str, $len);
+ }
+ return $tmp;
+}
+
+function splitlast($str, $split)
+{
+ $len = strlen($split);
+ $pos = strrpos($str, $split);
+ if ($pos===false) {
+ $tmp[0] = $str;
+ $tmp[1] = '';
+ } elseif ($pos>0) {
+ $tmp[0] = substr($str, 0, $pos);
+ $tmp[1] = substr($str, $pos+$len);
+ } else {
+ $tmp[0] = '';
+ $tmp[1] = substr($str, $len);
+ }
+ return $tmp;
+}
+
+function 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'] = '*/*';
+ //if (!isset($headers['Referer'])) $headers['Referer'] = $url;*
+ $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);
+ //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
+ $response['body'] = curl_exec($ch);
+ $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
+ //$response['Location'] = curl_getinfo($ch);
+ curl_close($ch);
+ error_log($response['stat'].'
+'.$response['body'].'
+');
+ return $response;
+}
+
+function fetch_files($path = '/')
+{
+ global $exts;
+ $path1 = path_format($path);
+ $path = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
+ 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
+ $pos = splitlast($path, '/');
+ $parentpath = $pos[0];
+ if ($parentpath=='') $parentpath = '/';
+ $filename = $pos[1];
+ if ($parentfiles = getcache('path_' . $parentpath)) {
+ if (isset($parentfiles['children'][$filename][$_SERVER['DownurlStrName']])) {
+ if (in_array(splitlast($filename,'.')[1], $exts['txt'])) {
+ if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) {
+ $content1 = curl_request($parentfiles['children'][$filename][$_SERVER['DownurlStrName']]);
+ $parentfiles['children'][$filename]['content'] = $content1;
+ savecache('path_' . $parentpath, $parentfiles);
+ }
+ }
+ return $parentfiles['children'][$filename];
+ }
+ }
+
+ $url = $_SERVER['api_url'];
+ if ($path !== '/') {
+ $url .= ':' . $path;
+ if (substr($url,-1)=='/') $url=substr($url,0,-1);
+ }
+ $url .= '?expand=children(select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'].')';
+ $retry = 0;
+ $arr = [];
+ while ($retry<3&&!$arr['stat']) {
+ $arr = curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']],1);
+ $retry++;
+ }
+ if ($arr['stat']<500) {
+ $files = json_decode($arr['body'], true);
+ //echo $path . '' . json_encode($arr, JSON_PRETTY_PRINT) . ' ';
+ if (isset($files['folder'])) {
+ if ($files['folder']['childCount']>200) {
+ // files num > 200 , then get nextlink
+ $page = $_POST['pagenum']==''?1:$_POST['pagenum'];
+ if ($page>1) $files=fetch_files_children($files, $path1, $page);
+ $files['children'] = children_name($files['children']);
+ /*$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'];*/
+ } else {
+ // files num < 200 , then cache
+ //if (isset($files['children'])) {
+ $files['children'] = children_name($files['children']);
+ //}
+ savecache('path_' . $path, $files);
+ }
+ }
+ if (isset($files['file'])) {
+ if (in_array(splitlast($files['name'],'.')[1], $exts['txt'])) {
+ if (!(isset($files['content'])&&$files['content']['stat']==200)) {
+ $content1 = curl_request($files[$_SERVER['DownurlStrName']]);
+ $files['content'] = $content1;
+ savecache('path_' . $path, $files);
+ }
+ }
+ }
+ if (isset($files['error'])) {
+ $files['error']['stat'] = $arr['stat'];
+ }
+ } else {
+ //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));
+ }
+ }
+
+ return $files;
+}
+
+function children_name($children)
+{
+ $tmp = [];
+ foreach ($children as $file) {
+ $tmp[strtolower($file['name'])] = $file;
+ }
+ return $tmp;
+}
+
+function fetch_files_children($files, $path, $page)
+{
+ $path1 = path_format($path);
+ $path = path_format($_SERVER['list_path'] . path_format($path));
+ if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1);
+ $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) {
+ $pageinfo = curl_request($cachefile[$_SERVER['DownurlStrName']])['body'];
+ $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);
+ $url .= ':/children?$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
+ } else {
+ $url .= '/children?$select=id,name,size,file,folder,parentReference,lastModifiedDateTime,'.$_SERVER['DownurlStrName'];
+ }
+ $children = json_decode(curl_request($url, false, ['Authorization' => 'Bearer ' . $_SERVER['access_token']])['body'], true);
+ // echo $url . '' . json_encode($children, JSON_PRETTY_PRINT) . ' ';
+ 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 . '' . json_encode($children, JSON_PRETTY_PRINT) . ' ';
+ $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 . '' . json_encode($children, JSON_PRETTY_PRINT) . ' ';
+ $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;
+}
+
+function get_refresh_token()
+{
+ global $constStr;
+ global $CommonEnv;
+ config_oauth();
+ $envs = '';
+ foreach ($CommonEnv as $env) $envs .= '\'' . $env . '\', ';
+ $url = path_format($_SERVER['PHP_SELF'] . '/');
+ if (isset($_GET['install2']) && isset($_GET['code'])) {
+ $_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 : ';
+ $str .= '
+
+ '.getconstStr('SavingToken').'
+ ';
+ $tmptoken['refresh_token'] = $refresh_token;
+ $tmptoken['token_expires'] = time()+7*24*60*60;
+ if (getConfig('usesharepoint')=='on') {
+ $tmp1 = get_siteid($ret['access_token']);
+ if (isset($tmp1['stat'])) return message($tmp1['body'], 'Error', $tmp1['stat']);
+ $tmptoken['siteid'] = $tmp1;
+ }
+ $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 .= '
+ ';
+ return message($str, getconstStr('WaitJumpIndex'));
+ }
+ }
+ return message('' . json_encode(json_decode($tmp['body']), JSON_PRETTY_PRINT) . ' ', $tmp['stat']);
+ //return message('' . json_encode($ret, JSON_PRETTY_PRINT) . ' ', 500);
+ }
+ if (isset($_GET['install1'])) {
+ $_SERVER['disktag'] = $_COOKIE['disktag'];
+ config_oauth();
+ if (getConfig('Drive_ver')=='MS' || getConfig('Drive_ver')=='CN') {
+ return message('
+ '.getconstStr('JumptoOffice').'
+
+ ', getconstStr('Wait').' 1s', 201);
+ } else {
+ 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 . ''.getconstStr('Refresh').' ', '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;
+ } else {
+ if ($_POST['Drive_custom']=='on') {
+ $tmp['Drive_custom'] = $_POST['Drive_custom'];
+ $tmp['client_id'] = $_POST['client_id'];
+ $tmp['client_secret'] = $_POST['client_secret'];
+ } else {
+ $tmp['Drive_custom'] = '';
+ $tmp['client_id'] = '';
+ $tmp['client_secret'] = '';
+ }
+ if ($_POST['usesharepoint']=='on') {
+ $tmp['usesharepoint'] = $_POST['usesharepoint'];
+ $tmp['sharepointSiteAddress'] = $_POST['sharepointSiteAddress'];
+ } else {
+ $tmp['usesharepoint'] = '';
+ $tmp['sharepointSiteAddress'] = '';
+ }
+ }
+ $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 ';
+ if ($_POST['Drive_ver']=='shareurl') $html = getconstStr('Wait') . ' 3s ';
+ }
+ return message($html, $title, 201);
+ }
+ }
+
+ //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);
+ $html = '
+
+ ';
+ $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 = 'OneManager '.getconstStr('Setup').' ';
+ if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) {
+ $response = setConfigResponse(OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch']));
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ //WaitSCFStat();
+ $html .= getconstStr('UpdateSuccess') . '
+'.getconstStr('Refresh').' ';
+ $title = getconstStr('Setup');
+ }
+ 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;
+ }
+ if ($k == 'disk') $_SERVER['disk_oprating'] = $v;
+ }
+ /*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));
+ }
+ $tmp['domain_path'] = $tmparr;
+ }*/
+ $response = setConfigResponse( setConfig($tmp, $_SERVER['disk_oprating']) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ //WaitSCFStat();
+ $html .= getconstStr('Success') . '!
+'.getconstStr('Refresh').' ';
+ $title = getconstStr('Setup');
+ }
+ return message($html, $title);
+ }
+ if (isset($_GET['preview'])) {
+ $preurl = $_SERVER['PHP_SELF'] . '?preview';
+ } else {
+ $preurl = path_format($_SERVER['PHP_SELF'] . '/');
+ }
+ $html .= '
+'.getconstStr('Back').' '.getconstStr('Back').getconstStr('Home').'
+Github ';
+
+ $html .= '
+ ';
+ foreach (explode("|",getConfig('disktag')) as $disktag) {
+ if ($disktag!='') {
+ $html .= '
+
+ ';
+ if (getConfig('refresh_token', $disktag)!='') {
+ $html .= '
+ ';
+ } else {
+ $html .= '
+
+ Please add this disk again.
+ ';
+ }
+ $html .= '
+
';
+ }
+ }
+ $html .= '
+'.getconstStr('AddDisk').' ';
+
+ $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;
+ } elseif ($_SERVER['BCE_CFC_RUNTIME_NAME']=='php7') {
+ $canOneKeyUpate = 1;
+ } elseif ($_SERVER['_APP_SHARE_DIR']==='/var/share/CFF/processrouter') {
+ $canOneKeyUpate = 1;
+ } else {
+ $tmp = time();
+ if ( mkdir(''.$tmp, 0777) ) {
+ rmdir(''.$tmp);
+ $canOneKeyUpate = 1;
+ }
+ }
+ if (!$canOneKeyUpate) {
+ $html .= '
+'.getconstStr('CannotOneKeyUpate').' ';
+ } else {
+ $html .= '
+
+
+';
+ }
+ if ($needUpdate) {
+ $html .= '
+ ' . str_replace("\r", ' ', $_SERVER['github_ver_new']) . '
+
+More...
+
+ ' . str_replace("\r", ' ', $_SERVER['github_ver_old']) . '
+
';
+ }/* else {
+ $html .= getconstStr('NotNeedUpdate');
+ }*/
+ return message($html, getconstStr('Setup'));
+}
+
+function render_list($path = '', $files = '')
+{
+ global $exts;
+ global $constStr;
+
+ 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 = '';
+ //$authinfo = $path . '' . json_encode($files, JSON_PRETTY_PRINT) . ' ';
+
+ if (isset($_COOKIE['theme'])&&$_COOKIE['theme']!='') $theme = $_COOKIE['theme'];
+ if ( !file_exists(__DIR__.'/theme/'.$theme) ) $theme = '';
+ if ( $theme=='' ) {
+ $tmp = getConfig('customTheme');
+ if ( $tmp!='' ) $theme = $tmp;
+ }
+ if ( $theme=='' ) {
+ $theme = getConfig('theme');
+ if ( $theme=='' || !file_exists(__DIR__.'/theme/'.$theme) ) $theme = 'classic.html';
+ }
+ if (substr($theme,-4)=='.php') {
+ @ob_start();
+ include 'theme/'.$theme;
+ $html = ob_get_clean();
+ } else {
+ if (file_exists(__DIR__.'/theme/'.$theme)) {
+ $file_path = __DIR__.'/theme/'.$theme;
+ $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);
+ }
+
+ }
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $IconValues = json_decode($tmp[0], true);
+ $html .= $tmp[1];
+
+ if (!$files) {
+ //$html = ''.json_encode($files, JSON_PRETTY_PRINT).' ' . $html;
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+ if ($_SERVER['admin']) {
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Operate'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Create'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Encrypt'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('RefreshCache'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Setup'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Logout'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Rename'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Submit'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Delete'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Copy'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Move'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Folder'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('File'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Name'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Content'), $html);
+
+ } else {
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ if (getConfig('adminloginpage')=='') {
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ } else {
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ }
+
+ if ($_SERVER['ishidden']==4) {
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ /*$tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }*/
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ } else {
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ }
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Download'), $html);
+
+ if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ } else {
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ }
+ if ($_SERVER['is_guestup_path']||( $_SERVER['admin']&&isset($files['folder'])&&$_SERVER['ishidden']<4 )) {
+ while (strpos($html, '')) {
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Calculate'), $html);
+ }
+ } else {
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+
+ if (isset($files['file'])) {
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ $html = str_replace('', str_replace('%2523', '%23', str_replace('%26amp%3B','&',spurlencode(path_format($_SERVER['base_disk_path'] . '/' . $path), '/'))), $html);
+ $html = str_replace('', 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, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ //while (strpos($html, '')) $html = str_replace('', $files[$_SERVER['DownurlStrName']], $html);
+ while (strpos($html, '')) $html = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path), $html);
+ while (strpos($html, '')) $html = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path), $html);
+ while (strpos($html, '')) $html = str_replace('', $files['name'], $html);
+ $html = str_replace('', urlencode($files[$_SERVER['DownurlStrName']]), $html);
+ $html = str_replace('', getconstStr('ClicktoEdit'), $html);
+ $html = str_replace('', getconstStr('CancelEdit'), $html);
+ $html = str_replace('', getconstStr('Save'), $html);
+ while (strpos($html, '')) $html = str_replace('', htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']), $html);
+ $html = str_replace('', getconstStr('FileNotSupport'), $html);
+
+
+ //$html = str_replace('', getconstStr('File'), $html);
+ } elseif (isset($files['children'])) {
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ $html = str_replace('', getconstStr('File'), $html);
+ $html = str_replace('', getconstStr('ShowThumbnails'), $html);
+ $html = str_replace('', getconstStr('CopyAllDownloadUrl'), $html);
+ $html = str_replace('', getconstStr('EditTime'), $html);
+ $html = str_replace('', getconstStr('Size'), $html);
+
+ $filenum = 0;
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $FolderList = $tmp[0];
+ foreach ($files['children'] as $file) {
+ if (isset($file['folder'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++;
+ $FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList);
+ $FolderListStr = str_replace('', str_replace('&','&', $file['showname']?$file['showname']:$file['name']), $FolderListStr);
+ $FolderListStr = str_replace('', time_format($file['lastModifiedDateTime']), $FolderListStr);
+ $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr);
+ while (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $filenum, $FolderListStr);
+ $html .= $FolderListStr;
+ }
+ }
+ }
+ $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $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('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . encode_str_replace($file['name'])), $FolderList);
+ $FolderListStr = str_replace('', $ext, $FolderListStr);
+ if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('', 'audio', $FolderListStr);
+ elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('', 'iframe', $FolderListStr);
+ else $FolderListStr = str_replace('', '', $FolderListStr);
+ $FolderListStr = str_replace('', str_replace('&','&', $file['name']), $FolderListStr);
+ //$FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&', $file['name'])), $FolderListStr);
+ $FolderListStr = str_replace('', time_format($file['lastModifiedDateTime']), $FolderListStr);
+ $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr);
+ if (!!$IconValues) {
+ foreach ($IconValues as $key1 => $value1) {
+ if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) {
+ $FolderListStr = str_replace('', $value1, $FolderListStr);
+ }
+ if ($ext==$key1) {
+ $FolderListStr = str_replace('', $value1, $FolderListStr);
+ }
+ //error_log('file:'.$file['name'].':'.$key1);
+ if (!strpos($FolderListStr, '')) break;
+ }
+ if (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $IconValues['default'], $FolderListStr);
+ }
+ while (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $filenum, $FolderListStr);
+ $html .= $FolderListStr;
+ }
+ }
+ }
+ $html .= $tmp[1];
+ while (strpos($html, '')) $html = str_replace('', $filenum, $html);
+
+ if ($files['folder']['childCount']>200) {
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+ while (strpos($html, '')) $html = str_replace('', '', $html);
+
+ $pagenum = $files['folder']['page'];
+ if ($pagenum=='') $pagenum = 1;
+ $maxpage = ceil($files['folder']['childCount']/200);
+
+ if ($pagenum!=1) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ $html = str_replace('', getconstStr('PrePage'), $html);
+ $html = str_replace('', $pagenum-1, $html);
+ } else {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ //$html .= json_encode($files['folder']);
+ if ($pagenum!=$maxpage) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ $html = str_replace('', getconstStr('NextPage'), $html);
+ $html = str_replace('', $pagenum+1, $html);
+ } else {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $MorePageListNow = str_replace('', $pagenum, $tmp[0]);
+ $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $MorePageList = $tmp[0];
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $MorePageListStr = $MorePageListNow;
+ } else {
+ $MorePageListStr = str_replace('', $page, $MorePageList);
+ $MorePageListStr = str_replace('', $page, $MorePageListStr);
+ }
+ $html .= $MorePageListStr;
+ }
+ $html .= $tmp[1];
+
+ while (strpos($html, '')) $html = str_replace('', $maxpage, $html);
+
+ } else {
+ while (strpos($html, '')) {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+
+ }
+
+ $html = str_replace('', $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, $html);
+
+ $keywords = $n_path;
+ if ($p_path!='') $keywords .= ', ' . $p_path;
+ if ($_SERVER['sitename']!='OneManager') $keywords .= ', ' . $_SERVER['sitename'] . ', OneManager';
+ else $keywords .= ', OneManager';
+ $html = str_replace('', $keywords, $html);
+
+ 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'];
+ $html = str_replace('', $description, $html);
+
+ while (strpos($html, '')) $html = str_replace('', (substr($_SERVER['base_disk_path'],-1)=='/'?substr($_SERVER['base_disk_path'],0,-1):$_SERVER['base_disk_path']), $html);
+ while (strpos($html, '')) $html = str_replace('', $_SERVER['base_path'], $html);
+ while (strpos($html, '')) $html = str_replace('', str_replace('%23', '#', str_replace('&','&', path_format($path.'/'))), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Home'), $html);
+
+ $html = str_replace('', getConfig('customCss'), $html);
+ $html = str_replace('', getConfig('customScript'), $html);
+
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Login'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Close'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('InputPassword'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('InputPasswordUWant'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Submit'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Success'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('GetUploadLink'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UpFileTooLarge'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadStart'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadStartAt'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('LastUpload'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('ThisTime'), $html);
+
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Upload'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('AverageSpeed'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('CurrentSpeed'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('Expect'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadErrorUpAgain'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('EndAt'), $html);
+
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadComplete'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('CopyUrl'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFail23'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('GetFileNameFail'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFile'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFolder'), $html);
+ while (strpos($html, '')) $html = str_replace('', getconstStr('FileSelected'), $html);
+ while (strpos($html, '')) $html = str_replace('', (isset($_GET['preview'])?'?preview&':'?'), $html);
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (getConfig('background')) {
+ $html .= str_replace('', getConfig('background'), $tmp[0]);
+ }
+ $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (getConfig('backgroundm')) {
+ $html .= str_replace('', getConfig('backgroundm'), $tmp[0]);
+ }
+ $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ if ($tmp[1]!='') {
+ $tmp = splitfirst($tmp[1], '');
+ $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('', ($folder1==$files['name']?'':$tmp_url), $PathArrayStr);
+ $PathArrayStr1 = str_replace('', $folder1, $PathArrayStr1);
+ $html .= $PathArrayStr1;
+ }
+ $tmp_path = $tmp1[1];
+ }
+ $html .= $tmp[1];
+ }
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ if ($tmp[1]!='') {
+ $tmp = splitfirst($tmp[1], '');
+ $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('', ($folder1==$files['name']?'':$tmp_url), $PathArrayStr);
+ $PathArrayStr1 = str_replace('', ($folder1==$_SERVER['disktag']?(getConfig('diskname')==''?$_SERVER['disktag']:getConfig('diskname')):$folder1), $PathArrayStr1);
+ $html .= $PathArrayStr1;
+ }
+ $tmp_path = $tmp1[1];
+ }
+ $html .= $tmp[1];
+ }
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $SelectLanguage = $tmp[0];
+ foreach ($constStr['languages'] as $key1 => $value1) {
+ $SelectLanguageStr = str_replace('', $key1, $SelectLanguage);
+ $SelectLanguageStr = str_replace('', $value1, $SelectLanguageStr);
+ $SelectLanguageStr = str_replace('', ($key1==$constStr['language']?'selected="selected"':''), $SelectLanguageStr);
+ $html .= $SelectLanguageStr;
+ }
+ $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $NeedUpdateStr = $tmp[0];
+ if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) $NeedUpdateStr = str_replace('', getconstStr('NeedUpdate'), $NeedUpdateStr);
+ else $NeedUpdateStr ='';
+ $html .= $NeedUpdateStr . $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $current_url = path_format($_SERVER['PHP_SELF'] . '/');
+ if ($current_url !== $_SERVER['base_path']) {
+ 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('', $parent_url.'/', $tmp[0]);
+ }
+ $html .= $BackArrow . $tmp[1];
+
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ //if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) {
+ if (!getConfig('disableShowThumb')) {
+ $html .= str_replace('', getconstStr('OriginalPic'), $tmp[0]) . $tmp[1];
+ } else $html .= $tmp[1];
+ }
+ $imgextstr = '';
+ foreach ($exts['img'] as $imgext) $imgextstr .= '\''.$imgext.'\', ';
+ $html = str_replace('', $imgextstr, $html);
+
+
+ $html = str_replace('', $_SERVER['sitename'], $html);
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $disktags = explode("|",getConfig('disktag'));
+ if (count($disktags)>1) {
+ $tmp1 = $tmp[1];
+ $tmp = splitfirst($tmp[0], '');
+ $MultiDiskArea = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $MultiDisks = $tmp[0];
+ foreach ($disktags as $disk) {
+ $diskname = getConfig('diskname', $disk);
+ if ($diskname=='') $diskname = $disk;
+ $MultiDisksStr = str_replace('', path_format($_SERVER['base_path'].'/'.$disk.'/'), $MultiDisks);
+ $MultiDisksStr = str_replace('', ($_SERVER['disktag']==$disk?' now':''), $MultiDisksStr);
+ $MultiDisksStr = str_replace('', $diskname, $MultiDisksStr);
+ $MultiDiskArea .= $MultiDisksStr;
+ }
+ $MultiDiskArea .= $tmp[1];
+ $tmp[1] = $tmp1;
+ }
+ $html .= $MultiDiskArea . $tmp[1];
+ $diskname = getConfig('diskname');
+ if ($diskname=='') $diskname = $_SERVER['disktag'];
+ //if (strlen($diskname)>15) $diskname = substr($diskname, 0, 12).'...';
+ while (strpos($html, '')) $html = str_replace('', $diskname, $html);
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (isset($files['children']['head.omf'])) {
+ $headomf = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/head.omf'),'/'))['content']['body'], $tmp[0]);
+ }
+ $html .= $headomf . $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (isset($files['children']['head.md'])) {
+ $headmd = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/head.md'),'/'))['content']['body'], $tmp[0]);
+ $html .= $headmd . $tmp[1];
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ } else {
+ $html .= $tmp[1];
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html_aft = $tmp[1];
+ if ($files) {
+ $listarea = $tmp[0];
+ }
+ $html .= $listarea . $html_aft;
+ }
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (isset($files['children']['readme.md'])) {
+ $Readmemd = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/readme.md'),'/'))['content']['body'], $tmp[0]);
+ $html .= $Readmemd . $tmp[1];
+ while (strpos($html, '')) {
+ $html = str_replace('', '', $html);
+ $html = str_replace('', '', $html);
+ }
+ } else {
+ $html .= $tmp[1];
+ $tmp[1] = 'a';
+ while ($tmp[1]!='') {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+ }
+
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (isset($files['children']['foot.omf'])) {
+ $Footomf = str_replace('', fetch_files(spurlencode(path_format(urldecode($path) . '/foot.omf'),'/'))['content']['body'], $tmp[0]);
+ }
+ $html .= $Footomf . $tmp[1];
+
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ 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, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= str_replace('', getconstStr('Encrypt'), $tmp[0]) . $tmp[1];
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ } else {
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= str_replace('', getconstStr('SetpassfileBfEncrypt'), $tmp[0]) . $tmp[1];
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $html .= $tmp[1];
+ }
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if ($path != '/') {
+ $html .= str_replace('', getconstStr('ParentDir'), $tmp[0]) . $tmp[1];
+ } else $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ $MoveDirs = $tmp[0];
+ if (isset($files['children'])) {
+ foreach ($files['children'] as $file) {
+ if (isset($file['folder'])) {
+ $MoveDirsStr = str_replace('', str_replace('&','&', $file['name']), $MoveDirs);
+ $MoveDirsStr = str_replace('', str_replace('&','&', $file['name']), $MoveDirsStr);
+ $html .= $MoveDirsStr;
+ }
+ }
+ }
+ $html .= $tmp[1];
+
+ $tmp = splitfirst($html, '');
+ $html = $tmp[0];
+ $tmp = splitfirst($tmp[1], '');
+ if (!isset($_COOKIE['timezone'])) $html .= str_replace('', $_SERVER['timezone'], $tmp[0]);
+ $html .= $tmp[1];
+ while (strpos($html, '')) $html = str_replace('', $_SERVER['timezone'], $html);
+
+ 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);
+ }
+
+ // 最后清除换行
+ while (strpos($html, "\r\n\r\n")) $html = str_replace("\r\n\r\n", "\r\n", $html);
+ //while (strpos($html, "\r\r")) $html = str_replace("\r\r", "\r", $html);
+ while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html);
+ //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);
+ $html = str_replace('', date("Y-m-d H:i:s")." ".getconstStr('Week')[date("w")]." ".$_SERVER['REMOTE_ADDR'].' Runningtime:'.$exetime.'s Mem:'.size_format(memory_get_usage()), $html);
+ }
+
+ if ($_SERVER['admin']||!getConfig('disableChangeTheme')) {
+ $theme_arr = scandir(__DIR__.'/theme');
+ $html .= '
+
+
+ '.getconstStr('Theme').' ';
+ foreach ($theme_arr as $v1) {
+ if ($v1!='.' && $v1!='..') $html .= '
+ '.$v1.' ';
+ }
+ $html .= '
+
+
+';
+ }
+
+ $html = $authinfo . $html;
+ if (isset($_SERVER['Set-Cookie'])) return output($html, $statusCode, [ 'Set-Cookie' => $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]);
+ return output($html,$statusCode);
+}
diff --git a/config.php b/config.php
new file mode 100644
index 0000000..4fe2ccb
--- /dev/null
+++ b/config.php
@@ -0,0 +1,4 @@
+ [
+ 'en-us' => 'English',
+ 'zh-cn' => '简体中文',
+ 'ja' => '日本語',
+ 'ko-kr' => '한국어',
+ 'fa' => 'فارسی',
+ ],
+ 'Week' => [
+ 'en-us' => [
+ 0 => 'Sunday',
+ 1 => 'Monday',
+ 2 => 'Tuesday',
+ 3 => 'Wednesday',
+ 4 => 'Thursday',
+ 5 => 'Friday',
+ 6 => 'Saturday',
+ ],
+ 'zh-cn' => [
+ 0 => '星期日',
+ 1 => '星期一',
+ 2 => '星期二',
+ 3 => '星期三',
+ 4 => '星期四',
+ 5 => '星期五',
+ 6 => '星期六',
+ ],
+ 'ja' => [
+ 0 => '日曜日',
+ 1 => '月曜日',
+ 2 => '火曜日',
+ 3 => '水曜日',
+ 4 => '木曜日',
+ 5 => '金曜日',
+ 6 => '土曜日',
+ ],
+ 'ko-kr' => [
+ 0 => '일요일',
+ 1 => '월요일',
+ 2 => '화요일',
+ 3 => '수요일',
+ 4 => '목요일',
+ 5 => '금요일',
+ 6 => '토요일',
+ ],
+ 'fa' => [
+ 0 => 'یکشنبه',
+ 1 => 'دوشنبه',
+ 2 => 'سه شنبه',
+ 3 => 'چهارشنبه',
+ 4 => 'پنج شنبه',
+ 5 => 'جمعه',
+ 6 => 'شنبه',
+ ],
+ ],
+ 'EnvironmentsDescription' => [
+ 'en-us' => [
+ 'admin' => 'The admin password, Login button will not show when empty',
+ 'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.',
+ 'autoJumpFirstDisk' => 'used in multy disks, if 1, auto jump to first disk',
+ 'customScript' => '
+ ', 'Program updating', 201);
+ }
+ return output('Jump
+
+ ', 302);
+ }
+ if ($_GET['install1']) {
+ //if ($_POST['admin']!='') {
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $AccessKeyID = getConfig('AccessKeyID');
+ if ($AccessKeyID=='') {
+ $AccessKeyID = $_POST['AccessKeyID'];
+ $tmp['AccessKeyID'] = $AccessKeyID;
+ }
+ $AccessKeySecret = getConfig('AccessKeySecret');
+ if ($AccessKeySecret=='') {
+ $AccessKeySecret = $_POST['AccessKeySecret'];
+ $tmp['AccessKeySecret'] = $AccessKeySecret;
+ }
+ $response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], $AccessKeyID, $AccessKeySecret) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ //}
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function FCAPI2016($config, $Method, $data = '')
+{
+ $accountId = $config['accountId'];
+ $region = $config['region'];
+ $service_name = $config['service_name'];
+ $function_name = $config['function_name'];
+ $AccessKeyID = $config['AccessKeyID'];
+ $AccessKeySecret = $config['AccessKeySecret'];
+
+ $host = $accountId . '.' . $region . '-internal.fc.aliyuncs.com';
+ $path = '/2016-08-15/services/' . $service_name . '/functions/' . $function_name;
+ $url = 'https://' . $host . $path;
+
+ $ContentMd5 = '';
+ $ContentType = 'application/json';
+ date_default_timezone_set('UTC'); // unset last timezone setting
+ $Date = substr(gmdate("r", time()), 0, -5) . 'GMT';
+ $CanonicalizedFCHeaders = '';
+ $CanonicalizedResource = $path;
+
+ $signaturestr = $Method . "\n" . $ContentMd5 . "\n" . $ContentType . "\n" . $Date . "\n" . $CanonicalizedFCHeaders . $CanonicalizedResource;
+ $signature = base64_encode(hash_hmac('sha256', $signaturestr, $AccessKeySecret, true));
+
+ $header['Host'] = $host;
+ $header['Date'] = $Date;
+ $header['Content-Type'] = $ContentType;
+ $header['Authorization'] = 'FC ' . $AccessKeyID . ':' . $signature;
+ $header['Content-Length'] = strlen($data);
+
+ //return curl($Method, $url, $data, $header)['body'];
+ $p = 0;
+ while ($response['stat']==0 && $p<3) {
+ $response = curl($Method, $url, $data, $header);
+ $p++;
+ }
+
+ if ($response['stat']==0) {
+ $tmp['ErrorCode'] = 'Network Error';
+ $tmp['ErrorMessage'] = 'Can not connect ' . $host;
+ return json_encode($tmp);
+ }
+ if ($response['stat']!=200) {
+ $tmp = json_decode($response['body'], true);
+ $tmp['ErrorMessage'] .= ' ' . $response['stat'] . ' ' . $signaturestr . ' ' . json_encode($header) . PHP_EOL;
+ return json_encode($tmp);
+ }
+ return $response['body'];
+}
+
+function getfunctioninfo($config)
+{
+ return FCAPI2016($config, 'GET');
+}
+
+function updateEnvironment($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
+{
+ //print_r($Envs);
+ $config['accountId'] = $accountId;
+ $config['region'] = $region;
+ $config['service_name'] = $service_name;
+ $config['function_name'] = $function_name;
+ $config['AccessKeyID'] = $AccessKeyID;
+ $config['AccessKeySecret'] = $AccessKeySecret;
+
+ $tmp = json_decode(getfunctioninfo($config), true);
+ foreach ($tmp['environmentVariables'] as $key => $value ) {
+ $tmp_env[$key] = $value;
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmpdata['environmentVariables'] = $tmp_env;
+ return FCAPI2016($config, 'PUT', json_encode($tmpdata));
+}
+
+function SetbaseConfig($Envs, $accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret)
+{
+ $config['accountId'] = $accountId;
+ $config['region'] = $region;
+ $config['service_name'] = $service_name;
+ $config['function_name'] = $function_name;
+ $config['AccessKeyID'] = $AccessKeyID;
+ $config['AccessKeySecret'] = $AccessKeySecret;
+
+ $tmp = json_decode(getfunctioninfo($config), true);
+ foreach ($tmp['environmentVariables'] as $key => $value ) {
+ $tmp_env[$key] = $value;
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmpdata['description'] = 'Onedrive index and manager in Aliyun FC.';
+ $tmpdata['memorySize'] = 128;
+ $tmpdata['timeout'] = 30;
+ $tmpdata['environmentVariables'] = $tmp_env;
+
+ return FCAPI2016($config, 'PUT', json_encode($tmpdata));
+}
+
+function updateProgram($accountId, $region, $service_name, $function_name, $AccessKeyID, $AccessKeySecret, $source)
+{
+ $config['accountId'] = $accountId;
+ $config['region'] = $region;
+ $config['service_name'] = $service_name;
+ $config['function_name'] = $function_name;
+ $config['AccessKeyID'] = $AccessKeyID;
+ $config['AccessKeySecret'] = $AccessKeySecret;
+
+ $tmp = json_decode(getfunctioninfo($config), true);
+
+ $tmpdata['code']['zipFile'] = base64_encode( file_get_contents($source) );
+
+ return FCAPI2016($config, 'PUT', json_encode($tmpdata));
+}
+
+function api_error($response)
+{
+ return isset($response['ErrorMessage']);
+}
+
+function api_error_msg($response)
+{
+ return $response['ErrorCode'] . '
+' . $response['ErrorMessage'] . '
+
+accountId:' . $_SERVER['accountId'] . '
+region:' . $_SERVER['region'] . '
+service_name:' . $_SERVER['service_name'] . '
+function_name:' . $_SERVER['function_name'] . '
+
+'.getconstStr('Refresh').' ';
+}
+
+function setConfigResponse($response)
+{
+ return json_decode($response, true);
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/';
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ $tarfile = '/tmp/github.tar.gz';
+ file_put_contents($tarfile, file_get_contents($url));
+ $phar = new PharData($tarfile);
+ $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
+
+ // 获取解压出的目录名
+/*
+ @ob_start();
+ passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
+ $html.='状态:' . $stat . '
+ 结果:
+ ';
+ $archivefolder = ob_get_clean();
+ if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
+ $outPath .= $archivefolder;
+ $html.=htmlspecialchars($archivefolder);
+ //return $html;
+*/
+ $tmp = scandir($outPath);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath .= $f;
+ break;
+ }
+ }
+
+ // 将目录中文件打包成zip
+ $zip=new ZipArchive();
+ if($zip->open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ $zip->close(); //关闭处理的zip文件
+ }
+
+ return updateProgram($_SERVER['accountId'], $_SERVER['region'], $_SERVER['service_name'], $_SERVER['function_name'], getConfig('AccessKeyID'), getConfig('AccessKeySecret'), $source);
+}
+
+function addFileToZip($zip, $rootpath, $path = '')
+{
+ if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
+ if (substr($path,0,1)=='/') $path = substr($path, 1);
+ $handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
+ while($filename=readdir($handler)){
+ if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
+ $nowname = path_format($rootpath.'/'.$path."/".$filename);
+ if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
+ addFileToZip($zip, $rootpath, $path."/".$filename);
+ }else{ //将文件加入zip对象
+ $zip->addFile($nowname);
+ $newname = $path."/".$filename;
+ if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
+ $zip->renameName($nowname, $newname);
+ }
+ }
+ }
+ @closedir($path);
+}
diff --git a/platform/BaiduCFC.php b/platform/BaiduCFC.php
new file mode 100644
index 0000000..78a2128
--- /dev/null
+++ b/platform/BaiduCFC.php
@@ -0,0 +1,407 @@
+500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
+ echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
+
+' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
+
+';
+}
+
+function GetGlobalVariable($event)
+{
+ $_GET = $event['queryStringParameters'];
+ foreach ($_GET as $k => $v) {
+ if ($v == '') $_GET[$k] = true;
+ }
+ $postbody = explode("&",$event['body']);
+ foreach ($postbody as $postvalues) {
+ $pos = strpos($postvalues,"=");
+ $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
+ }
+ $cookiebody = explode("; ",$event['headers']['Cookie']);
+ foreach ($cookiebody as $cookievalues) {
+ $pos = strpos($cookievalues,"=");
+ $_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
+ }
+ $_SERVER['HTTP_USER_AGENT'] = $event['headers']['User-Agent'];
+ $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
+ $_SERVER['BCE_CFC_RUNTIME_NAME'] = 'php7';
+}
+
+function GetPathSetting($event, $context)
+{
+ $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['Accept-Language'],';')[0],',')[0]);
+ $_SERVER['functionBrn'] = $context['functionBrn'];
+ $_SERVER['base_path'] = '/';
+ $path = $event['path'];
+ if (substr($path,-1)=='/') $path=substr($path,0,-1);
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['X-Requested-With'];
+ return $path;
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $env = json_decode(getenv($disktag), true);
+ if (isset($env[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
+ else return $env[$str];
+ }
+ } else {
+ if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
+ else return getenv($str);
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $disktags = explode("|",getConfig('disktag'));
+ $diskconfig = json_decode(getenv($disktag), true);
+ $tmp = [];
+ $indisk = 0;
+ $oparetdisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
+ else $diskconfig[$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $oparetdisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $tmp[$v] = '';
+ $oparetdisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
+ else $tmp[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }
+ if ($oparetdisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
+ else $tmp['disktag'] = '';
+ }
+// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
+//';
+ $response = updateEnvironment($tmp, getConfig('SecretId'), getConfig('SecretKey'));
+ return $response;
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install2']) {
+ $tmp['admin'] = $_POST['admin'];
+ $response = setConfigResponse( setConfig($tmp) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ if (needUpdate()) {
+ OnekeyUpate();
+ return message('update to github version, reinstall.
+
+ ', 'Program updating', 201);
+ }
+ return output('Jump
+
+ ', 302);
+ }
+ if ($_GET['install1']) {
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $SecretId = getConfig('SecretId');
+ if ($SecretId=='') {
+ $SecretId = $_POST['SecretId'];
+ $tmp['SecretId'] = $SecretId;
+ }
+ $SecretKey = getConfig('SecretKey');
+ if ($SecretKey=='') {
+ $SecretKey = $_POST['SecretKey'];
+ $tmp['SecretKey'] = $SecretKey;
+ }
+ $response = setConfigResponse(SetbaseConfig($tmp, $SecretId, $SecretKey));
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function CFCAPIv1($Brn, $AccessKey, $SecretKey, $Method, $End, $data = '')
+{
+ // brn:bce:cfc:bj:c094b1ca1XXXXXXXXb8dea6ab482:function:fdsa:$LATEST
+ $BRN = explode(':', $Brn);
+ if ( !($BRN[0]=='brn' && $BRN[1]=='bce' && $BRN[2]=='cfc') ) {
+ $tmp['code'] = 'BRN Error';
+ $tmp['message'] = 'The BRN expect start with "brn:bce:cfc:", given: ' . $Brn . ' .';
+ return json_encode($tmp);
+ }
+ $Region = $BRN[3];
+ //$project_id = $BRN[4];
+ $FunctionName = $BRN[6];
+ $host = 'cfc.' . $Region . '.baidubce.com';
+ date_default_timezone_set('UTC'); // unset last timezone setting
+ $timestamp = date('Y-m-d\TH:i:s\Z');
+ //date_default_timezone_set(get_timezone($_SERVER['timezone']));
+ $authStringPrefix = 'bce-auth-v1/' . $AccessKey . '/' . $timestamp . '/1800' ;
+ $path = '/v1/functions/' . $FunctionName . '/' . $End;
+ $CanonicalURI = spurlencode($path, '/');
+ $CanonicalQueryString = '';
+ $CanonicalHeaders = 'host:' . $host;
+ $CanonicalRequest = $Method . "\n" . $CanonicalURI . "\n" . $CanonicalQueryString . "\n" . $CanonicalHeaders;
+ $SigningKey = hash_hmac('sha256', $authStringPrefix, $SecretKey);
+ $Signature = hash_hmac('sha256', $CanonicalRequest, $SigningKey);
+ $authorization = $authStringPrefix . '/host/' . $Signature;
+
+ $p = 0;
+ while ($response['stat']==0 && $p<3) {
+ $response = curl(
+ $Method,
+ 'https://' . $host . $path,
+ $data,
+ [
+ 'Authorization' => $authorization,
+ 'Content-type' => 'application/json'
+ ]
+ );
+ $p++;
+ }
+
+ if ($response['stat']==0) {
+ $tmp['code'] = 'Network Error';
+ $tmp['message'] = 'Can not connect ' . $host;
+ return json_encode($tmp);
+ }
+ if ($response['stat']!=200) {
+ $tmp = json_decode($response['body'], true);
+ $tmp['message'] .= ' ' . $response['stat'] . ' ' . $timestamp . PHP_EOL;
+ return json_encode($tmp);
+ }
+ return $response['body'];
+}
+
+function getfunctioninfo($SecretId, $SecretKey)
+{
+ return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'GET', 'configuration');
+}
+
+function updateEnvironment($Envs, $SecretId, $SecretKey)
+{
+ $FunctionConfig = json_decode(getfunctioninfo($SecretId, $SecretKey), true);
+ $tmp_env = $FunctionConfig['Environment']['Variables'];
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmp['Environment']['Variables'] = $tmp_env;
+ $data = json_encode($tmp);
+
+ return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'configuration', $data);
+}
+
+function SetbaseConfig($Envs, $SecretId, $SecretKey)
+{
+ $FunctionConfig = json_decode(getfunctioninfo($SecretId, $SecretKey), true);
+ $tmp_env = $FunctionConfig['Environment']['Variables'];
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmp['Timeout'] = 30;
+ $tmp['Description'] = 'Onedrive index and manager in Baidu CFC.';
+ $tmp['Environment']['Variables'] = $tmp_env;
+ $data = json_encode($tmp);
+
+ return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'configuration', $data);
+}
+
+function updateProgram($SecretId, $SecretKey, $source)
+{
+ $tmp['ZipFile'] = base64_encode( file_get_contents($source) );
+ $data = json_encode($tmp);
+ return CFCAPIv1($_SERVER['functionBrn'], $SecretId, $SecretKey, 'PUT', 'code', $data);
+}
+
+function api_error($response)
+{
+ //return isset($response['code']);
+ return !(isset($response['FunctionBrn']) && $response['FunctionBrn'] == $_SERVER['functionBrn']);
+}
+
+function api_error_msg($response)
+{
+ if (isset($response['code'])) $html = $response['code'] . '
+' . $response['message'];
+ else $html = var_dump($response);
+ return $html . '
+BRN: ' . $_SERVER['functionBrn'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function setConfigResponse($response)
+{
+ //return $response;
+ return json_decode( $response, true );
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/';
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ $tarfile = '/tmp/github.tar.gz';
+ file_put_contents($tarfile, file_get_contents($url));
+ $phar = new PharData($tarfile);
+ $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
+
+ // 获取包中目录名
+ $tmp = scandir('phar://'.$tarfile);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath .= $f;
+ break;
+ }
+ }
+ // 放入配置文件
+ //file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
+
+ // 将目录中文件打包成zip
+ //$zip=new ZipArchive();
+ $zip=new PharData($source);
+ //if($zip->open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ // $zip->close(); //关闭处理的zip文件
+ //}
+
+ return updateProgram(getConfig('SecretId'), getConfig('SecretKey'), $source);
+}
+
+function addFileToZip($zip, $rootpath, $path = '')
+{
+ if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
+ if (substr($path,0,1)=='/') $path = substr($path, 1);
+ $handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
+ while($filename=readdir($handler)){
+ if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
+ $nowname = path_format($rootpath.'/'.$path."/".$filename);
+ if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
+ $zip->addEmptyDir($path."/".$filename);
+ addFileToZip($zip, $rootpath, $path."/".$filename);
+ }else{ //将文件加入zip对象
+ $newname = $path."/".$filename;
+ if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
+ $zip->addFile($nowname, $newname);
+ //$zip->renameName($nowname, $newname);
+ }
+ }
+ }
+ @closedir($path);
+}
diff --git a/platform/Heroku.php b/platform/Heroku.php
new file mode 100644
index 0000000..81ddde0
--- /dev/null
+++ b/platform/Heroku.php
@@ -0,0 +1,270 @@
+0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
+ else $path = $_SERVER['REQUEST_URI'];
+ $path = path_format( substr($path, strlen($_SERVER['base_path'])) );
+ return substr($path, 1);
+ //return spurlencode($path, '/');
+}
+
+function getGET()
+{
+ $p = strpos($_SERVER['REQUEST_URI'],'?');
+ if ($p>0) {
+ $getstr = substr($_SERVER['REQUEST_URI'], $p+1);
+ $getstrarr = explode("&",$getstr);
+ foreach ($getstrarr as $getvalues) {
+ if ($getvalues != '') {
+ $pos = strpos($getvalues, "=");
+ //echo $pos;
+ if ($pos > 0) {
+ $getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
+ } else {
+ $getarry[urldecode($getvalues)] = true;
+ }
+ }
+ }
+ }
+ if (isset($getarry)) {
+ return $getarry;
+ } else {
+ return [];
+ }
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $env = json_decode(getenv($disktag), true);
+ if (isset($env[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
+ else return $env[$str];
+ }
+ } else {
+ if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
+ else return getenv($str);
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $disktags = explode("|",getConfig('disktag'));
+ $diskconfig = json_decode(getenv($disktag), true);
+ $tmp = [];
+ $indisk = 0;
+ $oparetdisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
+ else $diskconfig[$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $oparetdisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $tmp[$v] = '';
+ $oparetdisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
+ else $tmp[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }
+ if ($oparetdisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
+ else $tmp['disktag'] = '';
+ }
+ foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
+// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
+//';
+ return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install1']) {
+ if ($_POST['admin']!='') {
+ $tmp['admin'] = $_POST['admin'];
+ //$tmp['language'] = $_POST['language'];
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $APIKey = getConfig('APIKey');
+ if ($APIKey=='') {
+ $APIKey = $_POST['APIKey'];
+ $tmp['APIKey'] = $APIKey;
+ }
+ $function_name = getConfig('function_name');
+ if ($function_name=='') {
+ $tmp1 = substr($_SERVER['HTTP_HOST'], 0, strrpos($_SERVER['HTTP_HOST'], '.'));
+ $maindomain = substr($tmp1, strrpos($tmp1, '.')+1);
+ if ($maindomain=='herokuapp') $function_name = substr($tmp1, 0, strrpos($tmp1, '.'));
+ else $function_name = 'visit from xxxx.herokuapp.com';
+ $tmp['function_name'] = $function_name;
+ }
+ $response = json_decode(setHerokuConfig($tmp, $function_name, $APIKey)['body'], true);
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ } else {
+ return output('Jump
+
+ ', 302);
+ }
+ return message($html, $title, 201);
+ }
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function HerokuAPI($method, $url, $data = '', $apikey)
+{
+ if ($method=='PATCH'||$method=='POST') {
+ $headers['Content-Type'] = 'application/json';
+ }
+ $headers['Authorization'] = 'Bearer ' . $apikey;
+ $headers['Accept'] = 'application/vnd.heroku+json; version=3';
+ //if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
+ //if (!isset($headers['Referer'])) $headers['Referer'] = $url;
+ $sendHeaders = array();
+ foreach ($headers as $headerName => $headerVal) {
+ $sendHeaders[] = $headerName . ': ' . $headerVal;
+ }
+ error_log($method . $url . $data . $apikey);
+ $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);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
+ $response['body'] = curl_exec($ch);
+ $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ error_log($response['stat'].'
+'.$response['body'].'
+');
+ return $response;
+}
+
+function getHerokuConfig($function_name, $apikey)
+{
+ return HerokuAPI('GET', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', '', $apikey);
+}
+
+function setHerokuConfig($env, $function_name, $apikey)
+{
+ $data = json_encode($env);
+ return HerokuAPI('PATCH', 'https://api.heroku.com/apps/' . $function_name . '/config-vars', $data, $apikey);
+}
+
+function updateHerokuapp($function_name, $apikey, $source)
+{
+ $tmp['source_blob']['url'] = $source;
+ $data = json_encode($tmp);
+ return HerokuAPI('POST', 'https://api.heroku.com/apps/' . $function_name . '/builds', $data, $apikey);
+}
+
+function api_error($response)
+{
+ return isset($response['id'])&&isset($response['message']);
+}
+
+function api_error_msg($response)
+{
+ return $response['id'] . '
+' . $response['message'] . '
+function_name:' . $_SERVER['function_name'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ //'https://github.com/qkqpttgf/OneManager-php/tarball/master/';
+ $source = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ return updateHerokuapp(getConfig('function_name'), getConfig('APIKey'), $source);
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response['body'], true );
+}
diff --git a/platform/HuaweiFG_env.php b/platform/HuaweiFG_env.php
new file mode 100644
index 0000000..125ca42
--- /dev/null
+++ b/platform/HuaweiFG_env.php
@@ -0,0 +1,464 @@
+geteventID();
+ $tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
+ $tmp['AccessKey'] = $context->getAccessKey();
+ $tmp['SecretKey'] = $context->getSecretKey();
+ $tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
+ $tmp['FunctionName'] = $context->getFunctionName();
+ $tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
+ $tmp['Version'] = $context->getVersion();
+ $tmp['MemorySize'] = $context->getMemorySize();
+ $tmp['CPUNumber'] = $context->getCPUNumber();
+ $tmp['ProjectID'] = $context->getProjectID();
+ $tmp['Package'] = $context->Package();
+ $tmp['Token'] = $context->getToken();
+ $tmp['Logger'] = $context->getLogger();
+
+ if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
+ echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
+
+' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
+
+';
+}
+
+function GetGlobalVariable($event)
+{
+ $_GET = $event['queryStringParameters'];
+ $postbody = explode("&",$event['body']);
+ foreach ($postbody as $postvalues) {
+ $pos = strpos($postvalues,"=");
+ $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
+ }
+ $cookiebody = explode("; ",$event['headers']['cookie']);
+ foreach ($cookiebody as $cookievalues) {
+ $pos = strpos($cookievalues,"=");
+ $_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
+ }
+ $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
+ $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
+ $_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
+}
+
+function GetPathSetting($event, $context)
+{
+ $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
+ $_SERVER['function_name'] = $context->getFunctionName();
+ $_SERVER['ProjectID'] = $context->getProjectID();
+ $host_name = $event['headers']['host'];
+ $_SERVER['HTTP_HOST'] = $host_name;
+ $path = path_format($event['pathParameters'][''].'/');
+ $_SERVER['base_path'] = path_format($event['path'].'/');
+ if ( $_SERVER['base_path'] == $path ) {
+ $_SERVER['base_path'] = '/';
+ } else {
+ $_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
+ if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
+ }
+ if (substr($path,-1)=='/') $path=substr($path,0,-1);
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
+ return $path;
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ global $contextUserData;
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $env = json_decode($contextUserData->getUserData($disktag), true);
+ if (isset($env[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
+ else return $env[$str];
+ }
+ } else {
+ if (in_array($str, $Base64Env)) return base64y_decode($contextUserData->getUserData($str));
+ else return $contextUserData->getUserData($str);
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ global $contextUserData;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $disktags = explode("|",getConfig('disktag'));
+ $diskconfig = json_decode($contextUserData->getUserData($disktag), true);
+ $tmp = [];
+ $indisk = 0;
+ $oparetdisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
+ else $diskconfig[$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $oparetdisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $tmp[$v] = '';
+ $oparetdisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
+ else $tmp[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }
+ if ($oparetdisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
+ else $tmp['disktag'] = '';
+ }
+// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
+//';
+ $response = updateEnvironment($tmp, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
+ return $response;
+}
+
+function install()
+{
+ global $constStr;
+ global $contextUserData;
+ if ($_GET['install2']) {
+ $tmp['admin'] = $_POST['admin'];
+ $response = setConfigResponse( setConfig($tmp) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ if (needUpdate()) {
+ OnekeyUpate();
+ return message('update to github version, reinstall.
+
+ ', 'Program updating', 201);
+ }
+ return output('Jump
+
+ ', 302);
+ }
+ if ($_GET['install1']) {
+ //if ($_POST['admin']!='') {
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $tmp['HW_urn'] = getConfig('HW_urn');
+ if ($tmp['HW_urn']=='') {
+ $tmp['HW_urn'] = $_POST['HW_urn'];
+ }
+ $tmp['HW_key'] = getConfig('HW_key');
+ if ($tmp['HW_key']=='') {
+ $tmp['HW_key'] = $_POST['HW_key'];
+ }
+ $tmp['HW_secret'] = getConfig('HW_secret');
+ if ($tmp['HW_secret']=='') {
+ $tmp['HW_secret'] = $_POST['HW_secret'];
+ }
+ $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
+ //$response = json_decode(SetbaseConfig($tmp, $HW_urn, $HW_name, $HW_pwd), true)['Response'];
+ $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
+ $html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '' . getconstStr('Home') . ' ';
+ $title = 'Reinstall';
+ return message($html, $title, 201);
+ }
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ //}
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function FGAPIV2($HW_urn, $HW_key, $HW_secret, $Method, $End, $data = '')
+{
+ if ($HW_urn==''||$HW_key==''||$HW_secret=='') {
+ $tmp['error_code'] = 'Config Error';
+ $tmp['error_msg'] = 'HW urn or access key id or secret is empty.';
+ return json_encode($tmp);
+ }
+
+ $URN = explode(':', $HW_urn);
+ $Region = $URN[2];
+ $project_id = $URN[3];
+
+ $host = 'functiongraph.' . $Region . '.myhuaweicloud.com';
+ $path = '/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/' . $End;
+ $url = 'https://' . $host . $path;
+ $CanonicalURI = spurlencode($path, '/') . '/';
+ $CanonicalQueryString = '';
+
+ date_default_timezone_set('UTC'); // unset last timezone setting
+ $timestamp = date('Ymd\THis\Z');
+ $header['X-Sdk-Date'] = $timestamp;
+ $header['Host'] = $host;
+ $header['Content-Type'] = 'application/json;charset=utf8';
+ ksort($header);
+ $CanonicalHeaders = '';
+ $SignedHeaders = '';
+ foreach ($header as $key => $value) {
+ $CanonicalHeaders .= strtolower($key) . ':' . $value . "\n";
+ $SignedHeaders .= strtolower($key) . ';';
+ }
+ $SignedHeaders = substr($SignedHeaders, 0, -1);
+ $Hashedbody = hash("sha256", $data);
+ $CanonicalRequest = $Method . "\n" . $CanonicalURI . "\n" . $CanonicalQueryString . "\n" . $CanonicalHeaders . "\n" . $SignedHeaders . "\n" . $Hashedbody;
+ $HashedCanonicalRequest = hash("sha256", $CanonicalRequest);
+ $Algorithm = 'SDK-HMAC-SHA256';
+ $StringToSign = $Algorithm . "\n" . $timestamp . "\n" . $HashedCanonicalRequest;
+ $signature = hash_hmac("sha256", $StringToSign, $HW_secret);
+ $Authorization = "$Algorithm Access=$HW_key, SignedHeaders=$SignedHeaders, Signature=$signature";
+ $header['Authorization'] = $Authorization;
+
+ //return curl($Method, $url, $data, $header)['body']; // . $CanonicalRequest;
+ $p = 0;
+ while ($response['stat']==0 && $p<3) {
+ $response = curl($Method, $url, $data, $header);
+ $p++;
+ }
+
+ if ($response['stat']==0) {
+ $tmp['error_code'] = 'Network Error';
+ $tmp['error_msg'] = 'Can not connect ' . $host;
+ return json_encode($tmp);
+ }
+ if ($response['stat']!=200) {
+ $tmp = json_decode($response['body'], true);
+ $tmp['error_code'] .= '.';
+ $tmp['error_msg'] .= ' ' . $response['stat'] . ' ' . $CanonicalRequest . ' ' . json_encode($header) . PHP_EOL;
+ return json_encode($tmp);
+ }
+ return $response['body'];
+}
+
+function getfunctioninfo($HW_urn, $HW_key, $HW_secret)
+{
+ return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'GET', 'config');
+}
+
+function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
+{
+ //echo json_encode($Envs,JSON_PRETTY_PRINT);
+ global $contextUserData;
+ $tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmpdata['handler'] = 'index.handler';
+ $tmpdata['memory_size'] = $contextUserData->getMemorySize()+1-1;
+ $tmpdata['runtime'] = 'PHP7.3';
+ $tmpdata['timeout'] = $contextUserData->getRunningTimeInSeconds()+1-1;
+ $tmpdata['user_data'] = json_encode($tmp_env);
+
+ return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'config', json_encode($tmpdata));
+}
+
+function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
+{
+ //echo json_encode($Envs,JSON_PRETTY_PRINT);
+ if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
+ $tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+
+ $tmpdata['handler'] = 'index.handler';
+ $tmpdata['memory_size'] = 128;
+ $tmpdata['runtime'] = 'PHP7.3';
+ $tmpdata['timeout'] = 30;
+ $tmpdata['description'] = 'Onedrive index and manager in Huawei FG.';
+ $tmpdata['user_data'] = json_encode($tmp_env);
+
+ return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'config', json_encode($tmpdata));
+}
+
+function updateProgram($HW_urn, $HW_key, $HW_secret, $source)
+{
+ $tmpdata['code_type'] = 'zip';
+ $tmpdata['func_code']['file'] = base64_encode( file_get_contents($source) );
+
+ return FGAPIV2($HW_urn, $HW_key, $HW_secret, 'PUT', 'code', json_encode($tmpdata));
+}
+
+function api_error($response)
+{
+ return isset($response['error_msg']);
+}
+
+function api_error_msg($response)
+{
+ return $response['error_code'] . '
+' . $response['error_msg'] . '
+request_id: ' . $response['request_id'] . '
+function_name: ' . $_SERVER['function_name'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response, true );
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/';
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ $tarfile = '/tmp/github.tar.gz';
+ file_put_contents($tarfile, file_get_contents($url));
+ $phar = new PharData($tarfile);
+ $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
+
+ // 获取解压出的目录名
+ $tmp = scandir($outPath);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath .= $f;
+ break;
+ }
+ }
+
+ // 将目录中文件打包成zip
+ //$zip=new ZipArchive();
+ $zip=new PharData($source);
+ //if($zip->open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ // $zip->close(); //关闭处理的zip文件
+ //}
+
+ return updateProgram(getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'), $source);
+}
+
+function addFileToZip($zip, $rootpath, $path = '')
+{
+ if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
+ if (substr($path,0,1)=='/') $path = substr($path, 1);
+ $handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
+ while($filename=readdir($handler)){
+ if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
+ $nowname = path_format($rootpath.'/'.$path."/".$filename);
+ if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
+ $zip->addEmptyDir($path."/".$filename);
+ addFileToZip($zip, $rootpath, $path."/".$filename);
+ }else{ //将文件加入zip对象
+ $newname = $path."/".$filename;
+ if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
+ $zip->addFile($nowname, $newname);
+ //$zip->renameName($nowname, $newname);
+ }
+ }
+ }
+ @closedir($path);
+}
diff --git a/platform/HuaweiFG_file.php b/platform/HuaweiFG_file.php
new file mode 100644
index 0000000..0d78918
--- /dev/null
+++ b/platform/HuaweiFG_file.php
@@ -0,0 +1,840 @@
+geteventID();
+ $tmp['RemainingTimeInMilliSeconds'] = $context->getRemainingTimeInMilliSeconds();
+ $tmp['AccessKey'] = $context->getAccessKey();
+ $tmp['SecretKey'] = $context->getSecretKey();
+ $tmp['UserData']['HW_urn'] = $context->getUserData('HW_urn');
+ $tmp['FunctionName'] = $context->getFunctionName();
+ $tmp['RunningTimeInSeconds'] = $context->getRunningTimeInSeconds();
+ $tmp['Version'] = $context->getVersion();
+ $tmp['MemorySize'] = $context->getMemorySize();
+ $tmp['CPUNumber'] = $context->getCPUNumber();
+ $tmp['ProjectID'] = $context->getProjectID();
+ $tmp['Package'] = $context->Package();
+ $tmp['Token'] = $context->getToken();
+ $tmp['Logger'] = $context->getLogger();
+
+ if (strlen(json_encode($event['body']))>500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
+ echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
+
+' . urldecode(json_encode($tmp, JSON_PRETTY_PRINT)) . '
+
+';
+}
+
+function GetGlobalVariable($event)
+{
+ $_GET = $event['queryStringParameters'];
+ $postbody = explode("&",$event['body']);
+ foreach ($postbody as $postvalues) {
+ $pos = strpos($postvalues,"=");
+ $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
+ }
+ $cookiebody = explode("; ",$event['headers']['cookie']);
+ foreach ($cookiebody as $cookievalues) {
+ $pos = strpos($cookievalues,"=");
+ $_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
+ }
+ $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
+ $_SERVER['HTTP_TRANSLATE'] = $event['headers']['translate'];//'f'
+ $_SERVER['_APP_SHARE_DIR'] = '/var/share/CFF/processrouter';
+}
+
+function GetPathSetting($event, $context)
+{
+ $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
+ $_SERVER['function_name'] = $context->getFunctionName();
+ $_SERVER['ProjectID'] = $context->getProjectID();
+ $host_name = $event['headers']['host'];
+ $_SERVER['HTTP_HOST'] = $host_name;
+ $path = path_format($event['pathParameters'][''].'/');
+ $_SERVER['base_path'] = path_format($event['path'].'/');
+ if ( $_SERVER['base_path'] == $path ) {
+ $_SERVER['base_path'] = '/';
+ } else {
+ $_SERVER['base_path'] = substr($_SERVER['base_path'], 0, -strlen($path));
+ if ($_SERVER['base_path']=='') $_SERVER['base_path'] = '/';
+ }
+ if (substr($path,-1)=='/') $path=substr($path,0,-1);
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['REMOTE_ADDR'] = $event['headers']['x-real-ip'];
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
+ return $path;
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ //include 'config.php';
+ $s = file_get_contents(__DIR__ . '/../config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') {
+ $envs = json_decode($configs, true);
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ if (isset($envs[$disktag][$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
+ else return $envs[$disktag][$str];
+ }
+ } else {
+ if (isset($envs[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
+ else return $envs[$str];
+ }
+ }
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ //include 'config.php';
+ $s = file_get_contents(__DIR__ . '/../config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') $envs = json_decode($configs, true);
+ $disktags = explode("|",getConfig('disktag'));
+ $indisk = 0;
+ $operatedisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
+ else $envs[$disktag][$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $operatedisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $envs[$v] = '';
+ $operatedisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
+ else $envs[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = $envs[$disktag];
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $envs[$disktag] = $diskconfig;
+ }
+ if ($operatedisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
+ else $envs['disktag'] = '';
+ }
+ $envs = array_filter($envs, 'array_value_isnot_null');
+ ksort($envs);
+ $response = updateEnvironment($envs, getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'));
+ return $response;
+}
+
+function install()
+{
+ global $constStr;
+ global $contextUserData;
+ if ($_GET['install2']) {
+ $tmp['admin'] = $_POST['admin'];
+ $response = setConfigResponse( setConfig($tmp) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ if (needUpdate()) {
+ OnekeyUpate();
+ return message('update to github version, reinstall.
+
+ ', 'Program updating', 201);
+ }
+ return output('Jump
+
+ ', 302);
+ }
+ if ($_GET['install1']) {
+ //if ($_POST['admin']!='') {
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $tmp['HW_urn'] = getConfig('HW_urn');
+ if ($tmp['HW_urn']=='') {
+ $tmp['HW_urn'] = $_POST['HW_urn'];
+ }
+ $tmp['HW_key'] = getConfig('HW_key');
+ if ($tmp['HW_key']=='') {
+ $tmp['HW_key'] = $_POST['HW_key'];
+ }
+ $tmp['HW_secret'] = getConfig('HW_secret');
+ if ($tmp['HW_secret']=='') {
+ $tmp['HW_secret'] = $_POST['HW_secret'];
+ }
+ $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
+ //return message($html, $title, 201);
+ $response = setConfigResponse( SetbaseConfig($tmp, $tmp['HW_urn'], $tmp['HW_key'], $tmp['HW_secret']) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
+ $html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '' . getconstStr('Home') . ' ';
+ $title = 'Reinstall';
+ return message($html, $title, 201);
+ }
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ //}
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function getfunctioninfo($HW_urn, $HW_key, $HW_secret)
+{
+ $URN = explode(':', $HW_urn);
+ $Region = $URN[2];
+ $project_id = $URN[3];
+ $url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/config';
+ $signer = new Signer();
+ $signer->Key = $HW_key;
+ $signer->Secret = $HW_secret;
+ $req = new Request('GET', $url);
+ $req->headers = array(
+ 'content-type' => 'application/json;charset=utf8',
+ );
+ $req->body = '';
+ $curl = $signer->Sign($req);
+ $response = curl_exec($curl);
+ $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ curl_close($curl);
+ return $response;
+}
+
+function getfunctioncode($HW_urn, $HW_key, $HW_secret)
+{
+ $URN = explode(':', $HW_urn);
+ $Region = $URN[2];
+ $project_id = $URN[3];
+ $url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/code';
+ $signer = new Signer();
+ $signer->Key = $HW_key;
+ $signer->Secret = $HW_secret;
+ $req = new Request('GET', $url);
+ $req->headers = array(
+ 'content-type' => 'application/json;charset=utf8',
+ );
+ $req->body = '';
+ $curl = $signer->Sign($req);
+ $response = curl_exec($curl);
+ $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ curl_close($curl);
+ //return $response;
+ $url = json_decode($response, true)['func_code']['link'];
+ // return $url;
+
+
+ $bucket = splitfirst( splitfirst($url, '//')[1], '.')[0];
+ $path = splitfirst( splitfirst($url, '//')[1], '/')[1];
+ $date = gmdate('D, d M Y H:i:s') . ' GMT';
+ //$date = 'Wed, 05 Aug 2020 06:34:50 GMT';
+ $StringToSign = 'GET
+' . '
+' . '
+' . '
+' . 'x-obs-date:' . $date . '
+' . '/' . $bucket . '/' . $path;
+
+ $signature = base64_encode(hash_hmac('sha1', $StringToSign, $HW_secret, true));
+ $response = curl_request($url, false, [ 'Authorization' => 'OBS ' . $HW_key . ':' . $signature, 'x-obs-date' => $date, 'Content-Type' => '' ]);
+ //if ($response['stat']==200) return $response['body'];
+ if ($response['stat']==0) return json_encode( [ 'error_code' => 'Network', 'error_msg' => 'Network error in getting code.' ] );
+ else return $response['body'];
+}
+
+function copyFolder($from, $to)
+{
+ if (substr($from, -1)=='/') $from = substr($from, 0, -1);
+ if (substr($to, -1)=='/') $to = substr($to, 0, -1);
+ if (!file_exists($to)) mkdir($to, 0777);
+ $handler=opendir($from);
+ while($filename=readdir($handler)) {
+ if($filename != '.' && $filename != '..'){
+ $fromfile = $from.'/'.$filename;
+ $tofile = $to.'/'.$filename;
+ if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
+ copyFolder($fromfile, $tofile);
+ }else{
+ copy($fromfile, $tofile);
+ }
+ }
+ }
+ closedir($handler);
+ return 1;
+}
+
+function updateEnvironment($Envs, $HW_urn, $HW_key, $HW_secret)
+{
+
+ //echo json_encode($Envs,JSON_PRETTY_PRINT);
+ global $contextUserData;
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/code/';
+ $oldcode = '/tmp/oldcode.zip';
+
+ // 获取当前代码,并解压
+ $coderoot = __DIR__ . '/../';
+
+ copyFolder($coderoot, $outPath);
+
+ // 将配置写入
+ $prestr = 'open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ // $zip->close(); //关闭处理的zip文件
+ //}
+
+ return updateProgram($HW_urn, $HW_key, $HW_secret, $source);
+}
+
+function SetbaseConfig($Envs, $HW_urn, $HW_key, $HW_secret)
+{
+ //echo json_encode($Envs,JSON_PRETTY_PRINT);
+ if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
+ else {
+ $Envs['ONEMANAGER_CONFIG_SAVE'] == '';
+ $envs = $Envs;
+ $tmp_env = json_decode(json_decode(getfunctioninfo($HW_urn, $HW_key, $HW_secret),true)['user_data'],true);
+ foreach ($envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+ $envs = $tmp_env;
+ }
+
+ // https://functiongraph.cn-north-4.myhuaweicloud.com/v2/{project_id}/fgs/functions/{function_urn}/config
+ $URN = explode(':', $HW_urn);
+ $Region = $URN[2];
+ $project_id = $URN[3];
+ $url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/config';
+ $signer = new Signer();
+ $signer->Key = $HW_key;
+ $signer->Secret = $HW_secret;
+ $req = new Request('PUT', $url);
+ $req->headers = array(
+ 'content-type' => 'application/json;charset=utf8',
+ );
+ $tmpdata['handler'] = 'index.handler';
+ $tmpdata['memory_size'] = 128;
+ $tmpdata['runtime'] = 'PHP7.3';
+ $tmpdata['timeout'] = 30;
+ $tmpdata['description'] = 'Onedrive index and manager in Huawei FG.';
+ $tmpdata['user_data'] = json_encode($envs);
+ $req->body = json_encode($tmpdata);
+ $curl = $signer->Sign($req);
+ $response = curl_exec($curl);
+ $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ curl_close($curl);
+ //return $response;
+ if (api_error(setConfigResponse($response))) {
+ return $response;
+ }
+ $s = file_get_contents(__DIR__ . '/../config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') $tmp_env = json_decode($configs, true);
+ foreach ($Envs as $k => $v) {
+ $tmp_env[$k] = $v;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null');
+ ksort($tmp_env);
+ $response = updateEnvironment($tmp_env, $HW_urn, $HW_key, $HW_secret);
+ return $response;
+}
+
+function updateProgram($HW_urn, $HW_key, $HW_secret, $source)
+{
+ $URN = explode(':', $HW_urn);
+ $Region = $URN[2];
+ $project_id = $URN[3];
+ $url = 'https://functiongraph.' . $Region . '.myhuaweicloud.com/v2/' . $project_id . '/fgs/functions/' . $HW_urn . '/code';
+ $signer = new Signer();
+ $signer->Key = $HW_key;
+ $signer->Secret = $HW_secret;
+ $req = new Request('PUT', $url);
+ $req->headers = array(
+ 'content-type' => 'application/json;charset=utf8',
+ );
+ $tmpdata['code_type'] = 'zip';
+ $tmpdata['func_code']['file'] = base64_encode( file_get_contents($source) );
+ $req->body = json_encode($tmpdata);
+ $curl = $signer->Sign($req);
+ $response = curl_exec($curl);
+ $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ curl_close($curl);
+ return $response;
+}
+
+function api_error($response)
+{
+ return isset($response['error_code']);
+}
+
+function api_error_msg($response)
+{
+ return $response['error_code'] . '
+' . $response['error_msg'] . '
+request_id: ' . $response['request_id'] . '
+function_name: ' . $_SERVER['function_name'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response, true );
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/';
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ $tarfile = '/tmp/github.tar.gz';
+ file_put_contents($tarfile, file_get_contents($url));
+ $phar = new PharData($tarfile);
+ $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
+
+ // 获取解压出的目录名
+/*
+ @ob_start();
+ passthru('ls /tmp | grep '.$auth.'-'.$project.'',$stat);
+ $html.='状态:' . $stat . '
+ 结果:
+ ';
+ $archivefolder = ob_get_clean();
+ if (substr($archivefolder,-1)==PHP_EOL) $archivefolder = substr($archivefolder, 0, -1);
+ $outPath .= $archivefolder;
+ $html.=htmlspecialchars($archivefolder);
+ //return $html;
+*/
+ $tmp = scandir($outPath);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath .= $f;
+ break;
+ }
+ }
+
+ // 放入配置文件
+ file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
+
+ // 将目录中文件打包成zip
+ //$zip=new ZipArchive();
+ $zip=new PharData($source);
+ //if($zip->open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ // $zip->close(); //关闭处理的zip文件
+ //}
+
+ return updateProgram(getConfig('HW_urn'), getConfig('HW_key'), getConfig('HW_secret'), $source);
+}
+
+function addFileToZip($zip, $rootpath, $path = '')
+{
+ if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
+ if (substr($path,0,1)=='/') $path = substr($path, 1);
+ $handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
+ while($filename=readdir($handler)){
+ if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
+ $nowname = path_format($rootpath.'/'.$path."/".$filename);
+ if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
+ $zip->addEmptyDir($path."/".$filename);
+ addFileToZip($zip, $rootpath, $path."/".$filename);
+ }else{ //将文件加入zip对象
+ $newname = $path."/".$filename;
+ if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
+ $zip->addFile($nowname, $newname);
+ //$zip->renameName($nowname, $newname);
+ }
+ }
+ }
+ @closedir($path);
+}
+
+
+
+
+
+
+
+
+define("BasicDateFormat", "Ymd\THis\Z");
+define("Algorithm", "SDK-HMAC-SHA256");
+define("HeaderXDate", "X-Sdk-Date");
+define("HeaderHost", "host");
+define("HeaderAuthorization", "Authorization");
+define("HeaderContentSha256", "X-Sdk-Content-Sha256");
+
+class Request
+{
+ public $method = '';
+ public $scheme = '';
+ public $host = '';
+ public $uri = '';
+ public $query = array();
+ public $headers = array();
+ public $body = '';
+
+ function __construct()
+ {
+ $args = func_get_args();
+ $i = count($args);
+ if ($i == 0) {
+ $this->construct(NULL, NULL, NULL, NULL);
+ } elseif ($i == 1) {
+ $this->construct($args[0], NULL, NULL, NULL);
+ } elseif ($i == 2) {
+ $this->construct($args[0], $args[1], NULL, NULL);
+ } elseif ($i == 3) {
+ $this->construct($args[0], $args[1], $args[2], NULL);
+ } else {
+ $this->construct($args[0], $args[1], $args[2], $args[3]);
+ }
+ }
+
+ function construct($method, $url, $headers, $body)
+ {
+ if ($method != NULL) {
+ $this->method = $method;
+ }
+ if ($url != NULL) {
+ $spl = explode("://", $url, 2);
+ $scheme = 'http';
+ if (count($spl) > 1) {
+ $scheme = $spl[0];
+ $url = $spl[1];
+ }
+ $spl = explode("?", $url, 2);
+ $url = $spl[0];
+ $query = array();
+ if (count($spl) > 1) {
+ foreach (explode("&", $spl[1]) as $kv) {
+ $spl = explode("=", $kv, 2);
+ $key = $spl[0];
+ if (count($spl) == 1) {
+ $value = "";
+ } else {
+ $value = $spl[1];
+ }
+ if ($key != "") {
+ $key = urldecode($key);
+ $value = urldecode($value);
+ if (array_key_exists($key, $query)) {
+ array_push($query[$key], $value);
+ } else {
+ $query[$key] = array($value);
+ }
+ }
+ }
+ }
+ $spl = explode("/", $url, 2);
+ $host = $spl[0];
+ if (count($spl) == 1) {
+ $url = "/";
+ } else {
+ $url = "/" . $spl[1];
+ }
+ $this->scheme = $scheme;
+ $this->host = $host;
+ $this->uri = urldecode($url);
+ $this->query = $query;
+ }
+ if ($headers != NULL) {
+ $this->headers = $headers;
+ }
+ if ($body != NULL) {
+ $this->body = $body;
+ }
+ }
+}
+
+class Signer
+{
+ public $Key = '';
+ public $Secret = '';
+
+ function escape($string)
+ {
+ $entities = array('+', "%7E");
+ $replacements = array('%20', "~");
+ return str_replace($entities, $replacements, urlencode($string));
+ }
+
+ function findHeader($r, $header)
+ {
+ foreach ($r->headers as $key => $value) {
+ if (!strcasecmp($key, $header)) {
+ return $value;
+ }
+ }
+ return NULL;
+ }
+
+// Build a CanonicalRequest from a regular request string
+//
+// CanonicalRequest =
+// HTTPRequestMethod + '\n' +
+// CanonicalURI + '\n' +
+// CanonicalQueryString + '\n' +
+// CanonicalHeaders + '\n' +
+// SignedHeaders + '\n' +
+// HexEncode(Hash(RequestPayload))
+ function CanonicalRequest($r, $signedHeaders)
+ {
+ $CanonicalURI = $this->CanonicalURI($r);
+ $CanonicalQueryString = $this->CanonicalQueryString($r);
+ $canonicalHeaders = $this->CanonicalHeaders($r, $signedHeaders);
+ $signedHeadersString = join(";", $signedHeaders);
+ $hash = $this->findHeader($r, HeaderContentSha256);
+ if (!$hash) {
+ $hash = hash("sha256", $r->body);
+ }
+ return "$r->method\n$CanonicalURI\n$CanonicalQueryString\n$canonicalHeaders\n$signedHeadersString\n$hash";
+ }
+
+// CanonicalURI returns request uri
+ function CanonicalURI($r)
+ {
+ $pattens = explode("/", $r->uri);
+ $uri = array();
+ foreach ($pattens as $v) {
+ array_push($uri, $this->escape($v));
+ }
+ $urlpath = join("/", $uri);
+ if (substr($urlpath, -1) != "/") {
+ $urlpath = $urlpath . "/";
+ }
+ return $urlpath;
+ }
+
+// CanonicalQueryString
+ function CanonicalQueryString($r)
+ {
+ $keys = array();
+ foreach ($r->query as $key => $value) {
+ array_push($keys, $key);
+ }
+ sort($keys);
+ $a = array();
+ foreach ($keys as $key) {
+ $k = $this->escape($key);
+ $value = $r->query[$key];
+ if (is_array($value)) {
+ sort($value);
+ foreach ($value as $v) {
+ $kv = "$k=" . $this->escape($v);
+ array_push($a, $kv);
+ }
+ } else {
+ $kv = "$k=" . $this->escape($value);
+ array_push($a, $kv);
+ }
+ }
+ return join("&", $a);
+ }
+
+// CanonicalHeaders
+ function CanonicalHeaders($r, $signedHeaders)
+ {
+ $headers = array();
+ foreach ($r->headers as $key => $value) {
+ $headers[strtolower($key)] = trim($value);
+ }
+ $a = array();
+ foreach ($signedHeaders as $key) {
+ array_push($a, $key . ':' . $headers[$key]);
+ }
+ return join("\n", $a) . "\n";
+ }
+
+ function curlHeaders($r)
+ {
+ $header = array();
+ foreach ($r->headers as $key => $value) {
+ array_push($header, strtolower($key) . ':' . trim($value));
+ }
+ return $header;
+ }
+
+// SignedHeaders
+ function SignedHeaders($r)
+ {
+ $a = array();
+ foreach ($r->headers as $key => $value) {
+ array_push($a, strtolower($key));
+ }
+ sort($a);
+ return $a;
+ }
+
+// Create a "String to Sign".
+ function StringToSign($canonicalRequest, $t)
+ {
+ date_default_timezone_set('UTC');
+ $date = date(BasicDateFormat, $t);
+ $hash = hash("sha256", $canonicalRequest);
+ return "SDK-HMAC-SHA256\n$date\n$hash";
+ }
+
+// Create the HWS Signature.
+ function SignStringToSign($stringToSign, $signingKey)
+ {
+ return hash_hmac("sha256", $stringToSign, $signingKey);
+ }
+
+// Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign
+ function AuthHeaderValue($signature, $accessKey, $signedHeaders)
+ {
+ $signedHeadersString = join(";", $signedHeaders);
+ return "SDK-HMAC-SHA256 Access=$accessKey, SignedHeaders=$signedHeadersString, Signature=$signature";
+ }
+
+ public function Sign($r)
+ {
+ date_default_timezone_set('UTC');
+ $date = $this->findHeader($r, HeaderXDate);
+ if ($date) {
+ $t = date_timestamp_get(date_create_from_format(BasicDateFormat, $date));
+ }
+ if (!@$t) {
+ $t = time();
+ $r->headers[HeaderXDate] = date(BasicDateFormat, $t);
+ }
+ $queryString = $this->CanonicalQueryString($r);
+ if ($queryString != "") {
+ $queryString = "?" . $queryString;
+ }
+ $signedHeaders = $this->SignedHeaders($r);
+ $canonicalRequest = $this->CanonicalRequest($r, $signedHeaders);
+ $stringToSign = $this->StringToSign($canonicalRequest, $t);
+ $signature = $this->SignStringToSign($stringToSign, $this->Secret);
+ $authValue = $this->AuthHeaderValue($signature, $this->Key, $signedHeaders);
+ $r->headers[HeaderAuthorization] = $authValue;
+
+ $curl = curl_init();
+ $uri = str_replace(array("%2F"), array("/"), rawurlencode($r->uri));
+ $url = $r->scheme . '://' . $r->host . $uri . $queryString;
+ $headers = $this->curlHeaders($r);
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $r->method);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $r->body);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($curl, CURLOPT_NOBODY, FALSE);
+ return $curl;
+ }
+}
diff --git a/platform/Normal.php b/platform/Normal.php
new file mode 100644
index 0000000..d4e9a5b
--- /dev/null
+++ b/platform/Normal.php
@@ -0,0 +1,348 @@
+0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
+ else $path = $_SERVER['REQUEST_URI'];
+ $path = path_format( substr($path, strlen($_SERVER['base_path'])) );
+ return $path;
+ //return substr($path, 1);
+ //return spurlencode($path, '/');
+}
+
+function getGET()
+{
+ if (isset($_SERVER['UNENCODED_URL'])) $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
+ $p = strpos($_SERVER['REQUEST_URI'],'?');
+ if ($p>0) {
+ $getstr = substr($_SERVER['REQUEST_URI'], $p+1);
+ $getstrarr = explode("&",$getstr);
+ foreach ($getstrarr as $getvalues) {
+ if ($getvalues != '') {
+ $pos = strpos($getvalues, "=");
+ //echo $pos;
+ if ($pos > 0) {
+ $getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1));
+ } else {
+ $getarry[urldecode($getvalues)] = true;
+ }
+ }
+ }
+ }
+ if (isset($getarry)) {
+ return $getarry;
+ } else {
+ return [];
+ }
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ //include 'config.php';
+ $s = file_get_contents('config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') {
+ $envs = json_decode($configs, true);
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ if (isset($envs[$disktag][$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
+ else return $envs[$disktag][$str];
+ }
+ } else {
+ if (isset($envs[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
+ else return $envs[$str];
+ }
+ }
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ //include 'config.php';
+ $s = file_get_contents('config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') $envs = json_decode($configs, true);
+ $disktags = explode("|",getConfig('disktag'));
+ $indisk = 0;
+ $operatedisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
+ else $envs[$disktag][$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $operatedisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $envs[$v] = '';
+ $operatedisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
+ else $envs[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = $envs[$disktag];
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $envs[$disktag] = $diskconfig;
+ }
+ if ($operatedisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
+ else $envs['disktag'] = '';
+ }
+ $envs = array_filter($envs, 'array_value_isnot_null');
+ ksort($envs);
+ //echo ''. json_encode($envs, JSON_PRETTY_PRINT).' ';
+ $prestr = '0) return json_encode( [ 'response' => 'success' ] );
+ return json_encode( [ 'message' => 'Failed to write config.', 'code' => 'failed' ] );
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install2']) {
+ if ($_POST['admin']!='') {
+ $tmp['admin'] = $_POST['admin'];
+ //$tmp['language'] = $_COOKIE['language'];
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $response = setConfigResponse( setConfig($tmp) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ return output('Jump
+
+ ', 302);
+ }
+ }
+ }
+ if ($_GET['install1']) {
+ if (!ConfigWriteable()) {
+ $html .= getconstStr('MakesuerWriteable');
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ /*if (!RewriteEngineOn()) {
+ $html .= getconstStr('MakesuerRewriteOn');
+ $title = 'Error';
+ return message($html, $title, 201);
+ }*/
+ $html .= ''.getconstStr('MakesuerRewriteOn').'
+
+
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function ConfigWriteable()
+{
+ $t = md5( md5(time()).rand(1000,9999) );
+ $r = setConfig([ 'tmp' => $t ]);
+ $tmp = getConfig('tmp');
+ setConfig([ 'tmp' => '' ]);
+ if ($tmp == $t) return true;
+ if ($r) return true;
+ return false;
+}
+
+function RewriteEngineOn()
+{
+ $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
+ $tmpurl = $http_type . $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'];
+ $tmpurl .= path_format($_SERVER['base_path'] . '/config.php');
+ $tmp = curl_request($tmpurl);
+ if ($tmp['stat']==200) return false;
+ if ($tmp['stat']==201) return true; //when install return 201, after installed return 404 or 200;
+ return false;
+}
+
+function api_error($response)
+{
+ return isset($response['message']);
+}
+
+function api_error_msg($response)
+{
+ return $response['code'] . '
+' . $response['message'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function setConfigResponse($response)
+{
+ return json_decode($response, true);
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $slash = '/';
+ if (strpos(__DIR__, ':')) $slash = '\\';
+ // __DIR__ is xxx/platform
+ $projectPath = splitlast(__DIR__, $slash)[0];
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ $tarfile = $projectPath . $slash .'github.tar.gz';
+ $githubfile = file_get_contents($url);
+ if (!$githubfile) return 0;
+ file_put_contents($tarfile, $githubfile);
+ if (splitfirst(PHP_VERSION, '.')[0] == '7') {
+ $phar = new PharData($tarfile); // need php7
+ $phar->extractTo($projectPath, null, true);//路径 要解压的文件 是否覆盖
+ } else {
+ ob_start();
+ passthru('tar -xzvf ' . $tarfile, $stat);
+ ob_get_clean();
+ }
+ unlink($tarfile);
+
+ $outPath = '';
+ $tmp = scandir($projectPath);
+ $name = $auth . '-' . $project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath = $projectPath . $slash . $f;
+ break;
+ }
+ }
+ //error_log($outPath);
+ if ($outPath=='') return 0;
+
+ //unlink($outPath.'/config.php');
+ $response = rename($projectPath . $slash . 'config.php', $outPath . $slash . 'config.php');
+ if (!$response) {
+ $tmp1['code'] = "Move Failed";
+ $tmp1['message'] = "Can not move " . $projectPath . $slash . 'config.php' . " to " . $outPath . $slash . 'config.php';
+ return json_encode($tmp1);
+ }
+ return moveFolder($outPath, $projectPath, $slash);
+}
+
+function moveFolder($from, $to, $slash)
+{
+ if (substr($from, -1)==$slash) $from = substr($from, 0, -1);
+ if (substr($to, -1)==$slash) $to = substr($to, 0, -1);
+ if (!file_exists($to)) mkdir($to, 0777);
+ $handler=opendir($from);
+ while($filename=readdir($handler)) {
+ if($filename != '.' && $filename != '..'){
+ $fromfile = $from . $slash . $filename;
+ $tofile = $to . $slash . $filename;
+ if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
+ $response = moveFolder($fromfile, $tofile, $slash);
+ if (api_error(setConfigResponse($response))) return $response;
+ }else{
+ //if (file_exists($tofile)) unlink($tofile);
+ $response = rename($fromfile, $tofile);
+ if (!$response) {
+ $tmp['code'] = "Move Failed";
+ $tmp['message'] = "Can not move " . $fromfile . " to " . $tofile;
+ return json_encode($tmp);
+ }
+ if (file_exists($fromfile)) unlink($fromfile);
+ }
+ }
+ }
+ closedir($handler);
+ rmdir($from);
+ return json_encode( [ 'response' => 'success' ] );
+}
diff --git a/platform/TencentSCF_env.php b/platform/TencentSCF_env.php
new file mode 100644
index 0000000..e2951a4
--- /dev/null
+++ b/platform/TencentSCF_env.php
@@ -0,0 +1,439 @@
+500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
+ echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
+
+' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
+
+';
+}
+
+function GetGlobalVariable($event)
+{
+ $_GET = $event['queryString'];
+ $postbody = explode("&",$event['body']);
+ foreach ($postbody as $postvalues) {
+ $pos = strpos($postvalues,"=");
+ $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
+ }
+ $cookiebody = explode("; ",$event['headers']['cookie']);
+ foreach ($cookiebody as $cookievalues) {
+ $pos = strpos($cookievalues,"=");
+ $_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
+ }
+ $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
+ $_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
+ $_SERVER['USER'] = 'qcloud';
+}
+
+function GetPathSetting($event, $context)
+{
+ $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
+ $_SERVER['function_name'] = $context['function_name'];
+ $_SERVER['namespace'] = $context['namespace'];
+ $_SERVER['Region'] = getenv('TENCENTCLOUD_REGION');
+ $host_name = $event['headers']['host'];
+ $_SERVER['HTTP_HOST'] = $host_name;
+ $serviceId = $event['requestContext']['serviceId'];
+ if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
+ $_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
+ $path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
+ } else {
+ $_SERVER['base_path'] = $event['requestContext']['path'];
+ $path = substr($event['path'], strlen($event['requestContext']['path']));
+ }
+ if (substr($path,-1)=='/') $path=substr($path,0,-1);
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
+ return $path;
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $env = json_decode(getenv($disktag), true);
+ if (isset($env[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($env[$str]);
+ else return $env[$str];
+ }
+ } else {
+ if (in_array($str, $Base64Env)) return base64y_decode(getenv($str));
+ else return getenv($str);
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ $disktags = explode("|",getConfig('disktag'));
+ $diskconfig = json_decode(getenv($disktag), true);
+ $tmp = [];
+ $indisk = 0;
+ $oparetdisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $diskconfig[$k] = base64y_encode($v);
+ else $diskconfig[$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $oparetdisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $tmp[$v] = '';
+ $oparetdisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $tmp[$k] = base64y_encode($v);
+ else $tmp[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $tmp[$disktag] = json_encode($diskconfig);
+ }
+ if ($oparetdisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
+ else $tmp['disktag'] = '';
+ }
+// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
+//';
+ $response = updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
+ WaitSCFStat();
+ return $response;
+}
+
+function WaitSCFStat()
+{
+ $trynum = 0;
+ while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install2']) {
+ $tmp['admin'] = $_POST['admin'];
+ $response = setConfigResponse( setConfig($tmp) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ if (needUpdate()) {
+ OnekeyUpate();
+ return message('update to github version, reinstall.
+
+ ', 'Program updating', 201);
+ }
+ return output('Jump
+
+ ', 302);
+ }
+ if ($_GET['install1']) {
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $SecretId = getConfig('SecretId');
+ if ($SecretId=='') {
+ $SecretId = $_POST['SecretId'];
+ $tmp['SecretId'] = $SecretId;
+ }
+ $SecretKey = getConfig('SecretKey');
+ if ($SecretKey=='') {
+ $SecretKey = $_POST['SecretKey'];
+ $tmp['SecretKey'] = $SecretKey;
+ }
+ $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
+ $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') {
+ $html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '' . getconstStr('Home') . ' ';
+ $title = 'Reinstall';
+ return message($html, $title, 201);
+ }
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function post2url($url, $data)
+{
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ 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);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ $response = curl_exec($ch);
+ curl_close($ch);
+ //echo $response;
+ return $response;
+}
+
+function ReorganizeDate($arr)
+{
+ $str = '';
+ ksort($arr);
+ foreach ($arr as $k1 => $v1) {
+ $str .= '&' . $k1 . '=' . $v1;
+ }
+ $str = substr($str, 1); // remove first '&'. 去掉第一个&
+ return $str;
+}
+
+function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //$meth = 'GET';
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'GetFunction';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ //return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //print_r($Envs);
+ WaitSCFStat();
+ //json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
+ $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
+ foreach ($tmp as $tmp1) {
+ $tmp_env[$tmp1['Key']] = $tmp1['Value'];
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ //$tmp_env['Region'] = $Region;
+ ksort($tmp_env);
+
+ $i = 0;
+ foreach ($tmp_env as $key1 => $value1) {
+ $tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
+ $tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
+ $i++;
+ }
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionConfiguration';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //echo json_encode($Envs,JSON_PRETTY_PRINT);
+ if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $Envs = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
+ /*$trynum = 0;
+ while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;*/
+ //json_decode($a,true)['Response']['Environment']['Variables'][0]['Key']
+ $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
+ foreach ($tmp as $tmp1) {
+ $tmp_env[$tmp1['Key']] = $tmp1['Value'];
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ //$tmp_env['Region'] = $Region;
+ ksort($tmp_env);
+
+ $i = 0;
+ foreach ($tmp_env as $key1 => $value1) {
+ $tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
+ $tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
+ $i++;
+ }
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionConfiguration';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $tmpdata['Description'] = 'Onedrive index and manager in Tencent SCF.';
+ $tmpdata['MemorySize'] = 64;
+ $tmpdata['Timeout'] = 30;
+ $data = ReorganizeDate($tmpdata);
+ echo $data;
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
+{
+ WaitSCFStat();
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionCode';
+ $tmpdata['Code.GitUrl'] = $source['url'];
+ $tmpdata['Code.GitBranch'] = $source['branch'];
+ $tmpdata['CodeSource'] = 'Git';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Handler'] = 'index.main_handler';
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function api_error($response)
+{
+ return isset($response['Error']);
+}
+
+function api_error_msg($response)
+{
+ return $response['Error']['Code'] . '
+' . $response['Error']['Message'] . '
+function_name:' . $_SERVER['function_name'] . '
+Region:' . $_SERVER['Region'] . '
+namespace:' . $_SERVER['namespace'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source['url'] = 'https://github.com/' . $auth . '/' . $project;
+ $source['branch'] = $branch;
+ return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response, true )['Response'];
+}
diff --git a/platform/TencentSCF_file.php b/platform/TencentSCF_file.php
new file mode 100644
index 0000000..7cd3788
--- /dev/null
+++ b/platform/TencentSCF_file.php
@@ -0,0 +1,621 @@
+500) $event['body']=substr($event['body'],0,strpos($event['body'],'base64')+30) . '...Too Long!...' . substr($event['body'],-50);
+ echo urldecode(json_encode($event, JSON_PRETTY_PRINT)) . '
+
+' . urldecode(json_encode($context, JSON_PRETTY_PRINT)) . '
+
+';
+}
+
+function GetGlobalVariable($event)
+{
+ $_GET = $event['queryString'];
+ $postbody = explode("&",$event['body']);
+ foreach ($postbody as $postvalues) {
+ $pos = strpos($postvalues,"=");
+ $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1));
+ }
+ $cookiebody = explode("; ",$event['headers']['cookie']);
+ foreach ($cookiebody as $cookievalues) {
+ $pos = strpos($cookievalues,"=");
+ $_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
+ }
+ $_SERVER['HTTP_USER_AGENT'] = $event['headers']['user-agent'];
+ $_SERVER['HTTP_TRANSLATE']==$event['headers']['translate'];//'f'
+ $_SERVER['USER'] = 'qcloud';
+}
+
+function GetPathSetting($event, $context)
+{
+ $_SERVER['firstacceptlanguage'] = strtolower(splitfirst(splitfirst($event['headers']['accept-language'],';')[0],',')[0]);
+ $_SERVER['function_name'] = $context['function_name'];
+ $_SERVER['namespace'] = $context['namespace'];
+ $_SERVER['Region'] = getenv('TENCENTCLOUD_REGION');
+ $host_name = $event['headers']['host'];
+ $_SERVER['HTTP_HOST'] = $host_name;
+ $serviceId = $event['requestContext']['serviceId'];
+ if ( $serviceId === substr($host_name,0,strlen($serviceId)) ) {
+ $_SERVER['base_path'] = '/'.$event['requestContext']['stage'].'/'.$_SERVER['function_name'].'/';
+ $path = substr($event['path'], strlen('/'.$_SERVER['function_name'].'/'));
+ } else {
+ $_SERVER['base_path'] = $event['requestContext']['path'];
+ $path = substr($event['path'], strlen($event['requestContext']['path']));
+ }
+ if (substr($path,-1)=='/') $path=substr($path,0,-1);
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
+ $_SERVER['REMOTE_ADDR'] = $event['requestContext']['sourceIp'];
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = $event['headers']['x-requested-with'];
+ return $path;
+}
+
+function getConfig($str, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ //include 'config.php';
+ $s = file_get_contents('config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') {
+ $envs = json_decode($configs, true);
+ if (in_array($str, $InnerEnv)) {
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ if (isset($envs[$disktag][$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($envs[$disktag][$str]);
+ else return $envs[$disktag][$str];
+ }
+ } else {
+ if (isset($envs[$str])) {
+ if (in_array($str, $Base64Env)) return base64y_decode($envs[$str]);
+ else return $envs[$str];
+ }
+ }
+ }
+ return '';
+}
+
+function setConfig($arr, $disktag = '')
+{
+ global $InnerEnv;
+ global $Base64Env;
+ if ($disktag=='') $disktag = $_SERVER['disktag'];
+ //include 'config.php';
+ $s = file_get_contents('config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') $envs = json_decode($configs, true);
+ $disktags = explode("|",getConfig('disktag'));
+ $indisk = 0;
+ $operatedisk = 0;
+ foreach ($arr as $k => $v) {
+ if (in_array($k, $InnerEnv)) {
+ if (in_array($k, $Base64Env)) $envs[$disktag][$k] = base64y_encode($v);
+ else $envs[$disktag][$k] = $v;
+ $indisk = 1;
+ } elseif ($k=='disktag_add') {
+ array_push($disktags, $v);
+ $operatedisk = 1;
+ } elseif ($k=='disktag_del') {
+ $disktags = array_diff($disktags, [ $v ]);
+ $envs[$v] = '';
+ $operatedisk = 1;
+ } else {
+ if (in_array($k, $Base64Env)) $envs[$k] = base64y_encode($v);
+ else $envs[$k] = $v;
+ }
+ }
+ if ($indisk) {
+ $diskconfig = $envs[$disktag];
+ $diskconfig = array_filter($diskconfig, 'array_value_isnot_null');
+ ksort($diskconfig);
+ $envs[$disktag] = $diskconfig;
+ }
+ if ($operatedisk) {
+ $disktags = array_unique($disktags);
+ foreach ($disktags as $disktag) if ($disktag!='') $disktag_s .= $disktag . '|';
+ if ($disktag_s!='') $envs['disktag'] = substr($disktag_s, 0, -1);
+ else $envs['disktag'] = '';
+ }
+ $envs = array_filter($envs, 'array_value_isnot_null');
+ ksort($envs);
+ $response = updateEnvironment($envs, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
+ WaitSCFStat($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
+ return $response;
+}
+
+function WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ $trynum = 0;
+ while( json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;
+}
+
+function install()
+{
+ global $constStr;
+ if ($_GET['install2']) {
+ $tmp['admin'] = $_POST['admin'];
+ $response = setConfigResponse( setConfig($tmp) );
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ }
+ if (needUpdate()) {
+ OnekeyUpate();
+ return message('update to github version, reinstall.
+
+ ', 'Program updating', 201);
+ }
+ return output('Jump
+
+ ', 302);
+ }
+ if ($_GET['install1']) {
+ $tmp['timezone'] = $_COOKIE['timezone'];
+ $SecretId = getConfig('SecretId');
+ if ($SecretId=='') {
+ $SecretId = $_POST['SecretId'];
+ $tmp['SecretId'] = $SecretId;
+ }
+ $SecretKey = getConfig('SecretKey');
+ if ($SecretKey=='') {
+ $SecretKey = $_POST['SecretKey'];
+ $tmp['SecretKey'] = $SecretKey;
+ }
+ $tmp['ONEMANAGER_CONFIG_SAVE'] = $_POST['ONEMANAGER_CONFIG_SAVE'];
+ $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
+ if (api_error($response)) {
+ $html = api_error_msg($response);
+ $title = 'Error';
+ return message($html, $title, 201);
+ } else {
+ if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') {
+ $html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '' . getconstStr('Home') . ' ';
+ $title = 'Reinstall';
+ return message($html, $title, 201);
+ }
+ $html .= '
+
+ ';
+ $title = getconstStr('SetAdminPassword');
+ return message($html, $title, 201);
+ }
+ }
+ if ($_GET['install0']) {
+ $html .= '
+
+ ';
+ $title = getconstStr('SelectLanguage');
+ return message($html, $title, 201);
+ }
+ $html .= ''.getconstStr('ClickInstall').' , '.getconstStr('LogintoBind');
+ $title = 'Error';
+ return message($html, $title, 201);
+}
+
+function post2url($url, $data)
+{
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ 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);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ $response = curl_exec($ch);
+ curl_close($ch);
+ //echo $response;
+ return $response;
+}
+
+function ReorganizeDate($arr)
+{
+ $str = '';
+ ksort($arr);
+ foreach ($arr as $k1 => $v1) {
+ $str .= '&' . $k1 . '=' . $v1;
+ }
+ $str = substr($str, 1); // remove first '&'. 去掉第一个&
+ return $str;
+}
+
+function getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //$meth = 'GET';
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'GetFunction';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ //return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ //$meth = 'GET';
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'GetFunctionAddress';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $data = ReorganizeDate($tmpdata);
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ //return file_get_contents('https://'.$url.'&Signature='.urlencode($signStr));
+ return post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+}
+
+function copyFolder($from, $to)
+{
+ if (substr($from, -1)=='/') $from = substr($from, 0, -1);
+ if (substr($to, -1)=='/') $to = substr($to, 0, -1);
+ if (!file_exists($to)) mkdir($to, 0777);
+ $handler=opendir($from);
+ while($filename=readdir($handler)) {
+ if($filename != '.' && $filename != '..'){
+ $fromfile = $from.'/'.$filename;
+ $tofile = $to.'/'.$filename;
+ if(is_dir($fromfile)){// 如果读取的某个对象是文件夹,则递归
+ copyFolder($fromfile, $tofile);
+ }else{
+ copy($fromfile, $tofile);
+ }
+ }
+ }
+ closedir($handler);
+ return 1;
+}
+
+function updateEnvironment($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ // 获取当前代码并解压
+ //$codeurl = json_decode(getfunctioncodeurl($function_name, $Region, $Namespace, $SecretId, $SecretKey), true)['Response']['Url'];
+ //$codezip = '/tmp/oldcode.zip';
+ $outPath = '/tmp/code/';
+
+ //file_put_contents($codezip, file_get_contents($codeurl));
+ //$zip=new ZipArchive();
+ //$zip->open($codezip);
+ //$html = $zip->extractTo($outPath);
+
+ $coderoot = __DIR__ . '/../';
+ copyFolder($coderoot, $outPath);
+
+ // 将配置写入
+ $prestr = 'open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ // $zip->close(); //关闭处理的zip文件
+ //}
+
+ return updateProgram($function_name, $Region, $namespace, $SecretId, $SecretKey, $source);
+ $tmp1['Response']['Error']['Message'] = $codeurl;
+ error_log($tmp1['Response']['Error']['Message']);
+ return json_encode($tmp1);
+}
+
+function SetbaseConfig($Envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey)
+{
+ if ($Envs['ONEMANAGER_CONFIG_SAVE'] == 'file') $tmp_env = Array( 'ONEMANAGER_CONFIG_SAVE' => 'file' );
+ else {
+ $Envs['ONEMANAGER_CONFIG_SAVE'] == '';
+ $tmp = json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Environment']['Variables'];
+ foreach ($tmp as $tmp1) {
+ $tmp_env[$tmp1['Key']] = $tmp1['Value'];
+ }
+ foreach ($Envs as $key1 => $value1) {
+ $tmp_env[$key1] = $value1;
+ }
+ $tmp_env = array_filter($tmp_env, 'array_value_isnot_null'); // remove null. 清除空值
+ ksort($tmp_env);
+ }
+
+ $i = 0;
+ foreach ($tmp_env as $key1 => $value1) {
+ $tmpdata['Environment.Variables.'.$i.'.Key'] = $key1;
+ $tmpdata['Environment.Variables.'.$i.'.Value'] = $value1;
+ $i++;
+ }
+
+ $meth = 'POST';
+ $host = 'scf.tencentcloudapi.com';
+ $tmpdata['Action'] = 'UpdateFunctionConfiguration';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Namespace'] = $Namespace;
+ $tmpdata['Nonce'] = time();
+ $tmpdata['Region'] = $Region;
+ $tmpdata['SecretId'] = $SecretId;
+ $tmpdata['Timestamp'] = time();
+ $tmpdata['Token'] = '';
+ $tmpdata['Version'] = '2018-04-16';
+ $tmpdata['Description'] = 'Onedrive index and manager in Tencent SCF.';
+ $tmpdata['MemorySize'] = 64;
+ $tmpdata['Timeout'] = 30;
+ $data = ReorganizeDate($tmpdata);
+ //echo $data;
+ $signStr = base64_encode(hash_hmac('sha1', $meth.$host.'/?'.$data, $SecretKey, true));
+ //echo urlencode($signStr);
+ $response = post2url('https://'.$host, $data.'&Signature='.urlencode($signStr));
+ if (api_error(setConfigResponse($response))) {
+ return $response;
+ }
+ if ( json_decode(getfunctioninfo($function_name, $Region, $Namespace, $SecretId, $SecretKey),true)['Response']['Timeout'] < 25 ) {
+ $tmp['Response']['Error']['Message'] = 'Operating, please try again.';
+ $tmp['Response']['Error']['Code'] = 'Retry';
+ return json_encode($tmp);
+ }
+ WaitSCFStat($function_name, $Region, $Namespace, $SecretId, $SecretKey);
+
+ $s = file_get_contents('config.php');
+ //$configs = substr($s, 18, -2);
+ $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
+ if ($configs!='') $envs = json_decode($configs, true);
+ foreach ($Envs as $k => $v) {
+ $envs[$k] = $v;
+ }
+ $envs = array_filter($envs, 'array_value_isnot_null');
+ ksort($envs);
+ $response = updateEnvironment($envs, $function_name, $Region, $Namespace, $SecretId, $SecretKey);
+ return $response;
+}
+
+function updateProgram($function_name, $Region, $Namespace, $SecretId, $SecretKey, $source)
+{
+ $secretId = $SecretId;
+ $secretKey = $SecretKey;
+ $host = 'scf.tencentcloudapi.com';
+ $service = "scf";
+ $version = "2018-04-16";
+ $action = "UpdateFunctionCode";
+ $region = $Region;
+ $timestamp = time();
+ $algorithm = "TC3-HMAC-SHA256";
+
+ // step 1: build canonical request string
+ $httpRequestMethod = "POST";
+ $canonicalUri = "/";
+ $canonicalQueryString = "";
+ $canonicalHeaders = "content-type:application/json; charset=utf-8\n"."host:".$host."\n";
+ $signedHeaders = "content-type;host";
+
+ //$tmpdata['Action'] = 'UpdateFunctionCode';
+ $tmpdata['Code']['ZipFile'] = base64_encode( file_get_contents($source) );
+ $tmpdata['CodeSource'] = 'ZipFile';
+ $tmpdata['FunctionName'] = $function_name;
+ $tmpdata['Handler'] = 'index.main_handler';
+ //$tmpdata['Namespace'] = $Namespace;
+ //$tmpdata['Nonce'] = time();
+ //$tmpdata['Region'] = $Region;
+ //$tmpdata['SecretId'] = $SecretId;
+ //$tmpdata['Timestamp'] = time();
+ //$tmpdata['Token'] = '';
+ //$tmpdata['Version'] = '2018-04-16';
+ $payload = json_encode($tmpdata);
+ //$payload = '{"Limit": 1, "Filters": [{"Values": ["\u672a\u547d\u540d"], "Name": "instance-name"}]}';
+ $hashedRequestPayload = hash("SHA256", $payload);
+ $canonicalRequest = $httpRequestMethod."\n"
+ .$canonicalUri."\n"
+ .$canonicalQueryString."\n"
+ .$canonicalHeaders."\n"
+ .$signedHeaders."\n"
+ .$hashedRequestPayload;
+ //echo $canonicalRequest.PHP_EOL;
+
+ // step 2: build string to sign
+ $date = gmdate("Y-m-d", $timestamp);
+ $credentialScope = $date."/".$service."/tc3_request";
+ $hashedCanonicalRequest = hash("SHA256", $canonicalRequest);
+ $stringToSign = $algorithm."\n"
+ .$timestamp."\n"
+ .$credentialScope."\n"
+ .$hashedCanonicalRequest;
+ //echo $stringToSign.PHP_EOL;
+
+ // step 3: sign string
+ $secretDate = hash_hmac("SHA256", $date, "TC3".$secretKey, true);
+ $secretService = hash_hmac("SHA256", $service, $secretDate, true);
+ $secretSigning = hash_hmac("SHA256", "tc3_request", $secretService, true);
+ $signature = hash_hmac("SHA256", $stringToSign, $secretSigning);
+ //echo $signature.PHP_EOL;
+
+ // step 4: build authorization
+ $authorization = $algorithm
+ ." Credential=".$secretId."/".$credentialScope
+ .", SignedHeaders=content-type;host, Signature=".$signature;
+ //echo $authorization.PHP_EOL;
+
+ //$curl = "curl -X POST https://".$host
+ // .' -H "Authorization: '.$authorization.'"'
+ // .' -H "Content-Type: application/json; charset=utf-8"'
+ // .' -H "Host: '.$host.'"'
+ // .' -H "X-TC-Action: '.$action.'"'
+ // .' -H "X-TC-Timestamp: '.$timestamp.'"'
+ // .' -H "X-TC-Version: '.$version.'"'
+ // .' -H "X-TC-Region: '.$region.'"'
+ // ." -d '".$payload."'";
+ //error_log( $curl.PHP_EOL );
+ //return '{"response": {"Error": {"Message":"' . $curl . '"}}}';
+ $headers['Authorization'] = $authorization;
+ $headers['Content-Type'] = 'application/json; charset=utf-8';
+ $headers['Host'] = $host;
+ $headers['X-TC-Action'] = $action;
+ $headers['X-TC-Timestamp'] = $timestamp;
+ $headers['X-TC-Version'] = $version;
+ $headers['X-TC-Region'] = $region;
+ return curl_request('https://'.$host, $payload, $headers)['body'];
+}
+
+function api_error($response)
+{
+ return isset($response['Error']);
+ return ($response==null)||isset($response['Error']);
+}
+
+function api_error_msg($response)
+{
+ return $response['Error']['Code'] . '
+' . $response['Error']['Message'] . '
+function_name:' . $_SERVER['function_name'] . '
+Region:' . $_SERVER['Region'] . '
+namespace:' . $_SERVER['namespace'] . '
+'.getconstStr('Refresh').' ';
+}
+
+function setConfigResponse($response)
+{
+ return json_decode( $response, true )['Response'];
+}
+
+function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
+{
+ $source = '/tmp/code.zip';
+ $outPath = '/tmp/';
+
+ // 从github下载对应tar.gz,并解压
+ $url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
+ $tarfile = '/tmp/github.tar.gz';
+ file_put_contents($tarfile, file_get_contents($url));
+ $phar = new PharData($tarfile);
+ $html = $phar->extractTo($outPath, null, true);//路径 要解压的文件 是否覆盖
+
+ // 获取包中目录名
+ $tmp = scandir('phar://'.$tarfile);
+ $name = $auth.'-'.$project;
+ foreach ($tmp as $f) {
+ if ( substr($f, 0, strlen($name)) == $name) {
+ $outPath .= $f;
+ break;
+ }
+ }
+ // 放入配置文件
+ file_put_contents($outPath . '/config.php', file_get_contents(__DIR__.'/../config.php'));
+
+ // 将目录中文件打包成zip
+ //$zip=new ZipArchive();
+ $zip=new PharData($source);
+ //if($zip->open($source, ZipArchive::CREATE)){
+ addFileToZip($zip, $outPath); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
+ // $zip->close(); //关闭处理的zip文件
+ //}
+
+ return updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'), $source);
+}
+
+function addFileToZip($zip, $rootpath, $path = '')
+{
+ if (substr($rootpath,-1)=='/') $rootpath = substr($rootpath, 0, -1);
+ if (substr($path,0,1)=='/') $path = substr($path, 1);
+ $handler=opendir(path_format($rootpath.'/'.$path)); //打开当前文件夹由$path指定。
+ while($filename=readdir($handler)){
+ if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作
+ $nowname = path_format($rootpath.'/'.$path."/".$filename);
+ if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归
+ $zip->addEmptyDir($path."/".$filename);
+ addFileToZip($zip, $rootpath, $path."/".$filename);
+ }else{ //将文件加入zip对象
+ $newname = $path."/".$filename;
+ if (substr($newname,0,1)=='/') $newname = substr($newname, 1);
+ $zip->addFile($nowname, $newname);
+ //$zip->renameName($nowname, $newname);
+ }
+ }
+ }
+ @closedir($path);
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..00a793a
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,95 @@
+Install program first, then add onedrive in setup after login.
+先安装程序,登录后在设置中添加onedrive。
+
+# Deploy to Heroku
+Official: https://heroku.com
+Demo: https://herooneindex.herokuapp.com/
+
+How to Install: Click the button [](https://heroku.com/deploy?template=https://github.com/qkqpttgf/OneManager-php) to Deploy a new app, or create an app then deploy via connect to your github fork.
+
+
+# Deploy to Tencent Serverless Cloud Function (SCF 腾讯无服务器云函数)
+Official: https://cloud.tencent.com/product/scf
+DEMO: 无
+注意:SCF新增限制,环境变量整体最大4KB,所以最多添加4个盘。
+
+How to Install: 无,(重点:勾选集成响应)
+
+添加网盘时,SCF可能会反应不过来,不跳转到微软,导致添加失败,请不要删除这个盘,再添加一次相同标签的盘就可以了。
+
+
+# Deploy to Virtual Private Server (VPS 或空间)
+DEMO: 无
+How to Install:
+ 1.Start web service on your server (httpd or other), make sure you can visit it.
+ 启动web服务器,确保你能访问到。
+ 2.Make the rewrite works, the rule is in .htaccess file, make sure any query redirect to index.php.
+ 开启伪静态(重写)功能,规则在.htaccess文件中,ngnix从里面复制,我们的目的是不管访问什么都让index.php来处理。
+ 3.Upload code.
+ 上传好代码。
+ 4.Change the file config.php can be read&write (666 is suggested).
+ 让代码中的config.php文件程序可读写,推荐chmod 666 config.php。
+ 5.View the website in chrome or other.
+ 在浏览器中访问。
+
+
+# Deploy to Huawei cloud Function Graph (FG 华为云函数工作流)
+Official: https://console.huaweicloud.com/functiongraph/
+DEMO: 无
+注意:FG中,环境变量整体大小为2KB,所以最多添加2个盘。
+
+How to Install:
+1,在函数列表,点右边创建函数
+2,输入名称,选择运行时语言为PHP7.3,点上传ZIP文件,选择文件,然后点右边的创建函数(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。)
+3,创建触发器:选API网关,安全认证选None,后端超时(毫秒)将5000改成30000,上面创建分组一下,其它的点点点
+4,访问触发器给的url,开始安装
+5,在触发器界面点触发器名称,跳到API网关管理,右边更多URL,可以添加自定义域名,自定义域名后发现还是要 xxxx.com/函数名 来访问,点上方的编辑,第1页不用改,点下一步,请求Path改成/,注意匹配模式是前缀匹配,Method为ANY,然后不用点下一步了,点立即完成,然后去发布生效
+
+
+# Deploy to Aliyun Function Compute (FC 阿里云函数计算)
+Official: https://fc.console.aliyun.com/
+DEMO: 无
+
+How to Install:
+1,新建函数 -- HTTP函数
+2,运行环境选择php7.2
+3,触发器认证方式选择anonymous,请求方式里面,点一下GET,再点一下POST,最终框框里面有这2个
+4,上传代码
+5,触发器中点进去,找到配置自定义域名,点击前往,创建,路径中填 /* ,其它下拉选择。
+6,访问你的域名,开始安装
+
+
+# Deploy to Baidu Cloud Function Compute (CFC 百度云函数计算)
+Official: https://console.bce.baidu.com/cfc/#/cfc/functions
+DEMO: 无
+自定义域名需要另外使用API网关,并备案。
+
+How to Install:
+1,在函数列表,点创建函数
+2,创建方式改为空白函数,点下一步
+3,输入名称,选择运行时为PHP7.2,点下一步
+4,触发器:下拉选择HTTP触发器,URL路径填 /{filepath+} ,HTTP方法全选,身份验证:不验证,点提交
+5,进入代码编辑页,编辑类型改上传函数ZIP包,选择文件(这里的ZIP文件不能直接用从Github上下载的ZIP文件,要将它解压后,去掉外层文件夹后,再压缩为ZIP。),开始上传
+6,点击右边触发器,复制并访问提供的url,开始安装
+
+
+# Features 特性
+When downloading files, the program produce a direct url, visitor download files from MS OFFICE via the direct url, the server expend a few bandwidth in produce.
+下载时,由程序解析出直链,浏览器直接从微软Onedrive服务器下载文件,服务器只消耗与微软通信的少量流量。
+When uploading files, the program produce a direct url, visitor upload files to MS OFFICE via the direct url, the server expend a few bandwidth in produce.
+上传时,由程序生成上传url,浏览器直接向微软Onedrive的这个url上传文件,服务器只消耗与微软通信的少量流量。
+The XXX_path in setting is the path in Onedrive, not in url, program will find the path in Onedrive.
+设置中的 XXX_path 是Onedrive里面的路径,并不是你url里面的,程序会去你Onedrive里面找这个路径。
+LOGO ICON: put your 'favicon.ico' in the path you showed, make sure xxxxx.com/favicon.ico can be visited.
+网站图标:将favicon.ico文件放在你要展示的目录中,确保 xxxxx.com/favicon.ico 可以访问到。
+Program will show content of 'readme.md' & 'head.md'.
+可以在文件列表显示head.md跟readme.md文件的内容。
+guest up path, is a folder that the guest can upload files, but can not be list (exclude admin).
+游客上传目录(也叫图床目录),是指定一个目录,让游客可以上传文件,不限格式,不限大小。这个目录里面的内容不列清单(除非管理登录)。
+If there is 'index.html' file, program will only show the content of 'index.html', not list the files.
+如果目录中有index.html文件,只会输出显示html文件,不显示程序框架。
+Click 'EditTime' or 'Size', the list will sort by time or size, Click 'File' can resume sort.
+点击“时间”、“大小”,可以排序显示,点“文件”恢复原样。
+
+QQ Group: 943919989 (请看完上面的中英双语再加群,谢谢!)
+Telegram Group: https://t.me/joinchat/I_RVc0bqxuxlT-d0cO7ozw
diff --git a/theme/Onedrive-dev.html b/theme/Onedrive-dev.html
new file mode 100644
index 0000000..ac664b2
--- /dev/null
+++ b/theme/Onedrive-dev.html
@@ -0,0 +1,572 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ Language
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/classic.html b/theme/classic.html
new file mode 100644
index 0000000..1bacac5
--- /dev/null
+++ b/theme/classic.html
@@ -0,0 +1,1245 @@
+
+{
+ "music":"musical-notes",
+ "video":"logo-youtube",
+ "img":"image",
+ "office":"paper",
+ "txt":"clipboard",
+ "zip":"filing",
+ "iso":"disc",
+ "apk":"logo-android",
+ "exe":"logo-windows",
+ "default":"document"
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading PDF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/ly_white.php b/theme/ly_white.php
new file mode 100644
index 0000000..13c0df4
--- /dev/null
+++ b/theme/ly_white.php
@@ -0,0 +1,1289 @@
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
+?>
+
+
+ ' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+"日)",
+ "1"=>"一)",
+ "2"=>"二)",
+ "3"=>"三)",
+ "4"=>"四)",
+ "5"=>"五)",
+ "6"=>"六)"
+);
+echo '(星期'.$week[$w];
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/lybwb.php b/theme/lybwb.php
new file mode 100644
index 0000000..a273a94
--- /dev/null
+++ b/theme/lybwb.php
@@ -0,0 +1,1283 @@
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
+?>
+
+
+ ' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) {
+ if (strtolower($file['name']) === 'head.md') $head = $file;
+ if (strtolower($file['name']) === 'readme.md') $readme = $file;
+ if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) {
+ $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body'];
+ return output($html,200);
+ }
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/minus.php b/theme/minus.php
new file mode 100644
index 0000000..491601e
--- /dev/null
+++ b/theme/minus.php
@@ -0,0 +1,1544 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
+?>
+
+
+ ' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Theme minus by Crazy白茫茫
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/nchyn_grey.html b/theme/nchyn_grey.html
new file mode 100644
index 0000000..f07b8f5
--- /dev/null
+++ b/theme/nchyn_grey.html
@@ -0,0 +1,1414 @@
+
+{
+ "music":"musical-notes",
+ "video":"logo-youtube",
+ "img":"image",
+ "office":"paper",
+ "txt":"clipboard",
+ "zip":"filing",
+ "iso":"disc",
+ "apk":"logo-android",
+ "exe":"logo-windows",
+ "default":"document"
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
OneManager By 逸笙 Theme By Nchyn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/nexmoe1.html b/theme/nexmoe1.html
new file mode 100644
index 0000000..56998de
--- /dev/null
+++ b/theme/nexmoe1.html
@@ -0,0 +1,377 @@
+
+{
+ "music":"audiotrack",
+ "video":"ondemand_video",
+ "img":"image",
+ "default":"insert_drive_file"
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https
+
+
+
+
+
+ fingerprint
+
+
+
+
+
+
+
+
+
+
+
+-->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
file_download
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
format_list_bulleted
+
+
+
+
+
+
+
+
diff --git a/theme/nexmoe2.html b/theme/nexmoe2.html
new file mode 100644
index 0000000..3ed1f54
--- /dev/null
+++ b/theme/nexmoe2.html
@@ -0,0 +1,580 @@
+
+{
+ "music":"audiotrack",
+ "video":"ondemand_video",
+ "img":"image",
+ "default":"insert_drive_file"
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https
+
+
+
+
+
+ fingerprint
+
+
+
+
+
+
+
+
+
+
+
+-->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+file_download
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/onemoe.html b/theme/onemoe.html
new file mode 100644
index 0000000..88f54c0
--- /dev/null
+++ b/theme/onemoe.html
@@ -0,0 +1,1204 @@
+
+{
+ "music":"musical-notes",
+ "video":"logo-youtube",
+ "img":"image",
+ "office":"paper",
+ "txt":"clipboard",
+ "zip":"filing",
+ "iso":"disc",
+ "apk":"logo-android",
+ "exe":"logo-windows",
+ "default":"document"
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Loading PDF
+
+
+
+
+
+
+
+
+
+
+
+
+ onchange="document.getElementById('txt-save').onclick=function(){document.getElementById('txt-form').submit();}" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/purenice.php b/theme/purenice.php
new file mode 100644
index 0000000..99e5b31
--- /dev/null
+++ b/theme/purenice.php
@@ -0,0 +1,1272 @@
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
+?>
+
+
+ ' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/renexmoe.html b/theme/renexmoe.html
new file mode 100644
index 0000000..d9f9197
--- /dev/null
+++ b/theme/renexmoe.html
@@ -0,0 +1,639 @@
+
+{
+ "music":"audiotrack",
+ "video":"ondemand_video",
+ "img":"image",
+ "default":"insert_drive_file"
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ https
+
+
+
+
+
+ fingerprint
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+file_download
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ expand_more
+ expand_more
+ expand_more
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/ruoli_blue.php b/theme/ruoli_blue.php
new file mode 100644
index 0000000..92c4659
--- /dev/null
+++ b/theme/ruoli_blue.php
@@ -0,0 +1,1240 @@
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
登陆
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
+?>
+
+
+ ' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) {
+ if (strtolower($file['name']) === 'head.md') $head = $file;
+ if (strtolower($file['name']) === 'readme.md') $readme = $file;
+ if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) {
+ $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body'];
+ return output($html,200);
+ }
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OneManager by 逸笙 theme by 若离
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/ruoli_violet.php b/theme/ruoli_violet.php
new file mode 100644
index 0000000..ce71dfc
--- /dev/null
+++ b/theme/ruoli_violet.php
@@ -0,0 +1,1259 @@
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files['@microsoft.graph.downloadUrl'];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])['body']);
+?>
+
+
+ ' . curl_request($files['@microsoft.graph.downloadUrl'])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) {
+ if (strtolower($file['name']) === 'head.md') $head = $file;
+ if (strtolower($file['name']) === 'readme.md') $readme = $file;
+ if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) {
+ $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body'];
+ return output($html,200);
+ }
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/tfo_md.php b/theme/tfo_md.php
new file mode 100644
index 0000000..9e8cdc2
--- /dev/null
+++ b/theme/tfo_md.php
@@ -0,0 +1,1296 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+';
+?>
+
+';
+?>
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files[$_SERVER['DownurlStrName']];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files[$_SERVER['DownurlStrName']];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']);
+?>
+
+
+ ' . curl_request($files[$_SERVER['DownurlStrName']])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . fetch_files(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'] . '
+
+
+';
+ }
+ }
+ } else {
+ echo '
+
+
+
+
+
+
+
+ ';
+ $statusCode = 401;
+ }
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/tfo_mdtr.php b/theme/tfo_mdtr.php
new file mode 100644
index 0000000..e286954
--- /dev/null
+++ b/theme/tfo_mdtr.php
@@ -0,0 +1,1296 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+';
+?>
+
+';
+?>
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files[$_SERVER['DownurlStrName']];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files[$_SERVER['DownurlStrName']];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']);
+?>
+
+
+ ' . curl_request($files[$_SERVER['DownurlStrName']])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . fetch_files(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'] . '
+
+
+';
+ }
+ }
+ } else {
+ echo '
+
+
+
+
+
+
+
+ ';
+ $statusCode = 401;
+ }
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/tfo_mdtrbaw.php b/theme/tfo_mdtrbaw.php
new file mode 100644
index 0000000..b3d5248
--- /dev/null
+++ b/theme/tfo_mdtrbaw.php
@@ -0,0 +1,1297 @@
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+';
+?>
+
+';
+?>
+
+
+
+
+
+
+
+
+
+ Language
+ $value1) { ?>
+ >
+
+
+
+
+
+
+
+
+
+1) { ?>
+
+
+
+
+
+
+
+
';
+ $statusCode=404;
+ } else {
+ if (isset($files['file'])) {
+?>
+
+
+
+document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" />
+';
+ } elseif (in_array($ext, $exts['video'])) {
+ //echo '
';
+ $DPvideo=$files[$_SERVER['DownurlStrName']];
+ echo '
+';
+ } elseif (in_array($ext, $exts['music'])) {
+ echo '
+';
+ } elseif (in_array($ext, ['pdf'])) {
+ /*echo '
+
+';*/
+ $pdfurl = $files[$_SERVER['DownurlStrName']];
+ echo '
+';
+ } elseif (in_array($ext, $exts['office'])) {
+ echo '
+';
+ } elseif (in_array($ext, $exts['txt'])) {
+ $txtstr = htmlspecialchars(curl_request($files[$_SERVER['DownurlStrName']])['body']);
+?>
+
+
+ ' . curl_request($files[$_SERVER['DownurlStrName']])['body'] . '
+
+';
+ }*/ else {
+ echo '
'.getconstStr('FileNotSupport').' ';
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ foreach ($files['children'] as $file) {
+ // Files
+ if (isset($file['file'])) {
+ if ($_SERVER['admin'] or !isHideFile($file['name'])) {
+ $filenum++; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+200) {
+ $pagenum = $files['folder']['page'];
+ $maxpage = ceil($files['folder']['childCount']/200);
+ $prepagenext = '
+
+
+
+
+ ';
+ if ($pagenum!=1) {
+ $prepagenum = $pagenum-1;
+ $prepagenext .= '
+ '.getconstStr('PrePage').' ';
+ }
+ $prepagenext .= '
+
+ ';
+ for ($page=1;$page<=$maxpage;$page++) {
+ if ($page == $pagenum) {
+ $prepagenext .= '
+ ' . $page . ' ';
+ } else {
+ $prepagenext .= '
+ ' . $page . ' ';
+ }
+ }
+ $prepagenext = substr($prepagenext,0,-1);
+ $prepagenext .= '
+
+ ';
+ if ($pagenum!=$maxpage) {
+ $nextpagenum = $pagenum+1;
+ $prepagenext .= '
+ '.getconstStr('NextPage').' ';
+ }
+ $prepagenext .= '
+
+
+
+ ';
+ echo $prepagenext;
+ }
+ if ($_SERVER['admin']) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . fetch_files(spurlencode(path_format($path . '/readme.md'),'/'))['content']['body'] . '
+
+
+';
+ }
+ }
+ } else {
+ echo '
+
+
+
+
+
+
+
+ ';
+ $statusCode = 401;
+ }
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/update.sh b/update.sh
new file mode 100644
index 0000000..3df4e0c
--- /dev/null
+++ b/update.sh
@@ -0,0 +1,72 @@
+#!bash
+
+if [ $# -eq 0 ]; then
+ echo "
+"$0" -i|u [-b branch]
+ i a new install with empty config.
+ u update use exist config.
+ b install the branch after parameter b, default master
+
+example:
+ "$0" -i
+ "$0" -u
+ "$0" -b master
+ "$0" -u -b master
+ "$0" -ib test
+"
+# exit
+ echo "###############
+0, new install
+1, update"
+ read -p "Input:" c
+ [ g"$c" == g"0" ] && install=1
+ [ g"$c" == g"1" ] && update=1
+fi
+
+i=0
+para[$i]=$0
+for av in "$@"
+do
+#echo $av
+ ((i++))
+ para[$i]=$av
+ if [ g"${av:0:1}" == g"-" ]; then
+ while [ g"$av" != g"" ]
+ do
+ ag=${av:0:1}
+ av=${av:1}
+ [ g"$ag" == g"b" ] && isbranch=1
+ [ g"$ag" == g"i" ] && install=1
+ [ g"$ag" == g"u" ] && update=1
+ done
+ else
+ if [ g"$isbranch" == g"1" ]; then
+ branch="-b $av"
+ isbranch=0
+ fi
+ fi
+done
+
+if [ g"$install" == g"1" -a g"$update" == g"1" ]; then
+ echo "Both install & update, exit"
+ exit
+fi
+if [ g"$install" != g"1" -a g"$update" != g"1" ]; then
+ echo "Not install & Not update, exit"
+ exit
+fi
+
+gitsource='https://github.com/qkqpttgf/OneManager-php'
+
+OneManagerPath=`cd $(dirname $0);pwd -P`
+cd ${OneManagerPath}
+
+git clone ${branch} ${gitsource}
+[ g"$install" == g"1" ] || \mv -b config.php OneManager-php/
+\mv -b OneManager-php/* ./
+\mv -b OneManager-php/.[^.]* ./
+rm -rf *~
+rm -rf .[^.]*~
+rm -rf OneManager-php
+chmod 666 config.php
+
diff --git a/vendor/autoload.php b/vendor/autoload.php
new file mode 100644
index 0000000..8abd9f2
--- /dev/null
+++ b/vendor/autoload.php
@@ -0,0 +1,7 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Composer\Autoload\ClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->add('Symfony\Component', __DIR__.'/component');
+ * $loader->add('Symfony', __DIR__.'/framework');
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * // to enable searching the include path (eg. for PEAR packages)
+ * $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier
+ * @author Jordi Boggiano
+ * @see http://www.php-fig.org/psr/psr-0/
+ * @see http://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ // PSR-4
+ private $prefixLengthsPsr4 = array();
+ private $prefixDirsPsr4 = array();
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ private $prefixesPsr0 = array();
+ private $fallbackDirsPsr0 = array();
+
+ private $useIncludePath = false;
+ private $classMap = array();
+ private $classMapAuthoritative = false;
+ private $missingClasses = array();
+ private $apcuPrefix;
+
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
+ }
+
+ return array();
+ }
+
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param array $classMap Class to filename map
+ */
+ public function addClassMap(array $classMap)
+ {
+ if ($this->classMap) {
+ $this->classMap = array_merge($this->classMap, $classMap);
+ } else {
+ $this->classMap = $classMap;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix, either
+ * appending or prepending to the ones previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param array|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ (array) $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace, either
+ * appending or prepending to the ones previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param array|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ (array) $paths
+ );
+ }
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+ // Register directories for a new namespace.
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix,
+ * replacing any others previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param array|string $paths The PSR-0 base directories
+ */
+ public function set($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr0 = (array) $paths;
+ } else {
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace,
+ * replacing any others previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param array|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function setPsr4($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr4 = (array) $paths;
+ } else {
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Turns on searching the include path for class files.
+ *
+ * @param bool $useIncludePath
+ */
+ public function setUseIncludePath($useIncludePath)
+ {
+ $this->useIncludePath = $useIncludePath;
+ }
+
+ /**
+ * Can be used to check if the autoloader uses the include path to check
+ * for classes.
+ *
+ * @return bool
+ */
+ public function getUseIncludePath()
+ {
+ return $this->useIncludePath;
+ }
+
+ /**
+ * Turns off searching the prefix and fallback directories for classes
+ * that have not been registered with the class map.
+ *
+ * @param bool $classMapAuthoritative
+ */
+ public function setClassMapAuthoritative($classMapAuthoritative)
+ {
+ $this->classMapAuthoritative = $classMapAuthoritative;
+ }
+
+ /**
+ * Should class lookup fail if not found in the current class map?
+ *
+ * @return bool
+ */
+ public function isClassMapAuthoritative()
+ {
+ return $this->classMapAuthoritative;
+ }
+
+ /**
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
+ *
+ * @param string|null $apcuPrefix
+ */
+ public function setApcuPrefix($apcuPrefix)
+ {
+ $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
+ }
+
+ /**
+ * The APCu prefix in use, or null if APCu caching is not enabled.
+ *
+ * @return string|null
+ */
+ public function getApcuPrefix()
+ {
+ return $this->apcuPrefix;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return bool|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ includeFile($file);
+
+ return true;
+ }
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|false The path if found, false otherwise
+ */
+ public function findFile($class)
+ {
+ // class map lookup
+ if (isset($this->classMap[$class])) {
+ return $this->classMap[$class];
+ }
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
+ return false;
+ }
+ if (null !== $this->apcuPrefix) {
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
+ if ($hit) {
+ return $file;
+ }
+ }
+
+ $file = $this->findFileWithExtension($class, '.php');
+
+ // Search for Hack files if we are running on HHVM
+ if (false === $file && defined('HHVM_VERSION')) {
+ $file = $this->findFileWithExtension($class, '.hh');
+ }
+
+ if (null !== $this->apcuPrefix) {
+ apcu_add($this->apcuPrefix.$class, $file);
+ }
+
+ if (false === $file) {
+ // Remember that this class does not exist.
+ $this->missingClasses[$class] = true;
+ }
+
+ return $file;
+ }
+
+ private function findFileWithExtension($class, $ext)
+ {
+ // PSR-4 lookup
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+ $first = $class[0];
+ if (isset($this->prefixLengthsPsr4[$first])) {
+ $subPath = $class;
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
+ $subPath = substr($subPath, 0, $lastPos);
+ $search = $subPath . '\\';
+ if (isset($this->prefixDirsPsr4[$search])) {
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ if (file_exists($file = $dir . $pathEnd)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-4 fallback dirs
+ foreach ($this->fallbackDirsPsr4 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 lookup
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+ } else {
+ // PEAR-like class name
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+ }
+
+ if (isset($this->prefixesPsr0[$first])) {
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($dirs as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-0 fallback dirs
+ foreach ($this->fallbackDirsPsr0 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 include paths.
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+ return $file;
+ }
+
+ return false;
+ }
+}
+
+/**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ */
+function includeFile($file)
+{
+ include $file;
+}
diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE
new file mode 100644
index 0000000..f27399a
--- /dev/null
+++ b/vendor/composer/LICENSE
@@ -0,0 +1,21 @@
+
+Copyright (c) Nils Adermann, Jordi Boggiano
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
new file mode 100644
index 0000000..7a91153
--- /dev/null
+++ b/vendor/composer/autoload_classmap.php
@@ -0,0 +1,9 @@
+ array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'),
+ 'App\\' => array($baseDir . '/app'),
+);
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
new file mode 100644
index 0000000..14baf56
--- /dev/null
+++ b/vendor/composer/autoload_real.php
@@ -0,0 +1,52 @@
+= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
+ if ($useStaticLoader) {
+ require_once __DIR__ . '/autoload_static.php';
+
+ call_user_func(\Composer\Autoload\ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd::getInitializer($loader));
+ } else {
+ $map = require __DIR__ . '/autoload_namespaces.php';
+ foreach ($map as $namespace => $path) {
+ $loader->set($namespace, $path);
+ }
+
+ $map = require __DIR__ . '/autoload_psr4.php';
+ foreach ($map as $namespace => $path) {
+ $loader->setPsr4($namespace, $path);
+ }
+
+ $classMap = require __DIR__ . '/autoload_classmap.php';
+ if ($classMap) {
+ $loader->addClassMap($classMap);
+ }
+ }
+
+ $loader->register(true);
+
+ return $loader;
+ }
+}
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
new file mode 100644
index 0000000..62275fa
--- /dev/null
+++ b/vendor/composer/autoload_static.php
@@ -0,0 +1,39 @@
+
+ array (
+ 'Doctrine\\Common\\Cache\\' => 22,
+ ),
+ 'A' =>
+ array (
+ 'App\\' => 4,
+ ),
+ );
+
+ public static $prefixDirsPsr4 = array (
+ 'Doctrine\\Common\\Cache\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache',
+ ),
+ 'App\\' =>
+ array (
+ 0 => __DIR__ . '/../..' . '/app',
+ ),
+ );
+
+ public static function getInitializer(ClassLoader $loader)
+ {
+ return \Closure::bind(function () use ($loader) {
+ $loader->prefixLengthsPsr4 = ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInit95653bfe69a47d1c8f876456a9c468fd::$prefixDirsPsr4;
+
+ }, null, ClassLoader::class);
+ }
+}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
new file mode 100644
index 0000000..2355284
--- /dev/null
+++ b/vendor/composer/installed.json
@@ -0,0 +1,80 @@
+[
+ {
+ "name": "doctrine/cache",
+ "version": "v1.6.2",
+ "version_normalized": "1.6.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/cache.git",
+ "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b",
+ "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": "~5.5|~7.0"
+ },
+ "conflict": {
+ "doctrine/common": ">2.2,<2.4"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.8|~5.0",
+ "predis/predis": "~1.0",
+ "satooshi/php-coveralls": "~0.6"
+ },
+ "time": "2017-07-22T12:49:21+00:00",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.6.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Caching library offering an object-oriented API for many cache backends",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "cache",
+ "caching"
+ ]
+ }
+]
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
new file mode 100644
index 0000000..89fe323
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
@@ -0,0 +1,116 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Interface for cache drivers.
+ *
+ * @link www.doctrine-project.org
+ * @since 2.0
+ * @author Benjamin Eberlei
+ * @author Guilherme Blanco
+ * @author Jonathan Wage
+ * @author Roman Borschel
+ * @author Fabio B. Silva
+ * @author Kévin Dunglas
+ */
+interface Cache
+{
+ const STATS_HITS = 'hits';
+ const STATS_MISSES = 'misses';
+ const STATS_UPTIME = 'uptime';
+ const STATS_MEMORY_USAGE = 'memory_usage';
+ const STATS_MEMORY_AVAILABLE = 'memory_available';
+ /**
+ * Only for backward compatibility (may be removed in next major release)
+ *
+ * @deprecated
+ */
+ const STATS_MEMORY_AVAILIABLE = 'memory_available';
+
+ /**
+ * Fetches an entry from the cache.
+ *
+ * @param string $id The id of the cache entry to fetch.
+ *
+ * @return mixed The cached data or FALSE, if no cache entry exists for the given id.
+ */
+ public function fetch($id);
+
+ /**
+ * Tests if an entry exists in the cache.
+ *
+ * @param string $id The cache id of the entry to check for.
+ *
+ * @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
+ */
+ public function contains($id);
+
+ /**
+ * Puts data into the cache.
+ *
+ * If a cache entry with the given id already exists, its data will be replaced.
+ *
+ * @param string $id The cache id.
+ * @param mixed $data The cache entry/data.
+ * @param int $lifeTime The lifetime in number of seconds for this cache entry.
+ * If zero (the default), the entry never expires (although it may be deleted from the cache
+ * to make place for other entries).
+ *
+ * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
+ */
+ public function save($id, $data, $lifeTime = 0);
+
+ /**
+ * Deletes a cache entry.
+ *
+ * @param string $id The cache id.
+ *
+ * @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
+ * Deleting a non-existing entry is considered successful.
+ */
+ public function delete($id);
+
+ /**
+ * Retrieves cached information from the data store.
+ *
+ * The server's statistics array has the following values:
+ *
+ * - hits
+ * Number of keys that have been requested and found present.
+ *
+ * - misses
+ * Number of items that have been requested and not found.
+ *
+ * - uptime
+ * Time that the server is running.
+ *
+ * - memory_usage
+ * Memory used by this server to store items.
+ *
+ * - memory_available
+ * Memory allowed to use for storage.
+ *
+ * @since 2.2
+ *
+ * @return array|null An associative array with server's statistics if available, NULL otherwise.
+ */
+ public function getStats();
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
new file mode 100644
index 0000000..9f57923
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
@@ -0,0 +1,312 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Base class for cache provider implementations.
+ *
+ * @since 2.2
+ * @author Benjamin Eberlei
+ * @author Guilherme Blanco
+ * @author Jonathan Wage
+ * @author Roman Borschel
+ * @author Fabio B. Silva
+ */
+abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiGetCache, MultiPutCache
+{
+ const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
+
+ /**
+ * The namespace to prefix all cache ids with.
+ *
+ * @var string
+ */
+ private $namespace = '';
+
+ /**
+ * The namespace version.
+ *
+ * @var integer|null
+ */
+ private $namespaceVersion;
+
+ /**
+ * Sets the namespace to prefix all cache ids with.
+ *
+ * @param string $namespace
+ *
+ * @return void
+ */
+ public function setNamespace($namespace)
+ {
+ $this->namespace = (string) $namespace;
+ $this->namespaceVersion = null;
+ }
+
+ /**
+ * Retrieves the namespace that prefixes all cache ids.
+ *
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fetch($id)
+ {
+ return $this->doFetch($this->getNamespacedId($id));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fetchMultiple(array $keys)
+ {
+ if (empty($keys)) {
+ return array();
+ }
+
+ // note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys
+ $namespacedKeys = array_combine($keys, array_map(array($this, 'getNamespacedId'), $keys));
+ $items = $this->doFetchMultiple($namespacedKeys);
+ $foundItems = array();
+
+ // no internal array function supports this sort of mapping: needs to be iterative
+ // this filters and combines keys in one pass
+ foreach ($namespacedKeys as $requestedKey => $namespacedKey) {
+ if (isset($items[$namespacedKey]) || array_key_exists($namespacedKey, $items)) {
+ $foundItems[$requestedKey] = $items[$namespacedKey];
+ }
+ }
+
+ return $foundItems;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function saveMultiple(array $keysAndValues, $lifetime = 0)
+ {
+ $namespacedKeysAndValues = array();
+ foreach ($keysAndValues as $key => $value) {
+ $namespacedKeysAndValues[$this->getNamespacedId($key)] = $value;
+ }
+
+ return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function contains($id)
+ {
+ return $this->doContains($this->getNamespacedId($id));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function save($id, $data, $lifeTime = 0)
+ {
+ return $this->doSave($this->getNamespacedId($id), $data, $lifeTime);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function delete($id)
+ {
+ return $this->doDelete($this->getNamespacedId($id));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getStats()
+ {
+ return $this->doGetStats();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function flushAll()
+ {
+ return $this->doFlush();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function deleteAll()
+ {
+ $namespaceCacheKey = $this->getNamespaceCacheKey();
+ $namespaceVersion = $this->getNamespaceVersion() + 1;
+
+ if ($this->doSave($namespaceCacheKey, $namespaceVersion)) {
+ $this->namespaceVersion = $namespaceVersion;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Prefixes the passed id with the configured namespace value.
+ *
+ * @param string $id The id to namespace.
+ *
+ * @return string The namespaced id.
+ */
+ private function getNamespacedId($id)
+ {
+ $namespaceVersion = $this->getNamespaceVersion();
+
+ return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
+ }
+
+ /**
+ * Returns the namespace cache key.
+ *
+ * @return string
+ */
+ private function getNamespaceCacheKey()
+ {
+ return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace);
+ }
+
+ /**
+ * Returns the namespace version.
+ *
+ * @return integer
+ */
+ private function getNamespaceVersion()
+ {
+ if (null !== $this->namespaceVersion) {
+ return $this->namespaceVersion;
+ }
+
+ $namespaceCacheKey = $this->getNamespaceCacheKey();
+ $this->namespaceVersion = $this->doFetch($namespaceCacheKey) ?: 1;
+
+ return $this->namespaceVersion;
+ }
+
+ /**
+ * Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
+ *
+ * @param array $keys Array of keys to retrieve from cache
+ * @return array Array of values retrieved for the given keys.
+ */
+ protected function doFetchMultiple(array $keys)
+ {
+ $returnValues = array();
+
+ foreach ($keys as $key) {
+ if (false !== ($item = $this->doFetch($key)) || $this->doContains($key)) {
+ $returnValues[$key] = $item;
+ }
+ }
+
+ return $returnValues;
+ }
+
+ /**
+ * Fetches an entry from the cache.
+ *
+ * @param string $id The id of the cache entry to fetch.
+ *
+ * @return mixed|false The cached data or FALSE, if no cache entry exists for the given id.
+ */
+ abstract protected function doFetch($id);
+
+ /**
+ * Tests if an entry exists in the cache.
+ *
+ * @param string $id The cache id of the entry to check for.
+ *
+ * @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
+ */
+ abstract protected function doContains($id);
+
+ /**
+ * Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
+ *
+ * @param array $keysAndValues Array of keys and values to save in cache
+ * @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
+ * cache entries (0 => infinite lifeTime).
+ *
+ * @return bool TRUE if the operation was successful, FALSE if it wasn't.
+ */
+ protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
+ {
+ $success = true;
+
+ foreach ($keysAndValues as $key => $value) {
+ if (!$this->doSave($key, $value, $lifetime)) {
+ $success = false;
+ }
+ }
+
+ return $success;
+ }
+
+ /**
+ * Puts data into the cache.
+ *
+ * @param string $id The cache id.
+ * @param string $data The cache entry/data.
+ * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
+ * cache entry (0 => infinite lifeTime).
+ *
+ * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
+ */
+ abstract protected function doSave($id, $data, $lifeTime = 0);
+
+ /**
+ * Deletes a cache entry.
+ *
+ * @param string $id The cache id.
+ *
+ * @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
+ */
+ abstract protected function doDelete($id);
+
+ /**
+ * Flushes all cache entries.
+ *
+ * @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
+ */
+ abstract protected function doFlush();
+
+ /**
+ * Retrieves cached information from the data store.
+ *
+ * @since 2.2
+ *
+ * @return array|null An associative array with server's statistics if available, NULL otherwise.
+ */
+ abstract protected function doGetStats();
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
new file mode 100644
index 0000000..3a91eaf
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
@@ -0,0 +1,40 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Interface for cache that can be flushed.
+ *
+ * Intended to be used for partial clearing of a cache namespace. For a more
+ * global "flushing", see {@see FlushableCache}.
+ *
+ * @link www.doctrine-project.org
+ * @since 1.4
+ * @author Adirelle
+ */
+interface ClearableCache
+{
+ /**
+ * Deletes all cache entries in the current cache namespace.
+ *
+ * @return bool TRUE if the cache entries were successfully deleted, FALSE otherwise.
+ */
+ public function deleteAll();
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php
new file mode 100644
index 0000000..b2e0427
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FileCache.php
@@ -0,0 +1,286 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Base file cache driver.
+ *
+ * @since 2.3
+ * @author Fabio B. Silva
+ * @author Tobias Schultze
+ */
+abstract class FileCache extends CacheProvider
+{
+ /**
+ * The cache directory.
+ *
+ * @var string
+ */
+ protected $directory;
+
+ /**
+ * The cache file extension.
+ *
+ * @var string
+ */
+ private $extension;
+
+ /**
+ * @var int
+ */
+ private $umask;
+
+ /**
+ * @var int
+ */
+ private $directoryStringLength;
+
+ /**
+ * @var int
+ */
+ private $extensionStringLength;
+
+ /**
+ * @var bool
+ */
+ private $isRunningOnWindows;
+
+ /**
+ * Constructor.
+ *
+ * @param string $directory The cache directory.
+ * @param string $extension The cache file extension.
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct($directory, $extension = '', $umask = 0002)
+ {
+ // YES, this needs to be *before* createPathIfNeeded()
+ if ( ! is_int($umask)) {
+ throw new \InvalidArgumentException(sprintf(
+ 'The umask parameter is required to be integer, was: %s',
+ gettype($umask)
+ ));
+ }
+ $this->umask = $umask;
+
+ if ( ! $this->createPathIfNeeded($directory)) {
+ throw new \InvalidArgumentException(sprintf(
+ 'The directory "%s" does not exist and could not be created.',
+ $directory
+ ));
+ }
+
+ if ( ! is_writable($directory)) {
+ throw new \InvalidArgumentException(sprintf(
+ 'The directory "%s" is not writable.',
+ $directory
+ ));
+ }
+
+ // YES, this needs to be *after* createPathIfNeeded()
+ $this->directory = realpath($directory);
+ $this->extension = (string) $extension;
+
+ $this->directoryStringLength = strlen($this->directory);
+ $this->extensionStringLength = strlen($this->extension);
+ $this->isRunningOnWindows = defined('PHP_WINDOWS_VERSION_BUILD');
+ }
+
+ /**
+ * Gets the cache directory.
+ *
+ * @return string
+ */
+ public function getDirectory()
+ {
+ return $this->directory;
+ }
+
+ /**
+ * Gets the cache file extension.
+ *
+ * @return string
+ */
+ public function getExtension()
+ {
+ return $this->extension;
+ }
+
+ /**
+ * @param string $id
+ *
+ * @return string
+ */
+ protected function getFilename($id)
+ {
+ $hash = hash('sha256', $id);
+
+ // This ensures that the filename is unique and that there are no invalid chars in it.
+ if (
+ '' === $id
+ || ((strlen($id) * 2 + $this->extensionStringLength) > 255)
+ || ($this->isRunningOnWindows && ($this->directoryStringLength + 4 + strlen($id) * 2 + $this->extensionStringLength) > 258)
+ ) {
+ // Most filesystems have a limit of 255 chars for each path component. On Windows the the whole path is limited
+ // to 260 chars (including terminating null char). Using long UNC ("\\?\" prefix) does not work with the PHP API.
+ // And there is a bug in PHP (https://bugs.php.net/bug.php?id=70943) with path lengths of 259.
+ // So if the id in hex representation would surpass the limit, we use the hash instead. The prefix prevents
+ // collisions between the hash and bin2hex.
+ $filename = '_' . $hash;
+ } else {
+ $filename = bin2hex($id);
+ }
+
+ return $this->directory
+ . DIRECTORY_SEPARATOR
+ . substr($hash, 0, 2)
+ . DIRECTORY_SEPARATOR
+ . $filename
+ . $this->extension;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doDelete($id)
+ {
+ $filename = $this->getFilename($id);
+
+ return @unlink($filename) || ! file_exists($filename);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doFlush()
+ {
+ foreach ($this->getIterator() as $name => $file) {
+ if ($file->isDir()) {
+ // Remove the intermediate directories which have been created to balance the tree. It only takes effect
+ // if the directory is empty. If several caches share the same directory but with different file extensions,
+ // the other ones are not removed.
+ @rmdir($name);
+ } elseif ($this->isFilenameEndingWithExtension($name)) {
+ // If an extension is set, only remove files which end with the given extension.
+ // If no extension is set, we have no other choice than removing everything.
+ @unlink($name);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doGetStats()
+ {
+ $usage = 0;
+ foreach ($this->getIterator() as $name => $file) {
+ if (! $file->isDir() && $this->isFilenameEndingWithExtension($name)) {
+ $usage += $file->getSize();
+ }
+ }
+
+ $free = disk_free_space($this->directory);
+
+ return array(
+ Cache::STATS_HITS => null,
+ Cache::STATS_MISSES => null,
+ Cache::STATS_UPTIME => null,
+ Cache::STATS_MEMORY_USAGE => $usage,
+ Cache::STATS_MEMORY_AVAILABLE => $free,
+ );
+ }
+
+ /**
+ * Create path if needed.
+ *
+ * @param string $path
+ * @return bool TRUE on success or if path already exists, FALSE if path cannot be created.
+ */
+ private function createPathIfNeeded($path)
+ {
+ if ( ! is_dir($path)) {
+ if (false === @mkdir($path, 0777 & (~$this->umask), true) && !is_dir($path)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Writes a string content to file in an atomic way.
+ *
+ * @param string $filename Path to the file where to write the data.
+ * @param string $content The content to write
+ *
+ * @return bool TRUE on success, FALSE if path cannot be created, if path is not writable or an any other error.
+ */
+ protected function writeFile($filename, $content)
+ {
+ $filepath = pathinfo($filename, PATHINFO_DIRNAME);
+
+ if ( ! $this->createPathIfNeeded($filepath)) {
+ return false;
+ }
+
+ if ( ! is_writable($filepath)) {
+ return false;
+ }
+
+ $tmpFile = tempnam($filepath, 'swap');
+ @chmod($tmpFile, 0666 & (~$this->umask));
+
+ if (file_put_contents($tmpFile, $content) !== false) {
+ if (@rename($tmpFile, $filename)) {
+ return true;
+ }
+
+ @unlink($tmpFile);
+ }
+
+ return false;
+ }
+
+ /**
+ * @return \Iterator
+ */
+ private function getIterator()
+ {
+ return new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+ }
+
+ /**
+ * @param string $name The filename
+ *
+ * @return bool
+ */
+ private function isFilenameEndingWithExtension($name)
+ {
+ return '' === $this->extension
+ || strrpos($name, $this->extension) === (strlen($name) - $this->extensionStringLength);
+ }
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php
new file mode 100644
index 0000000..d988294
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FilesystemCache.php
@@ -0,0 +1,111 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Filesystem cache driver.
+ *
+ * @since 2.3
+ * @author Fabio B. Silva
+ */
+class FilesystemCache extends FileCache
+{
+ const EXTENSION = '.doctrinecache.data';
+
+ /**
+ * {@inheritdoc}
+ */
+ public function __construct($directory, $extension = self::EXTENSION, $umask = 0002)
+ {
+ parent::__construct($directory, $extension, $umask);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doFetch($id)
+ {
+ $data = '';
+ $lifetime = -1;
+ $filename = $this->getFilename($id);
+
+ if ( ! is_file($filename)) {
+ return false;
+ }
+
+ $resource = fopen($filename, "r");
+
+ if (false !== ($line = fgets($resource))) {
+ $lifetime = (int) $line;
+ }
+
+ if ($lifetime !== 0 && $lifetime < time()) {
+ fclose($resource);
+
+ return false;
+ }
+
+ while (false !== ($line = fgets($resource))) {
+ $data .= $line;
+ }
+
+ fclose($resource);
+
+ return unserialize($data);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doContains($id)
+ {
+ $lifetime = -1;
+ $filename = $this->getFilename($id);
+
+ if ( ! is_file($filename)) {
+ return false;
+ }
+
+ $resource = fopen($filename, "r");
+
+ if (false !== ($line = fgets($resource))) {
+ $lifetime = (int) $line;
+ }
+
+ fclose($resource);
+
+ return $lifetime === 0 || $lifetime > time();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doSave($id, $data, $lifeTime = 0)
+ {
+ if ($lifeTime > 0) {
+ $lifeTime = time() + $lifeTime;
+ }
+
+ $data = serialize($data);
+ $filename = $this->getFilename($id);
+
+ return $this->writeFile($filename, $lifeTime . PHP_EOL . $data);
+ }
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
new file mode 100644
index 0000000..4311d4f
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
@@ -0,0 +1,37 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Interface for cache that can be flushed.
+ *
+ * @link www.doctrine-project.org
+ * @since 1.4
+ * @author Adirelle
+ */
+interface FlushableCache
+{
+ /**
+ * Flushes all cache entries, globally.
+ *
+ * @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
+ */
+ public function flushAll();
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
new file mode 100644
index 0000000..df7146d
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
@@ -0,0 +1,39 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Interface for cache drivers that allows to get many items at once.
+ *
+ * @link www.doctrine-project.org
+ * @since 1.4
+ * @author Asmir Mustafic
+ */
+interface MultiGetCache
+{
+ /**
+ * Returns an associative array of values for keys is found in cache.
+ *
+ * @param string[] $keys Array of keys to retrieve from cache
+ * @return mixed[] Array of retrieved values, indexed by the specified keys.
+ * Values that couldn't be retrieved are not contained in this array.
+ */
+ function fetchMultiple(array $keys);
+}
diff --git a/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
new file mode 100644
index 0000000..bf87ea9
--- /dev/null
+++ b/vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
@@ -0,0 +1,41 @@
+.
+ */
+
+namespace Doctrine\Common\Cache;
+
+/**
+ * Interface for cache drivers that allows to put many items at once.
+ *
+ * @link www.doctrine-project.org
+ * @since 1.6
+ * @author Daniel Gorgan
+ */
+interface MultiPutCache
+{
+ /**
+ * Returns a boolean value indicating if the operation succeeded.
+ *
+ * @param array $keysAndValues Array of keys and values to save in cache
+ * @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
+ * cache entries (0 => infinite lifeTime).
+ *
+ * @return bool TRUE if the operation was successful, FALSE if it wasn't.
+ */
+ function saveMultiple(array $keysAndValues, $lifetime = 0);
+}
diff --git a/version b/version
new file mode 100644
index 0000000..3aec2e4
--- /dev/null
+++ b/version
@@ -0,0 +1,81 @@
+20200828-1420.26
+nginx rewrite rule exclude .well-known folder, as auto SSL. add web.config to rewrite in IIS. now in windwos can do with \ in path. in aliyun FC & huawei FG API, use my code. CN 21Vianet client_id&secret expire. update description now only show new.
+nginx的伪静态中排除.well-known目录,方便自动SSL。添加IIS的伪静态。与linux不同,处理windows下目录用\分隔。FC、FG中使用自己代码对接平台。世纪互联旧API即将过期失效,升级后世纪互联的盘需要删除重新添加。 更新说明只显示部分。
+
+20200817-1740.25
+when multy disks, now will default show disks as folders in root, if set autoJumpFirstDisk 1, it will auto jump to first disk.
+多盘时,在网站根目录,默认会将各盘当成文件夹显示,可以去设置中设置autoJumpFirstDisk为1,这样可以跟以前一样自动跳到第一个盘。
+20200816-1145.24
+add platform: Baidu CFC. add setting: mobile background.
+新增百度CFC平台。可以分别设置PC与手机的背景。
+20200808-1130.23
+FG: select save in env or file.
+在FG中安装时,选择配置保存在环境变量还是文件中。
+20200806-1130.23
+SCF: select save in env or file.
+在SCF中安装时,选择配置保存在环境变量还是文件中。
+20200804-1453.22
+fix: once error will stop the after files in uploading multy files. SCF can get region now, change install. SCF config save in code file now not in env, if use SCF, you must reinstall after update .
+修复,当上传多个文件时,一个文件出错将导致后续文件不再上传。SCF可以获取到region了,安装过程修改。在SCF中,现在将配置保存到代码文件中,不受环境变量4K大小限制,升级后,用SCF的要重装 。
+20200723-1430.21
+fix content-type in "?json". can not custom microsoft API id & secret by a link now, so show the return uri.
+当使用"?json"时,现在content-type是json了。现在微软不能一键创建API应用了,提供回调URI。
+20200713-1800.20
+add platform: Huawei cloud Function Graph. now you can use "?json" to get a json of folder or file. fix some bug.
+新增白嫖平台:华为云函数工作流FG。可以用"?json"来获得目录或文件的json。修复bug。
+20200607-1856.19
+add platform: Aliyun Function Compute. add setting: replace sharepoint.com to a proxy server name. add setting: disableShowThumb,customTheme. add function: php hosting website can update by a click
+现在可以安装到阿里函数计算FC了。php空间可以一键更新了。可以设置某个盘替换sharpoint.com域名为你的反代域名。新增disableShowThumb,customTheme。
+20200503-1848.18
+Rebuild theme. Add custom Css & custom Script, add FunctionalityFile: head.omf & foot.omf.
+重建主题文件结构。增加自定义css与自定义script。增加2个功能文件:head.omf、foot.omf。
+20200402-1830.17
+Oneclick update can select which branch to update. Now use the accept language instead of the language config.
+一键更新可以选择哪个分支了。现在开始使用浏览器语言,抛弃language设置。
+20200326-0001.16
+You can add sharepoint site drive as a disk, you must reinstall after update .
+可以将sharepoint网站添加成一个盘,由于结构改变,升级后只能重装 。
+20200321-1830.15
+本次更新后,'index.html'功能在其它主题会导致bug。
+文本类文件将缓存;添加hideFunctionalityFile开关;在添加网盘时会显示已经在用的标签。
+after this update, then 'index.html' function will bug in other theme.
+cache text file content;add hideFunctionalityFile;list exist disktags when AddDisk。
+20200311-2150.14
+Add a switch, can download a known file or not, while the folder is encrypted.
+Hide time and size in mobile.
+Now, you can get a random 'jpg' from a folder when you type '?random=jpg' after the folder.
+增加一个开关,在目录加密后能否下载其中的某个文件。
+在手机上浏览时,隐藏修改时间跟大小。
+加入一个功能,现在可以在某个目录后面加上'?random=jpg'来得到本目录里面的一张随机jpg。
+20200229-1300.13
+In SCF, some config can input Special symbols now, like ?&= 。
+在SCF中,某些配置可以输入特殊符号了,像background可以用?&=之类的了。
+20200225-1310.12
+Can update by one click any time. fix bugs: special tag, reupload.
+可以不管版本直接一键更新(覆盖)了。修复可以使用特殊onedrive标签的bug,修复断网续传的问题。
+20200222-2130.11
+you can set background now. fix bug: 2nd disk upload.
+可以设置背景图片了。第2个盘上传后链接不对。
+20200222-1700.09
+Can copy file and folder now.
+可以复制文件跟目录了。
+20200220-1220.08
+Multy Mode! You can add more Onedrive in one project (bind Onedrive in setup). And now, heroku apps can update in setup!
+多盘来了,在设置中添加Onedrive,另,heroku 上也能一键更新了!
+20200215-1850.07
+fix: head.md not show if no readme.md.
+修复当没有readme的时候就不显示head的问题。
+20200215-1700.06
+classic theme can read the head.md file now.
+classic主题可以处理head.md文件了。
+20200202-2010.05
+refresh token expires in 90 day, save a new token per month. classic theme add some icon for admin.
+refresh token 90天过期,所以每月保存一个新的token。classic主题加了点管理图标。
+20200129-2050.04
+if there is 'index.html', then do not show file but show the index.html, except admin.
+如果有index.html,就不显示文件列表了,直接显示index.html内容,除非是管理员。
+20200120.02
+fix domain_path do not work. domain_path正常工作了。
+20200118.01
+Can be deploy to heroku/SCF/normal space. SCF、heroku、普通VPS,三种环境都可以用了。
+Change imgup_path to guestup_path, plz make sure it after update. 将imgup_path改成guestup_path更符合用途,更新后请注意更改。
diff --git a/web.config b/web.config
new file mode 100644
index 0000000..18e4239
--- /dev/null
+++ b/web.config
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/writeable.sh b/writeable.sh
new file mode 100644
index 0000000..8d3b5dc
--- /dev/null
+++ b/writeable.sh
@@ -0,0 +1,3 @@
+OneManagerPath=`cd $(dirname $0);pwd -P`
+cd ${OneManagerPath}
+chmod 666 config.php