Файл: load_img.php
Строк: 66
<?php
/**
 * @author [FaNiska]
 * @copyright 2009
 * Загруз центр
 * Предложения, идеи, вопросы и об ошибках писать в icq 65-64-538 или на mobi-m-ru@ya.ru
 */
session_start();
include 'inc/db_connect.php';
include 'inc/function.php';
include 'inc/set.php';
$file_info = mysql_fetch_array(mysql_query('SELECT `s_name` FROM `' . $table . '` WHERE `id` = ' . $id . ' LIMIT 1'));
if (file_exists($file_info['s_name']))
{
    mysql_query('UPDATE `' . $table . '` SET `count`=`count`+1, `lastload`=' . $time . ' WHERE `id`=' . $id . ' LIMIT 1');
    $url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/' . $file_info['s_name'];
    $url = str_replace('/', '/', $url);
    $pathinfo = pathinfo($file_info['s_name']);
    $name = str_replace('.' . $pathinfo['extension'], '', basename($file_info['s_name']));
    $ras = $pathinfo['extension'];
    if ($ras == 'gif')
    {
        if (copy($file_info['s_name'], 'temp/' . $_SERVER['SERVER_NAME'] . '_' . $table . '_' . $id . '.' . $ras))
        {
            header('Location: temp/' . $_SERVER['SERVER_NAME'] . '_' . $table . '_' . $id . '.' . $ras);
            exit();
        } else
        {
            header('Location: ' . $file_info['s_name']);
            exit();
        }
    } else
    {
        $pic = urldecode(htmlspecialchars($file_info['s_name']));
        if (substr($pic, 0, 1) != '.')
        {
            if (preg_match('/.jpg$|.jpeg$|.jpe$/i', $pic))
            {
                $old = imageCreateFromJpeg($pic);
            } elseif (preg_match('/.png$/i', $pic))
            {
                $old = imageCreateFromPNG($pic);
            }
            $wn = imageSX($old);
            $hn = imageSY($old);
            if ($setup['mark_set'] == 1 && $setup['mark_text'] != null)
            {
                if ($setup['mark_size'] != null && $setup['mark_size'] != 0)
                {
                    $setup['mark_size'] = intval($setup['mark_size']);
                } else
                {
                    $setup['mark_size'] = 2;
                }
                // фон
                $bg = imagecolorallocate($old, 255, 255, 255);
                // цвет
                $color = imagecolorallocate($old, 100, 200, 0);
                imagestring($old, $setup['mark_size'], (strlen($setup['mark_text'])), ($hn - 15), $setup['mark_text'], $color);
            }
            $name = $_SERVER['SERVER_NAME'] . '_' . $table . '_' . $id . '.' . $ras;
            if ($ras == 'jpg')
            {
                ImageJpeg($old, 'temp/' . $name, 100);
                header('Location: temp/' . $name);
                imagedestroy($old);
                exit();
            } elseif ($ras == 'png')
            {
                //imagecolortransparent($screen,0);
                Imagepng($old, 'temp/' . $name, 100);
                header('Location: temp/' . $name);
                imagedestroy($old);
                exit();
            }
            exit;
        }
    }
} else
{
    header('Location: index.php');
    exit();
}
?>