Add Script of the site
This commit is contained in:
529
Scripts/AnnuAgenda.php
Normal file
529
Scripts/AnnuAgenda.php
Normal file
@@ -0,0 +1,529 @@
|
||||
<?
|
||||
/***************************************************************************
|
||||
AnnuAgenda.php - Classe Annu Agenda
|
||||
-------------------
|
||||
begin : Septembre UTC 2002
|
||||
copyright : (C) 2002 by NADAL Jean-Baptiste
|
||||
email : jbnadal@ifrance.com
|
||||
***************************************************************************
|
||||
*
|
||||
* Cette classe permet de gerer les concerts sur
|
||||
* le site de l'Harmonie de Montpellier-Jacou
|
||||
*
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************
|
||||
* $Id: AnnuAgenda.php,v 1.7 2005/03/10 18:08:46 jb Exp $
|
||||
***************************************************************************/
|
||||
|
||||
if (file_exists ("conf.php"))
|
||||
require ("conf.php");
|
||||
else
|
||||
require ("./Scripts/conf.php");
|
||||
|
||||
|
||||
class AnnuAgenda
|
||||
{
|
||||
// =============================================================
|
||||
// Les Variables
|
||||
var $szNomBase; /* nom de la base de travail. */
|
||||
var $szPage; /* Nom de la page courante dans le site. */
|
||||
var $nNbMorceaux;
|
||||
var $tab_Morceau;
|
||||
var $tab_list_select;
|
||||
var $taille_tab_Morceau;
|
||||
|
||||
var $nID;
|
||||
var $nHeure;
|
||||
var $nMin;
|
||||
var $nMois;
|
||||
var $nJour;
|
||||
var $nAnnee;
|
||||
var $szVille;
|
||||
var $szLieu;
|
||||
var $szCommentaire;
|
||||
var $szListeMorceaux;
|
||||
|
||||
// =============================================================
|
||||
// Constructeur
|
||||
function AnnuAgenda ($nomB, $page)
|
||||
{
|
||||
$this->szNomBase = $nomB;
|
||||
$this->szPage = $page;
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// Cette fonction permet de lister tous les downloads présent dans la base
|
||||
function Lister ()
|
||||
{
|
||||
global $racine, $page_index, $sql_bdd;
|
||||
|
||||
/* on affiche l"entete du tablo. */
|
||||
echo "<center><table border=0 width=\"95%\">
|
||||
<tr>
|
||||
<th bgcolor=\"#d5dee6\"> Date </th>
|
||||
<th bgcolor=\"#d5dee6\"> Ville </th>
|
||||
<th bgcolor=\"#d5dee6\" colspan=2>Action</th>
|
||||
</tr>\n";
|
||||
/* On se connecte sur la base de Annuaire. */
|
||||
$connect_db = jb_sql_connect (false);
|
||||
$resultat = mysql_db_query ($sql_bdd,
|
||||
"select * from $this->szNomBase order by".
|
||||
" date_php", $connect_db);
|
||||
$i = 0;
|
||||
while ($row = mysql_fetch_row ($resultat)) {
|
||||
|
||||
if (($i % 2) == 0)
|
||||
echo"<tr bgcolor=\"#DDDDDD\">\n";
|
||||
else
|
||||
echo "<tr bgcolor=\"#CCCCCC\">\n";
|
||||
|
||||
echo "<td>$row[1] </td>\n";
|
||||
echo "<td>$row[4] </td>\n";
|
||||
echo "<td><a href=$racine/$page_index?page=$this->szPage".
|
||||
"&nAction=modifier&elem=$row[0]>Modifier
|
||||
</a></td> \n";
|
||||
echo " <td><a href=$racine/$page_index?page=$this->szPage".
|
||||
"&nAction=supprimer&elem=$row[0]>Supprimer
|
||||
</a></td> </tr>\n";
|
||||
$i++;
|
||||
}
|
||||
mysql_free_result ($resultat);
|
||||
MYSQL_CLOSE;
|
||||
echo "</table> </center><br/><br/>";
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// Cette fonction supprime l'élement de base passé en paramètre
|
||||
function AjouterConcert ($nbMorceaux)
|
||||
{
|
||||
$this->nNbMorceaux = $nbMorceaux;
|
||||
echo "<center><h1> Ajout d'un nouveau Concert</h1></center><br>\n";
|
||||
$this->debutFormulaire ("ValideAjouter", 0);
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// Cette fonction permet de modifier un download présent dans la base
|
||||
function ModifierConcert ($elem, $nbmorceaux)
|
||||
{
|
||||
// Les variables locales
|
||||
global $sql_bdd;
|
||||
// Fin des variables locales
|
||||
|
||||
// On se connecte sur la base de Download
|
||||
$connect_db = jb_sql_connect (false);
|
||||
$resultat = mysql_db_query ($sql_bdd, "select * from $this->szNomBase".
|
||||
" where id='$elem'", $connect_db);
|
||||
|
||||
$this->nID = $elem;
|
||||
|
||||
$datephp = mysql_result ($resultat, 0, "date_php");
|
||||
$dateFOR = getdate ($datephp);
|
||||
$this->nJour = $dateFOR["mday"];
|
||||
$this->nMois = $dateFOR["mon"];
|
||||
$this->nAnnee = $dateFOR["year"];
|
||||
$this->nHeure = $dateFOR["hours"];
|
||||
$this->nMin = $dateFOR["minutes"];
|
||||
|
||||
if ($this->nMin < 9)
|
||||
$this->nMin = "0$this->nMin";
|
||||
|
||||
$this->szVille = mysql_result ($resultat, 0, "ville");
|
||||
$this->szLieu = mysql_result ($resultat, 0, "lieu");
|
||||
$this->szCommentaire = mysql_result ($resultat, 0, "commentaire");
|
||||
$this->szListeMorceaux = mysql_result ($resultat, 0, "liste_morceaux");
|
||||
if ($nbmorceaux != "")
|
||||
$this->nNbMorceaux = $nbmorceaux;
|
||||
|
||||
echo "<center><h1> Modification du Concert à $this->szVille </h1>
|
||||
</center><br>\n";
|
||||
$this->debutFormulaire ("ValideModifier", 2);
|
||||
mysql_free_result ($resultat);
|
||||
MYSQL_CLOSE;
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// Cette fonction Creer un formulaire pour la création d'un nouvel élément
|
||||
function debutFormulaire ($valide, $naction)
|
||||
{
|
||||
global $racine, $page_index;
|
||||
|
||||
$this->InputJavaScript();
|
||||
//echo "nid vaut ici :$this->nID<br>";
|
||||
echo "<form method=post action=$racine/$page_index?page=$this->szPage>
|
||||
<input type=hidden name=elem size=32 value=\"$this->nID\" />
|
||||
<input type=hidden name=nAction value=$valide />
|
||||
<table border=\"0\" align=\"center\">
|
||||
<tr>
|
||||
<td align=left>Date : </td>
|
||||
<td>\n";
|
||||
if ($naction == 0) {
|
||||
$this->nJour = 1;
|
||||
$this->nMois = 1;
|
||||
$this->nAnnee = 2002;
|
||||
$this->nHeure = 21;
|
||||
$this->nMin = "00";
|
||||
$this->szVille = "";
|
||||
$this->szLieu = "";
|
||||
$this->szCommentaire = " ";
|
||||
$this->szListeMorceaux = "";
|
||||
}
|
||||
|
||||
// On creer les trois boites permettant de sélectionner la date
|
||||
$this->CreateDate ();
|
||||
echo"</td>\n</tr><tr>\n<td> Heure : </td>\n<td>
|
||||
<input type=text name=heure value=$this->nHeure
|
||||
style='width:30px;' maxlength=2 /> h
|
||||
<input type=text name=Mins value='$this->nMin'
|
||||
style='width:30px;' maxlength=2 />
|
||||
</td>\n</tr><tr>\n<td> Ville : </td>\n<td>
|
||||
<input type=text name=ville value='$this->szVille'
|
||||
style='width:300px;' maxlength=250 />
|
||||
</td>\n</tr><tr>\n<td> Lieu : </td>\n<td>
|
||||
<input type=text name=lieu value='$this->szLieu'
|
||||
style='width:300px;' maxlength=250 />
|
||||
</td>\n</tr>\n";
|
||||
if ($naction == 2) {
|
||||
// Si la fonction est applelé par le mode modification
|
||||
echo "<tr>\n<td> Commentaire : </td>\n<td>
|
||||
<textarea name=commentaire wrap=virtual cols=40 rows=10>
|
||||
$this->szCommentaire</textarea>
|
||||
</td>\n</tr>\n";
|
||||
|
||||
$tablo = explode(";", $this->szListeMorceaux);
|
||||
$cpt = 0;
|
||||
|
||||
foreach ($tablo as $elem) {
|
||||
$this->tab_list_select[$cpt] = $elem;
|
||||
$cpt++;
|
||||
}
|
||||
//$this->nNbMorceaux =$cpt;
|
||||
if ( $this->nNbMorceaux == "")
|
||||
$this->nNbMorceaux = $cpt;
|
||||
|
||||
echo "<tr><td colspan=2>
|
||||
<br><br>
|
||||
<u> Nombre de morceaux du Concert</u> :
|
||||
<input type=text name=Forcenb value=$this->nNbMorceaux
|
||||
style='width:30px;' maxlength=2 />
|
||||
<input type=\"button\" value=\"Modifier\"
|
||||
onClick=\"modNBtracks(this.form)\" />";
|
||||
|
||||
|
||||
echo "<br>\n<input type=hidden name=nbmorceaux
|
||||
value='$this->nNbMorceaux' />";
|
||||
$this->CreateTabloMorceaux ();
|
||||
|
||||
for ($i = 1; $i <= $this->nNbMorceaux; $i++) {
|
||||
echo "<tr>\n<td> Morceau $i : </td>\n<td>\n";
|
||||
$this->CreateListeMorceaux ($i, $this->tab_list_select[$i-1]);
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</table><br><center><input type=submit value=valider />
|
||||
</center><br></form>";
|
||||
|
||||
} // fin debutFormulaire
|
||||
|
||||
function CreateTabloMorceaux ()
|
||||
{
|
||||
// Les variables locales
|
||||
global $sql_serveur;
|
||||
global $sql_bdd;
|
||||
global $sql_user;
|
||||
global $sql_passwd;
|
||||
global $table_repertoire;
|
||||
// Fin des variables locales
|
||||
|
||||
// On se connecte sur la base
|
||||
$connect_db = jb_sql_connect (false);
|
||||
$resultat = mysql_db_query ($sql_bdd, "select * from ".
|
||||
"$table_repertoire order by numero",
|
||||
$connect_db);
|
||||
$this->taille_tab_Morceau = 0;
|
||||
|
||||
while($row = mysql_fetch_array ($resultat)) {
|
||||
$col_id = $row["id"];
|
||||
$col_num = $row["numero"];
|
||||
$col_nom = $row["nom"];
|
||||
|
||||
$this->tab_Morceau[] = array ($col_id, "$col_num-$col_nom");
|
||||
$this->taille_tab_Morceau++;
|
||||
}
|
||||
}
|
||||
|
||||
function CreateListeMorceaux ($num, $elem)
|
||||
{
|
||||
echo "<select name='morceau_$num' >\n";
|
||||
for ($i = 0; $i < $this->taille_tab_Morceau; $i++) {
|
||||
list ($list_id, $list_nomMorceau) = $this->tab_Morceau[$i];
|
||||
if ($list_id==$elem)
|
||||
echo "<option value =$list_id selected> $list_nomMorceau ";
|
||||
else echo "<option value = $list_id > $list_nomMorceau";
|
||||
}
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
function CreateDate()
|
||||
{
|
||||
echo"<select name=day size=1 onChange='changeDays(1,this.form)'>\n";
|
||||
for ($i = 1; $i < 32; $i++)
|
||||
if ($this->nJour == $i)
|
||||
echo " <option value = $i selected> $i";
|
||||
else
|
||||
echo " <option value = $i> $i";
|
||||
echo"</select>\n";
|
||||
|
||||
echo "</select><select name=month onChange='changeDays(0,this.form)'
|
||||
size=1>\n";
|
||||
for ($i = 1; $i < 13; $i++)
|
||||
if ($this->nMois == $i)
|
||||
echo "<option value = $i selected> $i";
|
||||
else
|
||||
echo " <option value = $i> $i";
|
||||
echo"</select>\n";
|
||||
|
||||
echo "<select name=year onChange='changeDays(0,this.form)' size=1>\n";
|
||||
for ($i = 2000; $i < 2011; $i++)
|
||||
if ($this->nAnnee == $i)
|
||||
echo "<option value = $i selected> $i";
|
||||
else
|
||||
echo " <option value = $i> $i";
|
||||
echo"</select>\n";
|
||||
}
|
||||
|
||||
function InputJavaScript ()
|
||||
{
|
||||
echo "<script language=\"JavaScript1.1\">
|
||||
<!--
|
||||
var min_year = 2004; // defines lowest year in year menu
|
||||
var max_year = 2010; // defines highest year in the year menu
|
||||
|
||||
// make this false to prevent the weekday element from being displayed
|
||||
var weekday_showing = false;
|
||||
|
||||
// make this true to make dayofweek return a number (0-6)
|
||||
var dayofweek_returned_as_number = false;
|
||||
|
||||
// make this true to make month return a number (0-11)
|
||||
var month_returned_as_number = true;
|
||||
|
||||
if (min_year <= 400)
|
||||
alert(\"Minimum year must be higher than 400 for".
|
||||
" this algorithm to work.\");
|
||||
|
||||
function changeDays(numb,date_form)
|
||||
{
|
||||
mth = date_form.month.selectedIndex;
|
||||
sel = date_form.year.selectedIndex;
|
||||
yr = date_form.year.options[sel].text;
|
||||
if (numb != 1)
|
||||
{
|
||||
numDays = numDaysIn(mth,yr);
|
||||
date_form.day.options.length = numDays;
|
||||
for (i=27;i<numDays;i++) {
|
||||
date_form.day.options[i].text = i+1; }
|
||||
}
|
||||
day = date_form.day.selectedIndex+1;
|
||||
if (weekday_showing)
|
||||
date_form.dayofweek.selectedIndex = ".
|
||||
"getWeekDay(mth,day,yr);
|
||||
}
|
||||
|
||||
function numDaysIn(mth,yr)
|
||||
{
|
||||
if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
|
||||
else if ((mth==1) && leapYear(yr)) return 29;
|
||||
else if (mth==1) return 28;
|
||||
else return 31;
|
||||
}
|
||||
|
||||
function leapYear(yr)
|
||||
{
|
||||
if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function arr()
|
||||
{
|
||||
this.length=arr.arguments.length;
|
||||
for (n=0;n<arr.arguments.length;n++)
|
||||
this[n] = arr.arguments[n];
|
||||
}
|
||||
|
||||
weekdays = new arr(\"Sun.\",\"Mon.\",\"Tues.\",\"Wed.\",\"Thurs.\",".
|
||||
"\"Fri.\",\"Sat.\");
|
||||
// *** comment out the one you don't want to use ***
|
||||
//weekdays = new arr(\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",
|
||||
// \"Thursday\",\"Friday\",\"Saturday\");
|
||||
|
||||
months = new arr(\"01\",\"02\",\"03\",\"04\",\"05\", \"06\",\"07\",".
|
||||
"\"08\",\"09\",\"10\",\"11\",\"12\");
|
||||
// *** comment out the one you don't want to use ***
|
||||
//months = new arr(\"January\",\"February\",\"March\",\"April\",".
|
||||
"\"May\",
|
||||
// \"June\",\"July\",\"August\",\"September\",\"October\",".
|
||||
"\"November\",\"December\");
|
||||
|
||||
var cur = new Date();
|
||||
|
||||
function getWeekDay(mth,day,yr)
|
||||
{
|
||||
first_day = firstDayOfYear(yr);
|
||||
for (num=0;num<mth;num++)
|
||||
first_day += numDaysIn(num,yr);
|
||||
first_day += day-1;
|
||||
return first_day%7;
|
||||
}
|
||||
function firstDayOfYear(yr)
|
||||
{
|
||||
diff = yr - 401;
|
||||
return parseInt((1 + diff + (diff / 4) - (diff / 100) + ".
|
||||
"(diff / 400)) % 7);
|
||||
}
|
||||
// fixes a Netscape 2 and 3 bug
|
||||
function getFullYear(d)
|
||||
{ // d is a date object
|
||||
yr = d.getYear();
|
||||
if (yr < 1000)
|
||||
yr+=1900;
|
||||
return yr;
|
||||
}
|
||||
function modNBtracks(pForm)
|
||||
{
|
||||
pForm.nAction.value = \"modifier\";
|
||||
//alert('Vous avez oublié de saisir votre nom !');
|
||||
pForm.submit();
|
||||
}
|
||||
// -->
|
||||
</script>\n";
|
||||
}
|
||||
|
||||
|
||||
// =================================================
|
||||
// Cette fonction supprime l'élement de base passé en paramètre
|
||||
function Supprimer ($num_elem)
|
||||
{
|
||||
global $racine, $page_index, $sql_bdd;
|
||||
|
||||
// On se connecte sur la base
|
||||
$connect_db = jb_sql_connect(false);
|
||||
$resultat = mysql_db_query($sql_bdd, "delete from $this->szNomBase".
|
||||
" where id=$num_elem", $connect_db);
|
||||
if ($resultat == 1)
|
||||
echo "<br><br><center><font size=4 color=red>
|
||||
<b>L' élement message $num_elem a été effacé</b>
|
||||
</font></center><br><br>\n";
|
||||
else
|
||||
echo "<br><br><center><font size=6 color=red>
|
||||
<b>BUG !!! suppression Impossible</b></font></center>
|
||||
<br><br>\n";
|
||||
|
||||
MYSQL_CLOSE;
|
||||
echo "<br><br>
|
||||
<center><a href=$racine/$page_index?page=$this->szPage>
|
||||
Retour à la page d'administration de l'Agenda
|
||||
</a> </center> \n";
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// Cette fonction Rajoute une entree dans la base de données
|
||||
function InsertConcert ($date_texte, $date_php, $heure_deb, $ville,
|
||||
$lieu, $liste_morceaux, $commentaire)
|
||||
{
|
||||
global $racine, $page_index, $sql_bdd;
|
||||
|
||||
/*
|
||||
echo "
|
||||
date_texte : $date_texte <br>
|
||||
date_php : $date_php <br>
|
||||
heure_deb : $heure_deb <br>
|
||||
ville : $ville <br>
|
||||
lieu : $lieu <br>
|
||||
liste_morceaux : $liste_morceaux <br>
|
||||
commentaire : $commentaire <br>";
|
||||
|
||||
echo " nom : $nom <br> compo : $compositeur <br> style : $Style <br>
|
||||
numero : $num<br> id : $elem";
|
||||
*/
|
||||
if (($date_php == '') || ($ville == "") || ($lieu == ""))
|
||||
echo "<br><br><center><font size=6 color=red>
|
||||
<b>BUG !!! Le Concert à $ville n'a pas été ajouté</b>
|
||||
</font><br> certains champs sont vides</center><br><br>\n";
|
||||
else {
|
||||
// On se connecte sur la base de Download
|
||||
$connect_db = jb_sql_connect(false);
|
||||
$resultat = mysql_db_query($sql_bdd,"insert into $this->szNomBase".
|
||||
" (date_texte, date_php, heure_deb,".
|
||||
"ville,lieu, liste_morceaux,".
|
||||
"commentaire ) values ('$date_texte',".
|
||||
"'$date_php', '$heure_deb', '$ville',".
|
||||
"'$lieu', '$liste_morceaux',".
|
||||
" '$commentaire' )", $connect_db);
|
||||
if ($resultat == 1)
|
||||
echo "<br><br><center><font size=4 color=red>
|
||||
<b>Le Concert à $ville a été Ajouté</b></font></center>
|
||||
<br><br>\n";
|
||||
else
|
||||
echo "<br><br><center><font size=6 color=red>
|
||||
<b>BUG !!! LeConcert à $ville n'a pas été ajouté</b>
|
||||
</font></center><br><br>\n";
|
||||
|
||||
MYSQL_CLOSE;
|
||||
}
|
||||
echo "<br/><br/>
|
||||
<center><a href=$racine/$page_index?page=$this->szPage>
|
||||
Retour à la page d'administration de l'Agenda</a>
|
||||
</center> \n";
|
||||
}
|
||||
|
||||
|
||||
// =================================================
|
||||
// Cette fonction Rajoute une entree dans la base de données
|
||||
function ValideModifierConcert ($elem, $date_texte, $date_php, $heure_deb,
|
||||
$ville, $lieu, $liste_morceaux,
|
||||
$commentaire)
|
||||
{
|
||||
global $racine, $page_index, $sql_bdd;
|
||||
|
||||
|
||||
/* echo " nom : $nom <br> compo : $compositeur <br> style :
|
||||
* $Style <br> numero : $num<br> id : $elem";
|
||||
*
|
||||
* On se connecte sur la base de Download
|
||||
*/
|
||||
$connect_db = jb_sql_connect(false);
|
||||
$requete = "update $this->szNomBase".
|
||||
" set date_texte='$date_texte' ,date_php=".
|
||||
"'$date_php', heure_deb='$heure_deb',".
|
||||
" ville='$ville', lieu='$lieu',".
|
||||
"liste_morceaux='$liste_morceaux',".
|
||||
" commentaire='$commentaire' where ".
|
||||
"id='$elem'";
|
||||
|
||||
$resultat = mysql_db_query($sql_bdd, $requete, $connect_db);
|
||||
if ($resultat == 1)
|
||||
echo "<br><br><center><font size=4 color=red>
|
||||
<b>L' élement $elem a été Modifié</b></font></center>
|
||||
<br><br>\n";
|
||||
else
|
||||
echo "<br><br><center><font size=6 color=red>
|
||||
<b>BUG !!! L' élement $elem n'a pas été Modifié</b></font>
|
||||
</center><br><br>\n";
|
||||
|
||||
MYSQL_CLOSE;
|
||||
echo "<br><br>
|
||||
<center><a href=$racine/$page_index?page=$this->szPage>
|
||||
Retour à la page d'administration de
|
||||
l'Agenda</a> </center> \n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user