Merge pull request #60 from qkqpttgf/master

pull
pull/98/head
Mr.Lin 2020-03-28 17:10:53 +08:00 committed by GitHub
commit e309e8dc7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 46 deletions

View File

@ -70,7 +70,7 @@ $constStr = [
'diskname' => 'The disk name you want show.', 'diskname' => 'The disk name you want show.',
'disktag' => 'A tag used in store config and url.', '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', '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.', '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', '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.', 'passfile' => 'The password of dir will save in this file.',
@ -85,7 +85,7 @@ $constStr = [
'diskname' => '这个盘你想显示什么名称。', 'diskname' => '这个盘你想显示什么名称。',
'disktag' => '一个标签用于保存配置多盘时会显示在url中。', 'disktag' => '一个标签用于保存配置多盘时会显示在url中。',
'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。', 'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。',
'background' => '设置一个url作为背景或者在你显示的目录放一个background.jpg文件。', 'background' => '设置一个url作为背景。',
'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。', 'guestup_path' => '设置游客上传路径(图床路径),不设置这个值时该目录内容会正常列文件出来,设置后只有上传界面,不显示其中文件(登录后显示)。',
'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看但它的功能正常比如readme.md', 'hideFunctionalityFile' => '0 或 1。如果 1, 某些文件不列表给游客看但它的功能正常比如readme.md',
'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;', 'passfile' => '自定义密码文件的名字,可以是\'pppppp\',也可以是\'aaaa.txt\'等等;列目录时不会显示,只有知道密码才能查看或下载此文件。密码是这个文件的内容,可以空格、可以中文;',
@ -114,7 +114,7 @@ $constStr = [
'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?', 'diskname' => '이 디스크에 어떤 이름을 표시 하시겠습니까?',
'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.', 'disktag' => '레이블은 구성을 저장하는 데 사용되며 디스크가 여러 개인 경우 URL에 표시됩니다.',
'downloadencrypt' => '', 'downloadencrypt' => '',
'background' => 'URL을 배경으로 설정하거나 표시하는 디렉토리에 background.jpg 파일을 넣으십시오.', 'background' => 'URL을 배경으로 설정하거나 표시하는.',
'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).', 'guestup_path' => '방문자의 업로드 경로 (맵 베드 경로)를 설정합니다.이 값을 설정하지 않으면 디렉토리의 내용이 파일로 표시되고 설정 후에는 업로드 인터페이스 만 표시되고 파일은 표시되지 않습니다 (로그인 후 표시).',
'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.', 'passfile' => '사용자 정의 비밀번호 파일의 이름은 \'pppppp\' \'aaaa.txt \'등이 될 수 있으며 디렉토리가 나열되어 있으면 표시되지 않으며 비밀번호를 알고있는 경우에만이 파일을 보거나 다운로드 할 수 있습니다. 암호는이 파일의 내용이며 공백이거나 한국어 일 수 있습니다.',
'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.', 'public_path' => 'API 긴 링크 액세스를 사용하는 경우 네트워크 디스크 파일의 경로가 표시됩니다. 설정되지 않은 경우 기본적으로 루트 디렉토리로 설정됩니다.',

View File

@ -175,20 +175,21 @@ function config_oauth()
function get_siteid($access_token) 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; $i=0;
$response = []; $response = [];
while ($response['stat']!=200&&$i<4) { while ($url!=''&&$response['stat']!=200&&$i<4) {
$response = curl_request('https://graph.microsoft.com/v1.0/sites/root:/sites/'.getConfig('sharepointname'), 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'].' //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']; 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) function getListpath($domain)
@ -261,7 +262,7 @@ function array_value_isnot_null($arr)
return $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['Accept'])) $headers['Accept'] = '*/*';
//if (!isset($headers['Referer'])) $headers['Referer'] = $url; //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_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 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_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $sendHeaders); 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); $response['stat'] = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);
//if ($response['stat']==0) return curl_request($url, $data, $headers);
return $response; return $response;
} }
@ -544,26 +554,8 @@ function main($path)
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);
$_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('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', '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')=='') { if (getConfig('adminloginpage')=='') {
$adminloginpage = 'admin'; $adminloginpage = 'admin';
} else { } else {
@ -599,7 +591,26 @@ function main($path)
return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 302, [ 'Location' => $url ]); return output('<script>alert(\''.getconstStr('SetSecretsFirst').'\');</script>', 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('<meta http-equiv="refresh" content="2;URL='.$_SERVER['base_path'].'">Please visit from <a href="'.$_SERVER['base_path'].'">Home Page</a>.', '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(); config_oauth();
if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token(); if ($_SERVER['admin']) if (isset($_GET['AddDisk'])||isset($_GET['authorization_code'])) return get_refresh_token();
$refresh_token = getConfig('refresh_token'); $refresh_token = getConfig('refresh_token');
@ -1313,7 +1324,7 @@ function get_refresh_token()
</div> </div>
<br> <br>
<div> <div>
<label><input type="checkbox" name="Drive_custom" onclick="document.getElementById(\'secret\').style.display=(document.getElementById(\'secret\').style.display==\'\'?\'none\':\'\');">'.getconstStr('CustomIdSecret').'</label> <label><input type="checkbox" name="Drive_custom" onclick="document.getElementById(\'secret\').style.display=(this.checked?\'\':\'none\');">'.getconstStr('CustomIdSecret').'</label>
<div id="secret" style="display:none;margin:10px 35px"> <div id="secret" style="display:none;margin:10px 35px">
<a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br> <a href="'.$app_url.'" target="_blank">'.getconstStr('GetSecretIDandKEY').'</a><br>
client_secret:<input type="text" name="client_secret"><br> client_secret:<input type="text" name="client_secret"><br>
@ -1321,7 +1332,7 @@ function get_refresh_token()
</div> </div>
</div> </div>
<div> <div>
<label><input type="checkbox" name="usesharepoint" onclick="document.getElementById(\'sharepoint\').style.display=(document.getElementById(\'sharepoint\').style.display==\'\'?\'none\':\'\');">'.getconstStr('UseSharepointInstead').'</label><br> <label><input type="checkbox" name="usesharepoint" onclick="document.getElementById(\'sharepoint\').style.display=(this.checked?\'\':\'none\');">'.getconstStr('UseSharepointInstead').'</label><br>
<div id="sharepoint" style="display:none;margin:10px 35px"> <div id="sharepoint" style="display:none;margin:10px 35px">
'.getconstStr('GetSharepointName').'<br> '.getconstStr('GetSharepointName').'<br>
<input type="text" name="sharepointname" placeholder="'.getconstStr('InputSharepointName').'"><br> <input type="text" name="sharepointname" placeholder="'.getconstStr('InputSharepointName').'"><br>
@ -1413,7 +1424,7 @@ function EnvOpt($needUpdate = 0)
} else { } else {
//WaitSCFStat(); //WaitSCFStat();
//sleep(3); //sleep(3);
$html .= 'Success!<br> $html .= getconstStr('Success') . '!<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>'; <button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
$title = getconstStr('Setup'); $title = getconstStr('Setup');
} }

View File

@ -118,7 +118,7 @@ function install()
if ($_GET['install2']) { if ($_GET['install2']) {
if ($_POST['admin']!='') { if ($_POST['admin']!='') {
$tmp['admin'] = $_POST['admin']; $tmp['admin'] = $_POST['admin'];
$tmp['language'] = $_POST['language']; $tmp['language'] = $_COOKIE['language'];
$response = setConfig($tmp); $response = setConfig($tmp);
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);

View File

@ -139,6 +139,7 @@ function install()
if ($_GET['install1']) { if ($_GET['install1']) {
//if ($_POST['admin']!='') { //if ($_POST['admin']!='') {
$tmp['language'] = $_POST['language']; $tmp['language'] = $_POST['language'];
$tmp['Region'] = $_POST['Region'];
$SecretId = getConfig('SecretId'); $SecretId = getConfig('SecretId');
if ($SecretId=='') { if ($SecretId=='') {
$SecretId = $_POST['SecretId']; $SecretId = $_POST['SecretId'];
@ -149,11 +150,9 @@ function install()
$SecretKey = $_POST['SecretKey']; $SecretKey = $_POST['SecretKey'];
$tmp['SecretKey'] = $SecretKey; $tmp['SecretKey'] = $SecretKey;
} }
$response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response']; $response = json_decode(SetbaseConfig($tmp, $_SERVER['function_name'], $_POST['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (api_error($response)) { if (api_error($response)) {
$html = api_error_msg($response); $html = api_error_msg($response);
$html .= '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
$title = 'Error'; $title = 'Error';
return message($html, $title, 201); return message($html, $title, 201);
} else { } else {
@ -190,6 +189,21 @@ language:<br>';
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br> <label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>'; <label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
$html .= ' $html .= '
<select class="changelanguage" name="Region">
<option value="">选择区域</option>
<option value="ap-beijing">华北地区(北京)</option>
<option value="ap-chengdu">西南地区(成都)</option>
<option value="ap-guangzhou">华南地区(广州)</option>
<option value="ap-guangzhou-open">华南地区(广州Open)</option>
<option value="ap-hongkong">港澳台地区(中国香港)</option>
<option value="ap-mumbai">亚太南部(孟买)</option>
<option value="ap-shanghai">华东地区(上海)</option>
<option value="ap-shanghai-fsi">华东地区(上海金融)</option>
<option value="ap-singapore">亚太东南(新加坡)</option>
<option value="ap-tokyo">亚太东北(东京)</option>
<option value="na-siliconvalley">美国西部(硅谷)</option>
<option value="na-toronto">北美地区(多伦多)</option>
</select>(腾讯几个月了还不做出来,只能先弄选择了)<br>
<input type="submit" value="'.getconstStr('Submit').'"> <input type="submit" value="'.getconstStr('Submit').'">
</form> </form>
<script> <script>

View File

@ -705,8 +705,7 @@
tmptextarea.select(); tmptextarea.select();
tmptextarea.setSelectionRange(0, tmptextarea.value.length); tmptextarea.setSelectionRange(0, tmptextarea.value.length);
document.execCommand("copy"); document.execCommand("copy");
//alert(tmptextarea.innerHTML); alert(tmptextarea.innerHTML+'<?php echo getconstStr('Success'); ?>');
alert('Success');
} }
var sort=0; var sort=0;
function sortby(string) { function sortby(string) {