PDA

View Full Version : List users by access masks


Chen
17 Sep 2001, 07:55
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_UNIXTIME(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!
17 Sep 2001, 09:47
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!

Chen
17 Sep 2001, 10:25
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!
Who said we're not having one? ;) j/k...
Seriously, thanks a lot. :)

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

orca
17 Sep 2001, 13:52
Had the following mySQL-error:

Database error in vBulletin Control Panel: Invalid SQL: SELECT userid,username,usergroupid,password,email,FROM_UNIXTIME(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 ()...

Chen
17 Sep 2001, 13:54
Ooops, if there are no results I should bring you back to the search screen.
I'll fix it in a mo.

Chen
17 Sep 2001, 13:59
Fixed.
If no users are found an appropriate line appears and you are brought back to main search screen.

orca
17 Sep 2001, 14:00
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?

Chen
17 Sep 2001, 14:02
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
17 Sep 2001, 14:04
Hmm, ok, now after the bug fix I see somehow how it's working...

Chen
17 Sep 2001, 14:11
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
17 Sep 2001, 14:18
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
17 Sep 2001, 17:21
Yes May be some can need to use it but it's really for specific search :)

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

thanks

Reeve of shinra
10 Dec 2001, 02:48
sweet... I am gonna install this now.

trainer
10 Dec 2001, 03:08
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
10 Dec 2001, 05:27
thats okay we didnt upgrade yet -- were waiting for ver 3.
(that means hurry up lol).

igowoofwoof
03 Jan 2002, 21:20
you cannot apply this crack with version 2.2.1. Can you please make an update for this, thank you

Jawelin
04 Jan 2002, 23:05
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

Chen
05 Jan 2002, 08:55
I'll see what I can come up with Jawelin, but I can't promise anything.

Jawelin
05 Jan 2002, 12:51
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
12 Jan 2002, 05:26
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
20 Jan 2002, 12:17
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
20 Jan 2002, 16:53
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
27 Jan 2002, 14:55
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 Feb 2002, 20:19
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
05 Feb 2002, 06:33
works fine on my forums, thanks

Jawelin
05 Feb 2002, 10:16
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
22 Feb 2002, 06:58
The man, much needed installed great too.

over
25 Feb 2002, 11:38
niec hack cheers :) makes my life easier

JonC
03 Mar 2002, 13:30
Does This work on 2.2.2 ?

trainer
22 Mar 2002, 01:58
does this work for 2.2.4?

SWFans.net
24 Apr 2002, 01:35
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
12 May 2002, 03:27
install it in 225. working good. :)

ohgenki
17 May 2002, 00:58
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 Jun 2002, 01:38
yep, works good for me, too. :)

Gutty
14 Sep 2002, 12:58
what about 2.2.7????

bouncer18
20 Sep 2002, 18:44
good to go on 2.2.7

Legacy
22 Oct 2002, 15:41
works on 2.2.8

ladyfyre
05 Dec 2002, 15:39
hmmm....it won't work on 2.2.8 for me :(

BlackDeath
24 Dec 2002, 06:52
thanks. this works for 2.28 great.

Rose
04 Jan 2003, 20:10
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
10 Jan 2003, 04:08
*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
10 Jan 2003, 12:33
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
16 Feb 2003, 22:06
This is also interested to me!

Kohhal
13 May 2003, 15:29
Nice, I've been looking for this :)
(Installed on 2.2.9)

HP409ss
07 Nov 2003, 06:50
Great Hack! Helped me out allot!!!!