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
|
<?php
/*
* SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* For more information, please refer to UNLICENSE
*/
require_once "class/form.class.php";
require_once "class/user.class.php";
require_once "class/settings.class.php";
/*
* Action: login - Attempt to authenticate new user
*/
if (isAction("login"))
{
$form = new form();
$form->text("uname");
$form->text("passwd", false);
if (!$form->populate(input()))
goto prep;
if (!(($user = user::getByUname($form->uname)) &&
$user->validatePasswd($form->passwd)))
{
logError(ERROR, "Username or password is incorrect");
if ($user)
$log = mesg::initNewAdminLog("Failed login for username '%s'", $user);
goto prep;
}
user::setCurrent($user);
location();
}
/*
* Action: signup - Attempt to register a new account
*/
if (isAction("signup"))
{
if (!settings::allowPublicSignup() &&
count(user::getAll_ordByUname()) > 0)
{
logError(ERROR, "You may not signup at this time");
goto prep;
}
$form = new form();
$form->text("uname");
$form->text("passwd", false);
$form->text("cpasswd", false);
if (!$form->populate(input()))
goto prep;
if ($form->passwd != $form->cpasswd)
{
logError(ERROR, "Passwords do not match");
goto prep;
}
if (!($user = user::initNew($form->uname, $form->passwd)))
{
logError(ERROR, "Your requested username is already in use");
goto prep;
}
user::setCurrent($user);
$log = mesg::initNewAdminLog("%s account registered", $user);
location("/");
}
prep:
if (count(user::getAll_ordByUname()) == 0)
{
$noaccounts = true;
$activeTab['signup'] = "in active";
$tabSwap = false;
}
else
{
$activeTab['login'] = "in active";
$tabSwap = settings::allowPublicSignup();
}
?>
|