1
0
This commit is contained in:
Daniel Tartavel 2022-09-23 18:59:08 +02:00
parent 5c84c7eda6
commit bd977181e0
10 changed files with 31 additions and 421 deletions

View File

@ -1,7 +0,0 @@
Options -Indexes
AuthName "back_office"
AuthBasicProvider file
AuthType Basic
AuthUserFile "/var/www/html/vote/gestionsite/.htpasswd"
require valid-user

View File

@ -1 +0,0 @@
daniel:$apr1$67uwe85A$ygTTmLOR/DxIJgPMqGVox.

View File

@ -1,73 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Kevin PITA - Daniel Tartavel">
<title>Lyon Association Libre Informatique Solidaire</title>
<!-- Bootstrap Core CSS - Uses Bootswatch Flatly Theme: http://bootswatch.com/flatly/ -->
<link href="../css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="../css/freelancer.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="../font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body id="page-top" class="index">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<!--button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button-->
<a class="navbar-brand" href="#page-top">LALIS</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
<a href="https://lalis.fr/index.html#page-top"></a>
</li>
<li class="page-scroll">
<a href="https://lalis.fr/index.html#content">Présentation</a>
</li>
<li class="page-scroll">
<a href="https://lalis.fr/index.html#about">Nos engagements</a>
</li>
<li class="page-scroll">
<a href="https://lalis.fr/index.html#horaires">Horaires</a>
</li>
<li class="page-scroll">
<a href="https://lalis.fr/index.html#contact">Contact</a>
</li>
</ul>
</div><div><a>Association loi 1901</a></div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>

View File

