PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/create_account.php

https://bitbucket.org/Dzoki/travianx
PHP | 371 lines | 265 code | 62 blank | 44 comment | 35 complexity | 35057146d8f59e30849e1896080b0b42 MD5 | raw file
  1. <?php
  2. /** --------------------------------------------------- **\
  3. | ********* DO NOT REMOVE THIS COPYRIGHT NOTICE ********* |
  4. +---------------------------------------------------------+
  5. | Credits: All the developers including the leaders: |
  6. | Advocaite & Dzoki & Donnchadh |
  7. | |
  8. | Copyright: TravianX Project All rights reserved |
  9. \** --------------------------------------------------- **/
  10. include_once ("GameEngine/Session.php");
  11. include_once ("GameEngine/config.php");
  12. mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
  13. mysql_select_db(SQL_DB);
  14. /**
  15. * If user is not administrator, access is denied!
  16. */
  17. if($session->access < ADMIN)
  18. die("Access Denied: You are not Admin!");
  19. /**
  20. * Functions
  21. */
  22. function generateBase($kid, $uid, $username) {
  23. global $database, $message;
  24. if($kid == 0) {
  25. $kid = rand(1, 4);
  26. } else {
  27. $kid = $_POST['kid'];
  28. }
  29. $wid = $database->generateBase($kid);
  30. $database->setFieldTaken($wid);
  31. $database->addVillage($wid, $uid, $username, 1);
  32. $database->addResourceFields($wid, $database->getVillageType($wid));
  33. $database->addUnits($wid);
  34. $database->addTech($wid);
  35. $database->addABTech($wid);
  36. $database->updateUserField($uid, "access", USER, 1);
  37. $message->sendWelcome($uid, $username);
  38. }
  39. /**
  40. * Creating account & capital village
  41. */
  42. $username = "Natars";
  43. $password = md5('013ab00e4' . rand(999999999999, 9999999999999999999999999) . 'f248588ed');
  44. $email = "natars@travianx.com";
  45. $tribe = 5;
  46. $desc = "********************
  47. [#natars]
  48. ********************";
  49. $q = "INSERT INTO " . TB_PREFIX . "users (id,username,password,access,email,timestamp,tribe,location,act,protect) VALUES (3, '$username', '$password', " . USER . ", '$email', ".time().", $tribe, '', '', 0)";
  50. mysql_query($q);
  51. unset($q);
  52. $uid = $database->getUserField($username, 'id', 1);
  53. generateBase(0, $uid, $username);
  54. $wid = mysql_fetch_assoc(mysql_query("SELECT * FROM " . TB_PREFIX . "vdata WHERE owner = $uid"));
  55. $q = "UPDATE " . TB_PREFIX . "vdata SET pop = 834 WHERE owner = $uid";
  56. mysql_query($q) or die(mysql_error());
  57. $q2 = "UPDATE " . TB_PREFIX . "users SET access = 0 WHERE id = $uid";
  58. mysql_query($q2) or die(mysql_error());
  59. if(SPEED > 3) {
  60. $speed = 5;
  61. } else {
  62. $speed = SPEED;
  63. }
  64. $q3 = "UPDATE " . TB_PREFIX . "units SET u41 = " . (64700 * $speed) . ", u42 = " . (295231 * $speed) . ", u43 = " . (180747 * $speed) . ", u44 = " . (7 * $speed) . ", u45 = " . (364401 * $speed) . ", u46 = " . (217602 * $speed) . ", u47 = " . (2034 * $speed) . ", u48 = " . (1040 * $speed) . " , u49 = " . (1 * $speed) . ", u50 = " . (9 * $speed) . " WHERE vref = " . $wid['wref'] . "";
  65. mysql_query($q3) or die(mysql_error());
  66. $q4 = "UPDATE " . TB_PREFIX . "users SET desc2 = '$desc' WHERE id = $uid";
  67. mysql_query($q4) or die(mysql_error());
  68. /**
  69. * SMALL ARTEFACTS
  70. */
  71. function Artefact($uid, $type, $size, $art_name, $village_name, $desc, $effect, $img) {
  72. global $database;
  73. $kid = rand(1, 4);
  74. $wid = $database->generateBase($kid);
  75. $database->addArtefact($wid, $uid, $type, $size, $art_name, $desc, $effect, $img);
  76. $database->setFieldTaken($wid);
  77. $database->addVillage($wid, $uid, $village_name, '0');
  78. $database->addResourceFields($wid, $database->getVillageType($wid));
  79. $database->addUnits($wid);
  80. $database->addTech($wid);
  81. $database->addABTech($wid);
  82. mysql_query("UPDATE " . TB_PREFIX . "vdata SET pop = 163 WHERE wref = $wid");
  83. mysql_query("UPDATE " . TB_PREFIX . "vdata SET name = '$village_name' WHERE wref = $wid");
  84. if(SPEED > 3) {
  85. $speed = 5;
  86. } else {
  87. $speed = SPEED;
  88. }
  89. if($size == 1) {
  90. mysql_query("UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(1000, 2000) * $speed) . ", u42 = " . (rand(1500, 2000) * $speed) . ", u43 = " . (rand(2300, 2800) * $speed) . ", u44 = " . (rand(25, 75) * $speed) . ", u45 = " . (rand(1200, 1900) * $speed) . ", u46 = " . (rand(1500, 2000) * $speed) . ", u47 = " . (rand(500, 900) * $speed) . ", u48 = " . (rand(100, 300) * $speed) . " , u49 = " . (rand(1, 5) * $speed) . ", u50 = " . (rand(1, 5) * $speed) . " WHERE vref = " . $wid . "");
  91. mysql_query("UPDATE " . TB_PREFIX . "fdata SET f22t = 27, f22 = 10, f28t = 25, f28 = 10, f19t = 23, f19 = 10, f32t = 23, f32 = 10 WHERE vref = $wid");
  92. } elseif($size == 2) {
  93. mysql_query("UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(2000, 4000) * $speed) . ", u42 = " . (rand(3000, 4000) * $speed) . ", u43 = " . (rand(4600, 5600) * $speed) . ", u44 = " . (rand(50, 150) * $speed) . ", u45 = " . (rand(2400, 3800) * $speed) . ", u46 = " . (rand(3000, 4000) * $speed) . ", u47 = " . (rand(1000, 1800) * $speed) . ", u48 = " . (rand(200, 600) * $speed) . " , u49 = " . (rand(2, 10) * $speed) . ", u50 = " . (rand(2, 10) * $speed) . " WHERE vref = " . $wid . "");
  94. mysql_query("UPDATE " . TB_PREFIX . "fdata SET f22t = 27, f22 = 10, f28t = 25, f28 = 20, f19t = 23, f19 = 10, f32t = 23, f32 = 10 WHERE vref = $wid");
  95. } elseif($size == 3) {
  96. mysql_query("UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(4000, 8000) * $speed) . ", u42 = " . (rand(6000, 8000) * $speed) . ", u43 = " . (rand(9200, 11200) * $speed) . ", u44 = " . (rand(100, 300) * $speed) . ", u45 = " . (rand(4800, 7600) * $speed) . ", u46 = " . (rand(6000, 8000) * $speed) . ", u47 = " . (rand(2000, 3600) * $speed) . ", u48 = " . (rand(400, 1200) * $speed) . " , u49 = " . (rand(4, 20) * $speed) . ", u50 = " . (rand(4, 20) * $speed) . " WHERE vref = " . $wid . "");
  97. mysql_query("UPDATE " . TB_PREFIX . "fdata SET f22t = 27, f22 = 10, f28t = 25, f28 = 20, f19t = 23, f19 = 10, f32t = 23, f32 = 10 WHERE vref = $wid");
  98. }
  99. }
  100. /**
  101. * THE ARCHITECTS
  102. */
  103. $desc = 'All buildings in the area of effect are stronger. This means that you will need more catapults to damage buildings protected by this artifacts powers.';
  104. $vname = 'Diamond Chisel';
  105. $effect = '(4x)';
  106. for($i > 1; $i < 6; $i++) {
  107. Artefact($uid, 1, 1, 'The architects slight secret', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type1.gif');
  108. }
  109. unset($i);
  110. unset($vname);
  111. unset($effect);
  112. $vname = 'Giant Marble Hammer';
  113. $effect = '(3x)';
  114. for($i > 1; $i < 4; $i++) {
  115. Artefact($uid, 1, 2, 'The architects great secret', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type1.gif');
  116. }
  117. unset($i);
  118. unset($vname);
  119. unset($effect);
  120. $vname = 'Hemons Scrolls';
  121. $effect = '(5x)';
  122. for($i > 1; $i < 1; $i++) {
  123. Artefact($uid, 1, 3, 'The architects unique secret', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type1.gif');
  124. }
  125. /**
  126. * MILITARY HASTE
  127. */
  128. $desc = 'All troops in the area of effect move faster.';
  129. unset($i);
  130. unset($vname);
  131. unset($effect);
  132. $vname = 'Opal Horseshoe';
  133. $effect = '(2x)';
  134. for($i > 1; $i < 6; $i++) {
  135. Artefact($uid, 2, 1, 'The slight titan boots', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type2.gif');
  136. }
  137. unset($i);
  138. unset($vname);
  139. unset($effect);
  140. $vname = 'Golden Chariot';
  141. $effect = '(1.5x)';
  142. for($i > 1; $i < 4; $i++) {
  143. Artefact($uid, 2, 2, 'The great titan boots', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type2.gif');
  144. }
  145. unset($i);
  146. unset($vname);
  147. unset($effect);
  148. $vname = 'Pheidippides Sandals';
  149. $effect = '(3x)';
  150. for($i > 1; $i < 1; $i++) {
  151. Artefact($uid, 2, 3, 'The unique titan boots', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type2.gif');
  152. }
  153. /**
  154. * HAWK'S EYESIGHT
  155. */
  156. $desc = 'All spies (Scouts, Pathfinders, and Equites Legati) increase their spying ability. In addition, with all versions of this artifact you can see the incoming TYPE of troops but not how many there are.';
  157. unset($i);
  158. unset($vname);
  159. unset($effect);
  160. $vname = 'Tale of a Rat';
  161. $effect = '(5x)';
  162. for($i > 1; $i < 6; $i++) {
  163. Artefact($uid, 3, 1, 'The eagles slight eyes', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type3.gif');
  164. }
  165. unset($i);
  166. unset($vname);
  167. unset($effect);
  168. $vname = 'Generals Letter';
  169. $effect = '(3x)';
  170. for($i > 1; $i < 4; $i++) {
  171. Artefact($uid, 3, 2, 'The eagles great eyes', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type3.gif');
  172. }
  173. unset($i);
  174. unset($vname);
  175. unset($effect);
  176. $vname = 'Diary of Sun Tzu';
  177. $effect = '(10x)';
  178. for($i > 1; $i < 1; $i++) {
  179. Artefact($uid, 3, 3, 'The eagles unique eyes', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type3.gif');
  180. }
  181. /**
  182. * THE DIET
  183. */
  184. $desc = 'All troops in the artifacts range consume less wheat, making it possible to maintain a larger army.';
  185. unset($i);
  186. unset($vname);
  187. unset($effect);
  188. $vname = 'Silver Platter';
  189. $effect = '(50%)';
  190. for($i > 1; $i < 6; $i++) {
  191. Artefact($uid, 4, 1, 'Slight diet control', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type4.gif');
  192. }
  193. unset($i);
  194. unset($vname);
  195. unset($effect);
  196. $vname = 'Sacred Hunting Bow';
  197. $effect = '(25%)';
  198. for($i > 1; $i < 4; $i++) {
  199. Artefact($uid, 4, 2, 'Great diet control', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type4.gif');
  200. }
  201. unset($i);
  202. unset($vname);
  203. unset($effect);
  204. $vname = 'King Arthurs Chalice';
  205. $effect = '(50%)';
  206. for($i > 1; $i < 1; $i++) {
  207. Artefact($uid, 4, 3, 'Unique diet control', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type4.gif');
  208. }
  209. /**
  210. * ACADEMIC ADVANCEMENT
  211. */
  212. $desc = 'Troops are built a certain percentage faster within the scope of the artifact.';
  213. unset($i);
  214. unset($vname);
  215. unset($effect);
  216. $vname = 'Scribed Soldiers Oath';
  217. $effect = '(50%)';
  218. for($i > 1; $i < 6; $i++) {
  219. Artefact($uid, 5, 1, 'The trainers slight talent', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type5.gif');
  220. }
  221. unset($i);
  222. unset($vname);
  223. unset($effect);
  224. $vname = 'Declaration of War';
  225. $effect = '(25%)';
  226. for($i > 1; $i < 4; $i++) {
  227. Artefact($uid, 5, 2, 'The trainers great talent', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type5.gif');
  228. }
  229. unset($i);
  230. unset($vname);
  231. unset($effect);
  232. $vname = 'Memoirs of Alexander the Great';
  233. $effect = '(50%)';
  234. for($i > 1; $i < 1; $i++) {
  235. Artefact($uid, 5, 3, 'The trainers unique talent', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type5.gif');
  236. }
  237. /**
  238. * STORAGE MASTER PLAN
  239. */
  240. $desc = 'With this building plan you are able to build the Great Granary or Great Warehouse in the Village with the artifact, or the whole account depending on the artifact. As long as you posses that artifact you are able to build and enlarge those buildings.';
  241. unset($i);
  242. unset($vname);
  243. unset($effect);;
  244. $vname = 'Builders Sketch';
  245. $effect = '';
  246. for($i > 1; $i < 6; $i++) {
  247. Artefact($uid, 6, 1, 'Slight storage masterplan', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type6.gif');
  248. }
  249. unset($i);
  250. unset($vname);
  251. unset($effect);
  252. $vname = 'Babylonian Tablet';
  253. $effect = '';
  254. for($i > 1; $i < 4; $i++) {
  255. Artefact($uid, 6, 2, 'Great storage masterplan', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type6.gif');
  256. }
  257. /**
  258. * RIVAL'S CONFUSION
  259. */
  260. $desc = 'Cranny capacity is increased by a certain amount for each type of artifact. Catapults can only shoot random on villages within this artifacts power. Exceptions are the WW which can always be targeted and the treasure chamber which can always be targeted, except with the unique artifact. When aiming at a resource field only random resource fields can be hit, when aiming at a building only random buildings can be hit.';
  261. unset($i);
  262. unset($vname);
  263. unset($effect);
  264. $vname = 'Map of the Hidden Caverns';
  265. $effect = '(200)';
  266. for($i > 1; $i < 6; $i++) {
  267. Artefact($uid, 7, 1, 'Rivals slight confusion', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type7.gif');
  268. }
  269. unset($i);
  270. unset($vname);
  271. unset($effect);
  272. $vname = 'Bottomless Satchel';
  273. $effect = '(100)';
  274. for($i > 1; $i < 4; $i++) {
  275. Artefact($uid, 7, 2, 'Rivals great confusion', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type7.gif');
  276. }
  277. unset($i);
  278. unset($vname);
  279. unset($effect);
  280. $vname = 'Trojan Horse';
  281. $effect = '(500)';
  282. for($i > 1; $i < 1; $i++) {
  283. Artefact($uid, 7, 3, 'Rivals unique confusion', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type7.gif');
  284. }
  285. /**
  286. * ARTEFACT OF THE FOOL
  287. */
  288. $desc = 'Every 24 hours it gets a random effect, bonus, or penalty (all are possible with the exception of great warehouse, great granary and WW building plans). They change effect AND scope every 24 hours. The unique artifact will always take positive bonuses.';
  289. unset($i);
  290. unset($vname);
  291. unset($effect);
  292. $vname = 'Pendant of Mischief';
  293. for($i > 1; $i < 5; $i++) {
  294. Artefact($uid, 8, 1, 'Artefact of the slight fool', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type8.gif');
  295. }
  296. unset($i);
  297. unset($vname);
  298. unset($effect);
  299. $vname = 'Pendant of Mischief';
  300. for($i > 1; $i < 5; $i++) {
  301. Artefact($uid, 8, 2, 'Artefact of the slight fool', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type8.gif');
  302. }
  303. unset($i);
  304. unset($vname);
  305. unset($effect);
  306. $vname = 'Forbidden Manuscript';
  307. for($i > 1; $i < 1; $i++) {
  308. Artefact($uid, 8, 3, 'Artefact of the unique fool', '' . $vname . '', '' . $desc . '', '' . $effect . '', 'type8.gif');
  309. }