From afbe4c74003b6e29148972212eeba039f58e5cfc Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Wed, 21 Sep 2022 14:47:18 +0200 Subject: [PATCH] debug --- gestion/.htaccess | 7 ++++ gestion/.htpasswd | 1 + gestion/entete.php | 73 +++++++++++++++++++++++++++++++++++ gestion/envoiMailing.php | 78 ++++++++++++++++++++++++++++++++++++++ gestion/footer.html | 56 +++++++++++++++++++++++++++ gestion/index.php | 30 +++++++++++++++ gestion/modifVotation.php | 53 ++++++++++++++++++++++++++ gestion/saisieVotation.php | 43 +++++++++++++++++++++ gestion/saisieVotes.php | 67 ++++++++++++++++++++++++++++++++ include/config.inc.php | 6 ++- session_init.php | 7 +--- vote.form.php | 2 +- vote.php | 1 - vote.resultat.php | 2 +- 14 files changed, 416 insertions(+), 10 deletions(-) create mode 100644 gestion/.htaccess create mode 100644 gestion/.htpasswd create mode 100644 gestion/entete.php create mode 100644 gestion/envoiMailing.php create mode 100644 gestion/footer.html create mode 100644 gestion/index.php create mode 100644 gestion/modifVotation.php create mode 100644 gestion/saisieVotation.php create mode 100644 gestion/saisieVotes.php diff --git a/gestion/.htaccess b/gestion/.htaccess new file mode 100644 index 0000000..8b5a076 --- /dev/null +++ b/gestion/.htaccess @@ -0,0 +1,7 @@ +Options -Indexes +AuthName "back_office" +AuthBasicProvider file +AuthType Basic +AuthUserFile "/var/www/html/vote/gestionsite/.htpasswd" +require valid-user + diff --git a/gestion/.htpasswd b/gestion/.htpasswd new file mode 100644 index 0000000..e4ed400 --- /dev/null +++ b/gestion/.htpasswd @@ -0,0 +1 @@ +daniel:$apr1$67uwe85A$ygTTmLOR/DxIJgPMqGVox. diff --git a/gestion/entete.php b/gestion/entete.php new file mode 100644 index 0000000..fee51e3 --- /dev/null +++ b/gestion/entete.php @@ -0,0 +1,73 @@ + + + + + + + + + + + + Lyon Association Libre Informatique Solidaire + + + + + + + + + + + + + + + + + + + + + + diff --git a/gestion/envoiMailing.php b/gestion/envoiMailing.php new file mode 100644 index 0000000..8deeecf --- /dev/null +++ b/gestion/envoiMailing.php @@ -0,0 +1,78 @@ +
+ + +
+
+
+
+

VOTE

'); + +$db = new db(); +$dolibarr = new dbDolibarr(); + +if (empty($idVotation)) +{ + choixVotation('./envoiMailing.php') ; +}else +{ + //chargement des données de la votation + $db->query("SELECT *, UNIX_TIMESTAMP( DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf, UNIX_TIMESTAMP(dateFin) as df, UNIX_TIMESTAMP(dateDebut) as dd FROM liste_votations WHERE id=" . $idVotation); + $votation = $db->result->fetch_array(); + + if(empty($_GET['status'])) + { + print('
+ +

Êtes-vous sûr de vouloir envoyer le Mailing pour la votation : ' . $votation['libelle'] .'

+

+
+ + + +
+
+ '); + }elseif($_GET['status'] == 'Oui' OR $_GET['status'] == 'Test') + { + // message + + //chargement de la liste des adhérents + $dolibarr->query("SELECT login, firstname, lastname, email FROM llx_adherent"); + $adherents = $dolibarr->result->fetch_all(MYSQLI_ASSOC); + $dolibarr->close(); + + $sujet = "[LALIS] Convocation à un vote"; + $textDebut = "Bonjour,\nL'association Lalis vous invite à un vote du " . formatteDate('fr', $votation['dd'], 'Europe/Paris') . " 0h00 au " . formatteDate('fr', $votation['df'], 'Europe/Paris') . " minuit.\nMotif du vote : " . $votation['libelle'] . "\n\nPour voter, cliquez sur le lien suivant :\nhttps://lalis69.ddns.net:10443/vote.form.php?v=" . $idVotation . "&id="; + $textFin = "\n\nNous vous rappelons que pour pouvoir voter, vous devez être à jour de cotisation à la date du vote.\nLes résultats seront visibles dès le " . formatteDate('fr', $votation['tf'], 'Europe/Paris') . " par le lien suivant : https://lalis69.ddns.net:10443/vote.resultat.php?id=" . $idVotation . "\nAttention: ce lien contient votre identifiant de vote, ne le transmettez, sinon la personne pourra voter à votre place.\n\nPour Lalis, Le Président, David Larochette."; + foreach($adherents as $adherent) + { + $text = $textDebut . base64_encode($adherent['login']) . $textFin; + print '
' . $adherent['email'] . ' ' . $adherent['firstname'] . ' ' . $adherent['lastname'] . EOLH . nl2br($text) . '
'; + if ( $_GET['status'] == 'Oui') + { + //print $text; + envoiMail($adherent['email'], $sujet, $text, $html=false, $cc='', $bcc=''); + //envoiMail('dtux@free.fr', $sujet, $text, $html=false, $cc='', $bcc=''); + } + } + }else + { + print("

Annulation de l'envoi du Mailing pour la votation : " . $votation['libelle'] . "

+

