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 namespace XoopsModules\Tdmcreate\Files\User; |
||
| 2 | |||
| 3 | use XoopsModules\Tdmcreate; |
||
| 4 | use XoopsModules\Tdmcreate\Files; |
||
| 5 | |||
| 6 | /* |
||
| 7 | You may not change or alter any portion of this comment or credits |
||
| 8 | of supporting developers from this source code or any supporting source code |
||
| 9 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, |
||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 14 | */ |
||
| 15 | /** |
||
| 16 | * tdmcreate module. |
||
| 17 | * |
||
| 18 | * @copyright XOOPS Project (https://xoops.org) |
||
| 19 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
| 20 | * |
||
| 21 | * @since 2.5.0 |
||
| 22 | * |
||
| 23 | * @author Txmod Xoops http://www.txmodxoops.org |
||
| 24 | * |
||
| 25 | * @version $Id: pages.php 12258 2014-01-02 09:33:29Z timgno $ |
||
| 26 | */ |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Class UserPages. |
||
| 30 | */ |
||
| 31 | class UserPages extends Files\CreateFile |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * @public function constructor |
||
| 35 | * @param null |
||
| 36 | */ |
||
| 37 | public function __construct() |
||
| 38 | { |
||
| 39 | parent::__construct(); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @static function getInstance |
||
| 44 | * @param null |
||
| 45 | * @return UserPages |
||
| 46 | */ |
||
| 47 | public static function getInstance() |
||
| 48 | { |
||
| 49 | static $instance = false; |
||
| 50 | if (!$instance) { |
||
| 51 | $instance = new self(); |
||
| 52 | } |
||
| 53 | |||
| 54 | return $instance; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @public function write |
||
| 59 | * @param $module |
||
| 60 | * @param $table |
||
| 61 | * @param $filename |
||
| 62 | */ |
||
| 63 | public function write($module, $table, $filename) |
||
| 64 | { |
||
| 65 | $this->setModule($module); |
||
| 66 | $this->setTable($table); |
||
| 67 | $this->setFileName($filename); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @private function getUserPagesHeader |
||
| 72 | * @param $moduleDirname |
||
| 73 | * @param $tableName |
||
| 74 | * @return string |
||
| 75 | */ |
||
| 76 | private function getUserPagesHeader($moduleDirname, $tableName) |
||
| 77 | { |
||
| 78 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 79 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 80 | $uc = UserXoopsCode::getInstance(); |
||
| 81 | $ret = $this->getInclude(); |
||
| 82 | $ret .= $uc->getUserTplMain($moduleDirname, $tableName); |
||
| 83 | $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); |
||
| 84 | $ret .= $xc->getXcXoopsRequest('start', 'start', '0', 'Int'); |
||
| 85 | $userpager = $xc->getXcGetConfig($moduleDirname, 'userpager'); |
||
| 86 | $ret .= $xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int'); |
||
| 87 | $ret .= $pc->getPhpCodeCommentLine('Define Stylesheet'); |
||
| 88 | $ret .= $xc->getXcAddStylesheet(); |
||
| 89 | |||
| 90 | return $ret; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @private function getUserPages |
||
| 95 | * @param $moduleDirname |
||
| 96 | * @param $tableName |
||
| 97 | * @param $tableSoleName |
||
| 98 | * @return string |
||
| 99 | */ |
||
| 100 | private function getUserPages($moduleDirname, $tableName, $tableSoleName) |
||
|
0 ignored issues
–
show
|
|||
| 101 | { |
||
| 102 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 103 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 104 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 105 | $ucfTableName = ucfirst($tableName); |
||
| 106 | $t = "\t"; |
||
| 107 | $ret = $pc->getPhpCodeCommentLine(); |
||
| 108 | $ret .= $xc->getXcTplAssign('xoops_icons32_url', 'XOOPS_ICONS32_URL'); |
||
| 109 | $ret .= $xc->getXcTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL"); |
||
| 110 | $ret .= $pc->getPhpCodeCommentLine(); |
||
| 111 | $ret .= $xc->getXcObjHandlerCount($tableName); |
||
| 112 | $ret .= $xc->getXcObjHandlerAll($tableName, '', '$start', '$limit'); |
||
| 113 | $ret .= $pc->getPhpCodeArray('keywords', null, false, ''); |
||
| 114 | $condIf = $pc->getPhpCodeArray($tableName, null, false, $t); |
||
| 115 | $condIf .= $pc->getPhpCodeCommentLine('Get All', $ucfTableName, $t); |
||
| 116 | $foreach = $xc->getXcGetValues($tableName, $tableName . '[]', 'i', false, $t); |
||
| 117 | |||
| 118 | $table = $this->getTable(); |
||
| 119 | // Fields |
||
| 120 | $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||
| 121 | foreach (array_keys($fields) as $f) { |
||
| 122 | $fieldName = $fields[$f]->getVar('field_name'); |
||
| 123 | if (1 == $fields[$f]->getVar('field_main')) { |
||
| 124 | $fieldMain = $fieldName; // fieldMain = fields parameters main field |
||
| 125 | } |
||
| 126 | } |
||
| 127 | $foreach .= $xc->getXcGetVar('keywords[]', "{$tableName}All[\$i]", $fieldMain, false, $t . "\t"); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 128 | $condIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t); |
||
| 129 | $condIf .= $xc->getXcTplAssign($tableName, "\${$tableName}", true, $t); |
||
| 130 | $condIf .= $pc->getPhpCodeUnset($tableName, $t); |
||
| 131 | $condIf .= $xc->getXcPageNav($tableName, $t); |
||
| 132 | $tableType = $xc->getXcGetConfig($moduleDirname, 'table_type'); |
||
| 133 | $condIf .= $xc->getXcTplAssign('type', $tableType, true, $t); |
||
| 134 | $divideby = $xc->getXcGetConfig($moduleDirname, 'divideby'); |
||
| 135 | $condIf .= $xc->getXcTplAssign('divideby', $divideby, true, $t); |
||
| 136 | $numbCol = $xc->getXcGetConfig($moduleDirname, 'numb_col'); |
||
| 137 | $condIf .= $xc->getXcTplAssign('numb_col', $numbCol, true, $t); |
||
| 138 | |||
| 139 | $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf); |
||
| 140 | |||
| 141 | return $ret; |
||
| 142 | } |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @private function getUserPagesFooter |
||
| 146 | * @param $moduleDirname |
||
| 147 | * @param $tableName |
||
| 148 | * @param $tableSoleName |
||
| 149 | * @param $language |
||
| 150 | * |
||
| 151 | * @return string |
||
| 152 | */ |
||
| 153 | private function getUserPagesFooter($moduleDirname, $tableName, $tableSoleName, $language) |
||
| 154 | { |
||
| 155 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 156 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 157 | $uc = UserXoopsCode::getInstance(); |
||
| 158 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||
| 159 | $stuTableName = mb_strtoupper($tableName); |
||
| 160 | $stuTableSoleName = mb_strtoupper($tableSoleName); |
||
|
0 ignored issues
–
show
|
|||
| 161 | $ret = $pc->getPhpCodeCommentLine('Breadcrumbs'); |
||
| 162 | $ret .= $uc->getUserBreadcrumbs($language, $stuTableName); |
||
| 163 | $ret .= $pc->getPhpCodeCommentLine('Keywords'); |
||
| 164 | $ret .= $uc->getUserMetaKeywords($moduleDirname); |
||
| 165 | $ret .= $pc->getPhpCodeUnset('keywords'); |
||
| 166 | $ret .= $pc->getPhpCodeCommentLine('Description'); |
||
| 167 | $ret .= $uc->getUserMetaDesc($moduleDirname, $language, $stuTableName); |
||
| 168 | $ret .= $xc->getXcTplAssign('xoops_mpageurl', "{$stuModuleDirname}_URL.'/{$tableName}.php'"); |
||
| 169 | $ret .= $xc->getXcTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL"); |
||
| 170 | $ret .= $this->getInclude('footer'); |
||
| 171 | |||
| 172 | return $ret; |
||
| 173 | } |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @public function render |
||
| 177 | * @param null |
||
| 178 | * @return bool|string |
||
| 179 | */ |
||
| 180 | public function render() |
||
| 181 | { |
||
| 182 | $module = $this->getModule(); |
||
| 183 | $table = $this->getTable(); |
||
| 184 | $tableName = $table->getVar('table_name'); |
||
| 185 | $tableSoleName = $table->getVar('table_solename'); |
||
| 186 | $filename = $this->getFileName(); |
||
| 187 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 188 | $language = $this->getLanguage($moduleDirname, 'MA'); |
||
| 189 | $content = $this->getHeaderFilesComments($module, $filename); |
||
| 190 | $content .= $this->getUserPagesHeader($moduleDirname, $tableName); |
||
| 191 | $content .= $this->getUserPages($moduleDirname, $tableName, $tableSoleName); |
||
| 192 | $content .= $this->getUserPagesFooter($moduleDirname, $tableName, $tableSoleName, $language); |
||
| 193 | |||
| 194 | $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||
| 195 | |||
| 196 | return $this->renderFile(); |
||
| 197 | } |
||
| 198 | } |
||
| 199 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.