@ -1,79 +0,0 @@
<?php
session_start();
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'entete.php';
$idVotation =$_GET["id"];
print('<br><br>
<!-- lalis Grid Section -->
<section id="content">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h3>VOTE</h3>');
$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('<form method="get" action="envoiMailing.php">
<input type="hidden" name="id" value="' . $idVotation . '">
<pre><h4>Êtes-vous sûr de vouloir envoyer le Mailing pour la votation : ' . $votation['libelle'] .'</h4>
</pre><br>
<div>
<input type="submit" name="status" value="Oui">
<input type="submit" name="status" value="Non">
<input type="submit" name="status" value="Test">
</div>
</form>
');
}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 '<pre>' . $adherent['email'] . ' ' . $adherent['firstname'] . ' ' . $adherent['lastname'] . EOLH . nl2br($text) . '</pre>';
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("<pre><h4>Annulation de l'envoi du Mailing pour la votation : " . $votation['libelle'] . "</h4>
</pre><br>");
}
print(' </div>
</div>
</div>
</section>');
}
require_once("footer.html");
?>

View File

@ -1,56 +0,0 @@
<!-- Footer -->
<footer class="text-center">
<div class="footer-above">
<div class="container">
<div class="row">
<div class="footer-col col-md-4">
<h5>adresse</h5>
<p>7 place Louis Chazette<br>69001 Lyon</p>
</div>
<div class="footer-col col-md-4">
<h5>LALIS</h5>
<p>Lyon Association Libre Informatique Solidaire</p>
</div>
<div class="footer-col col-md-4">
<h5>Mail</h5>
<p>contact[arobase]lalis.fr</p>
</div>
</div>
</div>
</div>
<div class="footer-below">
<div class="container">
<div class="row">
<div class="col-lg-12">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/zero/1.0/88x31.png" />
</div>
</div>
</div>
</div>
</footer>
<div class="scroll-top page-scroll visible-xs visible-sm">
<a class="btn btn-primary" href="#page-top">
<i class="fa fa-chevron-up"></i>
</a>
</div>
<script src="../js/lalis.js"></script>
<script src="../js/jquery.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="../js/classie.js"></script>
<script src="../js/cbpAnimatedHeader.js"></script>
<script src="../js/jqBootstrapValidation.js"></script>
<script src="../js/contact_me.js"></script>
<script src="../js/freelancer.js"></script>
</body>
</html>

View File

@ -1,30 +0,0 @@
<?php
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'entete.php';
print(' <br><br>
<!-- lalis Grid Section -->
<section id="content">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h3>Gestion du site</h3>
</div>
</div>
<div class="row">
<ul>
<li><a href="../vote.resultat.php">liste des votations</a></li>
<li><a href="saisieVotation.php">nouvelle votations</a></li>
<li><a href="saisieVotes.php">Ajouter des votes à une votations</a></li>
<li><a href="modifVotation.php">Modifier une votation</a></li>
<li><a href="envoiMailing.php">Envoyer le mailing</a></li>
<li><a href="modifVotation.php?action=cloture">Clôturer une votation</a></li>
</ul>
</div>
</div>
</section>');
require_once './footer.html';
?>

View File

@ -1,54 +0,0 @@
<?php
session_start();
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'entete.php';
require_once 'fonctions.inc.php';
$action = $_GET["action"];
$idVotation = $_GET["id"];
print('<br><br>
<!-- lalis Grid Section -->
<section id="content">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h4>Choisissez une votations à modifier</h4>' . 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(' </div>
</div>
</div>
</section>');
require_once './footer.html';
?>

View File

@ -1,44 +0,0 @@
<?php
session_start();
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'entete.php';
require_once 'fonctions.inc.php';
$path = $_SERVER["PHP_SELF"];
print('<br><br>
<!-- lalis Grid Section -->
<section id="content">
<div class="container">');
print(' <div class="row">
<div class="col-lg-12 text-center">
<h3>Nouvelle votation</h3>
<h4>');
$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(' </div>
</div>
</form>
</div>
</section>');
require_once("footer.html");
?>

View File

@ -1,68 +0,0 @@
<?php
session_start();
require_once '../session_init.php';
require_once 'config.inc.php';
require_once 'db.class.php';
require_once 'entete.php';
require_once 'fonctions.inc.php';
$path = $_SERVER["PHP_SELF"];
$db = new db();
function queryVotationName($db, $idVotation) :string
{
$query = "SELECT libelle FROM liste_votations WHERE id='" . $idVotation . "'";
$db->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('<br><br>
<!-- lalis Grid Section -->
<section id="content">
<div class="container">') . EOL;
print(' <div class="row">
<div class="col-lg-12 text-center">
<h3>Nouveau vote pour la votation');
if (empty($idVotation))
{
choixVotation($path, 0, false);
}else
{
print(": " . $votationName . '</h3>' . 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(' </div>
</div>
</div>
</section>');
require_once("footer.html");
?>

View File

@ -28,32 +28,54 @@ class schulze
} }
} }
function stringify($votes)
{
$r = array();
foreach($votes as $vote)
{
$r[] = implode($vote);
}
return $r;
}
function votify($votes)
{
$r = array();
foreach($votes as $vote)
{
$r[] = explode($vote);
}
return $r;
}
function test($v) function test($v)
{ {
$w = array(); $w = array();
$i = 0; $i = 0;
$j = 0; $j = 0;
$v = stringify($v);
asort($v); sort($v);
print_r($v); print_r($v);
for($i = 0;$i < count($v) - 1;$i++) for($i = 0;$i < count($v) - 1;$i++)
{ {
if ($i == 0) if ($i == 0)
{ {
$w[$j]["vote"] = $v[$i];
$w[$j]['vote'] = $v[$i]; $w[$j]["n"] = 1;
$w[$j]['n'] = 1;
$j += 1; $j += 1;
} }
if ($v[$i] == $v[$i+1]) if ($v[$i] === $v[$i+1])
{ {
$w[$J]["n"] += 1; $x = array_search($v[$i], $w);
$w[$x]["n"] += 1;
}else }else
{ {
$w[$j++] = $v[$i+1]; $w[$j]["vote"] = $v[$i+1];
$w[$j]["n"] = 1;
$j += 1;
} }
} }
$w = votify($w);
print_r($w); print_r($w);
} }