summaryrefslogtreecommitdiff
path: root/validate.php
diff options
context:
space:
mode:
authorKyle McFarland <tfkyle@gmail.com>2018-01-31 00:51:07 -0600
committerKyle McFarland <tfkyle@gmail.com>2018-01-31 00:51:07 -0600
commit61d1aa04d8d44b17bfe6dace90088669fc6c3df8 (patch)
tree7ede15c880e4c41a18cded46fe6d03fb2dc4543b /validate.php
downloadmcoop-master.zip
mcoop-master.tar.gz
mcoop-master.tar.bz2
Initial importHEADmaster
* Registration system's almost done * Just part way through implementing tasks So not much done yet, but it's a start.
Diffstat (limited to 'validate.php')
-rw-r--r--validate.php40
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
+));
+
+?>