From 399fedbdf08d52b268480f7005aba95885a2c9f3 Mon Sep 17 00:00:00 2001 From: Jincheng Lu Date: Mon, 16 May 2022 12:05:32 +0000 Subject: [PATCH] displayed folder content --- README.md | 8 ++++---- index.php | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e9df716..30315eb 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Installation -1. First assign the `$share_url` variable with your onedrive share link. example: `$share_url = "";` -2. Place index.php file inside the DocumentRoot folder of apache or nginx. Make sure php is enabled.. +1. First assign the `$share_url` variable with your onedrive share link. Example: `$share_url = "";` +2. Place index.php file inside the DocumentRoot folder of apache or nginx. Make sure php is enabled. 3. You need to redirect all routes to the index.php file and put the path in a parameter called path. * If you are using apache, you can add following rewrite rules in your virualhost config file: --- RewriteEngine on RewriteRule ^(.*)$ /index.php?path=$1 [PT,L,QSA] - --- * If you are using nginx, please search the equivalent configuration on the internet --- - --- \ No newline at end of file +# Resource +https://docs.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http#encoding-sharing-urls \ No newline at end of file diff --git a/index.php b/index.php index c99820d..ed55582 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ " . substr($path, 1) . " does not exists!"; + echo "

" . ($result['pathvalid'] ? ($result['isfolder'] ? "Index of " . $path : ("the download link to file is: " . $result['data']['@content.downloadUrl'])) : "Path not valid") . "

" . PHP_EOL; + echo "
"; + if ($result['pathvalid'] && $result['isfolder']) { + $data = $result['data']; + echo "
"; + if ($path != "/") { + echo "

" . "" . + "\"back" . + " " . "
" . "Parent Directory" . "
" . "
" . "

" . PHP_EOL; + } + foreach ($data['children'] as $item) { + echo "

" . "" . + (isset($item['folder']) ? + "\"folder" + : + "\"file" + ) . + " " . "
" . $item['name'] . "
" . "
" . "

" . PHP_EOL; + } + echo "
"; + } ?> - + \ No newline at end of file