Add Script of the site
This commit is contained in:
867
Scripts/AlbumPhotos.php
Normal file
867
Scripts/AlbumPhotos.php
Normal file
@@ -0,0 +1,867 @@
|
||||
<?php
|
||||
/*
|
||||
*********************************************************************
|
||||
* File : $RCSfile: AlbumPhotos.php,v $
|
||||
* Version : $Revision: 1.7 $
|
||||
* Modified by : $Author: jb $ ($Date: 2005/04/17 16:44:32 $)
|
||||
*********************************************************************
|
||||
Classe Cadre
|
||||
V 0.01 : NADAL Jean-Baptiste : 02 03 2001
|
||||
V 2.0: : rewrite the module to administrat it trought the web site.
|
||||
*/
|
||||
|
||||
class AlbumPhotos {
|
||||
|
||||
/* Déclaraion of the members variables. */
|
||||
var $root;
|
||||
var $albumDir;
|
||||
var $nOrdre;
|
||||
var $nJour;
|
||||
var $nMois;
|
||||
var $nAnnee;
|
||||
var $szName;
|
||||
var $szPlace;
|
||||
var $szDep;
|
||||
|
||||
/**************************************************************************
|
||||
* Constructeur
|
||||
**************************************************************************/
|
||||
function AlbumPhotos ($Page, $SiteRoot, $AlbmDir, $numAlbum)
|
||||
{
|
||||
global $table_APhotos, $KeyAdmAlbm, $sql_bdd;
|
||||
$this->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 "<center><table border=0 width=\"95%\">
|
||||
<tr>
|
||||
<th bgcolor=\"#d5dee6\">".
|
||||
" ".
|
||||
"Nom".
|
||||
" ".
|
||||
"</th>
|
||||
<th bgcolor=\"#d5dee6\">".
|
||||
" ".
|
||||
"Place".
|
||||
" ".
|
||||
"</th>
|
||||
<th bgcolor=\"#d5dee6\"> départ. </th>
|
||||
<th bgcolor=\"#d5dee6\"> Date </th>
|
||||
<th bgcolor=\"#d5dee6\"> Ordre </th>
|
||||
<th bgcolor=\"#d5dee6\" colspan=3> Action</th>
|
||||
</tr>\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"<tr bgcolor=\"#DDDDDD\" align=\"center\">\n";
|
||||
else
|
||||
echo "<tr bgcolor=\"#CCCCCC\" align=\"center\">\n";
|
||||
/* name. */
|
||||
if (strlen ($row[1]) > 13)
|
||||
$nom = substr($row[1], 0, 13)."...";
|
||||
else
|
||||
$nom = $row[1];
|
||||
echo "<td>".$nom ."</td>\n";
|
||||
/* place. */
|
||||
if (strlen ($row[2]) > 13)
|
||||
$place = substr($row[2], 0, 13)."...";
|
||||
else
|
||||
$place = $row[2];
|
||||
echo "<td>".$place ."</td>\n";
|
||||
/* dep. */
|
||||
echo "<td>".$row[3] ."</td>\n";
|
||||
/* date_text. */
|
||||
echo "<td>".$row[4] ."</td>\n";
|
||||
/* ordre. */
|
||||
echo "<td>".$row[5] ."</td>\n";
|
||||
|
||||
echo "<td>";
|
||||
echo "
|
||||
<a href=$racine/$page_index?page=$this->szPage&".
|
||||
"action=modifier&elem=$row[0]>Modifier</a>
|
||||
</td>
|
||||
<td><a href=$racine/$page_index?page=$this->szPage&".
|
||||
"action=supprimer&elem=$row[0]>Supprimer</a>".
|
||||
"</td>
|
||||
<td><a href=$racine/$page_index?page=$this->szPage&".
|
||||
"action=afficher&elem=$row[0]>Afficher</a>";
|
||||
|
||||
|
||||
echo "</td> </tr>\n";
|
||||
$i++;
|
||||
}
|
||||
mysql_free_result ($resultat);
|
||||
MYSQL_CLOSE;
|
||||
echo "</table> </center><br><br>";
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* AjouterAlbumPlusRecent:
|
||||
* - Add a new album photos.
|
||||
*
|
||||
**************************************************************************/
|
||||
function AjouterAlbumPlusRecent ()
|
||||
{
|
||||
echo "<center><h1> Ajout d'un nouvel Album.</h1></center><br>\n";
|
||||
$this->debutFormulaire ("ValideAjouter", 0);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* InputJavaScript:
|
||||
* - This function add javascripts functions to create a formated
|
||||
* Date.
|
||||
*
|
||||
**************************************************************************/
|
||||
function InputJavaScript ()
|
||||
{
|
||||
echo "<script language=\"JavaScript1.1\">
|
||||
<!--
|
||||
var min_year = 2000; // 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";
|
||||
}
|
||||
|
||||
// =================================================
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
// =================================================
|
||||
// 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<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=action value=$valide />
|
||||
<table border=\"0\" align=\"center\">
|
||||
<tr>";
|
||||
if ($naction == 0) {
|
||||
$this->nJour = 1;
|
||||
$this->nMois = 1;
|
||||
$this->nAnnee = 2002;
|
||||
$this->szName = "";
|
||||
$this->szPlace = "";
|
||||
$this->szDep = " ";
|
||||
$connect_db = jb_sql_connect (false);
|
||||
$requete = "select * from $this->szNomBase";
|
||||
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
|
||||
$nbElem = mysql_num_rows ($resultat);
|
||||
MYSQL_CLOSE;
|
||||
$this->nOrdre = $nbElem + 1;
|
||||
}
|
||||
|
||||
// On creer les trois boites permettant de sélectionner la date
|
||||
echo"<tr>\n<td> Nom : </td>\n<td>
|
||||
<input type=text name='name' value=\"".$this->szName."\"".
|
||||
" style='width:300px;' maxlength=50 /></td>\n</tr>";
|
||||
echo"<tr>\n<td> Place : </td>\n<td>
|
||||
<input type=text name='place' value=\"".$this->szPlace."\"".
|
||||
" style='width:300px;' maxlength=50 /></td>\n</tr>";
|
||||
echo"<tr>\n<td> Département : </td>\n<td>
|
||||
<input type=text name='dep' value=\"".$this->szDep."\"".
|
||||
" style='width:30px;' maxlength=2 /></td>\n</tr>";
|
||||
echo"<tr>\n<td> Date : </td>\n<td>";
|
||||
$this->CreateDate ();
|
||||
echo "</td>\n</tr>";
|
||||
echo"<tr>\n<td> Position : </td>\n<td>
|
||||
<input type=text name='ordre' value=\"".$this->nOrdre."\"".
|
||||
" style='width:30px;' maxlength=2 /></td>\n</tr>";
|
||||
|
||||
echo "</table><br><center><input type=submit value=valider />
|
||||
</center><br></form>";
|
||||
|
||||
} // fin debutFormulaire
|
||||
|
||||
// =================================================
|
||||
function InsertNewAlbum ($name, $place, $dep, $ordre,
|
||||
$jour, $mois, $annee)
|
||||
{
|
||||
global $sql_bdd, $racine, $page_index;
|
||||
|
||||
/* DEbug information:
|
||||
print "name: ".$name."</br>";
|
||||
print "place: ".$place."</br>";
|
||||
print "ordre: ".$ordre."</br>";
|
||||
print "dep: ".$dep."</br>";
|
||||
print "jour: ".$jour."</br>";
|
||||
print "mois: ".$mois."</br>";
|
||||
print "annee: ".$annee."</br>";*/
|
||||
|
||||
|
||||
if (($name == '') || ($place == "") ||
|
||||
($dep == ""))
|
||||
echo "<br/><br/><center> <font size=6 color=red>
|
||||
<b>Erreur !!! L'Album $name n'a pas été ajouté</b></font><br/>
|
||||
certains champs sont vides</center><br><br>\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 "<br/><br/><center> <font size=6 color=red>
|
||||
<b>Erreur !!! L'Album $name n'a pas été ajouté</b>".
|
||||
"</font><br/>".
|
||||
"Un autre album est deja a la position: ".$ordre.
|
||||
"</center><br><br>\n";
|
||||
}
|
||||
else {
|
||||
$requete = "insert into ".$this->szNomBase .
|
||||
"(name,place,ordre,dep,date_texte)".
|
||||
" values ('$name','$place','$ordre','$dep','$date' )";
|
||||
|
||||
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
|
||||
|
||||
if ($resultat == 1) {
|
||||
echo "<br><br><center><font size=4 color=red>".
|
||||
"<b>L'Album $name a été Ajouté</b></font>".
|
||||
"</center><br/><br/>\n";
|
||||
}
|
||||
else {
|
||||
echo "<br><br><center><font size=6 color=red>".
|
||||
"<b>BUG !!! L'Album $name n'a pas été ajouté</b>".
|
||||
"</font></center><br/><br/>\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 "<br/><br/>
|
||||
<center><a href=$racine/$page_index?page=$this->szPage>
|
||||
Retour à la page d'administration des Albums</a></center>\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 "<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;
|
||||
|
||||
/* Remove all the file off this album. */
|
||||
|
||||
|
||||
echo "<br/><br/>
|
||||
<center><a href=$racine/$page_index?page=$this->szPage>
|
||||
Retour à la page d'administration des Albums.</a></center>\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 "<font size =\"-1\" face=\"arial, helvetica\">Ajouter une image:".
|
||||
"</font>";
|
||||
echo "<center><form enctype=\"multipart/form-data\" method=\"post\" ".
|
||||
"action=\"$PHP_SELF?page=$this->szPage\">";
|
||||
echo "<input type=\"hidden\" name=\"elem\" size=\"32\" ".
|
||||
"value=\"$num_elem\" />";
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"upload\" />";
|
||||
echo "<input name=\"imgfile\" type=\"file\" size=\"40\">";
|
||||
echo "<input type=\"submit\" upload=\"upload\" value=\"Go!\">";
|
||||
echo "</form></center>";
|
||||
echo "<hr><center><table border=2><tr>";
|
||||
$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 "<tr>";
|
||||
$numImg = 0;
|
||||
}
|
||||
echo "<td align=\"center\"><table><tr><td>".
|
||||
"<img src=\"".$racine."/".$this->albumDir.
|
||||
"/album-".$num_elem."/mini/".$file."\"></td></tr>".
|
||||
"<tr><td align=\"center\">".
|
||||
"<a href=$racine/$page_index?page=".
|
||||
$this->szPage."&action=".
|
||||
"suppImage&elem=".$num_elem."&file=".$file.">".
|
||||
"Supprimer</a></td></tr></table></td>";
|
||||
$numImg += 1;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
echo "</tr></table></center>";
|
||||
}
|
||||
|
||||
// =================================================
|
||||
// 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."</br>";
|
||||
echo ", vers: ".$rootDir.$File_name."</br>";*/
|
||||
|
||||
/* 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)<br><br>";
|
||||
$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 "<center><h1> Modification de l'album: $this->szName </h1>
|
||||
</center><br/>\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 "<br/><br/><center><font size=4 color=red>
|
||||
<b>L'album $name a été Modifié</b></font>
|
||||
</center><br/><br/>\n";
|
||||
else
|
||||
echo "<br/><br/><center><font size=6 color=red>
|
||||
<b>BUG !!! L'album $name 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'album photos".
|
||||
"</a></center>\n";
|
||||
}
|
||||
|
||||
|
||||
function AfficheAbumRacine ($Rep)
|
||||
{
|
||||
global $sql_bdd, $AlbumRoot, $racine;
|
||||
|
||||
$connect_db = jb_sql_connect (false);
|
||||
$requete = "select * from $this->szNomBase order by ordre desc";
|
||||
$resultat = mysql_db_query ($sql_bdd, $requete, $connect_db);
|
||||
$i = 0;
|
||||
echo "<br><center><table border=2 width=\"75%\"><tr>\n";
|
||||
|
||||
while ($row = mysql_fetch_row ($resultat)) {
|
||||
$fichier = $racine ."/".$AlbumRoot."/album-".$row[0].
|
||||
"/mini/01.jpg";
|
||||
echo "<td align=\"center\">
|
||||
<a href=\"$page_index?page=".
|
||||
$this->szPage."&palb=$row[0]\">\n";
|
||||
$commentaire = $row[1]." ".$row[2]." (".$row[3].")<br>".
|
||||
"le ".$row[4];
|
||||
echo "<img src=$fichier alt=$array[$i] border=0></a><br>\n
|
||||
<table width=\"180\" height=\"61\">
|
||||
<tr>
|
||||
<td background=\"$racine/Imgs/raye10.gif\"
|
||||
bgcolor=\"#5b8cc1\" valign=center>\n
|
||||
<br><font color=\"white\">
|
||||
<center>$commentaire</center>
|
||||
</font>
|
||||
</td>
|
||||
</tr>
|
||||
</table> </td>";
|
||||
if ($i == 1) {
|
||||
echo "</tr><tr>";
|
||||
$i = 0;
|
||||
}
|
||||
else
|
||||
$i = $i + 1;
|
||||
}
|
||||
echo "</tr></table>\n";
|
||||
echo "</center> \n";
|
||||
}
|
||||
|
||||
function AfficheAbum ($Rep)
|
||||
{
|
||||
global $racine, $AlbumRoot;
|
||||
|
||||
$monRepertoire = opendir($this->root."/album-".$Rep."/normal");
|
||||
$precedent ="";
|
||||
$suivant = "";
|
||||
$bTrouve =false;
|
||||
echo "<br><center><table border=2 width=\"75%\"><tr>\n";
|
||||
$i = 0;
|
||||
|
||||
while ($entryName = readdir ($monRepertoire)) {
|
||||
if (($entryName != ".") && ($entryName != "..")) {
|
||||
$fichier = $racine ."/".$AlbumRoot."/album-".$Rep.
|
||||
"/mini/".$entryName;
|
||||
echo "<td align=\"center\">
|
||||
<a href=\"$page_index?page=".$this->szPage.
|
||||
"&palb=$Rep&img=".$entryName."\">\n
|
||||
<img src=$fichier alt=$array[$i] border=0></a>";
|
||||
|
||||
if ($i == 1) {
|
||||
echo "</tr><tr>";
|
||||
$i = 0;
|
||||
}
|
||||
else
|
||||
$i = $i + 1;
|
||||
}
|
||||
}
|
||||
echo "</tr></table>\n";
|
||||
echo "<br /><br />
|
||||
<b>Clicker sur l'image pour voir la collection</b><br><br>\n";
|
||||
echo "<table border=1><tr>\n";
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=racine >\n";
|
||||
echo "<img src=$racine/Imgs/home.gif alt=home border=0></a></td>\n";
|
||||
/*
|
||||
if ($precedent == "")
|
||||
echo "<td><a href=$page_index?page=album_photo&palb=racine >\n";
|
||||
else
|
||||
echo "<td><a href=$page_index?page=album_photo&palb=$precedent>\n";
|
||||
echo "<img src=$racine/Imgs/back.gif alt=back border=0></a></td>\n";
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=racine >\n";
|
||||
echo "<img src=$racine/Imgs/home.gif alt=home border=0></a></td>\n";
|
||||
if ( $suivant =="")
|
||||
echo "<td><a href=$page_index?page=album_photo&palb=racine >\n";
|
||||
else
|
||||
echo "<td><a href=$page_index?page=album_photo&palb=$suivant>\n";
|
||||
echo "<img src=$racine/Imgs/forward.gif alt=suivant border=0></a></td>\n";
|
||||
*/
|
||||
echo "</tr></table>\n";
|
||||
}
|
||||
|
||||
/* Affiche a specific image of a specific album. */
|
||||
function AfficheImage ($Rep, $NumImg)
|
||||
{
|
||||
global $page_index, $racine;
|
||||
global $racine, $AlbumRoot;
|
||||
|
||||
$ImgPath = $this->root."/album-".$Rep."/normal";
|
||||
$ImgPathWeb = $racine ."/".$AlbumRoot."/album-".$Rep."/normal";
|
||||
|
||||
$fichier ="\"$ImgPathWeb/$NumImg\"";
|
||||
echo "<img src=$fichier alt=$NumImg>\n";
|
||||
$chemin = "$this->szCheminAlbum/$Rep/normal";
|
||||
|
||||
$monRepertoire = opendir($ImgPath);
|
||||
$precedent ="";
|
||||
$suivant = "";
|
||||
$bTrouve =false;
|
||||
while ($entryName = readdir ($monRepertoire)) {
|
||||
|
||||
if (($entryName !=".") && ($entryName !="..")) {
|
||||
if ($bTrouve == true) {
|
||||
$suivant = $entryName;
|
||||
break;
|
||||
}
|
||||
if ($entryName == $NumImg)
|
||||
$bTrouve = true;
|
||||
|
||||
if ($bTrouve == false)
|
||||
$precedent =$entryName;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<br><br><center><table border=1><tr>\n";
|
||||
if ( $precedent =="")
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=$Rep>\n";
|
||||
else
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=$Rep&img=$precedent >\n";
|
||||
echo "<img src=$racine/Imgs/back.gif alt=back border=0></a></td>\n";
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=$Rep>\n";
|
||||
echo "<img src=$racine/Imgs/home.gif alt=home border=0></a></td>\n";
|
||||
if ( $suivant=="")
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=$Rep>\n";
|
||||
else
|
||||
echo "<td><a href=$page_index?page=$this->szPage&palb=$Rep&img=$suivant >\n";
|
||||
echo "<img src=$racine/Imgs/forward.gif alt=suivant border=0></a></td>\n";
|
||||
echo "</tr></table></center>\n";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user