View Full Version : Auto close thread after x days.
trafix
01-20-2005, 10:00 PM
Requested by Skyline_GT
This is a simple script that will close all threads where the last post is 30 days or older
Edited script with KirbyDE's code
I got it this time :) ... and tested and works
Tnx :)
only 1 variable to edit here .... default is 30 days but you can change it to whatever you want ;)
Please click Install
Andreas
01-20-2005, 11:45 PM
Seems to be complicated, and might/will issue a lot of UPDATEs
I think this could also be done in 1 line ;)
trafix
01-20-2005, 11:51 PM
Sorry if i steped on you toes KirbyDE
if updates are required ... its just the code
Andreas
01-21-2005, 12:03 AM
if updates are required ... its just the code
I don't understand this, sorry.
What do you mean?
I just wanted to point out that this can be done with just one UPDATE, instead of querying the table for outdated threads to get the threadis and then issue a query for each thread to close it.
Imagine the script is run for the first time and there are 10.000 outdated threads.
This would mean 10.001 queries are being executed ...
I think Kirby was refering to this easier way (https://vborg.vbsupport.ru/showpost.php?p=598980&postcount=2)
trafix
01-21-2005, 12:11 AM
hmm ... i see where you are comming from ....
can i use your 1 liner?
Andreas
01-21-2005, 12:12 AM
Sure :)
I must admit that I didn't test it, but as the query is pretty simple I am 99,75% sure that it does the job.
trafix
01-21-2005, 12:20 AM
Tnx Co-authour ;)
Andreas
01-21-2005, 12:28 AM
I fear that this version will close no threads ...
Let's say TIMENOW is 1106274310
Then $deletedate will be 1103682310
So (TIMENOW - $deletedate) will be 2592000, which is the timestamp of 1970-01-31 01:00:00.
I don't think you'll find threads that old anywhere ;)
trafix
01-21-2005, 12:40 AM
oh crap ... i forgot about that the line should be
$DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open=0 WHERE lastpost <= $deletedate"
);
trafix
01-21-2005, 12:48 AM
Fixed and tested
nintendo
01-31-2005, 09:26 AM
How about making it so we can give different boards different XX days. On less active boards we might want to do 60 days for example.
Or even better, delete threads after XX days.
And is this XX days after the last reply, or the first post?
TCattitude
02-05-2005, 11:16 PM
How can make it to close threads in specific forums by id?
I want this active but not in all forums.
This can be done in a easy way?
Please? Somebody?
By the way, this affect all threads?
Even the sticky ones? :rolleyes:
(If it is, how do to not affect sticky?)
Paul M
02-05-2005, 11:34 PM
Try this;
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE forumid IN (1,2,3) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30))
);
Where (1,2,3) is the list of forum id's you want it to work for, and 30 is the number of days
TCattitude
02-06-2005, 03:59 AM
Try this;
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE forumid IN (1,2,3) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30))
);
Where (1,2,3) is the list of forum id's you want it to work for, and 30 is the number of days
Works like a charm!
Thanks Paul :D
trafix
02-06-2005, 04:01 AM
well done guys :)
Rebecca217
02-07-2005, 08:21 PM
Thank you. This is very useful! :D *clicks install*
Rebecca
trafix
02-07-2005, 10:20 PM
Your welcome :)
teedizz
05-16-2005, 02:59 AM
can this be set for one particular forum or is this for ALL threads because I want to have threads auto close after 8 days in 1 particular forum on my site....is that possible with this hack?
teedizz
05-18-2005, 05:20 PM
bump
Marco van Herwaarden
05-18-2005, 07:02 PM
Looking at the instructions it seems to me that you can not select a forum.
bryan09
05-29-2005, 08:12 AM
Try this;
$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE forumid IN (1,2,3) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30))
);
Where (1,2,3) is the list of forum id's you want it to work for, and 30 is the number of days
I got this problem when I inserted the above code ..
ERROR: Unknown Punctuation String @ 9
STR: ->
SQL: $DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE forumid IN (36) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30))
)
SQL-query:
$DB_site->query(" UPDATE " . TABLE_PREFIX . "thread SET open = 0 WHERE forumid IN (36) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30)) )
MySQL said:
#1064 - You have an error in your SQL syntax near '$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE for' at line 1
TCattitude
06-06-2005, 11:14 PM
This is a absurd question, but... i'm a newbie on php:
This cronjob close thread after X days since the creation of the thread, or after X days of inactivity?
(Are diferent things)
How to change that?
How to setup this cronjob to close old threads (based on "original post date") or to close inactive threads (based on "last post date")?
Thanks for all in advance ;)
korny
07-20-2005, 11:10 PM
I got this problem when I inserted the above code ..
ERROR: Unknown Punctuation String @ 9
STR: ->
SQL: $DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE forumid IN (36) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30))
)
SQL-query:
$DB_site->query(" UPDATE " . TABLE_PREFIX . "thread SET open = 0 WHERE forumid IN (36) AND open = 1 AND sticky = 0 AND lastpost < " . intval(TIMENOW - (86400 * 30)) )
MySQL said:
#1064 - You have an error in your SQL syntax near '$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET open = 0
WHERE for' at line 1
I just got the same error.
Please let me know what I maybe doing wrong?
korny
08-29-2005, 06:27 AM
Anyone now a fix for my SQL query problem?
Thank you Trafix and KirbyDE, worked like a charm. Been looking for this for a very long time : ).
Paul M
10-06-2005, 12:51 AM
I just got the same error.
Please let me know what I maybe doing wrong?That is php code to insert in a vbulletin file and run, sounds/looks to me like you are trying to run it directly as an sql query.
korny
10-06-2005, 01:51 AM
Opps, well it looked like it was a sql query, what you posted.
Got it now..thanks Paul!
cunder
09-06-2006, 07:27 AM
hello
Can these be made that he does it also on Vbulletin 3.6.0 please!!
thanks
Simplicity
09-16-2006, 04:04 PM
I would also like this for 3.6
PIKenPIK
10-07-2006, 09:38 AM
I would also like this for 3.6
wanna have for 3.6.2. with variables forumID
Eagle Creek
10-27-2006, 12:53 PM
Hi!
Does this work with vB 3.6.x?
Can I apply this to one subforum specific?
echamberlain
11-04-2006, 06:16 AM
I wrote an auto thread close product for 3.6.2 (https://vborg.vbsupport.ru/showthread.php?t=130738).
You can configure the number of days until close and exclude forums.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.