Number of Nations: 0
Number of Regions: 0
Number of UN Members: 0 (0%)

Current UN Report:
Nation Ranking (For ): 0
Nation's Percentile: 100th

Current Resolution: No Resolution Currently Up For Vote
Total Votes: 0
For Votes: 0 (0%)
Against Votes: 0 (0%)

Code:

<?
$nation2 = strtolower(str_replace(" ", "_", $nation));
if($pin) $pintext = "/pin=$pin";
$filename = "http://www.nationstates.net/cgi-bin/index.cgi/page=world" . $pintext;
$size = "6000";
$fp = fopen($filename, 'r');
$text = fread($fp, $size);
fclose($fp);
$filename = "http://www.nationstates.net/cgi-bin/index.cgi/page=un";
$size = "6000";
$fp = fopen($filename, 'r');
$text2 = fread($fp, $size);
fclose($fp);

$nationtext = substr($text, strpos($text, "<a href=\"nation=$nation2\">") - 50, 500);
$nationcount = intval(str_replace(array("<p>The world contains ", ","), array("", ""), substr($text, strpos($text, "<p>The world contains "), (strpos($text, " nations in") - strpos($text, "<p>The world contains ")))));
$regioncount = intval(str_replace(array(" nations in\n", ","), array("", ""), substr($text, strpos($text, " nations in\n"), (strpos($text, " regions.") - strpos($text, " nations in\n")))));
$reporttitle = str_replace("<h3>", "", substr($text, strpos($text, "<h3>"), (strpos($text, "</h3>") - strpos($text, "<h3>"))));
$nationrank = intval(str_replace("<td align=\"right\">", "", substr($nationtext, strpos($nationtext, "<td align=\"right\">"), (strpos($nationtext, ".</td><td><strong><a href=\"nation=$nation2\">") - strpos($nationtext, "<td align=\"right\">")))));

$unnationcount = intval(str_replace(array("<p>The United Nations has ", ","), array("", ""), substr($text2, strpos($text2, "<p>The United Nations has "), (strpos($text2, "\nmember nations") - strpos($text2, "<p>The United Nations ")))));
if(strpos($text2, "Votes For") === false)
{
	$resolution = "No Resolution Currently Up For Vote";
	$for = 0;
	$against = 0;
}
else
{
	$resolution = str_replace("<h2 style=\"margin-bottom:0\">", "", substr($text2, strpos($text2, "<h2 style=\"margin-bottom:0\">"), (strpos($text2, "</h2>") - strpos($text2, "<h2 style=\"margin-bottom:0\">"))));
	$for = intval(str_replace("<strong>Votes For:</strong> ", "", substr($text2, strpos($text2, "<strong>Votes For:</strong> "), (strpos($text2, "\n<br><br>") - strpos($text2, "<strong>Votes For:</strong> ")))));
	$against = intval(str_replace("<strong>Votes Against:</strong> ", "", substr($text2, strpos($text2, "<strong>Votes Against:</strong> "), (strpos($text2, "<br><br>") - strpos($text2, "<strong>Votes Against:</strong> ")))));
}

$nationpercentile = 100 - round($nationrank / $nationcount * 100);
if(substr($nationpercentile, -1) == 1) $nationpercentile .= "st";
elseif(substr($nationpercentile, -1) == 2) $nationpercentile .= "nd";
elseif(substr($nationpercentile, -1) == 3) $nationpercentile .= "rd";
else $nationpercentile .= "th";

$unpercent = round($unnationcount / $nationcount * 100, 2);
$votes = $for + $against;
if($votes)
{
	$forpercent = round($for / $votes * 100, 2);
	$againstpercent = round($against / $votes * 100, 2);
}
else
{
	$forpercent = 0;
	$againstpercent = 0;
}

echo "<p>Number of Nations: $nationcount<br>Number of Regions: $regioncount<br>Number of UN Members: $unnationcount ($unpercent%)</p><p>Current UN Report: $reporttitle<br>Nation Ranking (For $nation): $nationrank<br>Nation's Percentile: $nationpercentile</p><p>Current Resolution: $resolution<br>Total Votes: $votes<br>For Votes: $for ($forpercent%)<br>Against Votes: $against ($againstpercent%)</p>";
?>