PDA

View Full Version : No Permission Error on WOL


NTLDR
10-10-2002, 05:47 PM
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...

return $userinfo;

above it try adding...

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:// ###################### 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:
$DB_site->query("UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'");

then in online.php
find: $userinfo[$key][location] = $user[location];


and replace with:
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$DB_site->query("UPDATE session SET location=CONCAT('nop-',location) WHERE sessionhash='$session[sessionhash]'");

you have to use this i think:

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:
global $bbtitle,$logincode,$url,$scriptpath,$bbuserinfo,$ session;


into 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:

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:

$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
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
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