From d595234a58b595c742354d0d7a1e2087f3445e2f Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:40:28 +0800 Subject: [PATCH] try fix customTheme --- common.php | 1052 +++++++++++++++++++++++++--------------------------- 1 file changed, 502 insertions(+), 550 deletions(-) diff --git a/common.php b/common.php index 13aa821..83bd3fe 100644 --- a/common.php +++ b/common.php @@ -29,7 +29,7 @@ $EnvConfigs = [ 'disableShowThumb' => 0b1010, //'disableChangeTheme'=> 0b1010, 'disktag' => 0b0000, - 'hideFunctionalityFile'=> 0b1010, + 'hideFunctionalityFile' => 0b1010, 'timezone' => 0b0010, 'passfile' => 0b0011, 'sitename' => 0b0011, @@ -71,77 +71,71 @@ $EnvConfigs = [ 'fileConduitCacheTime' => 0b0110, ]; -$timezones = array( - '-12'=>'Pacific/Kwajalein', - '-11'=>'Pacific/Samoa', - '-10'=>'Pacific/Honolulu', - '-9'=>'America/Anchorage', - '-8'=>'America/Los_Angeles', - '-7'=>'America/Denver', - '-6'=>'America/Mexico_City', - '-5'=>'America/New_York', - '-4'=>'America/Caracas', - '-3.5'=>'America/St_Johns', - '-3'=>'America/Argentina/Buenos_Aires', - '-2'=>'America/Noronha', - '-1'=>'Atlantic/Azores', - '0'=>'UTC', - '1'=>'Europe/Paris', - '2'=>'Europe/Helsinki', - '3'=>'Europe/Moscow', - '3.5'=>'Asia/Tehran', - '4'=>'Asia/Baku', - '4.5'=>'Asia/Kabul', - '5'=>'Asia/Karachi', - '5.5'=>'Asia/Calcutta', //Asia/Colombo - '6'=>'Asia/Dhaka', - '6.5'=>'Asia/Rangoon', - '7'=>'Asia/Bangkok', - '8'=>'Asia/Shanghai', - '9'=>'Asia/Tokyo', - '9.5'=>'Australia/Darwin', - '10'=>'Pacific/Guam', - '11'=>'Asia/Magadan', - '12'=>'Asia/Kamchatka' +$timezones = array( + '-12' => 'Pacific/Kwajalein', + '-11' => 'Pacific/Samoa', + '-10' => 'Pacific/Honolulu', + '-9' => 'America/Anchorage', + '-8' => 'America/Los_Angeles', + '-7' => 'America/Denver', + '-6' => 'America/Mexico_City', + '-5' => 'America/New_York', + '-4' => 'America/Caracas', + '-3.5' => 'America/St_Johns', + '-3' => 'America/Argentina/Buenos_Aires', + '-2' => 'America/Noronha', + '-1' => 'Atlantic/Azores', + '0' => 'UTC', + '1' => 'Europe/Paris', + '2' => 'Europe/Helsinki', + '3' => 'Europe/Moscow', + '3.5' => 'Asia/Tehran', + '4' => 'Asia/Baku', + '4.5' => 'Asia/Kabul', + '5' => 'Asia/Karachi', + '5.5' => 'Asia/Calcutta', //Asia/Colombo + '6' => 'Asia/Dhaka', + '6.5' => 'Asia/Rangoon', + '7' => 'Asia/Bangkok', + '8' => 'Asia/Shanghai', + '9' => 'Asia/Tokyo', + '9.5' => 'Australia/Darwin', + '10' => 'Pacific/Guam', + '11' => 'Asia/Magadan', + '12' => 'Asia/Kamchatka' ); -function isCommonEnv($str) -{ +function isCommonEnv($str) { global $EnvConfigs; - if (isset($EnvConfigs[$str])) return ( $EnvConfigs[$str] & 0b0100 ) ? false : true; + 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; + 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; + 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; + 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; + 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; @@ -153,45 +147,45 @@ function main($path) $path = path_format($path); $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); $_SERVER['base_disk_path'] = $_SERVER['base_path']; - if (getConfig('forceHttps')&&$_SERVER['REQUEST_SCHEME']=='http') { + if (getConfig('forceHttps') && $_SERVER['REQUEST_SCHEME'] == 'http') { if ($_GET) { $tmp = ''; foreach ($_GET as $k => $v) { - if ($v===true) $tmp .= '&' . $k; + if ($v === true) $tmp .= '&' . $k; else $tmp .= '&' . $k . '=' . $v; } $tmp = substr($tmp, 1); - if ($tmp!='') $param = '?' . $tmp; + if ($tmp != '') $param = '?' . $tmp; } - return output('visit via https.', 302, [ 'Location' => 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $param ]); + return output('visit via https.', 302, ['Location' => 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $param]); } if (in_array($_SERVER['firstacceptlanguage'], array_keys($constStr['languages']))) { $constStr['language'] = $_SERVER['firstacceptlanguage']; } else { $prelang = splitfirst($_SERVER['firstacceptlanguage'], '-')[0]; - foreach ( array_keys($constStr['languages']) as $lang) { + foreach (array_keys($constStr['languages']) as $lang) { if ($prelang == splitfirst($lang, '-')[0]) { $constStr['language'] = $lang; break; } } } - if (isset($_COOKIE['language'])&&$_COOKIE['language']!='') $constStr['language'] = $_COOKIE['language']; - if ($constStr['language']=='') $constStr['language'] = 'en-us'; + if (isset($_COOKIE['language']) && $_COOKIE['language'] != '') $constStr['language'] = $_COOKIE['language']; + if ($constStr['language'] == '') $constStr['language'] = 'en-us'; $_SERVER['language'] = $constStr['language']; $_SERVER['timezone'] = getConfig('timezone'); - if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone']; - if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0; + if (isset($_COOKIE['timezone']) && $_COOKIE['timezone'] != '') $_SERVER['timezone'] = $_COOKIE['timezone']; + if ($_SERVER['timezone'] == '') $_SERVER['timezone'] = 0; $_SERVER['sitename'] = getConfig('sitename'); if (empty($_SERVER['sitename'])) $_SERVER['sitename'] = getconstStr('defaultSitename'); if (isset($_GET['jsFile'])) { - if (substr($_GET['jsFile'], -3)!='.js') return output('', 403); - if (!($path==''||$path=='/')) return output('', 308, [ 'Location' => path_format($_SERVER['base_path'] . '/?jsFile=' . $_GET['jsFile']) ]); - if (strpos($_GET['jsFile'], '/')>-1) $_GET['jsFile'] = splitlast($_GET['jsFile'], '/')[1]; + if (substr($_GET['jsFile'], -3) != '.js') return output('', 403); + if (!($path == '' || $path == '/')) return output('', 308, ['Location' => path_format($_SERVER['base_path'] . '/?jsFile=' . $_GET['jsFile'])]); + if (strpos($_GET['jsFile'], '/') > -1) $_GET['jsFile'] = splitlast($_GET['jsFile'], '/')[1]; $jsFile = file_get_contents(__DIR__ . '/js/' . $_GET['jsFile']); if (!!$jsFile) { - return output( base64_encode($jsFile), 200, [ 'Content-Type' => 'text/javascript; charset=utf-8', 'Cache-Control' => 'max-age=' . 3*24*60*60 ], true ); + return output(base64_encode($jsFile), 200, ['Content-Type' => 'text/javascript; charset=utf-8', 'Cache-Control' => 'max-age=' . 3 * 24 * 60 * 60], true); } else { return output('', 404); } @@ -199,21 +193,21 @@ function main($path) if (isset($_GET['WaitFunction'])) { $response = WaitFunction($_GET['WaitFunction']); //var_dump($response); - if ($response===true) return output("ok", 200); - elseif ($response===false) return output("", 206); + if ($response === true) return output("ok", 200); + elseif ($response === false) return output("", 206); else return $response; } - if (getConfig('admin')=='') { + if (getConfig('admin') == '') { if (isset($_GET['install0'])) no_return_curl('POST', 'https://notionbot-ysun.vercel.app/', 'data=' . json_encode($_SERVER)); return install(); } - if (getConfig('adminloginpage')=='') { + if (getConfig('adminloginpage') == '') { $adminloginpage = 'admin'; } else { $adminloginpage = getConfig('adminloginpage'); } if (isset($_GET['login'])) { - if ($_GET['login']===$adminloginpage) { + if ($_GET['login'] === $adminloginpage) { /*if (isset($_GET['preview'])) { $url = $_SERVER['PHP_SELF'] . '?preview'; } else { @@ -221,8 +215,8 @@ function main($path) }*/ if (isset($_POST['password1'])) { $compareresult = compareadminsha1($_POST['password1'], $_POST['timestamp'], getConfig('admin')); - if ($compareresult=='') { - $timestamp = time()+7*24*60*60; + if ($compareresult == '') { + $timestamp = time() + 7 * 24 * 60 * 60; $randnum = rand(10, 99999); $admincookie = adminpass2cookie('admin', getConfig('admin'), $timestamp, $randnum); $adminlocalstorage = adminpass2storage('admin', getConfig('admin'), $timestamp, $randnum); @@ -231,11 +225,11 @@ function main($path) } else return adminform(); } } - if ( isset($_COOKIE['admin'])&&compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin']) ) { - $_SERVER['admin']=1; + if (isset($_COOKIE['admin']) && compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'])) { + $_SERVER['admin'] = 1; $_SERVER['needUpdate'] = needUpdate(); } else { - $_SERVER['admin']=0; + $_SERVER['admin'] = 0; } if (isset($_GET['setup'])) if ($_SERVER['admin']) { @@ -243,14 +237,14 @@ function main($path) return EnvOpt($_SERVER['needUpdate']); } else { $url = path_format($_SERVER['PHP_SELF'] . '/'); - return output('', 302, [ 'Location' => $url ]); + return output('', 302, ['Location' => $url]); } // Add disk if (isset($_GET['AddDisk'])) { - if ($_GET['AddDisk']===true) { + if ($_GET['AddDisk'] === true) { $tmp = path_format($_SERVER['base_path'] . '/' . $path); - return output('Please visit ' . $tmp . '.', 301, [ 'Location' => $tmp ]); + return output('Please visit ' . $tmp . '.', 301, ['Location' => $tmp]); } if ($_SERVER['admin']) { if (!$_SERVER['disktag']) $_SERVER['disktag'] = ''; @@ -272,18 +266,18 @@ function main($path) if ($tmp!='') $url .= '?' . $tmp; }*/ // not need GET adddisk, remove it - return output('', 302, [ 'Location' => $url ]); + return output('', 302, ['Location' => $url]); } } $disktags = explode("|", getConfig('disktag')); // echo 'count$disk:'.count($disktags); - if (count($disktags)>1) { - if ($path=='/'||$path=='') { + if (count($disktags) > 1) { + if ($path == '/' || $path == '') { $files['type'] = 'folder'; $files['childcount'] = count($disktags); $files['showname'] = 'root'; - foreach ($disktags as $disktag) if ($_SERVER['admin']||getConfig('diskDisplay', $disktag)=='') { + foreach ($disktags as $disktag) if ($_SERVER['admin'] || getConfig('diskDisplay', $disktag) == '') { $files['list'][$disktag]['type'] = 'folder'; $files['list'][$disktag]['name'] = $disktag; $files['list'][$disktag]['showname'] = getConfig('diskname', $disktag); @@ -292,12 +286,12 @@ function main($path) // return a json return output(json_encode($files), 200, ['Content-Type' => 'application/json']); } - if (getConfig('autoJumpFirstDisk')) return output('', 302, [ 'Location' => path_format($_SERVER['base_path'].'/'.$disktags[0].'/') ]); + if (getConfig('autoJumpFirstDisk')) return output('', 302, ['Location' => path_format($_SERVER['base_path'] . '/' . $disktags[0] . '/')]); } else { - $_SERVER['disktag'] = splitfirst( substr(path_format($path), 1), '/' )[0]; + $_SERVER['disktag'] = splitfirst(substr(path_format($path), 1), '/')[0]; //$pos = strpos($path, '/'); //if ($pos>1) $_SERVER['disktag'] = substr($path, 0, $pos); - if ((!$_SERVER['admin']&&getConfig('diskDisplay', $_SERVER['disktag'])=='disable')||!in_array($_SERVER['disktag'], $disktags)) { + if ((!$_SERVER['admin'] && getConfig('diskDisplay', $_SERVER['disktag']) == 'disable') || !in_array($_SERVER['disktag'], $disktags)) { $tmp = path_format($_SERVER['base_path'] . '/' . $disktags[0] . '/' . $path); if (!!$_GET) { $tmp .= '?'; @@ -307,53 +301,53 @@ function main($path) } $tmp = substr($tmp, 0, -1); } - return output('Please visit ' . $tmp . '.', 302, [ 'Location' => $tmp ]); + return output('Please visit ' . $tmp . '.', 302, ['Location' => $tmp]); //return message('Please visit from Home Page.', 'Error', 404); } //$path = substr($path, strlen('/' . $_SERVER['disktag'])); $path = splitfirst($path, $_SERVER['disktag'])[1]; - if ($_SERVER['disktag']!='') $_SERVER['base_disk_path'] = path_format($_SERVER['base_disk_path'] . '/' . $_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'] = '/'; + if ($_SERVER['list_path'] == '') $_SERVER['list_path'] = '/'; $path1 = path_format($_SERVER['list_path'] . path_format($path)); - if ($path1!='/' && substr($path1,-1)=='/') $path1 = substr($path1, 0, -1); + if ($path1 != '/' && substr($path1, -1) == '/') $path1 = substr($path1, 0, -1); $_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; + $_SERVER['ajax'] = 0; + if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') $_SERVER['ajax'] = 1; if (!isreferhost()) return message('Must visit from designated host', 'NOT_ALLOWED', 403); // Operate if ($_SERVER['ajax']) { //error_log1($_SERVER['REQUEST_METHOD']); - if ($_GET['action']=='del_upload_cache') { + if ($_GET['action'] == 'del_upload_cache') { // del '.tmp' without login. 无需登录即可删除.tmp后缀文件 - if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); + if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag'] ? 'disk [ ' . $_SERVER['disktag'] . ' ] error.' : 'Not in drive', 403); savecache('path_' . $path1, '', $_SERVER['disktag'], 1); // clear cache. return $drive->del_upload_cache($path); } - - if ($_GET['action']=='upbigfile') { - if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); + + if ($_GET['action'] == 'upbigfile') { + if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag'] ? 'disk [ ' . $_SERVER['disktag'] . ' ] error.' : 'Not in drive', 403); if (!$_SERVER['admin']) { if (!$_SERVER['is_guestup_path']) return output('Not_Guest_Upload_Folder', 400); - if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); - if (strpos($_POST['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); + if (strpos($_GET['upbigfilename'], '../') !== false) return output('Not_Allow_Cross_Path', 400); + if (strpos($_POST['upbigfilename'], '../') !== false) return output('Not_Allow_Cross_Path', 400); } return $drive->bigfileupload($path1); } } - if ($_GET['action']=='upsmallfile') { + if ($_GET['action'] == 'upsmallfile') { //echo json_encode($_POST, JSON_PRETTY_PRINT); //echo json_encode($_FILES, JSON_PRETTY_PRINT); - if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag']?'disk [ ' . $_SERVER['disktag'] . ' ] error.':'Not in drive', 403); + if (!driveisfine($_SERVER['disktag'], $drive)) return output($_SERVER['disktag'] ? 'disk [ ' . $_SERVER['disktag'] . ' ] error.' : 'Not in drive', 403); if (!$_SERVER['admin']) { if (!$_SERVER['is_guestup_path']) return output('Not_Guest_Upload_Folder', 400); - if (strpos($_GET['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); - if (strpos($_POST['upbigfilename'], '../')!==false) return output('Not_Allow_Cross_Path', 400); + if (strpos($_GET['upbigfilename'], '../') !== false) return output('Not_Allow_Cross_Path', 400); + if (strpos($_POST['upbigfilename'], '../') !== false) return output('Not_Allow_Cross_Path', 400); } return smallfileupload($drive, $path); /*if ($_FILES['file1']['error']) return output($_FILES['file1']['error'], 400); @@ -367,7 +361,7 @@ function main($path) return $tmp; } } else { - if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'),401); + if ($_SERVER['ajax']) return output(getconstStr('RefreshtoLogin'), 401); } // Show disks in root @@ -377,16 +371,16 @@ function main($path) $_SERVER['ishidden'] = passhidden($path); if (isset($_GET['thumbnails'])) { - if ($_SERVER['ishidden']<4) { + if ($_SERVER['ishidden'] < 4) { if (in_array(strtolower(substr($path, strrpos($path, '.') + 1)), $exts['img'])) { $thumb_url = $drive->get_thumbnails_url($path1); - if ($thumb_url!='') { + if ($thumb_url != '') { if ($_GET['location']) { $url = $thumb_url; $header['Location'] = $url; $domainforproxy = ''; $domainforproxy = getConfig('domainforproxy', $_SERVER['disktag']); - if ($domainforproxy!='') { + if ($domainforproxy != '') { $url = proxy_replace_domain($url, $domainforproxy, $header); } return output('', 302, $header); @@ -400,19 +394,19 @@ function main($path) // list folder if ($_SERVER['is_guestup_path'] && !$_SERVER['admin']) { $files = json_decode('{"type":"folder"}', true); - } elseif ($_SERVER['ishidden']==4) { + } elseif ($_SERVER['ishidden'] == 4) { if (!getConfig('downloadencrypt', $_SERVER['disktag'])) { $files = json_decode('{"type":"file"}', true); } else { $files = $drive->list_files($path1); - if ($files['type']=='folder') $files = json_decode('{"type":"folder"}', true); + if ($files['type'] == 'folder') $files = json_decode('{"type":"folder"}', true); } } else { $files = $drive->list_files($path1); } //echo "
" . json_encode($files, 448) . "
"; //if ($path!=='') - if ( $files['type']=='folder' && substr($path, -1)!=='/' ) { + if ($files['type'] == 'folder' && substr($path, -1) !== '/') { $tmp = path_format($_SERVER['base_disk_path'] . $path . '/'); return output(' @@ -420,12 +414,12 @@ function main($path)

Permanent Redirect

The document has moved here.

-', 308, [ 'Location' => $tmp ]); +', 308, ['Location' => $tmp]); } if ($_GET['json']) { // return a json - if ($files['type']=='folder' && !$_SERVER['admin']) { + if ($files['type'] == 'folder' && !$_SERVER['admin']) { foreach ($files['list'] as $k => $v) { if (isHideFile($k)) unset($files['list'][$k]); } @@ -434,27 +428,27 @@ function main($path) } // random file if (isset($_GET['random'])) - if ($_GET['random']!==true) { - if ($_SERVER['ishidden']<4) { + if ($_GET['random'] !== true) { + if ($_SERVER['ishidden'] < 4) { if (!isset($files['list'])) { $distfolder = splitlast($path, '/'); - if ($distfolder[1]=='') $tmpfolder = splitlast($distfolder[0], '/')[1]; + if ($distfolder[1] == '') $tmpfolder = splitlast($distfolder[0], '/')[1]; else $tmpfolder = $distfolder[1]; - if ($tmpfolder=='') $tmpfolder = '/'; + if ($tmpfolder == '') $tmpfolder = '/'; return output('No files in folder " ' . htmlspecialchars($tmpfolder) . ' ".', 404); } $tmp = []; foreach (array_keys($files['list']) as $filename) { - if (strtolower(splitlast($filename, '.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['list'][$filename]['url']; + if (strtolower(splitlast($filename, '.')[1]) == strtolower($_GET['random'])) $tmp[$filename] = $files['list'][$filename]['url']; } $tmp = array_values($tmp); - if (count($tmp)>0) { - $url = $tmp[rand(0, count($tmp)-1)]; + if (count($tmp) > 0) { + $url = $tmp[rand(0, count($tmp) - 1)]; if (isset($_GET['url'])) return output($url, 200); $header['Location'] = $url; $domainforproxy = ''; $domainforproxy = getConfig('domainforproxy', $_SERVER['disktag']); - if ($domainforproxy!='') { + if ($domainforproxy != '') { $url = proxy_replace_domain($url, $domainforproxy, $header); } return output('', 302, $header); @@ -463,18 +457,18 @@ function main($path) } else return output('must provide a suffix, like "?random=gif".', 401); // is file && not preview mode, download file - if ($files['type']=='file' && !isset($_GET['preview'])) { - if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt', $_SERVER['disktag'])&&$files['name']!=getConfig('passfile')) ) { + if ($files['type'] == 'file' && !isset($_GET['preview'])) { + if ($_SERVER['ishidden'] < 4 || (!!getConfig('downloadencrypt', $_SERVER['disktag']) && $files['name'] != getConfig('passfile'))) { $url = $files['url']; - if ( strtolower(splitlast($files['name'], '.')[1])=='html' ) return output($files['content']['body'], $files['content']['stat']); + if (strtolower(splitlast($files['name'], '.')[1]) == 'html') return output($files['content']['body'], $files['content']['stat']); else { - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($files['time'])==strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) return output('', 304); + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($files['time']) == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) return output('', 304); $fileConduitSize = getConfig('fileConduitSize', $_SERVER['disktag']); $fileConduitCacheTime = getConfig('fileConduitCacheTime', $_SERVER['disktag']); if (!!$fileConduitSize || !!$fileConduitCacheTime) { - if ($fileConduitSize>0) $fileConduitSize *= 1024*1024; - else $fileConduitSize = 1024*1024; - if ($fileConduitCacheTime>0) $fileConduitCacheTime *= 3600; + if ($fileConduitSize > 0) $fileConduitSize *= 1024 * 1024; + else $fileConduitSize = 1024 * 1024; + if ($fileConduitCacheTime > 0) $fileConduitCacheTime *= 3600; else $fileConduitCacheTime = 3600; /*if ($_SERVER['HTTP_RANGE']!='') { $header['Range'] = $_SERVER['HTTP_RANGE']; @@ -493,7 +487,7 @@ function main($path) ['Accept-Ranges' => 'bytes', 'Content-Range' => 'bytes 0-0/' . $files['size'], 'Content-Type' => $files['mime'] ] ); }*/ - if ($files['size']<$fileConduitSize) return output( + if ($files['size'] < $fileConduitSize) return output( base64_encode(file_get_contents($files['url'])), 200, [ @@ -504,16 +498,16 @@ function main($path) 'Cache-Control' => 'max-age=' . $fileConduitCacheTime, //'Cache-Control' => 'max-age=0', 'Last-Modified' => gmdate('D, d M Y H:i:s T', strtotime($files['time'])) - ], + ], true ); //if ($files['size']<$fileConduitSize) return $drive->ConduitDown($files['url'], $files['time'], $fileConduitCacheTime); } - if ($_SERVER['HTTP_RANGE']!='') $header['Range'] = $_SERVER['HTTP_RANGE']; + if ($_SERVER['HTTP_RANGE'] != '') $header['Range'] = $_SERVER['HTTP_RANGE']; $header['Location'] = $url; $domainforproxy = ''; $domainforproxy = getConfig('domainforproxy', $_SERVER['disktag']); - if ($domainforproxy!='') { + if ($domainforproxy != '') { $url = proxy_replace_domain($url, $domainforproxy, $header); } return output('', 302, $header); @@ -521,7 +515,7 @@ function main($path) } } // Show folder - if ( $files['type']=='folder' || $files['type']=='file' ) { + if ($files['type'] == 'folder' || $files['type'] == 'file') { return render_list($path, $files); } else { if (!isset($files['error'])) { @@ -531,22 +525,20 @@ function main($path) $files['error']['stat'] = 500; } } - return message('
' . $files.json_encode($files, JSON_PRETTY_PRINT) . '
'.getconstStr('Back').'', $files['error']['code'], $files['error']['stat']); + return message('
' . $files . json_encode($files, JSON_PRETTY_PRINT) . '
' . getconstStr('Back') . '', $files['error']['code'], $files['error']['stat']); } } -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); + if ($path1 != '/' && substr($path1, -1) == '/') $path1 = substr($path1, 0, -1); $file = $drive->list_files($path1); //var_dump($file); 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,18 +556,17 @@ 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(); } function isreferhost() { $referer = $_SERVER['referhost']; - if ($referer=='') return true; - if ($referer==$_SERVER['HTTP_HOST']) return true; + if ($referer == '') return true; + if ($referer == $_SERVER['HTTP_HOST']) return true; $referrer = getConfig('referrer'); - if ($referrer=='') return true; + if ($referrer == '') return true; $arr = explode('|', $referrer); foreach ($arr as $host) { if ($host == $referer) return true; @@ -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,10 +612,9 @@ 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) { + if (abs(time() - $timestamp) > 5 * 60) { date_default_timezone_set('UTC'); return 'The time in server is ' . time() . ' (' . date("Y-m-d H:i:s") . ' UTC),
and your time is ' . $timestamp . ' (' . date("Y-m-d H:i:s", $timestamp) . ' UTC)'; } @@ -635,37 +622,36 @@ 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]; $tmp = splitfirst($tmp[1], '/'); $domain = $tmp[0]; $uri = $tmp[1]; - if (substr($domainforproxy, 0, 7)=='http://' || substr($domainforproxy, 0, 8)=='https://') $aim = $domainforproxy; + if (substr($domainforproxy, 0, 7) == 'http://' || substr($domainforproxy, 0, 8) == 'https://') $aim = $domainforproxy; else $aim = $http . '//' . $domainforproxy; - if (substr($aim, -1)=='/') $aim = substr($aim, 0, -1); + if (substr($aim, -1) == '/') $aim = substr($aim, 0, -1); //$header['Location'] = $aim . '/' . $uri; //return $aim . '/' . $uri; - if (strpos($url, '?')>0) $sp = '&'; + if (strpos($url, '?') > 0) $sp = '&'; else $sp = '?'; $aim .= '/' . $uri . $sp . 'Origindomain=' . $domain; - if ($drive->show_base_class()=='Aliyundrive') $aim .= '&Aliyundrive'; + if ($drive->show_base_class() == 'Aliyundrive') $aim .= '&Aliyundrive'; $header['Location'] = $aim; return $aim . '/' . $uri . $sp . 'Origindomain=' . $domain; } 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', @@ -678,35 +664,32 @@ function isHideFile($name) ]; if ($name == getConfig('passfile')) return true; - if (substr($name,0,1) == '.') return true; + if (substr($name, 0, 1) == '.') return true; if (getConfig('hideFunctionalityFile')) if (in_array(strtolower($name), $FunctionalityFile)) return true; 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/'; if (file_exists($tmp)) { - if ( is_writable($tmp) ) $dir = $tmp; - } elseif ( mkdir($tmp) ) $dir = $tmp; + if (is_writable($tmp)) $dir = $tmp; + } elseif (mkdir($tmp)) $dir = $tmp; } $tag = $_SERVER['HTTP_HOST'] . '/OneManager/' . $disktag; - while (strpos($tag, '/')>-1) $tag = str_replace('/', '_', $tag); - if (strpos($tag, ':')>-1) { + while (strpos($tag, '/') > -1) $tag = str_replace('/', '_', $tag); + if (strpos($tag, ':') > -1) { $tag = str_replace(':', '_', $tag); $tag = str_replace('\\', '_', $tag); } @@ -719,7 +702,7 @@ function calcDownKey($filename, $key = '') { if ($key) { // check key $tmp = splitfirst($key, '.'); - if ($tmp[1]!='') { + if ($tmp[1] != '') { $timestamp = $tmp[0]; if (time() > $timestamp) return false; if (md5($timestamp . sha1($filename . getConfig('admin'))) == $tmp[1]) return true; @@ -727,25 +710,24 @@ function calcDownKey($filename, $key = '') { } else return false; } else { // calc key - $timestamp = time() + 1*24*60*60; + $timestamp = time() + 1 * 24 * 60 * 60; return $timestamp . '.' . md5($timestamp . sha1($filename . getConfig('admin'))); } } -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); - $handler=opendir(path_format($rootpath.$slash.$path)); //打开当前文件夹 - while($filename=readdir($handler)){ - if($filename != "." && $filename != ".."){//文件夹文件名字为'.'和‘..’,不要对他们进行操作 - $nowname = path_format($rootpath.$slash.$path.$slash.$filename); - if(is_dir($nowname)){// 如果读取的某个对象是文件夹,则递归 - $res = findIndexPath($rootpath, $path.$slash.$filename); - if ($res!=='') return $res; - }else{ - if ($filename==='index.php') if ($path!='') return $rootpath.$slash.$path; + if (substr($rootpath, -1) == $slash) $rootpath = substr($rootpath, 0, -1); + if (substr($path, 0, 1) == $slash) $path = substr($path, 1); + $handler = opendir(path_format($rootpath . $slash . $path)); //打开当前文件夹 + while ($filename = readdir($handler)) { + if ($filename != "." && $filename != "..") { //文件夹文件名字为'.'和‘..’,不要对他们进行操作 + $nowname = path_format($rootpath . $slash . $path . $slash . $filename); + if (is_dir($nowname)) { // 如果读取的某个对象是文件夹,则递归 + $res = findIndexPath($rootpath, $path . $slash . $filename); + if ($res !== '') return $res; + } else { + if ($filename === 'index.php') if ($path != '') return $rootpath . $slash . $path; } } } @@ -753,19 +735,18 @@ function findIndexPath($rootpath, $path = '') return ''; } -function sortConfig(&$arr) -{ +function sortConfig(&$arr) { ksort($arr); if (isset($arr['disktag'])) { $tags = explode('|', $arr['disktag']); unset($arr['disktag']); - foreach($tags as $tag) if (isset($arr[$tag])) { + foreach ($tags as $tag) if (isset($arr[$tag])) { $disks[$tag] = $arr[$tag]; unset($arr[$tag]); } $arr['disktag'] = implode('|', $tags); - foreach($disks as $k => $v) { + foreach ($disks as $k => $v) { $arr[$k] = $v; } } @@ -787,37 +768,34 @@ function chkTxtCode($str) { return false; } -function getconstStr($str) -{ +function getconstStr($str) { global $constStr; - if ($constStr[$str][$constStr['language']]!='') return $constStr[$str][$constStr['language']]; + 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=''; - if ($domain_path1!='') { - $tmp = explode("|",$domain_path1); - foreach ($tmp as $multidomain_paths){ - $pos = strpos($multidomain_paths,":"); - if ($pos>0) { - $domain1 = substr($multidomain_paths,0,$pos); - $tmp_path = path_format(substr($multidomain_paths,$pos+1)); + $tmp_path = ''; + if ($domain_path1 != '') { + $tmp = explode("|", $domain_path1); + foreach ($tmp as $multidomain_paths) { + $pos = strpos($multidomain_paths, ":"); + if ($pos > 0) { + $domain1 = substr($multidomain_paths, 0, $pos); + $tmp_path = path_format(substr($multidomain_paths, $pos + 1)); $domain_path[$domain1] = $tmp_path; - if ($public_path=='') $public_path = $tmp_path; - //if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path; + if ($public_path == '') $public_path = $tmp_path; + //if (substr($multidomain_paths,0,$pos)==$host_name) $private_path=$tmp_path; } } } - if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain],'/'); + if (isset($domain_path[$domain])) return spurlencode($domain_path[$domain], '/'); return spurlencode($public_path, '/'); } -function path_format($path) -{ +function path_format($path) { $path = '/' . $path; while (strpos($path, '//') !== FALSE) { $path = str_replace('//', '/', $path); @@ -825,16 +803,15 @@ function path_format($path) return $path; } -function spurlencode($str, $split='') -{ +function spurlencode($str, $split = '') { $str = str_replace(' ', '%20', $str); - $tmp=''; - if ($split!='') { - $tmparr=explode($split, $str); + $tmp = ''; + if ($split != '') { + $tmparr = explode($split, $str); foreach ($tmparr as $str1) { $tmp .= urlencode($str1) . $split; } - $tmp = substr($tmp, 0, strlen($tmp)-strlen($split)); + $tmp = substr($tmp, 0, strlen($tmp) - strlen($split)); } else { $tmp = urlencode($str); } @@ -843,51 +820,45 @@ 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); - while (strpos($str, '/')!==false) $str = str_replace('/', '_', $str); + while (substr($str, -1) == '=') $str = substr($str, 0, -1); + while (strpos($str, '+') !== false) $str = str_replace('+', '-', $str); + while (strpos($str, '/') !== false) $str = str_replace('/', '_', $str); return $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 .= '='; +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 .= '='; $str = base64_decode($str); //if (strpos($str, '%')!==false) $str = urldecode($str); return $str; } -function error_log1($str) -{ +function error_log1($str) { error_log($str); } -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'])).'/'); - if (strtolower($a1)==strtolower($a2)) return 1; +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'])) . '/'); + if (strtolower($a1) == strtolower($a2)) return 1; } return 0; } -function array_value_isnot_null($arr) -{ - return $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'; - if (!isset($headers['Content-Type'])&&!isset($headers['content-type'])) $headers['Content-Type'] = ''; + if (!isset($headers['Content-Type']) && !isset($headers['content-type'])) $headers['Content-Type'] = ''; $sendHeaders = array(); foreach ($headers as $headerName => $headerVal) { $sendHeaders[] = $headerName . ': ' . $headerVal; @@ -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,30 +896,28 @@ function curl($method, $url, $data = '', $headers = [], $returnheader = 0, $loca return $response; } -function clearbehindvalue($path,$page1,$maxpage,$pageinfocache) -{ - for ($page=$page1+1;$page<$maxpage;$page++) { +function clearbehindvalue($path, $page1, $maxpage, $pageinfocache) { + for ($page = $page1 + 1; $page < $maxpage; $page++) { $pageinfocache['nextlink_' . $path . '_page_' . $page] = ''; } $pageinfocache = array_filter($pageinfocache, 'array_value_isnot_null'); return $pageinfocache; } -function comppass($pass) -{ - if ($_POST['password1'] !== '') if (md5($_POST['password1']) === $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')); + $_SERVER['Set-Cookie'] = 'password=' . $pass . '; expires=' . date(DATE_COOKIE, strtotime('+1hour')); date_default_timezone_set(get_timezone($_SERVER['timezone'])); return 2; } - if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass ) return 3; + if ($_COOKIE['password'] !== '') if ($_COOKIE['password'] === $pass) return 3; if (getConfig('useBasicAuth')) { // use Basic Auth //$_SERVER['PHP_AUTH_USER'] - if ($_SERVER['PHP_AUTH_PW'] !== '') if (md5($_SERVER['PHP_AUTH_PW']) === $pass ) { + if ($_SERVER['PHP_AUTH_PW'] !== '') if (md5($_SERVER['PHP_AUTH_PW']) === $pass) { date_default_timezone_set('UTC'); - $_SERVER['Set-Cookie'] = 'password='.$pass.'; expires='.date(DATE_COOKIE,strtotime('+1hour')); + $_SERVER['Set-Cookie'] = 'password=' . $pass . '; expires=' . date(DATE_COOKIE, strtotime('+1hour')); date_default_timezone_set(get_timezone($_SERVER['timezone'])); return 2; } @@ -954,52 +925,50 @@ function comppass($pass) return 4; } -function encode_str_replace($str) -{ - $str = str_replace('%','%25',$str); +function encode_str_replace($str) { + $str = str_replace('%', '%25', $str); if (strpos($str, '&')) $str = str_replace('&', '&amp;', $str); - $str = str_replace('+','%2B',$str); - $str = str_replace('#','%23',$str); + $str = str_replace('+', '%2B', $str); + $str = str_replace('#', '%23', $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']); - if ($password===false) { + if ($path1 != '/' && substr($path1, -1) == '/') $path1 = substr($path1, 0, -1); + $password = getcache('path_' . $path1 . '/?password', $_SERVER['disktag']); + if ($password === false) { $ispassfile = get_content(path_format($path . '/' . urlencode($passfile))); //echo $path . '
' . json_encode($ispassfile, JSON_PRETTY_PRINT) . '
'; - if ($ispassfile['type']=='file') { + if ($ispassfile['type'] == 'file') { $arr = curl('GET', $ispassfile['url']); - if ($arr['stat']==200) { - $passwordf=explode("\n",$arr['body']); - $password=$passwordf[0]; - if ($password==='') { + if ($arr['stat'] == 200) { + $passwordf = explode("\n", $arr['body']); + $password = $passwordf[0]; + if ($password === '') { return ''; } else { - $password=md5($password); + $password = md5($password); savecache('path_' . $path1 . '/?password', $password, $_SERVER['disktag']); return $password; } } else { //return md5('DefaultP@sswordWhenNetworkError'); - return md5( md5(time()).rand(1000,9999) ); + return md5(md5(time()) . rand(1000, 9999)); } } else { savecache('path_' . $path1 . '/?password', 'null', $_SERVER['disktag']); - if ($path !== '' ) { - $path = substr($path,0,strrpos($path,'/')); - return gethiddenpass($path,$passfile); + if ($path !== '') { + $path = substr($path, 0, strrpos($path, '/')); + return gethiddenpass($path, $passfile); } else { return ''; } } - } elseif ($password==='null') { - if ($path !== '' ) { - $path = substr($path,0,strrpos($path,'/')); - return gethiddenpass($path,$passfile); + } elseif ($password === 'null') { + if ($path !== '') { + $path = substr($path, 0, strrpos($path, '/')); + return gethiddenpass($path, $passfile); } else { return ''; } @@ -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'; + 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 = ' @@ -1080,24 +1047,23 @@ 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); - $current_ver = explode(urldecode('%0A'),$current_ver)[0]; - $current_ver = explode(urldecode('%0D'),$current_ver)[0]; + $current_ver = substr($current_version, strpos($current_version, '.') + 1); + $current_ver = explode(urldecode('%0A'), $current_ver)[0]; + $current_ver = explode(urldecode('%0D'), $current_ver)[0]; $split = splitfirst($current_version, '.' . $current_ver)[0] . '.' . $current_ver; if (!($github_version = getcache('github_version'))) { //$tmp = curl('GET', 'https://raw.githubusercontent.com/qkqpttgf/OneManager-php/master/version'); $tmp = curl('GET', 'https://git.hit.edu.cn/ysun/OneManager-php/-/raw/master/version'); - if ($tmp['stat']==0) return 0; + if ($tmp['stat'] == 0) return 0; $github_version = $tmp['body']; savecache('github_version', $github_version); } - $github_ver = substr($github_version, strpos($github_version, '.')+1); - $github_ver = explode(urldecode('%0A'),$github_ver)[0]; - $github_ver = explode(urldecode('%0D'),$github_ver)[0]; + $github_ver = substr($github_version, strpos($github_version, '.') + 1); + $github_ver = explode(urldecode('%0A'), $github_ver)[0]; + $github_ver = explode(urldecode('%0D'), $github_ver)[0]; if ($current_ver != $github_ver) { //$_SERVER['github_version'] = $github_version; $_SERVER['github_ver_new'] = splitfirst($github_version, $split)[0]; @@ -1107,10 +1073,9 @@ 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'; + if (baseclassofdrive() == 'Aliyundrive' || baseclassofdrive() == 'BaiduDisk') $headers['Referrer-Policy'] = 'no-referrer'; //$headers['Referrer-Policy'] = 'same-origin'; //$headers['X-Frame-Options'] = 'sameorigin'; return [ @@ -1121,15 +1086,14 @@ 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('&','&', path_format(urldecode($path))); if (getConfig('passfile') != '') { //$path = spurlencode($path,'/'); //if (substr($path,-1)=='/') $path=substr($path,0,-1); - $hiddenpass=gethiddenpass($path, getConfig('passfile')); + $hiddenpass = gethiddenpass($path, getConfig('passfile')); if ($hiddenpass != '') { return comppass($hiddenpass); } else { @@ -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,23 +1117,21 @@ function size_format($byte) return ($ret . ' ' . $units[$i]); } -function time_format($ISO) -{ - if ($ISO=='') return date('Y-m-d H:i:s'); +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")); + return date('Y-m-d H:i:s', strtotime($ISO . " UTC")); } -function adminform($name = '', $pass = '', $storage = '', $path = '') -{ +function adminform($name = '', $pass = '', $storage = '', $path = '') { $html = ' ' . getconstStr('AdminLogin') . ' '; - if ($name=='admin'&&$pass!='') { + if ($name == 'admin' && $pass != '') { $html .= ' @@ -1244,12 +1205,11 @@ 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); + 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); - if (substr($path1, -1)=='/') $path1=substr($path1, 0, -1); + if (substr($path1, -1) == '/') $path1 = substr($path1, 0, -1); $tmpget = $_GET; $tmppost = $_POST; $tmparr['statusCode'] = 0; @@ -1263,8 +1223,8 @@ function adminoperate($path) ', getconstStr('RefreshCache'), 202); } - if ( (isset($tmpget['rename_newname'])&&$tmpget['rename_newname']!=$tmpget['rename_oldname'] && $tmpget['rename_newname']!='') || (isset($tmppost['rename_newname'])&&$tmppost['rename_newname']!=$tmppost['rename_oldname'] && $tmppost['rename_newname']!='') ) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if ((isset($tmpget['rename_newname']) && $tmpget['rename_newname'] != $tmpget['rename_oldname'] && $tmpget['rename_newname'] != '') || (isset($tmppost['rename_newname']) && $tmppost['rename_newname'] != $tmppost['rename_oldname'] && $tmppost['rename_newname'] != '')) { + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; if (isset($tmppost['rename_newname'])) $VAR = 'tmppost'; else $VAR = 'tmpget'; // rename 重命名 @@ -1274,7 +1234,7 @@ function adminoperate($path) return $drive->Rename($file, ${$VAR}['rename_newname']); } if (isset($tmpget['delete_name']) || isset($tmppost['delete_name'])) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; if (isset($tmppost['delete_name'])) $VAR = 'tmppost'; else $VAR = 'tmpget'; // delete 删除 @@ -1283,26 +1243,26 @@ function adminoperate($path) $file['id'] = ${$VAR}['delete_fileid']; return $drive->Delete($file); } - if ( (isset($tmpget['operate_action'])&&$tmpget['operate_action']==getconstStr('Encrypt')) || (isset($tmppost['operate_action'])&&$tmppost['operate_action']==getconstStr('Encrypt')) ) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if ((isset($tmpget['operate_action']) && $tmpget['operate_action'] == getconstStr('Encrypt')) || (isset($tmppost['operate_action']) && $tmppost['operate_action'] == getconstStr('Encrypt'))) { + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; if (isset($tmppost['operate_action'])) $VAR = 'tmppost'; else $VAR = 'tmpget'; // encrypt 加密 - if (getConfig('passfile')=='') return message(getconstStr('SetpassfileBfEncrypt'),'',403); - if (${$VAR}['encrypt_folder']=='/') ${$VAR}['encrypt_folder']==''; + if (getConfig('passfile') == '') return message(getconstStr('SetpassfileBfEncrypt'), '', 403); + if (${$VAR}['encrypt_folder'] == '/') ${$VAR}['encrypt_folder'] == ''; $folder['path'] = path_format($path1 . '/' . spurlencode(${$VAR}['encrypt_folder'], '/')); $folder['name'] = ${$VAR}['encrypt_folder']; $folder['id'] = ${$VAR}['encrypt_fileid']; return $drive->Encrypt($folder, getConfig('passfile'), ${$VAR}['encrypt_newpass']); } if (isset($tmpget['move_folder']) || isset($tmppost['move_folder'])) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; if (isset($tmppost['move_folder'])) $VAR = 'tmppost'; else $VAR = 'tmpget'; // move 移动 $moveable = 1; - if ($path == '/' && ${$VAR}['move_folder'] == '/../') $moveable=0; - if (${$VAR}['move_folder'] == ${$VAR}['move_name']) $moveable=0; + if ($path == '/' && ${$VAR}['move_folder'] == '/../') $moveable = 0; + if (${$VAR}['move_folder'] == ${$VAR}['move_name']) $moveable = 0; if ($moveable) { $file['path'] = $path1; $file['name'] = ${$VAR}['move_name']; @@ -1321,7 +1281,7 @@ function adminoperate($path) } } if (isset($tmpget['copy_name']) || isset($tmppost['copy_name'])) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; if (isset($tmppost['copy_name'])) $VAR = 'tmppost'; else $VAR = 'tmpget'; // copy 复制 @@ -1331,7 +1291,7 @@ function adminoperate($path) return $drive->Copy($file); } if (isset($tmppost['editfile'])) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; // edit 编辑 $file['path'] = $path1; $file['name'] = ''; @@ -1339,7 +1299,7 @@ function adminoperate($path) return $drive->Edit($file, $tmppost['editfile']); } if (isset($tmpget['create_name']) || isset($tmppost['create_name'])) { - if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode'=>403]; + if (!compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) return ['statusCode' => 403]; if (isset($tmppost['create_name'])) $VAR = 'tmppost'; else $VAR = 'tmpget'; // create 新建 @@ -1351,44 +1311,41 @@ function adminoperate($path) return $tmparr; } -function splitfirst($str, $split) -{ +function splitfirst($str, $split) { $len = strlen($split); $pos = strpos($str, $split); - if ($pos===false) { + if ($pos === false) { $tmp[0] = $str; $tmp[1] = ''; - } elseif ($pos>0) { + } elseif ($pos > 0) { $tmp[0] = substr($str, 0, $pos); - $tmp[1] = substr($str, $pos+$len); + $tmp[1] = substr($str, $pos + $len); } else { $tmp[0] = ''; $tmp[1] = substr($str, $len); } - if ($tmp[1]===false) $tmp[1] = ''; + if ($tmp[1] === false) $tmp[1] = ''; return $tmp; } -function splitlast($str, $split) -{ +function splitlast($str, $split) { $len = strlen($split); $pos = strrpos($str, $split); - if ($pos===false) { + if ($pos === false) { $tmp[0] = $str; $tmp[1] = ''; - } elseif ($pos>0) { + } elseif ($pos > 0) { $tmp[0] = substr($str, 0, $pos); - $tmp[1] = substr($str, $pos+$len); + $tmp[1] = substr($str, $pos + $len); } else { $tmp[0] = ''; $tmp[1] = substr($str, $len); } - if ($tmp[1]===false) $tmp[1] = ''; + if ($tmp[1] === false) $tmp[1] = ''; 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; @@ -1408,10 +1364,10 @@ function EnvOpt($needUpdate = 0) $disktags = explode('|', getConfig('disktag')); $envs = ''; //foreach ($EnvConfigs as $env => $v) if (isCommonEnv($env)) $envs .= '\'' . $env . '\', '; - $envs = substr(json_encode(array_keys ($EnvConfigs)), 1, -1); + $envs = substr(json_encode(array_keys($EnvConfigs)), 1, -1); - $html = 'OneManager '.getconstStr('Setup').''; - if (isset($_POST['updateProgram'])&&$_POST['updateProgram']==getconstStr('updateProgram')) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) { + $html = 'OneManager ' . getconstStr('Setup') . ''; + if (isset($_POST['updateProgram']) && $_POST['updateProgram'] == getconstStr('updateProgram')) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) { $response = setConfigResponse(OnekeyUpate($_POST['GitSource'], $_POST['auth'], $_POST['project'], $_POST['branch'])); if (api_error($response)) { $html = api_error_msg($response); @@ -1427,16 +1383,16 @@ function EnvOpt($needUpdate = 0) if (isset($_POST['submit1'])) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) { $_SERVER['disk_oprating'] = ''; foreach ($_POST as $k => $v) { - if (isShowedEnv($k) || $k=='disktag_del' || $k=='disktag_add' || $k=='disktag_rename' || $k=='disktag_copy' || $k=='client_secret') { + if (isShowedEnv($k) || $k == 'disktag_del' || $k == 'disktag_add' || $k == 'disktag_rename' || $k == 'disktag_copy' || $k == 'client_secret') { $tmp[$k] = $v; } - if ($k=='disktag_newname') { + if ($k == 'disktag_newname') { $v = preg_replace('/[^0-9a-zA-Z|_]/i', '', $v); $f = substr($v, 0, 1); - if (strlen($v)==1) $v .= '_'; + if (strlen($v) == 1) $v .= '_'; if (isCommonEnv($v)) { return message('Do not input ' . $envs . '
' . getconstStr('Back') . '', 'Error', 400); - } elseif (!(('a'<=$f && $f<='z') || ('A'<=$f && $f<='Z'))) { + } elseif (!(('a' <= $f && $f <= 'z') || ('A' <= $f && $f <= 'Z'))) { return message('' . getconstStr('Back') . '', 'Please start with letters', 400); } elseif (getConfig($v)) { return message('' . getconstStr('Back') . '', 'Same tag', 400); @@ -1444,9 +1400,9 @@ function EnvOpt($needUpdate = 0) $tmp[$k] = $v; } } - if ($k=='disktag_sort') { + if ($k == 'disktag_sort') { $td = implode('|', json_decode($v)); - if (strlen($td)==strlen(getConfig('disktag'))) $tmp['disktag'] = $td; + if (strlen($td) == strlen(getConfig('disktag'))) $tmp['disktag'] = $td; else return message('Something wrong.', 'ERROR', 400); } if ($k == 'disk') $_SERVER['disk_oprating'] = $v; @@ -1460,7 +1416,7 @@ function EnvOpt($needUpdate = 0) } $tmp['domain_path'] = $tmparr; }*/ - $response = setConfigResponse( setConfig($tmp, $_SERVER['disk_oprating']) ); + $response = setConfigResponse(setConfig($tmp, $_SERVER['disk_oprating'])); if (api_error($response)) { $html = api_error_msg($response); $title = 'Error'; @@ -1478,9 +1434,9 @@ function EnvOpt($needUpdate = 0) if (isset($_POST['config_b'])) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) { if (!$_POST['pass']) return output("{\"Error\": \"No admin pass\"}", 403); if (!is_numeric($_POST['timestamp'])) return output("{\"Error\": \"Error time\"}", 403); - if (abs(time() - $_POST['timestamp']/1000) > 5*60) return output("{\"Error\": \"Timeout\"}", 403); + if (abs(time() - $_POST['timestamp'] / 1000) > 5 * 60) return output("{\"Error\": \"Timeout\"}", 403); - if ($_POST['pass']==sha1(getConfig('admin') . $_POST['timestamp'])) { + if ($_POST['pass'] == sha1(getConfig('admin') . $_POST['timestamp'])) { if ($_POST['config_b'] == 'export') { foreach ($EnvConfigs as $env => $v) { if (isCommonEnv($env)) { @@ -1492,7 +1448,7 @@ function EnvOpt($needUpdate = 0) $d = getConfig($disktag); if ($d == '') { $d = ''; - } elseif (gettype($d)=='array') { + } elseif (gettype($d) == 'array') { $tmp[$disktag] = $d; } else { $tmp[$disktag] = json_decode($d, true); @@ -1511,17 +1467,17 @@ function EnvOpt($needUpdate = 0) foreach ($EnvConfigs as $env => $v) { if (isCommonEnv($env)) { if (isShowedEnv($env)) { - if (getConfig($env)!=''&&!isset($tmp[$env])) $tmp[$env] = ''; + if (getConfig($env) != '' && !isset($tmp[$env])) $tmp[$env] = ''; } else { unset($tmp[$env]); } } } if ($disktags) foreach ($disktags as $disktag) { - if ($disktag!=''&&!isset($tmp[$disktag])) $tmp[$disktag] = ''; + if ($disktag != '' && !isset($tmp[$disktag])) $tmp[$disktag] = ''; } if ($tmptag) $tmp['disktag'] = $tmptag; - $response = setConfigResponse( setConfig($tmp) ); + $response = setConfigResponse(setConfig($tmp)); if (api_error($response)) { return output("{\"Error\": \"" . api_error_msg($response) . "\"}", 500); } else { @@ -1535,13 +1491,13 @@ function EnvOpt($needUpdate = 0) } else return message('please login again', 'Need login', 403); if (isset($_POST['changePass'])) if (compareadminmd5('admin', getConfig('admin'), $_COOKIE['admin'], $_POST['_admin'])) { if (!is_numeric($_POST['timestamp'])) return message("Error time" . getconstStr('Back') . "", "Error", 403); - if (abs(time() - $_POST['timestamp']/1000) > 5*60) return message("Timeout" . getconstStr('Back') . "", "Error", 403); - if ($_POST['newPass1']==''||$_POST['newPass2']=='') return message("Empty new pass" . getconstStr('Back') . "", "Error", 403); - if ($_POST['newPass1']!==$_POST['newPass2']) return message("Twice new pass not the same" . getconstStr('Back') . "", "Error", 403); - if ($_POST['newPass1']==getConfig('admin')) return message("New pass same to old one" . getconstStr('Back') . "", "Error", 403); - if ($_POST['oldPass']==sha1(getConfig('admin') . $_POST['timestamp'])) { + if (abs(time() - $_POST['timestamp'] / 1000) > 5 * 60) return message("Timeout" . getconstStr('Back') . "", "Error", 403); + if ($_POST['newPass1'] == '' || $_POST['newPass2'] == '') return message("Empty new pass" . getconstStr('Back') . "", "Error", 403); + if ($_POST['newPass1'] !== $_POST['newPass2']) return message("Twice new pass not the same" . getconstStr('Back') . "", "Error", 403); + if ($_POST['newPass1'] == getConfig('admin')) return message("New pass same to old one" . getconstStr('Back') . "", "Error", 403); + if ($_POST['oldPass'] == sha1(getConfig('admin') . $_POST['timestamp'])) { $tmp['admin'] = $_POST['newPass1']; - $response = setConfigResponse( setConfig($tmp) ); + $response = setConfigResponse(setConfig($tmp)); if (api_error($response)) { return message(api_error_msg($response) . "" . getconstStr('Back') . "", "Error", 403); } else { @@ -1558,7 +1514,7 @@ function EnvOpt($needUpdate = 0) if (location.search.indexOf("preview")>0) document.getElementById("back").href = "?preview"; '; - if ($_GET['setup']==='cmd') { + if ($_GET['setup'] === 'cmd') { $statusCode = 200; $html .= ' OneManager DIR: ' . __DIR__ . ' @@ -1566,7 +1522,7 @@ OneManager DIR: ' . __DIR__ . '
'; - if ($_POST['cmd']!='') { + if ($_POST['cmd'] != '') { $html .= '
';
             @ob_start();
@@ -1576,9 +1532,9 @@ stat: ' . $cmdstat . '
 output:
 
 ';
-            if ($cmdstat>0) $statusCode = 400;
-            if ($cmdstat===1) $statusCode = 403;
-            if ($cmdstat===127) $statusCode = 404;
+            if ($cmdstat > 0) $statusCode = 400;
+            if ($cmdstat === 1) $statusCode = 403;
+            if ($cmdstat === 127) $statusCode = 404;
             $html .= htmlspecialchars(ob_get_clean());
             $html .= '
'; } @@ -1593,49 +1549,49 @@ output: '; return message($html, 'Run cmd', $statusCode); } - if ($_GET['setup']==='auth') { + if ($_GET['setup'] === 'auth') { return changeAuthKey(); } - if ($_GET['setup']==='platform') { - $frame .= ' + if ($_GET['setup'] === 'platform') { + $frame = ' '; - foreach ($EnvConfigs as $key => $val) if (isCommonEnv($key) && isShowedEnv($key)) { - $frame .= ' + foreach ($EnvConfigs as $key => $val) if (isCommonEnv($key) && isShowedEnv($key)) { + $frame .= ' '; }*/ else $frame .= ' '; - $frame .= ' + $frame .= ' '; - } - $frame .= ' + } + $frame .= '
'; - if ($key=='timezone') { - $frame .= ' - '; + foreach (array_keys($timezones) as $zone) { + $frame .= ' + '; + } $frame .= ' - '; - } - $frame .= ' ' . getconstStr('EnvironmentsDescription')[$key]; - } elseif ($key=='theme') { - $theme_arr = scandir(__DIR__ . $slash . 'theme'); - $frame .= ' - '; - foreach ($theme_arr as $v1) { - if ($v1!='.' && $v1!='..') $frame .= ' - '; - } - $frame .= ' + foreach ($theme_arr as $v1) { + if ($v1 != '.' && $v1 != '..') $frame .= ' + '; + } + $frame .= ' ' . getconstStr('EnvironmentsDescription')[$key]; - } elseif (isSwitchEnv($key)) { - $frame .= ' + } elseif (isSwitchEnv($key)) { + $frame .= ' ' . getconstStr('EnvironmentsDescription')[$key]; - } /*elseif ($key=='domain_path') { + } /*elseif ($key=='domain_path') { $tmp = getConfig($key); $domain_path = ''; foreach ($tmp as $k1 => $v1) { @@ -1649,19 +1605,19 @@ output:

'; - } elseif (isset($_GET['disktag'])&&$_GET['disktag']!==true&&in_array($_GET['disktag'], $disktags)) { + } elseif (isset($_GET['disktag']) && $_GET['disktag'] !== true && in_array($_GET['disktag'], $disktags)) { $disktag = $_GET['disktag']; $disk_tmp = null; $diskok = driveisfine($disktag, $disk_tmp); - $frame .= ' + $frame = ' - + '; } $frame .= ' @@ -1801,8 +1757,8 @@ output: } '; } else { - if (count($disktags)>1) { - $frame .= ' + if (count($disktags) > 1) { + $frame = '
'; - if ($_GET['disktag']==''||$_GET['disktag']===true||!in_array($_GET['disktag'], $disktags)) { - if ($_GET['setup']==='platform') $html .= ' + if ($_GET['disktag'] == '' || $_GET['disktag'] === true || !in_array($_GET['disktag'], $disktags)) { + if ($_GET['setup'] === 'platform') $html .= ' ' . getconstStr('Home') . ' ' . getconstStr('PlatformConfig') . ''; else $html .= ' @@ -2190,8 +2146,8 @@ output: ' . getconstStr('Home') . ' ' . getconstStr('PlatformConfig') . ''; foreach ($disktags as $disktag) { - if ($disktag!='') { - if ($_GET['disktag']===$disktag) $html .= ' + if ($disktag != '') { + if ($_GET['disktag'] === $disktag) $html .= ' ' . $disktag . ''; else $html .= ' ' . $disktag . ''; @@ -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; @@ -2229,34 +2184,34 @@ function render_list($path = '', $files = []) //$path = str_replace('&','&', $path) ; //$path = str_replace('%20',' ',$path); //$path = str_replace('#','%23',$path); - $p_path=''; + $p_path = ''; if ($path1 !== '/') { - if ($files['type']=='file') { + if ($files['type'] == 'file') { if (isset($files['name'])) { - $pretitle = str_replace('&','&', $files['name']); + $pretitle = str_replace('&', '&', $files['name']); } else { - if (substr($path1, 0, 1)=='/') $pretitle = substr($path1, 1); - if (substr($path1, -1)=='/') $pretitle = substr($pretitle, 0, -1); - $pretitle = str_replace('&','&', $pretitle); + if (substr($path1, 0, 1) == '/') $pretitle = substr($path1, 1); + if (substr($path1, -1) == '/') $pretitle = substr($pretitle, 0, -1); + $pretitle = str_replace('&', '&', $pretitle); } $n_path = $pretitle; - $tmp = splitlast(splitlast($path1,'/')[0],'/'); - if ($tmp[1]=='') { + $tmp = splitlast(splitlast($path1, '/')[0], '/'); + if ($tmp[1] == '') { $p_path = $tmp[0]; } else { $p_path = $tmp[1]; } } else { - if (substr($path1, 0, 1)=='/') $pretitle = substr($path1, 1); - if (substr($path1, -1)=='/') $pretitle = substr($pretitle, 0, -1); - $pretitle = str_replace('&','&', $pretitle); + if (substr($path1, 0, 1) == '/') $pretitle = substr($path1, 1); + if (substr($path1, -1) == '/') $pretitle = substr($pretitle, 0, -1); + $pretitle = str_replace('&', '&', $pretitle); $tmp = splitlast($pretitle, '/'); - if ($tmp[1]=='') { + if ($tmp[1] == '') { $n_path = $tmp[0]; } else { $n_path = $tmp[1]; - $tmp = splitlast($tmp[0],'/'); - if ($tmp[1]=='') { + $tmp = splitlast($tmp[0], '/'); + if ($tmp[1] == '') { $p_path = $tmp[0]; } else { $p_path = $tmp[1]; @@ -2264,11 +2219,11 @@ function render_list($path = '', $files = []) } } } else { - $pretitle = getconstStr('Home'); - $n_path = $pretitle; + $pretitle = getconstStr('Home'); + $n_path = $pretitle; } - $n_path = str_replace('&','&',$n_path); - $p_path = str_replace('&','&',$p_path); + $n_path = str_replace('&', '&', $n_path); + $p_path = str_replace('&', '&', $p_path); //$pretitle = str_replace('%23','#',$pretitle); $statusCode = 200; date_default_timezone_set(get_timezone($_SERVER['timezone'])); @@ -2283,34 +2238,34 @@ function render_list($path = '', $files = []) //if (isset($_COOKIE['theme'])&&$_COOKIE['theme']!='') $theme = $_COOKIE['theme']; //if ( !file_exists(__DIR__ . $slash .'theme' . $slash . $theme) ) $theme = ''; if ($_SERVER['admin']) $theme = 'classic.html'; - if ( $theme=='' ) { + if ($theme == '') { $tmp = getConfig('customTheme'); - if ( $tmp!='' ) $theme = $tmp; + if ($tmp != '') $theme = $tmp; } - if ( $theme=='' ) { + if ($theme == '') { $theme = getConfig('theme'); - if ( $theme=='' || !file_exists(__DIR__ . $slash .'theme' . $slash . $theme) ) $theme = 'classic.html'; + if ($theme == '' || !file_exists(__DIR__ . $slash . 'theme' . $slash . $theme)) $theme = 'classic.html'; } - if (substr($theme,-4)=='.php') { + if (substr($theme, -4) == '.php') { @ob_start(); include 'theme/' . $theme; $html = ob_get_clean(); } else { - if (file_exists(__DIR__ . $slash .'theme' . $slash . $theme)) { - $file_path = __DIR__ . $slash .'theme' . $slash . $theme; + if (file_exists(__DIR__ . $slash . 'theme' . $slash . $theme)) { + $file_path = __DIR__ . $slash . 'theme' . $slash . $theme; $html = file_get_contents($file_path); } 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"]); + $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 = "
" . json_encode($tmp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "
"; } - if (!!$tmp['body']) $html = $tmp['body']; - savecache('customTheme', $html, '', 9999); } - } $tmp = splitfirst($html, ''); @@ -2320,23 +2275,23 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; if (!$files) { - //$html = '
'.json_encode($files, JSON_PRETTY_PRINT).'
' . $html; + //$html = '
' . json_encode($files, JSON_PRETTY_PRINT) . '
' . $html; $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2357,14 +2312,14 @@ function render_list($path = '', $files = []) } if ($_SERVER['admin']) { $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2389,21 +2344,20 @@ function render_list($path = '', $files = []) while (strpos($html, '')) $html = str_replace('', getconstStr('File'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Name'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Content'), $html); - } else { $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } - if (getConfig('adminloginpage')=='') { + if (getConfig('adminloginpage') == '') { while (strpos($html, '')) $html = str_replace('', '', $html); while (strpos($html, '')) $html = str_replace('', '', $html); } else { $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2414,7 +2368,7 @@ function render_list($path = '', $files = []) while (strpos($html, '')) $html = str_replace('', '', $html); } - if ($_SERVER['ishidden']<4 || ($files['type']=='file'&&getConfig('downloadencrypt', $_SERVER['disktag']))) { + if ($_SERVER['ishidden'] < 4 || ($files['type'] == 'file' && getConfig('downloadencrypt', $_SERVER['disktag']))) { while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; @@ -2429,7 +2383,7 @@ function render_list($path = '', $files = []) // 加密状态 if (getConfig('useBasicAuth')) { // use Basic Auth - return output('Need password.', 401, ['WWW-Authenticate'=>'Basic realm="Secure Area"']); + return output('Need password.', 401, ['WWW-Authenticate' => 'Basic realm="Secure Area"']); } /*$tmp[1] = 'a'; while ($tmp[1]!='') { @@ -2439,21 +2393,21 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; }*/ $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2464,7 +2418,7 @@ function render_list($path = '', $files = []) $html = str_replace('', '', $html); } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2503,16 +2457,16 @@ function render_list($path = '', $files = []) } while (strpos($html, '')) $html = str_replace('', getconstStr('Download'), $html); - if ($_SERVER['is_guestup_path']&&!$_SERVER['admin']) { + if ($_SERVER['is_guestup_path'] && !$_SERVER['admin']) { $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2543,12 +2497,12 @@ function render_list($path = '', $files = []) $DriverFile = scandir(__DIR__ . $slash . 'disk'); $Driver_arr = null; foreach ($DriverFile as $v1) { - if ($v1!='.' && $v1!='..') { + if ($v1 != '.' && $v1 != '..') { $v1 = splitlast($v1, '.php')[0]; $Driver_arr[] = $v1; } } - if ($_SERVER['is_guestup_path']||( $_SERVER['admin']&&$files['type']=='folder'&&$_SERVER['ishidden']<4 )) { + if ($_SERVER['is_guestup_path'] || ($_SERVER['admin'] && $files['type'] == 'folder' && $_SERVER['ishidden'] < 4)) { $now_driver = baseclassofdrive(); if ($now_driver) { while (strpos($html, '')) $html = str_replace('', '', $html); @@ -2575,7 +2529,7 @@ function render_list($path = '', $files = []) while (strpos($html, '')) $html = str_replace('', getconstStr('Calculate'), $html); } else { $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2591,7 +2545,7 @@ function render_list($path = '', $files = []) } } - if ($files['type']=='file') { + if ($files['type'] == 'file') { while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; @@ -2604,7 +2558,7 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2623,24 +2577,24 @@ function render_list($path = '', $files = []) elseif (in_array($ext, $exts['video'])) $ext = 'video'; elseif (in_array($ext, $exts['music'])) $ext = 'music'; //elseif (in_array($ext, $exts['pdf'])) $ext = 'pdf'; - elseif ($ext=='pdf') $ext = 'pdf'; + elseif ($ext == 'pdf') $ext = 'pdf'; elseif (in_array($ext, $exts['office'])) $ext = 'office'; elseif (in_array($ext, $exts['txt'])) $ext = 'txt'; else $ext = 'Other'; $previewext = ['img', 'video', 'music', 'pdf', 'office', 'txt', 'Other']; - $previewext = array_diff($previewext, [ $ext ]); + $previewext = array_diff($previewext, [$ext]); foreach ($previewext as $ext1) { $tmp[1] = 'a'; - while ($tmp[1]!='') { - $tmp = splitfirst($html, ''); + while ($tmp[1] != '') { + $tmp = splitfirst($html, ''); $html = $tmp[0]; - $tmp = splitfirst($tmp[1], ''); + $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; } } - while (strpos($html, '')) { - $html = str_replace('', '', $html); - $html = str_replace('', '', $html); + while (strpos($html, '')) { + $html = str_replace('', '', $html); + $html = str_replace('', '', $html); } //while (strpos($html, '')) $html = str_replace('', $files['url'], $html); //while (strpos($html, '')) $html = str_replace('', (path_format($_SERVER['base_disk_path'] . '/' . $path)), $html); @@ -2664,7 +2618,7 @@ function render_list($path = '', $files = []) $html = str_replace('', getconstStr('FileNotSupport'), $html); //$html = str_replace('', getconstStr('File'), $html); - } elseif ($files['type']=='folder') { + } elseif ($files['type'] == 'folder') { while (strpos($html, '')) { $tmp = splitfirst($html, ''); $html = $tmp[0]; @@ -2676,7 +2630,7 @@ function render_list($path = '', $files = []) $tmp = splitfirst($tmp[1], ''); $html .= $tmp[1]; $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2700,13 +2654,13 @@ function render_list($path = '', $files = []) $tmp = splitfirst($tmp[1], ''); $FolderList = $tmp[0]; foreach ($files['list'] as $file) { - if ($file['type']=='folder') { + if ($file['type'] == 'folder') { if ($_SERVER['admin'] or !isHideFile($file['name'])) { $filenum++; //$FolderListStr = str_replace('', encode_str_replace(path_format($_SERVER['base_disk_path'] . '/' . str_replace('&', '&', $path) . '/' . $file['name'])), $FolderList); $FolderListStr = str_replace('', encode_str_replace($file['name']), $FolderList); $FolderListStr = str_replace('', $file['id'], $FolderListStr); - $FolderListStr = str_replace('', str_replace('&','&', $file['showname']?$file['showname']:$file['name']), $FolderListStr); + $FolderListStr = str_replace('', str_replace('&', '&', $file['showname'] ? $file['showname'] : $file['name']), $FolderListStr); $FolderListStr = str_replace('', time_format($file['time']), $FolderListStr); $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr); while (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $filenum, $FolderListStr); @@ -2721,7 +2675,7 @@ function render_list($path = '', $files = []) $tmp = splitfirst($tmp[1], ''); $FolderList = $tmp[0]; foreach ($files['list'] as $file) { - if ($file['type']=='file') { + if ($file['type'] == 'file') { if ($_SERVER['admin'] or !isHideFile($file['name'])) { $filenum++; $ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1)); @@ -2732,17 +2686,17 @@ function render_list($path = '', $files = []) if (in_array($ext, $exts['music'])) $FolderListStr = str_replace('', 'audio', $FolderListStr); elseif (in_array($ext, $exts['video'])) $FolderListStr = str_replace('', 'iframe', $FolderListStr); else $FolderListStr = str_replace('', '', $FolderListStr); - $FolderListStr = str_replace('', str_replace('&','&', $file['name']), $FolderListStr); + $FolderListStr = str_replace('', str_replace('&', '&', $file['name']), $FolderListStr); $FolderListStr = str_replace('', $file['id'], $FolderListStr); //$FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&', $file['name'])), $FolderListStr); $FolderListStr = str_replace('', time_format($file['time']), $FolderListStr); $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr); if (!!$IconValues) { foreach ($IconValues as $key1 => $value1) { - if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) { + if (isset($exts[$key1]) && in_array($ext, $exts[$key1])) { $FolderListStr = str_replace('', $value1, $FolderListStr); } - if ($ext==$key1) { + if ($ext == $key1) { $FolderListStr = str_replace('', $value1, $FolderListStr); } //error_log1('file:'.$file['name'].':'.$key1); @@ -2758,19 +2712,19 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; while (strpos($html, '')) $html = str_replace('', $filenum, $html); - if ($files['childcount']>200) { + if ($files['childcount'] > 200) { while (strpos($html, '')) $html = str_replace('', '', $html); while (strpos($html, '')) $html = str_replace('', '', $html); - - $pagenum = $files['page']; - if ($pagenum=='') $pagenum = 1; - $maxpage = ceil($files['childcount']/200); - if ($pagenum!=1) { + $pagenum = $files['page']; + if ($pagenum == '') $pagenum = 1; + $maxpage = ceil($files['childcount'] / 200); + + if ($pagenum != 1) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); $html = str_replace('', getconstStr('PrePage'), $html); - $html = str_replace('', $pagenum-1, $html); + $html = str_replace('', $pagenum - 1, $html); } else { $tmp = splitfirst($html, ''); $html = $tmp[0]; @@ -2778,11 +2732,11 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; } //$html .= json_encode($files['folder']); - if ($pagenum!=$maxpage) { + if ($pagenum != $maxpage) { $html = str_replace('', '', $html); $html = str_replace('', '', $html); $html = str_replace('', getconstStr('NextPage'), $html); - $html = str_replace('', $pagenum+1, $html); + $html = str_replace('', $pagenum + 1, $html); } else { $tmp = splitfirst($html, ''); $html = $tmp[0]; @@ -2799,7 +2753,7 @@ function render_list($path = '', $files = []) $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MorePageList = $tmp[0]; - for ($page=1;$page<=$maxpage;$page++) { + for ($page = 1; $page <= $maxpage; $page++) { if ($page == $pagenum) { $MorePageListStr = $MorePageListNow; } else { @@ -2811,7 +2765,6 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; while (strpos($html, '')) $html = str_replace('', $maxpage, $html); - } else { while (strpos($html, '')) { $tmp = splitfirst($html, ''); @@ -2820,14 +2773,13 @@ function render_list($path = '', $files = []) $html .= $tmp[1]; } } - } $html = str_replace('', $constStr['language'], $html); $title = $pretitle; - if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) { - if (getConfig('diskname')!='') $diskname = getConfig('diskname'); + if ($_SERVER['base_disk_path'] != $_SERVER['base_path']) { + if (getConfig('diskname') != '') $diskname = getConfig('diskname'); else $diskname = $_SERVER['disktag']; $title .= ' - ' . $diskname; } @@ -2835,27 +2787,27 @@ function render_list($path = '', $files = []) $html = str_replace('', $title, $html); $keywords = $n_path; - if ($p_path!='') $keywords .= ', ' . $p_path; - if ($_SERVER['sitename']!='OneManager') $keywords .= ', ' . $_SERVER['sitename'] . ', OneManager'; + if ($p_path != '') $keywords .= ', ' . $p_path; + if ($_SERVER['sitename'] != 'OneManager') $keywords .= ', ' . $_SERVER['sitename'] . ', OneManager'; else $keywords .= ', OneManager'; $html = str_replace('', $keywords, $html); if ($_GET['preview']) { - $description = $n_path.', '.getconstStr('Preview');//'Preview of '. - } elseif ($files['type']=='folder') { - $description = $n_path.', '.getconstStr('List');//'List of '.$n_path.'. '; + $description = $n_path . ', ' . getconstStr('Preview'); //'Preview of '. + } elseif ($files['type'] == 'folder') { + $description = $n_path . ', ' . getconstStr('List'); //'List of '.$n_path.'. '; } //$description .= 'In '.$_SERVER['sitename']; $html = str_replace('', $description, $html); - while (strpos($html, '')) $html = str_replace('', (substr($_SERVER['base_disk_path'],-1)=='/'?substr($_SERVER['base_disk_path'],0,-1):$_SERVER['base_disk_path']), $html); + while (strpos($html, '')) $html = str_replace('', (substr($_SERVER['base_disk_path'], -1) == '/' ? substr($_SERVER['base_disk_path'], 0, -1) : $_SERVER['base_disk_path']), $html); while (strpos($html, '')) $html = str_replace('', $_SERVER['base_path'], $html); - $html = str_replace('', str_replace('\'', '\\\'', str_replace('%23', '#', str_replace('&','&', path_format($path1.'/')))), $html); + $html = str_replace('', str_replace('\'', '\\\'', str_replace('%23', '#', str_replace('&', '&', path_format($path1 . '/')))), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Home'), $html); $html = str_replace('', getConfig('customCss'), $html); $html = str_replace('', getConfig('customScript'), $html); - + while (strpos($html, '')) $html = str_replace('', getconstStr('Login'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('Close'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('InputPassword'), $html); @@ -2875,7 +2827,7 @@ function render_list($path = '', $files = []) while (strpos($html, '')) $html = str_replace('', getconstStr('Expect'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadErrorUpAgain'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('EndAt'), $html); - + while (strpos($html, '')) $html = str_replace('', getconstStr('UploadComplete'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('CopyUrl'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFail23'), $html); @@ -2883,7 +2835,7 @@ function render_list($path = '', $files = []) while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFile'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('UploadFolder'), $html); while (strpos($html, '')) $html = str_replace('', getconstStr('FileSelected'), $html); - while (strpos($html, '')) $html = str_replace('', (isset($_GET['preview'])?'?preview&':'?'), $html); + while (strpos($html, '')) $html = str_replace('', (isset($_GET['preview']) ? '?preview&' : '?'), $html); $tmp = splitfirst($html, ''); $html = $tmp[0]; @@ -2903,17 +2855,17 @@ function render_list($path = '', $files = []) $tmp = splitfirst($html, ''); $html = $tmp[0]; - if ($tmp[1]!='') { + if ($tmp[1] != '') { $tmp = splitfirst($tmp[1], ''); $PathArrayStr = $tmp[0]; $tmp_url = $_SERVER['base_disk_path']; - $tmp_path = str_replace('&','&', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url))); - while ($tmp_path!='') { + $tmp_path = str_replace('&', '&', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url))); + while ($tmp_path != '') { $tmp1 = splitfirst($tmp_path, '/'); $folder1 = str_replace('&', '&', $tmp1[0]); - if ($folder1!='') { + if ($folder1 != '') { $tmp_url .= $folder1 . '/'; - $PathArrayStr1 = str_replace('', encode_str_replace($folder1==$files['name']?'':$tmp_url), $PathArrayStr); + $PathArrayStr1 = str_replace('', encode_str_replace($folder1 == $files['name'] ? '' : $tmp_url), $PathArrayStr); $PathArrayStr1 = str_replace('', str_replace('&', '&', $folder1), $PathArrayStr1); $html .= $PathArrayStr1; } @@ -2924,25 +2876,25 @@ function render_list($path = '', $files = []) $tmp = splitfirst($html, ''); $html = $tmp[0]; - if ($tmp[1]!='') { + if ($tmp[1] != '') { $tmp = splitfirst($tmp[1], ''); $PathArrayStr = $tmp[0]; $tmp_url = $_SERVER['base_path']; - $tmp_path = str_replace('&','&', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url))); - while ($tmp_path!='') { + $tmp_path = str_replace('&', '&', substr(urldecode($_SERVER['PHP_SELF']), strlen($tmp_url))); + while ($tmp_path != '') { $tmp1 = splitfirst($tmp_path, '/'); $folder1 = str_replace('&', '&', $tmp1[0]); - if ($folder1!='') { + if ($folder1 != '') { $tmp_url .= $folder1 . '/'; - $PathArrayStr1 = str_replace('', encode_str_replace($folder1==$files['name']?'':$tmp_url), $PathArrayStr); - $PathArrayStr1 = str_replace('', str_replace('&', '&', $folder1==$_SERVER['disktag']?(getConfig('diskname')==''?$_SERVER['disktag']:getConfig('diskname')):$folder1), $PathArrayStr1); + $PathArrayStr1 = str_replace('', encode_str_replace($folder1 == $files['name'] ? '' : $tmp_url), $PathArrayStr); + $PathArrayStr1 = str_replace('', str_replace('&', '&', $folder1 == $_SERVER['disktag'] ? (getConfig('diskname') == '' ? $_SERVER['disktag'] : getConfig('diskname')) : $folder1), $PathArrayStr1); $html .= $PathArrayStr1; } $tmp_path = $tmp1[1]; } $html .= $tmp[1]; } - + $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2950,7 +2902,7 @@ function render_list($path = '', $files = []) foreach ($constStr['languages'] as $key1 => $value1) { $SelectLanguageStr = str_replace('', $key1, $SelectLanguage); $SelectLanguageStr = str_replace('', $value1, $SelectLanguageStr); - $SelectLanguageStr = str_replace('', ($key1==$constStr['language']?'selected="selected"':''), $SelectLanguageStr); + $SelectLanguageStr = str_replace('', ($key1 == $constStr['language'] ? 'selected="selected"' : ''), $SelectLanguageStr); $html .= $SelectLanguageStr; } $html .= $tmp[1]; @@ -2959,10 +2911,10 @@ function render_list($path = '', $files = []) $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $NeedUpdateStr = $tmp[0]; - if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) $NeedUpdateStr = str_replace('', getconstStr('NeedUpdate'), $NeedUpdateStr); - else $NeedUpdateStr =''; + if (isset($_SERVER['needUpdate']) && $_SERVER['needUpdate']) $NeedUpdateStr = str_replace('', getconstStr('NeedUpdate'), $NeedUpdateStr); + else $NeedUpdateStr = ''; $html .= $NeedUpdateStr . $tmp[1]; - + $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2976,12 +2928,12 @@ function render_list($path = '', $files = []) } else { $parent_url = $current_url; } - $BackArrow = str_replace('', $parent_url.'/', $tmp[0]); + $BackArrow = str_replace('', $parent_url . '/', $tmp[0]); } $html .= $BackArrow . $tmp[1]; $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -2991,7 +2943,7 @@ function render_list($path = '', $files = []) } else $html .= $tmp[1]; } $imgextstr = ''; - foreach ($exts['img'] as $imgext) $imgextstr .= '\''.$imgext.'\', '; + foreach ($exts['img'] as $imgext) $imgextstr .= '\'' . $imgext . '\', '; $html = str_replace('', $imgextstr, $html); @@ -3000,18 +2952,18 @@ function render_list($path = '', $files = []) $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); - $disktags = explode("|",getConfig('disktag')); - if (count($disktags)>1) { + $disktags = explode("|", getConfig('disktag')); + if (count($disktags) > 1) { $tmp1 = $tmp[1]; $tmp = splitfirst($tmp[0], ''); $MultiDiskArea = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MultiDisks = $tmp[0]; - foreach ($disktags as $disk) if ($_SERVER['admin']||getConfig('diskDisplay', $disk)=='') { + foreach ($disktags as $disk) if ($_SERVER['admin'] || getConfig('diskDisplay', $disk) == '') { $diskname = getConfig('diskname', $disk); - if ($diskname=='') $diskname = $disk; - $MultiDisksStr = str_replace('', path_format($_SERVER['base_path'].'/'.$disk.'/'), $MultiDisks); - $MultiDisksStr = str_replace('', ($_SERVER['disktag']==$disk?' now':''), $MultiDisksStr); + if ($diskname == '') $diskname = $disk; + $MultiDisksStr = str_replace('', path_format($_SERVER['base_path'] . '/' . $disk . '/'), $MultiDisks); + $MultiDisksStr = str_replace('', ($_SERVER['disktag'] == $disk ? ' now' : ''), $MultiDisksStr); $MultiDisksStr = str_replace('', $diskname, $MultiDisksStr); $MultiDiskArea .= $MultiDisksStr; } @@ -3020,7 +2972,7 @@ function render_list($path = '', $files = []) } $html .= $MultiDiskArea . $tmp[1]; $diskname = getConfig('diskname', $_SERVER['disktag']); - if ($diskname=='') $diskname = $_SERVER['disktag']; + if ($diskname == '') $diskname = $_SERVER['disktag']; //if (strlen($diskname)>15) $diskname = substr($diskname, 0, 12).'...'; while (strpos($html, '')) $html = str_replace('', $diskname, $html); @@ -3032,7 +2984,7 @@ function render_list($path = '', $files = []) } elseif (getConfig('globalHeadOmfUrl')) { if (!$headomfcontent = getcache('HeadomfContent')) { $headomfres = curl('GET', getConfig('globalHeadOmfUrl'), '', [], 0, 1); - if ($headomfres['stat']==200) { + if ($headomfres['stat'] == 200) { $headomfcontent = $headomfres['body']; savecache('HeadomfContent', $headomfcontent); } else $headomfcontent = $headomfres['stat']; @@ -3054,7 +3006,7 @@ function render_list($path = '', $files = []) } elseif (getConfig('globalHeadMdUrl')) { if (!$headmdcontent = getcache('HeadmdContent')) { $headmdres = curl('GET', getConfig('globalHeadMdUrl'), '', [], 0, 1); - if ($headmdres['stat']==200) { + if ($headmdres['stat'] == 200) { $headmdcontent = $headmdres['body']; savecache('HeadmdContent', $headmdcontent); } else $headmdcontent = $headmdres['stat']; @@ -3068,7 +3020,7 @@ function render_list($path = '', $files = []) } else { $html .= $tmp[1]; $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -3077,7 +3029,7 @@ function render_list($path = '', $files = []) } $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -3102,7 +3054,7 @@ function render_list($path = '', $files = []) } elseif (getConfig('globalReadmeMdUrl')) { if (!$readmemdcontent = getcache('ReadmemdContent')) { $readmemdres = curl('GET', getConfig('globalReadmeMdUrl'), '', [], 0, 1); - if ($readmemdres['stat']==200) { + if ($readmemdres['stat'] == 200) { $readmemdcontent = $readmemdres['body']; savecache('ReadmemdContent', $readmemdcontent); } else $readmemdcontent = $readmemdres['stat']; @@ -3116,7 +3068,7 @@ function render_list($path = '', $files = []) } else { $html .= $tmp[1]; $tmp[1] = 'a'; - while ($tmp[1]!='') { + while ($tmp[1] != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -3133,7 +3085,7 @@ function render_list($path = '', $files = []) } elseif (getConfig('globalFootOmfUrl')) { if (!$footomfcontent = getcache('FootomfContent')) { $footres = curl('GET', getConfig('globalFootOmfUrl'), '', [], 0, 1); - if ($footres['stat']==200) { + if ($footres['stat'] == 200) { $footomfcontent = $footres['body']; savecache('FootomfContent', $footomfcontent); } else $footomfcontent = $footres['stat']; @@ -3145,11 +3097,11 @@ function render_list($path = '', $files = []) $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); - if (isset($files['list']['head.md'])||isset($files['list']['readme.md'])||getConfig('globalHeadMdUrl')||getConfig('globalReadmeMdUrl')) { + if (isset($files['list']['head.md']) || isset($files['list']['readme.md']) || getConfig('globalHeadMdUrl') || getConfig('globalReadmeMdUrl')) { $html .= $tmp[0] . $tmp[1]; } else $html .= $tmp[1]; - if (getConfig('passfile')!='') { + if (getConfig('passfile') != '') { $tmp = splitfirst($html, ''); $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); @@ -3180,11 +3132,11 @@ function render_list($path = '', $files = []) $html = $tmp[0]; $tmp = splitfirst($tmp[1], ''); $MoveDirs = $tmp[0]; - if ($files['type']=='folder') { + if ($files['type'] == 'folder') { foreach ($files['list'] as $file) { - if ($file['type']=='folder') { - $MoveDirsStr = str_replace('', str_replace('&','&', $file['name']), $MoveDirs); - $MoveDirsStr = str_replace('', str_replace('&','&', $file['name']), $MoveDirsStr); + if ($file['type'] == 'folder') { + $MoveDirsStr = str_replace('', str_replace('&', '&', $file['name']), $MoveDirs); + $MoveDirsStr = str_replace('', str_replace('&', '&', $file['name']), $MoveDirsStr); $html .= $MoveDirsStr; } } @@ -3207,12 +3159,12 @@ function render_list($path = '', $files = []) $tmp['size'] = size_format($file['size']); $tmp['date'] = time_format($file['lastModifiedDateTime']); $tmp['@time'] = $file['date']; - $tmp['@type'] = ($file['type']=='folder')?'folder':'file'; - $str .= json_encode($tmp).','; + $tmp['@type'] = ($file['type'] == 'folder') ? 'folder' : 'file'; + $str .= json_encode($tmp) . ','; } if ($str == '[') { $str = ''; - } else $str = substr($str, 0, -1).']'; + } else $str = substr($str, 0, -1) . ']'; $html = str_replace('{{.RawData}}', base64_encode($str), $html); } @@ -3222,7 +3174,7 @@ function render_list($path = '', $files = []) //while (strpos($html, "\n\n")) $html = str_replace("\n\n", "\n", $html); //while (strpos($html, PHP_EOL.PHP_EOL)) $html = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $html); - $exetime = round(microtime(true)-$_SERVER['php_starttime'],3); + $exetime = round(microtime(true) - $_SERVER['php_starttime'], 3); //$ip2city = json_decode(curl('GET', 'http://ip.taobao.com/outGetIpInfo?ip=' . $_SERVER['REMOTE_ADDR'] . '&accessKey=alibaba-inc')['body'], true); //if ($ip2city['code']===0) $city = ' ' . $ip2city['data']['city']; $html = str_replace('', date("Y-m-d H:i:s") . " " . getconstStr('Week')[date("w")] . " " . $_SERVER['REMOTE_ADDR'] . $city . ' Runningtime:' . $exetime . 's Mem:' . size_format(memory_get_usage()), $html);
@@ -1732,19 +1688,19 @@ output:
'; - if ($key=='diskDisplay') { + if ($key == 'diskDisplay') { $frame .= ' ' . getconstStr('EnvironmentsDescription')[$key]; } elseif (isSwitchEnv($key)) { $frame .= ' ' . getconstStr('EnvironmentsDescription')[$key]; } else { @@ -1760,7 +1716,7 @@ output: } else { $frame .= '
' . ($disk_tmp->error['body']?$disk_tmp->error['stat'] . '
' . $disk_tmp->error['body']:'Add this disk again.') . '
' . ($disk_tmp->error['body'] ? $disk_tmp->error['stat'] . '
' . $disk_tmp->error['body'] : 'Add this disk again.') . '