Merge pull request #209 from akshay9/master

Fixes and added homepage caching
This commit is contained in:
yi12345
2013-04-23 11:33:01 -07:00
8 changed files with 56 additions and 26 deletions
+11
View File
@@ -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);
+13 -2
View File
@@ -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);
@@ -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";
@@ -2150,7 +2161,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);
}
+1 -19
View File
@@ -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){
+1 -1
View File
@@ -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']);
+4
View File
@@ -0,0 +1,4 @@
<Files ~ "\.cache$">
Order allow,deny
Deny from all
</Files>
+23 -1
View File
@@ -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");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -272,4 +288,10 @@ include ("GameEngine/Lang/".LANG.".php");
var galarie = new Fx.Screenshots('screen_view', 'screen_hl', 'screen_desc', screenshots);
</script>
</body>
</html>
</html>
<?php
$c = ob_get_contents();
file_put_contents($cachefile);
?>
+2 -2
View File
@@ -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,
+1 -1
View File
@@ -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);
}
};