Disable caching check on Smarty globals
This will ensure data is available for those pages relying on global data. A better step might be to load template specific data always on the pages that require the data instead of relying on global data to be available. Fixes #309
This commit is contained in:
parent
bb0e9dff39
commit
d25387f0b5
@ -7,34 +7,33 @@ if (!defined('SECURITY'))
|
|||||||
// Globally available variables
|
// Globally available variables
|
||||||
$debug->append('Global smarty variables', 3);
|
$debug->append('Global smarty variables', 3);
|
||||||
|
|
||||||
if (!$smarty->isCached('master.tpl', md5(serialize($_REQUEST)))) {
|
$debug->append('No cached page detected, loading smarty globals', 3);
|
||||||
$debug->append('No cached page detected, loading smarty globals', 3);
|
// Defaults to get rid of PHP Notice warnings
|
||||||
// Defaults to get rid of PHP Notice warnings
|
$dDifficulty = 1;
|
||||||
$dDifficulty = 1;
|
$aRoundShares = 1;
|
||||||
$aRoundShares = 1;
|
|
||||||
|
|
||||||
// Only run these if the user is logged in
|
// Only run these if the user is logged in
|
||||||
if (@$_SESSION['AUTHENTICATED']) {
|
if (@$_SESSION['AUTHENTICATED']) {
|
||||||
$aRoundShares = $statistics->getRoundShares();
|
$aRoundShares = $statistics->getRoundShares();
|
||||||
if ($bitcoin->can_connect() === true) {
|
if ($bitcoin->can_connect() === true) {
|
||||||
$dDifficulty = $bitcoin->query('getdifficulty');
|
$dDifficulty = $bitcoin->query('getdifficulty');
|
||||||
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
|
||||||
$dDifficulty = $dDifficulty['proof-of-work'];
|
$dDifficulty = $dDifficulty['proof-of-work'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Always fetch this since we need for ministats header
|
// Always fetch this since we need for ministats header
|
||||||
$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0;
|
$bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0;
|
||||||
|
|
||||||
// Fetch some data
|
// Fetch some data
|
||||||
$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers();
|
$iCurrentActiveWorkers = $worker->getCountAllActiveWorkers();
|
||||||
$iCurrentPoolHashrate = $statistics->getCurrentHashrate();
|
$iCurrentPoolHashrate = $statistics->getCurrentHashrate();
|
||||||
$iCurrentPoolShareRate = $statistics->getCurrentShareRate();
|
$iCurrentPoolShareRate = $statistics->getCurrentShareRate();
|
||||||
|
|
||||||
// Avoid confusion, ensure our nethash isn't higher than poolhash
|
// Avoid confusion, ensure our nethash isn't higher than poolhash
|
||||||
if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate;
|
if ($iCurrentPoolHashrate > $dNetworkHashrate) $dNetworkHashrate = $iCurrentPoolHashrate;
|
||||||
|
|
||||||
// Global data for Smarty
|
// Global data for Smarty
|
||||||
$aGlobal = array(
|
$aGlobal = array(
|
||||||
'slogan' => $config['website']['slogan'],
|
'slogan' => $config['website']['slogan'],
|
||||||
'websitename' => $config['website']['name'],
|
'websitename' => $config['website']['name'],
|
||||||
'hashrate' => $iCurrentPoolHashrate,
|
'hashrate' => $iCurrentPoolHashrate,
|
||||||
@ -60,22 +59,22 @@ if (!$smarty->isCached('master.tpl', md5(serialize($_REQUEST)))) {
|
|||||||
'max' => $config['ap_threshold']['max']
|
'max' => $config['ap_threshold']['max']
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Special calculations for PPS Values based on reward_type setting and/or available blocks
|
// Special calculations for PPS Values based on reward_type setting and/or available blocks
|
||||||
if ($config['reward_type'] != 'block') {
|
if ($config['reward_type'] != 'block') {
|
||||||
$aGlobal['ppsvalue'] = number_format(round(50 / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
$aGlobal['ppsvalue'] = number_format(round(50 / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||||
} else {
|
} else {
|
||||||
// Try to find the last block value and use that for future payouts, revert to fixed reward if none found
|
// Try to find the last block value and use that for future payouts, revert to fixed reward if none found
|
||||||
if ($aLastBlock = $block->getLast()) {
|
if ($aLastBlock = $block->getLast()) {
|
||||||
$aGlobal['ppsvalue'] = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
$aGlobal['ppsvalue'] = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||||
} else {
|
} else {
|
||||||
$aGlobal['ppsvalue'] = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
$aGlobal['ppsvalue'] = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't want these session infos cached
|
// We don't want these session infos cached
|
||||||
if (@$_SESSION['USERDATA']['id']) {
|
if (@$_SESSION['USERDATA']['id']) {
|
||||||
$aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array();
|
$aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array();
|
||||||
$aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']['id']);
|
$aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']['id']);
|
||||||
|
|
||||||
@ -108,15 +107,12 @@ if (!$smarty->isCached('master.tpl', md5(serialize($_REQUEST)))) {
|
|||||||
$_SESSION['POPUP'][] = array('CONTENT' => 'You have exceeded your accounts balance. Please transfer some ' . $config['currency'] . "!", 'TYPE' => 'errormsg');
|
$_SESSION['POPUP'][] = array('CONTENT' => 'You have exceeded your accounts balance. Please transfer some ' . $config['currency'] . "!", 'TYPE' => 'errormsg');
|
||||||
if ($user->getUserFailed($_SESSION['USERDATA']['id']) > 0)
|
if ($user->getUserFailed($_SESSION['USERDATA']['id']) > 0)
|
||||||
$_SESSION['POPUP'][] = array('CONTENT' => 'You have ' . $user->getUserFailed($_SESSION['USERDATA']['id']) . ' failed login attempts! <a href="?page=account&action=reset_failed">Reset Counter</a>', 'TYPE' => 'errormsg');
|
$_SESSION['POPUP'][] = array('CONTENT' => 'You have ' . $user->getUserFailed($_SESSION['USERDATA']['id']) . ' failed login attempts! <a href="?page=account&action=reset_failed">Reset Counter</a>', 'TYPE' => 'errormsg');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($setting->getValue('maintenance'))
|
if ($setting->getValue('maintenance'))
|
||||||
$_SESSION['POPUP'][] = array('CONTENT' => 'This pool is currently in maintenance mode.', 'TYPE' => 'warning');
|
$_SESSION['POPUP'][] = array('CONTENT' => 'This pool is currently in maintenance mode.', 'TYPE' => 'warning');
|
||||||
|
|
||||||
// Make it available in Smarty
|
// Make it available in Smarty
|
||||||
$smarty->assign('PATH', 'site_assets/' . THEME);
|
$smarty->assign('PATH', 'site_assets/' . THEME);
|
||||||
$smarty->assign('GLOBAL', $aGlobal);
|
$smarty->assign('GLOBAL', $aGlobal);
|
||||||
} else {
|
|
||||||
$debug->append('We found a cached page, not loaded smarty globals', 3);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user