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
This commit is contained in:
Henry Sudhof 2009-07-06 13:10:05 +00:00
parent 2854705096
commit 3f7ab4b8a6
3 changed files with 54 additions and 0 deletions

View file

@ -143,6 +143,12 @@
<dd><input type="hidden" name="action" value="purge_cache" /><input class="button2" type="submit" id="action_purge_cache" name="action_purge_cache" value="{L_RUN}" /></dd>
</dl>
</form>
<form id="action_purge_cache_form" method="post" action="{U_ACTION}">
<dl>
<dt><label for="action_purge_cache">{L_PURGE_SESSIONS}</label><br /><span>{L_PURGE_SESSIONS_EXPLAIN}</span></dt>
<dd><input type="hidden" name="action" value="purge_sessions" /><input class="button2" type="submit" id="action_purge_sessions" name="action_purge_sessions" value="{L_RUN}" /></dd>
</dl>
</form>
<!-- ENDIF -->
</fieldset>
<!-- ENDIF -->

View file

@ -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;
}
}
}

View file

@ -136,6 +136,7 @@ $lang = array_merge($lang, array(
'ACP_PERMISSION_TRACE' => 'Permission trace',
'ACP_PHP_INFO' => 'PHP information',
'ACP_POST_SETTINGS' => 'Post settings',
'ACP_PRUNE_ATTACHMENTS' => 'Prune attachments',
'ACP_PRUNE_FORUMS' => 'Prune forums',
'ACP_PRUNE_USERS' => 'Prune users',
'ACP_PRUNING' => 'Pruning',
@ -339,6 +340,10 @@ $lang = array_merge($lang, array(
'PURGE_CACHE_CONFIRM' => 'Are you sure you wish to purge the cache?',
'PURGE_CACHE_EXPLAIN' => 'Purge all cache related items, this includes any cached template files or queries.',
'PURGE_SESSIONS' => 'Purge all sessions',
'PURGE_SESSIONS_CONFIRM' => 'Are you sure you wish to purge all sessions? This will log out all users.',
'PURGE_SESSIONS_EXPLAIN' => 'Purge all sessions. This will log out all users by truncating the session table.',
'RESET_DATE' => 'Reset boards start date',
'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the boards start date?',
'RESET_ONLINE' => 'Reset most users ever online',
@ -611,6 +616,7 @@ $lang = array_merge($lang, array(
'LOG_PROFILE_FIELD_REMOVED' => '<strong>Profile field removed</strong><br />» %s',
'LOG_PRUNE' => '<strong>Pruned forums</strong><br />» %s',
'LOG_PRUNE_ATTACHMENTS' => '<strong>Pruned attachments</strong>',
'LOG_AUTO_PRUNE' => '<strong>Auto-pruned forums</strong><br />» %s',
'LOG_PRUNE_USER_DEAC' => '<strong>Users deactivated</strong><br />» %s',
'LOG_PRUNE_USER_DEL_DEL' => '<strong>Users pruned and posts deleted</strong><br />» %s',