<?php
 require_once "base.php";
 if ($_GET[site]) {
   $result = pg_query_ok("select publie from pilotes where id = $_GET[site]");
   $pilote = pg_num_rows($result);
   if ( (! $pilote) || ($pilote && (pg_fetch_result($result, 0,0) == "t"))) {
	 $result = pg_query_ok("select photo, photo_type from sites where id = $_GET[site] and photo_type is not null");
	 if (pg_num_rows($result)) {
	   header("Content-Type: ".pg_fetch_result($result, 0, "photo_type"));
	   print stripcslashes(pg_fetch_result($result, 0, "photo")); 
	   exit(); 
	 }
   } 
 }
 header("Content-Type: image/png");
 readfile("img/unknown.png")
?>