Page 3 of 3

Posted: Thu Jul 14, 2005 4:43 am
by King Moonraiser
Would it be possible to run the auto_lock.php manually through a cron job?

Possible Bug

Posted: Sat Jul 16, 2005 7:52 am
by Phade
Hey,

I have downloaded and installed auto-lock and it seems to work fine. I was browsing the code to see how it works and found a possible bug in auto-lock.php. Should this line:
auto-lock.php wrote: return array ('topics' => $pruned_topics);


be this instead:
Possible Correction wrote: return array ('topics' => $locked_topics);


Just checking. Thanks again and have a great day!

Phade.

Posted: Sun Jul 17, 2005 11:50 pm
by Phade
Hey All,

After further investigation, I have noticed that the plugin works very slowly as written for large data sets (we have 580,000+ posts). I have narrowed it down to the select statement using the OR starting on line 40:

Code: Select all

$sql = "SELECT t.topic_id 
	FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
	WHERE t.forum_id = $forum_id
		$lock_all 
		AND ( p.post_id = t.topic_last_post_id 
			OR t.topic_last_post_id = 0 )";
if ( $lock_date != '' )
{
	$sql .= " AND p.post_time < $lock_date";
}
For some reason, this resulting query is very expensive to calculate. I benchmarked each portion of the OR parts in seperate queries vs. the query as a whole with the OR. The parts executed in miliseconds while the OR executed in minutes.

I have found that by removing the OR and exeuting the two parts seperatly, the query runs much much faster. Here is the same query using a UNION:

Code: Select all

$sql = "SELECT t.topic_id 
	FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
	WHERE t.forum_id = $forum_id
		$lock_all 
		AND  p.post_id = t.topic_last_post_id" .
	( $lock_date != '' ? " AND p.post_time < $lock_date" : '' ) .
	" UNION
	SELECT t.topic_id 
		FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
		WHERE t.forum_id = $forum_id
			$lock_all 
			AND t.topic_last_post_id = 0" .
	( $lock_date != '' ? " AND p.post_time < $lock_date" : '' );
Using UNION requires MySQL 4+. If you must use MySQL 3.x, the query can be split into two execution stages:

Code: Select all

$sql = "SELECT t.topic_id 
	FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
	WHERE t.forum_id = $forum_id
		$lock_all 
		AND t.topic_last_post_id = 0 ";
if ( $lock_date != '' )
{
	$sql .= " AND p.post_time < $lock_date";
}

if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not obtain lists of topics to lock', '', __LINE__, __FILE__, $sql);
}

$sql_topics = '';
while( $row = $db->sql_fetchrow($result) )
{
	$sql_topics .= ( ( $sql_topics != '' ) ? ', ' : '' ) . $row['topic_id'];
}
$db->sql_freeresult($result);

$sql = "SELECT t.topic_id 
	FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
	WHERE t.forum_id = $forum_id
		$lock_all 
		AND p.post_id = t.topic_last_post_id ";
if ( $lock_date != '' )
{
	$sql .= " AND p.post_time < $lock_date";
}

if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not obtain lists of topics to lock', '', __LINE__, __FILE__, $sql);
}

while( $row = $db->sql_fetchrow($result) )
{
	$sql_topics .= ( ( $sql_topics != '' ) ? ', ' : '' ) . $row['topic_id'];
}
$db->sql_freeresult($result);
I hope this helps.

Phade.

Auto-lock Hours

Posted: Mon Sep 05, 2005 12:40 am
by qqq123
Can you have the topics auto-lock if now replies within x hours instead of days? Also, can you have it check for locked topics every hour instead of once per day?

Posted: Tue Oct 18, 2005 2:15 pm
by guspasho
I am impressed. Fortunately I have a small board (1782 topics) so the "OR" deal isn't an issue for me. However, I have the same problem as one other person: it doesn't lock topics with polls. How can I fix that?

Posted: Tue Nov 22, 2005 3:29 pm
by Jackanape
This mod works extremely well for me, and has for some time now...I just upgraded to .18, and it still is a workhorse. Is there an upgrade in store, or should it be OK the way it is?

Posted: Fri Apr 14, 2006 12:24 pm
by bluesomething
i've installed the mod. Everything looks fine, but when I set the enable forum autolocking to yes in the admin panel configuration and then click ok, it will be reset to no.

anyone know how i solve this?


never mind, one of the queries didn't work, i've fixed it already

Posted: Fri Apr 14, 2006 1:07 pm
by Jackanape
bluesomething wrote: i've installed the mod. Everything looks fine, but when I set the enable forum autolocking to yes in the admin panel configuration and then click ok, it will be reset to no.

anyone know how i solve this?


Did you run your SQL queries? Those are usually the culprit in something like this.

Is it possible to do a time lock also ?

Posted: Wed May 03, 2006 8:57 am
by Masochist
Great Job

This might be my first post in here, I am using phpBB v 2 and Guys I really would like to thank you for the very effort you are doing. I bought a domain name and a host and installed the whole forum. everything is working just great and more than I imagined.

I have only one problem which is really interesting to be posted. I work for an Architecture Company in Jordan. I and the rest of the team members gathered and got the permission for the high-level management in our firm to have an internal/external forum for our employees and our boss was very happy though we paid the cost ... but he had one comment on those who are abusing the working hours on the forum so he asked me to do something like a restriction. He wanted the Forum to be disable during the working hours except the break.

I know I can disable the forum from the configuration but this will be no professional to have it disabled manually every day and in hours. So I am asking you guys of there's any way to amend the script to make it AUTOMATICALLY disabled during the working hours.

Thank you,
Nida' Elias


Amman - jordan
www.2k-forum.com

Posted: Thu Jul 20, 2006 2:08 am
by dcrhaekte
I have installed this mod sucessfully but when I went back to my admin control panel I got this error on the left side where the controls are supposed to be:

Code: Select all

Parse error: parse error, unexpected T_STRING in /var/www/asgard/admin/admin_forums.php on line 506
The section it is referring to is this:

Code: Select all

505: $sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", forum_view_threshold = " . intval($HTTP_POST_VARS['forumviewthreshold']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . ", auto_lock_enable = " . intval($HTTP_POST_VARS['auto_lock_enable'])
				506: WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL])
The original pre mod change looked like this:

Code: Select all

505: $sql = "UPDATE " . FORUMS_TABLE . "
				SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", forum_view_threshold = " . intval($HTTP_POST_VARS['forumviewthreshold']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
				506: WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL])
Does anyone see why I am getting that error with the new syntax? I've racked my brains on this for 3 days now and I'm at the point where I either fix this or wipe the entire forum. What good is a PHPBB if you cannot do anything in the admin control panel? Ugh!

Any help will be greatly appreciated.

Posted: Thu Jul 20, 2006 3:08 pm
by dcrhaekte
Anybody?

Posted: Tue Sep 12, 2006 2:38 pm
by qqq123
Can you use autolock to lock topics that haven't had activity for hours or minuted instead of days?

Posted: Sat Sep 30, 2006 8:37 am
by janlotte
Hi all,

Phade noticed a possible bug and offered a possible solutions to the max_user_connections errors on large forums.
Is it a bug and is his solution working with UNION? Is it safe to use? I heard UNION can cause problems. I emailed both Sune and phade but both did not answer my email. So I hope someone can check this solution cause Sune's last post was Wed Jan 05, 2005 and Phade's last post was Sun Jul 17, 2005 given the fact they did not answer my email and both dates I doubt they will check this post.

Hope someone can help me out cause this mod would be a great addition to my forum.

With kind regards,
Lotte