2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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($lang->string('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(gmdate('F j
, Y
@ H
'))), false);
72 if (!$bugsys->userinfo['userid
'])
74 $funct->cookie(COOKIE_PREFIX . 'userid
');
75 $funct->cookie(COOKIE_PREFIX . 'authkey
');
78 $message->error($lang->string('Invalid email
or password
.'));
81 $message->redirect($lang->string('Welcome back
! 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
');
93 $message->redirect($lang->string('You have been logged out
.'), 'index
.php
');
97 $message->error($lang->string('You need to be logged in to access this feature
.'));
101 // ###################################################################
103 if ($_REQUEST['do'] == 'cplogout
')
105 if ($_COOKIE[COOKIE_PREFIX . 'adminsession
'])
107 $funct->cookie(COOKIE_PREFIX . 'adminsession
');
108 $message->redirect($lang->string('You have been logged out
.'), 'admin
/');
112 $message->error($lang->string('You are not logged in
.'));
116 /*=====================================================================*\
117 || ###################################################################
120 || ###################################################################
121 \*=====================================================================*/