GDLib Sig

BrettFreeman

New Member
Messages
106
Reaction score
0
Points
0
I've started playing around with the GDLib functions in PHP. It's pretty fun to work with. Here is a sig that I created. It tells how many times it's been viewed, the users browser and the users IP. Please rate it!

test.php
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
When I get home in a little bit, I'll post my script for a sig I made in php. I got *whatever* user ids' information for whatpulse from a xml doc., and would write the info on there accordingly. I had the options to change background, and font colors.


:kiss:
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Chocolate?

Plzkthx? lol


Here goes. Adjust the fields in bold to change the different "options". Upload the image, or all, to a folder named images, and there ya go. The colors are in r-p-g "form", NOT hex.


Function.php -

PHP:
<?php
function UserStats($userid)
	{
		$WhatPulseStats = array();
		$stat_types = array("UserID", "AccountName", "Country",
		 			"DateJoined", "Homepage", "LastPulse", 
		 			"Pulses", "TotalKeyCount", "TotalMouseClicks",
		 		 "AvKeysPerPulse", "AvClicksPerPulse", 
		 			"AvKPS", "AvCPS", "Rank", "TeamID", 
		 			"TeamName", "TeamMembers", "TeamKeys", 
		 			"TeamClicks", "TeamDescription", 
		 		 "TeamDateFormed", "RankInTeam", "GeneratedTime");
		   $data = @implode("", file("http://whatpulse.org/api/users/".$userid.".xml"));
		   $parser = xml_parser_create();
		   xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
		   xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
		   xml_parse_into_struct($parser, $data, $values, $tags);
		   xml_parser_free($parser);
		   

		   foreach ($tags as $key => $val) 
			   {
			   if ($key == "UserStats") 
				   {
				   $ranges = $val;
		 		for ($i = 0; $i < count($ranges); $i += 2) 
				   {
					$offset = $ranges[$i] + 1;
					$len = $ranges[$i + 1] - $offset;
		 		$statsarray = array_slice($values, $offset, $len);
		 		foreach($statsarray as $key => $value)
			{
		 			for($i = 0; $i < count($stat_types); $i++)
			{
		 		 	if($value['tag'] == $stat_types[$i]) 
			{
		 		 		$type = $stat_types[$i];
		 		 		$WhatPulseStats[$type] = $value['value'];
			}
			} 
			} 
			} 
			} else {
			continue;
			}
			} 
		
		return $WhatPulseStats;
}
?>

(credits to whatpulse.org for that)


Sig.php -

Code:
<?php
header("Content-type: image/gif");
include('function.php');

############################
## Get User's ID From Url ##
############################

$id = [b]119431[/b];
$stats = UserStats($id);


##################
## Create Image ##
##################

$BGImage = imagecreatefromgif("[b]bg1.gif[/b]");


#############################################
## Set The String Vars' To Diffrent Values ##
#############################################

$Line1 = "Username:";
$Line2 = ucfirst($stats['AccountName']);
$Line3 = "Team:";
$Line4 = $stats['TeamName'];
$Line5 = "Keys:";
$Line6 = $stats['TotalKeyCount'];
$Line7 = "Clicks:";
$Line8 = $stats['TotalMouseClicks'];
$Line9 = "Rank:";
$Line10 = $stats['Rank'];
$Line11 = "Team Rank:";
$Line12 = $stats['RankInTeam'];


######################################################
## Create Variables Holding User's Information From ##
######################################################

#########################################
##		   RPG Font Colors		   ##
##					   ##
## Each value can be between 0 and 255 ##
## First set is for the "title" text   ##
## Second set is for the "value" text  ##
#########################################

###########
## First ##
###########

$r1 = [b]0[/b];
$b1 =[b] 0[/b];
$g1 =[b] 0[/b];

############
## Second ##
############

$r2 = [b]84[/b];
$g2 = [b]123[/b];
$b2 = [b]84[/b];



##############################
## If No Colors, Both Black ##
##############################

if (!$g2) { $g2 = 0; }
if (!$r2) { $r2 = 0; }
if (!$b2) { $b2 = 0; }
if (!$g1) { $g1 = 0; }
if (!$r1) { $r1 = 0; }
if (!$b1) { $b1 = 0; }

#######################################
## Create Colors To Use In The Image ##
#######################################

$color1 = imagecolorallocate($BGImage, $r1, $g1, $b1);
$color2 = imagecolorallocate($BGImage, $r2, $g2, $b2);

#################
## Define Font ##
#################

$font = "[b]mckenzie.ttf[/b]";


##################################################
## Start Placeing User's Information Onto Image ##
##################################################

##################
## Col 1, Row 1 ##
##################

imagettftext($BGImage, 15, 0, 7, 23, $color1, $font, $Line1);
imagettftext($BGImage, 15, 0, 65, 23, $color2, $font, $Line2);

##################
## Col 1, Row 2 ##
##################

imagettftext($BGImage, 15, 0, 7, 52, $color1, $font, $Line3);
imagettftext($BGImage, 15, 0, 40, 52, $color2, $font, $Line4);

##################
## Col 2, Row 1 ##
##################

imagettftext($BGImage, 15, 0, 165, 23, $color1, $font, $Line5);
imagettftext($BGImage, 15, 0, 197, 23, $color2, $font, $Line6);

##################
## Col 2, Row 2 ##
##################

imagettftext($BGImage, 15, 0, 165, 52, $color1, $font, $Line7);
imagettftext($BGImage, 15, 0, 200, 52, $color2, $font, $Line8);

##################
## Col 3, Row 1 ##
##################

imagettftext($BGImage, 15, 0, 275, 23, $color1, $font, $Line9);
imagettftext($BGImage, 15, 0, 308, 23, $color2, $font, $Line10);

##################
## Col 3, Row 2 ##
##################

imagettftext($BGImage, 15, 0, 275, 52, $color1, $font, $Line11);
imagettftext($BGImage, 15, 0, 338, 52, $color2, $font, $Line12);



##################
## Finish Image ##
##################



imagegif($BGImage);


############################
## Destroy Finished Image ##
############################

imagedestroy($BGImage);
?>


That *should* work. If you want to change the background image, change the:
Code:
$BGImage = imagecreatefromgif("[b]bg1.gif[/b]");

To what you want.

Everytign else should be self-explaining, if you know even some php. If you need help, post here and I will try my best to help you.

In order for this to work, you must go to your WhatPulse account, in the options there, and set the option to "generate XML stats", if you don't, this WILL NOT work. To get *your* stats, change the id variable all the way at the top.

Font:

http://www.nedren.elementfx.com/mckenzie.ttf


If you change teh font, which some of you ppl might, you might have to edit the locations of the text. If you need help, like I said, post here.
 
Last edited:

n4tec

Active Member
Messages
3,312
Reaction score
0
Points
36
I like it!!! Cool sig and scripts!!!

*4*
 
Top