customTheme (url)

pull/72/head
qkqpttgf 2020-05-24 15:07:56 +08:00 committed by GitHub
parent b3c61d22d3
commit 8d961d72de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 50 additions and 21 deletions

View File

@ -18,6 +18,7 @@ $Base64Env = [
'sitename', 'sitename',
'customScript', 'customScript',
'customCss', 'customCss',
'customTheme',
//'theme', //'theme',
//'Drive_ver', //'Drive_ver',
//'Drive_custom', //'Drive_custom',
@ -52,6 +53,7 @@ $CommonEnv = [
'sitename', 'sitename',
'customScript', 'customScript',
'customCss', 'customCss',
'customTheme',
'theme', 'theme',
]; ];
@ -71,6 +73,7 @@ $ShowedCommonEnv = [
'sitename', 'sitename',
'customScript', 'customScript',
'customCss', 'customCss',
'customTheme',
'theme', 'theme',
]; ];
@ -175,8 +178,6 @@ function main($path)
$_SERVER['timezone'] = getConfig('timezone'); $_SERVER['timezone'] = getConfig('timezone');
if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone']; if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone'];
if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0; if ($_SERVER['timezone']=='') $_SERVER['timezone'] = 0;
if (isset($_COOKIE['theme'])&&$_COOKIE['theme']!='') $_SERVER['theme'] = $_COOKIE['theme'];
else $_SERVER['theme'] = getConfig('theme');
$_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path); $_SERVER['PHP_SELF'] = path_format($_SERVER['base_path'] . $path);
if (getConfig('admin')=='') return install(); if (getConfig('admin')=='') return install();
@ -989,6 +990,7 @@ function adminoperate($path)
$path1 = path_format($_SERVER['list_path'] . path_format($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);
savecache('path_' . $path1 . '/?password', '', 1); savecache('path_' . $path1 . '/?password', '', 1);
savecache('customTheme', '', 1);
return message('<meta http-equiv="refresh" content="2;URL=./">', getconstStr('RefreshCache'), 302); return message('<meta http-equiv="refresh" content="2;URL=./">', getconstStr('RefreshCache'), 302);
} }
return $tmparr; return $tmparr;
@ -1750,18 +1752,40 @@ function render_list($path = '', $files = '')
Github: https://github.com/qkqpttgf/OneManager-php Github: https://github.com/qkqpttgf/OneManager-php
-->'; -->';
//$theme = getConfig('theme');
$theme = $_SERVER['theme']; if (isset($_COOKIE['theme'])&&$_COOKIE['theme']!='') $theme = $_COOKIE['theme'];
if ( $theme=='' || !file_exists('theme/'.$theme) ) $theme = 'classic.html'; if ( $theme=='' ) {
$tmp = getConfig('customTheme');
if ( $tmp!='' ) $theme = $tmp;
}
if ( $theme=='' ) {
$theme = getConfig('theme');
if ( $theme=='' || !file_exists('theme/'.$theme) ) $theme = 'classic.html';
}
if (substr($theme,-4)=='.php') { if (substr($theme,-4)=='.php') {
@ob_start(); @ob_start();
include 'theme/'.$theme; include 'theme/'.$theme;
$html = ob_get_clean(); $html = ob_get_clean();
} else { } else {
$file_path = 'theme/'.$theme; if (file_exists('theme/'.$theme)) {
$fp = fopen($file_path,"r"); $file_path = 'theme/'.$theme;
$html = fread($fp,filesize($file_path)); $html = file_get_contents($file_path);
fclose($fp); } else {
if (!($html = getcache('customTheme'))) {
$file_path = $theme;
$tmp = curl_request($file_path, false, [], 1);
if ($tmp['stat']==302) {
error_log(json_encode($tmp));
$tmp = curl_request($tmp["returnhead"]["Location"]);
}
if (!!$tmp['body']) $html = $tmp['body'];
savecache('customTheme', $html, 9999);
}
}
//$fp = fopen($file_path,"r");
//$html = fread($fp,filesize($file_path));
//fclose($fp);
$tmp = splitfirst($html, '<!--IconValuesStart-->'); $tmp = splitfirst($html, '<!--IconValuesStart-->');
$html = $tmp[0]; $html = $tmp[0];
@ -2009,17 +2033,19 @@ function render_list($path = '', $files = '')
//$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&amp;', $file['name'])), $FolderListStr); //$FolderListStr = str_replace('<!--FileEncodeReplaceUrl-->', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&amp;', $file['name'])), $FolderListStr);
$FolderListStr = str_replace('<!--lastModifiedDateTime-->', time_format($file['lastModifiedDateTime']), $FolderListStr); $FolderListStr = str_replace('<!--lastModifiedDateTime-->', time_format($file['lastModifiedDateTime']), $FolderListStr);
$FolderListStr = str_replace('<!--size-->', size_format($file['size']), $FolderListStr); $FolderListStr = str_replace('<!--size-->', size_format($file['size']), $FolderListStr);
foreach ($IconValues as $key1 => $value1) { if (!!$IconValues) {
if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) { foreach ($IconValues as $key1 => $value1) {
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr); if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) {
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr);
}
if ($ext==$key1) {
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr);
}
//error_log('file:'.$file['name'].':'.$key1);
if (!strpos($FolderListStr, '<!--IconValue-->')) break;
} }
if ($ext==$key1) { if (strpos($FolderListStr, '<!--IconValue-->')) $FolderListStr = str_replace('<!--IconValue-->', $IconValues['default'], $FolderListStr);
$FolderListStr = str_replace('<!--IconValue-->', $value1, $FolderListStr);
}
//error_log('file:'.$file['name'].':'.$key1);
if (!strpos($FolderListStr, '<!--IconValue-->')) break;
} }
if (strpos($FolderListStr, '<!--IconValue-->')) $FolderListStr = str_replace('<!--IconValue-->', $IconValues['default'], $FolderListStr);
while (strpos($FolderListStr, '<!--filenum-->')) $FolderListStr = str_replace('<!--filenum-->', $filenum, $FolderListStr); while (strpos($FolderListStr, '<!--filenum-->')) $FolderListStr = str_replace('<!--filenum-->', $filenum, $FolderListStr);
$html .= $FolderListStr; $html .= $FolderListStr;
} }
@ -2236,7 +2262,7 @@ function render_list($path = '', $files = '')
$folder1 = $tmp1[0]; $folder1 = $tmp1[0];
if ($folder1!='') { if ($folder1!='') {
$tmp_url .= $folder1 . '/'; $tmp_url .= $folder1 . '/';
$PathArrayStr1 = str_replace('<!--PathArrayLink-->', $tmp_url, $PathArrayStr); $PathArrayStr1 = str_replace('<!--PathArrayLink-->', (isset($files['file'])?'':$tmp_url), $PathArrayStr);
$PathArrayStr1 = str_replace('<!--PathArrayName-->', $folder1, $PathArrayStr1); $PathArrayStr1 = str_replace('<!--PathArrayName-->', $folder1, $PathArrayStr1);
$html .= $PathArrayStr1; $html .= $PathArrayStr1;
} }
@ -2321,7 +2347,7 @@ function render_list($path = '', $files = '')
$html .= $MultiDiskArea . $tmp[1]; $html .= $MultiDiskArea . $tmp[1];
$diskname = getConfig('diskname'); $diskname = getConfig('diskname');
if ($diskname=='') $diskname = $_SERVER['disktag']; if ($diskname=='') $diskname = $_SERVER['disktag'];
if (strlen($diskname)>10) $diskname = substr($diskname, 0, 7).'...'; if (strlen($diskname)>15) $diskname = substr($diskname, 0, 12).'...';
while (strpos($html, '<!--DiskNameNow-->')) $html = str_replace('<!--DiskNameNow-->', $diskname, $html); while (strpos($html, '<!--DiskNameNow-->')) $html = str_replace('<!--DiskNameNow-->', $diskname, $html);
$tmp = splitfirst($html, '<!--HeadomfStart-->'); $tmp = splitfirst($html, '<!--HeadomfStart-->');
@ -2467,8 +2493,11 @@ function render_list($path = '', $files = '')
<option value="">'.getconstStr('Theme').'</option>'; <option value="">'.getconstStr('Theme').'</option>';
foreach ($theme_arr as $v1) { foreach ($theme_arr as $v1) {
if ($v1!='.' && $v1!='..') $html .= ' if ($v1!='.' && $v1!='..') $html .= '
<option value="'.$v1.'" '.($v1==$_SERVER['theme']?'selected="selected"':'').'>'.$v1.'</option>'; <option value="'.$v1.'" '.($v1==$theme?'selected="selected"':'').'>'.$v1.'</option>';
} }
//$tmp = getConfig('customTheme');
//if ($tmp!='') $html .= '
// <option value="" '.($tmp==$theme?'selected="selected"':'').'>customTheme</option>';
$html .= ' $html .= '
</select> </select>
</div> </div>