Salve a tutti, ho alcuni dubbi su "loginsession20" che ho scaricato tra gli script disponibili.
Ho seguito i passi e praticamente funziona quasi tutto.
Però, una volta che faccio il login, non riesco a vedere il logout, mi apre una pagina bianca e non riesco a "disconnettermi".. inoltre, gli utenti che si registrano con i loro dati, dove li vado a vedere??


<?php session_start();

// file di dati
$data = "MPiu79yqw56L.php";

// percorso assoluto al file di dati
$path = "C:\Users\chiara rasetti\Desktop\loginsession\users.txt";

// Abilita / Disabilita registrazione utente: 1=abilitato, 0=disabilitato
$registration = 1;

// Codifica chiave - Cambia l'opzione per qualsiasi stringa di caratteri
$keyCode = "vsne7y4f6bvavhlgutrx9pazzcvtde0fa9kemhj0uqxmw90tu y7qadnl96g84w";

// Principali fogli di stile a cascata
$style = '
html, body {
height: 90%;
font-family: Calibri, Arial, Verdana;
font-size: 14px;
}
#titlebar {
position: relative;
height: 20px;
width: 260px;
border-top: 1px solid #000000;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
background-color: #FF66FF;
color: #000000;
text-align: center;
font-size: 16px;
}
#foot {
position: relative;
height: 20px;
width: 260px;
color: #000000;
text-align: center;
font-size: 12px;
}
input.text {
width: 220px;
height: 20px;
border: 1px solid #000000;
background-color: #FFEECB;
}
input.btn {
width: 60px;
height: 20px;
border: 1px solid #000000;
background-color: #0093DD;
color: #000000;
}
input.btn:hover {
cursor: pointer;
}
a {
color: #000000;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
';
$log_style = '
#wrapper {
position: absolute;
height: 185px;
width: 260px;
text-align: center;
color: #000000;
left: 50%;
top: 50%;
margin-left: -130px;
margin-top: -85px;
}
#form {
position: relative;
height: 170px;
width: 260px;
border: 1px solid #000000;
background-color: #66cc99;
color: #000000;
text-align: left;
}
';
$reg_style = '
#wrapper {
position: absolute;
height: 270px;
width: 260px;
text-align: center;
color: #000000;
left: 50%;
top: 50%;
margin-left: -130px;
margin-top: -135px;
}
#form {
position: relative;
height: 250px;
width: 260px;
border: 1px solid #000000;
background-color: #66cc99;
color: #000000;
text-align: left;
}
';

// Non cambiare il codice seguente

$version = '2.2.4';

function encode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i++) {
$ordStr = ord(substr($string,$i,1));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
}
return $hash;
}

function decode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i+=2) {
$ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),3 6,16));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= chr($ordStr - $ordKey);
}
return $hash;
}

$users = $path . $data;

if (file_exists($users)) {
$records = count(file($users));
}
else {
fopen($users, 'w') or die("Impossibile aprire il database utente.");
}
if (isset($_GET['ls_logout'])) {
unset($_SESSION['ls_id']);
unset($_SESSION['ls_user']);
unset($_SESSION['ls_email']);
}
if (isset($_POST)) {
$login = FALSE;
$register = FALSE;
$errors = '';
foreach ($_POST as $key => $value) {
if ($key == "ls_reg") { $login = FALSE; $register = TRUE; }
else if ($key == "ls_log") { $login = TRUE; $register = FALSE; }
else if ($key == "ls_user") {
if (!eregi('^[[:alnum:]\.\'\-]{3,15}$', $value)) { $u_invalid = 1; }
$user = encode($value,$keyCode);
}
else if ($key == "ls_email") {
if (!eregi('^[a-zA-Z]+[\.a-zA-Z0-9_-]*@([a-zA-Z0-9_-]+){1}(\.[a-zA-Z0-9]+){1,2}', $value)) { $e_invalid = 1; }
$email = encode($value,$keyCode);
}
else if ($key == "ls_pass") {
if (!eregi("^[[:alnum:]\.\'\-]{3,15}$", $value)) { $p_invalid = 1; }
$pass = sha1($value);
}
else if ($key == "ls_repeat") { $repeat = sha1($value); }
}
}
if ($login == TRUE) {
if (file_exists($users)) {
$lines = file($users);
foreach ($lines as $line_num => $line) {
$array = explode("||",str_replace("\n","",$line));
$c_id = $array[0];
$c_user = $array[1];
$c_email = $array[2];
$c_pass = $array[3];
if ($c_user == $user && $c_pass == $pass) {
$_SESSION['ls_id'] = $c_id;
$_SESSION['ls_user'] = decode($c_user,$keyCode);
$_SESSION['ls_email'] = decode($c_email,$keyCode);
}
}
if (!isset($_SESSION['ls_id']) || !isset($_SESSION['ls_user']) || !isset($_SESSION['ls_email'])) {
$errors[] = "Invalid Login.";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Errore di Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<?php echo $style; ?>
<?php echo $log_style; ?>
</style>
</head>
<body>
<div id="wrapper">
<div id="titlebar">Errori</div>
<div id="form">
<div style="padding:10px;">
<ul style="padding:0px;margin:15px;">
<?php
foreach ($errors as $msg) {
echo "<li style=\"padding:0px;margin:0px;\">$msg";
}
$errors = '';
?>
[/list]
<div style="text-align:center;padding:20px;">
Clicca qui per tornare indietro.
</div>
</div>
</div>
</div>
</body>
</html>
<?php
exit();
}
}
}
else if ($register == TRUE) {
if (file_exists($users)) {
$lines = file($users);
foreach ($lines as $line_num => $line) {
$array = explode("||",str_replace("\n","",$line));
$c_id = $array[0];
$c_user = $array[1];
$c_email = $array[2];
$c_pass = $array[3];
if ($user == $c_user) { $u_taken = 1; }
if ($email == $c_email) { $e_taken = 1; }
}
if ($user == NULL) { $errors[] = 'Il campo utente non pu&ograve; essere vuoto.'; }
if ($u_invalid == 1) { $errors[] = 'User ' . htmlspecialchars(decode($user,$keyCode)) . ' non &egrave; valido. Richiesti da 3 a 15 caratteri alfanumerici.'; }
if ($u_taken == 1) { $errors[] = 'Username ' . htmlspecialchars(decode($user,$keyCode)) . ' &egrave; gi&agrave; utilizzato.'; }
if ($email == NULL) { $errors[] = 'Il campo Email non pu&ograve; essere vuoto.'; }
if ($e_invalid == 1) { $errors[] = 'Indirizzo Email ' . htmlspecialchars(decode($email,$keyCode)) . ' non &egrave; valido.'; }
if ($e_taken == 1) { $errors[] = 'Indirizzo Email ' . htmlspecialchars(decode($email,$keyCode)) . ' &egrave; gi&agrave; utilizzato.'; }
if ($pass == sha1(NULL)) { $errors[] = 'Il campo Password non pu&ograve; essere vuoto.'; }
if ($p_invalid == 1) { $errors[] = 'Password non valida. Richiesti da 3 a 15 caratteri alfanumerici.'; }
if ($repeat == sha1(NULL)) { $errors[] = 'Il campo Verifica Password non pu&ograve; essere vuoto.'; }
if ($pass != $repeat) { $errors[] = 'Password e Verifica Password non corrispondono.'; }
}
if (empty($errors)) {
$newline = $records++;
$data = "$newline||$user||$email||$pass\n";
$fh = fopen($users, 'a') or die("Impossibile aprire il database utente.");
fwrite($fh, $data);
fclose($fh);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Registrazione Avvenuta</title>
<link type="text/css" href="../foglio_stile.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<?php echo $style; ?>
<?php echo $log_style; ?>
</style>
</head>
<body>
<div id="wrapper">
<div id="titlebar">Registrazione avvenuta!</div>
<div id="form">
<div style="text-align:center;padding:20px;">
Sei stato registrato con successo.

Clicca qui per entrare.
</div>
</div>
</div>
</body>
</html>
<?php
exit();
}
else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>Errore di Registrazione</title>
<link type="text/css" href="../foglio_stile.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<?php echo $style; ?>
<?php echo $reg_style; ?>
</style>
</head>
<body>
<div id="wrapper">
<div id="titlebar">Errori</div>
<div id="form">
<div style="padding:10px;">
<ul style="padding:0px;margin:15px;">
<?php
foreach ($errors as $msg) {
echo "<li style=\"padding:0px;margin:0px;\">$msg";
}
$errors = '';
?>
[/list]
<div style="text-align:center;padding:20px;">
Clicca qui per tornare indietro.
</div>
</div>
</div>
</div>
</body>
</html>
<?php
exit();
}
}
else if (isset($_GET['ls_register']) && $registration == 1) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Registrazione nuovo utente</title>
<link type="text/css" href="../foglio_stile.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<?php echo $style; ?>
<?php echo $reg_style; ?>
</style>
</head>
<body>
<div id="wrapper">
<div id="titlebar">Form di Registrazione</div>
<div id="form">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<div style="text-align:left;padding:20px;width:220px;">
<label>Username:

<input type="text" name="ls_user" value="" class="text" /></label>

<label>Email:

<input type="text" name="ls_email" value="" class="text" /></label>

<label>Password:
<input type="password" name="ls_pass" value="" class="text" /></label>

<label>Ripeti Password:
<input type="password" name="ls_repeat" value="" class="text" /></label>

<div style="text-align:center;margin:20px 0px 0px 0px;">
<input type="submit" name="ls_reg" value="Invia" class="btn" />
</div>
<div style="text-align:right;">Login</div>
</div>
</form>
</div>

</div>
</body>
</html>
<?php
exit();
}
else if (!isset($_SESSION['ls_id']) && !isset($_SESSION['ls_user']) && !isset($_SESSION['ls_email'])) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Login Richiesto</title>
<link type="text/css" href="../foglio_stile.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<?php echo $style; ?>
<?php echo $log_style; ?>
</style>
</head>
<body>
<div id="wrapper">
<div id="titlebar">Login Richiesto</div>
<div id="form">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<div style="text-align:left;padding:20px;width:220px;">
<label>Username:

<input type="text" name="ls_user" value="" class="text" /></label>

<label>Password:
<input type="password" name="ls_pass" value="" class="text" /></label>

<div style="text-align:center;margin:20px 0px 0px 0px;">
<input type="submit" name="ls_log" value="Login" class="btn" />
</div>
<?php
if ($registration == 1) {
?>
<div style="text-align:right;">Registrati</div>
<?php
}
?>
</div>
</form>
</div>
</div>
</body>
</html>
<?php
exit();
}
?>