edit/foto/cover: replace fatal exceptions by abort()
[minimedit.git] / edit / foto / cover / index.php
1 <?php
2 if (!$User->admin('foto')) {
3         abort("Beheerrechten verplicht voor instellen van covers", '403 unauthorised');
4 }
5
6 $rootdir = 'foto' . $Page->path;
7 $target = "$rootdir/index.jpg";
8
9 if (is_link($target) or file_exists($target)) {
10         if (!unlink($target)) {
11                 abort("Kon bestaande cover niet weghalen voor {$Page->path}", '500 delete error');
12         }
13 }
14
15 if (isset($_GET['img'])) {
16         $img = str_repeat('../', substr_count($target, '/')); # up to docroot
17         $img .= ltrim($_GET['img'], '/');
18         if (!symlink($img, $target)) {
19                 abort("Fout bij instellen van cover voor {$Page->path}", '500 link error');
20         }
21 }
22
23 $album = pathinfo($rootdir);
24 abort("/{$album['dirname']}#{$album['basename']}", '302 linked');