vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   No Permission Error on WOL (https://vborg.vbsupport.ru/showthread.php?t=44479)

NTLDR 10-10-2002 05:47 PM

No Permission Error on WOL
 
I've been trying without much luck to get the text No Permission in front of a users loaction on the WOL page if they have the standard no permission error, like vB3 has.

Anyone have any ideas/know how to do this?

g-force2k2 10-10-2002 07:13 PM

err... do you mean for the users that are trying to view the wol or the users that have permission and view other users that get wol permission errors? i haven't seen the vb3 wol in the works yet sorry :p

but should be able to do somethign within the function included in the online.php

the varaiable...

$userinfo[activity]

thats in the whosonlinebit

in the php file find...

PHP Code:

return $userinfo

above it try adding...

PHP Code:

if($bbuserinfo['userid'] == 0)
  
$userinfo[activity] == "No Permission"

not sure if you can do anything with that... but i would approach the situation somewhere along those lines ;) regards...

g-force2k2

Xenon 10-10-2002 07:17 PM

hmm, i think they use another session system within vb3..

perhaps an idea:

open admin/functions.php
find:
PHP Code:

// ###################### Start show_nopermission #######################
function show_nopermission() {
  global 
$bbtitle,$logincode,$url,$scriptpath,$bbuserinfo,$session;

  
// generate 'logged in as:' box or username and pwd box
  
if (!$logincode) {
    
$logincode=makelogincode();
  } 

below add:
PHP Code:

$DB_site->query("UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'"); 

then in online.php
find:
PHP Code:

        $userinfo[$key][location] = $user[location]; 

and replace with:
PHP Code:

if (strstr($user[location],'nop-')) {
        
$userinfo[$key][location] = substr($user[location],4);
        
$userinfo[$key][nop] = 'No Permission - ';
} else {
        
$userinfo[$key][location] = $user[location];
        
$userinfo[$key][nop] = '';



then edit your whosonlinebit template and add
$userinfo[nop] before $userinfo[where]

i'm not sure if it works correct, but the idea should work, maybe small bugs in ;)

g-force2k2 10-10-2002 07:20 PM

then again Xenon's code is probably alot more affective :p for one it uses the show_nopermission function so yeah his code is more effecient and effective :p oh well i tried...

g-force2k2

Xenon 10-10-2002 07:40 PM

As long as the guardians solve the problems it's good ;)

also take up the competition pal, it'll train our both skills ;););)

NTLDR 10-10-2002 08:00 PM

Thanks for the help Xenon and g-force2k2.

I started out along the same lines as what Xenon posted, the problem is that the query that adds nop- to the start of the location gets overwritten by the final query that is run for the page, which updates the users session and therefore re-setting the location without the nop- preceding it.

I can't seem to see anyway around it where the nop- will get removed when the session is updated and the users hasn't got the show_nopermission(); message.

Xenon 10-10-2002 08:10 PM

it is?

hmm the query within the function show_nopermission should be the last query, because there's an exit call in it...

hmm
*subscribing to the thread*
i'll test it out tomorrow perhaps i can find a way :)

NTLDR 10-10-2002 09:11 PM

I turned debug on to see and it was about 8th out of the 13 queries that were being run.

Thanks for the help Xenon :)

Logician 10-11-2002 08:39 AM

@NTLDR: This is a good hack idea, I can use this one too. I can't convince my Super Moderators that user in whoisonline is not actually in that location when he's not allowed. ;)

@Xenon: Your algorithm is very good, congratulations. :)

And the solution:
The problem why your solutions do not apply is related to the PHP's register_shutdown_function(). To recap, in PHP you can set the script to run a couple of commands before its execution is terminated. This is done via register_shutdown_function and allows the developer to arrange things before the script ends.. So even if you put an "EXIT" command right after

$DB_site->query("UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'");

You'll find that the location field is still overwritten. This is because the function doshutdown() runs right before the script ends (as a part of register_shutdown configuration) and it overwrites your table field since there is another session update in that function.

The solution as you might guess is to hack that function too.. It's in function.php.

BTW. I like threads like this, they are good for our brain.. :)

Xenon 10-11-2002 10:05 AM

Thx pal :)

i didn't know the how the shutdownfunction works, now i see why you always have to reload the who's online to show yourself viewing who's online :)...


well i think then it shouldn't be so hard to fix this bug:

instead of this line
PHP Code:

$DB_site->query("UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'"); 

you have to use this i think:
PHP Code:

    if ($noshutdownfunc) {
$DB_site->query("UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'");
} else {
$shutdownqueries[]="UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'";


then you have to change also in show_nopermission function:
PHP Code:

  global $bbtitle,$logincode,$url,$scriptpath,$bbuserinfo,$session

into
PHP Code:

  global $bbtitle,$logincode,$url,$scriptpath,$bbuserinfo,$session,$noshutdownfunc,$shutdownqueries


Logician 10-11-2002 11:30 AM

yes I guess this should work.. And I believe "$DB_site" variable also needs to be globalized in show_nopermission function.

NTLDR 10-11-2002 11:52 AM

That code works great Xenon :D

You do need the $DB_site in the gobal variables and you also need to add this code:

PHP Code:

        if (strstr($user[location],'nop-')) {
            
$guests[$count][location] = substr($user[location],4);
            
$guests[$count][nop] = "<b>No Permission: </b>";
    } else {
            
$guests[$count][location] = $user[location];
            
$guests[$count][nop] = '';
    } 

Instead of:

PHP Code:

$guests[$count][location] = $user[location]; 

in online.php to make it work for guests as well.

Thanks for the help guys, this is a great addition to online.php :D

Logician 10-11-2002 12:00 PM

Now we should convince Stefan to release it hehe

Freddie Bingham 10-11-2002 01:58 PM

So you are issueing two queries when a no_permission screen is shown? One with the location and then another to overwrite that with 'nop_'? You need to fix that ;) Also show_nopermission() is not used everywhere that it should be so don't expect this to always work.

Erwin 10-11-2002 02:56 PM

Great idea. It would reduce the confusion of the admins and mods who think that members are accessing restricted pages when they're not. :)

Xenon 10-11-2002 03:49 PM

freddy you could share the code from vb3 with us, that'll solve the problems *ggg*
hmm, but show_nopermission is shown on most of the pages ;)

but good to know it works, now we can optimize it ;)

Freddie Bingham 10-11-2002 05:28 PM

Quote:

Originally posted by Xenon
freddy you could share the code from vb3 with us, that'll solve the problems *ggg*
hmm, but show_nopermission is shown on most of the pages ;)

but good to know it works, now we can optimize it ;)

vB3 has another field in the session table called something like 'badlocation' which is set to 1 if show_nopermission() is encountered, pretty much the same way that this script works except the existing query that updates the session table is used so there are no new queries involved. This way you still have the location and can show the Admin where the user tried to go but couldn't. It's a bit more involved than I have explained but that is the general way it works.

NTLDR 10-11-2002 05:55 PM

Quote:

Originally posted by freddie
vB3 has another field in the session table
I tried the extra field in the DB approch before I posted here but failed to be able to use the existing queries to change this properly.

Xenon 10-11-2002 07:08 PM

ah thanks freddie, intresting way it works.

thanks for sharing

Chris M 10-11-2002 07:17 PM

Cool:)

Satan


All times are GMT. The time now is 07:17 PM.

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.01245 seconds
  • Memory Usage 1,789KB
  • 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
  • (12)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (20)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