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 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
15 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
16 | * @author Brian Wahoff <[email protected]> |
||||
17 | * @author Eric Juden <[email protected]> |
||||
18 | * @author XOOPS Development Team |
||||
19 | */ |
||||
20 | |||||
21 | use Xmf\Request; |
||||
22 | use XoopsModules\Xhelp; |
||||
23 | |||||
24 | require_once __DIR__ . '/header.php'; |
||||
25 | //require_once XHELP_BASE_PATH . '/functions.php'; |
||||
26 | |||||
27 | $helper = Xhelp\Helper::getInstance(); |
||||
28 | |||||
29 | global $xoopsModule, $xoopsUser; |
||||
30 | |||||
31 | // Disable module caching in smarty |
||||
32 | $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; |
||||
33 | |||||
34 | if ($xoopsUser) { |
||||
35 | $responseTplID = 0; |
||||
36 | |||||
37 | $op = 'default'; |
||||
38 | if (Request::hasVar('op', 'REQUEST')) { |
||||
39 | $op = $_REQUEST['op']; |
||||
40 | } |
||||
41 | |||||
42 | if (Request::hasVar('responseTplID', 'GET')) { |
||||
43 | $responseTplID = Request::getInt('responseTplID', 0, 'GET'); |
||||
44 | } |
||||
45 | |||||
46 | $GLOBALS['xoopsOption']['template_main'] = 'xhelp_staff_profile.tpl'; // Set template |
||||
47 | require_once XOOPS_ROOT_PATH . '/header.php'; // Include the page header |
||||
48 | |||||
49 | $numResponses = 0; |
||||
50 | $uid = $xoopsUser->getVar('uid'); |
||||
51 | /** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
||||
52 | $staffHandler = $helper->getHandler('Staff'); |
||||
53 | if (!$staff = $staffHandler->getByUid($uid)) { |
||||
54 | $helper->redirect('index.php', 3, _XHELP_ERROR_INV_STAFF); |
||||
55 | } |
||||
56 | /** @var \XoopsModules\Xhelp\TicketListHandler $ticketListHandler */ |
||||
57 | $ticketListHandler = $helper->getHandler('TicketList'); |
||||
58 | /** @var \XoopsModules\Xhelp\ResponseTemplatesHandler $responseTemplatesHandler */ |
||||
59 | $responseTemplatesHandler = $helper->getHandler('ResponseTemplates'); |
||||
60 | $criteria = new \Criteria('uid', $uid); |
||||
61 | $criteria->setSort('name'); |
||||
62 | $responseTpl = $responseTemplatesHandler->getObjects($criteria); |
||||
63 | |||||
64 | foreach ($responseTpl as $response) { |
||||
65 | $aResponseTpl[] = [ |
||||
66 | 'id' => $response->getVar('id'), |
||||
67 | 'uid' => $response->getVar('uid'), |
||||
68 | 'name' => $response->getVar('name'), |
||||
69 | 'response' => $response->getVar('response'), |
||||
70 | ]; |
||||
71 | } |
||||
72 | $has_responseTpl = count($responseTpl) > 0; |
||||
73 | unset($responseTpl); |
||||
74 | |||||
75 | $displayTpl = $responseTemplatesHandler->get($responseTplID); |
||||
76 | |||||
77 | switch ($op) { |
||||
78 | case 'responseTpl': |
||||
79 | if (Request::hasVar('updateResponse', 'POST')) { |
||||
80 | if (Request::hasVar('attachSig', 'POST')) { |
||||
81 | $staff->setVar('attachSig', \Xmf\Request::getString('attachSig', '', 'POST')); |
||||
82 | if (!$staffHandler->insert($staff)) { |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
83 | $message = _XHELP_MESSAGE_UPDATE_SIG_ERROR; |
||||
84 | } |
||||
85 | } |
||||
86 | if ('' === \Xmf\Request::getString('name', '', 'POST') || '' == \Xmf\Request::getString('replyText', '', 'POST')) { |
||||
87 | $helper->redirect('profile.php', 3, _XHELP_ERROR_INV_TEMPLATE); |
||||
88 | } |
||||
89 | if (0 != $_POST['responseid']) { |
||||
90 | $updateTpl = $responseTemplatesHandler->get($_POST['responseid']); |
||||
91 | } else { |
||||
92 | $updateTpl = $responseTemplatesHandler->create(); |
||||
93 | } |
||||
94 | $updateTpl->setVar('uid', $uid); |
||||
95 | $updateTpl->setVar('name', \Xmf\Request::getString('name', '', 'POST')); |
||||
96 | $updateTpl->setVar('response', \Xmf\Request::getString('replyText', '', 'POST')); |
||||
97 | if ($responseTemplatesHandler->insert($updateTpl)) { |
||||
98 | $message = _XHELP_MESSAGE_RESPONSE_TPL; |
||||
99 | } else { |
||||
100 | $message = _XHELP_MESSAGE_RESPONSE_TPL_ERROR; |
||||
101 | } |
||||
102 | $helper->redirect('profile.php', 3, $message); |
||||
103 | } else { // Delete response template |
||||
104 | /** @var \XoopsModules\Xhelp\ResponseTemplatesHandler $responseTemplatesHandler */ |
||||
105 | $responseTemplatesHandler = $helper->getHandler('ResponseTemplates'); |
||||
106 | $displayTpl = $responseTemplatesHandler->get($_POST['tplID']); |
||||
107 | if ($responseTemplatesHandler->delete($displayTpl)) { |
||||
108 | $message = _XHELP_MESSAGE_DELETE_RESPONSE_TPL; |
||||
109 | } else { |
||||
110 | $message = _XHELP_MESSAGE_DELETE_RESPONSE_TPL_ERROR; |
||||
111 | } |
||||
112 | $helper->redirect('profile.php', 3, $message); |
||||
113 | } |
||||
114 | break; |
||||
115 | case 'updateNotification': |
||||
116 | $notArray = (is_array($_POST['notifications']) ? $_POST['notifications'] : [0]); |
||||
117 | $notValue = array_sum($notArray); |
||||
118 | $staff->setVar('notify', $notValue); |
||||
119 | if (Request::hasVar('email', 'POST') && \Xmf\Request::getString('email', '', 'POST') != $staff->getVar('email')) { |
||||
120 | $staff->setVar('email', \Xmf\Request::getString('email', '', 'POST')); |
||||
121 | } |
||||
122 | if (!$staffHandler->insert($staff)) { |
||||
123 | $message = _XHELP_MESSAGE_UPDATE_EMAIL_ERROR; |
||||
124 | } |
||||
125 | $message = _XHELP_MESSAGE_NOTIFY_UPDATE; |
||||
126 | $helper->redirect('profile.php', 3, $message); |
||||
127 | break; |
||||
128 | case 'addTicketList': |
||||
129 | if (Request::hasVar('savedSearch', 'POST') && (0 != $_POST['savedSearch'])) { |
||||
130 | $searchid = Request::getInt('savedSearch', 0, 'POST'); |
||||
131 | /** @var \XoopsModules\Xhelp\TicketList $ticketList */ |
||||
132 | $ticketList = $ticketListHandler->create(); |
||||
133 | $ticketList->setVar('uid', $xoopsUser->getVar('uid')); |
||||
134 | $ticketList->setVar('searchid', $searchid); |
||||
135 | $ticketList->setVar('weight', $ticketListHandler->createNewWeight($xoopsUser->getVar('uid'))); |
||||
136 | |||||
137 | if ($ticketListHandler->insert($ticketList)) { |
||||
138 | $helper->redirect('profile.php'); |
||||
139 | } else { |
||||
140 | $helper->redirect('profile.php', 3, _XHELP_MSG_ADD_TICKETLIST_ERR); |
||||
141 | } |
||||
142 | } |
||||
143 | break; |
||||
144 | case 'editTicketList': |
||||
145 | if (Request::hasVar('id', 'REQUEST') && 0 != $_REQUEST['id']) { |
||||
146 | $listID = Request::getInt('id', 0, 'REQUEST'); |
||||
147 | } else { |
||||
148 | $helper->redirect('profile.php', 3, _XHELP_MSG_NO_ID); |
||||
149 | } |
||||
150 | break; |
||||
151 | case 'deleteTicketList': |
||||
152 | if (Request::hasVar('id', 'REQUEST') && 0 != $_REQUEST['id']) { |
||||
153 | $listID = Request::getInt('id', 0, 'REQUEST'); |
||||
154 | } else { |
||||
155 | $helper->redirect('profile.php', 3, _XHELP_MSG_NO_ID); |
||||
156 | } |
||||
157 | $ticketList = $ticketListHandler->get($listID); |
||||
158 | if ($ticketListHandler->delete($ticketList, true)) { |
||||
159 | $helper->redirect('profile.php'); |
||||
160 | } else { |
||||
161 | $helper->redirect('profile.php', 3, _XHELP_MSG_DEL_TICKETLIST_ERR); |
||||
162 | } |
||||
163 | break; |
||||
164 | case 'changeListWeight': |
||||
165 | if (Request::hasVar('id', 'REQUEST') && 0 != $_REQUEST['id']) { |
||||
166 | $listID = Request::getInt('id', 0, 'REQUEST'); |
||||
167 | } else { |
||||
168 | $helper->redirect('profile.php', 3, _XHELP_MSG_NO_ID); |
||||
169 | } |
||||
170 | $up = false; |
||||
171 | if (Request::hasVar('up', 'REQUEST')) { |
||||
172 | $up = $_REQUEST['up']; |
||||
173 | } |
||||
174 | $ticketListHandler->changeWeight($listID, $up); |
||||
175 | $helper->redirect('profile.php'); |
||||
176 | break; |
||||
177 | default: |
||||
178 | $xoopsTpl->assign('xhelp_responseTplID', $responseTplID); |
||||
179 | $module_header = '<!--[if lt IE 7]><script src="iepngfix.js" language="JavaScript" type="text/javascript"></script><![endif]-->'; |
||||
180 | $xoopsTpl->assign('xhelp_imagePath', XOOPS_URL . '/modules/xhelp/assets/images/'); |
||||
181 | $xoopsTpl->assign('xhelp_has_sig', $staff->getVar('attachSig')); |
||||
182 | if (isset($aResponseTpl)) { |
||||
183 | $xoopsTpl->assign('xhelp_responseTpl', $aResponseTpl); |
||||
184 | } else { |
||||
185 | $xoopsTpl->assign('xhelp_responseTpl', 0); |
||||
186 | } |
||||
187 | $xoopsTpl->assign('xhelp_hasResponseTpl', isset($aResponseTpl) ? count($aResponseTpl) > 0 : 0); |
||||
188 | if (!empty($responseTplID)) { |
||||
189 | $xoopsTpl->assign('xhelp_displayTpl_id', $displayTpl->getVar('id')); |
||||
190 | $xoopsTpl->assign('xhelp_displayTpl_name', $displayTpl->getVar('name')); |
||||
191 | $xoopsTpl->assign('xhelp_displayTpl_response', $displayTpl->getVar('response', 'e')); |
||||
192 | } else { |
||||
193 | $xoopsTpl->assign('xhelp_displayTpl_id', 0); |
||||
194 | $xoopsTpl->assign('xhelp_displayTpl_name', ''); |
||||
195 | $xoopsTpl->assign('xhelp_displayTpl_response', ''); |
||||
196 | } |
||||
197 | $xoopsTpl->assign('xoops_module_header', $module_header); |
||||
198 | $xoopsTpl->assign('xhelp_callsClosed', $staff->getVar('callsClosed')); |
||||
199 | $xoopsTpl->assign('xhelp_numReviews', $staff->getVar('numReviews')); |
||||
200 | $xoopsTpl->assign('xhelp_responseTime', Xhelp\Utility::formatTime(($staff->getVar('ticketsResponded') ? $staff->getVar('responseTime') / $staff->getVar('ticketsResponded') : 0))); |
||||
201 | $notify_method = $xoopsUser->getVar('notify_method'); |
||||
202 | $xoopsTpl->assign('xhelp_notify_method', (1 == $notify_method) ? _XHELP_NOTIFY_METHOD1 : _XHELP_NOTIFY_METHOD2); |
||||
203 | |||||
204 | if ((0 == $staff->getVar('rating')) || (0 == $staff->getVar('numReviews'))) { |
||||
205 | $xoopsTpl->assign('xhelp_rating', 0); |
||||
206 | } else { |
||||
207 | $xoopsTpl->assign('xhelp_rating', (int)($staff->getVar('rating') / $staff->getVar('numReviews'))); |
||||
208 | } |
||||
209 | $xoopsTpl->assign('xhelp_uid', $xoopsUser->getVar('uid')); |
||||
210 | $xoopsTpl->assign('xhelp_rating0', _XHELP_RATING0); |
||||
211 | $xoopsTpl->assign('xhelp_rating1', _XHELP_RATING1); |
||||
212 | $xoopsTpl->assign('xhelp_rating2', _XHELP_RATING2); |
||||
213 | $xoopsTpl->assign('xhelp_rating3', _XHELP_RATING3); |
||||
214 | $xoopsTpl->assign('xhelp_rating4', _XHELP_RATING4); |
||||
215 | $xoopsTpl->assign('xhelp_rating5', _XHELP_RATING5); |
||||
216 | $xoopsTpl->assign('xhelp_staff_email', $staff->getVar('email')); |
||||
217 | $xoopsTpl->assign('xhelp_savedSearches', $aSavedSearches); |
||||
218 | |||||
219 | $myRolesArray = $staffHandler->getRoles($xoopsUser->getVar('uid'), true); |
||||
220 | /** @var \XoopsModules\Xhelp\NotificationHandler $notificationHandler */ |
||||
221 | $notificationHandler = $helper->getHandler('Notification'); |
||||
222 | $settings = $notificationHandler->getObjects(null, true); |
||||
223 | |||||
224 | $templates = $xoopsModule->getInfo('_email_tpl'); |
||||
225 | $has_notifications = count($templates); |
||||
226 | |||||
227 | // Check that notifications are enabled by admin |
||||
228 | $i = 0; |
||||
229 | $staff_enabled = true; |
||||
230 | foreach ($templates as $template_id => $template) { |
||||
231 | if ('dept' === $template['category']) { |
||||
232 | if (isset($settings[$template_id])) { |
||||
233 | $staff_setting = $settings[$template_id]->getVar('staff_setting'); |
||||
234 | if (4 == $staff_setting) { |
||||
235 | $staff_enabled = false; |
||||
236 | } elseif (2 == $staff_setting) { |
||||
237 | $staff_options = $settings[$template_id]->getVar('staff_options'); |
||||
238 | foreach ($staff_options as $role) { |
||||
239 | if (array_key_exists($role, $myRolesArray)) { |
||||
0 ignored issues
–
show
It seems like
$myRolesArray can also be of type false ; however, parameter $array of array_key_exists() does only seem to accept ArrayObject|array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
240 | $staff_enabled = true; |
||||
241 | break; |
||||
242 | } |
||||
243 | |||||
244 | $staff_enabled = false; |
||||
245 | } |
||||
246 | } |
||||
247 | } |
||||
248 | $deptNotification[] = [ |
||||
249 | 'id' => $template_id, |
||||
250 | 'name' => $template['name'], |
||||
251 | 'category' => $template['category'], |
||||
252 | 'template' => $template['mail_template'], |
||||
253 | 'subject' => $template['mail_subject'], |
||||
254 | 'bitValue' => 2 ** $template['bit_value'], |
||||
255 | 'title' => $template['title'], |
||||
256 | 'caption' => $template['caption'], |
||||
257 | 'description' => $template['description'], |
||||
258 | 'isChecked' => ($staff->getVar('notify') & (2 ** $template['bit_value'])) > 0, |
||||
259 | 'staff_setting' => $staff_enabled, |
||||
260 | ]; |
||||
261 | } |
||||
262 | } |
||||
263 | if ($has_notifications) { |
||||
264 | $xoopsTpl->assign('xhelp_deptNotifications', $deptNotification); |
||||
265 | } else { |
||||
266 | $xoopsTpl->assign('xhelp_deptNotifications', 0); |
||||
267 | } |
||||
268 | |||||
269 | /** @var \XoopsModules\Xhelp\StaffReviewHandler $staffReviewHandler */ |
||||
270 | $staffReviewHandler = $helper->getHandler('StaffReview'); |
||||
271 | /** @var \XoopsMemberHandler $memberHandler */ |
||||
272 | $memberHandler = xoops_getHandler('member'); |
||||
273 | $criteria = new \Criteria('staffid', $xoopsUser->getVar('uid')); |
||||
274 | $criteria->setSort('id'); |
||||
275 | $criteria->setOrder('DESC'); |
||||
276 | $criteria->setLimit(5); |
||||
277 | |||||
278 | $reviews = $staffReviewHandler->getObjects($criteria); |
||||
279 | |||||
280 | $displayName = $helper->getConfig('xhelp_displayName'); // Determines if username or real name is displayed |
||||
281 | |||||
282 | foreach ($reviews as $review) { |
||||
283 | $reviewer = $memberHandler->getUser($review->getVar('submittedBy')); |
||||
284 | $xoopsTpl->append('xhelp_reviews', [ |
||||
285 | 'rating' => $review->getVar('rating'), |
||||
286 | 'ratingdsc' => Xhelp\Utility::getRating($review->getVar('rating')), |
||||
287 | 'submittedBy' => $reviewer ? Xhelp\Utility::getUsername($reviewer, $displayName) : $xoopsConfig['anonymous'], |
||||
0 ignored issues
–
show
It seems like
$displayName can also be of type null ; however, parameter $displayName of XoopsModules\Xhelp\Utility::getUsername() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
288 | 'submittedByUID' => $review->getVar('submittedBy'), |
||||
289 | 'responseid' => $review->getVar('responseid'), |
||||
290 | 'comments' => $review->getVar('comments'), |
||||
291 | 'ticketid' => $review->getVar('ticketid'), |
||||
292 | ]); |
||||
293 | } |
||||
294 | $xoopsTpl->assign('xhelp_hasReviews', count($reviews) > 0); |
||||
295 | |||||
296 | // Ticket Lists |
||||
297 | $ticketLists = $ticketListHandler->getListsByUser($xoopsUser->getVar('uid')); |
||||
298 | $aMySavedSearches = []; |
||||
299 | $mySavedSearches = Xhelp\Utility::getSavedSearches([$xoopsUser->getVar('uid'), XHELP_GLOBAL_UID]); |
||||
300 | $has_savedSearches = (is_array($aMySavedSearches) && count($aMySavedSearches) > 0); |
||||
301 | $ticketListCount = count($ticketLists); |
||||
302 | $aTicketLists = []; |
||||
303 | $aUsedSearches = []; |
||||
304 | $eleNum = 0; |
||||
305 | foreach ($ticketLists as $ticketList) { |
||||
306 | $weight = $ticketList->getVar('weight'); |
||||
307 | $searchid = $ticketList->getVar('searchid'); |
||||
308 | $aTicketLists[$ticketList->getVar('id')] = [ |
||||
309 | 'id' => $ticketList->getVar('id'), |
||||
310 | 'uid' => $ticketList->getVar('uid'), |
||||
311 | 'searchid' => $searchid, |
||||
312 | 'weight' => $weight, |
||||
313 | 'name' => $mySavedSearches[$ticketList->getVar('searchid')]['name'], |
||||
314 | 'hasWeightUp' => $eleNum != $ticketListCount - 1, |
||||
315 | 'hasWeightDown' => 0 != $eleNum, |
||||
316 | 'hasEdit' => -999 != $mySavedSearches[$ticketList->getVar('searchid')]['uid'], |
||||
317 | ]; |
||||
318 | ++$eleNum; |
||||
319 | $aUsedSearches[$searchid] = $searchid; |
||||
320 | } |
||||
321 | unset($ticketLists); |
||||
322 | |||||
323 | // Take used searches to get unused searches |
||||
324 | $aSearches = []; |
||||
325 | if ($mySavedSearches && is_array($mySavedSearches)) { |
||||
326 | foreach ($mySavedSearches as $savedSearch) { |
||||
327 | if (!in_array($savedSearch['id'], $aUsedSearches)) { |
||||
328 | if ('' != $savedSearch['id']) { |
||||
329 | $aSearches[$savedSearch['id']] = $savedSearch; |
||||
330 | } |
||||
331 | } |
||||
332 | } |
||||
333 | } |
||||
334 | $hasUnusedSearches = count($aSearches) > 0; |
||||
335 | $xoopsTpl->assign('xhelp_ticketLists', $aTicketLists); |
||||
336 | $xoopsTpl->assign('xhelp_hasTicketLists', count($aTicketLists) > 0); |
||||
337 | $xoopsTpl->assign('xhelp_unusedSearches', $aSearches); |
||||
338 | $xoopsTpl->assign('xhelp_hasUnusedSearches', $hasUnusedSearches); |
||||
339 | $xoopsTpl->assign('xhelp_baseURL', XHELP_BASE_URL); |
||||
340 | break; |
||||
341 | } |
||||
342 | } else { |
||||
343 | redirect_header(XOOPS_URL . '/user.php', 3); |
||||
344 | } |
||||
345 | |||||
346 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||||
347 |