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