fix: undefined indexes

This commit is contained in:
Martin Ambrus
2017-11-20 21:34:54 +01:00
parent f58878abfa
commit 4f20ae4c0e
3 changed files with 26 additions and 13 deletions
+8 -4
View File
@@ -7,10 +7,14 @@ include('menu.tpl');
<td>Village</td><td><img class="r1" src="img/x.gif" title="" alt=""></td><td><img class="r2" src="img/x.gif" title="" alt=""></td><td><img class="r3" src="img/x.gif" title="" alt=""></td><td><img class="r4" src="img/x.gif" title="" alt=""></td><td>Merchants</td>
</tr></thead><tbody>
<?php
$varray = $database->getProfileVillages($session->uid);
foreach($varray as $vil){
$varray = $database->getProfileVillages($session->uid);
$woodSUM = 0;
$claySUM = 0;
$ironSUM = 0;
$cropSUM = 0;
foreach($varray as $vil){
$vid = $vil['wref'];
$vdata = $database->getVillage($vid);
$vdata = $database->getVillage($vid);
$totalmerchants = $building->getTypeLevel(17,$vid);
$availmerchants = $totalmerchants - $database->totalMerchantUsed($vid);
if($vdata['wood'] > $vdata['maxstore']) { $wood = $vdata['maxstore']; } else { $wood = $vdata['wood']; }
@@ -28,7 +32,7 @@ foreach($varray as $vil){
<td class="tra lc">'.($totalmerchants>0?'<a href="build.php?newdid='.$vid.'&amp;gid=17">':'').$availmerchants.'/'.$totalmerchants.'</a></td>
</tr>
';
$woodSUM += $wood;
$woodSUM += $wood;
$claySUM += $clay;
$ironSUM += $iron;
$cropSUM += $crop;
+14 -5
View File
@@ -18,7 +18,7 @@
<?php
foreach($varray as $vil) {
$vid = $vil['wref'];
if($vdata['capital'] == 1){$class = 'hl';}else{$class = '';}
if(isset($vdata) && $vdata['capital'] == 1){$class = 'hl';}else{$class = '';}
$units = $database->getEnforceVillage($vid,1);
array_unshift($units,$database->getUnit($vid));
@@ -31,18 +31,27 @@
$uni['u'.$i] += $unit['u'.$i];
$unit_total['u'.$i] += $unit['u'.$i];
}
$uni['u'.$i] += $movement['u'.$i];
$unit_total['u'.$i] += $movement['u'.$i];
if (isset($movement['u'.$i])) {
$uni[ 'u' . $i ] += $movement[ 'u' . $i ];
$unit_total['u'.$i] += $movement['u'.$i];
}
if($uni['u'.$i] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$uni['u'.$i].'</td>';
}
$uni['hero'] = 0;
if (!isset($unit_total['hero'])) {
$unit_total['hero'] = 0;
}
foreach($units as $unit) {
$uni['hero'] += $unit['hero'];
$unit_total['hero'] += $unit['hero'];
}
$uni['hero'] += $movement['hero'];
$unit_total['hero'] += $movement['hero'];
if (isset($movement['hero'])) {
$uni['hero'] += $movement['hero'];
$unit_total['hero'] += $movement['hero'];
}
if($uni['hero'] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$uni['hero'].'</td>';
echo '</tr>';
+4 -4
View File
@@ -1,7 +1,7 @@
<div id="textmenu">
<a href="dorf3.php" class="<?php if(!isset($_GET['s'])){echo 'selected';}?>">Overview</a>
| <a href="dorf3.php?s=2" class="<?php if($_GET['s'] == 2){echo 'selected';}?>">Resources</a>
| <a href="dorf3.php?s=3" class="<?php if($_GET['s'] == 3){echo 'selected';}?>">Warehouse</a>
| <a href="dorf3.php?s=4" class="<?php if($_GET['s'] == 4){echo 'selected';}?>">CP</a>
| <a href="dorf3.php?s=5" class="<?php if($_GET['s'] == 5){echo 'selected';}?>">Troops</a>
| <a href="dorf3.php?s=2" class="<?php if(isset($_GET['s']) && $_GET['s'] == 2){echo 'selected';}?>">Resources</a>
| <a href="dorf3.php?s=3" class="<?php if(isset($_GET['s']) && $_GET['s'] == 3){echo 'selected';}?>">Warehouse</a>
| <a href="dorf3.php?s=4" class="<?php if(isset($_GET['s']) && $_GET['s'] == 4){echo 'selected';}?>">CP</a>
| <a href="dorf3.php?s=5" class="<?php if(isset($_GET['s']) && $_GET['s'] == 5){echo 'selected';}?>">Troops</a>
</div>