Merge pull request #48 from qkqpttgf/master

pull
pull/98/head
Mr.Lin 2020-03-20 21:47:39 +08:00 committed by GitHub
commit 53c300d93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 30 deletions

View File

@ -6,7 +6,7 @@ RewriteRule ^(.*) index.php?/$1 [L]
#-----------------------------------
# nginx
# rewrite ^(.*) index.php?/$1 last;
# rewrite ^(.*) /index.php?/$1 last;
#
# caddy (not sure)
# rewrite {

View File

@ -688,7 +688,18 @@ $constStr = [
'ko-kr' => '다시 쓰기 (의사 정적) 기능이 활성화되어 있는지 확인하십시오.',
'fa' => 'لطفاً مطمئن شوید که RewriteEngine روشن است.',
],
'CopyUrl' => [
'en-us' => 'Copy URL',
'zh-cn' => '复制链接',
],
'Success' => [
'en-us' => 'Success',
'zh-cn' => '成功',
],
'SetAdminPassword' => [
'en-us' => 'Set Admin Password',
'zh-cn' => '设置管理密码',
],
'Refresh' => [
'en-us' => 'Refresh',
'zh-cn' => '刷新',

View File

@ -608,7 +608,12 @@ function main($path)
$data = '{"name":"' . $_GET['filemd5'] . $ext . '"}';
//echo $oldname .'<br>'. $data;
$tmp = MSAPI('PATCH',$oldname,$data,$_SERVER['access_token']);
if ($tmp['stat']==409) MSAPI('DELETE',$oldname,'',$_SERVER['access_token'])['body'];
if ($tmp['stat']==409) {
MSAPI('DELETE',$oldname,'',$_SERVER['access_token']);
$tmpbody = json_decode($tmp['body'], true);
$tmpbody['name'] = $_GET['filemd5'] . $ext;
$tmp['body'] = json_encode($tmpbody);
}
$path1 = path_format($_SERVER['list_path'] . path_format($path));
savecache('path_' . $path1, json_decode('{}',true), 1);
return output($tmp['body'],$tmp['stat']);

View File

@ -93,6 +93,7 @@ function setConfig($arr, $disktag = '')
if ($disktag_s!='') $tmp['disktag'] = substr($disktag_s, 0, -1);
else $tmp['disktag'] = '';
}
foreach ($tmp as $key => $val) if ($val=='') $tmp[$key]=null;
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
//';
return setHerokuConfig($tmp, getConfig('function_name'), getConfig('APIKey'));

View File

