XML problem

Discussion in 'Techie Discussion' started by Deadnala, Jan 22, 2004.

  1. Deadnala

    Deadnala Fledgling Freddie

  2. Shovel

    Shovel Can't get enough of FH

    This original post is as follows:

    PHP:
    <?php
    // My link
    // [url]http://www.innersphere.be/daoc/char...ntName=Deadnala[/url]
    $PicFile "dragon.jpg"// Background
    $GuildID "1214";   // Guilde ID found on [url]http://daoc-stats.com/[/url]
    $TextCol "L";    // Textcolor L/D
    $textpos[0] = "T";   // Ver Textposition T/B
    $TextPos[1] = "C";   // Hor Textposition L/C/R   
    $Server "Excalibur";  // Server
    $XMLFile "http://www.camelot-europe.goa.com/herald/servers/" $Server "/guilds/" $GuildID ".xml";
    $character = array();
    function 
    guildXML_startElement($parser$tagName$attrs){
    global 
    $insideCharacterTag$curTag$name$laston$timestamp$guildname$realm$guildrp$activechars$activemembers$lastweekrp;
    global 
    $CharType$CharLevel;
    if (
    sizeof($attrs)){
      if (
    $tagName == "CHARACTER"){
       while (list(
    $attrtag$data) = each($attrs)){
        switch(
    $attrtag){
         case 
    "NAME":
          
    $name .= $data;
          break;
        }
       }
      }
      if (
    $tagName == "GUILD"){
       while (list(
    $attrtag$data) = each($attrs)){
        switch(
    $attrtag){
         case 
    "NAME":
          
    $guildname .= $data;
          break;
        }
       }
      }
    }
    if (
    $insideCharacterTag){
      
    $curTag $tagName;
    } else if (
    $tagName == "CHARACTER"){
      
    $insideCharacterTag true;
    }
    }
    function 
    guildXML_characterData($parser$data){
    global 
    $insideCharacterTag$curTag$race$class$level$guildrank$totalrp$tagName$lastweekrp;
    global 
    $CharType$CharLevel;
    if (
    $insideCharacterTag){
      switch (
    $curTag){
       case 
    "RACE":
        
    $race .= $data;
        break;
       case 
    "CLASS":
        
    $class .= $data;
        break;
       case 
    "LEVEL":
        
    $level .= $data;
        break;
       case 
    "GUILDRANK":
        
    $guildrank .= $data;
        break;
       case 
    "TOTALRP":
        
    $totalrp .= $data;
        break;
       case 
    "LASTWEEKRP":
        
    $lastweekrp .= $data;
        break;
      }
    }
    }
    function 
    guildXML_endElement($parser$tagName){
    global 
    $character$insideCharacterTag$curTag$name$race$class$level$guildrank$totalrp$lastweekrp;
    global 
    $CharType$CharLevel;
    if (
    $tagName == "CHARACTER"){
      
    $charinfo = array($guildrank$name""$race$class$level$totalrp$lastweekrp);
      
    array_push($character$charinfo);
      
    $curTag "";
      
    $name "";
      
    $race "";
      
    $class "";
      
    $level "";
      
    $guildrank "";
      
    $totalrp "";
      
    $timestamp "";
      
    $guildrp "";
      
    $lastweekrp "" ;
      
    $activechars "";
      
    $activemembers "";
      
    $insideCharacterTag false;
    }
    }
    $xml_parser xml_parser_create();
    xml_set_element_handler($xml_parser"guildXML_startElement""guildXML_endElement");
    xml_set_character_data_handler($xml_parser"guildXML_characterData");
    $fp fopen($XMLFile,"r") or die("Error reading GOA data.");
    while (
    $data fgets($fp4096))
    xml_parse($xml_parser$datafeof($fp)) or die(sprintf("XML error: %s at line %d"xml_error_string(xml_get_error_code($xml_parser)),   xml_get_current_line_number($xml_parser)));
    fclose($fp);
    xml_parser_free($xml_parser);
    $totalofcharacter count($character);
    for(
    $i=0$i<$totalofcharacter$i++){
      
    $ranksort $character[$i];
      if (
    strncmp($ranksort[1], $PrintNamestrlen($PrintName)) == 0){
       
    $ih imagecreatefromjpeg($PicFile);
       
    $black imagecolorallocate($ih000);
       
    $white imagecolorallocate($ih255255255);
       if (
    $TextCol == "L"){
        
    $color1 imagecolorallocate($ih255255255);
        
    $color2 imagecolorallocate($ih2552550);
        
    $shade imagecolorallocate($ih000);
       } elseif (
    $TextCol == "D"){
        
    $color1 imagecolorallocate($ih00,0);
        
    $color2 imagecolorallocate($ih000);
        
    $shade imagecolorallocate($ih255255255);
       }
       
    header('Content-Type: image/jpeg');
       if (!
    $ih){
        
    $ih  imagecreate(20080); /* Create a blank image */
        
    imagefilledrectangle($ih0020080$black);
        
    imagestring($ih155"Error loading $imgname"$white);
       } else {
        
    $size getimagesize($PicFile);
        
    imagealphablending($ihtrue);
        
    $TextLine1 trim($ranksort[1]);
        
    $TextLine2 trim("L" trim($ranksort[5]) . " " trim($ranksort[3]) . " " trim($ranksort[4]));
        
    $TextLine3 trim(number_format($ranksort[6], 0)) . " RP";
        
    $TextLine4 trim($guildname);
        if (
    $TextPos[0] == 'T'){
         
    $y1 18;
         
    $y2 32;
         
    $y3 46;
         
    $y4 60;
        } elseif (
    $TextPos[0] == 'B') {
         
    $LnName imagettfbbox(120"mael"$TextLine1);
         
    $y1 $size[1]  - $LnName[3] - 44;
         
    $LnName imagettfbbox(80"tahomabd"$TextLine2);
         
    $y2 $size[1]  - $LnName[3] - 38;
         
    $LnName imagettfbbox(80"tahomabd"$TextLine3);
         
    $y3 $size[1]  - $LnName[3] - 22;
         
    $LnName imagettfbbox(120"mael"$TextLine4);
         
    $y4 $size[1]  - $LnName[3] - 6;
        }
        if (
    $TextPos[1] == 'L'){
         
    $x1 6;
         
    $x2 6;
         
    $x3 6;
         
    $x4 6;
        } elseif (
    $TextPos[1] == 'R') {
         
    $LnName imagettfbbox(120"mael"$TextLine1);
         
    $x1 $size[0]  - $LnName[2] - 6;
         
    $LnName imagettfbbox(80"tahomabd"$TextLine2);
         
    $x2 $size[0]  - $LnName[2] - 4;
         
    $LnName imagettfbbox(80"tahomabd"$TextLine3);
         
    $x3 $size[0]  - $LnName[2] - 4;
         
    $LnName imagettfbbox(120"mael"$TextLine4);
         
    $x4 $size[0]  - $LnName[2] - 4;
        } elseif (
    $TextPos[1] == 'C'){
         
    $LnName imagettfbbox(120"mael"$TextLine1);
         
    $x1 = ($size[0]  - $LnName[2]) / 2;
         
    $LnName imagettfbbox(80"tahomabd"$TextLine2);
         
    $x2 = ($size[0]  - $LnName[2]) / 2;
         
    $LnName imagettfbbox(80"tahomabd"$TextLine3);
         
    $x3 = ($size[0]  - $LnName[2]) / 2;
         
    $LnName imagettfbbox(120"mael"$TextLine4);
         
    $x4 = ($size[0]  - $LnName[2]) / 2;
        }
        
    imagettftext($ih120$x1$y1$shade"mael"$TextLine1);
        
    imagettftext($ih120$x1-1$y1-1$color1"mael"$TextLine1);
        
    imagettftext($ih80$x2$y2$shade"tahomabd"$TextLine2);
        
    imagettftext($ih80$x2-1$y2-1$color1"tahomabd"$TextLine2);
        
    imagettftext($ih80$x3$y3$shade"tahomabd"$TextLine3);
        
    imagettftext($ih80$x3-1$y3-1$color2"tahomabd"$TextLine3);
        
    imagettftext($ih120$x4$y4$shade"mael"$TextLine4);
        
    imagettftext($ih120$x4-1$y4-1$color1"mael"$TextLine4);
       }
       
    imagejpeg($ih);
       
    imagedestroy($ih);
      }
    }

    ?>
     
  3. Shovel

    Shovel Can't get enough of FH

    Oh God, the
    PHP:
     tag hasn't had it's background changed after all.
    /
    me sulks off to the feedback forum.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.