remove smarty {version} function, we have {#globals.version#} for it !!!
[platal.git] / include / profil / verif_emploi.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
50a40a33 3 * Copyright (C) 2003-2006 Polytechnique.org *
0337d704 4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22include_once('xorg.misc.inc.php');
23
24function set_flag_i(&$var,$var_name,$i){
25 $tab = Env::getMixed($var_name, Array());
26 if(isset($tab[$i])){
27 $var[$i] = 1;
28 }
29 else
30 $var[$i] = '0';
31}
32
33for($i = 0; $i < 2; $i++){
34replace_ifset_i($entreprise,"entreprise",$i);
35replace_ifset_i($poste,"poste",$i);
36replace_ifset_i($secteur,"secteur",$i);
37replace_ifset_i($ss_secteur,"ss_secteur",$i);
38replace_ifset_i($fonction,"fonction",$i);
39
40replace_ifset_i($adrpro1,"adrpro1",$i);
41replace_ifset_i($adrpro2,"adrpro2",$i);
42replace_ifset_i($adrpro3,"adrpro3",$i);
43replace_ifset_i($postcodepro,"postcodepro",$i);
44replace_ifset_i($citypro,"citypro",$i);
45replace_ifset_i($countrypro,"countrypro",$i);
46replace_ifset_i($regionpro,"regionpro",$i);
47replace_ifset_i($telpro,"telpro",$i);
48replace_ifset_i($faxpro,"faxpro",$i);
49replace_ifset_i($mobilepro,"mobilepro",$i);
50replace_ifset_i($pubpro,"pubpro",$i);
51replace_ifset_i($adr_pubpro,"adr_pubpro",$i);
52replace_ifset_i($tel_pubpro,"tel_pubpro",$i);
53replace_ifset_i($emailpro,"emailpro",$i);
54replace_ifset_i($email_pubpro,"email_pubpro",$i);
55replace_ifset_i($webpro,"webpro",$i);
56replace_ifset($cv,"cv");
57
58// validité de l'entreprise
59$j = $i+1;
60if (strlen(strtok($entreprise[$i],"<>{}#~;!§*`[]|%^=")) < strlen($entreprise[$i]))
61{
79a5acea 62 $page->trig("Le champ 'Entreprise $j' contient un caractère interdit.");
0337d704 63}
64
65//validité du poste
66if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i]))
67{
79a5acea 68 $page->trig("Le champ 'Poste $j' contient un caractère interdit.");
0337d704 69}
70
71//validité du CV
72if (strlen(strtok($cv,"<>{}~§`")) < strlen($cv))
73{
79a5acea 74 $page->trig("Le champ 'Curriculum vitae' contient un caractère interdit.");
0337d704 75}
76
77// correction du champ web si vide
78if ($webpro[$i]=="http://" or $webpro[$i] == '') {
79 $webpro[$i]='';
80} elseif (!preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $webpro[$i])) {
81 // validité de l'url donnée dans web
82 $page->trig("URL incorrecte dans le champ 'Page web', une url doit commencer par
83 http:// ou https:// ou ftp:// et ne pas contenir de caractères interdits");
84} else {
85 $webpro[$i] = str_replace('&', '&amp;', $webpro[$i]);
86}
87
88// validité de l'e-mail
89if ($emailpro[$i]) {
90 $emailpro[$i] = strtolower(trim($emailpro[$i]));
91 if (!isvalid_email($emailpro[$i])) {
92 $page->trig("Adresse e-mail incorrecte dans le champ 'E-mail'");
93 }
94}
95
96if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i]))
97 {
79a5acea 98 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.");
0337d704 99 }
100 if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i]))
101 {
79a5acea 102 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.");
0337d704 103 }
104 if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i]))
105 {
79a5acea 106 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.");
0337d704 107 }
108 if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i]))
109 {
79a5acea 110 $page->trig("Le champ 'Code Postal professionnel $j' contient un caractère interdit.");
0337d704 111 }
112 if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i]))
113 {
79a5acea 114 $page->trig("Le champ 'Ville professionnelle $j' contient un caractère interdit.");
0337d704 115 }
116 if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i]))
117 {
79a5acea 118 $page->trig("Le champ 'Téléphone professionnel $j' contient un caractère interdit.");
0337d704 119 }
120 if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i]))
121 {
79a5acea 122 $page->trig("Le champ 'Fax professionnel $j' contient un caractère interdit.");
0337d704 123 }
124 if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i]))
125 {
79a5acea 126 $page->trig("Le champ 'Mobile professionnel $j' contient un caractère interdit.");
0337d704 127 }
128
129}
130?>