Optimizations

-Removed the "sort_type" 6 from the movement table, looted resources
will now be saved in the "sort_type" 4 returing attack.
This reduces a lot the spam in the tables "send" and "movement" of the
database
-Removed some useless methods in Database.php and Message.php
+Optimized report loading, own report will be loaded only once (and not
twice at random) and allied reports aren't loaded anymore
+Minor improovements and better indentation
This commit is contained in:
iopietro
2018-05-05 17:54:34 +02:00
parent cf74514451
commit f7e05c9802
14 changed files with 437 additions and 624 deletions
+10 -14
View File
@@ -11,12 +11,13 @@
include_once("../GameEngine/Generator.php"); include_once("../GameEngine/Generator.php");
include_once("../GameEngine/Technology.php"); include_once("../GameEngine/Technology.php");
include_once("../GameEngine/Message.php"); include_once("../GameEngine/Message.php");
if ($_GET['bid']){ if ($_GET['bid']) $rep = $database->getNotice2($_GET['bid']);
$rep = $database->getNotice4($_GET['bid']); else
}else {
$sql = "SELECT * FROM ".TB_PREFIX."ndata ORDER BY time DESC "; $sql = "SELECT * FROM " . TB_PREFIX . "ndata ORDER BY time DESC ";
$result = mysqli_query($GLOBALS["link"], $sql); $result = mysqli_query($GLOBALS["link"], $sql);
$rep1 = $database->mysqli_fetch_all($result); $rep1 = $database->mysqli_fetch_all($result);
}
if($rep1) if($rep1)
{ {
//$att = $database->getUserArray($rep1['uid'],1); //$att = $database->getUserArray($rep1['uid'],1);
@@ -47,13 +48,8 @@ if($rep)
<div id="content" class="reports"> <div id="content" class="reports">
<h1>Reporte</h1> <h1>Reporte</h1>
<?php <?php
$type = $rep[0]['ntype']; $type = $rep[0]['ntype'];
include("Notice/".$type.".tpl"); include ("Notice/" . $type . ".tpl");
} }
else else echo "Report ID ".$_GET['bid']." doesn't exist!";
{
echo "Report ID ".$_GET['bid']." doesn't exist!";
}
?> ?>
+5 -6
View File
@@ -379,13 +379,12 @@ class adm_DB {
mysqli_query($this->connection, $q); mysqli_query($this->connection, $q);
$getmovement = $database->getMovement(3,$wref,1); $getmovement = $database->getMovement(3, $wref, 1);
foreach($getmovement as $movedata) { foreach($getmovement as $movedata){
$time = microtime(true); $time = microtime(true);
$time2 = $time - $movedata['starttime']; $time2 = $time - $movedata['starttime'];
$database->setMovementProc($movedata['moveid']); $database->setMovementProc($movedata['moveid']);
$database->addMovement(4,$movedata['to'],$movedata['from'],$movedata['ref'],$time,$time+$time2); $database->addMovement(4, $movedata['to'], $movedata['from'], $movedata['ref'], $time, $time + $time2);
//$database->setMovementProc($movedata['moveid']);
} }
//check return enforcement from del village //check return enforcement from del village
@@ -652,8 +651,8 @@ class adm_DB {
$troopsTime = $this->procDistanceTime($fromCor, $toCor, min($speeds), $enforce['from']); $troopsTime = $this->procDistanceTime($fromCor, $toCor, min($speeds), $enforce['from']);
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime); $time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
$reference = $database->addAttack($enforce['from'],$enforce['u'.$start],$enforce['u'.($start+1)],$enforce['u'.($start+2)],$enforce['u'.($start+3)],$enforce['u'.($start+4)],$enforce['u'.($start+5)],$enforce['u'.($start+6)],$enforce['u'.($start+7)],$enforce['u'.($start+8)],$enforce['u'.($start+9)],$enforce['hero'],2,0,0,0,0); $reference = $database->addAttack($enforce['from'], $enforce['u' . $start], $enforce['u' . ($start + 1)], $enforce['u' . ($start + 2)], $enforce['u' . ($start + 3)], $enforce['u' . ($start + 4)], $enforce['u' . ($start + 5)], $enforce['u' . ($start + 6)], $enforce['u' . ($start + 7)], $enforce['u' . ($start + 8)], $enforce['u' . ($start + 9)], $enforce['hero'], 2, 0, 0, 0, 0);
$database->addMovement(4,$wref,$enforce['from'],$reference,time(),($time+time())); $database->addMovement(4, $wref, $enforce['from'], $reference, time(), ($time + time()));
$database->deleteReinf($enforce['id']); $database->deleteReinf($enforce['id']);
} }
} }
+107 -151
View File
@@ -34,7 +34,6 @@ class Automation {
const bountyOCropProd = 40 * SPEED; const bountyOCropProd = 40 * SPEED;
public function __construct() { public function __construct() {
$this->procNewClimbers(); $this->procNewClimbers();
$this->ClearUser(); $this->ClearUser();
$this->ClearInactive(); $this->ClearInactive();
@@ -680,9 +679,9 @@ class Automation {
$database->getVillageByWorldID($vilIDs); $database->getVillageByWorldID($vilIDs);
foreach($dataarray as $data) { foreach($dataarray as $data) {
$targettribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0); $targettribe = $database->getUserField($database->getVillageField($data['from'], "owner"), "tribe", 0);
$this->sendResource2($data['wood'],$data['clay'],$data['iron'],$data['crop'],$data['from'],$data['wid'],$targettribe,$data['deliveries']); $this->sendResource2($data['wood'], $data['clay'], $data['iron'], $data['crop'], $data['from'], $data['wid'], $targettribe, $data['deliveries']);
$database->editTradeRoute($data['id'],"timestamp",86400,1); $database->editTradeRoute($data['id'], "timestamp", 86400, 1);
} }
} }
@@ -719,7 +718,7 @@ class Automation {
$database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1); $database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
$targettribe = $userData_to["tribe"]; $targettribe = $userData_to["tribe"];
$endtime = $units->getWalkingTroopsTime($data['from'], $data['to'], 0, 0, [$targettribe], 0) + $data['endtime']; $endtime = $units->getWalkingTroopsTime($data['from'], $data['to'], 0, 0, [$targettribe], 0) + $data['endtime'];
$database->addMovement(2,$data['to'],$data['from'],$data['merchant'],time(),$endtime,$data['send'],$data['wood'],$data['clay'],$data['iron'],$data['crop']); $database->addMovement(2, $data['to'], $data['from'], $data['merchant'], time(), $endtime, $data['send'], $data['wood'], $data['clay'], $data['iron'], $data['crop']);
$database->setMovementProc($data['moveid']); $database->setMovementProc($data['moveid']);
} }
@@ -1048,11 +1047,11 @@ class Automation {
$evasionUnitModifications_amounts[] = $DefenderUnit['hero']; $evasionUnitModifications_amounts[] = $DefenderUnit['hero'];
$evasionUnitModifications_modes[] = 0; $evasionUnitModifications_modes[] = 0;
$attackid = $database->addAttack($data['to'],$data['u1'],$data['u2'],$data['u3'],$data['u4'],$data['u5'],$data['u6'],$data['u7'],$data['u8'],$data['u9'],$data['u10'],$data['u11'],4,0,0,0,0,0,0,0,0,0,0,0); $attackid = $database->addAttack($data['to'], $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$database->addMovement(4,0,$data['to'],$attackid,microtime(true),microtime(true)+(180/EVASION_SPEED)); $database->addMovement(4, 0, $data['to'], $attackid, microtime(true), microtime(true) + (180 / EVASION_SPEED));
$newgold = $gold-2; $newgold = $gold - 2;
$newmaxevasion = $maxevasion-1; $newmaxevasion = $maxevasion - 1;
$database->updateUserField($DefenderID, ["gold", "maxevasion"], [$newgold, $newmaxevasion], 1); $database->updateUserField($DefenderID, ["gold", "maxevasion"], [$newgold, $newmaxevasion], 1);
} }
// modify units in DB // modify units in DB
@@ -2471,63 +2470,57 @@ class Automation {
$troopsTime = $units->getWalkingTroopsTime($from['wref'], $to['wref'], $from['owner'], $owntribe, $returningTroops, 1, 't'); $troopsTime = $units->getWalkingTroopsTime($from['wref'], $to['wref'], $from['owner'], $owntribe, $returningTroops, 1, 't');
$endtime = $database->getArtifactsValueInfluence($from['owner'], $from['wref'], 2, $troopsTime); $endtime = $database->getArtifactsValueInfluence($from['owner'], $from['wref'], 2, $troopsTime);
$endtime += $AttackArrivalTime; $endtime += $AttackArrivalTime;
if($type == 1) { if($type == 1){
if($from['owner'] == 3) { //fix natar report by ronix if($from['owner'] == 3){ // fix natar report by ronix
$database->addNotice($to['owner'],$to['wref'],$targetally,20,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime); $database->addNotice($to['owner'], $to['wref'], $targetally, 20, '' . addslashes($from['name']) . ' scouts ' . addslashes($to['name']) . '', $data2, $AttackArrivalTime);
}elseif ($totaldead_att == 0 && $totaltraped_att == 0){ }elseif($totaldead_att == 0 && $totaltraped_att == 0){
$database->addNotice($from['owner'],$to['wref'],$ownally,18,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime); $database->addNotice($from['owner'], $to['wref'], $ownally, 18, '' . addslashes($from['name']) . ' scouts ' . addslashes($to['name']) . '', $data2, $AttackArrivalTime);
}else{ }else{
$database->addNotice($from['owner'],$to['wref'],$ownally,21,''.addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data2,$AttackArrivalTime); $database->addNotice($from['owner'], $to['wref'], $ownally, 21, '' . addslashes($from['name']) . ' scouts ' . addslashes($to['name']) . '', $data2, $AttackArrivalTime);
} }
}else { }else{
if ((empty($totaldead_att) || $totaldead_att == 0) && (empty($totaltraped_att) || $totaltraped_att == 0)){ if((empty($totaldead_att) || $totaldead_att == 0) && (empty($totaltraped_att) || $totaltraped_att == 0)){
$database->addNotice($from['owner'],$to['wref'],$ownally,1,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime); $database->addNotice($from['owner'], $to['wref'], $ownally, 1, '' . addslashes($from['name']) . ' attacks ' . addslashes($to['name']) . '', $data2, $AttackArrivalTime);
}else{ }else{
$database->addNotice($from['owner'],$to['wref'],$ownally,2,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,$AttackArrivalTime); $database->addNotice($from['owner'], $to['wref'], $ownally, 2, '' . addslashes($from['name']) . ' attacks ' . addslashes($to['name']) . '', $data2, $AttackArrivalTime);
} }
} }
$database->setMovementProc($data['moveid']); $database->setMovementProc($data['moveid']);
if (!isset($chiefing_village)) $chiefing_village = 0; if (!isset($chiefing_village)) $chiefing_village = 0;
if($chiefing_village != 1){ if($chiefing_village != 1){
$database->addMovement(4,$DefenderWref,$AttackerWref,$data['ref'],$AttackArrivalTime,$endtime); $database->addMovement(4, $DefenderWref, $AttackerWref, $data['ref'], $AttackArrivalTime, $endtime, 1, $steal[0], $steal[1], $steal[2], $steal[3]);
// send the bounty on type 6.
if($type !== 1){ if($type !== 1){
$reference = $database->sendResource($steal[0], $steal[1], $steal[2], $steal[3], 0, 0); if ($isoasis == 0) $database->modifyResource($DefenderWref, $steal[0], $steal[1], $steal[2], $steal[3], 0);
if ($isoasis == 0){ else
$database->modifyResource($DefenderWref, $steal[0], $steal[1], $steal[2], $steal[3], 0); {
}else{ //if it's an oasis but it's conquered by someone, resources must be modified in the owner's village
if($conqureby > 0) //if it's an oasis but it's conquered by someone, resources must be modified in the owner village if($conqureby > 0) $database->modifyResource($conqureby, $steal[0], $steal[1], $steal[2], $steal[3], 0);
{
$database->modifyResource($conqureby, $steal[0], $steal[1], $steal[2], $steal[3], 0);
}
else $database->modifyOasisResource($DefenderWref, $steal[0], $steal[1], $steal[2], $steal[3], 0); else $database->modifyOasisResource($DefenderWref, $steal[0], $steal[1], $steal[2], $steal[3], 0);
} }
$database->addMovement(6,$DefenderWref,$AttackerWref,$reference,$AttackArrivalTime,$endtime,1,0,0,0,0,$data['ref']); $totalstolengain = $steal[0] + $steal[1] + $steal[2] + $steal[3];
$totalstolengain=$steal[0]+$steal[1]+$steal[2]+$steal[3]; $totalstolentaken = ((isset($totalstolentaken) ? $totalstolentaken : 0) - ($steal[0] + $steal[1] + $steal[2] + $steal[3]));
$totalstolentaken=((isset($totalstolentaken) ? $totalstolentaken : 0)-($steal[0]+$steal[1]+$steal[2]+$steal[3])); $database->modifyPoints($from['owner'], 'RR', $totalstolengain);
$database->modifyPoints($from['owner'],'RR',$totalstolengain); $database->modifyPoints($to['owner'], 'RR', $totalstolentaken);
$database->modifyPoints($to['owner'],'RR',$totalstolentaken); $database->modifyPointsAlly($targetally, 'RR', $totalstolentaken);
$database->modifyPointsAlly($targetally,'RR',$totalstolentaken ); $database->modifyPointsAlly($ownally, 'RR', $totalstolengain);
$database->modifyPointsAlly($ownally,'RR',$totalstolengain);
} }
}else{ //fix by ronix if only 1 chief left to conqured - don't add with zero enforces }else{ //fix by ronix if only 1 chief left to conqured - don't add with zero enforces
if($totalsend_att - ($totaldead_att + (isset($totaltraped_att) ? $totaltraped_att : 0)) > 1){ if($totalsend_att - ($totaldead_att + (isset($totaltraped_att) ? $totaltraped_att : 0)) > 1){
$database->addEnforce2($data,$owntribe,$troopsdead1,$troopsdead2,$troopsdead3,$troopsdead4,$troopsdead5,$troopsdead6,$troopsdead7,$troopsdead8,$troopsdead9,$troopsdead10,$troopsdead11); $database->addEnforce2($data, $owntribe, $troopsdead1, $troopsdead2, $troopsdead3, $troopsdead4, $troopsdead5, $troopsdead6, $troopsdead7, $troopsdead8, $troopsdead9, $troopsdead10, $troopsdead11);
} }
} }
} }
else //else they die and don't return or report. else //else they die and don't return or report.
{ {
$database->setMovementProc($data['moveid']); $database->setMovementProc($data['moveid']);
if($type == 1){ if($type == 1){
$database->addNotice($from['owner'],$to['wref'],$ownally,19,addslashes($from['name']).' scouts '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime); $database->addNotice($from['owner'], $to['wref'], $ownally, 19, addslashes($from['name']) . ' scouts ' . addslashes($to['name']) . '', $data_fail, $AttackArrivalTime);
}else{ }else{
$database->addNotice($from['owner'],$to['wref'],$ownally,3,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime); $database->addNotice($from['owner'], $to['wref'], $ownally, 3, '' . addslashes($from['name']) . ' attacks ' . addslashes($to['name']) . '', $data_fail, $AttackArrivalTime);
} }
} }
if($type == 3 || $type == 4) $database->addGeneralAttack($totalattackdead); if($type == 3 || $type == 4) $database->addGeneralAttack($totalattackdead);
@@ -2920,7 +2913,7 @@ class Automation {
$time = time(); $time = time();
$q = " $q = "
SELECT SELECT
`to`, `from`, moveid, starttime, endtime, `to`, `from`, moveid, starttime, endtime, wood, clay, iron, crop,
t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11
FROM FROM
".TB_PREFIX."movement, ".TB_PREFIX."movement,
@@ -2939,9 +2932,7 @@ class Automation {
// so we need to de-duplicate them here by checking for the same wave properties sent out at the // so we need to de-duplicate them here by checking for the same wave properties sent out at the
// same time (i.e. with exactly the same timestamp) // same time (i.e. with exactly the same timestamp)
$wavesData = []; $wavesData = [];
if ($dataarray && count($dataarray)) { if ($dataarray && count($dataarray)) {
// preload village data // preload village data
$vilIDs = []; $vilIDs = [];
foreach($dataarray as $data) { foreach($dataarray as $data) {
@@ -2955,16 +2946,20 @@ class Automation {
$movementProcIDs = []; $movementProcIDs = [];
foreach($dataarray as $data) { foreach($dataarray as $data) {
if (!isset($wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']])) { if (!isset($wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']])) {
$tribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0); $tribe = $database->getUserField($database->getVillageField($data['to'], "owner"), "tribe", 0);
$u = $tribe == 1 ? "" : $tribe - 1; $u = $tribe == 1 ? "" : $tribe - 1;
$database->modifyUnit( $database->modifyUnit(
$data['to'], $data['to'],
[$u."1", $u."2", $u."3", $u."4", $u."5", $u."6", $u."7", $u."8", $u."9", $tribe."0", "hero"], [$u."1", $u."2", $u."3", $u."4", $u."5", $u."6", $u."7", $u."8", $u."9", $tribe."0", "hero"],
[$data['t1'], $data['t2'], $data['t3'], $data['t4'], $data['t5'], $data['t6'], $data['t7'], $data['t8'], $data['t9'], $data['t10'], $data['t11']], [$data['t1'], $data['t2'], $data['t3'], $data['t4'], $data['t5'], $data['t6'], $data['t7'], $data['t8'], $data['t9'], $data['t10'], $data['t11']],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
); );
//If there's at least 1 resource, add it to the village
if($data['wood'] + $data['clay'] + $data['iron'] + $data['crop'] > 0){
$database->modifyResource($data['to'], $data['wood'], $data['clay'], $data['iron'], $data['crop'], 1);
}
$movementProcIDs[] = $data['moveid']; $movementProcIDs[] = $data['moveid'];
//Update starvation data //Update starvation data
@@ -2973,48 +2968,24 @@ class Automation {
// make sure we don't process duplicate movements until the big bad bug which inserts them into DB is fixed // make sure we don't process duplicate movements until the big bad bug which inserts them into DB is fixed
$wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']] = true; $wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']] = true;
} // duplicate record, just mark it as processed } // duplicate record, just mark it as processed
else $movementProcIDs[] = $data['moveid']; else $movementProcIDs[] = $data['moveid'];
} }
$database->setMovementProc(implode(', ', $movementProcIDs)); $database->setMovementProc(implode(', ', $movementProcIDs));
$this->pruneResource();
} }
// Recieve the bounty on type 6.
$q = "SELECT s.wood, s.clay, s.iron, s.crop, `to`, `from`, endtime, merchant, send, moveid FROM ".TB_PREFIX."movement m, ".TB_PREFIX."send s WHERE m.ref = s.id AND m.proc = 0 AND sort_type = 6 AND endtime < $time";
$dataarray = $database->query_return($q);
$movementProcIDs = [];
foreach($dataarray as $data) {
if($data['wood'] >= $data['clay'] && $data['wood'] >= $data['iron'] && $data['wood'] >= $data['crop']) $sort_type = 10;
elseif($data['clay'] >= $data['wood'] && $data['clay'] >= $data['iron'] && $data['clay'] >= $data['crop']) $sort_type = 11;
elseif($data['iron'] >= $data['wood'] && $data['iron'] >= $data['clay'] && $data['iron'] >= $data['crop']) $sort_type = 12;
elseif($data['crop'] >= $data['wood'] && $data['crop'] >= $data['clay'] && $data['crop'] >= $data['iron']) $sort_type = 13;
$to = $database->getMInfo($data['to']);
$from = $database->getMInfo($data['from']);
$database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
//$database->updateVillage($data['to']);
$movementProcIDs[] = $data['moveid'];
//Update starvation data
$this->addStarvationData($data['to']);
}
$database->setMovementProc(implode(', ', $movementProcIDs));
$this->pruneResource();
// Settlers // Settlers
$q = "SELECT `to`, moveid FROM ".TB_PREFIX."movement where ref = 0 and proc = '0' and sort_type = '4' and endtime < $time"; $q = "SELECT `to`, moveid FROM ".TB_PREFIX."movement where ref = 0 and proc = '0' and sort_type = '4' and endtime < $time";
$dataarray = $database->query_return($q); $dataarray = $database->query_return($q);
$movementProcIDs = []; $movementProcIDs = [];
if ($dataarray && count($dataarray)) { if ($dataarray && count($dataarray)) {
foreach($dataarray as $data) { foreach($dataarray as $data) {
$tribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0); $tribe = $database->getUserField($database->getVillageField($data['to'], "owner"), "tribe", 0);
$database->modifyUnit($data['to'],array($tribe."0"),array(3),array(1)); $database->modifyUnit($data['to'], [$tribe."0"], [3], [1]);
//If a settling is canceled, add 750 for each resource type
$database->modifyResource($data['to'], 750, 750, 750, 750, 1);
$movementProcIDs[] = $data['moveid']; $movementProcIDs[] = $data['moveid'];
} }
$database->setMovementProc(implode(', ', $movementProcIDs)); $database->setMovementProc(implode(', ', $movementProcIDs));
@@ -3031,6 +3002,7 @@ class Automation {
if(file_exists($autoprefix."GameEngine/Prevention/settlers.txt")) { if(file_exists($autoprefix."GameEngine/Prevention/settlers.txt")) {
unlink($autoprefix."GameEngine/Prevention/settlers.txt"); unlink($autoprefix."GameEngine/Prevention/settlers.txt");
} }
$ourFileHandle = fopen($autoprefix."GameEngine/Prevention/settlers.txt", 'w'); $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/settlers.txt", 'w');
fclose($ourFileHandle); fclose($ourFileHandle);
$time = microtime(true); $time = microtime(true);
@@ -3061,45 +3033,43 @@ class Automation {
$database->getVillageByWorldID($vilIDs); $database->getVillageByWorldID($vilIDs);
foreach($dataarray as $data) { foreach($dataarray as $data) {
$ownerID = $database->getUserField($database->getVillageField($data['from'],"owner"),"id",0); $ownerID = $database->getUserField($database->getVillageField($data['from'], "owner"), "id", 0);
$to = $database->getMInfo($data['from']); $to = $database->getMInfo($data['from']);
$user = addslashes($database->getUserField($to['owner'],'username',0)); $user = addslashes($database->getUserField($to['owner'], 'username', 0));
$taken = $database->getVillageState($data['to']); $taken = $database->getVillageState($data['to']);
if($taken != 1){ if($taken != 1){
$fieldIDs[] = $data['to']; $fieldIDs[] = $data['to'];
$database->addVillage($data['to'],$to['owner'],$user,'0'); $database->addVillage($data['to'], $to['owner'], $user, '0');
$database->addResourceFields($data['to'],$database->getVillageType($data['to'])); $database->addResourceFields($data['to'], $database->getVillageType($data['to']));
$addUnitsWrefs[] = $data['to']; $addUnitsWrefs[] = $data['to'];
$addTechWrefs[] = $data['to']; $addTechWrefs[] = $data['to'];
$addABTechWrefs[] = $data['to']; $addABTechWrefs[] = $data['to'];
$movementProcIDs[] = $data['moveid']; $movementProcIDs[] = $data['moveid'];
$exp1 = $database->getVillageField($data['from'],'exp1'); $exp1 = $database->getVillageField($data['from'], 'exp1');
$exp2 = $database->getVillageField($data['from'],'exp2'); $exp2 = $database->getVillageField($data['from'], 'exp2');
$exp3 = $database->getVillageField($data['from'],'exp3'); $exp3 = $database->getVillageField($data['from'], 'exp3');
if($exp1 == 0){ if($exp1 == 0){
$exp = 'exp1'; $exp = 'exp1';
$value = $data['to']; $value = $data['to'];
} }elseif($exp2 == 0){
elseif($exp2 == 0){ $exp = 'exp2';
$exp = 'exp2'; $value = $data['to'];
$value = $data['to']; }else{
} $exp = 'exp3';
else{ $value = $data['to'];
$exp = 'exp3'; }
$value = $data['to'];
} $database->setVillageField($data['from'], $exp, $value);
$database->setVillageField($data['from'],$exp,$value); }else{
}
else{
// here must come movement from returning settlers // here must come movement from returning settlers
$types[] = 4; $types[] = 4;
$froms[] = $data['to']; $froms[] = $data['to'];
$tos[] = $data['from']; $tos[] = $data['from'];
$refs[] = $data['ref']; $refs[] = $data['ref'];
$times[] = $time; $times[] = $time;
$endtimes[] = $time+($time-$data['starttime']); $endtimes[] = $time + ($time - $data['starttime']);
$movementProcIDs[] = $data['moveid']; $movementProcIDs[] = $data['moveid'];
} }
} }
@@ -4072,12 +4042,9 @@ class Automation {
// find the first not-empty array // find the first not-empty array
foreach($allTroopsArray as $type => $allTroops) foreach($allTroopsArray as $type => $allTroops)
{ {
if(!empty($allTroops)) if(!empty($allTroops)){
{ foreach($allTroops as $subtype => $troops){
foreach($allTroops as $subtype => $troops) if(!empty($troops)){
{
if(!empty($troops))
{
$starvingTroops = reset($troops); $starvingTroops = reset($troops);
break 2; break 2;
} }
@@ -4091,25 +4058,23 @@ class Automation {
// counting // counting
$timedif = $time-$starv['starvupdate']; $timedif = $time-$starv['starvupdate'];
$cropProd = $database->getCropProdstarv($starv['wref']) - $starv['starv']; $cropProd = $database->getCropProdstarv($starv['wref']) - $starv['starv'];
if($cropProd < 0) if($cropProd < 0){
{
$starvsec = (abs($cropProd) / 3600); $starvsec = (abs($cropProd) / 3600);
$difcrop = ($timedif * $starvsec); //crop eat up over time $difcrop = ($timedif * $starvsec); //crop eat up over time
$newcrop = 0; $newcrop = 0;
$oldcrop = $database->getVillageField($starv['wref'], 'crop'); $oldcrop = $database->getVillageField($starv['wref'], 'crop');
if ($oldcrop > 100) //if the grain is then tries to send all
{ //if the grain is then tries to send all
$difcrop = $difcrop-$oldcrop; if ($oldcrop > 100){
if($difcrop < 0) $difcrop = $difcrop - $oldcrop;
{ if($difcrop < 0){
$difcrop = 0; $difcrop = 0;
$newcrop = $oldcrop-$difcrop; $newcrop = $oldcrop - $difcrop;
$database->setVillageField($starv['wref'], 'crop', $newcrop); $database->setVillageField($starv['wref'], 'crop', $newcrop);
} }
} }
if($difcrop > 0 && $oldcrop <= 0) if($difcrop > 0 && $oldcrop <= 0){
{
$tribe = $database->getUserField(($type == 2) ? $starv['owner'] : $database->getVillageField($starvingTroops['from'], "owner"), "tribe", 0); $tribe = $database->getUserField(($type == 2) ? $starv['owner'] : $database->getVillageField($starvingTroops['from'], "owner"), "tribe", 0);
$start = ($special = in_array($type, [1, 3])) ? 1 : ($tribe - 1) * 10 + 1; $start = ($special = in_array($type, [1, 3])) ? 1 : ($tribe - 1) * 10 + 1;
$end = ($special) ? 10 : $tribe * 10 ; $end = ($special) ? 10 : $tribe * 10 ;
@@ -4126,16 +4091,14 @@ class Automation {
{ {
$units = (isset($starvingTroops[$utype.$i]) ? $starvingTroops[$utype.$i] : 0); $units = (isset($starvingTroops[$utype.$i]) ? $starvingTroops[$utype.$i] : 0);
if($counting) $totalUnits += $units; if($counting) $totalUnits += $units;
if($units > $maxcount) if($units > $maxcount){
{
$maxcount = $units; $maxcount = $units;
$maxtype = $i; $maxtype = $i;
} }
} }
if($counting) $counting = false; if($counting) $counting = false;
if($maxtype > 0) if($maxtype > 0){
{
$starvingTroops[$utype.$maxtype]--; $starvingTroops[$utype.$maxtype]--;
$killedUnits[$maxtype]++; $killedUnits[$maxtype]++;
$difcrop -= $GLOBALS['u'.(($special) ? $maxtype + ($tribe - 1) * 10 : $maxtype)]['crop']; $difcrop -= $GLOBALS['u'.(($special) ? $maxtype + ($tribe - 1) * 10 : $maxtype)]['crop'];
@@ -4144,8 +4107,7 @@ class Automation {
} }
$totalKilledUnits = array_sum($killedUnits); $totalKilledUnits = array_sum($killedUnits);
if($starvingTroops[$heroType] > 0 && ($totalUnits == 0 || $totalUnits == $totalKilledUnits)) if($starvingTroops[$heroType] > 0 && ($totalUnits == 0 || $totalUnits == $totalKilledUnits)){
{
$totalKilledUnits += $starvingTroops[$heroType]; $totalKilledUnits += $starvingTroops[$heroType];
$totalUnits += $starvingTroops[$heroType]; $totalUnits += $starvingTroops[$heroType];
$starvingTroops['heroinfo'] = $database->getHero(($type == 2) ? $starv['owner'] : $database->getVillageField(($type == 3 && $subtype == 1) ? $starvingTroops['to'] : $starvingTroops['from'], "owner"))[0]; $starvingTroops['heroinfo'] = $database->getHero(($type == 2) ? $starv['owner'] : $database->getVillageField(($type == 3 && $subtype == 1) ? $starvingTroops['to'] : $starvingTroops['from'], "owner"))[0];
@@ -4161,21 +4123,17 @@ class Automation {
switch($type) switch($type)
{ {
case 0: case 0:
if($totalKilledUnits < $totalUnits) if($totalKilledUnits < $totalUnits){
{
$database->modifyEnforce($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0); $database->modifyEnforce($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
} }
else $database->deleteReinf($starvingTroops['id']); else $database->deleteReinf($starvingTroops['id']);
break; break;
case 1: case 1:
if($totalKilledUnits < $totalUnits) if($totalKilledUnits < $totalUnits){
{
$database->modifyPrisoners($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0); $database->modifyPrisoners($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
$database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalKilledUnits], [0]); $database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalKilledUnits], [0]);
} }else{
else
{
$database->deletePrisoners($starvingTroops['id']); $database->deletePrisoners($starvingTroops['id']);
$database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalUnits], [0]); $database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalUnits], [0]);
} }
@@ -4186,11 +4144,10 @@ class Automation {
break; break;
case 3: case 3:
if($totalKilledUnits < $totalUnits) if($totalKilledUnits < $totalUnits){
{
$database->modifyAttack2($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0); $database->modifyAttack2($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
} }
else $database->setMovementProc($starvingTroops['moveid'].(($subtype == 1) ? ", ".($starvingTroops['moveid'] + 1) : "")); else $database->setMovementProc($starvingTroops['moveid']);
break; break;
} }
@@ -4201,8 +4158,7 @@ class Automation {
} }
$crop = $database->getCropProdstarv($starv['wref'], false); $crop = $database->getCropProdstarv($starv['wref'], false);
if ($crop > 0) $database->setVillageField($starv['wref'], ['starv', 'starvupdate'], [0, 0]);
if ($crop > $upkeep) $database->setVillageField($starv['wref'], ['starv', 'starvupdate'], [0, 0]);
unset ($unitarrays, $type, $subtype); unset ($unitarrays, $type, $subtype);
} }
+3 -6
View File
@@ -225,12 +225,9 @@ $input = preg_replace_callback(
function($matches) { function($matches) {
global $database; global $database;
$report = count($database->getNotice4((int) $matches[1])); $report = count($database->getNotice2((int) $matches[1]));
if (count($report)) { if (count($report)) return "<a href=berichte.php?id=".$matches[1].">".$matches[2]."</a>";
return "<a href=berichte.php?id=".$matches[1].">".$matches[2]."</a>"; else return $matches[2];
} else {
return $matches[2];
}
}, },
$input); $input);
+2 -27
View File
@@ -359,11 +359,6 @@ class MYSQLi_DB implements IDbConnection {
*/ */
$noticesCacheById = [], $noticesCacheById = [],
/**
* @var array Cache of notices by user ID.
*/
$noticesCacheByUId = [],
/** /**
* @var array Cache of merchants used count. * @var array Cache of merchants used count.
*/ */
@@ -4257,7 +4252,7 @@ References: User ID/Message ID, Mode
return $this->mysqli_fetch_all($result); return $this->mysqli_fetch_all($result);
} }
function getNotice2($id, $field, $use_cache = true) { function getNotice2($id, $field = null, $use_cache = true) {
list($id, $field) = $this->escape_input((int) $id, $field); list($id, $field) = $this->escape_input((int) $id, $field);
// first of all, check if we should be using cache and whether the field // first of all, check if we should be using cache and whether the field
@@ -4271,27 +4266,7 @@ References: User ID/Message ID, Mode
$dbarray = mysqli_fetch_array($result); $dbarray = mysqli_fetch_array($result);
self::$noticesCacheById[$id] = $dbarray; self::$noticesCacheById[$id] = $dbarray;
return self::$noticesCacheById[$id][$field]; return is_null($field) ? self::$noticesCacheById[$id] : self::$noticesCacheById[$id][$field];
}
function getNotice3($uid, $alliance, $use_cache = true) {
list($uid) = $this->escape_input((int) $uid);
// first of all, check if we should be using cache and whether the field
// required is already cached
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$noticesCacheByUId, $uid)) && !is_null($cachedValue)) {
return $cachedValue;
}
$q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ".($alliance > 0 ? 'OR ally = '.$alliance.'' : '')." ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC');
$result = mysqli_query($this->dblink,$q);
$noticesCacheByUId[$uid] = $this->mysqli_fetch_all($result);
return $noticesCacheByUId[$uid];
}
function getNotice4($id, $use_cache = true) {
return $this->getNotice2($id, $use_cache);
} }
function getUnViewNotice($uid) { function getUnViewNotice($uid) {
+49 -72
View File
@@ -12,8 +12,8 @@
class Market class Market
{ {
public $onsale,$onmarket,$sending,$recieving,$return = array(); public $onsale, $onmarket, $sending, $recieving, $return = [];
public $maxcarry,$merchant,$used; public $maxcarry, $merchant, $used;
public function procMarket($post) public function procMarket($post)
{ {
@@ -114,8 +114,8 @@ class Market
elseif($post['send3'] < 1 || $post['send3'] > 3 || ($post['send3'] > 1 && !$session->goldclub)) $form->addError("error", INVALID_MERCHANTS_REPETITION); elseif($post['send3'] < 1 || $post['send3'] > 3 || ($post['send3'] > 1 && !$session->goldclub)) $form->addError("error", INVALID_MERCHANTS_REPETITION);
elseif($availableWood >= $post['r1'] && $availableClay >= $post['r2'] && $availableIron >= $post['r3'] && $availableCrop >= $post['r4']) elseif($availableWood >= $post['r1'] && $availableClay >= $post['r2'] && $availableIron >= $post['r3'] && $availableCrop >= $post['r4'])
{ {
$resource = array($wtrans,$ctrans,$itrans,$crtrans); $resource = [$wtrans, $ctrans, $itrans, $crtrans];
$reqMerc = ceil((array_sum($resource)-0.1)/$this->maxcarry); $reqMerc = ceil((array_sum($resource) - 0.1) / $this->maxcarry);
if($this->merchantAvail() > 0 && $reqMerc <= $this->merchantAvail()) if($this->merchantAvail() > 0 && $reqMerc <= $this->merchantAvail())
{ {
@@ -124,14 +124,13 @@ class Market
if($database->getVillageState($id)) if($database->getVillageState($id))
{ {
$timetaken = $generator->procDistanceTime($coor, $village->coor, $session->tribe, 0); $timetaken = $generator->procDistanceTime($coor, $village->coor, $session->tribe, 0);
$res = $resource[0]+$resource[1]+$resource[2]+$resource[3]; $res = $resource[0] + $resource[1] + $resource[2] + $resource[3];
if($res!=0) if($res != 0){
{ $reference = $database->sendResource($resource[0], $resource[1], $resource[2], $resource[3], $reqMerc, 0);
$reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0); $database->modifyResource($village->wid, $resource[0], $resource[1], $resource[2], $resource[3], 0);
$database->modifyResource($village->wid,$resource[0],$resource[1],$resource[2],$resource[3],0); $database->addMovement(0, $village->wid, $id, $reference, time(), time() + $timetaken, $post['send3']);
$database->addMovement(0,$village->wid,$id,$reference,time(),time()+$timetaken,$post['send3']); $logging->addMarketLog($village->wid, 1, [$resource[0], $resource[1], $resource[2], $resource[3], $id]);
$logging->addMarketLog($village->wid,1,array($resource[0],$resource[1],$resource[2],$resource[3],$id)); }
}
} }
header("Location: build.php?id=".$post['id']); header("Location: build.php?id=".$post['id']);
exit; exit;
@@ -251,7 +250,6 @@ class Market
} }
} }
// We don't have enough resources // We don't have enough resources
if($infoarray['wamt'] > ([$village->awood, $village->aclay, $village->airon, $village->acrop])[$infoarray['wtype']]) if($infoarray['wamt'] > ([$village->awood, $village->aclay, $village->airon, $village->acrop])[$infoarray['wtype']])
{ {
@@ -271,7 +269,7 @@ class Market
exit; exit;
} }
$myresource = $hisresource = array(1=>0,0,0,0); $myresource = $hisresource = [ 1=> 0, 0, 0, 0];
$myresource[$infoarray['wtype']] = $infoarray['wamt']; $myresource[$infoarray['wtype']] = $infoarray['wamt'];
$mysendid = $database->sendResource($myresource[1],$myresource[2],$myresource[3],$myresource[4],$reqMerc,0); $mysendid = $database->sendResource($myresource[1],$myresource[2],$myresource[3],$myresource[4],$reqMerc,0);
$hisresource[$infoarray['gtype']] = $infoarray['gamt']; $hisresource[$infoarray['gtype']] = $infoarray['gamt'];
@@ -289,13 +287,13 @@ class Market
[$timestamp, $timestamp], [$timestamp, $timestamp],
[$mytime + $timestamp, $histime + $timestamp] [$mytime + $timestamp, $histime + $timestamp]
); );
$resource = array(1=>0,0,0,0); $resource = [1 => 0, 0, 0, 0];
$resource[$infoarray['wtype']] = $infoarray['wamt']; $resource[$infoarray['wtype']] = $infoarray['wamt'];
$database->modifyResource($village->wid, $resource[1], $resource[2], $resource[3], $resource[4] , 0); $database->modifyResource($village->wid, $resource[1], $resource[2], $resource[3], $resource[4], 0);
$database->setMarketAcc($get['g']); $database->setMarketAcc($get['g']);
$database->removeAcceptedOffer($get['g']); $database->removeAcceptedOffer($get['g']);
$logging->addMarketLog($village->wid,2,array($infoarray['vref'],$get['g'])); $logging->addMarketLog($village->wid, 2, [$infoarray['vref'], $get['g']]);
header("Location: build.php?id=".$get['id']); header("Location: build.php?id=" . $get['id']);
exit; exit;
} }
@@ -304,7 +302,7 @@ class Market
global $database,$village,$session,$multisort,$generator; global $database,$village,$session,$multisort,$generator;
$displayarray = $database->getMarket($village->wid,1); $displayarray = $database->getMarket($village->wid,1);
$holderarray = array(); $holderarray = [];
foreach($displayarray as $value) foreach($displayarray as $value)
{ {
$targetcoor = $database->getCoor($value['vref']); $targetcoor = $database->getCoor($value['vref']);
@@ -320,57 +318,36 @@ class Market
private function filterNeed($get) private function filterNeed($get)
{ {
if(isset($get['v']) || isset($get['s']) || isset($get['b'])) if(isset($get['v']) || isset($get['s']) || isset($get['b'])){
{ $holder = $holder2 = [];
$holder = $holder2 = array(); if(isset($get['v']) && $get['v'] == "1:1"){
if(isset($get['v']) && $get['v'] == "1:1") foreach($this->onsale as $equal){
{ if($equal['wamt'] <= $equal['gamt']){
foreach($this->onsale as $equal) array_push($holder, $equal);
{ }
if($equal['wamt'] <= $equal['gamt']) }
{ }
array_push($holder,$equal); else $holder = $this->onsale;
}
} foreach($holder as $sale){
} if(isset($get['s']) && isset($get['b'])){
else if($sale['gtype'] == $get['s'] && $sale['wtype'] == $get['b']){
{ array_push($holder2, $sale);
$holder = $this->onsale; }
} }else if(isset($get['s']) && !isset($get['b'])){
foreach($holder as $sale) if($sale['gtype'] == $get['s']){
{ array_push($holder2, $sale);
if(isset($get['s']) && isset($get['b'])) }
{ }else if(isset($get['b']) && !isset($get['s'])){
if($sale['gtype'] == $get['s'] && $sale['wtype'] == $get['b']) if($sale['wtype'] == $get['b']){
{ array_push($holder2, $sale);
array_push($holder2,$sale); }
} }
} else $holder2 = $holder;
else if(isset($get['s']) && !isset($get['b'])) }
{ $this->onsale = $holder2;
if($sale['gtype'] == $get['s'])
{
array_push($holder2,$sale);
}
}
else if(isset($get['b']) && !isset($get['s']))
{
if($sale['wtype'] == $get['b'])
{
array_push($holder2,$sale);
}
}
else
{
$holder2 = $holder;
}
}
$this->onsale = $holder2;
}
else
{
$this->loadOnsale();
} }
else $this->loadOnsale();
} }
private function tradeResource($post) private function tradeResource($post)
+160 -217
View File
@@ -13,38 +13,33 @@ class Message {
public $unread, $nunread = false; public $unread, $nunread = false;
public $note; public $note;
public $inbox, $inbox1, $sent, $sent1, $reading, $reply, $archived, $archived1, $noticearray, $notice, $readingNotice = array(); public $inbox, $inbox1, $sent, $sent1, $reading, $reply, $archived, $archived1, $noticearray, $readingNotice = [];
private $totalMessage, $totalNotice; private $totalMessage;
private $allNotice = [];
function __construct() { function __construct() {
$req_file = basename($_SERVER['PHP_SELF']); $req_file = basename($_SERVER['PHP_SELF']);
$this->unread = $this->checkUnread(); $this->unread = $this->checkUnread();
$this->nunread = $this->checkNUnread(); $this->nunread = $this->checkNUnread();
if ($req_file == 'nachrichten.php') { if($req_file == 'nachrichten.php'){
if ( isset( $_GET['t'] ) ) { if(isset($_GET['t'])){
switch ( $_GET['t'] ) { switch($_GET['t']){
// send messages page or a single sent message // send messages page or a single sent message
case 2: case 2 :
case '2a': case '2a' :
$this->getMessages( 2 ); $this->getMessages(2);
break; break;
// archived messages page // archived messages page
case 3: case 3 :
$this->getMessages( 3 ); $this->getMessages(3);
break; break;
} }
} else { }
// inbox - received messages page else $this->getMessages(1); // inbox - received messages page
$this->getMessages( 1 ); }
}
}
if ($req_file == 'berichte.php') { if ($req_file == 'berichte.php') $this->getNotice();
$this->getNotice();
}
if(isset($_SESSION['reply'])) { if(isset($_SESSION['reply'])) {
$this->reply = $_SESSION['reply']; $this->reply = $_SESSION['reply'];
@@ -59,14 +54,10 @@ class Message {
$this->quoteMessage($post['id']); $this->quoteMessage($post['id']);
break; break;
case "m2": case "m2":
if ($post['an'] == "[ally]"){ if ($post['an'] == "[ally]") $this->sendAMessage($post['be'],addslashes($post['message']));
$this->sendAMessage($post['be'],addslashes($post['message'])); else $this->sendMessage($post['an'],$post['be'],addslashes($post['message']));
}else{ header("Location: nachrichten.php?t=2");
$this->sendMessage($post['an'],$post['be'],addslashes($post['message'])); exit;
}
header("Location: nachrichten.php?t=2");
exit;
break;
case "m3": case "m3":
case "m4": case "m4":
case "m5": case "m5":
@@ -74,12 +65,8 @@ class Message {
$this->removeMessage($post); $this->removeMessage($post);
$this->header($get); $this->header($get);
} }
if(isset($post['archive_x'])) { if(isset($post['archive_x'])) $this->archiveMessage($post);
$this->archiveMessage($post); if(isset($post['start_x'])) $this->unarchiveMessage($post);
}
if(isset($post['start_x'])) {
$this->unarchiveMessage($post);
}
break; break;
case "m6": case "m6":
$this->createNote($post); $this->createNote($post);
@@ -94,46 +81,28 @@ class Message {
public function noticeType($get) { public function noticeType($get) {
global $session, $database; global $session, $database;
if(isset($get['t'])) { if(isset($get['t'])) {
if($get['t'] == 1) { if($get['t'] == 1) $type = [8, 15, 16, 17];
$type = array(8, 15, 16, 17); if($get['t'] == 2) $type = [10, 11, 12, 13];
} if($get['t'] == 3) $type = [1, 2, 3, 4, 5, 6, 7];
if($get['t'] == 2) { if($get['t'] == 4) $type = [0, 18, 19, 20, 21];
$type = array(10, 11, 12, 13);
}
if($get['t'] == 3) {
$type = array(1, 2, 3, 4, 5, 6, 7);
}
if($get['t'] == 4) {
$type = array(0, 18, 19, 20, 21);
}
if($get['t'] == 5) { if($get['t'] == 5) {
if(!$session->plus){ if(!$session->plus){
header("Location: berichte.php"); header("Location: berichte.php");
exit; exit;
} else {
$type = 9;
} }
else $type = 9;
} }
if (!is_array($type)) { $type = array($type); } if (!is_array($type)) $type = [$type];
$this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type); $this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type);
$this->notice = $this->filter_by_value($database->getNotice3($session->uid, $session->alliance), "ntype", $type);
} }
if(isset($get['id'])) { if(isset($get['id'])) $this->readingNotice = $this->getReadNotice($get['id']);
$this->readingNotice = $this->getReadNotice($get['id']);
}
} }
public function procNotice($post) { public function procNotice($post) {
if(isset($post["del_x"])) { if(isset($post["del_x"])) $this->removeNotice($post);
$this->removeNotice($post); if(isset($post['archive_x'])) $this->archiveNotice($post);
} if(isset($post['start_x'])) $this->unarchiveNotice($post);
if(isset($post['archive_x'])) {
$this->archiveNotice($post);
}
if(isset($post['start_x'])) {
$this->unarchiveNotice($post);
}
} }
public function quoteMessage($id) { public function quoteMessage($id) {
@@ -142,22 +111,22 @@ class Message {
$message = preg_replace('/\[message\]/', '', $message); $message = preg_replace('/\[message\]/', '', $message);
$message = preg_replace('/\[\/message\]/', '', $message); $message = preg_replace('/\[\/message\]/', '', $message);
for($i=1;$i<=$message['alliance'];$i++){ for($i = 1; $i <= $message['alliance']; $i++){
$message = preg_replace('/\[alliance'.$i.'\]/', '[alliance0]', $message); $message = preg_replace('/\[alliance'.$i.'\]/', '[alliance0]', $message);
$message = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance0]', $message); $message = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance0]', $message);
} }
for($i=0;$i<=$message['player'];$i++){ for($i = 0; $i <= $message['player']; $i++){
$message = preg_replace('/\[player'.$i.'\]/', '[player0]', $message); $message = preg_replace('/\[player'.$i.'\]/', '[player0]', $message);
$message = preg_replace('/\[\/player'.$i.'\]/', '[/player0]', $message); $message = preg_replace('/\[\/player'.$i.'\]/', '[/player0]', $message);
} }
for($i=0;$i<=$message['coor'];$i++){ for($i = 0; $i <= $message['coor']; $i++){
$message = preg_replace('/\[coor'.$i.'\]/', '[coor0]', $message); $message = preg_replace('/\[coor'.$i.'\]/', '[coor0]', $message);
$message = preg_replace('/\[\/coor'.$i.'\]/', '[/coor0]', $message); $message = preg_replace('/\[\/coor'.$i.'\]/', '[/coor0]', $message);
} }
for($i=0;$i<=$message['report'];$i++){ for($i = 0; $i <= $message['report']; $i++){
$message = preg_replace('/\[report'.$i.'\]/', '[report0]', $message); $message = preg_replace('/\[report'.$i.'\]/', '[report0]', $message);
$message = preg_replace('/\[\/report'.$i.'\]/', '[/report0]', $message); $message = preg_replace('/\[\/report'.$i.'\]/', '[/report0]', $message);
} }
@@ -171,34 +140,39 @@ class Message {
public function loadMessage($id) { public function loadMessage($id) {
global $database, $session; global $database, $session;
if($this->findInbox($id)) { if($this->findInbox($id)) {
foreach($this->inbox as $message) { foreach($this->inbox as $message) {
if($message['id'] == $id) { if($message['id'] == $id) {
$this->reading = $message; $this->reading = $message;
break;
} }
} }
} }
if($this->findSent($id)) { if($this->findSent($id)) {
foreach($this->sent as $message) { foreach($this->sent as $message) {
if($message['id'] == $id) { if($message['id'] == $id) {
$this->reading = $message; $this->reading = $message;
break;
} }
} }
} }
if($session->plus && $this->findArchive($id)) { if($session->plus && $this->findArchive($id)) {
foreach($this->archived as $message) { foreach($this->archived as $message) {
if($message['id'] == $id) { if($message['id'] == $id) {
$this->reading = $message; $this->reading = $message;
break;
} }
} }
} }
if($this->reading['viewed'] == 0) {
$database->getMessage($id, 4); if($this->reading['viewed'] == 0) $database->getMessage($id, 4);
}
} }
private function filter_by_value_except($array, $index, $value) { private function filter_by_value_except($array, $index, $value) {
$newarray = array(); $newarray = [];
if(is_array($array) && count($array) > 0) { if(is_array($array) && count($array) > 0) {
foreach(array_keys($array) as $key) { foreach(array_keys($array) as $key) {
$temp[$key] = $array[$key][$index]; $temp[$key] = $array[$key][$index];
@@ -213,7 +187,7 @@ class Message {
} }
private function filter_by_value($array, $index, $value) { private function filter_by_value($array, $index, $value) {
$newarray = array(); $newarray = [];
if(is_array($array) && count($array) > 0) { if(is_array($array) && count($array) > 0) {
foreach(array_keys($array) as $key) { foreach(array_keys($array) as $key) {
$temp[$key] = $array[$key][$index]; $temp[$key] = $array[$key][$index];
@@ -229,46 +203,32 @@ class Message {
private function getNotice() { private function getNotice() {
global $database, $session; global $database, $session;
$this->allNotice = $database->getNotice3($session->uid, $session->alliance);
$this->noticearray = $this->filter_by_value_except($database->getNotice($session->uid), "ntype", 9); $this->noticearray = $this->filter_by_value_except($database->getNotice($session->uid), "ntype", 9);
$this->notice = $this->filter_by_value_except($this->allNotice, "ntype", 9);
$this->totalNotice = count($this->allNotice);
} }
private function removeMessage($post) { private function removeMessage($post) {
global $database,$session; global $database, $session;
$post = $database->escape($post); $post = $database->escape($post);
$mode5updates = $mode7updates = $mode8updates = [];
$mode5updates = []; for($i = 1; $i <= 10; $i++){
$mode7updates = []; if(isset($post['n' . $i])){
$mode8updates = []; $message1 = mysqli_query($database->dblink, "SELECT target, owner FROM " . TB_PREFIX . "mdata where id = " . (int)$post['n' . $i] . "");
$message = mysqli_fetch_array($message1);
for($i = 1; $i <= 10; $i++) { if($message['target'] == $session->uid && $message['owner'] == $session->uid){
if ( isset( $post[ 'n' . $i ] ) ) { $mode8updates[] = $post['n' . $i];
$message1 = mysqli_query( $database->dblink, "SELECT target, owner FROM " . TB_PREFIX . "mdata where id = " . (int) $post[ 'n' . $i ] . "" ); }
$message = mysqli_fetch_array( $message1 ); else if($message['target'] == $session->uid) $mode5updates[] = $post['n' . $i];
else if($message['owner'] == $session->uid) $mode7updates[] = $post['n' . $i];
if ( $message['target'] == $session->uid && $message['owner'] == $session->uid ) { }
$mode8updates[] = $post[ 'n' . $i ];
} else if ( $message['target'] == $session->uid ) {
$mode5updates[] = $post[ 'n' . $i ];
} else if ( $message['owner'] == $session->uid ) {
$mode7updates[] = $post[ 'n' . $i ];
}
}
} }
if (count($mode5updates)) { if(count($mode5updates)) $database->getMessage($mode5updates, 5);
$database->getMessage( $mode5updates, 5 ); if(count($mode7updates)) $database->getMessage($mode7updates, 7);
} if(count($mode8updates)) $database->getMessage($mode8updates, 8);
if (count($mode7updates)) {
$database->getMessage( $mode7updates, 7 );
}
if (count($mode8updates)) {
$database->getMessage( $mode8updates, 8 );
}
header("Location: nachrichten.php"); header("Location: nachrichten.php");
exit; exit;
@@ -294,12 +254,12 @@ class Message {
global $database; global $database;
$normIDs = []; $normIDs = [];
for($i = 1; $i <= 10; $i++) { for($i = 1; $i <= 10; $i++) {
if(isset($post['n' . $i])) { if(isset($post['n' . $i])) {
$normIDs[] = $post['n' . $i]; $normIDs[] = $post['n' . $i];
} }
} }
$database->setNorm($normIDs); $database->setNorm($normIDs);
header("Location: nachrichten.php"); header("Location: nachrichten.php");
@@ -310,12 +270,12 @@ class Message {
global $database; global $database;
$removeIDs = []; $removeIDs = [];
for($i = 1; $i <= 10; $i++) { for($i = 1; $i <= 10; $i++) {
if(isset($post['n' . $i])) { if(isset($post['n' . $i])) {
$removeIDs[] = $post['n' . $i]; $removeIDs[] = $post['n' . $i];
} }
} }
$database->removeNotice($removeIDs); $database->removeNotice($removeIDs);
header("Location: berichte.php"); header("Location: berichte.php");
@@ -326,12 +286,12 @@ class Message {
global $database; global $database;
$archiveIDs = []; $archiveIDs = [];
for($i = 1; $i <= 10; $i++) { for($i = 1; $i <= 10; $i++) {
if(isset($post['n' . $i])) { if(isset($post['n' . $i])) {
$archiveIDs[] = $post['n' . $i]; $archiveIDs[] = $post['n' . $i];
} }
} }
$database->archiveNotice($archiveIDs); $database->archiveNotice($archiveIDs);
header("Location: berichte.php"); header("Location: berichte.php");
@@ -342,12 +302,12 @@ class Message {
global $database; global $database;
$unarchIDs = []; $unarchIDs = [];
for($i = 1; $i <= 10; $i++) { for($i = 1; $i <= 10; $i++) {
if(isset($post['n' . $i])) { if(isset($post['n' . $i])) {
$unarchIDs[] = $post['n' . $i]; $unarchIDs[] = $post['n' . $i];
} }
} }
$database->unarchiveNotice($unarchIDs); $database->unarchiveNotice($unarchIDs);
header("Location: berichte.php"); header("Location: berichte.php");
@@ -356,12 +316,13 @@ class Message {
private function getReadNotice($id) { private function getReadNotice($id) {
global $database, $session; global $database, $session;
foreach($this->allNotice as $notice) {
if($notice['id'] == $id) { $notice = $database->getNotice2($id);
if($notice['uid'] == $session->uid) $database->noticeViewed($notice['id']); if($notice['uid'] == $session->uid || $notice['ally'] == $session->alliance){
return $notice; if($notice['uid'] == $session->uid) $database->noticeViewed($notice['id']);
} return $notice;
} }
else return null;
} }
/** /**
@@ -402,17 +363,16 @@ class Message {
public function loadNotes() { public function loadNotes() {
global $session; global $session;
if(file_exists("GameEngine/Notes/" . md5($session->username) . ".txt")) { if(file_exists("GameEngine/Notes/".md5($session->username).".txt")) {
$this->note = file_get_contents("GameEngine/Notes/" . md5($session->username) . ".txt"); $this->note = file_get_contents("GameEngine/Notes/".md5($session->username).".txt");
} else {
$this->note = "";
} }
else $this->note = "";
} }
private function createNote($post) { private function createNote($post) {
global $session; global $session;
if($session->plus) { if($session->plus) {
$ourFileHandle = fopen("GameEngine/Notes/" . md5($session->username) . ".txt", 'w'); $ourFileHandle = fopen("GameEngine/Notes/".md5($session->username).".txt", 'w');
fwrite($ourFileHandle, $post['notizen']); fwrite($ourFileHandle, $post['notizen']);
fclose($ourFileHandle); fclose($ourFileHandle);
} }
@@ -421,21 +381,24 @@ class Message {
private function getMessages($which) { private function getMessages($which) {
global $database, $session; global $database, $session;
switch ($which) { switch($which){
case 1: $this->inbox = $database->getMessage($session->uid, 1); case 1 :
$this->inbox1 = $database->getMessage($session->uid, 9); $this->inbox = $database->getMessage($session->uid, 1);
break; $this->inbox1 = $database->getMessage($session->uid, 9);
break;
case 2: $this->sent = $database->getMessage($session->uid, 2); case 2 :
$this->sent1 = $database->getMessage($session->uid, 10); $this->sent = $database->getMessage($session->uid, 2);
break; $this->sent1 = $database->getMessage($session->uid, 10);
break;
case 3: if($session->plus) { case 3 :
$this->archived = $database->getMessage($session->uid, 6); if($session->plus){
$this->archived1 = $database->getMessage($session->uid, 11); $this->archived = $database->getMessage($session->uid, 6);
} $this->archived1 = $database->getMessage($session->uid, 11);
break; }
} break;
}
} }
private function sendAMessage($topic,$text) { private function sendAMessage($topic,$text) {
@@ -524,8 +487,8 @@ class Message {
} }
} }
if($permission['opt7']==1){ if($permission['opt7'] == 1){
if ($userally != 0) { if ($userally > 0) {
while ($allmembers = mysqli_fetch_array($allmembersQ)) { while ($allmembers = mysqli_fetch_array($allmembersQ)) {
$database->sendMessage($allmembers[id],$session->uid,htmlspecialchars(addslashes($topic)),htmlspecialchars(addslashes($text)),0,$alliance,$player,$coor,$report); $database->sendMessage($allmembers[id],$session->uid,htmlspecialchars(addslashes($topic)),htmlspecialchars(addslashes($text)),0,$alliance,$player,$coor,$report);
} }
@@ -555,9 +518,7 @@ class Message {
$text = $this->wordCensor($text); $text = $this->wordCensor($text);
} }
if($topic == "") { if(empty($topic)) $topic = "No subject";
$topic = "No subject";
}
if ( ! preg_match( '/\[message\]/', $text ) && ! preg_match( '/\[\/message\]/', $text ) ) { if ( ! preg_match( '/\[message\]/', $text ) && ! preg_match( '/\[\/message\]/', $text ) ) {
$text = "[message]" . $text . "[/message]"; $text = "[message]" . $text . "[/message]";
@@ -620,34 +581,23 @@ class Message {
} }
// check if we're not sending this as Support or Multihunter // check if we're not sending this as Support or Multihunter
$support_from_admin_allowed = ( $session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES ); $support_from_admin_allowed = ($session->access == ADMIN && ADMIN_RECEIVE_SUPPORT_MESSAGES);
$send_as = $session->uid; $send_as = $session->uid;
// send as Support? // send as Support?
if (( ! empty( $_POST['as_support'] ) && $support_from_admin_allowed )) { if((!empty($_POST['as_support']) && $support_from_admin_allowed)) $send_as = 1;
$send_as = 1;
}
// send as Multihunter // send as Multihunter
if (( ! empty( $_POST['as_multihunter'] ) && $session->access == MULTIHUNTER )) { if((!empty($_POST['as_multihunter']) && $session->access == MULTIHUNTER)) $send_as = 5;
$send_as = 5;
}
$database->sendMessage( $user, $send_as, htmlspecialchars( addslashes( $topic ) ), htmlspecialchars( addslashes( $text ) ), 0, $alliance, $player, $coor, $report ); $database->sendMessage($user, $send_as, htmlspecialchars(addslashes($topic)), htmlspecialchars(addslashes($text)), 0, $alliance, $player, $coor, $report);
} }
} }
//7 = village, attacker, att tribe, u1 - u10, lost %, w,c,i,c , cap
//8 = village, attacker, att tribe, enforcement
private function sendNotice($from, $vid, $fowner, $owner, $type, $extra) {
}
public function sendWelcome($uid, $username) { public function sendWelcome($uid, $username) {
global $database; global $database;
$welcomemsg = file_get_contents("GameEngine/Admin/welcome.tpl"); $welcomemsg = file_get_contents("GameEngine/Admin/welcome.tpl");
$welcomemsg = "[message]".preg_replace( $welcomemsg = "[message]".preg_replace(
["'%USER%'", "'%START%'", "'%TIME%'", "'%PLAYERS%'", "'%ALLI%'", "'%SERVER_NAME%'", "'%PROTECTION%'"], ["'%USER%'", "'%START%'", "'%TIME%'", "'%PLAYERS%'", "'%ALLI%'", "'%SERVER_NAME%'", "'%PROTECTION%'"],
[$username, date("y.m.d", COMMENCE), date("H:i", COMMENCE), $database->countUser(), $database->countAlli(), SERVER_NAME, round((PROTECTION/3600))], [$username, date("y.m.d", COMMENCE), date("H:i", COMMENCE), $database->countUser(), $database->countAlli(), SERVER_NAME, round((PROTECTION/3600))],
@@ -678,85 +628,78 @@ class Message {
} }
private function findInbox($id) { private function findInbox($id) {
if (count($this->inbox)) { if(count($this->inbox)){
foreach ( $this->inbox as $message ) { foreach($this->inbox as $message){
if ( $message['id'] == $id ) { if($message['id'] == $id) return true;
return true; }
} }
}
}
return false; return false;
} }
private function findSent($id) { private function findSent($id){
if (!empty($this->sent)) { if(!empty($this->sent)){
foreach ( $this->sent as $message ) { foreach($this->sent as $message){
if ( $message['id'] == $id ) { if($message['id'] == $id) return true;
return true; }
} }
}
}
return false; return false;
} }
private function findArchive($id) { private function findArchive($id){
if (!empty($this->archived)) { if(!empty($this->archived)){
foreach ( $this->archived as $message ) { foreach($this->archived as $message){
if ( $message['id'] == $id ) { if($message['id'] == $id) return true;
return true; }
} }
}
}
return false; return false;
} }
public function addFriends($post) { public function addFriends($post){
global $database; global $database;
for ( $i = 0; $i <= 19; $i ++ ) { for($i = 0; $i <= 19; $i++){
if ( $post[ 'addfriends' . $i ] != "" ) { if($post['addfriends'.$i] != ""){
$uid = $database->getUserField( $post[ 'addfriends' . $i ], "id", 1 ); $uid = $database->getUserField($post['addfriends'.$i], "id", 1);
$added = 0; $added = 0;
for ( $j = 0; $j <= $i; $j ++ ) { for($j = 0; $j <= $i; $j++){
if ( $added == 0 ) { if($added == 0){
$user = $database->getUserField( $post['myid'], "friend" . $j, 0 ); $user = $database->getUserField($post['myid'], "friend".$j, 0);
$userwait = $database->getUserField( $post['myid'], "friend" . $j . "wait", 0 ); $userwait = $database->getUserField($post['myid'], "friend".$j."wait", 0);
$exist = 0; $exist = 0;
for ( $k = 0; $k <= 19; $k ++ ) { for($k = 0; $k <= 19; $k++){
$user1 = $database->getUserField( $post['myid'], "friend" . $k, 0 ); $user1 = $database->getUserField($post['myid'], "friend".$k, 0);
if ( $user1 == $uid or $uid == $post['myid'] ) { if($user1 == $uid or $uid == $post['myid']){
$exist = 1; $exist = 1;
} }
} }
if ( $user == 0 && $userwait == 0 && $exist == 0 ) { if($user == 0 && $userwait == 0 && $exist == 0){
$added1 = 0; $added1 = 0;
for ( $l = 0; $l <= 19; $l ++ ) { for($l = 0; $l <= 19; $l++){
$user2 = $database->getUserField( $uid, "friend" . $l, 0 ); $user2 = $database->getUserField($uid, "friend".$l, 0);
$userwait2 = $database->getUserField( $uid, "friend" . $l . "wait", 0 ); $userwait2 = $database->getUserField($uid, "friend".$l."wait", 0);
if ( $user2 == 0 && $userwait2 == 0 && $added1 == 0 ) { if($user2 == 0 && $userwait2 == 0 && $added1 == 0){
$database->addFriend( $uid, "friend" . $l . "wait", $post['myid'] ); $database->addFriend($uid, "friend".$l."wait", $post['myid']);
$added1 = 1; $added1 = 1;
} }
} }
$database->addFriend( $post['myid'], "friend" . $j, $uid ); $database->addFriend($post['myid'], "friend".$j, $uid);
$database->addFriend( $post['myid'], "friend" . $j . "wait", $uid ); $database->addFriend($post['myid'], "friend".$j."wait", $uid);
$added = 1; $added = 1;
} }
} }
} }
} }
} }
header( "Location: nachrichten.php?t=1" ); header("Location: nachrichten.php?t=1");
exit; exit();
} }
} };
;
+19 -20
View File
@@ -503,27 +503,26 @@ class Units {
$troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $post, 1, 't'); $troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $post, 1, 't');
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime); $time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
$reference = $database->addAttack($enforce['from'], $post['t1'], $post['t2'], $post['t3'], $post['t4'], $post['t5'], $post['t6'], $post['t7'], $post['t8'], $post['t9'], $post['t10'], $post['t11'], 2, 0, 0, 0, 0 ); $reference = $database->addAttack($enforce['from'], $post['t1'], $post['t2'], $post['t3'], $post['t4'], $post['t5'], $post['t6'], $post['t7'], $post['t8'], $post['t9'], $post['t10'], $post['t11'], 2, 0, 0, 0, 0);
$database->addMovement(4, $village->wid, $enforce['from'], $reference, time(), ($time + time())); $database->addMovement(4, $village->wid, $enforce['from'], $reference, time(), ($time + time()));
$technology->checkReinf($post['ckey'], false ); $technology->checkReinf($post['ckey'], false);
header( "Location: build.php?id=39&refresh=1" ); header("Location: build.php?id=39&refresh=1");
exit; exit();
}
} }else{
} else { $form->addError("error", "You cant change someones troops.");
$form->addError( "error", "You cant change someones troops." ); if($form->returnErrors() > 0){
if ( $form->returnErrors() > 0 ) { $_SESSION['errorarray'] = $form->getErrors();
$_SESSION['errorarray'] = $form->getErrors(); $_SESSION['valuearray'] = $_POST;
$_SESSION['valuearray'] = $_POST; header("Location: a2b.php");
header( "Location: a2b.php" ); exit();
exit; }
} }
} }else{
} else { header("Location: banned.php");
header( "Location: banned.php" ); exit();
exit; }
}
} }
public function Settlers($post) { public function Settlers($post) {
+1 -1
View File
@@ -317,5 +317,5 @@ class Village {
}; };
$village = new Village; $village = new Village;
$building = new Building; $building = new Building;
include_once ("Automation.php"); include_once("Automation.php");
?> ?>
+4 -15
View File
@@ -1,5 +1,5 @@
<?php <?php
include_once ("GameEngine/Data/unitdata.php"); include_once("GameEngine/Data/unitdata.php");
$units = $database->getMovement(34, $village->wid, 1); $units = $database->getMovement(34, $village->wid, 1);
$total_for = count($units); $total_for = count($units);
@@ -7,12 +7,6 @@ $send = $database->getMovement(1, $village->wid, 1);
$total_for2 = count($send); $total_for2 = count($send);
$artifactsSum = $database->getArtifactsSumByKind($session->uid, $village->wid, 3); $artifactsSum = $database->getArtifactsSumByKind($session->uid, $village->wid, 3);
for($y = 0; $y < $total_for; $y++){ for($y = 0; $y < $total_for; $y++){
for($i = 0; $i < $total_for2; $i++){
if($units[$y]['ref'] == $send[$i]['ref2']){
$res1 = mysqli_query($database->dblink, "SELECT wood, clay, iron, crop FROM ".TB_PREFIX."send where id = ".(int)$send[$i]['ref']."");
$res = mysqli_fetch_array($res1);
}
}
$session->timer++; $session->timer++;
if($units[$y]['sort_type'] == 3){ if($units[$y]['sort_type'] == 3){
if($units[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR; if($units[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR;
@@ -162,10 +156,8 @@ for($y = 0; $y < $total_for; $y++){
</tr> </tr>
</tbody> </tbody>
<?php <?php
if(isset($res)) $totalres = $res['wood'] + $res['clay'] + $res['iron'] + $res['crop']; $totalres = $units[$y]['wood'] + $units[$y]['clay'] + $units[$y]['iron'] + $units[$y]['crop'];
else $totalres = 0; if($units[$y]['attack_type'] != 2 && $units[$y]['attack_type'] != 1 && $totalres > 0){
if($units[$y]['attack_type'] != 2 && $units[$y]['attack_type'] != 1 && !empty($totalres)){
?> ?>
<tbody class="goods"> <tbody class="goods">
<tr> <tr>
@@ -175,11 +167,9 @@ for($y = 0; $y < $total_for; $y++){
<?php <?php
$totalcarry = 0; $totalcarry = 0;
for($i = 0; $i <= 9; $i++) $totalcarry += $units[$y]['t'.($i + 1)] * ${'u'.($start + $i)}['cap']; for($i = 0; $i <= 9; $i++) $totalcarry += $units[$y]['t'.($i + 1)] * ${'u'.($start + $i)}['cap'];
echo "<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".$res['wood']." | <img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".$res['clay']." | <img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".$res['iron']." | <img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".$res['crop']."</div>"; echo "<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".$units[$y]['wood']." | <img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".$units[$y]['clay']." | <img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".$units[$y]['iron']." | <img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".$units[$y]['crop']."</div>";
echo "<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\"/>".$totalres."/".$totalcarry."</div>"; echo "<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\"/>".$totalres."/".$totalcarry."</div>";
?> ?>
</tr> </tr>
</tbody> </tbody>
<?php } ?> <?php } ?>
@@ -202,7 +192,6 @@ for($y = 0; $y < $total_for; $y++){
</table> </table>
<?php <?php
} }
unset($res, $res1);
} }
$array = $database->getOasis($village->wid); $array = $database->getOasis($village->wid);
foreach($array as $conqured){ foreach($array as $conqured){
+30 -34
View File
@@ -1,5 +1,7 @@
<?php <?php
$noticeClass = array("Scout Report","Won as attacker without losses","Won as attacker with losses","Lost as attacker with losses","Won as defender without losses","Won as defender with losses","Lost as defender with losses","Lost as defender without losses","Reinforcement arrived","","Wood Delivered","Clay Delivered","Iron Delivered","Crop Delivered","","Won as defender without losses","Won as defender with losses","Lost as defender with losses","Won scouting as attacker","Lost scouting as attacker","Won scouting as defender","Lost scouting as defender","Scout Report"); $noticeClass = ["Scout Report", "Won as attacker without losses", "Won as attacker with losses", "Lost as attacker with losses", "Won as defender without losses", "Won as defender with losses", "Lost as defender with losses", "Lost as defender without losses", "Reinforcement arrived", "",
"Wood Delivered", "Clay Delivered", "Iron Delivered", "Crop Delivered", "", "Won as defender without losses", "Won as defender with losses", "Lost as defender with losses", "Won scouting as attacker", "Lost scouting as attacker", "Won scouting as defender", "Lost scouting as defender",
"Scout Report"];
?> ?>
<form method="post" action="berichte.php" name="msg"> <form method="post" action="berichte.php" name="msg">
<table cellpadding="1" cellspacing="1" id="overview" <table cellpadding="1" cellspacing="1" id="overview"
@@ -55,41 +57,35 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att
<tbody> <tbody>
<?php <?php
if(isset($_GET['s'])) { if(isset($_GET['s'])) $s = $_GET['s'];
$s = $_GET['s']; else $s = 0;
}
else {
$s = 0;
}
$name = 1; $name = 1;
$count = 0; $count = 0;
for($i=(1+$s);$i<=(10+$s);$i++) { for($i = (1 + $s); $i <= (10 + $s); $i++){
if(count($message->noticearray) >= $i) { if(count($message->noticearray) >= $i){
echo "<tr><td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->noticearray[$i-1]['id']."\" /></td> echo "<tr><td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $message->noticearray[$i - 1]['id'] . "\" /></td>
<td class=\"sub\">"; <td class=\"sub\">";
$type = (isset($_GET['t']) && $_GET['t'] == 5)? $message->noticearray[$i-1]['archive'] : $message->noticearray[$i-1]['ntype']; $type = (isset($_GET['t']) && $_GET['t'] == 5) ? $message->noticearray[$i - 1]['archive'] : $message->noticearray[$i - 1]['ntype'];
if($type == 23) $type = 22; if($type == 23) $type = 22;
if($type >= 15 && $type <= 17){ if($type >= 15 && $type <= 17){
$type = $type-11; $type = $type - 11;
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"".$noticeClass[$type]."\" title=\"".$noticeClass[$type]."\" />"; echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}else if($type >= 18 && $type <= 22){ }else if($type >= 18 && $type <= 22){
echo "<img src=\"gpack/travian_default/img/scouts/$type.gif\" alt=\"".$noticeClass[$type]."\" title=\"".$noticeClass[$type]."\" />"; echo "<img src=\"gpack/travian_default/img/scouts/$type.gif\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}else{ }else{
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"".$noticeClass[$type]."\" title=\"".$noticeClass[$type]."\" />"; echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
} }
echo "<div><a href=\"berichte.php?id=".$message->noticearray[$i-1]['id']."\">".$message->noticearray[$i-1]['topic']."</a> "; echo "<div><a href=\"berichte.php?id=" . $message->noticearray[$i - 1]['id'] . "\">" . $message->noticearray[$i - 1]['topic'] . "</a> ";
if($message->noticearray[$i-1]['viewed'] == 0) { if($message->noticearray[$i - 1]['viewed'] == 0){
echo "(new)"; echo "(new)";
} }
$date = $generator->procMtime($message->noticearray[$i-1]['time']); $date = $generator->procMtime($message->noticearray[$i - 1]['time']);
echo "</div></td><td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>"; echo "</div></td><td class=\"dat\">" . $date[0] . " " . $date[1] . "</td></tr>";
} }
$name++; $name++;
} }
if(count($message->noticearray) == 0) { if(count($message->noticearray) == 0) echo "<td colspan=\"3\" class=\"none\">There are no reports available.</td></tr>";
echo "<td colspan=\"3\" class=\"none\">There are no reports available.</td></tr>";
}
?> ?>
</tbody> </tbody>
+22 -33
View File
@@ -252,39 +252,28 @@ if(isset($_POST['a']) == 533374 && isset($_POST['id']) == 39) {
} }
} }
if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'troops' && isset( $_GET['cancel'] ) && $_GET['cancel'] == 1 ) { if(isset($_GET['mode']) && $_GET['mode'] == 'troops' && isset($_GET['cancel']) && $_GET['cancel'] == 1){
if ( $session->access != BANNED ) { if($session->access != BANNED){
$oldmovement = $database->getMovementById( $_GET['moveid'] ); $oldmovement = $database->getMovementById($_GET['moveid']);
$now = time(); $now = time();
if(($now - $oldmovement[0]['starttime']) < 90 && $oldmovement[0]['from'] == $village->wid){
if ( ( $now - $oldmovement[0]['starttime'] ) < 90 && $oldmovement[0]['from'] == $village->wid ) { $qc = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement where proc = 0 and moveid = " . $database->escape((int)$_GET['moveid']);
$resultc = mysqli_fetch_array(mysqli_query($database->dblink, $qc), MYSQLI_ASSOC);
$qc = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement where proc = 0 and moveid = " . $database->escape( (int) $_GET['moveid'] ); if($resultc['Total'] == 1){
$resultc = mysqli_fetch_array( mysqli_query( $database->dblink, $qc ), MYSQLI_ASSOC ); $q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where proc = 0 and moveid = " . $database->escape((int)$_GET['moveid']);
$database->query($q);
if ( $resultc['Total'] == 1 ) { $end = $now + ($now - $oldmovement[0]['starttime']);
$q2 = "SELECT id FROM " . TB_PREFIX . "send ORDER BY id DESC";
$q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where proc = 0 and moveid = " . $database->escape( (int) $_GET['moveid'] ); $lastid = mysqli_fetch_array(mysqli_query($database->dblink, $q2));
$database->query( $q ); $database->addMovement(4, $oldmovement[0]['to'], $oldmovement[0]['from'], $oldmovement[0]['ref'], $now, $end);
$end = $now + ( $now - $oldmovement[0]['starttime'] ); }
//echo "6,".$oldmovement[0]['to'].",".$oldmovement[0]['from'].",0,".$now.",".$end; }
$q2 = "SELECT id FROM " . TB_PREFIX . "send ORDER BY id DESC"; header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id']);
$lastid = mysqli_fetch_array( mysqli_query( $database->dblink, $q2 ) ); exit();
$newid = $lastid['id'] + 1; }else{
$q2 = "INSERT INTO " . TB_PREFIX . "send values ($newid,0,0,0,0,0)"; header("Location: banned.php");
$database->query( $q2 ); exit();
$database->addMovement( 4, $oldmovement[0]['to'], $oldmovement[0]['from'], $oldmovement[0]['ref'], $now, $end ); }
$database->addMovement( 6, $oldmovement[0]['to'], $oldmovement[0]['from'], $newid, $now, $end );
}
}
header( "Location: " . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id'] );
exit;
} else {
header( "Location: banned.php" );
exit;
}
} }
if(isset($_GET['id'])) $automation->isWinner(); if(isset($_GET['id'])) $automation->isWinner();
?> ?>
+1 -3
View File
@@ -234,9 +234,7 @@ if(isset($_POST['password']) && $_POST['password'] != ""){
} }
} }
if ($counter > 0) { if ($counter > 0) $database->addMovement($type, $from, $to, $ref, $time, $endtime);
$database->addMovement( $type, $from, $to, $ref, $time, $endtime );
}
/** /**
* SMALL ARTEFACTS * SMALL ARTEFACTS
+1 -2
View File
@@ -21,9 +21,8 @@ if(isset($_GET['newdid'])) {
$database->query("UPDATE ".TB_PREFIX."users SET village_select=".$database->escape((int) $_GET['newdid'])." WHERE id=".$session->uid); $database->query("UPDATE ".TB_PREFIX."users SET village_select=".$database->escape((int) $_GET['newdid'])." WHERE id=".$session->uid);
header("Location: ".$_SERVER['PHP_SELF']); header("Location: ".$_SERVER['PHP_SELF']);
exit; exit;
}else{
$building->procBuild($_GET);
} }
else $building->procBuild($_GET);
$automation->isWinner(); $automation->isWinner();
?> ?>