Ho migrato l'intero gestionale (+200 files) da PHP 5.5 a 7.4 e funziona tutto tranne questo file di autorizzazione che girava sotto la versione precedente ma non sotto la 7 e non riesco a trovare la funzione incompatibile (php non me lo segnala)
Lo posto commentato :
Codice PHP:
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
ini_set('session.gc_maxlifetime', '6000');
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "loginSorry.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
if($_SESSION['MM_UserGroup'] < 4)
{header("Location: Pub_loginSorry.php");
}
/* echo "--------------------------------------------------------- gc_maxlifetime -> ".ini_get('session.gc_maxlifetime');*/
Questa la pagina di accesso:
Codice PHP:
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=mysqli_real_escape_string($tao_conn, $_POST['username']);
$password=mysqli_real_escape_string(sha1($tao_conn, $_POST['password']));
$MM_fldUserAuthorization = "AuthLev";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "loginSorry.php";
$MM_redirecttoReferrer = false;
mysqli_select_db($tao_conn, $database_tao_conn);$LoginRS__query=sprintf("SELECT username, password, AuthLev FROM adminauth WHERE username=%s AND password=%s",
GetSQLValueString($tao_conn,$loginUsername, "text"), GetSQLValueString($tao_conn,$password, "text"));
$LoginRS = mysqli_query($tao_conn,$LoginRS__query) or die(mysqli_error($tao_conn));
$loginFoundUser = mysqli_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysqli_result($LoginRS,0,'AuthLev');
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 );
}