Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 5 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 linda 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: eflore_photo.inc.php,v 1.1 2004-06-17 13:23:16 linda Exp $
23
/**
24
* Titre
25
*
26
* Description
27
*
28
*@package nom_du_paquetage
29
*@subpackage nom_du_sous-paquetage_si_necessaire
30
//Auteur original :
31
*@author        linda ANGAMA<linda_angama@yahoo.fr>
32
//Autres auteurs :
33
*@author        Aucun
34
*@copyright     Tela-Botanica 2000-2004
35
*@version       $Revision: 1.1 $ $Date: 2004-06-17 13:23:16 $
36
*/
37
 
38
session_start();
39
$res="";
40
$res.="<HTML><HEAD><link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"photo.css\" /></HEAD><BODY>";
41
 
42
error_reporting(E_ALL);
43
include_once "DB.php";
44
 
45
if (isset($agrandit))
46
{
47
$res.="<div align=\"center\">";
48
$res.="<p><a href=\"photo.php?".SID."&deb=".$_SESSION['dep']."\">Retour &agrave la miniature</a></p>";
49
$res.="<img src=\"".$agrandit."\"></div>";
50
unset($agrandit);
51
echo $res;
52
}
53
 
54
$_SESSION['dep']=$deb;
55
echo $deb;
56
$path_rdf="/home/linda/Documents/testphp/rdf/";
57
$sep="\"\n";
58
if (!isset($deb)){$deb=0;}
59
$img_pg=6;
60
$prec=null;
61
$suiv=null;
62
 
63
//en-tete commune a tous les fichiers rdf
64
$en_tete="<rdf=RDF";
65
$en_tete .="\n";
66
$en_tete .="xmls:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#";
67
$en_tete .=$sep;
68
$en_tete .="xmls:dc=\"http://purl.org/dc/elements/1.1/".$sep;
69
$en_tete .="xmls:dcterms=\"http://purl.org/dc/terms".$sep;
70
$en_tete .=">"."\n\n";
71
 
72
//connexion a la base
73
$dsn="mysql://root:0000@localhost/test";
74
$db=DB::connect($dsn);
75
 if (DB::isError($db))
76
  {
77
        echo "<ERREUR>";
78
        echo "Impossible d'&eacutetablir de connexion ",$db->getMessage();
79
        echo "</ERREUR>";
80
        exit;
81
    }
82
 
83
 
84
//requete sql
85
$req="select * from images";
86
$cond="where identifier<=7";
87
if(!$cond=="")
88
{
89
	$resultat=$db->query($req." ".$cond);
90
	$cpt=$db->query("select count('identifier') from images ".$cond);
91
	$nbre_ligne=$cpt->fetchRow(DB_FETCHMODE_ORDERED);
92
	print("nombre de lignes r&eacutesultat de la requ&ecircte : ".$nbre_ligne[0]."<br>");
93
}
94
else
95
{
96
	$resultat=$db->query($req);
97
	$cpt=$db->query("select count('identifier') from images ");
98
	$nbre_ligne=$cpt->fetchRow(DB_FETCHMODE_ORDERED);
99
}
100
 
101
//selection des lignes de la requete &agrave traiter
102
 
103
if (($deb+$img_pg+1)<=($nbre_ligne[0]))
104
{
105
	$fin=$deb+$img_pg-1;
106
}
107
else
108
{
109
	$fin=$nbre_ligne[0]-1;
110
}
111
 
112
 
113
 
114
//affichage des miniatures et g&eacuten&eacuteration des fichiers rdf
115
if ($fin!==0)
116
{
117
	foreach (range($deb, $fin) as $num_ligne)
118
	{
119
		if (!$ligne = $resultat->fetchrow(DB_FETCHMODE_ORDERED, $num_ligne))
120
		{
121
			break;
122
		}
123
		$url_img=$ligne[8];
124
		$url_img_mini=$url_img."mini_photos/mini_";
125
		$url_img_mini .=$ligne[1];
126
		$url_img .=$ligne[1];
127
		$res.="<div class=\"float\">";
128
		$res.="<map name=\"mini".$url_img."\">";
129
		$res.="<area shape=\"rect\" coords=\"0,0,175,175\" href=\"gde_photo.php?agrandit=".$url_img."&".SID."\">";
130
		$res.="</map>";
131
		$res.="<img src=\"".$url_img_mini."\" border=0 usemap=\"#mini".$url_img."\">";
132
		$res.="<p>num_ligne : ".$num_ligne."  id:  ".$ligne[0]."->".$ligne[1]."</p></div>";
133
 
134
		//g&eacuten&eacuteration d'un fichier rdf pour chaque resultat de la requete
135
		$fic=$path_rdf;
136
		$fic .=$ligne[0];
137
		$fic .=".rdf";
138
		if(!file_exists($fic))
139
		{
140
			$fp=fopen($fic,"w+");
141
			$text_rdf="";
142
			if(!$fp)
143
			{
144
				$res.="erreur de cr&eacuteation du fichier rdf";
145
				exit;
146
			}
147
 
148
			$text_rdf .=$en_tete;
149
 
150
			$text_rdf .="<rdf:Description  rdf:about=\"";
151
			$url_img=$ligne[8];
152
			$url_img .=$ligne[1];
153
			$text_rdf .=$url_img .$sep;
154
 
155
			$text_rdf .="dc:identifier=\"";
156
			$text_rdf .=$ligne[0];
157
			$text_rdf .=$sep;
158
 
159
			$text_rdf .="dc:title=\"";
160
			$text_rdf .=$ligne[1];
161
			$text_rdf .=$sep;
162
 
163
			$text_rdf .="dc:creator=\"";
164
			$text_rdf .=$ligne[2];
165
			$text_rdf .=$sep;
166
 
167
			$text_rdf .="dc:type=\"";
168
			$text_rdf .=$ligne[3];
169
			$text_rdf .=$sep;
170
 
171
			if(!(is_null($ligne[4])))
172
			{
173
				$text_rdf .="dcterms:created=\"";
174
				$text_rdf .=$ligne[4];
175
				$text_rdf .=$sep;
176
			}
177
 
178
			$text_rdf .=">\n</rdf:Description>\n</rdf:RDF>\n";
179
 
180
			$i=fwrite($fp,$text_rdf);
181
			fclose($fp);
182
		}
183
	}
184
	if ($deb!=0)
185
	{
186
		if (($deb-$img_pg-1)>=0)
187
		{
188
			$prec="<a href=photo.php?deb=".($deb-$img_pg-1).">Pr&eacutec&eacutedent</a>";
189
			$res.="<div class=\"prec\">".$prec."</div>";
190
		}
191
		else
192
		{
193
			$prec="<a href=photo.php?deb=0>Pr&eacutec&eacutedent</a>";
194
		}
195
		$res.="<div class=\"prec\">".$prec."</div>";
196
	}
197
 
198
	if ($deb+$img_pg<$nbre_ligne[0])
199
	{
200
		$suiv="<a href=photo.php?deb=".($fin+1).">Suivant</a>";
201
		$res.="<div class=\"suiv\">".$suiv."</div>";
202
	}
203
 
204
}
205
 
206
DB::disconnect();
207
echo $res;
208
 
209
?>
210
</BODY>
211
</HTML>