<?php
/*ini_set('display_errors',1);
header('Content-Type: text/html; charset=utf-8');*/

include('include/entete.php');
include('config/config.inc.php');
include('config/lib.inc.php');

//echo md5('titi');		5d933eef19aee7da192608de61b6c23d
//exit();

$maCleDeCryptage = getCleDeCryptage();

/*
	$query="select * from sollicitations";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->execute();
	$data=$queryRequest->fetchAll();
	echo "<table>";
	foreach($data as $cle=>$val){
		echo "<tr>";
		echo "<td>".$val['idCoLy']."</td>";
		echo "<td>".decrypter($maCleDeCryptage,$val['etaCoLy'])."</td>";
		echo "</tr>";
	}
	echo "<table>";
	exit();
*/

/*
	$query="select * from capitaines where id_cap=84";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->execute();
	$data=$queryRequest->fetchAll();
	echo "<table>";
	foreach($data as $cle=>$val){
		echo "<tr>";
		echo "<td>".$val['id_cap']."</td>";
		echo "<td>".decrypter($maCleDeCryptage,$val['nom_cap'])."</td>";
		echo "<td>".decrypter($maCleDeCryptage,$val['prenom_cap'])."</td>";
		echo "<td>".decrypter($maCleDeCryptage,$val['email_cap'])."</td>";
		echo "</tr>";
	}
	echo "<table>";
	exit();
*/

/*
echo '404 : ||'.crypter($maCleDeCryptage,'helene.genin@almea-formations-08.fr')."||<br>";
echo '405 : ||'.crypter($maCleDeCryptage,'patrice.bindler@almea-formations-10.fr')."||<br>";
echo '406 : ||'.crypter($maCleDeCryptage,'philippe.vanthournout@centre-alfor.fr')."||<br>";
echo '407 : ||'.crypter($maCleDeCryptage,'maxime.bordier@almea-formations-52.fr')."||<br>";
echo '408 : ||'.crypter($maCleDeCryptage,'mtroussel@saintmalofougeres.cci.fr')."||<br>";
*/

/*
//echo md5('deciday19');
//eqp6UJWdU53FgXuke4KHmpuhrYODmNHTWH7Qq5n7Cquc1w==
//echo crypter($maCleDeCryptage,'CS20109');
//$adresse2=crypter($maCleDeCryptage,"CS20109");

//$test = crypter($maCleDeCryptage,'eausset');
$sql = "select * from eta WHERE id_eta=410 or id_eta=411";
$query=($sql);
$db = connect_base();
$queryRequest = $db->prepare( $query );
$queryRequest->execute();
$data=$queryRequest->fetchAll();
echo "<table>";
$tab=array();
foreach($data as $cle=>$val){
	echo "<tr>";
	echo "<td>".$val['id_eta']."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['academie'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['nom_eta'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['adresse1'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['adresse2'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['cp'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['ville'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['nom_ref'])."</td>";
	echo "<td>".decrypter($maCleDeCryptage,$val['tel_ref'])."</td>";
	echo "<td>||".decrypter($maCleDeCryptage,$val['email_ref'])."||</td>";
	echo "</tr>";
	//if(isset($tab[trim(decrypter($maCleDeCryptage,$val['email_ref']))])) $tab[trim(decrypter($maCleDeCryptage,$val['email_ref']))]++;
	//else $tab[trim(decrypter($maCleDeCryptage,$val['email_ref']))]=1;
}
echo "<table>";
exit();
*/

/*
	$query="select * from contact_pro";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->execute();
	$data=$queryRequest->fetchAll();
	foreach($data as $cle=>$val){
		echo decrypter($maCleDeCryptage,$val['nom_cp']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['prenom_cp']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['age_cp']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['classe_cp']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['email_cp']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['comment_cp']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['type_pro']);
		echo "<br>";
		echo "<br>";
		echo "<br>";
	}
*/


/*
	$query="select * from inscriptions_pro";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->execute();
	$data=$queryRequest->fetchAll();
	foreach($data as $cle=>$val){
		echo decrypter($maCleDeCryptage,$val['nom_pro']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['prenom_pro']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['cp_pro']);
		echo "<br>";
		echo decrypter($maCleDeCryptage,$val['email_pro']);
		echo "<br>";
		echo "<br>";
		echo "<br>";
	}
*/

/*
	include('include/agenda.inc.php');	
	$query="select * from capitaines";
	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->execute();
	$data=$queryRequest->fetchAll();
	foreach($data as $cle=>$val){
		foreach($arrWeek as $kw=>$vw){
			foreach($vw as $vDay){
				if(!empty($vDay)){
					foreach($arrCreneaux as $va){
						if($vDay==$theGreatDay) $statut='libre';
						else $statut='bloque';
						$numCoLy=0;
						$query2 = "insert into agenda (numCap,numCoLy,numEta,jour,creneau,statut,dateLastUpdate) values (:numCap,:numCoLy,:numEta,:jour,:creneau,:statut,:dateLastUpdate)";
						$db2 = connect_base();
						$queryRequest2 = $db2->prepare( $query2 );
						$queryRequest2->bindParam( ':numCap', $val['id_cap'], PDO::PARAM_INT );
						$queryRequest2->bindParam( ':numCoLy', $numCoLy, PDO::PARAM_INT );
						$queryRequest2->bindParam( ':numEta', $val['num_eta'], PDO::PARAM_INT );
						$queryRequest2->bindParam( ':jour', $vDay, PDO::PARAM_STR );
						$queryRequest2->bindParam( ':creneau', $va, PDO::PARAM_STR );
						$queryRequest2->bindParam( ':statut', $statut, PDO::PARAM_STR );
						$queryRequest2->bindParam( ':dateLastUpdate', date('Y-m-d'), PDO::PARAM_STR );
						//$queryRequest2->execute();

					}
				}
			}
		}
	}
	exit();
*/

	//echo md5('a2018Deci60');
	//exit();

/*	
	//Trouve  les comptes test
	$ct1 = 's.descamps@fafih.com';
	$ct2 = 'n.thuillier@fafih.com';
	$ct3 = 'ozdeger@pointvirgule.fr';
	$ct4 = 'b.vdm@pointvirgule.net';
	$query = 'select * from eta where email_ref=:ct1 || email_ref=:ct2 || email_ref=:ct3 || email_ref=:ct4';

	$db = connect_base();
	$queryRequest = $db->prepare( $query );
	$queryRequest->bindParam( ':ct1', crypter($maCleDeCryptage,$ct1), PDO::PARAM_STR );
	$queryRequest->bindParam( ':ct2', crypter($maCleDeCryptage,$ct2), PDO::PARAM_STR );
	$queryRequest->bindParam( ':ct3', crypter($maCleDeCryptage,$ct3), PDO::PARAM_STR );
	$queryRequest->bindParam( ':ct4', crypter($maCleDeCryptage,$ct4), PDO::PARAM_STR );
	$queryRequest->execute();
	$data=$queryRequest->fetchAll();
	foreach($data as $cle=>$val){
		echo $val['id_eta'].' : '.decrypter($maCleDeCryptage,$val['email_ref']).' : '.md5('deciday19').'<br />';
	}

	exit();	
*/


/*echo "<pre>";print_r($tab);
echo "</pre>";*/
	
/*
        $query = 'select * from eta';

        $db = connect_base();
		$queryRequest = $db->prepare( $query );
        $queryRequest->execute();
		$data=$queryRequest->fetchAll();
		foreach($data as $cle=>$val){
			$email=decrypter($maCleDeCryptage,$val['email_ref']);
			$query2 = 'update eta set email_ref=:email_ref where id_eta=:id_eta';
			$db2 = connect_base();
			$queryRequest2 = $db2->prepare( $query2 );
			$queryRequest2->bindParam( ':id_eta', $val['id_eta'], PDO::PARAM_INT );
			$queryRequest2->bindParam( ':email_ref', crypter($maCleDeCryptage,trim($email), PDO::PARAM_STR ));
			//$queryRequest2->execute();
		}


exit();
*/


//////////////////////   AJOUT D UN ETABLISSEMENT

