refactor: 1st round of database values caching

This commit is contained in:
Martin Ambrus
2017-11-15 16:01:00 +01:00
parent 06161dd5f9
commit dab768f662
11 changed files with 1675 additions and 1023 deletions
+15 -9
View File
@@ -135,8 +135,13 @@ class Account {
if($uid) { if($uid) {
setcookie("COOKUSR",$_POST['name'],time()+COOKIE_EXPIRE,COOKIE_PATH); setcookie("COOKUSR",$_POST['name'],time()+COOKIE_EXPIRE,COOKIE_PATH);
setcookie("COOKEMAIL",$_POST['email'],time()+COOKIE_EXPIRE,COOKIE_PATH); setcookie("COOKEMAIL",$_POST['email'],time()+COOKIE_EXPIRE,COOKIE_PATH);
$database->updateUserField($uid,"act","",1); $database->updateUserField(
$database->updateUserField($uid,"invited",$_POST['invited'],1); $uid,
["act", "invited"],
["", $_POST['invited']],
1
);
$this->generateBase($_POST['kid'],$uid,$_POST['name']); $this->generateBase($_POST['kid'],$uid,$_POST['name']);
header("Location: login.php"); header("Location: login.php");
exit; exit;
@@ -177,7 +182,7 @@ class Account {
private function Unreg() { private function Unreg() {
global $database; global $database;
$q = "SELECT password, username FROM ".TB_PREFIX."activate where id = '".$database->escape((int) $_POST['id'])."'"; $q = "SELECT password, username FROM ".TB_PREFIX."activate where id = ".(int) $_POST['id'];
$result = mysqli_query($GLOBALS['link'],$q); $result = mysqli_query($GLOBALS['link'],$q);
$dbarray = mysqli_fetch_array($result); $dbarray = mysqli_fetch_array($result);
if(password_verify($_POST['pw'], $dbarray['password'])) { if(password_verify($_POST['pw'], $dbarray['password'])) {
@@ -207,12 +212,14 @@ class Account {
$form->addError("pw",LOGIN_PW_ERROR); $form->addError("pw",LOGIN_PW_ERROR);
} }
if($database->getUserField($_POST['user'],"act",1) != "") { $userData = $database->getUserArray($_POST['user'], 0);
if($userData["act"] != "") {
$form->addError("activate",$_POST['user']); $form->addError("activate",$_POST['user']);
} }
// Vacation mode by Shadow // Vacation mode by Shadow
if($database->getUserField($_POST['user'],"vac_mode",1) == 1 && $database->getUserField($_POST['user'],"vac_time",1) > time()) { if($userData["vac_mode"] == 1 && $userData["vac_time"] > time()) {
$form->addError("vacation","Vacation mode is still enabled"); $form->addError("vacation","Vacation mode is still enabled");
} }
@@ -224,14 +231,13 @@ class Account {
header("Location: login.php"); header("Location: login.php");
exit; exit;
} else { } else {
$userid = $database->getUserArray($_POST['user'], 0);
// Vacation mode by Shadow // Vacation mode by Shadow
$database->removevacationmode($userid['id']); $database->removevacationmode($userData['id']);
// Vacation mode by Shadow // Vacation mode by Shadow
if($database->login($_POST['user'],$_POST['pw'])){ if($database->login($_POST['user'],$_POST['pw'])){
$database->UpdateOnline("login" ,$_POST['user'],time(),$userid['id']); $database->UpdateOnline("login" ,$_POST['user'],time(),$userData['id']);
}else if($database->sitterLogin($_POST['user'],$_POST['pw'])){ }else if($database->sitterLogin($_POST['user'],$_POST['pw'])){
$database->UpdateOnline("sitter" ,$_POST['user'],time(),$userid['id']); $database->UpdateOnline("sitter" ,$_POST['user'],time(),$userData['id']);
} }
setcookie("COOKUSR",$_POST['user'],time()+COOKIE_EXPIRE,COOKIE_PATH); setcookie("COOKUSR",$_POST['user'],time()+COOKIE_EXPIRE,COOKIE_PATH);
$session->login($_POST['user']); $session->login($_POST['user']);
+20 -19
View File
@@ -380,26 +380,27 @@ class Alliance {
*****************************************/ *****************************************/
private function kickAlliUser($post) { private function kickAlliUser($post) {
global $database, $session, $form; global $database, $session, $form;
if($session->access != BANNED){
$UserData = $database->getUserArray($post['a_user'], 1); if ($session->access != BANNED) {
if($this->userPermArray['opt2'] == 0) { $UserData = $database->getUserArray($post['a_user'], 1);
$form->addError("perm", NO_PERMISSION); if($this->userPermArray['opt2'] == 0) {
} else if($UserData['id'] != $session->uid){ $form->addError("perm", NO_PERMISSION);
$database->updateUserField($post['a_user'], 'alliance', 0, 1); } else if($UserData['id'] != $session->uid){
$database->deleteAlliPermissions($post['a_user']); $database->updateUserField($post['a_user'], 'alliance', 0, 1);
$database->deleteAlliance($session->alliance); $database->deleteAlliPermissions($post['a_user']);
// log the notice $database->deleteAlliance($session->alliance);
$database->insertAlliNotice($session->alliance, '<a href="spieler.php?uid=' . $UserData['id'] . '">' . addslashes($post['a_user']) . '</a> has quit the alliance.'); // log the notice
if($session->alliance && $database->isAllianceOwner($UserData['id']) == $session->alliance){ $database->insertAlliNotice($session->alliance, '<a href="spieler.php?uid=' . $UserData['id'] . '">' . addslashes($post['a_user']) . '</a> has quit the alliance.');
$newowner = $database->getAllMember2($session->alliance); if($session->alliance && $database->isAllianceOwner($UserData['id']) == $session->alliance){
$newleader = $newowner['id']; $newowner = $database->getAllMember2($session->alliance);
$q = "UPDATE " . TB_PREFIX . "alidata set leader = ".(int) $newleader." where id = ".(int) $session->alliance.""; $newleader = $newowner['id'];
$database->query($q); $q = "UPDATE " . TB_PREFIX . "alidata set leader = ".(int) $newleader." where id = ".(int) $session->alliance."";
$database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1); $database->query($q);
Automation::updateMax($newleader); $database->updateAlliPermissions($newleader, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Automation::updateMax($newleader);
}
} }
} } else {
}else{
header("Location: banned.php"); header("Location: banned.php");
exit; exit;
} }
+74 -33
View File
@@ -244,7 +244,6 @@ class Automation {
//create new file to check filetime //create new file to check filetime
//not every click regenerate but 1 minute or after //not every click regenerate but 1 minute or after
$ourFileHandle = fopen($autoprefix."GameEngine/Prevention/loyalty.txt", 'w'); $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/loyalty.txt", 'w');
fclose($ourFileHandle); fclose($ourFileHandle);
global $database; global $database;
@@ -1283,7 +1282,7 @@ class Automation {
$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->updateUserFields($DefenderID, ["gold", "maxevasion"], [$newgold, $newmaxevasion], 1); $database->updateUserField($DefenderID, ["gold", "maxevasion"], [$newgold, $newmaxevasion], 1);
} }
} }
//get defence units //get defence units
@@ -2363,9 +2362,11 @@ class Automation {
} }
} }
$exp1 = $database->getVillageField($from['wref'],'exp1'); $expArray = $database->getVillageFields($from['wref'], 'exp1, exp2, exp3');
$exp2 = $database->getVillageField($from['wref'],'exp2'); $exp1 = $expArray['exp1'];
$exp3 = $database->getVillageField($from['wref'],'exp3'); $exp2 = $expArray['exp2'];
$exp3 = $expArray['exp3'];
if($exp1 == 0){ if($exp1 == 0){
$villexp = 0; $villexp = 0;
} }
@@ -2381,18 +2382,24 @@ class Automation {
$mode = CP; $mode = CP;
$cp_mode = $GLOBALS['cp'.$mode]; $cp_mode = $GLOBALS['cp'.$mode];
$need_cps = $cp_mode[count($varray1)+1]; $need_cps = $cp_mode[count($varray1)+1];
$user_cps = $database->getUserField($from['owner'],"cp",0);
//see if last village, or village head if (!isset($cachedUserData[$from['owner']])) {
$cachedUserData[$from['owner']] = $database->getUserArray($from['owner'], 1);
}
$user_cps = $cachedUserData[$from['owner']]['cp'];
//check for last village or capital
if($user_cps >= $need_cps){ if($user_cps >= $need_cps){
if(count($varray)!='1' AND $to['capital']!='1' AND $villexp < $canconquer){ if(count($varray)!='1' AND $to['capital']!='1' AND $villexp < $canconquer){
if($to['owner']!=3 OR $to['name']!='WW Buildingplan'){ if($to['owner']!=3 OR $to['name']!='WW Buildingplan'){
//if there is no Palace/Residence // check for standing Palace or Residence
for ($i=18; $i<39; $i++){ if ($database->getFieldLevelInVillage($data['to'], '25, 26')) {
if ($database->getFieldLevel($data['to'],"".$i."t")==25 or $database->getFieldLevel($data['to'],"".$i."t")==26){ $nochiefing = 1;
$nochiefing='1'; $info_chief = "".$chief_pic.",The Palace/Residence isn\'t destroyed!";
$info_chief = "".$chief_pic.",The Palace/Residence isn\'t destroyed!";
}
} }
// we can conquer this village
if(!isset($nochiefing)){ if(!isset($nochiefing)){
//$info_chief = "".$chief_pic.",You don't have enought CP to chief a village."; //$info_chief = "".$chief_pic.",You don't have enought CP to chief a village.";
if($this->getTypeLevel(35,$data['from']) == 0){ if($this->getTypeLevel(35,$data['from']) == 0){
@@ -2408,31 +2415,46 @@ class Automation {
$rand+=rand(5,15); $rand+=rand(5,15);
} }
} }
//loyalty is more than 0
if(($toF['loyalty']-$rand)>0){ // loyalty is more than 0
if (($toF['loyalty']-$rand) > 0) {
$info_chief = "".$chief_pic.",The loyalty was lowered from <b>".floor($toF['loyalty'])."</b> to <b>".floor($toF['loyalty']-$rand)."</b>."; $info_chief = "".$chief_pic.",The loyalty was lowered from <b>".floor($toF['loyalty'])."</b> to <b>".floor($toF['loyalty']-$rand)."</b>.";
$database->setVillageField($data['to'],'loyalty',($toF['loyalty']-$rand)); $database->setVillageField($data['to'],'loyalty',($toF['loyalty']-$rand));
} else if (!$village_destroyed) { } else if (!$village_destroyed) {
//you took over the village // you took over the village
$villname = addslashes($database->getVillageField($data['to'],"name")); $villname = addslashes($database->getVillageField($data['to'],"name"));
$artifact = $database->getOwnArtefactInfo($data['to']); $artifact = $database->getOwnArtefactInfo($data['to']);
$info_chief = "".$chief_pic.",Inhabitants of ".$villname." village decided to join your empire."; $info_chief = "".$chief_pic.",Inhabitants of ".$villname." village decided to join your empire.";
if ($artifact['vref'] == $data['to']){ if ($artifact['vref'] == $data['to']){
$database->claimArtefact($data['to'],$data['to'],$database->getVillageField($data['from'],"owner")); if (!isset($villageOwners[$data['from']])) {
$villageOwners[$data['from']] = $database->getVillageField($data['from'],"owner");
}
$database->claimArtefact($data['to'], $data['to'], $villageOwners[$data['from']]);
} }
$database->setVillageField($data['to'],'loyalty',0);
$database->setVillageField($data['to'],'owner',$database->getVillageField($data['from'],"owner"));
$database->setVillageFields(
$data['to'],
['loyalty', 'owner'],
[0, $villageOwners[$data['from']]]
);
//delete upgrades in armory and blacksmith //delete upgrades in armory and blacksmith
$q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref = ".(int) $data['to'].""; $q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref = ".(int) $data['to'];
$database->query($q); $database->query($q);
$database->addABTech($data['to']); $database->addABTech($data['to']);
//delete researches in academy //delete researches in academy
$q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref = ".(int) $data['to'].""; $q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref = ".(int) $data['to'];
$database->query($q); $database->query($q);
$database->addTech($data['to']); $database->addTech($data['to']);
//delete reinforcement //delete reinforcement
$q = "DELETE FROM ".TB_PREFIX."enforcement WHERE `from` = ".(int) $data['to'].""; $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE `from` = ".(int) $data['to'];
$database->query($q); $database->query($q);
//no units can stay in the village itself //no units can stay in the village itself
$units2reset = []; $units2reset = [];
for ($u = 1; $u <= 50; $u++) { for ($u = 1; $u <= 50; $u++) {
@@ -2443,36 +2465,50 @@ class Automation {
$units2reset[] = 'hero = 0'; $units2reset[] = 'hero = 0';
$q = "UPDATE ".TB_PREFIX."units SET ".implode(',', $units2reset)." WHERE vref = ".(int) $data['to']; $q = "UPDATE ".TB_PREFIX."units SET ".implode(',', $units2reset)." WHERE vref = ".(int) $data['to'];
$database->query($q); $database->query($q);
// check buildings // check buildings
$newLevels_fieldNames = [];
$newLevels_fieldValues = [];
$pop1 = $database->getVillageField($data['from'],"pop"); $pop1 = $database->getVillageField($data['from'],"pop");
$pop2 = $database->getVillageField($data['to'],"pop"); $pop2 = $database->getVillageField($data['to'],"pop");
if($pop1 > $pop2){ if($pop1 > $pop2){
$buildlevel = $database->getResourceLevel($data['to']); $buildlevel = $database->getResourceLevel($data['to']);
for ($i=1; $i<=39; $i++){ for ($i=1; $i<=39; $i++){
if($buildlevel['f'.$i]!=0){ if($buildlevel['f'.$i]!=0){
if($buildlevel['f'.$i."t"]!=35 && $buildlevel['f'.$i."t"]!=36 && $buildlevel['f'.$i."t"]!=41){ if($buildlevel['f'.$i."t"]!=35 && $buildlevel['f'.$i."t"]!=36 && $buildlevel['f'.$i."t"]!=41){
$leveldown = $buildlevel['f'.$i]-1; $leveldown = $buildlevel['f'.$i]-1;
$database->setVillageLevel($data['to'],"f".$i,$leveldown); $newLevels_fieldNames[] = "f".$i;
$newLevels_fieldValues[] = $leveldown;
}else{ }else{
$database->setVillageLevel($data['to'],"f".$i,0); $newLevels_fieldNames[] = "f".$i;
$database->setVillageLevel($data['to'],"f".$i."t",0); $newLevels_fieldValues[] = 0;
$newLevels_fieldNames[] = "f".$i."t";
$newLevels_fieldValues[] = 0;
} }
} }
} }
if($buildlevel['f99']!=0){
if ($buildlevel['f99']!=0) {
$leveldown = $buildlevel['f99']-1; $leveldown = $buildlevel['f99']-1;
$database->setVillageLevel($data['to'],"f99",$leveldown); $newLevels_fieldNames[] = "f99";
$newLevels_fieldValues[] = $leveldown;
} }
} }
//destroy wall //destroy wall
$database->setVillageLevel($data['to'],"f40",0); $newLevels_fieldNames[] = "f40";
$database->setVillageLevel($data['to'],"f40t",0); $newLevels_fieldValues[] = 0;
$database->clearExpansionSlot($data['to']);
$newLevels_fieldNames[] = "f40t";
$newLevels_fieldValues[] = 0;
$exp1 = $database->getVillageField($data['from'],'exp1'); $expArray = $database->getVillageFields($data['from'], 'exp1, exp2, exp3');
$exp2 = $database->getVillageField($data['from'],'exp2'); $exp1 = $expArray['exp1'];
$exp3 = $database->getVillageField($data['from'],'exp3'); $exp2 = $expArray['exp2'];
$exp3 = $expArray['exp3'];
if($exp1 == 0){ if($exp1 == 0){
$exp = 'exp1'; $exp = 'exp1';
@@ -2486,11 +2522,16 @@ class Automation {
$exp = 'exp3'; $exp = 'exp3';
$value = $data['to']; $value = $data['to'];
} }
$database->setVillageField($data['from'],$exp,$value); $database->setVillageField($data['from'],$exp,$value);
//remove oasis related to village //remove oasis related to village
$units->returnTroops($data['to'],1); $units->returnTroops($data['to'],1);
$chiefing_village = 1; $chiefing_village = 1;
// update data in the database
$database->clearExpansionSlot($data['to']);
$database->setVillageLevel($data['to'], $newLevels_fieldNames, $newLevels_fieldValues);
} }
} }
} else { } else {
+587 -584
View File
File diff suppressed because it is too large Load Diff
+729 -180
View File
File diff suppressed because it is too large Load Diff
View File
+32 -16
View File
@@ -94,7 +94,10 @@ class Market
$wtrans = str_replace("-", "", $wtrans); $wtrans = str_replace("-", "", $wtrans);
$ctrans = str_replace("-", "", $ctrans); $ctrans = str_replace("-", "", $ctrans);
$itrans = str_replace("-", "", $itrans); $itrans = str_replace("-", "", $itrans);
$crtrans = str_replace("-", "", $crtrans); $crtrans = str_replace("-", "", $crtrans);
// preload all village data, since we're retrieving some of those separately below
$database->getVillage($village->wid);
$availableWood = $database->getWoodAvailable($village->wid); $availableWood = $database->getWoodAvailable($village->wid);
$availableClay = $database->getClayAvailable($village->wid); $availableClay = $database->getClayAvailable($village->wid);
$availableIron = $database->getIronAvailable($village->wid); $availableIron = $database->getIronAvailable($village->wid);
@@ -130,8 +133,9 @@ class Market
exit; exit;
} }
else else
{ {
// something // TODO: WTF??? :D
// something
} }
} }
@@ -163,7 +167,11 @@ class Market
$wood = ($post['rid1'] == 1)? $post['m1'] : 0; $wood = ($post['rid1'] == 1)? $post['m1'] : 0;
$clay = ($post['rid1'] == 2)? $post['m1'] : 0; $clay = ($post['rid1'] == 2)? $post['m1'] : 0;
$iron = ($post['rid1'] == 3)? $post['m1'] : 0; $iron = ($post['rid1'] == 3)? $post['m1'] : 0;
$crop = ($post['rid1'] == 4)? $post['m1'] : 0; $crop = ($post['rid1'] == 4)? $post['m1'] : 0;
// preload all village data, since we're retrieving some of those separately below
$database->getVillage($village->wid);
$availableWood = $database->getWoodAvailable($village->wid); $availableWood = $database->getWoodAvailable($village->wid);
$availableClay = $database->getClayAvailable($village->wid); $availableClay = $database->getClayAvailable($village->wid);
$availableIron = $database->getIronAvailable($village->wid); $availableIron = $database->getIronAvailable($village->wid);
@@ -235,16 +243,23 @@ class Market
} }
} }
$myresource = $hisresource = array(1=>0,0,0,0); $myresource = $hisresource = array(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'];
$hissendid = $database->sendResource($hisresource[1],$hisresource[2],$hisresource[3],$hisresource[4],$infoarray['merchant'],0); $hissendid = $database->sendResource($hisresource[1],$hisresource[2],$hisresource[3],$hisresource[4],$infoarray['merchant'],0);
$hiscoor = $database->getCoor($infoarray['vref']); $hiscoor = $database->getCoor($infoarray['vref']);
$mytime = $generator->procDistanceTime($hiscoor,$village->coor,$session->tribe,0); $mytime = $generator->procDistanceTime($hiscoor,$village->coor,$session->tribe,0);
$targettribe = $database->getUserField($database->getVillageField($infoarray['vref'],"owner"),"tribe",0); $targettribe = $database->getUserField($database->getVillageField($infoarray['vref'],"owner"),"tribe",0);
$histime = $generator->procDistanceTime($village->coor,$hiscoor,$targettribe,0); $histime = $generator->procDistanceTime($village->coor,$hiscoor,$targettribe,0);
$database->addMovement(0,$village->wid,$infoarray['vref'],$mysendid,time(),$mytime+time()); $timestamp = time();
$database->addMovement(0,$infoarray['vref'],$village->wid,$hissendid,time(),$histime+time()); $database->addMovement(
[0, 0],
[$village->wid, $infoarray['vref']],
[$infoarray['vref'], $village->wid],
[$mysendid, $hissendid],
[$timestamp, $timestamp],
[$mytime + $timestamp, $histime + $timestamp]
);
$resource = array(1=>0,0,0,0); $resource = array(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);
@@ -346,11 +361,12 @@ class Market
} }
else if (($post['m2'][0]+$post['m2'][1]+$post['m2'][2]+$post['m2'][3])<=(round($village->awood)+round($village->aclay)+round($village->airon)+round($village->acrop))) else if (($post['m2'][0]+$post['m2'][1]+$post['m2'][2]+$post['m2'][3])<=(round($village->awood)+round($village->aclay)+round($village->airon)+round($village->acrop)))
{ {
$database->setVillageField($village->wid,"wood",$post['m2'][0]); $database->setVillageField(
$database->setVillageField($village->wid,"clay",$post['m2'][1]); $village->wid,
$database->setVillageField($village->wid,"iron",$post['m2'][2]); ["wood", "clay", "iron", "crop"],
$database->setVillageField($village->wid,"crop",$post['m2'][3]); [$post['m2'][0], $post['m2'][1], $post['m2'][2], $post['m2'][3]]
$database->modifyGold($session->uid,3,0); );
$database->modifyGold($session->uid,3,0);
header("Location: build.php?id=".$post['id']."&t=3&c");; header("Location: build.php?id=".$post['id']."&t=3&c");;
exit; exit;
} }
+191 -171
View File
@@ -40,9 +40,9 @@ class Message {
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{ }else{
$this->sendMessage($post['an'],$post['be'],addslashes($post['message'])); $this->sendMessage($post['an'],$post['be'],addslashes($post['message']));
} }
header("Location: nachrichten.php?t=2"); header("Location: nachrichten.php?t=2");
exit; exit;
@@ -51,8 +51,8 @@ class Message {
case "m4": case "m4":
case "m5": case "m5":
if(isset($post['delmsg_x'])) { if(isset($post['delmsg_x'])) {
$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);
@@ -346,75 +346,83 @@ class Message {
$allmembersQ = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'"); $allmembersQ = mysqli_query($GLOBALS['link'],"SELECT id FROM ".TB_PREFIX."users WHERE alliance='".$session->alliance."'");
$userally = $database->getUserField($session->uid,"alliance",0); $userally = $database->getUserField($session->uid,"alliance",0);
$permission=mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'")); $permission=mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT opt7 FROM ".TB_PREFIX."ali_permission WHERE uid='".$session->uid."'"));
if(WORD_CENSOR) { if(WORD_CENSOR) {
$topic = $this->wordCensor($topic); $topic = $this->wordCensor($topic);
$text = $this->wordCensor($text); $text = $this->wordCensor($text);
} }
if($topic == "") { if($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]";
$alliance = $player = $coor = $report = 0; $alliance = $player = $coor = $report = 0;
for($i=0;$i<=$alliance;$i++){
if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){ for ( $i = 0; $i <= $alliance; $i ++ ) {
$alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text); if ( preg_match( '/\[alliance' . $i . '\]/', $text ) && preg_match( '/\[\/alliance' . $i . '\]/', $text ) ) {
if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){ $alliance1 = preg_replace( '/\[message\](.*?)\[\/alliance' . $i . '\]/is', '', $text );
$j = $i+1; if ( preg_match( '/\[alliance' . $i . '\]/', $alliance1 ) && preg_match( '/\[\/alliance' . $i . '\]/', $alliance1 ) ) {
$alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text); $j = $i + 1;
$alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1); $alliance2 = preg_replace( '/\[\/alliance' . $i . '\](.*?)\[\/message\]/is', '', $text );
$alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1); $alliance1 = preg_replace( '/\[alliance' . $i . '\]/', '[alliance' . $j . ']', $alliance1 );
$text = $alliance2."[/alliance".$i."]".$alliance1; $alliance1 = preg_replace( '/\[\/alliance' . $i . '\]/', '[/alliance' . $j . ']', $alliance1 );
$alliance += 1; $text = $alliance2 . "[/alliance" . $i . "]" . $alliance1;
} $alliance += 1;
} }
} }
for($i=0;$i<=$player;$i++){ }
if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){
$player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text); for ( $i = 0; $i <= $player; $i ++ ) {
if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){ if ( preg_match( '/\[player' . $i . '\]/', $text ) && preg_match( '/\[\/player' . $i . '\]/', $text ) ) {
$j = $i+1; $player1 = preg_replace( '/\[message\](.*?)\[\/player' . $i . '\]/is', '', $text );
$player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text); if ( preg_match( '/\[player' . $i . '\]/', $player1 ) && preg_match( '/\[\/player' . $i . '\]/', $player1 ) ) {
$player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1); $j = $i + 1;
$player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1); $player2 = preg_replace( '/\[\/player' . $i . '\](.*?)\[\/message\]/is', '', $text );
$text = $player2."[/player".$i."]".$player1; $player1 = preg_replace( '/\[player' . $i . '\]/', '[player' . $j . ']', $player1 );
$player += 1; $player1 = preg_replace( '/\[\/player' . $i . '\]/', '[/player' . $j . ']', $player1 );
} $text = $player2 . "[/player" . $i . "]" . $player1;
} $player += 1;
} }
for($i=0;$i<=$coor;$i++){ }
if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){ }
$coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text);
if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){ for ( $i = 0; $i <= $coor; $i ++ ) {
$j = $i+1; if ( preg_match( '/\[coor' . $i . '\]/', $text ) && preg_match( '/\[\/coor' . $i . '\]/', $text ) ) {
$coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text); $coor1 = preg_replace( '/\[message\](.*?)\[\/coor' . $i . '\]/is', '', $text );
$coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1); if ( preg_match( '/\[coor' . $i . '\]/', $coor1 ) && preg_match( '/\[\/coor' . $i . '\]/', $coor1 ) ) {
$coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1); $j = $i + 1;
$text = $coor2."[/coor".$i."]".$coor1; $coor2 = preg_replace( '/\[\/coor' . $i . '\](.*?)\[\/message\]/is', '', $text );
$coor += 1; $coor1 = preg_replace( '/\[coor' . $i . '\]/', '[coor' . $j . ']', $coor1 );
} $coor1 = preg_replace( '/\[\/coor' . $i . '\]/', '[/coor' . $j . ']', $coor1 );
} $text = $coor2 . "[/coor" . $i . "]" . $coor1;
} $coor += 1;
for($i=0;$i<=$report;$i++){ }
if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){ }
$report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text); }
if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){
$j = $i+1; for ( $i = 0; $i <= $report; $i ++ ) {
$report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text); if ( preg_match( '/\[report' . $i . '\]/', $text ) && preg_match( '/\[\/report' . $i . '\]/', $text ) ) {
$report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1); $report1 = preg_replace( '/\[message\](.*?)\[\/report' . $i . '\]/is', '', $text );
$report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1); if ( preg_match( '/\[report' . $i . '\]/', $report1 ) && preg_match( '/\[\/report' . $i . '\]/', $report1 ) ) {
$text = $report2."[/report".$i."]".$report1; $j = $i + 1;
$report += 1; $report2 = preg_replace( '/\[\/report' . $i . '\](.*?)\[\/message\]/is', '', $text );
} $report1 = preg_replace( '/\[report' . $i . '\]/', '[report' . $j . ']', $report1 );
} $report1 = preg_replace( '/\[\/report' . $i . '\]/', '[/report' . $j . ']', $report1 );
} $text = $report2 . "[/report" . $i . "]" . $report1;
if($permission[opt7]==1){ $report += 1;
if ($userally != 0) { }
while ($allmembers = mysqli_fetch_array($allmembersQ)) { }
$database->sendMessage($allmembers[id],$session->uid,htmlspecialchars(addslashes($topic)),htmlspecialchars(addslashes($text)),0,$alliance,$player,$coor,$report); }
}
} if($permission['opt7']==1){
} if ($userally != 0) {
while ($allmembers = mysqli_fetch_array($allmembersQ)) {
$database->sendMessage($allmembers[id],$session->uid,htmlspecialchars(addslashes($topic)),htmlspecialchars(addslashes($text)),0,$alliance,$player,$coor,$report);
}
}
}
} }
} }
@@ -438,69 +446,75 @@ class Message {
$topic = $this->wordCensor($topic); $topic = $this->wordCensor($topic);
$text = $this->wordCensor($text); $text = $this->wordCensor($text);
} }
if($topic == "") { if($topic == "") {
$topic = "No subject"; $topic = "No subject";
} }
if(!preg_match('/\[message\]/',$text) && !preg_match('/\[\/message\]/',$text)){
$text = "[message]".$text."[/message]"; if ( ! preg_match( '/\[message\]/', $text ) && ! preg_match( '/\[\/message\]/', $text ) ) {
$alliance = $player = $coor = $report = 0; $text = "[message]" . $text . "[/message]";
for($i=0;$i<=$alliance;$i++){ $alliance = $player = $coor = $report = 0;
if(preg_match('/\[alliance'.$i.'\]/',$text) && preg_match('/\[\/alliance'.$i.'\]/',$text)){
$alliance1 = preg_replace('/\[message\](.*?)\[\/alliance'.$i.'\]/is', '', $text); for ( $i = 0; $i <= $alliance; $i ++ ) {
if(preg_match('/\[alliance'.$i.'\]/',$alliance1) && preg_match('/\[\/alliance'.$i.'\]/',$alliance1)){ if ( preg_match( '/\[alliance' . $i . '\]/', $text ) && preg_match( '/\[\/alliance' . $i . '\]/', $text ) ) {
$j = $i+1; $alliance1 = preg_replace( '/\[message\](.*?)\[\/alliance' . $i . '\]/is', '', $text );
$alliance2 = preg_replace('/\[\/alliance'.$i.'\](.*?)\[\/message\]/is', '', $text); if ( preg_match( '/\[alliance' . $i . '\]/', $alliance1 ) && preg_match( '/\[\/alliance' . $i . '\]/', $alliance1 ) ) {
$alliance1 = preg_replace('/\[alliance'.$i.'\]/', '[alliance'.$j.']', $alliance1); $j = $i + 1;
$alliance1 = preg_replace('/\[\/alliance'.$i.'\]/', '[/alliance'.$j.']', $alliance1); $alliance2 = preg_replace( '/\[\/alliance' . $i . '\](.*?)\[\/message\]/is', '', $text );
$text = $alliance2."[/alliance".$i."]".$alliance1; $alliance1 = preg_replace( '/\[alliance' . $i . '\]/', '[alliance' . $j . ']', $alliance1 );
$alliance += 1; $alliance1 = preg_replace( '/\[\/alliance' . $i . '\]/', '[/alliance' . $j . ']', $alliance1 );
} $text = $alliance2 . "[/alliance" . $i . "]" . $alliance1;
} $alliance += 1;
} }
for($i=0;$i<=$player;$i++){ }
if(preg_match('/\[player'.$i.'\]/',$text) && preg_match('/\[\/player'.$i.'\]/',$text)){ }
$player1 = preg_replace('/\[message\](.*?)\[\/player'.$i.'\]/is', '', $text);
if(preg_match('/\[player'.$i.'\]/',$player1) && preg_match('/\[\/player'.$i.'\]/',$player1)){ for ( $i = 0; $i <= $player; $i ++ ) {
$j = $i+1; if ( preg_match( '/\[player' . $i . '\]/', $text ) && preg_match( '/\[\/player' . $i . '\]/', $text ) ) {
$player2 = preg_replace('/\[\/player'.$i.'\](.*?)\[\/message\]/is', '', $text); $player1 = preg_replace( '/\[message\](.*?)\[\/player' . $i . '\]/is', '', $text );
$player1 = preg_replace('/\[player'.$i.'\]/', '[player'.$j.']', $player1); if ( preg_match( '/\[player' . $i . '\]/', $player1 ) && preg_match( '/\[\/player' . $i . '\]/', $player1 ) ) {
$player1 = preg_replace('/\[\/player'.$i.'\]/', '[/player'.$j.']', $player1); $j = $i + 1;
$text = $player2."[/player".$i."]".$player1; $player2 = preg_replace( '/\[\/player' . $i . '\](.*?)\[\/message\]/is', '', $text );
$player += 1; $player1 = preg_replace( '/\[player' . $i . '\]/', '[player' . $j . ']', $player1 );
} $player1 = preg_replace( '/\[\/player' . $i . '\]/', '[/player' . $j . ']', $player1 );
} $text = $player2 . "[/player" . $i . "]" . $player1;
} $player += 1;
for($i=0;$i<=$coor;$i++){ }
if(preg_match('/\[coor'.$i.'\]/',$text) && preg_match('/\[\/coor'.$i.'\]/',$text)){ }
$coor1 = preg_replace('/\[message\](.*?)\[\/coor'.$i.'\]/is', '', $text); }
if(preg_match('/\[coor'.$i.'\]/',$coor1) && preg_match('/\[\/coor'.$i.'\]/',$coor1)){
$j = $i+1; for ( $i = 0; $i <= $coor; $i ++ ) {
$coor2 = preg_replace('/\[\/coor'.$i.'\](.*?)\[\/message\]/is', '', $text); if ( preg_match( '/\[coor' . $i . '\]/', $text ) && preg_match( '/\[\/coor' . $i . '\]/', $text ) ) {
$coor1 = preg_replace('/\[coor'.$i.'\]/', '[coor'.$j.']', $coor1); $coor1 = preg_replace( '/\[message\](.*?)\[\/coor' . $i . '\]/is', '', $text );
$coor1 = preg_replace('/\[\/coor'.$i.'\]/', '[/coor'.$j.']', $coor1); if ( preg_match( '/\[coor' . $i . '\]/', $coor1 ) && preg_match( '/\[\/coor' . $i . '\]/', $coor1 ) ) {
$text = $coor2."[/coor".$i."]".$coor1; $j = $i + 1;
$coor += 1; $coor2 = preg_replace( '/\[\/coor' . $i . '\](.*?)\[\/message\]/is', '', $text );
} $coor1 = preg_replace( '/\[coor' . $i . '\]/', '[coor' . $j . ']', $coor1 );
} $coor1 = preg_replace( '/\[\/coor' . $i . '\]/', '[/coor' . $j . ']', $coor1 );
} $text = $coor2 . "[/coor" . $i . "]" . $coor1;
for($i=0;$i<=$report;$i++){ $coor += 1;
if(preg_match('/\[report'.$i.'\]/',$text) && preg_match('/\[\/report'.$i.'\]/',$text)){ }
$report1 = preg_replace('/\[message\](.*?)\[\/report'.$i.'\]/is', '', $text); }
if(preg_match('/\[report'.$i.'\]/',$report1) && preg_match('/\[\/report'.$i.'\]/',$report1)){ }
$j = $i+1;
$report2 = preg_replace('/\[\/report'.$i.'\](.*?)\[\/message\]/is', '', $text); for ( $i = 0; $i <= $report; $i ++ ) {
$report1 = preg_replace('/\[report'.$i.'\]/', '[report'.$j.']', $report1); if ( preg_match( '/\[report' . $i . '\]/', $text ) && preg_match( '/\[\/report' . $i . '\]/', $text ) ) {
$report1 = preg_replace('/\[\/report'.$i.'\]/', '[/report'.$j.']', $report1); $report1 = preg_replace( '/\[message\](.*?)\[\/report' . $i . '\]/is', '', $text );
$text = $report2."[/report".$i."]".$report1; if ( preg_match( '/\[report' . $i . '\]/', $report1 ) && preg_match( '/\[\/report' . $i . '\]/', $report1 ) ) {
$report += 1; $j = $i + 1;
} $report2 = preg_replace( '/\[\/report' . $i . '\](.*?)\[\/message\]/is', '', $text );
} $report1 = preg_replace( '/\[report' . $i . '\]/', '[report' . $j . ']', $report1 );
} $report1 = preg_replace( '/\[\/report' . $i . '\]/', '[/report' . $j . ']', $report1 );
$text = $report2 . "[/report" . $i . "]" . $report1;
// check if we're not sending this as support $report += 1;
$support_from_admin_allowed = (($session->access == MULTIHUNTER || $session->access == ADMIN) && ADMIN_RECEIVE_SUPPORT_MESSAGES); }
$database->sendMessage($user, ((!empty($_POST['as_support']) && $support_from_admin_allowed) ? 1 : $session->uid), htmlspecialchars(addslashes($topic)), htmlspecialchars(addslashes($text)), 0, $alliance, $player, $coor, $report); }
} }
// check if we're not sending this as support
$support_from_admin_allowed = ( ( $session->access == MULTIHUNTER || $session->access == ADMIN ) && ADMIN_RECEIVE_SUPPORT_MESSAGES );
$database->sendMessage( $user, ( ( ! empty( $_POST['as_support'] ) && $support_from_admin_allowed ) ? 1 : $session->uid ), htmlspecialchars( addslashes( $topic ) ), htmlspecialchars( addslashes( $text ) ), 0, $alliance, $player, $coor, $report );
}
} }
//7 = village, attacker, att tribe, u1 - u10, lost %, w,c,i,c , cap //7 = village, attacker, att tribe, u1 - u10, lost %, w,c,i,c , cap
@@ -511,15 +525,15 @@ class Message {
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 = preg_replace("'%USER%'", $username, $welcomemsg);
$welcomemsg = preg_replace("'%START%'", date("y.m.d", COMMENCE), $welcomemsg); $welcomemsg = "[message]".preg_replace(
$welcomemsg = preg_replace("'%TIME%'", date("H:i", COMMENCE), $welcomemsg); ["'%USER%'", "'%START%'", "'%TIME%'", "'%PLAYERS%'", "'%ALLI%'", "'%SERVER_NAME%'", "'%PROTECTION%'"],
$welcomemsg = preg_replace("'%PLAYERS%'", $database->countUser(), $welcomemsg); [$username, date("y.m.d", COMMENCE), date("H:i", COMMENCE), $database->countUser(), $database->countAlli(), SERVER_NAME, round((PROTECTION/3600))],
$welcomemsg = preg_replace("'%ALLI%'", $database->countAlli(), $welcomemsg); $welcomemsg
$welcomemsg = preg_replace("'%SERVER_NAME%'", SERVER_NAME, $welcomemsg); )."[/message]";
$welcomemsg = preg_replace("'%PROTECTION%'", (PROTECTION/3600), $welcomemsg);
$welcomemsg = "[message]".$welcomemsg."[/message]";
return $database->sendMessage($uid, 1, WEL_TOPIC, addslashes($welcomemsg), 0, 0, 0, 0, 0); return $database->sendMessage($uid, 1, WEL_TOPIC, addslashes($welcomemsg), 0, 0, 0, 0, 0);
} }
@@ -578,41 +592,47 @@ class Message {
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++) {
if($added == 0){ for ( $j = 0; $j <= $i; $j ++ ) {
$user = $database->getUserField($post['myid'], "friend".$j, 0); if ( $added == 0 ) {
$userwait = $database->getUserField($post['myid'], "friend".$j."wait", 0); $user = $database->getUserField( $post['myid'], "friend" . $j, 0 );
$exist = 0; $userwait = $database->getUserField( $post['myid'], "friend" . $j . "wait", 0 );
for($k=0;$k<=19;$k++){ $exist = 0;
$user1 = $database->getUserField($post['myid'], "friend".$k, 0);
if($user1 == $uid or $uid == $post['myid']){ for ( $k = 0; $k <= 19; $k ++ ) {
$exist = 1; $user1 = $database->getUserField( $post['myid'], "friend" . $k, 0 );
} if ( $user1 == $uid or $uid == $post['myid'] ) {
} $exist = 1;
if($user == 0 && $userwait == 0 && $exist == 0){ }
$added1 = 0; }
for($l=0;$l<=19;$l++){
$user2 = $database->getUserField($uid, "friend".$l, 0); if ( $user == 0 && $userwait == 0 && $exist == 0 ) {
$userwait2 = $database->getUserField($uid, "friend".$l."wait", 0); $added1 = 0;
if($user2 == 0 && $userwait2 == 0 && $added1 == 0){
$database->addFriend($uid,"friend".$l."wait",$post['myid']); for ( $l = 0; $l <= 19; $l ++ ) {
$added1 = 1; $user2 = $database->getUserField( $uid, "friend" . $l, 0 );
} $userwait2 = $database->getUserField( $uid, "friend" . $l . "wait", 0 );
}
$database->addFriend($post['myid'],"friend".$j,$uid); if ( $user2 == 0 && $userwait2 == 0 && $added1 == 0 ) {
$database->addFriend($post['myid'],"friend".$j."wait",$uid); $database->addFriend( $uid, "friend" . $l . "wait", $post['myid'] );
$added = 1; $added1 = 1;
} }
} }
}
} $database->addFriend( $post['myid'], "friend" . $j, $uid );
} $database->addFriend( $post['myid'], "friend" . $j . "wait", $uid );
header("Location: nachrichten.php?t=1"); $added = 1;
exit; }
}
}
}
}
header( "Location: nachrichten.php?t=1" );
exit;
} }
} }
+19 -6
View File
@@ -97,8 +97,7 @@ class Profile {
for($i=0;$i<=count($varray)-1;$i++) { for($i=0;$i<=count($varray)-1;$i++) {
$k = trim($post['dname'.$i]); $k = trim($post['dname'.$i]);
$name = preg_replace("/[^a-zA-Z0-9_-\s]/", "", $k); $name = preg_replace("/[^a-zA-Z0-9_-\s]/", "", $k);
$database->setVillageName($database->RemoveXSS($varray[$i]['wref']),$name); $database->setVillageName($varray[$i]['wref'],$database->RemoveXSS($name));
$database->setVillageName($database->RemoveXSS($varray[$i]['wref']),$k);
} }
header("Location: spieler.php?uid=".$post['uid']); header("Location: spieler.php?uid=".$post['uid']);
exit; exit;
@@ -146,13 +145,14 @@ class Profile {
private function updateAccount($post) { private function updateAccount($post) {
global $database,$session,$form; global $database,$session,$form;
if($post['pw2'] == $post['pw3']) { if($post['pw2'] == $post['pw3']) {
if($database->login($session->username,$post['pw1'])) { if($database->login($session->username,$post['pw1'])) {
if ($_POST['uid'] != $session->uid){ if ($_POST['uid'] != $session->uid){
die("Hacking Attempr"); die("Hacking Attempr");
} else { } else {
$database->updateUserField($post['uid'],"password",password_hash($post['pw2'], PASSWORD_BCRYPT,['cost' => 12]),1); $database->updateUserField($post['uid'],"password",password_hash($post['pw2'], PASSWORD_BCRYPT,['cost' => 12]),1);
} }
} }
else { else {
$form->addError("pw",LOGIN_PW_ERROR); $form->addError("pw",LOGIN_PW_ERROR);
@@ -161,18 +161,24 @@ class Profile {
else { else {
$form->addError("pw",PASS_MISMATCH); $form->addError("pw",PASS_MISMATCH);
} }
if($post['email_alt'] == $session->userinfo['email']) { if($post['email_alt'] == $session->userinfo['email']) {
$database->updateUserField($post['uid'],"email",$post['email_neu'],1); $database->updateUserField($post['uid'],"email",$post['email_neu'],1);
} }
else { else {
$form->addError("email",EMAIL_ERROR); $form->addError("email",EMAIL_ERROR);
} }
if($post['del'] && password_verify($post['del_pw'], $session->userinfo['password'])) { if($post['del'] && password_verify($post['del_pw'], $session->userinfo['password'])) {
$database->setDeleting($post['uid'],0); $database->setDeleting($post['uid'],0);
} }
else { else {
$form->addError("del",PASS_MISMATCH); $form->addError("del",PASS_MISMATCH);
} }
if($post['v1'] != "") { if($post['v1'] != "") {
$sitid = $database->getUserField($post['v1'],"id",1); $sitid = $database->getUserField($post['v1'],"id",1);
if($sitid == $session->userinfo['sit1'] || $sitid == $session->userinfo['sit2']) { if($sitid == $session->userinfo['sit1'] || $sitid == $session->userinfo['sit2']) {
@@ -187,6 +193,7 @@ class Profile {
} }
} }
} }
$_SESSION['errorarray'] = $form->getErrors(); $_SESSION['errorarray'] = $form->getErrors();
header("Location: spieler.php?s=3"); header("Location: spieler.php?s=3");
exit; exit;
@@ -194,12 +201,15 @@ class Profile {
private function removeSitter($get) { private function removeSitter($get) {
global $database,$session; global $database,$session;
if($get['a'] == $session->checker) { if($get['a'] == $session->checker) {
if($session->userinfo['sit'.$get['type']] == $get['id']) { if($session->userinfo['sit'.$get['type']] == $get['id']) {
$database->updateUserField($session->uid,"sit".$get['type'],0,1); $database->updateUserField($session->uid,"sit".$get['type'],0,1);
} }
$session->changeChecker(); $session->changeChecker();
} }
header("Location: spieler.php?s=".$get['s']); header("Location: spieler.php?s=".$get['s']);
exit; exit;
} }
@@ -213,13 +223,16 @@ class Profile {
private function removeMeSit($get) { private function removeMeSit($get) {
global $database,$session; global $database,$session;
if($get['a'] == $session->checker) { if($get['a'] == $session->checker) {
$database->removeMeSit($get['id'],$session->uid); $database->removeMeSit($get['id'],$session->uid);
$session->changeChecker(); $session->changeChecker();
} }
header("Location: spieler.php?s=".$get['s']); header("Location: spieler.php?s=".$get['s']);
exit; exit;
} }
}; };
$profile = new Profile; $profile = new Profile;
?> ?>
+6 -4
View File
@@ -102,7 +102,9 @@ class Session {
$user_sanitized = $database->escape($user); $user_sanitized = $database->escape($user);
$_SESSION['checker'] = $generator->generateRandStr(3); $_SESSION['checker'] = $generator->generateRandStr(3);
$_SESSION['mchecker'] = $generator->generateRandStr(5); $_SESSION['mchecker'] = $generator->generateRandStr(5);
$_SESSION['qst'] = $database->getUserField($user_sanitized, "quest", 1);
$userFields = $database->getUserFields($user_sanitized, "quest, id", 1, true);
$_SESSION['qst'] = $userFields["quest"];
$result = mysqli_query($GLOBALS['link'],"SELECT id, village_select FROM `". TB_PREFIX."users` WHERE `username`='".$user_sanitized."'"); $result = mysqli_query($GLOBALS['link'],"SELECT id, village_select FROM `". TB_PREFIX."users` WHERE `username`='".$user_sanitized."'");
$dbarray = mysqli_fetch_assoc($result); $dbarray = mysqli_fetch_assoc($result);
@@ -113,7 +115,7 @@ class Session {
if($selected_village!='') { if($selected_village!='') {
$query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); $query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village);
}else{ }else{
$query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . (int) $database->getUserField($user_sanitized, "id", 1) . ' LIMIT 1'); $query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $userFields["id"] . ' LIMIT 1');
} }
$data = mysqli_fetch_assoc($query); $data = mysqli_fetch_assoc($query);
$_SESSION['wid'] = $data['wref']; $_SESSION['wid'] = $data['wref'];
@@ -122,7 +124,7 @@ class Session {
if($selected_village!='') { if($selected_village!='') {
$query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village); $query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `wref` = '.$selected_village);
}else{ }else{
$query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . (int) $database->getUserField($user_sanitized, "id", 1) . ' LIMIT 1'); $query = mysqli_query($GLOBALS['link'],'SELECT wref FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = ' . $userFields["id"] . ' LIMIT 1');
} }
$data = mysqli_fetch_assoc($query); $data = mysqli_fetch_assoc($query);
$_SESSION['wid'] = $data['wref']; $_SESSION['wid'] = $data['wref'];
@@ -196,7 +198,7 @@ class Session {
$database->updateUserField($user, "timestamp", $this->time, 0); $database->updateUserField($user, "timestamp", $this->time, 0);
return true; return true;
} else { } else {
return false; return false;
} }
} }
+2 -1
View File
@@ -37,10 +37,11 @@ class Village {
} }
//add new line code //add new line code
//check exist village if from village destroy to avoid error msg. //check exist village if from village destroy to avoid error msg.
if (!$database-> checkVilExist($this->wid)) { if ( !$database->checkVilExist($this->wid) ) {
$this->wid=$database->getVillageID($session->uid); $this->wid=$database->getVillageID($session->uid);
$_SESSION['wid']=$this->wid; $_SESSION['wid']=$this->wid;
} }
$this->LoadTown(); $this->LoadTown();
$this->calculateProduction(); $this->calculateProduction();
$this->processProduction(); $this->processProduction();