<?
// Parametros: db / db_id / db_mime
if (!isset( $db_fid ) ) $db_fid="001";
$filename = "db/$db/$db_id"."_i".$db_fid;
$fp = fopen($filename, "rb");

if ( $fp )
{
    Header( "Content-type: $db_mime" );
    echo fread($fp,filesize($filename)); 
    fclose($fp);
} else {
    Header("Content-type: image/gif"); 

    $fp = fopen("images/simagen.gif","rb"); 
    echo fread($fp,filesize("images/simagen.gif")); 
    fclose($fp); 
}
  
?>