/*		$academie=crypter($maCleDeCryptage,"");
		$nom_eta=crypter($maCleDeCryptage,"U.R.M.A. Université Régionale des Métiers et de l'Artisanat de Région Nord Pas-de-Calais – Antenne de Dunkerque");
		$adresse1=crypter($maCleDeCryptage,"214 rue du Contre-Torpilleur le Triomphant");
		$adresse2=crypter($maCleDeCryptage,"");
		$cp=crypter($maCleDeCryptage,"59140");
		$ville=crypter($maCleDeCryptage,"DUNKERQUE");
		$nom_ref=crypter($maCleDeCryptage,"Pierre Crespi");
		$tel_ref=crypter($maCleDeCryptage,"0328587787");
		$email_ref=crypter($maCleDeCryptage,"p.crespi@cma-hautsdefrance.fr");

        $query = 'insert into eta (academie,nom_eta,adresse1,adresse2,cp,ville,nom_ref,tel_ref,email_ref,mdp_ref) values (:academie,:nom_eta, :adresse1, :adresse2,:cp,:ville,:nom_ref,:tel_ref, :email_ref, :mdp_ref)';

        $db = connect_base();
		$queryRequest = $db->prepare( $query );
        $queryRequest->bindParam( ':academie', $academie, PDO::PARAM_STR );
        $queryRequest->bindParam( ':nom_eta', $nom_eta, PDO::PARAM_STR );
        $queryRequest->bindParam( ':adresse1', $adresse1, PDO::PARAM_STR );
        $queryRequest->bindParam( ':adresse2', $adresse2, PDO::PARAM_STR );
        $queryRequest->bindParam( ':cp', $cp, PDO::PARAM_STR );
        $queryRequest->bindParam( ':ville', $ville, PDO::PARAM_STR );
        $queryRequest->bindParam( ':nom_ref', $nom_ref, PDO::PARAM_STR );
        $queryRequest->bindParam( ':tel_ref', $tel_ref, PDO::PARAM_STR );
        $queryRequest->bindParam( ':email_ref', $email_ref, PDO::PARAM_STR );
        $queryRequest->bindParam( ':mdp_ref', md5('deciday19'), PDO::PARAM_STR );
        $queryRequest->execute();

exit();*/




// 	$maCleDeCryptage = getCleDeCryptage();	
// 	$ident2=crypter($maCleDeCryptage,"admin3");
// 	$query='insert into droits (login_adm,mdp_adm,droit_adm) values (:ident2,:mdp2,1)';
// 	try {
//     // Connexion PDO
//     $db = connect_base();
//     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

//     // Requête INSERT avec la nouvelle colonne droit_autre
//     $sql = '
//         INSERT INTO droits (
//             login_adm,
//             mdp_adm,
//             droit_adm,
//             droit_autre
//         ) VALUES (
//             :login,
//             :mdp,
//             :droit,
//             :droit_autre
//         )
//     ';
//     $stmt = $db->prepare($sql);

//     // Préparation des valeurs
//     $maCleDeCryptage = getCleDeCryptage();
//     $login          = crypter($maCleDeCryptage, 'admin3');
//     $mdp            = md5('testpv');
//     $droit          = 1;
//     $droitAutre     = 1; // <-- la nouvelle valeur constante

//     // Liaison des paramètres
//     $stmt->bindParam(':login',       $login,      PDO::PARAM_STR);
//     $stmt->bindParam(':mdp',         $mdp,        PDO::PARAM_STR);
//     $stmt->bindParam(':droit',       $droit,      PDO::PARAM_INT);
//     $stmt->bindParam(':droit_autre', $droitAutre, PDO::PARAM_INT);

//     // Exécution
//     if ($stmt->execute()) {
//         echo 'Nouvel enregistrement créé avec droit_autre = 1.';
//     } else {
//         $err = $stmt->errorInfo();
//         echo "Erreur SQL [{$err[0]}] : {$err[2]}";
//     }

// } catch (PDOException $e) {
//     echo 'Exception PDO : ' . htmlspecialchars($e->getMessage(), ENT_QUOTES);
//     exit;
// }








?>