37 |
*/ |
*/ |
38 |
class utils extends application { |
class utils extends application { |
39 |
|
|
40 |
|
/** |
41 |
|
* Cette méthode permet de renvoyer la valeur soumise par post. |
42 |
|
* |
43 |
|
* Si on ne trouve pas de paramètre correspondant alors on retourne chaîne vide |
44 |
|
* |
45 |
|
* @return null ou la valeur |
46 |
|
*/ |
47 |
|
function getSubmittedPostValue($param = null) { |
48 |
|
// |
49 |
|
if ($param == null) { |
50 |
|
return $this->submittedPostValue; |
51 |
|
} |
52 |
|
// |
53 |
|
if (isset($this->submittedPostValue[$param])) { |
54 |
|
// |
55 |
|
return $this->submittedPostValue[$param]; |
56 |
|
} |
57 |
|
// |
58 |
|
return null; |
59 |
|
} |
60 |
|
|
61 |
|
/** |
62 |
|
* Cette méthode permet de renvoyer la valeur soumise par get. |
63 |
|
* |
64 |
|
* Si on ne trouve pas de paramètre correspondant alors on retourne chaîne vide |
65 |
|
* |
66 |
|
* @return null ou la valeur |
67 |
|
*/ |
68 |
|
function getSubmittedGetValue($param = null) { |
69 |
|
// |
70 |
|
if ($param == null) { |
71 |
|
return $this->submittedGetValue; |
72 |
|
} |
73 |
|
// |
74 |
|
if (isset($this->submittedGetValue[$param])) { |
75 |
|
// |
76 |
|
return $this->submittedGetValue[$param]; |
77 |
|
} |
78 |
|
// |
79 |
|
return null; |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
/** |
84 |
|
* Cette methode permet d'affecter des parametres dans un attribut de |
85 |
|
* l'objet. |
86 |
|
* |
87 |
|
* @return void |
88 |
|
*/ |
89 |
|
function setMoreParams() { |
90 |
|
parent::setMoreParams(); |
91 |
|
$this->setSubmittedValue(); |
92 |
|
} |
93 |
|
|
94 |
|
function setSubmittedValue() { |
95 |
|
if(isset($_GET) and !empty($_GET)) { |
96 |
|
foreach ($_GET as $key => $value) { |
97 |
|
$this->submittedGetValue[$key]=$this->clean_break($value); |
98 |
|
} |
99 |
|
} |
100 |
|
if(isset($_POST) and !empty($_POST)) { |
101 |
|
foreach ($_POST as $key => $value) { |
102 |
|
$this->submittedPostValue[$key]=$this->clean_break($value); |
103 |
|
} |
104 |
|
} |
105 |
|
} |
106 |
|
|
107 |
// {{{ |
// {{{ |
108 |
|
|
109 |
/** |
/** |
144 |
|
|
145 |
// Récupération des infos utilisateur |
// Récupération des infos utilisateur |
146 |
$sqlUser = "SELECT om_utilisateur, nom, email, login, om_collectivite, om_profil ". |
$sqlUser = "SELECT om_utilisateur, nom, email, login, om_collectivite, om_profil ". |
147 |
"FROM ".DB_PREFIXE."om_utilisateur WHERE login = '".$_SESSION['login']."'"; |
"FROM ".DB_PREFIXE."om_utilisateur WHERE login = '".$this->clean_break($_SESSION['login'])."'"; |
148 |
$resUser=$this->db->query($sqlUser); |
$resUser=$this->db->query($sqlUser); |
149 |
$this->addToLog("getUserInfos(): db->query(\"".$sqlUser."\");", VERBOSE_MODE); |
$this->addToLog("getUserInfos(): db->query(\"".$sqlUser."\");", VERBOSE_MODE); |
150 |
if ( database::isError($resUser)){ |
if ( database::isError($resUser)){ |
606 |
//On ajoute la parcelle, si un arrondissement a été trouvé |
//On ajoute la parcelle, si un arrondissement a été trouvé |
607 |
if ($arrondissement!=="") { |
if ($arrondissement!=="") { |
608 |
// |
// |
609 |
$wParcelle[] = $arrondissement.$value["quartier"]." ". |
$wParcelle[] = $arrondissement.$value["quartier"]. |
610 |
$value["section"].$value["parcelle"]; |
str_pad($value["section"], 2, " ", STR_PAD_LEFT). |
611 |
|
$value["parcelle"]; |
612 |
} |
} |
613 |
} |
} |
614 |
} |
} |
1005 |
if (!empty($groupe)) { |
if (!empty($groupe)) { |
1006 |
// Choisit l'opérateur logique |
// Choisit l'opérateur logique |
1007 |
$op_logique = $key > 0 ? 'OR' : 'AND ('; |
$op_logique = $key > 0 ? 'OR' : 'AND ('; |
1008 |
// Ajoute la condition |
// Ajoute la condition |
1009 |
$whereContraintes .= " ".$op_logique." lower(contrainte.groupe) = lower('" |
$whereContraintes .= " ".$op_logique." lower(trim(both E'\n\r\t' from contrainte.groupe)) = lower('" |
1010 |
.pg_escape_string($groupe)."')"; |
.pg_escape_string($groupe)."')"; |
1011 |
} |
} |
1012 |
} |
} |
1025 |
// Choisit l'opérateur logique |
// Choisit l'opérateur logique |
1026 |
$op_logique = $key > 0 ? 'OR' : 'AND ('; |
$op_logique = $key > 0 ? 'OR' : 'AND ('; |
1027 |
// Ajoute la condition |
// Ajoute la condition |
1028 |
$whereContraintes .= " ".$op_logique." lower(contrainte.sousgroupe) = lower('" |
$whereContraintes .= " ".$op_logique." lower(trim(both E'\n\r\t' from contrainte.sousgroupe)) = lower('" |
1029 |
.pg_escape_string($sousgroupe)."')"; |
.pg_escape_string($sousgroupe)."')"; |
1030 |
} |
} |
1031 |
} |
} |
1039 |
// Si l'option service_consulte n'est pas vide |
// Si l'option service_consulte n'est pas vide |
1040 |
if ($service_consulte != "") { |
if ($service_consulte != "") { |
1041 |
// Ajoute la condition |
// Ajoute la condition |
1042 |
$whereContraintes .= " AND service_consulte = lower('".$service_consulte."')"; |
$whereContraintes .= " AND service_consulte = cast(lower('".$service_consulte."') as boolean) "; |
1043 |
} |
} |
1044 |
|
|
1045 |
// Condition retournée |
// Condition retournée |
1055 |
* @return date Date calculée |
* @return date Date calculée |
1056 |
*/ |
*/ |
1057 |
function mois_date($date, $delay, $operator = "+") { |
function mois_date($date, $delay, $operator = "+") { |
1058 |
|
|
1059 |
|
// Si aucune date n'a été fournie ou si ce n'est pas une date correctement formatée |
1060 |
|
if ( is_null($date) || $date == "" || |
1061 |
|
preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $date) == 0 ){ |
1062 |
|
return null; |
1063 |
|
} |
1064 |
|
|
1065 |
// Découpage de la date |
// Découpage de la date |
1066 |
$temp = explode("-", $date); |
$temp = explode("-", $date); |
1163 |
// |
// |
1164 |
return false; |
return false; |
1165 |
} |
} |
1166 |
|
|
1167 |
|
function clean_break($input) { |
1168 |
|
//remove whitespace... |
1169 |
|
$input = trim($input); |
1170 |
|
//disable magic quotes... |
1171 |
|
if(get_magic_quotes_gpc()) { |
1172 |
|
stripslashes($input); |
1173 |
|
} |
1174 |
|
//prevent sql injection... |
1175 |
|
if(is_numeric($input)) { |
1176 |
|
$input = intval($input); |
1177 |
|
} else { |
1178 |
|
if(isset($this->db)) { |
1179 |
|
$this->db->escapeSimple($input); |
1180 |
|
} |
1181 |
|
} |
1182 |
|
//prevent xss... |
1183 |
|
$input = htmlentities($input); |
1184 |
|
return $input; |
1185 |
|
} |
1186 |
} |
} |
1187 |
|
|
1188 |
?> |
?> |