Issues (311)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

registration.php (3 issues)

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
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/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 before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
23
use XoopsModules\Wgevents;
24
use XoopsModules\Wgevents\{
25
    Constants,
26
    Common,
27
    MailHandler,
28
    Utility
29
};
30
31
require __DIR__ . '/header.php';
32
33
$op = Request::getCmd('op', 'list');
34
if ('show' === $op) {
35
    $GLOBALS['xoopsOption']['template_main'] = 'wgevents_registration_single.tpl';
36
} else  {
37
    $GLOBALS['xoopsOption']['template_main'] = 'wgevents_registration.tpl';
38
}
39
require_once \XOOPS_ROOT_PATH . '/header.php';
40
41
$regId    = Request::getInt('id');
42
$regEvid  = Request::getInt('evid');
43
$start    = Request::getInt('start');
44
$limit    = Request::getInt('limit', $helper->getConfig('userpager'));
45
$redir    = Request::getString('redir', 'list');
46
$showinfo = Request::getInt('showinfo');
47
//$sortBy  = Request::getString('sortby', 'datecreated');
48
//$orderBy = Request::getString('orderby', 'asc');
49
50
$GLOBALS['xoopsTpl']->assign('start', $start);
51
$GLOBALS['xoopsTpl']->assign('limit', $limit);
52
//$GLOBALS['xoopsTpl']->assign('sort_order', $sortBy . '_' . $orderBy);
53
$GLOBALS['xoopsTpl']->assign('evid', $regEvid);
54
if (1 === $showinfo) {
55
    $GLOBALS['xoopsTpl']->assign('warning', \_MA_WGEVENTS_REGISTRATION_INFO_SPAM);
56
}
57
58
if (Request::hasVar('cancel')) {
59
    $op = 'listeventmy';
60
}
61
if (Request::hasVar('exec_contactall_test')) {
62
    $op = 'exec_contactall_test';
63
}
64
65
// Define Stylesheet
66
$GLOBALS['xoTheme']->addStylesheet($style, null);
67
// JS
68
$GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js');
69
// Paths
70
$GLOBALS['xoopsTpl']->assign('xoops_icons32_url', \XOOPS_ICONS32_URL);
71
$GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL);
72
$GLOBALS['xoopsTpl']->assign('wgevents_icons_url_16', \WGEVENTS_ICONS_URL_16);
73
// Keywords
74
$keywords = [];
75
// Breadcrumbs
76
$xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_INDEX, 'link' => 'index.php'];
77
// Permission
78
$permView = $permissionsHandler->getPermRegistrationView();
79
$GLOBALS['xoopsTpl']->assign('permView', $permView);
80
81
$uidCurrent = \is_object($GLOBALS['xoopsUser']) ? (int)$GLOBALS['xoopsUser']->uid() : 0;
82
83
switch ($op) {
84
    case 'show':
85
        $verifKey = Request::getString('verifkey');
86
        $verifKeyArray  = explode('||', base64_decode($verifKey, true));
87
        // for testing purposes //$verifKeyArray = [5, 'http://localhost/wgevents/htdocs/modules/wgevents', 1, '[email protected]', 'z4NBI7sYn3'];
88
        $regId = $verifKeyArray[0];
89
        $registrationObj = $registrationHandler->get($regId);
90
        $eventName = $eventHandler->get($registrationObj->getVar('evid'))->getVar('name');
91
        if ($regId > 0 && \is_object($registrationObj) && \WGEVENTS_URL == (string)$verifKeyArray[1] &&
92
            (int)$registrationObj->getVar('evid') == (int)$verifKeyArray[2] &&
93
            (string)$registrationObj->getVar('email') == (string)$verifKeyArray[3] &&
94
            (string)$registrationObj->getVar('verifkey') == (string)$verifKeyArray[4]) {
95
                $registration = [];
96
                // get all detail of this registration
97
                $registration = $registrationObj->getValuesRegistrations();
98
                // get event info
99
                $evId = $registrationObj->getVar('evid');
100
                $eventObj = $eventHandler->get($evId);
101
                $event = $eventObj->getValuesEvents();
102
                $questionsArr = $questionHandler->getQuestionsByEvent($evId);
103
                $registration['questions'] = $questionsArr;
104
105
                // get all answers for this event
106
                $answers = $answerHandler->getAnswersDetailsByRegistration($regId, $questionsArr);
107
                foreach ($questionsArr as $key => $value) {
108
                    $question_answer[$key]['caption'] = $value['caption'];
109
                    $question_answer[$key]['answer'] = $answers[$key];
110
                }
111
                $registration['questions'] = \count($question_answer);
112
                $registration['question_answer'] = $question_answer;
113
114
                $GLOBALS['xoopsTpl']->assign('event', $event);
115
                $GLOBALS['xoopsTpl']->assign('registration', $registration);
116
                $GLOBALS['xoopsTpl']->assign('verifKey', $verifKey);
117
                $GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL);
118
        } else {
119
            $GLOBALS['xoopsTpl']->assign('error', \sprintf(\_MA_WGEVENTS_MAIL_REG_VERIF_ERROR, $eventName));
120
        }
121
    case 'list':
122
    default:
