ACC SHELL
<?php
error_reporting(0);
ini_set('display_errors', FALSE);
ini_set('display_startup_errors', FALSE);
ini_set('html_errors', 'Off');
header("Content-Type: image/jpeg");
$method = @$_GET["method"];
$width = intval(@$_GET["width"]);
$height = intval(@$_GET["height"]);
$doplnit = true;
if ($width == 0) { $width = NULL; $doplnit = false; }
if ($height == 0) { $height = NULL; $doplnit = false; }
$pom_dir = @$_GET["pom_dir"];
$pom_id = @$_GET["pom_id"];
$soubor = @$_GET["soubor"];
// 1. oveření zdali již soubor neexistuje, pokud ano, přesměruj na něj
$url = "data/thumb/{$pom_dir}/{$pom_id}/{$method}-{$width}x{$height}_{$soubor}";
if (is_file($url)){
$fp = fopen($url, 'rb');
fpassthru($fp);
exit;
}
// 2. pokud ne, vytvoř jej do složky /data/thumb/...
// k tomuto už potřebujeme nette
require("./include/config.php");
//if ($soubor == "no-photo") { set404(); }
// nejprve nutno ověřit, zdali již jsou vytvořeny všechny složky
if (!is_dir("data")) { mkdir("data"); }
if (!is_dir("data/thumb")) { mkdir("data/thumb"); }
if (!is_dir("data/thumb/{$pom_dir}")) { mkdir("data/thumb/{$pom_dir}"); }
if (!is_dir("data/thumb/{$pom_dir}/{$pom_id}")) { mkdir("data/thumb/{$pom_dir}/{$pom_id}"); }
use Nette\Image;
try {
$image = Image::fromFile(DATA_DIR . $pom_dir . "/" . $pom_id . "/" . $soubor);
if ($method =="crop") { $image->resize($width,$height,Image::FILL); }
elseif ($method =="crop2") { $image->resize($width,$height,Image::FILL)->crop("0","0",$width,$height); }
else { $image->resize($width,$height,Image::SHRINK_ONLY); }
if ($doplnit == false) {
$image->save($url, 90, Image::JPEG);
$image->send(Image::JPEG, 90);
} else {
$blank = Image::fromBlank($width, $height, Image::rgb(255, 255, 255));
$blank->place($image, ($width/2)-($image->width/2), ($height/2)-($image->height/2));
$blank->save($url, 90, Image::JPEG);
$blank->send(Image::JPEG, 90);
}
} catch (Exception $e) {
set404();
}
ACC SHELL 2018