From 5acebc37d3c1f0439c4ed0bb9ae8035305c360e4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 9 Jul 2013 16:13:43 +0200 Subject: [PATCH] Allow guest access to pages with config options This will allow pool owners to make certain pages public accessible without user registration or login. Please check the config dist file for details. Fixes #408 --- public/include/config/global.inc.dist.php | 16 ++++++++++++++++ public/include/pages/statistics/blocks.inc.php | 7 +++++-- public/include/pages/statistics/pool.inc.php | 4 +++- public/include/smarty_globals.inc.php | 2 +- public/templates/mmcFE/global/navigation.tpl | 8 ++++++++ .../statistics/pool/contributors_hashrate.tpl | 2 +- .../statistics/pool/contributors_shares.tpl | 2 +- 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 9390b534..162bba00 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -121,6 +121,22 @@ $config['website']['theme'] = 'mmcFE'; $config['website']['mobile'] = true; $config['website']['mobile_theme'] = 'mobile'; +/** + * Some basic access restrictions on some pages + * + * Explanation: + * Some pools would like to run a few pages for public access instead + * of enforcing a login. You can change visibility of some pages here. + * + * Options: + * 'public' : Allow guest access and authenticated user to view page + * 'private' : Only allow logged in users access to view page + * + * Defaults: + * 'private' for every page + **/ +$config['website']['acl']['statistics']['pool'] = 'private'; +$config['website']['acl']['statistics']['blocks'] = 'private'; /** * Re-Captcha settings diff --git a/public/include/pages/statistics/blocks.inc.php b/public/include/pages/statistics/blocks.inc.php index 6c3b00b8..22eeadff 100644 --- a/public/include/pages/statistics/blocks.inc.php +++ b/public/include/pages/statistics/blocks.inc.php @@ -2,7 +2,6 @@ // Make sure we are called from index.php if (!defined('SECURITY')) die('Hacking attempt'); -if (!$user->isAuthenticated()) header("Location: index.php?page=home"); // Grab the last blocks found $iLimit = 20; @@ -12,5 +11,9 @@ $aBlocksFoundData = $statistics->getBlocksFound($iLimit); $smarty->assign("BLOCKSFOUND", $aBlocksFoundData); $smarty->assign("BLOCKLIMIT", $iLimit); -$smarty->assign("CONTENT", "default.tpl"); +if ($config['website']['acl']['statistics']['blocks'] == 'public') { + $smarty->assign("CONTENT", "default.tpl"); +} else if ($user->isAuthenticated()) { + $smarty->assign("CONTENT", "default.tpl"); +} ?> diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index 1cab1009..27395cc1 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -53,7 +53,9 @@ count($aBlockData) > 0 ? $smarty->assign("LASTBLOCK", $aBlockData['height']) : $ $smarty->assign("DIFFICULTY", $dDifficulty); $smarty->assign("REWARD", $config['reward']); -if ($user->isAuthenticated()) { +if ($config['website']['acl']['statistics']['pool'] == 'public') { + $smarty->assign("CONTENT", "authenticated.tpl"); +} else if ($user->isAuthenticated() && $config['website']['acl']['statistics']['pool'] == 'private') { $smarty->assign("CONTENT", "authenticated.tpl"); } else { $smarty->assign("CONTENT", "../default.tpl"); diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 147b38e9..be65e39e 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -47,7 +47,7 @@ $aGlobal = array( 'blockexplorer' => $config['blockexplorer'], 'chaininfo' => $config['chaininfo'], 'config' => array( - 'website' => array( 'title' => $config['website']['title'] ), + 'website' => array( 'title' => $config['website']['title'], 'acl' => $config['website']['acl'] ), 'price' => array( 'currency' => $config['price']['currency'] ), 'targetdiff' => $config['difficulty'], 'currency' => $config['currency'], diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 70619098..6cafd1f6 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -31,6 +31,14 @@ {else}
  • Statistics + {/if}
  • Getting Started
  • Support
  • diff --git a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl index 7b294265..a2a6ed58 100644 --- a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl +++ b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl @@ -23,7 +23,7 @@ {if $GLOBAL.config.price.currency}{($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"}{/if} {/section} -{if $listed != 1} +{if $listed != 1 && $GLOBAL.userdata.username|default:""} {if $GLOBAL.userdata.hashrate > 0}{math assign="myestday" equation="round(reward / ( diff * pow(2,32) / ( hashrate * 1000 ) / 3600 / 24), 3)" diff=$DIFFICULTY reward=$REWARD hashrate=$GLOBAL.userdata.hashrate}{/if} n/a diff --git a/public/templates/mmcFE/statistics/pool/contributors_shares.tpl b/public/templates/mmcFE/statistics/pool/contributors_shares.tpl index 444effa4..2a482209 100644 --- a/public/templates/mmcFE/statistics/pool/contributors_shares.tpl +++ b/public/templates/mmcFE/statistics/pool/contributors_shares.tpl @@ -18,7 +18,7 @@ {$CONTRIBSHARES[hashrate].shares|number_format} {/section} -{if $listed != 1} +{if $listed != 1 && $GLOBAL.userdata.username|default:""} n/a {$GLOBAL.userdata.username}