From eb13d74a54796fabaa4034eeb2e803f41c7424ab Mon Sep 17 00:00:00 2001 From: gburri Date: Tue, 30 Sep 2008 21:46:13 +0000 Subject: [PATCH] =?utf8?q?ADD=20informations=20concernant=20les=20jours=20?= =?utf8?q?pendant=20lesquels=20les=20participants=20sont=20pr=C3=A9sent=20?= =?utf8?q?(fini)=20ADD=20script=20de=20mise=20en=20prod?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn://localhost/cl7/trunk@6 4c3d3983-c6fa-4c6c-9935-18c3bbef1bf0 --- css/style.css | 8 ++++++++ index.php | 4 +++- js/cl7.js | 4 ++-- php/class_participant.php | 10 ++++----- php/config.php | 43 ++++++++++++++++----------------------- php/config_bd.php | 7 +++++++ php/connexion.php | 2 +- php/controller.php | 2 +- php/pizzas.php | 4 ++-- php/tx_inscrits.php | 32 +++++++++++++++++++++-------- php/update_db.php | 26 +++++++++++++++++++---- tools/exclude | 8 ++++++++ tools/mise_en_prod.sh | 10 +++++++++ 13 files changed, 109 insertions(+), 51 deletions(-) create mode 100644 php/config_bd.php create mode 100644 tools/exclude create mode 100755 tools/mise_en_prod.sh diff --git a/css/style.css b/css/style.css index eefd885..907ffd0 100644 --- a/css/style.css +++ b/css/style.css @@ -133,6 +133,14 @@ ul#menu { margin-top: 1px; margin-bottom: 0px; } +#contenu .inscrits .participe { + text-align: center; + background-image: url(../images/fond2.png); + background-repeat: repeat; +} +#contenu .inscrits .participe:before { + content: "×"; +} #informations { margin: 5px; diff --git a/index.php b/index.php index d8467fa..e1d6fb1 100644 --- a/index.php +++ b/index.php @@ -9,9 +9,9 @@ $MASK_RESEAU = '255.255.255.0'; if($titre[1] && (ip2long($REMOTE_ADDR) & ip2long($MASK_RESEAU)) != (ip2long($IP_SERVEUR) & ip2long($MASK_RESEAU))) */ -include_once("php/config.php"); include_once("php/class_participant.php"); include_once("php/connexion.php"); +include_once("php/config.php"); include_once("php/controller.php"); $MENU = array( @@ -36,6 +36,8 @@ echo ''; '; + echo ''; + echo ''; ?> Corcelles-Lan 7 diff --git a/js/cl7.js b/js/cl7.js index d482fdc..61a82a7 100644 --- a/js/cl7.js +++ b/js/cl7.js @@ -79,9 +79,9 @@ $(document).ready( $('a#contactPifou').attr('href', util.rot13('znvygb:tert.oheev@tznvy.pbz')); $('a#contactLePiaf').attr('href', util.rot13('znvygb:tyrcvns695@zfa.pbz')); - $('#formulaireInscription input[name="periodes[]"]').change(function() { + /*$('#formulaireInscription input[name="periodes[]"]').change(function() { cl7.maj_prix_inscription(); - }); + });*/ // met à jour le prix d'inscription cl7.maj_prix_inscription(); diff --git a/php/class_participant.php b/php/class_participant.php index d5f9c71..a402402 100644 --- a/php/class_participant.php +++ b/php/class_participant.php @@ -27,7 +27,7 @@ class Participant else # Sinon c'est l'id $res = mysql_query("SELECT * FROM participants WHERE id = " . addslashes($v1)); - if (mysql_num_rows($res) == 0) + if (mysql_error() || mysql_num_rows($res) == 0) { $this->valide = FALSE; } @@ -57,11 +57,11 @@ class Participant */ static function nombre_participant_max_atteint() { - global $NB_MAX_PARTICIPANT; + global $config; $res_SQL = mysql_query("SELECT COUNT(*) FROM participants"); $nb_participant = mysql_fetch_row($res_SQL); - return $nb_participant[0] >= $NB_MAX_PARTICIPANT; + return $nb_participant[0] >= $config->get('nb_max_participant'); } /** @@ -69,11 +69,11 @@ class Participant */ static function nombre_place_restante() { - global $NB_MAX_PARTICIPANT; + global $config; $res_SQL = mysql_query("SELECT COUNT(*) FROM participants"); $nb_participant = mysql_fetch_row($res_SQL); - return $NB_MAX_PARTICIPANT - $nb_participant[0]; + return $config->get('nb_max_participant') - $nb_participant[0]; } } diff --git a/php/config.php b/php/config.php index 220da45..c7f5ee5 100644 --- a/php/config.php +++ b/php/config.php @@ -1,29 +1,20 @@ config[$val->nom] = $val->valeur; + } + + function get($nom) + { + return $this->config[$nom]; + } + + private $config; +} -$COUT_PERIODE = 15; -$COUT_TOTAL = 40; - -# nombre maximum de participant -$NB_MAX_PARTICIPANT = 25; - -# nombre de votes possibles par participants -$NB_VOTES_JEUX = 3; - -# mettre à TRUE pour cloturer les inscriptions -$INSCRIPTIONS_TERMINEES = FALSE; - -# si la partie pizza est visible -$PIZZA_VISIBLE = 0; - -# si on peut commander des pizza (mettre a 0 lorsque on telephone pour commander ! ;) -$PIZZA_PEUT_COMMANDER = 1; +$config = new Config(); ?> diff --git a/php/config_bd.php b/php/config_bd.php new file mode 100644 index 0000000..10e53f8 --- /dev/null +++ b/php/config_bd.php @@ -0,0 +1,7 @@ + diff --git a/php/connexion.php b/php/connexion.php index 6f0ea85..0701270 100644 --- a/php/connexion.php +++ b/php/connexion.php @@ -4,7 +4,7 @@ * Produit une variable globale nommée '$le_participant'. */ -include_once("config.php"); +include_once("config_bd.php"); include_once("class_participant.php"); $lien_mysql = mysql_connect($SQL_HOTE, $SQL_LOGIN, $SQL_PASS); diff --git a/php/controller.php b/php/controller.php index 75a4668..5a40098 100644 --- a/php/controller.php +++ b/php/controller.php @@ -147,7 +147,7 @@ else if (isset($_POST['set_jeux_joues']) && $le_participant->valide) mysql_query("DELETE FROM jeux_choisis WHERE participant_id = " . $le_participant->info->id); # traite les trois premiers votes - for ($i = 0; $i < count($votes) && $i < $NB_VOTES_JEUX ; $i++) + for ($i = 0; $i < count($votes) && $i < $config->get('nb_votes_jeux'); $i++) { mysql_query("INSERT INTO jeux_choisis (participant_id, jeu_id) VALUES (".$le_participant->info->id.", ".(int)$votes[$i].")"); } diff --git a/php/pizzas.php b/php/pizzas.php index 31aad2d..ce43dd2 100644 --- a/php/pizzas.php +++ b/php/pizzas.php @@ -4,12 +4,12 @@ function selection_pizzas() { - global $PIZZA_PEUT_COMMANDER; + global $config; global $le_participant; $requ = mysql_query("select * from pizzas order by nom"); echo '

