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 |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | You may not change or alter any portion of this comment or credits |
||
| 7 | of supporting developers from this source code or any supporting source code |
||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * wgEvents module for xoops |
||
| 17 | * |
||
| 18 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 19 | * @license GPL 2.0 or later |
||
| 20 | * @package wgevents |
||
| 21 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 22 | */ |
||
| 23 | |||
| 24 | use Xmf\Request; |
||
|
0 ignored issues
–
show
|
|||
| 25 | use XoopsModules\Wgevents; |
||
| 26 | use XoopsModules\Wgevents\Constants; |
||
| 27 | use XoopsModules\Wgevents\Common; |
||
| 28 | |||
| 29 | require __DIR__ . '/header.php'; |
||
| 30 | // Get all request values |
||
| 31 | $op = Request::getCmd('op', 'list'); |
||
| 32 | $taskId = Request::getInt('id'); |
||
| 33 | $start = Request::getInt('start'); |
||
| 34 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||
| 35 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
| 36 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
| 37 | |||
| 38 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 39 | |||
| 40 | switch ($op) { |
||
| 41 | case 'list': |
||
| 42 | default: |
||
| 43 | // Define Stylesheet |
||
| 44 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 45 | $templateMain = 'wgevents_admin_task.tpl'; |
||
| 46 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('task.php')); |
||
| 47 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_TASK, 'task.php?op=new'); |
||
| 48 | $adminObject->addItemButton(\_AM_WGEVENTS_DELETE_TASKS_PENDING, 'task.php?op=delete_all&deltype=pending'); |
||
| 49 | $adminObject->addItemButton(\_AM_WGEVENTS_DELETE_TASKS_DONE, 'task.php?op=delete_all&deltype=done'); |
||
| 50 | $adminObject->addItemButton(\_AM_WGEVENTS_STATISTICS, 'task.php?op=statistics'); |
||
| 51 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 52 | |||
| 53 | $tasksCount = $taskHandler->getCountTasks(); |
||
| 54 | $tasksAll = $taskHandler->getAllTasks(); |
||
| 55 | $GLOBALS['xoopsTpl']->assign('tasks_count', $tasksCount); |
||
| 56 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
| 57 | $GLOBALS['xoopsTpl']->assign('wgevents_icons_url_16', \WGEVENTS_ICONS_URL_16); |
||
| 58 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 59 | $GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
||
| 60 | // Table view tasks |
||
| 61 | if ($tasksCount > 0) { |
||
| 62 | foreach (\array_keys($tasksAll) as $i) { |
||
| 63 | $task = $tasksAll[$i]->getValuesTasks(); |
||
| 64 | $GLOBALS['xoopsTpl']->append('tasks_list', $task); |
||
| 65 | unset($task); |
||
| 66 | } |
||
| 67 | } else { |
||
| 68 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_TASKS); |
||
| 69 | } |
||
| 70 | break; |
||
| 71 | case 'statistics': |
||
| 72 | $templateMain = 'wgevents_admin_task.tpl'; |
||
| 73 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('task.php')); |
||
| 74 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_TASKS, 'task.php', 'list'); |
||
| 75 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 76 | // get statistics |
||
| 77 | $statistics = []; |
||
| 78 | $taskObj = $taskHandler->create(); |
||
| 79 | // loop all mail types |
||
| 80 | for ($i = 1; $i <= 10; $i++) { |
||
| 81 | $statistics[$i]['mailtype'] = $taskObj->getMailNotificationText($i); |
||
| 82 | // loop all status types |
||
| 83 | for ($j = 0; $j <= 10; $j++) { |
||
| 84 | if (Constants::STATUS_NONE === $j || Constants::STATUS_DONE === $j || Constants::STATUS_PROCESSING === $j || Constants::STATUS_PENDING === $j) { |
||
| 85 | $crTaskStats = new \CriteriaCompo(); |
||
| 86 | $crTaskStats->add(new \Criteria('status', $j)); |
||
| 87 | $crTaskStats->add(new \Criteria('type', $i)); |
||
| 88 | $tasksStatCount = $taskHandler->getCount($crTaskStats); |
||
| 89 | switch ($j) { |
||
| 90 | case Constants::STATUS_PENDING: |
||
| 91 | $statistics[$i]['pending'] = $tasksStatCount; |
||
| 92 | break; |
||
| 93 | case Constants::STATUS_PROCESSING: |
||
| 94 | $statistics[$i]['processing'] = $tasksStatCount; |
||
| 95 | break; |
||
| 96 | case Constants::STATUS_DONE: |
||
| 97 | $statistics[$i]['done'] = $tasksStatCount; |
||
| 98 | break; |
||
| 99 | case Constants::STATUS_NONE: |
||
| 100 | $statistics[$i]['none'] = $tasksStatCount; |
||
| 101 | break; |
||
| 102 | default: |
||
| 103 | break; |
||
| 104 | } |
||
| 105 | unset($crTaskStats); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | } |
||
| 109 | unset($taskObj); |
||
| 110 | $GLOBALS['xoopsTpl']->assign('statistics', $statistics); |
||
| 111 | break; |
||
| 112 | case 'new': |
||
| 113 | $templateMain = 'wgevents_admin_task.tpl'; |
||
| 114 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('task.php')); |
||
| 115 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_TASKS, 'task.php', 'list'); |
||
| 116 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 117 | // Form Create |
||
| 118 | $taskObj = $taskHandler->create(); |
||
| 119 | $form = $taskObj->getFormTasks(); |
||
| 120 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 121 | break; |
||
| 122 | case 'save': |
||
| 123 | // Security Check |
||
| 124 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 125 | \redirect_header('task.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 126 | } |
||
| 127 | if ($taskId > 0) { |
||
| 128 | $taskObj = $taskHandler->get($taskId); |
||
| 129 | } else { |
||
| 130 | $taskObj = $taskHandler->create(); |
||
| 131 | } |
||
| 132 | // Set Vars |
||
| 133 | $taskObj->setVar('type', Request::getInt('type')); |
||
| 134 | $taskObj->setVar('params', Request::getText('params')); |
||
| 135 | $taskObj->setVar('recipient', Request::getString('recipient')); |
||
| 136 | $taskDatecreatedArr = Request::getArray('datecreated'); |
||
| 137 | $taskDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $taskDatecreatedArr['date']); |
||
| 138 | $taskDatecreatedObj->setTime(0, 0); |
||
| 139 | $taskDatecreated = $taskDatecreatedObj->getTimestamp() + (int)$taskDatecreatedArr['time']; |
||
| 140 | $taskObj->setVar('datecreated', $taskDatecreated); |
||
| 141 | $taskObj->setVar('submitter', Request::getInt('submitter')); |
||
| 142 | $taskObj->setVar('status', Request::getInt('status')); |
||
| 143 | $taskDatedoneArr = Request::getArray('datedone'); |
||
| 144 | $taskDatedoneObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $taskDatedoneArr['date']); |
||
| 145 | $taskDatedoneObj->setTime(0, 0); |
||
| 146 | $taskDatedone = $taskDatedoneObj->getTimestamp() + (int)$taskDatedoneArr['time']; |
||
| 147 | $taskObj->setVar('datedone', $taskDatedone); |
||
| 148 | // Insert Data |
||
| 149 | if ($taskHandler->insert($taskObj)) { |
||
| 150 | \redirect_header('task.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||
| 151 | } |
||
| 152 | // Get Form |
||
| 153 | $GLOBALS['xoopsTpl']->assign('error', $taskObj->getHtmlErrors()); |
||
| 154 | $form = $taskObj->getFormTasks(); |
||
| 155 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 156 | break; |
||
| 157 | case 'edit': |
||
| 158 | $templateMain = 'wgevents_admin_task.tpl'; |
||
| 159 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('task.php')); |
||
| 160 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_TASK, 'task.php?op=new'); |
||
| 161 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_TASKS, 'task.php', 'list'); |
||
| 162 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 163 | // Get Form |
||
| 164 | $taskObj = $taskHandler->get($taskId); |
||
| 165 | $taskObj->start = $start; |
||
| 166 | $taskObj->limit = $limit; |
||
| 167 | $form = $taskObj->getFormTasks(); |
||
| 168 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 169 | break; |
||
| 170 | case 'delete': |
||
| 171 | $templateMain = 'wgevents_admin_task.tpl'; |
||
| 172 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('task.php')); |
||
| 173 | $taskObj = $taskHandler->get($taskId); |
||
| 174 | $taskEvid = $taskObj->getVar('task_evid'); |
||
| 175 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||
| 176 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 177 | \redirect_header('task.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 178 | } |
||
| 179 | if ($taskHandler->delete($taskObj)) { |
||
| 180 | \redirect_header('task.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
| 181 | } else { |
||
| 182 | $GLOBALS['xoopsTpl']->assign('error', $taskObj->getHtmlErrors()); |
||
| 183 | } |
||
| 184 | } else { |
||
| 185 | $customConfirm = new Common\Confirm( |
||
| 186 | ['ok' => 1, 'task_id' => $taskId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||
| 187 | $_SERVER['REQUEST_URI'], |
||
| 188 | \sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $taskObj->getVar('id'))); |
||
| 189 | $form = $customConfirm->getFormConfirm(); |
||
| 190 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 191 | } |
||
| 192 | break; |
||
| 193 | case 'delete_all': |
||
| 194 | $delType = Request::getString('deltype', 'done'); |
||
| 195 | $templateMain = 'wgevents_admin_task.tpl'; |
||
| 196 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('task.php')); |
||
| 197 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||
| 198 | $crTask = new \CriteriaCompo(); |
||
| 199 | if ('pending' === $delType) { |
||
| 200 | $crTask->add(new \Criteria('status', Constants::STATUS_PENDING)); |
||
| 201 | } else { |
||
| 202 | $crTask->add(new \Criteria('status', Constants::STATUS_DONE)); |
||
| 203 | } |
||
| 204 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 205 | \redirect_header('task.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 206 | } |
||
| 207 | if (0 === $taskHandler->getCount($crTask) || $taskHandler->deleteAll($crTask)) { |
||
| 208 | \redirect_header('task.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
| 209 | } else { |
||
| 210 | $GLOBALS['xoopsTpl']->assign('error', $taskHandler->getHtmlErrors()); |
||
| 211 | } |
||
| 212 | } else { |
||
| 213 | if ('pending' === $delType) { |
||
| 214 | $textConfirm = \_AM_WGEVENTS_DELETE_TASKS_PENDING; |
||
| 215 | } else { |
||
| 216 | $textConfirm = \_AM_WGEVENTS_DELETE_TASKS_DONE; |
||
| 217 | } |
||
| 218 | $customConfirm = new Common\Confirm( |
||
| 219 | ['ok' => 1, 'op' => 'delete_all', 'deltype' => $delType], |
||
| 220 | $_SERVER['REQUEST_URI'], |
||
| 221 | \sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $textConfirm)); |
||
| 222 | $form = $customConfirm->getFormConfirm(); |
||
| 223 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 224 | } |
||
| 225 | break; |
||
| 226 | case 'setprocessingtopending': |
||
| 227 | // if there are no pending tasks, but there are processing tasks (which should not be) then set processing tasks to pending |
||
| 228 | $crTaskProcessing = new \CriteriaCompo(); |
||
| 229 | $crTaskProcessing->add(new \Criteria('status', Constants::STATUS_PROCESSING)); |
||
| 230 | $taskHandler->updateAll('status', Constants::STATUS_PENDING, $crTaskProcessing,true); |
||
| 231 | echo "setprocessingtopending done"; |
||
| 232 | break; |
||
| 233 | } |
||
| 234 | require __DIR__ . '/footer.php'; |
||
| 235 |
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: