Computer Science Canada

How do you do that image thing?

Author:  JayLo [ Tue Feb 03, 2004 8:50 pm ]
Post subject:  How do you do that image thing?

Primarily directed to Amailer because i saw that image first. It's his old sig picture with the stats of his site. How would you do that?

Author:  Amailer [ Tue Feb 03, 2004 9:05 pm ]
Post subject: 

ah, yes.
php.

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);
}

$logged_online = 0;

$prev_user_id = 0;

while( $row = $db->sql_fetchrow($result) )
{
   // User is logged in and therefor not a guest
   if ( $row['session_logged_in'] )
   {
      // Skip multiple sessions for one user
      if ( $row['user_id'] != $prev_user_id )
      {
            $logged_online++;
      }

      $prev_user_id = $row['user_id'];
   }
}

$image = "termix-sig.png";
$im = imagecreatefrompng($image);
$tc  = ImageColorAllocate ($im, 129, 129, 129);
$red  = ImageColorAllocate ($im, 107, 8, 9);
$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+175;
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
ImageString($im, 3, 100, 2, "Statistics for $sitename", $tc);
ImageString($im, 2, 100, 15, "PHPBB Version: $version", $tc);
ImageString($im, 2, 100, 25, "Members: $total_users - ", $tc);
ImageString($im, 2, $leerzeichen, 25, "Online: $logged_online", $red);
ImageString($im, 2, 100, 35, "Total Posts: $total_posts Posts in $total_topics Topics", $tc);
ImageString($im, 2, 100, 45, "Newest Member: $newest_user", $tc);
header("Content-type: image/png");
Imagepng($im,'',100);
ImageDestroy ($im);
?>



Posted Image, might have been reduced in size. Click Image to view fullscreen.


: