Register Members List Search Today's Posts Mark Forums Read

Reply
 
Mod Options
Open Toggle - Automate Site Opening and Closing Details »
Open Toggle - Automate Site Opening and Closing
Mod Version: 1.00, by MrEyes (Coder) MrEyes is offline
Developer Last Online: May 2017 I like it Show Printable Version Email this Page

vB Version: 3.8.4 Rating: (0 vote - 0 average) Installs: 9
Released: 28 Sep 2009 Last Update: 28 Sep 2009 Downloads: 33
Not Supported Additional Files Re-usable Code Translations Is in Beta Stage  

Open Toggle v1.0 BETA
Advanced (ish)


What this does

Anybody who has read through the guidelines available at vbulletin.com will know that you should perform regular backups of your database. You may also know that it is best to use mysqldump via an operating system scheduled task as using vBulletin cron may result in backup failures, especially on large databases. It is also wise to lock all tables (to prevent inserts etc) that may corrupt your backup.

Now this is all well and good, however if you have tried to do this on an active site you will have seen the site grind to a halt and on occasion spit out errors to the end user. If you have any interest in user experience you should really close the site down gracefully with a meaningful user message, for example "We are currently backing up, please check back in 10 minutes".

The problem is that although you can do this through admincp there is no automated way to do this from an external process (i.e. your scheduled backup script). Most of us run backups during off time and most of us probably don't want to get up at 3am to gracefully close the site for 10 minutes. This modification fixes that problem and automates the entire thing.

This is not a "real" modification rather a standalone PHP script that you can call from a shell script (using wget on similar) that will open or close the site. So before you start your script mysqldump back you call the script to close the site, once done you call the script to open the site. Simples

Note: This script does not do any backups

Installation

There is no installation, all you need to do is:
  1. Download the attached script and extract to your computer.
  2. Review the configuration options at the top of the script and amend as you see fit.
  3. Upload the amended script to your forum home directory, i.e. where forumdisplay.php is.

Using the script

This script is designed to be called from wget, as an example your backup script would look like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Security

While this script isn't data destructive if somebody "malicious" was constantly calling it and closing/opening your site you would probably be a tad miffed. So the script has various inbuilt security mechanisms, so the script can be configured to:
  • Only execute if the call is from a user agent your define, so you could change the wget call above to something like this:


    Block Disabled:      (Update License Status)  
    Suspended or Unlicensed Members Cannot View Code.

  • To use custom values for "do=", the default is open/close however you could configure these to be monkeys to open and parrots to close, e.g.:

    Open the site

    Block Disabled:      (Update License Status)  
    Suspended or Unlicensed Members Cannot View Code.

    Close the site

    Block Disabled:      (Update License Status)  
    Suspended or Unlicensed Members Cannot View Code.

  • Output or not a result detailing what was done with XML. This output can be parsed by your backup script to check that it can proceed.
  • You can rename the script to any valid file name and it will still work, e.g. wibblewobble.php

Other Configuration

There are a few other configuration values, I won't get into specifics here as the php script is well commented. In summary you can do the following:
  • Run the script in test mode
  • Switch user agent checks on or off
  • Customise the responses
  • Customise the structure of the response XML
  • Define multiple closed messages, you might be closing for a backup or maybe something else.
  • Switch output XML on or off

Sample Output

If you have configured the script to create outputs you will get something like this when you call it:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In this example the script was called to close the site, it shows the time of the request, the requested uri (url & query string), testmode not enabled (it would be testmode="1" if it was), the result code and the result text.

All the text you see above is customisable.

Other Information

As mentioned above this script was primarily designed to be called from wget (or similar) however there is nothing to stop you from calling it in a browser or any other mechanism capable of performing http calls.

Finally, for those that are more technical. You may have noticed the following line:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Yes this is deliberate, we are pretending to be the login script. The reason for this is that when the script is called it is executed as a guest user, this means that when attempting to open a closed site the VB backend will abort and return back the "site currently offline" message rather than opening the site. Impersonating the login script allows this script to bypass the internal "is offline" check.

Download Now

Only licensed members can download files, Click Here for more information.

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
  #16  
Old 30 Dec 2009, 01:54
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
If you have a cron that performs backups at 3am, then create a notice in vBulletin that shows every night at 2:55am until 3:00am. Use the UTC time, and just figure out the difference between it and server time.

Cheers
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

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


New To Site? Need Help?

All times are GMT. The time now is 03:47.

Layout Options | Width: Wide Color: