Il mio sito continua a essere bucato. Il mio MNT dice che la colpa è legata al mio codice php (senza guardarlo). Ho provato più volte a controllarlo ma non capisco cosa c'è che non va.. a me sembra tutto ok..
Se qualcuno vuole, posto il mio codice qui sotto..
Ho preso liberamente spunto (copiato) da questa pagina: http://www.siforge.org/articles/2003...sioni_php.html
Qualcuno mi puo' dire se c'è qualche buco? o se è più presumibile che la colpa sia dei gestori dell'host?
---------------------------------------------------------
PAGINA INDEX: CREAZIONE SESSIONE E LOGIN
-------------------------------------------------------codice:<?php $redirect="index.php"; include_once("../parametri.php"); //contiene i parametri per la connessione al db include_once("../connessione.php"); // connessione al db //gestione della sessione nel caso in cui i cookie sono disabilitati if(IsSet($_POST['PHPSESSID']) && !IsSet($_COOKIE['PHPSESSID'])) { $PHPSESSID=$_POST['PHPSESSID']; header("Location: $redirect?PHPSESSID=$PHPSESSID"); //si ricarica la pagina di login } session_start(); //si inizia o continua la sessione //controllo user e passwd da login if(IsSet($_POST['posted_username']) && IsSet($_POST['posted_password'])) { $md5passw = md5($_POST['posted_password']); $user = $_POST['posted_username']; $query = "select * from utenti where nick='$user' and pass='$md5passw'"; if (!mysql_query($query, $conn)) echo ("Il webmaster è un pirla perchè ha sbagliato a scrivere la query."); $risultato = mysql_query($query, $conn); if (mysql_num_rows($risultato) > 0) $_SESSION['utente']=$_POST['posted_username']; } //creazione cookie per login automatico if(IsSet($_POST['ricorda']) && IsSet($_SESSION['utente'])) { $cok=md5($_POST['posted_password']).";;".$_POST['posted_username']; setcookie("save_user","$cok",time()+31536000); } //logout if($_GET['logout']==1) { $_SESSION=array(); // Desetta tutte le variabili di sessione. session_destroy(); //DISTRUGGE la sessione. if(IsSet($_COOKIE['save_user'])) //se presente si distrugge il cookie di login automatico setcookie("save_user","",time()-31536000); header("Location: $redirect"); //si ricarica la pagina di login exit; //si termina lo script in modo da ritornare alla schermata di login } //controllo user e passwd da cookie if(IsSet($_COOKIE['save_user'])) { $info_cok=$_COOKIE['save_user']; $cok_pass=strtok($info_cok,";;"); $cok_user=strtok(";;"); setcookie("save_user","$info_cok",time()+31536000); $query = "select * from utenti where nick='$cok_user' and pass='$cok_pass'"; if (!mysql_query($query, $conn)) echo ("Il webmaster è un pirla perchè ha sbagliato a scrivere la query."); $risultato = mysql_query($query, $conn); if (mysql_num_rows($risultato) > 0) $_SESSION['utente']=$cok_user; } //caso in cui si vuole ricordare il login, ma i cookie sono off if(!IsSet($_COOKIE['PHPSESSID']) && IsSet($_POST['ricorda'])) header("Location: $redirect?nocookie=1"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>...</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body class="pagina"> <table width="780" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="center">[img]titolo.gif[/img] </div></td> </tr> <tr> <td> <?php $PHPSESSID=session_id(); if(!IsSet($_SESSION['utente'])) //non siamo loggati, pagina di login { if($_GET['nocookie']==1) //i cookie sono off e si vuole ricordare il login print("<div align=center>Spiacente, ma con i cookie disabilitati non posso fare i miracoli ;) Attivali se vuoi ricordare il tuo login.</div> "); if (IsSet($_POST['SUBMIT'])) print("<div align=center><font color=red>Nome utente e/o password non corretti.</font></div> "); print(" <form action=" . $redirect . " method=post> <table border=0 align=center cellpadding=0 cellspacing=0> <tr> <td><div align=center>Inserire nome utente e password. </div></td> </tr> <tr> <td><table width=100% border=0 cellspacing=1 cellpadding=1> <tr> <td>Nome utente:</td> <td><input name=posted_username type=text size=20 maxlength=10></td> </tr> <tr> <td>Password:</td> <td><input name=posted_password type=password size=20 maxlength=15></td> </tr> <tr> <td></td> <td><input type=checkbox name=ricorda value=1> ricorda accesso</td> </tr> </table></td> </tr> <tr> <td><div align=right> <input name=SUBMIT type=submit value=login> </div></td> </tr> </table> "); if (!isset($_COOKIE['PHPSESSID'])) //i cookie sono off, dobbiamo propagare noi il PHPSESSID print("<input type=hidden name=PHPSESSID value=$PHPSESSID>"); print(" </form> "); } else //siamo loggati pagina riservata { ?> ......... <a href="index.php?logout=1" class="link">LOG-OUT.. </a><? } ?> </td> </tr> </table> </body> </html>
PAGINA PROTETTA
codice:<? include_once("../parametri.php"); include_once("../connessione.php"); session_start(); $PHPSESSID=session_id(); if(!IsSet($_SESSION['utente'])) //non siamo loggati, pagina di login header("Location: index.php"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>...</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body class="pagina"> <table width="780" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="center">[img]titolo.gif[/img] </div></td> </tr> <tr> <td> .... </td> </tr> </table> </body> </html>

Rispondi quotando