From 54371ffe11b3adfc9f36277dbbf07a11f289f0cf Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 1 Jul 2013 12:12:04 +0200 Subject: [PATCH 1/2] Updated inline config documentation Added reference to trade header removal. This allows users to disable the trade header at the top of the page by setting currency to an empty string. Addresses #305 --- public/include/config/global.inc.dist.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 317a3b32..acaa51bb 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -61,7 +61,8 @@ $config['wallet']['password'] = 'testnet'; * Explanation: * mmcfe-ng will try to fetch the current exchange rates * from this API URL/target. Currently btc-e and coinchoose - * are supported in mmcfe-ng. + * are supported in mmcfe-ng. If you want to remove the trade + * header just set currency to an empty string. * * Default (btc-e.com): * url = `https://btc-e.com` From e3c1d7e0d05028b32663b845be8ba7f3121d1a92 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 1 Jul 2013 12:32:59 +0200 Subject: [PATCH 2/2] Modfied templates to support empty trade currency This will remove any template content related to the trade currency if that one is left empty in the configuration. While going through the templates I also cleaned up the PHP Warnings left. The code and templates should now process without throwing any PHP warnings. Fixes #305 and further addresses #301 --- public/include/pages/admin/settings.inc.php | 2 +- public/include/pages/logout.inc.php | 1 + public/include/pages/statistics/blocks.inc.php | 3 +-- public/include/pages/statistics/pool.inc.php | 4 ++-- public/templates/mmcFE/admin/transactions/default.tpl | 7 +++++-- public/templates/mmcFE/global/sidebar_pps.tpl | 4 ++-- public/templates/mmcFE/global/sidebar_prop.tpl | 4 ++-- public/templates/mmcFE/logout/default.tpl | 0 .../templates/mmcFE/statistics/pool/authenticated.tpl | 2 +- .../mmcFE/statistics/pool/contributors_hashrate.tpl | 10 +++++----- 10 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 public/templates/mmcFE/logout/default.tpl diff --git a/public/include/pages/admin/settings.inc.php b/public/include/pages/admin/settings.inc.php index 34946173..dab1f096 100644 --- a/public/include/pages/admin/settings.inc.php +++ b/public/include/pages/admin/settings.inc.php @@ -9,7 +9,7 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { die("404 Page not found"); } -if ($_REQUEST['do'] == 'save' && !empty($_REQUEST['data'])) { +if (@$_REQUEST['do'] == 'save' && !empty($_REQUEST['data'])) { foreach($_REQUEST['data'] as $var => $value) { $setting->setValue($var, $value); } diff --git a/public/include/pages/logout.inc.php b/public/include/pages/logout.inc.php index b10415f4..8622fd8e 100644 --- a/public/include/pages/logout.inc.php +++ b/public/include/pages/logout.inc.php @@ -6,5 +6,6 @@ if (!defined('SECURITY')) // This probably (?) never fails $user->logoutUser(); +$smarty->assign("CONTENT", "default.tpl"); header('Location: index.php?page=home'); ?> diff --git a/public/include/pages/statistics/blocks.inc.php b/public/include/pages/statistics/blocks.inc.php index 011f4b5c..c65ea861 100644 --- a/public/include/pages/statistics/blocks.inc.php +++ b/public/include/pages/statistics/blocks.inc.php @@ -5,9 +5,8 @@ if (!defined('SECURITY')) die('Hacking attempt'); if (!$user->isAuthenticated()) header("Location: index.php?page=home"); // Grab the last blocks found -$iLimit = 20; +empty($_REQUEST['limit']) ? $iLimit = 20 : $iLimit = $_REQUEST['limit']; $aBlocksFoundData = $statistics->getBlocksFound($iLimit); -$aBlockData = $aBlocksFoundData[0]; // Propagate content our template $smarty->assign("BLOCKSFOUND", $aBlocksFoundData); diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index 12605353..17129628 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -25,7 +25,7 @@ $aContributorsHashes = $statistics->getTopContributors('hashes', 15); // Grab the last 10 blocks found $iLimit = 5; $aBlocksFoundData = $statistics->getBlocksFound($iLimit); -$aBlockData = $aBlocksFoundData[0]; +count($aBlocksFoundData) > 0 ? $aBlockData = $aBlocksFoundData[0] : $aBlockData = array(); // Estimated time to find the next block $iCurrentPoolHashrate = $statistics->getCurrentHashrate(); @@ -50,7 +50,7 @@ $smarty->assign("BLOCKLIMIT", $iLimit); $smarty->assign("CONTRIBSHARES", $aContributorsShares); $smarty->assign("CONTRIBHASHES", $aContributorsHashes); $smarty->assign("CURRENTBLOCK", $iBlock); -$smarty->assign("LASTBLOCK", $aBlockData['height']); +count($aBlockData) > 0 ? $smarty->assign("LASTBLOCK", $aBlockData['height']) : $smarty->assign("LASTBLOCK", 0); $smarty->assign("DIFFICULTY", $dDifficulty); $smarty->assign("REWARD", $config['reward']); diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index 492b1a97..d611f6d6 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -1,7 +1,7 @@ {include file="global/block_header.tpl" BLOCK_HEADER="Transaction Log" BUTTONS=array(Confirmed,Unconfirmed,Orphan)}
- - + +
@@ -18,6 +18,7 @@ + {assign var=confirmed value=0} {section transaction $TRANSACTIONS} {if ( (($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus')and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations) @@ -71,6 +72,7 @@ + {assign var=unconfirmed value=0} {section transaction $TRANSACTIONS} {if ( ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations @@ -114,6 +116,7 @@ + {assign var=orphaned value=0} {section transaction $TRANSACTIONS} {if ( $TRANSACTIONS[transaction].type == 'Orphan_Credit' diff --git a/public/templates/mmcFE/global/sidebar_pps.tpl b/public/templates/mmcFE/global/sidebar_pps.tpl index dcd436d5..b90f9aed 100644 --- a/public/templates/mmcFE/global/sidebar_pps.tpl +++ b/public/templates/mmcFE/global/sidebar_pps.tpl @@ -30,11 +30,11 @@ Pool Invalid - {$GLOBAL.roundshares.invalid|number_format} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.roundshares.invalid)|number_format:"2"}%) + {$GLOBAL.roundshares.invalid|number_format}{if $GLOBAL.roundshares.valid > 0} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.roundshares.invalid)|number_format:"2"}%){/if} Your Invalid - {$GLOBAL.userdata.shares.invalid|number_format} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.userdata.shares.invalid)|number_format:"2"}%) + {$GLOBAL.userdata.shares.invalid|number_format}{if $GLOBAL.roundshares.valid > 0} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.userdata.shares.invalid)|number_format:"2"}%){/if}   {$GLOBAL.config.currency} Estimates diff --git a/public/templates/mmcFE/global/sidebar_prop.tpl b/public/templates/mmcFE/global/sidebar_prop.tpl index 0c50e577..b3075c57 100644 --- a/public/templates/mmcFE/global/sidebar_prop.tpl +++ b/public/templates/mmcFE/global/sidebar_prop.tpl @@ -33,11 +33,11 @@ Pool Invalid - {$GLOBAL.roundshares.invalid|number_format} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.roundshares.invalid)|number_format:"2"}%) + {$GLOBAL.roundshares.invalid|number_format}{if $GLOBAL.roundshares.valid > 0} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.roundshares.invalid)|number_format:"2"}%){/if} Your Invalid - {$GLOBAL.userdata.shares.invalid|number_format} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.userdata.shares.invalid)|number_format:"2"}%) + {$GLOBAL.userdata.shares.invalid|number_format}{if $GLOBAL.roundshares.valid > 0} ({(100 / $GLOBAL.roundshares.valid * $GLOBAL.userdata.shares.invalid)|number_format:"2"}%){/if} {$GLOBAL.config.currency} Round Estimate diff --git a/public/templates/mmcFE/logout/default.tpl b/public/templates/mmcFE/logout/default.tpl new file mode 100644 index 00000000..e69de29b diff --git a/public/templates/mmcFE/statistics/pool/authenticated.tpl b/public/templates/mmcFE/statistics/pool/authenticated.tpl index edc0e0ba..f740c91e 100644 --- a/public/templates/mmcFE/statistics/pool/authenticated.tpl +++ b/public/templates/mmcFE/statistics/pool/authenticated.tpl @@ -13,7 +13,7 @@ Pool Efficiency - {(100 - (100 / $GLOBAL.roundshares.valid * $GLOBAL.roundshares.invalid))|number_format:"2"} % + {if $GLOBAL.roundshares.valid > 0}{(100 - (100 / $GLOBAL.roundshares.valid * $GLOBAL.roundshares.invalid))|number_format:"2"}{else}0{/if} % Current Active Workers diff --git a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl index 3e8791e3..2de97f37 100644 --- a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl +++ b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl @@ -7,30 +7,30 @@ User Name KH/s {$GLOBAL.config.currency}/Day - {$GLOBAL.config.price.currency}/Day + {if $GLOBAL.config.price.currency}{$GLOBAL.config.price.currency}/Day{/if} {assign var=rank value=1} {assign var=listed value=0} {section contrib $CONTRIBHASHES} - {math assign="estday" equation="round(reward / ( diff * pow(2,32) / ( hashrate * 1000 ) / 3600 / 24), 3)" diff=$DIFFICULTY reward=$REWARD hashrate=$CONTRIBHASHES[contrib].hashrate} + {if $GLOBAL.userdata.hashrate > 0}{math assign="estday" equation="round(reward / ( diff * pow(2,32) / ( hashrate * 1000 ) / 3600 / 24), 3)" diff=$DIFFICULTY reward=$REWARD hashrate=$CONTRIBHASHES[contrib].hashrate}{/if} {$rank++} {$CONTRIBHASHES[contrib].account} {$CONTRIBHASHES[contrib].hashrate|number_format} {$estday|number_format:"3"} - {($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"} + {if $GLOBAL.config.price.currency}{($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"}{/if} {/section} {if $listed != 1} - {math assign="estday" equation="round(reward / ( diff * pow(2,32) / ( hashrate * 1000 ) / 3600 / 24), 3)" diff=$DIFFICULTY reward=$REWARD hashrate=$GLOBAL.userdata.hashrate} + {if $GLOBAL.userdata.hashrate > 0}{math assign="estday" equation="round(reward / ( diff * pow(2,32) / ( hashrate * 1000 ) / 3600 / 24), 3)" diff=$DIFFICULTY reward=$REWARD hashrate=$GLOBAL.userdata.hashrate}{/if} n/a {$GLOBAL.userdata.username} {$GLOBAL.userdata.hashrate} {$estday|number_format:"3"|default:"n/a"} - {($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"} + {if $GLOBAL.config.price.currency}{($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"}{/if} {/if}