<?php
/*
[DISCUZ!] statspng.php - board images statistics
This is NOT a freeware, use is subject to license terms
Version: 2.0.0
Author: Loveyuki ([email]webmaster@loveyuki.com[/email])
Copyright: Soar Computer Studio (www.loveyuki.com)
Last Modified: 2003/10/6 17:00
*/
define('IN_DISCUZ', TRUE);
Header("Content-type: image/PNG");
require 'config.php';
require 'include/db_'.$database.'.php';
$tables = array('members', 'posts', 'sessions', 'stats');
foreach($tables as $tablename) {
${'table_'.$tablename} = $tablepre.$tablename;
}
unset($tablename);
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$db->select_db($dbname);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$query = $db->query("SELECT count,type,var FROM $table_stats WHERE type='total' and var='hits'");
$stats = $db->fetch_array($query);
$stats = $stats['count'];
$query = $db->query("SELECT count(*) FROM $table_members");
$members = $db->result($query,0);
$query = $db->query("SELECT count(*) FROM $table_posts");
$posts = $db->result($query,0);
$query = $db->query("SELECT count(*) FROM $table_sessions");
$online = $db->result($query,0);
if(getenv('HTTP_CLIENT_IP')) {
$onlineip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR')) {
$onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR')) {
$onlineip = getenv('REMOTE_ADDR');
} else {
$onlineip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
}
$currenttime = date("Y-m-d A");
$im = @imagecreatefromgif("images/statspng.gif");
$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0,0,0);
imagestring($im, 3, 160, 2, $stats, $black);
imagestring($im, 3, 159, 1, $stats, $white);
imagestring($im, 3, 160, 17, $posts, $black);
imagestring($im, 3, 159, 16, $posts, $white);
imagestring($im, 3, 160, 32, $members, $black);
imagestring($im, 3, 159, 31, $members, $white);
imagestring($im, 3, 287, 2, $onlineip, $black);
imagestring($im, 3, 286, 1, $onlineip, $white);
imagestring($im, 3, 287, 17, $online, $black);
imagestring($im, 3, 286, 16, $online, $white);
imagestring($im, 3, 287, 32, $currenttime, $black);
imagestring($im, 3, 286, 31, $currenttime, $white);
ImagePNG($im);
ImageDestroy($im);
?>