Scheduled site closure via Cron scripts
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:
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" 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:
Alternatively, don't set a "msg" parameter and default to message 1.
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'); Download
opentoggle_v1.1.zip (2.2 KB, 56 downloads) |