Simple knowledge needed with this.

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Simple knowledge needed with this.
AalnyanIcestorm
CZ Super Newbie
 Codezwiz Site Donator
AalnyanIcestorm has been a member for over 19 year's 19 Year Member
usa.gif oregon.gif
Occupation: Web Design & Computer Consultant
Age: 61
Gender: Male
Website:
Status: Offline
Joined: Dec 30, 2004
0.01 posts per day
Posts: 81
Points: 7,351
  MSN Messenger 
How would I turn the following into a module with all parameters being able to be passed and also to use the current colors of the users selected theme.

I've showed all the code here but only need maybe an example on both parts. The using theme colors and calling maybe I search function and how its turned into a module so that it loads in the site leaving left and right parts of site intact.

Thanks.



Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,430
   
icon_scratch.gif




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: Simple knowledge needed with this.
AalnyanIcestorm
CZ Super Newbie
 Codezwiz Site Donator
AalnyanIcestorm has been a member for over 19 year's 19 Year Member
usa.gif oregon.gif
Occupation: Web Design & Computer Consultant
Age: 61
Gender: Male
Website:
Status: Offline
Joined: Dec 30, 2004
0.01 posts per day
Posts: 81
Points: 7,351
  MSN Messenger 
Hmmm I see the code did attach lol..

Ok I've attached it as a file and a second attempt at the code


<?php

    /*
    *    guildxml.php
    *    a Dark Age of Camelot Guild XML data parser that returns a guild roster
    *     sortable with some parameters like name, Realm Points, Level, etc...
    *    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 [ Register or login to view links on this board. ]
    *    http://www.purpledragons.net/xml/
    *
    *    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
    *
    *    Enjoy and please link to our site
    *    http://www.purpledragons.net
    *
    *     Changelog:
    *     September 9, 2003 : added support for realm title selection according to realm in XML
    *     March 28, 2003 : added UTF8 support for GOA XML - Euro servers only
    *     Feb. 25, 2003 : finally added $param as $_GET['param']
    */


class guildXML {

    /*
    *    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_char;
        var $in_alliance;
        var $chars_array;
        var $alliance_array;
        var $current_tag ='';

    /*
    *    Class Constructor
    */

    function guildXML() {
        $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);
    }

//Class Members
    function concat($str) {
        $this->html .= $str;
    }

    function startElement($parser, $name, $attrs) {
        global $totalchars, $num_activechars,$num_inactivechars, $insideElement, $in_char, $current_tag, $i;

        if (($in_char==1)||($in_alliance==1)){
            $current_tag = $name;
        }
        if ($name=='GUILD'){
            $current_tag= $name;
            if (sizeof($attrs)) {
                while (list($k, $v) = each($attrs)) {
                    if ($k=='GUILDRP'){$this->guildrp=$v;};
                    if ($k=='TIMESTAMP'){$this->timestamp=$v;};
                    if ($k=='REALM'){$this->realm=$v;};
                 }
            }
        }

        if ($name=='CHARACTER'){
            $in_alliance = 1;
        }
        if ($name=='CHARACTER'){
            $in_char=1;
            $totalchars++;
            if (sizeof($attrs)) {
                while (list($k, $v) = each($attrs)) {
                    if ($k=='NAME'){
                        $this->chars_array[$i]['name']=trim($v);
                        $this->chars_array[$i]['firstname']= trim (substr($this->chars_array[$i]['name'],0, strpos($this->chars_array[$i]['name'],' ')));
                        $this->chars_array[$i]['lastname']= trim (substr($this->chars_array[$i]['name'], strpos($this->chars_array[$i]['name'],' ')));
                        // Italian servers with Base64 encoding for last name, comment the above line and uncomment the following line
                        //$this->chars_array[$i]['lastname']= base64_decode(trim (substr($this->chars_array[$i]['name'], strpos($this->chars_array[$i]['name'],' '))));

                        if (!$this->chars_array[$i]['firstname'] && $this->chars_array[$i]['lastname']){
                             $this->chars_array[$i]['firstname'] = $this->chars_array[$i]['lastname'];
                             $this->chars_array[$i]['lastname']='';
                        }
                    }

                    if ($k=='LASTON') {
                        $this->chars_array[$i]['laston']=$v;
                        if ($v!='Inactive') {
                            $num_activechars++;
                        } elseif($v=='Inactive'){
                            $num_inactivechars++;
                        }
                    }
                 }
             }
        }

    }

    function endElement($parser, $name) {
               global $close_tag, $current_tag, $in_char, $i;

                if ($name=='CHARACTER'){$i++; $in_char=0;}
                if ($name=='ALLIANCE'){$i++; $in_alliance=0;}
    }

    function characterData($parser, $data) {
        global $guildrp, $inactiverp, $current_tag, $in_char, $i;
                //$content_output .= '<br>'.$current_tag.' = '.$data.'<br>';
                if (($in_char==1) && ($current_tag=='RACE')){
                    $this->chars_array[$i]['race'].=$data;
                }
                if (($in_char==1) && ($current_tag=='CLASS')){
                    $this->chars_array[$i]['class'].=$data;
                }
                if (($in_char==1) && ($current_tag=='LEVEL')){
                    $this->chars_array[$i]['level'].=$data;
                }
                if (($in_char==1) && ($current_tag=='TOTALRP')){
                    $this->chars_array[$i]['rp'].=$data;
                    if ($this->chars_array[$i]['laston']=='Inactive'){
                        $inactiverp += $data;
                    } else {
                        $guildrp += $data;
                    }

                }
                if (($in_char==1) && ($current_tag=='GUILDRANK')){
                    $this->chars_array[$i]['guildrank'].=$data;
                }
                //$this->html .= $data;
         }

    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_parser, XML_OPTION_CASE_FOLDING, true);

        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($fp, 4096)) {
            if (!xml_parse($this->xml_parser, $data, feof($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

// Support functions

    /*
    *    The function sortItems() is used for sorting, called upon by uksort()
    *    It uses querystring parameter $param as the sorting parameter
    *    querystring parameter $dir indicates ascending or descending order
    */

    function sortItems($a, $b) {
        global $gu, $dir, $param;

        $val_a = ($gu[$a][$param]);
        $val_b = ($gu[$b][$param]);

        if (!$param){$param='level';}
        if (!$dir){$dir='down';}
        switch ($param){
            case 'rp':
            $val_a = $val_a - 0;
            $val_b = $val_b - 0;
            break;

            case 'level':
            $val_a = $val_a - 0;
            $val_b = $val_b - 0;
            break;
        }

        if ($dir=='up'){
            if ( $val_a > $val_b ){return 1;}
            if ( $val_a < $val_b ){return -1;}
            if ( $val_a = $val_b ){return 0;}
        } else {
            if ( $val_a < $val_b ){return 1;}
            if ( $val_a > $val_b ){return -1;}
            if ( $val_a = $val_b ){return 0;}
        }
    }

    /*
    *    returns array with Guild Rank information
    */

    function guildrank($rank){
        switch ($rank){
            case 0: $rankname = array('Guildmaster', 'Description for Guildmaster');
            break;

            case 1: $rankname = array('Rank 1 Title', 'Description for Guild Rank 1');
            break;

            case 2: $rankname = array('Rank 2 Title', 'Description for Guild Rank 2');
            break;

            case 3: $rankname = array('Rank 3 Title', 'Description for Guild Rank 3');
            break;

            case 4: $rankname = array('Rank 4 Title', 'Description for Guild Rank 4');
            break;

            case 5: $rankname = array('Rank 5 Title', 'Description for Guild Rank 5');
            break;

            case 6: $rankname = array('Rank 6 Title', 'Description for Guild Rank 6');
            break;

            case 7: $rankname = array('Rank 7 Title', 'Description for Guild Rank 7');
            break;

            case 8: $rankname = array('Rank 8 Title', 'Description for Guild Rank 8');
            break;

            case 9: $rankname = array('Rank 9 Title', 'Description for Guild Rank 9');
            break;
        }
        return $rankname;
    }

    /*
    *    returns Realm Rank/Level
    */

    function realmlevel ($rp){
        $rap =1;
        for ($i=1; $i<11; $i++){
            if ($i!=1){
                for ($j=0;$j<10;$j++){
                    $rp_needed = ((25/3)*(pow($rap,3))) - ((25/2)*(pow($rap,2))) + ((25/6)*$rap);

                    if ($rp_needed <10) {
                        $rp_needed =0;
                    }
                    if ($rp>=$rp_needed) {
                        $level = 'R'.$i.'L'.$j;
                    }
                    $rap++;
                }
            } else {
                for ($j=1;$j<10;$j++){
                    $rp_needed = ((25/3)*(pow($rap,3))) - ((25/2)*(pow($rap,2))) + ((25/6)*$rap);

                    if ($rp_needed <10) {
                        $rp_needed =0;
                    }
                    if ($rp>=$rp_needed) {
                        $level = 'R'.$i.'L'.$j;
                    }
                    $rap++;
                }

            }
        }
        return $level;
    }

    /*
    *    returns Realm Title
    */


    function realmtitle($rp){
        /*
        *    You start at Rank 1. To rise to Rank 2, you need 7125 realm points.
        *    Rank 3 = 61750, Rank 4 = 213875, Rank 5 = 513500, Rank 6 = 1010625, Rank 7 = 1755250, Rank 8 = 2797375, Rank 9 = 4187000
        *    and finally Rank 10 = 5974125
        *
        *    These ranks are for the Albion Realm. You need to add correct values for Hibernia or Midgard.
        *    The list of ranks per realm can be found at http://www.purpledragons.net/camelot/rp_chart.php
        */
        global $realm_id;

        if ($rp >=0)
            $rank= array ('Guardian','Savant','Skilvakten');

        if ($rp > 7125)
            $rank = array ('Warder','Cosantoir','Isen Vakten');

        if ($rp > 61750)
            $rank = array ('Myrmidon','Brehon','Flamen Vakten');

        if ($rp > 213875)
            $rank = array ('Gryphon Knight','Grove Protector','Elding Vakten');

        if ($rp > 513500)
            $rank = array ('Eagle Knight','Raven Ardent','Stormur Vakten');

        if ($rp > 1010625)
            $rank = array ('Phoenix Knight','Silver Hand','Isen Herra');

        if ($rp > 1755250)
            $rank = array ('Alerion Knight','Thunderer','Flammen Herra');

        if ($rp > 2797375)
            $rank = array ('Unicorn Knight','Gilded Spear','Elding Herra');

        if ($rp > 4187000)
            $rank = array ('Lion Knight','Tiarna','Stormur Herra');

        if ($rp > 5974125)
            $rank = array ('Dragon Knight','Emerald Rider','Einherjar');

        return $rank[$realm_id];
    }

// Main content

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

    $guild->parse();


    // Copy some variables
    $gu = $guild->chars_array;
    $guildrp = $guild->guildrp;
    $guildtimestamp = $guild->timestamp;
    $realm = $guild->realm;

    switch($realm){
        case 'Albion': $realm_id=0; break;
        case 'Hibernia': $realm_id=1; break;
        case 'Midgard': $realm_id=2; break;
        default: $realm_id=0;
    } // switch

    $xml_file = $guild->xml_file;

    $guild->destroy(); // destroy the object

    $param = $_GET['param']; // retrieve sort parameter from URL querystring

    uksort($gu, "sortItems");  // call upon sortItems() to sort the guild information array
    reset($gu);

    /*
    *
    *    Bases stats on active vs. inactive characters and indicates differentials
    *
    */


    if ($_GET['active']=='no'){
        $content_output.= 'Statistics for <b>'.$num_inactivechars.'</b> inactive characters  out of <b>'. $totalchars .'</b> [<a href=" '.$PHP_SELF. '">see active</a>]<br>';

    } else {
        $content_output.='Statistics for <b>'.$num_activechars.'</b> active characters out of <b>'.$totalchars.'</b> [<a href="'.$PHP_SELF.'?active=no">see inactive</a>]<br>';
    }

    /*
    *    Creates the output table
    */

    $content_output .= 'Total Realm Points: <b>'. $guildrp .'</b>';
    $content_output .= '<br><span style="font-size:9pt;">Data last updated: <b>'.$guildtimestamp.'</b> ;;:: ;;<a href="'.$xml_file.'" target="xml">View raw XML data</a></span><hr noshade="true">
<table cellspacing="0" cellpadding="0" style="border: solid 1px #3F5471;">
<tr>
    <td>
        <table width="100%" cellspacing="0" cellpadding="2">
            <tr bgcolor="#E5E5E5">
                <form action="'. $PHP_SELF .'" method="get">
                <td>
                    <SELECT name="param">
                        <option value="name">Name</option>
                        <option value="level">Level</option>
                        <option value="class">Class</option>
                        <option value="race">Race</option>
                        <option value="rp">RP</option>
                        <option value="guildrank">Guild Rank</option>
                    </select>
                    <SELECT name="dir">
                        <option value="up">Ascending</option>
                        <option value="down">Descending</option>
                    </select>
                    <input type="submit" value="search"><input type="hidden" name="active" value="'.$_GET['active'].'">
                </td>
                </form>
            </tr>
        </table>
    </td>
</tr>
<tr>
    <td>
        <table cellspacing="0" cellpadding="5">
            <tr style="font-weight: bold;" bgcolor="#CCCCCC">
                <td>#</td>
                <td>Name</td>
                <td>Level</td>
                <td>Class</td>
                <td>Race</td>
                <td>RPs</td>
                <td>Rank</td>
                <td>level</td>
                <td>Guild</td>
            </tr>
    ';

    $i=1;

    foreach ($gu as $key=>$value){

        if ($_GET['active']!='no'){
            if ($value['laston']!='Inactive') {
                if ($i%2==0){$color='#CCCCCC';}else{$color='#DDDDFF';}
                $content_output .= '
            <tr bgcolor="'.$color.'" style="font-size:9pt;">
                <td>#'.$i.'</td>
                <td><b>'.$value['firstname'].' '.$value['lastname'].'</b></td>
                <td>'.$value['level'].'</td>
                <td>'.$value['class'].'</td>
                <td>'.$value['race'].'</td>
                <td align="right">';
                if ($value['level']>=20){
                    $content_output .= number_format($value['rp']);
                } else {
                    $content_output .= ' ;;';
                }
                $content_output .= '
                </td>
                <td>';
                if ($value['level']>=20){
                    $content_output .= realmtitle($value['rp']);
                } else {
                    $content_output .= ' ;;';
                }
                $content_output .= '
                </td>
                <td>';
                if ($value['level']>=20){
                    $content_output .= realmlevel($value['rp']);
                } else {
                    $content_output .= ' ;;';
                }
                $content_output .= '
                </td>';
                $guildrank = guildrank($value['guildrank']);
                $content_output .= '
                <td>'.$guildrank[0].'</td>
            </tr>';
                $i++;
            }
        } else {
            if ($value['laston']=='Inactive') {
                if ($i%2==0){$color='#CCCCCC';}else{$color='#DDDDFF';}
                $content_output .= '
            <tr bgcolor="'.$color.'" style="font-size:9pt;">
                <td>#'.$i.'</td>
                <td><b>'.$value['firstname'].' '.$value['lastname'].'</b></td>
                <td>'.$value['level'].'</td>
                <td>'.$value['class'].'</td>
                <td>'.$value['race'].'</td>
                <td align="right">';
                if ($value['level']>=20){
                    $content_output .= number_format($value['rp']);
                } else {
                    $content_output .= ' ;;';
                }
                $content_output .= '
                </td>
                <td>';
                if ($value['level']>=20){
                    $content_output .= realmtitle($value['rp']);
                } else {
                    $content_output .= ' ;;';
                }
                $content_output .= '
                </td>
                <td>';
                if ($value['level']>=20){
                    $content_output .= realmlevel($value['rp']);
                } else {
                    $content_output .= ' ;;';
                }
                $content_output .= '
                </td>';
                $guildrank = guildrank($value['guildrank']);
                $content_output .= '
                <td>'.$guildrank[0].'</td>
            </tr>';
                $i++;
            }

        }

    }
    $content_output .= '
        </table>
    </td>
</tr>
</table>';

    /*
        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;
?>





Attached Files
guildroster.zip (4.59 KB, Downloaded: 5235 Time(s))


Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,430
   
You mean like this?
[ Register or login to view links on this board. ]




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   re: Simple knowledge needed with this.
AalnyanIcestorm
CZ Super Newbie
 Codezwiz Site Donator
AalnyanIcestorm has been a member for over 19 year's 19 Year Member
usa.gif oregon.gif
Occupation: Web Design & Computer Consultant
Age: 61
Gender: Male
Website:
Status: Offline
Joined: Dec 30, 2004
0.01 posts per day
Posts: 81
Points: 7,351
  MSN Messenger 
OMG Exactly like that :P

But it doesn't show me how icon_sad.gif



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum