This repository has been archived by the owner on Aug 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.php
75 lines (65 loc) · 2.62 KB
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
function mailToResp($surname, $name, $job){
require_once("templates/mailToResp.php");
mail($to, $subject, $message, $headers);
}
//vire les accents et remplace caractere non alphanumeric par '-'
function checkChars($toCheck){
$toCheck = strtr($toCheck,
'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ',
'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
$toCheck = preg_replace('/([^.a-z0-9]+)/i', '-', $toCheck);
return $toCheck;
}
function mailToApprenti($to, $job){
require_once("templates/mailToApp.php");
mail($to, $subject, $message, $headers);
}
function uploadFile(&$candidateData, $pathAnnexes, $file, $name){
$extension = strtolower(strrchr($file['name'], '.'));
$validExt = ['.pdf', '.jpeg', '.png', '.jpg'];
$filename = $name . $extension;
//-> dataValidator
if(!in_array($extension, $validExt)){
$erreur = "uploadError";
}
if(!isset($erreur)){
$filename = checkChars($filename);
move_uploaded_file($file['tmp_name'], $pathAnnexes . $filename);
$candidateData->fichiers[$name] = $filename;
}
}
//Crée le dossier principal est ses 2 sous-dossiers
function createCandidateFolders($candidateData){
$paths = $candidateData->getPaths();
if (!mkdir($paths["pathInfos"], 0777, true)){
die('Echec lors de la création du dossier informations');
}
if (!mkdir($paths["pathAnnexes"], 0777, true)){
die('Echec lors de la création du dossier annexes');
}
}
function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){
uploadFile($candidateData, $pathAnnexes, $postedFiles['photo'], "photo-passeport");
uploadFile($candidateData, $pathAnnexes, $postedFiles['idCard'], "carte-identite");
uploadFile($candidateData, $pathAnnexes, $postedFiles['cv'], "curriculum-vitae");
uploadFile($candidateData, $pathAnnexes, $postedFiles['lettre'], "lettre-motivation");
for($i=1; $i<=9; $i++){
if(array_key_exists('certifs'.$i, $postedFiles)){
if(!($postedFiles['certifs'.$i]['name'] == "")) {
uploadFile($candidateData, $pathAnnexes, $postedFiles['certifs'.$i], "annexe".$i);
}
}
}
if($candidateData->formation=="polyMecanicien"){
uploadFile($candidateData, $pathAnnexes, $postedFiles['gimch'], "certificat-gimch");
}
if($candidateData->formation=="informaticien"){
uploadFile($candidateData, $pathAnnexes, $postedFiles['griTestInput'], "certificat-gri");
}
return $candidateData;
}
function debuglog($message){
//echo $message;
}
?>