PDA

View Full Version : External PHP Private Message Stats


mark99
05-02-2004, 02:58 PM
I use a very simple piece of PHP code to show the visitors username, unread PM's and total PM's when they first visit the site. Code (what I used under vBulletin 2):

<?php

error_reporting(7);

require("global.php");

//check usergroup of user to see if they can use PMs
//$permissions=getpermissions($forumid);
if ($enablepms==1 and $permissions['canusepm'] and $bbuserinfo['receivepm']) {
$ignoreusers="";
if (trim($bbuserinfo['ignorelist'])!="") {
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' ', trim($bbuserinfo['ignorelist'])));
}

$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");

if ($newpm['messages']==0) {
echo "";
} else {
echo "";
}

} else {
$pminfo='';
}

//BEGIN HTML OUTPUT
//BE SURE TO LEAVE THE ECHO Strings in place
//Any Quotation marks need to have a \ before them

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
echo "Welcome: <b>$username</b> - <a href=\"http://www.ispreview.co.uk/talk/private.php?s=\" target=\"_parent\">New Messages</a>: <b>$newpm[messages] ($allpm[messages] Total)</b>";
} else {
echo "Welcome: <i>You must enable cookies + <a href=\"talk/register.php?s=$session[sessionhash]\" target=\"_parent\">REGISTER</a> to view stats</i>";
}

?>

Now obvious these tables have changed in vB3, in fact there are now several tables (pm, pmtext etc.) witt the data I need to access in. I'm not good at PHP, so could somebody please show me the changes required to once again be able to show the PM stats?

mark99
05-02-2004, 03:36 PM
Never mind, I found the updated hack for vB3 and cut it down again, works ok now ;).