<?php
//////////////////////////////////////pārbaudām vai bilde eksistē
$mape = trim($_GET['kur']);
$mape = str_replace('.', '', $mape);
$mape = str_replace('\\', '', $mape);
$mape = str_replace('/', '', $mape);
$mape = str_replace('$', '', $mape);
$mape = htmlspecialchars($mape, ENT_QUOTES);
$fails = trim($_GET['nos']);
$fails = str_replace('\\', '', $fails);
$fails = str_replace('/', '', $fails);
$fails = str_replace('$', '', $fails);
$fails = htmlspecialchars($fails, ENT_QUOTES);
$parbaude = pathinfo($fails);
if (file_exists('ielades/'.$mape.'/'.$fails)!=false && (strtolower($parbaude['extension'])=='jpeg' || strtolower($parbaude['extension'])=='jpg'
|| strtolower($parbaude['extension'])=='gif' || strtolower($parbaude['extension'])=='png'))
{
//samazinām bildi
$bilde = file_get_contents('ielades/'.$mape.'/'.$fails);
$img = imagecreatefromstring($bilde);
$i_platums = imagesx($img);
$i_augstums = imagesy($img);
$jaugstums = round($jplatums*$i_augstums/$i_platums);
$tmp = imagecreatetruecolor($jplatums, $jaugstums);
imagecopyresized($tmp, $img, 0, 0, 0, 0, $jplatums, $jaugstums, $i_platums, $i_augstums);
header("Content-Type: image/png");
imagepng($tmp);
imagedestroy($img);
imagedestroy($tmp);
}
else
{
$im = imagecreate(60, 25);
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 5, 5, 4, 'KLUDA!', $text_color);
header ("Content-type: image/png");
imagepng($im);
imagedestroy($im);
}
?>