vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   would this hack use too much resources?? (https://vborg.vbsupport.ru/showthread.php?t=32003)

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

PHP Code:

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


I added...

PHP Code:

//check usergroup of user to see if they can use PMs
//$permissions=getpermissions($forumid);
if ($enablepms==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:
Code:

if ($enablepms==1 and $permissions['canusepm'] and $bbuserinfo['receivepm']) {
should be:
Code:

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

PHP Code:

$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


All times are GMT. The time now is 06:59 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01078 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete