vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Forum and Server Management (https://vborg.vbsupport.ru/forumdisplay.php?f=232)
-   -   Turn off Forum via Shell Command Line? (https://vborg.vbsupport.ru/showthread.php?t=239990)

BryceW 04-07-2010 02:21 PM

Turn off Forum via Shell Command Line?
 
I currently have a decently large forum with 56,000+ members and 2.1 million posts. This is on dedicated server and I back it up using mysqldump via SSH command line. I want to automate this process via a cron job.
Currently, I turn off the forums in the admin CP, do the mysqldump in shell then turn it back on.

Obviously, the mysqldump is easily scripted but I need a way to turn off the forums with a script, like a ssh command or something. Any suggestions, ideas?

If I dont turn the forums off, the update takes twice as long, the forums lag out and my members just sit there hitting refresh :)

Marco van Herwaarden 04-07-2010 02:34 PM

You will need to run 2 queries:

To turn your forums off
UPDATE datastore SET data=REPLACE(data,'s:8:"bbactive";i:1;','s:8:"bbac tive";i:0;') WHERE title='options';
UPDATE setting SET value=0 WHERE varname='bbactive';


To turn your forums on
UPDATE datastore SET data=REPLACE(data,'s:8:"bbactive";i:0;','s:8:"bbac tive";i:1;') WHERE title='options';
UPDATE setting SET value=1 WHERE varname='bbactive';

kmike 04-07-2010 05:31 PM

Note that the queries above will not work when one of the datastore caching modules (XCache, APC, eAccelerator, memcached) is enabled. The script must be more sophisticated - it should be able to flush memory cache for the appropriate datastore caching module.

Andreas 04-08-2010 03:27 PM

Here is a more sophisticated script:

PHP Code:

<?php
@ini_set('display_errors'0);
@
error_reporting(0);

define('VB_AREA''Maintenance');
define('SKIP_SESSIONCREATE'1);
define('SKIP_LOCATIONUPDATE'1);
define('SKIP_DEFAULTDATASTORE'1);
define('DISABLE_HOOKS'1); // You might want to comment this out if you need plugins in this script
define('NOCOOKIES'1);
define('CWD''/path/to/vbulletin');
require(
CWD '/includes/init.php');
require(
DIR '/includes/adminfunctions.php');

$db->query_write("UPDATE " TABLE_PREFIX "setting SET value = " . (($_SERVER['argv'][1] == 1) ? 0) . " WHERE varname = 'bbactive'");

build_options();
?>

I've turned off all error reporting as vB 4 seems to assume that every request comes through a webserver :rolleyes:
(Adding yet-another bug report now ...)

Also setting the board offline does not completely kill queries so you might still run into table locking issues.

BryceW 04-18-2010 11:21 AM

Sorry its taken me so long to get back to you. But thanks alot all. I appreciate it. Hopefully thread will help others as well.

zagman76 09-03-2012 10:19 PM

-bump-

Sorry to bump such an old thread, but I was wondering how one could manipulate this to do the reverse - turn the forum back ON via a script.

NickCat 09-17-2012 07:55 PM

Quote:

Originally Posted by zagman76 (Post 2362368)
-bump-

Sorry to bump such an old thread, but I was wondering how one could manipulate this to do the reverse - turn the forum back ON via a script.

This script does already allow for that... you just have to pass a variable it to the script.

If calling from a shell (ie straight on the server using command line) you would call it like this:

> vbscript.php (will close the site)
> vbscript.php 1 (will open the site)
> vbscript.php 0 (will also close site)

I believe you can also use these through a direct call to the file from a web browser. I'm not sure the exact formatting, but it would be similar to "yourservername.com/vbscript.php?1"

Hope that helps.

Also from a security standpoint I wound't suggest allowing something like this to be call from a web browser and only use it on the command line.

I'm integrating this into a script I use to backup my site, but we are so large I need to have the site offline in order to make the 18GB backup.

PHP Page for reference on usage: http://www.php.net/manual/en/reserve...les.server.php

argv specific section:
Quote:

'argv'
Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.


All times are GMT. The time now is 11:10 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.01292 seconds
  • Memory Usage 1,736KB
  • 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
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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