Log in

View Full Version : would this hack use too much resources??


Justice
11-02-2001, 02:06 AM
I just wrote a hack, sort of, but before I impliment it, I wanted to ask if it would cause too much server strain.

Basically, I want a Private Message notice on my forumdisplay.php page.
I have the PM pop-up notices turned off, but I do want my members notified when they get new messages. So, I used some of the code from index.php and placed in forumdisplay.php.

Right under


$getperms=getpermissions($forumid,-1,-1,$foruminfo['parentlist']);
if (!$getperms[canview]) {
show_nopermission();
}

I added...

//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(' ',$bbuserinfo[ignorelist]));
}

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

if ($newpm['messages']==0) {
$lightbulb='off';
} else {
$lightbulb='on';
}
eval("\$pminfo = \"".gettemplate('forumdisplay_pmloggedin')."\";");

} else {
$pminfo='';
}


I created a new template called "forumdisplay_pmloggedin," and everything works fine.

Now, it looks like this would call from the private message table every time the user loads the forumdisplay.php. Would this use more or less resources than the pop-up feature, or is the amount virtually negligible?

Admin
11-02-2001, 11:44 AM
One thing, this:
if ($enablepms==1 and $permissions['canusepm'] and $bbuserinfo['receivepm']) {
should be:
if ($enablepms==1 and $getperms['canusepm'] and $bbuserinfo['receivepm']) {
(or you can keep the code but you'll have to move the whole block down in the file)

And no, I don't think this would take too much resources. :)

Justice
11-02-2001, 01:18 PM
thanks for the response, that's great news...

and what do you mean move the block down? It's not at the top, like on the index.php file. It's further down, after


$forumid = intval($forumid);
$foruminfo = verifyid('forum',$forumid,1,1);

$getperms=getpermissions($forumid,-1,-1,$foruminfo['parentlist']);
if (!$getperms[canview]) {
show_nopermission();
}


Is that what you meant, because otherwise I'm lost. What's the difference between $permissions['canusepm'] and $getperms['canusepm'] ?

Admin
11-02-2001, 01:30 PM
The thing is the $getperms array is only copied into $permissions in line 119~.

So if you want to use $permissions and not $getperms, you must put that block after line 119~ and not before.

Justice
11-02-2001, 01:40 PM
$permissions was working just fine on line 50, but I changed it to $getperms just to be safe. Thanks again