http://www.ageofempi...mp;ladder=AoCRM
Como eu posso fazer com que esse endereço vire uma figura png?
igz_sign.pgp
<?php
/**
* CIGZSignature
* IGZones.com Implementation
* @autor jose @ www.t1poder.com.ar - www.aocgroup.com.ar
* @data Agoust, 2007
* @param string $_GET['nick'] nick of the player
* @param string $_GET['ladder'] Ladder ID
* @param string $_GET['country'] Country ID
**/
$nick=$_GET['nick'];
$ladder=$_GET['ladder'];
$country=$_GET['country'];
class CIGZSignature
{
var $strBuffer;
var $nick;
var $ladderID;
/**
* Constructor
*
* @param string $nick
* @param string $roomId
**/
function CIGZSignature ($nick, $ladderID, $country)
{
$this->country = trim ($country);
$this->nick = $this->cleanUserName (trim ($nick));
$this->ladderID = $ladderID;
$ladders = array (
'AoCRM', /* default value */
'AoCDM',
'AoCCS',
'AoKDM',
'AoKRM',
'AoKCS',
'RoRRM',
'AoERM'
);
if (array_search ($this->ladderID, $ladders) === FALSE)
{
$this->ladderID = $ladders[0];
}
$this->cache_file = 'cache/' . $this->nick . "-" . $this->ladderID . '.txt';
}
function cleanUserName ($nick)
{
$tag = '';
if ($nick[0] == '[')
{
$end = strpos ($nick, ']') + 1;
$nick = substr ($nick, $end);
}
return $nick;
}
/**
*
* Read Ratings Info from IGZ
*
**/
function getRatings ()
{
$this->buffer = '';
if ($this->nick == '')
{
$this->parsedData = array ();
return;
}
if (file_exists ($this->cache_file))
{
if ((filemtime ($this->cache_file) + 21600) > time ())
{
$fp = fopen ($this->cache_file, 'r');
$this->buffer = fread ($fp, 8096);
fclose ($fp);
}
}
if ($this->buffer == '')
{
$host = "www.igzones.com";
$headers = "GET /ratingservices?ladder=%s&player=%s&getclan=1 HTTP/1.0\r\nHost: %s\r\n\r\n";
$strHeaders = sprintf ($headers, $this->ladderID, $this->nick, $host);
$socket = @fsockopen($host, 80, $errNo, $errStr, 30);
if ($socket)
{
@socket_set_blocking ($socket, FALSE);
@fwrite ($socket, $strHeaders);
}
while (!@feof ($socket))
{
$this->buffer .= @fgets ($socket, 8192);
}
if ($socket)
{
@fclose ($socket);
}
$initStr = strpos ($this->buffer, "\r\n\r\n");
$this->buffer = trim (substr ($this->buffer, $initStr));
$fp = fopen ($this->cache_file, 'w');
fwrite ($fp, $this->buffer);
fclose ($fp);
}
$this->parseData ();
}
/**
* Data Parser
**/
function parseData ()
{
$playerInfo = split (",", $this->buffer);
/**
*
**/
/*
1,eXecute,1818,28,5,1,-1,AoCDM;
8 elements
FuriX Development Team,FuriX,1,eXecute,1818,28,5,1,-1,AoCDM;
10 elemetns
*/
if (count ($playerInfo) == 8) //without clan info
{
$pInfo = array (
'nick' => $playerInfo[1],
'rating' => $playerInfo[2],
'games' => ($playerInfo[3] + $playerInfo[4]),
'winper' => sprintf ("%.2f", @($playerInfo[3]/($playerInfo[3] + $playerInfo[4])) * 100),
'wins' => $playerInfo[3],
'losses' => $playerInfo[4],
'inc' => $playerInfo[5],
'streak' => $playerInfo[6],
'tag' => ''
);
}
elseif (count ($playerInfo) == 10) // with Clan Info
{
$pInfo = array (
'nick' => $playerInfo[3],
'rating' => $playerInfo[4],
'games' => ($playerInfo[5] + $playerInfo[6]),
'winper' => sprintf ("%.2f", @($playerInfo[5]/($playerInfo[5] + $playerInfo[6])) * 100),
'wins' => $playerInfo[5],
'losses' => $playerInfo[6],
'inc' => $playerInfo[7],
'streak' => $playerInfo[8],
'tag' => $playerInfo[1]
);
}
else
{
$pInfo = array ();
}
$this->parsedData = $pInfo;
}
/**
* Build Signature
**/
function showSignature ()
{
header ("Content-type: image/png");
$im = imagecreatefromgif ("firma.gif");
$black = imagecolorallocate ($im, 255, 255, 255);
$white = imagecolorallocate ($im, 255, 255, 255);
if (count ($this->parsedData) > 0)
{
if ($this->parsedData['tag'] != '')
{
$this->nick = '[' . $this->parsedData['tag'] . ']' . $this->parsedData['nick'];
}
else
{
$this->nick = $this->parsedData['nick'];
}
if ($this->country != '' && function_exists ('imagecreatefromgif'))
{
$imFlag = @imagecreatefromgif ('images/flags/' . strtolower ($this->country) . '.gif');
if (is_resource ($imFlag))
{
imagecopy ($im, $imFlag, 47, 7, 0, 0, 18, 12);
$this->nick = " " . $this->nick;
imagedestroy ($imFlag);
}
}
$this->parsedData['winpercent'] = sprintf ("%.2f", @$this->parsedData['wins'] / $this->parsedData['games'] * 100);
$ratingLine1 = "Games: " . $this->parsedData['games']." - Win: " . $this->parsedData['winpercent'] . "%";
$ratingLine2 = "Wins: " . $this->parsedData['wins'] . " - Losses: " . $this->parsedData['losses'] . " - Inc: " . $this->parsedData['inc'] . " - IGZ:" . $this->ladderID;
$rating = "Rating: " . $this->parsedData['rating'];
imagestring ($im, 3, 305 - imagefontwidth (4) * strlen ($rating), 6, $rating, $white);
imagestring ($im, 4, 43, 5, $this->nick, $white);
imagestring ($im, 4, 42, 5, $this->nick, $white);
imagestring ($im, 2, 49, 25, $ratingLine1, $white);
imagestring ($im, 2, 49, 25, $ratingLine1, $white);
imagestring ($im, 2, 49, 35, $ratingLine2, $white);
imagestring ($im, 2, 49, 35, $ratingLine2, $white);
}
else
{
imagestring ($im, 2, 110, 20, "No Rating Information", $white);
}
imagepng ($im);
imagedestroy ($im);
}
}
$signature = new CIGZSignature ($_GET['nick'], $_GET['laddder'], $_GET['country']);
$signature->getRatings ();
$signature->showSignature ();
?>Obrigado.











