PDA

View Full Version : Mini Mods - Live Statistics Image 1.0.0 Light


Gio~Logist
10-01-2008, 10:00 PM
Brought To You By
ModernvB - Vbulletin Solutions & Services
http://www.modernvb.com

Live Statistics Image Light 1.0.0
A great way to display your website's live stats! A 468x60 image is automatically generated with your site's name, url, and a few statistics.

Live Demo:
http://www.giologist.com/vb/stats_image.php


Instructions

Upload stats_image.php
Get ready to link it away :p
(it can be used in pretty much any image tag where dynamic images are accepted)

acquiesce
10-02-2008, 05:19 PM
Can the image be posted anywhere, like signatures on other sites, for example?

I like the sound of this :)

Gio~Logist
10-02-2008, 05:21 PM
Can the image be posted anywhere, like signatures on other sites, for example?

I like the sound of this :)

Yep, wherever dynamic images are accepted.. This will be allowed. The only reason you can't do it over here on vb.org (in your signature at least) is because they attach/store their signature pictures. So even if it were possible, it'd be pointless. However, wherever you are allowed to have an image tag, you can definitely bring this along! ;)

acquiesce
10-02-2008, 05:50 PM
Fantastic. I'll be using this, would be good "word of mouth" advertising if I can get my users to use it :D

Lea Verou
10-02-2008, 06:04 PM
Is the image cached or its generated every time?
If its generated every time, it could be bad for the server load.

schlottkej
10-02-2008, 06:09 PM
Looks good (Im assuming its a cache)

Also, Im still waiting on that PM Gio~ =) )

GoTTi
10-02-2008, 06:10 PM
this is the same as that stats in signature thing a LONG time ago that came out right? but it doesnt make a png image where you can share the image, you need to share the link to the php file?

killerkraft
10-02-2008, 07:25 PM
I must admit, it's so simple it hurts my PhP programmer feelings, eheheh

Thank's and bravo.

KK

iogames
10-02-2008, 07:54 PM
Wow...

Gio~Logist
10-02-2008, 08:22 PM
this is the same as that stats in signature thing a LONG time ago that came out right? but it doesnt make a png image where you can share the image, you need to share the link to the php file?

Yea, i think there was something like this released a bit ago. I had remembered seeing someone's signature do something like this and so I decided to write a modification to do so. Not sure what you mean about sharing, but you can always have people link it to the .php file and it won't cause any security exploits of course. Other than that, there are ways to allow different urls, etc. via .htaccess.

Gio~Logist
10-02-2008, 08:23 PM
Looks good (Im assuming its a cache)

Also, Im still waiting on that PM Gio~ =) )

Yep, the thread and reply count are pulled live via the forum's cache, and the amount of members is pulled via a query.

Gio~Logist
10-02-2008, 08:24 PM
I must admit, it's so simple it hurts my PhP programmer feelings, eheheh

Thank's and bravo.

KK


Heh, not so difficult at all. It's just sometimes we over-analyze things and overlook the simpler solutions :p I'm definitely going to look into adding things though, to further allow the image outputted, etc. :)

Wow...

Glad you like it :up:

binevi
10-02-2008, 09:53 PM
2 questions : 1. How can i change background colour? i mean defult colour written as $background = imagecolorallocate( $my_img, 255, 255, 255 ); how can i replace white colour with a image?

2. i think it is a different mod but rather than showing forum statistic how can we do it for each user's statistic i usually see that in signatures in different forums

by the way great hack (;

macc
10-02-2008, 11:22 PM
nice hack - but how to change background color?

regards

macc

Gio~Logist
10-02-2008, 11:31 PM
To change the background color edit the following line in the file:
$background = imagecolorallocate( $my_img, 255, 255, 255 );

The 3 numbers (255) shown above are red,green,blue components of the color you wish to generate.

If you do not know how to find the red,green,blue components for your desire color, there are an assortment of websites you can resort to such as http://www.pagetutor.com/colorpicker/index.html

macc
10-02-2008, 11:44 PM
thanks for help!

macc

PoetJA-1975
10-03-2008, 03:17 AM
Excellent share = Thanx ;)
It would be nice to have a background IMAGE though.
Also - is there anyway - to center the text?

Thanx.

Jacquii.

https://vborg.vbsupport.ru/ (http://jpicforum.info)

TimberFloorAu
10-03-2008, 06:41 PM
Works great. Thanks.

We use another script, which I wrote to add personal info on ( in our case visas )

Will post cpl of screenies. Reason I am asking, this mod, could pull lots of global info, which would be great for at a glance stuff.

Great work mate.

The attached image, triggers on hover. Is a writeable png, and is integrated within our forum. I havent released it, as the coding is complex, and beyond most users acceptable mod and template changes.

( Only added this info, as it deploys a dynamic png ) similar to question asked within this thread

to view in action: try this link ;)

http://www.yobromofo.com/forum/barbie/5004-joke-i-have-my-doubts.html#post55601

PoetJA-1975
10-03-2008, 10:39 PM
^ Interesting - what script is that?

Jacquii.

TimberFloorAu
10-03-2008, 11:18 PM
^ Interesting - what script is that?

Jacquii.

My own :)

TilkiBey
10-04-2008, 02:01 PM
oops
an error!!!
i cant see that php page

i cant translate the error writing which shown in ff

the error writing in ie
<br /> <b>Fatal error</b>: Call to undefined function: imagecreate() in <b>c:\program files\easyphp1-8\www\forum\stats_image.php</b> on line <b>46</b><br />

TimberFloorAu
10-04-2008, 10:47 PM
Why are you calling the stats_image.php locally ?

TilkiBey
10-05-2008, 08:37 AM
Why are you calling the stats_image.php locally ?

coz i dont ve an online vB site for now

i use local vB with easyphp
for testing add-ons, styles etc...
and,for translating add-ons.

is it (using localhost) a problem for this add-on?

star88
10-05-2008, 07:20 PM
what an excellent work
merci !

TilkiBey
10-11-2008, 04:09 PM
will u ans. my question?

soqzippo
10-12-2008, 05:25 AM
Love this thing. Although how do you edit it so that it links to your website? instead of just the image


http://soqpro.com/stats_image.php (http://www.soqpro.com)

soqzippo
10-12-2008, 05:28 AM
Excellent share = Thanx ;)
It would be nice to have a background IMAGE though.
Also - is there anyway - to center the text?

Thanx.

Jacquii.

http://jpicforum.info/stats_image.php (http://jpicforum.info)

Change the numbers in red higher or lower


imagestring( $my_img, 5, 78, 0, $vbulletin->options[bbtitle], $text_colour );

imagestring( $my_img, 2,95, 15, $vbulletin->options[bburl], $text_colour );
imagesetthickness ( $my_img, 2 );
imageline( $my_img, 0, 30, 300, 30, $line_colour );

imagestring( $my_img, 2,36, 40, "Threads: $total_threads Posts: $total_posts Members: $total_members", $text_colour );

denman75
10-12-2008, 06:11 AM
installed *
another great feature from u running on my site
btw have it installed in my footer also ;)

http://www.bullterrierforum.nl/bullforums/stats_image.php

RedTrinity
10-18-2008, 10:07 AM
Brilliant little hack :)

Any way to change the font?

http://www.theparentingsanctuary.com.au/forums/stats_image.php

dodjer42
10-20-2008, 01:42 PM
This script is dangerous. It contains several db queries. By posting it on a busy forum you are effectively creating your own distributed denial of service.

A far more safe way to do this, though not updated in real time, is to run a cron job which creates the signature image every hour or so.

In regards to changing font, its pretty straight forward:

$font_size = "10";
$font_file = "bombard.ttf"
imagettftext($my_img, $font_size, 3, 0, 5, $text_colour, $font_file, $vbulletin->options[bbtitle]);

Font must be a true type.

soqzippo
10-20-2008, 11:24 PM
nobody cares.. the mod rules

dodjer42
10-21-2008, 05:50 AM
nobody cares.. the mod rules

And you speak for all?

The implementation of a statistics signature for vbulletin is a great idea, though it has been done before, and done better:

http://www.vbseo.com/blogs/danny-bembibre/forum-stats-signature-generator-63/

Gio deserves rep for it but at the same time, those considering it should be aware of the risk of this code.

Read around; lots of admins shy away from installing mods that perform even a single database query on a busy board. Now this does 3 queries for every view of the signature. Say you post this signature on a busy forum with around 100 concurrent users. You are looking at 300 mysql queries to generate a single image. Big problem!

carlos54321
10-21-2008, 08:25 AM
This script is dangerous. It contains several db queries. By posting it on a busy forum you are effectively creating your own distributed denial of service.

A far more safe way to do this, though not updated in real time, is to run a cron job which creates the signature image every hour or so.

In regards to changing font, its pretty straight forward:

$font_size = "10";
$font_file = "bombard.ttf"
imagettftext($my_img, $font_size, 3, 0, 5, $text_colour, $font_file, $vbulletin->options[bbtitle]);

Font must be a true type.

Thanks
liked this mod but as to the comment you made,your right this is not so good so until i can work out how to cron job it then ive uninstalled.
would be nice on some instructions on how to make a cron job which creates the signature image every hour or so. please:)

dodjer42
10-21-2008, 08:39 AM
Check the link above Carlos. That one has a cron built in.

Maybe Gio will include one in an update too.

carlos54321
10-21-2008, 10:45 AM
:) ahh fantastic cheers fella

Gio~Logist
11-24-2008, 08:13 AM
Updated stats_image.php to use vbulletin's datastore and forumcache to pull stats, as oppose to running queries for each.

onehost
11-24-2008, 07:30 PM
Interesting, I like this, Marked Installed.

however, i really do not like the background/font colors, anyway to change this?

TerryMason
01-05-2009, 04:40 PM
Interesting, I like this, Marked Installed.

however, i really do not like the background/font colors, anyway to change this?


Take a look at this image
http://www.pchangout.com/forum/sig5.php

I just used my own background with it:

// Gather info
$total_posts = number_format($total_posts);
$total_threads = number_format($total_threads);
$total_members = vb_number_format($vbulletin->userstats['numbermembers']);

$my_img = imagecreatefrompng("http://www.pchangout.com/images/sig/5.png");
$background = imagecolorallocate( $my_img, 255, 255, 255 );
$text_colour = imagecolorallocate( $my_img, 000, 000, 0 );
$line_colour = imagecolorallocate( $my_img, 203, 203, 203 );

private_ale
01-05-2009, 07:32 PM
Awesome idea and very customizable!
Installed :D

and because I'm in a good mood, Nominated for MOTM :)

https://vborg.vbsupport.ru/

clubbah
01-08-2009, 02:32 AM
Is there a way where you can also include how many members are currently online? Is that possible?

flup
01-19-2009, 05:08 PM
Simple & Nice, installed.

Shamil.
02-07-2009, 08:47 AM
Brilliant...Would you be able to post some tutorials on how to modify this. For example on how to change the background to an image or gradient. And mabey create some modules to create signatures for specific users rather than the whole forum.

GCSkye
03-02-2009, 01:08 PM
Take a look at this image
http://www.pchangout.com/forum/sig5.php

I just used my own background with it:

// Gather info
$total_posts = number_format($total_posts);
$total_threads = number_format($total_threads);
$total_members = vb_number_format($vbulletin->userstats['numbermembers']);

$my_img = imagecreatefrompng("http://www.pchangout.com/images/sig/5.png");
$background = imagecolorallocate( $my_img, 255, 255, 255 );
$text_colour = imagecolorallocate( $my_img, 000, 000, 0 );
$line_colour = imagecolorallocate( $my_img, 203, 203, 203 );

I got the following:

<?php
//###############################################
////////////////////// Satistics Image Light 1.0.0 Add-On /////////////////
//////----------------------- by Gio~Logist --------------------\\\\\\\\\\
/////------------------------ http://www.giologist.com/vb ---------------------\\\\\\\\\\
///////////////////////////////////////////////////////////////////////
//###############################################

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'stats_image');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(
);

// get special data templates from the datastore
$specialtemplates = array(
'userstats'
);

// pre-cache templates used by all actions
$globaltemplates = array(
);

// pre-cache templates used by specific actions
$actiontemplates = array(
);

// ######################### REQUIRE BACK-END ############################
require_once('global.php');

Header ("Content-type: image/gif");

// Count Threads and Posts
$counter = $db->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post");
$count_threads = $db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");

// Gather info
$total_posts=number_format($counter['posts']);
$total_threads = number_format($countthreads['threads']);
$total_members = vb_number_format($vbulletin->userstats['numbermembers']);

$my_img = imagecreatefrompng("http://www.evercube.net/images/eclite.png");
$background = imagecolorallocate( $my_img, 255, 255, 255 );
$text_colour = imagecolorallocate( $my_img, 000, 000, 0 );
$line_colour = imagecolorallocate( $my_img, 203, 203, 203 );

imagestring( $my_img, 3, 0, 5, $vbulletin->options[bbtitle], $text_colour );

imagestring( $my_img, 2, 0, 15, $vbulletin->options[bburl], $text_colour );
imagesetthickness ( $my_img, 2 );
imageline( $my_img, 0, 30, 468, 30, $line_colour );

imagestring( $my_img, 2, 0, 40, "Threads: $total_threads Posts: $total_posts Members: $total_members", $text_colour );

header( "Content-type: image/gif" );
imagegif( $my_img );
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
?>



The image location is right but when I view the php I get no image:
http://evercube.net/forum/stats_image.php

Any thoughts on why this isn't working?

=-=-=-= Edit

Seemed to fix itself. Thanks thou.