Passed
Push — master ( cd4615...b1d497 )
by Michael
02:16
created

hook-thumb.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * ExtGallery User area
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   {@link https://xoops.org/ XOOPS Project}
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Zoullou (http://www.zoullou.net)
15
 * @package     ExtGallery
16
 */
17
18
19
use XoopsModules\Extgallery;
20
21
include __DIR__ . '/header.php';
22
//require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php';
23
24
25
$photoId = \Xmf\Request::getInt('id', 0, 'GET');
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
/** @var Extgallery\PublicPhotoHandler $photoHandler */
28
/** @var Extgallery\Photo $photo */
29
$photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
30
$photo        = $photoHandler->get($photoId);
31
32
switch (strtolower(strrchr($photo->getVar('photo_name'), '.'))) {
33
    case '.png':
34
        $type = 'image/png';
35
        break;
36
    case '.gif':
37
        $type = 'image/gif';
38
        break;
39
    case '.jpg':
40
        $type = 'image/jpeg';
41
        break;
42
    default:
43
        $type = 'application/octet-stream';
44
        break;
45
}
46
47
$permHandler = Extgallery\PublicPermHandler::getInstance();
48
49
// If require image don't exist
50
if (0 == $photo->getVar('cat_id')) {
51
    header('Content-type: image/jpeg');
52
    readfile(XOOPS_ROOT_PATH . '/modules/extgallery/assets/images/dont-exist.jpg');
53
54
// If user is allowed to view this picture
55
} elseif ($permHandler->isAllowed($xoopsUser, 'public_access', $photo->getVar('cat_id'))) {
56
    $photo = $photoHandler->objectToArray($photo);
57
58
    header('Content-type: ' . $type . '');
59
    readfile(XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/thumb/thumb_' . $photo['photo_name']);
60
61
// If user isn't allowed to view this picture
62
} else {
63
    header('Content-type: image/jpeg');
64
    readfile(XOOPS_ROOT_PATH . '/modules/extgallery/assets/images/not-allowed.jpg');
65
}
66