Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 12-12-2002, 04:50 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't have that...nope...

if statements don't have anything to do with queries right? I have a lot of custom if statements in functions.php...
Reply With Quote
  #12  
Old 12-12-2002, 05:04 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, the only thinks that could be generating querys in it are queries ($DB_site->, mysql_query) or calls to other functions that may contain queries.
Reply With Quote
  #13  
Old 12-12-2002, 05:07 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then maybe I should look in showthread.php for some sort of call to a function which could be generating loads of queries?

Query: SELECT usergroupid FROM user

But what I don't understand is, this is selecting the usergroupid from the user table, any ideas why?
Reply With Quote
  #14  
Old 12-12-2002, 05:11 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have that query once on a unhacked showthread, I would say that its getting your usergroupid to check your permissions for view the thread or the other functions on the that page.
Reply With Quote
  #15  
Old 12-12-2002, 05:12 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's making it come up 10 times then?
Reply With Quote
  #16  
Old 12-12-2002, 05:15 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How many times do you have: getpermissions in showthread.php? It should be there twice, once in showpost and once in showthread
Reply With Quote
  #17  
Old 12-12-2002, 05:15 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I searched functions.php once again and I found the query in the getpermissions area:

PHP Code:

###################### Start getpermissions #######################
function getpermissions($forumid=0,$userid=-1,$usergroupid=-1,$parentlist="") {
  
// gets permissions, depending on given userid and forumid
  
global $DB_site$usercache$bbuserinfo$enableaccess;

  static 
$permscache$usergroupcache;

  
$userid=intval($userid);
  if (
$userid==-1) {
    
$userid=$bbuserinfo['userid'];
    
$usergroupid=$bbuserinfo['usergroupid'];
  }

  if (
$usergroupid==-or $usergroupid==0) {
    if (
$userid==0) {
      
$usergroupid=1;
    } else {
      if (isset(
$usercache["$userid"])) {
        
$usergroupid=$usercache["$userid"]['usergroupid'];
      } else {
        
$getuser=$DB_site->query_first("SELECT usergroupid FROM user WHERE userid=$userid");
        
$usergroupid=$getuser['usergroupid'];
      }
    }
  }

  if (!isset(
$permscache["$usergroupid"]["$forumid"])) {
    if (!
$forumid) {
      if (!isset(
$usergroupcache["$usergroupid"])) {
        
$usergroupcache["$usergroupid"] = $DB_site->query_first("SELECT * FROM usergroup WHERE usergroupid=$usergroupid");
        return 
$usergroupcache["$usergroupid"];
      } else {
        return 
$usergroupcache["$usergroupid"];
      }
    } else {
      if (!
$parentlist) {
        
$parentlist=getforumarray($forumid);
      }
      
$forums=getforumlist($forumid,"forumid","OR",$parentlist);
      if (
$enableaccess==AND $access=$DB_site->query_first("SELECT *,INSTR(',$parentlist,', CONCAT(',', forumid, ',') ) AS ordercontrol FROM access WHERE userid=$userid AND $forums ORDER BY ordercontrol LIMIT 1")) {
        if (
$access['accessmask']==1) {
          if (!isset(
$usergroupcache["$usergroupid"])) {
            
$getperms=$DB_site->query_first("SELECT * FROM usergroup WHERE usergroupid=$usergroupid");
            
$usergroupcache["$usergroupid"] = $getperms;
           } else {
            
$getperms $usergroupcache["$usergroupid"];
          }
        } else {
          if (!isset(
$usergroupcache["$usergroupid"])) {
            
$getperms2=$DB_site->query_first("SELECT * FROM usergroup WHERE usergroupid=$usergroupid");
            
$usergroupcache["$usergroupid"] = $getperms2;
          } else {
            
$getperms2 $usergroupcache["$usergroupid"];
          }
          while ( list(
$gpkey,$gpval)=each($getperms2) ) {
            
$getperms["$gpkey"] = 0;
          }
        }
      } else if (!
$getperms=$DB_site->query_first("SELECT *,INSTR(',$parentlist,', CONCAT(',', forumid, ',') ) AS ordercontrol FROM forumpermission WHERE usergroupid=$usergroupid AND $forums ORDER BY ordercontrol LIMIT 1")) {
        if (!isset(
$usergroupcache["$usergroupid"])) {
          
$getperms=$DB_site->query_first("SELECT * FROM usergroup WHERE usergroupid=$usergroupid");
          
$usergroupcache["$usergroupid"] = $getperms;
        } else {
          
$getperms $usergroupcache["$usergroupid"];
        }
      }
    }
    
$permscache["$usergroupid"]["$forumid"]=$getperms;
  } else {
    return 
$permscache["$usergroupid"]["$forumid"];
  }

  return 
$getperms;


That's the only place that kind of query shows up in functions.php
Reply With Quote
  #18  
Old 12-12-2002, 05:18 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by NTLDR
How many times do you have: getpermissions in showthread.php? It should be there twice, once in showpost and once in showthread
PHP Code:
// Logician Download Thread Hack
if ($action=="download") {

require(
"./global.php");

if (!
$threadid OR $threadid<1) {show_nopermission();}

$thread_db=$DB_site->query_first("SELECT * from thread WHERE threadid=$threadid AND visible=1");
if (!
$thread_db[threadid] OR $thread_db[threadid]<0) {show_nopermission();}
$forum=getforuminfo($thread_db['forumid']);
// Check Permissions so that a smartass wouldnt download a thread he doesnt allowed
$getperms=getpermissions($thread_db['forumid'],-1,-1,$forum['parentlist']);
if (!
$getperms['canview']) {show_nopermission();}
if (!
$getperms['canviewothers'] and ($thread['postuserid']!=$bbuserinfo['userid'] or $bbuserinfo['userid']==0)) {show_nopermission();} 

That code is near the top of showthread.php (there is a getpermissions call in there).

It's the download thread hack from logician...
Reply With Quote
  #19  
Old 12-12-2002, 05:48 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That should only add one query at the most to the page.
Reply With Quote
  #20  
Old 12-12-2002, 06:09 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could I PM you my showthread.php and functions.php?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:15 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04458 seconds
  • Memory Usage 2,292KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete