mambax7 /
tdmcreate-1.91
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 | /* |
||||||
| 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 | * tdmcreate module. |
||||||
| 14 | * |
||||||
| 15 | * @copyright XOOPS Project (https://xoops.org) |
||||||
| 16 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||||
| 17 | * |
||||||
| 18 | * @since 2.5.0 |
||||||
| 19 | * |
||||||
| 20 | * @author trabis <[email protected]> |
||||||
| 21 | * |
||||||
| 22 | * @version $Id: helper.php 12258 2014-04-12 23:45:12Z timgno $ |
||||||
| 23 | */ |
||||||
| 24 | |||||||
| 25 | /** |
||||||
| 26 | * Class TDMCreateHelper. |
||||||
| 27 | */ |
||||||
| 28 | class TDMCreateHelper |
||||||
| 29 | { |
||||||
| 30 | /** |
||||||
| 31 | * @var string |
||||||
| 32 | */ |
||||||
| 33 | private $dirname; |
||||||
| 34 | /** |
||||||
| 35 | * @var string |
||||||
| 36 | */ |
||||||
| 37 | private $module; |
||||||
| 38 | /** |
||||||
| 39 | * @var string |
||||||
| 40 | */ |
||||||
| 41 | private $handler; |
||||||
| 42 | /** |
||||||
| 43 | * @var string |
||||||
| 44 | */ |
||||||
| 45 | private $config; |
||||||
| 46 | /** |
||||||
| 47 | * @var string |
||||||
| 48 | */ |
||||||
| 49 | private $debug; |
||||||
| 50 | /* |
||||||
| 51 | * @protected function constructor class |
||||||
| 52 | * @param mixed $debug |
||||||
| 53 | */ |
||||||
| 54 | /** |
||||||
| 55 | * @param $debug |
||||||
| 56 | */ |
||||||
| 57 | public function __construct($debug) |
||||||
| 58 | { |
||||||
| 59 | $this->debug = $debug; |
||||||
| 60 | $this->dirname = basename(dirname(__DIR__)); |
||||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | /* |
||||||
| 64 | * @static function getInstance |
||||||
| 65 | * @param mixed $debug |
||||||
| 66 | */ |
||||||
| 67 | /** |
||||||
| 68 | * @param bool $debug |
||||||
| 69 | * |
||||||
| 70 | * @return Tdmcreate\Helper |
||||||
| 71 | */ |
||||||
| 72 | public static function getInstance($debug = false) |
||||||
| 73 | { |
||||||
| 74 | static $instance = false; |
||||||
| 75 | if (!$instance) { |
||||||
| 76 | $instance = new self($debug); |
||||||
| 77 | } |
||||||
| 78 | |||||||
| 79 | return $instance; |
||||||
| 80 | } |
||||||
| 81 | |||||||
| 82 | /* |
||||||
| 83 | * @static function getModule |
||||||
| 84 | * @param null |
||||||
| 85 | */ |
||||||
| 86 | /** |
||||||
| 87 | * @return string |
||||||
| 88 | */ |
||||||
| 89 | public function &getModule() |
||||||
| 90 | { |
||||||
| 91 | if (null === $this->module) { |
||||||
| 92 | $this->initModule(); |
||||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | return $this->module; |
||||||
| 96 | } |
||||||
| 97 | |||||||
| 98 | /* |
||||||
| 99 | * @static function getConfig |
||||||
| 100 | * @param string $name |
||||||
| 101 | */ |
||||||
| 102 | /** |
||||||
| 103 | * @param null $name |
||||||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||||||
| 104 | * |
||||||
| 105 | * @return null|string |
||||||
| 106 | */ |
||||||
| 107 | public function getConfig($name = null) |
||||||
| 108 | { |
||||||
| 109 | if (null === $this->config) { |
||||||
| 110 | $this->initConfig(); |
||||||
| 111 | } |
||||||
| 112 | if (!$name) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 113 | $this->addLog('Getting all config'); |
||||||
| 114 | |||||||
| 115 | return $this->config; |
||||||
| 116 | } |
||||||
| 117 | if (!isset($this->config[$name])) { |
||||||
| 118 | $this->addLog("ERROR :: CONFIG '{$name}' does not exist"); |
||||||
| 119 | |||||||
| 120 | return false; |
||||||
| 121 | } |
||||||
| 122 | $this->addLog("Getting config '{$name}' : ".$this->config[$name]); |
||||||
| 123 | |||||||
| 124 | return $this->config[$name]; |
||||||
| 125 | } |
||||||
| 126 | |||||||
| 127 | /* |
||||||
| 128 | * @static function setConfig |
||||||
| 129 | * @param string $name |
||||||
| 130 | * @param mixed $value |
||||||
| 131 | */ |
||||||
| 132 | /** |
||||||
| 133 | * @param null $name |
||||||
|
0 ignored issues
–
show
|
|||||||
| 134 | * @param null $value |
||||||
|
0 ignored issues
–
show
|
|||||||
| 135 | * |
||||||
| 136 | * @return mixed |
||||||
| 137 | */ |
||||||
| 138 | public function setConfig($name = null, $value = null) |
||||||
| 139 | { |
||||||
| 140 | if (null === $this->config) { |
||||||
| 141 | $this->initConfig(); |
||||||
| 142 | } |
||||||
| 143 | $this->config[$name] = $value; |
||||||
| 144 | $this->addLog("Setting config '{$name}' : ".$this->config[$name]); |
||||||
| 145 | |||||||
| 146 | return $this->config[$name]; |
||||||
| 147 | } |
||||||
| 148 | |||||||
| 149 | /* |
||||||
| 150 | * @static function getHandler |
||||||
| 151 | * @param string $name |
||||||
| 152 | */ |
||||||
| 153 | /** |
||||||
| 154 | * @param $name |
||||||
| 155 | * |
||||||
| 156 | * @return mixed |
||||||
| 157 | */ |
||||||
| 158 | public function &getHandler($name) |
||||||
| 159 | { |
||||||
| 160 | if (!isset($this->handler[$name.'Handler'])) { |
||||||
| 161 | $this->initHandler($name); |
||||||
| 162 | } |
||||||
| 163 | $this->addLog("Getting handler '{$name}'"); |
||||||
| 164 | |||||||
| 165 | return $this->handler[$name.'Handler']; |
||||||
| 166 | } |
||||||
| 167 | |||||||
| 168 | /* |
||||||
| 169 | * @static function initModule |
||||||
| 170 | * @param null |
||||||
| 171 | */ |
||||||
| 172 | public function initModule() |
||||||
| 173 | { |
||||||
| 174 | global $xoopsModule; |
||||||
| 175 | if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $this->dirname) { |
||||||
| 176 | $this->module = $xoopsModule; |
||||||
|
0 ignored issues
–
show
It seems like
$xoopsModule of type object is incompatible with the declared type string of property $module.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||||||
| 177 | } else { |
||||||
| 178 | $hModule = xoops_getHandler('module'); |
||||||
| 179 | $this->module = $hModule->getByDirname($this->dirname); |
||||||
|
0 ignored issues
–
show
The method
getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 180 | } |
||||||
| 181 | $this->addLog('INIT MODULE'); |
||||||
| 182 | } |
||||||
| 183 | |||||||
| 184 | /* |
||||||
| 185 | * @static function initConfig |
||||||
| 186 | * @param null |
||||||
| 187 | */ |
||||||
| 188 | public function initConfig() |
||||||
| 189 | { |
||||||
| 190 | $this->addLog('INIT CONFIG'); |
||||||
| 191 | $hModConfig = xoops_getHandler('config'); |
||||||
| 192 | $this->config = $hModConfig->getConfigsByCat(0, $this->getModule()->getVar('mid')); |
||||||
|
0 ignored issues
–
show
The method
getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 193 | } |
||||||
| 194 | |||||||
| 195 | /* |
||||||
| 196 | * @static function initHandler |
||||||
| 197 | * @param string $name |
||||||
| 198 | */ |
||||||
| 199 | /** |
||||||
| 200 | * @param $name |
||||||
| 201 | */ |
||||||
| 202 | public function initHandler($name) |
||||||
| 203 | { |
||||||
| 204 | $this->addLog('INIT '.$name.' HANDLER'); |
||||||
| 205 | $this->handler[$name.'Handler'] = xoops_getModuleHandler($name, $this->dirname); |
||||||
| 206 | } |
||||||
| 207 | |||||||
| 208 | /* |
||||||
| 209 | * @static function addLog |
||||||
| 210 | * @param string $log |
||||||
| 211 | */ |
||||||
| 212 | /** |
||||||
| 213 | * @param $log |
||||||
| 214 | */ |
||||||
| 215 | public function addLog($log) |
||||||
| 216 | { |
||||||
| 217 | if ($this->debug && is_object($GLOBALS['xoopsLogger'])) { |
||||||
| 218 | $GLOBALS['xoopsLogger']->addExtra($this->module->name(), $log); |
||||||
| 219 | } |
||||||
| 220 | } |
||||||
| 221 | } |
||||||
| 222 |