View Single Post
  #3 (permalink)  
Old 07-09-04, 06:53 AM
Rapid Dr3am Rapid Dr3am is offline
Community VIP
 
Join Date: Jan 2004
Location: Liverpool, England
Posts: 752
Thanks: 0
Thanked 0 Times in 0 Posts
Just an example is this:

PHP Code:

<?php 
/***************************************************************************
 *                            nationstate.php
 *                            -------------------
 *   begin                : Friday, 23, May, 2003
 *   copyright            : (C) Robin Morrison (People's Republic of Winnipeg)
 *
 *
 ***************************************************************************/
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
//check to see if a nation has been specified 
   
if (isset($_REQUEST['nation'])) { 
      
$nation $_REQUEST['nation']; 
      } else { 
      
$nation 'rapid_dr3am'//You can feel free to change this to the default nation of your choice. 
      

// Open and read the XML Output 
   
$fileName "http://www.nationstates.net/cgi-bin/nationdata.cgi/nation=".$nation
   
$size "800"
   
$fp fopen($fileName,'r'); 
   
$text fread($fp,$size); 
   
fclose($fp); 
//Create the Array of feed sections. Just use the ones you need. 
//To see all the avalible sections visit [url]http://www.nationstates.net/cgi-bin/nationdata.cgi/nation=xxx[/url]
   
$section = array(   1   =>   "FULLNAME"
                  
2   =>   "MOTTO"
                  
3   =>   "CATEGORY"
                  
4   =>   "UNSTATUS"
                  
5    =>   "CIVILRIGHTS"
                  
6   =>   "ECONOMY"
                  
7   =>   "POLITICALFREEDOM"
                  
8   =>   "REGION"
                  
9   =>   "POPULATION"
                  
10   =>   "TAX"
                  
11   =>   "ANIMAL"
                  
12   =>   "CURRENCY"
                  
13   =>   "FLAG"
                  
14   =>   "MAJORINDUSTRY"
                  
15   =>   "GOVTPRIORITY"
                  
16   =>   "LASTLOGIN"
                  
17   =>   "LASTACTIVITY"
               ); 
//Now run a foreach that goes through the array we just created. 
   
foreach ($section as $var) { 
      
$open "<".$var.">"
      
$close "</".$var.">"
      
$start strpos($text,$open); 
      
$end strpos($text,$close); 
      
$length $end $start
      
$val substr($text,$start,$length); 
//Make sure that these if() statements reflect the options you used in the $section array 
      
if ($var == 'FULLNAME') { $name str_replace($open''$val); } 
      if (
$var == 'MOTTO') { $motto str_replace($open''$val); } 
      if (
$var == 'CATEGORY') { $category str_replace($open''$val); } 
      if (
$var == 'UNSTATUS') { $unstatus str_replace($open''$val); } 
      if (
$var == 'CIVILRIGHTS') { $civilrights str_replace($open''$val); } 
      if (
$var == 'ECONOMY') { $economy str_replace($open''$val); } 
      if (
$var == 'POLITICALFREEDOM') { $political str_replace($open''$val); } 
      if (
$var == 'REGION') { $region str_replace($open''$val); } 
      if (
$var == 'POPULATION') { 
         
$pop str_replace($open''$val); 
         
//This Just changes the Population Output to Billions if it is more than 1000 
         
if ($pop >= 1000) { 
            
$pop round($pop/10002); 
            
$postfix "Billion"
            } else { 
            
$postfix "Million"
            } 
         } 
      if (
$var == 'TAX') { $tax str_replace($open''$val); } 
      if (
$var == 'ANIMAL') { $animal str_replace($open''$val); } 
      if (
$var == 'CURRENCY') { $currency str_replace($open''$val); } 
      if (
$var == 'FLAG') { $flag str_replace($open''$val); } 
      if (
$var == 'MAJORINDUSTRY') { $industry str_replace($open''$val); } 
      if (
$var == 'GOVTPRIORITY') { $priority str_replace($open''$val); } 
      if (
$var == 'LASTLOGIN') { $lastlogin str_replace($open''$val); } 
      if (
$var == 'LASTACTIVITY') { $lastactivity str_replace($open''$val); } 
      } 
//Check to see if a Message has been set ($msg) 
   
if (isset($msg)) { 
      echo 
"<font color=\"red\" size=\"3\">".$msg."</font><br><br>"
      } 
?> 
<table border="0"> 
   <tr> 
      <td valign="top" align="right"><font color="FFFFFF">FLAG:</font></td> 
     <td align="center"><img src="<? print($flag); ?>" style="border: 0 solid black;"></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Full Name:</font></td> 
      <td><? print($name); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Motto:</font></td> 
      <td><? print($motto); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Category:</font></td> 
      <td><? print($category); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">UN Status:</font></td> 
      <td><? print($unstatus); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Civilrights:</font></td> 
      <td><? print($civilrights); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Economy:</font></td> 
      <td><? print($economy); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Political Freedoms:</font></td> 
      <td><? print($political); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Region:</font></td> 
      <td><? print($region); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Population:</font></td> 
     <td><? print($pop."&nbsp;".$postfix); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Tax:</font></td> 
      <td><? print($tax); ?>%</td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Animal:</font></td> 
      <td><? print($animal); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Currency:</font></td> 
      <td><? print($currency); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Major Industry:</font></td> 
     <td><? print($industry); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Government Priority:</font></td> 
      <td><? print($priority); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Last Login:</font></td> 
      <td><? print($lastlogin); ?></td> 
   </tr><tr> 
      <td align="right"><font color="FFFFFF">Last Active:</font></td> 
      <td><? print($lastactivity); ?></td> 
   </tr> 
</table>
__________________
Placeholder, place signature here.
Reply With Quote