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 | $queId = 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 | $xoTheme->addStylesheet($helper->url('assets/js/tablesorter/css/theme.blue.css')); |
||
| 41 | |||
| 42 | switch ($op) { |
||
| 43 | case 'list': |
||
| 44 | default: |
||
| 45 | // Define Stylesheet |
||
| 46 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 47 | $templateMain = 'wgevents_admin_question.tpl'; |
||
| 48 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('question.php')); |
||
| 49 | if ($evId > 0) { |
||
| 50 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_QUESTION, 'question.php?op=new&id=' . $evId); |
||
| 51 | $adminObject->addItemButton(\_AM_WGEVENTS_GOTO_FORMSELECT, 'question.php', 'list'); |
||
| 52 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 53 | $crQuestion = new \CriteriaCompo(); |
||
| 54 | $crQuestion->add(new \Criteria('evid', $evId)); |
||
| 55 | $questionCount = $questionHandler->getCount($crQuestion); |
||
| 56 | $GLOBALS['xoopsTpl']->assign('questionCount', $questionCount); |
||
| 57 | $crQuestion->setSort('weight ASC, id'); |
||
| 58 | $crQuestion->setOrder('DESC'); |
||
| 59 | $crQuestion->setStart($start); |
||
| 60 | $crQuestion->setLimit($limit); |
||
| 61 | $GLOBALS['xoopsTpl']->assign('questionCount', $questionCount); |
||
| 62 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
| 63 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 64 | // Table view questions |
||
| 65 | if ($questionCount > 0) { |
||
| 66 | $questionAll = $questionHandler->getAll($crQuestion); |
||
| 67 | foreach (\array_keys($questionAll) as $i) { |
||
| 68 | $question = $questionAll[$i]->getValuesQuestions(); |
||
| 69 | $GLOBALS['xoopsTpl']->append('questions_list', $question); |
||
| 70 | unset($question); |
||
| 71 | } |
||
| 72 | } else { |
||
| 73 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_QUESTIONS); |
||
| 74 | } |
||
| 75 | } else { |
||
| 76 | $GLOBALS['xoopsTpl']->assign('eventsHeader', \sprintf(_AM_WGEVENTS_LIST_EVENTS_LAST, $limit)); |
||
| 77 | $eventCount = $eventHandler->getCountEvents(); |
||
| 78 | $GLOBALS['xoopsTpl']->append('eventCount', $eventCount); |
||
| 79 | // Table view events |
||
| 80 | if ($eventCount > 0) { |
||
| 81 | $eventAll = $eventHandler->getAllEvents($start, $limit); |
||
| 82 | foreach (\array_keys($eventAll) as $i) { |
||
| 83 | $event = $eventAll[$i]->getValuesEvents(); |
||
| 84 | $crQuestion = new \CriteriaCompo(); |
||
| 85 | $crQuestion->add(new \Criteria('evid', $i)); |
||
| 86 | $questionCount = $questionHandler->getCount($crQuestion); |
||
| 87 | $event['questions'] = $questionCount; |
||
| 88 | $GLOBALS['xoopsTpl']->append('events_list', $event); |
||
| 89 | unset($event); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | break; |
||
| 94 | case 'new': |
||
| 95 | $templateMain = 'wgevents_admin_question.tpl'; |
||
| 96 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
| 97 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('question.php')); |
||
| 98 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_QUESTIONS, 'question.php', 'list'); |
||
| 99 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 100 | // Form Create |
||
| 101 | $questionObj = $questionHandler->create(); |
||
| 102 | $questionObj->setVar('evid', $evId); |
||
| 103 | $form = $questionObj->getForm(); |
||
| 104 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 105 | break; |
||
| 106 | case 'clone': |
||
| 107 | $templateMain = 'wgevents_admin_question.tpl'; |
||
| 108 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
| 109 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('question.php')); |
||
| 110 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_QUESTIONS, 'question.php', 'list'); |
||
| 111 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_QUESTION, 'question.php?op=new'); |
||
| 112 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 113 | // Request source |
||
| 114 | $queIdSource = Request::getInt('id_source'); |
||
| 115 | // Get Form |
||
| 116 | $questionObjSource = $questionHandler->get($queIdSource); |
||
| 117 | $questionObj = $questionObjSource->xoopsClone(); |
||
| 118 | $form = $questionObj->getForm(); |
||
| 119 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 120 | break; |
||
| 121 | case 'save': |
||
| 122 | // Security Check |
||
| 123 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 124 | \redirect_header('question.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 125 | } |
||
| 126 | if ($queId > 0) { |
||
| 127 | $questionObj = $questionHandler->get($queId); |
||
| 128 | } else { |
||
| 129 | $questionObj = $questionHandler->create(); |
||
| 130 | } |
||
| 131 | // Set Vars |
||
| 132 | $questionObj->setVar('evid', Request::getInt('evid')); |
||
| 133 | $queType = Request::getInt('type'); |
||
| 134 | $questionObj->setVar('fdid', $queType); |
||
| 135 | $fieldObj = $fieldHandler->get($queType); |
||
| 136 | $questionObj->setVar('type', $fieldObj->getVar('type')); |
||
| 137 | $questionObj->setVar('caption', Request::getString('caption')); |
||
| 138 | $questionObj->setVar('desc', Request::getText('desc')); |
||
| 139 | $queValuesText = ''; |
||
| 140 | $queValues = Request::getString('values'); |
||
| 141 | if ('' !== $queValues) { |
||
| 142 | if (Constants::FIELD_COMBOBOX == $queType || |
||
| 143 | Constants::FIELD_SELECTBOX == $queType || |
||
| 144 | Constants::FIELD_RADIO == $queType || |
||
| 145 | Constants::FIELD_CHECKBOX == $queType) { |
||
| 146 | $queValuesText = \serialize(\preg_split('/\r\n|\r|\n/', $queValues)); |
||
| 147 | } else { |
||
| 148 | $tmpArr = [$queValues]; |
||
| 149 | $queValuesText = \serialize($tmpArr); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | $questionObj->setVar('values', $queValuesText); |
||
| 153 | $questionObj->setVar('placeholder', Request::getString('placeholder')); |
||
| 154 | $questionObj->setVar('weight', Request::getInt('weight')); |
||
| 155 | $questionObj->setVar('required', Request::getInt('required')); |
||
| 156 | $questionObj->setVar('print', Request::getInt('print')); |
||
| 157 | $questionDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated')); |
||
| 158 | $questionObj->setVar('datecreated', $questionDatecreatedObj->getTimestamp()); |
||
| 159 | $questionObj->setVar('submitter', Request::getInt('submitter')); |
||
| 160 | // Insert Data |
||
| 161 | if ($questionHandler->insert($questionObj)) { |
||
| 162 | \redirect_header('question.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||
| 163 | } |
||
| 164 | // Get Form |
||
| 165 | $GLOBALS['xoopsTpl']->assign('error', $questionObj->getHtmlErrors()); |
||
| 166 | $form = $questionObj->getForm(); |
||
| 167 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 168 | break; |
||
| 169 | case 'edit': |
||
| 170 | $templateMain = 'wgevents_admin_question.tpl'; |
||
| 171 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
| 172 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('question.php')); |
||
| 173 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_QUESTION, 'question.php?op=new'); |
||
| 174 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_QUESTIONS, 'question.php', 'list'); |
||
| 175 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 176 | // Get Form |
||
| 177 | $questionObj = $questionHandler->get($queId); |
||
| 178 | $questionObj->start = $start; |
||
| 179 | $questionObj->limit = $limit; |
||
| 180 | $form = $questionObj->getForm(); |
||
| 181 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 182 | break; |
||
| 183 | case 'delete': |
||
| 184 | $templateMain = 'wgevents_admin_question.tpl'; |
||
| 185 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('question.php')); |
||
| 186 | $questionObj = $questionHandler->get($queId); |
||
| 187 | $addEvid = $questionObj->getVar('evid'); |
||
| 188 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||
| 189 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 190 | \redirect_header('question.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 191 | } |
||
| 192 | if ($questionHandler->delete($questionObj)) { |
||
| 193 | \redirect_header('question.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
| 194 | } else { |
||
| 195 | $GLOBALS['xoopsTpl']->assign('error', $questionObj->getHtmlErrors()); |
||
| 196 | } |
||
| 197 | } else { |
||
| 198 | $customConfirm = new Common\Confirm( |
||
| 199 | ['ok' => 1, 'id' => $queId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||
| 200 | $_SERVER['REQUEST_URI'], |
||
| 201 | \sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $questionObj->getVar('evid'))); |
||
| 202 | $form = $customConfirm->getFormConfirm(); |
||
| 203 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 204 | } |
||
| 205 | break; |
||
| 206 | } |
||
| 207 | require __DIR__ . '/footer.php'; |
||
| 208 |
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: