0) $path = substr($_SERVER['REQUEST_URI'], 0, $p);
else $path = $_SERVER['REQUEST_URI'];
$path = path_format( substr($path, strlen($_SERVER['base_path'])) );
return $path;
//return spurlencode($path, '/');
}
function getGET()
{
$getstr = urldecode(substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'],'?')));
while (substr($getstr, 0, 1) == '/' || substr($getstr, 0, 1) == '?') $getstr = substr($getstr, 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 get_refresh_token()
{
global $constStr;
$url = path_format($_SERVER['PHP_SELF'] . '/');
if ($_GET['authorization_code'] && isset($_GET['code'])) {
$tmp = curl_request($_SERVER['oauth_url'] . 'token', 'client_id=' . $_SERVER['client_id'] .'&client_secret=' . $_SERVER['client_secret'] . '&grant_type=authorization_code&requested_token_use=on_behalf_of&redirect_uri=' . $_SERVER['redirect_uri'] .'&code=' . $_GET['code']);
if ($tmp['stat']==200) $ret = json_decode($tmp['body'], true);
if (isset($ret['refresh_token'])) {
$tmptoken = $ret['refresh_token'];
$str = '
refresh_token :
';
/*for ($i=1;strlen($tmptoken)>0;$i++) {
$t['t' . $i] = substr($tmptoken,0,128);
$str .= '
t' . $i . ':
';
$tmptoken=substr($tmptoken,128);
}
$str .= '
Add t1-t'.--$i.' to environments.*/
$str .= '
Adding refresh_token to Config.
';
setConfig([ 'refresh_token' => $tmptoken ]);
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
$str .= '
';
return message($str, $constStr['WaitJumpIndex'][$constStr['language']]);
}
return message('
' . $tmp['body'] . '', $tmp['stat']); //return message('
' . json_encode($ret, JSON_PRETTY_PRINT) . '', 500); } if ($_GET['install3']) { if (getConfig('Onedrive_ver')=='MS' || getConfig('Onedrive_ver')=='CN' || getConfig('Onedrive_ver')=='MSC') { return message(' '.$constStr['JumptoOffice'][$constStr['language']].' ', $constStr['Wait'][$constStr['language']].' 1s', 201); } } 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']; if ($_POST['Onedrive_ver']=='MSC') { $tmp['client_id'] = $_POST['client_id']; $tmp['client_secret'] = $_POST['client_secret']; } $response = setConfig($tmp); $title = $constStr['MayinEnv'][$constStr['language']]; $html = $constStr['Wait'][$constStr['language']] . ' 3s'; if (!$response) { $html = $response . '
'. json_encode($envs, JSON_PRETTY_PRINT).''; $prestr = '