Getting rid of various PHP notice warnings

* Assigned empty defaults on templates
* Added some variable checking
This commit is contained in:
Sebastian Grewe 2013-05-31 11:56:56 +02:00
parent cd13feee70
commit b2725fbce5
8 changed files with 27 additions and 25 deletions

View File

@ -9,7 +9,7 @@ if ($bitcoin->can_connect() === true){
$dDifficulty = $bitcoin->getdifficulty();
$iBlock = $bitcoin->getblockcount();
} else {
$iDifficulty = 1;
$dDifficulty = 1;
$iBlock = 0;
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
}

View File

@ -29,18 +29,20 @@ $aGlobal = array(
);
// We don't want these session infos cached
$aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array();
$aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']['id']);
if (@$_SESSION['USERDATA']['id']) {
$aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array();
$aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']['id']);
// Other userdata that we can cache savely
$aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['id']);
$aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']);
// Other userdata that we can cache savely
$aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['id']);
$aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']);
// Some estimations
$aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (int)$config['reward'], 3);
$aGlobal['userdata']['est_fee'] = round(($config['fees'] / 100) * $aGlobal['userdata']['est_block'], 3);
$aGlobal['userdata']['est_donation'] = round((( $aGlobal['userdata']['donate_percent'] / 100) * ($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_fee'])), 3);
$aGlobal['userdata']['est_payout'] = round($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_donation'] - $aGlobal['userdata']['est_fee'], 3);
// Some estimations
$aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (int)$config['reward'], 3);
$aGlobal['userdata']['est_fee'] = round(($config['fees'] / 100) * $aGlobal['userdata']['est_block'], 3);
$aGlobal['userdata']['est_donation'] = round((( $aGlobal['userdata']['donate_percent'] / 100) * ($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_fee'])), 3);
$aGlobal['userdata']['est_payout'] = round($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_donation'] - $aGlobal['userdata']['est_fee'], 3);
}
// Make it available in Smarty
$smarty->assign('PATH', 'site_assets/' . THEME);

View File

@ -77,7 +77,7 @@
{/section}
<tr>
<td colspan="5"><b>Unconfirmed Totals:</b></td>
<td><b>{$credits - $debits}</b></td>
<td><b>{$credits|default - $debits|default}</b></td>
</tr>
</tbody>
</table>
@ -121,7 +121,7 @@
{/section}
<tr>
<td colspan="5"><b>Orphaned Totals:</b></td>
<td><b>{$orphan_credits - $orphan_debits}</b></td>
<td><b>{$orphan_credits|default - $orphan_debits|default}</b></td>
</tr>
</tbody>
</table>

View File

@ -1,9 +1,9 @@
<div class="block{if $ALIGN} small {$ALIGN}{/if}" style="{if $BLOCK_STYLE}{$BLOCK_STYLE}{else}clear:none;{/if}">
<div class="block{if $ALIGN|default} small {$ALIGN}{/if}" style="{if $BLOCK_STYLE|default}{$BLOCK_STYLE}{else}clear:none;{/if}">
<div class="block_head">
<div class="bheadl"></div>
<div class="bheadr"></div>
<h2>{$BLOCK_HEADER|default:"UNKNOWN BLOCK"}</h2>
{if $BUTTONS}
{if $BUTTONS|default}
<ul class="tabs">
{foreach from=$BUTTONS item=name}
<li style="font-size:9px;"><a href="#{$name}">{$name}</a></li>
@ -11,4 +11,4 @@
</ul>
{/if}
</div>
<div class="block_content" style="{if $STYLE}{$STYLE}{else}padding:10px;{/if}">
<div class="block_content" style="{if $STYLE|default}{$STYLE}{else}padding:10px;{/if}">

View File

@ -1,4 +1,4 @@
{if $GLOBAL.motd}
{if $GLOBAL.motd|default}
<div id="generic_infobox" style="margin-left:3px;">
<font color="orange" size="1">***Message of the Day***<br></font>
<font size="1">{$GLOBAL.motd|escape:'html'}</font>

View File

@ -1,6 +1,6 @@
<ul id="nav">
<li><a href="{$smarty.server.PHP_SELF}">Home</a></li>
{if $smarty.session.AUTHENTICATED == 1}
{if $smarty.session.AUTHENTICATED|default:"0" == 1}
<li><a href="">My Account</a>
<ul>
<li><a href="{$smarty.server.PHP_SELF}?page=account&action=edit">Edit Account</a></li>
@ -10,11 +10,11 @@
</ul>
</li>
{/if}
{if $smarty.session.AUTHENTICATED == 1 && $GLOBAL.userdata.admin == 1}<li><a href="#">Admin Panel</a></li>{/if}
{if $smarty.session.AUTHENTICATED|default:"0" == 1 && $GLOBAL.userdata.admin == 1}<li><a href="#">Admin Panel</a></li>{/if}
<li><a href="{$smarty.server.PHP_SELF}?page=statistics">Statistics</a>
<ul>
<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=pool">Pool Stats</a></li>
{if $smarty.session.AUTHENTICATED}<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=blocks">Block Stats</a></li>{/if}
{if $smarty.session.AUTHENTICATED|default}<li><a href="{$smarty.server.PHP_SELF}?page=statistics&action=blocks">Block Stats</a></li>{/if}
</ul>
</li>
<li><a href="{$smarty.server.PHP_SELF}?page=gettingstarted">Getting Started</a></li>
@ -25,5 +25,5 @@
</ul>
</li>
<li><a href="{$smarty.server.PHP_SELF}?page=news">News</a></li>
{if $smarty.session.AUTHENTICATED == 1}<li><a href="{$smarty.server.PHP_SELF}?page=logout">Logout</a></li>{else}<li><a href="{$smarty.server.PHP_SELF}?page=register">Register</a></li>{/if}
{if $smarty.session.AUTHENTICATED|default == 1}<li><a href="{$smarty.server.PHP_SELF}?page=logout">Logout</a></li>{else}<li><a href="{$smarty.server.PHP_SELF}?page=register">Register</a></li>{/if}
</ul>

View File

@ -1,4 +1,4 @@
{if $GLOBAL.userdata.username}
{if $GLOBAL.userdata.username|default}
<h2>Welcome, {$smarty.session.USERDATA.username} <font size='1px'><b>Active Account</b>: <b>{$GLOBAL.fees}%</b> Pool Fee</font> <font size='1px'><i>(You are <a href='/osList'>donating</a> <b></i>{$GLOBAL.userdata.donate_percent}%</b> <i>of your earnings)</i></font></h2>
{else}
<h2>Welcome guest, <font size="1px"> please <a href="{$smarty.server.PHP_SELF}?page=register">register</a> to user this pool.</font></h2>

View File

@ -4,7 +4,7 @@
<title>ThePool</title>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" href="{$PATH}/css/mainstyle.css" type="text/css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="{$PATH}/js/jquery.browser.js"></script>
@ -45,14 +45,14 @@
</div>
<div class="block_content">
<div class="sidebar">
{if $smarty.session.AUTHENTICATED}
{if $smarty.session.AUTHENTICATED|default}
{include file="global/sidebar.tpl"}
{else}
{include file="global/login.tpl"}
{/if}
</div>
<div class="sidebar_content" id="sb1" style="margin-left: 13px">
{if is_array($smarty.session.POPUP)}
{if is_array($smarty.session.POPUP|default)}
{section popup $smarty.session.POPUP}
<div class="message {$smarty.session.POPUP[popup].TYPE|default:"success"}"><p>{$smarty.session.POPUP[popup].CONTENT}</p></div>
{/section}