PDA

View Full Version : List users by access masks


Admin
09-16-2001, 10:00 PM
This was requested by David Copeland.
He wanted to be able to list all users that have or don't have access to a certain forum.
This is very very easy to install, you just need to add one block of code and a link! :)

Demo:
http://www.vbulletin.com/forum/attachment.php?s=&postid=172632

Install:
In user.php (admin folder), add this code:
echo "<li><a href=\"user.php?s=$session[sessionhash]&action=findaccess\">List by access masks</a></li>\n";
right after
echo "<li><a href=\"user.php?s=$session[sessionhash]&action=find\">List all users</a></li>\n";
Still in user.php, add this code:
// ###################### Start Find by Access #######################
if ($action=="dofindaccess") {

if ($checkaccess!="1" and $checkaccess!="0") {
$action = "findaccess";
} else {
$lists = $DB_site->query("SELECT * FROM access");
$inquery = "";

while ($list = $DB_site->fetch_array($lists)) {
if ($list[forumid]==$forumfrom and $list[accessmask]==$checkaccess) {
if ($inquery) {
$inquery .= ",";
}
$inquery .= "$list[userid]";
}
}

if ($inquery=="") {
echo "No users found.";
$action = "findaccess";
} else {
$users = $DB_site->query("SELECT userid,username,usergroupid,password,email,FROM_UN IXTIME(joindate) AS joindate,FROM_UNIXTIME(lastvisit) AS lastvisit,posts FROM user WHERE userid IN ($inquery)");

echo "<p>Click username to view forum profile.</p>";
doformheader("","");

echo "<tr class='tblhead'>";

echo "<td><p><b><span class='tblhead'>Name</span></b></p></td>";
echo "<td><p><b><span class='tblhead'>Options</span></b></p></td>";
echo "<td><p><b><span class='tblhead'>Email</span></b></p></td>";
echo "<td><p><b><span class='tblhead'>Password</span></b></p></td>";
echo "<td><p><b><span class='tblhead'>Join Date</span></b></p></td>";
echo "<td><p><b><span class='tblhead'>Last Visit</span></b></p></td>";
echo "<td><p><b><span class='tblhead'>Posts</span></b></p></td>";

echo "</tr>\n";

while ($user=$DB_site->fetch_array($users)) {

echo "<tr class='".getrowbg()."'>";

echo "<td><p><a href='../member.php?s=$session[sessionhash]&action=getinfo&userid=$user[userid]' target='_blank'>$user[username]</a>&nbsp;</p></td>";
echo "<td><p>".
makelinkcode("edit","user.php?s=$session[sessionhash]&action=edit&userid=$user[userid]").
makelinkcode("email password","user.php?s=$session[sessionhash]&action=emailpassword&email=$user[email]").
makelinkcode("remove","user.php?s=$session[sessionhash]&action=remove&userid=$user[userid]").
makelinkcode("edit access masks","user.php?s=$session[sessionhash]&action=editaccess&userid=$user[userid]").
"</p></td>";
echo "<td><p><a href='mailto:$user[email]'>$user[email]</a>&nbsp;</p></td>";
echo "<td><p>$user[password]&nbsp;</p></td>";
echo "<td><p>$user[joindate]</p></td>";
echo "<td><p>$user[lastvisit]</p></td>";
echo "<td><p>$user[posts]</p></td>";

echo "</tr>\n";

}
echo "</table></td></tr></table></form>";
}
}

}

// ###################### Start List by Access #######################

if ($action=="findaccess") {

doformheader("user","dofindaccess");

maketableheader("List Users by Access Masks","",0);
echo "<tr class='firstalt'><td colspan=2><p>Here you can list all users that match the settings you set below.</p></td></tr>\n";

maketableheader("Forum Select");

makeforumchoosercode("Forum you'd like to order by:",forumfrom);
makeyesnocode("Does the user has access to that forum?",checkaccess,"2");
echo "</p></td></tr>\n";

doformfooter("List users");
}
right before
cpfooter();
?>

The end.
See, I told you it's easy! :D
Now you have a link for this under Users => Find => List by access masks (under List all users).

By the way, I know that one part of the code there could be combined with the other search part, but this is just as good.
Sue me. ;) :p
Feedback please. :)

ToraTora!
09-17-2001, 07:47 AM
you keep this up firefly, and vb is going to throw you into the staff lineup. If one didnt know better, a person would swear that you and tubedog are having a hack release contest...:D

Keep up the good work!

Admin
09-17-2001, 08:25 AM
[QUOTE]Originally posted by ToraTora!
you keep this up firefly, and vb is going to throw you into the staff lineup. If one didnt know better, a person would swear that you and tubedog are having a hack release contest...:D

Keep up the good work!

MarkB
09-17-2001, 09:06 AM
I look forward to adding this :) You're a hacking machine!

orca
09-17-2001, 11:52 AM
Had the following mySQL-error:

Database error in vBulletin Control Panel: Invalid SQL: SELECT userid,username,usergroupid,password,email,FROM_UN IXTIME(joindate) AS joindate,FROM_UNIXTIME(lastvisit) AS lastvisit,posts FROM user WHERE userid IN ()
mysql error: You have an error in your SQL syntax near ')' at line 1
mysql error number: 1064
Date: Monday 17th of September 2001 08:45:51 AM
Script: /admin/user.php
Referer: http://forum.arachid.org/admin/user.php?s=&action=findaccess


It seems there's a missing line in the form because the variable $inquery is empty (I guess it should be between the ()...

Admin
09-17-2001, 11:54 AM
Ooops, if there are no results I should bring you back to the search screen.
I'll fix it in a mo.

Admin
09-17-2001, 11:59 AM
Fixed.
If no users are found an appropriate line appears and you are brought back to main search screen.

orca
09-17-2001, 12:00 PM
It fails even if there should be search results. I checked it on a forum where everyone has access and it gets me that error. Actually, the members should be listed there.
Other question: If the forum's set that only admins and mods can post and reply but users can only read it, will that be included in the search?

Admin
09-17-2001, 12:02 PM
You missed something:
This searches by access masks, not by regular forum/usergroup permissions.

So only users that you specifically selected Yes for them will appear.

See this thread for more info:
http://www.vbulletin.com/forum/showthread.php?s=&threadid=27668

orca
09-17-2001, 12:04 PM
Hmm, ok, now after the bug fix I see somehow how it's working...

Admin
09-17-2001, 12:11 PM
In case others also didn't get it, this doesn't search by usergroups and permissions.
*sound of disappointment*
It searches for users that were given special access to this forum or another.
Just go here http://www.forums.com/admin/user.php?s=&action=editaccess&userid=1 and see what I mean.

orca
09-17-2001, 12:18 PM
Well, I got it now. I can be so stupid sometimes ;). Right now, I didn't realize that you meant the custom URL with http://www.forums.com/....

[VbbFr]Elie
09-17-2001, 03:21 PM
Yes May be some can need to use it but it's really for specific search :)

trainer
12-09-2001, 09:11 PM
great hack it would come in handy. does this work for 2.2.1?

thanks

Reeve of shinra
12-10-2001, 12:48 AM
sweet... I am gonna install this now.

trainer
12-10-2001, 01:08 AM
Originally posted by Reeve of shinra
sweet... I am gonna install this now.


i am not sure this hack works for 2.2.1

Reeve of shinra
12-10-2001, 03:27 AM
thats okay we didnt upgrade yet -- were waiting for ver 3.
(that means hurry up lol).

igowoofwoof
01-03-2002, 07:20 PM
you cannot apply this crack with version 2.2.1. Can you please make an update for this, thank you

Jawelin
01-04-2002, 09:05 PM
Originally posted by FireFly
In case others also didn't get it, this doesn't search by usergroups and permissions.
*sound of disappointment*
It searches for users that were given special access to this forum or another.
Just go here http://www.forums.com/admin/user.php?s=&action=editaccess&userid=1 and see what I mean.

Hi FireFly. First of all, thanks for this great hack (not crack!!!), which works perfectly on 2.2.1.... I installed it a long ago, and I asked about even a long ago... ;)

Hwr. I'm keepin'it up 'cause I need some enhancement:

I know (guess...) it would be VERY VERY difficult to check all the concurrent permissions at usergroup lever along with the access table ones, but I was thinking about....

Well, how do you figure out a select (with UNION, I think) to search for all the groups (and the users within, of course...);
I mean search the chosen forum in forumpermission, find out the usergroupid, then all the users...
It should be simple enough, less - at least to me - the UNION SELECT clause removing dupes... ;) ...

Could you investigate and give me (us) any tip to follow this path ?

Main problem lasting I think should be the forum categories: inheritance - even in your hack - is not checked... Infact, if I choose a forum category and in the access table I haven't that forumid, my search is empty! .... :(

Please, read and answer...

Thanks very very much.

Bye

Admin
01-05-2002, 06:55 AM
I'll see what I can come up with Jawelin, but I can't promise anything.

Jawelin
01-05-2002, 10:51 AM
Thanks a lot, even for such a fast answer! :)
Anyway...


I can't manage to use 'UNION' on two simple select ... Even returning the 'userid' alone.... :(

ERRATA CORRIGE: ooops. The UNION [ALL] SQL command requires +4.x version of MySQL...
I think the hack should merge itself the different result sets within php code and not sql-query... :(

Bye

Warlord
01-12-2002, 03:26 AM
Thanks this hack works great! And it makes it MUCH more convenient when trying to find out who all has access to certain forums.

As previously stated, it seems that it doesn't list users that have access to certain forums because they are allowed entry because of the user group they are in. Unless it is actually selected in the persons access masks, it doesn't list them as having access to that forum.

But this is better than nothing. :)

