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 declare(strict_types=1); |
||
2 | |||
3 | /* |
||
4 | You may not change or alter any portion of this comment or credits |
||
5 | of supporting developers from this source code or any supporting source code |
||
6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
7 | |||
8 | This program is distributed in the hope that it will be useful, |
||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * wgEvents module for xoops |
||
15 | * |
||
16 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
17 | * @license GPL 2.0 or later |
||
18 | * @package wgevents |
||
19 | * @since 1.0.0 |
||
20 | * @min_xoops 2.5.11 Beta1 |
||
21 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
22 | */ |
||
23 | |||
24 | use Xmf\Request; |
||
0 ignored issues
–
show
|
|||
25 | use XoopsModules\Wgevents; |
||
26 | use XoopsModules\Wgevents\Constants; |
||
27 | |||
28 | require __DIR__ . '/header.php'; |
||
29 | $GLOBALS['xoopsOption']['template_main'] = 'wgevents_index.tpl'; |
||
30 | require_once \XOOPS_ROOT_PATH . '/header.php'; |
||
31 | |||
32 | // Permission |
||
33 | if (!$permissionsHandler->getPermEventsView()) { |
||
34 | $GLOBALS['xoopsTpl']->assign('errorPerm', _NOPERM); |
||
35 | require __DIR__ . '/footer.php'; |
||
36 | exit; |
||
37 | } |
||
38 | $permRegister = $permissionsHandler->getPermRegistrationsSubmit(); |
||
39 | $GLOBALS['xoopsTpl']->assign('permRegister', $permRegister); |
||
40 | |||
41 | $op = Request::getCmd('op', 'coming'); |
||
42 | $start = Request::getInt('start'); |
||
43 | $limit = Request::getInt('limit', (int)$helper->getConfig('userpager')); |
||
44 | $catId = Request::getInt('cat_id'); |
||
45 | $filterCats = Request::getArray('filter_cats'); |
||
46 | if ($catId > 0 && 0 === \count($filterCats)) { |
||
47 | $filterCats[] = $catId; |
||
48 | } |
||
49 | $urlCats = Request::getString('cats'); |
||
50 | if (0 === \count($filterCats) && '' !== $urlCats) { |
||
51 | $filterCats = \explode(',', $urlCats); |
||
52 | } |
||
53 | $GLOBALS['xoopsTpl']->assign('urlCats', \implode(',', $filterCats)); |
||
54 | |||
55 | // Define Stylesheet |
||
56 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
57 | // Keywords |
||
58 | $keywords = []; |
||
59 | // Breadcrumbs |
||
60 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_INDEX]; |
||
61 | // Paths |
||
62 | $GLOBALS['xoopsTpl']->assign('xoops_icons32_url', \XOOPS_ICONS32_URL); |
||
63 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
64 | $GLOBALS['xoopsTpl']->assign('wgevents_icons_url_32', \WGEVENTS_ICONS_URL_32); |
||
65 | // JS |
||
66 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||
67 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/expander/jquery.expander.min.js'); |
||
68 | |||
69 | //preferences |
||
70 | $GLOBALS['xoopsTpl']->assign('index_header', $helper->getConfig('index_header')); |
||
71 | $GLOBALS['xoopsTpl']->assign('user_maxchar', $helper->getConfig('user_maxchar')); |
||
72 | $indexDisplayCats = (string)$helper->getConfig('index_displaycats'); |
||
73 | $GLOBALS['xoopsTpl']->assign('index_displaycats', $indexDisplayCats); |
||
74 | $indexDisplayEvents = (string)$helper->getConfig('index_displayevents'); |
||
75 | $GLOBALS['xoopsTpl']->assign('index_displayevents', $indexDisplayEvents); |
||
76 | $useGroups = (bool)$helper->getConfig('use_groups'); |
||
77 | $gmapsEnableEvent = false; |
||
78 | $gmapsHeight = false; |
||
79 | $useGMaps = (bool)$helper->getConfig('use_gmaps'); |
||
80 | if ($useGMaps) { |
||
81 | $gmapsPositionList = (string)$helper->getConfig('gmaps_enableindex'); |
||
82 | $gmapsEnableEvent = ('top' === $gmapsPositionList || 'bottom' === $gmapsPositionList); |
||
83 | $gmapsHeight = $helper->getConfig('gmaps_height'); |
||
84 | } |
||
85 | $eventRegprocessbar = (string)$helper->getConfig('event_regprocessbar'); |
||
86 | $GLOBALS['xoopsTpl']->assign('event_regprocessbar', $eventRegprocessbar); |
||
87 | $GLOBALS['xoopsTpl']->assign('use_urlregistration', $helper->getConfig('use_urlregistration')); |
||
88 | |||
89 | //misc |
||
90 | $GLOBALS['xoopsTpl']->assign('categoryCurrent', $catId); |
||
91 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
92 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
93 | $GLOBALS['xoopsTpl']->assign('categoryCurrent', $catId); |
||
94 | $catName = ''; |
||
95 | |||
96 | $uidCurrent = 0; |
||
97 | $userIsAdmin = false; |
||
98 | if (\is_object($GLOBALS['xoopsUser'])) { |
||
99 | $uidCurrent = $GLOBALS['xoopsUser']->uid(); |
||
100 | $userIsAdmin = $GLOBALS['xoopsUser']->isAdmin(); |
||
101 | } |
||
102 | |||
103 | if ('none' !== $indexDisplayCats) { |
||
104 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_catlogos_url', \WGEVENTS_UPLOAD_CATLOGOS_URL); |
||
105 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_catimages_url', \WGEVENTS_UPLOAD_CATIMAGES_URL); |
||
106 | $categories = $categoryHandler->getCategoriesForFilter($indexDisplayCats, $filterCats, $op, $useGroups); |
||
107 | $GLOBALS['xoopsTpl']->assign('categories', $categories); |
||
108 | if ('form' === $indexDisplayCats) { |
||
109 | $formCatsCb = $categoryHandler->getFormCatsCb($filterCats, $op); |
||
110 | $GLOBALS['xoopsTpl']->assign('formCatsCb', $formCatsCb->render()); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | $indexDisplayEvents = (string)$helper->getConfig('index_displayevents'); |
||
115 | $GLOBALS['xoopsTpl']->assign('index_displayevents', $indexDisplayEvents); |
||
116 | |||
117 | if ('none' !== $indexDisplayEvents) { |
||
118 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
||
119 | $listDescr = ''; |
||
120 | if ('past' === $op) { |
||
121 | $GLOBALS['xoopsTpl']->assign('showBtnComing', true); |
||
122 | $listDescr = \_MA_WGEVENTS_EVENTS_LISTPAST; |
||
123 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_EVENTS_LISTPAST]; |
||
124 | } else { |
||
125 | $GLOBALS['xoopsTpl']->assign('showBtnPast', true); |
||
126 | $listDescr = \_MA_WGEVENTS_EVENTS_LISTCOMING; |
||
127 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_EVENTS_LISTCOMING]; |
||
128 | } |
||
129 | /* $catId only for buttons*/ |
||
130 | /* |
||
131 | if ($catId > 0) { |
||
132 | //$crEvent->add(new \Criteria('catid', $catId)); |
||
133 | $listDescr .= ' - ' . $catName; |
||
134 | }*/ |
||
135 | |||
136 | $GLOBALS['xoopsTpl']->assign('listDescr', $listDescr); |
||
137 | |||
138 | // get events |
||
139 | $eventsArr = $eventHandler->getEvents($start, $limit, \time(), 0, '', '', $op, 0, '', $filterCats); |
||
140 | |||
141 | $eventsCount = $eventsArr['count']; |
||
142 | |||
143 | $GLOBALS['xoopsTpl']->assign('eventsCount', $eventsCount); |
||
144 | if ($eventsCount > 0) { |
||
145 | $eventsAll = $eventsArr['eventsAll']; |
||
146 | $events = []; |
||
147 | $eventsMap = []; |
||
148 | $evName = ''; |
||
149 | // Get All Event |
||
150 | foreach (\array_keys($eventsAll) as $i) { |
||
151 | $events[$i] = $eventsAll[$i]->getValuesEvents(); |
||
152 | $events[$i]['locked'] = (Constants::STATUS_LOCKED === (int)$events[$i]['status']); |
||
153 | $events[$i]['canceled'] = (Constants::STATUS_CANCELED === (int)$events[$i]['status']); |
||
154 | $permEdit = $permissionsHandler->getPermEventsEdit($events[$i]['submitter'], $events[$i]['status']) || $uidCurrent == $events[$i]['submitter']; |
||
155 | $events[$i]['permEdit'] = $permEdit; |
||
156 | |||
157 | $crRegistration = new \CriteriaCompo(); |
||
158 | $crRegistration->add(new \Criteria('evid', $i)); |
||
159 | $numberRegCurr = $registrationHandler->getCount($crRegistration); |
||
160 | $events[$i]['nb_registrations'] = $numberRegCurr; |
||
161 | $registerMax = (int)$events[$i]['register_max']; |
||
162 | if ($registerMax > 0) { |
||
163 | $events[$i]['regmax'] = $registerMax; |
||
164 | $proportion = $numberRegCurr / $registerMax; |
||
165 | if ($proportion >= 1) { |
||
166 | $events[$i]['regcurrent'] = \_MA_WGEVENTS_REGISTRATIONS_FULL; |
||
167 | } else { |
||
168 | $events[$i]['regcurrent'] = \sprintf(\_MA_WGEVENTS_REGISTRATIONS_NBCURR_INDEX, $numberRegCurr, $registerMax); |
||
169 | } |
||
170 | $events[$i]['regcurrent_text'] = $events[$i]['regcurrent']; |
||
171 | $events[$i]['regcurrent_tip'] = true; |
||
172 | if ($proportion < 0.75) { |
||
173 | $events[$i]['regcurrentstate'] = 'success'; |
||
174 | } elseif ($proportion < 1) { |
||
175 | $events[$i]['regcurrentstate'] = 'warning'; |
||
176 | } else { |
||
177 | $events[$i]['regcurrentstate'] = 'danger'; |
||
178 | $events[$i]['regcurrent_tip'] = false; |
||
179 | } |
||
180 | $events[$i]['regpercentage'] = (int)($proportion * 100); |
||
181 | } |
||
182 | $evName = $eventsAll[$i]->getVar('name'); |
||
183 | $keywords[$i] = $evName; |
||
184 | if ($useGMaps && $gmapsEnableEvent && (float)$eventsAll[$i]->getVar('locgmlat') > 0) { |
||
185 | $eventsMap[$i] = [ |
||
186 | 'name' => $evName, |
||
187 | 'location' => $events[$i]['location_text_user'], |
||
188 | 'from' => $events[$i]['datefrom_text'], |
||
189 | 'url' => 'event.php?op=show&id=' . $i, |
||
190 | 'lat' => (float)$eventsAll[$i]->getVar('locgmlat'), |
||
191 | 'lon' => (float)$eventsAll[$i]->getVar('locgmlon') |
||
192 | ]; |
||
193 | } |
||
194 | } |
||
195 | $GLOBALS['xoopsTpl']->assign('events', $events); |
||
196 | if ('show' === $op && $useGMaps) { |
||
197 | $GLOBALS['xoopsTpl']->assign('gmapsShow', true); |
||
198 | } |
||
199 | if ($useGMaps && count($eventsMap) > 0) { |
||
200 | $GLOBALS['xoopsTpl']->assign('gmapsShowList', true); |
||
201 | $GLOBALS['xoopsTpl']->assign('gmapsEnableEvent', $gmapsEnableEvent); |
||
202 | $GLOBALS['xoopsTpl']->assign('gmapsHeight', $gmapsHeight); |
||
203 | $GLOBALS['xoopsTpl']->assign('gmapsPositionList', $gmapsPositionList); |
||
204 | $GLOBALS['xoopsTpl']->assign('api_key', $helper->getConfig('gmaps_api')); |
||
205 | $GLOBALS['xoopsTpl']->assign('eventsMap', $eventsMap); |
||
206 | } |
||
207 | unset($events, $eventMaps); |
||
208 | // Display Navigation |
||
209 | if ($eventsCount > $limit) { |
||
210 | $urlCats = \implode(',', $filterCats); |
||
211 | require_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
212 | $pagenav = new \XoopsPageNav($eventsCount, $limit, $start, 'start', 'op=list&limit=' . $limit . '&cat_id=' . $catId . '&cats=' . $urlCats); |
||
213 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||
214 | /*TODO: give possibility to change counter for page nav*/ |
||
215 | /* |
||
216 | $params = []; |
||
217 | $params['op'] = $op; |
||
218 | $params['limit'] = $limit; |
||
219 | $params['catId'] = $catId; |
||
220 | $params['filterCats'] = $filterCats; |
||
221 | $formPageNavCounter = $eventHandler->getFormPageNavCounterSelect($params); |
||
222 | $GLOBALS['xoopsTpl']->assign('formPageNavCounter', $formPageNavCounter->render());*/ |
||
223 | } |
||
224 | } elseif (\count($filterCats) > 0) { |
||
225 | $GLOBALS['xoopsTpl']->assign('noEventsReason', \_MA_WGEVENTS_INDEX_THEREARENT_EVENTS_FILTER); |
||
226 | } else { |
||
227 | $GLOBALS['xoopsTpl']->assign('noEventsReason', \_MA_WGEVENTS_INDEX_THEREARENT_EVENTS); |
||
228 | } |
||
229 | } |
||
230 | |||
231 | // Keywords |
||
232 | wgeventsMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords)); |
||
233 | unset($keywords); |
||
234 | // Description |
||
235 | //wgeventsMetaDescription(\_MA_WGEVENTS_INDEX_DESC); |
||
236 | $GLOBALS['xoopsTpl']->assign('xoops_mpageurl', \WGEVENTS_URL.'/index.php'); |
||
237 | $GLOBALS['xoopsTpl']->assign('xoops_icons32_url', \XOOPS_ICONS32_URL); |
||
238 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
239 | require __DIR__ . '/footer.php'; |
||
240 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: