Plugin restrict search when server load is high
by
, 10-24-2007 at 10:43 AM (3115 Views)
This is a old plugin that i make in the earling times of vBulletin 3.5
This plugin allow to you disable searches when the load average reaches a defined level.
The code
- Can exclude user groups of the search restriction
- Users with search restricted can use google integrated search (by the plugin)
The plugin work with linux, freeBSD and unix servers not in WINDOWS.PHP Code:
$Groupids = explode(',', $vbulletin->options['Allowed_Groups']);
if(is_member_of($vbulletin->userinfo, $Groupids))
{
$SearchAllowed = true;
}
//$SearchAllowed = is_member_of($vbulletin->userinfo, explode(',',$vbulletin->options['Allowed_Groups'])) ? true : false;
if (!$SearchAllowed)
{
if ($load = @file_get_contents("/proc/loadavg")) //standard linux style
$loadavg = explode(' ', $load);
elseif ($load=@exec('uptime')) //unix style
preg_match('/averages?: ([0-9.]+),[s]+([0-9.]+),[s]+([0-9.]+)/',$load, $loadavg);
elseif ($load = @`sysctl vm.loadavg|cut -d" " -f3-5`) //BSD style
$loadavg = explode(' ', $load);
if (trim($loadavg[0]) > $search_load)
{
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('Danny_Restrict') . '");');
}
}
Be sure that you allow access to /proc/loadavg in open_basedir in php.ini
INSTALL
Simply install as product and go to ACP->Restrict Search Config and put a load value.
SCREENSHOTS










