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; |
||
| 4 | |||
| 5 | use XoopsModules\Tdmcreate; |
||
| 6 | |||
| 7 | /* |
||
| 8 | You may not change or alter any portion of this comment or credits |
||
| 9 | of supporting developers from this source code or any supporting source code |
||
| 10 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 11 | |||
| 12 | This program is distributed in the hope that it will be useful, |
||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 15 | */ |
||
| 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.7 |
||
| 24 | * |
||
| 25 | * @author Txmod Xoops <[email protected]> - <http://www.txmodxoops.org/> |
||
| 26 | * |
||
| 27 | */ |
||
| 28 | // include __DIR__ . '/autoload.php'; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Class Tables. |
||
| 32 | */ |
||
| 33 | class Tables extends \XoopsObject |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * Options. |
||
| 37 | */ |
||
| 38 | public $options = [ |
||
| 39 | 'install', |
||
| 40 | 'index', |
||
| 41 | 'blocks', |
||
| 42 | 'admin', |
||
| 43 | 'user', |
||
| 44 | 'submenu', |
||
| 45 | 'submit', |
||
| 46 | 'tag', |
||
| 47 | 'broken', |
||
| 48 | 'search', |
||
| 49 | 'comments', |
||
| 50 | 'notifications', |
||
| 51 | 'permissions', |
||
| 52 | 'rate', |
||
| 53 | 'print', |
||
| 54 | 'pdf', |
||
| 55 | 'rss', |
||
| 56 | 'single', |
||
| 57 | 'visit', |
||
| 58 | ]; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @public function constructor class |
||
| 62 | * @param null |
||
| 63 | */ |
||
| 64 | public function __construct() |
||
| 65 | { |
||
| 66 | $this->initVar('table_id', XOBJ_DTYPE_INT); |
||
| 67 | $this->initVar('table_mid', XOBJ_DTYPE_INT); |
||
| 68 | $this->initVar('table_category', XOBJ_DTYPE_INT); |
||
| 69 | $this->initVar('table_name', XOBJ_DTYPE_TXTBOX); |
||
| 70 | $this->initVar('table_solename', XOBJ_DTYPE_TXTBOX); |
||
| 71 | $this->initVar('table_fieldname', XOBJ_DTYPE_TXTBOX); |
||
| 72 | $this->initVar('table_nbfields', XOBJ_DTYPE_INT); |
||
| 73 | $this->initVar('table_order', XOBJ_DTYPE_INT); |
||
| 74 | $this->initVar('table_image', XOBJ_DTYPE_TXTBOX); |
||
| 75 | $this->initVar('table_autoincrement', XOBJ_DTYPE_INT); |
||
| 76 | $this->initVar('table_install', XOBJ_DTYPE_INT); |
||
| 77 | $this->initVar('table_index', XOBJ_DTYPE_INT); |
||
| 78 | $this->initVar('table_blocks', XOBJ_DTYPE_INT); |
||
| 79 | $this->initVar('table_admin', XOBJ_DTYPE_INT); |
||
| 80 | $this->initVar('table_user', XOBJ_DTYPE_INT); |
||
| 81 | $this->initVar('table_submenu', XOBJ_DTYPE_INT); |
||
| 82 | $this->initVar('table_submit', XOBJ_DTYPE_INT); |
||
| 83 | $this->initVar('table_tag', XOBJ_DTYPE_INT); |
||
| 84 | $this->initVar('table_broken', XOBJ_DTYPE_INT); |
||
| 85 | $this->initVar('table_search', XOBJ_DTYPE_INT); |
||
| 86 | $this->initVar('table_comments', XOBJ_DTYPE_INT); |
||
| 87 | $this->initVar('table_notifications', XOBJ_DTYPE_INT); |
||
| 88 | $this->initVar('table_permissions', XOBJ_DTYPE_INT); |
||
| 89 | $this->initVar('table_rate', XOBJ_DTYPE_INT); |
||
| 90 | $this->initVar('table_print', XOBJ_DTYPE_INT); |
||
| 91 | $this->initVar('table_pdf', XOBJ_DTYPE_INT); |
||
| 92 | $this->initVar('table_rss', XOBJ_DTYPE_INT); |
||
| 93 | $this->initVar('table_single', XOBJ_DTYPE_INT); |
||
| 94 | $this->initVar('table_visit', XOBJ_DTYPE_INT); |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param string $method |
||
| 99 | * @param array $args |
||
| 100 | * |
||
| 101 | * @return mixed |
||
| 102 | */ |
||
| 103 | public function __call($method, $args) |
||
| 104 | { |
||
| 105 | $arg = isset($args[0]) ? $args[0] : null; |
||
| 106 | |||
| 107 | return $this->getVar($method, $arg); |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @static function getInstance |
||
| 112 | * @param null |
||
| 113 | * @return Tables |
||
| 114 | */ |
||
| 115 | public static function getInstance() |
||
| 116 | { |
||
| 117 | static $instance = false; |
||
| 118 | if (!$instance) { |
||
| 119 | $instance = new self(); |
||
| 120 | } |
||
| 121 | |||
| 122 | return $instance; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @static function getFormTables |
||
| 127 | * @param mixed $action |
||
| 128 | * |
||
| 129 | * @return \XoopsThemeForm |
||
| 130 | */ |
||
| 131 | public function getFormTables($action = false) |
||
| 132 | { |
||
| 133 | if (false === $action) { |
||
| 134 | $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); |
||
| 135 | } |
||
| 136 | $helper = Tdmcreate\Helper::getInstance(); |
||
| 137 | $isNew = $this->isNew(); |
||
| 138 | $tableName = $this->getVar('table_name'); |
||
| 139 | $tableMid = $this->getVar('table_mid'); |
||
| 140 | $title = $isNew ? sprintf(_AM_TDMCREATE_TABLE_NEW) : sprintf(_AM_TDMCREATE_TABLE_EDIT); |
||
| 141 | |||
| 142 | xoops_load('XoopsFormLoader'); |
||
| 143 | $form = new \XoopsThemeForm($title, 'tableform', $action, 'post', true); |
||
| 144 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 145 | |||
| 146 | $modules = $helper->getHandler('Modules')->getObjects(null); |
||
| 147 | $modulesSelect = new \XoopsFormSelect(_AM_TDMCREATE_TABLE_MODULES, 'table_mid', $tableMid); |
||
| 148 | $modulesSelect->addOption('', _AM_TDMCREATE_TABLE_MODSELOPT); |
||
| 149 | foreach ($modules as $mod) { |
||
| 150 | $modulesSelect->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name')); |
||
| 151 | } |
||
| 152 | $form->addElement($modulesSelect, true); |
||
| 153 | |||
| 154 | $tableNameText = new \XoopsFormText(_AM_TDMCREATE_TABLE_NAME, 'table_name', 40, 150, $tableName); |
||
| 155 | $tableNameText->setDescription(_AM_TDMCREATE_TABLE_NAME_DESC); |
||
| 156 | $form->addElement($tableNameText, true); |
||
| 157 | |||
| 158 | $tableSoleNameText = new \XoopsFormText(_AM_TDMCREATE_TABLE_SOLENAME, 'table_solename', 40, 150, $this->getVar('table_solename')); |
||
| 159 | $tableSoleNameText->setDescription(_AM_TDMCREATE_TABLE_SOLENAME_DESC); |
||
| 160 | $form->addElement($tableSoleNameText, true); |
||
| 161 | |||
| 162 | $radioCategory = $isNew ? 0 : $this->getVar('table_category'); |
||
| 163 | $category = new \XoopsFormRadioYN(_AM_TDMCREATE_TABLE_CATEGORY, 'table_category', $radioCategory); |
||
| 164 | $category->setDescription(_AM_TDMCREATE_TABLE_CATEGORY_DESC); |
||
| 165 | $form->addElement($category); |
||
| 166 | |||
| 167 | $tableFieldname = new \XoopsFormText(_AM_TDMCREATE_TABLE_FIELDNAME, 'table_fieldname', 30, 50, $this->getVar('table_fieldname')); |
||
| 168 | $tableFieldname->setDescription(_AM_TDMCREATE_TABLE_FIELDNAME_DESC); |
||
| 169 | $form->addElement($tableFieldname); |
||
| 170 | |||
| 171 | $tableNumbFileds = new \XoopsFormText(_AM_TDMCREATE_TABLE_NBFIELDS, 'table_nbfields', 10, 25, $this->getVar('table_nbfields')); |
||
| 172 | $tableNumbFileds->setDescription(_AM_TDMCREATE_TABLE_NBFIELDS_DESC); |
||
| 173 | $form->addElement($tableNumbFileds, true); |
||
| 174 | |||
| 175 | if (!$isNew) { |
||
| 176 | $tableOrder = new \XoopsFormText(_AM_TDMCREATE_TABLE_ORDER, 'table_order', 5, 10, $this->getVar('table_order')); |
||
| 177 | $tableOrder->setDescription(_AM_TDMCREATE_TABLE_ORDER_DESC); |
||
| 178 | $form->addElement($tableOrder, true); |
||
| 179 | } |
||
| 180 | |||
| 181 | $getTableImage = $this->getVar('table_image'); |
||
| 182 | $tableImage = $getTableImage ?: 'blank.gif'; |
||
| 183 | $icons32Directory = '/Frameworks/moduleclasses/icons/32'; |
||
| 184 | $uploadsDirectory = '/uploads/tdmcreate/images/tables'; |
||
| 185 | $iconsDirectory = is_dir(XOOPS_ROOT_PATH . $icons32Directory) ? $icons32Directory : $uploadsDirectory; |
||
| 186 | |||
| 187 | $imgtray1 = new \XoopsFormElementTray(_AM_TDMCREATE_TABLE_IMAGE, '<br>'); |
||
| 188 | $imgpath1 = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, ".{$iconsDirectory}/"); |
||
| 189 | $imageSelect1 = new \XoopsFormSelect($imgpath1, 'table_image', $tableImage, 10); |
||
| 190 | $imageArray1 = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $iconsDirectory); |
||
| 191 | foreach ($imageArray1 as $image1) { |
||
| 192 | $imageSelect1->addOption($image1, $image1); |
||
| 193 | } |
||
| 194 | $imageSelect1->setExtra("onchange='showImgSelected(\"image1\", \"table_image\", \"" . $iconsDirectory . '", "", "' . XOOPS_URL . "\")'"); |
||
| 195 | $imgtray1->addElement($imageSelect1, false); |
||
| 196 | $imgtray1->addElement(new \XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $iconsDirectory . '/' . $tableImage . "' id='image1' alt='' />")); |
||
| 197 | $fileseltray1 = new \XoopsFormElementTray('', '<br>'); |
||
| 198 | $fileseltray1->addElement(new \XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image'))); |
||
| 199 | $fileseltray1->addElement(new \XoopsFormLabel('')); |
||
| 200 | $imgtray1->addElement($fileseltray1); |
||
| 201 | $imgtray1->setDescription(_AM_TDMCREATE_TABLE_IMAGE_DESC); |
||
| 202 | $form->addElement($imgtray1); |
||
| 203 | |||
| 204 | $tableAutoincrement = $this->isNew() ? 1 : $this->getVar('table_autoincrement'); |
||
| 205 | $checkTableAutoincrement = new \XoopsFormRadioYN(_AM_TDMCREATE_TABLE_AUTO_INCREMENT, 'table_autoincrement', $tableAutoincrement); |
||
| 206 | $checkTableAutoincrement->setDescription(_AM_TDMCREATE_TABLE_AUTO_INCREMENT_DESC); |
||
| 207 | $form->addElement($checkTableAutoincrement); |
||
| 208 | |||
| 209 | $optionsTray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
||
| 210 | |||
| 211 | $tableCheckAll = new \XoopsFormCheckBox('', 'tablebox', 1); |
||
| 212 | $tableCheckAll->addOption('allbox', _AM_TDMCREATE_TABLE_ALL); |
||
| 213 | $tableCheckAll->setExtra(' onclick="xoopsCheckAll(\'tableform\', \'tablebox\');" '); |
||
| 214 | $tableCheckAll->setClass('xo-checkall'); |
||
| 215 | $optionsTray->addElement($tableCheckAll); |
||
| 216 | // Options |
||
| 217 | $checkbox = new \XoopsFormCheckbox(' ', 'table_option', $this->getOptionsTables(), '<br>'); |
||
| 218 | $checkbox->setDescription(_AM_TDMCREATE_OPTIONS_DESC); |
||
| 219 | foreach ($this->options as $option) { |
||
| 220 | $checkbox->addOption($option, self::getDefinedLanguage('_AM_TDMCREATE_TABLE_' . mb_strtoupper($option))); |
||
| 221 | } |
||
| 222 | $optionsTray->addElement($checkbox); |
||
| 223 | |||
| 224 | $optionsTray->setDescription(_AM_TDMCREATE_TABLE_OPTIONS_CHECKS_DESC); |
||
| 225 | |||
| 226 | $form->addElement($optionsTray); |
||
| 227 | |||
| 228 | $buttonTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', ''); |
||
| 229 | $buttonTray->addElement(new \XoopsFormHidden('op', 'save')); |
||
| 230 | $buttonTray->addElement(new \XoopsFormHidden('table_id', ($isNew ? 0 : $this->getVar('table_id')))); |
||
| 231 | $buttonTray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
| 232 | $form->addElement($buttonTray); |
||
| 233 | |||
| 234 | return $form; |
||
| 235 | } |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Get Values. |
||
| 239 | * |
||
| 240 | * @param null $keys |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 241 | * @param null $format |
||
|
0 ignored issues
–
show
|
|||
| 242 | * @param null $maxDepth |
||
|
0 ignored issues
–
show
|
|||
| 243 | * |
||
| 244 | * @return array |
||
| 245 | */ |
||
| 246 | public function getValuesTables($keys = null, $format = null, $maxDepth = null) |
||
| 247 | { |
||
| 248 | $ret = $this->getValues($keys, $format, $maxDepth); |
||
| 249 | // Values |
||
| 250 | $ret['id'] = $this->getVar('table_id'); |
||
| 251 | $ret['mid'] = $this->getVar('table_mid'); |
||
| 252 | $ret['name'] = ucfirst($this->getVar('table_name')); |
||
| 253 | $ret['image'] = $this->getVar('table_image'); |
||
| 254 | $ret['nbfields'] = $this->getVar('table_nbfields'); |
||
| 255 | $ret['order'] = $this->getVar('table_order'); |
||
| 256 | $ret['blocks'] = $this->getVar('table_blocks'); |
||
| 257 | $ret['admin'] = $this->getVar('table_admin'); |
||
| 258 | $ret['user'] = $this->getVar('table_user'); |
||
| 259 | $ret['submenu'] = $this->getVar('table_submenu'); |
||
| 260 | $ret['search'] = $this->getVar('table_search'); |
||
| 261 | $ret['comments'] = $this->getVar('table_comments'); |
||
| 262 | $ret['notifications'] = $this->getVar('table_notifications'); |
||
| 263 | $ret['permissions'] = $this->getVar('table_permissions'); |
||
| 264 | |||
| 265 | return $ret; |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Get Options. |
||
| 270 | * |
||
| 271 | * @return array |
||
| 272 | */ |
||
| 273 | public function getOptionsTables() |
||
| 274 | { |
||
| 275 | $retTable = []; |
||
| 276 | foreach ($this->options as $option) { |
||
| 277 | if (1 == $this->getVar('table_' . $option)) { |
||
| 278 | $retTable[] = $option; |
||
| 279 | } |
||
| 280 | } |
||
| 281 | |||
| 282 | return $retTable; |
||
| 283 | } |
||
| 284 | |||
| 285 | /** |
||
| 286 | * Get Defined Language. |
||
| 287 | * |
||
| 288 | * @param $lang |
||
| 289 | * |
||
| 290 | * @return string |
||
| 291 | */ |
||
| 292 | private static function getDefinedLanguage($lang) |
||
| 293 | { |
||
| 294 | if (defined($lang)) { |
||
| 295 | return constant($lang); |
||
| 296 | } |
||
| 297 | |||
| 298 | return $lang; |
||
| 299 | } |
||
| 300 | } |
||
| 301 |