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 require_once('./global.php');
19 // ###################################################################
21 if ($bugsys->userinfo
['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin' AND $_REQUEST['do'] != 'cplogout')
23 $message->error('You are already logged in.');
26 // ###################################################################
28 if (empty($_REQUEST['do']))
30 eval('$template->flush("' . $template->fetch('login') . '");');
33 // ###################################################################
35 if ($_POST['do'] == 'login' OR $_POST['do'] == 'cplogin')
37 $keeplogin = intval($bugsys->in
['rememberme']);
38 if ($_POST['cplogin'])
43 if ($_SERVER['HTTP_REFERER'] AND !$_POST['goindex'])
45 $url = $_SERVER['HTTP_REFERER'];
52 $userinfo = $db->query_first("SELECT * FROM user WHERE email = '" . $bugsys->in
['email'] . "'");
53 if (md5(md5($bugsys->in
['password']) . md5($userinfo['salt'])) == $userinfo['password'])
55 if (!$bugsys->userinfo
['userid'])
57 $funct->cookie(COOKIE_PREFIX
. 'userid', $userinfo['userid'], $keeplogin);
58 $funct->cookie(COOKIE_PREFIX
. 'authkey', $userinfo['authkey'], $keeplogin);
61 if ($_POST['do'] == 'cplogin')
63 $funct->cookie(COOKIE_PREFIX
. 'adminsession', md5(md5($userinfo['authkey']) . md5($userinfo['email']) . md5($userinfo['userid'])), false
);
68 if (!$bugsys->userinfo
['userid'])
70 $funct->cookie(COOKIE_PREFIX
. 'userid');
71 $funct->cookie(COOKIE_PREFIX
. 'authkey');
74 $message->error('Invalid email or password.');
78 echo 'You are now logged in :-)';
80 header("Location: $url");
83 // ###################################################################
85 if ($_REQUEST['do'] == 'logout')
87 if ($bugsys->userinfo
['userid'])
89 $funct->cookie(COOKIE_PREFIX
. 'userid');
90 $funct->cookie(COOKIE_PREFIX
. 'authkey');
91 $funct->cookie(COOKIE_PREFIX
. 'adminsession');
95 $message->error('You need to be logged in!');
99 // ###################################################################
101 if ($_REQUEST['do'] == 'cplogout')
103 if ($_COOKIE[COOKIE_PREFIX
. 'adminsession'])
105 $funct->cookie(COOKIE_PREFIX
. 'adminsession');
110 echo 'you are not logged in';
114 /*=====================================================================*\
115 || ###################################################################
118 || ###################################################################
119 \*=====================================================================*/