XoopsModules25x /
mymenus
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 namespace XoopsModules\Mymenus\Plugins\Dynamic; |
||||
| 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 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 15 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
||||
| 16 | * @package Mymenus |
||||
| 17 | * @since 1.0 |
||||
| 18 | * @author trabis <[email protected]> |
||||
| 19 | */ |
||||
| 20 | |||||
| 21 | use XoopsModules\Mymenus; |
||||
| 22 | |||||
| 23 | defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||
| 24 | |||||
| 25 | /** |
||||
| 26 | * Class PluginItem |
||||
| 27 | */ |
||||
| 28 | class PluginItem extends Mymenus\PluginItem |
||||
| 29 | { |
||||
| 30 | public static function eventEnd() |
||||
| 31 | { |
||||
| 32 | $newmenus = []; |
||||
| 33 | $registry = Mymenus\Registry::getInstance(); |
||||
| 34 | $menus = $registry->getEntry('menus'); |
||||
|
0 ignored issues
–
show
|
|||||
| 35 | foreach ($menus as $menu) { |
||||
|
0 ignored issues
–
show
|
|||||
| 36 | if (!preg_match('/{(MODULE\|.*)}/i', $menu['title'], $reg)) { |
||||
| 37 | $newmenus[] = $menu; |
||||
| 38 | continue; |
||||
| 39 | } |
||||
| 40 | $result = array_map('mb_strtolower', explode('|', $reg[1])); |
||||
| 41 | $moduleMenus = self::getModuleMenus($result[1], $menu['pid']); |
||||
| 42 | foreach ($moduleMenus as $mMenu) { |
||||
| 43 | $newmenus[] = $mMenu; |
||||
| 44 | } |
||||
| 45 | } |
||||
| 46 | $registry->setEntry('menus', $newmenus); |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | /** |
||||
| 50 | * @param $module |
||||
| 51 | * @param $pid |
||||
| 52 | * |
||||
| 53 | * @return array |
||||
| 54 | */ |
||||
| 55 | protected static function getModuleMenus($module, $pid) |
||||
| 56 | { |
||||
| 57 | global $xoopsModule; |
||||
| 58 | static $id = -1; |
||||
| 59 | /** @var \XoopsModules\Mymenus\Helper $helper */ |
||||
| 60 | $helper = \XoopsModules\Mymenus\Helper::getInstance(); |
||||
| 61 | |||||
| 62 | |||||
| 63 | $ret = []; |
||||
| 64 | //Sanitizing $module |
||||
| 65 | if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $module)) { |
||||
| 66 | return $ret; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | $path = "modules/{$module}"; |
||||
| 70 | $file = $GLOBALS['xoops']->path("{$path}/xoops_version.php"); |
||||
| 71 | |||||
| 72 | if (!file_exists($file)) { |
||||
| 73 | return $ret; |
||||
| 74 | } |
||||
| 75 | $helper->loadLanguage('modinfo'); |
||||
| 76 | |||||
| 77 | |||||
| 78 | $overwrite = false; |
||||
| 79 | if (true === $force) { //can set to false for debug |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 80 | if (!($xoopsModule instanceof \XoopsModule) || ($xoopsModule->getVar('dirname') != $module)) { |
||||
| 81 | // @TODO: check the following 2 statements, they're basically just assigns - is this intended? |
||||
| 82 | $_xoopsModule = ($xoopsModule instanceof \XoopsModule) ? $xoopsModule : $xoopsModule; |
||||
| 83 | $_xoopsModuleConfig = is_object($xoopsModuleConfig) ? $xoopsModuleConfig : $xoopsModuleConfig; |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 84 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||
| 85 | $moduleHandler = xoops_getHandler('module'); |
||||
|
0 ignored issues
–
show
The function
xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 86 | $xoopsModule = $moduleHandler->getByDirname($module); |
||||
| 87 | $GLOBALS['xoopsModule'] = $xoopsModule; |
||||
| 88 | if ($xoopsModule instanceof \XoopsModule) { |
||||
| 89 | /** @var \XoopsConfigHandler $configHandler */ |
||||
| 90 | $configHandler = xoops_getHandler('config'); |
||||
| 91 | $xoopsModuleConfig = $configHandler->getConfigsByCat(0, $xoopsModule->getVar('mid')); |
||||
| 92 | $GLOBALS['xoopsModuleConfig'] = $xoopsModuleConfig; |
||||
| 93 | } |
||||
| 94 | $overwrite = true; |
||||
| 95 | } |
||||
| 96 | } |
||||
| 97 | $modversion['sub'] = []; |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 98 | require $file; |
||||
| 99 | |||||
| 100 | /** @var \XoopsModules\Mymenus\LinksHandler $linksHandler */ |
||||
| 101 | $linksHandler = $helper->getHandler('Links'); |
||||
| 102 | foreach ($modversion['sub'] as $links) { |
||||
| 103 | $obj = $linksHandler->create(); |
||||
| 104 | $obj->setVars([ |
||||
| 105 | 'title' => $links['name'], |
||||
| 106 | 'alt_title' => $links['name'], |
||||
| 107 | 'link' => $GLOBALS['xoops']->url("{$path}/{$links['url']}"), |
||||
| 108 | 'id' => $id, |
||||
| 109 | 'pid' => (int)$pid |
||||
| 110 | ]); |
||||
| 111 | $ret[] = $obj->getValues(); |
||||
| 112 | $id--; |
||||
| 113 | } |
||||
| 114 | |||||
| 115 | if ($overwrite) { |
||||
| 116 | $xoopsModule = $_xoopsModule; |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 117 | $GLOBALS['xoopsModule'] = $xoopsModule; |
||||
| 118 | $xoopsModuleConfig = $_xoopsModuleConfig; |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 119 | $GLOBALS['xoopsModuleConfig'] = $xoopsModuleConfig; |
||||
| 120 | } |
||||
| 121 | |||||
| 122 | return $ret; |
||||
| 123 | } |
||||
| 124 | } |
||||
| 125 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.