Файл: screen.php
Строк: 71
<?php
/**
* @author [FaNiska]
* @copyright 2009
* Загруз центр
* Предложения, идеи, вопросы и об ошибках писать в icq 65-64-538 или на mobi-m-ru@ya.ru
*/
include 'inc/db_connect.php';
$setting = mysql_query('SELECT * FROM `setting`;');
while ($set = mysql_fetch_assoc($setting))
{
$setup[$set['key']] = $set['value'];
}
if (isset($_GET['W']) && isset($_GET['H']))
{
$W = intval($_GET['W']);
$H = intval($_GET['H']);
} else
{
$W = $setup['prev_w'];
$H = $setup['prev_h'];
}
if (!isset($_GET['file']) && !eregi('.gif$|.png$|.jpeg$|.jpg$', $_GET['file']))
{
exit();
}
if (file_exists($_GET['file']))
{
$pathinfo = pathinfo($_GET['file']);
if (eregi('.jpeg$|.jpg$', $_GET['file']))
{
$ras = 'jpg';
$old = imageCreateFromJpeg($_GET['file']);
} elseif (eregi('.gif$', $_GET['file']))
{
$ras = 'gif';
$old = imageCreateFromGif($_GET['file']);
} elseif (eregi('.png$', $_GET['file']))
{
$ras = 'png';
$old = imageCreateFromPNG($_GET['file']);
}
$wn = imageSX($old);
$hn = imageSY($old);
if (isset($_GET['small']))
{
$W = intval($wn / 2);
$H = intval($hn / 2);
} elseif (isset($_GET['full']))
{
$W = intval($wn);
$H = intval($hn);
} elseif ($W > $wn || $H > $hn)
{
$W = $wn;
$H = $hn;
}
$new = imageCreateTrueColor($W, $H);
imageCopyResampled($new, $old, 0, 0, 0, 0, $W, $H, $wn, $hn);
if ($setup['mark_set'] == 1 && $setup['mark_text'] != null)
{
if ($setup['mark_size'] != null && $setup['mark_size'] != 0)
{
$setup['mark_size'] = intval($setup['mark_size']);
} else
{
$setup['mark_size'] = 2;
}
// фон
$bg = imagecolorallocate($new, 255, 255, 255);
// цвет
$color = imagecolorallocate($new, 100, 200, 0);
imagestring($new, $setup['mark_size'], (strlen($setup['mark_text'])), ($H - 15), $setup['mark_text'], $color);
}
$name = $_SERVER['SERVER_NAME'] . '_' . $table . '_' . $id . '.' . $ras;
if ($ras == 'jpg')
{
header("Content-type: image/jpeg");
ImageJpeg($new, null, 100);
} elseif ($ras == 'gif')
{
header("Content-type: image/gif");
ImageGif($new);
} elseif ($ras == 'png')
{
header("Content-type: image/png");
ImagePng($new);
}
imagedestroy($new);
exit();
} else
{
$pic = 'inc/no.png';
$old = imageCreateFromPNG($pic);
$wn = imageSX($old);
$hn = imageSY($old);
$new = imageCreateTrueColor($W, $H);
imageCopyResampled($new, $old, 0, 0, 0, 0, $W, $H, $wn, $hn);
header("Content-type: image/png");
ImagePng($new);
imagedestroy($new);
exit();
}
?>