From 5ce46cc9603ccc153bf26168b18afee0f3b645af Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Sat, 31 Mar 2012 00:16:28 +0530 Subject: [feature/delete-auto-logins] User can view/delete auto logins. User has an extra option in UCP->Profile to view the auto logins and clear them. PHPBB3-9647 --- phpBB/includes/ucp/ucp_profile.php | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'phpBB/includes/ucp/ucp_profile.php') diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 9d81503f0a..f3e0984685 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -618,6 +618,46 @@ class ucp_profile } break; + + case 'autologin_keys': + + add_form_key('ucp_autologin_keys'); + + if ($submit) + { + $keys = request_var('keys', array('')); + + if (!empty($keys)) + { + $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' + WHERE user_id = ' . (int) $user->data['user_id'] . ' + AND ' . $db->sql_in_set('key_id', $keys) ; + + $db->sql_query($sql); + + $message = $user->lang['AUTOLOGIN_SESSIONS_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + trigger_error($message); + } + } + + $sql = 'SELECT key_id, last_ip, last_login + FROM ' . SESSIONS_KEYS_TABLE . ' + WHERE user_id = ' . (int) $user->data['user_id']; + + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $template->assign_block_vars('sessions', array( + 'KEY' => $row['key_id'], + 'IP' => $row['last_ip'], + 'LOGIN_TIME' => $row['last_login'], + )); + } + + $db->sql_freeresult($result); + + break; } $template->assign_vars(array( -- cgit v1.2.1 From 79ef96043546074e19bf849e7a58279b3b463c1a Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Sat, 31 Mar 2012 18:27:34 +0530 Subject: [feature/delete-auto-logins] Fixes language entries and redirection. The user is redirected after deleting auto login session keys. PHPBB3-9647 --- phpBB/includes/ucp/ucp_profile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/ucp/ucp_profile.php') diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index f3e0984685..2595e48fb5 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -635,7 +635,8 @@ class ucp_profile $db->sql_query($sql); - $message = $user->lang['AUTOLOGIN_SESSIONS_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + meta_refresh(3, $this->u_action); + $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); trigger_error($message); } } -- cgit v1.2.1 From 4129711e9f9b67ea102594254434f6210cd03e81 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Sun, 1 Apr 2012 16:57:46 +0530 Subject: [feature/delete-auto-logins] checks form key The form key is checked after submission if not correct error is returned. PHPBB3-9647 --- phpBB/includes/ucp/ucp_profile.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/ucp/ucp_profile.php') diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 2595e48fb5..d4e5d75c10 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -627,18 +627,29 @@ class ucp_profile { $keys = request_var('keys', array('')); - if (!empty($keys)) + if (!check_form_key('ucp_autologin_keys')) { - $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' - WHERE user_id = ' . (int) $user->data['user_id'] . ' - AND ' . $db->sql_in_set('key_id', $keys) ; + $error[] = 'FORM_INVALID'; + } - $db->sql_query($sql); + if (!sizeof($error)) + { + if (!empty($keys)) + { + $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' + WHERE user_id = ' . (int) $user->data['user_id'] . ' + AND ' . $db->sql_in_set('key_id', $keys) ; - meta_refresh(3, $this->u_action); - $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + trigger_error($message); + } } + + // Replace "error" strings with their real, localised form + $error = array_map(array($user, 'lang'), $error); } $sql = 'SELECT key_id, last_ip, last_login @@ -650,6 +661,8 @@ class ucp_profile while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('sessions', array( + 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', + 'KEY' => $row['key_id'], 'IP' => $row['last_ip'], 'LOGIN_TIME' => $row['last_login'], -- cgit v1.2.1 From bdf66b27ab6e46cfb1978feb05b13c83c9bd9597 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Wed, 11 Apr 2012 03:34:29 +0530 Subject: [feature/delete-auto-logins] using loop for errors instead of hardcoding html code into ERROR variable, we use errors array and use loop in template file. PHPBB3-9647 --- phpBB/includes/ucp/ucp_profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/ucp/ucp_profile.php') diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index d4e5d75c10..a7b6eb29a1 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -661,7 +661,7 @@ class ucp_profile while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('sessions', array( - 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', + 'errors' => $error, 'KEY' => $row['key_id'], 'IP' => $row['last_ip'], -- cgit v1.2.1 From 71f84164805293a2ab5c70ec49799ee8bfa5eac3 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Fri, 13 Apr 2012 21:29:31 +0530 Subject: [feature/delete-auto-logins] improved styling and fixes language Table ahs been styled. Date is now formatted properly instead of the unix timestamp being displayed earlier. fixes small mistake in language entry PHPBB3-9647 --- phpBB/includes/ucp/ucp_profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/ucp/ucp_profile.php') diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a7b6eb29a1..2ac82fb52f 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -665,7 +665,7 @@ class ucp_profile 'KEY' => $row['key_id'], 'IP' => $row['last_ip'], - 'LOGIN_TIME' => $row['last_login'], + 'LOGIN_TIME' => $user->format_date($row['last_login']), )); } -- cgit v1.2.1