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\Admin; |
||
| 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 AdminIndex. |
||
| 31 | */ |
||
| 32 | class AdminIndex 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 AdminIndex |
||
| 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 mixed $tables |
||
| 62 | * @param string $filename |
||
| 63 | */ |
||
| 64 | public function write($module, $tables, $filename) |
||
| 65 | { |
||
| 66 | $this->setModule($module); |
||
| 67 | $this->setTables($tables); |
||
| 68 | $this->setFileName($filename); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @private function render |
||
| 73 | * @param $module |
||
| 74 | * |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | private function getAdminIndex($module) |
||
| 78 | { |
||
| 79 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||
| 80 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||
| 81 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||
| 82 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 83 | $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
||
| 84 | $language = $this->getLanguage($moduleDirname, 'AM'); |
||
| 85 | $languageThereAre = $this->getLanguage($moduleDirname, 'AM', 'THEREARE_'); |
||
| 86 | |||
| 87 | $ret = $this->getSimpleString(''); |
||
| 88 | $ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Common']); |
||
| 89 | $ret .= $pc->getPhpCodeIncludeDir('dirname(__DIR__)', 'preloads/autoloader', true); |
||
| 90 | $ret .= $this->getInclude(); |
||
| 91 | $ret .= $pc->getPhpCodeBlankLine(); |
||
| 92 | $ret .= $pc->getPhpCodeCommentLine('Template Index'); |
||
| 93 | $ret .= $axc->getAdminTemplateMain((string)$moduleDirname, 'index'); |
||
| 94 | $ret .= $pc->getPhpCodeBlankLine(); |
||
| 95 | $ret .= $pc->getPhpCodeCommentLine('Count elements'); |
||
| 96 | $tableName = null; |
||
| 97 | foreach (array_keys($tables) as $i) { |
||
| 98 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 99 | $ucfTableName = ucfirst($tableName); |
||
| 100 | $ret .= $xc->getXcEqualsOperator("\$count{$ucfTableName}", "\${$tableName}Handler->getCount()"); |
||
| 101 | } |
||
| 102 | $ret .= $pc->getPhpCodeBlankLine(); |
||
| 103 | $ret .= $pc->getPhpCodeCommentLine('InfoBox Statistics'); |
||
| 104 | $ret .= $axc->getAxcAddInfoBox($language . 'STATISTICS'); |
||
| 105 | $ret .= $pc->getPhpCodeCommentLine('Info elements'); |
||
| 106 | $tableInstall = []; |
||
| 107 | foreach (array_keys($tables) as $i) { |
||
| 108 | $tableName = $tables[$i]->getVar('table_name'); |
||
| 109 | $tableInstall[] = $tables[$i]->getVar('table_install'); |
||
| 110 | $stuTableName = $languageThereAre . mb_strtoupper($tableName); |
||
| 111 | $ucfTableName = ucfirst($tableName); |
||
| 112 | $ret .= $axc->getAxcAddInfoBoxLine($stuTableName, "\$count{$ucfTableName}"); |
||
| 113 | } |
||
| 114 | |||
| 115 | if (null === $tableName) { |
||
| 116 | $ret .= $axc->getAxcAddInfoBoxLine('No statistics', '0'); |
||
| 117 | } |
||
| 118 | |||
| 119 | if (is_array($tables) && in_array(1, $tableInstall)) { |
||
| 120 | $ret .= $pc->getPhpCodeBlankLine(); |
||
| 121 | $ret .= $pc->getPhpCodeCommentLine('Upload Folders'); |
||
| 122 | $ret .= $xc->getXcEqualsOperator('$configurator', 'new Common\Configurator()'); |
||
| 123 | $cond = '$configurator->uploadFolders && is_array($configurator->uploadFolders)'; |
||
| 124 | $fe_action = $xc->getXcEqualsOperator('$folder[]', '$configurator->uploadFolders[$i]', '',"\t\t"); |
||
| 125 | $condIf = $pc->getPhpCodeForeach('configurator->uploadFolders', true, false, 'i', $fe_action, "\t"); |
||
| 126 | $ret .= $pc->getPhpCodeConditions($cond, '', '', $condIf, false); |
||
| 127 | |||
| 128 | $ret .= $pc->getPhpCodeCommentLine('Uploads Folders Created'); |
||
| 129 | $boxLine = $axc->getAxcAddConfigBoxLine('$folder[$i]', 'folder', '', "\t"); |
||
| 130 | $boxLine .= $axc->getAxcAddConfigBoxLine("array(\$folder[\$i], '777')", 'chmod', '', "\t"); |
||
| 131 | $ret .= $pc->getPhpCodeForeach('folder', true, false, 'i', $boxLine, '') . PHP_EOL; |
||
| 132 | } |
||
| 133 | $ret .= $pc->getPhpCodeCommentLine('Render Index'); |
||
| 134 | $ret .= $xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('index.php')"); |
||
| 135 | $ret .= $pc->getPhpCodeCommentLine('Test Data'); |
||
| 136 | $condIf = $xc->getXcXoopsLoadLanguage('admin/modulesadmin',"\t", 'system'); |
||
| 137 | $condIf .= $pc->getPhpCodeIncludeDir('dirname(__DIR__)', 'testdata/index', true, '','',"\t"); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 138 | $condIf .= $axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_ADD_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=load', $type = 'samplebutton', $t = "\t"); |
||
| 139 | $condIf .= $axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_SAVE_SAMPLEDATA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=save', $type = 'samplebutton', $t = "\t"); |
||
| 140 | $condIf .= "//" . $axc->getAdminItemButton("constant('CO_' . \$moduleDirNameUpper . '_EXPORT_SCHEMA')", '', '', $op = '__DIR__ . /../../testdata/index.php?op=exportschema', $type = 'samplebutton', $t = "\t"); |
||
| 141 | $condIf .= $axc->getAdminDisplayButton('left', "\t"); |
||
| 142 | $cond = $xc->getXcGetConfig('displaySampleButton'); |
||
| 143 | $ret .= $pc->getPhpCodeConditions($cond, '', '', $condIf, false); |
||
| 144 | $ret .= $xc->getXcXoopsTplAssign('index', '$adminObject->displayIndex()'); |
||
| 145 | $ret .= $pc->getPhpCodeCommentLine('End Test Data'); |
||
| 146 | |||
| 147 | $ret .= $this->getInclude('footer'); |
||
| 148 | |||
| 149 | return $ret; |
||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @public function render |
||
| 154 | * @param null |
||
| 155 | * @return bool|string |
||
| 156 | */ |
||
| 157 | public function render() |
||
| 158 | { |
||
| 159 | $module = $this->getModule(); |
||
| 160 | $moduleDirname = $module->getVar('mod_dirname'); |
||
| 161 | $filename = $this->getFileName(); |
||
| 162 | $content = $this->getHeaderFilesComments($module); |
||
| 163 | $content .= $this->getAdminIndex($module); |
||
| 164 | |||
| 165 | $this->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||
| 166 | |||
| 167 | return $this->renderFile(); |
||
| 168 | } |
||
| 169 | } |
||
| 170 |