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 require_once('./global.php');
21 // ###################################################################
23 if ($bugsys->userinfo
['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin' AND $_REQUEST['do'] != 'cplogout')
25 $message->error('You are already logged in.');
28 // ###################################################################
30 if (empty($_REQUEST['do']))
32 eval('$template->flush("' . $template->fetch('login') . '");');
35 // ###################################################################
37 if ($_POST['do'] == 'login' OR $_POST['do'] == 'cplogin')
39 $keeplogin = intval($bugsys->in
['rememberme']);
40 if ($_POST['cplogin'])
45 if ($_SERVER['HTTP_REFERER'] AND !$_POST['goindex'])
47 $url = $_SERVER['HTTP_REFERER'];
54 $userinfo = $db->query_first("SELECT * FROM user WHERE email = '" . $bugsys->in
['email'] . "'");
55 if (md5(md5($bugsys->in
['password']) . md5($userinfo['salt'])) == $userinfo['password'])
57 if (!$bugsys->userinfo
['userid'])
59 $funct->cookie(COOKIE_PREFIX
. 'userid', $userinfo['userid'], $keeplogin);
60 $funct->cookie(COOKIE_PREFIX
. 'authkey', $userinfo['authkey'], $keeplogin);
63 if ($_POST['do'] == 'cplogin')
65 $funct->cookie(COOKIE_PREFIX
. 'adminsession', md5(md5($userinfo['authkey']) . md5($userinfo['email']) . md5($userinfo['userid'])), false
);
70 if (!$bugsys->userinfo
['userid'])
72 $funct->cookie(COOKIE_PREFIX
. 'userid');
73 $funct->cookie(COOKIE_PREFIX
. 'authkey');
76 $message->error('Invalid email or password.');
79 $message->redirect('You are now logged in :-)', $url);
82 // ###################################################################
84 if ($_REQUEST['do'] == 'logout')
86 if ($bugsys->userinfo
['userid'])
88 $funct->cookie(COOKIE_PREFIX
. 'userid');
89 $funct->cookie(COOKIE_PREFIX
. 'authkey');
90 $funct->cookie(COOKIE_PREFIX
. 'adminsession');
94 $message->error('You need to be logged in!');
98 // ###################################################################
100 if ($_REQUEST['do'] == 'cplogout')
102 if ($_COOKIE[COOKIE_PREFIX
. 'adminsession'])
104 $funct->cookie(COOKIE_PREFIX
. 'adminsession');
105 $message->redirect('logged out', 'admin/');
109 $message->error('you are not logged in');
113 /*=====================================================================*\
114 || ###################################################################
117 || ###################################################################
118 \*=====================================================================*/