2011-05-15 01:32:47 +02:00
< ? php
2014-07-04 11:21:31 +02:00
/* This software is governed by the CeCILL - B license . If a copy of this license
* is not distributed with this file , you can obtain one at
* http :// www . cecill . info / licences / Licence_CeCILL_V2 . 1 - en . txt
*
* Authors of STUdS ( initial project ) : Guilhem BORGHESI ( borghesi @ unistra . fr ) and Raphaël DROZ
* Authors of OpenSondage : Framasoft ( https :// github . com / framasoft )
*
* =============================
*
* Ce logiciel est régi par la licence CeCILL - B . Si une copie de cette licence
* ne se trouve pas avec ce fichier vous pouvez l ' obtenir sur
* http :// www . cecill . info / licences / Licence_CeCILL_V2 . 1 - fr . txt
*
* Auteurs de STUdS ( projet initial ) : Guilhem BORGHESI ( borghesi @ unistra . fr ) et Raphaël DROZ
* Auteurs d ' OpenSondage : Framasoft ( https :// github . com / framasoft )
*/
2011-05-15 01:32:47 +02:00
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-07-04 11:21:31 +02:00
print_header ( false , _ ( " Error! " ), '' , $lang );
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 " ;
2014-07-04 11:21:31 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
echo '<br /><br /><br /><br />' . " \n " ;
2011-05-15 03:56:54 +02:00
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 " ])) {
2014-07-04 11:21:31 +02:00
print_header ( true , '' , $lang );
2011-05-15 01:32:47 +02:00
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 " ;
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 " ;
2014-07-04 11:21:31 +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+ " ){
2014-07-04 11:21:31 +02:00
echo _ ( " Add a new column " ) . ' :<br /> <input type="text" name="nouvellecolonne" size="40" />' ;
echo '<p>' ;
echo '<button class="button red retour" type="submit" value="retoursondage" name="retoursondage_x"><strong>' . _ ( 'Back to the poll' ) . '</strong></button>' . " \n " ;
echo '<button type="submit" name="ajoutercolonne_x" class="button green poursuivre" ><strong>' . _ ( 'Add a column' ) . '</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
2014-07-04 11:21:31 +02:00
echo '<p>' . _ ( " You can add a new scheduling date to your poll. " ) . _ ( " If you just want to add a new hour to an existant date, put the same date and choose a new hour. " ) . '</p> ' . " \n " ;
echo '<p>' . _ ( " Add a date " ) . ' :<p>' . " \n " ;
echo '<p class="newday"><label for="nouveaujour">' . _ ( " Day " ) . '</label><br /><select name="nouveaujour" id="nouveaujour"> ' . " \n " ;
echo '<option value="vide"></option>' . " \n " ;
2011-05-15 03:56:54 +02:00
for ( $i = 1 ; $i < 32 ; $i ++ ){
2014-07-04 11:21:31 +02:00
echo '<option value="' . $i . '">' . $i . '</option>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
echo '</select></p>' . " \n " ;
2011-05-15 03:56:54 +02:00
2014-07-04 11:21:31 +02:00
echo '<p class="newmonth"><label for="nouveaumois">' . _ ( " Month " ) . '</label><br /><select name="nouveaumois" id="nouveaumois"> ' . " \n " ;
echo '<option value="vide"></option>' . " \n " ;
2011-05-22 02:13:44 +02:00
for ( $i = 1 ; $i < 13 ; $i ++ ) {
2014-07-04 11:21:31 +02:00
echo '<option value="' . $i . '">' . strftime ( '%B' , mktime ( 0 , 0 , 0 , $i )) . '</option>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
echo '</select></p>' . " \n " ;
2011-05-15 03:56:54 +02:00
2013-03-04 19:46:06 +01:00
2014-07-04 11:21:31 +02:00
echo '<p class="newyear"><label for="nouvelleannee">' . _ ( " Year " ) . '</label><br /><select name="nouvelleannee" id="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 ++ ) {
2014-07-04 11:21:31 +02:00
echo '<option value="' . $i . '">' . $i . '</option>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
echo '</select></p>' . " \n " ;
echo '<p class="clear-left">' . _ ( " Add a start hour (optional) " ) . ' : </p>' . " \n " ;
echo '<p class="newhour"><label for="nouvelleheuredebut">' . _ ( " Hour " ) . '</label><br /><select id="nouvelleheuredebut" name="nouvelleheuredebut"> ' . " \n " ;
echo '<option value="vide"></option>' . " \n " ;
2011-05-22 02:39:49 +02:00
for ( $i = 0 ; $i < 24 ; $i ++ ) {
2014-07-04 11:21:31 +02:00
echo '<option value="' . $i . '">' . $i . ' H</option>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
echo '</select></p>' . " \n " ;
echo '<p class="newmin"><label for="nouvelleminutedebut">' . _ ( " Min " ) . '</label><br /><select id="nouvelleminutedebut" 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></p>' . " \n " ;
echo '<p class="clear-left">' . _ ( " Add a end hour (optional) " ) . ' : </p>' . " \n " ;
echo '<p class="newhour"><label for="nouvelleheurefin">' . _ ( " Hour " ) . '</label><br /><select id="nouvelleheurefin" name="nouvelleheurefin"> ' . " \n " ;
echo '<option value="vide"></option>' . " \n " ;
2011-05-22 02:39:49 +02:00
for ( $i = 0 ; $i < 24 ; $i ++ ) {
2014-07-04 11:21:31 +02:00
echo '<option value="' . $i . '">' . $i . ' H</option>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
echo '</select></p>' . " \n " ;
echo '<p class="newmin"><label for="nouvelleminutefin">' . _ ( " Min " ) . '</label><br /><select id="nouvelleminutefin" 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></p>' . " \n " ;
echo '<p class="clear-left">' ;
echo '<button class="button red retour" type="submit" value="retoursondage" name="retoursondage_x"><strong>' . _ ( 'Back to the poll' ) . '</strong></button>' . " \n " ;
echo '<button type="submit" name="ajoutercolonne_x" class="button green poursuivre"><strong>' . _ ( 'Add a column' ) . '</strong></button></p>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
echo '</form>' . " \n " ;
2014-07-04 11:21:31 +02:00
echo '<br /><br /><br /><br />' . " \n " ;
2011-05-15 03:56:54 +02:00
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 " ])) {
2014-07-04 11:21:31 +02:00
print_header ( true , '' , $lang );
2011-07-03 00:10:13 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
echo " <h2> " . _ ( " Confirm removal of your poll " ) . " </h2><br /><br /> " . " \n " ;
2011-07-03 00:10:13 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
echo '<br /><br /><br /><br />' . " \n " ;
2011-07-03 00:10:13 +02:00
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
2014-07-04 11:21:31 +02:00
print_header ( false , '' , $lang );
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 ( _ ( " 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 " ;
2014-07-04 11:21:31 +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 " ;
2014-07-04 11:21:31 +02:00
echo '<br /><br /><br />' . " \n " ;
2011-05-22 02:13:44 +02:00
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
2014-07-04 11:21:31 +02:00
print_header ( true , '' , $lang );
2011-05-15 01:32:47 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
echo '<div class="imprimer"><p><a role="button" href="javascript:print()" class="button white medium">' . _ ( 'Print' ) . '</a></p>' ;
echo '<p><a role="button" class="button white medium" href="' . get_server_name () . 'exportcsv.php?numsondage=' . $numsondage . '">' . _ ( 'Export to CSV' ) . '</a></p></div>' ;
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 );
2014-07-04 11:21:31 +02:00
echo '<h2>' . $titre . '</h2>' . " \n " ;
2011-05-15 01:32:47 +02:00
//affichage du nom de l'auteur du sondage
2014-07-04 11:21:31 +02:00
echo '<div class="initiator"><p><span class="mlabel">' . _ ( " Initiator of the poll " ) . ' :</span><span class="nom"> ' . stripslashes ( $dsondage -> nom_admin ) . '</span></p></div>' . " \n " ;
echo '<div class="adress"><p><span class="mlabel">' . _ ( " Public link of the pool " ) . ' : </span><code>' . getUrlSondage ( $dsondage -> id_sondage ) . '</code></p></div>' . " \n " ;
echo '<div class="adress"><p><span class="mlabel">' . _ ( " Admin link of the pool " ) . ' : </span><code>' . getUrlSondage ( $dsondage -> id_sondage , true ) . '</code></p></div>' . " \n " ;
//affichage de la description du sondage
if ( $dsondage -> commentaires ) {
echo '<div class="admin_comment"><span class="mlabel">' . _ ( " Description: " ) . '</span><br />' . " \n " ;
$commentaires = $dsondage -> commentaires ;
$commentaires = nl2br ( str_replace ( " \\ " , " " , $commentaires ));
echo '<span class="mcontent">' . $commentaires . '</span>' ;
echo '</div>' . " \n " ;
2011-05-15 01:32:47 +02:00
}
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-07-04 11:21:31 +02:00
print_header ( false , _ ( " Error! " ), '' , $lang );
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 " ;
2014-07-04 11:21:31 +02:00
print " <h2> " . _ ( " This poll doesn't exist ! " ) . " </h2><br /><br /> " . " \n " ;
print " " . _ ( " Back to the homepage of " ) . " <a href= \" " . get_server_name () . " \" > " . NOMAPPLICATION . " </a>. " . " \n " ;
echo '<br /><br /><br /><br />' . " \n " ;
2011-05-22 02:13:44 +02:00
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 );
2014-07-04 11:21:31 +02:00
$toutsujet = str_replace ( " @ " , " <br /> " , $toutsujet );
2011-05-15 03:56:54 +02:00
$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 " ;
2014-07-04 11:21:31 +02:00
echo '<div class="cadre"><div class="information"><p> ' . " \n " ;
echo _ ( 'As poll administrator, you can change all the lines of this poll with this button ' ) . '<img src="' . get_server_name () . 'images/info.png" alt="' . _ ( 'Edit' ) . '" />.<br />' ;
echo _ ( 'You can, as well, remove a column or a line with ' ) . '<img src="' . get_server_name () . 'images/cancel.png" alt="' . _ ( 'Remove the column' ) . '" />.<br />' ;
echo _ ( 'You can also add a new column with ' ) . '<img src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add a colomn' ) . '" />.<br />' ;
echo _ ( 'Finally, you can change the informations of this poll like the title, the comments or your email address.' ) . " \n " ;
echo '</p></div>' . " \n " ;
2011-05-15 03:56:54 +02:00
//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-07-04 11:21:31 +02:00
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-07-04 11:21:31 +02:00
echo '<td class=somme><input type="image" name="effacecolonne' . $i . '" alt="' . _ ( 'Remove the column' ) . '" src="' . get_server_name () . 'images/cancel.png" /></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
echo '<td><input type="image" name="ajoutsujet" src="' . get_server_name () . 'images/add-16.png" alt="' . _ ( 'Add a column' ) . '" /></td></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-07-04 11:21:31 +02:00
echo '<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-07-04 11:21:31 +02:00
echo '<td></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-07-04 11:21:31 +02:00
echo '<td></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-07-04 11:21:31 +02:00
echo '<td></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-07-04 11:21:31 +02:00
echo '<td></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-07-04 11:21:31 +02:00
echo '<td><input type="image" name="effaceligne' . $compteur . '" src="' . get_server_name () . 'images/cancel.png" alt="' . _ ( 'Remove' ) . '" /></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 " ) {
2014-07-04 11:21:31 +02:00
echo '<td class="vide"><input type="checkbox" name="choix' . $j . '" value="" checked /></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
} else {
2014-07-04 11:21:31 +02:00
echo '<td class="vide"><input type="checkbox" name="choix' . $j . '" value="" /></td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
}
} 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-07-04 11:21:31 +02:00
echo '<td class=somme><input type="image" name="modifierligne' . $compteur . '" src="' . get_server_name () . 'images/info.png" alt="' . _ ( 'Edit' ) . '" /></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-07-04 11:21:31 +02:00
echo '<td><input type="image" name="validermodifier' . $compteur . '" src="' . get_server_name () . 'images/accept.png" alt="' . _ ( 'Validate' ) . '" /></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
}
2014-07-04 11:21:31 +02:00
if ( ! $testligneamodifier == " true " ) {
//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
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
echo '<td class="vide"><input type="checkbox" name="choix' . $i . '" value="" /></td>' . " \n " ;
}
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
echo '<td><input type="image" name="boutonp" src="' . get_server_name () . 'images/add-24.png" alt="' . _ ( 'Validate my choices' ) . '" /></td>' . " \n " ;
echo '</tr>' . " \n " ;
//focus en javascript sur le champ texte pour le nom d'utilisateur
echo '<script type="text/javascript">document.formulaire.nom.focus();</script>' . " \n " ;
2011-05-15 01:32:47 +02:00
2011-05-15 03:56:54 +02:00
}
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-07-04 11:21:31 +02:00
echo '<td class="somme"><img src="' . get_server_name () . 'images/medaille.png" alt="' . _ ( 'Best choice' ) . '" /></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 " ;
2014-07-04 11:21:31 +02:00
print '<td colspan=10><p class="error">' . _ ( " Enter a name ! " ) . " </p> \n " ;
2011-05-15 03:56:54 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
print '<td colspan=10><p class="error">' . _ ( " The name you've chosen already exist in this poll! " ) . " </p></td> \n " ;
2011-05-15 03:56:54 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
print '<td colspan=10><p class="error">' . _ ( " Characters \" ' < et > are not permitted " ) . " </p></td> \n " ;
2011-05-15 03:56:54 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
print '<td colspan=10><p class="error">' . _ ( " The date is not correct ! " ) . " </p></td> \n " ;
2011-05-15 03:56:54 +02:00
echo '</tr>' . " \n " ;
}
//fin du tableau
echo '</table>' . " \n " ;
echo '</div>' . " \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-07-04 11:21:31 +02:00
print " <img src= \" " . get_server_name () . " images/medaille.png \" alt= \" \" /> " . _ ( " 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-07-04 11:21:31 +02:00
print " <img src= \" " . get_server_name () . " images/medaille.png \" alt= \" \" /> " . _ ( " 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
}
2014-07-04 11:21:31 +02:00
echo '<br /><br />' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</p>' . " \n " ;
echo '</form>' . " \n " ;
echo '<form name="formulaire4" action="#bas" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
2014-07-04 11:21:31 +02:00
//Suppression du sondage
echo '<p class="affichageresultats"><input type="submit" id="suppressionsondage" name="suppressionsondage" value="' . _ ( " Remove the poll " ) . '" class="button red" /></p>' . " \n " ;
echo '<br />' . " \n " ;
2011-05-15 03:56:54 +02:00
//Gestion du sondage
2014-07-04 11:21:31 +02:00
echo '<div class="addcomment"><fieldset><legend>' . _ ( " Poll's management " ) . ' :</legend>' . " \n " ;
echo '<p>' . " \n " ;
echo '<br />' . " \n " ;
2011-05-15 03:56:54 +02:00
//Changer le titre du sondage
$adresseadmin = $dsondage -> mail_admin ;
2014-07-04 11:21:31 +02:00
echo '<label for="nouveautitre">' . _ ( " Poll title: " ) . '</label></p>' .
'<p><input type="text" title="' . _ ( " Change the title " ) . '" id="nouveautitre" name="nouveautitre" size="40" value="' . $dsondage -> titre . '" /></p>' .
'<p class="txt-right"><input type="submit" name="boutonnouveautitre" value="' . _ ( 'Save the new title' ) . '" class="button green medium" /></p>' . " \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' )) {
2014-07-04 11:21:31 +02:00
echo '<p class="error">' . _ ( " Enter a new title! " ) . '</p>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
//Changer l'adresse de l'administrateur
2014-07-04 11:21:31 +02:00
echo '<p><label for="nouvelleadresse">' . _ ( " Your e-mail address: " ) . '</label></p>' .
'<p><input type="text" title="' . _ ( " Change your email " ) . '" id="nouvelleadresse" name="nouvelleadresse" size="40" value="' . $dsondage -> mail_admin . '" /></p>' .
'<p class="txt-right"><input type="submit" name="boutonnouvelleadresse" value="' . _ ( 'Save your new email' ) . '" class="button green medium" /></p>' . " \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' )) {
2014-07-04 11:21:31 +02:00
echo '<p class="error">' . _ ( " Enter a new email address! " ) . '</p>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
2014-07-04 11:21:31 +02:00
//Changer la description du sondage
echo '<p><label for="nouveauxcommentaires">' . _ ( " Description: " ) . '</label></p>' .
'<p><textarea title="' . _ ( " Change the description " ) . '" id="nouveauxcommentaires" name="nouveauxcommentaires" rows="7" cols="40">' . stripslashes ( $dsondage -> commentaires ) . '</textarea></p>' .
'<p class="txt-right"><input type="submit" name="boutonnouveauxcommentaires" value="' . _ ( " Save the description " ) . '" class="button green medium" /></p>' . " \n " ;
echo '</fieldset></div>' . " \n " ;
2011-05-15 03:56:54 +02:00
//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 ) {
2014-07-04 11:21:31 +02:00
print " <br /><b> " . _ ( " Comments of polled people " ) . " :</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-07-04 11:21:31 +02:00
print " <div class= \" comment \" ><input type= \" image \" name= \" suppressioncomment $i\ " src = \ " " . get_server_name () . " images/cancel.png \" alt= \" " . _ ( 'Remove' ) . " \" /> " . '<span class="usercomment">' . stripslashes ( $dcomment -> usercomment ) . ' :</span> <span class="comment">' . stripslashes ( nl2br ( $dcomment -> comment )) . '</span></div>' ;
2011-05-15 03:56:54 +02:00
$i ++ ;
}
2013-03-04 19:46:06 +01:00
2014-07-04 11:21:31 +02:00
echo '<br />' ;
2011-05-15 03:56:54 +02:00
}
2011-05-22 02:13:44 +02:00
if ( isset ( $erreur_commentaire_vide ) && $erreur_commentaire_vide == " yes " ) {
2014-07-04 11:21:31 +02:00
print '<p class="error">' . _ ( " Enter a name and a comment! " ) . " </p> " ;
2011-05-15 03:56:54 +02:00
}
//affichage de la case permettant de rajouter un commentaire par les utilisateurs
2014-07-04 11:21:31 +02:00
print '<div class="addcomment">' . '<fieldset><legend>' . _ ( " Add a comment in the poll: " ) . '</legend>' . " \n " ;
echo '<p><label for="commentuser">' . _ ( " Name " ) . '</label> : <input type=text name="commentuser" id="commentuser" /></p>' . " \n " ;
echo '<p><label for="comment">' . _ ( " Your comment: " ) . '</label><br /><textarea title="' . _ ( " Write your comment " ) . '" name="comment" id="comment" rows="2" cols="40"></textarea></p>' . " \n " ;
echo '<p class="txt-center"><input type="submit" name="ajoutcomment" value="' . _ ( " Send your comment " ) . '" class="button green"></p>' . " \n " ;
echo '</fieldset></div></form>' . " \n " ;
echo '</div>' . " \n " ;
2011-05-22 02:13:44 +02:00
2014-07-04 11:21:31 +02:00
/* Lettre de convocation
2011-05-22 02:13:44 +02:00
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 " ;
2014-07-04 11:21:31 +02:00
echo _ ( " Generate the convocation letter (.PDF), choose the place to meet and validate " ) . '<br />' ;
2011-05-22 02:13:44 +02:00
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-07-04 11:21:31 +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 " ;
2014-07-04 11:21:31 +02:00
// '<font color="#FF0000">'. _("Enter a meeting place!") .'</font><br /><br />'."\n";
2011-05-22 02:13:44 +02:00
}
// TODO
if ( isset ( $_POST [ " exportpdf_x " ]) && ! issetAndNoEmpty ( 'lieureunion' )) {
2014-07-04 11:21:31 +02:00
echo '<font color="#FF0000">' . _ ( " Enter a meeting place! " ) . '</font><br /><br />' . " \n " ;
} */
2011-05-22 02:13:44 +02:00
2014-06-11 19:19:17 +02:00
echo '<a id="bas"></a>' . " \n " ;
2014-07-04 11:21:31 +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";
2014-07-04 11:21:31 +02:00
//echo '</div>';
2011-06-23 16:52:10 +02:00
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 " ;