Update addUsers.php

This commit is contained in:
Shadow
2014-03-25 08:28:27 +02:00
parent ee29c5bb7f
commit cae32d6603
+35 -13
View File
@@ -1,12 +1,12 @@
<?php
############################################################################
## Filename addUsers.php ##
## Created by: KFCSpike ##
## Contributors: KFCSpike ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2014. All rights reserved. ##
############################################################################
<?php
#########################################################
## Filename addUsers.php ##
## Created by: KFCSpike ##
## Contributors: KFCSpike ##
## Improve by: ronix ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2014. All rights reserved. ##
#########################################################
include_once("../../config.php");
include_once("../../Session.php");
@@ -14,6 +14,9 @@ include_once("../../Automation.php");
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysql_select_db(SQL_DB);
$wgarray=array(1=>1200,1700,2300,3100,4000,5000,6300,7800,9600,11800,14400,17600,21400,25900,31300,37900,45700,55100,66400,80000);
$id = $_POST['id'];
$baseName = $_POST['users_base_name'];
$amount = (int) $_POST['users_amount'];
@@ -83,7 +86,7 @@ else
if($uid)
{
/*
* @TODO
* [MENTION=6887]Tod[/MENTION]O
*
* Allow option to create (random) bigger villages,
* upgrade fields, granary, warehouse, wall etc
@@ -116,13 +119,32 @@ WHERE id = $uid") or die(mysql_error());
$database->updateUserField($uid,"act","",1);
$wid = $database->generateBase($kid,0);
$database->setFieldTaken($wid);
$database->addVillage($wid,$uid,$userName,1);
$database->addResourceFields($wid,$database->getVillageType($wid));
//calculate random generate value and level building
$rand_resource=rand(30000, 80000);
$level_storage=rand(10, 20);
$cap_storage=$wgarray[$level_storage]*(STORAGE_BASE/800);
$rand_resource=($rand_resource>$cap_storage)? $cap_storage:$rand_resource;
//insert village with all resource and building with random level
$time = time();
$q = "INSERT INTO ".TB_PREFIX."vdata (`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values ('$wid','$uid','".$userName."\'s village',1,200,1,0,0,$rand_resource,$rand_resource,$rand_resource,$cap_storage,$rand_resource,$cap_storage,$time,100,0,0,0,$time)";
mysql_query($q) or die(mysql_error());
$q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid ,".rand(5,10).",1,".rand(5,10).",4,".rand(5,10).",1,".rand(5,10).",3,".rand(5,10).",2,".rand(5,10).",2,".rand(5,10).",3,".rand(5,10).",4,".rand(5,10).",4,".rand(5,10).",3,".rand(5,10).",3,".rand(5,10).",4,".rand(5,10).",4,".rand(5,10).",1,".rand(5,10).",4,".rand(5,10).",2,".rand(5,10).",1,".rand(5,10).",2,".rand(2,5).",8,".rand(5,20).",37,".rand(10,20).",26,".rand(10,20).",22,".rand(10,20).",19,".rand(2,5).",9,$level_storage,11,".rand(10,20).",15,".rand(10,20).",20,0,0,".rand(10,15).",17,$level_storage,10,".rand(5,10).",12,0,0,10,23,0,0,0,0,0,0,0,0,".rand(5,10).",18,".rand(5,10).",16,0,0,0,0,'World Wonder')";
mysql_query($q);
$pop = $automation->recountPop($wid);
$cp = $automation->recountPop($wid);
$database->addUnits($wid);
$database->addTech($wid);
$database->addABTech($wid);
$database->updateUserField($uid,"access",USER,1);
//insert units randomly generate the number of troops
$q = "UPDATE " . TB_PREFIX . "units SET u".(($tribe-1)*10+1)." = ".rand(100, 2000).", u".(($tribe-1)*10+2)." = ".rand(100, 2400).", u".(($tribe-1)*10+3)." = ".rand(100, 1600).", u".(($tribe-1)*10+4)." = ".rand(100, 1500).", u".(($tribe-1)*10+5)." = " .rand(48, 1700).", u".(($tribe-1)*10+6)." = ".rand(60, 1800)." WHERE vref = '".$wid."'";
mysql_query($q);
$created ++;
}
else
{
@@ -132,4 +154,4 @@ WHERE id = $uid") or die(mysql_error());
}
header("Location: ../../../Admin/admin.php?p=addUsers&g=OK&bn=$baseName&am=$created&sk=$skipped&bp=$beginnersProtection&tr=$postTribe");
}
?>
?>