- Joined
- Oct 11, 2007
- Messages
- 1,706
- Reaction score
- 517
Well, I was having a hard time picking a signature for my profile, then I thought, why not use all of them instead?
So, I present to you: My random signature ... thingie.
lol basically what it does is that it randomizes my signatures every time someone refreshes and displays a different one .
(Example is in my signature).
If you want one then hit me up and I might make one for ya if I have some time over , if a lot of people want this I might just make it an automated service (it's pretty easy so).
Here's the source code if anyone is interested, it's coded like crap since well, I made this script in what, 2 hours, parts of it are not written by me and parts are, (the functions in the end arent by me.)
The rest should be mine, not sure, old script lol.
Anyhow, as you can see you also need a table with the following columns: id, sig_refresh.
And that should be it lol.
Add from alphakilo23:
So, I present to you: My random signature ... thingie.
lol basically what it does is that it randomizes my signatures every time someone refreshes and displays a different one .
(Example is in my signature).
If you want one then hit me up and I might make one for ya if I have some time over , if a lot of people want this I might just make it an automated service (it's pretty easy so).
Here's the source code if anyone is interested, it's coded like crap since well, I made this script in what, 2 hours, parts of it are not written by me and parts are, (the functions in the end arent by me.)
The rest should be mine, not sure, old script lol.
Anyhow, as you can see you also need a table with the following columns: id, sig_refresh.
And that should be it lol.
PHP:
<?php
$link = mysql_connect('ip', 'user', 'pw');
if (!$link) {
die('Could not connect to DATABASE: ' . mysql_error());
}
mysql_select_db('', $link);
/*
Coded by Justei (Kristoffer Blasiak)
For: RaGEZONE.com
*/
$q2 = mysql_query("UPDATE signature_fun SET sig_refresh = sig_refresh + 1 WHERE id = '1'")or die(mysql_error());
$q = mysql_query("SELECT * FROM signature_fun WHERE id = '1'")or die(mysql_error());
$r = mysql_fetch_row($q);
$text = 'Justei random sigs ftw ^^';
if(empty($text))
fatal_error('Error: Text not properly formatted.') ;
// customizable variables
$font_file = "ambient.ttf";
$font_size = 22 ; // font size in pts
$font_size2 = 11 ;
$i = rand(1, 7);
if($i == 1){
$font_color = '#ffffff';
$font_color2 = '#ffffff' ;
}
if($i == 2){
$font_color = '#000000';
$font_color2 = '#000000' ;
}
if($i == 3){
$font_color = '#000000';
$font_color2 = '#000000' ;
}
if($i == 4){
$font_color = '#ffffff';
$font_color2 = '#ffffff' ;
}
if($i == 5){
$font_color = '#ffffff';
$font_color2 = '#ffffff' ;
}
if($i == 6){
$font_color = '#ffffff';
$font_color2 = '#ffffff' ;
}
if($i == 7){
$font_color = '#ffffff';
$font_color2 = '#ffffff' ;
}
$image_file = 'img/'.$i.'.png';
// x and y for the bottom right of the text
// so it expands like right aligned text
$x_finalpos = 200;
$y_finalpos = 30;
// trust me for now...in PNG out PNG
$mime_type = 'image/png' ;
$extension = '.png' ;
$s_end_buffer_size = 4096 ;
// check for GD support
if(!function_exists('ImageCreate'))
fatal_error('Error: Server does not support PHP image generation') ;
// check font availability;
if(!is_readable($font_file)) {
fatal_error('Error: The server is missing the specified font.') ;
}
// create and measure the text
$font_rgb = hex_to_rgb($font_color) ;
$font_rgb2 = hex_to_rgb($font_color2) ;
$box = @ImageTTFBBox($font_size,0,$font_file,$text) ;
$text_width = abs($box[2]-$box[0]);
$text_height = abs($box[5]-$box[3]);
$image = imagecreatefrompng($image_file);
if(!$image || !$box)
{
fatal_error('Error: The server could not create this image.') ;
}
// allocate colors and measure final text position
$font_color = ImageColorAllocate($image,$font_rgb['red'],$font_rgb['green'],$font_rgb['blue']) ;
$font_color2 = ImageColorAllocate($image,$font_rgb2['red'],$font_rgb2['green'],$font_rgb2['blue']) ;
$image_width = imagesx($image);
$put_text_x = $image_width - $text_width - ($image_width - $x_finalpos);
$put_text_y = $y_finalpos;
// Write the text
$put_text_y2 = $y_finalpos + 18;
$put_text_y3 = $y_finalpos + 40;
$text2 = $r[1].' views of my sig ^^!';
$text3 = 'Coded by: Justei @ RageZone.com';
imagettftext($image, $font_size, 0, 10, $put_text_y, $font_color, $font_file, $text);
imagettftext($image, $font_size2, 0, 10, $put_text_y2, $font_color2, $font_file, $text2);
imagettftext($image, $font_size2, 0, 10, $put_text_y3, $font_color2, $font_file, $text3);
header('Content-type: ' . $mime_type) ;
ImagePNG($image) ;
ImageDestroy($image) ;
exit ;
function fatal_error($message)
{
// send an image
if(function_exists('ImageCreate'))
{
$width = ImageFontWidth(5) * strlen($message) + 10 ;
$height = ImageFontHeight(5) + 10 ;
if($image = ImageCreate($width,$height))
{
$background = ImageColorAllocate($image,255,255,255) ;
$text_color = ImageColorAllocate($image,0,0,0) ;
ImageString($image,5,5,5,$message,$text_color) ;
header('Content-type: image/png') ;
ImagePNG($image) ;
ImageDestroy($image) ;
exit ;
}
}
// send 500 code
header("HTTP/1.0 500 Internal Server Error") ;
print($message) ;
exit ;
}
/*
decode an HTML hex-code into an array of R,G, and B values.
accepts these formats: (case insensitive) #ffffff, ffffff, #fff, fff
*/
function hex_to_rgb($hex) {
// remove '#'
if(substr($hex,0,1) == '#')
$hex = substr($hex,1) ;
// expand short form ('fff') color to long form ('ffffff')
if(strlen($hex) == 3) {
$hex = substr($hex,0,1) . substr($hex,0,1) .
substr($hex,1,1) . substr($hex,1,1) .
substr($hex,2,1) . substr($hex,2,1) ;
}
if(strlen($hex) != 6)
fatal_error('Error: Invalid color "'.$hex.'"') ;
// convert from hexidecimal number systems
$rgb['red'] = hexdec(substr($hex,0,2)) ;
$rgb['green'] = hexdec(substr($hex,2,2)) ;
$rgb['blue'] = hexdec(substr($hex,4,2)) ;
return $rgb ;
}
?>
Add from alphakilo23:
Add:
after declaring the $image variable.PHP:imagealphablending($image, true); imagesavealpha($image, true);
Last edited: