|
From: Benjamin C. <bc...@us...> - 2002-03-20 20:03:22
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv11849
Modified Files:
include.php
Log Message:
Reworked user authentication and added "Remember me" functionality
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- include.php 20 Mar 2002 15:09:18 -0000 1.100
+++ include.php 20 Mar 2002 20:03:17 -0000 1.101
@@ -97,9 +97,9 @@
class templateclass extends Template {
function pparse($target, $handle, $append = false) {
- global $auth, $perm, $db;
+ global $_sv, $perm, $db, $HTTP_COOKIE_VARS;
- $u = isset($auth->auth['uid']) ? $auth->auth['uid'] : 0;
+ $u = isset($_sv['uid']) ? $_sv['uid'] : 0;
$this->set_block('wrap', 'logoutblock', 'loblock');
$this->set_block('wrap', 'loginblock', 'liblock');
$this->set_block('wrap', 'adminnavblock', 'anblock');
@@ -113,7 +113,7 @@
."from ".TBL_BUG." b left join ".TBL_STATUS." s using(status_id) where created_by = $u",
DB_FETCHMODE_ORDERED);
$this->set_var(array(
- 'loggedinas' => $auth->auth['uname'],
+ 'loggedinas' => $_sv['uname'],
'liblock' => '',
'owner_open' => $owner_open ? $owner_open : 0,
'owner_closed' => $owner_closed ? $owner_closed : 0,
@@ -122,11 +122,31 @@
));
$this->parse('loblock', 'logoutblock', true);
} else {
+ $this->set_block('loginblock', 'cookieblock', 'ckblock');
$this->set_var(array(
'loggedinas' => '',
'loblock' => '',
'loginlabel' => EMAIL_IS_LOGIN ? 'Email' : 'Login'
));
+ if (RECALL_LOGIN) {
+ if (!empty($HTTP_COOKIE_VARS['phpbt_user'])) {
+ $this->set_var(array(
+ 'cookielogin' => $HTTP_COOKIE_VARS['phpbt_user'],
+ 'cookiechecked' => 'checked'
+ ));
+ } else {
+ $this->set_var(array(
+ 'cookielogin' => '',
+ 'cookiechecked' => ''
+ ));
+ }
+ $this->parse('ckblock', 'cookieblock', true);
+ } else {
+ $this->set_var(array(
+ 'cookielogin' => '',
+ 'ckblock' => ''
+ ));
+ }
$this->parse('liblock', 'loginblock', true);
}
if (isset($perm) && $perm->have_perm('Administrator')) {
@@ -161,7 +181,7 @@
$_sv =& $HTTP_SESSION_VARS;
$auth = new uauth;
$perm = new uperm;
- $u = isset($auth->auth['uid']) ? $auth->auth['uid'] : 0;
+ $u = isset($_sv['uid']) ? $_sv['uid'] : 0;
}
// Check to see if the user is trying to login
@@ -186,6 +206,17 @@
$t->set_var('loginerror', '<div class="error">Invalid login</div>');
}
}
+
+ // "Remember me" handling
+ if (RECALL_LOGIN) {
+ if (!empty($_pv["savecookie"])) {
+ setcookie('phpbt_user', $_pv["username"], $now + 18144000); // 3 week expiration
+ } elseif (!empty($HTTP_COOKIE_VARS['phpbt_user'])) {
+ // Clear the cookie if the cookie is populated and the box wasn't checked
+ setcookie('phpbt_user');
+ }
+ }
+
}
$op = isset($_gv['op']) ? $_gv['op'] : (isset($_pv['op']) ? $_pv['op'] : '');
@@ -196,7 +227,7 @@
if (!$perm->have_perm('Admin')) {
$viewable_projects = delimit_list(',',
$db->getCol("select project_id from ".TBL_PROJECT_GROUP.
- " where group_id in (".delimit_list(',', $auth->auth['group_ids']).")"));
+ " where group_id in (".delimit_list(',', $_sv['group_ids']).")"));
$viewable_projects = $viewable_projects ? $viewable_projects : '0';
$matching_projects = delimit_list(',',
$db->getCol("select project_id from ".TBL_PROJECT_GROUP.
|