Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.86 KB | None | 0 0
  1. <?php
  2. include 'mysql.php';
  3.  
  4. session_start();
  5.  
  6. if(!isset($_SESSION['username']))
  7. {
  8. header("Location: index.php");
  9. exit();
  10. }
  11.  
  12. if(!userExists($_SESSION['username']))
  13. {
  14. session_destroy();
  15. header('Location: index.php');
  16. exit();
  17. }
  18.  
  19. function getDImage($domesticPolicy)
  20. {
  21. switch($domesticPolicy)
  22. {
  23. case "Urbanization":
  24. return "http://politicsandwar.com/img/icons/32/building.png";
  25. break;
  26.  
  27. case "Manifest Destiny":
  28. return "http://politicsandwar.com/img/icons/32/travel.png";
  29. break;
  30.  
  31. case "Open Markets":
  32. return "http://politicsandwar.com/img/icons/32/coins.png";
  33. break;
  34.  
  35. case "Technological Advancement":
  36. return "http://politicsandwar.com/img/icons/32/brain.png";
  37. break;
  38.  
  39. case "Imperialism":
  40. return "http://politicsandwar.com/img/icons/32/grenade.png";
  41. break;
  42.  
  43. default: return "http://politicsandwar.com/img/icons/32/building.png";
  44. }
  45. }
  46.  
  47. function getWImage($warPolicy)
  48. {
  49. switch($warPolicy)
  50. {
  51. case "Attrition":
  52. return "http://test.politicsandwar.com/img/icons/32/bomb.png";
  53. break;
  54.  
  55. case "Turtle":
  56. return "http://test.politicsandwar.com/img/icons/32/hard_hat_military.png";
  57. break;
  58.  
  59. case "Blitzkrieg":
  60. return "http://test.politicsandwar.com/img/icons/32/boxing_glove.png";
  61. break;
  62.  
  63. case "Fortress":
  64. return "http://test.politicsandwar.com/img/icons/stratocracy.png";
  65. break;
  66.  
  67. case "Moneybags":
  68. return "http://test.politicsandwar.com/img/icons/capitalist.png";
  69. break;
  70.  
  71. case "Pirate":
  72. return "http://test.politicsandwar.com/img/icons/32/pirate_flag.png";
  73. break;
  74.  
  75. case "Tactician":
  76. return "http://test.politicsandwar.com/img/icons/32/chess_tower.png";
  77. break;
  78.  
  79. case "Guardian":
  80. return "http://test.politicsandwar.com/img/icons/32/user_angel.png";
  81. break;
  82.  
  83. case "Covert":
  84. return "http://test.politicsandwar.com/img/icons/32/satellite_dish.png";
  85. break;
  86.  
  87. case "Arcane":
  88. return "http://test.politicsandwar.com/img/icons/32/script_text.png";
  89. break;
  90.  
  91. default: return "http://test.politicsandwar.com/img/icons/32/script_text.png";
  92. }
  93. }
  94.  
  95. $warnings = "";
  96. $warningCount = 0;
  97. ?>
  98.  
  99. <!DOCTYPE html>
  100. <html lang="en">
  101. <head>
  102. <title>OWR</title>
  103. <meta charset="utf-8">
  104. <meta name="viewport" content="width=device-width, initial-scale=1">
  105. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  106. <link rel="stylesheet" href="nation.css">
  107. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  108. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  109. </head>
  110. <body style="margin:0px; padding:0px;">
  111. <nav class="navbar navbar-default">
  112. <div class="container-fluid">
  113. <div class="navbar-header">
  114. <a class="navbar-brand" href="#">OWR Panel</a>
  115. </div>
  116. <ul class="nav navbar-nav">
  117. <li><a href="index.php">Home</a></li>
  118. <li><a href="table.php">All members</a></li>
  119. <li><a href="admin.php">Admin Panel</a></li>
  120. <li><a href="upgrade.php">City Purchase</a></li>
  121. </ul>
  122. </div>
  123. </nav>
  124. <div class="container">
  125. <?php
  126. $toSearch = htmlentities($_GET['name']);
  127. echo "<h2>The nation of {$toSearch}</h2>";
  128. ?>
  129. <INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;">
  130.  
  131. <?php
  132. $json = file_get_contents('cache/alliance.json');
  133. $data = json_decode($json);
  134. $cityCount = 0;
  135.  
  136. foreach($data as $nation)
  137. {
  138. if(strtoupper($nation->nation) == strtoupper($toSearch))
  139. {
  140. $nationID = $nation->nationid;
  141. $nationJSON = file_get_contents("http://politicsandwar.com/api/nation/id={$nationID}");
  142. $nationData = json_decode($nationJSON);
  143. $cityCount = $nation->cities;
  144.  
  145.  
  146. $dPolicy = $nationData->domestic_policy;
  147. $wPolicy = $nationData->war_policy;
  148. $commerceCanExceed100 = false;
  149. $inactive = false;
  150.  
  151. if($nation->inttradecenter == 1)
  152. {
  153. $commerceCanExceed100 = true;
  154. }
  155.  
  156. if($nationData->minutessinceactive >= 1440)
  157. {
  158. $warnings .= "<p style =\"font-weight: bold; color:red;\">[ACTIVITY] WARNING: This nation has been inactive for at least 24 hours!</p>";
  159. $warningCount++;
  160. $safe = false;
  161. }
  162.  
  163.  
  164. echo "
  165. <div id=\"header\">
  166. <p style=\"font-weight:bold; float: left; width: 33%; text-align: left;\">Domestic Policy: {$dPolicy} <img src=\"".getDImage($dPolicy)."\"></img></p>
  167. <p style=\"font-weight:bold; float: left; width: 33%; text-align: center;\">War Policy: {$wPolicy} <img src=\"".getWImage($wPolicy)."\"></img></p>
  168. <p style=\"font-weight:bold; float: left; width: 34%; text-align: right;\">Turns until next project: {$nationData->cityprojecttimerturns}</p>
  169. <br><br><br>
  170. <p style=\"font-weight:bold; float: left; width: 33%; text-align: left;\">City Count - {$nationData->cities}</p>
  171. <p style=\"font-weight:bold; float: left; width: 33%; text-align: Center;\"><a href=\"https://politicsandwar.com/nation/id={$nation->nationid}\">View Nation</a></p>
  172.  
  173. </div>";
  174.  
  175. echo "<table class=\"table\">
  176. <thead>
  177. <tr>
  178. <th>City Name</th>
  179. <th>City ID</th>
  180. <th>Infra</th>
  181. <th>Next 100 Infra</th>
  182. <th>Land</th>
  183. <th>Next 500 Land</th>
  184. </tr>
  185. </thead>
  186. <tbody>";
  187.  
  188.  
  189. foreach($nationData->cityids as $city)
  190. {
  191. $safe = true;
  192. $meetsMil = true;
  193. $meetsCom = true;
  194. $meetsac = true;
  195.  
  196. $json = file_get_contents('cache/alliance.json');
  197. $data = json_decode($json);
  198.  
  199. $cityJSON = file_get_contents("http://politicsandwar.com/api/city/id={$city}");
  200. $cityData = json_decode($cityJSON);
  201.  
  202.  
  203. $cityName = $cityData->name;
  204. $nextInfraCost = number_format((float)pow(($cityData->infrastructure - 10), 1.95) + 300, 2, '.', ',');
  205. $nextLandCost = number_format((float)pow(($cityData->land - 20), 2) + 50, 2, '.', ',');
  206. $cityCount = $nation->cities;
  207. $cityData->cities = $nation->cities;
  208.  
  209.  
  210. echo "
  211. <tr>
  212. <td>{$cityName}</td>
  213. <td><a href=\"https://politicsandwar.com/city/id=".$cityData->cityid."\" target=\"_blank\">{$cityData->cityid}</a></td>
  214. <td>{$cityData->infrastructure}</td>
  215. <td>$$nextInfraCost</td>
  216. <td>{$cityData->land}</td>
  217. <td>$$nextLandCost</td>
  218. </tr>
  219. ";
  220.  
  221. $cityPop = $cityData->population;
  222.  
  223. if($cityData->infrastructure > $cityData->land)
  224. {
  225. $warnings .= "<p style =\"font-weight: bold; color:purple;\">[STATS] WARNING: The city of {$cityName} has more infrastructure than land!</p>";
  226. $warningCount++;
  227. $safe = false;
  228. }
  229. if($cityData->crime >= 1)
  230. {
  231. $warnings .= "<p style =\"font-weight: bold; color:purple;\">[STATS] WARNING: The city of {$cityName} has a crime rate of ".substr($cityData->crime, 0, 4)."%! It has {$cityData->imp_policestation} Police Stations.</p>";
  232. $warningCount++;
  233. $safe = false;
  234. }
  235. if($cityData->disease >= 1)
  236. {
  237. $warnings .= "<p style =\"font-weight: bold; color:purple;\">[STATS] WARNING: The city of {$cityName} has a disease rate of ".substr($cityData->disease, 0, 4)."%! It has {$cityData->imp_hospital} Hospitals and {$cityData->pollution} Pollution.</p>";
  238. $warningCount++;
  239. $safe = false;
  240. }
  241.  
  242. // 1000 Infra audit
  243. if($cityData->infrastructure >= 1000 && $cityData->infrastructure < 1200)
  244. {
  245. // 1000 Commerce audit
  246. if($cityData->imp_bank < 4 || $cityData->imp_mall < 4 || $cityData->imp_stadium < 2)
  247. {
  248. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has incorrect commerce build! It has {$cityData->imp_bank} banks, {$cityData->imp_mall} malls, and {$cityData->imp_stadium} stadiums. 4/4/2 is the correct build</p>";
  249. $warningCount++;
  250. $safe = false;
  251. }
  252.  
  253. // 1000 Civil audit
  254. if($cityData->imp_hospital < 1 || $cityData->imp_policestation < 1 || $cityData->inttradecenter = 0)
  255. {
  256. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has incorrect civil build! It has {$cityData->imp_hospital} Hospitals and {$cityData->imp_policestation} Police Stations. It should have 1 of each</p>";
  257. $warningCount++;
  258. $safe = false;
  259. }
  260. }
  261.  
  262. if($cityData->commerce < 100 && $cityData->infrastructure >= 1200)
  263. {
  264. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has 1200+ infra, but doesn't have 100% commerce!</p>";
  265. $warningCount++;
  266. $safe = false;
  267. }
  268. if($cityData->infrastructure >= 1200)
  269. {
  270. if($cityData->imp_bank < 4 || $cityData->imp_mall < 4 || $cityData->imp_stadium < 3 || $cityData->imp_subway < 1)
  271. {
  272. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has incorrect commerce build! It has {$cityData->imp_bank} banks, {$cityData->imp_mall} malls, {$cityData->imp_stadium} stadiums, and {$cityData->imp_subway} subways.</p>";
  273. $warningCount++;
  274. $safe = false;
  275. }
  276.  
  277. if($cityData->imp_hospital < 1 || $cityData->imp_policestation < 1)
  278. {
  279. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has incorrect civil build! It has {$cityData->imp_hospital} Hospitals and {$cityData->imp_policestation} Police Stations. It should have 1 of each</p>";
  280. $warningCount++;
  281. $safe = false;
  282. }
  283. }
  284. if($cityData->imp_supermarket > 0)
  285. {
  286. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has {$cityData->imp_supermarket} supermarkets!</p>";
  287. $warningCount++;
  288. $safe = false;
  289. }
  290. if($cityData->imp_farm > 0 && $cityData->land < 2000)
  291. {
  292. $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has {$cityData->imp_farm} farms, but less than 2000 land!</p>";
  293. $warningCount++;
  294. $safe = false;
  295. }
  296.  
  297. // Military at less than 9 cities
  298. if($nationData->cities < 9)
  299. {
  300. if($cityData->imp_barracks < 10 && $cityData->imp_hangar < 10 && $cityData->imp_drydock < 1 && $cityData->factory < 10)
  301. {
  302. $warnings .= "<p style =\"font-weight: bold; color:red;\">[MILITARY] WARNING: The city of {$cityName} does not meet military requirements for a $cityCount city nation nation. It only has {$cityData->imp_barracks} barracks, {$cityData->imp_factory} factories, {$cityData->imp_hangar} hangars, and {$cityData->imp_drydock} drydocks. It should have 2/1/1/1.</p>";
  303. $warningCount++;
  304. $safe = false;
  305. $meetsMil = false;
  306. }
  307. }
  308. // (+ cities)
  309. if($nationData->cities > 8)
  310. {
  311. if($cityData->imp_barracks < 50 && $cityData->imp_hangar < 3 && $cityData->imp_drydock < 1 && $cityData->factory < 2)
  312. {
  313. $warnings .= "<p style =\"font-weight: bold; color:red;\">[MILITARY] WARNING: The city of {$cityName} does not meet military requirements for a $cityCount city nation nation. It only has {$cityData->imp_barracks} barracks, {$cityData->imp_factory} factories, {$cityData->imp_hangar} hangars, and {$cityData->imp_drydock} drydocks. It should have 0/1/3/1.</p>";
  314. $warningCount++;
  315. $safe = false;
  316. $meetsMil = false;
  317. }
  318. }
  319.  
  320. if($safe == true)
  321. {
  322. $warnings .= "<p style =\"font-weight: bold; color:green;\">{$cityName} looks good! No warnings to show. I'd let my kids live here.</p>";
  323. }
  324.  
  325. }
  326. }
  327. }
  328. ?>
  329.  
  330. </tbody>
  331. </table>
  332. <?php echo "<pre>{$warnings}<p style =\"font-weight: bold; color:red;\">Overall, this nation has {$warningCount} warnings.</p></pre><br />"; ?>
  333. </div>
  334. </body>
  335. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement