mambax7 /
extgallery
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 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 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
| 14 | * @author Zoullou (http://www.zoullou.net) |
||
| 15 | * @package ExtGallery |
||
| 16 | */ |
||
| 17 | |||
| 18 | use Xmf\Request; |
||
| 19 | use XoopsModules\Extgallery\{ |
||
| 20 | Helper, |
||
| 21 | PublicPermHandler |
||
| 22 | }; |
||
| 23 | /** @var Helper $helper */ |
||
| 24 | |||
| 25 | require_once __DIR__ . '/header.php'; |
||
| 26 | |||
| 27 | $GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-photo.tpl'; |
||
| 28 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 29 | |||
| 30 | |||
| 31 | $helper = Helper::getInstance(); |
||
| 32 | |||
| 33 | //if (!isset($_GET['photoId'])) { |
||
| 34 | // $photoId = 0; |
||
| 35 | //} else { |
||
| 36 | $photoId = Request::getInt('photoId', 0, 'GET'); |
||
| 37 | //} |
||
| 38 | |||
| 39 | /** @var PublicCategoryHandler $catHandler */ |
||
| 40 | $catHandler = Helper::getInstance()->getHandler('PublicCategory'); |
||
| 41 | /** @var PublicPhotoHandler $photoHandler */ |
||
| 42 | $photoHandler = Helper::getInstance()->getHandler('PublicPhoto'); |
||
| 43 | /** @var PublicRatingHandler $ratingHandler */ |
||
| 44 | $ratingHandler = Helper::getInstance()->getHandler('PublicRating'); |
||
| 45 | $permHandler = PublicPermHandler::getInstance(); |
||
| 46 | |||
| 47 | $photoObj = $photoHandler->getPhoto($photoId); |
||
| 48 | |||
| 49 | // Check is the photo exist |
||
| 50 | if (!$photoObj) { |
||
| 51 | redirect_header('index.php', 3, _NOPERM); |
||
| 52 | } |
||
| 53 | |||
| 54 | $photo = $photoHandler->objectToArray($photoObj, ['cat_id', 'uid']); |
||
| 55 | |||
| 56 | // Check the category access permission |
||
| 57 | $permHandler = PublicPermHandler::getInstance(); |
||
| 58 | if (!$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_access', $photo['cat']['cat_id'])) { |
||
| 59 | redirect_header('index.php', 3, _NOPERM); |
||
| 60 | } |
||
| 61 | |||
| 62 | // Don't update counter if user come from rating page |
||
| 63 | //if (null !== Request::getString('HTTP_REFERER', '', 'SERVER') && basename(Request::getString('HTTP_REFERER', '', 'SERVER')) != 'public-rating.php?photoId=' . $photoId) { |
||
| 64 | if (null !== Request::getString('HTTP_REFERER', '', 'SERVER') && basename(Request::getString('HTTP_REFERER', '', 'SERVER')) !== 'public-rating.php?photoId=' . $photoId) { |
||
| 65 | $photoHandler->updateHits($photoId); |
||
| 66 | } |
||
| 67 | |||
| 68 | // Plugin traitement |
||
| 69 | $plugin = Helper::getInstance()->getHandler('Plugin'); |
||
| 70 | $params = ['catId' => $photo['cat']['cat_id'], 'photoId' => $photo['photo_id'], 'link' => []]; |
||
| 71 | $plugin->triggerEvent('photoAlbumLink', $params); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 72 | $photo['link'] = $params['link']; |
||
| 73 | |||
| 74 | $photo['photo_date'] = formatTimestamp($photo['photo_date'], _MEDIUMDATESTRING); |
||
| 75 | $xoopsTpl->assign('photo', $photo); |
||
| 76 | |||
| 77 | $cat = $catHandler->objectToArray($catHandler->getCat($photo['cat']['cat_id'])); |
||
| 78 | $xoopsTpl->assign('cat', $cat); |
||
| 79 | |||
| 80 | $catPath = $catHandler->objectToArray($catHandler->getPath($photo['cat']['cat_id'], true)); |
||
| 81 | $xoopsTpl->assign('catPath', $catPath); |
||
| 82 | |||
| 83 | $photosIds = $photoHandler->getPhotoAlbumId($photoObj->getVar('cat_id')); |
||
| 84 | |||
| 85 | $nbPhoto = 0; |
||
| 86 | if ($photosIds && is_array($photosIds)) { |
||
| 87 | $nbPhoto = count($photosIds); |
||
| 88 | } |
||
| 89 | $currentPhotoPlace = array_search($photoId, $photosIds, true); |
||
| 90 | |||
| 91 | if (1 == $nbPhoto) { |
||
| 92 | $prev = 0; |
||
| 93 | $next = 0; |
||
| 94 | } elseif (0 == $currentPhotoPlace) { |
||
| 95 | $prev = 0; |
||
| 96 | $next = $photosIds[$currentPhotoPlace + 1]; |
||
| 97 | } elseif (($currentPhotoPlace + 1) == $nbPhoto) { |
||
| 98 | $prev = $photosIds[$currentPhotoPlace - 1]; |
||
| 99 | $next = 0; |
||
| 100 | } else { |
||
| 101 | $prev = $photosIds[$currentPhotoPlace - 1]; |
||
| 102 | $next = $photosIds[$currentPhotoPlace + 1]; |
||
| 103 | } |
||
| 104 | $xoopsTpl->assign('prevId', $prev); |
||
| 105 | $xoopsTpl->assign('nextId', $next); |
||
| 106 | $xoopsTpl->assign('currentPhoto', $currentPhotoPlace + 1); |
||
| 107 | $xoopsTpl->assign('totalPhoto', $nbPhoto); |
||
| 108 | |||
| 109 | //DNPROSSI - changed photo_desc to photo_title |
||
| 110 | $xoopsTpl->assign('xoops_pagetitle', $photo['photo_title'] . ' - ' . $cat['cat_name']); |
||
| 111 | $xoTheme->addMeta('meta', 'description', $photo['photo_title'] . ' - ' . $cat['cat_desc']); |
||
| 112 | |||
| 113 | $rel = 'alternate'; |
||
| 114 | $attributes['rel'] = $rel; |
||
| 115 | $attributes['type'] = 'application/rss+xml'; |
||
| 116 | $attributes['title'] = _MD_EXTGALLERY_RSS; |
||
| 117 | $attributes['href'] = XOOPS_URL . '/modules/extgallery/public-rss.php'; |
||
| 118 | $xoTheme->addMeta('link', $rel, $attributes); |
||
| 119 | $xoTheme->addStylesheet('modules/extgallery/assets/css/style.css'); |
||
| 120 | |||
| 121 | $xoopsTpl->assign('rating', $ratingHandler->getRate($photoId)); |
||
| 122 | |||
| 123 | $lang = [ |
||
| 124 | 'preview' => _MD_EXTGALLERY_PREVIEW, |
||
| 125 | 'next' => _MD_EXTGALLERY_NEXT, |
||
| 126 | 'of' => _MD_EXTGALLERY_OF, |
||
| 127 | 'voteFor' => _MD_EXTGALLERY_VOTE_FOR_THIS_PHOTO, |
||
| 128 | 'photoInfo' => _MD_EXTGALLERY_PHOTO_INFORMATION, |
||
| 129 | 'resolution' => _MD_EXTGALLERY_RESOLUTION, |
||
| 130 | 'pixels' => _MD_EXTGALLERY_PIXELS, |
||
| 131 | 'view' => _MD_EXTGALLERY_VIEW, |
||
| 132 | 'hits' => _MD_EXTGALLERY_HITS, |
||
| 133 | 'fileSize' => _MD_EXTGALLERY_FILE_SIZE, |
||
| 134 | 'added' => _MD_EXTGALLERY_ADDED, |
||
| 135 | 'score' => _MD_EXTGALLERY_SCORE, |
||
| 136 | 'votes' => _MD_EXTGALLERY_VOTES, |
||
| 137 | 'downloadOrig' => _MD_EXTGALLERY_DOWNLOAD_ORIG, |
||
| 138 | 'donwloads' => _MD_EXTGALLERY_DOWNLOADS, |
||
| 139 | 'sendEcard' => _MD_EXTGALLERY_SEND_ECARD, |
||
| 140 | 'sends' => _MD_EXTGALLERY_SENDS, |
||
| 141 | 'submitter' => _MD_EXTGALLERY_SUBMITTER, |
||
| 142 | 'allPhotoBy' => _MD_EXTGALLERY_ALL_PHOTO_BY, |
||
| 143 | ]; |
||
| 144 | $xoopsTpl->assign('lang', $lang); |
||
| 145 | |||
| 146 | if ($helper->getConfig('enable_rating')) { |
||
| 147 | $xoopsTpl->assign('canRate', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_rate', $cat['cat_id'])); |
||
| 148 | } else { |
||
| 149 | $xoopsTpl->assign('canRate', false); |
||
| 150 | //DNPROSSI - added preferences option - enable_rating |
||
| 151 | $xoopsTpl->assign('enable_rating', $helper->getConfig('enable_rating')); |
||
| 152 | } |
||
| 153 | |||
| 154 | //DNPROSSI - added preferences option |
||
| 155 | // enable_info, enable_resolution, enable_download, enable_date |
||
| 156 | // enable_ecards, enable_submitter_lnk, enable_photo_hits |
||
| 157 | //if ('photo' === $helper->getConfig('info_view') || 'both' === $helper->getConfig('info_view')) { |
||
| 158 | if (in_array($helper->getConfig('info_view'), ['photo', 'both'])) { |
||
| 159 | // if ('public' === $helper->getConfig('pubusr_info_view') || 'both' === $helper->getConfig('pubusr_info_view')) { |
||
| 160 | if (in_array($helper->getConfig('pubusr_info_view'), ['public', 'both'])) { |
||
| 161 | if (0 == $helper->getConfig('enable_info')) { |
||
|
0 ignored issues
–
show
|
|||
| 162 | $enable_info = $helper->getConfig('enable_info'); |
||
| 163 | } else { |
||
| 164 | $enable_info = 1; |
||
| 165 | } |
||
| 166 | } else { |
||
| 167 | $enable_info = 1; |
||
| 168 | } |
||
| 169 | } else { |
||
| 170 | $enable_info = 1; |
||
| 171 | } |
||
| 172 | |||
| 173 | $xoopsTpl->assign('enable_info', $enable_info); |
||
| 174 | $xoopsTpl->assign('enable_resolution', $helper->getConfig('enable_resolution')); |
||
| 175 | $xoopsTpl->assign('enable_download', $helper->getConfig('enable_download')); |
||
| 176 | $xoopsTpl->assign('enable_date', $helper->getConfig('enable_date')); |
||
| 177 | $xoopsTpl->assign('enable_ecards', $helper->getConfig('enable_ecards')); |
||
| 178 | $xoopsTpl->assign('enable_submitter_lnk', $helper->getConfig('enable_submitter_lnk')); |
||
| 179 | $xoopsTpl->assign('enable_photo_hits', $helper->getConfig('enable_photo_hits')); |
||
| 180 | $xoopsTpl->assign('show_social_book', $helper->getConfig('show_social_book')); |
||
| 181 | |||
| 182 | $xoopsTpl->assign('enableExtra', $helper->getConfig('display_extra_field')); |
||
| 183 | $xoopsTpl->assign('canSendEcard', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_ecard', $cat['cat_id'])); |
||
| 184 | $xoopsTpl->assign('canDownload', $permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_download', $cat['cat_id'])); |
||
| 185 | |||
| 186 | $xoopsTpl->assign('extgalleryName', $xoopsModule->getVar('name')); |
||
| 187 | $xoopsTpl->assign('disp_ph_title', $helper->getConfig('disp_ph_title')); |
||
| 188 | $xoopsTpl->assign('display_type', $helper->getConfig('display_type')); |
||
| 189 | $xoopsTpl->assign('show_rss', $helper->getConfig('show_rss')); |
||
| 190 | |||
| 191 | // For xoops tag |
||
| 192 | if (class_exists(\XoopsModules\Tag\Helper::class) && (1 == $helper->getConfig('usetag')) && is_dir('../tag')) { |
||
| 193 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; |
||
| 194 | $xoopsTpl->assign('tagbar', tagBar($photo['photo_id'], $catid = 0)); |
||
| 195 | $xoopsTpl->assign('tags', true); |
||
| 196 | } else { |
||
| 197 | $xoopsTpl->assign('tags', false); |
||
| 198 | } |
||
| 199 | |||
| 200 | require XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||
| 201 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 202 |