edit/foto/cover: replace fatal exceptions by abort()
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 26 Oct 2018 18:48:48 +0000 (20:48 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 30 Dec 2020 23:22:16 +0000 (00:22 +0100)
Code cleanup, identical behaviour.

edit/foto/cover/index.php

index 06acc1d22c0e586b6510b42e203c161942b1db47..6e59e85d053924c4302837c8de0b9868f0d2db32 100644 (file)
@@ -1,8 +1,6 @@
 <?php
 if (!$User->admin('foto')) {
-       http_response_code(403);
-       print "Beheerrechten verplicht voor instellen van covers\n";
-       exit;
+       abort("Beheerrechten verplicht voor instellen van covers", '403 unauthorised');
 }
 
 $rootdir = 'foto' . $Page->path;
@@ -10,9 +8,7 @@ $target = "$rootdir/index.jpg";
 
 if (is_link($target) or file_exists($target)) {
        if (!unlink($target)) {
-               http_response_code(500);
-               print "Kon bestaande cover niet weghalen voor {$Page->path}\n";
-               exit;
+               abort("Kon bestaande cover niet weghalen voor {$Page->path}", '500 delete error');
        }
 }
 
@@ -20,13 +16,9 @@ if (isset($_GET['img'])) {
        $img = str_repeat('../', substr_count($target, '/')); # up to docroot
        $img .= ltrim($_GET['img'], '/');
        if (!symlink($img, $target)) {
-               http_response_code(500);
-               print "Fout bij instellen van cover voor {$Page->path}\n";
-               exit;
+               abort("Fout bij instellen van cover voor {$Page->path}", '500 link error');
        }
 }
 
 $album = pathinfo($rootdir);
-header("Location: /{$album['dirname']}#{$album['basename']}");
-http_response_code(302);
-exit;
+abort("/{$album['dirname']}#{$album['basename']}", '302 linked');