- commit
- 3a76fd7497b609e37cba40fd67d77ad250ac35e9
- parent
- 7548dd4a204b3bc963a42d440699060f1449af28
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-20 21:18
consistent naming
Diffstat
| M | index.php | 34 | +++++++++++++++++----------------- |
| M | templates/base.html | 4 | ++-- |
| R | templates/uploads.html -> templates/files.html | 2 | +- |
3 files changed, 20 insertions, 20 deletions
diff --git a/index.php b/index.php
@@ -193,33 +193,33 @@ class Pupupu 193 193 return $this->targetUrl . $path . '/'; 194 194 } 195 195196 -1 public function upload($path, $file)-1 196 public function uploadFile($path, $file) 197 197 { 198 198 $p = $this->targetDir . '/files' . $path . '/' . $file['name']; 199 199 mkdirp(dirname($p)); 200 200 move_uploaded_file($file['tmp_name'], $p); 201 201 } 202 202203 -1 public function uploadFolder($path, $name)-1 203 public function createFileFolder($path, $name) 204 204 { 205 205 $p = $this->targetDir . '/files' . $path . '/' . $name; 206 206 mkdirp($p); 207 207 } 208 208209 -1 public function getUploads($path)-1 209 public function getFiles($path) 210 210 {211 -1 $uploads = array();-1 211 $files = array(); 212 212 $p = $this->targetDir . '/files' . $path; 213 213 $u = $this->targetUrl . '/files' . $path; 214 214 foreach (scandir($p) as $name) { 215 215 if ($name === '..' && $path !== '') {216 -1 $uploads[] = array(-1 216 $files[] = array( 217 217 'name' => $name, 218 218 'path' => pathDirname($path), 219 219 'is_file' => false, 220 220 ); 221 221 } elseif ($name !== '.' && $name !== '..') {222 -1 $uploads[] = array(-1 222 $files[] = array( 223 223 'name' => $name, 224 224 'path' => "$path/$name", 225 225 'url' => "$u/$name", @@ -228,10 +228,10 @@ class Pupupu 228 228 ); 229 229 } 230 230 }231 -1 return $uploads;-1 231 return $files; 232 232 } 233 233234 -1 public function rmUpload($path)-1 234 public function rmFile($path) 235 235 { 236 236 rmr($this->targetDir . '/files' . $path); 237 237 } @@ -298,22 +298,22 @@ function pagesView($pupupu, $twig) 298 298 )); 299 299 } 300 300301 -1 function uploadView($pupupu, $twig)-1 301 function filesView($pupupu, $twig) 302 302 {303 -1 $path = validatePath(substr($_GET['path'], 8));-1 303 $path = validatePath(substr($_GET['path'], 6)); 304 304 305 305 if ($_SERVER['REQUEST_METHOD'] == 'GET') {306 -1 echo $twig->render('uploads.html', array(307 -1 'files' => $pupupu->getUploads($path),-1 306 echo $twig->render('files.html', array( -1 307 'files' => $pupupu->getFiles($path), 308 308 )); 309 309 } elseif (isset($_FILES['file'])) {310 -1 $pupupu->upload($path, $_FILES['file']);-1 310 $pupupu->uploadFile($path, $_FILES['file']); 311 311 header("Location: ", true, 302); 312 312 } elseif (isset($_POST['folder'])) {313 -1 $pupupu->uploadFolder($path, $_POST['folder']);-1 313 $pupupu->createFileFolder($path, $_POST['folder']); 314 314 header("Location: ", true, 302); 315 315 } elseif (isset($_POST['delete'])) {316 -1 $pupupu->rmUpload($path . '/' . $_POST['name']);-1 316 $pupupu->rmFile($path . '/' . $_POST['name']); 317 317 header("Location: ", true, 302); 318 318 } else { 319 319 http_response_code(400); @@ -377,8 +377,8 @@ if (isset($_SERVER['REQUEST_METHOD'])) { 377 377 pagesView($pupupu, $twig); 378 378 } elseif ($_GET['path'] === '_site') { 379 379 siteView($pupupu, $twig);380 -1 } elseif (substr($_GET['path'], 0, 8) === '_uploads') {381 -1 uploadView($pupupu, $twig);-1 380 } elseif (substr($_GET['path'], 0, 6) === '_files') { -1 381 filesView($pupupu, $twig); 382 382 } else { 383 383 pageView($pupupu, $twig); 384 384 }
diff --git a/templates/base.html b/templates/base.html
@@ -12,8 +12,8 @@ 12 12 <header> 13 13 <nav> 14 14 <a href="?">{{ 'pages'|trans }}</a>15 -1 <a href="?path=_uploads">{{ 'uploads'|trans }}</a>16 -1 <a href="?path=_site">{{ 'config'|trans }}</a>-1 15 <a href="?path=_files">{{ 'files'|trans }}</a> -1 16 <a href="?path=_site">{{ 'site'|trans }}</a> 17 17 </nav> 18 18 </header> 19 19
diff --git a/templates/uploads.html b/templates/files.html
@@ -13,7 +13,7 @@ 13 13 <a href="{{ file.url }}" target="_blank" class="file-list__main">{{ file.name }}</a> 14 14 {% else %} 15 15 <img src="static/folder.png" class="file-list__icon" alt="{{ 'folder'|trans }}">16 -1 <a href="?path=_uploads{{ file.path }}" class="file-list__main">{{ file.name }}/</a>-1 16 <a href="?path=_files{{ file.path }}" class="file-list__main">{{ file.name }}/</a> 17 17 {% endif %} 18 18 19 19 {% if file.name != '..' %}