mambax7 /
extcal
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 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 14 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 15 | * @package extcal |
||
| 16 | * @since |
||
| 17 | * @author XOOPS Development Team, |
||
| 18 | */ |
||
| 19 | |||
| 20 | use Xmf\Module\Admin; |
||
| 21 | use Xmf\Request; |
||
| 22 | use XoopsModules\Extcal\{CategoryHandler, |
||
| 23 | Form |
||
| 24 | }; |
||
| 25 | |||
| 26 | const CONFIRM = 'confirm'; |
||
| 27 | |||
| 28 | require_once __DIR__ . '/admin_header.php'; |
||
| 29 | require_once dirname(__DIR__, 3) . '/class/xoopsformloader.php'; |
||
| 30 | require_once dirname(__DIR__) . '/include/constantes.php'; |
||
| 31 | |||
| 32 | global $xoopsUser, $xoopsTpl; |
||
| 33 | |||
| 34 | /** @var CategoryHandler $categoryHandler */ |
||
| 35 | |||
| 36 | $op = 'list'; |
||
| 37 | if (Request::hasVar('op', 'GET')) { |
||
| 38 | $op = Request::getCmd('op', 'list'); |
||
| 39 | $catId = Request::getInt('cat_id', 0); |
||
| 40 | } |
||
| 41 | |||
| 42 | if (Request::hasVar(CONFIRM, 'POST')) { |
||
| 43 | $confirm = Request::getInt(CONFIRM, 0, 'POST'); |
||
| 44 | } |
||
| 45 | |||
| 46 | // $t=print_r($gepeto,true); |
||
| 47 | // echo "<pre>{$t}</pre>"; |
||
| 48 | |||
| 49 | switch ($op) { |
||
| 50 | case 'enreg': |
||
| 51 | // Modify cat |
||
| 52 | $varArr = [ |
||
| 53 | 'cat_name' => Request::getString('cat_name', '', 'POST'), |
||
| 54 | 'cat_desc' => Request::getText('cat_desc', '', 'POST'), |
||
| 55 | 'cat_weight' => Request::getInt('cat_weight', 0, 'POST'), |
||
| 56 | 'cat_color' => mb_substr(Request::getString('cat_color', '', 'POST'), 1), |
||
| 57 | 'cat_icone' => Request::getString('cat_icone', '', 'POST'), |
||
| 58 | ]; |
||
| 59 | if (isset($catId) && $catId > 0) { |
||
| 60 | // $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
||
| 61 | // $varArr = [ |
||
| 62 | // 'cat_name' => Request::getString('cat_name', '', 'POST'), |
||
| 63 | // 'cat_desc' => Request::getText('cat_desc', '', 'POST'), |
||
| 64 | // 'cat_weight' => Request::getInt('cat_weight', 0, 'POST'), |
||
| 65 | // 'cat_color' => substr(Request::getString('cat_color', '', 'POST'), 1), |
||
| 66 | // 'cat_icone' => Request::getInt('cat_icone', 0, 'POST') |
||
| 67 | // ]; |
||
| 68 | |||
| 69 | $categoryHandler->modifyCat($catId, $varArr); |
||
| 70 | redirect_header('cat.php', 3, _AM_EXTCAL_CAT_EDITED, false); |
||
| 71 | // Create new cat |
||
| 72 | } else { |
||
| 73 | // $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
||
| 74 | // $varArr = [ |
||
| 75 | // 'cat_name' => $cat_name, |
||
| 76 | // 'cat_desc' => $cat_desc, |
||
| 77 | // 'cat_weight' => $cat_weight, |
||
| 78 | // 'cat_color' => substr($cat_color, 1), |
||
| 79 | // 'cat_icone' => $cat_icone, |
||
| 80 | // ]; |
||
| 81 | $categoryHandler->createCategory($varArr); |
||
| 82 | redirect_header('cat.php', 3, _AM_EXTCAL_CAT_CREATED, false); |
||
| 83 | } |
||
| 84 | |||
| 85 | break; |
||
| 86 | case 'new': |
||
| 87 | xoops_cp_header(); |
||
| 88 | |||
| 89 | // $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
||
| 90 | //$cat = $categoryHandler->getCat($catId, true); |
||
| 91 | |||
| 92 | $form = new \XoopsThemeForm(_AM_EXTCAL_ADD_CATEGORY, 'add_cat', 'cat.php?op=enreg', 'post', true); |
||
| 93 | $form->addElement(new \XoopsFormText(_AM_EXTCAL_NAME, 'cat_name', 30, 255), true); |
||
| 94 | $form->addElement(new \XoopsFormDhtmlTextArea(_AM_EXTCAL_DESCRIPTION, 'cat_desc', ''), false); |
||
| 95 | $form->addElement(new \XoopsFormText(_AM_EXTCAL_WEIGHT, 'cat_weight', 30, 5, 0), false); |
||
| 96 | $form->addElement(new \XoopsFormColorPicker(_AM_EXTCAL_COLOR, 'cat_color', '#FF0000')); |
||
| 97 | |||
| 98 | $file_path = dirname(__DIR__) . '/assets/css/images'; |
||
| 99 | $tf = \XoopsLists::getImgListAsArray($file_path); |
||
| 100 | array_unshift($tf, _MD_EXTCAL_NONE); |
||
| 101 | //$xfIcones = new \XoopsFormSelect(_AM_EXTCAL_ICONE, "cat_icone", $cat->getVar('cat_icone'), ''); |
||
| 102 | $xfIcones = new \XoopsFormSelect(_AM_EXTCAL_ICONE, 'cat_icone', '', ''); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 103 | $xfIcones->addOptionArray($tf); |
||
| 104 | $form->addElement($xfIcones, false); |
||
| 105 | |||
| 106 | $form->addElement(new \XoopsFormButton('', 'form_submit', _SUBMIT, 'submit'), false); |
||
| 107 | /** @var ThemeForm $form */ |
||
| 108 | $form->display(); |
||
| 109 | |||
| 110 | require_once __DIR__ . '/admin_footer.php'; |
||
| 111 | break; |
||
| 112 | case 'edit': |
||
| 113 | xoops_cp_header(); |
||
| 114 | |||
| 115 | if (isset($catId) && 0 != $catId) { |
||
| 116 | $cat = $categoryHandler->getCat($catId, true); |
||
| 117 | } |
||
| 118 | // $cat = $categoryHandler->getCat($catId, true); |
||
| 119 | |||
| 120 | echo '<fieldset><legend style="font-weight:bold; color:#990000;">' . _AM_EXTCAL_EDIT_CATEGORY . '</legend>'; |
||
| 121 | $form = new \XoopsThemeForm(_AM_EXTCAL_ADD_CATEGORY, 'add_cat', 'cat.php?op=enreg', 'post', true); |
||
| 122 | $form->addElement(new \XoopsFormText(_AM_EXTCAL_NAME, 'cat_name', 30, 255, $cat->getVar('cat_name')), true); |
||
| 123 | $form->addElement(new \XoopsFormDhtmlTextArea(_AM_EXTCAL_DESCRIPTION, 'cat_desc', $cat->getVar('cat_desc')), false); |
||
| 124 | $form->addElement(new \XoopsFormText(_AM_EXTCAL_WEIGHT, 'cat_weight', 30, 5, $cat->getVar('cat_weight')), false); |
||
| 125 | $form->addElement(new \XoopsFormColorPicker(_AM_EXTCAL_COLOR, 'cat_color', '#' . $cat->getVar('cat_color'))); |
||
| 126 | |||
| 127 | $file_path = dirname(__DIR__) . '/assets/css/images'; |
||
| 128 | $tf = \XoopsLists::getImgListAsArray($file_path); |
||
| 129 | array_unshift($tf, _MD_EXTCAL_NONE); |
||
| 130 | $xfIcones = new \XoopsFormSelect(_AM_EXTCAL_ICONE, 'cat_icone', $cat->getVar('cat_icone'), ''); |
||
| 131 | $xfIcones->addOptionArray($tf); |
||
| 132 | $form->addElement($xfIcones, false); |
||
| 133 | |||
| 134 | $form->addElement(new \XoopsFormHidden('cat_id', $cat->getVar('cat_id')), false); |
||
| 135 | $form->addElement(new \XoopsFormButton('', 'form_submit', _SUBMIT, 'submit'), false); |
||
| 136 | $form->display(); |
||
| 137 | |||
| 138 | echo '</fieldset>'; |
||
| 139 | |||
| 140 | xoops_cp_footer(); |
||
| 141 | break; |
||
| 142 | case 'delete': |
||
| 143 | if (!isset($confirm)) { |
||
| 144 | xoops_cp_header(); |
||
| 145 | $hiddens = [ |
||
| 146 | 'cat_id' => $catId, |
||
| 147 | 'form_delete' => '', |
||
| 148 | CONFIRM => 1, |
||
| 149 | ]; |
||
| 150 | xoops_confirm($hiddens, 'cat.php?op=delete', _AM_EXTCAL_CONFIRM_DELETE_CAT, _DELETE, 'cat.php'); |
||
| 151 | |||
| 152 | xoops_cp_footer(); |
||
| 153 | } else { |
||
| 154 | if (1 == $confirm) { |
||
| 155 | $categoryHandler->deleteCategory($catId); |
||
| 156 | redirect_header('cat.php', 3, _AM_EXTCAL_CAT_DELETED, false); |
||
| 157 | } |
||
| 158 | } |
||
| 159 | break; |
||
| 160 | // case 'modify': |
||
| 161 | // |
||
| 162 | // if (isset($form_modify)) { |
||
| 163 | // xoops_cp_header(); |
||
| 164 | // |
||
| 165 | // // $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
||
| 166 | // $cat = $categoryHandler->getCat($catId, true); |
||
| 167 | // |
||
| 168 | // echo'<fieldset><legend style="font-weight:bold; color:#990000;">' |
||
| 169 | // . _AM_EXTCAL_EDIT_CATEGORY . '</legend>'; |
||
| 170 | // |
||
| 171 | // $form = new \XoopsThemeForm(_AM_EXTCAL_ADD_CATEGORY, 'add_cat', 'cat.php?op=enreg', 'post', true); |
||
| 172 | // $form->addElement( new \XoopsFormText(_AM_EXTCAL_NAME, 'cat_name', 30, 255, $cat->getVar('cat_name')), true); |
||
| 173 | // $form->addElement( new \XoopsFormDhtmlTextArea(_AM_EXTCAL_DESCRIPTION, 'cat_desc', $cat->getVar('cat_desc')), false); |
||
| 174 | // $form->addElement( new \XoopsFormText(_AM_EXTCAL_WEIGHT, 'cat_weight', 30, 5, $cat->getVar('cat_weight')), false); |
||
| 175 | // $form->addElement( |
||
| 176 | // new \XoopsFormColorPicker(_AM_EXTCAL_COLOR, 'cat_color', |
||
| 177 | // '#' . $cat->getVar('cat_color')) |
||
| 178 | // ); |
||
| 179 | // $form->addElement( new \XoopsFormHidden('cat_id', $cat->getVar('cat_id')), false); |
||
| 180 | // $form->addElement( new \XoopsFormButton("", "form_submit", _SEND, "submit"), false); |
||
| 181 | // $form->display(); |
||
| 182 | // |
||
| 183 | // echo '</fieldset>'; |
||
| 184 | // |
||
| 185 | // xoops_cp_footer(); |
||
| 186 | // } else { |
||
| 187 | // if (isset($form_delete)) { |
||
| 188 | // if (!isset($confirm)) { |
||
| 189 | // xoops_cp_header(); |
||
| 190 | // // @author Gregory Mage (Aka Mage) |
||
| 191 | // //*************************************************************************************** |
||
| 192 | // require_once XOOPS_ROOT_PATH . "/modules/extcal/class/admin.php"; |
||
| 193 | // $adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 194 | // $adminObject->displayNavigation(basename(__FILE__)); |
||
| 195 | // //*************************************************************************************** |
||
| 196 | // |
||
| 197 | // $hiddens = array('cat_id' => $catId, 'form_delete' => '', CONFIRM => 1); |
||
| 198 | // xoops_confirm($hiddens, 'cat.php?op=modify', _AM_EXTCAL_CONFIRM_DELETE_CAT, _DELETE, 'cat.php'); |
||
| 199 | // |
||
| 200 | // xoops_cp_footer(); |
||
| 201 | // } else { |
||
| 202 | // if (isset($confirm) && $confirm == 1) { |
||
| 203 | // // $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
||
| 204 | // $categoryHandler->deleteCategory($catId); |
||
| 205 | // redirect_header("cat.php", 3, _AM_EXTCAL_CAT_DELETED, false); |
||
| 206 | // } |
||
| 207 | // } |
||
| 208 | // } |
||
| 209 | // } |
||
| 210 | // |
||
| 211 | // break; |
||
| 212 | // |
||
| 213 | // |
||
| 214 | // case 'default': |
||
| 215 | // |
||
| 216 | // xoops_cp_header(); |
||
| 217 | // // @author Gregory Mage (Aka Mage) |
||
| 218 | // //*************************************************************************************** |
||
| 219 | // $adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 220 | // $adminObject->displayNavigation(basename(__FILE__)); |
||
| 221 | // //*************************************************************************************** |
||
| 222 | // |
||
| 223 | // // $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
||
| 224 | // $cats = $categoryHandler->getAllCat($xoopsUser, 'all'); |
||
| 225 | // |
||
| 226 | // |
||
| 227 | // echo'<fieldset><legend style="font-weight:bold; color:#990000;">' |
||
| 228 | // . _AM_EXTCAL_EDIT_OR_DELETE_CATEGORY . '</legend>'; |
||
| 229 | // $form = new \XoopsThemeForm(_AM_EXTCAL_EDIT_OR_DELETE_CATEGORY, 'mod_cat', 'cat.php?op=modify', 'post', true); |
||
| 230 | // $catSelect = new \XoopsFormSelect(_AM_EXTCAL_CATEGORY, 'cat_id'); |
||
| 231 | // |
||
| 232 | // foreach ( |
||
| 233 | // $cats as $cat |
||
| 234 | //) { |
||
| 235 | // $catSelect->addOption($cat->getVar('cat_id'), $cat->getVar('cat_name')); |
||
| 236 | // } |
||
| 237 | // |
||
| 238 | // $form->addElement($catSelect, true); |
||
| 239 | // $button = new \XoopsFormElementTray(''); |
||
| 240 | // $button->addElement( new \XoopsFormButton("", "form_modify", _EDIT, "submit"), false); |
||
| 241 | // $button->addElement( new \XoopsFormButton("", "form_delete", _DELETE, "submit"), false); |
||
| 242 | // $form->addElement($button, false); |
||
| 243 | // $form->display(); |
||
| 244 | // |
||
| 245 | // |
||
| 246 | // echo '</fieldset><br>'; |
||
| 247 | // echo'<fieldset><legend style="font-weight:bold; color:#990000;">' |
||
| 248 | // . _AM_EXTCAL_ADD_CATEGORY . '</legend>'; |
||
| 249 | // |
||
| 250 | // $form = new \XoopsThemeForm(_AM_EXTCAL_ADD_CATEGORY, 'add_cat', 'cat.php?op=enreg', 'post', true); |
||
| 251 | // $form->addElement( new \XoopsFormText(_AM_EXTCAL_NAME, 'cat_name', 30, 255), true); |
||
| 252 | // $form->addElement( new \XoopsFormDhtmlTextArea(_AM_EXTCAL_DESCRIPTION, 'cat_desc', ''), false); |
||
| 253 | // $form->addElement( new \XoopsFormText(_AM_EXTCAL_WEIGHT, 'cat_weight', 30, 5, $cat->getVar('cat_weight')), false); |
||
| 254 | // $form->addElement( new \XoopsFormColorPicker(_AM_EXTCAL_COLOR, 'cat_color')); |
||
| 255 | // $form->addElement( new \XoopsFormButton("", "form_submit", _SEND, "submit"), false); |
||
| 256 | // $form->display(); |
||
| 257 | // |
||
| 258 | // echo '</fieldset><br>'; |
||
| 259 | // |
||
| 260 | // require_once __DIR__ . '/admin_footer.php'; |
||
| 261 | // |
||
| 262 | // break; |
||
| 263 | |||
| 264 | case 'list': |
||
| 265 | default: |
||
| 266 | xoops_cp_header(); |
||
| 267 | $adminObject = Admin::getInstance(); |
||
| 268 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 269 | |||
| 270 | $adminObject->addItemButton('Add Category', 'cat.php?op=new', 'add', ''); |
||
| 271 | $adminObject->displayButton('left', ''); |
||
| 272 | $cats = $categoryHandler->getAllCatById($xoopsUser); |
||
| 273 | |||
| 274 | $xoopsTpl->assign('cats', $cats); |
||
| 275 | //$xoopsTpl->assign("module_dirname", $helper->getModule()->getVar("dirname") ); |
||
| 276 | |||
| 277 | $xoopsTpl->display('db:admin/extcal_admin_cat_list.tpl'); |
||
| 278 | require_once __DIR__ . '/admin_footer.php'; |
||
| 279 | break; |
||
| 280 | } |
||
| 281 |