New file |
0,0 → 1,211 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: eflore_photo.inc.php,v 1.1 2004-06-17 13:23:16 linda Exp $ |
/** |
* Titre |
* |
* Description |
* |
*@package nom_du_paquetage |
*@subpackage nom_du_sous-paquetage_si_necessaire |
//Auteur original : |
*@author linda ANGAMA<linda_angama@yahoo.fr> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ $Date: 2004-06-17 13:23:16 $ |
*/ |
|
session_start(); |
$res=""; |
$res.="<HTML><HEAD><link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"photo.css\" /></HEAD><BODY>"; |
|
error_reporting(E_ALL); |
include_once "DB.php"; |
|
if (isset($agrandit)) |
{ |
$res.="<div align=\"center\">"; |
$res.="<p><a href=\"photo.php?".SID."&deb=".$_SESSION['dep']."\">Retour à la miniature</a></p>"; |
$res.="<img src=\"".$agrandit."\"></div>"; |
unset($agrandit); |
echo $res; |
} |
|
$_SESSION['dep']=$deb; |
echo $deb; |
$path_rdf="/home/linda/Documents/testphp/rdf/"; |
$sep="\"\n"; |
if (!isset($deb)){$deb=0;} |
$img_pg=6; |
$prec=null; |
$suiv=null; |
|
//en-tete commune a tous les fichiers rdf |
$en_tete="<rdf=RDF"; |
$en_tete .="\n"; |
$en_tete .="xmls:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#"; |
$en_tete .=$sep; |
$en_tete .="xmls:dc=\"http://purl.org/dc/elements/1.1/".$sep; |
$en_tete .="xmls:dcterms=\"http://purl.org/dc/terms".$sep; |
$en_tete .=">"."\n\n"; |
|
//connexion a la base |
$dsn="mysql://root:0000@localhost/test"; |
$db=DB::connect($dsn); |
if (DB::isError($db)) |
{ |
echo "<ERREUR>"; |
echo "Impossible d'établir de connexion ",$db->getMessage(); |
echo "</ERREUR>"; |
exit; |
} |
|
|
//requete sql |
$req="select * from images"; |
$cond="where identifier<=7"; |
if(!$cond=="") |
{ |
$resultat=$db->query($req." ".$cond); |
$cpt=$db->query("select count('identifier') from images ".$cond); |
$nbre_ligne=$cpt->fetchRow(DB_FETCHMODE_ORDERED); |
print("nombre de lignes résultat de la requête : ".$nbre_ligne[0]."<br>"); |
} |
else |
{ |
$resultat=$db->query($req); |
$cpt=$db->query("select count('identifier') from images "); |
$nbre_ligne=$cpt->fetchRow(DB_FETCHMODE_ORDERED); |
} |
|
//selection des lignes de la requete à traiter |
|
if (($deb+$img_pg+1)<=($nbre_ligne[0])) |
{ |
$fin=$deb+$img_pg-1; |
} |
else |
{ |
$fin=$nbre_ligne[0]-1; |
} |
|
|
|
//affichage des miniatures et génération des fichiers rdf |
if ($fin!==0) |
{ |
foreach (range($deb, $fin) as $num_ligne) |
{ |
if (!$ligne = $resultat->fetchrow(DB_FETCHMODE_ORDERED, $num_ligne)) |
{ |
break; |
} |
$url_img=$ligne[8]; |
$url_img_mini=$url_img."mini_photos/mini_"; |
$url_img_mini .=$ligne[1]; |
$url_img .=$ligne[1]; |
$res.="<div class=\"float\">"; |
$res.="<map name=\"mini".$url_img."\">"; |
$res.="<area shape=\"rect\" coords=\"0,0,175,175\" href=\"gde_photo.php?agrandit=".$url_img."&".SID."\">"; |
$res.="</map>"; |
$res.="<img src=\"".$url_img_mini."\" border=0 usemap=\"#mini".$url_img."\">"; |
$res.="<p>num_ligne : ".$num_ligne." id: ".$ligne[0]."->".$ligne[1]."</p></div>"; |
|
//génération d'un fichier rdf pour chaque resultat de la requete |
$fic=$path_rdf; |
$fic .=$ligne[0]; |
$fic .=".rdf"; |
if(!file_exists($fic)) |
{ |
$fp=fopen($fic,"w+"); |
$text_rdf=""; |
if(!$fp) |
{ |
$res.="erreur de création du fichier rdf"; |
exit; |
} |
|
$text_rdf .=$en_tete; |
|
$text_rdf .="<rdf:Description rdf:about=\""; |
$url_img=$ligne[8]; |
$url_img .=$ligne[1]; |
$text_rdf .=$url_img .$sep; |
|
$text_rdf .="dc:identifier=\""; |
$text_rdf .=$ligne[0]; |
$text_rdf .=$sep; |
|
$text_rdf .="dc:title=\""; |
$text_rdf .=$ligne[1]; |
$text_rdf .=$sep; |
|
$text_rdf .="dc:creator=\""; |
$text_rdf .=$ligne[2]; |
$text_rdf .=$sep; |
|
$text_rdf .="dc:type=\""; |
$text_rdf .=$ligne[3]; |
$text_rdf .=$sep; |
|
if(!(is_null($ligne[4]))) |
{ |
$text_rdf .="dcterms:created=\""; |
$text_rdf .=$ligne[4]; |
$text_rdf .=$sep; |
} |
|
$text_rdf .=">\n</rdf:Description>\n</rdf:RDF>\n"; |
|
$i=fwrite($fp,$text_rdf); |
fclose($fp); |
} |
} |
if ($deb!=0) |
{ |
if (($deb-$img_pg-1)>=0) |
{ |
$prec="<a href=photo.php?deb=".($deb-$img_pg-1).">Précédent</a>"; |
$res.="<div class=\"prec\">".$prec."</div>"; |
} |
else |
{ |
$prec="<a href=photo.php?deb=0>Précédent</a>"; |
} |
$res.="<div class=\"prec\">".$prec."</div>"; |
} |
|
if ($deb+$img_pg<$nbre_ligne[0]) |
{ |
$suiv="<a href=photo.php?deb=".($fin+1).">Suivant</a>"; |
$res.="<div class=\"suiv\">".$suiv."</div>"; |
} |
|
} |
|
DB::disconnect(); |
echo $res; |
|
?> |
</BODY> |
</HTML> |