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\Constants; |
||
| 25 | use XoopsModules\Wgevents\Common; |
||
| 26 | |||
| 27 | require __DIR__ . '/header.php'; |
||
| 28 | // Get all request values |
||
| 29 | $op = Request::getCmd('op', 'list'); |
||
| 30 | $ansId = Request::getInt('id'); |
||
| 31 | $evId = Request::getInt('evid'); |
||
| 32 | $start = Request::getInt('start'); |
||
| 33 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||
| 34 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
| 35 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
| 36 | |||
| 37 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 38 | |||
| 39 | $GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
||
| 40 | |||
| 41 | switch ($op) { |
||
| 42 | case 'list': |
||
| 43 | default: |
||
| 44 | // Define Stylesheet |
||
| 45 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 46 | $templateMain = 'wgevents_admin_answer.tpl'; |
||
| 47 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php')); |
||
| 48 | if ($evId > 0) { |
||
| 49 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_ANSWER, 'answer.php?op=new&evId=' . $evId); |
||
| 50 | $adminObject->addItemButton(\_AM_WGEVENTS_GOTO_FORMSELECT, 'answer.php', 'list'); |
||
| 51 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 52 | $crAnswer = new \CriteriaCompo(); |
||
| 53 | $crAnswer->add(new \Criteria('evid', $evId)); |
||
| 54 | $answerCount = $answerHandler->getCount($crAnswer); |
||
| 55 | $GLOBALS['xoopsTpl']->assign('answerCount', $answerCount); |
||
| 56 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
| 57 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 58 | // Table view answers |
||
| 59 | if ($answerCount > 0) { |
||
| 60 | $answerAll = $answerHandler->getAll($crAnswer); |
||
| 61 | foreach (\array_keys($answerAll) as $i) { |
||
| 62 | $answer = $answerAll[$i]->getValuesAnswers(); |
||
| 63 | $registrationObj = $registrationHandler->get($answer['regid']); |
||
| 64 | $answer['regname'] = $registrationObj->getVar('firstname') . ' ' . $registrationObj->getVar('lastname'); |
||
| 65 | $GLOBALS['xoopsTpl']->append('answers_list', $answer); |
||
| 66 | unset($answer); |
||
| 67 | } |
||
| 68 | } else { |
||
| 69 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_ANSWERS); |
||
| 70 | } |
||
| 71 | } else { |
||
| 72 | $GLOBALS['xoopsTpl']->assign('eventsHeader', \sprintf(_AM_WGEVENTS_LIST_EVENTS_LAST, $limit)); |
||
| 73 | $eventCount = $eventHandler->getCountEvents(); |
||
| 74 | $GLOBALS['xoopsTpl']->append('eventCount', $eventCount); |
||
| 75 | // Table view events |
||
| 76 | if ($eventCount > 0) { |
||
| 77 | $eventAll = $eventHandler->getAllEvents(); |
||
| 78 | foreach (\array_keys($eventAll) as $i) { |
||
| 79 | $event = $eventAll[$i]->getValuesEvents(); |
||
| 80 | $crAnswer = new \CriteriaCompo(); |
||
| 81 | $crAnswer->add(new \Criteria('evid', $i)); |
||
| 82 | $answerCount = $answerHandler->getCount($crAnswer); |
||
| 83 | $event['answers'] = $answerCount; |
||
| 84 | $GLOBALS['xoopsTpl']->append('events_list', $event); |
||
| 85 | unset($event); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | break; |
||
| 90 | case 'new': |
||
| 91 | $templateMain = 'wgevents_admin_answer.tpl'; |
||
| 92 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php')); |
||
| 93 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_ANSWERS, 'answer.php', 'list'); |
||
| 94 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 95 | // Form Create |
||
| 96 | $answerObj = $answerHandler->create(); |
||
| 97 | $answerObj->setVar('evid', $evId); |
||
| 98 | $form = $answerObj->getForm(); |
||
| 99 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 100 | break; |
||
| 101 | case 'clone': |
||
| 102 | $templateMain = 'wgevents_admin_answer.tpl'; |
||
| 103 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php')); |
||
| 104 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_ANSWERS, 'answer.php', 'list'); |
||
| 105 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_ANSWER, 'answer.php?op=new'); |
||
| 106 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 107 | // Request source |
||
| 108 | $ansIdSource = Request::getInt('id_source'); |
||
| 109 | // Get Form |
||
| 110 | $answerObjSource = $answerHandler->get($ansIdSource); |
||
| 111 | $answerObj = $answerObjSource->xoopsClone(); |
||
| 112 | $form = $answerObj->getForm(); |
||
| 113 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 114 | break; |
||
| 115 | case 'save': |
||
| 116 | // Security Check |
||
| 117 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 118 | \redirect_header('answer.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 119 | } |
||
| 120 | if ($ansId > 0) { |
||
| 121 | $answerObj = $answerHandler->get($ansId); |
||
| 122 | } else { |
||
| 123 | $answerObj = $answerHandler->create(); |
||
| 124 | } |
||
| 125 | // Set Vars |
||
| 126 | $answerObj->setVar('regid', Request::getInt('regid')); |
||
| 127 | $answerObj->setVar('queid', Request::getInt('queid')); |
||
| 128 | $answerObj->setVar('evid', Request::getInt('evid')); |
||
| 129 | $answerObj->setVar('text', Request::getString('text')); |
||
| 130 | $answerDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated')); |
||
| 131 | $answerObj->setVar('datecreated', $answerDatecreatedObj->getTimestamp()); |
||
| 132 | $answerObj->setVar('submitter', Request::getInt('submitter')); |
||
| 133 | // Insert Data |
||
| 134 | if ($answerHandler->insert($answerObj)) { |
||
| 135 | \redirect_header('answer.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||
| 136 | } |
||
| 137 | // Get Form |
||
| 138 | $GLOBALS['xoopsTpl']->assign('error', $answerObj->getHtmlErrors()); |
||
| 139 | $form = $answerObj->getForm(); |
||
| 140 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 141 | break; |
||
| 142 | case 'edit': |
||
| 143 | $templateMain = 'wgevents_admin_answer.tpl'; |
||
| 144 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php')); |
||
| 145 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_ANSWER, 'answer.php?op=new'); |
||
| 146 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_ANSWERS, 'answer.php', 'list'); |
||
| 147 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 148 | // Get Form |
||
| 149 | $answerObj = $answerHandler->get($ansId); |
||
| 150 | $answerObj->start = $start; |
||
| 151 | $answerObj->limit = $limit; |
||
| 152 | $form = $answerObj->getForm(); |
||
| 153 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 154 | break; |
||
| 155 | case 'delete': |
||
| 156 | $templateMain = 'wgevents_admin_answer.tpl'; |
||
| 157 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php')); |
||
| 158 | $answerObj = $answerHandler->get($ansId); |
||
| 159 | $ansEvid = $answerObj->getVar('evid'); |
||
| 160 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||
| 161 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 162 | \redirect_header('answer.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 163 | } |
||
| 164 | if ($answerHandler->delete($answerObj)) { |
||
| 165 | \redirect_header('answer.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
| 166 | } else { |
||
| 167 | $GLOBALS['xoopsTpl']->assign('error', $answerObj->getHtmlErrors()); |
||
| 168 | } |
||
| 169 | } else { |
||
| 170 | $customConfirm = new Common\Confirm( |
||
| 171 | ['ok' => 1, 'id' => $ansId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||
| 172 | $_SERVER['REQUEST_URI'], |
||
| 173 | \sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $answerObj->getVar('evid'))); |
||
| 174 | $form = $customConfirm->getFormConfirm(); |
||
| 175 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 176 | } |
||
| 177 | break; |
||
| 178 | } |
||
| 179 | require __DIR__ . '/footer.php'; |
||
| 180 |
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: