mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Fixed bugs in trade routes
+Trade routes can't be hacked anymore +Fixed a bug that permitted to choose any village when adding a trade route +Fixed a bug that permitted to choose a time greater than 23 and less than 0 +Fixed a bug that permitted to choose a number of repetitions greater than 3 and less than 1 +Fixed a bug that permitted to edit other players trade route +Fixed a bug that permitted to create a trading route with the same village you were in +Fixed some minor bugs +Reworked the post/get request system, it's buch better now
This commit is contained in:
@@ -67,141 +67,126 @@ if ( isset( $_GET['id'] ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $session->goldclub == 1 && count( $session->villages ) > 1 ) {
|
||||
if ( isset( $_GET['routeid'] ) ) {
|
||||
$routeid = $_GET['routeid'];
|
||||
if ($session->goldclub == 1 && count($session->villages) > 1 ) {
|
||||
if (isset($_POST['routeid'])) {
|
||||
$routeid = $_POST['routeid'];
|
||||
}
|
||||
|
||||
if ( isset( $_POST['action'] ) && $_POST['action'] == 'addRoute' ) {
|
||||
if ( $session->access != BANNED ) {
|
||||
if ( $session->gold >= 2 ) {
|
||||
for ( $i = 1; $i <= 4; $i ++ ) {
|
||||
if ( $_POST[ 'r' . $i ] == "" ) {
|
||||
$_POST[ 'r' . $i ] = 0;
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'addRoute') {
|
||||
if ($session->access != BANNED) {
|
||||
if ($session->gold >= 2 && $session->goldclub == 1) {
|
||||
for ($i = 1; $i <= 4; $i ++) {
|
||||
if (empty($_POST['r'.$i])) {
|
||||
$_POST['r'.$i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$totalres = preg_replace( "/[^0-9]/", "", $_POST['r1'] ) + preg_replace( "/[^0-9]/", "", $_POST['r2'] ) + preg_replace( "/[^0-9]/", "", $_POST['r3'] ) + preg_replace( "/[^0-9]/", "", $_POST['r4'] );
|
||||
$reqMerc = ceil( ( $totalres - 0.1 ) / $market->maxcarry );
|
||||
$second = date( "s" );
|
||||
$minute = date( "i" );
|
||||
$hour = date( "G" ) - $_POST['start'];
|
||||
$totalres = preg_replace("/[^0-9]/", "", $_POST['r1']) + preg_replace("/[^0-9]/", "", $_POST['r2']) + preg_replace("/[^0-9]/", "", $_POST['r3']) + preg_replace("/[^0-9]/", "", $_POST['r4']);
|
||||
$reqMerc = ceil(($totalres - 0.1) / $market->maxcarry);
|
||||
$second = date("s");
|
||||
$minute = date("i");
|
||||
$hour = date("G") - $_POST['start'];
|
||||
|
||||
if ( date( "G" ) > $_POST['start'] ) {
|
||||
$day = 1;
|
||||
} else {
|
||||
$day = 0;
|
||||
}
|
||||
if (date("G") > $_POST['start']) $day = 1;
|
||||
else $day = 0;
|
||||
|
||||
$timestamp = strtotime( "-$hour hours -$second second -$minute minutes +$day day" );
|
||||
$timestamp = strtotime("-$hour hours -$second second -$minute minutes +$day day");
|
||||
|
||||
if ( $totalres > 0 ) {
|
||||
$database->createTradeRoute( $session->uid, $_POST['tvillage'], $village->wid, $_POST['r1'], $_POST['r2'], $_POST['r3'], $_POST['r4'], $_POST['start'], $_POST['deliveries'], $reqMerc, $timestamp );
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
exit;
|
||||
if ($totalres > 0 && $_POST['tvillage'] != $village->wid && in_array($_POST['tvillage'], $session->villages) && ($_POST['start'] >= 0 && $_POST['start'] <= 23) && ($_POST['deliveries'] >= 1 && $_POST['deliveries'] <= 3)) {
|
||||
$database->createTradeRoute($session->uid, $_POST['tvillage'], $village->wid, $_POST['r1'], $_POST['r2'], $_POST['r3'], $_POST['r4'], $_POST['start'], $_POST['deliveries'], $reqMerc, $timestamp);
|
||||
$route = 1;
|
||||
header("Location: build.php?gid=17&t=4");
|
||||
exit;
|
||||
} else {
|
||||
header( "Location: build.php?gid=17&t=4&create" );
|
||||
exit;
|
||||
$route = 1;
|
||||
header("Location: build.php?gid=17&t=4&create");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$route = 0;
|
||||
header( "Location: banned.php" );
|
||||
header("Location: banned.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_GET['action'] ) && $_GET['action'] == 'extendRoute' ) {
|
||||
if ( $session->access != BANNED ) {
|
||||
if ( $session->gold >= 2 ) {
|
||||
$traderoute = $database->getTradeRouteUid( $_GET['routeid'] );
|
||||
|
||||
if ( $traderoute == $session->uid ) {
|
||||
$database->editTradeRoute( $_GET['routeid'], "timeleft", 604800, 1 );
|
||||
if (isset($_POST['routeid']) && isset($_POST['action']) && $_POST['action'] == 'extendRoute') {
|
||||
if ($session->access != BANNED) {
|
||||
if ($session->gold >= 2 && $session->goldclub == 1) {
|
||||
$traderoute = $database->getTradeRouteUid($_POST['routeid']);
|
||||
if ($traderoute == $session->uid) {
|
||||
$database->editTradeRoute($_POST['routeid'], "timeleft", 604800, 1);
|
||||
$newgold = $session->gold - 2;
|
||||
$database->updateUserField( $session->uid, 'gold', $newgold, 1 );
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
exit;
|
||||
$route = 1;
|
||||
unset( $routeid );
|
||||
} else {
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
exit;
|
||||
$route = 1;
|
||||
unset( $routeid );
|
||||
$database->updateUserField($session->uid, 'gold', $newgold, 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
exit;
|
||||
$route = 1;
|
||||
}
|
||||
} else {
|
||||
$route = 0;
|
||||
header( "Location: banned.php" );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_POST['action'] ) && $_POST['action'] == 'editRoute' ) {
|
||||
if ( $session->access != BANNED ) {
|
||||
$totalres = $_POST['r1'] + $_POST['r2'] + $_POST['r3'] + $_POST['r4'];
|
||||
$reqMerc = ceil( ( $totalres - 0.1 ) / $market->maxcarry );
|
||||
|
||||
if ( $totalres > 0 ) {
|
||||
$database->editTradeRoute( $_POST['routeid'], "wood", $_POST['r1'], 0 );
|
||||
$database->editTradeRoute( $_POST['routeid'], "clay", $_POST['r2'], 0 );
|
||||
$database->editTradeRoute( $_POST['routeid'], "iron", $_POST['r3'], 0 );
|
||||
$database->editTradeRoute( $_POST['routeid'], "crop", $_POST['r4'], 0 );
|
||||
$database->editTradeRoute( $_POST['routeid'], "start", $_POST['start'], 0 );
|
||||
$database->editTradeRoute( $_POST['routeid'], "deliveries", $_POST['deliveries'], 0 );
|
||||
$database->editTradeRoute( $_POST['routeid'], "merchant", $reqMerc, 0 );
|
||||
$second = date( "s" );
|
||||
$minute = date( "i" );
|
||||
$hour = date( "G" ) - $_POST['start'];
|
||||
if ( date( "G" ) > $_POST['start'] ) {
|
||||
$day = 1;
|
||||
} else {
|
||||
$day = 0;
|
||||
}
|
||||
$timestamp = strtotime( "-$hour hours -$second seconds -$minute minutes +$day day" );
|
||||
$database->editTradeRoute( $_POST['routeid'], "timestamp", $timestamp, 0 );
|
||||
}
|
||||
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
exit;
|
||||
}
|
||||
$route = 1;
|
||||
unset( $routeid );
|
||||
unset($routeid);
|
||||
header("Location: build.php?gid=17&t=4");
|
||||
exit;
|
||||
} else {
|
||||
$route = 0;
|
||||
header( "Location: banned.php" );
|
||||
header("Location: banned.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_GET['action'] ) && $_GET['action'] == 'delRoute' ) {
|
||||
if ( $session->access != BANNED ) {
|
||||
$traderoute = $database->getTradeRouteUid( $_GET['routeid'] );
|
||||
|
||||
if ( $traderoute == $session->uid ) {
|
||||
$database->deleteTradeRoute( $_GET['routeid'] );
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
exit;
|
||||
if (isset($_POST['routeid']) && isset($_POST['action']) && $_POST['action'] == 'editRoute2') {
|
||||
if ($session->access != BANNED) {
|
||||
if($session->goldclub == 1){
|
||||
for ($i = 1; $i <= 4; $i ++) {
|
||||
if (empty($_POST['r'.$i])) {
|
||||
$_POST['r'.$i] = 0;
|
||||
}
|
||||
}
|
||||
$totalres = preg_replace("/[^0-9]/", "", $_POST['r1']) + preg_replace("/[^0-9]/", "", $_POST['r2']) + preg_replace("/[^0-9]/", "", $_POST['r3']) + preg_replace("/[^0-9]/", "", $_POST['r4']);
|
||||
$reqMerc = ceil(($totalres - 0.1) / $market->maxcarry);
|
||||
|
||||
$traderoute = $database->getTradeRouteUid($_POST['routeid']);
|
||||
if ($totalres > 0 && $traderoute == $session->uid && ($_POST['start'] >= 0 && $_POST['start'] <= 23) && ($_POST['deliveries'] >= 1 && $_POST['deliveries'] <= 3)) {
|
||||
$database->editTradeRoute($_POST['routeid'], "wood", $_POST['r1'], 0);
|
||||
$database->editTradeRoute($_POST['routeid'], "clay", $_POST['r2'], 0);
|
||||
$database->editTradeRoute($_POST['routeid'], "iron", $_POST['r3'], 0);
|
||||
$database->editTradeRoute($_POST['routeid'], "crop", $_POST['r4'], 0);
|
||||
$database->editTradeRoute($_POST['routeid'], "start", $_POST['start'], 0);
|
||||
$database->editTradeRoute($_POST['routeid'], "deliveries", $_POST['deliveries'], 0);
|
||||
$database->editTradeRoute($_POST['routeid'], "merchant", $reqMerc, 0);
|
||||
$second = date("s");
|
||||
$minute = date("i");
|
||||
$hour = date("G") - $_POST['start'];
|
||||
if (date("G") > $_POST['start']) $day = 1;
|
||||
else $day = 0;
|
||||
$timestamp = strtotime("-$hour hours -$second seconds -$minute minutes +$day day");
|
||||
$database->editTradeRoute($_POST['routeid'], "timestamp", $timestamp, 0);
|
||||
}
|
||||
|
||||
$route = 1;
|
||||
unset( $routeid );
|
||||
unset($routeid);
|
||||
header("Location: build.php?gid=17&t=4");
|
||||
exit;
|
||||
} else {
|
||||
header( "Location: build.php?gid=17&t=4" );
|
||||
$route = 0;
|
||||
header("Location: banned.php");
|
||||
exit;
|
||||
$route = 1;
|
||||
unset( $routeid );
|
||||
}
|
||||
} else {
|
||||
$route = 0;
|
||||
header( "Location: banned.php" );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['routeid']) && isset($_POST['action']) && $_POST['action'] == 'delRoute') {
|
||||
if ($session->access != BANNED ) {
|
||||
if($session->goldclub == 1){
|
||||
$traderoute = $database->getTradeRouteUid($_POST['routeid']);
|
||||
if ($traderoute == $session->uid) $database->deleteTradeRoute($_POST['routeid']);
|
||||
$route = 1;
|
||||
unset($routeid);
|
||||
header("Location: build.php?gid=17&t=4");
|
||||
exit;
|
||||
} else {
|
||||
$route = 0;
|
||||
header("Location: banned.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +346,7 @@ if ( isset( $_GET['id'] ) ) {
|
||||
<?php include("Templates/menu.tpl"); ?>
|
||||
<div id="content" class="build">
|
||||
<?php
|
||||
if(isset($_GET['id']) or isset($_GET['gid']) or $route == 1 or isset($_GET['routeid']) or isset($_GET['buildingFinish'])) {
|
||||
if(isset($_GET['id']) || isset($_GET['gid']) || $route == 1 || isset($_POST['routeid']) || isset($_GET['buildingFinish'])) {
|
||||
if(isset($_GET['s']))
|
||||
{
|
||||
if (!ctype_digit($_GET['s'])) {
|
||||
|
||||
Reference in New Issue
Block a user