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
+4
View File
@@ -8,6 +8,10 @@ include('menu.tpl');
</tr></thead><tbody> </tr></thead><tbody>
<?php <?php
$varray = $database->getProfileVillages($session->uid); $varray = $database->getProfileVillages($session->uid);
$woodSUM = 0;
$claySUM = 0;
$ironSUM = 0;
$cropSUM = 0;
foreach($varray as $vil){ foreach($varray as $vil){
$vid = $vil['wref']; $vid = $vil['wref'];
$vdata = $database->getVillage($vid); $vdata = $database->getVillage($vid);
+14 -5
View File
@@ -18,7 +18,7 @@
<?php <?php
foreach($varray as $vil) { foreach($varray as $vil) {
$vid = $vil['wref']; $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); $units = $database->getEnforceVillage($vid,1);
array_unshift($units,$database->getUnit($vid)); array_unshift($units,$database->getUnit($vid));
@@ -31,18 +31,27 @@
$uni['u'.$i] += $unit['u'.$i]; $uni['u'.$i] += $unit['u'.$i];
$unit_total['u'.$i] += $unit['u'.$i]; $unit_total['u'.$i] += $unit['u'.$i];
} }
$uni['u'.$i] += $movement['u'.$i]; if (isset($movement['u'.$i])) {
$unit_total['u'.$i] += $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';} if($uni['u'.$i] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$uni['u'.$i].'</td>'; echo '<td class="'.$cl.'">'.$uni['u'.$i].'</td>';
} }
$uni['hero'] = 0; $uni['hero'] = 0;
if (!isset($unit_total['hero'])) {
$unit_total['hero'] = 0;
}
foreach($units as $unit) { foreach($units as $unit) {
$uni['hero'] += $unit['hero']; $uni['hero'] += $unit['hero'];
$unit_total['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';} if($uni['hero'] !=0){$cl = '';}else{$cl = 'none';}
echo '<td class="'.$cl.'">'.$uni['hero'].'</td>'; echo '<td class="'.$cl.'">'.$uni['hero'].'</td>';
echo '</tr>'; echo '</tr>';
+4 -4
View File
@@ -1,7 +1,7 @@
<div id="textmenu"> <div id="textmenu">
<a href="dorf3.php" class="<?php if(!isset($_GET['s'])){echo 'selected';}?>">Overview</a> <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=2" class="<?php if(isset($_GET['s']) && $_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=3" class="<?php if(isset($_GET['s']) && $_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=4" class="<?php if(isset($_GET['s']) && $_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=5" class="<?php if(isset($_GET['s']) && $_GET['s'] == 5){echo 'selected';}?>">Troops</a>
</div> </div>