auth: admin permissions per function
[minimedit.git] / edit / foto / cover / index.php
1 <?php
2 ob_clean();
3
4 if (!$User or !$User->admin('foto')) {
5         http_response_code(403);
6         print "Beheerrechten verplicht voor instellen van covers\n";
7         exit;
8 }
9
10 $rootdir = 'foto' . $Args;
11 $target = "$rootdir/index.jpg";
12
13 if (is_link($target) or file_exists($target)) {
14         if (!unlink($target)) {
15                 http_response_code(500);
16                 print "Kon bestaande cover niet weghalen voor $Args\n";
17                 exit;
18         }
19 }
20
21 if (isset($_GET['img'])) {
22         $img = str_repeat('../', substr_count($target, '/')); # up to docroot
23         $img .= ltrim($_GET['img'], '/');
24         if (!symlink($img, $target)) {
25                 http_response_code(500);
26                 print "Fout bij instellen van cover voor $Args\n";
27                 exit;
28         }
29 }
30
31 $album = pathinfo($rootdir);
32 header("Location: /{$album['dirname']}#{$album['basename']}");
33 http_response_code(302);