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 | * oledrion |
||
14 | * |
||
15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
17 | * @author Hossein Azizabadi ([email protected]) |
||
18 | */ |
||
19 | |||
20 | use XoopsModules\Oledrion; |
||
21 | |||
22 | /** |
||
23 | * Check is admin |
||
24 | */ |
||
25 | if (!defined('OLEDRION_ADMIN')) { |
||
26 | exit(); |
||
27 | } |
||
28 | |||
29 | switch ($action) { |
||
30 | case 'default': |
||
31 | |||
32 | xoops_cp_header(); |
||
33 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
34 | $adminObject->displayNavigation('index.php?op=packing'); |
||
35 | |||
36 | $start = \Xmf\Request::getInt('start', 0, 'GET'); |
||
37 | $packing = []; |
||
38 | $form = "<form method='post' action='$baseurl' name='frmaddpacking' id='frmaddpacking'><input type='hidden' name='op' id='op' value='packing'><input type='hidden' name='action' id='action' value='add'><input type='submit' name='btngo' id='btngo' value='" |
||
39 | . _AM_OLEDRION_ADD_ITEM |
||
40 | . "'></form>"; |
||
41 | echo $form; |
||
42 | // Oledrion\Utility::htitle(_MI_OLEDRION_ADMENU18, 4); |
||
43 | $packing = $packingHandler->getAllPacking(new Oledrion\Parameters([ |
||
44 | 'start' => $start, |
||
45 | 'limit' => $limit, |
||
46 | ])); |
||
47 | |||
48 | $class = ''; |
||
49 | echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
||
50 | echo "<tr><th align='center'>" . _AM_OLEDRION_ID . "</th><th align='center'>" . _AM_OLEDRION_PACKING_TITLE . "</th><th align='center'>" . _OLEDRION_PRICE . "</th><th align='center'>" . _OLEDRION_ONLINE . "</th><th align='center'>" . _AM_OLEDRION_ACTION . '</th></tr>'; |
||
51 | foreach ($packing as $item) { |
||
52 | $id = $item->getVar('packing_id'); |
||
53 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
54 | $actions = []; |
||
55 | $actions[] = "<a href='$baseurl?op=packing&action=edit&id=" . $id . "' title='" . _OLEDRION_EDIT . "'>" . $icons['edit'] . '</a>'; |
||
56 | $actions[] = "<a href='$baseurl?op=packing&action=delete&id=" . $id . "' title='" . _OLEDRION_DELETE . "'" . $conf_msg . '>' . $icons['delete'] . '</a>'; |
||
57 | $online = 1 == $item->getVar('packing_online') ? _YES : _NO; |
||
58 | echo "<tr class='" . $class . "'>\n"; |
||
59 | echo "<td align='center'>" . $id . "</td><td align='center'>" . $item->getVar('packing_title') . "</td><td align='center'>" . $item->getVar('packing_price') . "</td><td align='center'>" . $online . "</td><td align='center'>" . implode(' ', $actions) . "</td>\n"; |
||
60 | echo "<tr>\n"; |
||
61 | } |
||
62 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
63 | echo "<tr class='" . $class . "'>\n"; |
||
64 | echo "<td colspan='5' align='center'>" . $form . "</td>\n"; |
||
65 | echo "</tr>\n"; |
||
66 | echo '</table>'; |
||
67 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
68 | |||
69 | break; |
||
70 | case 'add': |
||
71 | |||
72 | case 'edit': |
||
73 | |||
74 | xoops_cp_header(); |
||
75 | if ('edit' === $action) { |
||
76 | $title = _AM_OLEDRION_PACKING_EDIT; |
||
77 | $id = \Xmf\Request::getInt('id', 0, 'GET'); |
||
78 | if (empty($id)) { |
||
79 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
80 | } |
||
81 | // Item exits ? |
||
82 | $item = null; |
||
83 | $item = $packingHandler->get($id); |
||
84 | if (!is_object($item)) { |
||
85 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
86 | } |
||
87 | $edit = true; |
||
88 | $label_submit = _AM_OLEDRION_MODIFY; |
||
89 | } else { |
||
90 | $title = _AM_OLEDRION_PACKING_ADD; |
||
91 | $item = $packingHandler->create(true); |
||
92 | $label_submit = _AM_OLEDRION_ADD; |
||
93 | $edit = false; |
||
94 | } |
||
95 | $sform = new \XoopsThemeForm($title, 'frmaddpacking', $baseurl); |
||
96 | $sform->addElement(new \XoopsFormHidden('op', 'packing')); |
||
97 | $sform->addElement(new \XoopsFormHidden('action', 'save')); |
||
98 | $sform->addElement(new \XoopsFormHidden('packing_id', $item->getVar('packing_id'))); |
||
99 | $sform->addElement(new \XoopsFormText(_AM_OLEDRION_PACKING_TITLE, 'packing_title', 50, 150, $item->getVar('packing_title', 'e')), true); |
||
100 | $sform->addElement(new \XoopsFormText(_AM_OLEDRION_PACKING_WIDTH, 'packing_width', 20, 20, $item->getVar('packing_width', 'e')), false); |
||
101 | $sform->addElement(new \XoopsFormText(_AM_OLEDRION_PACKING_LENGTH, 'packing_length', 20, 20, $item->getVar('packing_length', 'e')), false); |
||
102 | $sform->addElement(new \XoopsFormText(_AM_OLEDRION_PACKING_WEIGHT, 'packing_weight', 20, 20, $item->getVar('packing_weight', 'e')), false); |
||
103 | if ('edit' === $action && $item->pictureExists()) { |
||
104 | $pictureTray = new \XoopsFormElementTray(_AM_OLEDRION_CURRENT_PICTURE, '<br>'); |
||
105 | $pictureTray->addElement(new \XoopsFormLabel('', "<img src='" . $item->getPictureUrl() . "' alt='' border='0'>")); |
||
106 | $deleteCheckbox = new \XoopsFormCheckBox('', 'delpicture'); |
||
107 | $deleteCheckbox->addOption(1, _DELETE); |
||
108 | $pictureTray->addElement($deleteCheckbox); |
||
109 | $sform->addElement($pictureTray); |
||
110 | unset($pictureTray, $deleteCheckbox); |
||
111 | } |
||
112 | $sform->addElement(new \XoopsFormFile(_AM_OLEDRION_PICTURE, 'attachedfile', Oledrion\Utility::getModuleOption('maxuploadsize')), false); |
||
113 | $editor = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_DESCRIPTION, 'packing_description', $item->getVar('packing_description', 'e'), 15, 60, 'description_hidden'); |
||
114 | if ($editor) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
115 | $sform->addElement($editor, false); |
||
116 | } |
||
117 | $sform->addElement(new \XoopsFormText(_AM_OLEDRION_PACKING_PRICE, 'packing_price', 20, 20, $item->getVar('packing_price', 'e')), false); |
||
118 | $sform->addElement(new \XoopsFormRadioYN(_OLEDRION_ONLINE_HLP, 'packing_online', $item->getVar('packing_online')), true); |
||
119 | $buttonTray = new \XoopsFormElementTray('', ''); |
||
120 | $submit_btn = new \XoopsFormButton('', 'post', $label_submit, 'submit'); |
||
121 | $buttonTray->addElement($submit_btn); |
||
122 | $sform->addElement($buttonTray); |
||
123 | $sform = Oledrion\Utility::formMarkRequiredFields($sform); |
||
124 | $sform->display(); |
||
125 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
126 | |||
127 | break; |
||
128 | case 'save': |
||
129 | |||
130 | xoops_cp_header(); |
||
131 | $id = \Xmf\Request::getInt('packing_id', 0, 'POST'); |
||
132 | if (!empty($id)) { |
||
133 | $edit = true; |
||
134 | $item = $packingHandler->get($id); |
||
135 | if (!is_object($item)) { |
||
136 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
137 | } |
||
138 | $item->unsetNew(); |
||
139 | } else { |
||
140 | $item = $packingHandler->create(true); |
||
141 | } |
||
142 | $opRedirect = 'packing'; |
||
143 | $item->setVars($_POST); |
||
144 | |||
145 | if (\Xmf\Request::hasVar('delpicture', 'POST') && 1 == \Xmf\Request::getInt('delpicture', 0, 'POST')) { |
||
146 | $item->deletePicture(); |
||
147 | } |
||
148 | $destname = ''; |
||
149 | $res1 = Oledrion\Utility::uploadFile(0, OLEDRION_PICTURES_PATH); |
||
150 | if ($res1) { |
||
151 | if (Oledrion\Utility::getModuleOption('resize_others')) { |
||
152 | // Eventuellement on redimensionne l'image |
||
153 | Oledrion\Utility::resizePicture(OLEDRION_PICTURES_PATH . '/' . $destname, OLEDRION_PICTURES_PATH . '/' . $destname, Oledrion\Utility::getModuleOption('images_width'), Oledrion\Utility::getModuleOption('images_height'), true); |
||
154 | } |
||
155 | $item->setVar('packing_image', basename($destname)); |
||
156 | } else { |
||
157 | if (false !== $res1) { |
||
158 | echo $res1; |
||
159 | } |
||
160 | } |
||
161 | $res = $packingHandler->insert($item); |
||
162 | if ($res) { |
||
163 | Oledrion\Utility::updateCache(); |
||
164 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
165 | } else { |
||
166 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
167 | } |
||
168 | |||
169 | break; |
||
170 | case 'delete': |
||
171 | |||
172 | xoops_cp_header(); |
||
173 | $id = \Xmf\Request::getInt('id', 0, 'GET'); |
||
174 | if (0 == $id) { |
||
175 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
176 | } |
||
177 | $packing = null; |
||
178 | $packing = $packingHandler->get($id); |
||
179 | if (!is_object($packing)) { |
||
180 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_10, $baseurl, 5); |
||
181 | } |
||
182 | $msg = sprintf(_AM_OLEDRION_CONF_DEL_ITEM, $packing->getVar('packing_title')); |
||
183 | xoops_confirm(['op' => 'packing', 'action' => 'confdelete', 'id' => $id], 'index.php', $msg); |
||
184 | |||
185 | break; |
||
186 | case 'confdelete': |
||
187 | |||
188 | xoops_cp_header(); |
||
189 | $id = \Xmf\Request::getInt('id', 0, 'POST'); |
||
190 | if (empty($id)) { |
||
191 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
192 | } |
||
193 | $opRedirect = 'packing'; |
||
194 | |||
195 | $item = null; |
||
196 | $item = $packingHandler->get($id); |
||
197 | if (is_object($item)) { |
||
198 | $res = $packingHandler->delete($item); |
||
199 | if ($res) { |
||
200 | Oledrion\Utility::updateCache(); |
||
201 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
202 | } else { |
||
203 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
204 | } |
||
205 | } else { |
||
206 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
||
207 | } |
||
208 | |||
209 | break; |
||
210 | } |
||
211 |