diff --git a/index.php b/index.php index 7617da1..6c6b3b8 100644 --- a/index.php +++ b/index.php @@ -16,7 +16,7 @@ $sendHeaders = array(); foreach ($re['headers'] as $headerName => $headerVal) { header($headerName . ': ' . $headerVal, true); } -//http_response_code($re['statusCode']); +http_response_code($re['statusCode']); echo $re['body']; function main() @@ -129,7 +129,7 @@ function main() if ($_SERVER['ishidden']<4) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]); } if ( isset($files['folder']) || isset($files['file']) ) { - //return render_list($path, $files); + return render_list($path, $files); } else { return output('
' . $files['error']['message'] . '
', 404); } @@ -581,3 +581,1177 @@ function fetch_files_children($files, $path, $page, $cache) } return $files; } + +function render_list($path, $files) +{ + global $exts; + global $constStr; + @ob_start(); + $path = str_replace('%20','%2520',$path); + $path = str_replace('+','%2B',$path); + $path = str_replace('&','&',path_format(urldecode($path))) ; + $path = str_replace('%20',' ',$path); + $path = str_replace('#','%23',$path); + $p_path=''; + if ($path !== '/') { + if (isset($files['file'])) { + $pretitle = str_replace('&','&', $files['name']); + $n_path=$pretitle; + } else { + $pretitle = substr($path,-1)=='/'?substr($path,0,-1):$path; + $n_path=substr($pretitle,strrpos($pretitle,'/')+1); + $pretitle = substr($pretitle,1); + } + if (strrpos($path,'/')!=0) { + $p_path=substr($path,0,strrpos($path,'/')); + $p_path=substr($p_path,strrpos($p_path,'/')+1); + } + } else { + $pretitle = $constStr['Home'][$constStr['language']]; + $n_path=$pretitle; + } + $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($_COOKIE['timezone'])); +?> + + + + <?php echo $pretitle;?> - <?php echo $_SERVER['sitename'];?> + + + + + + + + + + + + + + +
  • + + + +
    + +

    + +

    +
    +
    +
    + + + + + +

    +
    +
    + +
    +
    + + +
    +
    +' . $files['error']['message'] . '
    '; + $statusCode=404; + } else { + if (isset($files['file'])) { +?> +
    +
    + +   +
    +
    +document.getElementById(\'url\').offsetWidth) this.style.width=\'100%\';" /> +'; + } elseif (in_array($ext, $exts['video'])) { + //echo ''; + $DPvideo=$files['@microsoft.graph.downloadUrl']; + echo '
    '; + } elseif (in_array($ext, $exts['music'])) { + echo ' + +'; + } elseif (in_array($ext, ['pdf'])) { + echo ' + +'; + } elseif (in_array($ext, $exts['office'])) { + echo ' + +'; + } elseif (in_array($ext, $exts['txt'])) { + $txtstr = htmlspecialchars(curl_request($files['@microsoft.graph.downloadUrl'])); +?> +
    + +
    + + + + +'; ?> +
    + + +
    +'; + } else { + echo ''.$constStr['FileNotSupport'][$constStr['language']].''; + } ?> +
    +
    + + + + + + + + + + + + + + +'; + foreach ($files['children'] as $file) { + // Files + if (isset($file['file'])) { + if ($_SERVER['admin'] or (substr($file['name'],0,1) !== '.' and $file['name'] !== getenv('passfile') ) ) { + if (strtolower($file['name']) === 'readme.md') $readme = $file; + if (strtolower($file['name']) === 'index.html') { + $html = curl_request(fetch_files(spurlencode(path_format($path . '/' .$file['name']),'/'))['@microsoft.graph.downloadUrl']); + return output($html,200); + } + $filenum++; ?> + + + + + + +
       
    + +
  • +
      +
    • +
    • +
    • +
    • +
    +
  •     + + + +
    + +
  • +
      +
    • +
    • +
    • +
    +
  •     + + + + + + + + + + + + + + + + + + + + + + + +
    +200) { + $pagenum = $files['folder']['page']; + $maxpage = ceil($files['folder']['childCount']/200); + $prepagenext = ' + + + + + + + + +
    '; + if ($pagenum!=1) { + $prepagenum = $pagenum-1; + $prepagenext .= ' + '.$constStr['PrePage'][$constStr['language']].''; + } + $prepagenext .= ' + '; + for ($page=1;$page<=$maxpage;$page++) { + if ($page == $pagenum) { + $prepagenext .= ' + ' . $page . ' '; + } else { + $prepagenext .= ' + ' . $page . ' '; + } + } + $prepagenext = substr($prepagenext,0,-1); + $prepagenext .= ' + '; + if ($pagenum!=$maxpage) { + $nextpagenum = $pagenum+1; + $prepagenext .= ' + '.$constStr['NextPage'][$constStr['language']].''; + } + $prepagenext .= ' +
    + '; + echo $prepagenext; + } + if ($_SERVER['admin']) { ?> +
    +
    + + +
    +
    + +
    + +
    +
    +
    +
    + + '.$readme['name'].' +
    + +
    +
    +'; + } + } + } else { + echo ' +
    +
    +
    + + +
    +
    +
    '; + $statusCode = 401; + } + } ?> +
    +
    +
    + + +
    + + + + + +
    + + + + + + + + + + + + + $_SERVER['Set-Cookie'], 'Content-Type' => 'text/html' ]); + return output($html,$statusCode); +}