vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Auto close thread after x days. (https://vborg.vbsupport.ru/showthread.php?t=74764)

trafix 01-20-2005 10:00 PM

Auto close thread after x days.
 
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

Quote:

Originally Posted by trafix
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 ...

cinq 01-21-2005 12:04 AM

I think Kirby was refering to this easier way

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

PHP Code:

$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;
[sql]$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))
);
[/sql]
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

Quote:

Originally Posted by Paul M
Try this;
[sql]$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))
);
[/sql]
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

Quote:

Originally Posted by Paul M
Try this;
[sql]$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))
);
[/sql]
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 ..

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

Quote:

Originally Posted by bryan09
I got this problem when I inserted the above code ..

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?

MasJ 09-05-2005 03:39 AM

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

Quote:

Originally Posted by korny
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

Quote:

Originally Posted by Simplicity
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.

You can configure the number of days until close and exclude forums.


All times are GMT. The time now is 03:33 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01989 seconds
  • Memory Usage 1,780KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (33)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete