9057adfef93efdec3626f7fb6decb557a50ee4c4
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 include_once('xorg.misc.inc.php');
24 function set_flag_i(&$var,$var_name,$i){
25 $tab = Env
::v($var_name, array());
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);
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");
58 // validité de l'entreprise
60 if (strlen(strtok($entreprise[$i],"<>{}#~;!§*`[]|%^=")) < strlen($entreprise[$i]))
62 $page->trig("Le champ 'Entreprise $j' contient un caractère interdit.");
66 if (strlen(strtok($poste[$i],"<>{}~?!§*`|%$^=+")) < strlen($poste[$i]))
68 $page->trig("Le champ 'Poste $j' contient un caractère interdit.");
72 if (strlen(strtok($cv,"<>{}~§`")) < strlen($cv))
74 $page->trig("Le champ 'Curriculum vitae' contient un caractère interdit.");
77 // correction du champ web si vide
78 if ($webpro[$i]=="http://" or $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");
85 $webpro[$i] = str_replace('&', '&', $webpro[$i]);
88 // validité de l'e-mail
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'");
96 if (strlen(strtok($adrpro1[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro1[$i]))
98 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 1' contient un caractère interdit.");
100 if (strlen(strtok($adrpro2[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro2[$i]))
102 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 2' contient un caractère interdit.");
104 if (strlen(strtok($adrpro3[$i],"<>{}@~?!§*`|%$^=+")) < strlen($adrpro3[$i]))
106 $page->trig("Le champ 'Adresse professionnelle $j - Ligne 3' contient un caractère interdit.");
108 if (strlen(strtok($postcodepro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($postcodepro[$i]))
110 $page->trig("Le champ 'Code Postal professionnel $j' contient un caractère interdit.");
112 if (strlen(strtok($citypro[$i],"<>{}@~?!§*`|%$^=+")) < strlen($citypro[$i]))
114 $page->trig("Le champ 'Ville professionnelle $j' contient un caractère interdit.");
116 if (strlen(strtok($telpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($telpro[$i]))
118 $page->trig("Le champ 'Téléphone professionnel $j' contient un caractère interdit.");
120 if (strlen(strtok($faxpro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($faxpro[$i]))
122 $page->trig("Le champ 'Fax professionnel $j' contient un caractère interdit.");
124 if (strlen(strtok($mobilepro[$i],"<>{}@&#~\/:;?,!§*_`[]|%$^=")) < strlen($mobilepro[$i]))
126 $page->trig("Le champ 'Mobile professionnel $j' contient un caractère interdit.");