I have been trying to find a way to make a custom mini profile background. I have looked everywhere and this code is all I can find. I have absolutely no knowlege of php so please bear with my questions.
I would like to know if any of you can tell me how exactly I am to use this code. Like how it works and what to i need to execute it. This is the only thing I could find that may do what I want. Here is the code:
<?php
/*
Signature Image Generator
Version 1.2
Last updated: September 13th, 2005
by Jonathan Preston
Use of any and all of this code is permitted without restriction,
with the exception that any substantial use of this code should
be acknowledged as the work of the original author within the
source code and any documentation.
By using this code, you hereby indemnify the author of any and
all liability resulting from its use.
*/
function xfire_read($name) { //return an array of game names and play times as given in the specified user's Xfire profile
if($content = file_get_contents('http://www.xfire.com/xf/modules.php?name=XFire&file=profile&uname='.$name)) { //attempt to open the target user's xfire profile page and read its contents into a variable - if this was successful, continue
/* Retreive needed data from profile page */
preg_match_all("/\<td\>\<img src\=\"(.*?)\" width\=\"16\" height\=\"16\"\>\<\/td\>(.*?)\<td nowrap\>(.*?)\<\/td\>(.*?)\<td align\=\"center\" nowrap\>(.*?)\<\/td\>(.*?)\<td align\=\"center\" nowrap\>(.*?)\<\/td\>/s", $content, $gamedata); //retreive all game data
preg_match_all("/\<span class\=\"label\"\>(.*?)\:\<\/span\> (.*?)\<br\>/", $content, $profile); //retreive profile data - name, age, gender, etc
/**/
/* Sort game data and store it to a temp array */
$gamearray = array(); //create an array to store our sorted game data in
foreach($gamedata[3] AS $num => $name) { //for each game name returned from above searches
$gamearray[$name]["Icon"] = $gamedata[1][$num]; //put icon path into temporary array
$gamearray[$name]["WeekTime"] = str_replace(array(' hrs',' hr','less than one hour','-'), array(' hours',' hour','<1 hour','0 hours'), $gamedata[5][$num]); //fix this week's playing time data for the current game and then store it to the temporary array
$gamearray[$name]["TotalTime"] = str_replace(array(' hrs',' hr','less than one hour','-'), array(' hours',' hour','<1 hour','0 hours'), $gamedata[7][$num]); //fix total playing time data for the current game and then store it to the temporary array
}
/**/
/* Sort profile data and store it to a temp array */
$profilearray = array(); //create an array to store our sorted profile data in
foreach($profile[1] AS $num => $name) { //for each profile item
if($name == "Web Site") { //if we're dealing with the web site field
$profile[2][$num] = preg_replace("/\<a href\=\"(.*?)\"\>(.*?)\<\/a\>/", "$2", $profile[2][$num]); //remove html tag data from web site data
}
elseif($name == "Email") { //if we're dealing with the email field
$profile[2][$num] = preg_replace("/\<a href\=\"mailto\:(.*?)\"\>(.*?)\<\/a\>/", "$2", $profile[2][$num]); //remove html tag data
}
$profilearray[$name] = $profile[2][$num]; //copy the profile item into the temp array
}
/**/
/* Set up output array */
$output = array(); //create an array to store our output data in
$output["Games"] = $gamearray; //create an array for game data
$output["Profile"] = $profilearray; //create an array for profile data
/**/
return $output; //return the output array to the main program
}
else { //if unable to read xfire profile page
return -1; //return error code
}
}
function di_read() {
if($content = file_get_contents('http://www.the-dragon.net/di/members.php')) { //if we can open the DI membership page
preg_match_all("/color\=\"999999\">(.*?)<\/font>/", $content, $data); //set up match to retreive all names, ranks, statuses, and credit counts
$output = array(); //set up output array
for($i = 0 ; $i < count($data[1]) ; $i++) {
$name = str_replace(array('<b>','</b>'),array('',''),$data[1][$i]);
$i++; //increment index to get to the rank of this member
$output[$name]["Rank"] = $data[1][$i]; //store rank in output array
$i++; //increment index to get to the status of this member
$output[$name]["Status"] = $data[1][$i]; //store status in output array
$i++; //increment index to get to the credit count of this member
$output[$name]["Credits"] = $data[1][$i]; //store credit count in output array
}
return $output; //return the output array to the main program
}
}
$xfire = xfire_read('pcmaster'); //read xfire data for specified username
$di = di_read(); //read all di member data
/ Get current online status from cropped XFire mini profile /
$img = imagecreatefrompng('http://miniprofile.xfire.com/pcmaster.png'); //open default mini profile image
$tmpimage = imagecreatetruecolor(80, 15); //create a new image to store cropped online status
imagecopy($tmpimage, $img, 0, 0, 115, 48, 80, 15); //copy online status to new image
imagedestroy($img); //destroy the mini profile image that was opened
$img = $tmpimage;
/**/
/ Get hash of image /
ob_start();
imagepng($img);
$data = ob_get_contents();
ob_end_clean();
$statushash = md5($data);
/**/
/ Precomputed hashes - used same code as above and verified status /
$statushash_online = '6d55074b2d434cfd653f19194b8d06ce';
$statushash_offline = 'c18a65bc024755a30731d2d9f62052b4';
/**/
/ Compare hash to known hashes and create online status text /
if($statushash == $statushash_online) {
$statustext = 'Online';
$size = 14;
}
elseif($statushash == $statushash_offline) {
$statustext = 'Offline';
$size = 14;
}
else {
$statustext = 'Playing a game...';
$size = 12;
}
/**/
/ Create image, set font, define basic colors that we'll use /
$image = imagecreatefromjpeg('sigbg.jpg'); //create an image from our existing background
$font = 'HEMIHEAD.TTF'; //set font to be used
$background = imagecolorallocate($image, 0, 0, 0); //set background color - we don't really need to do this, but the first call to this function always sets bg color
$white = imagecolorallocate($image, 255, 255, 255); //define a white color for use later
$black = imagecolorallocate($image, 0, 0, 0); //define a black color for use later
/**/
/ Output XFire text /
imagettftext($image, $size, 0, 10, 137, $white, $font, 'Status: '.$statustext);
imagettftext($image, 11, 0, 160, 148, $white, $font, 'This Week');
imagettftext($image, 11, 0, 180, 161, $white, $font, 'All Time');
imagettftext($image, 11, 0, 266, 133, $white, $font, 'Jedi Knight II');
imagettftext($image, 11, 0, 263, 148, $white, $font, $xfire['Games']['Jedi Knight II Multiplayer']['WeekTime']);
imagettftext($image, 11, 0, 263, 161, $white, $font, $xfire['Games']['Jedi Knight II Multiplayer']['TotalTime']);
imagettftext($image, 11, 0, 373, 133, $white, $font, 'Jedi Academy');
imagettftext($image, 11, 0, 370, 148, $white, $font, $xfire['Games']['Jedi Academy Multiplayer']['WeekTime']);
imagettftext($image, 11, 0, 370, 161, $white, $font, $xfire['Games']['Jedi Academy Multiplayer']['TotalTime']);
/**/
/ Open and copy game icons to image /
$icon = imagecreatefromgif($xfire['Games']['Jedi Knight II Multiplayer']['Icon']); //open JKII icon
imagecopyresampled($image, $icon, 253, 123, 0, 0, 11, 11, 16, 16); //copy and resize icon into main image
imagedestroy($icon); //close icon
$icon = imagecreatefromgif($xfire['Games']['Jedi Academy Multiplayer']['Icon']); //open JA icon
imagecopyresampled($image, $icon, 360, 123, 0, 0, 11, 11, 16, 16); //copy and resize icon into main image
imagedestroy($icon); //close icon
/**/
/ Create shadowed text for DI credit count /
imagettftext($image, 12, 0, 156, 96, $black, $font, $di['PC Master']['Credits'].' Credits'); //create shadow layer first so it appears behind main text
imagettftext($image, 12, 0, 154, 94, $white, $font, $di['PC Master']['Credits'].' Credits'); //create main text layer - same text as shadow, but offset +2 px in each direction
/**/
/ Output the image /
header('Content-type: image/png'); //send header so browser knows what type of image
imagepng($image); //send image data to browser
/**/
?>
this is the code as it was posted in the forums i took it from. please help me use this.
Thanks in advance.