From af90ff91f7de67059d3bdd9c89d2372a5e794d8f Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 16 Nov 2021 11:24:28 +0800 Subject: [PATCH 01/62] fix ' in path cause js error --- common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.php b/common.php index a2723a1..672438d 100644 --- a/common.php +++ b/common.php @@ -2559,7 +2559,7 @@ function render_list($path = '', $files = []) 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($path1.'/'))), $html); + $html = str_replace('', str_replace('\'', '\\\'', str_replace('%23', '#', str_replace('&','&', path_format($path1.'/')))), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Home'), $html); $html = str_replace('', getConfig('customCss'), $html); From 51d7e13ca539ecafa82b174f78e4a05050409acf Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 16 Nov 2021 13:35:03 +0800 Subject: [PATCH 02/62] sort config in vercel file --- platform/Vercel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/Vercel.php b/platform/Vercel.php index 07d0dd6..6a65b2f 100644 --- a/platform/Vercel.php +++ b/platform/Vercel.php @@ -151,6 +151,7 @@ function setConfig($arr, $disktag = '') } $envs = array_filter($envs, 'array_value_isnot_null'); //ksort($envs); + sortConfig($envs); //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT)); //echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT); return setVercelConfig($envs, getConfig('HerokuappId'), getConfig('APIKey')); From e0d7bba0fb7ad4dd8213fb5fde6e1d31e6ace6d6 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 23 Nov 2021 19:59:41 +0800 Subject: [PATCH 03/62] Redirect when folder not end with / (fix disktag with no /) --- common.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 672438d..30c3c1e 100644 --- a/common.php +++ b/common.php @@ -249,7 +249,8 @@ function main($path) return output('Please visit ' . $tmp . '.', 302, [ 'Location' => $tmp ]); //return message('Please visit from Home Page.', 'Error', 404); } - $path = substr($path, strlen('/' . $_SERVER['disktag'])); + //$path = substr($path, strlen('/' . $_SERVER['disktag'])); + $path = splitfirst($path, $_SERVER['disktag'])[1]; if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path'] . '/' . $_SERVER['disktag'] . '/'); } } else $_SERVER['disktag'] = $disktags[0]; @@ -358,7 +359,8 @@ function main($path) } else { $files = $drive->list_files($path1); } - if ($path!=='') if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { + //if ($path!=='') + if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { $tmp = path_format($_SERVER['base_disk_path'] . $path . '/'); return output(' @@ -1207,6 +1209,7 @@ function splitfirst($str, $split) $tmp[0] = ''; $tmp[1] = substr($str, $len); } + if ($tmp[1]===false) $tmp[1] = ''; return $tmp; } @@ -1224,6 +1227,7 @@ function splitlast($str, $split) $tmp[0] = ''; $tmp[1] = substr($str, $len); } + if ($tmp[1]===false) $tmp[1] = ''; return $tmp; } From 78c616b52d58f2e95857f5f9c7ec8b3e839afff5 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 23 Nov 2021 20:07:55 +0800 Subject: [PATCH 04/62] fix sort when size is TB #470 , --- theme/classic.html | 1 + 1 file changed, 1 insertion(+) diff --git a/theme/classic.html b/theme/classic.html index 17b04a9..6e2e242 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -785,6 +785,7 @@ } function size_reformat(str) { if (str.substr(-1)==' ') str=str.substr(0,str.length-1); + if (str.substr(-2)=='TB') num=str.substr(0,str.length-3)*1024*1024*1024*1024; if (str.substr(-2)=='GB') num=str.substr(0,str.length-3)*1024*1024*1024; if (str.substr(-2)=='MB') num=str.substr(0,str.length-3)*1024*1024; if (str.substr(-2)=='KB') num=str.substr(0,str.length-3)*1024; From a44ca9f83cea2d3ded5071af9d926ebdbfefe04f Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 25 Nov 2021 14:06:13 +0800 Subject: [PATCH 05/62] login by jump not dialog --- theme/renexmoe.html | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/theme/renexmoe.html b/theme/renexmoe.html index ab8b520..21e87f2 100644 --- a/theme/renexmoe.html +++ b/theme/renexmoe.html @@ -98,13 +98,9 @@
-
  • - account_circle登录 +
  • + account_circle + 登录
  • From 340c84ef7667e6632db43e99cebb8ce0a43a2b6f Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Thu, 25 Nov 2021 15:46:06 +0800 Subject: [PATCH 06/62] try clear cache after upload done --- common.php | 1 + 1 file changed, 1 insertion(+) diff --git a/common.php b/common.php index 30c3c1e..35b1173 100644 --- a/common.php +++ b/common.php @@ -303,6 +303,7 @@ function main($path) if ($_SERVER['ajax']) { if ($_GET['action']=='del_upload_cache') { // del '.tmp' without login. 无需登录即可删除.tmp后缀文件 + savecache('path_' . $path1, '', $_SERVER['disktag'], 1); // clear cache. return $drive->del_upload_cache($path); } if ($_GET['action']=='upbigfile') { From e6abbc6086ed6dcad9bce06793610ac45fd2813e Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 26 Nov 2021 09:46:25 +0800 Subject: [PATCH 07/62] fix back link with spacialChar --- common.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common.php b/common.php index 35b1173..07fdb1a 100644 --- a/common.php +++ b/common.php @@ -1402,7 +1402,14 @@ function EnvOpt($needUpdate = 0) $preurl = path_format($_SERVER['PHP_SELF'] . '/'); } $html .= ' -' . getconstStr('Back') . '
    +' . getconstStr('Back') . '
    + '; if ($_GET['setup']==='cmd') { $statusCode = 200; From 6383864bb674fa752bdbb53c1c2956d6150cd7ec Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:54:39 +0800 Subject: [PATCH 08/62] short fix back link when spacialChar --- common.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/common.php b/common.php index 07fdb1a..14bb5af 100644 --- a/common.php +++ b/common.php @@ -1396,19 +1396,10 @@ function EnvOpt($needUpdate = 0) } } else return message('please login again', 'Need login', 403); - if (isset($_GET['preview'])) { - $preurl = $_SERVER['PHP_SELF'] . '?preview'; - } else { - $preurl = path_format($_SERVER['PHP_SELF'] . '/'); - } $html .= ' -' . getconstStr('Back') . '
    +' . getconstStr('Back') . '
    '; if ($_GET['setup']==='cmd') { From 9fdd9227a53cdf49d2c29e6f0c99266ca2d767b3 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sat, 27 Nov 2021 12:38:49 +0800 Subject: [PATCH 09/62] remove ts, add 3gp --- conststr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conststr.php b/conststr.php index 4b72019..50db96b 100644 --- a/conststr.php +++ b/conststr.php @@ -7,7 +7,7 @@ $exts['img'] = ['ico', 'bmp', 'gif', 'jpg', 'jpeg', 'jpe', 'jfif', 'tif', 'tiff' $exts['music'] = ['mp3', 'wma', 'flac', 'ape', 'wav', 'ogg', 'm4a']; $exts['office'] = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; $exts['txt'] = ['txt', 'bat', 'sh', 'php', 'asp', 'js', 'css', 'json', 'html', 'c', 'cpp', 'md', 'py', 'omf']; -$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', 'ts', 'rmvb']; +$exts['video'] = ['mp4', 'webm', 'mkv', 'mov', 'flv', 'blv', 'avi', 'wmv', 'm3u8', 'rm', '3gp', 'rmvb']; $exts['zip'] = ['zip', 'rar', '7z', 'gz', 'tar']; $constStr = [ From 42e06e647d6405ef7a9de10e3b66eef164a1b5f4 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:23:18 +0800 Subject: [PATCH 10/62] mv waitfunction before install, add setp=auth --- common.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/common.php b/common.php index 14bb5af..3693263 100644 --- a/common.php +++ b/common.php @@ -167,6 +167,13 @@ function main($path) if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone']; if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0; + if (isset($_GET['WaitFunction'])) { + $response = WaitFunction($_GET['WaitFunction']); + //var_dump($response); + if ($response===true) return output("ok", 200); + elseif ($response===false) return output("", 206); + else return $response; + } if (getConfig('admin')=='') return install(); if (getConfig('adminloginpage')=='') { $adminloginpage = 'admin'; @@ -204,13 +211,6 @@ function main($path) $url = path_format($_SERVER['PHP_SELF'] . '/'); return output('', 302, [ 'Location' => $url ]); } - if (isset($_GET['WaitFunction'])) { - $response = WaitFunction($_GET['WaitFunction']); - //var_dump($response); - if ($response===true) return output("ok", 200); - elseif ($response===false) return output("", 206); - else return $response; - } $_SERVER['sitename'] = getConfig('sitename'); if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename'); @@ -616,7 +616,7 @@ function filecache($disktag) { $dir = sys_get_temp_dir(); if (!is_writable($dir)) { - $tmp = __DIR__ . '/tmp/'; + $tmp = $_SERVER['HTTP_HOST'] . '/tmp/'; if (file_exists($tmp)) { if ( is_writable($tmp) ) $dir = $tmp; } elseif ( mkdir($tmp) ) $dir = $tmp; @@ -636,10 +636,10 @@ function sortConfig(&$arr) { ksort($arr); - $tags = explode('|', $arr['disktag']); - unset($arr['disktag']); - if ($tags[0]!='') { - foreach($tags as $tag) { + if (isset($arr['disktag'])) { + $tags = explode('|', $arr['disktag']); + unset($arr['disktag']); + foreach($tags as $tag) if (isset($arr[$tag])) { $disks[$tag] = $arr[$tag]; unset($arr[$tag]); } @@ -920,7 +920,7 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0) //setTimeout(function() { getStatus() }, 1000); } } else if (xhr.status==206) { - errordiv.innerHTML = min + "
    ' . getconstStr('Wait') . '" + x; + errordiv.innerHTML = "' . getconstStr('Wait') . '" + x + "
    " + min; setTimeout(function() { getStatus() }, 1000); } else { errordiv.innerHTML = "ERROR
    " + xhr.status + "
    " + xhr.responseText; @@ -1405,8 +1405,9 @@ function EnvOpt($needUpdate = 0) if ($_GET['setup']==='cmd') { $statusCode = 200; $html .= ' +OneManager DIR: ' . __DIR__ . '
    -
    +
    '; if ($_POST['cmd']!='') { @@ -1436,6 +1437,9 @@ output: '; return message($html, 'Run cmd', $statusCode); } + if ($_GET['setup']==='auth') { + return changeAuthKey(); + } if ($_GET['setup']==='platform') { $frame .= ' From 41ca3bc56f2c3868cf18b7e84f339db8f36c8787 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:24:38 +0800 Subject: [PATCH 11/62] try fix no driver in config sometime --- disk/Onedrive.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/disk/Onedrive.php b/disk/Onedrive.php index cdf1b23..3ae42a0 100644 --- a/disk/Onedrive.php +++ b/disk/Onedrive.php @@ -611,6 +611,7 @@ class Onedrive { texta[i].style.height = texta[i].scrollHeight + \'px\'; } '; + $tmptoken['Driver'] = get_class($this); $tmptoken['refresh_token'] = $refresh_token; $tmptoken['token_expires'] = time()+7*24*60*60; $response = setConfigResponse( setConfig($tmptoken, $this->disktag) ); @@ -733,7 +734,7 @@ class Onedrive {
    @@ -743,7 +744,7 @@ class Onedrive {
    From 7fbc9c8285da6ec3f3e9691b54b613ce046088a9 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:26:01 +0800 Subject: [PATCH 12/62] add setup=auth --- platform/AliyunFC.php | 77 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/platform/AliyunFC.php b/platform/AliyunFC.php index 2618d89..7c2414f 100644 --- a/platform/AliyunFC.php +++ b/platform/AliyunFC.php @@ -185,16 +185,16 @@ function install() if ($_GET['install1']) { //if ($_POST['admin']!='') { $tmp['timezone'] = $_COOKIE['timezone']; - $AccessKeyID = getConfig('AccessKeyID'); - if ($AccessKeyID=='') { + //$AccessKeyID = getConfig('AccessKeyID'); + //if ($AccessKeyID=='') { $AccessKeyID = $_POST['AccessKeyID']; $tmp['AccessKeyID'] = $AccessKeyID; - } - $AccessKeySecret = getConfig('AccessKeySecret'); - if ($AccessKeySecret=='') { + //} + //$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); @@ -229,12 +229,13 @@ language:
    '; $html .= '
    '; } - if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= ' - '.getconstStr('Create').' AccessKeyID & AccessKeySecret
    -
    -
    '; + //if (getConfig('AccessKeyID')==''||getConfig('AccessKeySecret')=='') $html .= ' - + ' . getconstStr('Create') . ' AccessKeyID & AccessKeySecret
    +
    +
    '; + $html .= ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + ' . getconstStr('Create') . ' AccessKeyID & AccessKeySecret
    +
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From 7d56bde181425c31ccfe0ef2aa97840f5a903fe1 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:29:16 +0800 Subject: [PATCH 13/62] add setup=auth --- platform/BaiduCFC.php | 79 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/platform/BaiduCFC.php b/platform/BaiduCFC.php index f2b21e6..6a2c74a 100644 --- a/platform/BaiduCFC.php +++ b/platform/BaiduCFC.php @@ -1,4 +1,6 @@ '; $html .= '
    '; } - if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' - '.getconstStr('Create').' Access Key & Secret Key
    -
    -
    '; + //if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' - + ' . getconstStr('Create') . ' Access Key & Secret Key
    +
    +
    '; + $html .= ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + ' . getconstStr('Create') . ' Access Key & Secret Key
    +
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From 92d440107045ad2cefcebef41e8e14f5d37f2e0d Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:30:36 +0800 Subject: [PATCH 14/62] add setup=auth --- platform/Heroku.php | 78 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 13 deletions(-) diff --git a/platform/Heroku.php b/platform/Heroku.php index 971463e..2fc2c05 100644 --- a/platform/Heroku.php +++ b/platform/Heroku.php @@ -170,11 +170,8 @@ function install() $tmp['admin'] = $_POST['admin']; //$tmp['language'] = $_POST['language']; $tmp['timezone'] = $_COOKIE['timezone']; - $APIKey = getConfig('APIKey'); - if ($APIKey=='') { - $APIKey = $_POST['APIKey']; - $tmp['APIKey'] = $APIKey; - } + $APIKey = $_POST['APIKey']; + $tmp['APIKey'] = $APIKey; $HerokuappId = getConfig('HerokuappId'); if ($HerokuappId=='') { $function_name = getConfig('function_name'); @@ -197,17 +194,27 @@ function install() if (api_error($response)) { $html = api_error_msg($response); $title = 'Error'; + return message($html, $title, 400); } else { - return output('Jump + $html = getconstStr('Success') . ' - ', 302); + var status = "' . $response['DplStatus'] . '"; + var i = 0; + var uploadList = setInterval(function(){ + if (document.getElementById("dis").style.display=="none") { + console.log(i++); + } else { + clearInterval(uploadList); + location.href = "' . path_format($_SERVER['base_path'] . '/') . '"; + } + }, 1000); + '; + return message($html, $title, 201, 1); } - return message($html, $title, 201); } } if ($_GET['install0']) { @@ -218,9 +225,9 @@ language:
    '; $html .= '
    '; } - if (getConfig('APIKey')=='') $html .= ' - '.getconstStr('Create').' API Key
    -
    '; + $html .= ' + ' . getconstStr('Create') . ' API Key
    +
    '; $html .= '
    '; $html .= ' @@ -247,7 +254,7 @@ language:
    '; alert(\'input admin\'); return false; }'; - if (getConfig('APIKey')=='') $html .= ' + $html .= ' if (t.APIKey.value==\'\') { alert(\'input API Key\'); return false; @@ -358,3 +365,48 @@ function WaitFunction($buildId = '') { return $response; } } + +function changeAuthKey() { + if ($_POST['APIKey']!='') { + $APIKey = $_POST['APIKey']; + $tmp['APIKey'] = $APIKey; + $response = setConfigResponse( setHerokuConfig($tmp, getConfig('HerokuappId'), $APIKey) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + '.getconstStr('Create').' API Key
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From eee1c5511adebb55abb0f63e72a6d6b905c63302 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:36:52 +0800 Subject: [PATCH 15/62] add setup=auth --- platform/HuaweiFG_env.php | 77 +++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/platform/HuaweiFG_env.php b/platform/HuaweiFG_env.php index d3cebd9..f662608 100644 --- a/platform/HuaweiFG_env.php +++ b/platform/HuaweiFG_env.php @@ -1,4 +1,7 @@ '; $html .= '
    '; } - if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' + //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') + $html .= ' 在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:

    点击链接,新增访问密钥, 在下载的credentials.csv文件中找到对应信息,填入:

    -
    '; +
    '; $html .= '

    '; @@ -273,7 +268,8 @@ language:
    '; } function notnull(t) {'; - if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' + //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') + $html .= ' if (t.HW_urn.value==\'\') { alert(\'input URN\'); return false; @@ -491,3 +487,54 @@ function addFileToZip($zip, $rootpath, $path = '') function WaitFunction() { return true; } + +function changeAuthKey() { + if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') { + $tmp['HW_key'] = $_POST['HW_key']; + $tmp['HW_secret'] = $_POST['HW_secret']; + $response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + 点击链接,新增访问密钥, + 在下载的credentials.csv文件中找到对应信息,填入:
    +
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From 717b4542566e147bf6e5a7ba5d98a37cf05c7d75 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:38:07 +0800 Subject: [PATCH 16/62] add setup=auth --- platform/HuaweiFG_file.php | 81 ++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/platform/HuaweiFG_file.php b/platform/HuaweiFG_file.php index 64e6199..abddc7f 100644 --- a/platform/HuaweiFG_file.php +++ b/platform/HuaweiFG_file.php @@ -1,4 +1,7 @@ '; $html .= '
    '; } - if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' + //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') + $html .= ' 在函数代码操作页上方找到URN,鼠标放上去后显示URN,复制填入:

    点击链接,新增访问密钥, 在下载的credentials.csv文件中找到对应信息,填入:

    -
    '; +
    '; $html .= '

    '; @@ -287,17 +282,18 @@ language:
    '; } function notnull(t) {'; - if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') $html .= ' + //if (getConfig('HW_urn')==''||getConfig('HW_key')==''||getConfig('HW_secret')=='') + $html .= ' if (t.HW_urn.value==\'\') { alert(\'input URN\'); return false; } if (t.HW_key.value==\'\') { - alert(\'input name\'); + alert(\'input Access Key Id\'); return false; } if (t.HW_secret.value==\'\') { - alert(\'input pwd\'); + alert(\'input Secret Access Key\'); return false; }'; $html .= ' @@ -872,3 +868,54 @@ class Signer function WaitFunction() { return true; } + +function changeAuthKey() { + if ($_POST['HW_key']!=''&&$_POST['HW_secret']!='') { + $tmp['HW_key'] = $_POST['HW_key']; + $tmp['HW_secret'] = $_POST['HW_secret']; + $response = setConfigResponse( SetbaseConfig($tmp, getConfig('HW_urn'), $tmp['HW_key'], $tmp['HW_secret']) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + 点击链接,新增访问密钥, + 在下载的credentials.csv文件中找到对应信息,填入:
    +
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From f439497c6acf24937662676bb8d74c2129b82304 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:39:21 +0800 Subject: [PATCH 17/62] add setup=auth --- platform/Normal.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/Normal.php b/platform/Normal.php index 5002b19..aea9c10 100644 --- a/platform/Normal.php +++ b/platform/Normal.php @@ -390,3 +390,7 @@ function moveFolder($from, $to, $slash) function WaitFunction() { return true; } + +function changeAuthKey() { + return message("Not need.", 'Change platform Auth token or key', 404); +} From 8c270bb7eba9769d94b281578c31890825e52553 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:50:41 +0800 Subject: [PATCH 18/62] add setup=auth --- platform/TencentSCF_env.php | 81 ++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/platform/TencentSCF_env.php b/platform/TencentSCF_env.php index c8084ae..eae113d 100644 --- a/platform/TencentSCF_env.php +++ b/platform/TencentSCF_env.php @@ -1,4 +1,7 @@ - ', 'Program updating', 201); + ', 'Program updating', 201, 1); } - return output('Jump + return message(getconstStr('Success') . ' - ', 302); + var i = 0; + var uploadList = setInterval(function(){ + if (document.getElementById("dis").style.display=="none") { + console.log(i++); + } else { + clearInterval(uploadList); + location.href = "' . path_format($_SERVER['base_path'] . '/') . '"; + } + }, 1000); + ', 201, 1); } if ($_GET['install1']) { $tmp['timezone'] = $_COOKIE['timezone']; @@ -199,7 +210,7 @@ function install() if ($tmp['ONEMANAGER_CONFIG_SAVE'] == 'file') { $html = getconstStr('ONEMANAGER_CONFIG_SAVE_FILE') . '
    ' . getconstStr('Home') . ''; $title = 'Reinstall'; - return message($html, $title, 201); + return message($html, $title, 201, 1); } $html .= ' @@ -217,7 +228,7 @@ function install() } '; $title = getconstStr('SetAdminPassword'); - return message($html, $title, 201); + return message($html, $title, 201, 1); } } if ($_GET['install0']) { @@ -228,10 +239,11 @@ language:
    '; $html .= '
    '; } - if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' + //if (getConfig('SecretId')==''||getConfig('SecretKey')=='') + $html .= ' ' . getconstStr('Create') . ' SecretId & SecretKey

    -
    '; +
    '; $html .= '

    '; @@ -255,7 +267,8 @@ language:
    '; } function notnull(t) {'; - if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' + //if (getConfig('SecretId')==''||getConfig('SecretKey')=='') + $html .= ' if (t.SecretId.value==\'\') { alert(\'input SecretId\'); return false; @@ -603,3 +616,53 @@ function addFileToZip($zip, $rootpath, $path = '') } @closedir($path); } + +function changeAuthKey() { + if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') { + $tmp['SecretId'] = $_POST['SecretId']; + $tmp['SecretKey'] = $_POST['SecretKey']; + $response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + ' . getconstStr('Create') . ' SecretId & SecretKey
    +
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From 05531b5fe1a9e37d9a72d8aca1a2f885e0cbea8e Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:51:43 +0800 Subject: [PATCH 19/62] add setup=auth --- platform/TencentSCF_file.php | 95 ++++++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/platform/TencentSCF_file.php b/platform/TencentSCF_file.php index 78e8600..9f53d92 100644 --- a/platform/TencentSCF_file.php +++ b/platform/TencentSCF_file.php @@ -1,4 +1,7 @@ - ', 'Program updating', 201); + ', 'Program updating', 201, 1); } - return output('Jump + return message(getconstStr('Success') . ' - ', 302); + var i = 0; + var uploadList = setInterval(function(){ + if (document.getElementById("dis").style.display=="none") { + console.log(i++); + } else { + clearInterval(uploadList); + location.href = "' . path_format($_SERVER['base_path'] . '/') . '"; + } + }, 1000); + ', 201, 1); } 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; - } + $SecretId = $_POST['SecretId']; + $tmp['SecretId'] = $SecretId; + $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)) { @@ -211,7 +216,7 @@ function install() if ($tmp['ONEMANAGER_CONFIG_SAVE'] != 'file') { $html = getconstStr('ONEMANAGER_CONFIG_SAVE_ENV') . '
    ' . getconstStr('Home') . ''; $title = 'Reinstall'; - return message($html, $title, 201); + return message($html, $title, 201, 1); } $html .= ' @@ -229,7 +234,7 @@ function install() } '; $title = getconstStr('SetAdminPassword'); - return message($html, $title, 201); + return message($html, $title, 201, 1); } } if ($_GET['install0']) { @@ -240,10 +245,11 @@ language:
    '; $html .= '
    '; } - if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' + //if (getConfig('SecretId')==''||getConfig('SecretKey')=='') + $html .= ' '.getconstStr('Create').' SecretId & SecretKey

    -
    '; +
    '; $html .= '

    '; @@ -267,7 +273,8 @@ language:
    '; } function notnull(t) {'; - if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= ' + //if (getConfig('SecretId')==''||getConfig('SecretKey')=='') + $html .= ' if (t.SecretId.value==\'\') { alert(\'input SecretId\'); return false; @@ -649,3 +656,53 @@ function WaitFunction() { if ( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']=='Active' ) return true; else return false; } + +function changeAuthKey() { + if ($_POST['SecretId']!=''&&$_POST['SecretId']!='') { + $tmp['SecretId'] = $_POST['SecretId']; + $tmp['SecretKey'] = $_POST['SecretKey']; + $response = setConfigResponse( SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $tmp['SecretId'], $tmp['SecretKey']) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + ' . getconstStr('Create') . ' SecretId & SecretKey
    +
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From 21c11208673b9f520ee4684245998b4c86486cd7 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:54:29 +0800 Subject: [PATCH 20/62] add setup=auth, check if another building --- platform/Vercel.php | 137 ++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 56 deletions(-) diff --git a/platform/Vercel.php b/platform/Vercel.php index 6a65b2f..3c6a97a 100644 --- a/platform/Vercel.php +++ b/platform/Vercel.php @@ -151,7 +151,7 @@ function setConfig($arr, $disktag = '') } $envs = array_filter($envs, 'array_value_isnot_null'); //ksort($envs); - sortConfig($envs); + //sortConfig($envs); //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT)); //echo json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT); return setVercelConfig($envs, getConfig('HerokuappId'), getConfig('APIKey')); @@ -187,16 +187,24 @@ function install() $title = 'Error'; return message($html, $title, 400); } else { - /*$html = ''; - return message($html, $title, 201, 1);*/ - $data["dplId"] = $response['DplStatus']; - return output(json_encode($data), 201); + return message($html, $title, 201, 1); } } } @@ -208,10 +216,9 @@ language:
    '; $html .= '
    '; } - //if (getConfig('APIKey')=='') $html .= '
    ' . getconstStr('Create') . ' token
    -
    '; +
    '; $html .= '

    '; $html .= ' @@ -244,52 +251,7 @@ language:
    '; alert(\'input Token\'); return false; } - t.style.display = "none"; - errordiv.innerHTML = "' . getconstStr('Wait') . '"; - var xhr = new XMLHttpRequest(); - xhr.open("POST", t.action); - xhr.onload = function(e) { - if (xhr.status==201) { - var res = JSON.parse(xhr.responseText); - getStatus(res.dplId, t.APIKey.value); - } else { - t.style.display = ""; - errordiv.innerHTML = xhr.status + "
    " + xhr.responseText; - } - } - xhr.send("admin=" + t.admin.value + "&APIKey=" + t.APIKey.value); - - var x = ""; - var min = 0; - function getStatus(id, VercelToken) { - x += "."; - min++; - var xhr = new XMLHttpRequest(); - var url = "https://api.vercel.com/v11/now/deployments/" + id; - xhr.open("GET", url); - xhr.setRequestHeader("Authorization", "Bearer " + VercelToken); - xhr.onload = function(e) { - if (xhr.status==200) { - var deployStat = JSON.parse(xhr.responseText).readyState; - if (deployStat=="READY") { - x = ""; - min = 0; - errordiv.innerHTML = "Deploy done."; - location.href = "/"; - } else { - errordiv.innerHTML = deployStat + ", " + min + ".
    ' . getconstStr('Wait') . ' " + x; - if (deployStat!=="ERROR") setTimeout(function() { getStatus(id, VercelToken) }, 1000); - } - } else { - t.style.display = ""; - console.log(xhr.status); - console.log(xhr.responseText); - } - } - xhr.send(null); - } - - return false; + return true; } '; $title = getconstStr('SelectLanguage'); @@ -329,7 +291,7 @@ function copyFolder($from, $to) function setVercelConfig($envs, $appId, $token) { - //sortConfig($envs); cant view in vercel, not need sort. + sortConfig($envs); $outPath = '/tmp/code/'; $outPath_Api = $outPath . 'api/'; $coderoot = __DIR__; @@ -345,7 +307,8 @@ function setVercelConfig($envs, $appId, $token) function VercelUpdate($appId, $token, $sourcePath = "") { - $url = "https://api.vercel.com/v12/now/deployments"; + if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}'; + $url = "https://api.vercel.com/v13/deployments"; $header["Authorization"] = "Bearer " . $token; $header["Content-Type"] = "application/json"; $data["name"] = "OneManager"; @@ -367,6 +330,23 @@ function VercelUpdate($appId, $token, $sourcePath = "") return json_encode($result); } +function checkBuilding($projectId, $token) +{ + $r = 0; + $url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId; + $header["Authorization"] = "Bearer " . $token; + $header["Content-Type"] = "application/json"; + $response = curl("GET", $url, '', $header); + //echo json_encode($response, JSON_PRETTY_PRINT) . " ,res
    "; + $result = json_decode($response["body"], true); + foreach ( $result['deployments'] as $deployment ) { + if ($deployment['state']!=="READY") $r++; + } + return $r; + //if ($r===0) return true; + //else return false; +} + function getEachFiles(&$file, $base, $path = "") { //if (substr($base, -1)=="/") $base = substr($base, 0, -1); @@ -453,7 +433,7 @@ function WaitFunction($deployid = '') { } $header["Authorization"] = "Bearer " . getConfig('APIKey'); $header["Content-Type"] = "application/json"; - $url = "https://api.vercel.com/v11/now/deployments/" . $deployid; + $url = "https://api.vercel.com/v11/deployments/" . $deployid; $response = curl("GET", $url, "", $header); if ($response['stat']==200) { $result = json_decode($response['body'], true); @@ -465,3 +445,48 @@ function WaitFunction($deployid = '') { return $response; } } + +function changeAuthKey() { + if ($_POST['APIKey']!='') { + $APIKey = $_POST['APIKey']; + $tmp['APIKey'] = $APIKey; + $response = setConfigResponse( setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey) ); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + ' . getconstStr('Create') . ' token
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From ae757bef84bad415f2a5b952e8e76dedaa0f63dc Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:55:41 +0800 Subject: [PATCH 21/62] add setup=auth, check if another building --- platform/Vercel_env.php | 136 +++++++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 57 deletions(-) diff --git a/platform/Vercel_env.php b/platform/Vercel_env.php index 4ebd486..8b1888d 100644 --- a/platform/Vercel_env.php +++ b/platform/Vercel_env.php @@ -163,9 +163,6 @@ function install() //$tmp['language'] = $_POST['language']; $tmp['timezone'] = $_COOKIE['timezone']; $APIKey = $_POST['APIKey']; - //if ($APIKey=='') { - // $APIKey = getConfig('APIKey'); - //} $tmp['APIKey'] = $APIKey; $token = $APIKey; @@ -184,16 +181,24 @@ function install() $title = 'Error'; return message($html, $title, 400); } else { - /*$html = ''; - return message($html, $title, 201, 1);*/ - $data["dplId"] = $response['DplStatus']; - return output(json_encode($data), 201); + return message($html, $title, 201, 1); } } } @@ -205,10 +210,9 @@ language:
    '; $html .= '
    '; } - //if (getConfig('APIKey')=='') $html .= '
    ' . getconstStr('Create') . ' token
    -
    '; +
    '; $html .= '

    '; $html .= ' @@ -241,52 +245,7 @@ language:
    '; alert(\'input Token\'); return false; } - t.style.display = "none"; - errordiv.innerHTML = "' . getconstStr('Wait') . '"; - var xhr = new XMLHttpRequest(); - xhr.open("POST", t.action); - xhr.onload = function(e) { - if (xhr.status==201) { - var res = JSON.parse(xhr.responseText); - getStatus(res.dplId, t.APIKey.value); - } else { - t.style.display = ""; - errordiv.innerHTML = xhr.status + "
    " + xhr.responseText; - } - } - xhr.send("admin=" + t.admin.value + "&APIKey=" + t.APIKey.value); - - var x = ""; - var min = 0; - function getStatus(id, VercelToken) { - x += "."; - min++; - var xhr = new XMLHttpRequest(); - var url = "https://api.vercel.com/v11/now/deployments/" + id; - xhr.open("GET", url); - xhr.setRequestHeader("Authorization", "Bearer " + VercelToken); - xhr.onload = function(e) { - if (xhr.status==200) { - var deployStat = JSON.parse(xhr.responseText).readyState; - if (deployStat=="READY") { - x = ""; - min = 0; - errordiv.innerHTML = "Deploy done."; - location.href = "/"; - } else { - errordiv.innerHTML = deployStat + ", " + min + ".
    ' . getconstStr('Wait') . ' " + x; - if (deployStat!=="ERROR") setTimeout(function() { getStatus(id, VercelToken) }, 1000); - } - } else { - t.style.display = ""; - console.log(xhr.status); - console.log(xhr.responseText); - } - } - xhr.send(null); - } - - return false; + return true; } '; $title = getconstStr('SelectLanguage'); @@ -335,7 +294,8 @@ function setVercelConfig($envs, $appId, $token) function VercelUpdate($appId, $token, $sourcePath = "") { - $url = "https://api.vercel.com/v12/now/deployments"; + if (checkBuilding($appId, $token)) return '{"error":{"message":"Another building is in progress."}}'; + $url = "https://api.vercel.com/v13/deployments"; $header["Authorization"] = "Bearer " . $token; $header["Content-Type"] = "application/json"; $data["name"] = "OneManager"; @@ -357,6 +317,23 @@ function VercelUpdate($appId, $token, $sourcePath = "") return json_encode($result); } +function checkBuilding($projectId, $token) +{ + $r = 0; + $url = "https://api.vercel.com/v6/deployments/?projectId=" . $projectId; + $header["Authorization"] = "Bearer " . $token; + $header["Content-Type"] = "application/json"; + $response = curl("GET", $url, '', $header); + //echo json_encode($response, JSON_PRETTY_PRINT) . " ,res
    "; + $result = json_decode($response["body"], true); + foreach ( $result['deployments'] as $deployment ) { + if ($deployment['state']!=="READY") $r++; + } + return $r; + //if ($r===0) return true; + //else return false; +} + function getEachFiles(&$file, $base, $path = "") { //if (substr($base, -1)=="/") $base = substr($base, 0, -1); @@ -438,7 +415,7 @@ function WaitFunction($deployid) { } $header["Authorization"] = "Bearer " . getConfig('APIKey'); $header["Content-Type"] = "application/json"; - $url = "https://api.vercel.com/v11/now/deployments/" . $deployid; + $url = "https://api.vercel.com/v11/deployments/" . $deployid; $response = curl("GET", $url, "", $header); if ($response['stat']==200) { $result = json_decode($response['body'], true); @@ -450,3 +427,48 @@ function WaitFunction($deployid) { return $response; } } + +function changeAuthKey() { + if ($_POST['APIKey']!='') { + $APIKey = $_POST['APIKey']; + $tmp['APIKey'] = $APIKey; + $response = json_decode(setVercelConfig($tmp, getConfig('HerokuappId'), $APIKey), true); + if (api_error($response)) { + $html = api_error_msg($response); + $title = 'Error'; + return message($html, $title, 400); + } else { + $html = getconstStr('Success') . ' + '; + return message($html, $title, 201, 1); + } + } + $html = ' + + ' . getconstStr('Create') . ' token
    +
    + + + '; + return message($html, 'Change platform Auth token or key', 200); +} From 646c963eba28bfd8a0e794a4a5a3f1a2d3e453dd Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:12:57 +0800 Subject: [PATCH 22/62] Update version --- version | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/version b/version index 8241a53..e3c66df 100644 --- a/version +++ b/version @@ -1,7 +1,28 @@ +20211201-1602.41 +add a latent function, you can edit platform token(or API key) via '?setup=auth' when the token invalid, not need edit it in Environment(or Config Var) manually, (even in Vercel, config saved in file, and can't modiy it manually). +新增隐藏功能,在平台操作代码的token或API key失效时,可以在 '?setup=auth' 修改它,不用去环境变量修改了(特别地,Vercel保存在代码中时都改不到)。 +20211129 +check if there is another deployment building when start deploy. +Vercel部署时检测是否有另一个部署。 +20211104 +check if exist php-curl or not in php host and VPS. +在VPS中检测是否有php-curl。 +20211021 +specialchars, fix: list folder, encrypt folder, preview files, rename, show in title, error on back link after login at specialchars folder, etc. +针对特殊字符,解决目录的列表,目录的加密,文件的预览,目录与文件重命名,在网页标题的显示,在特殊字符处登录后跳转出错等问题。 +20211006 +oprate files by fileID, write a localStorage when login to anti CSRF. +管理时对文件id操作,管理登录时写入一个localStorage预防CSRF。 +20210908 +add fileConduitSize&fileConduitCacheTime, little files can stream from program, better to show html/js as local file. +增加fileConduitSize,fileConduitCacheTime,小文件可以从服务器中转,以对html/js本地化更好的支持。 +20210903 +add a latent function, you can run some command by '?setup=cmd', be care, please dont try "top", and set times by "ping -c 4". +新增隐藏功能,你可以通过'?setup=cmd'来跑一些命令,注意不要试图跑top,另外ping请-c设置次数。 + 20210820-1810.40 because Vercel must redeploy after change Environment Variables, and it must <4k, so decide that, save config in code file. in Vercel, after update, please install again. if you want continue use Environment, please add a ( name: "ONEMANAGER_CONFIG_SAVE", value: "env" ) in Environment Variables in Project Settings before update. 因为Vercel修改环境变量也必须重新部署才生效,而且环境变量只能小于4k,所以决定将配置保存在代码文件中。升级更新后,用Vercel的请重新安装。如果还想继续使用环境变量,请在更新前,在Project Settings的Environment Variables中,新增一个( name: "ONEMANAGER_CONFIG_SAVE", value: "env" )的环境变量。 - 20210817-2030.39 fix bugs in Vercel. add wait function in operating. change update method in SCF. add payme in readme. 修复一些Vercel上的bug。在操作完后添加等待功能,确认平台已经准备好。SCF的更新方式改变。在readme中添加讨饭链接。 From 108b14261c10ded483d8e260f435486faeab4349 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 6 Dec 2021 10:39:45 +0800 Subject: [PATCH 23/62] fix a new bug in tmp_dir --- common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 3693263..88b1928 100644 --- a/common.php +++ b/common.php @@ -616,12 +616,12 @@ function filecache($disktag) { $dir = sys_get_temp_dir(); if (!is_writable($dir)) { - $tmp = $_SERVER['HTTP_HOST'] . '/tmp/'; + $tmp = __DIR__ . '/tmp/'; if (file_exists($tmp)) { if ( is_writable($tmp) ) $dir = $tmp; } elseif ( mkdir($tmp) ) $dir = $tmp; } - $tag = __DIR__ . '/OneManager/' . $disktag; + $tag = $_SERVER['HTTP_HOST'] . '/OneManager/' . $disktag; while (strpos($tag, '/')>-1) $tag = str_replace('/', '_', $tag); if (strpos($tag, ':')>-1) { $tag = str_replace(':', '_', $tag); From 2e9ce0bbb4cb8e9022a3b1356a08fee27512051b Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 12 Dec 2021 14:24:57 +0800 Subject: [PATCH 24/62] Create Replit.php #413 try add replit --- platform/Replit.php | 379 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 379 insertions(+) create mode 100644 platform/Replit.php diff --git a/platform/Replit.php b/platform/Replit.php new file mode 100644 index 0000000..e8134e0 --- /dev/null +++ b/platform/Replit.php @@ -0,0 +1,379 @@ +0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); + else $path = $_SERVER['REQUEST_URI']; + $path = path_format( substr($path, strlen($_SERVER['base_path'])) ); + return $path; +} + +function getGET() +{ + if (!$_POST) { + if (!!$HTTP_RAW_POST_DATA) { + $tmpdata = $HTTP_RAW_POST_DATA; + } else { + $tmpdata = file_get_contents('php://input'); + } + if (!!$tmpdata) { + $postbody = explode("&", $tmpdata); + foreach ($postbody as $postvalues) { + $pos = strpos($postvalues,"="); + $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1)); + } + } + } + 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 ReplitAPI($op, $key, $value = '') { + //error_log1($op . '_' . $key . '_' . $value); + $apiurl = getenv('REPLIT_DB_URL'); + if ($op === 'r') { + return curl('GET', $apiurl . '/' . $key); + } elseif ($op === 'w') { + return curl('POST', $apiurl, $key . '=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]); + } elseif ($op === 'd') { + return curl('DELETE', $apiurl . '/' . $key); + } else { + return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().']; + } +} + +function getConfig($str, $disktag = '') +{ + if (isInnerEnv($str)) { + if ($disktag=='') $disktag = $_SERVER['disktag']; + $env = json_decode(ReplitAPI('r', $disktag)['body'], true); + if (isset($env[$str])) { + if (isBase64Env($str)) return base64y_decode($env[$str]); + else return $env[$str]; + } + } else { + if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']); + else return ReplitAPI('r', $str)['body']; + } + return ''; +} + +function setConfig($arr, $disktag = '') +{ + if ($disktag=='') $disktag = $_SERVER['disktag']; + $disktags = explode("|", getConfig('disktag')); + if ($disktag!='') $diskconfig = json_decode(ReplitAPI('r', $disktag)['body'], true); + $tmp = []; + $indisk = 0; + $operatedisk = 0; + foreach ($arr as $k => $v) { + if (isCommonEnv($k)) { + if (isBase64Env($k)) $tmp[$k] = base64y_encode($v); + else $tmp[$k] = $v; + } elseif (isInnerEnv($k)) { + if (isBase64Env($k)) $diskconfig[$k] = base64y_encode($v); + else $diskconfig[$k] = $v; + $indisk = 1; + } elseif ($k=='disktag_add') { + array_push($disktags, $v); + $operatedisk = 1; + } elseif ($k=='disktag_del') { + $disktags = array_diff($disktags, [ $v ]); + $tmp[$v] = ''; + $operatedisk = 1; + } elseif ($k=='disktag_copy') { + $newtag = $v . '_' . date("Ymd_His"); + $tmp[$newtag] = getConfig($v); + array_push($disktags, $newtag); + $operatedisk = 1; + } elseif ($k=='disktag_rename' || $k=='disktag_newname') { + if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1; + } else { + $tmp[$k] = json_encode($v); + } + } + if ($indisk) { + $diskconfig = array_filter($diskconfig, 'array_value_isnot_null'); + ksort($diskconfig); + $tmp[$disktag] = json_encode($diskconfig); + } + if ($operatedisk) { + if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') { + $tags = []; + foreach ($disktags as $tag) { + if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']); + else array_push($tags, $tag); + } + $tmp['disktag'] = implode('|', $tags); + $tmp[$arr['disktag_newname']] = getConfig($arr['disktag_rename']); + $tmp[$arr['disktag_rename']] = null; + } else { + $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'] = null; + } + } + $response = null; + foreach ($tmp as $key => $val) { + if (!!$val) $response = ReplitAPI('w', $key, $val); + else $response = ReplitAPI('d', $key); + if (api_error($response)) return ['stat'=>500, 'body'=>$response['body']]; + } + //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($tmp, JSON_PRETTY_PRINT)); + return $response; +} + +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 .= ' + + '; + $title = getconstStr('SetAdminPassword'); + return message($html, $title, 201); + } + if ($_GET['install0']) { + $html .= ' + +language:
    '; + foreach ($constStr['languages'] as $key1 => $value1) { + $html .= ' +
    '; + } + $html .= ' + + + '; + $title = getconstStr('SelectLanguage'); + return message($html, $title, 201); + } + + $title = 'Install'; + $html = '' . getconstStr('ClickInstall') . ', ' . getconstStr('LogintoBind'); + 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 api_error($response) +{ + return !($response['stat']==200||$response['stat']==204); + //return isset($response['message']); +} + +function api_error_msg($response) +{ + return '
    '. json_encode($response, JSON_PRETTY_PRINT).'
    ' . '
    +'; +} + +function setConfigResponse($response) +{ + return $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 ['stat'=>500, 'body'=>'download error from github.']; + file_put_contents($tarfile, $githubfile); + if (splitfirst(PHP_VERSION, '.')[0] > '5') { + $phar = new PharData($tarfile); // need php5.3, 7, 8 + $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_log1($outPath); + if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.']; + + 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 ['stat'=>500, 'body'=>json_encode($tmp)]; + } + if (file_exists($fromfile)) unlink($fromfile); + } + } + } + closedir($handler); + rmdir($from); + return ['stat'=>200, 'body'=>'success.']; +} + +function WaitFunction() { + return true; +} + +function changeAuthKey() { + return message("Not need.", 'Change platform Auth token or key', 404); +} From f909372a96f4bbf2ad84f04b936f7fc4dc17f4f0 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 12 Dec 2021 17:22:28 +0800 Subject: [PATCH 25/62] add platform replit --- index.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index a06dc76..725de56 100644 --- a/index.php +++ b/index.php @@ -39,6 +39,22 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { //echo 'path:'. $path; $_GET = getGET(); //echo '
    '. json_encode($_GET, JSON_PRETTY_PRINT).'
    '; + $re = main($path); + $sendHeaders = array(); + foreach ($re['headers'] as $headerName => $headerVal) { + header($headerName . ': ' . $headerVal, true); + } + http_response_code($re['statusCode']); + if ($re['isBase64Encoded']) echo base64_decode($re['body']); + else echo $re['body']; +} elseif (isset($_SERVER['DOCUMENT_ROOT'])&&substr($_SERVER['DOCUMENT_ROOT'], 0, 13)==='/home/runner/') { + include 'platform/Replit.php'; + + $path = getpath(); + //echo 'path:'. $path; + $_GET = getGET(); + //echo '
    '. json_encode($_GET, JSON_PRETTY_PRINT).'
    '; + $re = main($path); $sendHeaders = array(); foreach ($re['headers'] as $headerName => $headerVal) { @@ -56,7 +72,6 @@ if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') { //echo 'path:'. $path; $_GET = getGET(); //echo '
    '. json_encode($_GET, JSON_PRETTY_PRINT).'
    '; - $re = main($path); $sendHeaders = array(); foreach ($re['headers'] as $headerName => $headerVal) { From 5281adca5b7b26a5801b61c87947e38703f2469a Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 12 Dec 2021 18:15:22 +0800 Subject: [PATCH 26/62] Create .replit --- .replit | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .replit diff --git a/.replit b/.replit new file mode 100644 index 0000000..1dbf6d9 --- /dev/null +++ b/.replit @@ -0,0 +1,3 @@ +language = "php74" +run = "php -S 0.0.0.0:8000 index.php" +entrypoint = "index.php" From 6e76d23051f8aec7b52cad699bbc58e247be621a Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 12 Dec 2021 18:31:29 +0800 Subject: [PATCH 27/62] Update readme.md --- readme.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 3f12e7d..d87e993 100644 --- a/readme.md +++ b/readme.md @@ -60,7 +60,30 @@ ### How to Install - https://scfonedrive.github.io/Vercel/Deploy.html . +> https://scfonedrive.github.io/Vercel/Deploy.html . + +--- + +# Deploy to Replit + +### Official + + https://repl.it/ + https://replit.com/ + +### Demo + + null + +### Notice + +> `Import from Github` useing the `.replit` file in code files will cause an empty web page, may someone help me? + +### How to Install + +> 1. Click the "+" or "Create Repl", find template "PHP Web Server" (via input "php"), input a name for your project in "Title" or left it default, Click the "+ Create Repl". +> 2. After done, input `git clone https://github.com/qkqpttgf/OneManager-php && mv -f OneManager-php/* ./ && mv -f OneManager-php/.[^.]* ./ && rm -r OneManager-php` to Console or Shell on the right, press "Enter" to run it. +> 3. Click the green button "Run", it will show the web page on the right, you can open it in a new tab or window. --- From dd8c56179f5aa4b189c90efd804b6046100fc177 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 12 Dec 2021 18:47:17 +0800 Subject: [PATCH 28/62] add platform replit --- readme_cn.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/readme_cn.md b/readme_cn.md index 5d45aaf..62e76fb 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -62,6 +62,29 @@ --- +# 部署到 Replit + +### 官网 + + https://repl.it/ + https://replit.com/ + +### Demo + + null + +### 注意 + +> 直接`Import from Github`通过`.replit`文件指定php时,网页会空白,有人帮忙解决吗? + +### 安装 + +> 1. 点右上的 "+" 或左上的 "+ Create Repl",template中输入php,点选"PHP Web Server",在"Title"里输入你想要的名称或者让它默认, 点下面的"+ Create Repl"。 +> 2. 结束后,在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -f OneManager-php/* ./ && mv -f OneManager-php/.[^.]* ./ && rm -r OneManager-php` 敲回车运行。 +> 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你可以在新窗口打开它来安装。 + +--- + # 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF) ### 官网 From 7f0e1d96cef22d4050aa3baa682313a4d5a59497 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 12 Dec 2021 13:39:04 +0000 Subject: [PATCH 29/62] fix error in editting config --- platform/Replit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/Replit.php b/platform/Replit.php index e8134e0..572c150 100644 --- a/platform/Replit.php +++ b/platform/Replit.php @@ -152,7 +152,7 @@ function setConfig($arr, $disktag = '') foreach ($tmp as $key => $val) { if (!!$val) $response = ReplitAPI('w', $key, $val); else $response = ReplitAPI('d', $key); - if (api_error($response)) return ['stat'=>500, 'body'=>$response['body']]; + if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "
    \nError in writting " . $key . "=" . $val]; } //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($tmp, JSON_PRETTY_PRINT)); return $response; @@ -286,7 +286,7 @@ function ConfigWriteable() function api_error($response) { - return !($response['stat']==200||$response['stat']==204); + return !($response['stat']==200||$response['stat']==204||$response['stat']==404); //return isset($response['message']); } From d10e99a8fffafad93fe36dd83ad8e73c4114f64d Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 13 Dec 2021 14:51:28 +0800 Subject: [PATCH 30/62] read config every time --- platform/{Replit.php => Replit_old.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/{Replit.php => Replit_old.php} (100%) diff --git a/platform/Replit.php b/platform/Replit_old.php similarity index 100% rename from platform/Replit.php rename to platform/Replit_old.php From bdd76ca56732dfb27b1cc169e300b42965757786 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 13 Dec 2021 14:53:35 +0800 Subject: [PATCH 31/62] cache config for read --- platform/Replit.php | 386 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 386 insertions(+) create mode 100644 platform/Replit.php diff --git a/platform/Replit.php b/platform/Replit.php new file mode 100644 index 0000000..a7b0601 --- /dev/null +++ b/platform/Replit.php @@ -0,0 +1,386 @@ +0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); + else $path = $_SERVER['REQUEST_URI']; + $path = path_format( substr($path, strlen($_SERVER['base_path'])) ); + return $path; +} + +function getGET() +{ + if (!$_POST) { + if (!!$HTTP_RAW_POST_DATA) { + $tmpdata = $HTTP_RAW_POST_DATA; + } else { + $tmpdata = file_get_contents('php://input'); + } + if (!!$tmpdata) { + $postbody = explode("&", $tmpdata); + foreach ($postbody as $postvalues) { + $pos = strpos($postvalues,"="); + $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1)); + } + } + } + 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 ReplitAPI($op, $key, $value = '') { + //error_log1($op . '_' . $key . '_' . $value); + $apiurl = getenv('REPLIT_DB_URL'); + //foreach (explode("\n", curl('GET', $apiurl . '?prefix')['body']) as $a) curl('DELETE', $apiurl . '/' . $a); + if ($op === 'r') { + if (!($config = getcache('REPLIT_CONFIG'))) { + $config = json_decode(curl('GET', $apiurl . '/REPLIT_CONFIG')['body'], true); + savecache('REPLIT_CONFIG', $config); + } + return ['stat'=>200, 'body'=>(is_array($config[$key])?json_encode($config[$key]):$config[$key])]; + } elseif ($op === 'w') { + return curl('POST', $apiurl, 'REPLIT_CONFIG=' . $value, ["Content-Type"=>"application/x-www-form-urlencoded"]); + } elseif ($op === 'd') { + // not use + return curl('DELETE', $apiurl . '/' . $key); + } else { + return ['stat'=>500, 'body'=>'error option input to function ReplitAPI().']; + } +} + +function getConfig($str, $disktag = '') +{ + if (isInnerEnv($str)) { + if ($disktag=='') $disktag = $_SERVER['disktag']; + $env = json_decode(ReplitAPI('r', $disktag)['body'], true); + if (isset($env[$str])) { + if (isBase64Env($str)) return base64y_decode($env[$str]); + else return $env[$str]; + } + } else { + if (isBase64Env($str)) return base64y_decode(ReplitAPI('r', $str)['body']); + else return ReplitAPI('r', $str)['body']; + } + return ''; +} + +function setConfig($arr, $disktag = '') +{ + if (!($envs = getcache('REPLIT_CONFIG'))) { + $envs = json_decode(curl('GET', getenv('REPLIT_DB_URL') . '/REPLIT_CONFIG')['body'], true); + //savecache('REPLIT_CONFIG', $envs); + } + if ($disktag=='') $disktag = $_SERVER['disktag']; + $disktags = explode("|", getConfig('disktag')); + $indisk = 0; + $operatedisk = 0; + foreach ($arr as $k => $v) { + if (isCommonEnv($k)) { + if (isBase64Env($k)) $envs[$k] = base64y_encode($v); + else $envs[$k] = $v; + } elseif (isInnerEnv($k)) { + if (isBase64Env($k)) $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; + } elseif ($k=='disktag_copy') { + $newtag = $v . '_' . date("Ymd_His"); + $envs[$newtag] = $envs[$v]; + array_push($disktags, $newtag); + $operatedisk = 1; + } elseif ($k=='disktag_rename' || $k=='disktag_newname') { + if ($arr['disktag_rename']!=$arr['disktag_newname']) $operatedisk = 1; + } else { + $envs[$k] = $v; + } + } + if ($indisk) { + $diskconfig = $envs[$disktag]; + $diskconfig = array_filter($diskconfig, 'array_value_isnot_null'); + ksort($diskconfig); + $envs[$disktag] = $diskconfig; + } + if ($operatedisk) { + if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') { + $tags = []; + foreach ($disktags as $tag) { + if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']); + else array_push($tags, $tag); + } + $envs['disktag'] = implode('|', $tags); + $envs[$arr['disktag_newname']] = $envs[$arr['disktag_rename']]; + unset($envs[$arr['disktag_rename']]); + } else { + $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'); + $response = ReplitAPI('w', 'REPLIT_CONFIG', json_encode($envs)); + //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT)); + savecache('REPLIT_CONFIG', null, '', 0); + if (api_error($response)) return ['stat'=>$response['stat'], 'body'=>$response['body'] . "
    \nError in writting " . $key . "=" . $val]; + return $response; +} + +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 .= ' + + '; + $title = getconstStr('SetAdminPassword'); + return message($html, $title, 201); + } + if ($_GET['install0']) { + $html .= ' + +language:
    '; + foreach ($constStr['languages'] as $key1 => $value1) { + $html .= ' +
    '; + } + $html .= ' + + + '; + $title = getconstStr('SelectLanguage'); + return message($html, $title, 201); + } + + $title = 'Install'; + $html = '' . getconstStr('ClickInstall') . ', ' . getconstStr('LogintoBind'); + 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 api_error($response) +{ + return !($response['stat']==200||$response['stat']==204||$response['stat']==404); + //return isset($response['message']); +} + +function api_error_msg($response) +{ + return '
    '. json_encode($response, JSON_PRETTY_PRINT).'
    ' . '
    +'; +} + +function setConfigResponse($response) +{ + return $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 ['stat'=>500, 'body'=>'download error from github.']; + file_put_contents($tarfile, $githubfile); + if (splitfirst(PHP_VERSION, '.')[0] > '5') { + $phar = new PharData($tarfile); // need php5.3, 7, 8 + $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_log1($outPath); + if ($outPath=='') return ['stat'=>500, 'body'=>'can\'t find folder after download from github.']; + + 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 ['stat'=>500, 'body'=>json_encode($tmp)]; + } + if (file_exists($fromfile)) unlink($fromfile); + } + } + } + closedir($handler); + rmdir($from); + return ['stat'=>200, 'body'=>'success.']; +} + +function WaitFunction() { + return true; +} + +function changeAuthKey() { + return message("Not need.", 'Change platform Auth token or key', 404); +} From 0ab59926f6633abbce3b1084cd0ecfa90417f694 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 13 Dec 2021 19:08:09 +0800 Subject: [PATCH 32/62] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d87e993..4a21108 100644 --- a/readme.md +++ b/readme.md @@ -73,7 +73,7 @@ ### Demo - null + https://onemanager.qkqpttgf.repl.co/ ### Notice From 1580671b5e6a8eb515e728fb64eef2d04a5876c9 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 13 Dec 2021 19:11:03 +0800 Subject: [PATCH 33/62] Update readme_cn.md --- readme_cn.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/readme_cn.md b/readme_cn.md index 62e76fb..24af113 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -2,6 +2,8 @@ # 注意: + 请关掉浏览器的翻译。 + Releases只是当存档在用的,并不是最新代码。 请将设置中所有的设置项的说明都读一遍,有些问题就不用问了。 @@ -71,7 +73,7 @@ ### Demo - null + https://onemanager.qkqpttgf.repl.co/ ### 注意 @@ -81,7 +83,7 @@ > 1. 点右上的 "+" 或左上的 "+ Create Repl",template中输入php,点选"PHP Web Server",在"Title"里输入你想要的名称或者让它默认, 点下面的"+ Create Repl"。 > 2. 结束后,在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -f OneManager-php/* ./ && mv -f OneManager-php/.[^.]* ./ && rm -r OneManager-php` 敲回车运行。 -> 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你可以在新窗口打开它来安装。 +> 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你要在新窗口打开它来安装,不然不能登录。 --- From 801a9168e225e3aef184df41bc6eeb90da23dcb2 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:29:55 +0800 Subject: [PATCH 34/62] Update readme.md --- readme.md | 68 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/readme.md b/readme.md index 4a21108..5669b33 100644 --- a/readme.md +++ b/readme.md @@ -8,40 +8,6 @@ --- -# Deploy to Heroku - -### Official - - https://heroku.com - -### Demo - - https://herooneindex.herokuapp.com/ - -### How to Install - -> ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`) -> -> Star this project, then Fork, create a app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork. - ---- - -# Deploy to Glitch - -### Official - - https://glitch.com/ - -### Demo - - https://onemanager.glitch.me/ - -### How to Install - - [New Project] -> [Import form Github] -> paste "https://github.com/qkqpttgf/OneManager-php" , after done, [Show] -> [In a New Window]. - ---- - # Deploy to Vercel ### Official @@ -87,6 +53,40 @@ --- +# Deploy to Heroku + +### Official + + https://heroku.com + +### Demo + + https://herooneindex.herokuapp.com/ + +### How to Install + +> ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`) +> +> Star this project, then Fork, create a app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork. + +--- + +# Deploy to Glitch + +### Official + + https://glitch.com/ + +### Demo + + https://onemanager.glitch.me/ + +### How to Install + + [New Project] -> [Import form Github] -> paste "https://github.com/qkqpttgf/OneManager-php" , after done, [Show] -> [In a New Window]. + +--- + # Deploy to Tencent Serverless Cloud Function (SCF) ### Official From c85898fd985e6c5935af7337ffbf3938ca8c5607 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:31:48 +0800 Subject: [PATCH 35/62] Update readme_cn.md --- readme_cn.md | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/readme_cn.md b/readme_cn.md index 24af113..9ba5ccb 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -10,38 +10,6 @@ --- -# 部署到 Heroku - -### 官网 - - https://heroku.com - -### Demo - - https://herooneindex.herokuapp.com/ - -### 安装 - -> 给这个项目点star,然后fork,在Heroku创建一个app,然后点进Deploy页,在"Deployment method"处点"Connect GitHub",选择你的fork。 - ---- - -# 部署到 Glitch - -### 官网 - - https://glitch.com/ - -### Demo - - https://onemanager.glitch.me/ - -### 安装 - - 点 [New Project] -> 点 [Import form Github] -> 粘贴 "https://github.com/qkqpttgf/OneManager-php" ,结束后,左上角点 [Show] -> [In a New Window]。 - ---- - # 部署到 Vercel ### 官网 @@ -87,6 +55,38 @@ --- +# 部署到 Heroku + +### 官网 + + https://heroku.com + +### Demo + + https://herooneindex.herokuapp.com/ + +### 安装 + +> 给这个项目点star,然后fork,在Heroku创建一个app,然后点进Deploy页,在"Deployment method"处点"Connect GitHub",选择你的fork。 + +--- + +# 部署到 Glitch + +### 官网 + + https://glitch.com/ + +### Demo + + https://onemanager.glitch.me/ + +### 安装 + + 点 [New Project] -> 点 [Import form Github] -> 粘贴 "https://github.com/qkqpttgf/OneManager-php" ,结束后,左上角点 [Show] -> [In a New Window]。 + +--- + # 部署到腾讯无服务器云函数 Serverless Cloud Function (SCF) ### 官网 From f3391cd132ffc6814057e2ebdaf784c52c37b897 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:58:35 +0800 Subject: [PATCH 36/62] sha1.js use jsdelivr --- theme/classic.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/theme/classic.html b/theme/classic.html index 6e2e242..83ae3fb 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -487,7 +487,7 @@ - + - + From 270c73afb5229f290603f117b2e31b63735339bd Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:59:21 +0800 Subject: [PATCH 37/62] sha1.js use jsdelivr --- common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.php b/common.php index 88b1928..f6c3a62 100644 --- a/common.php +++ b/common.php @@ -1085,7 +1085,7 @@ function adminform($name = '', $pass = '', $storage = '', $path = '') } } -'; +'; $html .= ''; return output($html, $statusCode); } @@ -1778,7 +1778,7 @@ output: $frame .= getconstStr('NotNeedUpdate'); }*/ $frame .= '

    - +
    From 341124e5b062dc535f676058b31b7acbae26031b Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:47:34 +0800 Subject: [PATCH 38/62] sort to easy reading config in shell --- platform/Replit.php | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/Replit.php b/platform/Replit.php index a7b0601..ebc5acd 100644 --- a/platform/Replit.php +++ b/platform/Replit.php @@ -158,6 +158,7 @@ function setConfig($arr, $disktag = '') } } $envs = array_filter($envs, 'array_value_isnot_null'); + sortConfig($envs); $response = ReplitAPI('w', 'REPLIT_CONFIG', json_encode($envs)); //error_log1(json_encode($arr, JSON_PRETTY_PRINT) . ' => tmp:' . json_encode($envs, JSON_PRETTY_PRINT)); savecache('REPLIT_CONFIG', null, '', 0); From 16dec5d4cda2849b2fd7ce4d3db7e20ca25ad55d Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sat, 18 Dec 2021 20:43:41 +0800 Subject: [PATCH 39/62] change mv -b in deploy to replit --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 5669b33..4bd5dca 100644 --- a/readme.md +++ b/readme.md @@ -48,7 +48,7 @@ ### How to Install > 1. Click the "+" or "Create Repl", find template "PHP Web Server" (via input "php"), input a name for your project in "Title" or left it default, Click the "+ Create Repl". -> 2. After done, input `git clone https://github.com/qkqpttgf/OneManager-php && mv -f OneManager-php/* ./ && mv -f OneManager-php/.[^.]* ./ && rm -r OneManager-php` to Console or Shell on the right, press "Enter" to run it. +> 2. After done, input `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` to Console or Shell on the right, press "Enter" to run it. > 3. Click the green button "Run", it will show the web page on the right, you can open it in a new tab or window. --- @@ -67,7 +67,7 @@ > ~~Click the button [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) to Deploy a new app~~(`"We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy."`) > -> Star this project, then Fork, create a app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork. +> Star this project, then Fork, create an app in Heroku, then turn to the Deploy tab, "Deployment method" via "Connect GitHub", select your github fork. --- From 06c7efe513707819705314346b3e91d70e0f174b Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sat, 18 Dec 2021 20:45:23 +0800 Subject: [PATCH 40/62] change mv -b in deploy to replit --- readme_cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme_cn.md b/readme_cn.md index 9ba5ccb..bf8ab5e 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -50,7 +50,7 @@ ### 安装 > 1. 点右上的 "+" 或左上的 "+ Create Repl",template中输入php,点选"PHP Web Server",在"Title"里输入你想要的名称或者让它默认, 点下面的"+ Create Repl"。 -> 2. 结束后,在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -f OneManager-php/* ./ && mv -f OneManager-php/.[^.]* ./ && rm -r OneManager-php` 敲回车运行。 +> 2. 结束后,在右边的Console或Shell里输入 `git clone https://github.com/qkqpttgf/OneManager-php && mv -b OneManager-php/* ./ && mv -b OneManager-php/.[^.]* ./ && rm -rf *~ && rm -rf OneManager-php` 敲回车运行。 > 3. 点上方的绿色 "Run" 按钮,右边会显示一个网页,你要在新窗口打开它来安装,不然不能登录。 --- From faf5027f04e4ff6a3a3fb8e761f2c5549120b3b2 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 20 Dec 2021 10:38:31 +0800 Subject: [PATCH 41/62] add git source: HIT --- common.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 92 insertions(+), 7 deletions(-) diff --git a/common.php b/common.php index f6c3a62..3d0030e 100644 --- a/common.php +++ b/common.php @@ -632,6 +632,27 @@ function filecache($disktag) return $cache; } +function findIndexPath($rootpath, $path = '') +{// find the path of the first 'index.php' that not in rootpath. + global $slash; + if (substr($rootpath,-1)==$slash) $rootpath = substr($rootpath, 0, -1); + if (substr($path,0,1)==$slash) $path = substr($path, 1); + $handler=opendir(path_format($rootpath.$slash.$path)); //打开当前文件夹 + while($filename=readdir($handler)){ + if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作 + $nowname = path_format($rootpath.$slash.$path.$slash.$filename); + if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归 + $res = findIndexPath($rootpath, $path.$slash.$filename); + if ($res!=='') return $res; + }else{ + if ($filename==='index.php') if ($path!='') return $rootpath.$slash.$path; + } + } + } + @closedir($handler); + return ''; +} + function sortConfig(&$arr) { ksort($arr); @@ -952,7 +973,8 @@ function needUpdate() $current_ver = explode(urldecode('%0D'),$current_ver)[0]; $split = splitfirst($current_version, '.' . $current_ver)[0] . '.' . $current_ver; if (!($github_version = getcache('github_version'))) { - $tmp = curl('GET', 'https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version'); + //$tmp = curl('GET', 'https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version'); + $tmp = curl('GET', 'https://git.hit.edu.cn/ysun/OneManager-php/-/raw/master/version'); if ($tmp['stat']==0) return 0; $github_version = $tmp['body']; savecache('github_version', $github_version); @@ -1256,7 +1278,7 @@ function EnvOpt($needUpdate = 0) $html = 'OneManager '.getconstStr('Setup').''; if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) { - $response = setConfigResponse(OnekeyUpate($_POST['auth'], $_POST['project'], $_POST['branch'])); + $response = setConfigResponse(OnekeyUpate($_POST['GitSource'], $_POST['auth'], $_POST['project'], $_POST['branch'])); if (api_error($response)) { $html = api_error_msg($response); $title = 'Error'; @@ -1723,7 +1745,10 @@ output: $canOneKeyUpate = 1; } } - $frame .= 'Github'; + $frame .= ' + Github +HIT Gitlab

    +'; if (!$canOneKeyUpate) { $frame .= ' ' . getconstStr('CannotOneKeyUpate') . '
    '; @@ -1731,17 +1756,33 @@ output: $frame .= ' + Update from + - + + - + - + From d99ee1dadc3db4a3fccf6d31704ff912d3a1916b Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Fri, 24 Dec 2021 09:13:32 +0800 Subject: [PATCH 62/62] rm rewrite check --- platform/Replit.php | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/platform/Replit.php b/platform/Replit.php index 87ee3ca..a682197 100644 --- a/platform/Replit.php +++ b/platform/Replit.php @@ -202,13 +202,11 @@ function install() $title = 'Error'; return message($html, $title, 201); }*/ - $html .= ' -'; $title = getconstStr('SetAdminPassword'); return message($html, $title, 201);