De volgende codes:
config.php
ban.php
auth.php
Uitleg:
Ik heb in het admin gedeelte een IP ban functie toegevoegd en werkt perfect
Nu wil ik het alleen voor moderators beschikbaar maken. Ik kan users toevoegen die toegang moeten krijgen tot ban.php via het admin panel, werkt ook goed 
Het script wat hier staat werkt bij mij ook. Krijg een scherm waar gevraagd wordt om inlognaam + password. Bij andere gaat het helaas fout en ik begrijp maar niet waar deze fout zit
Wie kan het voor me testen en me op weg helpen
testlink
config.php
PHP:
1
2
3
4
5
6
7
8
9
10
| <?PHP $host = "localhost"; $db = "forum"; $user = "root"; $pass = ""; mysql_connect($host, $user, $pass); mysql_select_db($db); ?> |
ban.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| <? include("auth.php"); mysql_connect("localhost","root",""); mysql_select_db("forum"); if ($action == "unban") { mysql_query("DELETE FROM banlist WHERE ip='$banip'"); echo $banip ." is verwijderd uit de banlist"; echo "<p>Klik <a href='".$PHP_SELF."'>hier</a> om terug te gaan naar de lijst"; } elseif ($action == "add") { mysql_query("INSERT INTO banlist SET ip='$banip'"); echo $banip ." is toegevoegd aan de banlist"; echo "<p>Klik <a href='".$PHP_SELF."'>hier</a> om terug te gaan naar de lijst"; } else { $sql = mysql_query("SELECT ip FROM banlist"); while ($row = mysql_fetch_array($sql)) { echo "<p>".$row[0]." - <a href='".$PHP_SELF."?action=unban&banip=".$row[0]."'>Unban dit IP</a>"; } ?> <p><form action="<?=$PHP_SELF?>?action=add" method="post"> Voeg een IP toe aan de banlist: <br><input type="text" name="banip"> <p><input type="submit" value="Bannen!"> </form> <? } ?> |
auth.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| <?PHP function authenticate() { header("WWW-Authenticate: Basic realm=\"-=|V.i.P|=-\""); header("HTTP/1.0 401 Unauthorized"); print("You must enter a valid login username and password to access this resource.\n"); exit; } if(!isset($PHP_AUTH_USER)){ authenticate(); } else { include("config.php"); $q=sprintf("SELECT Username,Password FROM members WHERE Username='%s' AND Password='%s'", $PHP_AUTH_USER,$PHP_AUTH_PW); $q=mysql_query($q); if(mysql_num_rows($q)==0){ authenticate(); } } ?> |
Uitleg:
Ik heb in het admin gedeelte een IP ban functie toegevoegd en werkt perfect
Het script wat hier staat werkt bij mij ook. Krijg een scherm waar gevraagd wordt om inlognaam + password. Bij andere gaat het helaas fout en ik begrijp maar niet waar deze fout zit
testlink