@ -112,7 +112,9 @@ function setConfig($arr, $disktag = '')
}
// echo '正式设置:'.json_encode($tmp,JSON_PRETTY_PRINT).'
//';
return updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
$response = updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey'));
WaitSCFStat();
return $response;
}
function WaitSCFStat()
@ -125,9 +127,17 @@ function WaitSCFStat()
function install()
{
global $constStr;
if ($_GET['install1']) {
if ($_POST['admin']!='') {
if ($_GET['install2']) {
$tmp['admin'] = $_POST['admin'];
setConfig($tmp);
if (needUpdate()) {
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
return message('update to github version, reinstall.<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
}
return output('Jump<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
}
if ($_GET['install1']) {
//if ($_POST['admin']!='') {
$tmp['language'] = $_POST['language'];
$SecretId = getConfig('SecretId');
if ($SecretId=='') {
@ -145,18 +155,27 @@ function install()
$html .= '<br>
<button onclick="location.href = location.href;">'.getconstStr('Refresh').'</button>';
$title = 'Error';
return message($html, $title, 201);
} else {
$trynum = 0;
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
'.++$trynum;
if (needUpdate()) {
updateProgram($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
return message('update to github version, reinstall.<meta http-equiv="refresh" content="3;URL=' . $url . '">', 'Program updating', 201);
$html .= '
<form action="?install2" method="post" onsubmit="return notnull(this);">
<label>'.getconstStr('SetAdminPassword').':<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'Input admin\');
return false;
}
return output('Jump<meta http-equiv="refresh" content="3;URL=' . path_format($_SERVER['base_path'] . '/') . '">', 302);
return true;
}
</script>';
$title = getconstStr('SetAdminPassword');
return message($html, $title, 201);
}
//}
}
if ($_GET['install0']) {
$html .= '
@ -171,8 +190,6 @@ language:<br>';
<label>SecretId:<input name="SecretId" type="text" placeholder="" size=""></label><br>
<label>SecretKey:<input name="SecretKey" type="text" placeholder="" size=""></label><br>';
$html .= '
<label>Set admin password:<input name="admin" type="password" placeholder="' . getconstStr('EnvironmentsDescription')['admin'] . '" size="' . strlen(getconstStr('EnvironmentsDescription')['admin']) . '"></label><br>';
$html .= '
<input type="submit" value="'.getconstStr('Submit').'">
</form>
<script>
@ -182,11 +199,7 @@ language:<br>';
location.href = location.href;
}
function notnull(t)
{
if (t.admin.value==\'\') {
alert(\'input admin\');
return false;
}';
{';
if (getConfig('SecretId')==''||getConfig('SecretKey')=='') $html .= '
if (t.SecretId.value==\'\') {
alert(\'input SecretId\');

View File

@ -209,7 +209,7 @@
else $filenum = 0; ?>
<table class="list-table" id="list-table">
<tr id="tr0">
<th class="file"><a onclick="sortby('a');"><?php echo getconstStr('File'); ?></a><?php if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) { ?>&nbsp;&nbsp;&nbsp;<button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button><?php } ?><button onclick="CopyAllDownloadUrl();"><?php echo getconstStr('CopyAllDownloadUrl'); ?></button></th>
<th class="file"><a onclick="sortby('a');"><?php echo getconstStr('File'); ?></a><?php if (!(isset($_SERVER['USER'])&&$_SERVER['USER']=='qcloud')) { ?>&nbsp;&nbsp;&nbsp;<button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button><?php } ?>&nbsp;<button onclick="CopyAllDownloadUrl('.download');"><?php echo getconstStr('CopyAllDownloadUrl'); ?></button></th>
<th class="updated_at" width="25%"><a onclick="sortby('time');"><?php echo getconstStr('EditTime'); ?></a></th>
<th class="size" width="15%"><a onclick="sortby('size');"><?php echo getconstStr('Size'); ?></a></th>
</tr>
@ -712,17 +712,18 @@
} else console.log(xhr.status+'\n'+xhr.responseText);
}
}
function CopyAllDownloadUrl() {
function CopyAllDownloadUrl(str) {
var tmptextarea=document.createElement('textarea');
document.body.appendChild(tmptextarea);
tmptextarea.setAttribute('style','position:absolute;left:-100px;width:0px;height:0px;');
document.querySelectorAll('.download').forEach(function (e) {
document.querySelectorAll(str).forEach(function (e) {
tmptextarea.innerHTML+=e.href+"\r\n";
});
tmptextarea.select();
tmptextarea.setSelectionRange(0, tmptextarea.value.length);
document.execCommand("copy");
alert(tmptextarea.innerHTML);
//alert('Success');
}
var sort=0;
function sortby(string) {
@ -1001,8 +1002,9 @@
xhr4.onload = function(e){
console.log(xhr4.responseText+','+xhr4.status);
var filename;
if (xhr4.status==200) filename = JSON.parse(xhr4.responseText)['name'];
if (xhr4.status==409) filename = filemd5 + file.name.substr(file.name.indexOf('.'));
//if (xhr4.status==200) filename = JSON.parse(xhr4.responseText)['name'];
//if (xhr4.status==409) filename = filemd5 + file.name.substr(file.name.indexOf('.'));
filename = JSON.parse(xhr4.responseText)['name'];
if (filename=='') {
alert('<?php echo getconstStr('UploadErrorUpAgain'); ?>');
uploadbuttonshow();
@ -1011,8 +1013,9 @@
var lasturl = location.href;
if (lasturl.substr(lasturl.length-1)!='/') lasturl += '/';
lasturl += filename + '?preview';
//alert(lasturl);
window.open(lasturl);
//window.open(lasturl);
document.getElementById('upfile_a_'+tdnum).href = lasturl;
document.getElementById('upfile_a1_'+tdnum).href = filename;
}
<?php } ?>
EndTime=new Date();
@ -1022,7 +1025,7 @@
} else {
MiddleStr += '<?php echo getconstStr('ThisTime').getconstStr('AverageSpeed'); ?>:'+size_format((totalsize-newstartsize)*1000/(EndTime.getTime()-StartTime.getTime()))+'/s<br>';
}
document.getElementById('upfile_td1_'+tdnum).innerHTML='<font color="green"><?php if (!$_SERVER['admin']) { ?>'+filemd5+'<br><?php } ?>'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'<br><?php echo getconstStr('UploadComplete'); ?></font>';
document.getElementById('upfile_td1_'+tdnum).innerHTML='<div style="color:green"><a href="'+response.name+'?preview" id="upfile_a_'+tdnum+'" target="_blank">'+document.getElementById('upfile_td1_'+tdnum).innerHTML+'</a><br><a href="'+response.name+'" id="upfile_a1_'+tdnum+'"></a><?php echo getconstStr('UploadComplete'); ?><button onclick="CopyAllDownloadUrl(\'#upfile_a1_'+tdnum+'\');"><?php echo getconstStr('CopyUrl'); ?></button></div>';
label.innerHTML=StartStr+MiddleStr;
uploadbuttonshow();
<?php if ($_SERVER['admin']) { ?>