PDA

View Full Version : in_array problems


VodkaFish
08-07-2006, 11:55 PM
I was using this to set permissions on a php page:

if (in_array($vbulletin->userinfo['usergroupid'], array(1, 3, 4, 8))) {
print_no_permission();
}

However, now that I've upgraded to php 5 (and vb 3.6), it's simply blocking everyone, not just those usergroups. I don't really see any difference for in_array (http://us3.php.net/manual/en/function.in-array.php) between php 4 and 5, did something change in vb?

Freesteyelz
08-08-2006, 06:02 AM
I think it should be:


if (is_member_of($vbulletin->userinfo, 1, 3, 4, 8))

VodkaFish
08-08-2006, 06:19 AM
Thanks for the response. I gave that a shot earlier and it's weird, everyone is still being blocked.

If I do:
echo is_member_of($vbulletin->userinfo['usergroupid'], array(1, 3, 4, 8));I get nothing.
echo $vbulletin->userinfo['usergroupid'];I get my correct usergroupid.
echo is_member_of($vbulletin->userinfo, 1, 3, 4, 8);I get nothing again.

Dilmah
08-08-2006, 06:29 AM
is_member_of($vbulletin->userinfo, 1,3,4,8);

VodkaFish
08-08-2006, 06:43 AM
Unfortunately that produces the same result.

Dilmah
08-08-2006, 06:52 AM
What's code did you use?

VodkaFish
08-10-2006, 03:02 PM
What's code did you use?
I tried both:
if (in_array($vbulletin->userinfo['usergroupid'], array(1, 3, 4, 8))) {
print_no_permission();
} and
if (is_member_of($vbulletin->userinfo, 1,3,4,8)) {
print_no_permission();
}

Paul M
08-10-2006, 05:36 PM
Use this and post the full results back here;


print_r($vbulletin->userinfo);
if (is_member_of($vbulletin->userinfo, 1,3,4,8))
{
echo "No Permission <br />";
}
exit;

VodkaFish
08-10-2006, 05:47 PM
Array ( [userid] => 2105 [usertitle] => Owner [customtitle] => 1 [joindate] => 949813200 [daysprune] => 0 [lastvisit] => 1155232031 [lastactivity] => 1155232031 [lastpost] => 1155229271 [posts] => 12168 [timezoneoffset] => -5 [membergroupids] => [displaygroupid] => 6 [reputation] => 350

Paul M
08-10-2006, 06:09 PM
I've removed alot of the unnecessary stuff from your post

You are a member of usergroup 6 and didn't get "No Permission" echoed out, so it seems to be working to me.

VodkaFish
08-10-2006, 10:29 PM
Thanks for the cleanup.

I truly don't understand it - as I mentioned above, echo $vbulletin->userinfo['usergroupid']; writes my correct usergroup (6), but yet I'm still getting blocked. It must be something else in my template, I'll comb it again.

Paul M
08-11-2006, 12:22 AM
Please explain what you mean by "getting blocked"

VodkaFish
08-11-2006, 02:18 AM
All users get the no permission message, including myself.

Paul M
08-11-2006, 03:49 AM
Then you need to post all the code, not just that little section.

VodkaFish
08-11-2006, 04:31 AM
I found where it was, I used a variable called $fin and set it before I did require_once("./global.php");
Afterwards, it was getting wiped out, which also would give a no permission error.

So I changed my $fin to $fin_no_likey_vb (well, something different is the point) and all is good now.

Thanks everyone for the help.

Freesteyelz
08-11-2006, 07:16 AM
Cool. :)