Update common.php
parent
425bbcba64
commit
d5c6c6b1aa
|
@ -8,7 +8,9 @@ $Base64Env = [
|
||||||
//'admin',
|
//'admin',
|
||||||
//'adminloginpage',
|
//'adminloginpage',
|
||||||
'background',
|
'background',
|
||||||
|
'diskname',
|
||||||
//'disktag',
|
//'disktag',
|
||||||
|
//'downloadencrypt',
|
||||||
//'function_name', // used in heroku.
|
//'function_name', // used in heroku.
|
||||||
//'language',
|
//'language',
|
||||||
//'passfile',
|
//'passfile',
|
||||||
|
@ -19,7 +21,6 @@ $Base64Env = [
|
||||||
'client_secret',
|
'client_secret',
|
||||||
'domain_path',
|
'domain_path',
|
||||||
'guestup_path',
|
'guestup_path',
|
||||||
'diskname',
|
|
||||||
'public_path',
|
'public_path',
|
||||||
//'refresh_token',
|
//'refresh_token',
|
||||||
//'token_expires',
|
//'token_expires',
|
||||||
|
@ -61,9 +62,10 @@ $InnerEnv = [
|
||||||
'Onedrive_ver',
|
'Onedrive_ver',
|
||||||
'client_id',
|
'client_id',
|
||||||
'client_secret',
|
'client_secret',
|
||||||
'domain_path',
|
|
||||||
'guestup_path',
|
|
||||||
'diskname',
|
'diskname',
|
||||||
|
'domain_path',
|
||||||
|
'downloadencrypt',
|
||||||
|
'guestup_path',
|
||||||
'public_path',
|
'public_path',
|
||||||
'refresh_token',
|
'refresh_token',
|
||||||
'token_expires',
|
'token_expires',
|
||||||
|
@ -73,9 +75,10 @@ $ShowedInnerEnv = [
|
||||||
//'Onedrive_ver',
|
//'Onedrive_ver',
|
||||||
//'client_id',
|
//'client_id',
|
||||||
//'client_secret',
|
//'client_secret',
|
||||||
'domain_path',
|
|
||||||
'guestup_path',
|
|
||||||
'diskname',
|
'diskname',
|
||||||
|
'domain_path',
|
||||||
|
'downloadencrypt',
|
||||||
|
'guestup_path',
|
||||||
'public_path',
|
'public_path',
|
||||||
//'refresh_token',
|
//'refresh_token',
|
||||||
//'token_expires',
|
//'token_expires',
|
||||||
|
@ -107,7 +110,6 @@ function config_oauth()
|
||||||
$_SERVER['sitename'] = getConfig('sitename');
|
$_SERVER['sitename'] = getConfig('sitename');
|
||||||
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
|
if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename');
|
||||||
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
$_SERVER['redirect_uri'] = 'https://scfonedrive.github.io';
|
||||||
//$_SERVER['redirect_uri'] = 'https://git.ldxw.vip/scfone';
|
|
||||||
|
|
||||||
if (getConfig('Onedrive_ver')=='MS') {
|
if (getConfig('Onedrive_ver')=='MS') {
|
||||||
// MS
|
// MS
|
||||||
|
@ -271,24 +273,25 @@ function encode_str_replace($str)
|
||||||
|
|
||||||
function gethiddenpass($path,$passfile)
|
function gethiddenpass($path,$passfile)
|
||||||
{
|
{
|
||||||
$password=getcache('path_' . $path . '/?password');
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||||
|
$password=getcache('path_' . $path1 . '/?password');
|
||||||
if ($password=='') {
|
if ($password=='') {
|
||||||
$ispassfile = fetch_files(spurlencode(path_format($path . '/' . $passfile),'/'));
|
$ispassfile = fetch_files(path_format($path . '/' . urlencode($passfile)));
|
||||||
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
|
//echo $path . '<pre>' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '</pre>';
|
||||||
if (isset($ispassfile['file'])) {
|
if (isset($ispassfile['file'])) {
|
||||||
$arr = curl_request($ispassfile['@microsoft.graph.downloadUrl']);
|
$arr = curl_request($ispassfile['@microsoft.graph.downloadUrl']);
|
||||||
if ($arr['stat']==200) {
|
if ($arr['stat']==200) {
|
||||||
$passwordf=explode("\n",$arr['body']);
|
$passwordf=explode("\n",$arr['body']);
|
||||||
$password=$passwordf[0];
|
$password=$passwordf[0];
|
||||||
$password=md5($password);
|
if ($password!='') $password=md5($password);
|
||||||
savecache($path . '/password', $password);
|
savecache('path_' . $path1 . '/?password', $password);
|
||||||
return $password;
|
return $password;
|
||||||
} else {
|
} else {
|
||||||
//return md5('DefaultP@sswordWhenNetworkError');
|
//return md5('DefaultP@sswordWhenNetworkError');
|
||||||
return md5( md5(time()).rand(1000,9999) );
|
return md5( md5(time()).rand(1000,9999) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
savecache($path . '/password', 'null');
|
savecache('path_' . $path1 . '/?password', 'null');
|
||||||
if ($path !== '' ) {
|
if ($path !== '' ) {
|
||||||
$path = substr($path,0,strrpos($path,'/'));
|
$path = substr($path,0,strrpos($path,'/'));
|
||||||
return gethiddenpass($path,$passfile);
|
return gethiddenpass($path,$passfile);
|
||||||
|
@ -349,12 +352,15 @@ function get_timezone($timezone = '8')
|
||||||
function message($message, $title = 'Message', $statusCode = 200)
|
function message($message, $title = 'Message', $statusCode = 200)
|
||||||
{
|
{
|
||||||
return output('
|
return output('
|
||||||
|
<html lang="' . $_SERVER['language'] . '">
|
||||||
<html>
|
<html>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<body>
|
<body>
|
||||||
<h1>' . $title . '</h1>
|
<h1>' . $title . '</h1>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
' . $message . '
|
' . $message . '
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>', $statusCode);
|
</html>', $statusCode);
|
||||||
|
@ -392,6 +398,7 @@ function passhidden($path)
|
||||||
$path = str_replace('+','%2B',$path);
|
$path = str_replace('+','%2B',$path);
|
||||||
$path = str_replace('&','&', path_format(urldecode($path)));
|
$path = str_replace('&','&', path_format(urldecode($path)));
|
||||||
if (getConfig('passfile') != '') {
|
if (getConfig('passfile') != '') {
|
||||||
|
$path = spurlencode($path,'/');
|
||||||
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
if (substr($path,-1)=='/') $path=substr($path,0,-1);
|
||||||
$hiddenpass=gethiddenpass($path,getConfig('passfile'));
|
$hiddenpass=gethiddenpass($path,getConfig('passfile'));
|
||||||
if ($hiddenpass != '') {
|
if ($hiddenpass != '') {
|
||||||
|
@ -483,6 +490,7 @@ function main($path)
|
||||||
$constStr['language'] = $_COOKIE['language'];
|
$constStr['language'] = $_COOKIE['language'];
|
||||||
if ($constStr['language']=='') $constStr['language'] = getConfig('language');
|
if ($constStr['language']=='') $constStr['language'] = getConfig('language');
|
||||||
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
if ($constStr['language']=='') $constStr['language'] = 'en-us';
|
||||||
|
$_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'];
|
$_SERVER['base_disk_path'] = $_SERVER['base_path'];
|
||||||
$disktags = explode("|",getConfig('disktag'));
|
$disktags = explode("|",getConfig('disktag'));
|
||||||
|
@ -595,7 +603,7 @@ function main($path)
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($_SERVER['ajax']) return output(getconstStr('RefleshtoLogin'),401);
|
if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401);
|
||||||
}
|
}
|
||||||
$_SERVER['ishidden'] = passhidden($path);
|
$_SERVER['ishidden'] = passhidden($path);
|
||||||
if ($_GET['thumbnails']) {
|
if ($_GET['thumbnails']) {
|
||||||
|
@ -608,7 +616,7 @@ function main($path)
|
||||||
$files = list_files($path);
|
$files = list_files($path);
|
||||||
if (isset($files['file']) && !$_GET['preview']) {
|
if (isset($files['file']) && !$_GET['preview']) {
|
||||||
// is file && not preview mode
|
// is file && not preview mode
|
||||||
if ($_SERVER['ishidden']<4) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
|
if ( $_SERVER['ishidden']<4 || (getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
|
||||||
}
|
}
|
||||||
if ( isset($files['folder']) || isset($files['file']) ) {
|
if ( isset($files['folder']) || isset($files['file']) ) {
|
||||||
return render_list($path, $files);
|
return render_list($path, $files);
|
||||||
|
@ -623,8 +631,8 @@ function list_files($path)
|
||||||
$path = path_format($path);
|
$path = path_format($path);
|
||||||
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) {
|
||||||
$files = json_decode('{"folder":{}}', true);
|
$files = json_decode('{"folder":{}}', true);
|
||||||
} elseif ($_SERVER['ishidden']==4) {
|
} elseif (!getConfig('downloadencrypt')) {
|
||||||
$files = json_decode('{"folder":{}}', true);
|
if ($_SERVER['ishidden']==4) $files = json_decode('{"folder":{}}', true);
|
||||||
} else {
|
} else {
|
||||||
$files = fetch_files($path);
|
$files = fetch_files($path);
|
||||||
}
|
}
|
||||||
|
@ -703,7 +711,8 @@ function adminoperate($path)
|
||||||
$filename = path_format($path1 . '/' . $foldername . '/' . getConfig('passfile'));
|
$filename = path_format($path1 . '/' . $foldername . '/' . getConfig('passfile'));
|
||||||
//echo $foldername;
|
//echo $foldername;
|
||||||
$result = MSAPI('PUT', $filename, $_GET['encrypt_newpass'], $_SERVER['access_token']);
|
$result = MSAPI('PUT', $filename, $_GET['encrypt_newpass'], $_SERVER['access_token']);
|
||||||
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
$path1 = path_format($path1 . '/' . $foldername );
|
||||||
|
savecache('path_' . $path1 . '/?password', '', 1);
|
||||||
return output($result['body'], $result['stat']);
|
return output($result['body'], $result['stat']);
|
||||||
}
|
}
|
||||||
if ($_GET['move_folder']!='') {
|
if ($_GET['move_folder']!='') {
|
||||||
|
@ -790,8 +799,8 @@ function adminoperate($path)
|
||||||
return output($result['body'], $result['stat']);
|
return output($result['body'], $result['stat']);
|
||||||
}
|
}
|
||||||
if ($_GET['RefreshCache']) {
|
if ($_GET['RefreshCache']) {
|
||||||
//savecache('path_' . $path1, json_decode('{}',true), 1);
|
$path1 = path_format($_SERVER['list_path'] . path_format($path));
|
||||||
savecache('path_' . $path . '/?password', '', 1);
|
savecache('path_' . $path1 . '/?password', '', 1);
|
||||||
return message('<meta http-equiv="refresh" content="2;URL=./">', getconstStr('RefreshCache'), 302);
|
return message('<meta http-equiv="refresh" content="2;URL=./">', getconstStr('RefreshCache'), 302);
|
||||||
}
|
}
|
||||||
return $tmparr;
|
return $tmparr;
|
||||||
|
|
Loading…
Reference in New Issue