1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-05 05:55:15 +02:00
-Refactor the confirm table cleanup
-Add confirm table cleanup to session garbage collection. Might require own pseudo-cron.


git-svn-id: file:///svn/phpbb/trunk@8089 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Henry Sudhof 2007-09-13 15:15:27 +00:00
parent 685282c2cb
commit 052025bb1f
6 changed files with 66 additions and 41 deletions

View File

@ -206,6 +206,8 @@ p a {
<li>[Fix] Local magic URLs no longer get an additional trailing slash (Bug #14362)</li>
<li>[Fix] Do not let the cron script stale for one hour if register_shutdown_function is not able to be called (Bug #14436)</li>
<li>[Feature] Added /includes/db/db_tools.php file, which includes tools for handling cross-db actions such as altering columns, etc.</li>
<li>[Change] Reset the start parameter when the timeframe is changed in the mcp topic page (Ticket #14438)</li>
<li>[Change] Added Code for cleaning the confirm table to the session garbage collection</li>
</ul>
</div>

View File

@ -34,6 +34,7 @@ function mcp_topic_view($id, $mode, $action)
$icon_id = request_var('icon', 0);
$subject = utf8_normalize_nfc(request_var('subject', '', true));
$start = request_var('start', 0);
$sort_days_old = request_var('st_old', 0);
$forum_id = request_var('f', 0);
$to_topic_id = request_var('to_topic_id', 0);
$to_forum_id = request_var('to_forum_id', 0);
@ -104,6 +105,10 @@ function mcp_topic_view($id, $mode, $action)
{
$posts_per_page = $total;
}
if (!empty($sort_days_old) && $sort_days_old != $sort_days)
{
$start = 0;
}
$sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
@ -264,6 +269,10 @@ function mcp_topic_view($id, $mode, $action)
}
}
$s_hidden_fields = build_hidden_fields(array(
'st_old' => $sort_days,
));
$template->assign_vars(array(
'TOPIC_TITLE' => $topic_info['topic_title'],
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&amp;t=' . $topic_info['topic_id']),
@ -290,6 +299,8 @@ function mcp_topic_view($id, $mode, $action)
'S_MERGE_VIEW' => ($action == 'merge') ? true : false,
'S_SPLIT_VIEW' => ($action == 'split') ? true : false,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_SHOW_TOPIC_ICONS' => $s_topic_icons,
'S_TOPIC_ICON' => $icon_id,

View File

@ -746,6 +746,8 @@ class session
{
global $db, $config;
$batch_size = 10;
if (!$this->time_now)
{
$this->time_now = time();
@ -762,7 +764,7 @@ class session
FROM ' . SESSIONS_TABLE . '
WHERE session_time < ' . ($this->time_now - $config['session_length']) . '
GROUP BY session_user_id, session_page';
$result = $db->sql_query_limit($sql, 10);
$result = $db->sql_query_limit($sql, $batch_size);
$del_user_id = array();
$del_sessions = 0;
@ -788,12 +790,11 @@ class session
$db->sql_query($sql);
}
if ($del_sessions < 10)
if ($del_sessions < $batch_size)
{
// Less than 10 sessions, update gc timer ... else we want gc
// Less than 10 users, update gc timer ... else we want gc
// called again to delete other sessions
set_config('session_last_gc', $this->time_now, true);
}
if ($config['max_autologin_time'])
{
@ -801,10 +802,43 @@ class session
WHERE last_login < ' . (time() - (86400 * (int) $config['max_autologin_time']));
$db->sql_query($sql);
}
$this->confirm_gc();
}
return;
}
function confirm_gc($type = 0)
{
global $db, $config;
$sql = 'SELECT DISTINCT c.session_id
FROM ' . CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
WHERE s.session_id IS NULL' .
((empty($type)) ? '' : ' AND c.confirm_type = ' . (int) $type);
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$sql_in = array();
do
{
$sql_in[] = (string) $row['session_id'];
}
while ($row = $db->sql_fetchrow($result));
if (sizeof($sql_in))
{
$sql = 'DELETE FROM ' . CONFIRM_TABLE . '
WHERE ' . $db->sql_in_set('session_id', $sql_in);
$db->sql_query($sql);
}
}
$db->sql_freeresult($result);
}
/**
* Sets a cookie
*

View File

@ -427,30 +427,7 @@ class ucp_register
$str = '';
if (!$change_lang)
{
$sql = 'SELECT DISTINCT c.session_id
FROM ' . CONFIRM_TABLE . ' c
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
WHERE s.session_id IS NULL';
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$sql_in = array();
do
{
$sql_in[] = (string) $row['session_id'];
}
while ($row = $db->sql_fetchrow($result));
if (sizeof($sql_in))
{
$sql = 'DELETE FROM ' . CONFIRM_TABLE . '
WHERE ' . $db->sql_in_set('session_id', $sql_in) . '
AND confirm_type = ' . CONFIRM_REG;
$db->sql_query($sql);
}
}
$db->sql_freeresult($result);
$user->confirm_gc(CONFIRM_REG);
$sql = 'SELECT COUNT(session_id) AS attempts
FROM ' . CONFIRM_TABLE . "

View File

@ -163,6 +163,7 @@ onload_functions.push('subPanels()');
<div><a href="#" onclick="marklist('mcp', '', true); return false;">{L_MARK_ALL}</a> :: <a href="#" onclick="marklist('mcp', '', false); return false;">{L_UNMARK_ALL}</a></div>
</fieldset>
{S_HIDDEN_FIELDS}
</form>
<!-- INCLUDE mcp_footer.html -->

View File

@ -146,7 +146,7 @@
</select>&nbsp;<input class="btnmain" type="submit" name="mcp_topic_submit" value="{L_SUBMIT}" /></td>
</tr>
</table>
{S_HIDDEN_FIELDS}
</form>
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">