"); + } + + print('
+
+
+
'); +} +require_once("footer.html"); +?> diff --git a/gestion/footer.html b/gestion/footer.html new file mode 100644 index 0000000..cbedafb --- /dev/null +++ b/gestion/footer.html @@ -0,0 +1,56 @@ + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/gestion/index.php b/gestion/index.php new file mode 100644 index 0000000..9dfb4c4 --- /dev/null +++ b/gestion/index.php @@ -0,0 +1,30 @@ +
+ + +
+ +
'); + +require_once './footer.html'; +?> diff --git a/gestion/modifVotation.php b/gestion/modifVotation.php new file mode 100644 index 0000000..f7decf2 --- /dev/null +++ b/gestion/modifVotation.php @@ -0,0 +1,53 @@ +
+ + +
+
+
+
+

Choisissez une votations à modifier

' . EOL); + +$db = new db(); +if (empty($action)) +{ + $action="modif"; + choixVotation('./modifVotation.php') ; + +}else +{ + if ($action == "cloture") + { + if (empty($idVotation)) + { + // choix de la votation à cloturer + choixVotation('./modifVotation.php', 0); + }else + { + //TODO alert "Do you want to delete ..." + $query = "UPDATE liste_votations SET status=0 WHERE id='" . $db->protect($idVotation) . "'"; // clotûre + $db->query($query); + } + }elseif ($action == "modif") + { + //TODO + votationForm($path, $titre, $libelle, $dateDebut, $dateFin, $status); + } + +} + +print('
+
+
+
'); +require_once './footer.html'; +?> diff --git a/gestion/saisieVotation.php b/gestion/saisieVotation.php new file mode 100644 index 0000000..4c3bab8 --- /dev/null +++ b/gestion/saisieVotation.php @@ -0,0 +1,43 @@ +
+ + +
+
'); +print('
+
+

Nouvelle votation

+

'); + +$titre = getpost("titre"); +$libelle = getpost("libelle"); +$dateDebut = getpost("dateDebut"); +$dateFin = getpost("dateFin"); + +if ($titre !== null and $libelle!== null and $dateDebut!== null and $dateFin !== null) +{ + $db = new db(); + $query = "INSERT INTO liste_votations VALUES(0, '" . $titre . "', '" . $libelle . "', '0', '" . $dateDebut . "', '" . $dateFin . "')"; // clotûre + $db->query($query); + $db->close(); + // TODO retour à l'index +}else +{ + votationForm($path, $titre, $libelle, $dateDebut, $dateFin); +} + +print('

+
+ +
+
'); +require_once("footer.html"); + +?> diff --git a/gestion/saisieVotes.php b/gestion/saisieVotes.php new file mode 100644 index 0000000..e4be3c0 --- /dev/null +++ b/gestion/saisieVotes.php @@ -0,0 +1,67 @@ +query($query); + $votationLine = $db->result->fetch_assoc(); + return $votationLine["libelle"]; +} + +$idVotation = getpost("id"); +if (!empty($idVotation)) +{ + $_SESSION["idVotation"] = $idVotation; + $votationName = queryVotationName($db, $idVotation); +}elseif (array_key_exists("idVotation", $_SESSION)) +{ + if (!empty($_SESSION["idVotation"])) + { + $idVotation = $_SESSION["idVotation"]; + $votationName = queryVotationName($db, $idVotation); + } +} + +print('

+ +
+
') . EOL; +print('
+
+

Nouveau vote pour la votation'); + +if (empty($idVotation)) +{ + choixVotation($path, 0, false); +}else +{ + print(": " . $votationName . '

' . EOL); + $method = getpost("method"); + $libelle = getpost("libelle"); + if (empty($method) or empty($libelle)) + { + votesForm($path); + }else + { + $query = "INSERT INTO liste_votes ('libelle', 'method', 'id_votation') VALUES ('" . $libelle . "', '" . $method . "', '" . $idVotation . "')"; + print($query); + //$db->query($query); + } +} +$db->close(); + +print('
+
+
+
'); +require_once("footer.html"); + +?> diff --git a/include/config.inc.php b/include/config.inc.php index bdb69bc..a0769cb 100644 --- a/include/config.inc.php +++ b/include/config.inc.php @@ -19,11 +19,13 @@ $site = "Lalis"; $dossier = "/sftp"; $basedir = dirname( $_SERVER['DOCUMENT_ROOT'] ) . $dossier; -$base_url = "https://lalis69.ddns.net:10443"; -$url_admin = $base_url . "/gestionsite"; +$base_url = "https://lalis69.ddns.net:10443/vote"; +$url_admin = $base_url . "/gestion"; $accueil = $base_url . "/index.html"; if (empty( $_SERVER["PHP_AUTH_USER"])) { $_SERVER["PHP_AUTH_USER"] = 'script'; } +$webSite = "https://lalis.fr"; + ?> diff --git a/session_init.php b/session_init.php index 8ab98fd..87a55f5 100644 --- a/session_init.php +++ b/session_init.php @@ -2,7 +2,6 @@ ini_set('session.use_strict_mode','true'); ini_set('session.cookie_secure','true'); ini_set('session.hash_function','md5'); -session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ini_set('serialize_precision', 8); @@ -13,8 +12,6 @@ $base_path = "/var/www/html/vote"; set_include_path(get_include_path() . ':' .$base_path . '/include'); $cookiesparams = session_get_cookie_params(); -//session_set_cookie_params ( 0, $cookiesparams["path"], $cookiesparams["domain"], true, true ); -//session_start(); -$site_path = "https://lalis69.ddns.net:10443/vote"; -$webSite = "https://lalis.fr"; +session_set_cookie_params ( 0, $cookiesparams["path"], $cookiesparams["domain"], true, true ); +session_start(); ?> diff --git a/vote.form.php b/vote.form.php index 00f606f..45b6c5a 100644 --- a/vote.form.php +++ b/vote.form.php @@ -1,5 +1,5 @@