menuvue = new Menuvueutilisateur(); $this->menuvue->getMenuVue('Prestations'); $this->beneficiaire = new Beneficiaire(); $this->police = new Police(); $this->garantieadherent = new Garantieadherent(); $this->pbeneficiaire = new Pbeneficiaire(); $this->liensubstitut = (new Lienparente())->getListeSubstitut(); $this->naturepiece = (new Naturepiece())->getListe(); $this->sexe = (new Sexe())->getListe(); $_SESSION['modeDevis'] = "0"; } public function index() { $id = $this->requete->getParametre("id"); $idBeneficiaire = $id; $this->beneficiaire->getModeBiometrie(); // $this->beneficiaire->getContexteBeneficiaireId($id); $idPolice = $this->beneficiaire->getIdPoliceBeneficiaire($idBeneficiaire); // $idPolice = $_SESSION['idPolice_C']; $this->police->getContextePoliceId($idPolice); $beneficiaire = $this->pbeneficiaire->getContexteBeneficiaireIdPrest($idBeneficiaire); $idAdherent = $_SESSION['idAdherent_C']; $garantieadherents = $this->garantieadherent->getGarantieBeneficiaire($idBeneficiaire); $police = $this->police->getPoliceId($idPolice); $nomGarant = $this->police->getNomGarant($police['codeGcAssureur']); $_SESSION['nomGcAssureur_C'] = $nomGarant; // A enlever après $_SESSION['lienServeur'] = $_SESSION['lienProduction_C']; $prestationPossible = $this->beneficiaire->prestationPossible($idBeneficiaire); $this->genererVue(array('beneficiaire' => $beneficiaire, 'garantieadherents' => $garantieadherents, 'liensubstitut' => $this->liensubstitut, 'naturepiece' => $this->naturepiece, 'sexe' => $this->sexe, 'prestationPossible' => $prestationPossible)); } public function ebeneenregistrerface() { $_SESSION['messageFace'] = ""; $compare_face = $_POST['compare_face']; $del_face = $_POST['del_face']; if(isset($_POST['image_face'])) { $_SESSION['okId_face'] = "-1"; $_SESSION['okId'] = "-1"; $path = "Temp/"; $extension = "jpeg"; $data = $_POST['image_face']; $data = str_replace('data:image/jpeg;base64,', '', $data); $data = base64_decode($data); $username = $_SESSION['numeroBeneficiaire_C']; $date = date('YmdHis'); $file_name = "img_v_".$date.uniqid().".".$extension; $chemin = $path.$file_name; file_put_contents($chemin, $data); $rand = rand(1,1000000); $nomImage = $username."_".$rand.'.'. $extension; $nomImageCrypte_0 = $username."_".$rand.'.bin'; $nomImageCrypte = $_SESSION['lienPhotoFace'] . $nomImageCrypte_0; if ($compare_face=="1") { if($del_face=="1") { $this->beneficiaire->init_traiterlaface('3'); } else { $this->beneficiaire->init_traiterlaface('2'); } require_once 'Framework/Faceebene.php'; $sourceImage = $chemin; $targetImage = $_SESSION['photoAssureCrypte']; try { $result = $client->compareFaces ( [ 'SimilarityThreshold' => 80, 'SourceImage' => [ 'Bytes' => file_get_contents($sourceImage) ], 'TargetImage' => [ //'Bytes' => file_get_contents($targetImage) 'Bytes' => base64_decode($targetImage) ], ] ); $faceMatches = count($result['FaceMatches']); if ($faceMatches==0) { $_SESSION['messageFace'] = "Les faces ne correspondent pas! / The faces do not match!"; $this->beneficiaire->resultat_traitement_face($username, '0', $_SESSION['messageFace']); $this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "0")); } elseif ($del_face=="1") { $motif = $_POST['motif']; $this->beneficiaire->resultat_traitement_face($username, '1', $motif); $idBeneficiaire = $_SESSION['idBeneficiaire_C']; $this->beneficiaire->supprimerPhoto($idBeneficiaire); $this->beneficiaire->unregisterface($username, $motif); $_SESSION['messageFace'] = "Face supprimée pour motif : $motif / Face removed for reason : $motif"; $this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'photo_succes' => "1")); $_SESSION['lienPhoto_C']=""; } else { $this->beneficiaire->resultat_traitement_face($username, '1', ''); $_SESSION['okId_face'] = "1"; $_SESSION['messageFace'] = "Face confirmée! / Face confirmed!"; $this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "1")); } } catch (Exception $e) { // echo 'Message: ' .$e->getMessage(); // exit(); $msgErreur = $e->getMessage(); $_SESSION['messageFace'] = "Un problème lors du traitement! / A problem during treatment!"; $this->beneficiaire->resultat_traitement_face($username, '9', $msgErreur); $this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "0")); } } else { $this->beneficiaire->init_traiterlaface('1'); $cheminNew = $_SESSION['lienPhotoFace'] . $nomImage; $_SESSION['okId_face'] = "1"; // réduction de la taille de l'immage $infosImg = getimagesize($chemin); $src = $chemin; $imgtype = image_type_to_mime_type($infosImg[2]); switch ($imgtype) { case 'image/jpeg': $source_image = imagecreatefromjpeg($src); break; case 'image/jpg': $source_image = imagecreatefromjpeg($src); break; case 'image/png': $source_image = imagecreatefrompng($src); break; } $width = imagesx($source_image); $desired_width = $width; if ($desired_width > $_SESSION['largeurPhoto']) { $desired_width = $_SESSION['largeurPhoto']; } $height = imagesy($source_image); $desired_height = floor($height * ($desired_width / $width)); $virtual_image = imagecreatetruecolor($desired_width, $desired_height); imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); if(imagejpeg($virtual_image, $cheminNew, -1)) { encryptImage($cheminNew, $nomImageCrypte); unlink($cheminNew); $this->beneficiaire->registerface($username); $idBeneficiaire = $_SESSION['idBeneficiaire_C']; // $this->beneficiaire->changerPhoto($idBeneficiaire, $nomImage); $this->beneficiaire->changerPhoto($idBeneficiaire, $nomImageCrypte_0); $_SESSION['messageFace'] = "Enrôlement effectué avec succès! / Enrollment completed successfully!!"; $this->genererVueAjax(array('messageFace' => $_SESSION['messageFace'], 'msgErreur' => $_SESSION['messageFace'], 'photo_succes' => "1")); } $this->beneficiaire->resultat_traitement_face($username, '1', ''); } unlink($chemin); } } }