<?php

	// On prolonge la session
	session_start();
	include("../M0/get_parameters.php") ;

	// On teste si la variable de session existe et contient une valeur
	if( empty($_SESSION['login']) ) {
		
		// Si inexistante ou nulle, on redirige vers le formulaire de login
		header('Location: ' . $root_dir . '/M1/login.php');
		exit();
		
	} 

	if ( $_SESSION['user_type']	== "super_user" ) {
		
		include ("../M0/get_AQCM05_sites.php");
		$_SESSION['list_sites'] = $sites_from_AQCM05_SITES_LIST ;
		
	}


	if ( ! empty($_POST) ) {
		
		if ( !empty( $_POST['select_site_id'] ) ) {

			$_SESSION['SITE_ID'] = $_POST['select_site_id'] ;

			if ( $_SESSION['user_type']	== "normal_user" ) {
				
				for ($i = 0; $i < sizeof($_SESSION['list_sites']); $i++) {
					
					if ( $_SESSION['SITE_ID'] == $_SESSION['list_sites'][$i] ) {
						
						$_SESSION['index_session'] 	= $i ;
						$_SESSION['base_users']  	= "AQCM05_SITE_" . $_SESSION['SITE_ID'] ;
						
						$_SESSION['status']			= $_SESSION['status_OK'][$_SESSION['index_session']] ;
						$_SESSION['level']			= $_SESSION['level_OK'][$_SESSION['index_session']] ;
						$_SESSION['t_max']			= $_SESSION['t_max_OK'][$_SESSION['index_session']] ;
						
						$_SESSION['login_level'] 	= $_SESSION['login'] . "&nbsp;&nbsp;&nbsp;(" . $_SESSION['level'] . ")" ;

					}
				
				}
				
			}

		}
		
	}


?>
