1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
9	die('This script may only be included.');
10}
11
12// get average server load in the last minute
13if (function_exists('sys_getloadavg')) {
14	$load = sys_getloadavg();
15	$server_load = $load[0];
16
17	if ($prefs['use_load_threshold'] == 'y' and $tiki_p_access_closed_site != 'y' and ! isset($bypass_siteclose_check)) {
18		if ($server_load > $prefs['load_threshold']) {
19			$url = 'tiki-error_simple.php?error=' . urlencode($prefs['site_busy_msg']);
20			header('location: ' . $url);
21			exit;
22		}
23	}
24	$smarty->assign('server_load', $server_load == 0 ? '?' : $server_load);
25}
26