1
0

ajout fermeture de la database

This commit is contained in:
Daniel Tartavel 2022-09-19 12:04:33 +02:00
parent cf526f166c
commit cd91a95aea
5 changed files with 18 additions and 5 deletions

View File

@ -23,7 +23,7 @@ if (array_key_exists("idVotation", $GLOBALS) and empty($idVotation))
if (empty($idVotation)) if (empty($idVotation))
{ {
choixVotation($path); choixVotation($path, 1, false);
} }
$method = getpost("method"); $method = getpost("method");

View File

@ -46,8 +46,9 @@ function mb_ucfirst($str)
function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 1 = votations en cours 0 = votations cloturées function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 1 = votations en cours 0 = votations cloturées
{ {
global $db, $base_url, $action; global $base_url, $action;
$db = new db();
$query = "SELECT * FROM liste_votations"; $query = "SELECT * FROM liste_votations";
if ($methode != 2) if ($methode != 2)
{ {
@ -82,6 +83,7 @@ function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les v
<input type="submit" value="Envoyer"/> <input type="submit" value="Envoyer"/>
</div> </div>
</form>'; </form>';
$db->close;
} }
function votationForm($path, $titre="", $libelle="", $dateDebut="", $DateFin="", $status=0) function votationForm($path, $titre="", $libelle="", $dateDebut="", $DateFin="", $status=0)
@ -133,6 +135,7 @@ function votesForm($path, $libelle = "", $method = 0)
print('<input type="submit" formaction="index.php" value="' . _("Annuler") . '"/>') . EOL; print('<input type="submit" formaction="index.php" value="' . _("Annuler") . '"/>') . EOL;
print('<input type="submit" value="' . _("Envoyer") . '"/>') . EOL; print('<input type="submit" value="' . _("Envoyer") . '"/>') . EOL;
print('</form>') . EOL; print('</form>') . EOL;
$db->close();
} }
function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='') function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
@ -219,10 +222,11 @@ function listeAdherents()
function listeVotants($idVotation, $idVote, $listeAdherents) function listeVotants($idVotation, $idVote, $listeAdherents)
{ {
global $db;
$nv = 0; $nv = 0;
$text = ''; $text = '';
$db->open();
$query = "SELECT DISTINCT idVotant FROM votes WHERE idVotation=" . $idVotation . ' AND idVote=' . $idVote; $query = "SELECT DISTINCT idVotant FROM votes WHERE idVotation=" . $idVotation . ' AND idVote=' . $idVote;
$result = $db->query($query); $result = $db->query($query);
@ -233,6 +237,7 @@ function listeVotants($idVotation, $idVote, $listeAdherents)
} }
print('Nombre de votants : ' . $nv . EOLH . '<div id="listeVotants' . $idVote . '" style="display: none; line-height: 0.8;">' . $text . '</div>'); print('Nombre de votants : ' . $nv . EOLH . '<div id="listeVotants' . $idVote . '" style="display: none; line-height: 0.8;">' . $text . '</div>');
print('<button id="button' . $idVote . '" onclick="show(\'listeVotants\',\'' . $idVote . '\')">Voir la liste des votants</button>' . EOLH); print('<button id="button' . $idVote . '" onclick="show(\'listeVotants\',\'' . $idVote . '\')">Voir la liste des votants</button>' . EOLH);
$db->close();
} }
?> ?>

View File

@ -10,8 +10,10 @@ require_once 'fonctions.inc.php';
// $level => INFO, ALERT, ERROR // $level => INFO, ALERT, ERROR
function log_write($log, $level=INFO) function log_write($log, $level=INFO)
{ {
global $table_prefix, $webmaster, $db; global $table_prefix, $webmaster;
// actual connected user or user 'script' // actual connected user or user 'script'
$db = new db();
$user = (!empty( $_SERVER["PHP_AUTH_USER"])?$_SERVER["PHP_AUTH_USER"]:'Intruder?!'); $user = (!empty( $_SERVER["PHP_AUTH_USER"])?$_SERVER["PHP_AUTH_USER"]:'Intruder?!');
//mail message //mail message
@ -54,6 +56,7 @@ function log_write($log, $level=INFO)
{ {
mail( $webmaster, "Erreur Site Web", $log_mail ); mail( $webmaster, "Erreur Site Web", $log_mail );
} }
$db->close();
} }
// $w_db = true -> write log in database (default) // $w_db = true -> write log in database (default)

View File

@ -87,6 +87,7 @@ if ($dolibarr->result->num_rows == 0)
print " Bonjour " . $votant['firstname'] . " " . $votant['lastname'] . ',</h4>' . EOLH . EOLH . "Le vote ne sera ouvert qu'à partir du " . formattedate('fr', $votation['td'] , "Europe/Paris") . " et jusqu'au " . formattedate('fr', $votation['df'] , "Europe/Paris") . '.' . EOLH . "Si vous pensez que ceci est une erreur, veuillez prendre contact avec les responsables de l'association.</h4>"; print " Bonjour " . $votant['firstname'] . " " . $votant['lastname'] . ',</h4>' . EOLH . EOLH . "Le vote ne sera ouvert qu'à partir du " . formattedate('fr', $votation['td'] , "Europe/Paris") . " et jusqu'au " . formattedate('fr', $votation['df'] , "Europe/Paris") . '.' . EOLH . "Si vous pensez que ceci est une erreur, veuillez prendre contact avec les responsables de l'association.</h4>";
} }
} }
$db->close();
} }
print(' </div> print(' </div>
</div> </div>

View File

@ -22,6 +22,7 @@ print '<script type="text/javascript">
</script>'; </script>';
$db = new db(); $db = new db();
print(' <br><br> print(' <br><br>
<!-- lalis Grid Section --> <!-- lalis Grid Section -->
@ -29,6 +30,7 @@ print(' <br><br>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg-12 text-center"><h3>LISTE DES VOTATIONS</h3>'); <div class="col-lg-12 text-center"><h3>LISTE DES VOTATIONS</h3>');
if ( empty( $_GET["id"])) if ( empty( $_GET["id"]))
{ {
choixVotation('/vote.resultat.php'); choixVotation('/vote.resultat.php');
@ -38,6 +40,7 @@ if ( empty( $_GET["id"]))
print(' print('
<h3>VOTE</h3> <h3>VOTE</h3>
<h4>'); <h4>');
$query = 'SELECT *, UNIX_TIMESTAMP(DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation); $query = 'SELECT *, UNIX_TIMESTAMP(DATE_ADD(dateFin, INTERVAL 1 DAY)) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation);
$result = $db->query($query); $result = $db->query($query);
$votation = $db->result->fetch_array(MYSQLI_ASSOC); $votation = $db->result->fetch_array(MYSQLI_ASSOC);
@ -111,6 +114,7 @@ if ( empty( $_GET["id"]))
</section>'); </section>');
} }
$db->close();
require_once 'footer.html'; require_once 'footer.html';
?> ?>