From edc7e84bd9ebbe08dad92e0eb025e9a51f387759 Mon Sep 17 00:00:00 2001 From: FramaJosephK <josephk@framasoft.org> Date: Wed, 25 Feb 2015 20:58:04 +0100 Subject: [PATCH] =?UTF-8?q?Import=20des=20modifs=20effectu=C3=A9es=20en=20?= =?UTF-8?q?prod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG => CHANGELOG.md | 0 INSTALL | 186 ---------------- INSTALL.md | 163 ++++++++++++++ README.md | 268 +++++++++--------------- admin/index.php | 61 +++--- adminstuds.php | 361 +++++++++++++++----------------- app/classes/Framadate/Utils.php | 84 ++++---- app/inc/constants.php.template | 7 +- app/inc/init.php | 13 +- choix_date.php | 93 ++++---- composer.json | 8 +- composer.lock | 22 +- creation_sondage.php | 71 +++---- css/print.css | 28 ++- css/style.css | 41 ++-- studs.php | 107 +++++----- 16 files changed, 697 insertions(+), 816 deletions(-) rename CHANGELOG => CHANGELOG.md (100%) delete mode 100644 INSTALL create mode 100644 INSTALL.md diff --git a/CHANGELOG b/CHANGELOG.md similarity index 100% rename from CHANGELOG rename to CHANGELOG.md diff --git a/INSTALL b/INSTALL deleted file mode 100644 index e8d32d63..00000000 --- a/INSTALL +++ /dev/null @@ -1,186 +0,0 @@ -========================================================================== - -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 -de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA -sur le site "http://www.cecill.info". - -Le fait que vous puissiez accéder à cet en-tête signifie que vous avez -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 -abiding by the rules of distribution of free software. You can use, -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 -"http://www.cecill.info". - -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. - -========================================================================== - - -Paramètres -========== - -Le fichier app/inc/constants.php.template contient le paramétrage par défaut de -l'application Framadate. Pour personnaliser votre installation, copiez -ce fichier sous le nom app/inc/constants.php et modifiez ce dernier. - -Configuration du fichier php.ini -================================ - -Pour que les quotes simples soient acceptées dans la partie "Création de sondage", il faut que la variable magic_quotes_gpc soit activée ("On") dans le fichier php.ini. - - -Base de données -=============== - -STUdS fonctionne indépendemment de la base SQL utilisée, sous réserve que -le serveur dispose de l'extension ADOdb (http://sourceforge.net/projects/adodb) - -Cependant la base de donnée doit être créée au préalable. -Deux scripts le faisant sont fournis : -install.sql: pour postgresql -install.mysql.sql: pour mysql - -Pour postgresql : -Après avoir renseigné les paramètres de la base de données, créez la -base et pré-chargez les données par défaut. Ceci ressemble à : - -% su - pgsql -% createdb studs -% psql -d studs -f install.sql - -Attention : Si vous créez la base de données avec l'utilisateur "pgsql", il vous faudra faire un "grant all on <chaque table> to studs" pour donner les droits à l'utilisateur studs de lire et modifier la base. Les tables de l'applications sont décrites plus loin dans ce fichier dans la partie "Tables de la base de données". - - -Accès à la page administrateur -============================== - -Le répertoire admin/ contient un fichier .htaccess pour Apache, qui restreint l'accès -à la page d'administration de l'application. -Modifiez le contenu de ce fichier .htaccess pour l'adapter au chemin du fichier .htpasswd -sur votre serveur. -Le fichier .htpasswd à besoin d'être créé par vos soins en utilisant par exemple la commande -suivante : -htpasswd -mnb <admin_username> <admin_password> - -Un fichier admin/logs_studs.txt doit être créé et accessible en écriture -par votre serveur Web. Quelque chose comme : - -% touch admin/logs_studs.txt -% chmod 700 admin/logs_studs.txt -% chown www-data admin/logs_studs.txt - -devrait convenir. - -Maintenance -=========== -Studs dispose d'une possibilité de mise en maintenance par le biais -d'un fichier .htaccess. -La section <Directory> relative à Studs, dans la configuration d'Apache -doit au moins contenir : -AllowOverride AuthConfig Options -Le fichier .htaccess correspondant doit être modifier pour y configurer -l'adresse IP depuis laquelle s'effectue la maintenance. -N'oubliez pas de le recommenter en intégralité une fois la maintenance effectuée. - -Tables de la base de données -============================ - -Voici la structure des tables de l'application. La base se compose de trois tables : - -- sondage : Le contenu de chacun des sondages, -- sujet_studs : les sujets ou dates de tous les sondages, -- user_studs : les identifiants des sondés de tous les sondages. - -Chacune des tables contient les champs suivants : - -SONDAGE - - Nom du champ format description - - id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire - commentaires text commentaires liés au sondage - mail_admin text adresse de l'auteur du sondage - nom_admin text nom de l'auteur du sondage - titre text titre du sondage - id_sondage_admin alpha-numérique numéro du sondage pour le lien d'administration - date_fin alpha-numérique date de fin su sondage au format SQL - format text format du sondage : D/D+ pour Date, A/A+ pour Autre - mailsonde text envoi de mail a l'auteur du sondage a chaque participation ("yes" ou vide) - -SUJET_STUDS - - Nom du champ format description - - id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire - sujet text tous les sujets du sondage - -USER_STUDS - - Nom du champ format description - - user text nom du participant - id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire - reponses text reponses a chacun des sujets proposés au vote (0 pour non, 1 pour OK) - id_users alpha-numérique numéro d'utilisateur par ordre croissant de participation pour garder l'ordre de participation - -COMMENTS - Nom du champ format description - - id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire - comment text commentaires d'un participant - usercomment text nom de l'utilisateur qui laisse le commentaire - id_comment alpha-numérique numéro de commentaire par ordre croissant de participation pour garder l'ordre de remplissage - - -Traductions -=========== - -Pour pouvoir bénéficier de toutes les traductions en FR, EN, DE et ES -il faut avoir installé les locales fr_FR, de_DE, en_US et es_ES sur le -serveur qui héberge l'application ainsi que disposer de l'extension PHP Gettext. - -Export -====== - -Pour pouvoir bénéficier de l'export au format PDF, l'extension PHP PEAR -FPDF (php-fpdf) doit être installée. - -Synthèses des librairies utilisées -================================== - -ADOdb -http://sourceforge.net/projects/adodb -paquet: php5-adodb - -fpdf -http://www.fpdf.org -paquet: php-fpdf - -gettext -https://launchpad.net/php-gettext -paquet: php-gettext - -Sous GNU/Linux, -disposer des locales utf-8 suivantes pour la glibc: -FR, EN, ES, DE (/etc/locales.gen) diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 00000000..bfc96235 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,163 @@ +[](https://git.framasoft.org) + + **Framasoft uses GitLab** for the development of its free softwares. Our Github repositories are only mirrors. +If you want to work with us, **fork us on [git.framasoft.org](https://git.framasoft.org)**. (no registration needed, you can sign in with your Github account) + + **Framasoft utilise GitLab** pour le développement de ses logiciels libres. Nos dépôts Github ne sont que des mirroirs. +Si vous souhaitez travailler avec nous, **forkez-nous sur [git.framasoft.org](https://git.framasoft.org)**. (l'inscription n'est pas nécessaire, vous pouvez vous connecter avec votre compte Github) +* * * + + +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-B_V1-en.txt](http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) + +Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ +Authors of Framadate/OpenSondate: [Framasoft](https://git.framasoft.org/framasoft/framadate) + + +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-B_V1-fr.txt](http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt) + +Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ +Auteurs de Framadate/OpenSondage : [Framasoft](https://git.framasoft.org/framasoft/framadate) + +* * * + +#Avertissement +**Les instructions contenues ci-dessous dans ce fichier ne sont pas actualisées.** +Vous trouverez là : +=> **[le tutoriel d'installation complet](http://framacloud.org/cultiver-son-jardin/installation-de-framadate/)** +(en Français uniquement pour le moment) + +* * * + +##Paramètres + +Le fichier app/inc/constants.php.template contient le paramétrage par défaut de +l'application Framadate. Pour personnaliser votre installation, copiez +ce fichier sous le nom app/inc/constants.php et modifiez ce dernier. + +##Configuration du fichier php.ini + +Pour que les quotes simples soient acceptées dans la partie "Création de sondage", il faut que la variable magic_quotes_gpc soit activée ("On") dans le fichier php.ini. + +##Base de données + +STUdS fonctionne indépendemment de la base SQL utilisée, sous réserve que +le serveur dispose de l'extension [ADOdb](http://sourceforge.net/projects/adodb) + +Cependant la base de donnée doit être créée au préalable. +Deux scripts le faisant sont fournis : +install.sql: pour postgresql +install.mysql.sql: pour mysql + +Pour postgresql : +Après avoir renseigné les paramètres de la base de données, créez la +base et pré-chargez les données par défaut. Ceci ressemble à : + + % su - pgsql + % createdb studs + % psql -d studs -f install.sql + +Attention : Si vous créez la base de données avec l'utilisateur "pgsql", il vous faudra faire un "grant all on <chaque table> to studs" pour donner les droits à l'utilisateur studs de lire et modifier la base. Les tables de l'applications sont décrites plus loin dans ce fichier dans la partie "Tables de la base de données". + + +##Accès à la page administrateur + +Le répertoire admin/ contient un fichier .htaccess pour Apache, qui restreint l'accès +à la page d'administration de l'application. +Modifiez le contenu de ce fichier .htaccess pour l'adapter au chemin du fichier .htpasswd +sur votre serveur. +Le fichier .htpasswd à besoin d'être créé par vos soins en utilisant par exemple la commande +suivante : +`htpasswd -mnb <admin_username> <admin_password>` + +Un fichier `admin/logs_studs.txt` doit être créé et accessible en écriture +par votre serveur Web. Quelque chose comme : + + % touch admin/logs_studs.txt + % chmod 700 admin/logs_studs.txt + % chown www-data admin/logs_studs.txt + +devrait convenir. + +##Maintenance + +Studs dispose d'une possibilité de mise en maintenance par le biais +d'un fichier .htaccess. +La section `<Directory>` relative à Studs, dans la configuration d'Apache +doit au moins contenir : +`AllowOverride AuthConfig Options` +Le fichier .htaccess correspondant doit être modifier pour y configurer +l'adresse IP depuis laquelle s'effectue la maintenance. +N'oubliez pas de le recommenter en intégralité une fois la maintenance effectuée. + +##Tables de la base de données + +Voici la structure des tables de l'application. La base se compose de trois tables : + +- sondage : Le contenu de chacun des sondages, +- sujet_studs : les sujets ou dates de tous les sondages, +- user_studs : les identifiants des sondés de tous les sondages. + +Chacune des tables contient les champs suivants : + +SONDAGE + + Nom du champ format description + + id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire + commentaires text commentaires liés au sondage + mail_admin text adresse de l'auteur du sondage + nom_admin text nom de l'auteur du sondage + titre text titre du sondage + id_sondage_admin alpha-numérique numéro du sondage pour le lien d'administration + date_fin alpha-numérique date de fin su sondage au format SQL + format text format du sondage : D/D+ pour Date, A/A+ pour Autre + mailsonde text envoi de mail a l'auteur du sondage a chaque participation ("yes" ou vide) + +SUJET_STUDS + + Nom du champ format description + + id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire + sujet text tous les sujets du sondage + +USER_STUDS + + Nom du champ format description + + user text nom du participant + id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire + reponses text reponses a chacun des sujets proposés au vote (0 pour non, 1 pour OK) + id_users alpha-numérique numéro d'utilisateur par ordre croissant de participation pour garder l'ordre de participation + +COMMENTS + + Nom du champ format description + + id_sondage (clé primaire) alpha-numérique numéro du sondage aléatoire + comment text commentaires d'un participant + usercomment text nom de l'utilisateur qui laisse le commentaire + id_comment alpha-numérique numéro de commentaire par ordre croissant de participation pour garder l'ordre de remplissage + + +##Traductions + +Pour pouvoir bénéficier de toutes les traductions en FR, EN, DE et ES +il faut avoir installé les locales fr_FR, de_DE, en_US et es_ES sur le +serveur qui héberge l'application ainsi que disposer de l'extension PHP Gettext. + +##Synthèses des librairies utilisées + +[ADOdb](http://sourceforge.net/projects/adodb), +paquet: php5-adodb + +[gettext](https://launchpad.net/php-gettext), +paquet: php-gettext + +Sous GNU/Linux, +disposer des locales utf-8 suivantes pour la glibc: +FR, EN, ES, DE (/etc/locales.gen) diff --git a/README.md b/README.md index 798b3de5..87f39037 100644 --- a/README.md +++ b/README.md @@ -1,185 +1,109 @@ -[](https://git.framasoft.org) - - **Framasoft uses GitLab** for the development of its free softwares. Our Github repositories are only mirrors. -If you want to work with us, **fork us on [git.framasoft.org](https://git.framasoft.org)**. (no registration needed, you can sign in with your Github account) - - **Framasoft utilise GitLab** pour le développement de ses logiciels libres. Nos dépôts Github ne sont que des mirroirs. -Si vous souhaitez travailler avec nous, **forkez-nous sur [git.framasoft.org](https://git.framasoft.org)**. (l'inscription n'est pas nécessaire, vous pouvez vous connecter avec votre compte Github) -* * * - -Framadate est un fork du projet STUdS : https://sourcesup.cru.fr/projects/studs/ - -Framadate est le projet qui motorise framadate.org pour framasoft.org - -Les auteurs principaux de Framadate sont : -- Simon LEBLANC -- Pierre-Yves GOSSET - -Les auteurs principaux du projet STUdS sont : -- Guilhem BORGHESI -- Raphaël DROZ - - -========================================================================== - -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 -de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA -sur le site "http://www.cecill.info". - -Le fait que vous puissiez accéder à cet en-tête signifie que vous avez -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 -abiding by the rules of distribution of free software. You can use, -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 -"http://www.cecill.info". - -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. - -========================================================================== - -============================================================================= -Fichiers de l'application -============================================================================= - -index.php - La page d'accueil de STUdS -studs.php - La page de présentation de sondage -adminstuds.php - La page d'administration réservée à l'auteur du sondage -infos_sondage.php - La page (1/2) de création de sondage récupérant les informations générales -choix_date.php - La page de création (2/2) pour un sondage pour déterminer une date -choix_autre.php - La page de création (2/2) pour un sondage sur un sujet quelconque -creation_sondage.php - Le fichier qui récupérent les informations des pages précédentes pour procéder à l'insertion du nouveau sondage dans la base PostgreSQL -style.css - Le fichier CSS de style pour toute l'application -app/inc/constants.php - Le fichier contenant les constantes à changer en fonction de la machine locale -app/inc/functions.php - Le fichier contenant quelques fonctions récurrentes de l'application -app/inc/i18n.php - Le fichier contenant quelques fonctions récurrentes de l'application relatives à l'internationalisation -README - Ce fichier -INSTALL - Le fichier contenant les informations d'installation sur l'application -CHANGELOG - Le fichier contenant toutes les modifications de l'application entre les différentes versions -contacts.php - La page permettant aux usagers de poser une question à l'administrateur de l'application -apropos.php - La page expliquant les détails techniques relatifs à l'application et les dernieres modifications et celles à venir sur l'application -bandeaux.php - Le fichier contenant tous les bandeaux des pages PHP de l'application -favicon.ico - L'icone de favoris de l'application -sources.php - La page qui propose les sources de l'application -exportics.php - Le fichier d'export de la meilleure date au format iCAL (fichier .ICS) -exportcsv.php - Le fichier d'export de tous le tableau des participants avec leurs réponses dans un tableur (format .CSV) -exportpdf.php - Le fichier d'export de la lettre de convocation que le créateur du sondage pourra envoyer aux participants (format .PDF) - -admin/ - Le répertoire réservé à l'administrateur de l'application -admin/.htaccess - Le fichier gérant les droits restreints du répertoire ADMIN -admin/.htpasswd - Le fichier contenant les passwd des logins ayant accès au répertoire ADMIN -admin/index.php - La page présentant tous les sondages actuellement dans la base à l'administrateur -admin/log_studs.txt - Le fichier contenant un historique de toutes les creations/suppressions de sondage dans la base - -errors/ - Le répertoire contenant toutes les pages d'erreurs -errors/error-forbidden.php - La page qui indique dans la charte graphique de l'application l'erreur "501 forbidden" -errors/maintenance.php - La page qui indique que l'application est en maintenance temporaire - -export/ - Le répertoire qui contient tous les exports ICS - -iCalcreator/ - Le répertoire qui contient les librairies d'export en iCal - -php2pdf/ - Le répertoire qui contient les librairies d'export en PDF - -scripts/ - Le répertoire qui contient tous les scripts de l'application - -sources/ - Le répertoire qui contient les sources de l'application disponible sur la page sources.php - -locale/ + +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-B_V1-en.txt](http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt) + +Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ +Authors of Framadate/OpenSondate: [Framasoft](https://git.framasoft.org/framasoft/framadate) + + +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-B_V1-fr.txt](http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt) + +Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ +Auteurs de Framadate/OpenSondage : [Framasoft](https://git.framasoft.org/framasoft/framadate) + +* * * + +#Framadate +[Framadate](https://framadate.org) est un fork du projet [STUdS](https://sourcesup.cru.fr/projects/studs/). +Il est développé par l'association [Framasoft](http://framasoft.org). + +##Fichiers de l'application + +### Administration +* `/admin` + Le répertoire réservé à l'administrateur de l'application +* `admin/index.php` + La page présentant tous les sondages actuellement dans la base à l'administrateur +* `admin/log_studs.txt` + Le fichier contenant un historique de toutes les creations/suppressions de sondage dans la base + +* `install/` (pas utilisé - en développement) + Le répertoire qui contient les scripts chargés de simplifier la procédure d'installation +* `scripts/` (pas utilisé) + Le répertoire qui contient quelques vieux scripts pour la maintenance de l'application + +### Application +* `app/inc/constants.php.template` + Le fichier contenant les constantes à changer en fonction de la machine locale +* `app/classes/Framadate/Utils.php` + Le fichier contenant quelques fonctions récurrentes de l'application +* `app/inc/i18n.php` + Le fichier contenant quelques fonctions récurrentes de l'application relatives à l'internationalisation +* `app/inc/init.php` + Le fichier qui charge les dépendances et ouvre la connexion à la base de données + +* `css/` + Les fichiers CSS de l'application (dont ceux de Bootstrap) +* `fonts/` + Les fichiers des icônes de Bootstrap +* `images/` + Logo et images de la page d'accueil +* `js/` + Les fichiers javascript de l'application (dont ceux de Bootstrap et de jQuery) + +* `locale/` Le répertoire qui contient les fichiers de traduction modifiables (.po) et compilés (.mo) au format gettext -============================================================================= - Validations des pages -============================================================================= - -Toutes les pages de STUdS sont validées HTML 4.01 Strict. -La CSS de STUdS est validée CSS 2.1. - -============================================================================= -Technologies utilisées -============================================================================= +* `index.php` + La page d'accueil de STUdS +* `studs.php` + La page de présentation de sondage +* `adminstuds.php` + La page d'administration réservée à l'auteur du sondage +* `infos_sondage.php` + La page (1/2) de création de sondage récupérant les informations générales +* `choix_date.php` + La page de création (2/2) pour un sondage pour déterminer une date +* `choix_autre.php` + La page de création (2/2) pour un sondage sur un sujet quelconque +* `creation_sondage.php` + Le fichier qui récupérent les informations des pages précédentes pour procéder à l'insertion du nouveau sondage dans la base PostgreSQL -- PHP 5.4.4, php-fpdf, php-adodb, php-gettext -- PostgreSQL, mysql -- Apache -- iCalcreator +* `bandeaux.php` + Le fichier contenant les éléments de l'entête et du pied de page de l'application +* `exportcsv.php` + Le fichier d'export de tous le tableau des participants avec leurs réponses dans un tableur (format .CSV) +* `favicon.ico` + L'icone de favoris de l'application + +### Infos +* `AUTHORS.md` + Liste des principaux développeurs du logiciel +* `README.md` + Ce fichier +* `INSTALL.md` + Le fichier contenant les informations d'installation sur l'application +* `CHANGELOG.md` + Le fichier contenant la liste des principale modifications de l'application entre les différentes versions + +##Technologies utilisées + +- PHP 5.4.4, php-adodb, php-gettext, composer +- Bootstrap, jQuery, Bootstrap Datepicker +- MySQL +- Nginx, Apache - POedit -- Icônes : Deleket (http://deleket.deviantart.com/) et DryIcons (http://dryicons.com) -============================================================================= -Compatibilités des navigateurs -Dernière mise à jour le 21 avril 2014 -============================================================================= +##Compatibilités des navigateurs +(Dernière mise à jour le 21 avril 2014) - Firefox : Ubuntu 13.10/FF28 - Chrome : Ubuntu 13.10/Chromium33 - Opera (non testé) - Konqueror -- Links (non testé, inutile) - Safari (non testé) - IE : Win7/IE9 - ------------------ -Janvier 2008 -Guilhem BORGHESI -Université de Strasbourg - -Mai 2010 -Raphaël DROZ, raphael.droz@gmail.com - diff --git a/admin/index.php b/admin/index.php index 7cba06d8..bb3078b5 100644 --- a/admin/index.php +++ b/admin/index.php @@ -27,10 +27,10 @@ include_once __DIR__ . '/../bandeaux.php'; // de l'application. // Affichage des balises standards -Utils::print_header( _('Polls administrator') ); -bandeau_titre(_('Polls administrator')); +Utils::print_header( _("Polls administrator") ); +bandeau_titre(_("Polls administrator")); -$sondage=$connect->Execute('SELECT * FROM sondage'); +$sondage=$connect->Execute("select * from sondage"); echo' <form action="' . Utils::get_server_name() . 'admin/index.php" method="POST">'."\n"; @@ -40,15 +40,15 @@ while($dsondage = $sondage->FetchNextObject(false)) { echo ' <div class="alert alert-warning text-center"> <h3>'. _("Confirm removal of the poll ") .'"'.$dsondage->id_sondage.'</h3> - <p><button class="btn btn-default" type="submit" value="1" name="annullesuppression">'._('Keep this poll!').'</button> - <button type="submit" name="confirmesuppression'.$dsondage->id_sondage.'" value="1" class="btn btn-danger">'._('Remove this poll!').'</button></p> + <p><button class="btn btn-default" type="submit" value="1" name="annullesuppression">'._("Keep this poll!").'</button> + <button type="submit" name="confirmesuppression'.$dsondage->id_sondage.'" value="1" class="btn btn-danger">'._("Remove this poll!").'</button></p> </div>'; } // Traitement de la confirmation de suppression if (Utils::issetAndNoEmpty('confirmesuppression'.$dsondage->id_sondage) === true) { // On inclut la routine de suppression - $date = date('H:i:s d/m/Y'); + $date=date('H:i:s d/m/Y'); if (Utils::remove_sondage($connect, $dsondage->id_sondage)) { // ecriture des traces dans le fichier de logs @@ -57,7 +57,7 @@ while($dsondage = $sondage->FetchNextObject(false)) { } } -$sondage=$connect->Execute('SELECT * FROM sondage WHERE date_fin > DATE_SUB(now(), INTERVAL 3 MONTH) ORDER BY date_fin ASC'); +$sondage=$connect->Execute("select * from sondage WHERE date_fin > DATE_SUB(now(), INTERVAL 3 MONTH) ORDER BY date_fin ASC"); $nbsondages=$sondage->RecordCount(); $btn_logs = (is_readable('logs_studs.txt')) ? '<a role="button" class="btn btn-default btn-xs pull-right" href="'.str_replace('/admin','', Utils::get_server_name()).'admin/logs_studs.txt">'. _("Logs") .'</a>' : ''; @@ -67,24 +67,24 @@ echo '<p>' . $nbsondages. ' ' . _("polls in the database at this time") . $btn_l // tableau qui affiche tous les sondages de la base echo '<table class="table table-bordered"> <tr align="center"> - <th scope="col">'. _('Poll ID') .'</th> - <th scope="col">'. _('Format') .'</th> - <th scope="col">'. _('Title') .'</th> - <th scope="col">'. _('Author') .'</th> - <th scope="col">'. _('Email') .'</th> - <th scope="col">'. _('Expiration\'s date') .'</th> - <th scope="col">'. _('Users') .'</th> - <th scope="col" colspan="3">'. _('Actions') .'</th> + <th scope="col">'. _("Poll ID") .'</th> + <th scope="col">'. _("Format") .'</th> + <th scope="col">'. _("Title") .'</th> + <th scope="col">'. _("Author") .'</th> + <th scope="col">'. _("Email") .'</th> + <th scope="col">'. _("Expiration's date") .'</th> + <th scope="col">'. _("Users") .'</th> + <th scope="col" colspan="3">'. _("Actions") .'</th> </tr>'."\n"; $i = 0; while($dsondage = $sondage->FetchNextObject(false)) { /* possible en 1 bonne requête dans $sondage */ - $subjects = $connect->Execute("SELECT * FROM sujet_studs WHERE id_sondage='$dsondage->id_sondage'"); - $dsujets = $subjects->FetchObject(false); + $sujets=$connect->Execute( "select * from sujet_studs where id_sondage='$dsondage->id_sondage'"); + $dsujets=$sujets->FetchObject(false); - $user_studs = $connect->Execute("SELECT * from user_studs WHERE id_sondage='$dsondage->id_sondage'"); - $nb_users = $user_studs->RecordCount(); + $user_studs=$connect->Execute( "select * from user_studs where id_sondage='$dsondage->id_sondage'"); + $nbuser=$user_studs->RecordCount(); echo ' <tr align="center"> @@ -95,19 +95,19 @@ while($dsondage = $sondage->FetchNextObject(false)) { <td>'.stripslashes($dsondage->mail_admin).'</td>'; if (strtotime($dsondage->date_fin) > time()) { - echo '<td>'.date('d/m/y', strtotime($dsondage->date_fin)).'</td>'; + echo ' + <td>'.date("d/m/y",strtotime($dsondage->date_fin)).'</td>'; } else { - echo '<td><span class="text-danger">' - . date('d/m/y', strtotime($dsondage->date_fin)) - . '</span></td>'; + echo ' + <td><span class="text-danger">'.date("d/m/y",strtotime($dsondage->date_fin)).'</span></td>'; } echo ' - <td>'.$nb_users.'</td> - <td><a href="' . Utils::getUrlSondage($dsondage->id_sondage) . '" class="btn btn-link" title="'. _('See the poll') .'"><span class="glyphicon glyphicon-eye-open"></span><span class="sr-only">' . _('See the poll') . '</span></a></td> - <td><a href="' . Utils::getUrlSondage($dsondage->id_sondage_admin, true) . '" class="btn btn-link" title="'. _('Change the poll') .'"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _("Change the poll") . '</span></a></td> - <td><button type="submit" name="supprimersondage'.$dsondage->id_sondage.'" value="'. _('Remove the poll') .'" class="btn btn-link" title="'. _("Remove the poll") .'"><span class="glyphicon glyphicon-trash text-danger"></span><span class="sr-only">' . _('Remove the poll') . '</span></td> + <td>'.$nbuser.'</td> + <td><a href="' . Utils::getUrlSondage($dsondage->id_sondage) . '" class="btn btn-link" title="'. _("See the poll") .'"><span class="glyphicon glyphicon-eye-open"></span><span class="sr-only">' . _("See the poll") . '</span></a></td> + <td><a href="' . Utils::getUrlSondage($dsondage->id_sondage_admin, true) . '" class="btn btn-link" title="'. _("Change the poll") .'"><span class="glyphicon glyphicon-pencil"></span><span class="sr-only">' . _("Change the poll") . '</span></a></td> + <td><button type="submit" name="supprimersondage'.$dsondage->id_sondage.'" value="'. _("Remove the poll") .'" class="btn btn-link" title="'. _("Remove the poll") .'"><span class="glyphicon glyphicon-trash text-danger"></span><span class="sr-only">' . _("Remove the poll") . '</span></td> </tr>'."\n"; - ++$i; + $i++; } echo '</table></form>'."\n"; @@ -115,6 +115,5 @@ echo '</table></form>'."\n"; bandeau_pied(true); // si on annule la suppression, rafraichissement de la page -/*if (Utils::issetAndNoEmpty('annulesuppression') === true) { - // TODO -}*/ +if (Utils::issetAndNoEmpty('annulesuppression') === true) { +} diff --git a/adminstuds.php b/adminstuds.php index 724e15c2..56c159dd 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -29,51 +29,15 @@ if (file_exists('bandeaux_local.php')) { include_once('bandeaux.php'); } -function getChoicesFromPOST($nbColumns) -{ - $choices = array(); - for ($i=0; $i < $nbColumns; ++$i) { - // radio checked 1 = Yes, 2 = Ifneedbe, 0 = No - if (isset($_POST['choix'. $i])) { - $choices[] = $_POST['choix'. $i]; - } - } - return $choices; -} - -function getNewChoiceFromChoices($choices) -{ - if(!is_array($choice)) { - /* throw new Exception('$choices must be a an array'); - PHP Fatal error: Class 'Framadate\Exception' not found */ - } - - $newChoice = ''; - foreach ($choices as $choice) { - // radio checked 1 = Yes, 2 = Ifneedbe, 0 = No - switch ($choice) { - case 1: $newChoice .= '1'; break; - case 2: $newChoice .= '2'; break; - default: $newChoice .= '0'; - } - } - return $newChoice; -} - -function getNewChoiceFromPOST($nbColumns) -{ - return getNewChoiceFromChoices(getChoicesFromPOST($nbColumns)); -} - // Initialisation des variables $numsondageadmin = false; $sondage = false; // recuperation du numero de sondage admin (24 car.) dans l'URL if (Utils::issetAndNoEmpty('sondage', $_GET) && is_string($_GET['sondage']) && strlen($_GET['sondage']) === 24) { - $numsondageadmin = $_GET['sondage']; + $numsondageadmin=$_GET["sondage"]; //on découpe le résultat pour avoir le numéro de sondage (16 car.) - $numsondage = substr($numsondageadmin, 0, 16); + $numsondage=substr($numsondageadmin, 0, 16); } if (preg_match(";[\w\d]{24};i", $numsondageadmin)) { @@ -86,7 +50,7 @@ if (preg_match(";[\w\d]{24};i", $numsondageadmin)) { $sql = $connect->Prepare($sql); $sujets = $connect->Execute($sql, array($numsondage)); - $sql = 'SELECT * FROM user_studs WHERE id_sondage = '.$connect->Param('numsondage').' ORDER BY id_users'; + $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)); } @@ -121,22 +85,22 @@ function send_mail_admin() { global $poll_title; global $numsondageadmin; global $smtp_allowed; - if($smtp_allowed == true) { - if(!isset($_SESSION['mail_admin_sent'])) { + if($smtp_allowed==true){ + if(!isset($_SESSION["mail_admin_sent"])) { Utils::sendEmail( $email_admin, _("[ADMINISTRATOR] New settings for your poll") . ' ' . stripslashes( $poll_title ), - _('You have changed the settings of your poll. \nYou can modify this poll with this link') . + _("You have changed the settings of your poll. \nYou can modify this poll with this link") . " :\n\n" . Utils::getUrlSondage($numsondageadmin, true) . "\n\n" . - _('Thanks for your confidence.') . "\n" . NOMAPPLICATION + _("Thanks for your confidence.") . "\n" . NOMAPPLICATION ); - $_SESSION['mail_admin_sent']=true; + $_SESSION["mail_admin_sent"]=true; } } } //si la valeur du nouveau titre est valide et que le bouton est activé -if (isset($_POST['boutonnouveautitre'])) { +if (isset($_POST["boutonnouveautitre"])) { if (Utils::issetAndNoEmpty('nouveautitre') === false) { $err |= TITLE_EMPTY; } else { @@ -191,9 +155,12 @@ if (isset($_POST["boutonnouvelleadresse"])) { //New poll rules if (isset($_POST["btn_poll_rules"])) { echo '<!-- '; print_r($_POST); echo ' -->'; - $new_poll_rules = substr($dsondage->format, 0, 1); - if($_POST['poll_rules'] == '+' || $_POST['poll_rules'] == '-') { - $new_poll_rules .= $_POST['poll_rules']; + if($_POST['poll_rules'] == '+') { + $new_poll_rules = substr($dsondage->format, 0, 1).'+'; + } elseif($_POST['poll_rules'] == '-') { + $new_poll_rules = substr($dsondage->format, 0, 1).'-'; + } else { + $new_poll_rules = substr($dsondage->format, 0, 1); } //Update SQL database with new rules @@ -210,10 +177,10 @@ if (isset($_POST["btn_poll_rules"])) { $dsujet=$sujets->FetchObject(false); $dsondage=$sondage->FetchObject(false); -if (isset($_POST['ajoutsujet'])) { - Utils::print_header( _('Add a column') .' - ' . stripslashes( $dsondage->titre )); +if (isset($_POST["ajoutsujet"])) { + Utils::print_header( _("Add a column") .' - ' . stripslashes( $dsondage->titre )); - bandeau_titre(_('Make your polls')); + bandeau_titre(_("Make your polls")); //on recupere les données et les sujets du sondage @@ -234,14 +201,14 @@ if (isset($_POST['ajoutsujet'])) { } else { //ajout d'une date avec creneau horaire echo ' - <p>'. _('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.') .'</p> + <p>'. _("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.") .'</p> <div class="form-group"> <label for="newdate" class="col-md-4">'. _("Day") .'</label> <div class="col-md-8"> <div class="input-group date"> <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span> - <input type="text" id="newdate" data-date-format="'. _('dd/mm/yyyy') .'" aria-describedby="dateformat" name="newdate" class="form-control" placeholder="'. _("dd/mm/yyyy") .'" /> + <input type="text" id="newdate" data-date-format="'. _("dd/mm/yyyy") .'" aria-describedby="dateformat" name="newdate" class="form-control" placeholder="'. _("dd/mm/yyyy") .'" /> </div> <span id="dateformat" class="sr-only">'. _("(dd/mm/yyyy)") .'</span> </div> @@ -276,8 +243,8 @@ if (isset($_POST["suppressionsondage"])) { <form name="formulaire" action="' . Utils::getUrlSondage($numsondageadmin, true) . '" method="POST"> <div class="alert alert-warning text-center"> <h2>' . _("Confirm removal of your poll") . '</h2> - <p><button class="btn btn-default" type="submit" value="" name="annullesuppression">'._('Keep this poll!').'</button> - <button type="submit" name="confirmesuppression" value="" class="btn btn-danger">'._('Remove this poll!').'</button></p> + <p><button class="btn btn-default" type="submit" value="" name="annullesuppression">'._("Keep this poll!").'</button> + <button type="submit" name="confirmesuppression" value="" class="btn btn-danger">'._("Remove this poll!").'</button></p> </div> </form>'; @@ -314,11 +281,11 @@ if (isset($_POST["confirmesuppression"])) { //affichage de l'ecran de confirmation de suppression de sondage Utils::print_header(_("Your poll has been removed!")); - bandeau_titre(_('Make your polls')); + bandeau_titre(_("Make your polls")); echo ' <div class="alert alert-success text-center"> - <h2>' . _('Your poll has been removed!') . '</h2> + <h2>' . _("Your poll has been removed!") . '</h2> <p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p> </div> </form>'."\n"; @@ -353,7 +320,7 @@ if (isset($_POST['ajoutcomment'])) { while ( $dcomment_user_doublon=$comment_user_doublon->FetchNextObject(false)) { if($dcomment_user_doublon->comment == $comment && $dcomment_user_doublon->usercomment == $comment_user) { $comment_doublon = true; - } + }; } } @@ -375,20 +342,31 @@ if (isset($_POST['ajoutcomment'])) { $nbcolonnes = substr_count($dsujet->sujet, ',') + 1; $nblignes = $user_studs->RecordCount(); -//s'il n'y a pas suppression alors on peut afficher normalement le tableau +//si il n'y a pas suppression alors on peut afficher normalement le tableau //action si le bouton participer est cliqué if (isset($_POST["boutonp"])) { //si on a un nom dans la case texte if (Utils::issetAndNoEmpty('nom')){ - $nouveauchoix = getNewChoiceFromPOST($nbcolonnes); + $nouveauchoix = ''; $erreur_prenom = false; - $nom = htmlentities(html_entity_decode($_POST['nom'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'); + for ($i=0;$i<$nbcolonnes;$i++){ + // radio checked 1 = Yes, 2 = Ifneedbe, 0 = No + if (isset($_POST["choix$i"])) { + switch ($_POST["choix$i"]) { + case 1: $nouveauchoix .= "1";break; + case 2: $nouveauchoix .= "2";break; + default: $nouveauchoix .= "0";break; + } + } + } + + $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) { - $erreur_prenom = 'yes'; + if ($nom == $user->nom){ + $erreur_prenom="yes"; } } @@ -407,12 +385,12 @@ if (isset($_POST["boutonp"])) { //action quand on ajoute une colonne au format AUTRE -if (isset($_POST['ajoutercolonne']) && Utils::issetAndNoEmpty('nouvellecolonne') && (substr($dsondage->format, 0, 1) == 'A' )) { +if (isset($_POST["ajoutercolonne"]) && Utils::issetAndNoEmpty('nouvellecolonne') && (substr($dsondage->format, 0, 1) == "A" )) { $nouveauxsujets=$dsujet->sujet; //on rajoute la valeur a la fin de tous les sujets deja entrés - $nouveauxsujets .= ','; - $nouveauxsujets .= str_replace(',', ' ', $_POST['nouvellecolonne']); + $nouveauxsujets.=","; + $nouveauxsujets.=str_replace(","," ",$_POST["nouvellecolonne"]); $nouveauxsujets = htmlentities(html_entity_decode($nouveauxsujets, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'); //mise a jour avec les nouveaux sujets dans la base @@ -425,18 +403,19 @@ if (isset($_POST['ajoutercolonne']) && Utils::issetAndNoEmpty('nouvellecolonne') //action quand on ajoute une colonne au format DATE -if (isset($_POST['ajoutercolonne']) && (substr($dsondage->format, 0, 1) == 'D')) { +if (isset($_POST["ajoutercolonne"]) && (substr($dsondage->format, 0, 1) == "D")) { $nouveauxsujets=$dsujet->sujet; - if (isset($_POST['newdate']) && $_POST['newdate'] != 'vide') { - $nouvelledate = mktime(0, 0, 0, substr($_POST['newdate'],3,2), substr($_POST['newdate'],0,2), substr($_POST['newdate'],6,4)); + if (isset($_POST["newdate"]) && $_POST["newdate"] != "vide") { + $nouvelledate=mktime(0, 0, 0, substr($_POST["newdate"],3,2), substr($_POST["newdate"],0,2), substr($_POST["newdate"],6,4)); - if (isset($_POST['newhour']) && $_POST['newhour'] != 'vide') { - $nouvelledate .= '@' . $_POST['newhour']; + if (isset($_POST["newhour"]) && $_POST["newhour"]!="vide"){ + $nouvelledate.="@"; + $nouvelledate.=$_POST["newhour"]; } //on rajoute la valeur dans les valeurs - $datesbase = explode(',', $dsujet->sujet); + $datesbase = explode(",",$dsujet->sujet); $taillebase = sizeof($datesbase); //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau @@ -445,7 +424,7 @@ if (isset($_POST['ajoutercolonne']) && (substr($dsondage->format, 0, 1) == 'D')) } elseif ($nouvelledate > $datesbase[$taillebase-1]) { $cleinsertion = count($datesbase); } else { - for ($i = 0; $i < count($datesbase); ++$i) { + for ($i = 0; $i < count($datesbase); $i++) { $j = $i + 1; if ($nouvelledate > $datesbase[$i] && $nouvelledate < $datesbase[$j]) { $cleinsertion = $j; @@ -456,11 +435,12 @@ if (isset($_POST['ajoutercolonne']) && (substr($dsondage->format, 0, 1) == 'D')) array_splice($datesbase, $cleinsertion, 0, $nouvelledate); $cle = array_search($nouvelledate, $datesbase); $dateinsertion = ''; - for ($i = 0; $i < count($datesbase); ++$i) { - $dateinsertion .= ',' . $datesbase[$i]; + for ($i = 0; $i < count($datesbase); $i++) { + $dateinsertion.=","; + $dateinsertion.=$datesbase[$i]; } - $dateinsertion = substr($dateinsertion, 1); + $dateinsertion = substr("$dateinsertion", 1); //mise a jour avec les nouveaux sujets dans la base //if (isset($erreur_ajout_date) && !$erreur_ajout_date){ @@ -484,19 +464,19 @@ if (isset($_POST['ajoutercolonne']) && (substr($dsondage->format, 0, 1) == 'D')) $newcar = ''; //parcours de toutes les réponses actuelles - for ($j = 0; $j < $nbcolonnes; ++$j) { - $car = substr($ensemblereponses,$j,1); + for ($j = 0; $j < $nbcolonnes; $j++) { + $car=substr($ensemblereponses,$j,1); //si les reponses ne concerne pas la colonne ajoutée, on concatene - if ($j == $cle) { - $newcar.='0'; + if ($j==$cle) { + $newcar.="0"; } - $newcar .= $car; + $newcar.=$car; } //mise a jour des reponses utilisateurs dans la base - if (isset($erreur_ajout_date) && !$erreur_ajout_date) { + if (isset($erreur_ajout_date) && !$erreur_ajout_date){ $connect->Execute($sql, array($newcar, $data->nom, $data->id_users)); } } @@ -505,24 +485,24 @@ if (isset($_POST['ajoutercolonne']) && (substr($dsondage->format, 0, 1) == 'D')) send_mail_admin(); } else { - $erreur_ajout_date = 'yes'; + $erreur_ajout_date="yes"; } } //suppression de ligne dans la base -for ($i = 0; $i < $nblignes; ++$i) { - if (isset($_POST['effaceligne'. $i])) { - $compteur = 0; +for ($i = 0; $i < $nblignes; $i++) { + if (isset($_POST["effaceligne$i"])) { + $compteur=0; $sql = 'DELETE FROM user_studs WHERE nom = '.$connect->Param('nom').' AND id_users = '.$connect->Param('id_users'); $sql = $connect->Prepare($sql); while ($data=$user_studs->FetchNextObject(false)) { - if ($compteur == $i) { + if ($compteur==$i){ $connect->Execute($sql, array($data->nom, $data->id_users)); } - ++$compteur; + $compteur++; } } } @@ -540,7 +520,7 @@ while ($dcomment = $comment_user->FetchNextObject(false)) { $connect->Execute($sql, array($dcomment->id_comment)); } - ++$i; + $i++; } @@ -548,43 +528,53 @@ while ($dcomment = $comment_user->FetchNextObject(false)) { $testmodifier = false; $testligneamodifier = false; -for ($i = 0; $i < $nblignes; ++$i) { - if (isset($_POST['modifierligne'. $i])) { - $ligneamodifier = $i; - $testligneamodifier = 'true'; +for ($i = 0; $i < $nblignes; $i++) { + if (isset($_POST["modifierligne$i"])) { + $ligneamodifier=$i; + $testligneamodifier="true"; } - //test pour voir si une ligne est à modifier - if (isset($_POST['validermodifier'. $i])) { - $modifier = $i; - $testmodifier = 'true'; + //test pour voir si une ligne est a modifier + if (isset($_POST["validermodifier$i"])) { + $modifier=$i; + $testmodifier="true"; } } //si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs if ($testmodifier) { - $nouveauchoix = getNewChoiceFromPOST($nbcolonnes); + $nouveauchoix = ''; + for ($i = 0; $i < $nbcolonnes; $i++) { + // radio checked 1 = Yes, 2 = Ifneedbe, 0 = No + if (isset($_POST["choix$i"])) { + switch ($_POST["choix$i"]) { + case 1: $nouveauchoix .= "1";break; + case 2: $nouveauchoix .= "2";break; + default: $nouveauchoix .= "0";break; + } + } + } - $compteur = 0; + $compteur=0; - while ($data = $user_studs->FetchNextObject(false)) { - //mise à jour des données de l'utilisateur dans la base SQL + while ($data=$user_studs->FetchNextObject(false)) { + //mise a jour des données de l'utilisateur dans la base SQL if ($compteur==$modifier) { $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)); } - ++$compteur; + $compteur++; } } //suppression de colonnes dans la base -for ($i = 0; $i < $nbcolonnes; ++$i) { - if ((isset($_POST['effacecolonne' .$i])) && $nbcolonnes > 1) { - $toutsujet = explode(',', $dsujet->sujet); +for ($i = 0; $i < $nbcolonnes; $i++) { + if ((isset($_POST["effacecolonne$i"])) && $nbcolonnes > 1){ + $toutsujet = explode(",",$dsujet->sujet); //sort($toutsujet, SORT_NUMERIC); $j = 0; $nouveauxsujets = ''; @@ -593,16 +583,17 @@ for ($i = 0; $i < $nbcolonnes; ++$i) { while (isset($toutsujet[$j])) { //si le sujet n'est pas celui qui a été effacé alors on concatene if ($i != $j) { - $nouveauxsujets .= ',' . $toutsujet[$j]; + $nouveauxsujets .= ','; + $nouveauxsujets .= $toutsujet[$j]; } - ++$j; + $j++; } - //on enlève la virgule au début - $nouveauxsujets = substr($nouveauxsujets, 1); + //on enleve la virgule au début + $nouveauxsujets = substr("$nouveauxsujets", 1); - //nettoyage des réponses actuelles correspondant au sujet effacé + //nettoyage des reponses actuelles correspondant au sujet effacé $compteur = 0; $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); @@ -612,7 +603,7 @@ for ($i = 0; $i < $nbcolonnes; ++$i) { $ensemblereponses = $data->reponses; //parcours de toutes les réponses actuelles - for ($j = 0; $j < $nbcolonnes; ++$j) { + for ($j = 0; $j < $nbcolonnes; $j++) { $car=substr($ensemblereponses, $j, 1); //si les reponses ne concerne pas la colonne effacée, on concatene if ($i != $j) { @@ -620,13 +611,13 @@ for ($i = 0; $i < $nbcolonnes; ++$i) { } } - ++$compteur; + $compteur++; - //mise à jour des reponses utilisateurs dans la base + //mise a jour des reponses utilisateurs dans la base $connect->Execute($sql, array($newcar, $data->nom, $data->id_users)); } - //mise à jour des sujets dans la base + //mise a jour des sujets dans la base $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)); @@ -648,12 +639,13 @@ if ($sondage !== false) { $sql = $connect->Prepare($sql); $user_studs = $connect->Execute($sql, array($numsondage)); } else { + Utils::print_header(_("Error!")); bandeau_titre(_("Error!")); echo ' <div class="alert alert-warning"> - <h2>' . _('This poll doesn\'t exist !') . '</h2> + <h2>' . _("This poll doesn't exist !") . '</h2> <p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p> </div>'."\n"; @@ -664,44 +656,35 @@ if ($sondage !== false) { // Errors $errors = ''; -if ((isset($_POST['boutonp'])) && $_POST['nom'] == '') { - $errors .= '<li>' . _('Enter a name') . '</li>'; +if ((isset($_POST["boutonp"])) && $_POST["nom"] == "") { + $errors .= '<li>' . _("Enter a name") . '</li>'; } if (isset($erreur_prenom) && $erreur_prenom) { - $errors .= '<li>' . _('The name you\'ve chosen already exist in this poll!') . '</li>'; + $errors .= '<li>' . _("The name you've chosen already exist in this poll!") . '</li>'; } if (isset($erreur_injection) && $erreur_injection) { $errors .= '<li>' . _("Characters \" ' < et > are not permitted") . '</li>'; } if (isset($erreur_ajout_date) && $erreur_ajout_date) { - $errors .= '<li>' . _('The date is not correct!') . '</li>'; + $errors .= '<li>' . _("The date is not correct !") . '</li>'; } //Poll title, description and email values -$title = (isset($_POST['boutonnouveautitre']) && Utils::issetAndNoEmpty('nouveautitre')) - ? htmlentities(html_entity_decode($_POST['nouveautitre'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') - : stripslashes( $dsondage->titre ); -$description = (isset($_POST['nouveauxcommentaires'])) - ? stripslashes(htmlentities(html_entity_decode($_POST['nouveauxcommentaires'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8')) - : stripslashes( $dsondage->commentaires ); -$email_admin = (isset($_POST['boutonnouvelleadresse']) && Utils::issetAndNoEmpty('nouvelleadresse')) - ? htmlentities(html_entity_decode($_POST['nouvelleadresse'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') - : stripslashes( $dsondage->mail_admin ); +$title = (isset($_POST["boutonnouveautitre"]) && Utils::issetAndNoEmpty('nouveautitre')) ? htmlentities(html_entity_decode($_POST['nouveautitre'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') : stripslashes( $dsondage->titre ); +$description = (isset($_POST["nouveauxcommentaires"])) ? stripslashes(htmlentities(html_entity_decode($_POST['nouveauxcommentaires'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8')) : stripslashes( $dsondage->commentaires ); +$email_admin = (isset($_POST["boutonnouvelleadresse"]) && Utils::issetAndNoEmpty('nouvelleadresse')) ? htmlentities(html_entity_decode($_POST['nouvelleadresse'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8') : stripslashes( $dsondage->mail_admin ); //Poll format (locked A-/D-, open A/D, editable A+/D+) -$poll_rules = (isset($_POST['poll_rules']) && Utils::issetAndNoEmpty('btn_poll_rules')) - ? $_POST['poll_rules'] : substr($dsondage->format, 1, 1); -$poll_rules_opt1 = ''; -$poll_rules_opt2 = ''; -$poll_rules_opt3 = ''; +$poll_rules = (isset($_POST["poll_rules"]) && Utils::issetAndNoEmpty('btn_poll_rules')) ? $_POST["poll_rules"] : substr($dsondage->format, 1, 1); +$poll_rules_opt1 = '';$poll_rules_opt2 = '';$poll_rules_opt3 = ''; if($poll_rules == '+') { - $poll_rules_text = '<span class="glyphicon glyphicon-edit"></span> '. _('Votes are editable'); + $poll_rules_text = '<span class="glyphicon glyphicon-edit"></span> '. _("Votes are editable"); $poll_rules_opt3 = 'selected'; } elseif($poll_rules == '-') { - $poll_rules_text = '<span class="glyphicon glyphicon-lock"></span> '. _('Votes and comments are locked'); + $poll_rules_text = '<span class="glyphicon glyphicon-lock"></span> '. _("Votes and comments are locked"); $poll_rules_opt1 = 'selected'; } else { - $poll_rules_text = '<span class="glyphicon glyphicon-check"></span> '. _('Votes and comments are open'); + $poll_rules_text = '<span class="glyphicon glyphicon-check"></span> '. _("Votes and comments are open"); $poll_rules_opt2 = 'selected'; } @@ -710,6 +693,7 @@ if ($errors!='') { bandeau_titre(_("Error!")); echo '<div class="alert alert-danger"><ul class="list-unstyled">'.$errors.'</ul></div>'."\n"; + } else { Utils::print_header(_('Poll administration').' - '.$title); bandeau_titre(_('Poll administration').' - '.$title); @@ -739,13 +723,13 @@ echo ' <button onclick="javascript:print(); return false;" class="btn btn-default"><span class="glyphicon glyphicon-print"></span> ' . _('Print') . '</button> <button onclick="window.location.href=\'' . Utils::get_server_name() . 'exportcsv.php?numsondage=' . $numsondage . '\';return false;" class="btn btn-default"><span class="glyphicon glyphicon-download-alt"></span> ' . _('Export to CSV') . '</button> <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown"> - <span class="glyphicon glyphicon-trash"></span> <span class="sr-only">' . _('Remove') . '</span> <span class="caret"></span> + <span class="glyphicon glyphicon-trash"></span> <span class="sr-only">' . _("Remove") . '</span> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><button class="btn btn-link" type="submit" name="removevotes">' . _('Remove all the votes') . '</button></li> <li><button class="btn btn-link" type="submit" name="removecomments">' . _('Remove all the comments') . '</button></li> <li class="divider" role="presentation"></li> - <li><button class="btn btn-link" type="submit" id="suppressionsondage" name="suppressionsondage" value="" >'. _('Remove the poll') .'</button></li> + <li><button class="btn btn-link" type="submit" id="suppressionsondage" name="suppressionsondage" value="" >'. _("Remove the poll") .'</button></li> </ul> </div> </div> @@ -826,9 +810,9 @@ $dsujet=$sujets->FetchObject(false); $dsondage=$sondage->FetchObject(false); //reformatage des données des sujets du sondage -$toutsujet = explode(',', $dsujet->sujet); -$toutsujet = str_replace('°', '\'',$toutsujet); -$nbcolonnes = substr_count($dsujet->sujet,',') +1; +$toutsujet=explode(",",$dsujet->sujet); +$toutsujet=str_replace("°","'",$toutsujet); +$nbcolonnes=substr_count($dsujet->sujet,',')+1; // Table headers $thead = '<thead>'; @@ -841,24 +825,24 @@ $td_headers = array(); // for a11y, headers="M1 D4 H5" on each td $radio_title = array(); // date for // Dates poll -if (substr($dsondage->format, 0, 1) == 'D') { +if (substr($dsondage->format, 0, 1)=="D") { $tr_months = '<tr><th role="presentation"></th>'; - $tr_days = '<tr><th role="presentation"></th>'; - $tr_hours = '<tr><th role="presentation"></th>'; + $tr_days = '<tr><th role="presentation"></th>'; + $tr_hours = '<tr><th role="presentation"></th>'; // Headers $colspan_month = 1; $colspan_day = 1; - for ($i = 0; $i < count($toutsujet); ++$i) { + for ($i = 0; $i < count($toutsujet); $i++) { // Current date $current = $toutsujet[$i];//format date@hour. ex : 2020292820@10:00 $horoCur = explode("@",$current); //horoCur[0] = date, horoCur[1] = hour if (isset($toutsujet[$i+1])){ $next = $toutsujet[$i+1]; - $horoNext = explode('@', $next); + $horoNext = explode("@",$next); } $border[$i] = false; $radio_title[$i] = strftime($date_format['txt_short'],$horoCur[0]); @@ -871,18 +855,18 @@ if (substr($dsondage->format, 0, 1) == 'D') { } else { $border[$i] = true; $tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).'</th>'; - $colspan_month = 1; + $colspan_month=1; } // Days $td_headers[$i] .= ' D'.($i+1-$colspan_day); if (isset($toutsujet[$i+1]) && strftime($date_format['txt_day'],$horoCur[0])==strftime($date_format['txt_day'],$horoNext[0]) && strftime("%B",$horoCur[0])==strftime("%B",$horoNext[0])){ - ++$colspan_day; + $colspan_day++; } else { $rbd = ($border[$i]) ? ' rbd' : ''; $tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$horoCur[0]).'</th>'; - $colspan_day = 1; + $colspan_day=1; } // Hours @@ -896,33 +880,30 @@ if (substr($dsondage->format, 0, 1) == 'D') { } // Remove col - $tr_add_remove_col .= (count($toutsujet) > 2 ) - ? '<td headers="'.$td_headers[$i].'"><button type="submit" name="effacecolonne'.$i.'" class="btn btn-link btn-sm" title="' . _('Remove the column') . ' ' .$radio_title[$i]. '"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">'. _("Remove") .'</span></button></td>' - : '<td role="presentation"></td>'; + $tr_add_remove_col .= (count($toutsujet) > 2 ) ? '<td headers="'.$td_headers[$i].'"><button type="submit" name="effacecolonne'.$i.'" class="btn btn-link btn-sm" title="' . _('Remove the column') . ' ' .$radio_title[$i]. '"><span class="glyphicon glyphicon-remove text-danger"></span><span class="sr-only">'. _("Remove") .'</span></button></td>' : '<td role="presentation"></td>'; } $border[count($border)-1] = false; // suppression de la bordure droite du dernier mois $tr_months .= '<th></th></tr>'; - $tr_days .= '<th></th></tr>'; - $tr_hours .= '<th></th></tr>'; + $tr_days .= '<th></th></tr>'; + $tr_hours .= '<th></th></tr>'; // Add col - $tr_add_remove_col .= '<td><button type="submit" name="ajoutsujet" class="btn btn-link btn-sm" title="'. _('Add a column') . '"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _('Add a column') .'</span></button></td></tr>'; + $tr_add_remove_col .= '<td><button type="submit" name="ajoutsujet" class="btn btn-link btn-sm" title="'. _('Add a column') . '"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add a column") .'</span></button></td></tr>'; $thead = "\n".$tr_add_remove_col."\n".$tr_months."\n".$tr_days."\n".$tr_hours."\n"; // Subjects poll } else { - $toutsujet=str_replace('@', '<br />', $toutsujet); + $toutsujet=str_replace("@","<br />",$toutsujet); $tr_subjects = '<tr><th role="presentation"></th>'; - for ($i = 0; isset($toutsujet[$i]); ++$i) { + for ($i = 0; isset($toutsujet[$i]); $i++) { - $td_headers[$i]=''; - $radio_title[$i]=''; // init before concatenate + $td_headers[$i]='';$radio_title[$i]=''; // init before concatenate // Subjects preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$toutsujet[$i],$md_a_img); // Markdown [](href) @@ -962,7 +943,7 @@ if (substr($dsondage->format, 0, 1) == 'D') { // Add col $tr_add_remove_col .= '<td><button type="submit" name="ajoutsujet" class="btn btn-link btn-sm" title="'. _('Add a column') . '"><span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add a column") .'</span></button></td></tr>'; - $thead = $tr_add_remove_col . $tr_subjects . '<th></th></tr>'; + $thead = $tr_add_remove_col.$tr_subjects.'<th></th></tr>'; } // Print headers @@ -1004,7 +985,7 @@ while ($data = $user_studs->FetchNextObject(false)) { $ensemblereponses = $data->reponses; // Print name - $nombase=str_replace('°', '\'',$data->nom); + $nombase=str_replace("°","'",$data->nom); echo '<tr> <th class="bg-info">'.stripslashes($nombase).'</th>'."\n"; @@ -1014,30 +995,28 @@ while ($data = $user_studs->FetchNextObject(false)) { $rbd = ($border[$k]) ? ' rbd' : ''; $car = substr($ensemblereponses, $k, 1); switch ($car) { - case '1': echo '<td class="bg-success text-success'.$rbd.'" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only"> ' . _('Yes') . '</span></td>'."\n"; + case "1": echo '<td class="bg-success text-success'.$rbd.'" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only"> ' . _('Yes') . '</span></td>'."\n"; if (isset($somme[$k]) === false) { $somme[$k] = 0; } - ++$somme[$k]; break; - case '2': echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break; + $somme[$k]++; break; + case "2": echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break; default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n";break; } } } else { // sinon on remplace les choix de l'utilisateur par une ligne de radio pour recuperer de nouvelles valeurs // si c'est bien la ligne a modifier on met les radios - if ($compteur == $ligneamodifier) { - for ($j = 0; $j < $nbcolonnes; ++$j) { + if ($compteur == "$ligneamodifier") { + for ($j = 0; $j < $nbcolonnes; $j++) { $car = substr($ensemblereponses, $j, 1); // variable pour afficher la valeur cochée - $car_html[0] = 'value="0"'; - $car_html[1] = 'value="1"'; - $car_html[2] = 'value="2"'; + $car_html[0]='value="0"';$car_html[1]='value="1"';$car_html[2]='value="2"'; switch ($car) { - case '1': $car_html[1]='value="1" checked'; break; - case '2': $car_html[2]='value="2" checked'; break; - default: $car_html[0]='value="0" checked'; + case "1": $car_html[1]='value="1" checked';break; + case "2": $car_html[2]='value="2" checked';break; + default: $car_html[0]='value="0" checked';break; } echo ' @@ -1066,24 +1045,24 @@ while ($data = $user_studs->FetchNextObject(false)) { } } else { //sinon on affiche les lignes normales - for ($k = 0; $k < $nbcolonnes; ++$k) { + for ($k = 0; $k < $nbcolonnes; $k++) { $rbd = ($border[$k]) ? ' rbd' : ''; $car = substr($ensemblereponses, $k, 1); switch ($car) { - case '1': echo '<td class="bg-success text-success'.$rbd.'" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only"> ' . _('Yes') . '</span></td>'."\n"; + case "1": echo '<td class="bg-success text-success'.$rbd.'" headers="'.$td_headers[$k].'"><span class="glyphicon glyphicon-ok"></span><span class="sr-only"> ' . _('Yes') . '</span></td>'."\n"; if (isset($somme[$k]) === false) { $somme[$k] = 0; } - ++$somme[$k]; break; - case '2': echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break; - default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n"; + $somme[$k]++; break; + case "2": echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break; + default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n";break; } } } } //a la fin de chaque ligne se trouve les boutons modifier - if (!$testligneamodifier == 'true') { + if (!$testligneamodifier=="true") { echo ' <td> <button type="submit" class="btn btn-link btn-sm" name="modifierligne'.$compteur.'" title="'. _('Edit the line:') .' '.stripslashes($nombase).'"> @@ -1096,19 +1075,19 @@ while ($data = $user_studs->FetchNextObject(false)) { } //demande de confirmation pour modification de ligne - for ($i = 0; $i < $nblignes; ++$i) { - if (isset($_POST['modifierligne'. $i])) { + for ($i = 0; $i < $nblignes; $i++) { + if (isset($_POST["modifierligne$i"])) { if ($compteur == $i) { echo '<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="validermodifier'.$compteur.'" title="'. _('Save the choices') .' '.stripslashes($nombase).'">'. _('Save') .'</button></td>'."\n"; } } } - ++$compteur; + $compteur++; echo '</tr>'."\n"; } -if (!$testligneamodifier == 'true') { +if (!$testligneamodifier=="true") { //affichage de la case vide de texte pour un nouvel utilisateur echo '<tr id="vote-form"> <td class="bg-info" style="padding:5px"> @@ -1119,7 +1098,7 @@ if (!$testligneamodifier == 'true') { </td>'."\n"; //une ligne de checkbox pour le choix du nouvel utilisateur - for ($i = 0; $i < $nbcolonnes; ++$i) { + for ($i = 0; $i < $nbcolonnes; $i++) { echo ' <td class="bg-info" headers="'.$td_headers[$i].'"> <ul class="list-unstyled choice"> @@ -1164,7 +1143,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { $tr_addition .= '<td><span class="glyphicon glyphicon-star text-warning"></span><span>'.$somme[$i].'</span></td>'; $meilleursujet.= '<li><b>'.$radio_title[$i].'</b></li>'; - ++$compteursujet; + $compteursujet++; } else { $tr_addition .= '<td>'.$somme[$i].'</td>'; @@ -1176,9 +1155,9 @@ for ($i = 0; $i < $nbcolonnes; $i++) { $tr_addition .= '<td></td></tr>'; //recuperation des valeurs des sujets et adaptation pour affichage -$toutsujet = explode(',', $dsujet->sujet); +$toutsujet = explode(",", $dsujet->sujet); -$meilleursujet = str_replace('°', '\'', $meilleursujet).'</ul>'; +$meilleursujet = str_replace("°", "'", $meilleursujet).'</ul>'; $vote_str = ($meilleurecolonne > 1) ? $vote_str = _('votes') : _('vote'); // Print Addition and Best choice @@ -1215,7 +1194,7 @@ $sql = $connect->Prepare($sql); $comment_user = $connect->Execute($sql, array($numsondage)); if ($comment_user->RecordCount() != 0) { - echo '<div><h3>' . _('Comments of polled people') . '</h3>'."\n"; + echo '<div><h3>' . _("Comments of polled people") . '</h3>'."\n"; $i = 0; while ( $dcomment=$comment_user->FetchNextObject(false)) { @@ -1232,15 +1211,15 @@ if ($comment_user->RecordCount() != 0) { echo ' <div class="hidden-print alert alert-info"> <div class="col-md-6 col-md-offset-3"> - <fieldset id="add-comment"><legend>' . _('Add a comment in the poll') . '</legend> + <fieldset id="add-comment"><legend>' . _("Add a comment in the poll") . '</legend> <div class="form-group"> - <p><label for="commentuser">'. _('Your name') .'</label><input type=text name="commentuser" class="form-control" id="commentuser" /></p> + <p><label for="commentuser">'. _("Your name") .'</label><input type=text name="commentuser" class="form-control" id="commentuser" /></p> </div> <div class="form-group"> - <p><label for="comment">'. _('Your comment') .'</label><br /> + <p><label for="comment">'. _("Your comment") .'</label><br /> <textarea name="comment" id="comment" class="form-control" rows="2" cols="40"></textarea></p> </div> - <p class="text-center"><input type="submit" name="ajoutcomment" value="'. _('Send the comment') .'" class="btn btn-success"></p> + <p class="text-center"><input type="submit" name="ajoutcomment" value="'. _("Send the comment") .'" class="btn btn-success"></p> </fieldset> </div> <div class="clearfix"></div> diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php index 6aeed8ac..3333c755 100644 --- a/app/classes/Framadate/Utils.php +++ b/app/classes/Framadate/Utils.php @@ -20,22 +20,16 @@ namespace Framadate; class Utils { - /** - * @return string Server name - */ public static function get_server_name() { - $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; + $scheme = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? 'https' : 'http'; $port = in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '/' : ':' . $_SERVER['SERVER_PORT'] . '/'; $server_name = $_SERVER['SERVER_NAME'] . $port . dirname($_SERVER['SCRIPT_NAME']) . '/'; - return $scheme . '://' . str_replace('/admin', '', str_replace('//', '/', str_replace('///', '/', $server_name))); + return $scheme . '://' . str_replace('/admin','',str_replace('//','/',str_replace('///','/',$server_name))); } - /** - * Returns a poll or false if it fails - */ - public static function get_poll_from_id($id) + public static function get_sondage_from_id($id) { global $connect; @@ -46,13 +40,13 @@ class Utils WHERE sondage.id_sondage = ' . $connect->Param('id_sondage'); $sql = $connect->Prepare($sql); - $poll = $connect->Execute($sql, [$id]); + $sondage = $connect->Execute($sql, [$id]); - if ($poll === false) { + if ($sondage === false) { return false; } - $psondage = $poll->FetchObject(false); + $psondage = $sondage->FetchObject(false); $psondage->date_fin = strtotime($psondage->date_fin); return $psondage; @@ -61,15 +55,6 @@ class Utils return false; } - /** - * Use get_poll_from_id that is fully english name - * @deprecated - */ - public static function get_sondage_from_id($id) - { - return self::get_poll_from_id($id); - } - public static function is_error($cerr) { global $err; @@ -92,20 +77,20 @@ class Utils echo '<!DOCTYPE html> <html lang="'.$lang.'"> <head> - <meta charset="utf-8" />'; + <meta charset="utf-8">'; - echo '<title>'; if (! empty($title)) { - echo stripslashes($title) . ' - '; + echo '<title>' . stripslashes($title) . ' - ' . NOMAPPLICATION . '</title>'; + } else { + echo '<title>' . NOMAPPLICATION . '</title>'; } - echo NOMAPPLICATION . '</title>'; echo ' - <link rel="stylesheet" href="' . self::get_server_name() . 'css/bootstrap.min.css" /> - <link rel="stylesheet" href="' . self::get_server_name() . 'css/datepicker3.css" /> - <link rel="stylesheet" href="' . self::get_server_name() . 'css/style.css" /> - <link rel="stylesheet" href="' . self::get_server_name() . 'css/frama.css" /> - <link rel="stylesheet" href="' . self::get_server_name() . 'css/print.css" media="print" /> + <link rel="stylesheet" href="' . self::get_server_name() . 'css/bootstrap.min.css"> + <link rel="stylesheet" href="' . self::get_server_name() . 'css/datepicker3.css"> + <link rel="stylesheet" href="' . self::get_server_name() . 'css/style.css"> + <link rel="stylesheet" href="' . self::get_server_name() . 'css/frama.css"> + <link rel="stylesheet" href="' . self::get_server_name() . 'css/print.css" media="print"> <script type="text/javascript" src="' . self::get_server_name() . 'js/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap.min.js"></script> <script type="text/javascript" src="' . self::get_server_name() . 'js/bootstrap-datepicker.js"></script> @@ -119,12 +104,18 @@ class Utils </head> <body> <div class="container ombre">'; + } public static function check_table_sondage() { global $connect; - return in_array('sondage', $connect->MetaTables('TABLES')); + + if (in_array('sondage', $connect->MetaTables('TABLES'))) { + return true; + } + + return false; } /** @@ -141,9 +132,11 @@ class Utils /** * Envoi un courrier avec un codage correct de To et Subject * Les en-têtes complémentaires ne sont pas gérés + * */ public static function sendEmail( $to, $subject, $body, $headers='', $param='') { + mb_internal_encoding('UTF-8'); $subject = mb_encode_mimeheader(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'), 'UTF-8', 'B', "\n", 9); @@ -182,9 +175,9 @@ class Utils $headers .= "Content-Type: text/plain; charset=UTF-8\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "Auto-Submitted:auto-generated\n"; - $headers .= 'Return-Path: <>'; + $headers .= "Return-Path: <>"; - $body = html_entity_decode($body, ENT_QUOTES, 'UTF-8'). "\n--\n\n" . _('« La route est longue, mais la voie est libre… »') ."\n" . _('Framasoft ne vit que par vos dons (déductibles des impôts).') ."\n". _('Merci d’avance pour votre soutien http://soutenir.framasoft.org.'); + $body = html_entity_decode($body, ENT_QUOTES, 'UTF-8')._("\n--\n\n« La route est longue, mais la voie est libre… »\nFramasoft ne vit que par vos dons (déductibles des impôts).\nMerci d'avance pour votre soutien http://soutenir.framasoft.org."); mail($to, $subject, $body, $headers, $param); } @@ -192,16 +185,16 @@ class Utils /** * Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau * @param string $name La clé à tester - * @param array $table Le tableau où rechercher la clé ($_POST par défaut) + * @param array $tableau Le tableau où rechercher la clé ($_POST par défaut) * @return bool Vrai si la clé existe et renvoie une valeur non vide */ - public static function issetAndNoEmpty($name, $table = null) + public static function issetAndNoEmpty($name, $tableau = null) { - if (is_null($table)) { - $table = $_POST; + if (is_null($tableau)) { + $tableau = $_POST; } - return isset($table[$name]) && ! empty($table[$name]); + return isset($tableau[$name]) && ! empty($tableau[$name]); } /** @@ -214,17 +207,19 @@ class Utils { if (URL_PROPRE) { if ($admin === true) { - return str_replace('/admin', '', self::get_server_name()) . $id . '/admin'; + $url = str_replace('/admin', '', self::get_server_name()) . $id . '/admin'; } else { - return str_replace('/admin', '', self::get_server_name()) . $id; + $url = str_replace('/admin', '', self::get_server_name()) . $id; } } else { if ($admin === true) { - return str_replace('/admin', '', self::get_server_name()) . 'adminstuds.php?sondage=' . $id; + $url = str_replace('/admin', '', self::get_server_name()) . 'adminstuds.php?sondage=' . $id; } else { - return str_replace('/admin', '', self::get_server_name()) . 'studs.php?sondage=' . $id; + $url = str_replace('/admin', '', self::get_server_name()) . 'studs.php?sondage=' . $id; } } + + return $url; } public static function remove_sondage($connect, $numsondage) @@ -253,11 +248,6 @@ class Utils return $suppression_OK ; } - /** - * @param $connect - * @param $log_txt - * @return void - */ public static function cleaning_polls($connect, $log_txt) { $connect->StartTrans(); $req = 'SELECT * FROM sondage WHERE date_fin < NOW() AND date_fin != 0 LIMIT 20'; diff --git a/app/inc/constants.php.template b/app/inc/constants.php.template index da740537..82567d63 100644 --- a/app/inc/constants.php.template +++ b/app/inc/constants.php.template @@ -20,8 +20,11 @@ // FRAMADATE version const VERSION = 0.8; +// Server name +const STUDS_URL = '<www.mydomain.com>'; + // Application name -const NOMAPPLICATION = '<Application name>'; +const NOMAPPLICATION = "<Application name>"; // Database administrator email const ADRESSEMAILADMIN = '<email address>'; @@ -33,7 +36,7 @@ const ADRESSEMAILREPONSEAUTO = '<no-reply@mydomain.com>'; const BASE = '<database name>'; // Database user -const USERBASE = '<database user>'; +const USERBASE = "<database user>"; // Database password const USERPASSWD = '<database password>'; diff --git a/app/inc/init.php b/app/inc/init.php index 912d6e5c..2a13d2b2 100644 --- a/app/inc/init.php +++ b/app/inc/init.php @@ -23,16 +23,9 @@ if (ini_get('date.timezone') == '') { // Autoloading of dependencies with Composer require_once __DIR__ . '/../../vendor/autoload.php'; -require_once __DIR__ . '/constants.php'; -require_once __DIR__ . '/i18n.php'; +include_once __DIR__ . '/constants.php'; +include_once __DIR__ . '/i18n.php'; $connect = NewADOConnection(BASE_TYPE); - -if ('pdo' === BASE_TYPE) { - $database_host = 'mysql:host='.SERVEURBASE; -} else { - $database_host = SERVEURBASE; -} - -$connect->Connect($database_host, USERBASE, USERPASSWD, BASE); +$connect->Connect(SERVEURBASE, USERBASE, USERPASSWD, BASE); $err = 0; diff --git a/choix_date.php b/choix_date.php index 5e4624cf..b9f63149 100644 --- a/choix_date.php +++ b/choix_date.php @@ -5,7 +5,7 @@ * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt * * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ - * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft https://git.framasoft.org/framasoft/framadate/) + * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft) * * ============================= * @@ -14,7 +14,7 @@ * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt * * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ - * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft https://git.framasoft.org/framasoft/framadate/) + * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft) */ namespace Framadate; @@ -31,13 +31,13 @@ if (is_readable('bandeaux_local.php')) { // Step 1/3 : error if $_SESSION from info_sondage are not valid if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmpty('nom', $_SESSION) === false || (($config['use_smtp']) ? Utils::issetAndNoEmpty('adresse', $_SESSION) === false : false)) { - Utils::print_header ( _('Error!') ); - bandeau_titre(_('Error!')); + Utils::print_header ( _("Error!") ); + bandeau_titre(_("Error!")); echo ' <div class="alert alter-danger"> - <h3>' . _('You haven\'t filled the first section of the poll creation.') . ' !</h3> - <p>' . _('Back to the homepage of ') . ' ' . '<a href="' . Utils::get_server_name() . '">' . NOMAPPLICATION . '</a>.</p> + <h3>' . _("You haven't filled the first section of the poll creation.") . ' !</h3> + <p>' . _("Back to the homepage of ") . ' ' . '<a href="' . Utils::get_server_name() . '">' . NOMAPPLICATION . '</a>.</p> </div>'; bandeau_pied(); @@ -46,19 +46,19 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp // Step 4 : Data prepare before insert in DB if (Utils::issetAndNoEmpty('confirmation')) { $temp_results = array(); - $choixdate = ''; + $choixdate=''; if (Utils::issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { - for ($i = 0; $i < count($_SESSION["totalchoixjour"]); ++$i) { + for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) { if(count($_SESSION['horaires'.$i])!=0) { - for ($j=0; $j< min(count($_SESSION['horaires'.$i]),12); ++$j) { - if ($_SESSION['horaires'.$i][$j] != '') { + for ($j=0;$j< min(count($_SESSION['horaires'.$i]),12);$j++) { + if ($_SESSION['horaires'.$i][$j]!="") { array_push($temp_results, $_SESSION["totalchoixjour"][$i].'@'.$_SESSION['horaires'.$i][$j]); } else { array_push($temp_results, $_SESSION["totalchoixjour"][$i]); } } } else { - array_push($temp_results, $_SESSION['totalchoixjour'][$i]); + array_push($temp_results, $_SESSION["totalchoixjour"][$i]); } } @@ -67,24 +67,23 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp // Sort and remove doublons $temp_results = array_unique($temp_results); sort($temp_results); - for ($i=0; $i < count($temp_results); ++$i) { + for ($i=0;$i<count($temp_results);$i++) { if (isset($temp_results[$i])) { - $choixdate .= ','. $temp_results[$i]; + $choixdate.=','.$temp_results[$i]; } } - $_SESSION['toutchoix'] = substr($choixdate, 1); + $_SESSION["toutchoix"]=substr($choixdate,1); // Expiration date → 6 months after last day if not filled or in bad format - // 86400 = 60*60*24 - $_SESSION['champdatefin']=end($temp_results)+(86400 * $config['default_poll_duration']); + $_SESSION["champdatefin"]=end($temp_results)+(86400 * $config['default_poll_duration']); if (Utils::issetAndNoEmpty('champdatefin')) { - $registredate = explode('/', $_POST['champdatefin']); + $registredate = explode("/",$_POST["champdatefin"]); if (is_array($registredate) == true && count($registredate) == 3) { $time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]); - if ($time > time() + 86400) { - $_SESSION['champdatefin'] = $time; + if ($time > time() + (24*60*60)) { + $_SESSION["champdatefin"]=$time; } } } @@ -93,20 +92,16 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp } else { if (Utils::issetAndNoEmpty('days')) { - if (!isset($_SESSION['totalchoixjour'])) { - $_SESSION['totalchoixjour'] = array(); + if (!isset($_SESSION["totalchoixjour"])) { + $_SESSION["totalchoixjour"]=array(); } $k = 0; - for ($i = 0; $i < count($_POST['days']); ++$i) { - if (isset($_POST['days'][$i]) && $_POST['days'][$i] !='') { - $_SESSION['totalchoixjour'][$k] = mktime( - 0, 0, 0, - substr($_POST["days"][$i], 3, 2), - substr($_POST['days'][$i], 0, 2), - substr($_POST['days'][$i], 6, 4)); + for ($i = 0; $i < count($_POST["days"]); $i++) { + if (isset($_POST["days"][$i]) && $_POST["days"][$i] !='') { + $_SESSION['totalchoixjour'][$k] = mktime(0, 0, 0, substr($_POST["days"][$i],3,2),substr($_POST["days"][$i],0,2),substr($_POST["days"][$i],6,4)); $l = 0; - for($j = 0; $j < count($_POST['horaires'.$i]); ++$j) { + for($j = 0; $j < count($_POST['horaires'.$i]); $j++) { if (isset($_POST['horaires'.$i][$j]) && $_POST['horaires'.$i][$j] != '') { $_SESSION['horaires'.$k][$l] = $_POST['horaires'.$i][$j]; $l++; @@ -119,26 +114,23 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp } //le format du sondage est DATE - $_SESSION['formatsondage'] = 'D'. $_SESSION['studsplus']; + $_SESSION["formatsondage"] = "D".$_SESSION["studsplus"]; // Step 3/3 : Confirm poll creation if (Utils::issetAndNoEmpty('choixheures') && Utils::issetAndNoEmpty('totalchoixjour', $_SESSION)) { - Utils::print_header ( _('Removal date and confirmation (3 on 3)') ); - bandeau_titre(_('Removal date and confirmation (3 on 3)')); + Utils::print_header ( _("Removal date and confirmation (3 on 3)") ); + bandeau_titre(_("Removal date and confirmation (3 on 3)")); - $temp_array = array_unique($_SESSION['totalchoixjour']); + $temp_array = array_unique($_SESSION["totalchoixjour"]); sort($temp_array); - $removal_date = utf8_encode( - strftime($date_format['txt_full'], - end($temp_array) + (86400 * $config['default_poll_duration'])) - ); + $removal_date=utf8_encode(strftime($date_format['txt_full'], end($temp_array)+ (86400 * $config['default_poll_duration']))); // Sumary $summary = '<ul>'; - for ($i=0; $i < count($_SESSION['totalchoixjour']); ++$i) { + for ($i=0;$i<count($_SESSION["totalchoixjour"]);$i++) { $summary .= '<li>'.strftime($date_format['txt_full'], $_SESSION["totalchoixjour"][$i]); - for ($j=0; $j < count($_SESSION['horaires'.$i]); ++$j) { + for ($j=0;$j<count($_SESSION['horaires'.$i]);$j++) { if (isset($_SESSION['horaires'.$i][$j])) { $summary .= ($j==0) ? ' : ' : ', '; $summary .= $_SESSION['horaires'.$i][$j]; @@ -154,7 +146,7 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp <div class="col-md-8 col-md-offset-2"> <h3>'. _("Confirm the creation of your poll") .'</h3> <div class="well summary"> - <h4>'. _('List of your choices').'</h4> + <h4>'. _("List of your choices").'</h4> '. $summary .' </div> <div class="alert alert-info clearfix"> @@ -172,9 +164,9 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp </div> <div class="alert alert-warning"> <p>'. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the administration page of your poll."). '</p>'; - if($config['use_smtp'] == true) { + if($config['use_smtp']==true){ echo ' - <p>' . _('Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.') .'</p>'; + <p>' . _("Then, you will receive quickly two emails: one contening the link of your poll for sending it to the voters, the other contening the link to the administration page of your poll.") .'</p>'; } echo ' </div> @@ -190,24 +182,24 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp // Step 2/3 : Select dates of the poll } else { - Utils::print_header ( _('Poll dates (2 on 3)') ); - bandeau_titre(_('Poll dates (2 on 3)')); + Utils::print_header ( _("Poll dates (2 on 3)") ); + bandeau_titre(_("Poll dates (2 on 3)")); echo ' <form name="formulaire" action="' . Utils::get_server_name() . 'choix_date.php" method="POST" class="form-horizontal" role="form"> <div class="row" id="selected-days"> <div class="col-md-10 col-md-offset-1"> - <h3>'. _('Choose the dates of your poll') .'</h3> + <h3>'. _("Choose the dates of your poll") .'</h3> <div class="alert alert-info"> <p>'. _("To schedule an event you need to propose at least two choices (two hours for one day or two days).").'</p> - <p>'. _("You can add or remove additionnal days and hours with the buttons") .' <span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _('Remove') .'</span> <span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></p> + <p>'. _("You can add or remove additionnal days and hours with the buttons") .' <span class="glyphicon glyphicon-minus text-info"></span><span class="sr-only">'. _("Remove") .'</span> <span class="glyphicon glyphicon-plus text-success"></span><span class="sr-only">'. _("Add") .'</span></p> <p>'. _("For each selected day, you can choose, or not, meeting hours (e.g.: \"8h\", \"8:30\", \"8h-10h\", \"evening\", etc.)").'</p> </div>'; // Fields days : 3 by default $nb_days = (isset($_SESSION["totalchoixjour"])) ? count($_SESSION["totalchoixjour"]) : 3; - for ($i=0; $i < $nb_days; ++$i) { - $day_value = isset($_SESSION['totalchoixjour'][$i]) ? strftime( "%d/%m/%Y", $_SESSION['totalchoixjour'][$i]) : ''; + for ($i=0;$i<$nb_days;$i++) { + $day_value = isset($_SESSION["totalchoixjour"][$i]) ? strftime( "%d/%m/%Y", $_SESSION["totalchoixjour"][$i]) : ''; echo ' <fieldset> <div class="form-group"> @@ -221,8 +213,8 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp </legend>'."\n"; // Fields hours : 3 by default - for ($j=0; $j < max(count(isset($_SESSION['horaires'.$i]) ? $_SESSION['horaires'.$i] : 0),3); ++$j) { - $hour_value = isset($_SESSION['horaires'.$i][$j]) ? $_SESSION['horaires'.$i][$j] : ''; + for ($j=0;$j<max(count(isset($_SESSION["horaires".$i]) ? $_SESSION["horaires".$i] : 0),3);$j++) { + $hour_value = isset($_SESSION["horaires".$i][$j]) ? $_SESSION["horaires".$i][$j] : ''; echo ' <div class="col-sm-2"> <label for="d'.$i.'-h'.$j.'" class="sr-only control-label">'. _("Time") .' '. ($j+1) .'</label> @@ -263,5 +255,6 @@ if (Utils::issetAndNoEmpty('titre', $_SESSION) === false || Utils::issetAndNoEmp </form>'."\n"; bandeau_pied(); + } } diff --git a/composer.json b/composer.json index 9f168daa..e4426a03 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,14 @@ { "name": "framasoft/framadate", "description": "Application to facilitate the schedule of events or classic polls", - "keywords": "poll", + "keywords": [ + "poll" + ], "version": "0.8.0", "license": "CeCILL-B", - + "type": "project", - + "require": { "adodb/adodb-php": "5.19" }, diff --git a/composer.lock b/composer.lock index babc2238..90f3ebaa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "09409801c18d04caaf9f8a4f8c7a67b1", + "hash": "3cdb051814926a50182b00bbf5297ed2", "packages": [ { "name": "adodb/adodb-php", @@ -53,11 +53,21 @@ "time": "2014-04-23 14:37:03" } ], - "packages-dev": [], - "aliases": [], + "packages-dev": [ + + ], + "aliases": [ + + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": [ + + ], "prefer-stable": false, - "platform": [], - "platform-dev": [] + "platform": [ + + ], + "platform-dev": [ + + ] } diff --git a/creation_sondage.php b/creation_sondage.php index 08a7fb80..bf22246a 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -18,7 +18,7 @@ */ namespace Framadate; -if (session_id() == '') { +if (session_id() == "") { session_start(); } @@ -26,23 +26,16 @@ include_once __DIR__ . '/app/inc/init.php'; //Generer une chaine de caractere unique et aleatoire -function random_string($length) +function random($car) { - $string = ''; - $chaine = 'abcdefghijklmnopqrstuvwxyz123456789'; + $string = ""; + $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; srand((double)microtime()*1000000); - for($i=0; $i < $length; ++$i) { + for($i=0; $i<$car; $i++) { $string .= $chaine[rand()%strlen($chaine)]; } - return $string; -} -/** - * @deprecated - */ -function random($car) -{ - return random_string($car); + return $string; } function ajouter_sondage() @@ -50,11 +43,11 @@ function ajouter_sondage() global $connect; global $config; - $poll = random(16); - $poll_admin = $poll . random(8); + $sondage=random(16); + $sondage_admin=$sondage.random(8); - $date_fin = $_SESSION['champdatefin']; // provided by choix_autre.php or choix_date.php - $_SESSION['champdatefin'] = ''; //clean param cause 2 polls created by the same user in the same session can be affected by this param during the 2nd creation. + $date_fin = $_SESSION["champdatefin"]; // provided by choix_autre.php or choix_date.php + $_SESSION["champdatefin"]=""; //clean param cause 2 polls created by the same user in the same session can be affected by this param during the 2nd creation. $sql = 'INSERT INTO sondage (id_sondage, commentaires, mail_admin, nom_admin, titre, id_sondage_admin, date_fin, format, mailsonde) VALUES ( @@ -64,55 +57,45 @@ function ajouter_sondage() '.$connect->Param('nom_admin').', '.$connect->Param('titre').', '.$connect->Param('id_sondage_admin').', - FROM_UNIXTIME('. $date_fin .'), + FROM_UNIXTIME('.$date_fin.'), '.$connect->Param('format').', '.$connect->Param('mailsonde').' )'; $sql = $connect->Prepare($sql); - $res = $connect->Execute($sql, array($poll, $_SESSION['commentaires'], $_SESSION['adresse'], $_SESSION['nom'], $_SESSION['titre'], $poll_admin, $_SESSION['formatsondage'], $_SESSION['mailsonde'])); + $res = $connect->Execute($sql, array($sondage, $_SESSION['commentaires'], $_SESSION['adresse'], $_SESSION['nom'], $_SESSION['titre'], $sondage_admin, $_SESSION['formatsondage'], $_SESSION['mailsonde'])); - $sql = 'INSERT INTO sujet_studs VALUES ('.$connect->Param('sondage').', '.$connect->Param('choix').')'; + $sql = 'INSERT INTO sujet_studs values ('.$connect->Param('sondage').', '.$connect->Param('choix').')'; $sql = $connect->Prepare($sql); - $connect->Execute($sql, array($poll, $_SESSION['toutchoix'])); + $connect->Execute($sql, array($sondage, $_SESSION['toutchoix'])); - if($config['use_smtp']==true) { + if($config['use_smtp']==true){ $message = _("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll."); $message .= "\n\n"; - $message .= stripslashes(html_entity_decode($_SESSION["nom"],ENT_QUOTES,"UTF-8"))." " . _('hast just created a poll called') . ' : "'.stripslashes(htmlspecialchars_decode($_SESSION['titre'],ENT_QUOTES))."\".\n"; - $message .= _('Thanks for filling the poll at the link above') . " :\n\n%s\n\n" . _('Thanks for your confidence.') ."\n". NOMAPPLICATION; + $message .= stripslashes(html_entity_decode($_SESSION["nom"],ENT_QUOTES,"UTF-8"))." " . _("hast just created a poll called") . " : \"".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES))."\".\n"; + $message .= _("Thanks for filling the poll at the link above") . " :\n\n%s\n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION; $message_admin = _("This message should NOT be sent to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above"); - $message_admin .= " :\n\n%s \n\n" . _('Thanks for your confidence.') . "\n". NOMAPPLICATION; + $message_admin .= " :\n\n"."%s \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION; - $message = sprintf($message, Utils::getUrlSondage($poll)); - $message_admin = sprintf($message_admin, Utils::getUrlSondage($poll_admin, true)); + $message = sprintf($message, Utils::getUrlSondage($sondage)); + $message_admin = sprintf($message_admin, Utils::getUrlSondage($sondage_admin, true)); if (Utils::isValidEmail($_SESSION['adresse'])) { - Utils::sendEmail( - "$_SESSION[adresse]", - "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"], ENT_QUOTES)), - $message_admin, - $_SESSION['adresse'] - ); - Utils::sendEmail( - "$_SESSION[adresse]", - "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"], ENT_QUOTES)), - $message, - $_SESSION['adresse'] - ); + Utils::sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message_admin, $_SESSION['adresse'] ); + Utils::sendEmail( "$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes(htmlspecialchars_decode($_SESSION["titre"],ENT_QUOTES)), $message, $_SESSION['adresse'] ); } } - error_log(date('H:i:s d/m/Y:') . ' CREATION: '.$poll."\t".$_SESSION[formatsondage]."\t".$_SESSION[nom]."\t".$_SESSION[adresse]."\t \t".$_SESSION[toutchoix]."\n", 3, 'admin/logs_studs.txt'); - Utils::cleaning_polls($connect, 'admin/logs_studs.txt'); + error_log(date('H:i:s d/m/Y:') . ' CREATION: '.$sondage."\t".$_SESSION[formatsondage]."\t".$_SESSION[nom]."\t".$_SESSION[adresse]."\t \t".$_SESSION[toutchoix]."\n", 3, 'admin/logs_studs.txt'); + //Utils::cleaning_polls($connect, 'admin/logs_studs.txt'); // Don't keep days, hours and choices in memory (in order to make new polls) - for ($i = 0; $i < count($_SESSION['totalchoixjour']); ++$i) { + for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) { unset($_SESSION['horaires'.$i]); } - unset($_SESSION['totalchoixjour']); + unset($_SESSION["totalchoixjour"]); unset($_SESSION['choices']); - header('Location:'. Utils::getUrlSondage($poll_admin, true)); + header("Location:".Utils::getUrlSondage($sondage_admin, true)); exit(); } diff --git a/css/print.css b/css/print.css index 5f677ec5..04b33c8a 100644 --- a/css/print.css +++ b/css/print.css @@ -4,12 +4,16 @@ body { background:none; } +.jumbotron { + page-break-after:always; +} + table { - page-break-after:always} + page-break-after:always; } table { - page-break-inside:auto + page-break-inside:auto; } tr { @@ -25,6 +29,26 @@ tfoot { display:table-footer-group; } +#tableContainer { + overflow-x:visible !important; +} + +#vote-form, .scroll-buttons, form .alert.alert-info { + display:none; +} + +table.results td { + border:2px solid #333; +} + +table.results tr td:last-child { + display:none; +} + +.container { + width:auto; +} + @page { size:landscape; } diff --git a/css/style.css b/css/style.css index f3bb3073..08cc5852 100644 --- a/css/style.css +++ b/css/style.css @@ -245,13 +245,18 @@ table.results .btn-link.btn-sm { #vote-form td { border-top:2px solid white; + vertical-align:top; } .yes input, .ifneedbe input,.no input { - position:absolute; - left:0; - margin-left:-15px; - margin-top:0; + position: absolute; + width: 1px; + height: 1px; + padding: 0px; + margin: -1px; + overflow: hidden; + clip: rect(0px, 0px, 0px, 0px); + border: 0px none; } .choice input:focus + label { @@ -269,45 +274,47 @@ table.results .btn-link.btn-sm { .yes .btn, .ifneedbe .btn, .no .btn { width:32px; - color:#555; } -.yes .btn { +.yes .btn,.yes .btn:hover { border-bottom-right-radius:0px !important; border-bottom-left-radius:0px !important; margin-bottom:-1px !important; margin-top:4px !important; + color:#677835; } -.ifneedbe .btn { +.ifneedbe .btn,.ifneedbe .btn:hover { border-radius:0px; + color:#C48A1B; } -.no .btn{ +.no .btn,.no .btn:hover{ border-top-right-radius:0px !important; border-top-left-radius:0px !important; margin-bottom:4px !important; margin-top:-1px !important; + color:#AD220F; } .yes input[type="radio"]:checked + label { /* =.btn-success.active */ - color: #fff; - background-color: #768745; - border-color: #67753C; + color: #FFF; + background-color: #7D8C3F; + border-color: #7D8C3F; box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.125) inset; } .ifneedbe input[type="radio"]:checked + label { /* =.btn-warning.active */ - color: #fff; - background-color: #CF9800; - border-color: #BD8A00; + color: #FFF; + background-color: #C48A1B; + border-color: #C48A1B; box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.125) inset; } .no input[type="radio"]:checked + label { /* =.btn-danger.active */ - color: #fff; - background-color: #BF2511; - border-color: #AD220F; + color: #FFF; + background-color: #B82E12; + border-color: #B82E12; box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.125) inset; } diff --git a/studs.php b/studs.php index e62aa93b..db63ea20 100644 --- a/studs.php +++ b/studs.php @@ -34,28 +34,28 @@ $numsondage = false; //On récupère le numéro de sondage par le lien web. if(Utils::issetAndNoEmpty('sondage', $_GET) === true) { - $numsondage = $_GET['sondage']; - $_SESSION['numsondage'] = $numsondage; + $numsondage = $_GET["sondage"]; + $_SESSION["numsondage"] = $numsondage; } if(Utils::issetAndNoEmpty('sondage') === true) { - $numsondage = $_POST['sondage']; - $_SESSION['numsondage'] = $numsondage; + $numsondage = $_POST["sondage"]; + $_SESSION["numsondage"] = $numsondage; } elseif(Utils::issetAndNoEmpty('sondage', $_COOKIE) === true) { - $numsondage = $_COOKIE['sondage']; + $numsondage = $_COOKIE["sondage"]; } elseif(Utils::issetAndNoEmpty('numsondage', $_SESSION) === true) { - $numsondage = $_SESSION['numsondage']; + $numsondage = $_SESSION["numsondage"]; } $dsondage = ($numsondage != false) ? Utils::get_sondage_from_id($numsondage) : false; -if (!$dsondage || $dsondage->id_sondage == '') { - Utils::print_header( _('Error!')); +if (!$dsondage || $dsondage->id_sondage == ''){ + Utils::print_header( _("Error!")); - bandeau_titre(_('Error!')); + bandeau_titre(_("Error!")); echo ' <div class="alert alert-warning"> - <h2>' . _('This poll doesn\'t exist !') . '</h2> + <h2>' . _("This poll doesn't exist !") . '</h2> <p>' . _('Back to the homepage of ') . ' <a href="' . Utils::get_server_name() . '"> ' . NOMAPPLICATION . '</a></p> </div>'."\n"; @@ -124,7 +124,7 @@ if(isset($_POST['ajoutcomment'])) { } -// Action quand on clique sur le bouton participer +// Action quand on clique le bouton participer $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)); @@ -136,21 +136,20 @@ if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) { $err |= NAME_EMPTY; } - if(!Utils::is_error(NAME_EMPTY) && (! ( USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']) ) || $_POST['nom'] == $_SESSION['nom'])) { + if(!Utils::is_error(NAME_EMPTY) && (! ( USE_REMOTE_USER && isset($_SERVER['REMOTE_USER']) ) || $_POST["nom"] == $_SESSION["nom"])) { $nouveauchoix = ''; for ($i=0;$i<$nbcolonnes;$i++) { // radio checked 1 = Yes, 2 = Ifneedbe, 0 = No - // TODO reuse getNewChoiceFromPOST of adminstuds.php see 8272e0db84fb65210eddf5a370e0c5a2411fea79 - if (isset($_POST['choix'. $i])) { - switch ($_POST['choix'. $i]) { - case 1: $nouveauchoix .= '1'; break; - case 2: $nouveauchoix .= '2'; break; - default: $nouveauchoix .= '0'; + if (isset($_POST["choix$i"])) { + switch ($_POST["choix$i"]) { + case 1: $nouveauchoix .= "1";break; + case 2: $nouveauchoix .= "2";break; + default: $nouveauchoix .= "0";break; } } } - $nom = substr($_POST['nom'], 0, 64); + $nom=substr($_POST["nom"],0,64); // protection contre les XSS : htmlentities $nom = htmlentities($nom, ENT_QUOTES, 'UTF-8'); @@ -173,14 +172,14 @@ if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) { // Todo : Il faudrait lever une erreur en cas d'erreur d'insertion $connect->Execute($sql, array($nom, $numsondage, $nouveauchoix)); - if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=='yes' || $dsondage->mailsonde=='true') { + if ($dsondage->mailsonde || /* compatibility for non boolean DB */ $dsondage->mailsonde=="yes" || $dsondage->mailsonde=="true") { if($config['use_smtp']==true){ - Utils::sendEmail( $dsondage->mail_admin, - '['.NOMAPPLICATION.'] '._('Poll\'s participation').' : '.html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), + Utils::sendEmail( "$dsondage->mail_admin", + "[".NOMAPPLICATION."] "._("Poll's participation")." : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8')."", html_entity_decode("\"$nom\" ", ENT_QUOTES, 'UTF-8'). - _('has filled a line.\nYou can find your poll at the link') . " :\n\n". + _("has filled a line.\nYou can find your poll at the link") . " :\n\n". Utils::getUrlSondage($numsondage) . " \n\n" . - _('Thanks for your confidence.') . "\n". NOMAPPLICATION ); + _("Thanks for your confidence.") . "\n". NOMAPPLICATION ); } } } @@ -190,22 +189,22 @@ if (!Utils::is_error(NO_POLL) && (isset($_POST["boutonp"]))) { } if($err != 0) { - Utils::print_header(_('Error!').' - '.$dsondage->titre); - bandeau_titre(_('Error!')); + Utils::print_header(_("Error!").' - '.$dsondage->titre); + bandeau_titre(_("Error!")); echo '<div class="alert alert-danger"><ul class="list-unstyled">'."\n"; if(Utils::is_error(NAME_EMPTY)) { - echo '<li>' . _('Enter a name') . "</li>\n"; + echo '<li>' . _("Enter a name") . "</li>\n"; } if(Utils::is_error(NAME_TAKEN)) { - echo '<li>' . _('The name you\'ve chosen already exist in this poll!') . "</li>\n"; + echo '<li>' . _("The name you've chosen already exist in this poll!") . "</li>\n"; } if(Utils::is_error(COMMENT_EMPTY) || Utils::is_error(COMMENT_USER_EMPTY)) { - echo '<li>' . _('Enter a name and a comment!') . "</li>\n"; + echo '<li>' . _("Enter a name and a comment!") . "</li>\n"; } if(Utils::is_error(COMMENT_INSERT_FAILED) ) { - echo '<li>' . _('Failed to insert the comment!') . "</li>\n"; + echo '<li>' . _("Failed to insert the comment!") . "</li>\n"; } echo '</ul></div>'; @@ -244,7 +243,7 @@ echo ' //affichage de la description du sondage if ($dsondage->commentaires) { $commentaires = $dsondage->commentaires; - $commentaires=nl2br(str_replace('\\', '', $commentaires)); + $commentaires=nl2br(str_replace("\\","",$commentaires)); echo ' <div class="form-group col-md-7"> <h4 class="control-label">'._("Description") .'</h4><br /> @@ -261,12 +260,12 @@ $nblignes = $user_studs->RecordCount(); //on teste pour voir si une ligne doit etre modifiée $testmodifier = false; $ligneamodifier = -1; -for ($i=0; $i < $nblignes; ++$i) { - if (isset($_POST['modifierligne'. $i])) { +for ($i=0;$i<$nblignes;$i++) { + if (isset($_POST["modifierligne$i"])) { $ligneamodifier = $i; } - //test pour voir si une ligne est à modifier + //test pour voir si une ligne est a modifier if (isset($_POST['validermodifier'.$i])) { $modifier = $i; $testmodifier = true; @@ -275,20 +274,19 @@ for ($i=0; $i < $nblignes; ++$i) { //si le test est valide alors on affiche des checkbox pour entrer de nouvelles valeurs if ($testmodifier) { - // TODO reuse getNewChoiceFromPOST of adminstuds.php see 8272e0db84fb65210eddf5a370e0c5a2411fea79 $nouveauchoix = ''; for ($i=0;$i<$nbcolonnes;$i++) { // radio checked 1 = Yes, 2 = Ifneedbe, 0 = No if (isset($_POST["choix$i"])) { switch ($_POST["choix$i"]) { - case 1: $nouveauchoix .= "1"; break; - case 2: $nouveauchoix .= "2"; break; - default: $nouveauchoix .= "0"; + case 1: $nouveauchoix .= "1";break; + case 2: $nouveauchoix .= "2";break; + default: $nouveauchoix .= "0";break; } } } - $compteur = 0; + $compteur=0; while ($data = $user_studs->FetchNextObject(false) ) { //mise a jour des données de l'utilisateur dans la base SQL if ($compteur == $modifier) { @@ -300,7 +298,7 @@ if ($testmodifier) { Utils::sendEmail( "$dsondage->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : ".html_entity_decode($dsondage->titre, ENT_QUOTES, 'UTF-8'), "\"".html_entity_decode($data->nom, ENT_QUOTES, 'UTF-8')."\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n" . Utils::getUrlSondage($numsondage) . " \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION ); } } - ++$compteur; + $compteur++; } } @@ -352,7 +350,7 @@ if ($dsondage->format=="D"||$dsondage->format=="D+"||$dsondage->format=="D-") { } else { $border[$i] = true; $tr_months .= '<th colspan="'.$colspan_month.'" class="bg-primary month" id="M'.($i+1-$colspan_month).'">'.strftime("%B",$horoCur[0]).' '.strftime("%Y", $horoCur[0]).'</th>'; - $colspan_month = 1; + $colspan_month=1; } // Days @@ -363,7 +361,7 @@ if ($dsondage->format=="D"||$dsondage->format=="D+"||$dsondage->format=="D-") { } else { $rbd = ($border[$i]) ? ' rbd' : ''; $tr_days .= '<th colspan="'.$colspan_day.'" class="bg-primary day'.$rbd.'" id="D'.($i+1-$colspan_day).'">'.strftime($date_format['txt_day'],$horoCur[0]).'</th>'; - $colspan_day = 1; + $colspan_day=1; } // Hours @@ -387,14 +385,13 @@ if ($dsondage->format=="D"||$dsondage->format=="D+"||$dsondage->format=="D-") { // Subjects poll } else { - $toutsujet=str_replace('@','<br />', $toutsujet); + $toutsujet=str_replace("@","<br />",$toutsujet); $tr_subjects = '<tr><th role="presentation"></th>'; - for ($i = 0; isset($toutsujet[$i]); ++$i) { + for ($i = 0; isset($toutsujet[$i]); $i++) { - $td_headers[$i] = ''; - $radio_title[$i] = ''; // init before concatenate + $td_headers[$i]='';$radio_title[$i]=''; // init before concatenate // Subjects preg_match_all('/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/',$toutsujet[$i],$md_a_img); // Markdown [](href) @@ -501,9 +498,9 @@ while ($data = $user_studs->FetchNextObject(false)) { // variable pour afficher la valeur cochée $car_html[0]='value="0"';$car_html[1]='value="1"';$car_html[2]='value="2"'; switch ($car) { - case '1': $car_html[1]='value="1" checked'; break; - case '2': $car_html[2]='value="2" checked'; break; - default: $car_html[0]='value="0" checked'; + case "1": $car_html[1]='value="1" checked';break; + case "2": $car_html[2]='value="2" checked';break; + default: $car_html[0]='value="0" checked';break; } echo ' @@ -538,7 +535,7 @@ while ($data = $user_studs->FetchNextObject(false)) { if (isset($somme[$k]) === false) { $somme[$k] = 0; } - ++$somme[$k]; break; + $somme[$k]++; break; case "2": echo '<td class="bg-warning text-warning'.$rbd.'" headers="'.$td_headers[$k].'">(<span class="glyphicon glyphicon-ok"></span>)<span class="sr-only"> ' . _('Yes') . _(', ifneedbe') . '</span></td>'."\n"; break; default: echo '<td class="bg-danger'.$rbd.'" headers="'.$td_headers[$k].'"><span class="sr-only">' . _('No') . '</span></td>'."\n"; } @@ -556,8 +553,8 @@ while ($data = $user_studs->FetchNextObject(false)) { } //demande de confirmation pour modification de ligne - for ($i=0; $i < $nblignes; ++$i) { - if (isset($_POST['modifierligne'. $i])) { + for ($i=0;$i<$nblignes;$i++) { + if (isset($_POST["modifierligne$i"])) { if ($compteur == $i) { echo '<td style="padding:5px"><button type="submit" class="btn btn-success btn-xs" name="validermodifier'.$compteur.'" title="'. _('Save the choices') .' '.stripslashes($nombase).'">'. _('Save') .'</button></td>'."\n"; } @@ -636,7 +633,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { } $tr_addition .= '<td></td></tr>'; -$meilleursujet = str_replace('°', '\'', $meilleursujet).'</ul>'; +$meilleursujet = str_replace("°", "'", $meilleursujet).'</ul>'; $vote_str = ($meilleurecolonne > 1) ? $vote_str = _('votes') : _('vote'); // Print Addition and Best choice @@ -674,7 +671,7 @@ $sql = $connect->Prepare($sql); $comment_user=$connect->Execute($sql, array($numsondage)); if ($comment_user->RecordCount() != 0) { - echo '<div><h3>' . _('Comments of polled people') . '</h3>'."\n"; + echo '<div><h3>' . _("Comments of polled people") . '</h3>'."\n"; while($dcomment = $comment_user->FetchNextObject(false)) { echo ' @@ -687,7 +684,7 @@ if ($comment_user->RecordCount() != 0) { echo '</div>'; } -if ($dsondage->format != 'A-' && $dsondage->format != 'D-') { +if ($dsondage->format!="A-" && $dsondage->format!="D-") { echo ' <div class="hidden-print alert alert-info"> <div class="col-md-6 col-md-offset-3"> -- GitLab