try fix customTheme

pull/700/head
qkqpttgf 2023-08-21 10:40:28 +08:00 committed by GitHub
parent 596955ffe0
commit d595234a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 502 additions and 550 deletions

View File

@ -105,43 +105,37 @@ $timezones = array(
'12' => 'Asia/Kamchatka'
);
function isCommonEnv($str)
{
function isCommonEnv($str) {
global $EnvConfigs;
if (isset($EnvConfigs[$str])) return ($EnvConfigs[$str] & 0b0100) ? false : true;
else return null;
}
function isInnerEnv($str)
{
function isInnerEnv($str) {
global $EnvConfigs;
if (isset($EnvConfigs[$str])) return ($EnvConfigs[$str] & 0b0100) ? true : false;
else return null;
}
function isShowedEnv($str)
{
function isShowedEnv($str) {
global $EnvConfigs;
if (isset($EnvConfigs[$str])) return ($EnvConfigs[$str] & 0b0010) ? true : false;
else return null;
}
function isBase64Env($str)
{
function isBase64Env($str) {
global $EnvConfigs;
if (isset($EnvConfigs[$str])) return ($EnvConfigs[$str] & 0b0001) ? true : false;
else return null;
}
function isSwitchEnv($str)
{
function isSwitchEnv($str) {
global $EnvConfigs;
if (isset($EnvConfigs[$str])) return ($EnvConfigs[$str] & 0b1000) ? true : false;
else return null;
}
function main($path)
{
function main($path) {
global $exts;
global $constStr;
global $slash;
@ -535,8 +529,7 @@ function main($path)
}
}
function get_content($path)
{
function get_content($path) {
global $drive;
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1 != '/' && substr($path1, -1) == '/') $path1 = substr($path1, 0, -1);
@ -545,8 +538,7 @@ function get_content($path)
return $file;
}
function driveisfine($tag, &$drive = null)
{
function driveisfine($tag, &$drive = null) {
global $slash;
$disktype = getConfig('Driver', $tag);
if (!$disktype) return false;
@ -556,8 +548,7 @@ function driveisfine($tag, &$drive = null)
else return false;
}
function baseclassofdrive($d = null)
{
function baseclassofdrive($d = null) {
global $drive;
if (!$d) $dr = $drive;
else $dr = $d;
@ -565,8 +556,7 @@ function baseclassofdrive($d = null)
return $dr->show_base_class();
}
function extendShow_diskenv($drive)
{
function extendShow_diskenv($drive) {
if (!$drive) return [];
return $drive->ext_show_innerenv();
}
@ -597,15 +587,13 @@ function no_return_curl($method, $url, $data = '') {
curl_close($ch);
}
function adminpass2cookie($name, $pass, $timestamp)
{
function adminpass2cookie($name, $pass, $timestamp) {
return md5($name . ':' . md5($pass) . '@' . $timestamp) . "(" . $timestamp . ")";
}
function adminpass2storage($name, $pass, $timestamp, $rand) {
return md5($timestamp . '/' . $pass . '^' . $name . '*' . $rand) . "(" . $rand . ")";
}
function compareadminmd5($name, $pass, $cookie, $storage = 'default')
{
function compareadminmd5($name, $pass, $cookie, $storage = 'default') {
$c = splitfirst($cookie, '(');
$c_md5 = $c[0];
$c_time = substr($c[1], 0, -1);
@ -624,8 +612,7 @@ function compareadminmd5($name, $pass, $cookie, $storage = 'default')
return false;
}
function compareadminsha1($adminsha1, $timestamp, $pass)
{
function compareadminsha1($adminsha1, $timestamp, $pass) {
if (!is_numeric($timestamp)) return 'Timestamp not Number';
if (abs(time() - $timestamp) > 5 * 60) {
date_default_timezone_set('UTC');
@ -635,8 +622,7 @@ function compareadminsha1($adminsha1, $timestamp, $pass)
else return 'Error password';
}
function proxy_replace_domain($url, $domainforproxy, &$header)
{
function proxy_replace_domain($url, $domainforproxy, &$header) {
global $drive;
$tmp = splitfirst($url, '//');
$http = $tmp[0];
@ -658,14 +644,14 @@ function proxy_replace_domain($url, $domainforproxy, &$header)
function bchexdec($hex) {
$len = strlen($hex);
$dec = 0;
for ($i = 1; $i <= $len; $i++)
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
return $dec;
}
function isHideFile($name)
{
function isHideFile($name) {
$FunctionalityFile = [
'head.md',
'readme.md',
@ -683,20 +669,17 @@ function isHideFile($name)
return false;
}
function getcache($str, $disktag = '')
{
function getcache($str, $disktag = '') {
$cache = filecache($disktag);
return $cache->fetch($str);
}
function savecache($key, $value, $disktag = '', $exp = 1800)
{
function savecache($key, $value, $disktag = '', $exp = 1800) {
$cache = filecache($disktag);
return $cache->save($key, $value, $exp);
}
function filecache($disktag)
{
function filecache($disktag) {
$dir = sys_get_temp_dir();
if (!is_writable($dir)) {
$tmp = __DIR__ . '/tmp/';
@ -732,8 +715,7 @@ function calcDownKey($filename, $key = '') {
}
}
function findIndexPath($rootpath, $path = '')
{// find the path of the first 'index.php' that not in rootpath.
function findIndexPath($rootpath, $path = '') { // find the path of the first 'index.php' that not in rootpath.
global $slash;
if (substr($rootpath, -1) == $slash) $rootpath = substr($rootpath, 0, -1);
if (substr($path, 0, 1) == $slash) $path = substr($path, 1);
@ -753,8 +735,7 @@ function findIndexPath($rootpath, $path = '')
return '';
}
function sortConfig(&$arr)
{
function sortConfig(&$arr) {
ksort($arr);
if (isset($arr['disktag'])) {
@ -787,15 +768,13 @@ function chkTxtCode($str) {
return false;
}
function getconstStr($str)
{
function getconstStr($str) {
global $constStr;
if ($constStr[$str][$constStr['language']] != '') return $constStr[$str][$constStr['language']];
return $constStr[$str]['en-us'];
}
function getListpath($domain)
{
function getListpath($domain) {
$domain_path1 = getConfig('domain_path', $_SERVER['disktag']);
$public_path = getConfig('public_path', $_SERVER['disktag']);
$tmp_path = '';
@ -816,8 +795,7 @@ function getListpath($domain)
return spurlencode($public_path, '/');
}
function path_format($path)
{
function path_format($path) {
$path = '/' . $path;
while (strpos($path, '//') !== FALSE) {
$path = str_replace('//', '/', $path);
@ -825,8 +803,7 @@ function path_format($path)
return $path;
}
function spurlencode($str, $split='')
{
function spurlencode($str, $split = '') {
$str = str_replace(' ', '%20', $str);
$tmp = '';
if ($split != '') {
@ -843,8 +820,7 @@ function spurlencode($str, $split='')
return $tmp;
}
function base64y_encode($str)
{
function base64y_encode($str) {
$str = base64_encode($str);
while (substr($str, -1) == '=') $str = substr($str, 0, -1);
while (strpos($str, '+') !== false) $str = str_replace('+', '-', $str);
@ -852,8 +828,7 @@ function base64y_encode($str)
return $str;
}
function base64y_decode($str)
{
function base64y_decode($str) {
while (strpos($str, '_') !== false) $str = str_replace('_', '/', $str);
while (strpos($str, '-') !== false) $str = str_replace('-', '+', $str);
while (strlen($str) % 4) $str .= '=';
@ -862,13 +837,11 @@ function base64y_decode($str)
return $str;
}
function error_log1($str)
{
function error_log1($str) {
error_log($str);
}
function is_guestup_path($path)
{
function is_guestup_path($path) {
if (getConfig('guestup_path', $_SERVER['disktag']) != '') {
$a1 = path_format(path_format(urldecode($_SERVER['list_path'] . path_format($path))) . '/');
$a2 = path_format(path_format(getConfig('guestup_path', $_SERVER['disktag'])) . '/');
@ -877,13 +850,11 @@ function is_guestup_path($path)
return 0;
}
function array_value_isnot_null($arr)
{
function array_value_isnot_null($arr) {
return $arr !== '';
}
function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $location = 0)
{
function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $location = 0) {
//if (!isset($headers['Accept'])) $headers['Accept'] = '*/*';
//if (!isset($headers['Referer'])) $headers['Referer'] = $url;
//if (!isset($headers['Content-Type'])) $headers['Content-Type'] = 'application/x-www-form-urlencoded';
@ -906,8 +877,10 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca
if ($location) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//$response['body'] = curl_exec($ch);
if ($returnheader) {
$tmpres = splitlast(curl_exec($ch), "\r\n\r\n");
$result['body'] = $tmpres[1];
$tmpresult = curl_exec($ch);
//error_log1($tmpresult);
$tmpres = splitlast($tmpresult, "\r\n\r\n");
$response['body'] = $tmpres[1];
$returnhead = $tmpres[0];
//echo "HEAD:" . $returnhead;
foreach (explode("\r\n", $returnhead) as $head) {
@ -923,8 +896,7 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca
return $response;
}
function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
{
function clearbehindvalue($path, $page1, $maxpage, $pageinfocache) {
for ($page = $page1 + 1; $page < $maxpage; $page++) {
$pageinfocache['nextlink_' . $path . '_page_' . $page] = '';
}
@ -932,8 +904,7 @@ function clearbehindvalue($path,$page1,$maxpage,$pageinfocache)
return $pageinfocache;
}
function comppass($pass)
{
function comppass($pass) {
if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $pass) {
date_default_timezone_set('UTC');
$_SERVER['Set-Cookie'] = 'password=' . $pass . '; expires=' . date(DATE_COOKIE, strtotime('+1hour'));
@ -954,8 +925,7 @@ function comppass($pass)
return 4;
}
function encode_str_replace($str)
{
function encode_str_replace($str) {
$str = str_replace('%', '%25', $str);
if (strpos($str, '&amp;')) $str = str_replace('&amp;', '&amp;amp;', $str);
$str = str_replace('+', '%2B', $str);
@ -963,8 +933,7 @@ function encode_str_replace($str)
return $str;
}
function gethiddenpass($path,$passfile)
{
function gethiddenpass($path, $passfile) {
$path1 = path_format($_SERVER['list_path'] . path_format($path));
if ($path1 != '/' && substr($path1, -1) == '/') $path1 = substr($path1, 0, -1);
$password = getcache('path_' . $path1 . '/?password', $_SERVER['disktag']);
@ -1007,15 +976,13 @@ function gethiddenpass($path,$passfile)
// return md5('DefaultP@sswordWhenNetworkError');
}
function get_timezone($timezone = '8')
{
function get_timezone($timezone = '8') {
global $timezones;
if ($timezone == '') $timezone = '8';
return $timezones[$timezone];
}
function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
{
function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0) {
$html = '
<html lang="' . $_SERVER['language'] . '">
<html>
@ -1080,8 +1047,7 @@ function message($message, $title = 'Message', $statusCode = 200, $wainstat = 0)
return output($html, $statusCode);
}
function needUpdate()
{
function needUpdate() {
global $slash;
$current_version = file_get_contents(__DIR__ . $slash . 'version');
$current_ver = substr($current_version, strpos($current_version, '.') + 1);
@ -1107,8 +1073,7 @@ function needUpdate()
return 0;
}
function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false)
{
function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/html'], $isBase64Encoded = false) {
if (isset($_SERVER['Set-Cookie'])) $headers['Set-Cookie'] = $_SERVER['Set-Cookie'];
if (baseclassofdrive() == 'Aliyundrive' || baseclassofdrive() == 'BaiduDisk') $headers['Referrer-Policy'] = 'no-referrer';
//$headers['Referrer-Policy'] = 'same-origin';
@ -1121,8 +1086,7 @@ function output($body, $statusCode = 200, $headers = ['Content-Type' => 'text/ht
];
}
function passhidden($path)
{
function passhidden($path) {
if ($_SERVER['admin']) return 0;
//$path = str_replace('+','%2B',$path);
//$path = str_replace('&amp;','&', path_format(urldecode($path)));
@ -1141,8 +1105,7 @@ function passhidden($path)
return 4;
}
function size_format($byte)
{
function size_format($byte) {
$i = 0;
while (abs($byte) >= 1024) {
$byte = $byte / 1024;
@ -1154,16 +1117,14 @@ function size_format($byte)
return ($ret . ' ' . $units[$i]);
}
function time_format($ISO)
{
function time_format($ISO) {
if ($ISO == '') return date('Y-m-d H:i:s');
$ISO = str_replace('T', ' ', $ISO);
$ISO = str_replace('Z', ' ', $ISO);
return date('Y-m-d H:i:s', strtotime($ISO . " UTC"));
}
function adminform($name = '', $pass = '', $storage = '', $path = '')
{
function adminform($name = '', $pass = '', $storage = '', $path = '') {
$html = '<html>
<head>
<title>' . getconstStr('AdminLogin') . '</title>
@ -1244,8 +1205,7 @@ function adminform($name = '', $pass = '', $storage = '', $path = '')
return output($html, $statusCode);
}
function adminoperate($path)
{
function adminoperate($path) {
global $drive;
if ($_SERVER['REQUEST_METHOD'] == 'POST') if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag'] ? 'disk [ ' . $_SERVER['disktag'] . ' ] error.' : 'Not in drive', 403);
$path1 = path_format($_SERVER['list_path'] . '/' . $path);
@ -1351,8 +1311,7 @@ function adminoperate($path)
return $tmparr;
}
function splitfirst($str, $split)
{
function splitfirst($str, $split) {
$len = strlen($split);
$pos = strpos($str, $split);
if ($pos === false) {
@ -1369,8 +1328,7 @@ function splitfirst($str, $split)
return $tmp;
}
function splitlast($str, $split)
{
function splitlast($str, $split) {
$len = strlen($split);
$pos = strrpos($str, $split);
if ($pos === false) {
@ -1387,8 +1345,7 @@ function splitlast($str, $split)
return $tmp;
}
function children_name($children)
{
function children_name($children) {
$tmp = [];
foreach ($children as $file) {
$tmp[strtolower($file['name'])] = $file;
@ -1396,8 +1353,7 @@ function children_name($children)
return $tmp;
}
function EnvOpt($needUpdate = 0)
{
function EnvOpt($needUpdate = 0) {
global $constStr;
global $EnvConfigs;
global $timezones;
@ -1597,7 +1553,7 @@ output:
return changeAuthKey();
}
if ($_GET['setup'] === 'platform') {
$frame .= '
$frame = '
<table border=1 width=100%>
<form name="common" action="" method="post">
<input name="_admin" type="hidden" value="">';
@ -1661,7 +1617,7 @@ output:
$disktag = $_GET['disktag'];
$disk_tmp = null;
$diskok = driveisfine($disktag, $disk_tmp);
$frame .= '
$frame = '
<table width=100%>
<tr>
<td>
@ -1802,7 +1758,7 @@ output:
</script>';
} else {
if (count($disktags) > 1) {
$frame .= '
$frame = '
<script src="https://www.unpkg.com/sortablejs@1.14.0/Sortable.min.js"></script>
<style>
.sortable-ghost {
@ -2209,8 +2165,7 @@ output:
return message($html, getconstStr('Setup'));
}
function render_list($path = '', $files = [])
{
function render_list($path = '', $files = []) {
global $exts;
global $constStr;
global $slash;
@ -2302,15 +2257,15 @@ function render_list($path = '', $files = [])
} else {
if (!($html = getcache('customTheme'))) {
$file_path = $theme;
$tmp = curl('GET', $file_path, '', [], 1);
if ($tmp['stat']==302) {
error_log1(json_encode($tmp));
$tmp = curl('GET', $tmp["returnhead"]["Location"]);
}
if (!!$tmp['body']) $html = $tmp['body'];
$tmp = curl('GET', $file_path, '', [], 1, 1);
//error_log1($file_path . " =+= " . json_encode($tmp));
if ($tmp['stat'] == 200) {
$html = $tmp['body'];
savecache('customTheme', $html, '', 9999);
} else {
$html = "<pre>" . json_encode($tmp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "</pre>";
}
}
}
$tmp = splitfirst($html, '<!--IconValuesStart-->');
@ -2389,7 +2344,6 @@ function render_list($path = '', $files = [])
while (strpos($html, '<!--constStr@File-->')) $html = str_replace('<!--constStr@File-->', getconstStr('File'), $html);
while (strpos($html, '<!--constStr@Name-->')) $html = str_replace('<!--constStr@Name-->', getconstStr('Name'), $html);
while (strpos($html, '<!--constStr@Content-->')) $html = str_replace('<!--constStr@Content-->', getconstStr('Content'), $html);
} else {
$tmp[1] = 'a';
while ($tmp[1] != '') {
@ -2811,7 +2765,6 @@ function render_list($path = '', $files = [])
$html .= $tmp[1];
while (strpos($html, '<!--MaxPageNum-->')) $html = str_replace('<!--MaxPageNum-->', $maxpage, $html);
} else {
while (strpos($html, '<!--MorePageStart-->')) {
$tmp = splitfirst($html, '<!--MorePageStart-->');
@ -2820,7 +2773,6 @@ function render_list($path = '', $files = [])
$html .= $tmp[1];
}
}
}
$html = str_replace('<!--constStr@language-->', $constStr['language'], $html);