Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'mysql.php';
- session_start();
- if(!isset($_SESSION['username']))
- {
- header("Location: index.php");
- exit();
- }
- if(!userExists($_SESSION['username']))
- {
- session_destroy();
- header('Location: index.php');
- exit();
- }
- function getDImage($domesticPolicy)
- {
- switch($domesticPolicy)
- {
- case "Urbanization":
- return "http://politicsandwar.com/img/icons/32/building.png";
- break;
- case "Manifest Destiny":
- return "http://politicsandwar.com/img/icons/32/travel.png";
- break;
- case "Open Markets":
- return "http://politicsandwar.com/img/icons/32/coins.png";
- break;
- case "Technological Advancement":
- return "http://politicsandwar.com/img/icons/32/brain.png";
- break;
- case "Imperialism":
- return "http://politicsandwar.com/img/icons/32/grenade.png";
- break;
- default: return "http://politicsandwar.com/img/icons/32/building.png";
- }
- }
- function getWImage($warPolicy)
- {
- switch($warPolicy)
- {
- case "Attrition":
- return "http://test.politicsandwar.com/img/icons/32/bomb.png";
- break;
- case "Turtle":
- return "http://test.politicsandwar.com/img/icons/32/hard_hat_military.png";
- break;
- case "Blitzkrieg":
- return "http://test.politicsandwar.com/img/icons/32/boxing_glove.png";
- break;
- case "Fortress":
- return "http://test.politicsandwar.com/img/icons/stratocracy.png";
- break;
- case "Moneybags":
- return "http://test.politicsandwar.com/img/icons/capitalist.png";
- break;
- case "Pirate":
- return "http://test.politicsandwar.com/img/icons/32/pirate_flag.png";
- break;
- case "Tactician":
- return "http://test.politicsandwar.com/img/icons/32/chess_tower.png";
- break;
- case "Guardian":
- return "http://test.politicsandwar.com/img/icons/32/user_angel.png";
- break;
- case "Covert":
- return "http://test.politicsandwar.com/img/icons/32/satellite_dish.png";
- break;
- case "Arcane":
- return "http://test.politicsandwar.com/img/icons/32/script_text.png";
- break;
- default: return "http://test.politicsandwar.com/img/icons/32/script_text.png";
- }
- }
- $warnings = "";
- $warningCount = 0;
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>OWR</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <link rel="stylesheet" href="nation.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </head>
- <body style="margin:0px; padding:0px;">
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <div class="navbar-header">
- <a class="navbar-brand" href="#">OWR Panel</a>
- </div>
- <ul class="nav navbar-nav">
- <li><a href="index.php">Home</a></li>
- <li><a href="table.php">All members</a></li>
- <li><a href="admin.php">Admin Panel</a></li>
- <li><a href="upgrade.php">City Purchase</a></li>
- </ul>
- </div>
- </nav>
- <div class="container">
- <?php
- $toSearch = htmlentities($_GET['name']);
- echo "<h2>The nation of {$toSearch}</h2>";
- ?>
- <INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;">
- <?php
- $json = file_get_contents('cache/alliance.json');
- $data = json_decode($json);
- $cityCount = 0;
- foreach($data as $nation)
- {
- if(strtoupper($nation->nation) == strtoupper($toSearch))
- {
- $nationID = $nation->nationid;
- $nationJSON = file_get_contents("http://politicsandwar.com/api/nation/id={$nationID}");
- $nationData = json_decode($nationJSON);
- $cityCount = $nation->cities;
- $dPolicy = $nationData->domestic_policy;
- $wPolicy = $nationData->war_policy;
- $commerceCanExceed100 = false;
- $inactive = false;
- if($nation->inttradecenter == 1)
- {
- $commerceCanExceed100 = true;
- }
- if($nationData->minutessinceactive >= 1440)
- {
- $warnings .= "<p style =\"font-weight: bold; color:red;\">[ACTIVITY] WARNING: This nation has been inactive for at least 24 hours!</p>";
- $warningCount++;
- $safe = false;
- }
- echo "
- <div id=\"header\">
- <p style=\"font-weight:bold; float: left; width: 33%; text-align: left;\">Domestic Policy: {$dPolicy} <img src=\"".getDImage($dPolicy)."\"></img></p>
- <p style=\"font-weight:bold; float: left; width: 33%; text-align: center;\">War Policy: {$wPolicy} <img src=\"".getWImage($wPolicy)."\"></img></p>
- <p style=\"font-weight:bold; float: left; width: 34%; text-align: right;\">Turns until next project: {$nationData->cityprojecttimerturns}</p>
- <br><br><br>
- <p style=\"font-weight:bold; float: left; width: 33%; text-align: left;\">City Count - {$nationData->cities}</p>
- <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>
- </div>";
- echo "<table class=\"table\">
- <thead>
- <tr>
- <th>City Name</th>
- <th>City ID</th>
- <th>Infra</th>
- <th>Next 100 Infra</th>
- <th>Land</th>
- <th>Next 500 Land</th>
- </tr>
- </thead>
- <tbody>";
- foreach($nationData->cityids as $city)
- {
- $safe = true;
- $meetsMil = true;
- $meetsCom = true;
- $meetsac = true;
- $json = file_get_contents('cache/alliance.json');
- $data = json_decode($json);
- $cityJSON = file_get_contents("http://politicsandwar.com/api/city/id={$city}");
- $cityData = json_decode($cityJSON);
- $cityName = $cityData->name;
- $nextInfraCost = number_format((float)pow(($cityData->infrastructure - 10), 1.95) + 300, 2, '.', ',');
- $nextLandCost = number_format((float)pow(($cityData->land - 20), 2) + 50, 2, '.', ',');
- $cityCount = $nation->cities;
- $cityData->cities = $nation->cities;
- echo "
- <tr>
- <td>{$cityName}</td>
- <td><a href=\"https://politicsandwar.com/city/id=".$cityData->cityid."\" target=\"_blank\">{$cityData->cityid}</a></td>
- <td>{$cityData->infrastructure}</td>
- <td>$$nextInfraCost</td>
- <td>{$cityData->land}</td>
- <td>$$nextLandCost</td>
- </tr>
- ";
- $cityPop = $cityData->population;
- if($cityData->infrastructure > $cityData->land)
- {
- $warnings .= "<p style =\"font-weight: bold; color:purple;\">[STATS] WARNING: The city of {$cityName} has more infrastructure than land!</p>";
- $warningCount++;
- $safe = false;
- }
- if($cityData->crime >= 1)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- if($cityData->disease >= 1)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- // 1000 Infra audit
- if($cityData->infrastructure >= 1000 && $cityData->infrastructure < 1200)
- {
- // 1000 Commerce audit
- if($cityData->imp_bank < 4 || $cityData->imp_mall < 4 || $cityData->imp_stadium < 2)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- // 1000 Civil audit
- if($cityData->imp_hospital < 1 || $cityData->imp_policestation < 1 || $cityData->inttradecenter = 0)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- }
- if($cityData->commerce < 100 && $cityData->infrastructure >= 1200)
- {
- $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has 1200+ infra, but doesn't have 100% commerce!</p>";
- $warningCount++;
- $safe = false;
- }
- if($cityData->infrastructure >= 1200)
- {
- if($cityData->imp_bank < 4 || $cityData->imp_mall < 4 || $cityData->imp_stadium < 3 || $cityData->imp_subway < 1)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- if($cityData->imp_hospital < 1 || $cityData->imp_policestation < 1)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- }
- if($cityData->imp_supermarket > 0)
- {
- $warnings .= "<p style =\"font-weight: bold; color:blue;\">[IMPROVEMENTS] WARNING: The city of {$cityName} has {$cityData->imp_supermarket} supermarkets!</p>";
- $warningCount++;
- $safe = false;
- }
- if($cityData->imp_farm > 0 && $cityData->land < 2000)
- {
- $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>";
- $warningCount++;
- $safe = false;
- }
- // Military at less than 9 cities
- if($nationData->cities < 9)
- {
- if($cityData->imp_barracks < 10 && $cityData->imp_hangar < 10 && $cityData->imp_drydock < 1 && $cityData->factory < 10)
- {
- $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>";
- $warningCount++;
- $safe = false;
- $meetsMil = false;
- }
- }
- // (+ cities)
- if($nationData->cities > 8)
- {
- if($cityData->imp_barracks < 50 && $cityData->imp_hangar < 3 && $cityData->imp_drydock < 1 && $cityData->factory < 2)
- {
- $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>";
- $warningCount++;
- $safe = false;
- $meetsMil = false;
- }
- }
- if($safe == true)
- {
- $warnings .= "<p style =\"font-weight: bold; color:green;\">{$cityName} looks good! No warnings to show. I'd let my kids live here.</p>";
- }
- }
- }
- }
- ?>
- </tbody>
- </table>
- <?php echo "<pre>{$warnings}<p style =\"font-weight: bold; color:red;\">Overall, this nation has {$warningCount} warnings.</p></pre><br />"; ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement