session_start();
if(isset($_REQUEST["q"])) {
- $query = $_REQUEST["q"];
- if($query == "login") return "gwvp_AuthHandleLogin";
- if($query == "logout") return "gwvp_AuthHandleLogout";
- if($query == "register") return "gwvp_RegistrationCall";
+ $query = explode("/", $_REQUEST["q"]);
+ if($query[0] == "login") return "gwvp_AuthHandleLogin";
+ if($query[0] == "logout") return "gwvp_AuthHandleLogout";
+ if($query[0] == "register") {
+ if(isset($query[1])) {
+ return "qwvp_attemptRegistration";
+ }
+ return "gwvp_RegistrationCall";
+ }
}
$login = gwvp_isLoggedIn();
function gwvp_RegistrationPageBody()
{
+ global $BASE_URL;
+
+ // TODO: registration page needs to be prettier - mostly the image for the captcha
+
?>
-<form method="post">
+<form method="post" action="<?php echo $BASE_URL?>/register/try">
<table>
<tr>
<td>Name</td>
<td><input name="name" type="text"></td>
<td>Your Full Name</td>
+ <td rowspan="4">
+ <?php if(gwvp_haveCaptcha()) {?>
+ <img id="captcha" src="<?php echo $BASE_URL?>/securimage/" alt="CAPTCHA Image" /><br>
+ <input type="text" name="captcha_code" size="10" maxlength="6" />
+ <a href="#" onclick="document.getElementById('captcha').src = '<?php echo $BASE_URL?>/securimage/' + Math.random(); return false">[ Different Image ]</a>
+ <?php } ?>
+ </td>
</tr>
<tr>
<td>Email</td>
<td><input name="username" type="text"></td>
<td>The Name Used to Refer to you on the site</td>
</tr>
+
+
<tr>
<td><input type="submit" name="register" value="Register"></td>
</tr>
<?php
}
+function qwvp_attemptRegistration()
+{
+ if(gwvp_haveCaptcha()) {
+ $securimage = new Securimage();
+ if ($securimage->check($_POST['captcha_code']) == false) {
+ // the code was incorrect
+ // you should handle the error so that the form processor doesn't continue
+
+ // or you can use the following code if there is no validation or you do not know how
+ echo "The security code entered was incorrect.<br /><br />";
+ echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again.";
+ } else {
+ echo "code was right";
+ }
+
+ }
+}
+
function gwvp_checkBasicAuthLogin()
{
$user = false;