mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-09 06:06:09 +00:00
Update db_MYSQL.php
This commit is contained in:
@@ -50,12 +50,6 @@ class MYSQL_DB {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function updateDate($userName, $timeZone, $dateFormat)
|
||||
{
|
||||
$q = "UPDATE users set timeZone = $timeZone, dateFormat = $dateFormat where username = '" . $userName . "'";
|
||||
return mysql_query($q,$this->connection);
|
||||
}
|
||||
|
||||
function unreg($username) {
|
||||
$q = "DELETE from " . TB_PREFIX . "activate where username = '$username'";
|
||||
@@ -373,40 +367,20 @@ class MYSQL_DB {
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
/*
|
||||
function generateBase($sector) {
|
||||
switch($sector) {
|
||||
case 1:
|
||||
$q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y > 0 and occupied = 0";
|
||||
break;
|
||||
case 2:
|
||||
$q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y > 0 and occupied = 0";
|
||||
break;
|
||||
case 3:
|
||||
$q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y < 0 and occupied = 0";
|
||||
break;
|
||||
case 4:
|
||||
$q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y < 0 and occupied = 0";
|
||||
break;
|
||||
}
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$num_rows = mysql_num_rows($result);
|
||||
$result = $this->mysql_fetch_all($result);
|
||||
$base = rand(0, ($num_rows-1));
|
||||
return $result[$base]['id'];
|
||||
}
|
||||
*/
|
||||
|
||||
function generateBase($sector, $mode=1) {
|
||||
$num_rows = 0;
|
||||
$count_while = 0;
|
||||
while (!$num_rows){
|
||||
if (!$mode) {
|
||||
$gamesday=time()-COMMENCE;
|
||||
if ($gamesday<3600*24*10) { //10 day
|
||||
if ($gamesday<3600*24*10 && $count_while==0) { //10 day
|
||||
$wide1=1;
|
||||
$wide2=20;
|
||||
} elseif ($gamesday<3600*24*20) { //20 day
|
||||
} elseif ($gamesday<3600*24*20 && $count_while==1) { //20 day
|
||||
$wide1=20;
|
||||
$wide2=40;
|
||||
} elseif ($gamesday<3600*24*30) { //30 day
|
||||
} elseif ($gamesday<3600*24*30 && $count_while==2) { //30 day
|
||||
$wide1=40;
|
||||
$wide2=80;
|
||||
} else { // over 30 day
|
||||
@@ -434,6 +408,8 @@ class MYSQL_DB {
|
||||
}
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$num_rows = mysql_num_rows($result);
|
||||
$count_while++;
|
||||
}
|
||||
$result = $this->mysql_fetch_all($result);
|
||||
$base = rand(0, ($num_rows-1));
|
||||
return $result[$base]['id'];
|
||||
@@ -497,12 +473,14 @@ class MYSQL_DB {
|
||||
}
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
function isVillageOases($wref) {
|
||||
$q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
return $dbarray['oasistype'];
|
||||
}
|
||||
function isVillageOases($wref) {
|
||||
$q = "SELECT id, oasistype FROM " . TB_PREFIX . "wdata where id = $wref";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
if($result){
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
return $dbarray['oasistype'];
|
||||
}else return 0;
|
||||
}
|
||||
|
||||
public function VillageOasisCount($vref) {
|
||||
$q = "SELECT count(*) FROM `".TB_PREFIX."odata` WHERE conqured=$vref";
|
||||
@@ -1231,12 +1209,25 @@ class MYSQL_DB {
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function DeleteCat($id) {
|
||||
$qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'";
|
||||
$q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'";
|
||||
mysql_query($qs, $this->connection);
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
function DeleteCat($id) {
|
||||
$qs = "DELETE from " . TB_PREFIX . "forum_cat where id = '$id'";
|
||||
$q = "DELETE from " . TB_PREFIX . "forum_topic where cat = '$id'";
|
||||
$q2="SELECT id from ".TB_PREFIX."forum_topic where cat ='$id'";
|
||||
$result = mysql_query($q2, $this->connection);
|
||||
if (!empty($result)) {
|
||||
$array=$this->mysql_fetch_all($result);
|
||||
foreach($array as $ss) {
|
||||
$this->DeleteSurvey($ss['id']);
|
||||
}
|
||||
}
|
||||
mysql_query($qs, $this->connection);
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function DeleteSurvey($id) {
|
||||
$qs = "DELETE from " . TB_PREFIX . "forum_survey where topic = '$id'";
|
||||
return mysql_query($qs, $this->connection);
|
||||
}
|
||||
|
||||
function DeleteTopic($id) {
|
||||
$qs = "DELETE from " . TB_PREFIX . "forum_topic where id = '$id'";
|
||||
@@ -3259,25 +3250,26 @@ class MYSQL_DB {
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
public function canClaimArtifact($from,$vref,$type,$kind) {
|
||||
public function canClaimArtifact($from,$vref,$size,$type) {
|
||||
//fix by Ronix
|
||||
global $session, $form;
|
||||
$type1 = $type2 = $type3 = 0;
|
||||
$size1 = $size2 = $size3 = 0;
|
||||
|
||||
$artifact = $this->getOwnArtefactInfo($from);
|
||||
if (!empty($artifact)) {
|
||||
$form->addError("error","Treasury is full. Your hero could not claim the artefact and");
|
||||
$form->addError("error","Treasury is full. Your hero could not claim the artefact");
|
||||
return false;
|
||||
}
|
||||
$uid=$session->uid;
|
||||
$q="SELECT Count(type) AS totals,
|
||||
SUM(IF(type = '1',1,0)) small,
|
||||
SUM(IF(type = '2',1,0)) great,
|
||||
SUM(IF(type = '3',1,0)) unique,
|
||||
$q="SELECT Count(size) AS totals,
|
||||
SUM(IF(size = '1',1,0)) small,
|
||||
SUM(IF(size = '2',1,0)) great,
|
||||
SUM(IF(size = '3',1,0)) `unique`
|
||||
FROM ".TB_PREFIX."artefacts WHERE owner = ".$uid;
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$artifact= $this->mysql_fetch_all($result);
|
||||
if($artifact['totals'] < 3 || $kind==11) {
|
||||
|
||||
if($artifact['totals'] < 3 || $type==11) {
|
||||
$DefenderFields = $this->getResourceLevel($vref);
|
||||
$defcanclaim = TRUE;
|
||||
for($i=19;$i<=38;$i++) {
|
||||
@@ -3285,7 +3277,7 @@ class MYSQL_DB {
|
||||
$defTresuaryLevel = $DefenderFields['f'.$i];
|
||||
if($defTresuaryLevel > 0) {
|
||||
$defcanclaim = FALSE;
|
||||
$form->addError("error","Treasury has not been destroyed. Your hero could not claim the artefact and");
|
||||
$form->addError("error","Treasury has not been destroyed. Your hero could not claim the artefact");
|
||||
return false;
|
||||
} else {
|
||||
$defcanclaim = TRUE;
|
||||
@@ -3308,26 +3300,29 @@ class MYSQL_DB {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($artifact['great']>0 || $artifact['unique']>0) && $type>1) {
|
||||
$form->addError("error","Max num. of great/unique artefacts. Your hero could not claim the artefact and");
|
||||
if (($artifact['great']>0 || $artifact['unique']>0) && $size>1) {
|
||||
$form->addError("error","Max num. of great/unique artefacts. Your hero could not claim the artefact");
|
||||
return FALSE;
|
||||
}
|
||||
if (($type == 1 && ($villageartifact || $accountartifact)) || (($type == 2 || $type == 3)&& $accountartifact)) {
|
||||
if($this->getVillageField($from,"capital")==1) {
|
||||
if (($size == 1 && ($villageartifact || $accountartifact)) || (($size == 2 || $size == 3)&& $accountartifact)) {
|
||||
return true;
|
||||
/*
|
||||
if($this->getVillageField($from,"capital")==1 && $type==11) {
|
||||
$form->addError("error","Ancient Construction Plan cannot kept in capital village");
|
||||
return FALSE;
|
||||
}else{
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
$form->addError("error","Your level treasury is low. Your hero could not claim the artefact");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
$form->addError("error","Max num. of artefacts. Your hero could not claim the artefact and");
|
||||
$form->addError("error","Max num. of artefacts. Your hero could not claim the artefact");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getArtefactDetails($id) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . "";
|
||||
@@ -3428,7 +3423,7 @@ class MYSQL_DB {
|
||||
|
||||
$basecrop = $grainmill = $bakery = 0;
|
||||
$owner = $this->getVrefField($wref, 'owner');
|
||||
$bonus = $this->getUserField($owner, b4, 0);
|
||||
$bonus = $this->getUserField($owner, 'b4', 0);
|
||||
|
||||
$buildarray = $this->getResourceLevel($wref);
|
||||
$cropholder = array();
|
||||
|
||||
Reference in New Issue
Block a user