From 996f0116665ae71e417be2472ec832d10d21bf37 Mon Sep 17 00:00:00 2001 From: iopietro Date: Sat, 21 Apr 2018 17:28:20 +0200 Subject: [PATCH] Fixed some report bugs +Added the report type 23, which indicates a defence during festive days +Festive reports in the alliance no longer duplicates +Festive reports in the village view no longer duplicates +Fixed a bug that didn't permit to read an allied report General: -Removed the possibility to view an inexistent village +Some minor improovements --- GameEngine/Automation.php | 17 ++-- GameEngine/Database.php | 6 +- GameEngine/Message.php | 14 ++-- Templates/Alliance/attack-filtered.tpl | 11 +-- Templates/Alliance/attacks.tpl | 5 +- Templates/Map/vilview.tpl | 104 +++++++++++++------------ Templates/Notice/22.tpl | 8 +- Templates/Notice/all.tpl | 5 +- karte.php | 9 +-- 9 files changed, 92 insertions(+), 87 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 0d35e9b4..10975f6a 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -3075,8 +3075,9 @@ class Automation { $database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],$AttackArrivalTime,$endtime); $peace = PEACE; $data2 = $from['owner'].','.$from['wref'].','.$to['owner'].','.$owntribe.','.$unitssend_att.','.$peace; - $database->addNotice($from['owner'],$to['wref'],$ownally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time()); - $database->addNotice($to['owner'],$to['wref'],$targetally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time()); + $time = time(); + $database->addNotice($from['owner'], $to['wref'], $ownally, 22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'', $data2, $time); + $database->addNotice($to['owner'], $to['wref'], $targetally, 23,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'', $data2, $time); } //check if not natar tribe @@ -3768,29 +3769,26 @@ class Automation { } private function updateRes($bountywid,$uid) { - global $session; - - $this->bountyLoadTown($bountywid); $this->bountycalculateProduction($bountywid,$uid); $this->bountyprocessProduction($bountywid); } private function updateORes($bountywid) { - global $session; $this->bountyLoadOTown($bountywid); $this->bountycalculateOProduction($bountywid); $this->bountyprocessOProduction($bountywid); } + private function bountyLoadOTown($bountywid) { - global $database,$session,$logging,$technology; + global $database; $this->bountyinfoarray = $database->getOasisV($bountywid); $this->bountyresarray = $database->getResourceLevel($bountywid); $this->bountypop = 2; } private function bountyLoadTown($bountywid) { - global $database,$session,$logging,$technology; + global $database; $this->bountyinfoarray = $database->getVillage($bountywid); $this->bountyresarray = $database->getResourceLevel($bountywid); $this->bountyoasisowned = $database->getOasis($bountywid); @@ -4802,7 +4800,7 @@ class Automation { /************************************************ Function for starvation - by brainiacX and Shadow Rework by ronix - Refacored by iopietro + Refactored by iopietro References: ************************************************/ @@ -5017,6 +5015,7 @@ class Automation { /************************************************ Function for starvation - by brainiacX and Shadow Rework by ronix + Refactored by iopietro References: ************************************************/ diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 43792931..966fba18 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -4270,7 +4270,7 @@ References: User ID/Message ID, Mode return self::$noticesCacheById[$id][$field]; } - function getNotice3($uid, $use_cache = true) { + 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 @@ -4279,8 +4279,8 @@ References: User ID/Message ID, Mode return $cachedValue; } - $q = "SELECT * FROM " . TB_PREFIX . "ndata where uid = $uid ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC'); - $result = mysqli_query($this->dblink,$q); + $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]; diff --git a/GameEngine/Message.php b/GameEngine/Message.php index 5d497f5c..8ec850b0 100755 --- a/GameEngine/Message.php +++ b/GameEngine/Message.php @@ -116,7 +116,7 @@ class Message { } if (!is_array($type)) { $type = array($type); } $this->noticearray = $this->filter_by_value($database->getNotice($session->uid), "ntype", $type); - $this->notice = $this->filter_by_value($database->getNotice3($session->uid), "ntype", $type); + $this->notice = $this->filter_by_value($database->getNotice3($session->uid, $session->alliance), "ntype", $type); } if(isset($get['id'])) { $this->readingNotice = $this->getReadNotice($get['id']); @@ -228,7 +228,7 @@ class Message { private function getNotice() { global $database, $session; - $this->allNotice = $database->getNotice3($session->uid); + $this->allNotice = $database->getNotice3($session->uid, $session->alliance); $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); @@ -354,10 +354,10 @@ class Message { } private function getReadNotice($id) { - global $database; + global $database, $session; foreach($this->allNotice as $notice) { - if($notice['id'] == $id) { - $database->noticeViewed($notice['id']); + if($notice['id'] == $id) { + if($notice['uid'] == $session->uid) $database->noticeViewed($notice['id']); return $notice; } } @@ -391,7 +391,9 @@ class Message { case 16: case 17: return 15; - case 19: return 3; + case 19: return 3; + + case 23: return 22; } return $type; diff --git a/Templates/Alliance/attack-filtered.tpl b/Templates/Alliance/attack-filtered.tpl index 8ea7b9c5..81e08a89 100644 --- a/Templates/Alliance/attack-filtered.tpl +++ b/Templates/Alliance/attack-filtered.tpl @@ -1,7 +1,7 @@ dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype != 0 AND ntype < 4 OR ntype > 17 AND ntype != 20 AND ntype != 21) ORDER BY time DESC LIMIT 20"); -elseif($filterType == 32) $sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype < 1 OR ntype > 3 AND ntype < 8 OR ntype > 19) ORDER BY time DESC LIMIT 20"); +if($filterType == 31) $sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype != 0 AND ntype < 4 OR ntype > 17 AND ntype != 20 AND ntype != 21 AND ntype != 22) ORDER BY time DESC LIMIT 20"); +elseif($filterType == 32) $sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype < 1 OR ntype > 3 AND ntype < 8 OR ntype > 19) AND ntype != 22 ORDER BY time DESC LIMIT 20"); $query = mysqli_num_rows($sql); $outputList = ''; @@ -31,7 +31,8 @@ while($row = mysqli_fetch_array($sql)){ $outputList .= ""; $type = (isset($_GET['t']) && $_GET['t'] == 5)? $archive : $ntype; - if((($type == 18 || $type == 19) && $filterType == 31) || (($type == 20 || $type == 21) && $filterType == 32)){ + if($type == 23) $type = 22; + if((($type == 18 || $type == 19) && $filterType == 31) || (($type == 20 || $type == 21) && $filterType == 32) || $type == 22){ $outputList .= ""; }else{ $outputList .= ""; @@ -43,8 +44,8 @@ while($row = mysqli_fetch_array($sql)){ $outputList .= $database->getUserField($dataarray[0], "username", 0); $outputList .= $nn; - $outputList .= $database->getUserField($type != 22 ? $dataarray[28] : $dataarray[2], "username", 0); - $getUserAlly = $database->getUserField($type != 22 ? $dataarray[28] : $dataarray[2], "alliance", 0); + $outputList .= $database->getUserField($type != 22 && $type != 23 ? $dataarray[28] : $dataarray[2], "username", 0); + $getUserAlly = $database->getUserField($type != 22 && $type != 23 ? $dataarray[28] : $dataarray[2], "alliance", 0); $getAllyName = $database->getAllianceName($getUserAlly); if(!$getUserAlly) $allyName = "-"; diff --git a/Templates/Alliance/attacks.tpl b/Templates/Alliance/attacks.tpl index ee2580a4..adafe160 100644 --- a/Templates/Alliance/attacks.tpl +++ b/Templates/Alliance/attacks.tpl @@ -21,7 +21,7 @@ if($_GET['f'] == 31 || $_GET['f'] == 32) include "Templates/Alliance/attack-filt else { -$sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype < 8 OR ntype > 17) ORDER BY time DESC LIMIT 20"); +$sql = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."ndata WHERE ally = ".(int) $session->alliance." AND (ntype < 8 OR (ntype > 17 AND ntype < 22) OR (ntype = 22 AND ally = $session->alliance) OR (ntype = 23 AND ally != $session->alliance)) ORDER BY time DESC LIMIT 20"); $query = mysqli_num_rows($sql); $outputList = ''; $name = 1; @@ -51,7 +51,8 @@ while($row = mysqli_fetch_array($sql)){ $outputList .= ""; $type = (isset($_GET['t']) && $_GET['t'] == 5)? $archive : $ntype; - if($type >= 18 && $type <= 21){ + if($type == 23) $type = 22; + if($type >= 18 && $type <= 22){ $outputList .= ""; }else{ $outputList .= ""; diff --git a/Templates/Map/vilview.tpl b/Templates/Map/vilview.tpl index f9fdd8bb..85529d54 100644 --- a/Templates/Map/vilview.tpl +++ b/Templates/Map/vilview.tpl @@ -14,7 +14,7 @@ echo !$oasis['conqured']? UNOCCUOASIS : OCCUOASIS; echo " (".$basearray['x']."|" $otext = !$oasis['conqured']? UNOCCUOASIS : OCCUOASIS; } ?> (capital)"; } -if($uinfo['owner']==3 && $uinfo['name']==PLANVILLAGE){ +if($uinfo['owner'] == 3 && $uinfo['name'] == PLANVILLAGE){ ?> <?php echo PLANVILLAGE;?> @@ -104,12 +104,13 @@ echo $tt."\""; $landd = explode("-",$tt);?> />
- - + getUnit($_GET['d']); - $unarray = array(31=>U31,U32,U33,U34,U35,U36,U37,U38,U39,U40); + $unarray = array(31 => U31, U32, U33, U34, U35, U36, U37, U38, U39, U40); $a = 0; for ($i = 31; $i <= 40; $i++) { if($unit['u'.$i]){ @@ -146,7 +147,7 @@ if($oasis['owner'] == 2){ } } if($a == 10){ - echo ''; + echo ''; } @@ -160,22 +161,22 @@ if($oasis['owner'] == 2){ uid == $database->getVillage($_GET['d'])){ - $limit = "ntype=0 and ntype=4 and ntype=5 and ntype=6 and ntype=7"; -}else{ - $limit = "ntype!=8 and ntype!=9 and ntype!=10 and ntype!=11 and ntype!=12 and ntype!=13 and ntype!=14 AND ntype!=15 AND ntype!=16 AND ntype!=17"; - } +if($session->uid == $database->getVillage($_GET['d'])['owner']){ + $limit = "ntype > 3 AND ntype < 8"; +} +else $limit = "ntype < 8 OR ntype > 17"; + $toWref = $_GET['d']; -if($session->alliance!=0){ -$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +if($session->alliance != 0){ +$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE ($limit) AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); $query = mysqli_num_rows($result); -if($query != 0){ +if($query){ while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; - $topic=$row['topic']; + $topic = $row['topic']; echo " - + - + -'; } else echo ' '; ?> - + - +
Bonus:
'.NOTROOP.'
"; -if($type==18 or $type==19 or $type==20 or $type==21){ +if($type >= 18 && $type <= 21){ echo "\"".$topic."\""; }else{ echo " "; @@ -193,13 +194,13 @@ if($type==18 or $type==19 or $type==20 or $type==21){ }else{ $result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); $query = mysqli_num_rows($result); -if($query != 0){ +if($query){ while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; echo "
"; -if($type==18 or $type==19 or $type==20 or $type==21){ +if($type >= 18 && $type <= 21){ echo "\"".$topic."\""; }else{ echo " "; @@ -222,29 +223,29 @@ if($type==18 or $type==19 or $type==20 or $type==21){ getUserArray($oasis['owner'],1); ?>
Tribe
Alliance '.$database->getUserAlliance($oasis['owner']).'
Owner getUserField($oasis['owner'],'username',0); ?>
Village getVillageField($oasis['conqured'], "name");?>
- + - + uid == $database->getVillage($_GET['d'])){ - $limit = "ntype=0 and ntype=4 and ntype=5 and ntype=6 and ntype=7 and ntype=20 and ntype=21"; -}else{ - $limit = "ntype!=8 and ntype!=9 and ntype!=10 and ntype!=11 and ntype!=12 and ntype!=13 and ntype!=14 and ntype!=15 and ntype!=16 and ntype!=17"; - } +if($session->uid == $database->getVillage($_GET['d'])['owner']){ + $limit = "(ntype > 3 AND ntype < 8) OR ntype = 20 OR ntype = 21"; +} +else $limit = "ntype < 8 OR ntype > 17"; + $toWref = $_GET['d']; -if($session->alliance!=0){ -$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +if($session->alliance != 0){ +$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE ($limit) AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); $query = mysqli_num_rows($result); -if($query != 0){ +if($query){ while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; - $topic=$row['topic']; + $topic = $row['topic']; echo "
Bonus:
Reports:
"; -if($type==18 or $type==19 or $type==20 or $type==21){ +if($type >= 18 && $type <= 21){ echo "\"".$topic."\""; }else{ echo " "; @@ -292,13 +293,13 @@ if($type==18 or $type==19 or $type==20 or $type==21){ }else{ $result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); $query = mysqli_num_rows($result); -if($query != 0){ +if($query){ while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; - $topic=$row['topic']; + $topic = $row['topic']; echo "
"; -if($type==18 or $type==19 or $type==20 or $type==21){ +if($type >= 18 && $type <= 21){ echo "\"".$topic."\""; }else{ echo " "; @@ -315,7 +316,8 @@ if($type==18 or $type==19 or $type==20 or $type==21){
@@ -385,22 +387,22 @@ if($type==18 or $type==19 or $type==20 or $type==21){ uid == $database->getVillage($_GET['d'])){ - $limit = "ntype=0 and ntype=4 and ntype=5 and ntype=6 and ntype=7"; -}else{ - $limit = "ntype!=8 and ntype!=9 and ntype!=10 and ntype!=11 and ntype!=12 and ntype!=13 and ntype!=14 AND ntype!=15 AND ntype!=16 AND ntype!=17"; - } +if($session->uid == $database->getVillage($_GET['d'])['owner']){ + $limit = "(ntype > 3 AND ntype < 8) OR ntype = 23"; +} +else $limit = "(ntype < 8 OR (ntype > 17 AND ntype < 22)) OR ntype = 22"; + $toWref = $_GET['d']; -if($session->alliance!=0){ -$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE $limit AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +if($session->alliance != 0){ +$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE ($limit) AND ally = ".$session->alliance." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); $query = mysqli_num_rows($result); -if($query != 0){ +if($query){ while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); - $type = $row['ntype']; - $topic=$row['topic']; + $type = ($row['ntype'] == 23) ? 22 : $row['ntype']; + $topic = $row['topic']; echo "
"; -if($type==18 or $type==19 or $type==20 or $type==21 or $type==22){ +if($type >= 18 && $type <= 22){ echo "\"".$topic."\""; }else{ echo " "; @@ -416,15 +418,15 @@ if($type==18 or $type==19 or $type==20 or $type==21 or $type==22){ dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE $limit AND uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); +$result = mysqli_query($database->dblink,"SELECT data, ntype, id, topic, time FROM ".TB_PREFIX."ndata WHERE ($limit) AND uid = ".$session->uid." AND toWref = ".$toWref." ORDER BY time DESC Limit 5"); $query = mysqli_num_rows($result); -if($query != 0){ +if($query){ while($row = mysqli_fetch_array($result)){ $dataarray = explode(",",$row['data']); $type = $row['ntype']; $topic=$row['topic']; echo "
"; -if($type==18 or $type==19 or $type==20 or $type==21){ +if($type >= 18 && $type <= 21){ echo "\"".$topic."\""; }else{ echo " "; diff --git a/Templates/Notice/22.tpl b/Templates/Notice/22.tpl index a4b8a249..7f10c15c 100644 --- a/Templates/Notice/22.tpl +++ b/Templates/Notice/22.tpl @@ -3,13 +3,13 @@ $dataarray = explode(",",$message->readingNotice['data']); $colspan = (isset($dataarray[14]) && $dataarray[14] > 0) ? 11 : 10; if($dataarray[15] == 1){ -$message1 = "".$database->getUserField($dataarray[0],"username",0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops"; +$message1 = "".$database->getUserField($dataarray[0], "username", 0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops"; }else if($dataarray[15] == 2){ -$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Merry Christmas"; +$message1 = "".$database->getUserField($dataarray[0], "username", 0)." wishes you Merry Christmas"; }else if($dataarray[15] == 3){ -$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Happy New Year"; +$message1 = "".$database->getUserField($dataarray[0], "username", 0)." wishes you Happy New Year"; }else{ -$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Happy Easter"; +$message1 = "".$database->getUserField($dataarray[0], "username", 0)." wishes you Happy Easter"; } ?> diff --git a/Templates/Notice/all.tpl b/Templates/Notice/all.tpl index f8479107..a8f9478e 100644 --- a/Templates/Notice/all.tpl +++ b/Templates/Notice/all.tpl @@ -69,10 +69,11 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att echo "
noticearray[$i-1]['id']."\" /> "; $type = (isset($_GET['t']) && $_GET['t'] == 5)? $message->noticearray[$i-1]['archive'] : $message->noticearray[$i-1]['ntype']; - if($type==15 or $type==16 or $type==17){ + if($type == 23) $type = 22; + if($type >= 15 && $type <= 17){ $type = $type-11; echo "\"".$noticeClass[$type]."\""; - }else if($type==18 or $type==19 or $type==20 or $type==21 or $type==22){ + }else if($type >= 18 && $type <= 22){ echo "\"".$noticeClass[$type]."\""; }else{ echo "\"".$noticeClass[$type]."\""; diff --git a/karte.php b/karte.php index 9d821942..e2ad874b 100644 --- a/karte.php +++ b/karte.php @@ -78,11 +78,10 @@ else{
getMapCheck($_GET['d']) == $_GET['c']) { - include("Templates/Map/vilview.tpl"); - } - else { +if(isset($_GET['d']) && !empty($_GET['d']) && isset($_GET['c']) && !empty($_GET['c'])) { + if($generator->getMapCheck($_GET['d']) == $_GET['c']) include("Templates/Map/vilview.tpl"); + else + { header("Location: dorf1.php"); exit; }