root = $SiteRoot."/".$AlbmDir;
$this->albumDir = $AlbmDir;
$this->szNomBase = $table_APhotos;
$this->szPage = $Page;
/* How many column of image are printed. */
$this->nbImgCol = 2;
if ($numAlbum != "") {
$connect_db = jb_sql_connect (false);
$requete = "select * from $this->szNomBase where id='".
$numAlbum."'";
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
$row = mysql_fetch_row ($resultat);
$this->title = $row[1]." ".$row[2];
$this->Date = $row[4];
}
}
/**************************************************************************
* Retourne under a normal form the date of the album.
**************************************************************************/
function getDate()
{
return $this->Date;
}
/**************************************************************************
* Retourne the title.
**************************************************************************/
function getTitre()
{
return $this->title;
}
/**************************************************************************
* ListerAlbumPlusRecent:
* - Liste all the album of the colection.
* - The first on the top is the more recent one.
**************************************************************************/
function ListerAlbumPlusRecent ()
{
global $sql_serveur, $sql_bdd;
global $racine, $page_index;
/* on affiche l"entete du tableau. */
echo "
".
" ".
"Nom".
" ".
"
".
" ".
"Place".
" ".
"
départ.
Date
Ordre
Action
\n";
/* On se connecte sur la base de la gallerie. */
$connect_db = jb_sql_connect (false);
$requete = "select * from $this->szNomBase order by ordre";
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
$i = 0;
while ($row = mysql_fetch_row ($resultat))
{
if (($i % 2) == 0)
echo"
";
}
/**************************************************************************
* AjouterAlbumPlusRecent:
* - Add a new album photos.
*
**************************************************************************/
function AjouterAlbumPlusRecent ()
{
echo "
Ajout d'un nouvel Album.
\n";
$this->debutFormulaire ("ValideAjouter", 0);
}
/**************************************************************************
* InputJavaScript:
* - This function add javascripts functions to create a formated
* Date.
*
**************************************************************************/
function InputJavaScript ()
{
echo "\n";
}
// =================================================
function CreateDate()
{
echo"\n";
echo "\n";
echo "\n";
}
// =================================================
// Cette fonction Creer un formulaire pour la création d'un nouvel élément
function debutFormulaire ($valide, $naction)
{
global $racine, $page_index;
global $sql_serveur, $sql_bdd;
$this->InputJavaScript();
//echo "nid vaut ici :$this->nID ";
echo "";
} // fin debutFormulaire
// =================================================
function InsertNewAlbum ($name, $place, $dep, $ordre,
$jour, $mois, $annee)
{
global $sql_bdd, $racine, $page_index;
/* DEbug information:
print "name: ".$name."";
print "place: ".$place."";
print "ordre: ".$ordre."";
print "dep: ".$dep."";
print "jour: ".$jour."";
print "mois: ".$mois."";
print "annee: ".$annee."";*/
if (($name == '') || ($place == "") ||
($dep == ""))
echo "
Erreur !!! L'Album $name n'a pas été ajouté
certains champs sont vides
\n";
else {
if ($jour < 10)
$jour = "0".$jour;
if ($mois < 10)
$mois = "0".$mois;
$date = $jour."/".$mois."/".$annee;
/* On se connecte sur la base de l'album. */
$connect_db = jb_sql_connect (false);
/* Check if a previous entry had is ordrer. order should be unique.*/
$requete = "select * from ".$this->szNomBase." where ordre='$ordre'";
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
$nbElem = mysql_num_rows ($resultat);
if ($nbElem > 0) {
echo "
Erreur !!! L'Album $name n'a pas été ajouté".
" ".
"Un autre album est deja a la position: ".$ordre.
"
\n";
}
/* Get the ID of the Album. */
$requete = "select * from ".$this->szNomBase.
" where ordre='$ordre'";
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
$row = mysql_fetch_row ($resultat);
$id = $row[0];
/* Finaly, create root directory, where, the album store his
image. */
mkdir ($this->root."/album-".$id, 0750);
/* Create the directory for the mini images .*/
mkdir ($this->root."/album-".$id."/mini", 0750);
/* Create the directory for the normal images. */
mkdir ($this->root."/album-".$id."/normal", 0750);
MYSQL_CLOSE;
}
echo "
\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);
return -1;
$resultat = mysql_db_query ($sql_bdd,
"delete from $this->szNomBase where ".
"id=$num_elem",$connect_db);
/* Remove the images in the normal directory. */
$rootDir = $this->root."/album-".$num_elem."/normal";
if ($dh = opendir ($rootDir)) {
while (($file = readdir($dh)) !== false)
if (($file != ".") && ($file != ".."))
unlink ($rootDir."/".$file);
}
closedir($dh);
/* Remove the normal directory. */
rmdir ($rootDir);
/* Remove the mini directory. */
$rootDir = $this->root."/album-".$num_elem."/mini";
if ($dh = opendir ($rootDir)) {
while (($file = readdir($dh)) !== false)
if (($file != ".") && ($file != ".."))
unlink ($rootDir."/".$file);
}
closedir($dh);
/* Remove the mini directory. */
rmdir ($rootDir);
/* Remove the album directory. */
$rootDir = $this->root."/album-".$num_elem;
rmdir ($rootDir);
if ($resultat == 1)
echo "
L' élement message $num_elem a été effacé
\n";
else
echo "
BUG !!! suppression Impossible
\n";
MYSQL_CLOSE;
/* Remove all the file off this album. */
echo "
\n";
}
// =================================================
// Cette fonction supprime l'élement de base passé en paramètre
function Afficher ($num_elem)
{
global $racine, $racine, $page_index;
$rootDir = $this->root."/album-".$num_elem."/normal";
/* Print the form to add a new image on this album.*/
echo "Ajouter une image:".
"";
echo "
";
echo "
";
$numImg = 0;
/* Get the list of all the file in this directory. */
if (is_dir ($rootDir)) {
if ($dh = opendir ($rootDir)) {
while (($file = readdir($dh)) !== false) {
if (($file != ".") && ($file != "..")) {
if ($numImg == 2) {
echo "
";
}
// =================================================
// Cette fonction transfert dans le repertoire root des images
function upload ($num_elem, $ImgFile, $File_name)
{
/* Sizes:
- normal image: 800
- mini: 170
*/
$SizeNormalized = 800;
$sizeMini = 170;
$rootDir = $this->root."/album-".$num_elem."/";
/*echo "copy de : " .$ImgFile."";
echo ", vers: ".$rootDir.$File_name."";*/
/* Only managed JPEG type file. */
$size = getimagesize($ImgFile);
if (($size[2] == 2) && (imagetypes() & IMG_JPG)) {
/* Get image. */
$src = imagecreatefromjpeg ($ImgFile);
$worig = $size[0];
$horig = $size[1];
//print "Size orig: worig: $worig, horig: $horig";
/* The image is a rectangle with W bigger than the H. */
if ($worig > $horig) {
/* the width will be resized to 800.*/
if ($worig > 800) {
/* we resize the image.*/
$wNew = $SizeNormalized;
$hNew = intval ($horig / ($worig / $SizeNormalized));
}
else {
$wNew = $worig;
$hNew = $horig;
}
//print "new size: $wNew, $hNew";
/* we resize the mini image.*/
$wMini = $sizeMini;
$hMini = intval ($horig / ($worig / $sizeMini));
//print "new size: $wMin, $hMin";
}
else {
/* The image is vertical. */
/* The height will be resized to 800. */
if ($horig > 800) {
/* We resize the image. */
$wNew = intval ($worig / ($horig / $SizeNormalized));
$hNew = $SizeNormalized;
}
else {
$wNew = $worig;
$hNew = $horig;
}
//print "new size: $wNew, $hNew";
/* we resize the mini image.*/
$wMini = intval ($worig / ($horig / $sizeMini));
$hMini = $sizeMini;
}
}
else {
echo "Only JPEG photos are supported sorry !!";
return;
}
/* Create the normal image resized. */
$Normal = imagecreatetruecolor ($wNew, $hNew);
imagecopyresized ($Normal, $src, 0, 0, 0, 0,
$wNew, $hNew, $worig, $horig);
/* Write the new resized file.*/
/* Get the nb photos present actualy to */
if ($handle = opendir($rootDir."/normal/")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$nbFiles++;
}
}
closedir($handle);
}
/* Increment the nb of files for the new one. */
$nbFiles++;
if ($nbFiles < 10)
$nbFiles = "0".$nbFiles;
$file = $rootDir."/normal/".$nbFiles.".jpg";
imagejpeg ($Normal, $file);
/* Create the Thumb image resized. */
$Mini = imagecreatetruecolor ($wMini, $hMini);
imagecopyresized ($Mini, $src, 0, 0, 0, 0,
$wMini, $hMini, $worig, $horig);
/* Write the new resized file.*/
$file = $rootDir."/mini/".$nbFiles.".jpg";
/*print "Add (mini): " . $file;*/
imagejpeg ($Mini, $file);
/* Remove the uploaded file. */
unlink ($ImgFile);
//copy ($ImgFile, $rootDir.$File_name);
/* Then print the list of the images. */
$this->Afficher ($num_elem);
}
// =================================================
// Cette fonction remove from the hard Drive of an image.
function SuppImage ($elem, $file)
{
print "Suppression de l'image: $file (gallerie: $elem)
";
$rootDir = $this->root."/album-".$elem."/";
$fileNormal = $rootDir."normal/".$file;
$fileMini = $rootDir."mini/".$file;
unlink ($fileNormal);
unlink ($fileMini);
/* Then print the list of the images. */
$this->Afficher ($elem);
}
// =================================================
// This function allow the possibility of modify the album parameters.
function Modifier ($elem)
{
global $sql_bdd;
// On se connecte sur la base de Download
$connect_db = jb_sql_connect (false);
$requete = "select * from $this->szNomBase where id='$elem'";
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
$this->nID = mysql_result ($resultat, 0, "id");
$this->szName = mysql_result ($resultat, 0, "name");
$this->szPlace = mysql_result ($resultat, 0, "place");
$this->szDep = mysql_result ($resultat, 0, "dep");
$this->nOrdre = mysql_result ($resultat, 0, "ordre");
/* Split the date, to get the differents fields. */
$dateTexte = mysql_result ($resultat, 0, "date_texte");
list ($this->nJour, $this->nMois, $this->nAnnee) = split('/',
$dateTexte);
echo "
Modification de l'album: $this->szName
\n";
$this->debutFormulaire ("ValideModifier", 1);
mysql_free_result ($resultat);
MYSQL_CLOSE;
}
// =================================================
// This function allow the possibility of modify the album parameters.
function ValideModifierAlbum ($elem, $name, $place, $dep, $ordre,
$jour, $mois, $annee)
{
global $racine, $page_index, $sql_bdd;
if ($jour < 10)
$jour = "0".$jour;
if ($mois < 10)
$mois = "0".$mois;
$date = $jour."/".$mois."/".$annee;
/* On se connecte sur la base de l'album photos. */
$connect_db = jb_sql_connect (false);
$requete = "update $this->szNomBase set name='$name' ,place=".
"'$place',dep='$dep',ordre='$ordre',date_texte='$date' ".
"where id='$elem'";
$resultat = mysql_db_query($sql_bdd, $requete, $connect_db);
if ($resultat == 1)
echo "