sto creando un forum con login a file, ma il login non viene effettuato a dovere.
functions.inc.php
e adesso la pagina di login login.phpcodice:<?php function prelogin() { ?><table width="100%"> <tr> <td align="center"><font size="+1" color="#00CC99">Login</font></td> </tr> <tr> <td><form name="login" method="post" action="<?=$PHP_SELF?>?action=login"> <table width="100%"> <tr> <td width="20%" align="right">Username:</td> <td width="80%"><input name="user" type="text" id="user" size="20" maxlength="10"></td> </tr> <tr> <td width="20%" align="right">Password:</td> <td width="80%"><input name="password" type="password" id="password" size="20" maxlength="10"></td> </tr><?php } function buttonlogin() { ?> <tr> <td width="20%"></td> <td width="80%"> <input style="font-size: 10px;" type="submit" height="1" value=" Login... " id="login" name="login"></td> </tr><?php } function nologin($message) { prelogin(); ?> <tr> <td colspan="2"><font color="red">ATTENZIONE:</font> <?=$message?></td> </tr><?php buttonlogin(); ?> </table></form> </td> </tr><?php } function check_user($kuser, $kpassword) { $result = false; $users_db = file("db/users.db.php"); unset($users_db[0], $users_db[1], $users_db[2], $users_db[3], $users_db[4], $users_db[5]); global $member; $pass = md5($kpassword); foreach($users_db as $user) { $member = explode("|", $user); if(($kuser == $member[0]) && ($pass == $member[1])) { setcookie("kuser", $kuser); setcookie("kpassword", $pass); $result = true; break; } } return $result; } function login($kutente, $kpass) { if(($kutente == "") || ($kpass == "")) { nologin("non hai inserito tutte le informazioni necessaie per il login."); }else{ if(check_user($kutente, $kpass)) { $self_file = __FILE__; header("Location: $self_file"); }else{ nologin("username e/o password errati."); } } } ?>
db/users.db.phpcodice:<?php include("functions.inc.php"); if(!isset($_GET['action'])) { prelogin(); buttonlogin(); ?> </table></form> </td> </tr><?php }elseif((isset($_GET['action'])) && ($_GET['action'] == "login")) { if((!isset($_COOKIE['kuser'])) && (!isset($_COOKIE['kpassword']))) { login($_POST['user'], $_POST['password']); }else{ if(check_user($_COOKIE['user'], $_COOKIE['password'])) { header("Location: $PHP_SELF"); }else{ nologin("username e/o password errati"); } }
il file log.php è dove ci sono descritti tutti i tentativi di intrusioni rilevati e bloccati aprendo in modo diretto il file users.db.php. Dove sta l'errore se tento di effettuare un login con username "utente" e password la password?codice:<?php die("Non hai i permessi per visualizzare questa pagina."); $fopen = fopen("log.php", "a+"); $message = "Tentativo di intrusione per la visualizzazione del database utenti rilevato e bloccato\n"; fputs($fopen, $message); ?> utente|password formato md5(convertita con la funzione md5() prima di essere scritta)


Rispondi quotando