2011-05-15 01:32:47 +02:00
< ? php
//==========================================================================
//
//Université de Strasbourg - Direction Informatique
//Auteur : Guilhem BORGHESI
//Création : Février 2008
//
//borghesi@unistra.fr
//
//Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
//respectant les principes de diffusion des logiciels libres. Vous pouvez
//utiliser, modifier et/ou redistribuer ce programme sous les conditions
2013-03-04 19:46:06 +01:00
//de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
2011-05-15 01:32:47 +02:00
//sur le site "http://www.cecill.info".
//
2013-03-04 19:46:06 +01:00
//Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
2011-05-15 01:32:47 +02:00
//pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
//termes. Vous pouvez trouver une copie de la licence dans le fichier LICENCE.
//
//==========================================================================
//
//Université de Strasbourg - Direction Informatique
//Author : Guilhem BORGHESI
//Creation : Feb 2008
//
//borghesi@unistra.fr
//
//This software is governed by the CeCILL-B license under French law and
2013-03-04 19:46:06 +01:00
//abiding by the rules of distribution of free software. You can use,
2011-05-15 01:32:47 +02:00
//modify and/ or redistribute the software under the terms of the CeCILL-B
//license as circulated by CEA, CNRS and INRIA at the following URL
2013-03-04 19:46:06 +01:00
//"http://www.cecill.info".
2011-05-15 01:32:47 +02:00
//
//The fact that you are presently reading this means that you have had
//knowledge of the CeCILL-B license and that you accept its terms. You can
//find a copy of this license in the file LICENSE.
//
//==========================================================================
session_start ();
//setlocale(LC_TIME, "fr_FR");
include_once ( 'fonctions.php' );
2011-05-15 03:56:54 +02:00
if ( file_exists ( 'bandeaux_local.php' )) {
include_once ( 'bandeaux_local.php' );
} else {
include_once ( 'bandeaux.php' );
}
2011-05-15 01:32:47 +02:00
2011-05-15 01:49:29 +02:00
// Initialisation des variables
$numsondageadmin = false ;
$sondage = false ;
2011-05-15 01:32:47 +02:00
2011-05-15 01:49:29 +02:00
// recuperation du numero de sondage admin (24 car.) dans l'URL
2011-05-22 02:13:44 +02:00
if ( issetAndNoEmpty ( 'sondage' , $_GET ) && is_string ( $_GET [ 'sondage' ]) && strlen ( $_GET [ 'sondage' ]) === 24 ) {
2011-05-15 03:56:54 +02:00
$numsondageadmin = $_GET [ " sondage " ];
//on découpe le résultat pour avoir le numéro de sondage (16 car.)
$numsondage = substr ( $numsondageadmin , 0 , 16 );
2011-05-15 01:49:29 +02:00
}
2011-05-15 01:32:47 +02:00
2011-05-15 01:49:29 +02:00
if ( preg_match ( " ;[ \ w \ d] { 24};i " , $numsondageadmin )) {
2011-05-15 03:56:54 +02:00
$sql = 'SELECT * FROM sondage WHERE id_sondage_admin = ' . $connect -> Param ( 'numsondageadmin' );
$sql = $connect -> Prepare ( $sql );
$sondage = $connect -> Execute ( $sql , array ( $numsondageadmin ));
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
if ( $sondage !== false ) {
$sql = 'SELECT * FROM sujet_studs WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
$sujets = $connect -> Execute ( $sql , array ( $numsondage ));
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$sql = 'SELECT * FROM user_studs WHERE id_sondage = ' . $connect -> Param ( 'numsondage' ) . ' order by id_users' ;
$sql = $connect -> Prepare ( $sql );
$user_studs = $connect -> Execute ( $sql , array ( $numsondage ));
}
2011-05-15 01:32:47 +02:00
}
//verification de l'existence du sondage, s'il n'existe pas on met une page d'erreur
if ( ! $sondage || $sondage -> RecordCount () != 1 ){
2014-06-11 19:19:17 +02:00
print_header ( false , _ ( " Error! " ));
2011-05-15 01:32:47 +02:00
echo '<body>' . " \n " ;
2011-06-23 16:52:10 +02:00
framanav ();
2011-05-15 03:56:54 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Error! " ));
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
echo '<div class=corpscentre>' . " \n " ;
print " <H2> " . _ ( " This poll doesn't exist ! " ) . " </H2><br><br> " . " \n " ;
2014-06-11 19:19:17 +02:00
print " " . _ ( " Back to the homepage of " ) . " <a href= \" " . get_server_name () . " \" > " . NOMAPPLICATION . " </A>. " . " \n " ;
2011-05-15 03:56:54 +02:00
echo '<br><br><br><br>' . " \n " ;
echo '</div>' . " \n " ;
# sur_bandeau_pied();
bandeau_pied ();
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
die ();
2011-05-15 01:32:47 +02:00
}
$dsujet = $sujets -> FetchObject ( false );
$dsondage = $sondage -> FetchObject ( false );
//si la valeur du nouveau titre est valide et que le bouton est activé
$adresseadmin = $dsondage -> mail_admin ;
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " boutonnouveautitre " ]) || isset ( $_POST [ " boutonnouveautitre_x " ])) {
if ( issetAndNoEmpty ( 'nouveautitre' ) === false ) {
2011-05-15 01:32:47 +02:00
$err |= TITLE_EMPTY ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-15 01:32:47 +02:00
//modification de la base SQL avec le nouveau titre
2011-05-22 02:13:44 +02:00
$nouveautitre = htmlentities ( html_entity_decode ( $_POST [ 'nouveautitre' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
$sql = 'UPDATE sondage SET titre = ' . $connect -> Param ( 'nouveautitre' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
//envoi du mail pour prevenir l'admin de sondage
if ( $connect -> Execute ( $sql , array ( $nouveautitre , $numsondage ))) {
2012-01-09 01:26:44 +01:00
sendEmail ( $adresseadmin ,
2011-05-22 02:13:44 +02:00
_ ( " [ADMINISTRATOR] New title for your poll " ) . ' ' . NOMAPPLICATION ,
_ ( " You have changed the title of your poll. \n You can modify this poll with this link " ) .
" : \n \n " . getUrlSondage ( $numsondageadmin , true ) . " \n \n " .
2012-01-11 20:34:37 +01:00
_ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION );
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 01:32:47 +02:00
// si le bouton est activé, quelque soit la valeur du champ textarea
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " boutonnouveauxcommentaires " ]) || isset ( $_POST [ " boutonnouveauxcommentaires_x " ])) {
if ( issetAndNoEmpty ( 'nouveautitre' ) === false ) {
2011-05-15 01:32:47 +02:00
$err |= COMMENT_EMPTY ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
$commentaires = htmlentities ( html_entity_decode ( $_POST [ 'nouveauxcommentaires' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2011-05-15 01:32:47 +02:00
//modification de la base SQL avec les nouveaux commentaires
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE sondage SET commentaires = ' . $connect -> Param ( 'commentaires' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( $connect -> Execute ( $sql , array ( $commentaires , $numsondage ))) {
//envoi du mail pour prevenir l'admin de sondage
2012-01-09 01:26:44 +01:00
sendEmail ( $adresseadmin ,
2011-05-22 02:13:44 +02:00
_ ( " [ADMINISTRATOR] New comments for your poll " ) . ' ' . NOMAPPLICATION ,
_ ( " You have changed the comments of your poll. \n You can modify this poll with this link " ) .
" : \n \n " . getUrlSondage ( $numsondageadmin , true ) . " \n \n " .
2012-01-11 20:34:37 +01:00
_ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION );
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
}
}
//si la valeur de la nouvelle adresse est valide et que le bouton est activé
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " boutonnouvelleadresse " ]) || isset ( $_POST [ " boutonnouvelleadresse_x " ])) {
if ( issetAndNoEmpty ( 'nouvelleadresse' ) === false || validateEmail ( $_POST [ " nouvelleadresse " ]) === false ) {
2011-05-15 01:32:47 +02:00
$err |= INVALID_EMAIL ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
$nouvelleadresse = htmlentities ( html_entity_decode ( $_POST [ 'nouvelleadresse' ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2011-05-15 01:32:47 +02:00
//modification de la base SQL avec la nouvelle adresse
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE sondage SET mail_admin = ' . $connect -> Param ( 'nouvelleadresse' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( $connect -> Execute ( $sql , array ( $nouvelleadresse , $numsondage ))) {
//envoi du mail pour prevenir l'admin de sondage
2012-01-09 01:26:44 +01:00
sendEmail ( $_POST [ 'nouvelleadresse' ],
2011-05-22 02:13:44 +02:00
_ ( " [ADMINISTRATOR] New email address for your poll " ) . ' ' . NOMAPPLICATION ,
_ ( " You have changed your email address in your poll. \n You can modify this poll with this link " ) .
" : \n \n " . getUrlSondage ( $numsondageadmin , true ) . " \n \n " .
2012-01-11 20:34:37 +01:00
_ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION );
2011-05-22 02:13:44 +02:00
}
2011-05-15 01:32:47 +02:00
}
}
// reload
$dsujet = $sujets -> FetchObject ( false );
$dsondage = $sondage -> FetchObject ( false );
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " ajoutsujet " ]) || isset ( $_POST [ " ajoutsujet_x " ])) {
2011-05-15 01:32:47 +02:00
print_header ( true );
echo '<body>' . " \n " ;
2011-06-23 16:52:10 +02:00
framanav ();
2011-05-15 01:32:47 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Make your polls " ));
sous_bandeau ();
2013-03-04 19:46:06 +01:00
2011-05-15 01:32:47 +02:00
//on recupere les données et les sujets du sondage
2013-03-04 19:46:06 +01:00
2011-06-23 16:52:10 +02:00
echo '<div class="corps">' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-20 02:52:22 +02:00
echo '<form name="formulaire" action="' . getUrlSondage ( $numsondageadmin , true ) . '" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-07-02 23:41:10 +02:00
echo '<div class="">' . " \n " ;
2011-05-15 03:56:54 +02:00
echo " <H2> " . _ ( " Column's adding " ) . " </H2><br><br> " . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
if ( $dsondage -> format == " A " || $dsondage -> format == " A+ " ){
2011-07-02 23:41:10 +02:00
echo _ ( " Add a new column " ) . ' :<br> <input type="text" name="nouvellecolonne" size="40">' ;
echo '<br><br>' ;
echo '<button class="button red retour" type="submit" value="retoursondage" name="retoursondage_x"><strong>Retourner au sondage</strong></button>' . " \n " ;
echo '<button type="submit" name="ajoutercolonne_x" value="Ajouter une colonne" class="button green poursuivre" alt="Valider"><strong>Valider</strong></button>' . " \n " ;
2011-05-15 03:56:54 +02:00
} else {
2013-03-04 19:46:06 +01:00
//ajout d'une date avec creneau horaire
2011-05-15 03:56:54 +02:00
echo _ ( " You can add a new scheduling date to your poll.<br> If you just want to add a new hour to an existant date, put the same date and choose a new hour. " ) . '<br><br> ' . " \n " ;
echo _ ( " Add a date " ) . ' :<br><br>' . " \n " ;
echo '<select name="nouveaujour"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
for ( $i = 1 ; $i < 32 ; $i ++ ){
echo '<OPTION VALUE="' . $i . '">' . $i . '</OPTION>' . " \n " ;
}
echo '</SELECT>' . " \n " ;
echo '<select name="nouveaumois"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
2011-05-22 02:13:44 +02:00
for ( $i = 1 ; $i < 13 ; $i ++ ) {
echo '<OPTION VALUE="' . $i . '">' . strftime ( '%B' , mktime ( 0 , 0 , 0 , $i )) . '</OPTION>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
echo '</SELECT>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
echo '<select name="nouvelleannee"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
2011-05-22 02:13:44 +02:00
for ( $i = date ( " Y " ); $i < ( date ( " Y " ) + 5 ); $i ++ ) {
2011-05-15 03:56:54 +02:00
echo '<OPTION VALUE="' . $i . '">' . $i . '</OPTION>' . " \n " ;
}
echo '</SELECT>' . " \n " ;
echo '<br><br>' . _ ( " Add a start hour (optional) " ) . ' : <br><br>' . " \n " ;
echo '<select name="nouvelleheuredebut"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
2011-05-22 02:39:49 +02:00
for ( $i = 0 ; $i < 24 ; $i ++ ) {
2011-05-15 03:56:54 +02:00
echo '<OPTION VALUE="' . $i . '">' . $i . ' H</OPTION>' . " \n " ;
}
echo '</SELECT>' . " \n " ;
echo '<select name="nouvelleminutedebut"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
echo '<OPTION VALUE="00">00</OPTION>' . " \n " ;
echo '<OPTION VALUE="15">15</OPTION>' . " \n " ;
echo '<OPTION VALUE="30">30</OPTION>' . " \n " ;
echo '<OPTION VALUE="45">45</OPTION>' . " \n " ;
echo '</SELECT>' . " \n " ;
echo '<br><br>' . _ ( " Add a end hour (optional) " ) . ' : <br><br>' . " \n " ;
echo '<select name="nouvelleheurefin"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
2011-05-22 02:39:49 +02:00
for ( $i = 0 ; $i < 24 ; $i ++ ) {
2011-05-15 03:56:54 +02:00
echo '<OPTION VALUE="' . $i . '">' . $i . ' H</OPTION>' . " \n " ;
}
echo '</SELECT>' . " \n " ;
echo '<select name="nouvelleminutefin"> ' . " \n " ;
echo '<OPTION VALUE="vide"></OPTION>' . " \n " ;
echo '<OPTION VALUE="00">00</OPTION>' . " \n " ;
echo '<OPTION VALUE="15">15</OPTION>' . " \n " ;
echo '<OPTION VALUE="30">30</OPTION>' . " \n " ;
echo '<OPTION VALUE="45">45</OPTION>' . " \n " ;
echo '</SELECT>' . " \n " ;
2011-07-02 23:41:10 +02:00
echo '<br><br>' ;
echo '<button class="button red retour" type="submit" value="retoursondage" name="retoursondage_x"><strong>Retourner au sondage</strong></button>' . " \n " ;
echo '<button type="submit" name="ajoutercolonne_x" value="Ajouter une colonne" class="button green poursuivre" alt="Valider"><strong>Valider</strong></button>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
echo '</form>' . " \n " ;
echo '<br><br><br><br>' . " \n " ;
echo '</div>' . " \n " ;
2011-06-23 16:52:10 +02:00
echo '</div>' . " \n " ;
echo '<div class="separateur"> </div>' ;
2011-05-15 03:56:54 +02:00
bandeau_pied ();
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
2013-03-04 19:46:06 +01:00
die ();
2011-05-15 01:32:47 +02:00
}
2011-07-03 00:10:13 +02:00
if ( isset ( $_POST [ " suppressionsondage_x " ])) {
print_header ( true );
echo '<body>' . " \n " ;
framanav ();
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Confirm removal of your poll " ));
sous_bandeau ();
echo '<div class="corps">' . " \n " ;
echo '<form name="formulaire" action="' . getUrlSondage ( $numsondageadmin , true ) . '" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
echo '<div class="">' . " \n " ;
echo " <H2> " . _ ( " Confirm removal of your poll " ) . " </H2><br><br> " . " \n " ;
echo '<button class="button red retour" type="submit" value="' . _ ( " Keep this poll! " ) . '" name="annullesuppression"><strong>' . _ ( " Keep this poll! " ) . '</strong></button>' . " \n " ;
echo '<button type="submit" name="confirmesuppression" value="' . _ ( " Remove this poll! " ) . '" class="button green poursuivre" alt="' . _ ( " Remove this poll! " ) . '"><strong>' . _ ( " Remove this poll! " ) . '</strong></button>' . " \n " ;
echo '</form>' . " \n " ;
echo '<br><br><br><br>' . " \n " ;
echo '</div>' . " \n " ;
echo '</div>' . " \n " ;
echo '<div class="separateur"> </div>' ;
2013-03-04 19:46:06 +01:00
2011-07-03 00:10:13 +02:00
bandeau_pied ();
2013-03-04 19:46:06 +01:00
2011-07-03 00:10:13 +02:00
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
die ();
}
2011-05-15 01:32:47 +02:00
//action si bouton confirmation de suppression est activé
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " confirmesuppression " ]) || isset ( $_POST [ " confirmesuppression_x " ])) {
2011-05-15 03:56:54 +02:00
$nbuser = $user_studs -> RecordCount ();
$date = date ( 'H:i:s d/m/Y:' );
2012-01-11 00:02:02 +01:00
if ( remove_sondage ( $connect , $numsondage ) ) {
2011-05-22 02:13:44 +02:00
// on ecrit dans le fichier de logs la suppression du sondage
2011-07-03 00:10:13 +02:00
error_log ( $date . " SUPPRESSION: $dsondage->id_sondage\t $dsondage->format\t $dsondage->nom_admin\t $dsondage->mail_admin\n " , 3 , 'admin/logs_studs.txt' );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
//envoi du mail a l'administrateur du sondage
2013-03-04 19:46:06 +01:00
sendEmail ( $adresseadmin ,
2011-05-22 02:13:44 +02:00
_ ( " [ADMINISTRATOR] Removing of your poll " ) . ' ' . NOMAPPLICATION ,
_ ( " You have removed your poll. \n You can make new polls with this link " ) .
" : \n \n " . get_server_name () . " index.php \n \n " .
2012-01-11 20:34:37 +01:00
_ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION );
2011-05-15 03:56:54 +02:00
2011-05-22 02:13:44 +02:00
//affichage de l'ecran de confirmation de suppression de sondage
print_header ();
echo '<body>' . " \n " ;
2011-06-23 16:52:10 +02:00
framanav ();
2011-05-22 02:13:44 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Make your polls " ));
2013-03-04 19:46:06 +01:00
2011-07-03 00:10:13 +02:00
echo '<div class="corps corpscentre">' . " \n " ;
2011-05-22 02:13:44 +02:00
print " <H2> " . _ ( " Your poll has been removed! " ) . " </H2><br><br> " ;
2014-06-11 19:19:17 +02:00
print _ ( " Back to the homepage of " ) . ' <a href="' . get_server_name () . '"> ' . NOMAPPLICATION . '</a>.' . " \n " ;
2011-05-22 02:13:44 +02:00
echo '<br><br><br>' . " \n " ;
echo '</div>' . " \n " ;
sur_bandeau_pied ();
bandeau_pied ();
echo '</form>' . " \n " ;
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
die ();
}
2011-05-15 01:32:47 +02:00
}
// quand on ajoute un commentaire utilisateur
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ 'ajoutcomment' ]) || isset ( $_POST [ 'ajoutcomment_x' ])) {
if ( issetAndNoEmpty ( 'commentuser' ) === false ) {
2011-05-15 01:32:47 +02:00
$err |= COMMENT_USER_EMPTY ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
$comment_user = htmlentities ( html_entity_decode ( $_POST [ " commentuser " ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( issetAndNoEmpty ( 'comment' ) === false ) {
2011-05-15 01:32:47 +02:00
$err |= COMMENT_EMPTY ;
2011-05-15 03:56:54 +02:00
}
2011-05-15 01:32:47 +02:00
2011-05-22 02:13:44 +02:00
if ( issetAndNoEmpty ( 'comment' ) && ! is_error ( COMMENT_EMPTY ) && ! is_error ( NO_POLL ) && ! is_error ( COMMENT_USER_EMPTY )) {
$comment = htmlentities ( html_entity_decode ( $_POST [ " comment " ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$sql = 'INSERT INTO comments (id_sondage, comment, usercomment) VALUES (' .
$connect -> Param ( 'id_sondage' ) . ',' .
$connect -> Param ( 'comment' ) . ',' .
$connect -> Param ( 'comment_user' ) . ')' ;
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$comments = $connect -> Execute ( $sql , array ( $numsondage , $comment , $comment_user ));
if ( $comments === false ) {
$err |= COMMENT_INSERT_FAILED ;
}
2011-05-15 01:32:47 +02:00
}
}
//s'il existe on affiche la page normale
// DEBUT DE L'AFFICHAGE DE LA PAGE HTML
print_header ( true );
echo '<body>' . " \n " ;
2011-06-23 16:52:10 +02:00
framanav ();
2011-05-15 01:32:47 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Make your polls " ));
sous_bandeau ();
2011-06-23 16:52:10 +02:00
echo '<div class="corps">' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 01:32:47 +02:00
echo '<div class="presentationdate"> ' . " \n " ;
//affichage du titre du sondage
2013-03-04 19:46:06 +01:00
$titre = str_replace ( " \\ " , " " , $dsondage -> titre );
2011-05-15 01:32:47 +02:00
echo '<H2>' . $titre . '</H2>' . " \n " ;
//affichage du nom de l'auteur du sondage
2011-06-23 16:52:10 +02:00
echo _ ( " Initiator of the poll " ) . ' : ' . stripslashes ( $dsondage -> nom_admin ) . '<br>' . " \n " ;
2011-05-15 01:32:47 +02:00
//affichage des commentaires du sondage
if ( $dsondage -> commentaires ){
echo '<br>' . _ ( " Comments " ) . ' :<br>' . " \n " ;
$commentaires = $dsondage -> commentaires ;
2013-03-04 19:46:06 +01:00
$commentaires = str_replace ( " \\ " , " " , $commentaires );
2011-06-23 16:52:10 +02:00
echo stripslashes ( nl2br ( $commentaires ));
2011-05-15 01:32:47 +02:00
echo '<br>' . " \n " ;
}
echo '<br>' . " \n " ;
echo '</div>' . " \n " ;
2011-05-22 02:13:44 +02:00
$nbcolonnes = substr_count ( $dsujet -> sujet , ',' ) + 1 ;
$nblignes = $user_studs -> RecordCount ();
2011-05-15 01:32:47 +02:00
//si il n'y a pas suppression alors on peut afficher normalement le tableau
2011-05-15 03:56:54 +02:00
//action si le bouton participer est cliqué
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " boutonp " ]) || isset ( $_POST [ " boutonp_x " ])) {
2011-05-15 03:56:54 +02:00
//si on a un nom dans la case texte
2011-05-22 02:13:44 +02:00
if ( issetAndNoEmpty ( 'nom' )){
$nouveauchoix = '' ;
$erreur_prenom = false ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ){
//si la checkbox est cochée alors valeur est egale à 1
if ( isset ( $_POST [ " choix $i " ])){
$nouveauchoix .= " 1 " ;
} else { //sinon 0
$nouveauchoix .= " 0 " ;
}
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$nom = htmlentities ( html_entity_decode ( $_POST [ " nom " ], ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
while ( $user = $user_studs -> FetchNextObject ( false )) {
if ( $nom == $user -> nom ){
2011-05-15 03:56:54 +02:00
$erreur_prenom = " yes " ;
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
// Ecriture des choix de l'utilisateur dans la base
2011-05-22 02:13:44 +02:00
if ( ! $erreur_prenom ) {
$sql = 'INSERT INTO user_studs (nom, id_sondage, reponses) VALUES (' .
$connect -> Param ( 'nom' ) . ',' .
$connect -> Param ( 'numsondage' ) . ',' .
$connect -> Param ( 'nouveauchoix' ) . ')' ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $nom , $numsondage , $nouveauchoix ));
2011-05-15 03:56:54 +02:00
}
}
}
//action quand on ajoute une colonne au format AUTRE
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " ajoutercolonne_x " ]) && issetAndNoEmpty ( 'nouvellecolonne' ) && ( $dsondage -> format == " A " || $dsondage -> format == " A+ " )) {
2011-05-15 03:56:54 +02:00
$nouveauxsujets = $dsujet -> sujet ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//on rajoute la valeur a la fin de tous les sujets deja entrés
$nouveauxsujets .= " , " ;
$nouveauxsujets .= str_replace ( " , " , " " , $_POST [ " nouvellecolonne " ]);
2011-05-22 04:03:44 +02:00
$nouveauxsujets = htmlentities ( html_entity_decode ( $nouveauxsujets , ENT_QUOTES , 'UTF-8' ), ENT_QUOTES , 'UTF-8' );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//mise a jour avec les nouveaux sujets dans la base
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE sujet_studs SET sujet = ' . $connect -> Param ( 'nouveauxsujets' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
if ( $connect -> Execute ( $sql , array ( $nouveauxsujets , $numsondage ))) {
//envoi d'un mail pour prévenir l'administrateur du changement
2012-01-09 02:18:25 +01:00
2012-01-09 01:26:44 +01:00
sendEmail ( " $adresseadmin " , " " . _ ( " [ADMINISTRATOR] New column for your poll " ) . NOMAPPLICATION , " " .
2011-05-22 02:13:44 +02:00
_ ( " You have added a new column in your poll. \n You can inform the voters of this change with this link " ) .
2012-01-11 20:34:37 +01:00
" : \n \n " . getUrlSondage ( $numsondage ) . " \n \n " . _ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION );
2011-05-22 02:13:44 +02:00
}
2011-05-15 03:56:54 +02:00
}
//action quand on ajoute une colonne au format DATE
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " ajoutercolonne_x " ]) && ( $dsondage -> format == " D " || $dsondage -> format == " D+ " )) {
2011-05-15 03:56:54 +02:00
$nouveauxsujets = $dsujet -> sujet ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " nouveaujour " ]) && $_POST [ " nouveaujour " ] != " vide " &&
isset ( $_POST [ " nouveaumois " ]) && $_POST [ " nouveaumois " ] != " vide " &&
isset ( $_POST [ " nouvelleannee " ]) && $_POST [ " nouvelleannee " ] != " vide " ) {
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$nouvelledate = mktime ( 0 , 0 , 0 , $_POST [ " nouveaumois " ], $_POST [ " nouveaujour " ], $_POST [ " nouvelleannee " ]);
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " nouvelleheuredebut " ]) && $_POST [ " nouvelleheuredebut " ] != " vide " ){
2011-05-15 03:56:54 +02:00
$nouvelledate .= " @ " ;
$nouvelledate .= $_POST [ " nouvelleheuredebut " ];
$nouvelledate .= " h " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
if ( $_POST [ " nouvelleminutedebut " ] != " vide " ) {
$nouvelledate .= $_POST [ " nouvelleminutedebut " ];
}
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " nouvelleheurefin " ]) && $_POST [ " nouvelleheurefin " ] != " vide " ){
2011-05-15 03:56:54 +02:00
$nouvelledate .= " - " ;
$nouvelledate .= $_POST [ " nouvelleheurefin " ];
$nouvelledate .= " h " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
if ( $_POST [ " nouvelleminutefin " ] != " vide " ) {
$nouvelledate .= $_POST [ " nouvelleminutefin " ];
}
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:39:49 +02:00
if ( $_POST [ " nouvelleheuredebut " ] == " vide " || ( isset ( $_POST [ " nouvelleheuredebut " ]) && isset ( $_POST [ " nouvelleheurefin " ]) && (( $_POST [ " nouvelleheuredebut " ] < $_POST [ " nouvelleheurefin " ]) || (( $_POST [ " nouvelleheuredebut " ] == $_POST [ " nouvelleheurefin " ]) && ( $_POST [ " nouvelleminutedebut " ] < $_POST [ " nouvelleminutefin " ]))))) {
2011-05-22 02:13:44 +02:00
$erreur_ajout_date = false ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
$erreur_ajout_date = " yes " ;
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//on rajoute la valeur dans les valeurs
2011-05-22 02:13:44 +02:00
$datesbase = explode ( " , " , $dsujet -> sujet );
$taillebase = sizeof ( $datesbase );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
2011-05-22 02:13:44 +02:00
if ( $nouvelledate < $datesbase [ 0 ]) {
$cleinsertion = 0 ;
} elseif ( $nouvelledate > $datesbase [ $taillebase - 1 ]) {
$cleinsertion = count ( $datesbase );
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < count ( $datesbase ); $i ++ ) {
$j = $i + 1 ;
if ( $nouvelledate > $datesbase [ $i ] && $nouvelledate < $datesbase [ $j ]) {
$cleinsertion = $j ;
2011-05-15 03:56:54 +02:00
}
}
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
array_splice ( $datesbase , $cleinsertion , 0 , $nouvelledate );
$cle = array_search ( $nouvelledate , $datesbase );
$dateinsertion = '' ;
for ( $i = 0 ; $i < count ( $datesbase ); $i ++ ) {
2011-05-15 03:56:54 +02:00
$dateinsertion .= " , " ;
$dateinsertion .= $datesbase [ $i ];
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$dateinsertion = substr ( " $dateinsertion " , 1 );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//mise a jour avec les nouveaux sujets dans la base
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_ajout_date ) && ! $erreur_ajout_date ){
$sql = 'UPDATE sujet_studs SET sujet = ' . $connect -> Param ( 'dateinsertion' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $dateinsertion , $numsondage ));
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
if ( $nouvelledate > strtotime ( $dsondage -> date_fin )) {
$date_fin = $nouvelledate + 200000 ;
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE sondage SET date_fin = ' . $connect -> Param ( 'date_fin' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $date_fin , $numsondage ));
2011-05-15 03:56:54 +02:00
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//mise a jour des reponses actuelles correspondant au sujet ajouté
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE user_studs SET reponses = ' . $connect -> Param ( 'reponses' ) . ' WHERE nom = ' . $connect -> Param ( 'nom' ) . ' AND id_users=' . $connect -> Param ( 'id_users' );
$sql = $connect -> Prepare ( $sql );
while ( $data = $user_studs -> FetchNextObject ( false )) {
2011-05-15 03:56:54 +02:00
$ensemblereponses = $data -> reponses ;
2011-05-22 02:13:44 +02:00
$newcar = '' ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//parcours de toutes les réponses actuelles
2011-05-22 02:13:44 +02:00
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ ) {
2011-05-15 03:56:54 +02:00
$car = substr ( $ensemblereponses , $j , 1 );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//si les reponses ne concerne pas la colonne ajoutée, on concatene
if ( $j == $cle ) {
$newcar .= " 0 " ;
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$newcar .= $car ;
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//mise a jour des reponses utilisateurs dans la base
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_ajout_date ) && ! $erreur_ajout_date ){
$connect -> Execute ( $sql , array ( $newcar , $data -> nom , $data -> id_users ));
2011-05-15 03:56:54 +02:00
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//envoi d'un mail pour prévenir l'administrateur du changement
2011-05-22 02:13:44 +02:00
$adresseadmin = $dsondage -> mail_admin ;
2013-03-04 19:46:06 +01:00
2012-01-09 01:26:44 +01:00
sendEmail ( $adresseadmin ,
2011-05-15 03:56:54 +02:00
_ ( " [ADMINISTRATOR] New column for your poll " ),
2011-05-22 02:13:44 +02:00
_ ( " You have added a new column in your poll. \n You can inform the voters of this change with this link " ) .
2012-01-11 20:34:37 +01:00
" : \n \n " . getUrlSondage ( $numsondage ) . " \n \n " . _ ( " Thanks for your confidence. " ) . " \n " . NOMAPPLICATION );
2011-05-15 03:56:54 +02:00
} else {
$erreur_ajout_date = " yes " ;
}
}
//suppression de ligne dans la base
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nblignes ; $i ++ ) {
if ( isset ( $_POST [ " effaceligne $i " ]) || isset ( $_POST [ 'effaceligne' . $i . '_x' ])) {
2011-05-15 03:56:54 +02:00
$compteur = 0 ;
2011-05-22 02:13:44 +02:00
$sql = 'DELETE FROM user_studs WHERE nom = ' . $connect -> Param ( 'nom' ) . ' AND id_users = ' . $connect -> Param ( 'id_users' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
while ( $data = $user_studs -> FetchNextObject ( false )) {
if ( $compteur == $i ){
2011-05-22 02:13:44 +02:00
$connect -> Execute ( $sql , array ( $data -> nom , $data -> id_users ));
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$compteur ++ ;
}
}
}
//suppression d'un commentaire utilisateur
2011-05-22 02:13:44 +02:00
$sql = 'SELECT * FROM comments WHERE id_sondage=' . $connect -> Param ( 'numsondage' ) . ' ORDER BY id_comment' ;
$sql = $connect -> Prepare ( $sql );
$comment_user = $connect -> Execute ( $sql , array ( $numsondage ));
2011-05-15 03:56:54 +02:00
$i = 0 ;
while ( $dcomment = $comment_user -> FetchNextObject ( false )) {
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ 'suppressioncomment' . $i . '_x' ])) {
$sql = 'DELETE FROM comments WHERE id_comment = ' . $connect -> Param ( 'id_comment' );
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $dcomment -> id_comment ));
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$i ++ ;
}
//on teste pour voir si une ligne doit etre modifiée
2011-05-22 02:13:44 +02:00
$testmodifier = false ;
$testligneamodifier = false ;
for ( $i = 0 ; $i < $nblignes ; $i ++ ) {
if ( isset ( $_POST [ " modifierligne $i " ]) || isset ( $_POST [ 'modifierligne' . $i . '_x' ])) {
2011-05-15 03:56:54 +02:00
$ligneamodifier = $i ;
$testligneamodifier = " true " ;
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//test pour voir si une ligne est a modifier
2011-05-22 02:13:44 +02:00
if ( isset ( $_POST [ " validermodifier $i " ]) || isset ( $_POST [ 'validermodifier' . $i . '_x' ])) {
2011-05-15 03:56:54 +02:00
$modifier = $i ;
$testmodifier = " true " ;
}
}
//si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs
if ( $testmodifier ) {
2011-05-22 02:13:44 +02:00
$nouveauchoix = '' ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
2011-05-15 03:56:54 +02:00
//recuperation des nouveaux choix de l'utilisateur
if ( isset ( $_POST [ " choix $i " ])) {
$nouveauchoix .= " 1 " ;
} else {
$nouveauchoix .= " 0 " ;
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$compteur = 0 ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
while ( $data = $user_studs -> FetchNextObject ( false )) {
2011-05-15 03:56:54 +02:00
//mise a jour des données de l'utilisateur dans la base SQL
if ( $compteur == $modifier ) {
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE user_studs SET reponses = ' . $connect -> Param ( 'reponses' ) . ' WHERE nom = ' . $connect -> Param ( 'nom' ) . ' AND id_users = ' . $connect -> Param ( 'id_users' );
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $nouveauchoix , $data -> nom , $data -> id_users ));
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$compteur ++ ;
}
}
//suppression de colonnes dans la base
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
if (( isset ( $_POST [ " effacecolonne $i " ]) || isset ( $_POST [ 'effacecolonne' . $i . '_x' ])) && $nbcolonnes > 1 ){
$toutsujet = explode ( " , " , $dsujet -> sujet );
2013-03-20 14:21:03 +01:00
//sort($toutsujet, SORT_NUMERIC);
2011-05-22 02:13:44 +02:00
$j = 0 ;
$nouveauxsujets = '' ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//parcours de tous les sujets actuels
2011-05-22 02:13:44 +02:00
while ( isset ( $toutsujet [ $j ])) {
2011-05-15 03:56:54 +02:00
//si le sujet n'est pas celui qui a été effacé alors on concatene
2011-05-22 02:13:44 +02:00
if ( $i != $j ) {
$nouveauxsujets .= ',' ;
$nouveauxsujets .= $toutsujet [ $j ];
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$j ++ ;
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//on enleve la virgule au début
2011-05-22 02:13:44 +02:00
$nouveauxsujets = substr ( " $nouveauxsujets " , 1 );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//nettoyage des reponses actuelles correspondant au sujet effacé
$compteur = 0 ;
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE user_studs SET reponses = ' . $connect -> Param ( 'reponses' ) . ' WHERE nom = ' . $connect -> Param ( 'nom' ) . ' AND id_users = ' . $connect -> Param ( 'id_users' );
$sql = $connect -> Prepare ( $sql );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
while ( $data = $user_studs -> FetchNextObject ( false )) {
$newcar = '' ;
$ensemblereponses = $data -> reponses ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//parcours de toutes les réponses actuelles
2011-05-22 02:13:44 +02:00
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ ) {
$car = substr ( $ensemblereponses , $j , 1 );
2011-05-15 03:56:54 +02:00
//si les reponses ne concerne pas la colonne effacée, on concatene
2011-05-22 02:13:44 +02:00
if ( $i != $j ) {
$newcar .= $car ;
2011-05-15 03:56:54 +02:00
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$compteur ++ ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//mise a jour des reponses utilisateurs dans la base
2011-05-22 02:13:44 +02:00
$connect -> Execute ( $sql , array ( $newcar , $data -> nom , $data -> id_users ));
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//mise a jour des sujets dans la base
2011-05-22 02:13:44 +02:00
$sql = 'UPDATE sujet_studs SET sujet = ' . $connect -> Param ( 'nouveauxsujets' ) . ' WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
$connect -> Execute ( $sql , array ( $nouveauxsujets , $numsondage ));
2011-05-15 03:56:54 +02:00
}
}
//recuperation des donnes de la base
2011-05-22 02:13:44 +02:00
$sql = 'SELECT * FROM sondage WHERE id_sondage_admin = ' . $connect -> Param ( 'numsondageadmin' );
$sql = $connect -> Prepare ( $sql );
$sondage = $connect -> Execute ( $sql , array ( $numsondageadmin ));
if ( $sondage !== false ) {
$sql = 'SELECT * FROM sujet_studs WHERE id_sondage = ' . $connect -> Param ( 'numsondage' );
$sql = $connect -> Prepare ( $sql );
$sujets = $connect -> Execute ( $sql , array ( $numsondage ));
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
$sql = 'SELECT * FROM user_studs WHERE id_sondage = ' . $connect -> Param ( 'numsondage' ) . ' order by id_users' ;
$sql = $connect -> Prepare ( $sql );
$user_studs = $connect -> Execute ( $sql , array ( $numsondage ));
} else {
2014-06-11 19:19:17 +02:00
print_header ( false , _ ( " Error! " ));
2011-05-22 02:13:44 +02:00
echo '<body>' . " \n " ;
2011-06-23 16:52:10 +02:00
framanav ();
2011-05-22 02:13:44 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Error! " ));
echo '<div class=corpscentre>' . " \n " ;
print " <H2> " . _ ( " This poll doesn't exist ! " ) . " </H2><br><br> " . " \n " ;
2014-06-11 19:19:17 +02:00
print " " . _ ( " Back to the homepage of " ) . " <a href= \" " . get_server_name () . " \" > " . NOMAPPLICATION . " </A>. " . " \n " ;
2011-05-22 02:13:44 +02:00
echo '<br><br><br><br>' . " \n " ;
echo '</div>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
bandeau_pied ();
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
die ();
}
2011-05-15 03:56:54 +02:00
//on recupere les données et les sujets du sondage
$dsujet = $sujets -> FetchObject ( false );
$dsondage = $sondage -> FetchObject ( false );
$toutsujet = explode ( " , " , $dsujet -> sujet );
$toutsujet = str_replace ( " @ " , " <br> " , $toutsujet );
$toutsujet = str_replace ( " ° " , " ' " , $toutsujet );
$nbcolonnes = substr_count ( $dsujet -> sujet , ',' ) + 1 ;
2011-05-20 02:52:22 +02:00
echo '<form name="formulaire" action="' . getUrlSondage ( $numsondageadmin , true ) . '" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '<div class="cadre"> ' . " \n " ;
2014-06-11 19:19:17 +02:00
echo _ ( 'As poll administrator, you can change all the lines of this poll with <img src="' . get_server_name () . 'images/info.png" alt="infos">.<br> You can, as well, remove a column or a line with <img src="' . get_server_name () . 'images/cancel.png" alt="Cancel">. <br>You can also add a new column with <img src="' . get_server_name () . 'images/add-16.png" alt="Add column">.<br> Finally, you can change the informations of this poll like the title, the comments or your email address.' ) . " \n " ;
2011-05-15 03:56:54 +02:00
echo '<br><br>' . " \n " ;
//debut de l'affichage de résultats
echo '<table class="resultats">' . " \n " ;
//reformatage des données des sujets du sondage
$toutsujet = explode ( " , " , $dsujet -> sujet );
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td></td>' . " \n " ;
2014-06-11 19:19:17 +02:00
echo '<td></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
//boucle pour l'affichage des boutons de suppression de colonne
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; isset ( $toutsujet [ $i ]); $i ++ ) {
2014-06-11 19:19:17 +02:00
echo '<td class=somme><input type="image" name="effacecolonne' . $i . '" value="Effacer la colonne" src="' . get_server_name () . 'images/cancel.png" /></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
echo '</tr>' . " \n " ;
2011-05-15 01:32:47 +02:00
//si le sondage est un sondage de date
2011-05-15 03:56:54 +02:00
if ( $dsondage -> format == " D " || $dsondage -> format == " D+ " ) {
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage des sujets du sondage
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td></td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage des années
$colspan = 1 ;
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < count ( $toutsujet ); $i ++ ) {
$current = $toutsujet [ $i ];
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( strpos ( $toutsujet [ $i ], '@' ) !== false ) {
$current = substr ( $toutsujet [ $i ], 0 , strpos ( $toutsujet [ $i ], '@' ));
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $toutsujet [ $i + 1 ]) && strpos ( $toutsujet [ $i + 1 ], '@' ) !== false ) {
$next = substr ( $toutsujet [ $i + 1 ], 0 , strpos ( $toutsujet [ $i + 1 ], '@' ));
} elseif ( isset ( $toutsujet [ $i + 1 ])) {
$next = $toutsujet [ $i + 1 ];
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $toutsujet [ $i + 1 ]) && strftime ( " %Y " , $current ) == strftime ( " %Y " , $next )){
2011-05-15 03:56:54 +02:00
$colspan ++ ;
} else {
2011-05-22 02:13:44 +02:00
echo '<td colspan=' . $colspan . ' class="annee">' . strftime ( " %Y " , $current ) . '</td>' . " \n " ;
2011-05-15 03:56:54 +02:00
$colspan = 1 ;
}
}
2013-03-04 19:46:06 +01:00
2014-06-11 19:19:17 +02:00
echo '<td class="annee"><input type="image" name="ajoutsujet" src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add' ) . '"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td></td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage des mois
2011-05-22 02:13:44 +02:00
$colspan = 1 ;
for ( $i = 0 ; $i < count ( $toutsujet ); $i ++ ) {
$current = $toutsujet [ $i ];
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( strpos ( $toutsujet [ $i ], '@' ) !== false ) {
$current = substr ( $toutsujet [ $i ], 0 , strpos ( $toutsujet [ $i ], '@' ));
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $toutsujet [ $i + 1 ]) && strpos ( $toutsujet [ $i + 1 ], '@' ) !== false ) {
$next = substr ( $toutsujet [ $i + 1 ], 0 , strpos ( $toutsujet [ $i + 1 ], '@' ));
} elseif ( isset ( $toutsujet [ $i + 1 ])) {
$next = $toutsujet [ $i + 1 ];
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $toutsujet [ $i + 1 ]) && strftime ( " %B " , $current ) == strftime ( " %B " , $next ) && strftime ( " %Y " , $current ) == strftime ( " %Y " , $next )){
2011-05-15 03:56:54 +02:00
$colspan ++ ;
} else {
if ( $_SESSION [ " langue " ] == " EN " ) {
2011-05-22 02:13:44 +02:00
echo '<td colspan=' . $colspan . ' class="mois">' . date ( " F " , $current ) . '</td>' . " \n " ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
echo '<td colspan=' . $colspan . ' class="mois">' . strftime ( " %B " , $current ) . '</td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$colspan = 1 ;
}
}
2013-03-04 19:46:06 +01:00
2014-06-11 19:19:17 +02:00
echo '<td class="mois"><input type="image" name="ajoutsujet" src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add' ) . '"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td></td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage des jours
2011-05-22 02:13:44 +02:00
$colspan = 1 ;
for ( $i = 0 ; $i < count ( $toutsujet ); $i ++ ) {
$current = $toutsujet [ $i ];
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( strpos ( $toutsujet [ $i ], '@' ) !== false ) {
$current = substr ( $toutsujet [ $i ], 0 , strpos ( $toutsujet [ $i ], '@' ));
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $toutsujet [ $i + 1 ]) && strpos ( $toutsujet [ $i + 1 ], '@' ) !== false ) {
$next = substr ( $toutsujet [ $i + 1 ], 0 , strpos ( $toutsujet [ $i + 1 ], '@' ));
} elseif ( isset ( $toutsujet [ $i + 1 ])) {
$next = $toutsujet [ $i + 1 ];
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $toutsujet [ $i + 1 ]) && strftime ( " %a %e " , $current ) == strftime ( " %a %e " , $next ) && strftime ( " %B " , $current ) == strftime ( " %B " , $next )){
2011-05-15 03:56:54 +02:00
$colspan ++ ;
} else {
if ( $_SESSION [ " langue " ] == " EN " ) {
2011-05-22 02:13:44 +02:00
echo '<td colspan=' . $colspan . ' class="jour">' . date ( " D jS " , $current ) . '</td>' . " \n " ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
echo '<td colspan=' . $colspan . ' class="jour">' . strftime ( " %a %e " , $current ) . '</td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$colspan = 1 ;
}
}
2013-03-04 19:46:06 +01:00
2014-06-11 19:19:17 +02:00
echo '<td class="jour"><input type="image" name="ajoutsujet" src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add' ) . '"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage des horaires
if ( strpos ( $dsujet -> sujet , '@' ) !== false ) {
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td></td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; isset ( $toutsujet [ $i ]); $i ++ ) {
$heures = explode ( " @ " , $toutsujet [ $i ]);
if ( isset ( $heures [ 1 ])) {
echo '<td class="heure">' . $heures [ 1 ] . '</td>' . " \n " ;
} else {
echo '<td class="heure"></td>' . " \n " ;
}
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2014-06-11 19:19:17 +02:00
echo '<td class="heure"><input type="image" name="ajoutsujet" src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add' ) . '"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
}
} else {
$toutsujet = str_replace ( " ° " , " ' " , $toutsujet );
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage des sujets du sondage
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td></td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; isset ( $toutsujet [ $i ]); $i ++ ) {
2011-06-23 16:52:10 +02:00
echo '<td class="sujet">' . stripslashes ( $toutsujet [ $i ]) . '</td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2014-06-11 19:19:17 +02:00
echo '<td class="sujet"><input type="image" name="ajoutsujet" src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add' ) . '"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
}
//affichage des resultats
2011-05-22 02:13:44 +02:00
$somme [] = 0 ;
2011-05-15 03:56:54 +02:00
$compteur = 0 ;
2011-05-22 02:13:44 +02:00
while ( $data = $user_studs -> FetchNextObject ( false )) {
$ensemblereponses = $data -> reponses ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
echo '<tr>' . " \n " ;
2014-06-11 19:19:17 +02:00
echo '<td><input type="image" name="effaceligne' . $compteur . '" value="Effacer" src="' . get_server_name () . 'images/cancel.png" alt="Icone efface" /></td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//affichage du nom
$nombase = str_replace ( " ° " , " ' " , $data -> nom );
2011-06-23 16:52:10 +02:00
echo '<td class="nom">' . stripslashes ( $nombase ) . '</td>' . " \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//si la ligne n'est pas a changer, on affiche les données
if ( ! $testligneamodifier ) {
2011-05-22 02:13:44 +02:00
for ( $k = 0 ; $k < $nbcolonnes ; $k ++ ) {
$car = substr ( $ensemblereponses , $k , 1 );
if ( $car == " 1 " ) {
2011-05-15 03:56:54 +02:00
echo '<td class="ok">OK</td>' . " \n " ;
2011-05-22 02:13:44 +02:00
if ( isset ( $somme [ $k ]) === false ) {
$somme [ $k ] = 0 ;
}
2011-05-15 03:56:54 +02:00
$somme [ $k ] ++ ;
} else {
echo '<td class="non"></td>' . " \n " ;
}
}
} else { //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//si c'est bien la ligne a modifier on met les checkbox
2011-05-22 02:13:44 +02:00
if ( $compteur == " $ligneamodifier " ) {
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ ) {
$car = substr ( $ensemblereponses , $j , 1 );
if ( $car == " 1 " ) {
2011-05-15 03:56:54 +02:00
echo '<td class="vide"><input type="checkbox" name="choix' . $j . '" value="" checked></td>' . " \n " ;
} else {
echo '<td class="vide"><input type="checkbox" name="choix' . $j . '" value=""></td>' . " \n " ;
}
}
} else { //sinon on affiche les lignes normales
2011-05-22 02:13:44 +02:00
for ( $k = 0 ; $k < $nbcolonnes ; $k ++ ) {
$car = substr ( $ensemblereponses , $k , 1 );
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( $car == " 1 " ) {
2011-05-15 03:56:54 +02:00
echo '<td class="ok">OK</td>' . " \n " ;
2011-05-22 02:13:44 +02:00
if ( isset ( $somme [ $k ]) === false ) {
$somme [ $k ] = 0 ;
}
2011-05-15 03:56:54 +02:00
$somme [ $k ] ++ ;
} else {
echo '<td class="non"></td>' . " \n " ;
}
}
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//a la fin de chaque ligne se trouve les boutons modifier
if ( ! $testligneamodifier == " true " ) {
2014-06-11 19:19:17 +02:00
echo '<td class=somme><input type="image" name="modifierligne' . $compteur . '" value="Modifier" src="' . get_server_name () . 'images/info.png" alt="Icone infos"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
//demande de confirmation pour modification de ligne
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nblignes ; $i ++ ) {
if ( isset ( $_POST [ " modifierligne $i " ]) || isset ( $_POST [ 'modifierligne' . $i . '_x' ])) {
if ( $compteur == $i ) {
2014-06-11 19:19:17 +02:00
echo '<td><input type="image" name="validermodifier' . $compteur . '" value="Valider la modification" src="' . get_server_name () . 'images/accept.png" alt="Icone valider"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
}
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$compteur ++ ;
echo '</tr>' . " \n " ;
2011-05-15 01:32:47 +02:00
}
2011-05-15 03:56:54 +02:00
//affichage de la case vide de texte pour un nouvel utilisateur
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td class=nom>' . " \n " ;
echo '<input type="text" name="nom"><br>' . " \n " ;
echo '</td>' . " \n " ;
//une ligne de checkbox pour le choix du nouvel utilisateur
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
2011-05-15 03:56:54 +02:00
echo '<td class="vide"><input type="checkbox" name="choix' . $i . '" value=""></td>' . " \n " ;
}
2011-05-15 01:32:47 +02:00
2011-05-15 03:56:54 +02:00
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
2014-06-11 19:19:17 +02:00
echo '<td><input type="image" name="boutonp" value="Participer" src="' . get_server_name () . 'images/add-24.png" alt="' . _ ( 'Add' ) . '"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
2011-05-15 01:32:47 +02:00
2011-05-15 03:56:54 +02:00
//determination du meilleur choix
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes + 1 ; $i ++ ) {
if ( isset ( $somme [ $i ]) === true ) {
if ( $i == " 0 " ) {
$meilleurecolonne = $somme [ $i ];
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $somme [ $i ]) && $somme [ $i ] > $meilleurecolonne ){
$meilleurecolonne = $somme [ $i ];
}
2011-05-15 03:56:54 +02:00
}
2011-05-15 01:32:47 +02:00
}
2011-05-15 03:56:54 +02:00
//affichage de la ligne contenant les sommes de chaque colonne
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td align="right">' . _ ( " Addition " ) . '</td>' . " \n " ;
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
if ( isset ( $somme [ $i ]) === true ) {
$affichesomme = $somme [ $i ];
} else {
$affichesomme = '' ;
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( $affichesomme == " " ) {
$affichesomme = " 0 " ;
2011-05-15 03:56:54 +02:00
}
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( isset ( $somme [ $i ]) === true && isset ( $meilleurecolonne ) === true && $somme [ $i ] == $meilleurecolonne ){
2011-05-15 03:56:54 +02:00
echo '<td class="somme">' . $affichesomme . '</td>' . " \n " ;
} else {
echo '<td class="somme">' . $affichesomme . '</td>' . " \n " ;
}
}
2014-06-11 19:19:17 +02:00
echo '<td></td>' . " \n " ;
echo '</tr>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
echo '<td class="somme"></td>' . " \n " ;
2011-05-22 02:13:44 +02:00
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
if ( isset ( $somme [ $i ]) === true && isset ( $meilleurecolonne ) === true && $somme [ $i ] == $meilleurecolonne ){
2014-06-11 19:19:17 +02:00
echo '<td class="somme"><img src="' . get_server_name () . 'images/medaille.png" alt="Meilleur resultat"></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
} else {
echo '<td class="somme"></td>' . " \n " ;
}
}
2014-06-11 19:19:17 +02:00
echo '<td></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
// S'il a oublié de remplir un nom
2011-05-22 02:13:44 +02:00
if (( isset ( $_POST [ " boutonp " ]) || isset ( $_POST [ " boutonp_x " ])) && $_POST [ " nom " ] == " " ) {
2011-05-15 03:56:54 +02:00
echo '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " Enter a name ! " ) . " </font> \n " ;
echo '</tr>' . " \n " ;
}
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_prenom ) && $erreur_prenom ) {
2011-05-15 03:56:54 +02:00
echo '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " The name you've chosen already exist in this poll! " ) . " </font></td> \n " ;
echo '</tr>' . " \n " ;
}
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_injection ) && $erreur_injection ) {
2011-05-15 03:56:54 +02:00
echo '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " Characters \" ' < et > are not permitted " ) . " </font></td> \n " ;
echo '</tr>' . " \n " ;
}
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_ajout_date ) && $erreur_ajout_date ) {
2011-05-15 03:56:54 +02:00
echo '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " The date is not correct ! " ) . " </font></td> \n " ;
echo '</tr>' . " \n " ;
}
//fin du tableau
echo '</table>' . " \n " ;
echo '</div>' . " \n " ;
//focus en javascript sur le champ texte pour le nom d'utilisateur
echo '<script type="text/javascript">' . " \n " ;
echo 'document.formulaire.nom.focus();' . " \n " ;
echo '</script>' . " \n " ;
//recuperation des valeurs des sujets et adaptation pour affichage
2011-05-22 02:13:44 +02:00
$toutsujet = explode ( " , " , $dsujet -> sujet );
2011-05-15 03:56:54 +02:00
//recuperation des sujets des meilleures colonnes
2011-05-22 02:13:44 +02:00
$compteursujet = 0 ;
$meilleursujet = '' ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
if ( isset ( $somme [ $i ]) === true && isset ( $meilleurecolonne ) === true && $somme [ $i ] == $meilleurecolonne ){
2011-05-15 03:56:54 +02:00
$meilleursujet .= " , " ;
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( $dsondage -> format == " D " || $dsondage -> format == " D+ " ) {
$meilleursujetexport = $toutsujet [ $i ];
2013-03-04 19:46:06 +01:00
2011-05-22 02:13:44 +02:00
if ( strpos ( $toutsujet [ $i ], '@' ) !== false ) {
$toutsujetdate = explode ( " @ " , $toutsujet [ $i ]);
if ( $_SESSION [ " langue " ] == " EN " ) {
$meilleursujet .= date ( " l, F jS Y " , $toutsujetdate [ 0 ]) . " " . _ ( " for " ) . " " . $toutsujetdate [ 1 ];
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
$meilleursujet .= strftime ( _ ( " %A, den %e. %B %Y " ), $toutsujetdate [ 0 ]) . ' ' . _ ( " for " ) . ' ' . $toutsujetdate [ 1 ];
2011-05-15 03:56:54 +02:00
}
} else {
2011-05-22 02:13:44 +02:00
if ( $_SESSION [ " langue " ] == " EN " ) {
$meilleursujet .= date ( " l, F jS Y " , $toutsujet [ $i ]);
2011-05-15 03:56:54 +02:00
} else {
2011-05-22 02:13:44 +02:00
$meilleursujet .= strftime ( _ ( " %A, den %e. %B %Y " ), $toutsujet [ $i ]);
2011-05-15 03:56:54 +02:00
}
}
} else {
$meilleursujet .= $toutsujet [ $i ];
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$compteursujet ++ ;
}
}
//adaptation pour affichage des valeurs
2011-05-22 02:13:44 +02:00
$meilleursujet = substr ( " $meilleursujet " , 1 );
$meilleursujet = str_replace ( " ° " , " ' " , $meilleursujet );
2011-05-15 03:56:54 +02:00
//ajout du S si plusieurs votes
$vote_str = _ ( 'vote' );
2011-05-22 02:13:44 +02:00
if ( isset ( $meilleurecolonne ) && $meilleurecolonne > 1 ) {
2011-05-15 03:56:54 +02:00
$vote_str = _ ( 'votes' );
}
echo '<p class=affichageresultats>' . " \n " ;
//affichage de la phrase annoncant le meilleur sujet
2011-05-22 02:13:44 +02:00
if ( isset ( $meilleurecolonne ) && $compteursujet == " 1 " ) {
2014-06-11 19:19:17 +02:00
print " <img src= \" " . get_server_name () . " images/medaille.png \" alt= \" Meilleur resultat \" > " . _ ( " The best choice at this time is " ) . " : <b> $meilleursujet </b> " . _ ( " with " ) . " <b> $meilleurecolonne </b> " . $vote_str . " .<br> \n " ;
2011-05-22 02:13:44 +02:00
} elseif ( isset ( $meilleurecolonne )) {
2014-06-11 19:19:17 +02:00
print " <img src= \" " . get_server_name () . " images/medaille.png \" alt= \" Meilleur resultat \" > " . _ ( " The bests choices at this time are " ) . " : <b> $meilleursujet </b> " . _ ( " with " ) . " <b> $meilleurecolonne </b> " . $vote_str . " .<br> \n " ;
2011-05-15 03:56:54 +02:00
}
echo '<br><br>' . " \n " ;
echo '</p>' . " \n " ;
echo '</form>' . " \n " ;
echo '<form name="formulaire4" action="#bas" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
//Gestion du sondage
echo '<div class=titregestionadmin>' . _ ( " Poll's management " ) . ' :</div>' . " \n " ;
echo '<p class=affichageresultats>' . " \n " ;
echo '<br>' . " \n " ;
//Changer le titre du sondage
$adresseadmin = $dsondage -> mail_admin ;
echo _ ( " Change the title " ) . ' :<br>' .
2011-05-22 02:13:44 +02:00
'<input type="text" name="nouveautitre" size="40" value="' . $dsondage -> titre . '">' .
2014-06-11 19:19:17 +02:00
'<input type="image" name="boutonnouveautitre" value="Changer le titre" src="' . get_server_name () . 'images/accept.png" alt="Valider"><br><br>' . " \n " ;
2011-05-15 03:56:54 +02:00
//si la valeur du nouveau titre est invalide : message d'erreur
2011-05-22 02:13:44 +02:00
if (( isset ( $_POST [ " boutonnouveautitre " ]) || isset ( $_POST [ " boutonnouveautitre_x " ])) && ! issetAndNoEmpty ( 'nouveautitre' )) {
2011-05-15 03:56:54 +02:00
echo '<font color="#FF0000">' . _ ( " Enter a new title! " ) . '</font><br><br>' . " \n " ;
}
//Changer les commentaires du sondage
2014-06-11 19:19:17 +02:00
echo _ ( " Change the comments " ) . ' :<br> <textarea name="nouveauxcommentaires" rows="7" cols="40">' . stripslashes ( $dsondage -> commentaires ) . '</textarea><br><input type="image" name="boutonnouveauxcommentaires" value="Changer les commentaires" src="' . get_server_name () . 'images/accept.png" alt="Valider"><br><br>' . " \n " ;
2011-05-15 03:56:54 +02:00
//Changer l'adresse de l'administrateur
2014-06-11 19:19:17 +02:00
echo _ ( " Change your email address " ) . ' :<br> <input type="text" name="nouvelleadresse" size="40" value="' . $dsondage -> mail_admin . '"> <input type="image" name="boutonnouvelleadresse" value="Changer votre adresse" src="' . get_server_name () . 'images/accept.png" alt="Valider"><br>' . " \n " ;
2011-05-15 03:56:54 +02:00
//si l'adresse est invalide ou le champ vide : message d'erreur
2011-05-22 02:13:44 +02:00
if (( isset ( $_POST [ " boutonnouvelleadresse " ]) || isset ( $_POST [ " boutonnouvelleadresse_x " ])) && ! issetAndNoEmpty ( 'nouvelleadresse' )) {
2011-05-15 03:56:54 +02:00
echo '<font color="#FF0000">' . _ ( " Enter a new email address! " ) . '</font><br><br>' . " \n " ;
}
//affichage des commentaires des utilisateurs existants
2011-05-22 02:13:44 +02:00
$sql = 'SELECT * FROM comments WHERE id_sondage=' . $connect -> Param ( 'numsondage' ) . ' ORDER BY id_comment' ;
$sql = $connect -> Prepare ( $sql );
$comment_user = $connect -> Execute ( $sql , array ( $numsondage ));
2011-05-15 03:56:54 +02:00
if ( $comment_user -> RecordCount () != 0 ) {
print " <br><b> " . _ ( " Comments " ) . " :</b><br> \n " ;
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
$i = 0 ;
while ( $dcomment = $comment_user -> FetchNextObject ( false )) {
2014-06-11 19:19:17 +02:00
print " <input type= \" image \" name= \" suppressioncomment $i\ " src = \ " " . get_server_name () . " images/cancel.png \" alt= \" supprimer commentaires \" /> " . stripslashes ( $dcomment -> usercomment ) . " : " . stripslashes ( $dcomment -> comment ) . " <br> " ;
2011-05-15 03:56:54 +02:00
$i ++ ;
}
2013-03-04 19:46:06 +01:00
2011-05-15 03:56:54 +02:00
echo '<br>' ;
}
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_commentaire_vide ) && $erreur_commentaire_vide == " yes " ) {
2011-05-15 03:56:54 +02:00
print " <font color=#FF0000> " . _ ( " Enter a name and a comment! " ) . " </font> " ;
}
//affichage de la case permettant de rajouter un commentaire par les utilisateurs
print " <br> " . _ ( " Add a comment in the poll " ) . " :<br> \n " ;
echo _ ( " Name " ) . ' : <input type=text name="commentuser"><br>' . " \n " ;
echo '<textarea name="comment" rows="2" cols="40"></textarea>' . " \n " ;
2014-06-11 19:19:17 +02:00
echo '<input type="image" name="ajoutcomment" value="Ajouter un commentaire" src="' . get_server_name () . 'images/accept.png" alt="Valider"><br>' . " \n " ;
2011-05-15 03:56:54 +02:00
//suppression du sondage
echo '<br>' . " \n " ;
2014-06-11 19:19:17 +02:00
echo _ ( " Remove your poll " ) . ' : <input type="image" name="suppressionsondage" value="' . _ ( " Remove the poll " ) . '" src="' . get_server_name () . 'images/cancel.png" alt="' . _ ( 'Cancel' ) . '" /><br><br>' . " \n " ;
2011-05-15 03:56:54 +02:00
2011-05-22 02:13:44 +02:00
echo '</form>' . " \n " ;
if ( $dsondage -> format == " D " || $dsondage -> format == " D+ " ) {
2014-06-11 19:19:17 +02:00
echo '<form name="formulaire2" action="' . get_server_name () . 'exportpdf.php" method="POST" onkeypress="javascript:process_keypress(event)" class="formulaire2">' . " \n " ;
2011-05-22 02:13:44 +02:00
echo _ ( " Generate the convocation letter (.PDF), choose the place to meet and validate " ) . '<br>' ;
echo '<input type="text" name="lieureunion" size="100" value="" />' ;
echo '<input type="hidden" name="sondage" value="$numsondageadmin" />' ;
echo '<input type="hidden" name="meilleursujet" value="$meilleursujetexport" />' ;
2014-06-11 19:19:17 +02:00
echo '<input type="image" name="exportpdf" value="Export en PDF" src="' . get_server_name () . 'images/accept.png" alt="Export PDF"><br><br>' ;
2011-05-22 02:13:44 +02:00
echo '</form>' . " \n " ;
// '<font color="#FF0000">'. _("Enter a meeting place!") .'</font><br><br>'."\n";
}
// TODO
if ( isset ( $_POST [ " exportpdf_x " ]) && ! issetAndNoEmpty ( 'lieureunion' )) {
echo '<font color="#FF0000">' . _ ( " Enter a meeting place! " ) . '</font><br><br>' . " \n " ;
}
2014-06-11 19:19:17 +02:00
echo '<a id="bas"></a>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '<br><br>' . " \n " ;
2011-05-15 01:32:47 +02:00
2011-05-15 03:56:54 +02:00
//fin de la partie GESTION et beandeau de pied
2014-06-11 19:19:17 +02:00
//echo '</p>'."\n";
2011-06-23 16:52:10 +02:00
echo '</div>' ;
echo '<div class="separateur"> </div>' ;
2011-05-15 03:56:54 +02:00
bandeau_pied_mobile ();
2014-06-11 19:19:17 +02:00
//echo '</form>'."\n";
2011-05-15 03:56:54 +02:00
echo '</body>' . " \n " ;
2011-12-29 18:57:49 +01:00
echo '</html>' . " \n " ;