How to make a self updating sig

Speedy

Machine Gun Funk
Joined
Jun 15, 2003
Messages
3,049
Reaction score
0
Location
Washington DC
A friend form another forum showed me this.

All it is php script that includes the global.php file, makes 3 queries and writes the value to a image using GD

To use it you need a server that supports GD


Code:
<?
error_reporting(7);

//Placement of stats on underlying signature image
//Please adjust these as necessary
//Created by tkeil69575, 03/2003, <a href="http://www.tk-doku.com" target="_blank">[url]http://www.tk-doku.com[/url]</a>

$width = 260; //Width in pixel of signature image
$height = 60; //Height in pixel of signature image
$left = 155; //Indent of Stats from left edge
$top = 8; //Distance from top of signature image
$zeilenabstand = 15; //Line spacing of stats text
$vorlagedatei = "images/signatur/sig.jpg";  //Relative path to underlying signature image
$ausgabedatei = "images/signatur/signatur.jpg"; //Relative path and Name to new signature image with stats
$komprimierung = 50; //Compression of signature image with stats (100 = No Compression)


################ DO NOT EDIT BELOW #################
require("./global.php");

// get forum members
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users, MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);

// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);

//get total threads
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);

$text = "Members: $numbermembers\nThreads: $totalthreads\nPosts: $totalposts\n";

$worte = split("\n", $text);
if(is_array($worte)){
       $i = 0;
       foreach($worte as $wort){
       $i++;
       $output[$i] = $wort;
       }
}

$vorlage = imagecreatefromjpeg("./$vorlagedatei");
$img = imagecreate($width,$height);

$bg_color = imagecolorallocate ($img, 255, 255, 255);//RGB values - Backgroundcolor of stats
$text_color = imagecolorallocate ($img, 255, 255, 255);//RGB values - Textcolor stats
imagefilledrectangle ($img, 0, 0, $width, $height, $bg_color);

imagecopy ($img, $vorlage, 0, 0, 0, 0, $width, $height); // Copy stats

imagecolortransparent($img, $bg_color);  // Set Background transparent

$i = 0;
while($i < count($output)){
imagestring($img, 2, $left, (($i * $zeilenabstand) - $zeilenabstand + $top), $output[$i], $text_color);
$i++;
}

header("Content-Type: image/png");
imagepng($img);
imagejpeg($img, "./$ausgabedatei",$komprimierung);
imagedestroy($img); // get the image out of memory
?>
As you can see. You can change the mysql variables if you want it to work with something other than vbulletin.

Thanks 'Root' for posting that.
 
Top