<?php
include "sys/cons.php";
include "sys/cepumi.php";
include "sys/funct.php";
include "sys/lang/$language.php";
include "sys/msg.php";
if( !empty($h) & !empty($w)){
@$newh = parbaude($_GET["h"]);
@$neww = parbaude($_GET["w"]);
@$fails = $_GET["fails"];
@$vards = $_GET["vards"];
@$height = $_GET["w"];
@$weight = $_GET["h"];
@$tip = $_GET["tips"];
$er = format($vards);//formāts
if(preg_match("[http]",$fails)) exit(ERROR_MESAGE);
if(preg_match("[%]",$fails)) exit(ERROR_MESAGE);
if(preg_match("[http]",$vards)) exit(ERROR_MESAGE);
if(preg_match("[%]",$$vards)) exit(ERROR_MESAGE);
if($height > 500 or $weight > 500) {
header ("Location: about.php?act=comm&fails=$fails&vards=$vards&mape=$mape&msg=bigwh&"); exit;}
if($er == 'png' or $er == 'gif' or $er == 'jpg' or $er == 'bmp' or $er == 'JPG' or $er == 'PNG' or $er == 'GIF') {
$counter = @file_get_contents("dati/$vards.count");
if(!empty($counter)) {
if(!preg_match("/[0-9]/i",$counter)){echo''.$lang['error'].''; exit;}
}
if(empty($counter)) {$counter = 0;}
if($fp=@fopen("dati/$vards.count","w+")){
@fputs($fp,$counter+1);
@fclose($fp);
} else{ echo ''.$lang['open_error'].'';exit;}
$sz = GetImageSize($fails);
$weigtht = $sz[0];
$heightt = $sz[1];
$destation = 'temp/img/'.$vards;
if ($neww == '' && $newh == ''){ $neww = $weigtht; $newh = $heightt;}
$new_w = isset($_GET['w']) ? (int) $_GET['w'] : $neww;
$new_h = isset($_GET['h']) ? (int) $_GET['h'] : $newh;
if ($image_info = getimagesize($fails)){
if($er=="gif" or $er=="GIF"){$image_create_handle = "imagecreatefromGif";
}elseif($er=="jpg" or $er=="JPG"){$image_create_handle = "imagecreatefromJpeg";}
elseif($er=="png" or $er=="PNG"){$image_create_handle = "imagecreatefromPng";}
if (!$fails = @$image_create_handle($fails)){echo ''.$lang['img_error_create'].'';exit;}
$neww = imagesx($fails);
$newh = imagesy($fails);
$ratio = $neww/$new_w;
$w_dest = round($neww/$ratio);
$h_dest = round($newh/$ratio);
$dest = imagecreatetruecolor($w_dest,$h_dest);
imagecopyresized($dest, $fails, 0, 0, 0, 0, $w_dest, $h_dest, $neww, $newh);
if ($im_wd == 1)
{
// вывод текста
// определяем координаты вывода текста
$size = &$im_ts; // размер шрифта
$x_text = $w_dest-imagefontwidth($size)*strlen($im_title)-3;
$y_text = $h_dest-imagefontheight($size)-3;
// определяем каким цветом на каком фоне выводить текст
$white = imagecolorallocate($dest, 255, 255, 255);
$black = imagecolorallocate($dest, 0, 0, 0);
$gray = imagecolorallocate($dest, 127, 127, 127);
if (imagecolorat($dest,$x_text,$y_text)>$gray) $color = $black;
if (imagecolorat($dest,$x_text,$y_text)<$gray) $color = $white;
// выводим текст
imagestring($dest, $size, $x_text-1, $y_text-1, $im_title, $white-$color);
imagestring($dest, $size, $x_text+1, $y_text+1, $im_title, $white-$color);
imagestring($dest, $size, $x_text+1, $y_text-1, $im_title, $white-$color);
imagestring($dest, $size, $x_text-1, $y_text+1, $im_title, $white-$color);
imagestring($dest, $size, $x_text-1, $y_text, $im_title, $white-$color);
imagestring($dest, $size, $x_text+1, $y_text, $im_title, $white-$color);
imagestring($dest, $size, $x_text, $y_text-1, $im_title, $white-$color);
imagestring($dest, $size, $x_text, $y_text+1, $im_title, $white-$color);
imagestring($dest, $size, $x_text, $y_text, $im_title, $color);
}
header("Content-Type: image/jpeg");
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($fails);
imagedestroy($wat);
}else{ echo ''.$lang['img_error_size'].'';exit;}
}else{echo''.$lang['img_no'].'';}
}else{echo'Bļe ievadi lielumu lol!';}//lieluma tukšums
?>