query($sql); $first_name = NULL; $last_name = NULL; $username = NULL; $note = NULL; $email = NULL; if ($res->fetchColumn() > 0) { $sql = "SELECT first_name, last_name, username, note, email FROM registrations WHERE admin_token = '" . $token . "' LIMIT 1;"; foreach ($db->query($sql) as $row) { // will only be executed once $first_name = $row["first_name"]; $last_name = $row["last_name"]; $username = $row["username"]; $note = $row["note"]; $email = $row["email"]; } } else { throw new Exception($language["UNKNOWN_TOKEN"]); } if ($action == RegisterState::RegistrationAccepted) { $db->exec("UPDATE registrations SET state = " . RegisterState::RegistrationAccepted) . " WHERE admin_token = \"" . $token. "\";"); // register user require_once("MatrixConnection.php"); $mxConn = new MatrixConnection($homeserver, $access_token); // generate a password with 8 characters $password = bin2hex(openssl_random_pseudo_bytes(4)); $res = $mxConn->register($username, $password, $shared_secret); // send registration_success send_mail_registration_success($homeserver, $first_name . " " . $last_name, $email, $username, $password, $howToURL) } elseif ($action == RegisterState::RegistrationDeclined) { $db->exec("UPDATE registrations SET state = " . RegisterState::RegistrationAccepted) . " WHERE admin_token = \"" . $token. "\";"); } $adminUrl = $webroot . "/admin_verify.php?t=" . $admin_token; print("