Optimizations

-Removed the "sort_type" 6 from the movement table, looted resources
will now be saved in the "sort_type" 4 returing attack.
This reduces a lot the spam in the tables "send" and "movement" of the
database
-Removed some useless methods in Database.php and Message.php
+Optimized report loading, own report will be loaded only once (and not
twice at random) and allied reports aren't loaded anymore
+Minor improovements and better indentation
This commit is contained in:
iopietro
2018-05-05 17:54:34 +02:00
parent cf74514451
commit f7e05c9802
14 changed files with 437 additions and 624 deletions
+22 -33
View File
@@ -252,39 +252,28 @@ if(isset($_POST['a']) == 533374 && isset($_POST['id']) == 39) {
}
}
if ( isset( $_GET['mode'] ) && $_GET['mode'] == 'troops' && isset( $_GET['cancel'] ) && $_GET['cancel'] == 1 ) {
if ( $session->access != BANNED ) {
$oldmovement = $database->getMovementById( $_GET['moveid'] );
$now = time();
if ( ( $now - $oldmovement[0]['starttime'] ) < 90 && $oldmovement[0]['from'] == $village->wid ) {
$qc = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement where proc = 0 and moveid = " . $database->escape( (int) $_GET['moveid'] );
$resultc = mysqli_fetch_array( mysqli_query( $database->dblink, $qc ), MYSQLI_ASSOC );
if ( $resultc['Total'] == 1 ) {
$q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where proc = 0 and moveid = " . $database->escape( (int) $_GET['moveid'] );
$database->query( $q );
$end = $now + ( $now - $oldmovement[0]['starttime'] );
//echo "6,".$oldmovement[0]['to'].",".$oldmovement[0]['from'].",0,".$now.",".$end;
$q2 = "SELECT id FROM " . TB_PREFIX . "send ORDER BY id DESC";
$lastid = mysqli_fetch_array( mysqli_query( $database->dblink, $q2 ) );
$newid = $lastid['id'] + 1;
$q2 = "INSERT INTO " . TB_PREFIX . "send values ($newid,0,0,0,0,0)";
$database->query( $q2 );
$database->addMovement( 4, $oldmovement[0]['to'], $oldmovement[0]['from'], $oldmovement[0]['ref'], $now, $end );
$database->addMovement( 6, $oldmovement[0]['to'], $oldmovement[0]['from'], $newid, $now, $end );
}
}
header( "Location: " . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id'] );
exit;
} else {
header( "Location: banned.php" );
exit;
}
if(isset($_GET['mode']) && $_GET['mode'] == 'troops' && isset($_GET['cancel']) && $_GET['cancel'] == 1){
if($session->access != BANNED){
$oldmovement = $database->getMovementById($_GET['moveid']);
$now = time();
if(($now - $oldmovement[0]['starttime']) < 90 && $oldmovement[0]['from'] == $village->wid){
$qc = "SELECT Count(*) as Total FROM " . TB_PREFIX . "movement where proc = 0 and moveid = " . $database->escape((int)$_GET['moveid']);
$resultc = mysqli_fetch_array(mysqli_query($database->dblink, $qc), MYSQLI_ASSOC);
if($resultc['Total'] == 1){
$q = "UPDATE " . TB_PREFIX . "movement set proc = 1 where proc = 0 and moveid = " . $database->escape((int)$_GET['moveid']);
$database->query($q);
$end = $now + ($now - $oldmovement[0]['starttime']);
$q2 = "SELECT id FROM " . TB_PREFIX . "send ORDER BY id DESC";
$lastid = mysqli_fetch_array(mysqli_query($database->dblink, $q2));
$database->addMovement(4, $oldmovement[0]['to'], $oldmovement[0]['from'], $oldmovement[0]['ref'], $now, $end);
}
}
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id']);
exit();
}else{
header("Location: banned.php");
exit();
}
}
if(isset($_GET['id'])) $automation->isWinner();
?>