View Single Post
  #8  
Old 05-18-2002, 10:43 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
Stick:
Code:
unset($permscache, $usergroupcache);
Before calling getpermissions().
There's something not working. I can't manage to clean the
cache, even outside the function...

If want, please try to upload this code to the admin/ directory
and try to execute vs. some private/protected forum (&forumid=xx) and with moderator or supermods usergroup (&grpid=y).
Even, a single user (&singleuser=uuu) can be specified.
PHP Code:
<?php
error_reporting
(E_ALL);

require(
"./global.php");
cpheader();

echo 
"<p>Group <b>$grpid</b> crossed with Forum <b>$forumid</b></p>";

if (isset(
$forumid) and isset($grpid)) {

   
$forum2test=$forumid;

    
$usergroups=$DB_site->query("SELECT usergroupid,title FROM usergroup where usergroupid=$grpid");

    echo 
"<p>";
    while (
$usergroup=$DB_site->fetch_array($usergroups)) {

        
$id=$usergroup[usergroupid];

        
$perms[$id]=getpermissions($forum2test,0,$id);

        
$k=$perms[$id];
        if (
$k[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by usergroup $usergroup[usergroupid] ($usergroup[title])";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by usergroup $usergroup[usergroupid] ($usergroup[title])";
    }
    echo 
"</p>";


    
$users=$DB_site->query("SELECT userid,username FROM user WHERE usergroupid=$grpid ORDER BY userid");

    echo 
"<p>";
    while (
$user=$DB_site->fetch_array($users)) {

        unset(
$permscache$usergroupcache);

        
$id=$user[userid];

        
$permuser[$id]=getpermissions($forum2test,$id);

        
$k=$permuser[$id];
        if (
$k[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by user $user[userid] ($user[username])";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by user $user[userid] ($user[username])";
    }
    echo 
"</p>";


    
// copy this code right before the first select...
    
if (isset($singleuser)) {

        unset(
$permscache$usergroupcache);

        
$user[userid]=$singleuser;
        
$permsingleuser=getpermissions($forum2test,$user[userid]);

        if (
$permsingleuser[canview])
            echo 
"<br>Forum <b>$forum2test</b> <b> can </b> be accessed by user $user[userid]";
        else
            echo 
"<br>Forum <b>$forum2test</b> <b>can't</b> be accessed by user $user[userid]";

    }
    
//  ... and if run with an user of the usergroup specified,
    //  you'll get different values for same instructions.

}

echo 
"<br><br><p>Performance stats: <b>".number_format($query_count)."</b> queries done in <b>".number_format($querytime,7)."</b> seconds</p>";

cpfooter();

?>
You can notice if run with a single user, that:
- if the user belongs to the specified group, permissions are
cached (i.e. wrong results if such user has single access mask
set)
- if not, permissions returned are true (reflecting the actual user ones)
- if you copy the same section of $singleuser also before the first
getpermissions(), you'll obtain true values ANY CASE, much
different from the same code at the end of the script.


It means that permissions are cached per usergroup and per
forum. And the unsets aren't enough ....

Thank you for attention.

Any idea ?
Bye
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01089 seconds
  • Memory Usage 1,814KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete