php-mpos/public/include/pages/statistics.inc.php
Sebastian Grewe bffeea07c9 Adding cache detection to many pages
This will allow pages to skip loading data from backends like the
database or the wallet RPC server. If a cached page is detected and
valid, all dynamic content generation will be skipped completely.

Other pages that have not been adjusted in this commit will still fetch
backend data all the time. This will ensure clients always see the most
recent data, like worker information or account changes.

This should fix #309 completely but needs some testing.
2013-07-11 09:02:34 +02:00

27 lines
911 B
PHP

<?php
// Make sure we are called from index.php
if (!defined('SECURITY'))
die('Hacking attempt');
if (!$smarty->isCached('master.tpl', md5(serialize($_REQUEST)))) {
$debug->append('No cached version available, fetching from backend', 3);
if ($bitcoin->can_connect() === true){
$dDifficulty = $bitcoin->query('getdifficulty');
if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty))
$dDifficulty = $dDifficulty['proof-of-work'];
$iBlock = $bitcoin->query('getblockcount');
} else {
$dDifficulty = 1;
$iBlock = 0;
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
}
$smarty->assign("CURRENTBLOCK", $iBlock);
$smarty->assign("DIFFICULTY", $dDifficulty);
} else {
$debug->append('Using cached page', 3);
}
$smarty->assign("CONTENT", "default.tpl");
?>