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 @@ Confirmed - + {$GLOBAL.userdata.balance.confirmed} Unconfirmed - + {$GLOBAL.userdata.balance.unconfirmed} + {if !$DISABLED_DASHBOARD and !$DISABLED_DASHBOARD_API} @@ -40,8 +41,9 @@ - +
Loading worker informationNo worker information available
+ {/if} diff --git a/public/templates/mpos/dashboard/default.tpl b/public/templates/mpos/dashboard/default.tpl index d12b4e1d..43e85d42 100644 --- a/public/templates/mpos/dashboard/default.tpl +++ b/public/templates/mpos/dashboard/default.tpl @@ -3,5 +3,9 @@ {include file="dashboard/system_stats.tpl"} {include file="dashboard/round_data.tpl"} {include file="dashboard/account_data.tpl"} - {include file="dashboard/js.tpl"} + {if !$DISABLED_DASHBOARD and !$DISABLED_DASHBOARD_API} + {include file="dashboard/js_api.tpl"} + {else} + {include file="dashboard/js_static.tpl"} + {/if} {/if} diff --git a/public/templates/mpos/dashboard/js.tpl b/public/templates/mpos/dashboard/js_api.tpl similarity index 100% rename from public/templates/mpos/dashboard/js.tpl rename to public/templates/mpos/dashboard/js_api.tpl diff --git a/public/templates/mpos/dashboard/js_static.tpl b/public/templates/mpos/dashboard/js_static.tpl new file mode 100644 index 00000000..b2468644 --- /dev/null +++ b/public/templates/mpos/dashboard/js_static.tpl @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + diff --git a/public/templates/mpos/dashboard/network_info.tpl b/public/templates/mpos/dashboard/network_info.tpl index 22bf9e79..1c8691c5 100644 --- a/public/templates/mpos/dashboard/network_info.tpl +++ b/public/templates/mpos/dashboard/network_info.tpl @@ -3,9 +3,9 @@ Difficulty - + {$NETWORK.difficulty} Current Block - + {$NETWORK.block} diff --git a/public/templates/mpos/dashboard/overview.tpl b/public/templates/mpos/dashboard/overview.tpl index 61b76021..779b1db7 100644 --- a/public/templates/mpos/dashboard/overview.tpl +++ b/public/templates/mpos/dashboard/overview.tpl @@ -1,5 +1,5 @@
-

Overview {if $GLOBAL.config.price.currency}{$GLOBAL.config.currency}/{$GLOBAL.config.price.currency}: {/if} / Pool Workers:

+

Overview {if $GLOBAL.config.price.currency}{$GLOBAL.config.currency}/{$GLOBAL.config.price.currency}: {$GLOBAL.price}{/if} / Pool Workers: {$GLOBAL.workers}

@@ -14,9 +14,11 @@
+ {if !$DISABLED_DASHBOARD and !$DISABLED_DASHBOARD_API}
+ {/if}