PDA

View Full Version : Stats in Image


Mr Chad
09-17-2005, 03:10 AM
I have this code:
<?php

// ################################################## #####################
// ################################################## #####################
// ## ##
// ## SIGNATURE STATS V3.04 ##
// ## ---------------------------- ##
// ## By Dan Ward ##
// ## www.collegepranks.co.uk ##
// ## ##
// ################################################## #####################
// ################################################## #####################
// ########### developed from tkeil69575's script for 2.3.x ##############

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

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

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

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

//////////////////////////////////////////////////////////////////////////
//
// Instructions
// ============
//
// Edit the 'ENTER DATABASE INFORMATION' and 'ENTER IMAGE INFORMATION' sections
// then edit the 'OUTPUT TEXT' and 'TEXT FORMATTING' sections
//
//////////////////////////////////////////////////////////////////////////

// #################### ENTER DATABASE INFORMATION #######################
//DB-Servername
$host = "";

//DB-Username
$user= "";

//DB-Password
$password= "";

//vbulletin database name
$database="";

//E-Mail Address where MySQL Error Messages are sent to
$adminemail = "";


// ###################### ENTER IMAGE INFORMATION #########################

//Width of banner image
$width = 300;

//Height of banner image
$height = 60;

//Left text-margin
$left = 26;

//text-margin from top
$top = 63;

//Font Size
$fontsize = 1;

//If you have GD2 or higher set $sgdver to 1, for any older GD version set $sgdver to 0
$sgdver = 1;

//If you wish to use a TrueType font set $ttfe to 1, for default php font set $ttfe to 0
$ttfe = 0;

//If you wish to use a TrueType font, please enter the location to the .ttf file below
$ttff = "verdana.ttf";

//Line-spacing of text
$zeilenabstand = 15;

//full path to empty signature image (input image)
$vorlagedatei = "sig.jpg";

//full path to signare image with forum data (output image)
$ausgabedatei = "signature.jpg";

//Compression of output image
$komprimierung = 95;

//debug mode
$debug = 0;

// ######################### DO NOT EDIT BELOW ############################

function mysql_query_eval($query, $database) {
$mysql_eval_error="";
$mysql_eval_result = mysql_query($query, $database) or $mysql_eval_error = mysql_error();
if ($mysql_eval_error) {
if ( $debug == 1 ) {
$letter = "An error was encountered during execution of the query:\n\n";
$letter .= $query."\n\n";
$letter .="The query returned with an errorcode of: \n\n$mysql_eval_error\n\n";
$letter .="To turn this email off set debug=0 in signature.php\n\n";
$email_from = "From: ".$adminemail;
$subject="Subject: Signature Error Report";
$subject=trim($subject);
mail( $email, $subject, $letter, $email_from );
} elseif ( $debug == 2 ) {
dieWell( "MySQL error reported!<p>Query: $query<p>Result: $mysql_eval_error<p>Database handle: $database" );
exit;
}
return FALSE;
} else {
return $mysql_eval_result;
}
}

// CONNECTING TO DATABASE
$link = mysql_connect ("$host", "$user", "$password") or die ('I cannot connect to the database.');
mysql_select_db ("$database")or die("Could not select database");

// GETTING FORUM MEMBERS
$querya="SELECT COUNT(*) AS users, MAX(userid) AS max FROM " . TABLE_PREFIX . "user WHERE usergroupid!=4";
$numa = mysql_query_eval($querya,$link);
$numb = mysql_fetch_array($numa);
$numbermembers=number_format($numb['users']);
mysql_free_result($numa);

// GETTING TOTAL MEMBERS ONLINE

$datecut = TIMENOW - $vboptions['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 0;

$forumusers = $DB_site->query("
SELECT
user.username, (user.options & $_USEROPTIONS[invisible]) AS invisible, user.usergroupid,
session.userid, session.inforum, session.lastactivity,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
ORDER BY " . iif($permissions['genericpermissions'] & CANSEEHIDDEN, 'invisible ASC, ') . "username ASC, lastactivity DESC
");

if ($bbuserinfo['userid'])
{
// fakes the user being online for an initial page view of index.php
$bbuserinfo['joingroupid'] = iif($bbuserinfo['displaygroupid'], $bbuserinfo['displaygroupid'], $bbuserinfo['usergroupid']);
$userinfos = array
(
$bbuserinfo['userid'] => array
(
'userid' => $bbuserinfo['userid'],
'username' => $bbuserinfo['username'],
'invisible' => $bbuserinfo['invisible'],
'inforum' => 0,
'lastactivity' => TIMENOW,
'musername' => fetch_musername($bbuserinfo, 'joingroupid')
)
);
$numberregistered = 1;
$numbervisible = 1;
$loggedin = $userinfos["$bbuserinfo[userid]"];
eval('$activeusers = ", ' . fetch_template('forumhome_loggedinuser') . '";');
}
else
{
$userinfos = array();
}
$inforum = array();

while ($loggedin = $DB_site->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
$inforum["$loggedin[inforum]"]++;
}
else if (empty($userinfos["$userid"]['lastactivity']) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
$numberregistered++;
if ($userid != $bbuserinfo['userid'])
{
$inforum["$loggedin[inforum]"]++;
}
$loggedin['musername'] = fetch_musername($loggedin);
}
}

// memory saving

$activeusers = substr($activeusers , 2); // get rid of initial comma

$DB_site->free_result($loggedins);

$totalonline = $numberregistered + $numberguest;

//////////////////////////////////////////////////////////////////////////////////////////////////

// GETTING TOTAL POSTS AND THREADS
include_once('./includes/functions_forumlist.php');
cache_ordered_forums(1, 0, 0);
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$nthreads += $forum['threadcount'];
$nposts += $forum['replycount'];
$totalthreads = number_format($nthreads);
$totalposts = number_format($nposts);
}
}

// ########################### OUTPUT TEXT ###############################
// Use \n\r to make a line break (only for use with truetype font SO FAR)
// Will be developed to use with default font soon :)

//Output text
$output = "Members: $numbermembers Threads: $totalthreads Posts: $totalposts Online: $totalonline";

$vorlage = imagecreatefromjpeg("$vorlagedatei");

if ($sgdver == "1")
{
$img = imagecreatetruecolor($width,$height);
} else {
$img = imagecreate($width,$height);
}

// ########################## TEXT FORMATTING ############################

// A PNG uses ImageColorAllocate instead of ImageColorClosest like jpeg uses

//EDIT: Background Colour (not really seen)
$bg_color = imagecolorallocate ($img, 255, 255, 255);

//EDIT: Text Colour
$text_color = imagecolorallocate ($img, 19, 36, 161);

// ######################### DO NOT EDIT BELOW ############################

imagefilledrectangle ($img, 0, 0, $width, $height, $bg_color);
imagecopy ($img, $vorlage, 0, 0, 0, 0, $width, $height); // copy empty banner
imagecolortransparent($img, $bg_color); // set dummybg transparent

// the distance is in pixels and the font # is 1 through 5
$i = 0;
while($i < count($output)){

if ($ttfe == "1")
{
imagettftext($img, $fontsize, 0, $left, (($i * $zeilenabstand) - $zeilenabstand + $top), $text_color, $ttff, $output);
} else {
imagestring($img, $fontsize, $left, (($i * $zeilenabstand) - $zeilenabstand + $top), $output, $text_color);
}
$i++;
}

header("Content-Type: image/png");
imagepng($img);
imagejpeg($img, "$ausgabedatei",$komprimierung); //Write jpg to folder and set compression
imagedestroy($img); // get the image out of memory
?>

But i keep getting this error:

Fatal error: Call to a member function on a non-object in /homepages/18/d117741316/htdocs/forums/signature.php on line 140

What is wrong? Did they change some DB call function or sumthin?

Andreas
09-17-2005, 04:54 AM
This is vBulletin 3.0 Code and won't work with vBulletin 3.5

Marco van Herwaarden
09-17-2005, 04:58 AM
That script looks like a vB3.0 script. That will not work on 3.5 without some modifications.

Mr Chad
09-17-2005, 07:01 AM
some guy said it would -_- , will the mods be hard ? or is there aready one out?

Marco van Herwaarden
09-17-2005, 07:51 AM
Then this guy don't know what he is talking about.

For a coder who is experienced with vB3.5 i don't think it would be very hard. You can have a look in the vB3.5 HOW-TO forum to see what modifications should be made.

Mr Chad
09-17-2005, 07:30 PM
Then this guy don't know what he is talking about.

For a coder who is experienced with vB3.5 i don't think it would be very hard. You can have a look in the vB3.5 HOW-TO forum to see what modifications should be made.

Im not experienced O_O, so this will be extreemly hard.

Marco van Herwaarden
09-17-2005, 08:12 PM
Go read the HOW-TO section and give it a try, you might enjoy it. :D

Andreas
09-17-2005, 08:13 PM
Im not experienced O_O, so this will be extreemly hard.
Learning by doing ;)
That's how I got my PHP knowlegde as well.

Mr Chad
10-02-2005, 09:01 PM
Learning by doing ;)
That's how I got my PHP knowlegde as well.

:'( i cant do it.

Mr Chad
10-05-2005, 09:01 PM
anyone?

Mr Chad
10-15-2005, 06:05 PM
oh come on, no one has released one for 3.5