PHP Code:
<?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 ;
}
?>