Wargoul
30-06-2006, 05:54
Well I noticed quite a few sites based on regions are on the web. I thought it would be cool if there were PHP scripts for these sites to display content. I decided to write a serious of scripts.
Heres the first that will let you see the top 10 in your region and I will eventually fix it to display everyone in pagenation. All thought I haven't finished it yet.
Working demo: http://goodvillain.com/ns/
<?
//Script by Brad "GoodVillain" Metcalf of the Wargoul Nation
//goodvillain.com
//Edit the below with your region name
$region = "allied_union_of_nations";
//Dont edit below unless you know what your doing
$rname = ereg_replace("[^A-Za-z0-9]", " ", $region);
$rname = ucwords($rname);
$rname = ucwords(strtolower($rname));
echo "Top 10 Nations in the $rname Region<br>";
set_time_limit(0);
$reg = '/.<\/td><td><a href=\"nation=(.*?)\"><img src=\"\/images\/flags\/(.*?)\"/i';
$page = join("", file("http://www.nationstates.net/page=display_region/region=$region"));
$page = ereg_replace("\n", "", $page);
preg_match_all($reg, $page, $matches);
$cnt = count($matches[0]);
for($x=0;$x<$cnt;$x++){
$url = $matches[1][$x];
$flag = $matches[2][$x];
$name = ereg_replace("[^A-Za-z0-9]", " ", $url);
$name = ucwords($name);
$name = ucwords(strtolower($name));
echo "<a href=\"http://nationstates.net/$url\"><img src=\"http://nationstates.net/images/flags/$flag\" alt=\"Flag\" hspace=\"6\" align=\"absmiddle\" height=\"26\" width=\"40\" border=\"0\"> $name</a><br>";
}
?>
Now PHP coders are thinking oh wooo thats simple. I know it is. My goal is to write a full portal that gets a lot more information of the region and nations in that region. But have it save to MySQL so the portals load faster. I was wondering if anyone would like to join the project and help me design the portals and choose what goes in them. Just so its not a complete rip of the region pages on this site I would also like to add content to make it a bit different, possibly doc management and ect for laws. I am actually very knowledgable in PHP so I am not looking for some slave, Ill do my fair share of the work too. :)
Heres the first that will let you see the top 10 in your region and I will eventually fix it to display everyone in pagenation. All thought I haven't finished it yet.
Working demo: http://goodvillain.com/ns/
<?
//Script by Brad "GoodVillain" Metcalf of the Wargoul Nation
//goodvillain.com
//Edit the below with your region name
$region = "allied_union_of_nations";
//Dont edit below unless you know what your doing
$rname = ereg_replace("[^A-Za-z0-9]", " ", $region);
$rname = ucwords($rname);
$rname = ucwords(strtolower($rname));
echo "Top 10 Nations in the $rname Region<br>";
set_time_limit(0);
$reg = '/.<\/td><td><a href=\"nation=(.*?)\"><img src=\"\/images\/flags\/(.*?)\"/i';
$page = join("", file("http://www.nationstates.net/page=display_region/region=$region"));
$page = ereg_replace("\n", "", $page);
preg_match_all($reg, $page, $matches);
$cnt = count($matches[0]);
for($x=0;$x<$cnt;$x++){
$url = $matches[1][$x];
$flag = $matches[2][$x];
$name = ereg_replace("[^A-Za-z0-9]", " ", $url);
$name = ucwords($name);
$name = ucwords(strtolower($name));
echo "<a href=\"http://nationstates.net/$url\"><img src=\"http://nationstates.net/images/flags/$flag\" alt=\"Flag\" hspace=\"6\" align=\"absmiddle\" height=\"26\" width=\"40\" border=\"0\"> $name</a><br>";
}
?>
Now PHP coders are thinking oh wooo thats simple. I know it is. My goal is to write a full portal that gets a lot more information of the region and nations in that region. But have it save to MySQL so the portals load faster. I was wondering if anyone would like to join the project and help me design the portals and choose what goes in them. Just so its not a complete rip of the region pages on this site I would also like to add content to make it a bit different, possibly doc management and ect for laws. I am actually very knowledgable in PHP so I am not looking for some slave, Ill do my fair share of the work too. :)