' . $var . "
"; if ( isset($_GET[$var]) ) { //echo '$_get -> $var =>' . $var . "
"; return $_GET[$var]; } elseif ( isset($_POST[$var]) ) { //echo '$_POST -> $var =>' . $var . "
"; return $_POST[$var]; }else { return null; } } // MET LA PREMIÈRE LETTRE D'UN MOT EN MAJUSCULE ( utf8 compliant ) function mb_ucfirst($str) { $char = mb_substr($str,0,1,"UTF8"); $str = mb_substr( $str, 1, NULL, "UTF8"); $char = mb_strtoupper( $char, "UTF8"); return $char . $str; } function choixVote($path, $idVotation, $confirm=false) { $db = new db(); $query = "SELECT * FROM liste_votes WHERE idVotation=" . $idVotation; $result = $db->query($query); $votes = $db->result->fetch_all(MYSQLI_ASSOC); print ('
'); print "
";
	print '';
	foreach($votes as $key => $value )
	{
		print ' ' . $value["libelle"] . '
'; } // TODO confirmation du choix par javascript si $confirm = true print '

'; $db->close(); } function choixVotation($path, $methode = 2, $confirm = true) //2 = toutes les votations 0 = votations en cours 1 = votations cloturées { $db = new db(); $query = "SELECT * FROM liste_votations"; if ($methode != 2) { $query .= " where status=" . $methode; } $result = $db->query($query); $votations = $db->result->fetch_all(MYSQLI_ASSOC); print ('
'); print "
";
	foreach($votations as $key => $value )
	{
		print ' ' . $value["titre"] . ' :' . $value["libelle"] . '
'; } // TODO confirmation du choix par javascript si $confirm = true print '

'; $db->close(); } function votationForm($path, $titre="", $libelle="", $dateDebut="", $dateFin="", $status=0) { //TODO vérification du formulaire en javascript print('
'); print(''); print('
') . EOLH; print('
') . EOLH; print('
') . EOLH; print('
') . EOLH; print('') . EOLH; print('') . EOLH; } function votesForm($path, $libelle = "", $method = 0) { $db = new db(); $query = "SELECT * FROM methods"; // clotûre $db->query($query); $methods = $db->result->fetch_all(MYSQLI_ASSOC); if (!(array_key_exists($method, $methods))) { print(_("L'ID de la méthode demandée n'est pas bonne " . __file__ . __LINE__)); log_error(_("L'ID de la méthode demandée n'est pas bonne " . __file__ . __LINE__), true, true); } //TODO vérification du formulaire en javascript print('' . EOL); print('
') . EOLH; print('
"). EOLH; print('') . EOL; print('') . EOL; print('
') . EOL; $db->close(); } function candidatsForm($path, $idVotation, $idVote) { //TODO vérification du formulaire en javascript print('
'); print(''); print(''); print('
') . EOLH; print('
') . EOLH; print('') . EOLH; print('') . EOLH; } function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='') { //require 'vendor/autoload.php'; $mail = new PHPMailer(true); try { if ($html) { // setParameters() takes an associative array $str = nl2br($text); $text = "\n" . $str . ""; log_write(__FILE__ . EOL . __LINE__ . EOL . wordwrap($text, 1000, "\r\n"), INFO); $mail->isHTML(true); $mail->AltBody = 'Ceci est un messssage HTML'; }else { //$mail->isHTML(false); $text = str_replace("\n","\r\n", $text); } //Server settings //$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = 'mail.gandi.net'; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'contact@lalis.fr'; //SMTP username $mail->Password = 'Gu>V$fiM{bQ^!x+FAHF+R.}bl'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit ssl encryption $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` $mail->MessageDate= ''; $mail->SMTPKeepAlive = true; //Recipients $mail->setFrom('contact@lalis.fr'); $mail->addAddress($destinataire); //Add a recipient //$mail->addReplyTo('info@example.com', 'Information'); $mail->CharSet = PHPMailer::CHARSET_UTF8; $mail->Body = $text; //Attachments //$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name //Content //Set email format to HTML $mail->Subject = $sujet; $mail->send(); echo 'Message has been sent'; log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel est parti:" . $destinataire . EOL . $sujet . EOL, INFO); } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; log_error(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" . $destinataire . EOL . $sujet . EOL . print_r($mail->ErrorInfo, true) . EOL . wordwrap($text, 1000 , "\r\n")); $mail->getSMTPInstance()->reset(); return false; } return true; } function formatteDate($locale, $date, $tz) { $formatter = new IntlDateFormatter($locale, IntlDateFormatter::LONG, IntlDateFormatter::NONE, $tz, IntlDateFormatter::GREGORIAN ); $datetime = new DateTime(); $datetime->setTimestamp($date); if ($formatter == null) { log_write(__FILE__ . EOLH . __LINE__ . EOLH . "Formatter error : locale = " . $locale . "tz = " . $tz . "Formatter = " . print_r($formatter, true) . InvalidConfigException(intl_get_error_message()),ERROR); } return $formatter->format($datetime ); } function listeAdherents() { $dolibarr = new dbDolibarr(); $query = 'SELECT login, firstname, lastname FROM llx_adherent'; $dolibarr->query($query); while ($adherent = $dolibarr->result->fetch_array()) { $listeAdherents[$adherent['login']] = $adherent['firstname'] . ' ' . $adherent['lastname']; } $dolibarr->close(); return $listeAdherents; } function listeVotants($idVotation, $idVote, $listeAdherents) { $nv = 0; $text = ''; $db->open(); $query = "SELECT DISTINCT idVotant FROM votes WHERE idVotation=" . $idVotation . ' AND idVote=' . $idVote; $result = $db->query($query); while ($idVotants = $db->result->fetch_assoc()) { $nv++; $text .= $listeAdherents[$idVotants['idVotant']] . EOLH; } print('Nombre de votants : ' . $nv . EOLH . ''); print('' . EOLH); $db->close(); } function printLine($path, $request, $libelle, $modif=true, $delete=false) { print('