mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-20 19:46:10 +00:00
Merge branch 'master' of https://github.com/Shadowss/TravianZ
This commit is contained in:
@@ -13,25 +13,23 @@
|
||||
if(!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
|
||||
include_once("../../Database.php");
|
||||
include_once("../../Technology.php");
|
||||
include_once("../../Data/unitdata.php");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$id = (int)$_POST['id'];
|
||||
$village = $database->getVillage($id);
|
||||
$user = $database->getUserArray($village['owner'],1);
|
||||
$units="";
|
||||
$tribe = $user['tribe'];
|
||||
if($tribe ==1){ $u = 0;}
|
||||
if($tribe ==2){ $u = 10;}
|
||||
if($tribe ==3){ $u = 20;}
|
||||
if($tribe ==4){ $u = 30;}
|
||||
if($tribe ==5){ $u = 40;}
|
||||
if($tribe ==6){ $u = 50;}
|
||||
$user = $database->getUserArray($village['owner'],1);
|
||||
$units = "";
|
||||
$tribe = $user['tribe'];
|
||||
$u = ($tribe - 1) * 10;
|
||||
|
||||
for($i=1; $i<11; $i++) {
|
||||
$units.="u".($u+$i)."=".$database->escape($_POST['u'.($u+$i)].(($i < 10) ? ", " : ""));
|
||||
for($i = 1; $i < 11; $i++) {
|
||||
$units.="u".($u + $i)."=".$database->escape($_POST['u'.($u + $i)].(($i < 10) ? ", " : ""));
|
||||
}
|
||||
$q = "UPDATE ".TB_PREFIX."units SET ".$units." WHERE vref = ".(int) $id;
|
||||
|
||||
$q = "UPDATE ".TB_PREFIX."units SET ".$units." WHERE vref = ".$id;
|
||||
$database->query($q);
|
||||
$database->query("Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Changed troop amounts in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")");
|
||||
|
||||
$database->addStarvationData($id);
|
||||
header("Location: ../../../Admin/admin.php?p=village&did=".$id."&d");
|
||||
?>
|
||||
@@ -24,57 +24,24 @@ for ($i = 0; $i < 5; $i++) {
|
||||
|
||||
include_once($autoprefix."GameEngine/Database.php");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session."");
|
||||
$access = mysqli_fetch_array($sql);
|
||||
$sessionaccess = $access['access'];
|
||||
$bonusDuration = [];
|
||||
$time = time();
|
||||
$bonusDuration['plus'] = (int) $_POST['plus'] * 86400; //Plus
|
||||
$bonusDuration['b1'] = (int) $_POST['wood'] * 86400; //+25% Wood
|
||||
$bonusDuration['b2'] = (int) $_POST['clay'] * 86400; //+25% Clay
|
||||
$bonusDuration['b3'] = (int) $_POST['iron'] * 86400; //+25% Iron
|
||||
$bonusDuration['b4'] = (int) $_POST['crop'] * 86400; //+25% Crop
|
||||
|
||||
if($sessionaccess != 9) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
|
||||
$user = $database->getUserArray($id, 1);
|
||||
|
||||
$pdur = (int) $_POST['plus'] * 86400;
|
||||
$b1dur = (int) $_POST['wood'] * 86400;
|
||||
$b2dur = (int) $_POST['clay'] * 86400;
|
||||
$b3dur = (int) $_POST['iron'] * 86400;
|
||||
$b4dur = (int) $_POST['crop'] * 86400;
|
||||
|
||||
$sql1 = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$id."");
|
||||
$user = mysqli_fetch_array($sql1);
|
||||
|
||||
if($user['plus'] < time()){
|
||||
if($pdur > 1){ $plus = (time() + $pdur); } else { $plus = time(); }
|
||||
}else{
|
||||
if($pdur > 1){ $plus = ($user['plus'] + $pdur); } else { $plus = $user['plus']; }
|
||||
}
|
||||
if($user['b1'] < time()){
|
||||
if($b1dur > 1){ $wood = (time() + $b1dur); } else { $wood = time(); }
|
||||
}else{
|
||||
if($b1dur > 1){ $wood = ($user['b1'] + $b1dur); } else { $wood = $user['b1']; }
|
||||
}
|
||||
if($user['b2'] < time()){
|
||||
if($b2dur > 1){ $clay = (time() + $b2dur); } else { $clay = time(); }
|
||||
}else{
|
||||
if($b2dur > 1){ $clay = ($user['b2'] + $b2dur); } else { $clay = $user['b2']; }
|
||||
}
|
||||
if($user['b3'] < time()){
|
||||
if($b3dur > 1){ $iron = (time() + $b3dur); } else { $iron = time(); }
|
||||
}else{
|
||||
if($b3dur > 1){ $iron = ($user['b3'] + $b3dur); } else { $iron = $user['b3']; }
|
||||
}
|
||||
if($user['b4'] < time()){
|
||||
if($b4dur > 1){ $crop = (time() + $b4dur); } else { $crop = time(); }
|
||||
}else{
|
||||
if($b4dur > 1){ $crop = ($user['b4'] + $b4dur); } else { $crop = $user['b4']; }
|
||||
foreach($bonusDuration as $index => $bonus){
|
||||
$bonusDuration[$index] = $bonusDuration[$index] + ($user[$index] < $time ? $time : $user[$index]);
|
||||
if($bonusDuration[$index] < $time) $bonusDuration[$index] = 0;
|
||||
}
|
||||
|
||||
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET
|
||||
plus = '".$plus."',
|
||||
b1 = '".$wood."',
|
||||
b2 = '".$clay."',
|
||||
b3 = '".$iron."',
|
||||
b4 = '".$crop."'
|
||||
WHERE id = $id") or die(mysqli_error($database->dblink));
|
||||
$database->updateUserField($id, array_keys($bonusDuration), array_values($bonusDuration), 1);
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=".$id."");
|
||||
?>
|
||||
@@ -30,14 +30,6 @@ for ($i = 0; $i < 5; $i++) {
|
||||
|
||||
include_once($autoprefix."GameEngine/Database.php");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session."");
|
||||
$access = mysqli_fetch_array($sql);
|
||||
$sessionaccess = $access['access'];
|
||||
|
||||
if($sessionaccess != 9) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
|
||||
|
||||
$sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1";
|
||||
$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0);
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
// # ##
|
||||
// ################################################################################
|
||||
include_once("../GameEngine/Artifacts.php");
|
||||
include_once("../GameEngine/Units.php");
|
||||
include_once("../GameEngine/Generator.php");
|
||||
|
||||
class funct
|
||||
{
|
||||
|
||||
@@ -28,7 +31,7 @@ class funct
|
||||
|
||||
function Act($get)
|
||||
{
|
||||
global $admin, $database;
|
||||
global $admin, $database, $units, $generator;
|
||||
|
||||
$artifact = new Artifacts();
|
||||
|
||||
@@ -71,8 +74,8 @@ class funct
|
||||
// add ban
|
||||
break;
|
||||
case "delOas":
|
||||
$database->query('UPDATE ' . TB_PREFIX . 'odata SET conqured = 0, owner = 2, name = "Unoccupied Oasis" WHERE wref = ' . $get['oid']);
|
||||
// oaza
|
||||
$units->returnTroops($get['did'], 1);
|
||||
$database->removeOases($get['oid']);
|
||||
break;
|
||||
case "logout":
|
||||
$this->LogOut();
|
||||
@@ -93,25 +96,30 @@ class funct
|
||||
$artifactInfo = $database->getArtefactDetails($_GET['artid'], $_GET['del']);
|
||||
|
||||
//Check if the artifact exists
|
||||
if(empty($artifactInfo) || $artifactInfo['owner'] == Artifacts::NATARS_UID) {
|
||||
if(empty($artifactInfo)) {
|
||||
header("location: admin.php");
|
||||
exit;
|
||||
}elseif($artifactInfo['owner'] == Artifacts::NATARS_UID){
|
||||
$database->updateArtifactDetails($_GET['artid'], ['del' => 0]);
|
||||
header("location: admin.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//Return the artifacts to the Natars' account
|
||||
$artifact->returnArtifactToNatars($artifactInfo);
|
||||
break;
|
||||
|
||||
case "addArtifacts":
|
||||
|
||||
$selectedArtifact = $_POST['selectedArtifact'];
|
||||
$artifactQuantity = $_POST['artifactQuantity'];
|
||||
$playerId = $_POST['playerId'];
|
||||
$artifactQuantity = (int)$_POST['artifactQuantity'];
|
||||
$playerId = (int)$_POST['playerId'];
|
||||
|
||||
//Check if the inputs are valid
|
||||
if(!isset($selectedArtifact) || !isset($artifactQuantity) || !isset($playerId) || empty($selectedArtifact) ||
|
||||
!is_numeric($artifactQuantity) || !is_numeric($playerId) || strpos($selectedArtifact, ':') === false ||
|
||||
$database->getUserField($playerId, "username", 0) == "[?]"){
|
||||
header("location: admin.php");
|
||||
!is_numeric($artifactQuantity) || $artifactQuantity <= 0 || $artifactQuantity > 999 || !is_numeric($playerId) ||
|
||||
strpos($selectedArtifact, ':') === false || $database->getUserField($playerId, "username", 0) == "[?]"){
|
||||
header("location: admin.php?p=natars&error=0");
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -125,7 +133,7 @@ class funct
|
||||
|
||||
//Check if the artifact has been found or if doesn't exist
|
||||
if(empty($chosenArtifact)){
|
||||
header("location: admin.php");
|
||||
header("location: admin.php?p=natars&error=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -134,9 +142,24 @@ class funct
|
||||
$artifactArrays[$selectedArtifact[2]][] = $chosenArtifact;
|
||||
|
||||
//Add the artifacts
|
||||
$artifact->addArtifactVillages($artifactArrays, $playerId);
|
||||
$artifact->addArtifactVillages($artifactArrays, $playerId, $playerId == Artifacts::NATARS_UID);
|
||||
break;
|
||||
|
||||
case "addWWVillages":
|
||||
|
||||
$numberOfVillages = (int)$_POST['numberOfVillages'];
|
||||
$playerId = (int)$_POST['playerId'];
|
||||
|
||||
//Check if the inserted values are valid
|
||||
if(!is_numeric($numberOfVillages) || $numberOfVillages <= 0 || $numberOfVillages > 999
|
||||
|| !is_numeric($playerId) || $database->getUserField($playerId, "username", 0) == "[?]"){
|
||||
header("location: admin.php?p=natars&error=2");
|
||||
}
|
||||
|
||||
//Create the desired WW villages
|
||||
$artifact->createWWVillages($numberOfVillages, $playerId, $playerId == Artifacts::NATARS_UID);
|
||||
break;
|
||||
|
||||
case "killHero":
|
||||
$varray = $database->getProfileVillages($get['uid']);
|
||||
$killhero = false;
|
||||
|
||||
Reference in New Issue
Block a user