commande de pizza

'; - if ($PIZZA_PEUT_COMMANDER) + if ($config->get('pizza_peut_commander')) { if ($le_participant->info->pizza != null) echo '
Vous avez deja commandé une pizza ! mais vous pouvez encore changez votre choix:'; diff --git a/php/tx_inscrits.php b/php/tx_inscrits.php index 89ff6a0..eac8390 100644 --- a/php/tx_inscrits.php +++ b/php/tx_inscrits.php @@ -2,33 +2,47 @@ include_once("traitement_pre_affichage.php"); -$res = mysql_query("SELECT pseudo, nom, prenom, age, clan_nom, clan_tag, remarques FROM participants ORDER by clan_nom, clan_tag, pseudo"); - +$participants = mysql_query(" + SELECT id, pseudo, nom, prenom, clan_nom, clan_tag, remarques + FROM participants + ORDER by clan_nom, clan_tag, pseudo +"); + +$periodes = mysql_query("SELECT nom_abrege FROM periodes ORDER BY id"); $debut_table = ' - - - + '; +while($periode = mysql_fetch_object($periodes)) + $debut_table .= ''; +$debut_table .= ''; $clan_courant = null; -while($participant = mysql_fetch_object($res)) +while($participant = mysql_fetch_object($participants)) { if ($clan_courant !== $participant->clan_nom) { echo ($participant->clan_nom != '' ? '
pseudo nomprénomageremarquesprénom'.$periode->nom_abrege.'remarques

'.traitement_pre_affichage($participant->clan_nom).'

' : ''), $debut_table; $clan_courant = $participant->clan_nom; - } + } + + $participations = mysql_query(" + SELECT periodes.nom, participations.participant_id FROM periodes + LEFT JOIN participations ON periodes.id = participations.periode_id AND participations.participant_id = ".$participant->id." + ORDER BY id + "); echo ''; echo '', htmlentities($participant->clan_tag, ENT_QUOTES, "UTF-8"), traitement_pre_affichage($participant->pseudo), ''; echo '', traitement_pre_affichage($participant->nom), ''; - echo '', traitement_pre_affichage($participant->prenom), ''; - echo '', traitement_pre_affichage($participant->age), ''; + echo '', traitement_pre_affichage($participant->prenom), ''; + while ($participation = mysql_fetch_object($participations)) + echo 'participant_id == $participant->id ? 'class="participe"' : '').'>'; + echo '', traitement_pre_affichage($participant->remarques), ''; echo ''; } diff --git a/php/update_db.php b/php/update_db.php index c094a9e..356ba67 100644 --- a/php/update_db.php +++ b/php/update_db.php @@ -92,12 +92,13 @@ function update_db() CREATE TABLE IF NOT EXISTS periodes ( id mediumint(3) unsigned NOT NULL auto_increment, nom varchar(200) NOT NULL, + nom_abrege varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED; "); - mysql_query("INSERT INTO periodes (nom) VALUES ('Vendredi soir à samedi')"); - mysql_query("INSERT INTO periodes (nom) VALUES ('Samedi à dimanche')"); - mysql_query("INSERT INTO periodes (nom) VALUES ('Dimanche à lundi')"); + mysql_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('vendredi soir à samedi', 'v->s')"); + mysql_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('samedi à dimanche', 's->d')"); + mysql_query("INSERT INTO periodes (nom, nom_abrege) VALUES ('dimanche à lundi', 'd->l')"); mysql_query(" CREATE TABLE IF NOT EXISTS participations ( participant_id mediumint(3) unsigned NOT NULL, @@ -108,7 +109,24 @@ function update_db() CONSTRAINT FK_periode_participations FOREIGN KEY (periode_id) REFERENCES periodes (id) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; "); - mysql_query("UPDATE config SET valeur = '2' WHERE nom = 'version')"); + $participations = mysql_query("SELECT participants.id as participant_id, periodes.id as periode_id FROM participants, periodes"); + while ($participation = mysql_fetch_object($participations)) + { + mysql_query(" + INSERT INTO participations (participant_id, periode_id) + VALUES (".$participation->participant_id.",".$participation->periode_id.")" + ); + } + mysql_query("UPDATE config SET valeur = '2' WHERE nom = 'version'"); + + mysql_query("INSERT INTO config (nom, valeur) VALUES ('cout_periode', '15')"); + mysql_query("INSERT INTO config (nom, valeur) VALUES ('cout_total', '40')"); + mysql_query("INSERT INTO config (nom, valeur) VALUES ('nb_max_participant', '25')"); + mysql_query("INSERT INTO config (nom, valeur) VALUES ('nb_votes_jeux', '3')"); + mysql_query("INSERT INTO config (nom, valeur) VALUES ('inscription_terminees', 'FALSE')"); + mysql_query("INSERT INTO config (nom, valeur) VALUES ('pizza_visible', 'FALSE')"); + mysql_query("INSERT INTO config (nom, valeur) VALUES ('pizza_peut_commander', 'TRUE')"); + mysql_query("COMMIT"); } } diff --git a/tools/exclude b/tools/exclude new file mode 100644 index 0000000..ba0b200 --- /dev/null +++ b/tools/exclude @@ -0,0 +1,8 @@ +# fichier décrivant les éléments à ne pas copier lors de la mise ne prod. +# voir "mise_en_prod.sh" + +.*/ +doc/ +TODO +tools/ +/cl7_urlrewrite.erl \ No newline at end of file diff --git a/tools/mise_en_prod.sh b/tools/mise_en_prod.sh new file mode 100755 index 0000000..9d5c9fa --- /dev/null +++ b/tools/mise_en_prod.sh @@ -0,0 +1,10 @@ +#/bin/bash + +ADRESSE=gburri@euphorik.ch +REP=/var/www/lans/cl7 + +cd ../urlrewrite +erlc cl7_urlrewrite.erl +cd .. +rsync -r --delete --exclude-from=tools/exclude . $ADRESSE:$REP +ssh $ADRESSE "cd $REP; php-cgi php/update_db.php && rm php/update_db.php" \ No newline at end of file -- 2.45.2