<?php

	include("../M0/session_start.php") ;

	if ( $_SESSION['level'] != 127 ) {
		header('Location: ' . $root_dir . '/M1/index_2.php');
		exit();
	}

	include("../M0/communs_en_tete_HTML_no_arrows.html") ;
	$back_link = "../M6_b/gestion_admins.php";
	include('../M0/communs_en_tete_home_back.html');

	$return_path = "../M6_b/modify_user_of_one_site_target.php" ;
	include('../M0/display_admin_admin_target.php'); 

	include("../M0/2FAS_Authenticator.php") ;
	if ( isset($_SESSION['target_admin_2fas_secret']) ) {
		if ( $_SESSION['target_admin_id'] == "none" ) {
			$TWO_FA_SECRET = "1234567890ABCDEF";
		}
		else {
			$TWO_FA_SECRET = $_SESSION['target_admin_2fas_secret'];
		}
	}
	else {
		$TWO_FA_SECRET = "1234567890ABCDEF";
	}
	if ( ! empty($_GET) ) {
		if ( ! empty( $_GET['RENEW'] ) ) {
			if ( $_GET['RENEW'] == 1 ) {
				$TWO_FA_SECRET = Authenticator::createSecret(16);
			}
		}
	}

?>

<form name="form2" id="form2" method="post" action="">

<table align="center" width="<?php echo $tables_width ; ?>"  border="2" cellspacing="2" cellpadding="2" bordercolor="#ffffff" bgcolor="#000033">	
	<tr>
		<td>
		
			<table width="100%" >
				<tr>
					<td align="center">
					
						<div><label style="display: block;font-size:24px; color:lightblue;padding-top:10px;margin-bottom:20px;" >
						<u>- modification d'un administrateur -</u>
						</label></div>
						
					</td>
				</tr>
					
				<tr align="center">
					<td>

						<?php

							if ( $get_super_users_erreur == 0 ) {
								
								if ( $_SESSION['level'] >= 127 )	{
									
									if ( $_SESSION['target_admin_id'] == "none" ) {
										echo( '<label>' ) ;
										echo( "<font color='Salmon'>") ;
										echo( 'sélectionnez un administrateur !!!</br></br>' ) ;
										echo( "</font>") ;
										echo( '</label>' ) ;
									}
									else {
										
										if ( $_SESSION['target_admin_level'] < 127 ) {
											
											//include("./modify_user_of_one_site_target_1.php");
											include("./modify_user_of_one_site_target_a.php") ;
											
										}
										else {
											echo( '<label>' ) ;
											echo( "<font color='Salmon'>") ;
											echo( "modification d'un super-administrateur impossible !!!</br></br>" ) ;
											echo( "</font>") ;
											echo( '</label>' ) ;
										}
										
									}
									
								}
								else {
									echo( '<label>' ) ;
									echo( "<font color='Salmon'>") ;
									echo( 'administrateur de niveau insuffisant !!!</br></br>' ) ;
									echo( "</font>") ;
									echo( '</label>' ) ;
								}

							}
							else {
								echo( '<label>' ) ;
								echo( "<font color='Salmon'>") ;
								echo( 'erreur (' . strval( $get_super_users_erreur ) . ') !!!</br></br>' ) ;
								echo( "</font>") ;
								echo( '</label>' ) ;
							}
						
						?> 

					</td>
				</tr>
			</table>
			
		</td>
	</tr>
</table>

</form>

<script>

function my_confirm_function() {
	
	var msg = "attention : voulez-vous vraiment modifier l'administrateur sélectionné ?";
	var txt;
	var r = confirm(msg);
	
	if ( r == true ) {
		txt = "./modify_user_of_one_site_target_execute.php";
	} else {
		txt = "./modify_user_of_one_site_target.php";
	}
	document.getElementById("form2").action = txt;

}

</script>

 </body>
</html>