Rev 495 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
169 | tom | 1 | <?php |
2 | |||
3 | require '_taios.php'; |
||
4 | |||
5 | $page = new Taios_Page('Login'); |
||
6 | |||
7 | $username = $_POST['username']; |
||
8 | $password = $_POST['password']; |
||
9 | $remember = $_POST['remember'] == 'yes'; |
||
10 | |||
483 | muzer | 11 | if(strpos($_POST['oldurl'], "tim32.org") === FALSE || strpos($_POST['oldurl'], "login") !== FALSE) |
12 | $redirurl = "http://tim32.org"; |
||
13 | else |
||
14 | $redirurl = $_POST['oldurl']; |
||
15 | |||
169 | tom | 16 | if (empty($username)) |
17 | { |
||
483 | muzer | 18 | $page->redirect('login.php?error=No Username Specified&oldurl=' . urlencode($redirurl)); |
169 | tom | 19 | } |
20 | if (empty($password)) |
||
21 | { |
||
483 | muzer | 22 | $page->redirect('login.php?error=No Password Specified&oldurl=' . urlencode($redirurl)); |
169 | tom | 23 | } |
24 | |||
25 | $user = $page->getUserByUsername($username); |
||
500 | freddie | 26 | if (!$user || $user->password !== $page->saltAndBurn($password, $user->salt)) |
169 | tom | 27 | { |
483 | muzer | 28 | $page->redirect('login.php?error=Incorrect Username or Password&oldurl=' . urlencode($redirurl)); |
169 | tom | 29 | } |
30 | |||
31 | $expires = -1; |
||
32 | |||
33 | if ($remember) |
||
34 | { |
||
35 | $expires = time() + 60 * 60 * 24 * 30; |
||
36 | } |
||
37 | |||
38 | setcookie('Tim32_Login', $user->username . '|~|' . $user->password, $expires, '/'); |
||
39 | |||
483 | muzer | 40 | $page->redirect($redirurl); |
169 | tom | 41 | |
42 | ?> |