Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

Reply
 
Thread Tools
Scheduled site closure via Cron scripts Details »»
Scheduled site closure via Cron scripts
Version: 1.1, by MrEyes MrEyes is offline
Developer Last Online: May 2017 Show Printable Version Email this Page

Category: Mini Mods - Version: 4.0.8 Rating:
Released: 11-30-2010 Last Update: 11-30-2010 Installs: 10
Uses Plugins
Re-useable Code Additional Files Translations  
No support by the author.

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 Now

File Type: zip opentoggle_v1.1.zip (2.2 KB, 54 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 12-01-2010, 08:00 PM
MrEyes MrEyes is offline
 
Join Date: Nov 2004
Posts: 380
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reseving this for when it all goes belly up
Reply With Quote
  #3  
Old 12-02-2010, 07:18 AM
Dr.osamA's Avatar
Dr.osamA Dr.osamA is offline
 
Join Date: Aug 2004
Location: Syrie
Posts: 979
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

good work

installed + 5 stars

How can I run with this modification ?

https://vborg.vbsupport.ru/showthrea...ghlight=Backup
Reply With Quote
  #4  
Old 12-02-2010, 07:34 PM
scottct1 scottct1 is offline
 
Join Date: Mar 2002
Location: Connecticut
Posts: 391
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a way I can set this up so that it reboots my server? I would love to automatically reboot it once a week. Seems to stay fast if I reboot it about once a week.

Thanks!
Reply With Quote
  #5  
Old 12-08-2010, 11:47 AM
Dr.osamA's Avatar
Dr.osamA Dr.osamA is offline
 
Join Date: Aug 2004
Location: Syrie
Posts: 979
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dr.osamA View Post
good work

installed + 5 stars

How can I run with this modification ?

https://vborg.vbsupport.ru/showthrea...ghlight=Backup
There is no answer??
Reply With Quote
  #6  
Old 12-09-2010, 11:59 AM
MrEyes MrEyes is offline
 
Join Date: Nov 2004
Posts: 380
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dr.osamA View Post
There is no answer??
You can't

This mod is only useful to you if you perform backups or other maintenance of your site via an external (i.e. sh) script.
Reply With Quote
  #7  
Old 12-09-2010, 07:35 PM
Dr.osamA's Avatar
Dr.osamA Dr.osamA is offline
 
Join Date: Aug 2004
Location: Syrie
Posts: 979
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you sir
Reply With Quote
  #8  
Old 12-09-2010, 11:33 PM
ZeroHour's Avatar
ZeroHour ZeroHour is offline
 
Join Date: Sep 2007
Location: Scotland
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just a thought but you could easily protect the system doubly by doing something like this post for a htaccess protection:
http://forums.devshed.com/showpost.p...63&postcount=4
The url would then be "http://userassword@www.blah.com/{file}?mode=open"

Just a thought
Reply With Quote
  #9  
Old 12-10-2010, 08:08 PM
MrEyes MrEyes is offline
 
Join Date: Nov 2004
Posts: 380
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ZeroHour View Post
Just a thought
Its a good idea

There a literally hundreds of different ways of protecting the script, in an earlier version I implemented a few. For this version I decided to keep it simple and let the people who use it decide how to secure it.
Reply With Quote
  #10  
Old 12-10-2010, 09:04 PM
ZeroHour's Avatar
ZeroHour ZeroHour is offline
 
Join Date: Sep 2007
Location: Scotland
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MrEyes View Post
Its a good idea

There a literally hundreds of different ways of protecting the script, in an earlier version I implemented a few. For this version I decided to keep it simple and let the people who use it decide how to secure it.
Simple is good
Maybe include a few thoughts/links at the top to end people asking the same sort of things.
Reply With Quote
Reply

Thread Tools

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

Forum Jump


All times are GMT. The time now is 11:36 AM.


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.11206 seconds
  • Memory Usage 2,320KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete