Al momento i codici sono puntati alla risoluzione del problema SESSION, visto che il problema HEADER è aggirabile, pur con una soluzione che esteticamente non mi piace. Quindi le righe che riguardano lo HEADER sono commentate e sono invece attive le righe con i forms alternativi.
La prima pagina è una pagina Joomla!, non ha contenuti PHP e si risolve nel solo FORM di accesso, quindi è inutile che la pubblichi.
Pagina di verifica dell'accesso (verifica_accesso_direzionale.php):
Codice PHP:
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="created" content="mar, 03 lug 2012 15.02.57 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="/templates/ff_sipbc_j11/css/sipbcall.css" type="text/css" media="all" />
<title>Verifica accesso direzionale</title>
<!-- Verifica se chi ha chiesto l'accesso direzionale è abilitato (dati provenienti da pagina Joomla) -->
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script type="text/javascript" src="../templates/ff_sipbc_j11/js/5shiv.js"></script>
<![endif]-->
</head>
<body>
<?php
error_reporting(E_ALL);
require_once('costanti.inc');
require_once('dbconnect.inc');
require_once('userinfo.inc');
$codice = $_POST["codice"];
$password = $_POST["pw"];
$conn = @new mysqli($db_server, $db_user_name, $db_password, $db_name);
if (mysqli_connect_errno() != 0)
{
$errno = mysqli_connect_errno();
$errmsg = mysqli_connect_error();
echo '<article id="modiscriz1">', TESTATA;
echo 'Errore connessione: ', ($errno),' ',$message, '<input type="button" value="Torna indietro" onClick="javascript:history.go(-1)" />';
exit;
}
$conn->query("SET NAMES 'utf8'");
$query_str = "SELECT * FROM accesso WHERE codice='$codice'";
$result = $conn->query($query_str);
if ($result === FALSE)
{
$errno = $conn->errno;
$errmsg = $conn->error;
echo '<article id="modiscriz1">', TESTATA;
echo 'Errore dati: ($errno) $errmsg<br/>','<input type="button" value="Torna indietro" onClick="javascript:history.go(-1)" />';
$conn->close();
exit;
}
$row_data = @$result->fetch_array();
$sha2=hash('sha256', $password);
if ($sha2 != $row_data['password'])
{
echo '<article id="modiscriz1">', TESTATA;
echo '<span style="color:red; font-weight:bold;">Codice e/o password non validi</span><br />';
echo '<input type="button" value="Torna indietro" onClick="javascript:history.go(-1)" />';
$result->close();
$conn->close();
exit;
}
ini_set('session.save_path', '../iscrizione/tmp/');
session_name('ACCESSODIREZIONALE');
session_start();
$tipo = $row_data['tipo'];
$sezione = $row_data['sezione'];
$delegazione = $row_data['delegazione'];
$user = new UserInfo($codice, $password, $tipo, $sezione, $delegazione);
$_SESSION['current_user'] = $user;
if (isset($result)): $result->close(); endif;
if (isset($conn)): $conn->close(); endif;
// header('location:accesso_direzionale.php');
// exit;
echo '<br /><h3>Credenziali corrette per ';
switch ($tipo)
{
case "1": echo "l'Amministratore del Sistema e la Segreteria Nazionale</h3>"; break;
case "2": echo 'il Presidente ed il Segretario Generale</h3>'; break;
case "3": echo 'la ', $sezione, '</h3>'; break;
case "4": echo 'la ', $delegazione, '</h3>'; break;
}
echo '<form method="post" name="avvio" action="accesso_direzionale.php">',
'<button type="submit" />Accedi</button>',
'</form>';
// exit;
?>
</article>
</body>
</html>
Pagina di accesso (accesso_direzionale.php)
Codice PHP:
<!DOCTYPE html>
<?php
error_reporting(E_ALL);
require_once('costanti.inc');
require_once('dbconnect.inc');
require_once('userinfo.inc');
ini_set('session.save_path', '../iscrizione/tmp/');
session_name('ACCESSODIREZIONALE');
session_start();
?>
<html lang="it">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="created" content="mar, 03 lug 2012 15.02.57 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="/templates/ff_sipbc_j11/css/sipbcall.css" type="text/css" media="all" />
<title>Accesso direzionale</title>
<!-- Riceve OK da verifica_accesso.php e seleziona il tipo di autorizzazione per l'utente -->
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script type="text/javascript" src="../templates/ff_sipbc_j11/js/5shiv.js"></script>
<![endif]-->
</head>
<body>
<?php
print_r(session_id()); // togliere dopo debug
print_r(session_name()); // togliere dopo debug
$user = $_SESSION['current_user'];
$codice = $user->get_codice();
$tipo = $user->get_tipo();
$pwu = $user->get_pwu();
$sezione = $user->get_sezione();
$delegazione = $user->get_delegazione();
$errore = FALSE;
echo '<article id="modiscriz1">';
echo TESTATA;
switch ($tipo)
{
case "1":
?>
<table style="width:1000px; border:black 5px ridge; color:blue; margin:auto; text-align:center;">
<tr style="font-weight:bold; text-align:center;">
<td colspan="5"><p>Accesso consentito con privilegi dell'Amministratore di sistema.</p></td>
</tr>
<tr>
<td><form method="post" name="avvio" action="../phpmyadmin" target="_blank">
<button type="submit" />Database</button>
</form></td>
<td><form method="post" name="avvio" action="abilita.php">
<button type="submit" />Abilita accesso</button>
</form></td>
<td><form method="post" name="avvio" action="lista_abilitati.php">
<button type="submit" />Elenco abilitati</button>
</form></td>
<td><form method="post" name="avvio" action="lista_iscrizioni.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Iscr. individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_iscrizioni_collettive.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Iscr. collettive</button>
</form></td>
</tr>
<tr>
<td><form method="post" name="avvio" action="nuovo_onore.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Ins. Membri On.</button>
</form></td>
<td><form method="post" name="avvio" action="lista_onore.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Membri d'Onore</button>
</form></td>
<td><form method="post" name="avvio" action="lista_soci.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Soci individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_collettivi.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Soci collettivi</button>
</form></td>
<?php
break;
case "2":
?>
<table style="width:1000px; border:black 5px ridge; color:blue; margin:auto; text-align:center;">
<tr style="font-weight:bold; text-align:center;">
<td colspan="3"><p>Accesso consentito con privilegi della Direzione Nazionale.</p></td>
</tr>
<tr>
<td><form method="post" name="avvio" action="lista_iscrizioni.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Iscr. individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_iscrizioni_collettive.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Iscr. collettive</button>
</form></td>
<td><form method="post" name="avvio" action="lista_onore.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Membri d'Onore</button>
</form></td>
</tr>
<tr>
<td><form method="post" name="avvio" action="lista_soci.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Soci individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_collettivi.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<button type="submit" />Soci collettivi</button>
</form></td>
<?php
break;
case "3":
?>
<table style="width:1000px; border:black 5px ridge; color:blue; margin:auto; text-align:center;">
<tr style="font-weight:bold; text-align:center;">
<td colspan="5"><p>Accesso consentito con privilegi della <?php echo $sezione; ?>.</p></td>
</tr>
<tr>
<td><form method="post" name="avvio" action="lista_iscrizioni.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="sezione" value="<?php echo $sezione; ?>" hidden="TRUE" />
<button type="submit" />Iscr. individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_iscrizioni_collettive.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="sezione" value="<?php echo $sezione; ?>" hidden="TRUE" />
<button type="submit" />Iscr. collettive</button>
</form></td>
<td><form method="post" name="avvio" action="lista_soci.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="sezione" value="<?php echo $sezione; ?>" hidden="TRUE" />
<button type="submit" />Soci individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_collettivi.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="sezione" value="<?php echo $sezione; ?>" hidden="TRUE" />
<button type="submit" />Soci collettivi</button>
</form></td>
<?php
break;
case "4":
?>
<table style="width:1000px; border:black 5px ridge; color:blue; margin:auto; text-align:center;">
<tr style="font-weight:bold; text-align:center;">
<td colspan="5"><p>Accesso consentito con privilegi della <?php echo $delegazione; ?>.</p></td>
</tr>
<tr>
<td><form method="post" name="avvio" action="lista_iscrizioni.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="delegazione" value="<?php echo $delegazione; ?>" hidden="TRUE" />
<button type="submit" />Iscr. individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_iscrizioni_collettive.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="delegazione" value="<?php echo $delegazione; ?>" hidden="TRUE" />
<button type="submit" />Iscr. collettive</button>
</form></td>
<td><form method="post" name="avvio" action="lista_soci.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="delegazione" value="<?php echo $delegazione; ?>" hidden="TRUE" />
<button type="submit" />Soci individuali</button>
</form></td>
<td><form method="post" name="avvio" action="lista_collettivi.php">
<input type="hidden" name="tipo" value="<?php echo $tipo; ?>" hidden="TRUE" />
<input type="hidden" name="delegazione" value="<?php echo $delegazione; ?>" hidden="TRUE" />
<button type="submit" />Soci collettivi</button>
</form></td>
<?php
break;
}
?>
<td>
<form method="post" name="avvio" action="../index.php?option=com_content&view=article&id=719&Itemid=898&lang=it">
<button type="submit" />Cambio accesso</button>
</form></td>
</tr>
</table>
</article>
</body>
</html>
Credo comunque che non troverai nulla nel codice: a parer mio il problema dovrebbe stare nel settaggio di php.ini sul server remoto, qualcosa che mi sfugge o che non so.