Nationstates GDP Calculator\n

Please add ?nation=(your nation name) to the url to get it to work properly (Remember, spaces should become \"%20\", HTML-encoded).

Other options:
&popspec=(the difference of your \"population\" from Nationstates) - For those countries who like to specify exact populations
&randomize=1 - Randomizes the GDP per capita and budget (and population if there's no popspec) slightly
&defenseprovided=1&defense=(percentage of your GDP spent on defense) - Calculates your Defense spending. REQUIRES DEFENSEPROVIDED TO BE SET.
&militarybudget=1 - Forces &defense= to represent the percentage of your budget instead of your GDP. MUST BE USED WITH THE TWO ABOVE VARIABLES.

"; } else { srand((double) microtime() * 1000000); $nation = str_replace(" ", "%20", $nation); $filename = "http://www.nationstates.net/cgi-bin/nationdata.cgi/nation=" . $nation; $size = "800"; $fp = fopen($filename, 'r'); $text = fread($fp, $size); fclose($fp); $name = str_replace("", "", substr($text, strpos($text, ""), (strpos($text, "") - strpos($text, "")))); $population = str_replace("", "", substr($text, strpos($text, ""), (strpos($text, "") - strpos($text, "")))) * 1000000; $economy = str_replace("", "", substr($text, strpos($text, ""), (strpos($text, "") - strpos($text, "")))); $civilrights = str_replace("", "", substr($text, strpos($text, ""), (strpos($text, "") - strpos($text, "")))); // Old GDP per Capita Ratings // $gdppercap = array("Imploded" => 100, "Basket Case" => 500, "Fragile" => 1000, "Weak" => 2000, "Struggling" => 3000, "Developing" => 4000, "Reasonable" => 5000, "Good" => 10000, "Strong" => 15000, "Very Strong" => 20000, "Thriving" => 25000, "Powerhouse" => 30000, "All Consuming" => 35000, "Frightening" => 40000); $gdppercap = array("Imploded" => 100, "Basket Case" => 500, "Fragile" => 1000, "Weak" => 2000, "Struggling" => 3000, "Developing" => 4000, "Reasonable" => 5000, "Good" => 7500, "Strong" => 10000, "Very Strong" => 15000, "Thriving" => 20000, "Powerhouse" => 25000, "All-Consuming" => 30000, "Frightening" => 35000); $budgetmultiplier = array("Frightening" => 1.5, "Excessive" => 1.44, "World Benchmark" => 1.38, "Superb" => 1.32, "Excellent" => 1.25, "Very Good" => 1.18, "Good" => 1.11, "Average" => 1.03, "Below Average" => 0.95, "Some" => 0.87, "Few" => 0.78, "Rare" => 0.69, "Unheard Of" => 0.60, "Outlawed" => 0.5); if($randomize == 1) { foreach($gdppercap as $econtype => $blingbling) { $gdppercap[$econtype] = $blingbling + rand(-500, 499); while($gdppercap[$econtype] <= 0) $gdppercap[$econtype] = $blingbling + rand(-500, 499); } if($popspec) $population += $popspec; if(!$popspec) $population += rand(-500000, 499999); } $gdp = $gdppercap[$economy] * $population; $budget = round(((1E-5 * pow($gdppercap[$economy], 2) + 0.1036 * $gdppercap[$economy]) * $budgetmultiplier[$civilrights]) * $population); if($randomize == 1) $budget += rand(-500000, 499999); echo "

$name Gross Domestic Product

\n

Population: " . number_format($population) . "
Civil Rights: $civilrights
Economy: $economy
GDP per Capita: $" . number_format($gdppercap[$economy]) . "
GDP: \$" . number_format($gdp) . "
National Budget: \$" . number_format($budget); if($defenseprovided) { if($militarybudget) { $military = round($budget * ($defense / 100)); $gdppercent = round($military / $gdp * 100, 2); echo "

\nPercentage of GDP Spent on Defense: $gdppercent%
Percentage of Budget Spent on Defense: $defense%
"; } else { $military = round($gdp * ($defense / 100)); $budgetpercent = round($military / $budget * 100, 2); echo "

\nPercentage of GDP Spent on Defense: $defense%
Percentage of Budget Spent on Defense: $budgetpercent%
"; } $f15e = floor($military / 31100000); $su34 = floor($military / 20000000); $f16 = floor($military / 18800000); $mig29 = floor($military / 11000000); $m1a2 = floor($military / 4300000); $t90 = floor($military / 3000000); $m16 = floor($military / 586); $ak47 = floor($military / 300); echo "Military Budget: \$" . number_format($military) . "

Enough for:
" . number_format($f15e) . " F-15Es, or...
" . number_format($su34) . " Su-34s, or...
" . number_format($f16) . " F-16s, or...
" . number_format($mig29) . " MiG 29s, or...
" . number_format($m1a2) . " M1A2 Abrams, or...
" . number_format($t90) . " T-90s, or...
" . number_format($m16) . " M-16s, or...
" . number_format($ak47) ." AK47s

"; } } ?>