From 498151c36083d6ce1fa8bc3cb9ba5d8b7469332c Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Sat, 30 Mar 2013 21:09:47 +0530 Subject: [PATCH 1/5] cache --- cache/.htaccess | 4 ++++ index.php | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 cache/.htaccess diff --git a/cache/.htaccess b/cache/.htaccess new file mode 100644 index 00000000..d87fe95b --- /dev/null +++ b/cache/.htaccess @@ -0,0 +1,4 @@ + +Order allow,deny +Deny from all + \ No newline at end of file diff --git a/index.php b/index.php index 25e4a9d6..325708be 100644 --- a/index.php +++ b/index.php @@ -43,9 +43,25 @@ else { die('Security: Please activate security class!'); } + +$cachefile = 'cache/'.basename($_SERVER['PHP_SELF']).'.cache'; // e.g. cache/index.php.cache +$cachetime = 3600; // time to cache in seconds + +if(file_exists($cachefile) && time()-$cachetime <= filemtime($cachefile)){ + $c = @file_get_contents($cf); + echo $c; + exit; +}else{ + unlink($cachefile); +} + +ob_start(); + include ("GameEngine/Database.php"); include ("GameEngine/Lang/".LANG.".php"); + ?> + @@ -272,4 +288,10 @@ include ("GameEngine/Lang/".LANG.".php"); var galarie = new Fx.Screenshots('screen_view', 'screen_hl', 'screen_desc', screenshots); - \ No newline at end of file + + \ No newline at end of file From 0c80a392bf3ed3eecd371529eaca9ae88189c74f Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Tue, 23 Apr 2013 14:03:43 +0530 Subject: [PATCH 2/5] MySQLi database update --- GameEngine/Database/db_MYSQLi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GameEngine/Database/db_MYSQLi.php b/GameEngine/Database/db_MYSQLi.php index 12352ede..e6c36862 100644 --- a/GameEngine/Database/db_MYSQLi.php +++ b/GameEngine/Database/db_MYSQLi.php @@ -19,7 +19,7 @@ class MYSQLi_DB { function register($username, $password, $email, $tribe, $act) { $time = time(); - $timep = (time() + PROTECTION); + $timep = (strtotime(START_TIME) + PROTECTION); $q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)"; if(mysqli_query($this->connection, $q)) { return mysqli_insert_id($this->connection); @@ -2150,7 +2150,7 @@ class MYSQLi_DB { } function getARanking() { - $q = "SELECT id,name,tag,oldrank FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC"; + $q = "SELECT id,name,tag,oldrank,Aap,Adp FROM " . TB_PREFIX . "alidata where id != '' ORDER BY id DESC"; $result = mysqli_query($this->connection, $q); return $this->mysqli_fetch_all($result); } From 5fd3a6ecc0c2c973adb615dd6ad188cabc98ad65 Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Tue, 23 Apr 2013 14:21:03 +0530 Subject: [PATCH 3/5] Fixes --- GameEngine/Database/db_MYSQL.php | 11 +++++++++++ GameEngine/Database/db_MYSQLi.php | 11 +++++++++++ Templates/Build/avaliable.tpl | 20 +------------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 66a8dee6..39fcdeba 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -120,7 +120,18 @@ class MYSQL_DB { $dbarray = mysql_fetch_array($result); return $dbarray['id']; } + + function caststruc($user) { + //loop search village user + $query = mysql_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); + while($villaggi_array = mysql_fetch_array($query)){ + //loop structure village + $query1 = mysql_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); + $strutture= mysql_fetch_array($query1); + return $strutture; + } + function removeMeSit($uid, $uid2) { $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2"; mysql_query($q, $this->connection); diff --git a/GameEngine/Database/db_MYSQLi.php b/GameEngine/Database/db_MYSQLi.php index e6c36862..54f624e2 100644 --- a/GameEngine/Database/db_MYSQLi.php +++ b/GameEngine/Database/db_MYSQLi.php @@ -119,6 +119,17 @@ class MYSQLi_DB { $dbarray = mysqli_fetch_array($result, MYSQLI_BOTH); return $dbarray['id']; } + + function caststruc($user) { + //loop search village user + $query = mysqli_query($this->connection, "SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); + while($villaggi_array = mysqli_fetch_array($query, MYSQLI_BOTH)){ + + //loop structure village + $query1 = mysqli_query($this->connection, "SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); + $strutture= mysqli_fetch_array($query1, MYSQLI_BOTH); + return $strutture; + } function removeMeSit($uid, $uid2) { $q = "UPDATE " . TB_PREFIX . "users set sit1 = 0 where id = $uid and sit1 = $uid2"; diff --git a/Templates/Build/avaliable.tpl b/Templates/Build/avaliable.tpl index d7c8620d..d7f6a63d 100644 --- a/Templates/Build/avaliable.tpl +++ b/Templates/Build/avaliable.tpl @@ -163,26 +163,8 @@ if($palace == 0 && $palace1 == 0 && $embassy >= 1 && $mainbuilding >= 5 && $id ! //id user $user = $session->uid; -//connect to DB -mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS); -mysql_select_db(SQL_DB); - -//loop search village user -$query = mysql_query("SELECT * FROM ".TB_PREFIX."vdata WHERE owner = ".$user.""); -while($villaggi_array = mysql_fetch_array($query)){ - - //loop structure village - $query1 = mysql_query("SELECT * FROM ".TB_PREFIX."fdata WHERE vref = ".$villaggi_array['wref'].""); - $strutture= mysql_fetch_array($query1); - //search Castle in array structure village -$test = in_array(26,$strutture); -if ($test){ - break; - } - -} - +$test = in_array(26, $database->caststruc($user)); //if Castle no ready include palace.tpl if (!$test){ From def107a549a7ed857d9b557a8a554b1a63e9dcfb Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Tue, 23 Apr 2013 21:19:40 +0530 Subject: [PATCH 4/5] Insttal Mysqli fix --- install/include/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/include/database.php b/install/include/database.php index b94124b5..426503c5 100644 --- a/install/include/database.php +++ b/install/include/database.php @@ -17,7 +17,7 @@ class MYSQLi_DB { $this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die(mysqli_error()); } function query($query) { - return $this->connection->query($query); + return mysqli_query($this->connection, $query); } }; From 130f2b21484644f6793e1ecb2fbe9e569a9faa01 Mon Sep 17 00:00:00 2001 From: Akshay Naik Date: Tue, 23 Apr 2013 22:03:40 +0530 Subject: [PATCH 5/5] FIX attack bug --- a2b.php | 2 +- install/data/sql.sql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/a2b.php b/a2b.php index 7ffa5c29..7ea3d55e 100644 --- a/a2b.php +++ b/a2b.php @@ -206,7 +206,7 @@ if(isset($_GET['o'])) { } $p_time = round($automation->procDistanceTime($p_to,$p_from,min($p_speeds),1)/$p_fastertroops); $p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0); - $database->addMovement(4,$prisoner['wref'],$prisoner['from'],$p_reference,time(),($p_time+time())); + $database->addMovement(4,$prisoner['wref'],$prisoner['from'],$p_reference,(microtime(true)),($p_time+microtime(true))); $troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11']; $database->modifyUnit($prisoner['wref'],array("99o"),array($troops),array(0)); $database->deletePrisoners($prisoner['id']); diff --git a/install/data/sql.sql b/install/data/sql.sql index e4c0bba2..80bba466 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -969,8 +969,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%movement` ( `to` int(11) unsigned NOT NULL DEFAULT '0', `ref` int(11) unsigned NOT NULL DEFAULT '0', `ref2` int(11) unsigned NOT NULL DEFAULT '0', - `starttime` int(11) unsigned NOT NULL DEFAULT '0', - `endtime` int(11) unsigned NOT NULL DEFAULT '0', + `starttime` float(20) unsigned NOT NULL DEFAULT '0', + `endtime` float(20) unsigned NOT NULL DEFAULT '0', `proc` tinyint(1) unsigned NOT NULL DEFAULT '0', `send` tinyint(1) unsigned NOT NULL, `wood` int(11) unsigned NOT NULL,