Thanks.

Jawelin
01-20-2002, 10:17 AM
Originally posted by FireFly
I'll see what I can come up with Jawelin, but I can't promise anything.
I know what you said, but just for reminder... :supwink:

Meanwhile I tried myself but can't manage to merge different result sets within php code, as my server has mySQL 3.2x and not +4...
Anyway is very hard to findout an algorithm to select and make explicit permissions with inherited ones...
:noid:

Thnx

Shenlong
01-20-2002, 02:53 PM
MY question:

why isnt firefly on vbb staff? damn man u can do ANYTHING and what u do with ur skillz is awesome

:up: :up:

Jawelin
01-27-2002, 12:55 PM
Originally posted by Shenlong
MY question:

why isnt firefly on vbb staff? damn man u can do ANYTHING and what u do with ur skillz is awesome
:up: :up:
Above all, if he isn't an official vb developer, they should listen to him when upgrading to a newer release... :greedy:
:pleased:

P.S.: it's a bump, did you realize that ? ;)

ladyfyre
02-02-2002, 06:19 PM
Ok....i am VERY sorry to be such a brat...but I have a BIG request here......

Any way I could talk you into adding a link in this hack that would reset a user's "custom status'" to usergroup defaults for ALL forums?? I have over 300 at present...and doing it by hand if a mod gets demoted gets REALLY old.

Recluse
02-05-2002, 04:33 AM
works fine on my forums, thanks

Jawelin
02-05-2002, 08:16 AM
Just a tip:
what about
1) choose a forum from a combo-list (best ordered the same way in jump-combo is, not alphabetically), fixing a parameter, this way.
2) seek all the user table checking :

$permissions=getpermissions($forum[forumid],$userid);
if ($permissions['canview'] == 1/0 ) {
// add this user to the enabled/disabled list
}


The complexity should be linear than the usercount, and this way the search should keep the inheritance, the access table, the usergroup permission, etc.

???

Thanks, FF.

KISS
02-22-2002, 04:58 AM
The man, much needed installed great too.

over
02-25-2002, 09:38 AM
niec hack cheers :) makes my life easier

JonC
03-03-2002, 11:30 AM
Does This work on 2.2.2 ?

trainer
03-21-2002, 11:58 PM
does this work for 2.2.4?

SWFans.net
04-23-2002, 11:35 PM
It works great in 2.2.5. :) and was just what I was looking for.

With just a few minor alterations and another previously added hack that gave mods the ability to edit access masks, this also works for mods.

Kudos and many thanks go out to Firefly and PPN. :)

TECK
05-12-2002, 01:27 AM
install it in 225. working good. :)

ohgenki
05-16-2002, 10:58 PM
Dear FireFly or rest,

Sorry to ask this question, how come my registered members still can access to the forum topic that i do not want them to access? I already try a lot of unchecked in the CP and double check the script. Kindly advise me.

Thank you.

Twig Deez
06-05-2002, 11:38 PM
yep, works good for me, too. :)

Gutty
09-14-2002, 10:58 AM
what about 2.2.7????

bouncer18
09-20-2002, 04:44 PM
good to go on 2.2.7

Legacy
10-22-2002, 01:41 PM
works on 2.2.8

ladyfyre
12-05-2002, 01:39 PM
hmmm....it won't work on 2.2.8 for me :(

BlackDeath
12-24-2002, 04:52 AM
thanks. this works for 2.28 great.

Rose
01-04-2003, 06:10 PM
I don't know if this thread is still active - but Thanks Firefly! It works on v2.2.8.

Is there a way to have it list all users that have access to a specific forum - not just those that are set specifically for that forum. For instance, members in my "Board" group have access to the "board" forum, but they only show up in the "List by Access" if I manually clicked "yes" in their permissions.

Is there a way to list all?

LadyFyre - What sort of errors are you having?

Rose
01-10-2003, 02:08 AM
*blush*

Bump

Anyone? :$ It'd be really handy for me. Unless someone has a hack that adds "usergroups" that has leaders to add their own members (much like vB3's usergroups/forum permissions) type.

:$ Anyone?

LeeCHeSSS
01-10-2003, 10:33 AM
Originally posted by Jawelin
Just a tip:
what about
1) choose a forum from a combo-list (best ordered the same way in jump-combo is, not alphabetically), fixing a parameter, this way.
Even though this is a pretty old hack, can someone try and point me out how to change the dropdown list as suggested above?

ego
02-16-2003, 08:06 PM
This is also interested to me!

Kohhal
05-13-2003, 01:29 PM
Nice, I've been looking for this :)
(Installed on 2.2.9)

HP409ss
11-07-2003, 04:50 AM
Great Hack! Helped me out allot!!!!