Vorrei modificare questo codice in modo da poter accedere a tutti gli utenti con un unico utente e password amministratore diverso da tutti gli altri.
Codice PHP:
<?php require_once('../Connections/condomini.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_condomini, $condomini);
$query_pdf = "SELECT * FROM indirizzi ORDER BY condominio ASC";
$pdf = mysql_query($query_pdf, $condomini) or die(mysql_error());
$row_pdf = mysql_fetch_assoc($pdf);
$totalRows_pdf = mysql_num_rows($pdf);
mysql_select_db($database_condomini, $condomini);
$query_superuser = "SELECT * FROM superAccesso ORDER BY ID ASC";
$superuser = mysql_query($query_superuser, $condomini) or die(mysql_error());
$row_superuser = mysql_fetch_assoc($superuser);
$totalRows_superuser = mysql_num_rows($superuser);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['utente'])) {
$loginUsername=$_POST['utente'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "documenti_condominio.php?utente=$_POST[utente]&condominio=$_POST[condominio]&citta=$_POST[citta]&via=$_POST[via]";
$MM_redirectLoginFailed = "area_personale.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_condomini, $condomini);
$LoginRS__query=sprintf("SELECT * FROM indirizzi WHERE utente=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $condomini) or die(mysql_error());
$row_LoginRS = mysql_fetch_assoc($LoginRS);
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
Grazie per i suggerimenti