IF rang

Gestart doorShahiem2 reacties42 weergaven

3 berichten · pagina 1 van 1

Shahiem

Lid · Topicstarter

Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb even een vraag:

Ik heb dit:
if(is_auth(2, $_SESSION[uId]))


Nieuwsreporters hebben rang 2
Moderators hebben rang 3
Admins hebben rang 4

Maar moderators mogen het niet zien en admin en nieuwsreporters wel.
Hoe kan ik daar voor zorgen?
0
Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kan je ff de hele code plaatsen?
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Verander de is_auth functie naar:

[COLOR= #0000BB]<?php[/COLOR]
  [COLOR= #007700]function[/COLOR] is_auth[COLOR= #007700]([/COLOR][COLOR= #0000BB]$uLev[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$uId[/COLOR][COLOR= #007700]) 
    {[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uId[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uId[/COLOR][COLOR= #007700]))
        {[/COLOR]
            [COLOR= #FF8000]// Haal level van gebruiker op[/COLOR]
            [COLOR= #0000BB]$sQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT uRang FROM member_accounts WHERE uId = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$uId[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #0000BB]$sAssoc[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sQuery[/COLOR][COLOR= #007700]);[/COLOR]
            
            [COLOR= #FF8000]/*
             * Level gelijk aan, of hoger dan benodigd: TRUE teruggeven
             * Level niet hoger dan of gelijk aan benodigd: FALSE teruggeven
             */[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/is_array"]is_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uLev[/COLOR][COLOR= #007700]))
            {[/COLOR]
                [URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sAssoc[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uRang[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$uLev[/COLOR][COLOR= #007700]) ?[/COLOR] TRUE [COLOR= #007700]:[/COLOR] FALSE[COLOR= #007700];
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$sAssoc[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uRang[/COLOR][COLOR= #007700]] >=[/COLOR] [COLOR= #0000BB]$uLev[/COLOR] [COLOR= #007700]?[/COLOR] TRUE [COLOR= #007700]:[/COLOR] FALSE[COLOR= #007700];
            }
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] FALSE[COLOR= #007700];
        }
    }[/COLOR]
?>


Dan roep je hem zo aan als 2 en 4 hem mogen zien:

if(is_auth(array(2, 4), $_SESSION[uId]))


en zo als iedereen vanaf 2 hem mag zien:

if(is_auth(2, $_SESSION[uId]))
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren