Working HTML part of the job tab
[platal.git] / modules / profile / verif_emploi.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2007 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::v($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 $page->trig("Le champ 'Entreprise $j' contient un caractère interdit.");
63 }
64
65 //validité du poste
66 if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i]))
67 {
68 $page->trig("Le champ 'Poste $j' contient un caractère interdit.");
69 }
70
71 // correction du champ web si vide
72 if ($webpro[$i]=="http://" or $webpro[$i] == '') {
73 $webpro[$i]='';
74 } elseif (!preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $webpro[$i])) {
75 // validité de l'url donnée dans web
76 $page->trig("URL incorrecte dans le champ 'Page web', une url doit commencer par
77 http:// ou https:// ou ftp:// et ne pas contenir de caractères interdits");
78 } else {
79 $webpro[$i] = str_replace('&', '&amp;', $webpro[$i]);
80 }
81
82 // validité de l'e-mail
83 if ($emailpro[$i]) {
84 $emailpro[$i] = strtolower(trim($emailpro[$i]));
85 if (!isvalid_email($emailpro[$i])) {
86 $page->trig("Adresse e-mail incorrecte dans le champ 'E-mail'");
87 }
88 }
89
90 if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i]))
91 {
92 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.");
93 }
94 if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i]))
95 {
96 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.");
97 }
98 if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i]))
99 {
100 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.");
101 }
102 if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i]))
103 {
104 $page->trig("Le champ 'Code Postal professionnel $j' contient un caractère interdit.");
105 }
106 if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i]))
107 {
108 $page->trig("Le champ 'Ville professionnelle $j' contient un caractère interdit.");
109 }
110 if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i]))
111 {
112 $page->trig("Le champ 'Téléphone professionnel $j' contient un caractère interdit.");
113 }
114 if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i]))
115 {
116 $page->trig("Le champ 'Fax professionnel $j' contient un caractère interdit.");
117 }
118 if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i]))
119 {
120 $page->trig("Le champ 'Mobile professionnel $j' contient un caractère interdit.");
121 }
122
123 }
124 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
125 ?>