mambax7 /
randomquote
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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 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 | * Module: randomquote |
||
| 15 | * |
||
| 16 | * @category Module |
||
| 17 | * @package randomquote |
||
| 18 | * @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
||
| 19 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 20 | * @license GPL 2.0 or later |
||
| 21 | * @link https://xoops.org/ |
||
| 22 | * @since 1.0.0 |
||
| 23 | */ |
||
| 24 | |||
| 25 | use Xmf\Request; |
||
| 26 | use Xmf\Module\Helper\Permission; |
||
| 27 | use Xoopsmodules\randomquote; |
||
|
0 ignored issues
–
show
|
|||
| 28 | use Xoopsmodules\randomquote\common; |
||
| 29 | |||
| 30 | require_once __DIR__ . '/admin_header.php'; |
||
| 31 | xoops_cp_header(); |
||
| 32 | //It recovered the value of argument op in URL$ |
||
| 33 | $op = Request::getString('op', 'list'); |
||
| 34 | $order = Request::getString('order', 'desc'); |
||
| 35 | $sort = Request::getString('sort', ''); |
||
| 36 | |||
| 37 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 38 | /** @var Permission $permHelper */ |
||
| 39 | $permHelper = new \Xmf\Module\Helper\Permission(); |
||
| 40 | $uploadDir = XOOPS_UPLOAD_PATH . '/randomquote/images/'; |
||
| 41 | $uploadUrl = XOOPS_UPLOAD_URL . '/randomquote/images/'; |
||
| 42 | |||
| 43 | switch ($op) { |
||
| 44 | case 'list': |
||
| 45 | default: |
||
| 46 | $adminObject->addItemButton(AM_RANDOMQUOTE_ADD_QUOTES, 'quotes.php?op=new', 'add'); |
||
| 47 | echo $adminObject->displayButton('left'); |
||
| 48 | $start = Request::getInt('start', 0); |
||
| 49 | $quotesPaginationLimit = $GLOBALS['xoopsModuleConfig']['userpager']; |
||
| 50 | |||
| 51 | $criteria = new CriteriaCompo(); |
||
| 52 | $criteria->setSort('id ASC, quote'); |
||
| 53 | $criteria->setOrder('ASC'); |
||
| 54 | $criteria->setLimit($quotesPaginationLimit); |
||
| 55 | $criteria->setStart($start); |
||
| 56 | $quotesTempRows = $quotesHandler->getCount(); |
||
| 57 | $quotesTempArray = $quotesHandler->getAll($criteria); |
||
| 58 | |||
| 59 | // Display Page Navigation |
||
| 60 | View Code Duplication | if ($quotesTempRows > $quotesPaginationLimit) { |
|
| 61 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
| 62 | |||
| 63 | $pagenav = new \XoopsPageNav($quotesTempRows, $quotesPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); |
||
| 64 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
| 65 | } |
||
| 66 | |||
| 67 | $GLOBALS['xoopsTpl']->assign('quotesRows', $quotesTempRows); |
||
| 68 | $quotesArray = []; |
||
| 69 | |||
| 70 | $criteria = new CriteriaCompo(); |
||
| 71 | |||
| 72 | //$criteria->setOrder('DESC'); |
||
| 73 | $criteria->setSort($sort); |
||
| 74 | $criteria->setOrder($order); |
||
| 75 | $criteria->setLimit($quotesPaginationLimit); |
||
| 76 | $criteria->setStart($start); |
||
| 77 | |||
| 78 | $quotesCount = $quotesHandler->getCount($criteria); |
||
| 79 | $quotesTempArray = $quotesHandler->getAll($criteria); |
||
| 80 | |||
| 81 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
| 82 | if ($quotesCount > 0) { |
||
| 83 | foreach (array_keys($quotesTempArray) as $i) { |
||
| 84 | |||
| 85 | |||
| 86 | // $field = explode(':', $fields[$i]); |
||
| 87 | |||
| 88 | $selectorid = $utility::selectSorting(AM_RANDOMQUOTE_QUOTES_ID, 'id'); |
||
| 89 | $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid); |
||
| 90 | $quotesArray['id'] = $quotesTempArray[$i]->getVar('id'); |
||
| 91 | |||
| 92 | $selectorquote = $utility::selectSorting(AM_RANDOMQUOTE_QUOTES_QUOTE, 'quote'); |
||
| 93 | $GLOBALS['xoopsTpl']->assign('selectorquote', $selectorquote); |
||
| 94 | $quotesArray['quote'] = $quotesTempArray[$i]->getVar('quote'); |
||
| 95 | |||
| 96 | $selectorauthor = $utility::selectSorting(AM_RANDOMQUOTE_QUOTES_AUTHOR, 'author'); |
||
| 97 | $GLOBALS['xoopsTpl']->assign('selectorauthor', $selectorauthor); |
||
| 98 | $quotesArray['author'] = $quotesTempArray[$i]->getVar('author'); |
||
| 99 | |||
| 100 | $selectoronline = $utility::selectSorting(AM_RANDOMQUOTE_QUOTES_ONLINE, 'online'); |
||
| 101 | $GLOBALS['xoopsTpl']->assign('selectoronline', $selectoronline); |
||
| 102 | $quotesArray['online'] = $quotesTempArray[$i]->getVar('online'); |
||
| 103 | |||
| 104 | $selectorcreated = $utility::selectSorting(AM_RANDOMQUOTE_QUOTES_CREATED, 'created'); |
||
| 105 | $GLOBALS['xoopsTpl']->assign('selectorcreated', $selectorcreated); |
||
| 106 | $quotesArray['created'] = date(_SHORTDATESTRING, strtotime($quotesTempArray[$i]->getVar('created'))); |
||
| 107 | |||
| 108 | $selectorcid = $utility::selectSorting(AM_RANDOMQUOTE_QUOTES_CID, 'cid'); |
||
| 109 | $GLOBALS['xoopsTpl']->assign('selectorcid', $selectorcid); |
||
| 110 | $quotesArray['cid'] = $categoryHandler->get($quotesTempArray[$i]->getVar('cid'))->getVar('title'); |
||
| 111 | $quotesArray['edit_delete'] = "<a href='quotes.php?op=edit&id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
| 112 | <a href='quotes.php?op=delete&id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
| 113 | <a href='quotes.php?op=clone&id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
| 114 | |||
| 115 | $GLOBALS['xoopsTpl']->append_by_ref('quotesArrays', $quotesArray); |
||
| 116 | unset($quotesArray); |
||
| 117 | } |
||
| 118 | unset($quotesTempArray); |
||
| 119 | // Display Navigation |
||
| 120 | View Code Duplication | if ($quotesCount > $quotesPaginationLimit) { |
|
| 121 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
| 122 | $pagenav = new \XoopsPageNav($quotesCount, $quotesPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); |
||
| 123 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
| 124 | } |
||
| 125 | |||
| 126 | echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/randomquote_admin_quotes.tpl'); |
||
| 127 | } |
||
| 128 | |||
| 129 | break; |
||
| 130 | |||
| 131 | View Code Duplication | case 'new': |
|
| 132 | $adminObject->addItemButton(AM_RANDOMQUOTE_QUOTES_LIST, 'quotes.php', 'list'); |
||
| 133 | echo $adminObject->displayButton('left'); |
||
| 134 | |||
| 135 | $quotesObject = $quotesHandler->create(); |
||
| 136 | $form = $quotesObject->getForm(); |
||
| 137 | $form->display(); |
||
| 138 | break; |
||
| 139 | |||
| 140 | case 'save': |
||
| 141 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 142 | redirect_header('quotes.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 143 | } |
||
| 144 | if (0 != Request::getInt('id', 0)) { |
||
| 145 | $quotesObject = $quotesHandler->get(Request::getInt('id', 0)); |
||
| 146 | } else { |
||
| 147 | $quotesObject = $quotesHandler->create(); |
||
| 148 | } |
||
| 149 | // Form save fields |
||
| 150 | $quotesObject->setVar('quote', Request::getText('quote', '')); |
||
| 151 | $quotesObject->setVar('author', Request::getVar('author', '')); |
||
| 152 | $quotesObject->setVar('online', Request::getVar('online', '')); |
||
| 153 | $quotesObject->setVar('created', $_REQUEST['created']); |
||
| 154 | $quotesObject->setVar('cid', Request::getVar('cid', '')); |
||
| 155 | if ($quotesHandler->insert($quotesObject)) { |
||
| 156 | redirect_header('quotes.php?op=list', 2, AM_RANDOMQUOTE_FORMOK); |
||
| 157 | } |
||
| 158 | |||
| 159 | echo $quotesObject->getHtmlErrors(); |
||
| 160 | $form = $quotesObject->getForm(); |
||
| 161 | $form->display(); |
||
| 162 | break; |
||
| 163 | |||
| 164 | View Code Duplication | case 'edit': |
|
| 165 | $adminObject->addItemButton(AM_RANDOMQUOTE_ADD_QUOTES, 'quotes.php?op=new', 'add'); |
||
| 166 | $adminObject->addItemButton(AM_RANDOMQUOTE_QUOTES_LIST, 'quotes.php', 'list'); |
||
| 167 | echo $adminObject->displayButton('left'); |
||
| 168 | $quotesObject = $quotesHandler->get(Request::getString('id', '')); |
||
| 169 | $form = $quotesObject->getForm(); |
||
| 170 | $form->display(); |
||
| 171 | break; |
||
| 172 | |||
| 173 | View Code Duplication | case 'delete': |
|
| 174 | $quotesObject = $quotesHandler->get(Request::getString('id', '')); |
||
| 175 | if (1 == Request::getInt('ok', 0)) { |
||
| 176 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 177 | redirect_header('quotes.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 178 | } |
||
| 179 | if ($quotesHandler->delete($quotesObject)) { |
||
| 180 | redirect_header('quotes.php', 3, AM_RANDOMQUOTE_FORMDELOK); |
||
| 181 | } else { |
||
| 182 | echo $quotesObject->getHtmlErrors(); |
||
| 183 | } |
||
| 184 | } else { |
||
| 185 | xoops_confirm(['ok' => 1, 'id' => Request::getString('id', ''), 'op' => 'delete'], Request::getCmd('REQUEST_URI', '', 'SERVER'), sprintf(AM_RANDOMQUOTE_FORMSUREDEL, $quotesObject->getVar('quote'))); |
||
| 186 | } |
||
| 187 | break; |
||
| 188 | |||
| 189 | View Code Duplication | case 'clone': |
|
| 190 | |||
| 191 | $id_field = Request::getString('id', ''); |
||
| 192 | |||
| 193 | if ($utility::cloneRecord('randomquote_quotes', 'id', $id_field)) { |
||
| 194 | redirect_header('quotes.php', 3, AM_RANDOMQUOTE_CLONED_OK); |
||
| 195 | } else { |
||
| 196 | redirect_header('quotes.php', 3, AM_RANDOMQUOTE_CLONED_FAILED); |
||
| 197 | } |
||
| 198 | |||
| 199 | break; |
||
| 200 | } |
||
| 201 | require_once __DIR__ . '/admin_footer.php'; |
||
| 202 |
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: