blob: 8a142dc6ff19fcb8afb5b6362cd8b32fbf6a12db [file] [log] [blame]
matheusfillipeabd513e2021-05-11 03:29:11 -03001<?php
2require_once 'vendor/autoload.php';
Matheus Fillipe301684b2021-05-14 09:09:43 +03003include 'config.php';
matheusfillipeabd513e2021-05-11 03:29:11 -03004include_once 'redis.php';
5include_once 'utils.php';
Matheus Fillipe301684b2021-05-14 09:09:43 +03006include_once 'mail.php';
7include_once 'ldap.php';
Marc Kupietz145f5b92023-03-09 20:39:31 +01008include_once 'db_backend.php';
Matheus Fillipe301684b2021-05-14 09:09:43 +03009include_once 'validators.php';
Marc Kupietz0215a442023-03-05 18:34:16 +010010include_once 'User.php';
Marc Kupietz49f677c2023-03-10 08:29:41 +010011include_once 'invoice.php';
Marc Kupietz0215a442023-03-05 18:34:16 +010012require __DIR__ . '/vendor/autoload.php';
13use Monolog\Level;
14use Monolog\Logger as Logger;
15use Monolog\Handler\StreamHandler;
16use Monolog\Handler\RotatingFileHandler;
17use \User as User;
Marc Kupietz145f5b92023-03-09 20:39:31 +010018use \DB as DB;
Marc Kupietza7074402023-03-06 07:04:59 +010019include $TEMPLATE . "strings.php";
Marc Kupietz0215a442023-03-05 18:34:16 +010020$log = new Logger('signup');
21$log->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/signup.log', 0, Logger::DEBUG));
Marc Kupietz9e5df242023-04-10 18:48:56 +020022$dinners_left = $MAX_DINNERS - (new DB($log))->dinner_count();
matheusfillipeabd513e2021-05-11 03:29:11 -030023
24if (!$DEBUG) error_reporting(0);
matheusfillipec0ce7fa2021-05-13 05:15:37 -030025else error_reporting(1);
matheusfillipeabd513e2021-05-11 03:29:11 -030026session_start();
27
matheusfillipeabd513e2021-05-11 03:29:11 -030028use Gregwar\Captcha\PhraseBuilder;
29
matheusfillipec0ce7fa2021-05-13 05:15:37 -030030$URI = array_slice(explode("/", explode('?', $_SERVER['REQUEST_URI'], 2)[0]), -1)[0];
matheusfillipef43dd962021-05-13 23:27:01 -030031if (strlen($URI) == 2) {
matheusfillipec0ce7fa2021-05-13 05:15:37 -030032 $GLOBALS["cc"] = $URI;
33 $_SESSION["cc"] = $URI;
34}
35
matheusfillipef43dd962021-05-13 23:27:01 -030036if (isset($_GET["lang"])) {
matheusfillipec0ce7fa2021-05-13 05:15:37 -030037 $GLOBALS["cc"] = $_GET["lang"];
38 $_SESSION["cc"] = $_GET["lang"];
39}
40
41$TEMPLATE = template_path();
42
43
Marc Kupietza7074402023-03-06 07:04:59 +010044function send_welcome_email(User $user)
45{
46 global $SMTP, $SERVICE_ACRONYM, $WELCOME_TEMPLATE, $TEMPLATE;
47 $TEMPLATE = template_path();
48 include $TEMPLATE . "email.php";
49 $url = "";
50
51 send_mail($user->email, $SMTP, (object) [
52 "subject" => $WELCOME_TEMPLATE->subject,
53 "text" => replace_all_user_variables($WELCOME_TEMPLATE->text, $user, $url),
54 "html" => replace_all_user_variables($WELCOME_TEMPLATE->html, $user, $url)
Marc Kupietz49f677c2023-03-10 08:29:41 +010055 ], $user);
Marc Kupietza7074402023-03-06 07:04:59 +010056}
57
Marc Kupietza3f3fdb2023-03-04 18:13:26 +010058function send_confirmation_email(string $mail, object $smtp, string $url, User $user)
matheusfillipef43dd962021-05-13 23:27:01 -030059{
matheusfillipeabd513e2021-05-11 03:29:11 -030060 include 'config.php';
matheusfillipef43dd962021-05-13 23:27:01 -030061 $TEMPLATE = template_path();
Matheus Fillipe301684b2021-05-14 09:09:43 +030062 include $TEMPLATE . "email.php";
matheusfillipef43dd962021-05-13 23:27:01 -030063
64 send_mail($mail, $smtp, (object) [
65 "subject" => $MAIL_TEMPLATE->subject,
Marc Kupietza3f3fdb2023-03-04 18:13:26 +010066 "text" => replace_all_user_variables($MAIL_TEMPLATE->text, $user, $url),
67 "html" => replace_all_user_variables($MAIL_TEMPLATE->html, $user, $url)
matheusfillipef43dd962021-05-13 23:27:01 -030068 ]);
69}
70
71function send_recovery_email(string $mail, object $smtp, string $url)
72{
73 include 'config.php';
matheusfillipef43dd962021-05-13 23:27:01 -030074 $TEMPLATE = template_path();
Matheus Fillipe301684b2021-05-14 09:09:43 +030075 include $TEMPLATE . "email.php";
matheusfillipef43dd962021-05-13 23:27:01 -030076
77 send_mail($mail, $smtp, (object) [
78 "subject" => $RECOVERY_EMAIL_TEMPLATE->subject,
79 "text" => str_replace("{{url}}", $url, $RECOVERY_EMAIL_TEMPLATE->text),
80 "html" => str_replace("{{url}}", $url, $RECOVERY_EMAIL_TEMPLATE->html)
81 ]);
82}
83
84function reload_captcha_script()
85{
86 include 'config.php';
Marc Kupietza7074402023-03-06 07:04:59 +010087
88 if ($CAPTCHA_LENGTH > 0) {
89 $TEMPLATE = template_path();
90 include $TEMPLATE . "strings.php";
91 echo '
92 <script>
93 const reload_captcha = async (e) => {
94 var cont = document.getElementById("reload_captcha");
95 cont.innerHTML = "<div class=\'spinner-border text-info\' role=\'status\'><span class=\'sr-only\'>' . $STRINGS->reloading_captcha . '</span></div>";
96 var img = document.getElementById("captcha")
97 var url = "' . $BASE_URL . '/captcha.php?token=' . $_SESSION["captcha_token"] . '"
98 await fetch(url, { cache: "reload", mode: "no-cors" })
99 .then(() => {
100 img.src = url+"&t=" + new Date().getTime();
101 setTimeout( () => {
102 cont.innerHTML = "<button id=\'reload\' class=\'btn btn-outline-info\' type=\'button\'> <span class=\'glyphicon glyphicon-refresh\' aria-hidden=\'true\'></span></button>";
103 bindButton()
104 }, 500);
105 })
106 }
107 function bindButton(){
108 var button = document.getElementById("reload");
109 button.addEventListener("click", reload_captcha)
110 }
111 bindButton()
112 </script>
113 ';
114 }
matheusfillipeabd513e2021-05-11 03:29:11 -0300115}
116
matheusfillipef43dd962021-05-13 23:27:01 -0300117function register_page($error = false)
118{
Marc Kupietz9e5df242023-04-10 18:48:56 +0200119 global $log, $dinners_left;
matheusfillipef43dd962021-05-13 23:27:01 -0300120 $TEMPLATE = template_path();
121 include 'config.php';
122 if ($error)
123 include $TEMPLATE . 'error.htm';
124 $_SESSION["captcha_token"] = generateRandomString(12);
125 include $TEMPLATE . "register.htm";
126 reload_captcha_script();
127}
matheusfillipeabd513e2021-05-11 03:29:11 -0300128
matheusfillipef43dd962021-05-13 23:27:01 -0300129
Marc Kupietz0215a442023-03-05 18:34:16 +0100130function verify_request(User $user)
matheusfillipef43dd962021-05-13 23:27:01 -0300131{
Marc Kupietzd5513b12023-03-30 17:12:22 +0200132 global $log, $CONFERENCE_REGISTRATION, $CAPTCHA_LENGTH, $DEBUG;
Marc Kupietz145f5b92023-03-09 20:39:31 +0100133
matheusfillipec0ce7fa2021-05-13 05:15:37 -0300134 $TEMPLATE = template_path();
matheusfillipeabd513e2021-05-11 03:29:11 -0300135 unset($_SESSION['captcha_token']);
matheusfillipef43dd962021-05-13 23:27:01 -0300136 include $TEMPLATE . 'strings.php';
matheusfillipeabd513e2021-05-11 03:29:11 -0300137 $password = $_POST["password"];
matheusfillipe47cf90b2021-05-13 03:36:21 -0300138 $error = "";
139
Marc Kupietz145f5b92023-03-09 20:39:31 +0100140 if (!$CONFERENCE_REGISTRATION) {
141 $error .= validate_username($user->username);
142 $error .= validate_password($password);
143 }
144 $log->debug("validating request");
Marc Kupietz03146622023-03-07 12:03:21 +0100145 $error .= validate_name($user->first_name, $FIRST_NAME_VALIDATION_ERROR);
matheusfillipe47cf90b2021-05-13 03:36:21 -0300146 $error .= validate_name($user->last_name, $LAST_NAME_VALIDATION_ERROR);
Marc Kupietz145f5b92023-03-09 20:39:31 +0100147 $log->debug("request validated: $error");
matheusfillipe47cf90b2021-05-13 03:36:21 -0300148 $error .= validate_email($user->email);
matheusfillipe47cf90b2021-05-13 03:36:21 -0300149
matheusfillipeabd513e2021-05-11 03:29:11 -0300150
Marc Kupietz493198f2023-03-04 14:59:16 +0100151 if ($CAPTCHA_LENGTH > 0 && !(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
Marc Kupietzd5513b12023-03-30 17:12:22 +0200152 $error = $error . $STRINGS->wrong_captcha . ($DEBUG ? " expected: " . $_SESSION['captcha'] . " actual: " . $_POST['captcha'] : "");
matheusfillipeabd513e2021-05-11 03:29:11 -0300153 }
154 unset($_SESSION["captcha"]);
matheusfillipef43dd962021-05-13 23:27:01 -0300155
matheusfillipeabd513e2021-05-11 03:29:11 -0300156 return $error;
157}
158
Marc Kupietza3f3fdb2023-03-04 18:13:26 +0100159
Marc Kupietz0215a442023-03-05 18:34:16 +0100160function approve_request(User $user)
matheusfillipef43dd962021-05-13 23:27:01 -0300161{
Matheus Fillipe301684b2021-05-14 09:09:43 +0300162 include 'config.php';
Marc Kupietz8e6a8df2023-03-07 13:05:23 +0100163 global $log, $_SESSION;
Marc Kupietz0215a442023-03-05 18:34:16 +0100164
matheusfillipec0ce7fa2021-05-13 05:15:37 -0300165 $token = generateRandomString();
matheusfillipeabd513e2021-05-11 03:29:11 -0300166 redis_set($token, $user, $MAIL_CONFIRMATION_AWAIT_DELAY);
167 $pending = redis_get("pending");
matheusfillipef43dd962021-05-13 23:27:01 -0300168 if ($pending) {
matheusfillipeabd513e2021-05-11 03:29:11 -0300169 $maillist = $pending->mails;
Marc Kupietz145f5b92023-03-09 20:39:31 +0100170 if(is_array($maillist))
171 array_push($maillist, $user->email);
matheusfillipef43dd962021-05-13 23:27:01 -0300172 } else
matheusfillipeabd513e2021-05-11 03:29:11 -0300173 $maillist = [$user->email];
matheusfillipef43dd962021-05-13 23:27:01 -0300174 redis_set("pending", (object)["mails" => $maillist], $MAIL_CONFIRMATION_AWAIT_DELAY);
matheusfillipeabd513e2021-05-11 03:29:11 -0300175
matheusfillipef43dd962021-05-13 23:27:01 -0300176 $url = $BASE_URL . "?type=confirmation&token=" . $token;
matheusfillipeabd513e2021-05-11 03:29:11 -0300177 if (in_array(explode("@", $user->email)[1], $MAIL_HOST_DIRECT_FALLBACK))
178 $smtp = $FALLBACK_SMTP;
179 else
180 $smtp = $SMTP;
Marc Kupietza3f3fdb2023-03-04 18:13:26 +0100181 send_confirmation_email($user->email, $smtp, $url, $user);
matheusfillipeabd513e2021-05-11 03:29:11 -0300182 $_SESSION['resend'] = generateRandomString(12);
183 $_SESSION['token'] = $token;
Marc Kupietz03146622023-03-07 12:03:21 +0100184 $user->backup_in_session();
matheusfillipec0ce7fa2021-05-13 05:15:37 -0300185 $TEMPLATE = template_path();
matheusfillipef43dd962021-05-13 23:27:01 -0300186 include $TEMPLATE . "confirm_your_email.htm";
Marc Kupietz03146622023-03-07 12:03:21 +0100187 $log->info("Registration process started for " . $user->to_string());
matheusfillipeabd513e2021-05-11 03:29:11 -0300188}
189
Matheus Fillipe301684b2021-05-14 09:09:43 +0300190function recover_form($error = null)
191{
192 $TEMPLATE = template_path();
193 include 'config.php';
194 $_SESSION["captcha_token"] = generateRandomString(12);
195 if ($error)
196 include $TEMPLATE . 'error.htm';
197 include $TEMPLATE . "recover_email_form.htm";
198 reload_captcha_script();
199}
200
201function new_password_form($error = null)
202{
203 $TEMPLATE = template_path();
204 if ($error)
205 include $TEMPLATE . 'error.htm';
206 include $TEMPLATE . "recover_new_password_form.htm";
207}
208
matheusfillipeabd513e2021-05-11 03:29:11 -0300209
210// PAGE
matheusfillipef43dd962021-05-13 23:27:01 -0300211include $TEMPLATE . "header.htm";
matheusfillipeabd513e2021-05-11 03:29:11 -0300212
213if ($_SERVER["REQUEST_METHOD"] == "POST") {
matheusfillipeabd513e2021-05-11 03:29:11 -0300214 if (isset($_POST['type'])) {
215 switch ($_POST['type']) {
216 case "register":
Marc Kupietz03146622023-03-07 12:03:21 +0100217 $log->info("Registration request from " . array_to_string($_POST));
218 $user = new User();
219 $user->init_from_array($_POST);
220 $log->info("Registration request from " . $user->to_string());
matheusfillipef43dd962021-05-13 23:27:01 -0300221 if (redis_inc_ipdata(getClientIP(), "register", true) > $HOURLY_REGISTRATIONS) {
222 include $TEMPLATE . "registration_limit.htm";
223 } else {
matheusfillipeabd513e2021-05-11 03:29:11 -0300224 $error = verify_request($user);
225 if ($error)
226 register_page($error);
227 else
228 approve_request($user);
229 }
230 break;
matheusfillipe47cf90b2021-05-13 03:36:21 -0300231 case "recover":
Marc Kupietz145f5b92023-03-09 20:39:31 +0100232 if ($CONFERENCE_REGISTRATION)
233 break;
matheusfillipef43dd962021-05-13 23:27:01 -0300234 $TEMPLATE = template_path();
235 unset($_SESSION['captcha_token']);
236 include $TEMPLATE . 'strings.php';
237
238 $email = $_POST["email"];
Marc Kupietz145f5b92023-03-09 20:39:31 +0100239 if (($CONFERENCE_REGISTRATION & ! (new DB($log))->mail_count($email)) || !ldap_mail_count($email)) {
Matheus Fillipe301684b2021-05-14 09:09:43 +0300240 unset($_POST['email']);
matheusfillipef43dd962021-05-13 23:27:01 -0300241 $error = $error . $STRINGS->recover_email_not_registered;
242 }
243
Marc Kupietz493198f2023-03-04 14:59:16 +0100244 if ($CAPTCHA_LENGTH > 0 && !(isset($_SESSION['captcha']) && PhraseBuilder::comparePhrases($_SESSION['captcha'], $_POST['captcha']))) {
matheusfillipef43dd962021-05-13 23:27:01 -0300245 $error = $error . $STRINGS->wrong_captcha;
246 }
247
248 unset($_SESSION["captcha"]);
249 if (redis_inc_ipdata(getClientIP(), "register", true) > $HOURLY_REGISTRATIONS) {
250 include $TEMPLATE . "registration_limit.htm";
251 } else {
252 if ($error) {
Matheus Fillipe301684b2021-05-14 09:09:43 +0300253 recover_form($error);
matheusfillipef43dd962021-05-13 23:27:01 -0300254 } else {
255 include $TEMPLATE . 'strings.php';
256 $token = generateRandomString();
257 redis_set($token, $email, $MAIL_CONFIRMATION_AWAIT_DELAY);
258
259 $url = $BASE_URL . "?type=password_change&token=" . $token;
260 if (in_array(explode("@", $email)[1], $MAIL_HOST_DIRECT_FALLBACK))
261 $smtp = $FALLBACK_SMTP;
262 else
263 $smtp = $SMTP;
matheusfillipef43dd962021-05-13 23:27:01 -0300264 $_SESSION['resend'] = generateRandomString(12);
265 $_SESSION['token'] = $token;
266 $_SESSION['email'] = $email;
267 $_SESSION['recover'] = $email;
268 $TEMPLATE = template_path();
matheusfillipef43dd962021-05-13 23:27:01 -0300269 send_recovery_email($email, $smtp, $url);
Matheus Fillipe301684b2021-05-14 09:09:43 +0300270 include $TEMPLATE . "confirm_your_email.htm";
Marc Kupietz0215a442023-03-05 18:34:16 +0100271 $log->info("Password recovery email sent to " . $email);
matheusfillipef43dd962021-05-13 23:27:01 -0300272 }
273 }
matheusfillipe47cf90b2021-05-13 03:36:21 -0300274 break;
matheusfillipef43dd962021-05-13 23:27:01 -0300275
276 case "password_change":
Marc Kupietz145f5b92023-03-09 20:39:31 +0100277 if ($CONFERENCE_REGISTRATION)
278 break;
matheusfillipef43dd962021-05-13 23:27:01 -0300279 $password = $_POST['password'];
280 $error = validate_password($password);
281 if ($error) {
Matheus Fillipe301684b2021-05-14 09:09:43 +0300282 new_password_form($error);
283 } else {
284 $TEMPLATE = template_path();
matheusfillipef43dd962021-05-13 23:27:01 -0300285 include $TEMPLATE . "recover_success.htm";
286 include $TEMPLATE . "email.php";
matheusfillipef43dd962021-05-13 23:27:01 -0300287 $email = $_SESSION["email_change"];
288 if (change_password($email, $password)) {
289 if (in_array(explode("@", $email)[1], $MAIL_HOST_DIRECT_FALLBACK))
290 $smtp = $FALLBACK_SMTP;
291 else
292 $smtp = $SMTP;
293 send_mail($email, $smtp, $PASSWORD_CHANGED_EMAIL_TEMPLATE);
Marc Kupietz0215a442023-03-05 18:34:16 +0100294 $log->info("Password changed for " . $email);
Matheus Fillipe301684b2021-05-14 09:09:43 +0300295 } else {
matheusfillipef43dd962021-05-13 23:27:01 -0300296 include $TEMPLATE . "strings.php";
297 echo $STRINGS->change_password_ldap_error;
298 }
Matheus Fillipe301684b2021-05-14 09:09:43 +0300299 unset($_SESSION["email_change"]);
300 redis_delete($_SESSION['token']);
matheusfillipef43dd962021-05-13 23:27:01 -0300301 }
302 break;
Matheus Fillipe301684b2021-05-14 09:09:43 +0300303 }
matheusfillipeabd513e2021-05-11 03:29:11 -0300304 }
305} elseif (isset($_GET['type'])) {
306 switch ($_GET['type']) {
307 case "confirmation":
matheusfillipef43dd962021-05-13 23:27:01 -0300308 if (!isset($_GET["token"])) {
matheusfillipe47cf90b2021-05-13 03:36:21 -0300309 echo $RUNTIME_ERROR->user_trying_invalid_get;
matheusfillipef43dd962021-05-13 23:27:01 -0300310 } else {
matheusfillipeabd513e2021-05-11 03:29:11 -0300311 $token = $_GET["token"];
Marc Kupietz0215a442023-03-05 18:34:16 +0100312 $user = redis_get_user($token);
matheusfillipef43dd962021-05-13 23:27:01 -0300313 if ($user && gettype($user) == "object") {
Marc Kupietz145f5b92023-03-09 20:39:31 +0100314 if (($CONFERENCE_REGISTRATION && (new DB($log))->add_user($user)) || (!$CONFERENCE_REGISTRATION && ldap_add_user($user))) {
matheusfillipeabd513e2021-05-11 03:29:11 -0300315 if ($REDIRECT_TO)
matheusfillipef43dd962021-05-13 23:27:01 -0300316 header("refresh:5;url=" . $REDIRECT_TO);
matheusfillipeabd513e2021-05-11 03:29:11 -0300317
318 $pending = redis_get("pending");
matheusfillipef43dd962021-05-13 23:27:01 -0300319 if ($pending) {
matheusfillipeabd513e2021-05-11 03:29:11 -0300320 $maillist = $pending->mails;
Marc Kupietz49f677c2023-03-10 08:29:41 +0100321 if (is_array($maillist) && in_array($user->email, $maillist)) {
matheusfillipeabd513e2021-05-11 03:29:11 -0300322 unset($maillist[array_search($user->email, $maillist)]);
matheusfillipef43dd962021-05-13 23:27:01 -0300323 redis_set("pending", (object)["mails" => $maillist], $MAIL_CONFIRMATION_AWAIT_DELAY);
matheusfillipeabd513e2021-05-11 03:29:11 -0300324 }
325 }
326 redis_inc_ipdata(getClientIP(), "register");
Marc Kupietz145f5b92023-03-09 20:39:31 +0100327 $log->info("User registration completed: " . $user->to_string());
matheusfillipe47cf90b2021-05-13 03:36:21 -0300328 echo $STRINGS->email_confirmation;
Matheus Fillipe5ad0cd52022-05-05 06:10:41 +0300329 if (isset($POST_REGISTER_HOOK)) $POST_REGISTER_HOOK($user);
matheusfillipef43dd962021-05-13 23:27:01 -0300330 include $TEMPLATE . "mail_confirmed.htm";
331 } else {
Marc Kupietz03146622023-03-07 12:03:21 +0100332 $log->error("User registration failed for: " . $user->to_string());
matheusfillipe47cf90b2021-05-13 03:36:21 -0300333 echo $STRINGS->email_confirmation;
matheusfillipef43dd962021-05-13 23:27:01 -0300334 include $TEMPLATE . "registration_error.htm";
matheusfillipeabd513e2021-05-11 03:29:11 -0300335 }
336 redis_delete($token);
matheusfillipef43dd962021-05-13 23:27:01 -0300337 } else {
338 include $TEMPLATE . "token_expired.htm";
matheusfillipeabd513e2021-05-11 03:29:11 -0300339 }
340 }
341 break;
342 case "resend":
matheusfillipef43dd962021-05-13 23:27:01 -0300343 if (isset($_GET['token']) && isset($_SESSION['resend']) && $_GET['token'] == $_SESSION['resend']) {
Marc Kupietz8e6a8df2023-03-07 13:05:23 +0100344 $log->info("Resending confirmation email to " . $_SESSION['email']);
345 $user = new User();
346 $user->init_from_array($_SESSION);
347 $log->info("Resending confirmation email to " . $user->to_string());
matheusfillipeabd513e2021-05-11 03:29:11 -0300348 $token = $_SESSION['token'];
matheusfillipef43dd962021-05-13 23:27:01 -0300349 $url = $BASE_URL . "?type=confirmation&token=" . $token;
matheusfillipeabd513e2021-05-11 03:29:11 -0300350 $smtp = $FALLBACK_SMTP;
matheusfillipef43dd962021-05-13 23:27:01 -0300351 $address = $_SESSION["email"];
Matheus Fillipe301684b2021-05-14 09:09:43 +0300352 if (isset($_SESSION['recover'])) {
matheusfillipef43dd962021-05-13 23:27:01 -0300353 $url = $BASE_URL . "?type=password_change&token=" . $token;
Marc Kupietza3f3fdb2023-03-04 18:13:26 +0100354 send_recovery_email($address, $smtp, $url, $user);
matheusfillipef43dd962021-05-13 23:27:01 -0300355 unset($_SESSION['recover']);
Matheus Fillipe301684b2021-05-14 09:09:43 +0300356 } else
Marc Kupietza3f3fdb2023-03-04 18:13:26 +0100357 send_confirmation_email($address, $smtp, $url, $user);
Marc Kupietz8e6a8df2023-03-07 13:05:23 +0100358 echo "<div class='alert alert-info' role='alert'> Another email has been sent to ". $_SESSION['email']. " </div>";
matheusfillipeabd513e2021-05-11 03:29:11 -0300359 unset($_SESSION['resend']);
360 unset($_SESSION['token']);
Marc Kupietza3f3fdb2023-03-04 18:13:26 +0100361 # unset($_SESSION['email']);
362 } else {
Marc Kupietz8e6a8df2023-03-07 13:05:23 +0100363 echo "<div class='alert alert-warning' role='alert'>A second email has already been sent.</div>";
matheusfillipeabd513e2021-05-11 03:29:11 -0300364 }
365 break;
matheusfillipef43dd962021-05-13 23:27:01 -0300366
matheusfillipe47cf90b2021-05-13 03:36:21 -0300367 case "recover":
Matheus Fillipe301684b2021-05-14 09:09:43 +0300368 recover_form();
matheusfillipe47cf90b2021-05-13 03:36:21 -0300369 break;
matheusfillipef43dd962021-05-13 23:27:01 -0300370
371 case "password_change":
372 $TEMPLATE = template_path();
matheusfillipef43dd962021-05-13 23:27:01 -0300373 $token = $_GET["token"];
374 $email = redis_get($token);
375 $_SESSION["email_change"] = $email;
Matheus Fillipe301684b2021-05-14 09:09:43 +0300376 $_SESSION["token"] = $token;
377 if ($email && gettype($email) == "string") {
378 new_password_form();
matheusfillipef43dd962021-05-13 23:27:01 -0300379 } else {
380 include $TEMPLATE . "token_expired.htm";
381 }
matheusfillipe47cf90b2021-05-13 03:36:21 -0300382 break;
matheusfillipeabd513e2021-05-11 03:29:11 -0300383 }
matheusfillipeabd513e2021-05-11 03:29:11 -0300384} else {
385 unset($_SESSION['captcha_token']);
386 register_page();
387}
388
matheusfillipef43dd962021-05-13 23:27:01 -0300389include $TEMPLATE . "bottom.htm";