Просмотр файла loads/image.php

Размер файла: 2.05Kb
<?php
include $_SERVER['DOCUMENT_ROOT'].'/loads/inc/baza.php';

if($_cnf_['v']=="y" && $session!==1){
echo'<br><center>Закрыт доступ для скачивания файлов!</center>';
exit; }

if(isset($_GET['image'])){
$image = htmlspecialchars($_GET['image']);

if(is_numeric($_POST['w_size']) && is_numeric($_POST['h_size'])){
if($_POST['w_size']<5 || $_POST['h_size']<5 || $_POST['w_size']>$_cnf_['g'] || $_POST['h_size']>$_cnf_['g']){
exit('Ошибка! Недопустимый размер!'); }

$x = $_POST['w_size'];
$y = $_POST['h_size'];
		}

elseif(is_numeric($_GET['w_size']) && is_numeric($_GET['h_size'])){
if($_GET['w_size']<6 || $_GET['h_size']<6 || $_GET['w_size']>$_cnf_['g'] || $_GET['h_size']>$_cnf_['g']){
exit('Ошибка! Недопустимый размер!'); }

$x = $_GET['w_size'];
$y = $_GET['h_size'];

		}

if(empty($_POST['w_size']) && empty($_POST['h_size']) && empty($_GET['w_size']) && empty($_GET['h_size'])){
$x=$_cnf_['e'];
$y=$_cnf_['f']; }

$font = $_SERVER['DOCUMENT_ROOT']."/loads/inc/mod/verdana.ttf";
$angle = "0";
$font_size = "15";
$text = $_cnf_['d'];

$i = $_SERVER['DOCUMENT_ROOT']."/loads/$image";
if(!file_exists($i)){ exit('Wrong way!'); }

$ext = strtolower(substr($i, 1 + strrpos($i, ".")));
if($ext!="png"){
if($ext!="jpg"){
if($ext!="gif"){
exit('Error in format!'); }}}
$im = imagecreatetruecolor($x, $y);

if($ext=="jpg"){ $img=imagecreatefromJPEG($image); }
if($ext=="png"){ $img=imagecreatefromPNG($image); }
if($ext=="gif"){ $img=imagecreatefromGIF($image); }

$color1 = ImagecolorAllocate($img, 0,0,0);
ImageTTFtext($img, $font_size, $angle, 10, 20, $color1, $font, $text);

$width = imagesx($img);
$height = imagesy($img);
imagecopyresampled($im, $img, 0, 0, 0, 0, $x, $y, $width, $height);

if($ext=="jpg"){
header("Content-type: image/jpeg");
imagejpeg($im); }
if($ext=="gif"){
header("Content-type: image/gif");
imagegif($im); }
if($ext=="png"){
header("Content-type: image/png");
imagepng($im); }
ImageDestroy($img);

}else{  echo'Error!';  }

?>