Alliance status

Copy the code below and paste it into a .php text file.
Save and upload to your web server.
Open script in browser.

*******************

<?php

    /*
    *    alliancexml.php
    *    a Dark Age of Camelot Guild XML data parser that returns an alliance status information table
    *    for use on Dark Age of Camelot community websites.
    *
    *    Dark Age of Camelot (or DAoC) is a MMORPG
    *    (massively multiplayer online rolepaying game)
    *    developed by Mythic Entertainment (http://www.mythicentertainment.com)
    *
    *    Author: Julien COQUET
    *    a.k.a Glenfiddich Singlemalt on DAoC Merlin/Albion
    *    e-mail glenfiddich@purpledragons.net
    *    http://www.purpledragons.net
    *
    *    Adapted from generic PHP code from http://www.php.net
    *
    *    Developed in September of 2002 under the GNU GPL License.
    *    For more information, visit http://www.gnu.org/licenses/gpl.html
    *
    *    Changelog:
    *     August 2nd, 2004: added support for when your guild is not in alliance
    *     March 28, 2003 : added UTF8 support for GOA XML - Euro servers only
    * 
    *    Enjoy and please link to our site
    *    http://www.purpledragons.net
    */

class allianceXML {

    /*
    *    This class takes a Dark Age of Camelot Herald XML guild data file and parses it
    */

        var $xml_parser;
        var 
$xml_file;
        var 
$html;
        var 
$open_tag ;
        var 
$close_tag ;
        var 
$in_alliance;
        var 
$chars_array;
        var 
$alliance_array;
        var 
$current_tag ='';

    /*
    *    Class Constructor
    */
        
function allianceXML() {
            
$this->xml_parser "";
            
$this->xml_file "";
            
$this->html "";
        }

    /*
    *    Class Destructor
    *    (has to be invoked manually as PHP does not support destructors)
    */
        
function destroy() {
            
xml_parser_free($this->xml_parser);
        }

    /*
    *    XML Elements - context methods
    *
    *    startElement and endElement are XML context indicators.
    *    XML attributes are handled in startElement
    *    They describe what should be done when in a specific XML tag
    *
    *    characterData handles PCDATA tag content
    */
        
function startElement($parser$name$attrs) {
            global 
$insideElement$in_alliance$in_guild$timestamp$current_tag$i;

            if ($in_alliance==1){
                
//if ($name=='CLASS'){$this->chars_array[$i]['class']=$name;}
                
$current_tag $name;
            }
            if (
$name=='ALLIANCEMEMBER'){
                
$in_alliance 1;
            }
            if (
$name=='GUILD'){
                
$in_guild 1;
            }
            if ((
$in_guild==1)){
                if (
sizeof($attrs)) {
                    while (list(
$k$v) = each($attrs)) {
                        if (
$k=='TIMESTAMP'){$timestamp=$v;};
                    }
                }
            }
        }

        function endElement($parser$name) {
            global 
$close_tag$current_tag$in_alliance$i;
            if (
$name=='ALLIANCEMEMBER'){$i++; $in_alliance=0;}
        }

        function characterData($parser$data) {
            global 
$current_tag$in_alliance$i;
            if ((
$in_alliance==1) && ($current_tag=='ALNAME')){
                
$this->alliance_array[$i]['name'].=$data;
            }
            if ((
$in_alliance==1) && ($current_tag=='ALGUILDID')){
                
$this->alliance_array[$i]['id'].=$data;
            }
            if ((
$in_alliance==1) && ($current_tag=='ALTOTALRP')){
                
$this->alliance_array[$i]['rp'].=$data;
            }
        }

    /*
    *
    *    the parse() method reads the input file line by line
    *    and uses the context method to process tags.
    *
    */
        
function parse() {

            $this->xml_parser xml_parser_create();
            
xml_set_object($this->xml_parser, &$this);
            
// use case-folding so we are sure to find the tag in $map_array
            
xml_parser_set_option($this->xml_parserXML_OPTION_CASE_FOLDINGtrue);

            xml_set_element_handler($this->xml_parser"startElement""endElement");
            
xml_set_character_data_handler($this->xml_parser"characterData");
            
//xml_set_processing_instruction_handler($this->xml_parser, "PIHandler");

            if (!($fp fopen($this->xml_file"r"))) {
                die(
"could not open XML input");
            }

            while ($data fread($fp4096)) {
                if (!
xml_parse($this->xml_parser$datafeof($fp))) {
                    die(
sprintf("XML error: %s at line %d",
                    
xml_error_string(xml_get_error_code($this->xml_parser)),
                    
xml_get_current_line_number($this->xml_parser)));
                }
            }
        }
}
// End of class

// Main content

    $alliance = new allianceXML(); // instantiate class
    
$alliance->xml_file "http://www.camelotherald.com/guilds/Merlin/804.xml";
    
// the xml_file property referes to you guild XML data file.
    // Example given is the Merlin/Albion guild Dragon's Blood

    $alliance->parse(); // begin parsing

    $gu $alliance->alliance_array// copy guild information array
    
$alliance->destroy(); // destroy the object

    $server 'Merlin'// Set servername for guild id for link to guild Herald page
    /*
    *    The function sortItems() is used for sorting, called upon by uksort()
    */

    function sortItems($a$b) {
     global 
$gu;

        $val_a = ($gu[$a]['rp']);
        
$val_b = ($gu[$b]['rp']);
        
$val_a $val_a 0;
        
$val_b $val_b 0;

        if ( $val_a $val_b ){return -1;}
        if ( 
$val_a $val_b ){return 1;}
        if ( 
$val_a $val_b ){return 0;}
    }

    if (count($gu)==0){
        print 
'This guild is not currently member of an alliance';
        
    } else {

    uksort($gu"sortItems");
    
reset($gu);

    /*
    *    Creates the output table
    */

    $content_output .='<style>.allianceTD {font-size: 10pt;}</style>'."\n";
    
$content_output .='<table cellspacing="0" cellpadding="5" style="border: solid 1px #3F5471;">';
    
$i=1;
    foreach (
$gu as $key=>$value){
        if (
$i %== 0){
            
$color='#CCCCCC';
        } else {
            
$color='#DDDDFF';
        }

        $content_output .='
<tr bgcolor="'
.$color.'">
    <td class="allianceTD">#'
.$i.'</td>
    <td class="allianceTD" nowrap="true">
        <b><a href="http://www.camelotherald.com/guilds/'
.$server.'/'.trim($value['id']).'.php" target="herald"'.$linkclass.'>'.stripslashes(trim($value['name'])).'</b></a>
    </td>
    <td class="allianceTD" align="right">
        <b>'
.number_format($value['rp'], 0'.'',').'</b>
    </td>
</tr>'
;
        
$alliancerp += $value['rp'];
        
$i++;
    }
    
$content_output .='
<tr bgcolor="#E5E5E5">
    <td class="allianceTD" colspan="2" align="right">
        <b>Total RPs:<b>
    </td>
    <td class="allianceTD" align="right">
        <b>'
.number_format($alliancerp0'.'',').'</b>
    </td>
</tr>
</table>
<span style="font-size:8pt;">Updated on <b>'
.$timestamp.'</b></span>'."\n";

    /*
        For Euro guilds: uncomment the following instructions
    */
    
//    $content_output = utf8_decode($content_output); // handles UTF8 character encoding

    /*
    *    Outputs table; end of script
    */

    print $content_output;
    }
?>