188 lines
6.2 KiB
PHP
188 lines
6.2 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
/**********************************
|
|||
|
|
FONCTIONS DE CRYPTAGE
|
|||
|
|
**********************************/
|
|||
|
|
|
|||
|
|
// crypte une chaine (via une clé de cryptage)
|
|||
|
|
function crypter($maCleDeCryptage="", $maChaineACrypter){
|
|||
|
|
if($maCleDeCryptage==""){
|
|||
|
|
$maCleDeCryptage=$GLOBALS[‘PHPSESSID’];
|
|||
|
|
}
|
|||
|
|
$maCleDeCryptage = md5($maCleDeCryptage);
|
|||
|
|
$letter = -1;
|
|||
|
|
$newstr = '';
|
|||
|
|
$strlen = strlen($maChaineACrypter);
|
|||
|
|
for($i = 0; $i < $strlen; $i++ ){
|
|||
|
|
$letter++;
|
|||
|
|
if ( $letter > 31 ){
|
|||
|
|
$letter = 0;
|
|||
|
|
}
|
|||
|
|
$neword = ord($maChaineACrypter{$i}) + ord($maCleDeCryptage{$letter});
|
|||
|
|
if ( $neword > 255 ){
|
|||
|
|
$neword -= 256;
|
|||
|
|
}
|
|||
|
|
$newstr .= chr($neword);
|
|||
|
|
}
|
|||
|
|
return base64_encode($newstr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// décrypte une chaine (avec la même clé de cryptage)
|
|||
|
|
function decrypter($maCleDeCryptage="", $maChaineCrypter){
|
|||
|
|
if($maCleDeCryptage==""){
|
|||
|
|
$maCleDeCryptage=$GLOBALS[‘PHPSESSID’];
|
|||
|
|
}
|
|||
|
|
$maCleDeCryptage = md5($maCleDeCryptage);
|
|||
|
|
$letter = -1;
|
|||
|
|
$newstr = '';
|
|||
|
|
$maChaineCrypter = base64_decode($maChaineCrypter);
|
|||
|
|
$strlen = strlen($maChaineCrypter);
|
|||
|
|
for ( $i = 0; $i < $strlen; $i++ ){
|
|||
|
|
$letter++;
|
|||
|
|
if ( $letter > 31 ){
|
|||
|
|
$letter = 0;
|
|||
|
|
}
|
|||
|
|
$neword = ord($maChaineCrypter{$i}) - ord($maCleDeCryptage{$letter});
|
|||
|
|
if ( $neword < 1 ){
|
|||
|
|
$neword += 256;
|
|||
|
|
}
|
|||
|
|
$newstr .= chr($neword);
|
|||
|
|
}
|
|||
|
|
return $newstr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Définit une clé de cryptage
|
|||
|
|
function getCleDeCryptage(){
|
|||
|
|
return $maCleDeCryptage = "Xàùé4f8s6c2D";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Affichage du contenu des boites à outils
|
|||
|
|
function listFilesBao($cat='', $unblock = 0){
|
|||
|
|
|
|||
|
|
$tFilesBao = array();
|
|||
|
|
|
|||
|
|
//Fichiers accessibles par tous
|
|||
|
|
// Fichiers disponible dans la sous-catégorie "Recrutement"
|
|||
|
|
if($cat=='recrutement' && $unblock == 0){
|
|||
|
|
$tFilesBao[]=array('file' => 'Mail_pour_colleges_et_lycees.docx', 'title' => 'Email de sollicitation');
|
|||
|
|
$tFilesBao[]=array('file' => 'Presentation_Deciday_pour_les_acteurs.pdf','title' => 'Dossier de présentation');
|
|||
|
|
}
|
|||
|
|
// Fichiers disponible dans la sous-catégorie "Guide"
|
|||
|
|
if($cat=='guide' && $unblock == 0){
|
|||
|
|
$tFilesBao[]=array('file' => 'Guide-Deciday-2018.pdf','title' => 'Rôle des CFA et des LP');
|
|||
|
|
$tFilesBao[]=array('file' => 'Guide-communication-CFA-LP.pdf','title' => 'Guide de communication Deciday ! pour les CFA et Lycées professionnels');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Les affiches
|
|||
|
|
// NIV 1
|
|||
|
|
if ($cat=='affiches' && $unblock == 0){
|
|||
|
|
$tFilesBao[]=array('file' => 'Affiche_deciday_2019_cfa.pdf', 'title' => 'Affiche Deciday ! CFA');
|
|||
|
|
$tFilesBao[]=array('file' => 'Affiche_deciday_2019_lycees_pro.pdf', 'title' => 'Affiche Deciday ! Lycées professionnels');
|
|||
|
|
$tFilesBao[]=array('file' => 'Affiche_deciday_2019_professionnels.pdf', 'title' => 'Affiche Deciday ! Professionnels');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Les kits pédagoqiues
|
|||
|
|
// NIV 1
|
|||
|
|
if($cat=='kitPedago' && $unblock == 0){
|
|||
|
|
$tFilesBao[]=array('file' => 'Kit_pedagogique_colleges_et_lycees_guide_deciday_enseignants_2018.pdf', 'title' => 'Kit pédagogique collèges et lycées guide Deciday ! enseignants');
|
|||
|
|
$tFilesBao[]=array('file' => 'Kit_pedagogique_colleges_et_lycees_guide_deciday_eleves_2018.pdf', 'title' => 'Kit pédagogique collèges et lycées guide Deciday ! élèves');
|
|||
|
|
$tFilesBao[]=array('file' => 'Kit_pedagogique_colleges_et_lycees_guide_poster.pdf', 'title' => 'Kit pédagogique collèges et lycées Poster de classe');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// NIV 2
|
|||
|
|
if($unblock==1 && $cat=='kitPedago'){
|
|||
|
|
$tFilesBao[] = array('file' => 'https://we.tl/t-Zz9oQ2c4mE','title' => 'Les clips');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Les kits d'animations
|
|||
|
|
// NIV 2
|
|||
|
|
if ($unblock==1 && $cat=='kitAnim'){
|
|||
|
|
$tFilesBao[] = array('file' => 'Kit_d_animation_Presentation_Deciday_v2.pdf','title' => 'Kit d’animation présentation Deciday !');
|
|||
|
|
$tFilesBao[] = array('file' => 'Kit_d_animation_Fiches_pratiques_Deciday.pdf','title' => 'Kit d’animation fiches pratiques Deciday !');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return $tFilesBao;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Affichage du créneau en créneau horaire compréhensible
|
|||
|
|
function getCreneau($creneau){
|
|||
|
|
|
|||
|
|
//$tCreneaux = array('am1'=>'de 8h00 à 9h30','am2'=>'de 10h00 à 11h30','pm1'=>'de 14h00 à 15h30','pm2'=>'de 16h00 à 17h30');
|
|||
|
|
$tCreneaux = array('am1'=>'Le matin','am2'=>'Le matin','pm1'=>'L\'après-midi','pm2'=>'L\'après-midi');
|
|||
|
|
|
|||
|
|
return $tCreneaux[$creneau];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Affichage du créneau en créneau horaire compréhensible
|
|||
|
|
function getCreneauPlus($creneau){
|
|||
|
|
|
|||
|
|
//$tCreneaux = array('am1'=>'de 8h00 à 9h30','am2'=>'de 10h00 à 11h30','pm1'=>'de 14h00 à 15h30','pm2'=>'de 16h00 à 17h30');
|
|||
|
|
$tCreneaux = array('am1'=>'Matin 1','am2'=>'Matin 2','pm1'=>'Après-midi 1','pm2'=>'Après-midi 2');
|
|||
|
|
|
|||
|
|
return $tCreneaux[$creneau];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Affichage du créneau en créneau horaire compréhensible pour les sollicitations
|
|||
|
|
function getCreneauSol($creneauSol){
|
|||
|
|
|
|||
|
|
//$tCreneaux = array('am1'=>'de 8h00 à 9h30','am2'=>'de 10h00 à 11h30','pm1'=>'de 14h00 à 15h30','pm2'=>'de 16h00 à 17h30');
|
|||
|
|
$tCreneaux = array('am'=>'Le matin','pm'=>'L\'après-midi');
|
|||
|
|
|
|||
|
|
return $tCreneaux[$creneauSol];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//recuperer une date de mysql
|
|||
|
|
function MysqlToDateFr($date){
|
|||
|
|
return date("d/m/Y", strtotime($date));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//insérer une date dans mysql
|
|||
|
|
function DateFrToMysql($date){
|
|||
|
|
list( $month, $day, $year ) = split( '[/-]', $date );
|
|||
|
|
// format de base : Jul 14, 2004
|
|||
|
|
return $date = trim($year)."-".trim($day)."-".trim($month);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function Password($nbr_caracteres,$base) {
|
|||
|
|
//srand(time());
|
|||
|
|
if($base==0) $choix = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
|
|||
|
|
elseif($base==1) $choix = "ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|||
|
|
elseif($base==2) $choix = "23456789";
|
|||
|
|
//$choix = "abcdefghijklmnopqrstuvwxyz123456789";
|
|||
|
|
$pass = "";
|
|||
|
|
while(strlen($pass)<$nbr_caracteres) {
|
|||
|
|
$pass .= substr($choix,(rand()%(strlen($choix))),1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return($pass);
|
|||
|
|
exit ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function verifCaptcha($response) {
|
|||
|
|
// Ma clé privée
|
|||
|
|
$secret = "6LfPdIIUAAAAAHlHrDhzErifvXgm0HfFB-aI2Vzr";
|
|||
|
|
|
|||
|
|
// On récupère l'IP de l'utilisateur
|
|||
|
|
$remoteip = $_SERVER['REMOTE_ADDR'];
|
|||
|
|
|
|||
|
|
$api_url = "https://www.google.com/recaptcha/api/siteverify?secret="
|
|||
|
|
. $secret
|
|||
|
|
. "&response=" . $response
|
|||
|
|
. "&remoteip=" . $remoteip ;
|
|||
|
|
|
|||
|
|
$decode = json_decode(file_get_contents($api_url), true);
|
|||
|
|
|
|||
|
|
if ($decode['success'] == true) {
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|