From 6d07e3a626dd430895c58a4cdf1cf28048086ace Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Sep 2012 22:44:28 +0300 Subject: [PATCH] more updates --- GameEngine/Alliance.php | 8 +++--- GameEngine/Automation.php | 48 ++++++++++++++++++++++++++------ GameEngine/Database/db_MYSQL.php | 9 +++++- GameEngine/Profile.php | 5 ---- GameEngine/Ranking.php | 2 ++ anmelden.php | 1 + 6 files changed, 54 insertions(+), 19 deletions(-) diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php index 5671020d..6888004b 100644 --- a/GameEngine/Alliance.php +++ b/GameEngine/Alliance.php @@ -362,7 +362,7 @@ $database->deleteAlliPermissions($post['a_user']); $database->deleteAlliance($session->alliance); // log the notice - $database->insertAlliNotice($session->alliance, '' . $post['a_user'] . ' has quit the alliance.'); + $database->insertAlliNotice($session->alliance, '' . $UserData['username'] . ' has quit the alliance.'); } }else{ header("Location: banned.php"); @@ -377,10 +377,10 @@ if(isset($post['f_link'])){ $database->setAlliForumLink($session->alliance, $post['f_link']); header("Location: allianz.php?s=5"); + } }else{ header("Location: banned.php"); } - } } /***************************************** Function to quit from alliance @@ -393,14 +393,14 @@ } elseif(md5($post['pw']) !== $session->userinfo['password']) { $form->addError("pw2", PW_ERR); } else { - if($database->isAllianceOwner($sessiom->uid)){ + $database->updateUserField($session->uid, 'alliance', 0, 1); + if($database->isAllianceOwner($session->uid)){ $newowner = $database->getAllMember2($session->alliance); $newleader = $newowner['id']; $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$session->alliance.""; $database->query($q); $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1); } - $database->updateUserField($session->uid, 'alliance', 0, 1); $database->deleteAlliPermissions($session->uid); // log the notice $database->deleteAlliance($session->alliance); diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 741a5940..96bb9ebf 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -208,6 +208,7 @@ class Automation { $this->updateStore(); $this->CheckBan(); $this->regenerateOasisTroops(); + $this->updateMax(); $this->artefactOfTheFool(); } @@ -394,6 +395,16 @@ class Automation { $database->addMovement(4,$enforce['vref'],$enforce['from'],$reference,$time,$time+$time2); } } + $database->updateUserField($session->uid, 'alliance', 0, 1); + if($database->isAllianceOwner($need['uid'])){ + $alliance = $database->getUserAllianceID($need['uid']); + $newowner = $database->getAllMember2($alliance); + $newleader = $newowner['id']; + $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".$newleader." where id = ".$alliance.""; + $database->query($q); + $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1); + } + $database->deleteAlliance($alliance); $q = "DELETE FROM ".TB_PREFIX."hero where uid = ".$need['uid']; $database->query($q); $q = "DELETE FROM ".TB_PREFIX."mdata where target = ".$need['uid']." or owner = ".$need['uid']; @@ -615,12 +626,6 @@ class Automation { $pop = $this->getPop($indi['type'],($level-1)); $database->modifyPop($indi['wid'],$pop[0],0); $database->addCP($indi['wid'],$pop[1]); - if($indi['type'] == 18) { - $owner = $database->getVillageField($indi['wid'],"owner"); - $max = $bid18[$level]['attri']; - $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $owner"; - $database->query($q); - } if($indi['type'] == 10) { $max=$database->getVillageField($indi['wid'],"maxstore"); @@ -3825,7 +3830,7 @@ $crannyimg = "=1){ if($hdata['health']<100 and $hdata['health']>0){ - $reg = $hdata['health']+$hdata['regeneration']*5*SPEED/86400*(time()-$hdata['lastupdate']); + $reg = $hdata['health']+$hdata['regeneration']*5*ceil(SPEED/10)/86400*(time()-$hdata['lastupdate']); if($reg <= 100){ $database->modifyHero("health",$reg,$hdata['heroid']); }else{ @@ -4239,7 +4244,7 @@ $crannyimg = "updateOasis($oasis['wref']); } } - + + private function updateMax() { + global $bid18, $database; + $q = "SELECT * FROM " . TB_PREFIX . "alidata where leader != 0"; + $array = $database->query_return($q); + foreach($array as $ally) { + $owner = $ally['leader']; + $villages = $database->getVillagesID2($owner); + $max = 0; + foreach($villages as $village){ + $field = $database->getResourceLevel($village['wref']); + for($i=19;$i<=40;$i++){ + if($field['f'.$i.'t'] == 18){ + $level = $field['f'.$i]; + $attri = $bid18[$level]['attri']; + } + } + } + if($attri > $max){ + $max = $attri; + } + $q = "UPDATE ".TB_PREFIX."alidata set max = $max where leader = $owner"; + $database->query($q); + } + } + private function artefactOfTheFool() { global $database; $time = time(); diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 52bca0a5..439dcdd5 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -221,7 +221,7 @@ class MYSQL_DB { } function setDeleting($uid, $mode) { - $time = time() + 72 * 3600; + $time = time() + 5 * 3600; if(!$mode) { $q = "INSERT into " . TB_PREFIX . "deleting values ($uid,$time)"; } else { @@ -693,6 +693,13 @@ class MYSQL_DB { } return $newarray; } + + function getVillagesID2($uid) { + $q = "SELECT wref from " . TB_PREFIX . "vdata where owner = $uid order by capital DESC,pop DESC"; + $result = mysql_query($q, $this->connection); + $array = $this->mysql_fetch_all($result); + return $array; + } function getVillage($vid) { $q = "SELECT * FROM " . TB_PREFIX . "vdata where wref = $vid"; diff --git a/GameEngine/Profile.php b/GameEngine/Profile.php index 25814b6d..492b2ffa 100644 --- a/GameEngine/Profile.php +++ b/GameEngine/Profile.php @@ -122,16 +122,11 @@ class Profile { $form->addError("email",EMAIL_ERROR); } if($post['del'] && md5($post['del_pw']) == $session->userinfo['password']) { - if($database->isAllianceOwner($post['uid'])) { - $form->addError("del",ALLI_OWNER); - } - else { if($session->access!=BANNED){ $database->setDeleting($post['uid'],0); }else{ header("Location: banned.php"); } - } } else { $form->addError("del",PASS_MISMATCH); diff --git a/GameEngine/Ranking.php b/GameEngine/Ranking.php index 30a15d68..1a9f0da3 100644 --- a/GameEngine/Ranking.php +++ b/GameEngine/Ranking.php @@ -58,9 +58,11 @@ break; case 31: $this->procAttRankArray(); + $this->getStart($this->searchRank($session->uid, "userid")); break; case 32: $this->procDefRankArray(); + $this->getStart($this->searchRank($session->uid, "userid")); break; case 2: $this->procVRankArray(); diff --git a/anmelden.php b/anmelden.php index 2c1e5f37..33ae6a6d 100644 --- a/anmelden.php +++ b/anmelden.php @@ -70,6 +70,7 @@ if(REG_OPEN == true){ ?> + Warning: password with & can cause problems! getError('pw'); ?>