123
        break;
124
    case 'listmy':
125
        // Check permissions
126
        if (!$permissionsHandler->getPermRegistrationsSubmit()) {
127
            \redirect_header('registration.php?op=list', 3, \_NOPERM);
128
        }
129
        $GLOBALS['xoopsTpl']->assign('redir', 'listmy');
130
        // Breadcrumbs
131
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_REGISTRATIONS_MYLIST];
132
        $events = [];
133
        $registrations = [];
134
        $regIp = $_SERVER['REMOTE_ADDR'];
135
        // get all events with my registrations
136
        $sql = 'SELECT evid, name, ' . $GLOBALS['xoopsDB']->prefix('wgevents_event') . '.submitter as ev_submitter, ' . $GLOBALS['xoopsDB']->prefix('wgevents_event') . '.status as ev_status ';
137
        $sql .= 'FROM ' . $GLOBALS['xoopsDB']->prefix('wgevents_registration') . ' ';
138
        $sql .= 'INNER JOIN ' . $GLOBALS['xoopsDB']->prefix('wgevents_event') . ' ON ' . $GLOBALS['xoopsDB']->prefix('wgevents_registration') . '.evid = ' . $GLOBALS['xoopsDB']->prefix('wgevents_event') . '.id ';
139
        $sql .= 'WHERE (';
140
        if ($uidCurrent > 0) {
141
            $sql .= '(' . $GLOBALS['xoopsDB']->prefix('wgevents_registration') . '.submitter)=' . $uidCurrent;
142
        } else {
143
            $sql .= '(' . $GLOBALS['xoopsDB']->prefix('wgevents_registration') . '.ip)="' . $regIp . '"';
144
        }
145
        $sql .= ') GROUP BY ' . $GLOBALS['xoopsDB']->prefix('wgevents_registration') . '.evid, ' . $GLOBALS['xoopsDB']->prefix('wgevents_event') . '.name ';
146
        $sql .= 'ORDER BY ' . $GLOBALS['xoopsDB']->prefix('wgevents_event') . '.datefrom DESC;';
147
        $result = $GLOBALS['xoopsDB']->query($sql);
148
        while (list($evId, $evName, $evSubmitter, $evStatus) = $GLOBALS['xoopsDB']->fetchRow($result)) {
149
            $events[$evId] = [
150
                'id' => $evId,
151
                'name' => $evName,
152
                'submitter' => $evSubmitter,
153
                'status' => $evStatus
154
            ];
155
        }
156
        foreach ($events as $evId => $event) {
157
            // get all questions for this event
158
            $questionsArr = $questionHandler->getQuestionsByEvent($evId);
159
            $registrations[$evId]['questions'] = $questionsArr;
160
            $registrations[$evId]['footerCols'] = \count($questionsArr) + 9;
161
            //get list of existing registrations for current user/current IP
162
            $registrations[$evId]['event_id'] = $event['id'];
163
            $registrations[$evId]['event_name'] = $event['name'];
164
            $permEdit = $permissionsHandler->getPermEventsEdit($event['submitter'], $event['status']) || $uidCurrent == $event['submitter'];
165
            $registrations[$evId]['permEditEvent'] = $permEdit;
166
            $registrations[$evId]['details'] = $registrationHandler->getRegistrationDetailsByEvent($evId, $questionsArr);
167
        }
168
        if (\count($registrations) > 0) {
169
            $GLOBALS['xoopsTpl']->assign('registrations', $registrations);
170
            unset($registrations);
171
        } else {
172
            $GLOBALS['xoopsTpl']->assign('warning', \_MA_WGEVENTS_REGISTRATIONS_THEREARENT);
173
        }
174
        break;
175
    case 'listeventmy': // list all registrations of current user of given event
176
    case 'listeventall': // list all registrations of all users of given event
177
        // Check params
178
        if (0 === $regEvid) {
179
            \redirect_header('index.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
180
        }
181
        // Check permissions
182
        if (!$permissionsHandler->getPermRegistrationsSubmit()) {
183
            \redirect_header('registration.php?op=list', 3, \_NOPERM);
184
        }
185
186
        $captionList = \_MA_WGEVENTS_REGISTRATIONS_MYLIST;
187
        $currentUserOnly = true;
188
        if ('listeventall' === $op) {
189
            $captionList = \_MA_WGEVENTS_REGISTRATIONS_LIST;
190
            $currentUserOnly = false;
191
            $GLOBALS['xoopsTpl']->assign('showSubmitter', true);
192
        }
193
        $GLOBALS['xoopsTpl']->assign('captionList', $captionList);
194
        $GLOBALS['xoopsTpl']->assign('redir', $op);
195
        $GLOBALS['xoopsTpl']->assign('op', $op);
196
        $GLOBALS['xoopsTpl']->assign('evid', $regEvid);
197
198
        // Breadcrumbs
199
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_REGISTRATION_ADD];
200
        // get all questions for this event
201
        $questionsArr = $questionHandler->getQuestionsByEvent($regEvid);
202
203
        //get list of existing registrations for current user/current IP
204
        $eventObj = $eventHandler->get($regEvid);
205
        $evSubmitter = (int)$eventObj->getVar('submitter');
