<?php
require_once(dirname(dirname(__FILE__)).'/inc/config.php');
include dirname(dirname(__FILE__)).'/inc/connect.php';

$id=isset($_GET['id']) ? $_GET['id']: 0;

$avatar=$flash->query("SELECT * FROM `merge` WHERE `file_name`='{$id}'");
$avatar=$avatar->fetch();

if($avatar>0):
$ext=$avatar['mime_type'] == 'image/png' ? 'png' : (($avatar['mime_type'] == 'image/jpeg') ? 'jpeg' : 'gif');


$imgf=imagecreatefrom.$ext;
$img=$imgf(dirname(dirname(__FILE__)).'/attachments/'.$avatar['file_name']);
header('Content-Type: '. $avatar['mime_type']);
$fname=image.'jpeg';
$fname($img);
imagedestroy($img);
else: echo 'image not found'; endif;
?>