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 | |||
| 29 | /** |
||
| 30 | * Class UserIndex. |
||
| 31 | */ |
||
| 32 | class UserIndex 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 UserIndex |
||
| 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 $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 | * @private function getTemplateHeaderFile |
||
| 73 | * @param $moduleDirname |
||
| 74 | * |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | private function getTemplateHeaderFile($moduleDirname) |
||
| 78 | { |
||
| 79 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 80 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 81 | $uxc = UserXoopsCode::getInstance(); |
||
| 82 | $ret = $this->getInclude(); |
||
| 83 | $ret .= $uxc->getUserTplMain($moduleDirname); |
||
| 84 | $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); |
||
| 85 | $ret .= $pc->getPhpCodeCommentLine('Define Stylesheet'); |
||
| 86 | $ret .= $xc->getXcXoThemeAddStylesheet(); |
||
| 87 | $ret .= $pc->getPhpCodeArray('keywords', null, false, ''); |
||
| 88 | |||
| 89 | return $ret; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @private function getBodyCategoriesIndex |
||
| 94 | * @param $tableMid |
||
| 95 | * @param $tableId |
||
| 96 | * @param $tableName |
||
| 97 | * @param $tableSoleName |
||
| 98 | * @param $tableFieldname |
||
| 99 | * @return string |
||
| 100 | */ |
||
| 101 | private function getBodyCategoriesIndex($tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname) |
||
| 102 | { |
||
| 103 | // Fields |
||
| 104 | $fields = $this->getTableFields($tableMid, $tableId); |
||
| 105 | $fieldParentId = []; |
||
| 106 | foreach (array_keys($fields) as $f) { |
||
| 107 | $fieldParentId[] = $fields[$f]->getVar('field_parent'); |
||
| 108 | } |
||
| 109 | $ret = ''; |
||
| 110 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 111 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 112 | if (in_array(1, $fieldParentId)) { |
||
| 113 | $ret .= $xc->getXcHandlerCountObj($tableName); |
||
| 114 | $ret .= $pc->getPhpCodeCommentLine('If there are ', $tableName); |
||
| 115 | $ret .= $this->getSimpleString('$count = 1;'); |
||
| 116 | |||
| 117 | $contentIf = $xc->getXcHandlerAllObj($tableName, '', 0, 0, "\t"); |
||
| 118 | $contentIf .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/tree', true, false, 'include', "\t"); |
||
| 119 | //$contentIf .= $cc->getClassXoopsObjectTree('mytree', $tableName, $fieldId, $fieldParent, "\t"); |
||
| 120 | $contentIf .= $pc->getPhpCodeArray($tableName, "\t"); |
||
| 121 | $foreach = $xc->getXcGetValues($tableName, $tableSoleName . 'Values', $tableFieldname, false, "\t\t"); |
||
| 122 | $foreach .= $pc->getPhpCodeArray('acount', ["'count'", '$count']); |
||
| 123 | $foreach .= $pc->getPhpCodeArrayType($tableName, 'merge', $tableSoleName . 'Values', '$acount'); |
||
| 124 | $foreach .= $this->getSimpleString('++$count;', "\t\t"); |
||
| 125 | $contentIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, $tableFieldname, $foreach, "\t"); |
||
| 126 | $contentIf .= $xc->getXcXoopsTplAssign($tableName, '$' . $tableName, true, "\t"); |
||
| 127 | $contentIf .= $pc->getPhpCodeUnset($tableName, "\t"); |
||
| 128 | $getConfig = $xc->getXcGetConfig('numb_col'); |
||
| 129 | $contentIf .= $xc->getXcXoopsTplAssign('numb_col', $getConfig, true, "\t"); |
||
| 130 | $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contentIf, false); |
||
| 131 | $ret .= $pc->getPhpCodeUnset('count'); |
||
| 132 | } |
||
| 133 | unset($fieldParentId); |
||
| 134 | |||
| 135 | return $ret; |
||
| 136 | } |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @private function getBodyPagesIndex |
||
| 140 | * @param $moduleDirname |
||
| 141 | * @param $tableName |
||
| 142 | * @param $tableSoleName |
||
| 143 | * @param $language |
||
| 144 | * @return string |
||
| 145 | */ |
||
| 146 | private function getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, $language) |
||
| 147 | { |
||
| 148 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 149 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 150 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 151 | $ucfTableName = ucfirst($tableName); |
||
| 152 | $ret = $pc->getPhpCodeCommentLine(); |
||
| 153 | $ret .= $xc->getXcXoopsTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
||
| 154 | $ret .= $xc->getXcXoopsTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL"); |
||
| 155 | $ret .= $pc->getPhpCodeCommentLine(); |
||
| 156 | $ret .= $xc->getXcHandlerCountObj($tableName); |
||
| 157 | $ret .= $xc->getXcXoopsTplAssign($tableName . 'Count', "\${$tableName}Count"); |
||
| 158 | $ret .= $this->getSimpleString('$count = 1;'); |
||
| 159 | $condIf = $xc->getXcXoopsRequest('start', 'start', '0', 'Int', false, "\t"); |
||
| 160 | $userpager = $xc->getXcGetConfig('userpager'); |
||
| 161 | $condIf .= $xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int', false, "\t"); |
||
| 162 | $condIf .= $xc->getXcHandlerAllObj($tableName, '', '$start', '$limit', "\t"); |
||
| 163 | $condIf .= $pc->getPhpCodeCommentLine('Get All', $ucfTableName, "\t"); |
||
| 164 | $condIf .= $pc->getPhpCodeArray($tableName, null, false, "\t"); |
||
| 165 | $foreach = $xc->getXcGetValues($tableName, $tableSoleName, 'i', false, "\t\t"); |
||
| 166 | $foreach .= $pc->getPhpCodeArray('acount', ["'count'", '$count']); |
||
| 167 | $foreach .= $pc->getPhpCodeArrayType($tableName, 'merge', $tableSoleName, '$acount'); |
||
| 168 | $table = $this->getTable(); |
||
| 169 | // Fields |
||
| 170 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
| 171 | $fieldMain = ''; |
||
| 172 | foreach (array_keys($fields) as $f) { |
||
| 173 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 174 | if (1 == $fields[$f]->getVar('field_main')) { |
||
| 175 | $fieldMain = $fieldName; // fieldMain = fields parameters main field |
||
| 176 | } |
||
| 177 | } |
||
| 178 | $foreach .= $xc->getXcGetVar('keywords[]', "{$tableName}All[\$i]", $fieldMain, false, "\t\t"); |
||
| 179 | $foreach .= $this->getSimpleString('++$count;', "\t\t"); |
||
| 180 | $condIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, "\t"); |
||
| 181 | $condIf .= $xc->getXcXoopsTplAssign($tableName, '$' . $tableName, true, "\t"); |
||
| 182 | $condIf .= $pc->getPhpCodeUnset($tableName, "\t"); |
||
| 183 | $condIf .= $xc->getXcPageNav($tableName, "\t"); |
||
| 184 | $thereare = $pc->getPhpCodeSprintf("{$language}INDEX_THEREARE", "\${$tableName}Count"); |
||
| 185 | $condIf .= $xc->getXcXoopsTplAssign('lang_thereare', $thereare, true, "\t"); |
||
| 186 | $divideby = $xc->getXcGetConfig('divideby'); |
||
| 187 | $condIf .= $xc->getXcXoopsTplAssign('divideby', $divideby, true, "\t"); |
||
| 188 | $numb_col = $xc->getXcGetConfig('numb_col'); |
||
| 189 | $condIf .= $xc->getXcXoopsTplAssign('numb_col', $numb_col, true, "\t"); |
||
| 190 | |||
| 191 | $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf); |
||
| 192 | $ret .= $pc->getPhpCodeUnset('count'); |
||
| 193 | $tableType = $xc->getXcGetConfig('table_type'); |
||
| 194 | $ret .= $xc->getXcXoopsTplAssign('table_type', $tableType); |
||
| 195 | |||
| 196 | return $ret; |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @private function getUserPagesFooter |
||
| 201 | * @param $moduleDirname |
||
| 202 | * @param $language |
||
| 203 | * @return string |
||
| 204 | */ |
||
| 205 | private function getUserIndexFooter($moduleDirname, $language) |
||
| 206 | { |
||
| 207 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 208 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 209 | $uxc = UserXoopsCode::getInstance(); |
||
| 210 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 211 | $ret = $pc->getPhpCodeCommentLine('Breadcrumbs'); |
||
| 212 | $ret .= $uxc->getUserBreadcrumbs($language); |
||
| 213 | $ret .= $pc->getPhpCodeCommentLine('Keywords'); |
||
| 214 | $ret .= $uxc->getUserMetaKeywords($moduleDirname); |
||
| 215 | $ret .= $pc->getPhpCodeUnset('keywords'); |
||
| 216 | $ret .= $pc->getPhpCodeCommentLine('Description'); |
||
| 217 | $ret .= $uxc->getUserMetaDesc($moduleDirname, $language); |
||
| 218 | $ret .= $xc->getXcXoopsTplAssign('xoops_mpageurl', "{$stuModuleDirname}_URL.'/index.php'"); |
||
| 219 | $ret .= $xc->getXcXoopsTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
||
| 220 | $ret .= $xc->getXcXoopsTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL"); |
||
| 221 | $ret .= $this->getInclude('footer'); |
||
| 222 | |||
| 223 | return $ret; |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @public function render |
||
| 228 | * @param null |
||
| 229 | * @return bool|string |
||
| 230 | */ |
||
| 231 | public function render() |
||
| 232 | { |
||
| 233 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 234 | $module = $this->getModule(); |
||
| 235 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
| 236 | $filename = $this->getFileName(); |
||
| 237 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 238 | $language = $this->getLanguage($moduleDirname, 'MA'); |
||
| 239 | $content = $this->getHeaderFilesComments($module, null); |
||
| 240 | $content .= $pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', ''); |
||
| 241 | $content .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', ''); |
||
| 242 | $content .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']); |
||
| 243 | $content .= $this->getTemplateHeaderFile($moduleDirname); |
||
| 244 | foreach (array_keys($tables) as $t) { |
||
| 245 | $tableId = $tables[$t]->getVar('table_id'); |
||
| 246 | $tableMid = $tables[$t]->getVar('table_mid'); |
||
| 247 | $tableName = $tables[$t]->getVar('table_name'); |
||
| 248 | $tableSoleName = $tables[$t]->getVar('table_solename'); |
||
| 249 | $tableCategory[] = $tables[$t]->getVar('table_category'); |
||
| 250 | $tableFieldname = $tables[$t]->getVar('table_fieldname'); |
||
| 251 | $tableIndex[] = $tables[$t]->getVar('table_index'); |
||
| 252 | if (in_array(1, $tableCategory, true) && in_array(1, $tableIndex)) { |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
Comprehensibility
Best Practice
introduced
by
|
|||
| 253 | $content .= $this->getBodyCategoriesIndex($tableMid, $tableId, $tableName, $tableSoleName, $tableFieldname); |
||
| 254 | } |
||
| 255 | if (in_array(0, $tableCategory, true) && in_array(1, $tableIndex)) { |
||
| 256 | $content .= $this->getBodyPagesIndex($moduleDirname, $tableName, $tableSoleName, $language); |
||
| 257 | } |
||
| 258 | } |
||
| 259 | $content .= $this->getUserIndexFooter($moduleDirname, $language); |
||
| 260 | |||
| 261 | $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||
| 262 | |||
| 263 | return $this->renderFile(); |
||
| 264 | } |
||
| 265 | } |
||
| 266 |