PDA

View Full Version : [mini-RELEASE v2.0.1] - Show IP Icon/Text to Admins and Mods only


VirtueTech
07-29-2001, 10:00 PM
Hello everyone,

I noticed that the IP Logged GIF or TEXT was just taking up some valuable icon space in my
posts for my registered members. Also the only people that use the IP icon/text are Admins,
Moderators, or Super Moderators.

So I just made a small hack to showthread.php and thought some of you might find this useful:

Hack Directions (tested on vb2.0.1)

In Showthread.php:
Find the following:

if ($post[ip]!="") {
if ($logip==2) {
eval("\$post[iplogged] .= \"".gettemplate("postbit_ip_show")."\";");
}
if ($logip==1) {
eval("\$post[iplogged] .= \"".gettemplate("postbit_ip_hidden")."\";");
}
if ($logip==0) {
$post[iplogged]="";
}
} else {
$post[iplogged]="";
}


And replace it with:

if ($post[ip]!="") {
if ($logip==2) {
eval("\$post[iplogged] .= \"".gettemplate("postbit_ip_show")."\";");
}
if ($logip==1 AND ($bbuserinfo['usergroupid']==6 or $bbuserinfo['usergroupid']==5 or $bbuserinfo['usergroupid']==95)) {
eval("\$post[iplogged] .= \"".gettemplate("postbit_ip_hidden")."\";");
} elseif ($logip==1 AND ($bbuserinfo['usergroupid']!=6 or $bbuserinfo['usergroupid']!=5 or $bbuserinfo['usergroupid']!=95)) {
$post[iplogged]="";
}
if ($logip==0) {
$post[iplogged]="";
}
} else {
$post[iplogged]="";
}


Next: Be sure to go through the function above and make sure that the 'usergroupid'
matches that of your Administrators, Moderators, and Super Moderators
for both the 'if' and 'elseif' statments in that script.

For example: my 'usergroupid' (s) looked like this:
$bbuserinfo['usergroupid']==5 (Super Mods)
$bbuserinfo['usergroupid']==6 (Mods)
$bbuserinfo['usergroupid']==95 (Admins)

Just something small to keep the administrative ideas away from the users as
much as possible to limit the users ideas of possible security threats as well as space
saving for the postbit template. :)

With IP Icon - What Admins/Mods/Super Mods See
http://images.paintballcity.com/w_ipicon.gif
Without IP Icon - What Members See
http://images.paintballcity.com/wo_ipicon.gif

Wayne Luke
07-30-2001, 06:46 AM
Here is how I did it... If you notice the code is a little simpler and it acheives an bonus effect in that moderators of the forum (including super moderators and administrators) don't see the "Report" icon I have set up for regular members.


if (ismoderator(0,"",$bbuserinfo[userid])) {
if ($post[ip]!="") {
if ($logip==2) {
eval("\$post[iplogged] .= \"".gettemplate("postbit_ip_show")."\";");
}
if ($logip==1) {
eval("\$post[iplogged] .= \"".gettemplate("postbit_ip_hidden")."\";");
}
if ($logip==0) {
$post[iplogged]="";
}
} else {
$post[iplogged]="";
}
$post[report]="";
} else {
eval("\$post[report] .= \"".gettemplate("postbit_report")."\";");
$post[iplogged]="";
}


This does require a new template called "postbit_report" to hold the code for the report icon.

VirtueTech
07-30-2001, 06:50 AM
Good idea with the Report button. I'll implement that.

Except you need to change your code a bit so that if the Admin chooses to show IP's publicly....on an intranet maybe.

Wayne Luke
07-30-2001, 07:00 AM
Actually it only tries to determine if the IP should be shown if the user is a moderator. If they are it will follow whatever settings are made under options.

If you look, the first line includes a call to "ismoderator()" this function returns true if the user is a moderator. You can find it in admin/functions.php. Makes it a lot easier to find appropriate moderator permissions without trying to remember user groups and permission levels or whatnot.

VirtueTech
07-30-2001, 07:52 AM
Correct me if I'm wrong but in your code...if $logip==2 then only your mods can view the IP...when $logip==2 sets the "view IP's to public viewing".

No big deal just a thought.

Thanks wluke for optimizing my code for me and teaching me about that ismoderator function. Very useful.

Now I'm off to go optimize some other code of mine where the usergroupid lines may range forever onward. :)

Admin
08-03-2001, 08:32 AM
It worked fine with v2.0.0, but I can't find that code in showthread.php of v2.0.3.

VirtueTech
08-03-2001, 08:54 AM
I haven't upgraded to vb2.0.3 yet. I just upgraded the sessions.php script like they said for the security issue.

When I upgrade I will be sure to let you know. Sorry :(

Admin
08-03-2001, 09:03 AM
The code it probably somewhere else, or on a template, I'll (try to) find it myself.
Thanks anyway. :)

Nice hack.

Admin
08-05-2001, 11:55 AM
Anyone found out how to install this hack on v2.0.3? :(

Wayne Luke
08-05-2001, 12:00 PM
You need to change the postbit function in admin/functions.php.

It is the second function in the file. The code is actually the same, just in a different file.

Admin
08-05-2001, 12:39 PM
Thanks for the quick reply. :)

Once again, great hack. :)