commit
fb99c8a29e
|
@ -17,9 +17,6 @@ function savecache($key, $value, $exp = 3300)
|
|||
function getconstStr($str)
|
||||
{
|
||||
global $constStr;
|
||||
$constStr['language'] = $_COOKIE['language'];
|
||||
if ($constStr['language']=='') $constStr['language'] = getConfig('language');
|
||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||
if ($constStr[$str][$constStr['language']]!='') return $constStr[$str][$constStr['language']];
|
||||
return $constStr[$str]['en-us'];
|
||||
}
|
||||
|
@ -353,7 +350,11 @@ function bigfileupload($path)
|
|||
function main($path)
|
||||
{
|
||||
global $exts;
|
||||
global $constStr;
|
||||
config_oauth();
|
||||
$constStr['language'] = $_COOKIE['language'];
|
||||
if ($constStr['language']=='') $constStr['language'] = getConfig('language');
|
||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||
$_SERVER['list_path'] = getListpath($_SERVER['HTTP_HOST']);
|
||||
if ($_SERVER['list_path']=='') $_SERVER['list_path'] = '/';
|
||||
$_SERVER['is_guestup_path'] = is_guestup_path($path);
|
||||
|
@ -364,6 +365,19 @@ function main($path)
|
|||
$refresh_token = getConfig('refresh_token');
|
||||
if (!$refresh_token) return get_refresh_token();
|
||||
|
||||
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
||||
$response = curl_request( $_SERVER['oauth_url'] . 'token', 'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token );
|
||||
if ($response['stat']==200) $ret = json_decode($response['body'], true);
|
||||
if (!isset($ret['access_token'])) {
|
||||
error_log('failed to get access_token. response' . json_encode($ret));
|
||||
throw new Exception($response['stat'].'failed to get access_token.'.$response['body']);
|
||||
}
|
||||
error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT));
|
||||
$_SERVER['access_token'] = $ret['access_token'];
|
||||
savecache('access_token', $_SERVER['access_token']);
|
||||
if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+30*24*60*60 ]);
|
||||
}
|
||||
|
||||
if (getConfig('adminloginpage')=='') {
|
||||
$adminloginpage = 'admin';
|
||||
} else {
|
||||
|
@ -400,19 +414,6 @@ function main($path)
|
|||
}
|
||||
$_SERVER['retry'] = 0;
|
||||
|
||||
if (!($_SERVER['access_token'] = getcache('access_token'))) {
|
||||
$ret = json_decode(curl_request(
|
||||
$_SERVER['oauth_url'] . 'token',
|
||||
'client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token
|
||||
)['body'], true);
|
||||
if (!isset($ret['access_token'])) {
|
||||
error_log('failed to get access_token. response' . json_encode($ret));
|
||||
throw new Exception('failed to get access_token.');
|
||||
}
|
||||
$_SERVER['access_token'] = $ret['access_token'];
|
||||
savecache('access_token', $_SERVER['access_token']);
|
||||
}
|
||||
|
||||
if ($_SERVER['ajax']) {
|
||||
if ($_GET['action']=='del_upload_cache'&&substr($_GET['filename'],-4)=='.tmp') {
|
||||
// del '.tmp' without login. 无需登录即可删除.tmp后缀文件
|
||||
|
|
|
@ -66,7 +66,7 @@ function get_refresh_token()
|
|||
}
|
||||
document.cookie=\'language=; path=/\';
|
||||
</script>';
|
||||
setConfig([ 'refresh_token' => $tmptoken ]);
|
||||
setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ]);
|
||||
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
|
||||
$str .= '
|
||||
<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
|
|
|
@ -65,7 +65,7 @@ function get_refresh_token()
|
|||
}
|
||||
document.cookie=\'language=; path=/\';
|
||||
</script>';
|
||||
setConfig([ 'refresh_token' => $tmptoken ]);
|
||||
setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ]);
|
||||
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
|
||||
$str .= '
|
||||
<meta http-equiv="refresh" content="5;URL=' . $url . '">';
|
||||
|
|
|
@ -23,6 +23,7 @@ function GetGlobalVariable($event)
|
|||
$pos = strpos($cookievalues,"=");
|
||||
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
|
||||
}
|
||||
$_SERVER['USER'] = 'qcloud';
|
||||
}
|
||||
|
||||
function GetPathSetting($event, $context)
|
||||
|
@ -100,7 +101,7 @@ function get_refresh_token()
|
|||
}
|
||||
document.cookie=\'language=; path=/\';
|
||||
</script>';
|
||||
setConfig([ 'refresh_token' => $tmptoken ]);
|
||||
setConfig([ 'refresh_token' => $tmptoken, 'token_expires' => time()+30*24*60*60 ]);
|
||||
savecache('access_token', $ret['access_token'], $ret['expires_in'] - 60);
|
||||
$trynum = 0;
|
||||
while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], getConfig('SecretId'), getConfig('SecretKey')),true)['Response']['Status']!='Active' ) echo '
|
||||
|
|
|
@ -55,17 +55,17 @@
|
|||
<?php
|
||||
if (getConfig('admin')!='') if (!$_SERVER['admin']) {
|
||||
if (getConfig('adminloginpage')=='') { ?>
|
||||
<a onclick="login();"><?php echo getconstStr('Login'); ?></a>
|
||||
<a onclick="login();"><ion-icon name="log-in"></ion-icon><?php echo getconstStr('Login'); ?></a>
|
||||
<?php }
|
||||
} else { ?>
|
||||
<li class="operate"><?php echo getconstStr('Operate'); ?><ul>
|
||||
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?><ul>
|
||||
<?php if (isset($files['folder'])) { ?>
|
||||
<li><a onclick="showdiv(event,'create','');"><?php echo getconstStr('Create'); ?></a></li>
|
||||
<li><a onclick="showdiv(event,'encrypt','');"><?php echo getconstStr('encrypt'); ?></a></li>
|
||||
<li><a href="?RefreshCache"><?php echo getconstStr('RefreshCache'); ?></a></li>
|
||||
<li><a onclick="showdiv(event,'create','');"><ion-icon name="add-circle"></ion-icon><?php echo getconstStr('Create'); ?></a></li>
|
||||
<li><a onclick="showdiv(event,'encrypt','');"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
||||
<li><a href="?RefreshCache"><ion-icon name="refresh"></ion-icon><?php echo getconstStr('RefreshCache'); ?></a></li>
|
||||
<?php } ?>
|
||||
<li><a href="<?php echo $_GET['preview']?'?preview&':'?';?>setup"><?php echo getconstStr('Setup'); ?></a></li>
|
||||
<li><a onclick="logout()"><?php echo getconstStr('Logout'); ?></a></li>
|
||||
<li><a href="<?php echo $_GET['preview']?'?preview&':'?';?>setup"><ion-icon name="settings"></ion-icon><?php echo getconstStr('Setup'); ?></a></li>
|
||||
<li><a onclick="logout()"><ion-icon name="log-out"></ion-icon><?php echo getconstStr('Logout'); ?></a></li>
|
||||
</ul></li>
|
||||
<?php
|
||||
} ?>
|
||||
|
@ -158,8 +158,9 @@
|
|||
<div id="txt">
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
<form id="txt-form" action="" method="POST">
|
||||
<a onclick="enableedit(this);" id="txt-editbutton"><?php echo getconstStr('ClicktoEdit'); ?></a>
|
||||
<a id="txt-save" style="display:none"><?php echo getconstStr('Save'); ?></a>
|
||||
<a onclick="document.getElementById('txt-a').readOnly='';document.getElementById('txt-save').style.display='';document.getElementById('txt-editbutton').style.display='none';document.getElementById('txt-cancelbutton').style.display='';" id="txt-editbutton"><ion-icon name="create"></ion-icon><?php echo getconstStr('ClicktoEdit'); ?></a>
|
||||
<a onclick="document.getElementById('txt-a').readOnly='readonly';document.getElementById('txt-save').style.display='none';document.getElementById('txt-editbutton').style.display='';document.getElementById('txt-cancelbutton').style.display='none';" id="txt-cancelbutton" style="display:none"><ion-icon name="close"></ion-icon><?php echo getconstStr('CancelEdit'); ?></a>
|
||||
<a id="txt-save" style="display:none"><ion-icon name="save"></ion-icon><?php echo getconstStr('Save'); ?></a>
|
||||
<?php } ?>
|
||||
<textarea id="txt-a" name="editfile" readonly style="width: 100%; margin-top: 2px;" <?php if ($_SERVER['admin']) echo 'onchange="document.getElementById(\'txt-save\').onclick=function(){document.getElementById(\'txt-form\').submit();}"';?> ><?php echo $txtstr;?></textarea>
|
||||
<?php if ($_SERVER['admin']) echo '</form>'; ?>
|
||||
|
@ -180,7 +181,7 @@
|
|||
$readme = false; ?>
|
||||
<table class="list-table" id="list-table">
|
||||
<tr id="tr0">
|
||||
<th class="file" onclick="sortby('a');"><?php echo getconstStr('File'); ?> <button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button></th>
|
||||
<th class="file" onclick="sortby('a');"><?php echo getconstStr('File'); if ($_SERVER['USER']!='qcloud') { ?> <button onclick="showthumbnails(this);"><?php echo getconstStr('ShowThumbnails'); ?></button><?php } ?></th>
|
||||
<th class="updated_at" width="25%" onclick="sortby('time');"><?php echo getconstStr('EditTime'); ?></th>
|
||||
<th class="size" width="15%" onclick="sortby('size');"><?php echo getconstStr('Size'); ?></th>
|
||||
</tr>
|
||||
|
@ -193,12 +194,12 @@
|
|||
<tr data-to id="tr<?php echo $filenum;?>">
|
||||
<td class="file">
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
<li class="operate"><?php echo getconstStr('Operate'); ?>
|
||||
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?>
|
||||
<ul>
|
||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><?php echo getconstStr('encrypt'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><?php echo getconstStr('Rename'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><?php echo getconstStr('Move'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><?php echo getconstStr('Delete'); ?></a></li>
|
||||
<li><a onclick="showdiv(event,'encrypt',<?php echo $filenum;?>);"><ion-icon name="lock"></ion-icon><?php echo getconstStr('encrypt'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><ion-icon name="trash"></ion-icon><?php echo getconstStr('Delete'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
@ -224,11 +225,11 @@
|
|||
<tr data-to id="tr<?php echo $filenum;?>">
|
||||
<td class="file">
|
||||
<?php if ($_SERVER['admin']) { ?>
|
||||
<li class="operate"><?php echo getconstStr('Operate'); ?>
|
||||
<li class="operate"><ion-icon name="construct"></ion-icon><?php echo getconstStr('Operate'); ?>
|
||||
<ul>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><?php echo getconstStr('Rename'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><?php echo getconstStr('Move'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><?php echo getconstStr('Delete'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'rename',<?php echo $filenum;?>);"><ion-icon name="create"></ion-icon><?php echo getconstStr('Rename'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'move',<?php echo $filenum;?>);"><ion-icon name="move"></ion-icon><?php echo getconstStr('Move'); ?></a></li>
|
||||
<li><a onclick="showdiv(event, 'delete',<?php echo $filenum;?>);"><ion-icon name="trash"></ion-icon><?php echo getconstStr('Delete'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php }
|
||||
|
@ -980,12 +981,6 @@
|
|||
document.cookie = "admin=; path=/";
|
||||
location.href = location.href;
|
||||
}
|
||||
function enableedit(obj) {
|
||||
document.getElementById('txt-a').readOnly=!document.getElementById('txt-a').readOnly;
|
||||
//document.getElementById('txt-editbutton').innerHTML=(document.getElementById('txt-editbutton').innerHTML=='取消编辑')?'点击后编辑':'取消编辑';
|
||||
obj.innerHTML=(obj.innerHTML=='<?php echo getconstStr('CancelEdit'); ?>')?'<?php echo getconstStr('ClicktoEdit'); ?>':'<?php echo getconstStr('CancelEdit'); ?>';
|
||||
document.getElementById('txt-save').style.display=document.getElementById('txt-save').style.display==''?'none':'';
|
||||
}
|
||||
<?php if (!$_GET['preview']) {?>
|
||||
function showdiv(event,action,num) {
|
||||
var $operatediv=document.getElementsByName('operatediv');
|
||||
|
|
Loading…
Reference in New Issue