
<!DOCTYPE HTML>
<html>

	<head>
	
		<title>AQCM05</title>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		
		<!--
		<meta name="viewport" content="width=device-width, initial-scale=1">
		-->
		
		<script type="text/javascript" src="../jquery.min.js"></script>
		<script type="text/javascript" src="../Highcharts-7.1.2/code/highcharts.js"></script>
		<script type="text/javascript" src="../Highcharts-7.1.2/code/modules/exporting.js"></script>
		<script type="text/javascript" src="../Highcharts-7.1.2/code/modules/export-data.js"></script>
		<script type="text/javascript" src="../Highcharts-7.1.2/code/modules/accessibility.js"></script>
		<style type="text/css"></style>
		<style type="text/css">
		   a:link {color: white;text-decoration: none;}      /* unvisited link */
		   a:visited {color: white;text-decoration: none;}   /* visited link */
		   a:hover {color: white;text-decoration: none;}     /* mouse over link */
		   a:active {color: white;text-decoration: none;}    /* selected link */

			table, th, td {
				padding: 4px;
				border: 1px solid white;
				border-collapse: collapse;
				text-align: center;
				font-family: arial;
				font-size: 14;
			}

		</style>
		
	</head>

	<body bgcolor="#000033" text="#CCCCCC" link="#00CCFF" vlink="#9966FF" alink="#CC0000">

	<?php
		
		//-------------------------------------------------------------------------
		include ("../_identifiants/sql_identification_sans_base.php");
		$mysql_base ='AQCM05_SITE_' . $p_aqcm_SITE_ID ;

		//-------------------------------------------------------------------------
		date_default_timezone_set('Europe/Paris');
		$marqueur_temps_maintenant = time();
		$marqueur_temps_maintenant = mktime(0, 0, 0, date("m", $marqueur_temps_maintenant)  , date("d", $marqueur_temps_maintenant) + 1, date("Y", $marqueur_temps_maintenant) );

		$link = mysqli_connect($mysql_host,$mysql_user,$mysql_password, $mysql_base);
		if (!$link) {
			$code_erreur = 1;
			echo $p_aqcm_SITE_ID . " ; " . $p_aqcm_MAC . "</br>";
			echo "erreur de connexion à la base ( mysqli_connect ) !" . "</br>";
			echo("</body></html>");
			exit($code_erreur);
		}
			
		$query_1	= "SELECT aqcm_NAME,aqcm_SERVER_PWD,aqcm_MESURES,aqcm_T_MAX FROM AQCM05_SONDES_MESURES WHERE aqcm_MAC='" . $p_aqcm_MAC . "'";

		$result	= mysqli_query($link, $query_1); 
		
		if (!$result) {	
			$code_erreur = 2;
			echo $p_aqcm_SITE_ID . " ; " . $p_aqcm_MAC . "</br>";
			echo "erreur lors de la requête ( mysqli_query ) !" . "</br>";
			mysqli_close($link);
			echo("</body></html>");
			exit($code_erreur);
		}

		if (mysqli_num_rows($result) != 1) {	
			$code_erreur = 3;
			echo $p_aqcm_SITE_ID . " ; " . $p_aqcm_MAC . "</br>";
			echo "résultat de la requête anormal ( mysqli_num_rows != 1 ) !" . "</br>";
			mysqli_close($link);
			echo("</body></html>");
			exit($code_erreur);
		}

		if ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { 
			extract($row);
		}
		else {
			$code_erreur = 4;
			echo $p_aqcm_SITE_ID . " ; " . $p_aqcm_MAC . "</br>";
			echo "erreur d'extraction des valeurs ( mysqli_fetch_array ) !" . "</br>";
			mysqli_close($link);
			echo("</body></html>");
			exit($code_erreur);
		}

		if ( $p_aqcm_SERVER_PWD != $aqcm_SERVER_PWD ) {
			$code_erreur = 5;
			echo $p_aqcm_SITE_ID . " ; " . $p_aqcm_MAC . "</br>";
			echo "mot de passe incorrect !" . "</br>";
			mysqli_close($link);
			echo("</body></html>");
			exit($code_erreur);
		}

		if ($aqcm_T_MAX <= $marqueur_temps_maintenant) {
			$code_erreur = 6;
			echo $p_aqcm_SITE_ID . " ; " . $p_aqcm_MAC . "</br>";
			echo "limite de validité dépassée ( $aqcm_T_MAX ) !" . "</br>";
			mysqli_close($link);
			echo("</body></html>");
			exit($code_erreur);
		}

		$code_erreur = 0;
		mysqli_close($link);
			
	?>

