<?php
include('inc/functions.inc.php');
$aid = $_GET['id'];
$reqtype = $_GET['type'];
$sel = $mysql->select(PRE.'forums_attachments', "id='".$aid."'", "id", "DESC", "1");
$a = mysql_fetch_assoc($sel);
if(!isset($reqtype))
{
$reqtype == 'dl';
}
if($a['type'] == 'image' && $reqtype == 'view')
{
$ftype = explode('.', $a['filename']);
header("Content-Type: image/".str_replace("jpg", "jpeg", $ftype[1]));
include('uploads/'.$a['filename']);
} elseif($reqtype == 'dl')
{
header("Content-Type: application/octet-stream");
include('uploads/'.$a['filename']);
}
?>