diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index c6d488a2..61521c87 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -287,6 +287,20 @@ $aSettings['system'][] = array( 'name' => 'disable_dashboard_api', 'value' => $setting->getValue('disable_dashboard_api'), 'tooltip' => 'Disable dashboard API entirely to reduce server load.' ); +$aSettings['system'][] = array( + 'display' => 'Disable Live Navbar', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes'), + 'default' => 0, + 'name' => 'disable_navbar', 'value' => $setting->getValue('disable_navbar'), + 'tooltip' => 'Disable live updates on the navbar to reduce server load.' +); +$aSettings['system'][] = array( + 'display' => 'Disable Navbar API', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes'), + 'default' => 0, + 'name' => 'disable_navbar_api', 'value' => $setting->getValue('disable_navbar_api'), + 'tooltip' => 'Disable navbar API entirely to reduce server load. Used in pool stats and navbar mini stats.' +); $aSettings['system'][] = array( 'display' => 'Disable TX Summaries', 'type' => 'select', 'options' => array( 0 => 'No', 1 => 'Yes'), diff --git a/public/include/pages/api/getnavbardata.inc.php b/public/include/pages/api/getnavbardata.inc.php index 3f9615a7..a412f984 100644 --- a/public/include/pages/api/getnavbardata.inc.php +++ b/public/include/pages/api/getnavbardata.inc.php @@ -3,8 +3,19 @@ // Make sure we are called from index.php if (!defined('SECURITY')) die('Hacking attempt'); -// Check if the API is activated -$api->isActive(); +// Check if the system is enabled +if ($setting->getValue('disable_navbar_api')) { + echo $api->get_json(array('error' => 'disabled')); + die(); +} + +// System load check +if ($load = @sys_getloadavg()) { + if (isset($config['system']['load']['max']) && $load[0] > $config['system']['load']['max']) { + header('HTTP/1.1 503 Too busy, try again later'); + die('Server too busy. Please try again later.'); + } +} // Fetch RPC information if ($bitcoin->can_connect() === true) { diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index e6b601bb..969cb323 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -65,6 +65,8 @@ $aGlobal = array( 'price' => $setting->getValue('price'), 'disable_payouts' => $setting->getValue('disable_payouts'), 'config' => array( + 'disable_navbar' => $setting->getValue('disable_navbar'), + 'disable_navbar_api' => $setting->getValue('disable_navbar_api'), 'algorithm' => $config['algorithm'], 'target_bits' => $config['target_bits'], 'accounts' => $config['accounts'], diff --git a/public/templates/mpos/global/navigation.tpl b/public/templates/mpos/global/navigation.tpl index b05ae0de..c6abcc58 100644 --- a/public/templates/mpos/global/navigation.tpl +++ b/public/templates/mpos/global/navigation.tpl @@ -88,6 +88,7 @@ {if $smarty.session.AUTHENTICATED|default:"0" == 1}
{else} + {if !$GLOBAL.website.api.disabled && !$GLOBAL.config.disable_navbar && !$GLOBAL.config.disable_navbar_api}