From 8d961d72de4d7cb7793d98d7eb49fddb52bd18f2 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 24 May 2020 15:07:56 +0800 Subject: [PATCH 01/14] customTheme (url) --- common.php | 71 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/common.php b/common.php index a8e8f63..6bb25db 100644 --- a/common.php +++ b/common.php @@ -18,6 +18,7 @@ $Base64Env = [ 'sitename', 'customScript', 'customCss', + 'customTheme', //'theme', //'Drive_ver', //'Drive_custom', @@ -52,6 +53,7 @@ $CommonEnv = [ 'sitename', 'customScript', 'customCss', + 'customTheme', 'theme', ]; @@ -71,6 +73,7 @@ $ShowedCommonEnv = [ 'sitename', 'customScript', 'customCss', + 'customTheme', 'theme', ]; @@ -175,8 +178,6 @@ function main($path) $_SERVER['timezone'] = getConfig('timezone'); if (isset($_COOKIE['timezone'])&&$_COOKIE['timezone']!='') $_SERVER['timezone'] = $_COOKIE['timezone']; 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); if (getConfig('admin')=='') return install(); @@ -989,6 +990,7 @@ function adminoperate($path) $path1 = path_format($_SERVER['list_path'] . path_format($path)); if ($path1!='/'&&substr($path1,-1)=='/') $path1=substr($path1,0,-1); savecache('path_' . $path1 . '/?password', '', 1); + savecache('customTheme', '', 1); return message('', getconstStr('RefreshCache'), 302); } return $tmparr; @@ -1750,18 +1752,40 @@ function render_list($path = '', $files = '') Github: https://github.com/qkqpttgf/OneManager-php -->'; - //$theme = getConfig('theme'); - $theme = $_SERVER['theme']; - if ( $theme=='' || !file_exists('theme/'.$theme) ) $theme = 'classic.html'; + + if (isset($_COOKIE['theme'])&&$_COOKIE['theme']!='') $theme = $_COOKIE['theme']; + 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') { @ob_start(); include 'theme/'.$theme; $html = ob_get_clean(); } else { - $file_path = 'theme/'.$theme; - $fp = fopen($file_path,"r"); - $html = fread($fp,filesize($file_path)); - fclose($fp); + if (file_exists('theme/'.$theme)) { + $file_path = 'theme/'.$theme; + $html = file_get_contents($file_path); + } 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, ''); $html = $tmp[0]; @@ -2009,17 +2033,19 @@ function render_list($path = '', $files = '') //$FolderListStr = str_replace('', path_format($_SERVER['base_disk_path'] . '/' . $path . '/' . str_replace('&','&', $file['name'])), $FolderListStr); $FolderListStr = str_replace('', time_format($file['lastModifiedDateTime']), $FolderListStr); $FolderListStr = str_replace('', size_format($file['size']), $FolderListStr); - foreach ($IconValues as $key1 => $value1) { - if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) { - $FolderListStr = str_replace('', $value1, $FolderListStr); + if (!!$IconValues) { + foreach ($IconValues as $key1 => $value1) { + if (isset($exts[$key1])&&in_array($ext, $exts[$key1])) { + $FolderListStr = str_replace('', $value1, $FolderListStr); + } + if ($ext==$key1) { + $FolderListStr = str_replace('', $value1, $FolderListStr); + } + //error_log('file:'.$file['name'].':'.$key1); + if (!strpos($FolderListStr, '')) break; } - if ($ext==$key1) { - $FolderListStr = str_replace('', $value1, $FolderListStr); - } - //error_log('file:'.$file['name'].':'.$key1); - if (!strpos($FolderListStr, '')) break; + if (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $IconValues['default'], $FolderListStr); } - if (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $IconValues['default'], $FolderListStr); while (strpos($FolderListStr, '')) $FolderListStr = str_replace('', $filenum, $FolderListStr); $html .= $FolderListStr; } @@ -2236,7 +2262,7 @@ function render_list($path = '', $files = '') $folder1 = $tmp1[0]; if ($folder1!='') { $tmp_url .= $folder1 . '/'; - $PathArrayStr1 = str_replace('', $tmp_url, $PathArrayStr); + $PathArrayStr1 = str_replace('', (isset($files['file'])?'':$tmp_url), $PathArrayStr); $PathArrayStr1 = str_replace('', $folder1, $PathArrayStr1); $html .= $PathArrayStr1; } @@ -2321,7 +2347,7 @@ function render_list($path = '', $files = '') $html .= $MultiDiskArea . $tmp[1]; $diskname = getConfig('diskname'); 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, '')) $html = str_replace('', $diskname, $html); $tmp = splitfirst($html, ''); @@ -2467,8 +2493,11 @@ function render_list($path = '', $files = '') '; foreach ($theme_arr as $v1) { if ($v1!='.' && $v1!='..') $html .= ' - '; + '; } + //$tmp = getConfig('customTheme'); + //if ($tmp!='') $html .= ' + // '; $html .= ' From ad14918cd7ae42415ed644d0cdb37dbba9c5141e Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 24 May 2020 15:14:58 +0800 Subject: [PATCH 02/14] echo Path in php --- theme/classic.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/theme/classic.html b/theme/classic.html index a9db090..efebcb5 100644 --- a/theme/classic.html +++ b/theme/classic.html @@ -151,7 +151,7 @@ -

+

/

@@ -480,7 +480,7 @@ location.href = location.href; } - var root = ''; + /*var root = ''; function path_format(path) { path = '/' + path + '/'; while (path.indexOf('//') !== -1) { @@ -500,7 +500,7 @@ } e.innerHTML += paths[paths.length - 1]; e.innerHTML = e.innerHTML.replace(/\s\/\s$/, '') - }); + });*/ var $url = document.getElementById('url'); if ($url) { From 0da8412119f20c0ba21ab53ca2d65235c314b302 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 24 May 2020 15:31:35 +0800 Subject: [PATCH 03/14] customTheme --- conststr.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conststr.php b/conststr.php index 9be638a..7a37eef 100644 --- a/conststr.php +++ b/conststr.php @@ -68,6 +68,7 @@ $constStr = [ 'adminloginpage' => 'if set, the Login button will not display, and the login page no longer \'?admin\', it is \'?{this value}\'.', 'customScript' => ' + @@ -196,6 +194,7 @@     +   @@ -220,7 +219,7 @@ - + @@ -606,29 +605,37 @@ function showthumbnails(obj) { + images = []; var files=document.getElementsByName('filelist'); for ($i=0;$i]; - if (images.indexOf(ext)>-1) get_thumbnails_url(str, files[$i]); + if (images.indexOf(ext)>-1) { + if (document.getElementById('originalpic').checked==true) { + var url=files[$i].href; + url=url.substr(0,url.length-8); + files[$i].parentNode.parentNode.innerHTML=''+str+''; + $i--; + } else { + var nurl=window.location.href; + if (nurl.substr(-1)!="/") nurl+="/"; + var url=nurl+str+'?thumbnails'; + get_thumbnails_url(url, str, files[$i]); + } + } } obj.disabled='disabled'; } - function get_thumbnails_url(str, filea) { - if (!str) return; - var nurl=window.location.href; - if (nurl.substr(-1)!="/") nurl+="/"; + function get_thumbnails_url(url, name, filea) { var xhr = new XMLHttpRequest(); - xhr.open("GET", nurl+str+'?thumbnails', true); - //xhr.setRequestHeader('x-requested-with','XMLHttpRequest'); + xhr.open("GET", url, true); xhr.send(''); xhr.onload = function(e){ if (xhr.status==200) { - if (xhr.responseText!='') filea.innerHTML=''+str+''; + if (xhr.responseText!='') filea.innerHTML=''+name+''; } else console.log(xhr.status+'\n'+xhr.responseText); } } From f5c7e1e2b5e2a384abc3a506c4950c0fac5381cd Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 24 May 2020 19:05:18 +0800 Subject: [PATCH 10/14] Update nexmoe1.html --- theme/nexmoe1.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/theme/nexmoe1.html b/theme/nexmoe1.html index b31abe3..fd296ba 100644 --- a/theme/nexmoe1.html +++ b/theme/nexmoe1.html @@ -289,7 +289,9 @@
+ format_list_bulleted + '; From 0cea4dee5ef525e05a53df959bd221112a2e3e2c Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 24 May 2020 19:17:52 +0800 Subject: [PATCH 13/14] Update conststr.php --- conststr.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conststr.php b/conststr.php index e578389..a519638 100644 --- a/conststr.php +++ b/conststr.php @@ -72,6 +72,7 @@ $constStr = [ 'domain_path' => 'more custom domain, format is a1.com:/dirto/path1|b2.com:/path2', 'diskname' => 'The disk name you want show.', 'disktag' => 'A tag used in store config and url.', + 'disableShowThumb' => 'if 1, the ShowThumbnail button will not display', 'downloadencrypt' => '0 or 1. if 1, the files in encrypt folder can be downloaded without password', 'background' => 'Set an url as background photo.', 'theme' => 'Select theme.', @@ -92,6 +93,7 @@ $constStr = [ 'domain_path' => '使用多个自定义域名时,指定每个域名看到的目录。格式为a1.com:/dirto/path1|b1.com:/path2,比private_path优先。', 'diskname' => '这个盘你想显示什么名称。', 'disktag' => '一个标签,用于保存配置,多盘时会显示在url中。', + 'disableShowThumb' => '如果填 1, ‘显示缩略’按钮将被隐藏。', 'downloadencrypt' => '0 或 1。如果 1, 那加密目录内的文件可以不需要密码就能下载。', 'background' => '设置一个url作为背景。', 'theme' => '选择一个主题。', From 6a616eca6bdc47b249533e3f6cfd3d07f7466c59 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 24 May 2020 20:08:36 +0800 Subject: [PATCH 14/14] fix: in preview, parent folders url error --- common.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common.php b/common.php index fa39ac7..f694199 100644 --- a/common.php +++ b/common.php @@ -368,7 +368,7 @@ function get_access_token($refresh_token) error_log('failed to get share access_token. response' . json_encode($ret)); throw new Exception($response['stat'].', failed to get share access_token.'.$response['body']); } - error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); + error_log('['.$_SERVER['disktag'].'] Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); savecache('access_token', $_SERVER['access_token']); $tmp = []; $tmp['shareapiurl'] = $_SERVER['api_url']; @@ -378,10 +378,10 @@ function get_access_token($refresh_token) if ($response['stat']==200) $ret = json_decode($response['body'], true); if (!isset($ret['access_token'])) { error_log($_SERVER['oauth_url'] . 'token'.'?client_id='. $_SERVER['client_id'] .'&client_secret='. $_SERVER['client_secret'] .'&grant_type=refresh_token&requested_token_use=on_behalf_of&refresh_token=' . $refresh_token); - error_log('failed to get access_token. response' . json_encode($ret)); - throw new Exception($response['stat'].', failed to get access_token.'.$response['body']); + error_log('failed to get ['.$_SERVER['disktag'].'] access_token. response' . json_encode($ret)); + throw new Exception($response['stat'].', failed to get ['.$_SERVER['disktag'].'] access_token.'.$response['body']); } - error_log('Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); + error_log('['.$_SERVER['disktag'].'] Get access token:'.json_encode($ret, JSON_PRETTY_PRINT)); $_SERVER['access_token'] = $ret['access_token']; savecache('access_token', $_SERVER['access_token'], $ret['expires_in'] - 300); if (time()>getConfig('token_expires')) setConfig([ 'refresh_token' => $ret['refresh_token'], 'token_expires' => time()+7*24*60*60 ]); @@ -2274,7 +2274,7 @@ function render_list($path = '', $files = '') $folder1 = $tmp1[0]; if ($folder1!='') { $tmp_url .= $folder1 . '/'; - $PathArrayStr1 = str_replace('', (isset($files['file'])?'':$tmp_url), $PathArrayStr); + $PathArrayStr1 = str_replace('', ($folder1==$files['name']?'':$tmp_url), $PathArrayStr); $PathArrayStr1 = str_replace('', $folder1, $PathArrayStr1); $html .= $PathArrayStr1; }