206
        $permEdit = $permissionsHandler->getPermEventsEdit($evSubmitter, $eventObj->getVar('status')) || $uidCurrent == $evSubmitter;
207
    // list all registrations of all users of given event
208
    // user must have perm to edit event
209
    if ('listeventall' === $op && $uidCurrent !== $evSubmitter && !$permEdit) {
210
        \redirect_header('registration.php?op=list', 3, \_NOPERM);
211
    }
212
        $event_name = $eventObj->getVar('name');
213
        $registrations[$regEvid]['event_id'] = $regEvid;
214
        $registrations[$regEvid]['event_name'] = $event_name;
215
        $registrations[$regEvid]['permEditEvent'] = $permEdit;
216
        $registrations[$regEvid]['event_fee'] = $eventObj->getVar('fee');
217
218
        $evFee = \json_decode($eventObj->getVar('fee'), true);
219
        $evFeeArr = [];
220
        foreach($evFee as $fee) {
221
            $evFeeArr[] = ['text' => Utility::FloatToString((float)$fee[0]), 'value' => (float)$fee[0]];
222
        }
223
        $registrations[$regEvid]['evfees'] = $evFeeArr;
224
        $registrations[$regEvid]['evfees_count'] = \count($evFeeArr);
225
        $registrations[$regEvid]['event_register_max'] = $eventObj->getVar('register_max');
226
        $registrations[$regEvid]['questions'] = $questionsArr;
227
        $registrations[$regEvid]['footerCols'] = \count($questionsArr) + 9;
228
        $registrations[$regEvid]['details'] = $registrationHandler->getRegistrationDetailsByEvent($regEvid, $questionsArr, $currentUserOnly);
229
        if ($registrations) {
230
            $GLOBALS['xoopsTpl']->assign('registrations', $registrations);
231
            unset($registrations);
232
        }
233
        if ('listeventall' === $op) {
234
            $GLOBALS['xoopsTpl']->assign('showHandleList', true);
235
        } else {
236
            //$permEdit = $permissionsHandler->getPermEventsEdit($evSubmitter, $eventObj->getVar('status'));
237
            if ($permEdit ||
238
                (\time() >= $eventObj->getVar('register_from') && \time() <= $eventObj->getVar('register_to'))
239
                ) {
240
                // Form Create
241
                $registrationObj = $registrationHandler->create();
242
                $registrationObj->setVar('evid', $regEvid);
243
                $registrationObj->setRedir($redir);
244
                $form = $registrationObj->getForm();
245
                $GLOBALS['xoopsTpl']->assign('form', $form->render());
246
            }
247
            if (!$permEdit && \time() < $eventObj->getVar('register_from')) {
248
                $GLOBALS['xoopsTpl']->assign('warning', sprintf(\_MA_WGEVENTS_REGISTRATION_TOEARLY, \formatTimestamp($eventObj->getVar('register_from'), 'm')));
249
            }
250
            if (!$permEdit && \time() > $eventObj->getVar('register_to')) {
251
                $GLOBALS['xoopsTpl']->assign('warning', sprintf(\_MA_WGEVENTS_REGISTRATION_TOLATE, \formatTimestamp($eventObj->getVar('register_to'), 'm')));
252
            }
253
        }
254
        //assign language vars for js calls
255
        $GLOBALS['xoopsTpl']->assign('js_lang_paid', \_MA_WGEVENTS_REGISTRATION_FINANCIAL_PAID);
256
        $GLOBALS['xoopsTpl']->assign('js_lang_unpaid', \_MA_WGEVENTS_REGISTRATION_FINANCIAL_UNPAID);
257
        if (1 === \count($evFeeArr)) {
258
            $GLOBALS['xoopsTpl']->assign('js_feedefault_value', $evFeeArr[0]['value']);
259
            $GLOBALS['xoopsTpl']->assign('js_feedefault_text', $evFeeArr[0]['text']);
260
261
        }
262
        $GLOBALS['xoopsTpl']->assign('js_feezero_text', Utility::FloatToString(0));
263
        $GLOBALS['xoopsTpl']->assign('js_lang_changed', \_MA_WGEVENTS_REGISTRATION_CHANGED);
264
        $GLOBALS['xoopsTpl']->assign('js_lang_approved', \_MA_WGEVENTS_STATUS_APPROVED);
265
        $GLOBALS['xoopsTpl']->assign('js_lang_error_save', \_MA_WGEVENTS_ERROR_SAVE);
266
267
        // tablesorter
268
        $GLOBALS['xoopsTpl']->assign('tablesorter', true);
269
        $GLOBALS['xoopsTpl']->assign('mod_url', \WGEVENTS_URL);
270
        $GLOBALS['xoopsTpl']->assign('tablesorter_allrows', \_AM_WGEVENTS_TABLESORTER_SHOW_ALL);
271
        $GLOBALS['xoopsTpl']->assign('tablesorter_of', \_AM_WGEVENTS_TABLESORTER_OF);
272
        $GLOBALS['xoopsTpl']->assign('tablesorter_total', \_AM_WGEVENTS_TABLESORTER_TOTALROWS);
273
        $GLOBALS['xoopsTpl']->assign('tablesorter_pagesize', $helper->getConfig('userpager'));
