<?
    
require_once('include/functions/image_directory.php');
    
    
$_id = isset($_GET['i']) ? intval($_GET['i']) : 0;

    if (
$_id)
    {
        
$binaries mysql_query("SELECT image_id, thumb FROM z_" binaries_path($_id) . " WHERE image_id = " sq($_id));
        if (
$binaries_row mysql_fetch_assoc($binaries))
        {
            if (
$_user)
            {
                
$handle imagecreatefromstring($binaries_row['thumb']);
                
$user_id get_user_id($_user);
                
$user_prefs mysql_fetch_assoc(mysql_query("SELECT show_name_avatar FROM users_preferences WHERE user_id = '" $user_id "'"));
                if (
$user_prefs['show_name_avatar'])
                {
                    
$font 'include/fonts/fstop.ttf';
                    
$fontsize 12;
                    
$white imagecolorallocate($handle255255255);
                    
$bar imagecreatefrompng('include/fonts/black_bar.png');
                    
imagecopymerge($handle$bar097001602350);
                    
$str_width = (floor($fontsize 3) * strlen($_user)) + 10;
                    
$x floor((imagesx($handle) / 2) - ($str_width 2));
                    
$y 115
                    
imagettftext($handle$fontsize0$x$y$white$font$_user);
                }
                
header('content-type: image/png');
                
header('content-disposition: inline; filename="' $binaries_row['image_id'] . '.png"');
                
imagepng($handle);
            }
            else
            {
                
header('content-type: image/png');
                
header('content-disposition: inline; filename="' $binaries_row['image_id'] . '.png"');
                echo 
$binaries_row['thumb'];
            }
        }
        else
        {
            
display_empty_image();
        }
    }
    else
    {
        
display_empty_image();
    }

    function 
display_empty_image()
    {
        
$im imagecreatetruecolor(264264);
        
imagefill($im000);
        
$white imagecolorallocate($im255255255);
        
imagefilledrectangle($imSIDE_PIXELSSIDE_PIXELS200 SIDE_PIXELS 1200 SIDE_PIXELS 1$white);
        
header ("Content-type: image/png");
        
header('content-disposition: inline; filename="empty.png"');
        
imagepng($im);
    }
?>