vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How do I automatically turn on/off specific forums at a set time? (https://vborg.vbsupport.ru/showthread.php?t=197143)

SemperFideles 11-24-2008 07:20 PM

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?

CypherSTL 11-25-2008 10:16 AM

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.

SemperFideles 11-25-2008 10:48 AM

Quote:

Originally Posted by CypherSTL (Post 1672596)
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.

CypherSTL 11-25-2008 10:55 AM

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.

ReCom 11-25-2008 11:13 AM

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.

SemperFideles 11-25-2008 11:46 AM

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'?

ReCom 11-25-2008 11:53 AM

Quote:

Originally Posted by SemperFideles (Post 1672645)
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') "


SemperFideles 11-25-2008 01:53 PM

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 


Lynne 11-25-2008 02:05 PM

Did you save the script where suggested? Have you renamed your admincp? What path did you put for your Scheduled Task Filename?

SemperFideles 11-25-2008 02:20 PM

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 



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

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.01079 seconds
  • Memory Usage 1,765KB
  • 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
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete