// Lecture de l'image du jour
$debug = "OFF";
//$path_to_images = "images";
$path_to_images = "gnactronches";
$datejour = date('Y') . date('m') . date('d');
require ('tronchedujourconf.php');
// Etape 1 : récupération de la tronche du jour
$conn = db_connect();
if ($conn) {
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") { echo "
[DEBUG] : Connexion OK
"; }
$get_tdj = db_get_tdj($conn,$table,$table_tdj,$datejour,$path_to_images);
if (is_array($get_tdj) AND $get_tdj[0] != "") {
// On a bien une tronche du jour
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") { echo "[DEBUG] : is_array(get_tdj) AND get_tdj[0] != ''
"; }
$img = $path_to_images . "/". $get_tdj[2]; // 0=ID, 1=NOM, 2=PHOTO
}
else {
// On n'a pas de tronche du jour
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") { echo "[DEBUG] : FAUX -> is_array(get_tdj) AND get_tdj[0] != ''
"; }
$cre_tdj = db_create_tdj($conn,$table,$table_tdj,$datejour,$path_to_images);
if (is_array($cre_tdj) AND $cre_tdj[1] != "") {
// On a bien pu créer la tronche du jour
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") { echo "[DEBUG] : is_array(cre_tdj) AND cre_tdj[1] != ''
"; }
$img = $path_to_images . $cre_tdj[3]; // 0=VRAI/FAUX, 1=ID, 2=NOM, 3=PHOTO
}
else {
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") { echo "[DEBUG] : FAUX -> is_array(cre_tdj) AND cre_tdj[1] != ''
"; }
$img = $path_to_images . "/defaut.jpg";
}
}
}
else {
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") { echo "[DEBUG] : Connexion KO
"; }
$img = $path_to_images . "/defaut.jpg";
}
$img = $_SERVER["DOCUMENT_ROOT"] . "/communaute/tronches/" . $img;
if ($debug=="ON" && $_SERVER["REMOTE_ADDR"]=="82.231.142.221") {
echo "Tronche = $img";
exit;
}
// Etape 2 : Affichage de l'image
list($width, $height, $type, $attr) = getimagesize($img);
$wt = 100;
$ht = 100;
$imgtmp = imagecreatetruecolor($wt,$ht);
$imgsrc = imagecreatefromjpeg($img);
imagecopyresampled($imgtmp,$imgsrc,0,0,0,0,$wt,$ht,$width,$height);
header('Content-type: image/jpeg');
imagejpeg($imgtmp);
imagedestroy($imgtmp);
?>