From 5ce46cc9603ccc153bf26168b18afee0f3b645af Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Sat, 31 Mar 2012 00:16:28 +0530 Subject: [PATCH] [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/info/ucp_profile.php | 1 + phpBB/includes/ucp/ucp_profile.php | 40 +++++++++++++++++ phpBB/language/en/ucp.php | 4 ++ .../template/ucp_profile_autologin_keys.html | 45 +++++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html diff --git a/phpBB/includes/ucp/info/ucp_profile.php b/phpBB/includes/ucp/info/ucp_profile.php index 09c0318de9..968538a178 100644 --- a/phpBB/includes/ucp/info/ucp_profile.php +++ b/phpBB/includes/ucp/info/ucp_profile.php @@ -23,6 +23,7 @@ class ucp_profile_info 'signature' => array('title' => 'UCP_PROFILE_SIGNATURE', 'auth' => '', 'cat' => array('UCP_PROFILE')), 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)', 'cat' => array('UCP_PROFILE')), 'reg_details' => array('title' => 'UCP_PROFILE_REG_DETAILS', 'auth' => '', 'cat' => array('UCP_PROFILE')), + 'autologin_keys'=> array('title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', 'auth' => '', 'cat' => array('UCP_PROFILE')), ), ); } 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( diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 2212e44628..1e36b4e9f7 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -87,6 +87,7 @@ $lang = array_merge($lang, array( 'ATTACHMENTS_EXPLAIN' => 'This is a list of attachments you have made in posts to this board.', 'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.', 'ATTACHMENT_DELETED' => 'Attachment successfully deleted.', + 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected auto-login session keys were successfully deleted.', 'AVATAR_CATEGORY' => 'Category', 'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$s, height: %2$s, file size: %3$.2f KiB.', 'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.', @@ -376,6 +377,8 @@ $lang = array_merge($lang, array( 'PREFERENCES_UPDATED' => 'Your preferences have been updated.', 'PROFILE_INFO_NOTICE' => 'Please note that this information may be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', 'PROFILE_UPDATED' => 'Your profile has been updated.', + 'PROFILE_AUTOLOGIN_KEYS' => 'The auto-login session keys can be selected and deleted.', + 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved auto-login session keys.', 'RECIPIENT' => 'Recipient', 'RECIPIENTS' => 'Recipients', @@ -465,6 +468,7 @@ $lang = array_merge($lang, array( 'UCP_PROFILE_PROFILE_INFO' => 'Edit profile', 'UCP_PROFILE_REG_DETAILS' => 'Edit account settings', 'UCP_PROFILE_SIGNATURE' => 'Edit signature', + 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Edit auto-login session keys', 'UCP_USERGROUPS' => 'Usergroups', 'UCP_USERGROUPS_MEMBER' => 'Edit memberships', diff --git a/phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html b/phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html new file mode 100644 index 0000000000..ad7b7a920d --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html @@ -0,0 +1,45 @@ + + +
+ +

{L_TITLE}

+
+
+ +
+

{ERROR}

+ +

{L_PROFILE_AUTOLOGIN_KEYS}

+ + + + + + + + + + + + + + + +
KeyIPLogin-Time
{sessions.KEY}{sessions.IP}{sessions.LOGIN_TIME}
+ +

{L_PROFILE_NO_AUTOLOGIN_KEYS}

+ +
+
+
+ + +
+ {S_HIDDEN_FIELDS}  + + {S_FORM_TOKEN} +
+ +
+ +