Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Adullact
Theme-WordPress-Adullact-org
Commits
8eca1da8
Commit
8eca1da8
authored
Jul 04, 2019
by
N. Peraldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit: formatted code
parent
3d952fae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
48 deletions
+16
-48
functions.php
functions.php
+4
-4
traitementAdhesion.php
traitementAdhesion.php
+12
-44
No files found.
functions.php
View file @
8eca1da8
...
...
@@ -21,8 +21,8 @@ function childrens_of_member_category($category)
foreach
(
$childrens
as
$c
)
{
$temp_category
=
get_category
(
$c
);
//objet contenant les infos de la catégorie enfant
$my_link
=
"<a href=
\"
?cat="
;
$my_link
.
=
$c
;
$my_link
=
"<a href=
\"
?cat="
;
$my_link
.
=
$c
;
$my_link
.
=
"
\"
class=
\"
adullact-sort-button"
;
if
(
$temp_category
->
name
==
$category
)
{
...
...
@@ -30,10 +30,10 @@ function childrens_of_member_category($category)
$my_link
.
=
" adullact-selected"
;
}
$my_link
.
=
"
\"
>"
;
$my_link
.
=
"
\"
>"
;
$my_link
.
=
$temp_category
->
name
;
$my_link
.
=
"</a>"
;
$my_link
.
=
"</a>"
;
echo
$my_link
;
...
...
traitementAdhesion.php
View file @
8eca1da8
...
...
@@ -34,8 +34,6 @@ $numberRequired = "Vous devez entrer un nombre.";
$fieldRequired
=
"Vous devez compléter ce champ."
;
$debug_mode_traitement
=
false
;
$elementsOfPostToTrash
=
[
"ancienSelectType"
,
"ancienSelectSize"
,
"ancienSelectPeriod"
];
...
...
@@ -59,13 +57,11 @@ $replacements = array(
function
sendAdhesionMail
(
$tab
)
{
//fonction utile pour l'envoi de mail grâce au $_POST
//on étudie le $_POST et on transfère les lignes utiles à $tableauFinal
global
$adresseMailCible
,
$subject
,
$elementsOfPostToTrash
,
$replacements
;
$tableauFinal
=
array
();
foreach
(
$tab
as
$key
=>
$value
)
{
if
(
!
isWordIn
(
$key
,
$elementsOfPostToTrash
))
{
if
(
$value
!=
""
&&
$value
!=
"none"
)
{
...
...
@@ -79,7 +75,6 @@ function sendAdhesionMail($tab)
$tableauFinal
[
$key
]
=
$value
;
}
}
}
$message
=
"Nouvelle requête pour le formulaire d'adhésion : <br><table>"
;
...
...
@@ -93,25 +88,22 @@ function sendAdhesionMail($tab)
$logMessage
=
$logMessage
.
$key
.
" : "
.
$value
.
"
\n
"
;
}
$header
=
"Content-type: text/html; charset=utf-8
\r\n
"
;
if
(
mail
(
$adresseMailCible
,
$subject
,
$message
,
$header
))
{
writeInLog
(
"Nouvelle demande"
,
$logMessage
);
writeInLog
(
"Nouvelle demande"
,
$logMessage
);
}
else
{
writeInLog
(
"Erreur de l'envoi mail."
,
"Header :
\n
"
.
$header
.
"
\n
Infos :"
.
$logMessage
);
}
else
{
writeInLog
(
"Erreur de l'envoi mail."
,
"Header :
\n
"
.
$header
.
"
\n
Infos :"
.
$logMessage
);
}
}
function
writeInLog
(
$intitule
,
$text
){
function
writeInLog
(
$intitule
,
$text
)
{
global
$workingDirectory
,
$debug_mode_traitement
;
date_default_timezone_set
(
'Europe/Paris'
);
$date
=
date
(
"d-m-Y"
);
$hour
=
date
(
"H:i:s"
);
...
...
@@ -123,19 +115,17 @@ function writeInLog($intitule, $text){
$fichier
=
fopen
(
$filePath
,
"a"
);
if
(
$debug_mode_traitement
){
if
(
$debug_mode_traitement
)
{
var_dump
(
$fichier
);
}
if
(
fwrite
(
$fichier
,
$finalMessage
)){
if
(
$debug_mode_traitement
){
if
(
fwrite
(
$fichier
,
$finalMessage
))
{
if
(
$debug_mode_traitement
)
{
echo
"fichier écrit"
;
}
}
else
{
if
(
$debug_mode_traitement
){
}
else
{
if
(
$debug_mode_traitement
)
{
echo
"fichier pas écrit"
;
echo
"<br> chemin accesz : <br>"
.
$filePath
;
}
...
...
@@ -143,8 +133,6 @@ function writeInLog($intitule, $text){
}
fclose
(
$fichier
);
}
//-----------------------Toutes les fonctions de vérification de données------------------------
...
...
@@ -157,21 +145,17 @@ function verifFirstSelection($tab)
//première sélection présente
if
(
$tab
[
"firstSelection"
]
!=
"none"
&&
$tab
[
"firstSelection"
]
!=
""
)
{
//l'utilisateur a sélectionné quelque chose. mais quoi ?
return
true
;
}
else
{
//sélection égale à "none" ou ""
return
false
;
}
}
else
{
//première sélection absente du formulaire
return
false
;
}
}
function
verifSecondSelection
(
$tab
,
$errors
)
...
...
@@ -200,7 +184,6 @@ function verifEPCI($tab, $errors)
$nombreHab
=
$tab
[
"nombreHabitantsEPCI"
];
$nombreCom
=
$tab
[
"nombreCommunesMembresEPCI"
];
if
(
is_numeric
(
$nombreHab
))
{
if
(
is_numeric
(
$nombreCom
))
{
if
(
$nombreHab
>
0
)
{
...
...
@@ -228,8 +211,6 @@ function verifEPCI($tab, $errors)
}
else
{
$errors
[
"EPCI hab"
]
=
$numberRequired
;
}
return
$errors
;
}
...
...
@@ -254,8 +235,6 @@ function verifNom($tab)
}
}
return
$fieldRequired
;
}
function
verifAdresse
(
$tab
)
...
...
@@ -318,12 +297,8 @@ function verifVille($tab)
global
$maxCityCharacters
,
$tooLongCity
,
$errorInCityName
,
$fieldRequired
;
//vérifie si la ville est correcte
if
(
isset
(
$tab
[
"villeCollectivite"
]))
{
$ville
=
$tab
[
"villeCollectivite"
];
if
(
strlen
(
$ville
)
>
0
)
{
if
(
strlen
(
$ville
)
<
$maxCityCharacters
)
{
$ville
=
strtolower
(
$ville
);
...
...
@@ -335,7 +310,6 @@ function verifVille($tab)
}
return
""
;
}
else
{
return
$tooLongCity
;
}
...
...
@@ -489,7 +463,6 @@ function traitementInformations($tab, $errors)
global
$debug_mode_traitement
;
$errors
[
"nom"
]
=
verifNom
(
$tab
);
$errors
[
"adresse"
]
=
verifAdresse
(
$tab
);
...
...
@@ -502,7 +475,7 @@ function traitementInformations($tab, $errors)
$errors
[
"site"
]
=
verifUrl
(
$tab
);
if
(
$tab
[
"firstSelection"
]
!=
"Association"
)
{
if
(
$tab
[
"firstSelection"
]
!=
"Association"
)
{
if
(
$debug_mode_traitement
)
{
echo
"tab[firstselection] = "
.
$tab
[
"firstSelection"
]
.
"
\n
"
;
}
...
...
@@ -519,8 +492,8 @@ function traitementInformations($tab, $errors)
function
traitement
(
$tab
,
$errors
)
{
//traitement principal, liste des actions à effectuer dans un certain ordre
global
$debug_mode_traitement
;
if
(
$debug_mode_traitement
)
{
echo
"début du traitement "
;
}
...
...
@@ -542,19 +515,14 @@ function traitement($tab, $errors)
$errors
=
verifSecondSelection
(
$tab
,
$errors
);
}
}
else
{
$errors
[
"first selection"
]
=
"Veuillez préciser le type de collectivité."
;
}
if
(
$debug_mode_traitement
)
{
echo
"errors : <br>"
;
var_dump
(
$errors
);
}
return
$errors
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment