Dynamic Forum Signature
Moderators: The|Tune|Of|Turbo, zangetsuBankai
5 posts • Page 1 of 1
Dynamic Forum Signature
Today We Are Going To Make A Dynamic Forum Signature.
These are those signatures that read from your PHPBB statistics, then write to a PNG file. When the file is called for, it appears as a GIF, even though it is really a dynamic PHP file. Confused? Read On.
First, Create a Directory in http://www.yoursite.com/phpBB2/
called sig.gif (Exactly as it is written, the directory must be named "sig.gif" without quotations)
Now, in that directory, create a PHP file called index.php. Again, exactly as written.
In index.php, paste this code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '.././';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
$sql = "SELECT u.username, u.user_id, s.session_logged_in, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
$user_forum_sql
ORDER BY u.username ASC, s.session_ip ASC";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
}
$sql2 = " SELECT session_time "
. " FROM " . SESSIONS_TABLE
. " WHERE session_logged_in = 0 "
. " AND session_time >= " . ( time() - 300 )
. " ORDER BY session_time DESC";
if(!$result2 = $db->sql_query($sql2))
{
message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql2);
}
$onlinerow_guest = $db->sql_fetchrowset($result2);
$guests_online = count($onlinerow_guest);
$total_online_users = $registered_user_online + $guests_online;
$logged_online = 0;
$prev_user_id = 0;
while( $row = $db->sql_fetchrow($result) )
{
if ( $row['session_logged_in'] )
{
if ( $row['user_id'] != $prev_user_id )
{
$logged_online++;
}
$prev_user_id = $row['user_id'];
}
}
$image = "../images/signature.png";
$im = imagecreatefrompng($image);
$tc = ImageColorAllocate ($im, 0, 0, 0);
$red = ImageColorAllocate ($im, 255, 0, 0);
$green = ImageColorAllocate ($im, 23, 124, 17);
$dblue = ImageColorAllocate ($im, 0, 0, 255);
$grey = ImageColorAllocate ($im, 240, 240, 240);
$white = ImageColorAllocate ($im, 255, 255, 255);
$version = '2'.$board_config['version'];
$sitename = $board_config['sitename'];
$total_users = get_db_stat('usercount');
$total_posts = get_db_stat('postcount');
$total_topics = get_db_stat('topiccount');
$j = strlen($total_users);
$leerzeichen = $j*6+237;
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
ImageString($im, 3, 148, 1, "22Pixels", $white);
ImageString($im, 2, 148, 13, "Total Members: $total_users", $grey);
ImageString($im, 2, $leerzeichen, 13, " Members Online: $logged_online - Guests: $guests_online", $white);
ImageString($im, 2, 148, 25, "A total of $total_posts Posts in $total_topics Topics", $grey);
ImageString($im, 2, 148, 36, "Newest 22Pixels Member: $newest_user", $white);
ImageString($im, 2, 148, 47, "Sig Made Via 22Pixels Tutorials [22Pixels.com]", $white);
header("Content-Type: image/png");
Imagepng($im,'',100);
ImageDestroy ($im);
?>
Green Should Be Changed To Your Site Name.
Blue Will Be The Location Of Your Image File.
Now, once you've got that all set, Create your Sig Image. If you don't have one, feel free to use the 22Pixel Sig Image, Found Here:
http://22pixels.com/forums/images/signature.png
Save your image as signature.png, and upload to the http://www.yoursite.com/phpBB2/images/ directory.
If you did all that correctly, you should be able to see your signature's live stats. Visit http://www.yoursite.com/phpBB2/sig.gif to view your dynamic signature.
The trick is, that PHPBB2 will not remotely include a php file. If you trick it into thinking that its loading a gif, instead of a php file that is generating a gif, everything works out, and your image is displayed.
To display your image in a forum, use this coding:
Now, want to change the text and colors? This is when you need to open photoshop.
If you take a look at the first line of text:
ImageString($im, 3, 148, 1, "22Pixels", $white);
See The $white? That is calling for the codes of the White color. You can find this coding a few lines up, as:
$white = ImageColorAllocate ($im, 255, 255, 255);
The Bold is the color that was asked for, White. The Blue numbers are the RGB color values of white.
So open up photoshop and double click on your Foreground Color Pad.
Get the color you want from the selection, then look at the image below.
Make a record of the three boxes on the lower left hand side of the right part of the selection box. These are your RGB color values.
In our case, we want to change our white to a green.
These are our RGB color values:
1st- R=52
2nd- G=138
3rd- B=41
Now take another look at the line of code again.
$white = ImageColorAllocate ($im, 255, 255, 255);
The Red Value Is The First Value,
The Green Value Is the Second Value,
The Blue Value Is The Third Value.
So Our Final Color Code Would Look Like This:
$white = ImageColorAllocate ($im, 52, 138, 41);
And All Our Text Defined As White Would Now Be Green (But The Variable Is Still Named White)
Thats All, Hope This Helps You Guys Out!
If You Liked This Tutorial Please Register In The Forums! Thanks!
These are those signatures that read from your PHPBB statistics, then write to a PNG file. When the file is called for, it appears as a GIF, even though it is really a dynamic PHP file. Confused? Read On.
First, Create a Directory in http://www.yoursite.com/phpBB2/
called sig.gif (Exactly as it is written, the directory must be named "sig.gif" without quotations)
Now, in that directory, create a PHP file called index.php. Again, exactly as written.
In index.php, paste this code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = '.././';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
$sql = "SELECT u.username, u.user_id, s.session_logged_in, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
$user_forum_sql
ORDER BY u.username ASC, s.session_ip ASC";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
}
$sql2 = " SELECT session_time "
. " FROM " . SESSIONS_TABLE
. " WHERE session_logged_in = 0 "
. " AND session_time >= " . ( time() - 300 )
. " ORDER BY session_time DESC";
if(!$result2 = $db->sql_query($sql2))
{
message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql2);
}
$onlinerow_guest = $db->sql_fetchrowset($result2);
$guests_online = count($onlinerow_guest);
$total_online_users = $registered_user_online + $guests_online;
$logged_online = 0;
$prev_user_id = 0;
while( $row = $db->sql_fetchrow($result) )
{
if ( $row['session_logged_in'] )
{
if ( $row['user_id'] != $prev_user_id )
{
$logged_online++;
}
$prev_user_id = $row['user_id'];
}
}
$image = "../images/signature.png";
$im = imagecreatefrompng($image);
$tc = ImageColorAllocate ($im, 0, 0, 0);
$red = ImageColorAllocate ($im, 255, 0, 0);
$green = ImageColorAllocate ($im, 23, 124, 17);
$dblue = ImageColorAllocate ($im, 0, 0, 255);
$grey = ImageColorAllocate ($im, 240, 240, 240);
$white = ImageColorAllocate ($im, 255, 255, 255);
$version = '2'.$board_config['version'];
$sitename = $board_config['sitename'];
$total_users = get_db_stat('usercount');
$total_posts = get_db_stat('postcount');
$total_topics = get_db_stat('topiccount');
$j = strlen($total_users);
$leerzeichen = $j*6+237;
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
ImageString($im, 3, 148, 1, "22Pixels", $white);
ImageString($im, 2, 148, 13, "Total Members: $total_users", $grey);
ImageString($im, 2, $leerzeichen, 13, " Members Online: $logged_online - Guests: $guests_online", $white);
ImageString($im, 2, 148, 25, "A total of $total_posts Posts in $total_topics Topics", $grey);
ImageString($im, 2, 148, 36, "Newest 22Pixels Member: $newest_user", $white);
ImageString($im, 2, 148, 47, "Sig Made Via 22Pixels Tutorials [22Pixels.com]", $white);
header("Content-Type: image/png");
Imagepng($im,'',100);
ImageDestroy ($im);
?>
Green Should Be Changed To Your Site Name.
Blue Will Be The Location Of Your Image File.
Now, once you've got that all set, Create your Sig Image. If you don't have one, feel free to use the 22Pixel Sig Image, Found Here:
http://22pixels.com/forums/images/signature.png
Save your image as signature.png, and upload to the http://www.yoursite.com/phpBB2/images/ directory.
If you did all that correctly, you should be able to see your signature's live stats. Visit http://www.yoursite.com/phpBB2/sig.gif to view your dynamic signature.
The trick is, that PHPBB2 will not remotely include a php file. If you trick it into thinking that its loading a gif, instead of a php file that is generating a gif, everything works out, and your image is displayed.
To display your image in a forum, use this coding:
- Code: Select all
[url=http://www.22pixels.com][img]http://www.yoursite.com/phpBB2/sig.gif[/img][/url]
Now, want to change the text and colors? This is when you need to open photoshop.
If you take a look at the first line of text:
ImageString($im, 3, 148, 1, "22Pixels", $white);
See The $white? That is calling for the codes of the White color. You can find this coding a few lines up, as:
$white = ImageColorAllocate ($im, 255, 255, 255);
The Bold is the color that was asked for, White. The Blue numbers are the RGB color values of white.
So open up photoshop and double click on your Foreground Color Pad.
Get the color you want from the selection, then look at the image below.
Make a record of the three boxes on the lower left hand side of the right part of the selection box. These are your RGB color values.
In our case, we want to change our white to a green.
These are our RGB color values:
1st- R=52
2nd- G=138
3rd- B=41
Now take another look at the line of code again.
$white = ImageColorAllocate ($im, 255, 255, 255);
The Red Value Is The First Value,
The Green Value Is the Second Value,
The Blue Value Is The Third Value.
So Our Final Color Code Would Look Like This:
$white = ImageColorAllocate ($im, 52, 138, 41);
And All Our Text Defined As White Would Now Be Green (But The Variable Is Still Named White)
Thats All, Hope This Helps You Guys Out!
If You Liked This Tutorial Please Register In The Forums! Thanks!
Contact me on AIM: TwentyTwoPixels
-

Sw1tch - Posts: 1084
- Joined: Sat Sep 03, 2005 10:33 pm
- Location: NJ
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest

