Add platform Glitch

This commit is contained in:
root 2020-11-06 18:02:03 +08:00
parent 580cd87af0
commit bd629d954c
4 changed files with 11 additions and 8 deletions

3
glitch.json Normal file
View File

@ -0,0 +1,3 @@
{
"start": "php -S 0.0.0.0:8080 index.php"
}

View File

@ -46,7 +46,7 @@ function getConfig($str, $disktag = '')
global $InnerEnv;
global $Base64Env;
//include 'config.php';
$s = file_get_contents('config.php');
$s = file_get_contents('.data/config.php');
//$configs = substr($s, 18, -2);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') {
@ -73,7 +73,7 @@ function setConfig($arr, $disktag = '')
global $Base64Env;
if ($disktag=='') $disktag = $_SERVER['disktag'];
//include 'config.php';
$s = file_get_contents('config.php');
$s = file_get_contents('.data/config.php');
//$configs = substr($s, 18, -2);
$configs = '{' . splitlast(splitfirst($s, '{')[1], '}')[0] . '}';
if ($configs!='') $envs = json_decode($configs, true);
@ -114,7 +114,7 @@ function setConfig($arr, $disktag = '')
//echo '<pre>'. json_encode($envs, JSON_PRETTY_PRINT).'</pre>';
$prestr = '<?php $configs = \'' . PHP_EOL;
$aftstr = PHP_EOL . '\';';
$response = file_put_contents('config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
$response = file_put_contents('.data/config.php', $prestr . json_encode($envs, JSON_PRETTY_PRINT) . $aftstr);
if ($response>0) return json_encode( [ 'response' => 'success' ] );
return json_encode( [ 'message' => 'Failed to write config.', 'code' => 'failed' ] );
}
@ -183,7 +183,7 @@ function install()
//if (location.port!="") url += ":" + location.port;
url += location.pathname;
if (url.substr(-1)!="/") url += "/";
url += "config.php";
url += ".data/config.php";
//alert(url);
var xhr4 = new XMLHttpRequest();
xhr4.open("GET", url);
@ -248,7 +248,7 @@ 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');
$tmpurl .= path_format($_SERVER['base_path'] . '/.data/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;
@ -308,10 +308,10 @@ function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch =
if ($outPath=='') return 0;
//unlink($outPath.'/config.php');
$response = rename($projectPath . $slash . 'config.php', $outPath . $slash . 'config.php');
$response = rename($projectPath . $slash . '.data' . $slash . 'config.php', $outPath . $slash . '.data' . $slash . 'config.php');
if (!$response) {
$tmp1['code'] = "Move Failed";
$tmp1['message'] = "Can not move " . $projectPath . $slash . 'config.php' . " to " . $outPath . $slash . 'config.php';
$tmp1['message'] = "Can not move " . $projectPath . $slash . '.data' . $slash . 'config.php' . " to " . $outPath . $slash . '.data' . $slash . 'config.php';
return json_encode($tmp1);
}
return moveFolder($outPath, $projectPath, $slash);

View File

@ -1,3 +1,3 @@
OneManagerPath=`cd $(dirname $0);pwd -P`
cd ${OneManagerPath}
chmod 666 config.php
chmod 666 .data/config.php