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 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | You may not change or alter any portion of this comment or credits |
||
7 | of supporting developers from this source code or any supporting source code |
||
8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
9 | |||
10 | This program is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
13 | */ |
||
14 | |||
15 | /** |
||
16 | * Module: Countdown |
||
17 | * |
||
18 | * @category Module |
||
19 | * @package countdown |
||
20 | * @author XOOPS Development Team <https://xoops.org> |
||
21 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
22 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
23 | * @link https://xoops.org/ |
||
24 | * @since 1.0.0 |
||
25 | */ |
||
26 | |||
27 | use Xmf\Module\Admin; |
||
28 | use Xmf\Database\Tables; |
||
29 | use Xmf\Debug; |
||
30 | use Xmf\Module\Helper; |
||
31 | use Xmf\Module\Helper\Permission; |
||
32 | use Xmf\Request; |
||
33 | |||
34 | require_once __DIR__ . '/admin_header.php'; |
||
35 | xoops_cp_header(); |
||
36 | //It recovered the value of argument op in URL$ |
||
37 | $op = Request::getString('op', 'list'); |
||
38 | $order = Request::getString('order', 'desc'); |
||
39 | $sort = Request::getString('sort', ''); |
||
40 | |||
41 | $adminObject->displayNavigation(basename(__FILE__)); |
||
42 | /** @var Permission $permHelper */ |
||
43 | $permHelper = new \Xmf\Module\Helper\Permission(); |
||
44 | $uploadDir = XOOPS_UPLOAD_PATH . '/countdown/images/'; |
||
45 | $uploadUrl = XOOPS_UPLOAD_URL . '/countdown/images/'; |
||
46 | |||
47 | switch ($op) { |
||
48 | case 'list': |
||
49 | default: |
||
50 | if (!$totalCategories = $categoryHandler->getCount()) { |
||
51 | xoops_error(_AM_COUNTDOWN_CATEGORY_EMPTY); |
||
52 | xoops_cp_footer(); |
||
53 | exit(); |
||
54 | } |
||
55 | $adminObject->addItemButton(_AM_COUNTDOWN_EVENTS_ADD, 'events.php?op=new', 'add'); |
||
56 | echo $adminObject->displayButton('left'); |
||
57 | $start = Request::getInt('start', 0); |
||
58 | $eventsPaginationLimit = $helper->getConfig('usereventperpage'); |
||
59 | |||
60 | $criteria = new \CriteriaCompo(); |
||
61 | $criteria->setSort('event_id ASC, event_id'); |
||
62 | $criteria->setOrder('ASC'); |
||
63 | $criteria->setLimit($eventsPaginationLimit); |
||
64 | $criteria->setStart($start); |
||
65 | $eventsTempRows = $eventsHandler->getCount(); |
||
66 | $eventsTempArray = $eventsHandler->getAll($criteria);/* |
||
67 | // |
||
68 | // |
||
69 | <th class='center width5'>"._AM_COUNTDOWN_FORM_ACTION."</th> |
||
70 | // </tr>"; |
||
71 | // $class = "odd"; |
||
72 | */ |
||
73 | |||
74 | // Display Page Navigation |
||
75 | if ($eventsTempRows > $eventsPaginationLimit) { |
||
76 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
77 | |||
78 | $pagenav = new \XoopsPageNav($eventsTempRows, $eventsPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); |
||
79 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
80 | } |
||
81 | $GLOBALS['xoopsTpl']->assign('countdown_url', COUNTDOWN_URL); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
82 | $GLOBALS['xoopsTpl']->assign('eventsRows', $eventsTempRows); |
||
83 | $eventsArray = []; |
||
84 | |||
85 | // $fields = explode('|', id:int:11::NOT NULL::primary:ID|uid:int:11::NOT NULL:0::User|name:varchar:50::NOT NULL:::Event|description:mediumtext:0::NOT NULL:::Description|date:timestamp:11::NOT NULL:0::End Date/Time); |
||
86 | // $fieldsCount = count($fields); |
||
87 | |||
88 | $criteria = new \CriteriaCompo(); |
||
89 | |||
90 | //$criteria->setOrder('DESC'); |
||
91 | $criteria->setSort($sort); |
||
92 | $criteria->setOrder($order); |
||
93 | $criteria->setLimit($eventsPaginationLimit); |
||
94 | $criteria->setStart($start); |
||
95 | |||
96 | $eventsCount = $eventsHandler->getCount($criteria); |
||
97 | $eventsTempArray = $eventsHandler->getAll($criteria); |
||
98 | |||
99 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
100 | if ($eventsCount > 0) { |
||
101 | foreach (array_keys($eventsTempArray) as $i) { |
||
102 | // $field = explode(':', $fields[$i]); |
||
103 | |||
104 | $selectorid = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_ID, 'event_id'); |
||
105 | $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid); |
||
106 | $eventsArray['event_id'] = $eventsTempArray[$i]->getVar('event_id'); |
||
107 | |||
108 | $selectoruid = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_POSTERNAME, 'event_uid'); |
||
109 | $GLOBALS['xoopsTpl']->assign('selectoruid', $selectoruid); |
||
110 | $eventsArray['event_uid'] = $eventsTempArray[$i]->getVar('event_uid'); |
||
111 | $eventsArray['event_submitter'] = \XoopsUser::getUnameFromId($eventsTempArray[$i]->getVar('event_uid')); |
||
112 | |||
113 | $selectorname = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_NAME, 'event_name'); |
||
114 | $GLOBALS['xoopsTpl']->assign('selectorname', $selectorname); |
||
115 | $eventsArray['event_name'] = $eventsTempArray[$i]->getVar('event_name'); |
||
116 | |||
117 | $selectordescription = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_DESCRIPTION, 'event_description'); |
||
118 | $GLOBALS['xoopsTpl']->assign('selectordescription', $selectordescription); |
||
119 | $eventsArray['event_description'] = ($eventsTempArray[$i]->getVar('event_description')); |
||
120 | |||
121 | $selectordate = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_DATE, 'event_date'); |
||
122 | $GLOBALS['xoopsTpl']->assign('selectordate', $selectordate); |
||
123 | $eventsArray['event_date'] = date(_DATESTRING, strtotime($eventsTempArray[$i]->getVar('event_date'))); |
||
124 | |||
125 | $selectorcategory = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_CATEGORY, 'event_categoryid'); |
||
126 | $GLOBALS['xoopsTpl']->assign('selectorcategory', $selectorcategory); |
||
127 | $eventsArray['event_categoryid'] = $eventsTempArray[$i]->getVar('event_categoryid'); |
||
128 | $categoryHandler = $helper->getHandler('category'); |
||
129 | $categoryObj = $categoryHandler->get($eventsTempArray[$i]->getVar('event_categoryid')); |
||
130 | $eventsArray['event_categoryname'] = $categoryObj->getVar('category_title'); |
||
131 | |||
132 | $selectorlogo = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_LOGO, 'event_logo'); |
||
133 | $GLOBALS['xoopsTpl']->assign('selectorlogo', $selectorlogo); |
||
134 | $eventsArray['event_logo'] = "<img src='" . $uploadUrl . $eventsTempArray[$i]->getVar('event_logo') . "' name='" . 'name' . "' id=" . 'id' . " alt='' style='max-width:100px'>"; |
||
135 | |||
136 | $selectordatecreated = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_DATE_CREATED, 'date_created'); |
||
137 | $GLOBALS['xoopsTpl']->assign('selectordatecreated', $selectordatecreated); |
||
138 | $eventsArray['date_created'] = formatTimestamp($eventsTempArray[$i]->getVar('date_created')); |
||
139 | $date_created = formatTimestamp($eventsTempArray[$i]->getVar('date_created')); |
||
140 | |||
141 | $selectordateupdated = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_DATE_UPDATED, 'date_updated'); |
||
142 | $GLOBALS['xoopsTpl']->assign('selectordateupdated', $selectordateupdated); |
||
143 | $eventsArray['date_updated'] = formatTimestamp($eventsTempArray[$i]->getVar('date_updated')); |
||
144 | $date_updated = formatTimestamp($eventsTempArray[$i]->getVar('date_updated')); |
||
145 | |||
146 | $selectorsubmitted = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_SUBMITTED, 'date_created'); |
||
147 | $GLOBALS['xoopsTpl']->assign('selectorsubmitted', $selectorsubmitted); |
||
148 | |||
149 | if ($date_created == $date_updated) { |
||
150 | $selectorsubmitted = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_SUBMITTED, 'date_created'); |
||
151 | } else { |
||
152 | $selectorsubmitted = $utility::selectSorting(_AM_COUNTDOWN_EVENTS_SUBMITTED, 'date_updated'); |
||
153 | } |
||
154 | |||
155 | $GLOBALS['xoopsTpl']->assign('selectorsubmitted', $selectorsubmitted); |
||
156 | $eventsArray['edit_delete'] = "<a href='events.php?op=edit&id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
157 | <a href='events.php?op=delete&id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
158 | <a href='events.php?op=clone&id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
159 | |||
160 | $GLOBALS['xoopsTpl']->append_by_ref('eventsArrays', $eventsArray); |
||
161 | unset($eventsArray); |
||
162 | } |
||
163 | unset($eventsTempArray); |
||
164 | // Display Navigation |
||
165 | if ($eventsCount > $eventsPaginationLimit) { |
||
166 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
167 | $pagenav = new \XoopsPageNav($eventsCount, $eventsPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); |
||
168 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
169 | } |
||
170 | |||
171 | echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/countdown_admin_events.tpl'); |
||
172 | } |
||
173 | |||
174 | break; |
||
175 | |||
176 | case 'new': |
||
177 | if (!$totalCategories = $categoryHandler->getCount()) { |
||
178 | xoops_error(_AM_COUNTDOWN_CATEGORY_EMPTY); |
||
179 | xoops_cp_footer(); |
||
180 | exit(); |
||
181 | } |
||
182 | $adminObject->addItemButton(_AM_COUNTDOWN_EVENTS_LIST, 'events.php', 'list'); |
||
183 | echo $adminObject->displayButton('left'); |
||
184 | |||
185 | $eventsObject = $eventsHandler->create(); |
||
186 | $form = $eventsObject->getForm(); |
||
187 | $form->display(); |
||
188 | break; |
||
189 | |||
190 | case 'save': |
||
191 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
192 | redirect_header('events.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
193 | } |
||
194 | if (0 != Request::getInt('event_id', 0)) { |
||
195 | $eventsObject = $eventsHandler->get(Request::getInt('event_id', 0)); |
||
196 | } else { |
||
197 | $eventsObject = $eventsHandler->create(); |
||
198 | } |
||
199 | // Form save fields |
||
200 | $eventsObject->setVar('event_categoryid', Request::getVar('event_categoryid', '')); |
||
201 | $eventsObject->setVar('event_uid', Request::getVar('event_uid', '')); |
||
202 | $eventsObject->setVar('event_name', Request::getVar('event_name', '')); |
||
203 | $eventsObject->setVar('event_description', Request::getText('event_description', '')); |
||
204 | $eventsObject->setVar('event_date', date('Y-m-d H:i:s', strtotime($_REQUEST['event_date']['date']) + $_REQUEST['event_date']['time'])); |
||
205 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||
206 | $eventsObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||
207 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_updated', '', 'POST')); |
||
208 | $eventsObject->setVar('date_updated', $dateTimeObj->getTimestamp()); |
||
209 | |||
210 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||
211 | $uploadDir = XOOPS_UPLOAD_PATH . '/countdown/images/'; |
||
212 | $uploader = new \XoopsMediaUploader($uploadDir, $helper->getConfig('mimetypes'), $helper->getConfig('maxsize'), null, null); |
||
213 | if ($uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0])) { |
||
214 | //$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '' , $_FILES['attachedfile']['name']); |
||
215 | //$imgName = str_replace(' ', '', $_POST['']).'.'.$extension; |
||
216 | |||
217 | $uploader->setPrefix('logo_'); |
||
218 | $uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0]); |
||
219 | if (!$uploader->upload()) { |
||
220 | $errors = $uploader->getErrors(); |
||
221 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||
222 | } else { |
||
223 | $eventsObject->setVar('event_logo', $uploader->getSavedFileName()); |
||
224 | } |
||
225 | } else { |
||
226 | $eventsObject->setVar('event_logo', Request::getVar('event_logo', '')); |
||
227 | } |
||
228 | |||
229 | if ($eventsHandler->insert($eventsObject)) { |
||
230 | redirect_header('events.php?op=list', 2, _AM_COUNTDOWN_FORMOK); |
||
231 | } |
||
232 | |||
233 | echo $eventsObject->getHtmlErrors(); |
||
234 | $form = $eventsObject->getForm(); |
||
235 | $form->display(); |
||
236 | break; |
||
237 | |||
238 | case 'edit': |
||
239 | $adminObject->addItemButton(_AM_COUNTDOWN_ADD_EVENTS, 'events.php?op=new', 'add'); |
||
240 | $adminObject->addItemButton(_AM_COUNTDOWN_EVENTS_LIST, 'events.php', 'list'); |
||
241 | echo $adminObject->displayButton('left'); |
||
242 | $eventsObject = $eventsHandler->get(Request::getString('id', '')); |
||
243 | $form = $eventsObject->getForm(); |
||
244 | $form->display(); |
||
245 | break; |
||
246 | |||
247 | case 'delete': |
||
248 | $eventsObject = $eventsHandler->get(Request::getString('id', '')); |
||
249 | if (1 == Request::getInt('ok', 0)) { |
||
250 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
251 | redirect_header('events.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
252 | } |
||
253 | if ($eventsHandler->delete($eventsObject)) { |
||
254 | redirect_header('events.php', 3, _AM_COUNTDOWN_FORMDELOK); |
||
255 | } else { |
||
256 | echo $eventsObject->getHtmlErrors(); |
||
257 | } |
||
258 | } else { |
||
259 | xoops_confirm(['ok' => 1, 'id' => Request::getString('id', ''), 'op' => 'delete'], Request::getUrl('REQUEST_URI', '', 'SERVER'), sprintf(_AM_COUNTDOWN_FORMSUREDEL, $eventsObject->getVar('event_id'))); |
||
260 | } |
||
261 | break; |
||
262 | |||
263 | case 'clone': |
||
264 | |||
265 | $id_field = Request::getString('id', ''); |
||
266 | |||
267 | if ($utility::cloneRecord('countdown_events', 'event_id', $id_field)) { |
||
268 | redirect_header('events.php', 3, _AM_COUNTDOWN_CLONED_OK); |
||
269 | } else { |
||
270 | redirect_header('events.php', 3, _AM_COUNTDOWN_CLONED_FAILED); |
||
271 | } |
||
272 | |||
273 | break; |
||
274 | } |
||
275 | require_once __DIR__ . '/admin_footer.php'; |
||
276 |