XML problem

Shovel

Part of the furniture
Joined
Dec 22, 2003
Messages
1,350
This original post is as follows:

For some reason i the text dont apear, i guess i can use some help.
http://www.innersphere.be/daoc/char...ntName=Deadnala

Here is the code, i changed it a little to make it readable (for myself
PHP Code:
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($fp, 4096))
xml_parse($xml_parser, $data, feof($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], $PrintName, strlen($PrintName)) == 0){
   $ih = imagecreatefromjpeg($PicFile);
   $black = imagecolorallocate($ih, 0, 0, 0);
   $white = imagecolorallocate($ih, 255, 255, 255);
   if ($TextCol == "L"){
    $color1 = imagecolorallocate($ih, 255, 255, 255);
    $color2 = imagecolorallocate($ih, 255, 255, 0);
    $shade = imagecolorallocate($ih, 0, 0, 0);
   } elseif ($TextCol == "D"){
    $color1 = imagecolorallocate($ih, 0, 0,0);
    $color2 = imagecolorallocate($ih, 0, 0, 0);
    $shade = imagecolorallocate($ih, 255, 255, 255);
   }
   header('Content-Type: image/jpeg');
   if (!$ih){
    $ih  = imagecreate(200, 80); /* Create a blank image */
    imagefilledrectangle($ih, 0, 0, 200, 80, $black);
    imagestring($ih, 1, 5, 5, "Error loading $imgname", $white);
   } else {
    $size = getimagesize($PicFile);
    imagealphablending($ih, true);
    $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(12, 0, "mael", $TextLine1);
     $y1 = $size[1]  - $LnName[3] - 44;
     $LnName = imagettfbbox(8, 0, "tahomabd", $TextLine2);
     $y2 = $size[1]  - $LnName[3] - 38;
     $LnName = imagettfbbox(8, 0, "tahomabd", $TextLine3);
     $y3 = $size[1]  - $LnName[3] - 22;
     $LnName = imagettfbbox(12, 0, "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(12, 0, "mael", $TextLine1);
     $x1 = $size[0]  - $LnName[2] - 6;
     $LnName = imagettfbbox(8, 0, "tahomabd", $TextLine2);
     $x2 = $size[0]  - $LnName[2] - 4;
     $LnName = imagettfbbox(8, 0, "tahomabd", $TextLine3);
     $x3 = $size[0]  - $LnName[2] - 4;
     $LnName = imagettfbbox(12, 0, "mael", $TextLine4);
     $x4 = $size[0]  - $LnName[2] - 4;
    } elseif ($TextPos[1] == 'C'){
     $LnName = imagettfbbox(12, 0, "mael", $TextLine1);
     $x1 = ($size[0]  - $LnName[2]) / 2;
     $LnName = imagettfbbox(8, 0, "tahomabd", $TextLine2);
     $x2 = ($size[0]  - $LnName[2]) / 2;
     $LnName = imagettfbbox(8, 0, "tahomabd", $TextLine3);
     $x3 = ($size[0]  - $LnName[2]) / 2;
     $LnName = imagettfbbox(12, 0, "mael", $TextLine4);
     $x4 = ($size[0]  - $LnName[2]) / 2;
    }
    imagettftext($ih, 12, 0, $x1, $y1, $shade, "mael", $TextLine1);
    imagettftext($ih, 12, 0, $x1-1, $y1-1, $color1, "mael", $TextLine1);
    imagettftext($ih, 8, 0, $x2, $y2, $shade, "tahomabd", $TextLine2);
    imagettftext($ih, 8, 0, $x2-1, $y2-1, $color1, "tahomabd", $TextLine2);
    imagettftext($ih, 8, 0, $x3, $y3, $shade, "tahomabd", $TextLine3);
    imagettftext($ih, 8, 0, $x3-1, $y3-1, $color2, "tahomabd", $TextLine3);
    imagettftext($ih, 12, 0, $x4, $y4, $shade, "mael", $TextLine4);
    imagettftext($ih, 12, 0, $x4-1, $y4-1, $color1, "mael", $TextLine4);
   }
   imagejpeg($ih);
   imagedestroy($ih);
  }
}

?>
 

Shovel

Part of the furniture
Joined
Dec 22, 2003
Messages
1,350
Oh God, the
PHP:
 tag hasn't had it's background changed after all.
/me sulks off to the feedback forum.
 

Users who are viewing this thread

Top Bottom