diff --git a/functions.php b/functions.php index 0230000..dcddc1f 100644 --- a/functions.php +++ b/functions.php @@ -234,7 +234,7 @@ function get_refresh_token() return message('
' . $tmp['body'] . '
', $tmp['stat']); //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '
', 500); } - if ($_GET['install2']) { + if ($_GET['install3']) { if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { return message(' '.$constStr['JumptoOffice'][$constStr['language']].' @@ -248,7 +248,7 @@ function get_refresh_token() ', $constStr['Wait'][$constStr['language']].' 1s', 201); } } - if ($_GET['install1']) { + if ($_GET['install2']) { // echo $_POST['Onedrive_ver']; if ($_POST['Onedrive_ver']=='MS' || $_POST['Onedrive_ver']=='CN' || $_POST['Onedrive_ver']=='MSC') { $tmp['Onedrive_ver'] = $_POST['Onedrive_ver']; @@ -258,7 +258,7 @@ function get_refresh_token() } $response = setConfig($tmp); $title = $constStr['MayinEnv'][$constStr['language']]; - $html = $constStr['Wait'][$constStr['language']] . ' 3s'; + $html = $constStr['Wait'][$constStr['language']] . ' 3s'; if (!$response) { $html = $response . '
Can not write config to file.
@@ -268,7 +268,7 @@ Can not write config to file.
return message($html, $title, 201); } } - if ($_GET['install0']) { + if ($_GET['install1']) { if ($_POST['admin']!='') { $tmp['admin'] = $_POST['admin']; $tmp['language'] = $_POST['language']; @@ -281,7 +281,7 @@ Can not write config to file.
$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 = ' -
+ Onedrive_Ver:


@@ -304,16 +304,28 @@ Can not write config to file.
return message($html, $title, 201); } } - $html .= ' - -
- language:
'; - foreach ($constStr['languages'] as $key1 => $value1) { + if ($_GET['install0']) { + if (!ConfigWriteable()) { + $html .= 'Plase make sure the config.php is writeable. +run Writeable.sh.'; + $title = 'Error'; + return message($html, $title, 201); + } + if (!RewriteEngineOn()) { + $html .= 'Plase make sure the RewriteEngine is On.'; + $title = 'Error'; + return message($html, $title, 201); + } $html .= ' -
'; - } - $html .= '
- + +
+language:
'; + foreach ($constStr['languages'] as $key1 => $value1) { + $html .= ' +
'; + } + $html .= '
+
'; - $title = $constStr['SelectLanguage'][$constStr['language']]; + $title = $constStr['SelectLanguage'][$constStr['language']]; + return message($html, $title, 201); + } + $html .= 'refresh_token not exist, click to install.'; + $title = 'Error'; return message($html, $title, 201); } +function ConfigWriteable() +{ + $t = md5( md5(time()).rand(1000,9999) ); + setConfig([ 'tmp' => $t ]); + $tmp = getConfig('tmp'); + setConfig([ 'tmp' => '' ]); + if ($tmp == $t) 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'] . '/config.php'; //.$_SERVER["REQUEST_URI"]; + $tmp = curl_request($tmpurl); + if ($tmp['stat']==201) return true; //when install return 201, after installed return 404 or 200; + return false; +} + function get_timezone($timezone = '8') { $timezones = array( @@ -500,7 +535,7 @@ function setConfig($arr) $envs = array_filter($envs, 'array_value_isnot_null'); ksort($envs); //echo '
'. json_encode($envs, JSON_PRETTY_PRINT).'
'; - $prestr = '