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 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
20 | */ |
||
21 | |||
22 | use Xmf\Request; |
||
0 ignored issues
–
show
|
|||
23 | use XoopsModules\Wgevents; |
||
24 | use XoopsModules\Wgevents\{ |
||
25 | Constants, |
||
26 | Common, |
||
27 | MailHandler, |
||
28 | Utility |
||
29 | }; |
||
30 | |||
31 | require __DIR__ . '/header.php'; |
||
32 | require_once \XOOPS_ROOT_PATH . '/header.php'; |
||
33 | |||
34 | $op = Request::getCmd('op', 'list'); |
||
35 | $regId = Request::getInt('id'); |
||
36 | $regEvid = Request::getInt('evid'); |
||
37 | $feeValue = Request::getFloat('feevalue'); |
||
38 | |||
39 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? (int)$GLOBALS['xoopsUser']->uid() : 0; |
||
40 | |||
41 | XoopsLoad::load('xoopslogger'); |
||
42 | $xoopsLogger = XoopsLogger::getInstance(); |
||
43 | $xoopsLogger->activated = false; |
||
44 | |||
45 | switch ($op) { |
||
46 | case 'show': |
||
47 | case 'list': |
||
48 | default: |
||
49 | break; |
||
50 | case 'change_financial': |
||
51 | if (0 === $regEvid) { |
||
52 | header('Content-Type: application/json'); |
||
53 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
54 | break; |
||
55 | } |
||
56 | $eventObj = $eventHandler->get($regEvid); |
||
57 | if (!is_object($eventObj)) { |
||
58 | header('Content-Type: application/json'); |
||
59 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
60 | break; |
||
61 | } |
||
62 | if (!$permissionsHandler->getPermRegistrationsApprove($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||
63 | header('Content-Type: application/json'); |
||
64 | echo json_encode(['status'=>'error','message'=>\_NOPERM]); |
||
65 | break; |
||
66 | } |
||
67 | if ($regId > 0) { |
||
68 | // Check permissions |
||
69 | $registrationObj = $registrationHandler->get($regId); |
||
70 | $registrationObjOld = $registrationHandler->get($regId); |
||
71 | } else { |
||
72 | header('Content-Type: application/json'); |
||
73 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
74 | break; |
||
75 | } |
||
76 | $regFinancial = Request::getInt('changeto'); |
||
77 | $registrationObj->setVar('financial', $regFinancial); |
||
78 | if (Constants::FINANCIAL_PAID == $regFinancial) { |
||
79 | $registrationObj->setVar('paidamount', $feeValue); |
||
80 | } else { |
||
81 | $registrationObj->setVar('paidamount', 0); |
||
82 | } |
||
83 | // Insert Data |
||
84 | if ($registrationHandler->insert($registrationObj)) { |
||
85 | // create history |
||
86 | $registrationhistHandler->createHistory($registrationObjOld, 'update'); |
||
87 | // TODO: Handle notification |
||
88 | |||
89 | $mailsHandler = new MailHandler(); |
||
90 | $mailParams = $mailsHandler->getMailParam($eventObj, $regId); |
||
91 | unset($mailsHandler); |
||
92 | // find changes in table registrations |
||
93 | $codeArr = [ |
||
94 | $regId, |
||
95 | \WGEVENTS_URL, |
||
96 | $regEvid, |
||
97 | $registrationObj->getVar('email'), |
||
98 | $registrationObj->getVar('verifkey') |
||
99 | ]; |
||
100 | $code = base64_encode(implode('||', $codeArr)); |
||
101 | $infotextReg = $registrationHandler->getRegistrationsCompare($registrationObjOld, $regId); |
||
102 | $singleRegLink = \WGEVENTS_URL . '/registration.php?op=show&verifkey=' . $code; |
||
103 | $infotextReg .= PHP_EOL . \sprintf(\_MA_WGEVENTS_MAIL_REG_SINGLE, $singleRegLink) . PHP_EOL; |
||
104 | $mailParams['infotext'] = $infotextReg; |
||
105 | |||
106 | // send notifications/confirmation emails |
||
107 | $registerNotify = (string)$eventObj->getVar('register_notify', 'e'); |
||
108 | if ('' !== $registerNotify) { |
||
109 | // send notifications to emails of register_notify |
||
110 | $notifyEmails = $eventHandler->getRecipientsNotify($registerNotify); |
||
111 | if (\count($notifyEmails) > 0) { |
||
112 | foreach ($notifyEmails as $recipient) { |
||
113 | $taskHandler->createTask(Constants::MAIL_REG_NOTIFY_MODIFY, $recipient, json_encode($mailParams)); |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | $regEmail = $registrationObj->getVar('email'); |
||
118 | if ('' !== $regEmail) { |
||
119 | $taskHandler->createTask(Constants::MAIL_REG_CONFIRM_MODIFY, $regEmail, json_encode($mailParams)); |
||
120 | } |
||
121 | // excetue mail sending by task handler |
||
122 | $taskHandler->processTasks(); |
||
123 | header('Content-Type: application/json'); |
||
124 | echo json_encode(['status'=>'success','message'=>'no errors']); |
||
125 | } |
||
126 | break; |
||
127 | case 'listwait_takeover': |
||
128 | if (0 === $regEvid) { |
||
129 | header('Content-Type: application/json'); |
||
130 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
131 | break; |
||
132 | } |
||
133 | $eventObj = $eventHandler->get($regEvid); |
||
134 | if (!is_object($eventObj)) { |
||
135 | header('Content-Type: application/json'); |
||
136 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
137 | break; |
||
138 | } |
||
139 | if (!$permissionsHandler->getPermRegistrationsApprove($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||
140 | header('Content-Type: application/json'); |
||
141 | echo json_encode(['status'=>'error','message'=>\_NOPERM]); |
||
142 | break; |
||
143 | } |
||
144 | if ($regId > 0) { |
||
145 | // create two objects of current registration |
||
146 | $registrationObj = $registrationHandler->get($regId); |
||
147 | $registrationObjOld = $registrationHandler->get($regId); |
||
148 | // create history |
||
149 | $registrationhistHandler->createHistory($registrationObj, 'update'); |
||
150 | } else { |
||
151 | header('Content-Type: application/json'); |
||
152 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
153 | break; |
||
154 | } |
||
155 | $registrationObj->setVar('listwait', 0); |
||
156 | // Insert Data |
||
157 | if ($registrationHandler->insert($registrationObj)) { |
||
158 | // TODO: Handle notification |
||
159 | |||
160 | $mailsHandler = new MailHandler(); |
||
161 | $mailParams = $mailsHandler->getMailParam($eventObj, $regId); |
||
162 | unset($mailsHandler); |
||
163 | // find changes in table registrations |
||
164 | $mailParams['infotext'] = $registrationHandler->getRegistrationsCompare($registrationObjOld, $regId); |
||
165 | |||
166 | // send notifications/confirmation emails |
||
167 | $registerNotify = (string)$eventObj->getVar('register_notify', 'e'); |
||
168 | if ('' !== $registerNotify) { |
||
169 | // send notifications to emails of register_notify |
||
170 | $notifyEmails = $eventHandler->getRecipientsNotify($registerNotify); |
||
171 | if (\count($notifyEmails) > 0) { |
||
172 | foreach ($notifyEmails as $recipient) { |
||
173 | $taskHandler->createTask(Constants::MAIL_REG_NOTIFY_MODIFY, $recipient, json_encode($mailParams)); |
||
174 | } |
||
175 | } |
||
176 | } |
||
177 | $regEmail = $registrationObj->getVar('email'); |
||
178 | if ('' !== $regEmail) { |
||
179 | $taskHandler->createTask(Constants::MAIL_REG_CONFIRM_MODIFY, $regEmail, json_encode($mailParams)); |
||
180 | } |
||
181 | // excetue mail sending by task handler |
||
182 | $taskHandler->processTasks(); |
||
183 | header('Content-Type: application/json'); |
||
184 | echo json_encode(['status'=>'success','message'=>'no errors']); |
||
185 | } |
||
186 | break; |
||
187 | case 'approve_status': |
||
188 | if (0 === $regEvid) { |
||
189 | header('Content-Type: application/json'); |
||
190 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
191 | break; |
||
192 | } |
||
193 | $eventObj = $eventHandler->get($regEvid); |
||
194 | if (!is_object($eventObj)) { |
||
195 | header('Content-Type: application/json'); |
||
196 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
197 | break; |
||
198 | } |
||
199 | if (!$permissionsHandler->getPermRegistrationsApprove($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||
200 | header('Content-Type: application/json'); |
||
201 | echo json_encode(['status'=>'error','message'=>\_NOPERM]); |
||
202 | break; |
||
203 | } |
||
204 | if ($regId > 0) { |
||
205 | // Check permissions |
||
206 | $registrationObj = $registrationHandler->get($regId); |
||
207 | $registrationObjOld = $registrationHandler->get($regId); |
||
208 | // create history |
||
209 | $registrationhistHandler->createHistory($registrationObj, 'update'); |
||
210 | } else { |
||
211 | header('Content-Type: application/json'); |
||
212 | echo json_encode(['status'=>'error','message'=>\_MA_WGEVENTS_INVALID_PARAM]); |
||
213 | break; |
||
214 | } |
||
215 | $registrationObj->setVar('listwait', 0); |
||
216 | $registrationObj->setVar('status', Constants::STATUS_APPROVED); |
||
217 | // Insert Data |
||
218 | if ($registrationHandler->insert($registrationObj)) { |
||
219 | // TODO: Handle notification |
||
220 | |||
221 | $mailsHandler = new MailHandler(); |
||
222 | $mailParams = $mailsHandler->getMailParam($eventObj, $regId); |
||
223 | unset($mailsHandler); |
||
224 | // find changes in table registrations |
||
225 | $mailParams['infotext'] = $registrationHandler->getRegistrationsCompare($registrationObjOld, $regId); |
||
226 | |||
227 | // send notifications/confirmation emails |
||
228 | $registerNotify = (string)$eventObj->getVar('register_notify', 'e'); |
||
229 | if ('' !== $registerNotify) { |
||
230 | // send notifications to emails of register_notify |
||
231 | $notifyEmails = $eventHandler->getRecipientsNotify($registerNotify); |
||
232 | if (\count($notifyEmails) > 0) { |
||
233 | foreach ($notifyEmails as $recipient) { |
||
234 | $taskHandler->createTask(Constants::MAIL_REG_NOTIFY_MODIFY, $recipient, json_encode($mailParams)); |
||
235 | } |
||
236 | } |
||
237 | } |
||
238 | $regEmail = $registrationObj->getVar('email'); |
||
239 | if ('' !== $regEmail) { |
||
240 | $taskHandler->createTask(Constants::MAIL_REG_CONFIRM_MODIFY, $regEmail, json_encode($mailParams)); |
||
241 | } |
||
242 | // execute mail sending by task handler |
||
243 | $taskHandler->processTasks(); |
||
244 | header('Content-Type: application/json'); |
||
245 | echo json_encode(['status'=>'success','message'=>'no errors']); |
||
246 | } |
||
247 | break; |
||
248 | } |
||
249 | |||
250 |
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: