2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 $fetchtemplates = array(
17 define('SVN', '$Id$');
19 $focus['user
'] = 'focus
';
21 require_once('./global.php
');
23 // ###################################################################
25 if ($bugsys->userinfo['userid
'] AND $_REQUEST['do'] != 'logout
' AND $_POST['do'] != 'cplogin
' AND $_REQUEST['do'] != 'cplogout
')
27 $message->error('You are already logged in
.');
30 // ###################################################################
32 if (empty($_REQUEST['do']))
34 eval('$template->flush("' . $template->fetch('login') . '");');
37 // ###################################################################
39 if ($_POST['do'] == 'login
' OR $_POST['do'] == 'cplogin
')
41 $keeplogin = intval($bugsys->in['rememberme
']);
42 if ($_POST['cplogin
'])
47 if ($_SERVER['HTTP_REFERER
'] AND !$_POST['goindex
'])
49 $url = $_SERVER['HTTP_REFERER
'];
56 $userinfo = $db->query_first("SELECT * FROM user WHERE email = '" . $bugsys->in['email'] . "'");
57 if (md5(md5($bugsys->in['password
']) . md5($userinfo['salt
'])) == $userinfo['password
'])
59 if (!$bugsys->userinfo['userid
'])
61 $funct->cookie(COOKIE_PREFIX . 'userid
', $userinfo['userid
'], $keeplogin);
62 $funct->cookie(COOKIE_PREFIX . 'authkey
', $userinfo['authkey
'], $keeplogin);
65 if ($_POST['do'] == 'cplogin
')
67 $funct->cookie(COOKIE_PREFIX . 'adminsession
', md5(md5($userinfo['authkey
']) . md5($userinfo['email
']) . md5($userinfo['userid
'])), false);
72 if (!$bugsys->userinfo['userid
'])
74 $funct->cookie(COOKIE_PREFIX . 'userid
');
75 $funct->cookie(COOKIE_PREFIX . 'authkey
');
78 $message->error('Invalid email
or password
.');
81 $message->redirect('You are now logged in
:-)', $url);
84 // ###################################################################
86 if ($_REQUEST['do'] == 'logout
')
88 if ($bugsys->userinfo['userid
'])
90 $funct->cookie(COOKIE_PREFIX . 'userid
');
91 $funct->cookie(COOKIE_PREFIX . 'authkey
');
92 $funct->cookie(COOKIE_PREFIX . 'adminsession
');
96 $message->error('You need to be logged in
!');
100 // ###################################################################
102 if ($_REQUEST['do'] == 'cplogout
')
104 if ($_COOKIE[COOKIE_PREFIX . 'adminsession
'])
106 $funct->cookie(COOKIE_PREFIX . 'adminsession
');
107 $message->redirect('logged out
', 'admin
/');
111 $message->error('you are not logged in
');
115 /*=====================================================================*\
116 || ###################################################################
119 || ###################################################################
120 \*=====================================================================*/