diff options
Diffstat (limited to 'validate.php')
-rw-r--r-- | validate.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/validate.php b/validate.php new file mode 100644 index 0000000..26fc67d --- /dev/null +++ b/validate.php @@ -0,0 +1,40 @@ +<?php +namespace mcoop; +require_once("recaptcha/autoload.php"); +require_once("vendor/autoload.php"); +require_once("common/config.php"); + +$danger_alerts = array(); +$success_alerts = array(); + +$vattempted = false; +if (isset($_GET["un"], $_GET["vcode"])) { + $vattempted = true; + try { + $m = DBMember::load_by($db, "username", $_GET["un"]); + if ($m->validation_code == $_GET["vcode"]) { + $st = $db->conn->prepare("UPDATE members SET validated=true WHERE userid = ?"); + $success = $st->execute(array($m->userid)); + if ($success) { + $success_alerts[] = 'Successfully validated your email address, <a href="/">Continue</a>'; + } else { + $einfo = $st->errorInfo(); + error_log("mcoop: validate.php failed updating members: " . var_export($einfo, true) . " ($m->userid)"); + $danger_alerts[] = "Failed to update the database to validate your email address, this is an internal error, please contact the admin"; + } + } else { + $danger_alerts[] = "Unable to validate email: incorrect validation code"; + } + } catch (UnknownMember $un) { + $danger_alerts[] = "Unable to validate email: no such user"; + } +} + +echo $twig->render("validate.tmpl", array( + "danger_alerts" => $danger_alerts, + "success_alerts" => $success_alerts, + "sess_info" => $sess_info, + "vattempted" => $vattempted +)); + +?> |