MyBB Community Forums

Full Version: [Download] MyBB Statistics Signature
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
Hm no, I don't want any credit...
Oh, well then yeah, sure, we can work on a great free one. Wink
Ok,

first, I replaced all language strings and db queries with mybb internal functions. so it make use of the mybb cache and it is language neutral.
Also I add a special header that allows browsers to cache the file:

statsig.php
<?php
define('IN_MYBB',1);
define('NO_ONLINE',1);
require_once './global.php';
$lang->load('stats');
$stats=$cache->read('stats');

header('Content-type: image/png');
header('Last-Modified: Sat, 26 Jul 1997 05:00:00 GMT'); // really this is a hard caching method...

$img = imageCreateFromPNG('statsig.png');
$fontcolor = ImageColorAllocate ($img, 0, 0, 0);

ImageString ($img, 2, 15, 10, utf8_decode($lang->members).' '.$stats['numusers'], $fontcolor);
ImageString ($img, 2, 135, 10, utf8_decode($lang->posts).' '.$stats['numposts'], $fontcolor);
ImageString ($img, 2, 255, 10, utf8_decode($lang->threads).' '.$stats['numthreads'], $fontcolor);
ImageString ($img, 2, 80, 40, utf8_decode($mybb->settings['bbname']).' - '.$mybb->settings['bburl'], $fontcolor);

ImagePng ($img);
ImageDestroy ($img);
?>

now nobody needs to touch the file. Exclamation

just copy the the statsig.php and a statsig.png to root directory. that's all! Big Grin

Next idea: Create a hard linked image in ./cache/ folder and refresh it only every hour (or so)... Shy
Nice, thanks for the help, I just modified it a bit so the link is centered.

I'll update the first post with the new download. Wink
anybody else who want's to perfect this signature mod? Smile
(2009-07-10, 06:02 PM)querschlaeger Wrote: [ -> ]Someone else want's to perfect this signature mod? Smile

Quote:Create a hard linked image in ./cache/ folder and refresh it only every hour (or so)

Is this something you'll implement?

Cheers,
Gene
Maybe, but I have to re-read some php function manuals. Uh, I got headache some hours before...
Quote:Create a hard linked image in ./cache/ folder and refresh it only every hour (or so)
I don't get it :| What does this do?
It will create a file (the signature image) in cache folder and load it to browser directly if it exsits. This will improve the image loading time and reduces the server load severely.

I'm working on it. Toungue
Cool. Sounds great, good luck then.
Pages: 1 2 3 4 5 6 7