From 6f1e9bf3572d163b562e25fd678742514c34c65a Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 22 Mar 2020 15:31:29 +0800 Subject: [PATCH 1/4] fix bug in cache path --- function/common.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/function/common.php b/function/common.php index 6c57325..59b5e89 100644 --- a/function/common.php +++ b/function/common.php @@ -935,6 +935,7 @@ function MSAPI($method, $path, $data = '', $access_token) function fetch_files($path = '/') { global $exts; + if (substr($path,-1)=='/') $path=substr($path,0,-1); $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); if (!($files = getcache('path_' . $path))) { @@ -944,13 +945,13 @@ function fetch_files($path = '/') $pos = splitlast($path, '/'); $parentpath = $pos[0]; $filename = $pos[1]; - if ($parentfiles = getcache('path_' . $parentpath. '/')) { + if ($parentfiles = getcache('path_' . $parentpath)) { if (isset($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl'])) { if (in_array(splitlast($filename,'.')[1], $exts['txt'])) { if (!(isset($parentfiles['children'][$filename]['content'])&&$parentfiles['children'][$filename]['content']['stat']==200)) { $content1 = curl_request($parentfiles['children'][$filename]['@microsoft.graph.downloadUrl']); $parentfiles['children'][$filename]['content'] = $content1; - savecache('path_' . $parentpath. '/', $parentfiles); + savecache('path_' . $parentpath, $parentfiles); } } return $parentfiles['children'][$filename]; From c3f303138f4e227ee61ce588e24692d5ef7ac3de Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 22 Mar 2020 15:40:41 +0800 Subject: [PATCH 2/4] fix fix bug --- function/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/function/common.php b/function/common.php index 59b5e89..385e847 100644 --- a/function/common.php +++ b/function/common.php @@ -935,9 +935,9 @@ function MSAPI($method, $path, $data = '', $access_token) function fetch_files($path = '/') { global $exts; - if (substr($path,-1)=='/') $path=substr($path,0,-1); $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); + if (substr($path,-1)=='/') $path=substr($path,0,-1); if (!($files = getcache('path_' . $path))) { // https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0 // https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http From 247e608ce44a2106d968c6e812890085bdcde165 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 22 Mar 2020 15:50:21 +0800 Subject: [PATCH 3/4] fix fix fix bug.... --- function/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/function/common.php b/function/common.php index 385e847..2a9bd45 100644 --- a/function/common.php +++ b/function/common.php @@ -937,7 +937,7 @@ function fetch_files($path = '/') global $exts; $path1 = path_format($path); $path = path_format($_SERVER['list_path'] . path_format($path)); - if (substr($path,-1)=='/') $path=substr($path,0,-1); + if ($path!='/'&&substr($path,-1)=='/') $path=substr($path,0,-1); if (!($files = getcache('path_' . $path))) { // https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0 // https://docs.microsoft.com/zh-cn/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http From 7f5a3f35f59b27e7add0bbbff43a3e0c655f71e7 Mon Sep 17 00:00:00 2001 From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com> Date: Sun, 22 Mar 2020 16:00:26 +0800 Subject: [PATCH 4/4] Update onemoe.php --- theme/onemoe.php | 124 ++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 66 deletions(-) diff --git a/theme/onemoe.php b/theme/onemoe.php index a76d5c0..ea738b0 100644 --- a/theme/onemoe.php +++ b/theme/onemoe.php @@ -2,15 +2,18 @@ - <?php echo $pretitle;?> - <?php echo $_SERVER['sitename'];?> + <?php echo $pretitle; if ($_SERVER['base_disk_path']!=$_SERVER['base_path']) echo ' - ' . getConfig('diskname');?> - <?php echo $_SERVER['sitename'];?> + + @@ -28,7 +31,7 @@
  • -
  • +
  • + if (isset($_SERVER['needUpdate'])&&$_SERVER['needUpdate']) { ?>

    @@ -67,7 +70,20 @@ + if ($files) { + if (isset($files['children']['head.md'])) { ?> +
    +
    +
    +
    + +
    +
    +
    +
    +
    @@ -91,6 +107,8 @@
    @@ -113,8 +131,6 @@
    document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" /> '; @@ -160,12 +176,12 @@
    + if (isset($_POST['filenum'])) $filenum = $_POST['filenum']; + if (!isset($filenum) and isset($files['folder']['page'])) $filenum = ($files['folder']['page']-1)*200; + else $filenum = 0; ?> - + @@ -200,13 +216,7 @@ foreach ($files['children'] as $file) { // Files if (isset($file['file'])) { - if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getConfig('passfile') ) ) { - if (strtolower($file['name']) === 'head.md') $head = $file; - if (strtolower($file['name']) === 'readme.md') $readme = $file; - if (strtolower($file['name']) === 'index.html' && !$_SERVER['admin']) { - $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl'])['body']; - return output($html,200); - } + if ($_SERVER['admin'] or !isHideFile($file['name'])) { $filenum++; ?>
           
    @@ -307,25 +317,7 @@ echo 'Unknown path or file.'; echo json_encode($files, JSON_PRETTY_PRINT); } - if ($head) { - echo ' - - - -
    -
    -
    -
    - - -
    -'; - } - if ($readme) { + if (isset($files['children']['readme.md'])) { echo '
    @@ -334,11 +326,8 @@
    -
    - +
    '; @@ -364,7 +353,7 @@ + if (!isset($_GET['preview'])) { ?>