diff --git a/platform/Vercel.php b/platform/Vercel.php index a808bc1..bd1bef0 100644 --- a/platform/Vercel.php +++ b/platform/Vercel.php @@ -1,31 +1,29 @@ 0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); + $p = strpos($_SERVER['REQUEST_URI'], '?'); + if ($p > 0) $path = substr($_SERVER['REQUEST_URI'], 0, $p); else $path = $_SERVER['REQUEST_URI']; - $path = path_format( substr($path, strlen($_SERVER['base_path'])) ); + $path = path_format(substr($path, strlen($_SERVER['base_path']))); return $path; } -function getGET() -{ +function getGET() { if (!$_POST) { if (!!$HTTP_RAW_POST_DATA) { $tmpdata = $HTTP_RAW_POST_DATA; @@ -35,20 +33,20 @@ function getGET() if (!!$tmpdata) { $postbody = explode("&", $tmpdata); foreach ($postbody as $postvalues) { - $pos = strpos($postvalues,"="); - $_POST[urldecode(substr($postvalues,0,$pos))]=urldecode(substr($postvalues,$pos+1)); + $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); + $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; + //echo $pos; if ($pos > 0) { $getarry[urldecode(substr($getvalues, 0, $pos))] = urldecode(substr($getvalues, $pos + 1)); } else { @@ -64,16 +62,15 @@ function getGET() } } -function getConfig($str, $disktag = '') -{ +function getConfig($str, $disktag = '') { $projectPath = splitlast(__DIR__, '/')[0]; $configPath = $projectPath . '/.data/config.php'; $s = file_get_contents($configPath); $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}'; - if ($configs!='') { + if ($configs != '') { $envs = json_decode($configs, true); if (isInnerEnv($str)) { - if ($disktag=='') $disktag = $_SERVER['disktag']; + if ($disktag == '') $disktag = $_SERVER['disktag']; if (isset($envs[$disktag][$str])) { if (isBase64Env($str)) return base64y_decode($envs[$disktag][$str]); else return $envs[$disktag][$str]; @@ -88,15 +85,14 @@ function getConfig($str, $disktag = '') return ''; } -function setConfig($arr, $disktag = '') -{ - if ($disktag=='') $disktag = $_SERVER['disktag']; +function setConfig($arr, $disktag = '') { + if ($disktag == '') $disktag = $_SERVER['disktag']; $projectPath = splitlast(__DIR__, '/')[0]; $configPath = $projectPath . '/.data/config.php'; $s = file_get_contents($configPath); $configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}'; - if ($configs!='') $envs = json_decode($configs, true); - $disktags = explode("|",getConfig('disktag')); + if ($configs != '') $envs = json_decode($configs, true); + $disktags = explode("|", getConfig('disktag')); $indisk = 0; $operatedisk = 0; foreach ($arr as $k => $v) { @@ -107,20 +103,20 @@ function setConfig($arr, $disktag = '') if (isBase64Env($k)) $envs[$disktag][$k] = base64y_encode($v); else $envs[$disktag][$k] = $v; $indisk = 1; - } elseif ($k=='disktag_add') { + } elseif ($k == 'disktag_add') { array_push($disktags, $v); $operatedisk = 1; - } elseif ($k=='disktag_del') { - $disktags = array_diff($disktags, [ $v ]); + } elseif ($k == 'disktag_del') { + $disktags = array_diff($disktags, [$v]); $envs[$v] = ''; $operatedisk = 1; - } elseif ($k=='disktag_copy') { + } 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; + } elseif ($k == 'disktag_rename' || $k == 'disktag_newname') { + if ($arr['disktag_rename'] != $arr['disktag_newname']) $operatedisk = 1; } else { $envs[$k] = $v; } @@ -132,10 +128,10 @@ function setConfig($arr, $disktag = '') $envs[$disktag] = $diskconfig; } if ($operatedisk) { - if (isset($arr['disktag_newname']) && $arr['disktag_newname']!='') { + if (isset($arr['disktag_newname']) && $arr['disktag_newname'] != '') { $tags = []; foreach ($disktags as $tag) { - if ($tag==$arr['disktag_rename']) array_push($tags, $arr['disktag_newname']); + if ($tag == $arr['disktag_rename']) array_push($tags, $arr['disktag_newname']); else array_push($tags, $tag); } $envs['disktag'] = implode('|', $tags); @@ -143,8 +139,9 @@ function setConfig($arr, $disktag = '') $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); + $disktag_s = ""; + foreach ($disktags as $disktag) if ($disktag != '') $disktag_s .= $disktag . '|'; + if ($disktag_s != '') $envs['disktag'] = substr($disktag_s, 0, -1); else $envs['disktag'] = ''; } } @@ -156,11 +153,10 @@ function setConfig($arr, $disktag = '') return setVercelConfig($envs, getConfig('HerokuappId'), getConfig('APIKey')); } -function install() -{ +function install() { global $constStr; if ($_GET['install1']) { - if ($_POST['admin']!='') { + if ($_POST['admin'] != '') { $tmp['admin'] = $_POST['admin']; //$tmp['language'] = $_POST['language']; $tmp['timezone'] = $_COOKIE['timezone']; @@ -178,10 +174,10 @@ function install() $aliases1 = []; foreach ($aliases["aliases"] as $key => $aliase) { $aliases1[] = $aliase["alias"]; - if ($host==$aliase["alias"]) $projectId = $aliase["projectId"]; + if ($host == $aliase["alias"]) $projectId = $aliase["projectId"]; } if (!$projectId) { - $html = 'Please visit from: ' . json_encode($aliases1); + $html = 'Please visit from one of: ' . json_encode($aliases1, JSON_PRETTY_PRINT); return message($html, 'Error', 400); } $tmp['HerokuappId'] = $projectId; @@ -209,17 +205,18 @@ function install() } }, 1000); '; + $title = "Success"; return message($html, $title, 201, 1); } } } if ($_GET['install0']) { - $html .= ' + $html = '
'; + $title = "Success"; return message($html, $title, 201, 1); } } @@ -497,6 +491,6 @@ function changeAuthKey() { function smallfileupload($drive, $path) { if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); - if ($_FILES['file1']['size']>4*1024*1024) return output('File too large', 400); + if ($_FILES['file1']['size'] > 4 * 1024 * 1024) return output('File too large', 400); return $drive->smallfileupload($path, $_FILES['file1']); }