• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Lack of interest [Suggestion] - Databaseless On/Off Switch

Jafo

Active member
#1
It would be nice if there was an option to use a file method to store the forums "on/off" status. When you turn a VB forum off, the script still has to access the db to see if the forum is off which can cause some issues during database repairs and dumps.

I already wrote an in-house product to do it for my VB forums but it sure would be nice if it was stock.
 

Mike

XenForo developer
Staff member
#2
Given that admins can still access when it's off, I don't think this would really work. If you need to take it down because of DB issues, you're likely better off breaking execution in the config script.
 

Cezz

Well-known member
#4
A wordpress style file based maintenance would be cool though... if you simply create a .maintenance in the domain root with the error message... This would disable for all even admin's and can be editied to allow for custom HTML page etc... After this no DB calls etc are made, this would be a great and easy way to take the site down with a nice error message while you do DB changes without having to break the config.php script..
 

Jafo

Active member
#6
Given that admins can still access when it's off, I don't think this would really work. If you need to take it down because of DB issues, you're likely better off breaking execution in the config script.
Actually I have it setup in VB where I can exclude IP addresses. Also, it does break execution in the config file:

$GLOBALS['preinit'] = '/path/to/writeable/maint.txt';

if (defined('CWD'))
{
include_once(CWD . '/includes/pre-init.php');
}

From there it checks the maint.txt file which has a serialized array of the maintenance status, exclusions and the message to show to users.

(pre-init):

if (file_exists($GLOBALS['preinit']) and THIS_SCRIPT != 'maintenance_mode' and THIS_SCRIPT != 'login')
{
$arr = file_get_contents($GLOBALS['preinit']);
$arr = unserialize($arr);
if (!in_array($_SERVER['REMOTE_ADDR'], $arr['ips']))
{
## include a file that shows the maint message and then exits..
}
}