Ищу Скрипт Демотиваторов

Статус
В этой теме нельзя размещать новые ответы.
Не большой апдейт:
PHP:
<?php
//Модуль создания демотиваторов
//Автор Kursor 2010
error_reporting(0);
set_time_limit(0);
  if (!defined("DATALIFEENGINE"))
  {
    die("Hacking Attemp!");
  }
  
 //Функции
    function win_to_utf($s) 
{ 
for($i=0, $m=strlen($s); $i<$m; $i++) 
{ 
$c=ord($s[$i]); 
if ($c<=127) 
{$t.=chr($c); continue; } 
if ($c>=192 && $c<=207) 
{$t.=chr(208).chr($c-48); continue; } 
if ($c>=208 && $c<=239) 
{$t.=chr(208).chr($c-48); continue; } 
if ($c>=240 && $c<=255) 
{$t.=chr(209).chr($c-112); continue; } 
if ($c==184) { $t.=chr(209).chr(209); 
continue; }; 
if ($c==168) { $t.=chr(208).chr(129); 
continue; }; 
} 
return $t; 
}

//Глобальные Настройки
$dirdem=ROOT_DIR.'/uploads/demotivation/';
$tpl->load_template('demgen.tpl');
//Конец настроек
 
if ((isset($_FILES["file"])) or (isset($_POST['url'])) ){
if(!$_POST['url']) {
$myfile = $_FILES["file"]["tmp_name"];
} else {
@copy($_POST['url'],$dirdem."tmp/temp.file");
$myfile = $dirdem."tmp/temp.file";
}
// Проверка на "заразу"
if (!exif_imagetype($myfile)) {
 $wdr="Это не картинка";
 } else {
/****/
$font = str_replace ( "\\", "/", getcwd () )."/arial.ttf";
$font1 = $font;
if ($_POST['hfs'] == 0) {
$headerSize = 20.0;
} elseif ($_POST['hfs'] == 1) {
$headerSize = 30.0;
} elseif ($_POST['hfs'] == 2) {
$headerSize = 40.0;
}

if ($_POST['tfs'] == 0) {
 $textSize = 10.0;
 } elseif ($_POST['tfs'] == 1) {
 $textSize = 15.0;
 } elseif ($_POST['tfs'] == 2) {
$textSize = 20.0;
 }
  $imageMargin = 20;
  $spacing = 16;
  $borderPad = 16;
$srcFile = $myfile;
 $header = win_to_utf( $_POST["head"]);
  $text = win_to_utf($_POST["text"]);
 if( !file_exists( $srcFile ) ){
    echo "picture file not found\n";
    exit;
  }
  $img = imagecreatefromjpeg( $srcFile );
  list($w, $h) = getimagesize( $srcFile );
 
  $ha1 = imagettfbbox($headerSize, 0, $font1, $header );
  $ha2 = imagettfbbox($textSize, 0,$font, $text );
 
  $wt1 = $ha1[2]-$ha1[0];
  $ht1 = $ha1[1]-$ha1[7];
  $wt2 = $ha2[2]-$ha2[0];
  $ht2 = $ha2[1]-$ha2[7];
 
  $fw = $w + 8 + $imageMargin * 2 + $borderPad * 2;
  $fh = $h + 8 + $imageMargin * 2 + $borderPad * 2 + $ht1 + $ht2 + $spacing * 3;
  $fon = imagecreatetruecolor($fw, $fh);
 
  $white = imagecolorallocate( $fon, 255, 255, 255 );
  $black = imagecolorallocate( $fon,   0,   0,   0 );
  imagefill( $fon, 0, 0, $black );
 
  imagecopy( $fon, $img, $imageMargin + $borderPad + 4, $imageMargin + $borderPad + 4, 0, 0, $w, $h );
 
  imagerectangle( $fon, $imageMargin + $borderPad + 4 - 3, $imageMargin + $borderPad + 4 - 3,
           $imageMargin + $borderPad + $w + 4 + 2, $imageMargin + $borderPad + $h + 4 + 2, $white );
  imagerectangle( $fon, $imageMargin + $borderPad + 4 - 4, $imageMargin + $borderPad + 4 - 4,
           $imageMargin + $borderPad + $w + 4 + 3, $imageMargin + $borderPad + $h + 4 + 3, $white );
 
  imagettftext( $fon, $headerSize, 0,
    ($fw - $wt1) / 2, $imageMargin + $borderPad*2 + 8 + $h + $ht1 + $spacing,
    $white, $font1, $header );
 
  imagettftext( $fon, $textSize, 0,
    ($fw - $wt2) / 2, $imageMargin + $borderPad*2 + 8 + $h + $ht1 + $ht2 + $spacing*2,
    $white, $font, $text );	
$textcolor = imagecolorresolve($fon, 255, 255, 255);
imagestring($fon, 4, 4, 2, $_SERVER['HTTP_HOST'] , $textcolor);
 $ts=$dirdem.time();
 $ts1='/uploads/demotivation/'.time();
  imagejpeg( $fon, $ts."_demotiv.jpg", 98 );
  imagecolordeallocate( $fon, $black );
  imagecolordeallocate( $fon, $white );
  imagedestroy( $fon );
 $output=$ts1."_demotiv.jpg";
 $wdr= <<<HTML
<div align=right>
     <form enctype="multipart/form-data">
	  Код для вставки в блог или на форум:  <input type="text" size=120 name="head" value="[img]http://{$_SERVER['HTTP_HOST']}{$output}[/img]"><br> 
	HTML-код: <input type="text" size=120 name="head" value="&lt;img src=&quot;http://{$_SERVER['HTTP_HOST']}{$output}&quot;&gt;"><br> 
	Прямая ссылка: <input type="text" size=120 name="head" value="http://{$_SERVER['HTTP_HOST']}{$output}"><br> 
	
	</form>
	

</div>
<center>	<img src="{$output}" alt="Демотиватор"></center>
HTML;
}
}  else {
$wdr = <<<HTML

     <form  method="post" enctype="multipart/form-data">
     Загрузите картинку: <input type="file" name="file"><br> 
	   Или урл картинки: <input type="text" name="url"><br> 
	  Заголовок: <input type="text" name="head"><br> 
	 Текст: <input type="text" name="text"><br> 
	 Размер шрифта: Заголовок - <select name='hfs'>
         <option value='0' >20</option>
         <option value='1'  selected>30</option>
         <option value='2' >40</option> </select>
		 Текст - <select name='tfs'>
         <option value='0' >10</option>
         <option value='1' selected>15</option>
         <option value='2'>20</option></select>
           <input onclick="submit"  type="image" style="width:81px; height:22px" src="/templates/Default/ms-img/ms_submit.gif"><br>

      </form>

HTML;

}
$tpl->set('{cnt}', $wdr);

    $tpl->compile('content');
    $tpl->clear();
?>
Добавил выбор размера шрифта. Галерею и всё что выше в свободное время буду писать...
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху