diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index 37769bd5..116a43bd 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -278,6 +278,20 @@ $aSettings['system'][] = array( 'name' => 'disable_about', 'value' => $setting->getValue('disable_about'), 'tooltip' => 'Showing About page in Navigation.' ); +$aSettings['system'][] = array( + 'display' => 'Disable Live Dashboard', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes'), + 'default' => 0, + 'name' => 'disable_dashboard', 'value' => $setting->getValue('disable_dashboard'), + 'tooltip' => 'Disable live updates on the dashboard to reduce server load.' +); +$aSettings['system'][] = array( + 'display' => 'Disable Dashboard API', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes'), + 'default' => 0, + 'name' => 'disable_dashboard_api', 'value' => $setting->getValue('disable_dashboard_api'), + 'tooltip' => 'Disable dashboard API entirely to reduce server load.' +); $aSettings['recaptcha'][] = array( 'display' => 'Enable re-Captcha', 'type' => 'select', 'options' => array( 0 => 'No', 1 => 'Yes' ), diff --git a/public/include/pages/api/getdashboarddata.inc.php b/public/include/pages/api/getdashboarddata.inc.php index 95d3b061..efc9d743 100644 --- a/public/include/pages/api/getdashboarddata.inc.php +++ b/public/include/pages/api/getdashboarddata.inc.php @@ -3,6 +3,12 @@ // Make sure we are called from index.php if (!defined('SECURITY')) die('Hacking attempt'); +// Check if the system is enabled +if ($setting->getValue('disable_dashboard_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']) { @@ -11,6 +17,9 @@ if ($load = @sys_getloadavg()) { } } +// Supress master template +$supress_master = 1; + // Check user token and access level permissions $user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']); @@ -116,8 +125,6 @@ $data = array( 'system' => array( 'load' => sys_getloadavg() ), 'network' => array( 'hashrate' => $dNetworkHashrateAdjusted, 'difficulty' => $dDifficulty, 'block' => $iBlock ), ); -echo $api->get_json($data); -// Supress master template -$supress_master = 1; +echo $api->get_json($data); ?> diff --git a/public/include/pages/dashboard.inc.php b/public/include/pages/dashboard.inc.php index e66558a4..06b4f3b3 100644 --- a/public/include/pages/dashboard.inc.php +++ b/public/include/pages/dashboard.inc.php @@ -10,14 +10,24 @@ if ($user->isAuthenticated()) { $dDifficulty = 1; $aRoundShares = 1; - // Only run these if the user is logged in $aRoundShares = $statistics->getRoundShares(); + $dDifficulty = 1; + $dNetworkHashrate = 1; + $iBlock = 0; if ($bitcoin->can_connect() === true) { $dDifficulty = $bitcoin->getdifficulty(); $dNetworkHashrate = $bitcoin->getnetworkhashps(); + $iBlock = $bitcoin->getblockcount(); } // Fetch some data + // Round progress + $iEstShares = $statistics->getEstimatedShares($dDifficulty); + if ($iEstShares > 0 && $aRoundShares['valid'] > 0) { + $dEstPercent = round(100 / $iEstShares * $aRoundShares['valid'], 2); + } else { + $dEstPercent = 0; + } if (!$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers()) $iCurrentActiveWorkers = 0; $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); $iCurrentPoolShareRate = $statistics->getCurrentShareRate(); @@ -26,6 +36,10 @@ if ($user->isAuthenticated()) { if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate; // Make it available in Smarty + $smarty->assign('DISABLED_DASHBOARD', $setting->getValue('disable_dashboard')); + $smarty->assign('DISABLED_DASHBOARD_API', $setting->getValue('disable_dashboard_api')); + $smarty->assign('ESTIMATES', array('shares' => $iEstShares, 'percent' => $dEstPercent)); + $smarty->assign('NETWORK', array('difficulty' => $dDifficulty, 'block' => $iBlock)); $smarty->assign('INTERVAL', $interval / 60); $smarty->assign('CONTENT', 'default.tpl'); } diff --git a/public/templates/mpos/dashboard/account_data.tpl b/public/templates/mpos/dashboard/account_data.tpl index ce1bf20b..c03165c7 100644 --- a/public/templates/mpos/dashboard/account_data.tpl +++ b/public/templates/mpos/dashboard/account_data.tpl @@ -24,13 +24,14 @@
| Loading worker information | +No worker information available |