diff --git a/conststr.php b/conststr.php
index c6d265a..c4f5df8 100644
--- a/conststr.php
+++ b/conststr.php
@@ -70,7 +70,7 @@ $constStr = [
'diskname' => 'The disk name you want show.',
'disktag' => 'A tag used in store config and url.',
'downloadencrypt' => '0 or 1. if 1, the files in encrypt folder can be downloaded without password',
- 'background' => 'Set an url as background photo, or put a \'background.jpg\' at showed path.',
+ 'background' => 'Set an url as background photo.',
'guestup_path' => 'Set guest upload dir, before set this, the files in this dir will show as normal.',
'hideFunctionalityFile' => '0 or 1. if 1, some file will not show in list to guest, like readme.md',
'passfile' => 'The password of dir will save in this file.',
@@ -85,7 +85,7 @@ $constStr = [
'diskname' => '这个盘你想显示什么名称。',
'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。',
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
- 'background' => '设置一个url作为背景,或者在你显示的目录放一个background.jpg文件。',
+ 'background' => '设置一个url作为背景。',
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看,但它的功能正常,比如readme.md',
'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
@@ -114,7 +114,7 @@ $constStr = [
'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?',
'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.',
'downloadencrypt' => '',
- 'background' => 'URL을 배경으로 설정하거나 표시하는 디렉토리에 background.jpg 파일을 넣으십시오.',
+ 'background' => 'URL을 배경으로 설정하거나 표시하는.',
'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).',
'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.',
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',
diff --git a/function/common.php b/function/common.php
index d99cbc9..67f8c7a 100644
--- a/function/common.php
+++ b/function/common.php
@@ -175,20 +175,21 @@ function config_oauth()
function get_siteid($access_token)
{
+ if (getConfig('Drive_ver')=='MS') $url = 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname');
+ if (getConfig('Drive_ver')=='CN') $url = 'https://microsoftgraph.chinacloudapi.cn/v1.0/sites/root:/sites/'.getConfig('sharepointname');
$i=0;
$response = [];
- while ($response['stat']!=200&&$i<4) {
- $response = curl_request('https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname'), false, ['Authorization' => 'Bearer ' . $access_token]);
+ while ($url!=''&&$response['stat']!=200&&$i<4) {
+ $response = curl_request($url, false, ['Authorization' => 'Bearer ' . $access_token]);
$i++;
- echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].'
- ';
+ //echo 'https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname').$response['stat'].$response['body'].'
+ //';
+ }
+ if ($response['stat']!=200) {
+ error_log('failed to get siteid. response' . json_encode($response));
+ throw new Exception($response['stat'].', failed to get siteid.'.$response['body']);
}
return json_decode($response['body'],true)['id'];
- //$_SERVER['api_url'] = 'https://graph.microsoft.com/v1.0/sites/' . $tmp['siteid'] . '/drive/root';
- //setConfig($tmp);
-
- //error_log('failed to get siteid. response' . json_encode($response));
- //throw new Exception($response['stat'].', failed to get siteid.'.$response['body']);
}
function getListpath($domain)
@@ -261,7 +262,7 @@ function array_value_isnot_null($arr)
return $arr!=='';
}
-function curl_request($url, $data = false, $headers = [])
+function curl_request($url, $data = false, $headers = [], $returnheader = 0)
{
if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;
@@ -279,14 +280,23 @@ function curl_request($url, $data = false, $headers = [])
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_HEADER, $returnheader);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders);
- $response['body'] = curl_exec($ch);
+ //$response['body'] = curl_exec($ch);
+ if ($returnheader) {
+ list($returnhead, $response['body']) = explode("\r\n\r\n", curl_exec($ch));
+ foreach (explode("\r\n", $returnhead) as $head) {
+ $tmp = explode(': ', $head);
+ $heads[$tmp[0]] = $tmp[1];
+ }
+ $response['returnhead'] = $heads;
+ } else {
+ $response['body'] = curl_exec($ch);
+ }
$response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
- //if ($response['stat']==0) return curl_request($url, $data, $headers);
return $response;
}
@@ -544,26 +554,8 @@ function main($path)
if ($constStr['language']=='') $constStr['language'] = 'en-us';
$_SERVER['language'] = $constStr['language'];
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
- $_SERVER['base_disk_path'] = $_SERVER['base_path'];
- $disktags = explode("|",getConfig('disktag'));
-// echo 'count$disk:'.count($disktags);
- if (count($disktags)>1) {
- if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
- $_SERVER['disktag'] = $path;
- $pos = strpos($path, '/');
- if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
- if (!in_array($_SERVER['disktag'], $disktags)) return message('Please visit from Home Page.', 'Error', 404);
- $path = substr($path, strlen('/'.$_SERVER['disktag']));
- if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/');
- } else $_SERVER['disktag'] = $disktags[0];
-// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.'
-//';
- $_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
- if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
- $_SERVER['is_guestup_path'] = is_guestup_path($path);
- $_SERVER['ajax']=0;
- if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
+ if (getConfig('admin')=='') return install();
if (getConfig('adminloginpage')=='') {
$adminloginpage = 'admin';
} else {
@@ -598,8 +590,27 @@ function main($path)
$url = path_format($_SERVER['PHP_SELF'] . '/');
return output('', 302, [ 'Location' => $url ]);
}
-
- if (getConfig('admin')=='') return install();
+
+ $_SERVER['base_disk_path'] = $_SERVER['base_path'];
+ $disktags = explode("|",getConfig('disktag'));
+// echo 'count$disk:'.count($disktags);
+ if (count($disktags)>1) {
+ if ($path=='/'||$path=='') return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]);
+ $_SERVER['disktag'] = $path;
+ $pos = strpos($path, '/');
+ if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos);
+ if (!in_array($_SERVER['disktag'], $disktags)) return message('Please visit from Home Page.', 'Error', 404);
+ $path = substr($path, strlen('/'.$_SERVER['disktag']));
+ if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path']. '/' . $_SERVER['disktag'] . '/');
+ } else $_SERVER['disktag'] = $disktags[0];
+// echo 'main.disktag:'.$_SERVER['disktag'].',path:'.$path.'
+//';
+ $_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
+ if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
+ $_SERVER['is_guestup_path'] = is_guestup_path($path);
+ $_SERVER['ajax']=0;
+ if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest') $_SERVER['ajax']=1;
+
config_oauth();
if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token();
$refresh_token = getConfig('refresh_token');
@@ -1313,7 +1324,7 @@ function get_refresh_token()