summaryrefslogtreecommitdiff
path: root/www/register.php
blob: aa5dffed5f8efafd0c21c0b35feea11dca4bed99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/*
	Displays the register page and possible errors. Users specify their username and password and email address to register. As this page is invite-only users must enter their invite-key aswell.
	
	It has already been checked that the user isn't already logged in.
	
	$case can have the following values:
	
		REGISTER_PASSWORD: Specifies that the password wasn't the same in both fields. The user is not registered.
		
		REGISTER_DATABASE: Specifies that the request could not be fullfilled due to a database error. The user is not registered.
		
		REGISTER_EMAIL: Specifies that the request could not be fullfilled due to invalid symbols in the password.
		
		REGISTER_PROHIBITED: Specifies that the request could not be fullfilled because the account has been marked "blocked"
		
		REGISTER_INVITEKEY: Specifies that the request could not be fullfilled because the invitekey does not match the database entry.
	
		REGISTER_USERNAME: Specifies that the request could not be fullfilled because the username already exists.

==================================================================================================================================================

*/

function print_register($case){
	include("static/header.html");
	
	$username = (isset($_POST["username"]) && $case != REGISTER_USERNAME)? $_POST["username"] : "";
	
	$email = (isset($_POST["email"]) && $case != REGISTER_EMAIL)? $_POST["email"] : "";
	
	$invite_key = (isset($_POST["key"]) && $case != REGISTER_INVITEKEY)? $_POST["key"] : "";
	
	$message = "";
	
	switch($case){
		case(REGISTER_PASSWORD):
			$message = '<h1 id="register-error">Passwords don&#39t match</h1>
					';
			break;
		case(REGISTER_DATABASE):
			$message = '<h1 id="register-error">Internal Error. Please contact admin</h1>
					';
			break;
		case(REGISTER_EMAIL):
			$message = '<h1 id="register-error">This is not a valid email address</h1>
					';
			break;
		case(REGISTER_PROHIBITED):
			$message = '<h1 id="register-error">Activation of your account is prohibited</h1>
					';
			break;
		case(REGISTER_INVITEKEY):
			$message = '<h1 id="register-error">Your invite-key is not correct.</h1>
					';
			break;
		case(REGISTER_USERNAME):
			$message = '<h1 id="register-error">This username is already in use</h1>
					';
			break;
	}


	echo '<link rel="stylesheet" type="text/css" href="/static/register.css">
	
	<div class="register-area">
		<h1 class="register-area"> Register </h1>
		<div class="register-area" id="register-info-bar">'
		.$message.
		'</div>
		<form id="register-form" action="/register" method="post">
			<input type="text" placeholder="username" name="username" id="username-input" class="register-input" value="'.$username.'" required>
			
			<input type="password" placeholder="password" name="pswd" id="password-input" class="register-input" required>
			<input type="password" placeholder="repeat password" name="2ndpswd" id="password-repeat-input" class="register-input" required>
			
			<input type="text" placeholder="invite-key" name="key" id="key-input" class="register-input"  value="'.$invite_key.'"required>
			<input type="email" placeholder="email" name="email" id="email-input" class="register-input" value="'.$email.'"required>
			
			<input type="submit" name="register" id="button-input" class="register-input" value="register">
		</form>
	</div>';
	include("static/footer.html");
}