diff options
author | Henry Sudhof <kellanved@phpbb.com> | 2009-07-06 13:10:05 +0000 |
---|---|---|
committer | Henry Sudhof <kellanved@phpbb.com> | 2009-07-06 13:10:05 +0000 |
commit | 3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb (patch) | |
tree | 729ac8efaec86e6c15f21dd4bb3eafd78fcb5833 /phpBB/includes/acp/acp_main.php | |
parent | 2854705096a5029295ab99fa9fcf063661fc2cbc (diff) | |
download | forums-3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb.tar forums-3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb.tar.gz forums-3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb.tar.bz2 forums-3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb.tar.xz forums-3f7ab4b8a6759374bc48c2ee5b8c88d1b695f0eb.zip |
Add a purge option for the session table to the acp. Seems that many boards get unusable due to styles not embedding the cron image and/or extremely long session timeout settings and/or DOS attacks. This new button can be a stopgap measure in those cases.
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9714 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/acp/acp_main.php')
-rw-r--r-- | phpBB/includes/acp/acp_main.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 5d6bd40681..42f6aa0b8e 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -97,6 +97,10 @@ class acp_main $confirm = true; $confirm_lang = 'PURGE_CACHE_CONFIRM'; break; + case 'purge_sessions': + $confirm = true; + $confirm_lang = 'PURGE_SESSIONS_CONFIRM'; + break; default: $confirm = true; @@ -341,6 +345,44 @@ class acp_main add_log('admin', 'LOG_PURGE_CACHE'); break; + + case 'purge_sessions': + if ((int) $user->data['user_type'] !== USER_FOUNDER) + { + trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); + + // DELETE would probably take a lot longer if we're dealing with a runaway table + foreach ($tables as $table) + { + $sql = "TRUNCATE TABLE $table"; + $db->sql_query($sql); + } + + // let's restore the admin session + $reinsert_ary = array( + 'session_id' => (string) $user->session_id, + 'session_page' => (string) substr($user->page['page'], 0, 199), + 'session_forum_id' => $user->page['forum'], + 'session_user_id' => (int) $user->data['user_id'], + 'session_start' => (int) $user->data['session_start'], + 'session_last_visit' => (int) $user->data['session_last_visit'], + 'session_time' => (int) $user->time_now, + 'session_browser' => (string) trim(substr($user->browser, 0, 149)), + 'session_forwarded_for' => (string) $user->forwarded_for, + 'session_ip' => (string) $user->ip, + 'session_autologin' => (int) $user->data['session_autologin'], + 'session_admin' => 1, + 'session_viewonline' => (int) $user->data['session_viewonline'], + ); + + $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); + $db->sql_query($sql); + + add_log('admin', 'LOG_PURGE_SESSIONS'); + break; } } } |