forked from exflickr/flamework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
108 lines (73 loc) · 1.53 KB
/
signup.php
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?
#
# $Id$
#
include("include/init.php");
if (!$GLOBALS['cfg']['enable_feature_signup']){
$smarty->display('page_signup_disabled.txt');
exit;
}
login_ensure_loggedout();
#
# carry this argument through
#
$smarty->assign('redir', request_str('redir'));
#
# are we signing up?
#
if (post_str('signup')){
$ok = 1;
$email = post_str('email');
$password = post_str('password');
$username = post_str('username');
$redir = post_str('redir');
$smarty->assign('email', $email);
$smarty->assign('password', $password);
$smarty->assign('username', $username);
$smarty->assign('redir', $redir);
#
# all fields are in order?
#
if ((!strlen($email)) || (!strlen($password)) || (!strlen($username))){
$smarty->assign('error_missing', 1);
$ok = 0;
}
#
# email available?
#
if ($ok && users_is_email_taken($email)){
$smarty->assign('email', '');
$smarty->assign('error_email_taken', 1);
$ok = 0;
}
#
# username available?
#
if ($ok && users_is_username_taken($username)){
$smarty->assign('username', '');
$smarty->assign('error_username_taken', 1);
$ok = 0;
}
#
# create account
#
if ($ok){
$user = users_create_user(array(
'username' => $username,
'email' => $email,
'password' => $password,
));
if ($user['id']){
$redir = strlen($redir) ? $redir : '/';
login_do_login($user, $redir);
exit;
}
$smarty->assign('error_failed', 1);
$ok = 0;
}
}
#
# output
#
$smarty->display('page_signup.txt');
?>