View Full Version : Auto Close threads after XX days
sabret00the
01-15-2004, 11:22 AM
errrr, kinda what the title says.
i would greatly appreciate it if someone made a hack that would automatically close threads in set forums after XX days
NTLDR
01-15-2004, 12:45 PM
All you need is a simple cron script that runs every day (or at whatever interval you choose) to update the threads table.
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET open = 0 WHERE forumid IN (X,Y,Z) AND dateline < A");
Where X,Y,Z are the forumids and A is the timestamp that the threads must be older than to be closed.
Gio Takahashi
01-15-2004, 04:30 PM
I need that, Thanks.
I am confused with the time stamp, but say threads older than 7 days, do I put in just "7"?
NTLDR
01-15-2004, 05:39 PM
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET open = 0 WHERE forumid IN (X,Y,Z) AND dateline < ".TIMENOW - (60 * 60 * 24 * 7));
That should close all threads in forumid X, Y and Z older than 7 days.
Gio Takahashi
01-15-2004, 07:56 PM
ran it and got this error:
Invalid SQL: -604800
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-604800' at line 1
mysql error number: 1064
And I used this for script:
$DB_site->query("UPDATE ".TABLE_PREFIX."thread SET open = 0 WHERE forumid IN 6 AND dateline < ".TIMENOW - (60 * 60 * 24 * 7));
NTLDR
01-15-2004, 08:03 PM
Try this instead:
$DB_site->query("UPDATE ".TABLE_PREFIX."thread
SET open = 0
WHERE dateline < ".(TIMENOW - (60 * 60 * 24 * 7))."
AND forumid IN (6)
");
Gio Takahashi
01-15-2004, 08:04 PM
A friend of mine helped out, and gave me the better coding, it should be:
argh, it only closed all thread regardless of time.
Gio Takahashi
01-15-2004, 08:18 PM
the last script you gave DID work....>.>
sabret00the
01-16-2004, 02:05 AM
nice one, will this email me to let me know which threads it's closed?
Gio Takahashi
01-16-2004, 02:56 AM
It should do the same as all other tasks do in task schedules.....
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.