fix: undefined indexes and variables

This commit is contained in:
Martin Ambrus
2017-10-28 02:18:00 +02:00
parent 6f7c70a0d7
commit eca2c9105c
6 changed files with 35 additions and 23 deletions
+23 -19
View File
@@ -3602,7 +3602,11 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
$movement = $database->getVillageMovement($base);
if(!empty($movement)) {
for($i=1;$i<=50;$i++) {
$ownunit['u'.$i] += $movement['u'.$i];
if (!isset($ownunit['u'.$i])) {
$ownunit['u'.$i] = 0;
}
$ownunit['u'.$i] += (isset($movement['u'.$i]) ? $movement['u'.$i] : 0);
}
}
$prisoners = $database->getPrisoners($base,1);
@@ -4184,24 +4188,24 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
{
if ($row['f' . $i . 't'] == 10)
{
$ress += $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
$ress += ((isset($bid10[$row['f' . $i]]) && isset($bid10[$row['f' . $i]]['attri'])) ? $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
}
if ($row['f' . $i . 't'] == 38)
{
$ress += $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
$ress += ((isset($bid38[$row['f' . $i]]) && isset($bid38[$row['f' . $i]]['attri'])) ? $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
}
if ($row['f' . $i . 't'] == 11)
{
$crop += $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
$crop += ((isset($bid11[$row['f' . $i]]) && isset($bid11[$row['f' . $i]]['attri'])) ? $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
}
if ($row['f' . $i . 't'] == 39)
{
$crop += $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER;
$crop += ((isset($bid39[$row['f' . $i]]) && isset($bid39[$row['f' . $i]]['attri'])) ? $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
}
}
@@ -4429,13 +4433,13 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
if(count($enforcearray)>0){
foreach ($enforcearray as $enforce){
for($i = 0 ; $i <= 50 ; $i++){
$units = $enforce['u'.$i];
if($enforce['u'.$i] > $maxcount){
$maxcount = $enforce['u'.$i];
$units = (isset($enforce['u'.$i]) ? $enforce['u'.$i] : 0);
if($units > $maxcount){
$maxcount = $units;
$maxtype = $i;
$enf = $enforce['id'];
}
$totalunits += $enforce['u'.$i];
$totalunits += $units;
}
if($totalunits == 0){
$maxcount = $enforce['hero'];
@@ -4449,13 +4453,13 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
if(count($enforcearray)>0){
foreach ($enforcearray as $enforce){
for($i = 0 ; $i <= 50 ; $i++){
$units = $enforce['u'.$i];
if($enforce['u'.$i] > $maxcount){
$maxcount = $enforce['u'.$i];
$units = (isset($enforce['u'.$i]) ? $enforce['u'.$i] : 0);
if($units > $maxcount){
$maxcount = $units;
$maxtype = $i;
$enf = $enforce['id'];
}
$totalunits += $enforce['u'.$i];
$totalunits += $units;
}
if($totalunits == 0){
$maxcount = $enforce['hero'];
@@ -4466,12 +4470,12 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
//get own unit
$unitarray = $database->getUnit($starv['wref']);
for($i = 0 ; $i <= 50 ; $i++){
$units = $unitarray['u'.$i];
if($unitarray['u'.$i] > $maxcount){
$maxcount = $unitarray['u'.$i];
$units = (isset($unitarray['u'.$i]) ? $unitarray['u'.$i] : 0);
if($units > $maxcount){
$maxcount = $units;
$maxtype = $i;
}
$totalunits += $unitarray['u'.$i];
$totalunits += $units;
}
if($totalunits == 0){
$maxcount = $unitarray['hero'];
@@ -4502,9 +4506,9 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
}
if($difcrop > 0){
global ${u.$maxtype};
global ${'u'.$maxtype};
$hungry=array();
$hungry=${u.$maxtype};
$hungry=${'u'.$maxtype};
if ($hungry['crop']>0 && $oldcrop <=0) {
$killunits = intval($difcrop/$hungry['crop']);
}else $killunits=0;
+7
View File
@@ -3577,8 +3577,15 @@ class MYSQLi_DB implements IDbConnection {
foreach($returningarray as $ret) {
if($ret['attack_type'] != 1) {
for($i = 1; $i <= 10; $i++) {
if (!isset($movingunits['u' . (($vtribe - 1) * 10 + $i)])) {
$movingunits['u' . (($vtribe - 1) * 10 + $i)] = 0;
}
$movingunits['u' . (($vtribe - 1) * 10 + $i)] += $ret['t' . $i];
}
if (!isset($movingunits['hero'])) {
$movingunits['hero'] = 0;
}
$movingunits['hero'] += $ret['t11'];
}
}
+1
View File
@@ -23,6 +23,7 @@
$users = "SELECT * FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8") . "";
$users2 = mysqli_num_rows(mysqli_query($GLOBALS['link'],$users));
$users3 = $users2+1;
$myrank = 0;
if(count($ranking) > 0) {
for($i=0;$i<($users3);$i++) {
if( isset( $ranking[$i]['userid'] ) ) {
+1 -1
View File
@@ -4,7 +4,7 @@
| <a href="spieler.php?s=2" <?php if(isset($_GET['s']) && $_GET['s'] == 2) { echo "class=\"selected\""; } ?>>Preferences</a>
| <a href="spieler.php?s=3" <?php if(isset($_GET['s']) && $_GET['s'] == 3) { echo "class=\"selected\""; } ?>>Account</a>
<?php
if($displayarray['username'] == "Shadow"){
if(isset($displayarray) && $displayarray['username'] == "Shadow"){
?>
| <a href="spieler.php?s=5" <?php if(isset($_GET['s']) && $_GET['s'] == 5) { echo "class=\"selected\""; } ?>>Vacation</a>
<?php
+2 -2
View File
@@ -16,9 +16,9 @@ $displayarray = $database->getUserArray($_GET['uid'],1);
$varmedal = $database->getProfileMedal($_GET['uid']);
$profiel="".$displayarray['desc1']."".md5(skJkev3)."".$displayarray['desc2']."";
$profiel="".$displayarray['desc1']."".md5('skJkev3')."".$displayarray['desc2']."";
require("medal.php");
$profiel=explode("".md5(skJkev3)."", $profiel);
$profiel=explode("".md5('skJkev3')."", $profiel);
$varray = $database->getProfileVillages($_GET['uid']);
$totalpop = 0;
+1 -1
View File
@@ -98,6 +98,6 @@ class User {
// convert result into an array
$res = mysqli_fetch_array($res, MYSQLI_NUM);
return ($res[0] > 0 || $res[1] > 0);
return ($res[0] > 0 || (count($res) > 1 && $res[1] > 0));
}
}