<?php

	if ( ( isset($_SESSION['login']) ) and ( $_SESSION['user_type'] == "super_user" ) ) {
		
		//----------------------------------------------------------
		include ("../_identifiants/sql_identification_main.php");
		
		$link = mysqli_connect($mysql_host,$mysql_user,$mysql_password, $mysql_base);
		
		if (!$link) {
			$code_erreur = 100;
			echo "Connexion impossible à la base de donnée MySQL !" . PHP_EOL; echo '</br>'; flush() ;
			echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo '</br>'; flush() ;
			echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; echo '</br>'; flush() ;
			exit($code_erreur);
		}

		$query_get_parameters = [] ;

		$query_get_parameters[0] = "
			SELECT USER_ID,USER_STATUS,USER_LEVEL,USER_T_MAX,USER_2FA_STATUS,USER_2FA_PHONE,USER_2FAS_STATUS,USER_2FAS_SECRET 
			FROM AQCM05_SUPER_USERS 
			WHERE ( USER_ID = '" . $_SESSION['login'] . "' )
			";

		//----------------------------------------------------------
		$code_erreur = 0;
		
		for ($i=0; $i < sizeof($query_get_parameters); $i++) {
			$result = mysqli_query($link, $query_get_parameters[$i]); 
			
			if (!$result) {	
				$code_erreur = 10*($i+1) + 1;
				echo "MySQL = " . $code_erreur . "<br>"; flush() ;
				echo "</br>";  flush() ;
				mysqli_close($link);
				exit($code_erreur);
			}
			else {
				if (mysqli_num_rows($result) == 0) {	
					$code_erreur = 10*($i+1) + 2;
					echo "MySQL = " . $code_erreur . "<br>"; flush() ;
					echo "</br>";  flush() ;
					mysqli_close($link);
					exit($code_erreur);
				}
				else {
					if ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { 
						extract($row);
					}
					else {
						$code_erreur = 10*($i+1) + 3;
						echo "MySQL = " . $code_erreur . "<br>"; flush() ;
						echo "</br>";  flush() ;
						mysqli_close($link);
						exit($code_erreur);
					}
				}
			}
		}
	}
	else {
	}
	
	//--------------------------------------------------------------------------------------------------------

	/*
	echo($_SESSION['login'] . "<br>") ;
	echo($USER_ID . "<br>") ;
	echo($USER_STATUS . "<br>") ;
	echo($USER_LEVEL . "<br>") ;
	echo($USER_T_MAX . "<br>") ;
	echo($USER_2FA_STATUS . "<br>") ;
	echo($USER_2FA_PHONE . "<br>") ;
	*/

	//-------------------------------------------------------------------------
	
?>