274
        if ('d.m.Y' === \_SHORTDATESTRING) {
0 ignored issues
show
The condition 'd.m.Y' === _SHORTDATESTRING is always false.
Loading history...
275
            $dateformat = 'ddmmyyyy';
276
        } else {
277
            $dateformat = 'mmddyyyy';
278
        }
279
        $GLOBALS['xoopsTpl']->assign('tablesorter_dateformat', $dateformat);
280
281
        $GLOBALS['xoTheme']->addStylesheet(\WGEVENTS_URL . '/assets/js/tablesorter/css/jquery.tablesorter.pager.min.css');
282
        $tablesorterTheme = $helper->getConfig('tablesorter_user');
283
        $GLOBALS['xoTheme']->addStylesheet(\WGEVENTS_URL . '/assets/js/tablesorter/css/theme.' . $tablesorterTheme . '.min.css');
284
        $GLOBALS['xoopsTpl']->assign('tablesorter_theme', $tablesorterTheme);
285
        $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/tablesorter/js/jquery.tablesorter.js');
286
        $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/tablesorter/js/jquery.tablesorter.widgets.js');
287
        $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/tablesorter/js/extras/jquery.tablesorter.pager.min.js');
288
        $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/tablesorter/js/widgets/widget-pager.min.js');
289
        break;
290
291
    case 'save':
292
        // Security Check
