Back to vBulletin 4.x Add-ons

Scheduled site closure via Cron scripts
Mod Version: 1.1, by MrEyes

vB Version: 4.0.8 Rating: (1 vote - 5.00 average) Installs: 10
Released: 01 Dec 2010 Last Update: 01 Dec 2010 Downloads: 50
Not Supported Uses Plugins Additional Files Re-usable Code Translations  

Open Toggle v1.1
Advanced (ish)


This mod is only useful to you if you perform backups or other maintenance of your site via an external (i.e. sh) script.

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 scheduling/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 modification has a number of ACP settings that allow you to define different messages it also includes a PHP script that you can use to open/close your site by calling it from a shell script (using wget on similar). The idea being that at the top of your backup script you close the site (with one of three customisable messages). Once your backup script completes you open the site. Simples

Note: This script does not do any backups

Installation

There is no installation, all you need to do is:
  1. Upload the contents of the upload folder, in the attached zip file, to your forum root.
  2. Add the modification xml

Using the script

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

Code:
wget "http://yoursite/forum/opentoggle.php?do=close?msg=1"
... Do you mysqldump here
wget "http://yoursite/forum/opentoggle.php?do=open"
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. In a previous version of this I had referrer checks etc. In order to simplify this version all that is gone. To "secure" this and prevent malicious use to rename the opentoggle.php file to something only you know, for example :

9d9ee951-ff11-44fe-b87a-cace0eaeef65.php

Lets face it, yes it is the much maligned security through obscurity, but if somebody can guess that then most of your passwords are also at risk

Configuration

Closure Messages
The modification allows you setup 3 predefined "closed" messages, you can then choose the message you want by calling the script (via wget) with different "msg" values, for example:
  • Use message 1 : wget "http://yoursite/forum/opentoggle.php?do=close?msg=1"
  • Use message 2 : wget "http://yoursite/forum/opentoggle.php?do=close?msg=2"
  • Use message 3 : wget "http://yoursite/forum/opentoggle.php?do=close?msg=3"

Alternatively, don't set a "msg" parameter and default to message 1.
  • Use message 1 : wget "http://yoursite/forum/opentoggle.php?do=close"

Closure messages can also include datetime replacement, this will show the datetime the close script was called. This can be useful as it allows you to present more meaningful closure messages. For example, site closed at XX:YY we estimate that we will be back online in 15 minutes.

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. Although it is worth mentioning that this script does not generate any output.

Finally, for those that are more technical

You may have noticed the following line in the PHP script:

Code:
define('THIS_SCRIPT', 'login');
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

File Type: %1$s opentoggle_v1.1.zip (2.2 KB, 56 downloads)


vblts.ru supports vBulletin®, 2022-2024