ggoffy /
wgevents
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 declare(strict_types=1); |
||
| 2 | |||
| 3 | /* |
||
| 4 | You may not change or alter any portion of this comment or credits |
||
| 5 | of supporting developers from this source code or any supporting source code |
||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 7 | |||
| 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 | |||
| 13 | /** |
||
| 14 | * wgEvents module for xoops |
||
| 15 | * |
||
| 16 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 17 | * @license GPL 2.0 or later |
||
| 18 | * @package wgevents |
||
| 19 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 20 | */ |
||
| 21 | |||
| 22 | use Xmf\Request; |
||
|
0 ignored issues
–
show
|
|||
| 23 | use XoopsModules\Wgevents; |
||
| 24 | use XoopsModules\Wgevents\ { |
||
| 25 | Constants, |
||
| 26 | Utility, |
||
| 27 | Common |
||
| 28 | }; |
||
| 29 | |||
| 30 | require __DIR__ . '/header.php'; |
||
| 31 | // Get all request values |
||
| 32 | $op = Request::getCmd('op', 'list'); |
||
| 33 | $evId = Request::getInt('id'); |
||
| 34 | $start = Request::getInt('start'); |
||
| 35 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||
| 36 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
| 37 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
| 38 | |||
| 39 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 40 | |||
| 41 | $GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
||
| 42 | |||
| 43 | switch ($op) { |
||
| 44 | case 'list': |
||
| 45 | default: |
||
| 46 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
| 47 | // Define Stylesheet |
||
| 48 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 49 | $templateMain = 'wgevents_admin_event.tpl'; |
||
| 50 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('event.php')); |
||
| 51 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_EVENT, 'event.php?op=new'); |
||
| 52 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 53 | $eventCount = $eventHandler->getCountEvents(); |
||
| 54 | $eventAll = $eventHandler->getAllEvents(); |
||
| 55 | $GLOBALS['xoopsTpl']->assign('eventCount', $eventCount); |
||
| 56 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
| 57 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 58 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
||
| 59 | $GLOBALS['xoopsTpl']->assign('use_gmaps', $helper->getConfig('use_gmaps')); |
||
| 60 | $GLOBALS['xoopsTpl']->assign('use_wggallery', $helper->getConfig('use_wggallery')); |
||
| 61 | $GLOBALS['xoopsTpl']->assign('use_register', $helper->getConfig('use_register')); |
||
| 62 | $GLOBALS['xoopsTpl']->assign('use_urlregistration', $helper->getConfig('use_urlregistration')); |
||
| 63 | $GLOBALS['xoopsTpl']->assign('use_groups', $helper->getConfig('use_groups')); |
||
| 64 | // Table view events |
||
| 65 | if ($eventCount > 0) { |
||
| 66 | foreach (\array_keys($eventAll) as $i) { |
||
| 67 | $event = $eventAll[$i]->getValuesEvents(); |
||
| 68 | $GLOBALS['xoopsTpl']->append('events_list', $event); |
||
| 69 | unset($event); |
||
| 70 | } |
||
| 71 | } else { |
||
| 72 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_EVENTS); |
||
| 73 | } |
||
| 74 | break; |
||
| 75 | case 'new': |
||
| 76 | $templateMain = 'wgevents_admin_event.tpl'; |
||
| 77 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('event.php')); |
||
| 78 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_EVENTS, 'event.php', 'list'); |
||
| 79 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 80 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
| 81 | // Form Create |
||
| 82 | $eventObj = $eventHandler->create(); |
||
| 83 | $form = $eventObj->getForm(); |
||
| 84 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 85 | break; |
||
| 86 | case 'save': |
||
| 87 | // Security Check |
||
| 88 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 89 | \redirect_header('event.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 90 | } |
||
| 91 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
| 92 | if ($evId > 0) { |
||
| 93 | $eventObj = $eventHandler->get($evId); |
||
| 94 | } else { |
||
| 95 | $eventObj = $eventHandler->create(); |
||
| 96 | } |
||
| 97 | // Set Vars |
||
| 98 | $uploaderErrors = ''; |
||
| 99 | $eventObj->setVar('catid', Request::getInt('catid')); |
||
| 100 | $subCats = \serialize(Request::getArray('subcats')); |
||
| 101 | $eventObj->setVar('subcats', $subCats); |
||
| 102 | $eventObj->setVar('name', Request::getString('name')); |
||
| 103 | // Set Var logo |
||
| 104 | require_once \XOOPS_ROOT_PATH . '/class/uploader.php'; |
||
| 105 | $filename = $_FILES['logo']['name']; |
||
| 106 | $imgMimetype = $_FILES['logo']['type']; |
||
| 107 | $imgNameDef = Request::getString('name'); |
||
| 108 | $uploadPath = \WGEVENTS_UPLOAD_EVENTLOGOS_PATH . '/' . $uidCurrent . '/'; |
||
| 109 | $uploader = new \XoopsMediaUploader($uploadPath, |
||
| 110 | $helper->getConfig('mimetypes_image'), |
||
| 111 | $helper->getConfig('maxsize_image'), null, null); |
||
| 112 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||
| 113 | $extension = \preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
||
| 114 | $imgName = \str_replace(' ', '', $imgNameDef) . '.' . $extension; |
||
| 115 | $uploader->setPrefix($imgName); |
||
| 116 | $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
||
| 117 | if ($uploader->upload()) { |
||
| 118 | $savedFilename = $uploader->getSavedFileName(); |
||
| 119 | $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
||
| 120 | $maxheight = (int)$helper->getConfig('maxheight_image'); |
||
| 121 | if ($maxwidth > 0 && $maxheight > 0) { |
||
| 122 | // Resize image |
||
| 123 | $imgHandler = new Wgevents\Common\Resizer(); |
||
| 124 | $imgHandler->sourceFile = $uploadPath . $savedFilename; |
||
| 125 | $imgHandler->endFile = $uploadPath . $savedFilename; |
||
| 126 | $imgHandler->imageMimetype = $imgMimetype; |
||
| 127 | $imgHandler->maxWidth = $maxwidth; |
||
| 128 | $imgHandler->maxHeight = $maxheight; |
||
| 129 | $result = $imgHandler->resizeImage(); |
||
| 130 | } |
||
| 131 | $eventObj->setVar('logo', $savedFilename); |
||
| 132 | } else { |
||
| 133 | $uploaderErrors .= '<br>' . $uploader->getErrors(); |
||
| 134 | } |
||
| 135 | } else { |
||
| 136 | if ('' !== $filename) { |
||
| 137 | $uploaderErrors .= '<br>' . $uploader->getErrors(); |
||
| 138 | } |
||
| 139 | $filename = Request::getString('logo'); |
||
| 140 | if ('' !== $filename) { |
||
| 141 | $eventObj->setVar('logo', $filename); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | $eventObj->setVar('desc', Request::getText('desc')); |
||
| 145 | $eventDatefromArr = Request::getArray('datefrom'); |
||
| 146 | $eventDatefromObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $eventDatefromArr['date']); |
||
| 147 | $eventDatefromObj->setTime(0, 0); |
||
| 148 | $eventDatefrom = $eventDatefromObj->getTimestamp() + (int)$eventDatefromArr['time']; |
||
| 149 | $eventObj->setVar('datefrom', $eventDatefrom); |
||
| 150 | $eventDatetoArr = Request::getArray('dateto'); |
||
| 151 | $eventDatetoObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $eventDatetoArr['date']); |
||
| 152 | $eventDatetoObj->setTime(0, 0); |
||
| 153 | $eventDateto = $eventDatetoObj->getTimestamp() + (int)$eventDatetoArr['time']; |
||
| 154 | $eventObj->setVar('dateto', $eventDateto); |
||
| 155 | $eventObj->setVar('allday', Request::getInt('allday')); |
||
| 156 | $eventObj->setVar('contact', Request::getString('contact')); |
||
| 157 | $eventObj->setVar('email', Request::getString('email')); |
||
| 158 | $eventObj->setVar('url', Request::getString('url')); |
||
| 159 | $eventObj->setVar('location', Request::getString('location')); |
||
| 160 | $eventObj->setVar('locgmlat', Request::getFloat('locgmlat')); |
||
| 161 | $eventObj->setVar('locgmlon', Request::getFloat('locgmlon')); |
||
| 162 | $eventObj->setVar('locgmzoom', Request::getInt('locgmzoom')); |
||
| 163 | $evFeeType = Request::getInt('fee_type'); |
||
| 164 | $eventObj->setVar('fee_type', $evFeeType); |
||
| 165 | if (Constants::FEETYPE_DECLARED === $evFeeType) { |
||
| 166 | $evFeeAmountArr = Request::getArray('fee'); |
||
| 167 | $evFeeDescArr = Request::getArray('feedesc'); |
||
| 168 | $evFeeArr = []; |
||
| 169 | foreach ($evFeeAmountArr as $key => $evFeeAmount) { |
||
| 170 | $evFeeArr[] = [Utility::StringToFloat($evFeeAmount), $evFeeDescArr[$key]]; |
||
| 171 | } |
||
| 172 | // remove last array item, as this is from hidden group |
||
| 173 | \array_pop($evFeeArr); |
||
| 174 | $evFee = \json_encode($evFeeArr); |
||
| 175 | } else { |
||
| 176 | $evFee = '[[0,""]]'; |
||
| 177 | } |
||
| 178 | $eventObj->setVar('fee', $evFee); |
||
| 179 | $eventObj->setVar('paymentinfo', Request::getText('paymentinfo')); |
||
| 180 | $eventObj->setVar('register_use', Request::getInt('register_use')); |
||
| 181 | if ($helper->getConfig('use_register')) { |
||
| 182 | $evRegisterUse = Request::getInt('register_use'); |
||
| 183 | $eventObj->setVar('register_use', $evRegisterUse); |
||
| 184 | if ($evRegisterUse) { |
||
| 185 | $evRegisterfromArr = Request::getArray('register_from'); |
||
| 186 | $evRegisterfromObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $evRegisterfromArr['date']); |
||
| 187 | $evRegisterfromObj->setTime(0, 0); |
||
| 188 | $evRegisterfrom = $evRegisterfromObj->getTimestamp() + (int)$evRegisterfromArr['time']; |
||
| 189 | $eventObj->setVar('register_from', $evRegisterfrom); |
||
| 190 | $evRegistertoArr = Request::getArray('register_to'); |
||
| 191 | $evRegistertoObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $evRegistertoArr['date']); |
||
| 192 | $evRegistertoObj->setTime(0, 0); |
||
| 193 | $evRegisterto = $evRegistertoObj->getTimestamp() + (int)$evRegistertoArr['time']; |
||
| 194 | $eventObj->setVar('register_to', $evRegisterto); |
||
| 195 | $eventObj->setVar('register_max', Request::getInt('register_max')); |
||
| 196 | $eventObj->setVar('register_listwait', Request::getInt('register_listwait')); |
||
| 197 | $eventObj->setVar('register_autoaccept', Request::getInt('register_autoaccept')); |
||
| 198 | $eventObj->setVar('register_notify', Request::getString('register_notify')); |
||
| 199 | $eventObj->setVar('register_sendermail', Request::getString('register_sendermail')); |
||
| 200 | $eventObj->setVar('register_sendername', Request::getString('register_sendername')); |
||
| 201 | $eventObj->setVar('register_signature', Request::getString('register_signature')); |
||
| 202 | } elseif ($evId > 0) { |
||
| 203 | //reset previous values |
||
| 204 | $eventObj->setVar('register_to', 0); |
||
| 205 | $eventObj->setVar('register_max', 0); |
||
| 206 | $eventObj->setVar('register_listwait', 0); |
||
| 207 | $eventObj->setVar('register_autoaccept', 0); |
||
| 208 | $eventObj->setVar('register_notify', ''); |
||
| 209 | $eventObj->setVar('register_sendermail', ''); |
||
| 210 | $eventObj->setVar('register_sendername', ''); |
||
| 211 | $eventObj->setVar('register_signature', ''); |
||
| 212 | $registrationHandler->cleanupRegistrations($evId); |
||
| 213 | $questionHandler->cleanupQuestions($evId); |
||
| 214 | $answerHandler->cleanupAnswers($evId); |
||
| 215 | } |
||
| 216 | } |
||
| 217 | if (Request::hasVar('url_registration')) { |
||
| 218 | $urlRegistration = Request::getString('url_registration'); |
||
| 219 | } else { |
||
| 220 | $urlRegistration = ''; |
||
| 221 | } |
||
| 222 | $eventObj->setVar('url_registration', $urlRegistration); |
||
| 223 | $eventObj->setVar('status', Request::getInt('status')); |
||
| 224 | $eventObj->setVar('galid', Request::getInt('galid')); |
||
| 225 | $arrGroups = Request::getArray('groups'); |
||
| 226 | if (in_array('00000', $arrGroups)) { |
||
| 227 | $eventObj->setVar('groups', '00000'); |
||
| 228 | } else { |
||
| 229 | $eventObj->setVar('groups', implode('|', $arrGroups)); |
||
| 230 | } |
||
| 231 | $eventObj->setVar('identifier', Request::getString('identifier')); |
||
| 232 | $eventDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated')); |
||
| 233 | $eventObj->setVar('datecreated', $eventDatecreatedObj->getTimestamp()); |
||
| 234 | $eventObj->setVar('submitter', Request::getInt('submitter')); |
||
| 235 | // Insert Data |
||
| 236 | if ($eventHandler->insert($eventObj)) { |
||
| 237 | $newEvId = $eventObj->getNewInsertedId(); |
||
| 238 | if ('' !== $uploaderErrors) { |
||
| 239 | \redirect_header('event.php?op=edit&id=' . $evId, 5, $uploaderErrors); |
||
| 240 | } else { |
||
| 241 | \redirect_header('event.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||
| 242 | } |
||
| 243 | } |
||
| 244 | // Get Form |
||
| 245 | $GLOBALS['xoopsTpl']->assign('error', $eventObj->getHtmlErrors()); |
||
| 246 | $form = $eventObj->getForm(); |
||
| 247 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 248 | break; |
||
| 249 | case 'edit': |
||
| 250 | $templateMain = 'wgevents_admin_event.tpl'; |
||
| 251 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('event.php')); |
||
| 252 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_EVENT, 'event.php?op=new'); |
||
| 253 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_EVENTS, 'event.php', 'list'); |
||
| 254 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 255 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
| 256 | // Get Form |
||
| 257 | $eventObj = $eventHandler->get($evId); |
||
| 258 | $eventObj->start = $start; |
||
| 259 | $eventObj->limit = $limit; |
||
| 260 | $form = $eventObj->getForm(); |
||
| 261 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 262 | break; |
||
| 263 | case 'delete': |
||
| 264 | $templateMain = 'wgevents_admin_event.tpl'; |
||
| 265 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('event.php')); |
||
| 266 | $eventObj = $eventHandler->get($evId); |
||
| 267 | $evName = $eventObj->getVar('name'); |
||
| 268 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||
| 269 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 270 | \redirect_header('event.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 271 | } |
||
| 272 | if ($eventHandler->delete($eventObj)) { |
||
| 273 | \redirect_header('event.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
| 274 | } else { |
||
| 275 | $GLOBALS['xoopsTpl']->assign('error', $eventObj->getHtmlErrors()); |
||
| 276 | } |
||
| 277 | } else { |
||
| 278 | $customConfirm = new Common\Confirm( |
||
| 279 | ['ok' => 1, 'id' => $evId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||
| 280 | $_SERVER['REQUEST_URI'], |
||
| 281 | \sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $eventObj->getVar('name'))); |
||
| 282 | $form = $customConfirm->getFormConfirm(); |
||
| 283 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 284 | } |
||
| 285 | break; |
||
| 286 | } |
||
| 287 | require __DIR__ . '/footer.php'; |
||
| 288 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: