View file foto/img_effects.php

File size: 1.42Kb
<?php

require('../sys/inc/core.php');

$p = (int)$_GET['id'];
$h = $_GET['hash'];
$file_path = PATH_UPLOADS.'/gallery/foto/' . $p . '.jpg';
$exp_path = H . 'sys/tmp/photo.effects.' . md5($p) . '.ser';

if (!is_file($file_path)) {
    die('Файл не найден');
}

$photo = db::fetch("
      SELECT ph.effects
      FROM gallery_foto AS ph 
      WHERE ph.id = '$p'
", ARRAY_A);

$image = $foo = new upload($file_path);

if ($image->image_src_x > 320) {
    $image->image_resize = true;
    $image->image_ratio_y = true;
    $image->image_x = 320;
}

if (is_file($exp_path)) {
    $exp = unserialize(file_get_contents($exp_path));
    if ($photo['effects']) {
        $exp = array_merge(unserialize($photo['effects']), $exp);
    }
    if ($exp['rotate'] != 0) {
        $image->image_rotate = $exp['rotate'];
    }
    if ($exp['filter'] != 'none') {
        if ($exp['filter'] == 'greyscale')
            $image->image_greyscale = true;
        if ($exp['filter'] == 'negative')
            $image->image_negative = true;
        if ($exp['filter'] == 'pixelate')
            $image->image_pixelate = 4;
    }
    if ($exp['tint'] != 'none') {
        $image->image_tint_color = $exp['tint'];
    }
}
header('Cache-control: public');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 60 * 60 * 24 * 7) . ' GMT');
header('Content-type: ' . $image->file_src_mime);
die($image->Process());