txmodxoops /
tdmcreate
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 | namespace XoopsModules\Tdmcreate\Files\User; |
||
| 4 | |||
| 5 | use XoopsModules\Tdmcreate; |
||
| 6 | use XoopsModules\Tdmcreate\Files; |
||
| 7 | |||
| 8 | /* |
||
| 9 | You may not change or alter any portion of this comment or credits |
||
| 10 | of supporting developers from this source code or any supporting source code |
||
| 11 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful, |
||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 16 | */ |
||
| 17 | /** |
||
| 18 | * tdmcreate module. |
||
| 19 | * |
||
| 20 | * @copyright XOOPS Project (https://xoops.org) |
||
| 21 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
| 22 | * |
||
| 23 | * @since 2.5.0 |
||
| 24 | * |
||
| 25 | * @author Txmod Xoops http://www.txmodxoops.org |
||
| 26 | * |
||
| 27 | */ |
||
| 28 | defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Class UserObjects. |
||
| 32 | */ |
||
| 33 | class UserObjects_old extends Files\CreateFile |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * @public function constructor |
||
| 37 | * @param null |
||
| 38 | */ |
||
| 39 | public function __construct() |
||
| 40 | { |
||
| 41 | parent::__construct(); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @static function getInstance |
||
| 46 | * @param null |
||
| 47 | * @return UserObjects |
||
| 48 | */ |
||
| 49 | public static function getInstance() |
||
| 50 | { |
||
| 51 | static $instance = false; |
||
| 52 | if (!$instance) { |
||
| 53 | $instance = new self(); |
||
| 54 | } |
||
| 55 | |||
| 56 | return $instance; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @public function getUserHeaderTpl |
||
| 61 | * @param string $moduleDirname |
||
| 62 | * @param string $tableName |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | public function getUserHeaderTpl($moduleDirname, $tableName) |
||
| 66 | { |
||
| 67 | $ret = <<<EOT |
||
| 68 | include __DIR__ . '/header.php'; |
||
| 69 | \$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl'; |
||
| 70 | include_once XOOPS_ROOT_PATH.'/header.php';\n |
||
| 71 | EOT; |
||
| 72 | |||
| 73 | return $ret; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @public function getUserIndex |
||
| 78 | * @param string $moduleDirname |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | public function getUserIndex($moduleDirname) |
||
| 82 | { |
||
| 83 | $ret = <<<EOT |
||
| 84 | include __DIR__ . '/header.php'; |
||
| 85 | \$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_index.tpl'; |
||
| 86 | include_once XOOPS_ROOT_PATH.'/header.php';\n |
||
| 87 | EOT; |
||
| 88 | |||
| 89 | return $ret; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @public function getUserFooter |
||
| 94 | * @param null |
||
| 95 | * @return string |
||
| 96 | */ |
||
| 97 | public function getUserFooter() |
||
| 98 | { |
||
| 99 | $ret = <<<'EOT' |
||
| 100 | include __DIR__ . '/footer.php'; |
||
| 101 | EOT; |
||
| 102 | |||
| 103 | return $ret; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @public function getSimpleSetVar |
||
| 108 | * @param string $tableName |
||
| 109 | * @param string $fieldName |
||
| 110 | * @return string |
||
| 111 | */ |
||
| 112 | public function getSimpleSetVar($tableName, $fieldName) |
||
| 113 | { |
||
| 114 | $ret = <<<EOT |
||
| 115 | // Set Var {$fieldName} |
||
| 116 | \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']);\n |
||
| 117 | EOT; |
||
| 118 | |||
| 119 | return $ret; |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @public function getTextDateSelectSetVar |
||
| 124 | * @param string $tableName |
||
| 125 | * @param string $fieldName |
||
| 126 | * @return string |
||
| 127 | */ |
||
| 128 | public function getTextDateSelectSetVar($tableName, $fieldName) |
||
| 129 | { |
||
| 130 | $ret = <<<EOT |
||
| 131 | // Set Var {$fieldName} |
||
| 132 | \${$tableName}Obj->setVar('{$fieldName}', strtotime(\$_POST['{$fieldName}']));\n |
||
| 133 | EOT; |
||
| 134 | |||
| 135 | return $ret; |
||
| 136 | } |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @public function getCheckBoxOrRadioYNSetVar |
||
| 140 | * @param string $tableName |
||
| 141 | * @param string $fieldName |
||
| 142 | * @return string |
||
| 143 | */ |
||
| 144 | public function getCheckBoxOrRadioYNSetVar($tableName, $fieldName) |
||
| 145 | { |
||
| 146 | $ret = <<<EOT |
||
| 147 | // Set Var {$fieldName} |
||
| 148 | \${$tableName}Obj->setVar('{$fieldName}', ((1 == \$_REQUEST['{$fieldName}']) ? '1' : '0'));\n |
||
| 149 | EOT; |
||
| 150 | |||
| 151 | return $ret; |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @public function getUrlFileSetVar |
||
| 156 | * @param $moduleDirname |
||
| 157 | * @param $tableName |
||
| 158 | * @param $fieldName |
||
| 159 | * @return string |
||
| 160 | */ |
||
| 161 | public function getUrlFileSetVar($moduleDirname, $tableName, $fieldName) |
||
| 162 | { |
||
| 163 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 164 | $ret = <<<EOT |
||
| 165 | // Set Var {$fieldName} |
||
| 166 | \${$tableName}Obj->setVar('{$fieldName}', formatUrl(\$_REQUEST['{$fieldName}']));\n |
||
| 167 | // Set Var {$fieldName} |
||
| 168 | include_once XOOPS_ROOT_PATH.'/class/uploader.php'; |
||
| 169 | \$uploaddir = {$stuModuleDirname}_UPLOAD_PATH.'/files/{$tableName}'; |
||
| 170 | \$uploader = new \XoopsMediaUploader(\$uploaddir, \$helper->getConfig('mimetypes_file'), |
||
| 171 | \$helper->getConfig('maxsize_file'), null, null); |
||
| 172 | if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][])) { |
||
| 173 | \$uploader->fetchMedia(\$_POST['xoops_upload_file'][]); |
||
| 174 | if (!\$uploader->upload()) { |
||
| 175 | \$errors = \$uploader->getErrors(); |
||
| 176 | redirect_header('javascript:history.go(-1)', 3, \$errors); |
||
| 177 | } else { |
||
| 178 | \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); |
||
| 179 | } |
||
| 180 | }\n |
||
| 181 | EOT; |
||
| 182 | |||
| 183 | return $ret; |
||
| 184 | } |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @public function getImageListSetVar |
||
| 188 | * @param string $moduleDirname |
||
| 189 | * @param string $tableName |
||
| 190 | * @param string $fieldName |
||
| 191 | * @return string |
||
| 192 | */ |
||
| 193 | public function getImageListSetVar($moduleDirname, $tableName, $fieldName) |
||
|
0 ignored issues
–
show
|
|||
| 194 | { |
||
| 195 | $ret = <<<EOT |
||
| 196 | // Set Var {$fieldName} |
||
| 197 | include_once XOOPS_ROOT_PATH.'/class/uploader.php'; |
||
| 198 | \$uploaddir = XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32'; |
||
| 199 | \$uploader = new \XoopsMediaUploader(\$uploaddir, \$helper->getConfig('mimetypes_image'), |
||
| 200 | \$helper->getConfig('maxsize_image'), null, null); |
||
| 201 | if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][])) { |
||
| 202 | //\$uploader->setPrefix('{$fieldName}_'); |
||
| 203 | //\$uploader->fetchMedia(\$_POST['xoops_upload_file'][]); |
||
| 204 | if (!\$uploader->upload()) { |
||
| 205 | \$errors = \$uploader->getErrors(); |
||
| 206 | redirect_header('javascript:history.go(-1)', 3, \$errors); |
||
| 207 | } else { |
||
| 208 | \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); |
||
| 209 | } |
||
| 210 | } else { |
||
| 211 | \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']); |
||
| 212 | }\n |
||
| 213 | EOT; |
||
| 214 | |||
| 215 | return $ret; |
||
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @public function getUploadImageSetVar |
||
| 220 | * @param string $moduleDirname |
||
| 221 | * @param string $tableName |
||
| 222 | * @param string $fieldName |
||
| 223 | * @param $fpmf |
||
| 224 | * @return string |
||
| 225 | */ |
||
| 226 | public function getUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fpmf) |
||
| 227 | { |
||
| 228 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 229 | $ret = <<<EOT |
||
| 230 | // Set Var {$fieldName} |
||
| 231 | include_once XOOPS_ROOT_PATH.'/class/uploader.php'; |
||
| 232 | \$uploaddir = {$stuModuleDirname}_UPLOAD_PATH.'/images/{$tableName}'; |
||
| 233 | \$uploader = new \XoopsMediaUploader(\$uploaddir, \$helper->getConfig('mimetypes_image'), |
||
| 234 | \$helper->getConfig('maxsize_image'), null, null); |
||
| 235 | if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][0])) { |
||
| 236 | \$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '' , \$_FILES['attachedfile']['name']); |
||
| 237 | \$imgName = str_replace(' ', '', \$_POST['{$fpmf}']).'.'.\$extension; |
||
| 238 | \$uploader->setPrefix(\$imgName); |
||
| 239 | \$uploader->fetchMedia(\$_POST['xoops_upload_file'][0]); |
||
| 240 | if (!\$uploader->upload()) { |
||
| 241 | \$errors = \$uploader->getErrors(); |
||
| 242 | redirect_header('javascript:history.go(-1)', 3, \$errors); |
||
| 243 | } else { |
||
| 244 | \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); |
||
| 245 | } |
||
| 246 | } else { |
||
| 247 | \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']); |
||
| 248 | }\n |
||
| 249 | EOT; |
||
| 250 | |||
| 251 | return $ret; |
||
| 252 | } |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @public function getUploadFileSetVar |
||
| 256 | * @param string $moduleDirname |
||
| 257 | * @param string $tableName |
||
| 258 | * @param string $fieldName |
||
| 259 | * @return string |
||
| 260 | */ |
||
| 261 | public function getUploadFileSetVar($moduleDirname, $tableName, $fieldName) |
||
| 262 | { |
||
| 263 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 264 | $ret = <<<EOT |
||
| 265 | // Set Var {$fieldName} |
||
| 266 | include_once XOOPS_ROOT_PATH.'/class/uploader.php'; |
||
| 267 | \$uploaddir = {$stuModuleDirname}_UPLOAD_PATH.'/files/{$tableName}'; |
||
| 268 | \$uploader = new \XoopsMediaUploader(\$uploaddir, \$helper->getConfig('mimetypes_file'), |
||
| 269 | \$helper->getConfig('maxsize_file'), null, null); |
||
| 270 | if (\$uploader->fetchMedia(\$_POST['xoops_upload_file'][])) { |
||
| 271 | //\$uploader->setPrefix('{$fieldName}_') ; |
||
| 272 | //\$uploader->fetchMedia(\$_POST['xoops_upload_file'][]); |
||
| 273 | if (!\$uploader->upload()) { |
||
| 274 | \$errors = \$uploader->getErrors(); |
||
| 275 | redirect_header('javascript:history.go(-1)', 3, \$errors); |
||
| 276 | } else { |
||
| 277 | \${$tableName}Obj->setVar('{$fieldName}', \$uploader->getSavedFileName()); |
||
| 278 | } |
||
| 279 | }\n |
||
| 280 | EOT; |
||
| 281 | |||
| 282 | return $ret; |
||
| 283 | } |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @public function getUserSaveFieldId |
||
| 287 | * @param $fields |
||
| 288 | * |
||
| 289 | * @return string |
||
| 290 | */ |
||
| 291 | public function getUserSaveFieldId($fields) |
||
| 292 | { |
||
| 293 | foreach (array_keys($fields) as $f) { |
||
| 294 | if (0 == $f) { |
||
| 295 | $fieldId = $fields[$f]->getVar('field_name'); |
||
| 296 | } |
||
| 297 | } |
||
| 298 | |||
| 299 | return $fieldId; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 300 | } |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @public function getUserSaveFieldMain |
||
| 304 | * @param $fields |
||
| 305 | * |
||
| 306 | * @return string |
||
| 307 | */ |
||
| 308 | public function getUserSaveFieldMain($fields) |
||
| 309 | { |
||
| 310 | foreach (array_keys($fields) as $f) { |
||
| 311 | if (1 == $fields[$f]->getVar('field_main')) { |
||
| 312 | $fieldMain = $fields[$f]->getVar('field_name'); |
||
| 313 | } |
||
| 314 | } |
||
| 315 | |||
| 316 | return $fieldMain; |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 317 | } |
||
| 318 | |||
| 319 | /** |
||
| 320 | * @public function getUserSaveElements |
||
| 321 | * @param $moduleDirname |
||
| 322 | * @param $tableName |
||
| 323 | * @param $fields |
||
| 324 | * |
||
| 325 | * @return string |
||
| 326 | */ |
||
| 327 | public function getUserSaveElements($moduleDirname, $tableName, $fields) |
||
| 328 | { |
||
| 329 | $ret = ''; |
||
| 330 | foreach (array_keys($fields) as $f) { |
||
| 331 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 332 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
| 333 | if (1 == $fields[$f]->getVar('field_main')) { |
||
| 334 | $fieldMain = $fieldName; |
||
| 335 | } |
||
| 336 | if ((5 == $fieldElement) || (6 == $fieldElement)) { |
||
| 337 | $ret .= $this->getCheckBoxOrRadioYNSetVar($tableName, $fieldName); |
||
| 338 | } elseif (13 == $fieldElement) { |
||
| 339 | $ret .= $this->getUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 340 | } elseif (14 == $fieldElement) { |
||
| 341 | $ret .= $this->getUploadFileSetVar($moduleDirname, $tableName, $fieldName); |
||
| 342 | } elseif (15 == $fieldElement) { |
||
| 343 | $ret .= $this->getTextDateSelectSetVar($tableName, $fieldName); |
||
| 344 | } else { |
||
| 345 | $ret .= $this->getSimpleSetVar($tableName, $fieldName); |
||
| 346 | } |
||
| 347 | } |
||
| 348 | |||
| 349 | return $ret; |
||
| 350 | } |
||
| 351 | |||
| 352 | /** |
||
| 353 | * @public function getSimpleGetVar |
||
| 354 | * @param string $lpFieldName |
||
| 355 | * @param string $rpFieldName |
||
| 356 | * @param string $tableName |
||
| 357 | * @param string $fieldName |
||
| 358 | * @return string |
||
| 359 | */ |
||
| 360 | public function getSimpleGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||
| 361 | { |
||
| 362 | $ret = <<<EOT |
||
| 363 | \t\t// Get Var {$fieldName} |
||
| 364 | \t\t\${$lpFieldName}['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n |
||
| 365 | EOT; |
||
| 366 | |||
| 367 | return $ret; |
||
| 368 | } |
||
| 369 | |||
| 370 | /** |
||
| 371 | * @public function getTopicGetVar |
||
| 372 | * @param string $lpFieldName |
||
| 373 | * @param string $rpFieldName |
||
| 374 | * @param string $tableName |
||
| 375 | * @param string $tableNameTopic |
||
| 376 | * @param string $fieldNameParent |
||
| 377 | * @param string $fieldNameTopic |
||
| 378 | * @return string |
||
| 379 | */ |
||
| 380 | public function getTopicGetVar($lpFieldName, $rpFieldName, $tableName, $tableNameTopic, $fieldNameParent, $fieldNameTopic) |
||
| 381 | { |
||
| 382 | $ret = <<<EOT |
||
| 383 | \t\t// Get Var {$fieldNameParent} |
||
| 384 | \t\t\${$rpFieldName} =& \${$tableNameTopic}Handler->get(\${$tableName}All[\$i]->getVar('{$fieldNameParent}')); |
||
| 385 | \t\t\${$lpFieldName}['{$rpFieldName}'] = \${$rpFieldName}->getVar('{$fieldNameTopic}');\n |
||
| 386 | EOT; |
||
| 387 | |||
| 388 | return $ret; |
||
| 389 | } |
||
| 390 | |||
| 391 | /** |
||
| 392 | * @public function getUploadImageGetVar |
||
| 393 | * @param string $lpFieldName |
||
| 394 | * @param string $rpFieldName |
||
| 395 | * @param string $tableName |
||
| 396 | * @param string $fieldName |
||
| 397 | * @return string |
||
| 398 | */ |
||
| 399 | public function getUploadImageGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||
| 400 | { |
||
| 401 | $ret = <<<EOT |
||
| 402 | \t\t// Get Var {$fieldName} |
||
| 403 | \t\t\${$fieldName} = \${$tableName}All[\$i]->getVar('{$fieldName}'); |
||
| 404 | \t\t\$upload_image = \${$fieldName} ? \${$fieldName} : 'blank.gif'; |
||
| 405 | \t\t\${$lpFieldName}['{$rpFieldName}'] = \$upload_image;\n |
||
| 406 | EOT; |
||
| 407 | |||
| 408 | return $ret; |
||
| 409 | } |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @public function getUrlFileGetVar |
||
| 413 | * @param string $lpFieldName |
||
| 414 | * @param string $rpFieldName |
||
| 415 | * @param string $tableName |
||
| 416 | * @param string $fieldName |
||
| 417 | * @return string |
||
| 418 | */ |
||
| 419 | public function getUrlFileGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||
| 420 | { |
||
| 421 | $ret = <<<EOT |
||
| 422 | \t\t\t\t// Get Var {$fieldName} |
||
| 423 | \t\t\t\t\${$lpFieldName}['{$rpFieldName}'] = \${$tableName}All[\$i]->getVar('{$fieldName}');\n |
||
| 424 | EOT; |
||
| 425 | |||
| 426 | return $ret; |
||
| 427 | } |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @public function getTextAreaGetVar |
||
| 431 | * @param string $lpFieldName |
||
| 432 | * @param string $rpFieldName |
||
| 433 | * @param string $tableName |
||
| 434 | * @param string $fieldName |
||
| 435 | * @return string |
||
| 436 | */ |
||
| 437 | public function getTextAreaGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||
| 438 | { |
||
| 439 | $ret = <<<EOT |
||
| 440 | \t\t// Get Var {$fieldName} |
||
| 441 | \t\t\${$lpFieldName}['{$rpFieldName}'] = strip_tags(\${$tableName}All[\$i]->getVar('{$fieldName}'));\n |
||
| 442 | EOT; |
||
| 443 | |||
| 444 | return $ret; |
||
| 445 | } |
||
| 446 | |||
| 447 | /** |
||
| 448 | * @public function getSelectUserGetVar |
||
| 449 | * @param string $lpFieldName |
||
| 450 | * @param string $rpFieldName |
||
| 451 | * @param string $tableName |
||
| 452 | * @param string $fieldName |
||
| 453 | * @return string |
||
| 454 | */ |
||
| 455 | public function getSelectUserGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||
| 456 | { |
||
| 457 | $ret = <<<EOT |
||
| 458 | \t\t// Get Var {$fieldName} |
||
| 459 | \t\t\${$lpFieldName}['{$rpFieldName}'] = \XoopsUser::getUnameFromId(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n |
||
| 460 | EOT; |
||
| 461 | |||
| 462 | return $ret; |
||
| 463 | } |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @public function getTextDateSelectGetVar |
||
| 467 | * @param string $lpFieldName |
||
| 468 | * @param string $rpFieldName |
||
| 469 | * @param string $tableName |
||
| 470 | * @param string $fieldName |
||
| 471 | * @return string |
||
| 472 | */ |
||
| 473 | public function getTextDateSelectGetVar($lpFieldName, $rpFieldName, $tableName, $fieldName) |
||
| 474 | { |
||
| 475 | $ret = <<<EOT |
||
| 476 | \t\t// Get Var {$fieldName} |
||
| 477 | \t\t\${$lpFieldName}['{$rpFieldName}'] = formatTimeStamp(\${$tableName}All[\$i]->getVar('{$fieldName}'), 's');\n |
||
| 478 | EOT; |
||
| 479 | |||
| 480 | return $ret; |
||
| 481 | } |
||
| 482 | } |
||
| 483 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.