blob: 691e26e2862f1300c96bf75d9ebab7f144a5bf1c (
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
|
<?
require_once("../include/Namespace.inc");
require_once("../include/Tools.inc");
require_once("../include/Template.inc");
$namespace = new Namespace(
array( have_database => 1,
have_session => 1,
have_user => 1 )
) or
die("Nobody loves me. I don't even have space for a name.");
$rules = Array();
$rules['auth']['password'] = array(type => 'string');
$rules['auth']['username'] = array(type => 'string');
$rules['auth']['goto'] = array(type => 'string', optional => 1);
$rules['login']['goto'] = array(type => 'string', optional => 1);
$rules['login']['username'] = array(type => 'string', optional => 1);
$rules['login']['message'] = array(type => 'string', optional => 1);
$arguments = param_check($GLOBALS, $rules, array(params_required=>false));
$message = $arguments['message'];
$logged_in = 0;
if ( $arguments['form_id']=='auth' ) {
$namespace->session->set_id();
$result = $namespace->user->do_login( $arguments['username'], $arguments['password']);
if ($result)
$logged_in = 1;
else
$message = 'Invalid username/password pair.';
}
if (! $logged_in ) {
$data = array();
$data['goto'] = $arguments['goto'];
$data['message'] = $message;
$data['username'] = $namespace->session->data['user']['username'];
$data['username_field'] = $arguments['username'];
$template = new Template('login.html', $namespace->config->template_path);
$template->parse($data);
print $template->output();
} else {
if ($arguments['goto'])
redirect($namespace, $arguments['goto']);
else
redirect($namespace, './');
}
$namespace->stop();
# vim:set ts=4:
# vim:set shiftwidth=4:
?>
|