293
        if (!$GLOBALS['xoopsSecurity']->check()) {
294
            \redirect_header('registration.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
295
        }
296
        // Check params
297
        if (0 === $regEvid) {
298
            \redirect_header('index.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
299
        }
300
        $eventObj           = $eventHandler->get($regEvid);
301
        $evSubmitter        = $eventObj->getVar('submitter');
302
        $evStatus           = $eventObj->getVar('status');
303
        $registerForceVerif = (bool)$eventObj->getVar('register_forceverif');
304
305
        if ($regId > 0) {
306
            // Check permissions
307
            $registrationObj = $registrationHandler->get($regId);
308
            $permEdit = $permissionsHandler->getPermRegistrationsEdit($registrationObj->getVar('ip'), $registrationObj->getVar('submitter'), $evSubmitter, $evStatus);
309
            if (!$permEdit) {
310
                // check for valid verifKey
311
                $verifKeyEdit = Request::getString('verifkeyEdit');
312
                $verifKeyArray  = explode('||', base64_decode($verifKeyEdit, true));
313
                if (\is_object($registrationObj) && \WGEVENTS_URL === (string)$verifKeyArray[1] &&
314
                    (int)$registrationObj->getVar('evid') === (int)$verifKeyArray[2] &&
315
                    (string)$registrationObj->getVar('email') === (string)$verifKeyArray[3] &&
316
                    (string)$registrationObj->getVar('verifkey') === (string)$verifKeyArray[4]) {
317
                    $permEdit = true;
318
                }
319
            }
320
            if (!$permEdit) {
321
                \redirect_header('registration.php?op=list', 3, \_NOPERM);
322
            }
323
            $registrationObj = $registrationHandler->get($regId);
324
            $registrationObjOld = $registrationHandler->get($regId);
325
        } else {
326
            // Check permissions
327
            if (!$permissionsHandler->getPermRegistrationsSubmit()) {
328
                \redirect_header('registration.php?op=list', 3, \_NOPERM);
329
            }
330
            $registrationObj = $registrationHandler->create();
331
        }
332
        // create item in table registrations
333
        $answersValueArr = [];
334
        $answersIdArr = Request::getArray('ans_id');
335
        $answersTypeArr = Request::getArray('type');
336
        $registrationObj->setVar('evid', $regEvid);
337
        $registrationObj->setVar('salutation', Request::getInt('salutation'));
338
        $registrationObj->setVar('firstname', Request::getString('firstname'));
339
        $registrationObj->setVar('lastname', Request::getString('lastname'));
340
        $regEmail = Request::getString('email');
341
        $registrationObj->setVar('email', $regEmail);
342
        $registrationObj->setVar('email_send', Request::getInt('email_send'));
343
        $registrationObj->setVar('gdpr', Request::getInt('gdpr'));
344
        $registrationObj->setVar('ip', Request::getString('ip'));
345
        $regVerifkey = ('' === Request::getString('verifkey')) ? xoops_makepass() . xoops_makepass(): Request::getString('verifkey');
346
        $registrationObj->setVar('verifkey', $regVerifkey);
347
        $regStatus = Request::getInt('status');
348
        $registrationObj->setVar('status', $regStatus);
349
        $registrationObj->setVar('financial', Request::getInt('financial'));
350
        $regPaidamount = Utility::StringToFloat(Request::getString('paidamount'));
351
        $registrationObj->setVar('paidamount', $regPaidamount);
352
        $regListwait = 0;
353
        if ($regId > 0 || $permissionsHandler->getPermRegistrationsApprove($evSubmitter, $evStatus)) {
354
            //existing registration or user has perm to approve => take value of form
355
            $registrationObj->setVar('listwait', Request::getInt('listwait'));
356
        } else {
357
            //check number of registrations
358
            $eventRegisterMax = (int)$eventObj->getVar('register_max');
359
            if ($eventRegisterMax > 0) {
360
                $crRegCheck = new \CriteriaCompo();
361
                $crRegCheck->add(new \Criteria('evid', $regEvid));
362
                $numberRegCurr = $registrationHandler->getCount($crRegCheck);
363
                if ($eventRegisterMax <= $numberRegCurr) {
364
                    $regListwait = 1;
365
                }
366
            }
367
            $registrationObj->setVar('listwait', $regListwait);
368
        }
369
        if (Request::hasVar('datecreated_int')) {
370
            $registrationObj->setVar('datecreated', Request::getInt('datecreated_int'));
371
        } else {
372
            $registrationDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated'));
373
            $registrationObj->setVar('datecreated', $registrationDatecreatedObj->getTimestamp());
374
        }
375
        $regSubmitter = Request::getInt('submitter');
376
        $registrationObj->setVar('submitter', $regSubmitter);
377
        // Insert Data
378
        if ($registrationHandler->insert($registrationObj)) {
379
            $newRegId = $regId > 0 ? $regId : (int)$registrationObj->getNewInsertedId();
380
            if ($regId > 0) {
381
                // create copy before deleting
382
                // get all questions for this event
383
                $questionsArr = $questionHandler->getQuestionsByEvent($regEvid);
384
                // get old answers for this questions
385
                $answersOld = $answerHandler->getAnswersDetailsByRegistration($newRegId, $questionsArr);
386
                // delete all existing answers
387
                $answerHandler->cleanupAnswers($regEvid, $regId);
388
            }
389
            // get all questions
390
            if (\count($answersIdArr) > 0) {
391
                foreach (\array_keys($answersIdArr) as $queId) {
392
                    $answer = '';
393
                    if (Request::hasVar('ans_id_' . $queId) && '' !== Request::getString('ans_id_' . $queId)) {
394
                        switch ($answersTypeArr[$queId]) {
395
                            case Constants::FIELD_CHECKBOX:
396
                            case Constants::FIELD_COMBOBOX:
397
                                $answer = serialize(Request::getArray('ans_id_' . $queId));
398
                                break;
399
                            case Constants::FIELD_SELECTBOX: //selectbox expect/gives single value, but stored as array
400
                                $answer = serialize(Request::getString('ans_id_' . $queId));
401
                                break;
402
                            default:
403
                                $answer = Request::getString('ans_id_' . $queId);
404
                                break;
405
                        }
406
                        $answersValueArr[$queId] = $answer;
407
                    }
408
                }
409
            }
410
411
            // create items in table answers
412
            foreach ($answersValueArr as $key => $answer) {
413
                if ('' !== (string)$answer) {
414
                    $answerObj = $answerHandler->create();
415
                    $answerObj->setVar('regid', $newRegId);
416
                    $answerObj->setVar('queid', $key);
417
                    $answerObj->setVar('evid', $regEvid);
418
                    $answerObj->setVar('text', $answer);
419
                    $answerObj->setVar('datecreated', \time());
420
                    $answerObj->setVar('submitter', $regSubmitter);
421
                    // Insert Data
422
                    $answerHandler->insert($answerObj);
423
                }
424
            }
425
            // TODO: Handle notification
426
            // send notifications/confirmation emails
427
            $infotextReg     = ''; // info text for registered person
428
            $infotextOrg     = ''; // infotext for organizer
429
            $previousMail    = '';
430
            $newRegistration = false;
431
            // create code for verification and showing single registration
432
            $codeArr = [
433
                $newRegId,
434
                \WGEVENTS_URL,
435
                $regEvid,
436
                $regEmail,
437
                $regVerifkey
438
            ];
439
            $code = base64_encode(implode('||', $codeArr));
440
            if ($regId > 0) {
441
                // find changes in table registrations
442
                $infotextReg = $registrationHandler->getRegistrationsCompare($registrationObjOld, $regId);
443
                if ('' !== $infotextReg) {
444
                    // create history
445
                    if ($registrationObjOld->getVar('email') != $registrationObj->getVar('email')) {
446
                        $previousMail = $registrationObjOld->getVar('email');
447
                    }
448
                    $registrationhistHandler->createHistory($registrationObjOld, 'update');
449
                }
450
                // find changes in table answers
451
                if (\is_array($answersOld)) {
452
                    // get new answers for this questions
453
                    $answersNew = $answerHandler->getAnswersDetailsByRegistration($newRegId, $questionsArr);
454
                    $result = $answerHandler->getAnswersCompare($answersOld, $answersNew);
455
                    if ('' !== $result) {
456
                        // create history
457
                        $answerhistHandler->createHistory($regEvid, $regId, 'update');
458
                    }
459
                    $infotextReg .= $result;
460
                }
461
                $infotextOrg = $infotextReg;
462
                $singleRegLink = \WGEVENTS_URL . '/registration.php?op=show&verifkey=' . $code;
463
                $infotextReg .= PHP_EOL . \sprintf(\_MA_WGEVENTS_MAIL_REG_SINGLE, $singleRegLink) . PHP_EOL;
464
                // other params
465
                $typeNotify  = Constants::MAIL_REG_NOTIFY_MODIFY;
466
                $typeConfirm = Constants::MAIL_REG_CONFIRM_MODIFY;
467
            } else {
468
                $newRegistration = true;
469
                if (1 === $regListwait) {
470
                    // registration was put on a waiting list
471
                    $infotextReg .= \_MA_WGEVENTS_MAIL_REG_IN_LISTWAIT . PHP_EOL;
472
                }
473
                if (Constants::STATUS_SUBMITTED == $regStatus) {
474
                    // user has no permission for autoverify
475
                    $verifLink     = \WGEVENTS_URL . '/verification.php?verifkey=' . $code;
476
                    $infotextReg   .= \sprintf(\_MA_WGEVENTS_MAIL_REG_IN_VERIF, $verifLink) . PHP_EOL;
477
                }
478
                if (1 === $regListwait || Constants::STATUS_SUBMITTED == $regStatus) {
479
                    // registration was put on a waiting list
480
                    $infotextReg .= \_MA_WGEVENTS_MAIL_REG_IN_FINAL . PHP_EOL;
481
                }
482
                $singleRegLink = \WGEVENTS_URL . '/registration.php?op=show&verifkey=' . $code;
483
                $infotextReg   .= PHP_EOL . \sprintf(\_MA_WGEVENTS_MAIL_REG_SINGLE, $singleRegLink) . PHP_EOL;
484
                $typeNotify  = Constants::MAIL_REG_NOTIFY_IN;
485
                $typeConfirm = Constants::MAIL_REG_CONFIRM_IN;
486
            }
487
            $showinfo = 0;
488
            if ($newRegistration || '' !== $infotextReg) {
489
                $mailsHandler = new MailHandler();
490
                $mailParams = $mailsHandler->getMailParam($eventObj, $newRegId);
0 ignored issues
show
It seems like $newRegId can also be of type string; however, parameter $regId of XoopsModules\Wgevents\MailHandler::getMailParam() 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 ignore-type  annotation

490
                $mailParams = $mailsHandler->getMailParam($eventObj, /** @scrutinizer ignore-type */ $newRegId);
Loading history...
491
                unset($mailsHandler);
492
                $registerNotify = (string)$eventObj->getVar('register_notify', 'e');
493
                if ('' !== $registerNotify) {
494
                    $mailParams['infotext'] = $infotextOrg;
495
                    // send notifications to emails of register_notify
496
                    $notifyEmails = $eventHandler->getRecipientsNotify($registerNotify);
497
                    if (\count($notifyEmails) > 0) {
498
                        foreach ($notifyEmails as $recipient) {
499
                            $taskHandler->createTask($typeNotify, $recipient, json_encode($mailParams));
500
                        }
501
                    }
502
                }
503
                if (('' !== $regEmail && Request::getInt('email_send') > 0) || ('' !== $previousMail)) {
504
                    $mailParams['infotext'] = $infotextReg;
505
                    $showinfo = 1;
506
                    // send confirmation, if radio is checked
507
                    // or inform old email in any case if email changed
508
                    $recipients = [];
509
                    $recipients[] = $regEmail;
510
                    if ('' !== $previousMail) {
511
                        // add old email address if it changed in order to inform old mail address
512
                        $recipients[] = $previousMail;
513
                    }
514
                    foreach ($recipients as $recipient) {
515
                        $taskHandler->createTask($typeConfirm, $recipient, json_encode($mailParams));
516
                    }
517
                }
518
            }
519
            // execute mail sending by task handler
520
            $taskHandler->processTasks();
521
            // redirect after insert
522
            \redirect_header('registration.php?op=' . $redir . '&amp;redir=' . $redir . '&amp;evid=' . $regEvid. '&amp;showinfo=' . $showinfo, 2, \_MA_WGEVENTS_FORM_OK);
523
        }
524
        // Get Form Error
525
        $GLOBALS['xoopsTpl']->assign('error', $registrationObj->getHtmlErrors());
526
        $form = $registrationObj->getForm();
527
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
528
        break;
529
    case 'edit':
530
        // Breadcrumbs
531
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_REGISTRATION_EDIT];
532
        // Check params
533
        if (0 === $regId) {
534
            \redirect_header('registration.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
535
        }
536
        $verifKey = Request::getString('verifkey');
537
        // Check permissions
538
        $registrationObj = $registrationHandler->get($regId);
539
        $eventObj = $eventHandler->get($registrationObj->getVar('evid'));
540
        $permEdit = $permissionsHandler->getPermRegistrationsEdit($registrationObj->getVar('ip'), $registrationObj->getVar('submitter'), $eventObj->getVar('submitter'), $eventObj->getVar('status'));
541
        if (!$permEdit) {
542
            // check for valid verifKey
543
            $verifKeyArray  = explode('||', base64_decode($verifKey, true));
544
            if ($regId > 0 && \is_object($registrationObj) && \WGEVENTS_URL === (string)$verifKeyArray[1] &&
545
                (int)$registrationObj->getVar('evid') === (int)$verifKeyArray[2] &&
546
                (string)$registrationObj->getVar('email') === (string)$verifKeyArray[3] &&
547
                (string)$registrationObj->getVar('verifkey') === (string)$verifKeyArray[4]) {
548
                $permEdit = true;
549
            }
550
        }
551
        if (!$permEdit) {
552
            \redirect_header('registration.php?op=list', 3, \_NOPERM);
553
        }
554
        if ('' !== $verifKey) {
555
            $redir = 'listmy';
556
        }
557
        // Get Form
558
        $registrationObj->setRedir($redir);
559
        $registrationObj->setVerifkeyEdit($verifKey);
560
        $registrationObj->setStart = $start;
561
        $registrationObj->setLimit = $limit;
562
        $form = $registrationObj->getForm();
563
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
564
        break;
565
566
    case 'clone':
567
        echo 'noch nicht programmiert';die;
568
        // Breadcrumbs
569
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_REGISTRATION_CLONE];
570
        // Check permissions
571
        if (!$permissionsHandler->getPermGlobalSubmit()) {
572
            \redirect_header('registration.php?op=list', 3, \_NOPERM);
573
        }
574
        // Request source
575
        $regIdSource = Request::getInt('id_source');
576
        // Check params
577
        if (0 === $regIdSource) {
578
            \redirect_header('registration.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
579
        }
580
        // Get Form
581
        $registrationObjSource = $registrationHandler->get($regIdSource);
582
        $registrationObj = $registrationObjSource->xoopsClone();
583
        $form = $registrationObj->getForm();
584
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
585
        break;
586
    case 'delete':
587
        // Breadcrumbs
588
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_REGISTRATION_DELETE];
589
        // Check params
590
        if (0 === $regId) {
591
            \redirect_header('index.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
592
        }
593
        // Check permissions
594
        $registrationObj = $registrationHandler->get($regId);
595
        if (!\is_object($registrationObj)) {
596
            \redirect_header('index.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
597
        }
598
        $eventObj = $eventHandler->get($registrationObj->getVar('evid'));
599
600
        $mailsHandler = new MailHandler();
601
        $mailParams = $mailsHandler->getMailParam($eventObj, $regId);
602
        unset($mailsHandler);
603
604
        $mailParams['email'] = $registrationObj->getVar('email');
605
        if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
606
            if (!$GLOBALS['xoopsSecurity']->check()) {
607
                \redirect_header('registration.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
608
            }
609
            // create history
610
            $registrationhistHandler->createHistory($registrationObj, 'delete');
611
            if ($registrationHandler->delete($registrationObj)) {
612
                // create history
613
                $answerhistHandler->createHistory($mailParams['evId'], $regId, 'delete');
614
                //delete existing answers
615
                $answerHandler->cleanupAnswers($mailParams['evId'], $regId);
616
                // TODO:  Event delete notification
617
                // send notifications/confirmation emails
618
                $registerNotify = (string)$eventObj->getVar('register_notify', 'e');
619
                if ('' !== $registerNotify) {
620
                    // send notifications to emails of register_notify
621
                    $notifyEmails = $eventHandler->getRecipientsNotify($registerNotify);
622
                    if (\count($notifyEmails) > 0) {
623
                        foreach ($notifyEmails as $recipient) {
624
                            $taskHandler->createTask(Constants::MAIL_REG_NOTIFY_OUT, $recipient, json_encode($mailParams));
625
                        }
626
                    }
627
                }
628
                // send email in any case if email is available
629
                if ('' !== (string)$mailParams['regEmail']) {
630
                    // send confirmation
631
                    $taskHandler->createTask(Constants::MAIL_REG_CONFIRM_OUT, $mailParams['regEmail'], json_encode($mailParams));
632
                }
633
                // execute mail sending by task handler
634
                $taskHandler->processTasks();
635
                \redirect_header('registration.php?op=' . $redir . '&amp;redir=' . $redir . '&amp;id=' . $regId . '&amp;evid=' . $regEvid, 3, \_MA_WGEVENTS_FORM_DELETE_OK);
636
            } else {
637
                $GLOBALS['xoopsTpl']->assign('error', $registrationObj->getHtmlErrors());
638
            }
639
        } else {
640
            $customConfirm = new Common\Confirm(
641
                ['ok' => 1, 'id' => $regId, 'evid' => $regEvid, 'op' => 'delete', 'redir' => $redir],
642
                $_SERVER['REQUEST_URI'],
643
                \sprintf(\_MA_WGEVENTS_CONFIRMDELETE_REGISTRATION, $mailParams['regFirstname'] . ' ' . $mailParams['regLastname']),
644
                \_MA_WGEVENTS_CONFIRMDELETE_TITLE,
645
                \_MA_WGEVENTS_CONFIRMDELETE_LABEL
646
            );
647
            $form = $customConfirm->getFormConfirm();
648
            $GLOBALS['xoopsTpl']->assign('form', $form->render());
649
        }
650
        break;
651
    case 'change_financial':
652
        /* function is handled by registration_ajax.php */
653
        echo 'registration.php: function change_financial is not used anymore';
654
        die;
655
    case 'listwait_takeover':
656
        /* function is handled by registration_ajax.php */
657
        echo 'registration.php: function listwait_takeover is not used anymore';
658
        die;
659
    case 'approve_status':
660
        /* function is handled by registration_ajax.php */
661
        echo 'registration.php: function approve_status is not used anymore';
662
        die;
663
    case 'contactall':
664
        // Breadcrumbs
665
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_CONTACT_ALL];
666
        // Check params
667
        if (0 === $regEvid) {
668
            \redirect_header('registration.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
669
        }
670
        // Get Form
671
        $eventObj = $eventHandler->get($regEvid);
672
        $form = $eventObj->getFormContactAll($eventObj->getVar('register_sendermail'), $eventObj->getVar('name'));
673
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
674
        break;
675
    case 'exec_contactall':
676
    case 'exec_contactall_test':
677
        // Security Check
678
        if (!$GLOBALS['xoopsSecurity']->check()) {
679
            \redirect_header('registration.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
680
        }
681
        // Check params
682
        if (0 === $regEvid) {
683
            \redirect_header('index.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
684
        }
685
686
        $eventObj = $eventHandler->get($regEvid);
687
        // Check permissions
688
        if (!$permissionsHandler->getPermEventsEdit($eventObj->getVar('submitter'), $eventObj->getVar('status'))) {
689
            \redirect_header('index.php?op=list', 3, \_NOPERM);
690
        }
691
        $crRegistration = new \CriteriaCompo();
692
        $crRegistration->add(new \Criteria('evid', $regEvid));
693
        $numberRegCurr = $registrationHandler->getCount($crRegistration);
694
        $mailToArr = [];
695
        if ($numberRegCurr > 0 && 'exec_contactall' === $op) {
696
            $registrationsAll = $registrationHandler->getAll($crRegistration);
697
            foreach (\array_keys($registrationsAll) as $i) {
698
                $mailToArr[$registrationsAll[$i]->getVar('email')] = $registrationsAll[$i]->getVar('email');
699
            }
700
        }
701
        $mailFrom    = Request::getString('mail_from');
702
        $mailSubject = Request::getString('mail_subject');
703
        $mailBody    = Request::getText('mail_body');
704
        $mailCopy    = Request::getInt('mail_copy');
705
        if (1 ===  $mailCopy) {
706
            $mailToArr[$mailFrom] = $mailFrom;
707
        }
708
        $mailParams = [];
709
        $mailParams['evId']                  = $regEvid;
710
        $mailParams['evName']                = $eventObj->getVar('name');
711
        $mailParams['evDatefrom']            = $eventObj->getVar('datefrom');
712
        $mailParams['evLocation']            = $eventObj->getVar('location');
713
        $mailParams['evSubmitter']           = $eventObj->getVar('submitter');
714
        $mailParams['evStatus']              = $eventObj->getVar('status');
715
        $mailParams['evRegister_sendermail'] = $eventObj->getVar('register_sendermail');
716
        $mailParams['evRegister_sendername'] = $eventObj->getVar('register_sendername');
717
        $mailParams['evRegister_signature']  = $eventObj->getVar('register_signature');
718
        $mailParams['mailFrom']              = $mailFrom;
719
        $mailParams['mailSubject']           = $mailSubject;
720
        $mailParams['mailBody']              = $mailBody;
721
722
        foreach ($mailToArr as $mail) {
723
            $taskHandler->createTask(Constants::MAIL_EVENT_NOTIFY_ALL, $mail, json_encode($mailParams));
724
        }
725
726
        $result = $taskHandler->processTasks();
727
        $counterDone = (int)$result['done'];
728
        $counterPending = (int)$result['pending'];
729
730
        if ($counterDone > 0 || $counterPending > 0) {
731
            if ('exec_contactall_test' === $op && $counterDone > 0) {
732
                $eventObj = $eventHandler->get($regEvid);
733
                $form = $eventObj->getFormContactAll($mailFrom, $mailSubject, $mailBody, $mailCopy);
734
                $GLOBALS['xoopsTpl']->assign('warning', \_MA_WGEVENTS_CONTACT_ALL_TEST_SUCCESS);
735
                $GLOBALS['xoopsTpl']->assign('form', $form->render());
736
                break;
737
            }
738
            // redirect after insert
739
            $message = '';
740
            if ($counterDone > 0) {
741
                $message .= sprintf( \_MA_WGEVENTS_CONTACT_ALL_SUCCESS, $counterDone) . '<br>';
742
            }
743
            if ($counterPending > 0) {
744
                $message .= sprintf( \_MA_WGEVENTS_CONTACT_ALL_PENDING, $counterDone) . '<br>';
745
            }
746
            \redirect_header('registration.php?op=listeventall&amp;evid=' . $regEvid, 3, $message);
747
        } else {
748
            \redirect_header('index.php?op=list', 3, 'exec_contactall:' . \_MA_WGEVENTS_INVALID_PARAM);
749
        }
750
751
        break;
752
}
753
754
// Keywords
755
wgeventsMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords));
756
unset($keywords);
757
758
// Description
759
wgeventsMetaDescription(\_MA_WGEVENTS_REGISTRATIONS_DESC);
760
$GLOBALS['xoopsTpl']->assign('xoops_mpageurl', \WGEVENTS_URL.'/registration.php');
761
$GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL);
762
763
require __DIR__ . '/footer.php';
764