first reimport from platal
[platal.git] / include / profil / verif_emploi.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
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
22 include_once('xorg.misc.inc.php');
23
24 function 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
33 for($i = 0; $i < 2; $i++){
34 replace_ifset_i($entreprise,"entreprise",$i);
35 replace_ifset_i($poste,"poste",$i);
36 replace_ifset_i($secteur,"secteur",$i);
37 replace_ifset_i($ss_secteur,"ss_secteur",$i);
38 replace_ifset_i($fonction,"fonction",$i);
39
40 replace_ifset_i($adrpro1,"adrpro1",$i);
41 replace_ifset_i($adrpro2,"adrpro2",$i);
42 replace_ifset_i($adrpro3,"adrpro3",$i);
43 replace_ifset_i($postcodepro,"postcodepro",$i);
44 replace_ifset_i($citypro,"citypro",$i);
45 replace_ifset_i($countrypro,"countrypro",$i);
46 replace_ifset_i($regionpro,"regionpro",$i);
47 replace_ifset_i($telpro,"telpro",$i);
48 replace_ifset_i($faxpro,"faxpro",$i);
49 replace_ifset_i($mobilepro,"mobilepro",$i);
50 replace_ifset_i($pubpro,"pubpro",$i);
51 replace_ifset_i($adr_pubpro,"adr_pubpro",$i);
52 replace_ifset_i($tel_pubpro,"tel_pubpro",$i);
53 replace_ifset_i($emailpro,"emailpro",$i);
54 replace_ifset_i($email_pubpro,"email_pubpro",$i);
55 replace_ifset_i($webpro,"webpro",$i);
56 replace_ifset($cv,"cv");
57
58 // validité de l'entreprise
59 $j = $i+1;
60 if (strlen(strtok($entreprise[$i],"<>{}#~;!§*`[]|%^=")) < strlen($entreprise[$i]))
61 {
62 $str_error = $str_error."Le champ 'Entreprise $j' contient un caractère interdit.<BR />";
63 }
64
65 //validité du poste
66 if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i]))
67 {
68 $str_error = $str_error."Le champ 'Poste $j' contient un caractère interdit.<BR />";
69 }
70
71 //validité du CV
72 if (strlen(strtok($cv,"<>{}~§`")) < strlen($cv))
73 {
74 $str_error = $str_error."Le champ 'Curriculum vitae' contient un caractère interdit.<BR />";
75 }
76
77 // correction du champ web si vide
78 if ($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
89 if ($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
96 if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i]))
97 {
98 $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.<BR />";
99 }
100 if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i]))
101 {
102 $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.<BR />";
103 }
104 if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i]))
105 {
106 $str_error = $str_error."Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.<BR />";
107 }
108 if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i]))
109 {
110 $str_error = $str_error."Le champ 'Code Postal professionnel $j' contient un caractère interdit.<BR />";
111 }
112 if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i]))
113 {
114 $str_error = $str_error."Le champ 'Ville professionnelle $j' contient un caractère interdit.<BR />";
115 }
116 if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i]))
117 {
118 $str_error = $str_error."Le champ 'Téléphone professionnel $j' contient un caractère interdit.<BR />";
119 }
120 if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i]))
121 {
122 $str_error = $str_error."Le champ 'Fax professionnel $j' contient un caractère interdit.<BR />";
123 }
124 if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i]))
125 {
126 $str_error = $str_error."Le champ 'Mobile professionnel $j' contient un caractère interdit.<BR />";
127 }
128
129 }
130 ?>