use accept_language
parent
a868d5df44
commit
286046b82a
72
common.php
72
common.php
|
@ -45,7 +45,7 @@ $CommonEnv = [
|
||||||
'disktag',
|
'disktag',
|
||||||
'function_name', // used in heroku.
|
'function_name', // used in heroku.
|
||||||
'hideFunctionalityFile',
|
'hideFunctionalityFile',
|
||||||
'language',
|
//'language',
|
||||||
'passfile',
|
'passfile',
|
||||||
'sitename',
|
'sitename',
|
||||||
'theme',
|
'theme',
|
||||||
|
@ -62,7 +62,7 @@ $ShowedCommonEnv = [
|
||||||
//'disktag',
|
//'disktag',
|
||||||
//'function_name', // used in heroku.
|
//'function_name', // used in heroku.
|
||||||
'hideFunctionalityFile',
|
'hideFunctionalityFile',
|
||||||
'language',
|
//'language',
|
||||||
'passfile',
|
'passfile',
|
||||||
'sitename',
|
'sitename',
|
||||||
'theme',
|
'theme',
|
||||||
|
@ -113,8 +113,11 @@ function main($path)
|
||||||
global $exts;
|
global $exts;
|
||||||
global $constStr;
|
global $constStr;
|
||||||
|
|
||||||
if (isset($_COOKIE['language'])) $constStr['language'] = $_COOKIE['language'];
|
if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) $constStr['language'] = $_SERVER['firstacceptlanguage'];
|
||||||
if (!$constStr['language']) $constStr['language'] = getConfig('language');
|
if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language'];
|
||||||
|
//if (!$constStr['language']) $constStr['language'] = getConfig('language');
|
||||||
|
/*echo 'firstacceptlanguage:'.$_SERVER['firstacceptlanguage'].'
|
||||||
|
'.'lan:'.$constStr['language'];*/
|
||||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||||
$_SERVER['language'] = $constStr['language'];
|
$_SERVER['language'] = $constStr['language'];
|
||||||
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
|
||||||
|
@ -274,28 +277,7 @@ function main($path)
|
||||||
function get_access_token($refresh_token)
|
function get_access_token($refresh_token)
|
||||||
{
|
{
|
||||||
if (getConfig('Drive_ver')=='shareurl') {
|
if (getConfig('Drive_ver')=='shareurl') {
|
||||||
|
|
||||||
//if (!$files) $files['body'] = $arr['body'];
|
|
||||||
//$files['returnhead'] = $arr['returnhead'];
|
|
||||||
//$files['cookie'] = $arr['returnhead']['Set-Cookie'];
|
|
||||||
//return $files;
|
|
||||||
|
|
||||||
/*$files['get'] = curl_request(
|
|
||||||
"https://mfedu-my.sharepoint.com/personal/ysun_ac_stu_office_gy/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='%2Fpersonal%2Fysun_ac_stu_office_gy%2FDocuments'&RootFolder=%2Fpersonal%2Fysun_ac_stu_office_gy%2FDocuments%2F&TryNewExperienceSingle=TRUE",
|
|
||||||
'{"parameters":{"__metadata":{"type":"SP.RenderListDataParameters"},"RenderOptions":136967,"AllowMultipleValueFilterForTaxonomyFields":true,"AddRequiredFields":true}}',
|
|
||||||
['Accept' => 'application/json;odata=verbose', 'Content-Type' => 'application/json;odata=verbose', 'origin' => 'https://mfedu-my.sharepoint.com', 'Cookie' => $arr['returnhead']['Set-Cookie']],
|
|
||||||
1);
|
|
||||||
$files['get']['body'] = json_decode($files['get']['body'], true);
|
|
||||||
$_SERVER['access_token'] = splitlast($files['get']['body']['ListSchema']['.driveAccessToken'],'=')[1];
|
|
||||||
$_SERVER['api_url'] = $files['get']['body']['ListSchema']['.driveUrl'].'/root';
|
|
||||||
|
|
||||||
$files = json_decode( curl_request( $_SERVER['api_url'].'?expand=children(select=name,size,file,folder,parentReference,lastModifiedDateTime,@microsoft.graph.downloadUrl,@content.downloadUrl)', false, ['Authorization' => 'Bearer ' . $_SERVER['access_token'], 'Accept' => 'application/json'] )['body'], true);
|
|
||||||
$files['children']['a']['file'] = $_SERVER['api_url'];
|
|
||||||
$files['children']['a']['name'] = $_SERVER['api_url'];
|
|
||||||
*/
|
|
||||||
$shareurl = getConfig('shareurl');
|
$shareurl = getConfig('shareurl');
|
||||||
//$url = 'https://mfedu-my.sharepoint.com/:f:/g/personal/ysun_ac_stu_office_gy/EpDIBOaYyExHjfu-PJA46icB40X0FKVwmn_9UDJsRvu3Ug?e=XyRZxP';
|
|
||||||
//$url = 'https://2d2-my.sharepoint.com/:f:/g/personal/ysun_host_ac_cn/Ehy8pjSQSoZOtLDs4ZKPiGUBYFt26CjEwG6bw7W5vleNNQ?e=DLZcWF';
|
|
||||||
$tmp1 = splitlast($shareurl, '/')[0];
|
$tmp1 = splitlast($shareurl, '/')[0];
|
||||||
$account = splitlast($tmp1, '/')[1];
|
$account = splitlast($tmp1, '/')[1];
|
||||||
$tmp1 = splitlast($shareurl, ':')[0];
|
$tmp1 = splitlast($shareurl, ':')[0];
|
||||||
|
@ -311,8 +293,8 @@ function get_access_token($refresh_token)
|
||||||
$_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root';
|
$_SERVER['api_url'] = $ret['ListSchema']['.driveUrl'].'/root';
|
||||||
if (!$_SERVER['access_token']) {
|
if (!$_SERVER['access_token']) {
|
||||||
error_log($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
|
error_log($domain . "/personal/" . $account . "/_api/web/GetListUsingPath(DecodedUrl=@a1)/RenderListDataAsStream?@a1='" . urlencode("/personal/" . $account . "/Documents") . "'&RootFolder=" . urlencode("/personal/" . $account . "/Documents/") . "&TryNewExperienceSingle=TRUE");
|
||||||
error_log('failed to get access_token. response' . json_encode($ret));
|
error_log('failed to get share access_token. response' . json_encode($ret));
|
||||||
throw new Exception($response['stat'].', failed to get access_token.'.$response['body']);
|
throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']);
|
||||||
}
|
}
|
||||||
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
|
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
|
||||||
savecache('access_token', $_SERVER['access_token']);
|
savecache('access_token', $_SERVER['access_token']);
|
||||||
|
@ -362,14 +344,12 @@ function isHideFile($name)
|
||||||
|
|
||||||
function getcache($str)
|
function getcache($str)
|
||||||
{
|
{
|
||||||
//$cache = null;
|
|
||||||
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
||||||
return $cache->fetch($str);
|
return $cache->fetch($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function savecache($key, $value, $exp = 1800)
|
function savecache($key, $value, $exp = 1800)
|
||||||
{
|
{
|
||||||
//$cache = null;
|
|
||||||
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
$cache = new \Doctrine\Common\Cache\FilesystemCache(sys_get_temp_dir(), __DIR__.'/Onedrive/'.$_SERVER['disktag']);
|
||||||
$cache->save($key, $value, $exp);
|
$cache->save($key, $value, $exp);
|
||||||
}
|
}
|
||||||
|
@ -434,8 +414,6 @@ function get_siteid($access_token)
|
||||||
while ($url!=''&&$response['stat']!=200&&$i<4) {
|
while ($url!=''&&$response['stat']!=200&&$i<4) {
|
||||||
$response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
|
$response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
|
||||||
$i++;
|
$i++;
|
||||||
//echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].'
|
|
||||||
//';
|
|
||||||
}
|
}
|
||||||
if ($response['stat']!=200) {
|
if ($response['stat']!=200) {
|
||||||
error_log('failed to get siteid. response' . json_encode($response));
|
error_log('failed to get siteid. response' . json_encode($response));
|
||||||
|
@ -505,7 +483,9 @@ function equal_replace($str, $add = false)
|
||||||
|
|
||||||
function is_guestup_path($path)
|
function is_guestup_path($path)
|
||||||
{
|
{
|
||||||
if (path_format('/'.path_format(urldecode($_SERVER['list_path'].path_format($path))).'/')==path_format('/'.path_format(getConfig('guestup_path')).'/')&&getConfig('guestup_path')!='') return 1;
|
$a1 = path_format(path_format(urldecode($_SERVER['list_path'].path_format($path))).'/')
|
||||||
|
$a2 = path_format(path_format(getConfig('guestup_path')).'/')
|
||||||
|
if (getConfig('guestup_path')!=''&&strtolower($a1)==strtolower($a2)) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,18 +937,36 @@ function adminoperate($path)
|
||||||
return $tmparr;
|
return $tmparr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function splitfirst($str, $split)
|
||||||
|
{
|
||||||
|
$len = strlen($split);
|
||||||
|
$pos = strpos($str, $split);
|
||||||
|
if ($pos===false) {
|
||||||
|
$tmp[0] = $str;
|
||||||
|
$tmp[1] = '';
|
||||||
|
} elseif ($pos>0) {
|
||||||
|
$tmp[0] = substr($str, 0, $pos);
|
||||||
|
$tmp[1] = substr($str, $pos+$len);
|
||||||
|
} else {
|
||||||
|
$tmp[0] = '';
|
||||||
|
$tmp[1] = substr($str, $len);
|
||||||
|
}
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
function splitlast($str, $split)
|
function splitlast($str, $split)
|
||||||
{
|
{
|
||||||
|
$len = strlen($split);
|
||||||
$pos = strrpos($str, $split);
|
$pos = strrpos($str, $split);
|
||||||
if ($pos===false) {
|
if ($pos===false) {
|
||||||
$tmp[0] = $str;
|
$tmp[0] = $str;
|
||||||
$tmp[1] = '';
|
$tmp[1] = '';
|
||||||
} elseif ($pos>0) {
|
} elseif ($pos>0) {
|
||||||
$tmp[0] = substr($str, 0, $pos);
|
$tmp[0] = substr($str, 0, $pos);
|
||||||
$tmp[1] = substr($str, $pos+1);
|
$tmp[1] = substr($str, $pos+$len);
|
||||||
} else {
|
} else {
|
||||||
$tmp[0] = '';
|
$tmp[0] = '';
|
||||||
$tmp[1] = substr($str, 1);
|
$tmp[1] = substr($str, $len);
|
||||||
}
|
}
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
@ -1612,14 +1610,14 @@ function EnvOpt($needUpdate = 0)
|
||||||
<a href="?AddDisk">'.getconstStr('AddDisk').'</a><br><br>';
|
<a href="?AddDisk">'.getconstStr('AddDisk').'</a><br><br>';
|
||||||
if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
|
if (!((isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud')||(isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app'))) {
|
||||||
$html .= '
|
$html .= '
|
||||||
In VPS can not update by a click!<br>';
|
'.getconstStr('VPSnotupdate').'<br>';
|
||||||
} else {
|
} else {
|
||||||
$html .= '
|
$html .= '
|
||||||
<form name="updateform" action="" method="post">
|
<form name="updateform" action="" method="post">
|
||||||
<input type="text" name="auth" placeholder="auth" value="qkqpttgf">
|
<input type="text" name="auth" placeholder="auth" value="qkqpttgf">
|
||||||
<input type="text" name="project" placeholder="project" value="OneManager-php">
|
<input type="text" name="project" placeholder="project" value="OneManager-php">
|
||||||
<button onclick="querybranchs();return false">查询分支</button>
|
<button onclick="querybranchs();return false">'.getconstStr('QueryBranchs').'</button>
|
||||||
<!--<input type="text" name="branch" placeholder="auth" value="master">-->
|
<!--<input type="text" name="branch" placeholder="branch" value="master">-->
|
||||||
<select name="branch">
|
<select name="branch">
|
||||||
<option value="master">master</option>
|
<option value="master">master</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue