<?php
/*
    ANISEED, NISEED System and Database
    Copyright (C) 2007 Olivier Tassy, Fabrice Daian, Patrick Lemaire

    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 3 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
include("connection.php");

	$id=$_GET["id"];
	
	

	
	header('Content-type: image/jpg');

	$requete = "SELECT \"THUMBNAIL\" FROM \"PICTURE\" where \"PICTURE_ID\" = $id";

	pg_query ($c, "begin");

	$stmt=pg_query($c,$requete);

$row = pg_fetch_array($stmt);
$lo_oid=$row["THUMBNAIL"];
$handle_lo = pg_lo_open($c,$lo_oid,"r") or die("<h1>Error.. can't get handle</h1>");
pg_lo_read_all($handle_lo) or die("<h1>Error, can't read large object.</h1>");




	


	pg_query($c, "commit");


?>