Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2008, 07:20 PM
SemperFideles's Avatar
SemperFideles SemperFideles is offline
 
Join Date: Oct 2006
Location: Northern VA
Posts: 223
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I automatically turn on/off specific forums at a set time?

I looked for some cron hacks that would do this but couldn't find any.

Here's what I want to do:

1. Automatically turn off certain forums on Saturday night.
2. Automatically turn them back on on Monday AM.

If I can't do it via the cron tab then could somebody give me an example of an SQL query that would turn off/on a forum so I could perform them all en masse at once if I have to do it manually?
Reply With Quote
  #2  
Old 11-25-2008, 10:16 AM
CypherSTL CypherSTL is offline
 
Join Date: Mar 2006
Location: St. Charles, MO
Posts: 306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you use Linux, and have access to create local cron job to execute a script at said times.

With the forums offline, I dont think vBulletin Cron Jobs will still function, so you would have to look "external of vBulletin" I would imagine.
Reply With Quote
  #3  
Old 11-25-2008, 10:48 AM
SemperFideles's Avatar
SemperFideles SemperFideles is offline
 
Join Date: Oct 2006
Location: Northern VA
Posts: 223
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CypherSTL View Post
If you use Linux, and have access to create local cron job to execute a script at said times.

With the forums offline, I dont think vBulletin Cron Jobs will still function, so you would have to look "external of vBulletin" I would imagine.
Thanks for the reply.

All the forums would not be offline but just the few forums that I want to turn off. I have about 150 forums and would be turning off only about 8 of them during the period.

My problem is not knowing that a cron job could be set up in Linux or vBulletin but how.
Reply With Quote
  #4  
Old 11-25-2008, 10:55 AM
CypherSTL CypherSTL is offline
 
Join Date: Mar 2006
Location: St. Charles, MO
Posts: 306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Read over the vBulletin Manual for scheduled tasks here: http://www.vbulletin.com/docs/html/scheduled_tasks

Looks like all you have to do is write a PHP Script to modify your database to make changes to the forum sections in question.
Reply With Quote
  #5  
Old 11-25-2008, 11:13 AM
ReCom ReCom is offline
 
Join Date: Mar 2008
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I spent about 30 minutes cracking this up:

PHP Code:
<?php
require_once('global.php');
require_once(
DIR '/includes/adminfunctions.php');

$vbulletin->input->clean_gpc('g''enable'TYPE_BOOL);
$enable $vbulletin->GPC['enable'];

$sql "SELECT `forumid`, `options` FROM `".TABLE_PREFIX."forum` WHERE `forumid` = '57'";
$res $vbulletin->db->query_read_slave($sql);
while (
$row $vbulletin->db->fetch_array($res))
{
  
$forumid $row['forumid'];
  
$optionbits $row['options'];
  
$newoptionbits = ($enable$optionbits $optionbits - ($optionbits 3));
  
$vbulletin->db->query_write("UPDATE `".TABLE_PREFIX."forum` SET `options` = '$newoptionbits' WHERE `forumid` = '$forumid'");
}

build_forum_permissions();
?>
Modify the SQL query $sql to put the forumids you are interested in. Then save as forumswitch.php in your vbulletin directory.

Set two Scheduled Tasks in AdminCP that call forumswitch.php?enable=0 and forumswitch.php?enable=1 respectively.
Reply With Quote
  #6  
Old 11-25-2008, 11:46 AM
SemperFideles's Avatar
SemperFideles SemperFideles is offline
 
Join Date: Oct 2006
Location: Northern VA
Posts: 223
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks so much ReCom!

Just so I'm clear, it seems like this line is t[he one with the forumid:

PHP Code:
$sql "SELECT `forumid`, `options` FROM `".TABLE_PREFIX."forum` WHERE `forumid` = '57'"
Do I replace the 57 with my forum id?
I have about 10 forums to turn off, do I replace the '57' with something like '1,2,3,4,5,6,7,8,9,10'?
Reply With Quote
  #7  
Old 11-25-2008, 11:53 AM
ReCom ReCom is offline
 
Join Date: Mar 2008
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SemperFideles View Post
Thanks so much ReCom!

Just so I'm clear, it seems like this line is t[he one with the forumid:

PHP Code:
$sql "SELECT `forumid`, `options` FROM `".TABLE_PREFIX."forum` WHERE `forumid` = '57'"
Do I replace the 57 with my forum id?
I have about 10 forums to turn off, do I replace the '57' with something like '1,2,3,4,5,6,7,8,9,10'?
Nope, you use IN, as in:
PHP Code:
$sql "SELECT `forumid`, `options` FROM `".TABLE_PREFIX."forum` WHERE `forumid` IN ('1','2','3','4','5','6','7','8','9','10') "
Reply With Quote
  #8  
Old 11-25-2008, 01:53 PM
SemperFideles's Avatar
SemperFideles SemperFideles is offline
 
Join Date: Oct 2006
Location: Northern VA
Posts: 223
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did a test run and get this error:
PHP Code:
Turn off Forum

Warning
: include_once([path]/./includes/cron/forumswitch.php?enable=0) [function.include-once]: failed to open streamNo such file or directory in [path]/admincp/cronadmin.php on line 113

Warning
: include_once() [function.include]: Failed opening '[path]/./includes/cron/forumswitch.php?enable=0' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php'in [path]/admincp/cronadmin.php on line 113

Done 
Reply With Quote
  #9  
Old 11-25-2008, 02:05 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you save the script where suggested? Have you renamed your admincp? What path did you put for your Scheduled Task Filename?
Reply With Quote
  #10  
Old 11-25-2008, 02:20 PM
SemperFideles's Avatar
SemperFideles SemperFideles is offline
 
Join Date: Oct 2006
Location: Northern VA
Posts: 223
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne,

Are you ReCom?

I saved it both in my vBulletin directory (same error) and in my includes/cron directory within my vBulletin directory (same error).

I have not renamed admincp.

--------------- Added [DATE]1227630218[/DATE] at [TIME]1227630218[/TIME] ---------------

Here is the error when run from the vBulletin directory:

PHP Code:
Turn off Forum

Warning
: include_once([path]/./forumswitch.php?enable=0) [function.include-once]: failed to open streamNo such file or directory in [path]/admincp/cronadmin.php on line 113

Warning
: include_once() [function.include]: Failed opening '[path]/./forumswitch.php?enable=0' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php'in [path]/admincp/cronadmin.php on line 113

Done 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:48 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05898 seconds
  • Memory Usage 2,281KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete