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\Includes; |
||||||
| 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 | |||||||
| 29 | /** |
||||||
| 30 | * Class IncludeCommon. |
||||||
| 31 | */ |
||||||
| 32 | class IncludeCommon extends Files\CreateFile |
||||||
| 33 | { |
||||||
| 34 | /** |
||||||
| 35 | * @public function constructor |
||||||
| 36 | * @param null |
||||||
| 37 | */ |
||||||
| 38 | public function __construct() |
||||||
| 39 | { |
||||||
| 40 | parent::__construct(); |
||||||
| 41 | } |
||||||
| 42 | |||||||
| 43 | /** |
||||||
| 44 | * @static function getInstance |
||||||
| 45 | * @param null |
||||||
| 46 | * @return IncludeCommon |
||||||
| 47 | */ |
||||||
| 48 | public static function getInstance() |
||||||
| 49 | { |
||||||
| 50 | static $instance = false; |
||||||
| 51 | if (!$instance) { |
||||||
| 52 | $instance = new self(); |
||||||
| 53 | } |
||||||
| 54 | |||||||
| 55 | return $instance; |
||||||
| 56 | } |
||||||
| 57 | |||||||
| 58 | /** |
||||||
| 59 | * @public function write |
||||||
| 60 | * @param string $module |
||||||
| 61 | * @param object $table |
||||||
| 62 | * @param string $filename |
||||||
| 63 | */ |
||||||
| 64 | public function write($module, $table, $filename) |
||||||
| 65 | { |
||||||
| 66 | $this->setModule($module); |
||||||
| 67 | $this->setTable($table); |
||||||
| 68 | $this->setFileName($filename); |
||||||
| 69 | } |
||||||
| 70 | |||||||
| 71 | /** |
||||||
| 72 | * @param $modDirname |
||||||
| 73 | * @param $const |
||||||
| 74 | * @param $desc |
||||||
| 75 | * @return string |
||||||
| 76 | */ |
||||||
| 77 | private function getCommonDefines($modDirname, $const, $desc) |
||||||
| 78 | { |
||||||
| 79 | $stuModDirname = mb_strtoupper($modDirname); |
||||||
| 80 | |||||||
| 81 | return "define('{$stuModDirname}_{$const}', {$desc});\n"; |
||||||
| 82 | } |
||||||
| 83 | |||||||
| 84 | /** |
||||||
| 85 | * @private function getCommonCode |
||||||
| 86 | * @param \XoopsObject $module |
||||||
| 87 | * @return string |
||||||
| 88 | */ |
||||||
| 89 | private function getCommonCode($module) |
||||||
| 90 | { |
||||||
| 91 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||
| 92 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||
| 93 | $hc = Tdmcreate\Files\CreateHtmlCode::getInstance(); |
||||||
| 94 | $table = $this->getTable(); |
||||||
| 95 | $moduleDirname = $module->getVar('mod_dirname'); |
||||||
| 96 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 97 | $moduleAuthor = $module->getVar('mod_author'); |
||||||
| 98 | $moduleAuthorWebsiteName = $module->getVar('mod_author_website_name'); |
||||||
| 99 | $moduleAuthorWebsiteUrl = $module->getVar('mod_author_website_url'); |
||||||
| 100 | $moduleAuthorImage = str_replace(' ', '', mb_strtolower($moduleAuthor)); |
||||||
|
0 ignored issues
–
show
It seems like
$moduleAuthor can also be of type array and array; however, parameter $str of mb_strtolower() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 101 | |||||||
| 102 | $contIf = $pc->getPhpCodeDefine('XOOPS_ICONS32_PATH', "XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32'", "\t"); |
||||||
| 103 | $ret = $pc->getPhpCodeConditions("!defined('XOOPS_ICONS32_PATH')", '','', $contIf, false); |
||||||
| 104 | $contIf = $pc->getPhpCodeDefine('XOOPS_ICONS32_URL', "XOOPS_URL . '/Frameworks/moduleclasses/icons/32'", "\t"); |
||||||
| 105 | $ret .= $pc->getPhpCodeConditions("!defined('XOOPS_ICONS32_URL')", '','', $contIf, false); |
||||||
| 106 | $ret .= $this->getCommonDefines($moduleDirname, 'DIRNAME', "'{$moduleDirname}'"); |
||||||
| 107 | $ret .= $this->getCommonDefines($moduleDirname, 'PATH', "XOOPS_ROOT_PATH.'/modules/'.{$stuModuleDirname}_DIRNAME"); |
||||||
| 108 | $ret .= $this->getCommonDefines($moduleDirname, 'URL', "XOOPS_URL.'/modules/'.{$stuModuleDirname}_DIRNAME"); |
||||||
| 109 | $ret .= $this->getCommonDefines($moduleDirname, 'ICONS_PATH', "{$stuModuleDirname}_PATH.'/assets/icons'"); |
||||||
| 110 | $ret .= $this->getCommonDefines($moduleDirname, 'ICONS_URL', "{$stuModuleDirname}_URL.'/assets/icons'"); |
||||||
| 111 | $ret .= $this->getCommonDefines($moduleDirname, 'IMAGE_PATH', "{$stuModuleDirname}_PATH.'/assets/images'"); |
||||||
| 112 | $ret .= $this->getCommonDefines($moduleDirname, 'IMAGE_URL', "{$stuModuleDirname}_URL.'/assets/images'"); |
||||||
| 113 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_PATH', "XOOPS_UPLOAD_PATH.'/'.{$stuModuleDirname}_DIRNAME"); |
||||||
| 114 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_URL', "XOOPS_UPLOAD_URL.'/'.{$stuModuleDirname}_DIRNAME"); |
||||||
| 115 | |||||||
| 116 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||||||
| 117 | $fieldElement = []; |
||||||
| 118 | foreach (array_keys($fields) as $f) { |
||||||
| 119 | $fieldElement[] = $fields[$f]->getVar('field_element'); |
||||||
| 120 | } |
||||||
| 121 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_FILES_PATH', "{$stuModuleDirname}_UPLOAD_PATH.'/files'"); |
||||||
| 122 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_FILES_URL', "{$stuModuleDirname}_UPLOAD_URL.'/files'"); |
||||||
| 123 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_IMAGE_PATH', "{$stuModuleDirname}_UPLOAD_PATH.'/images'"); |
||||||
| 124 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_IMAGE_URL', "{$stuModuleDirname}_UPLOAD_URL.'/images'"); |
||||||
| 125 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_SHOTS_PATH', "{$stuModuleDirname}_UPLOAD_PATH.'/images/shots'"); |
||||||
| 126 | $ret .= $this->getCommonDefines($moduleDirname, 'UPLOAD_SHOTS_URL', "{$stuModuleDirname}_UPLOAD_URL.'/images/shots'"); |
||||||
| 127 | $ret .= $this->getCommonDefines($moduleDirname, 'ADMIN', "{$stuModuleDirname}_URL . '/admin/index.php'"); |
||||||
| 128 | $ret .= $xc->getXcEqualsOperator('$localLogo', "{$stuModuleDirname}_IMAGE_URL . '/{$moduleAuthorImage}_logo.png'"); |
||||||
| 129 | $ret .= $pc->getPhpCodeCommentLine('Module Information'); |
||||||
| 130 | |||||||
| 131 | $img = $hc->getHtmlImage('".$localLogo."', $moduleAuthorWebsiteName); |
||||||
|
0 ignored issues
–
show
It seems like
$moduleAuthorWebsiteName can also be of type array and array; however, parameter $alt of XoopsModules\Tdmcreate\F...tmlCode::getHtmlImage() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 132 | $anchor = $hc->getHtmlAnchor($moduleAuthorWebsiteUrl, $img, $moduleAuthorWebsiteName, '_blank', '', '', '', "\n"); |
||||||
|
0 ignored issues
–
show
It seems like
$moduleAuthorWebsiteUrl can also be of type array and array; however, parameter $url of XoopsModules\Tdmcreate\F...mlCode::getHtmlAnchor() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
$moduleAuthorWebsiteName can also be of type array and array; however, parameter $title of XoopsModules\Tdmcreate\F...mlCode::getHtmlAnchor() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 133 | $replace = $xc->getXcEqualsOperator('$copyright', '"' . $anchor . '"'); |
||||||
| 134 | $ret .= str_replace("\n", '', $replace) . PHP_EOL; |
||||||
| 135 | $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/xoopsrequest', true); |
||||||
| 136 | $ret .= $pc->getPhpCodeIncludeDir("{$stuModuleDirname}_PATH", 'class/helper', true); |
||||||
| 137 | $ret .= $pc->getPhpCodeIncludeDir("{$stuModuleDirname}_PATH", 'include/functions', true); |
||||||
| 138 | |||||||
| 139 | return $ret; |
||||||
| 140 | } |
||||||
| 141 | |||||||
| 142 | /** |
||||||
| 143 | * @public function render |
||||||
| 144 | * @param null |
||||||
| 145 | * @return bool|string |
||||||
| 146 | */ |
||||||
| 147 | public function render() |
||||||
| 148 | { |
||||||
| 149 | $module = $this->getModule(); |
||||||
| 150 | $moduleDirname = $module->getVar('mod_dirname'); |
||||||
| 151 | $filename = $this->getFileName(); |
||||||
| 152 | $content = $this->getHeaderFilesComments($module); |
||||||
| 153 | $content .= $this->getCommonCode($module); |
||||||
| 154 | $this->create($moduleDirname, 'include', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||||||
| 155 | |||||||
| 156 | return $this->renderFile(); |
||||||
| 157 | } |
||||||
| 158 | } |
||||||
| 159 |