Maybe it's your SMTP server that's slowing things down. Here's a short script that sends an email.
Code: Select all
<?php
// standard hack prevent
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'.$phpEx);
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$start_time = microtime(true);
// Send test e-mail
$messenger = new messenger();
$messenger->subject("Test Message");
$messenger->to('[email protected]', 'Admin');
$messenger->template("admin_send_email");
$messenger->assign_vars(array('MESSAGE' => "This is a test message. Please delete it."));
$messenger->send();
$elapsed_time = round((microtime(true) - $start_time), 2);
echo "Finished in $elapsed_time seconds";
?>
You are allowing people to subscribe to forums? Set up test group/user and set the forum permission for "Can subscribe forum" to no.
Code: Select all
UPDATE phpbb_topics_watch SET notify_status = 0 WHERE notify_status = 1;
UPDATE phpbb_forums_watch SET notify_status = 0 WHERE notify_status = 1;
phpbb_
change accordingly.Code: Select all
// Delete old watch list / forum watch list entries
$table_ary = array(TOPICS_TRACK_TABLE, FORUMS_TRACK_TABLE);
foreach ($table_ary as $table)
{
$sql = "DELETE FROM $table WHERE mark_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY))";
$db->sql_query($sql);
}
$sql = "DELETE FROM " . NOTIFICATIONS_TABLE . " WHERE notification_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY))";
$db->sql_query($sql);
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
WHERE
user_regdate < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY)) AND
user_lastvisit > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 YEAR)) AND
user_lastvisit < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY)) AND
user_type <> ' . USER_IGNORE . ' ORDER BY user_lastvisit ASC LIMIT 100';
$result = $db->sql_query($sql);
$users_data = array();
while ($row = $db->sql_fetchrow($result)) {
$users_data[$row['user_id']] = $row;
}
$db->sql_freeresult($result);
$table_ary = array(TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, TOPICS_TRACK_TABLE, FORUMS_TRACK_TABLE, BOOKMARKS_TABLE, USER_NOTIFICATIONS_TABLE);
foreach ($table_ary as $table)
{
$sql = "DELETE FROM $table WHERE " . $db->sql_in_set('user_id', array_keys($users_data));
$db->sql_query($sql);
}
// Expire subscriptions for threads with no activity for a year.
$sql = "SELECT w.topic_id FROM " . TOPICS_WATCH_TABLE . " w, " . TOPICS_TABLE . " t WHERE w.topic_id = t.topic_id AND t.topic_last_post_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 YEAR))";
$result = $db->sql_query($sql);
$tid = array();
while ($row = $db->sql_fetchrow($result)) {
$tid[] = $row['topic_id'];
}
$db->sql_freeresult($result);
if (!empty($tid)) {
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE " . $db->sql_in_set('topic_id', $tid);
$db->sql_query($sql);
}