|

Исходные коды
<?php
if (get_magic_quotes_gpc()) {
$_POST[txt]=stripslashes($_POST[txt]);
}
function russtrtoupper($str) {
$str = strtoupper($str);
for($i=0; $i<strlen($str); ++$i) {
switch($str[$i]) {
case 'а': $str[$i] = 'А'; break;
case 'б': $str[$i] = 'Б'; break;
case 'в': $str[$i] = 'В'; break;
case 'г': $str[$i] = 'Г'; break;
case 'д': $str[$i] = 'Д'; break;
case 'е': $str[$i] = 'Е'; break;
case 'ё': $str[$i] = 'Ё'; break;
case 'ж': $str[$i] = 'Ж'; break;
case 'з': $str[$i] = 'З'; break;
case 'и': $str[$i] = 'И'; break;
case 'й': $str[$i] = 'Й'; break;
case 'к': $str[$i] = 'К'; break;
case 'ы': $str[$i] = 'Ы'; break;
case 'л': $str[$i] = 'Л'; break;
case 'м': $str[$i] = 'М'; break;
case 'н': $str[$i] = 'Н'; break;
case 'о': $str[$i] = 'О'; break;
case 'п': $str[$i] = 'П'; break;
case 'р': $str[$i] = 'Р'; break;
case 'с': $str[$i] = 'С'; break;
case 'т': $str[$i] = 'Т'; break;
case 'у': $str[$i] = 'У'; break;
case 'ф': $str[$i] = 'Ф'; break;
case 'х': $str[$i] = 'Х'; break;
case 'ч': $str[$i] = 'Ч'; break;
case 'щ': $str[$i] = 'Щ'; break;
case 'ш': $str[$i] = 'Ш'; break;
case 'ъ': $str[$i] = 'Ъ'; break;
case 'ь': $str[$i] = 'Ь'; break;
case 'э': $str[$i] = 'Э'; break;
case 'ю': $str[$i] = 'Ю'; break;
case 'я': $str[$i] = 'Я'; break;
}
}
return $str;
}
function getImageType($filename) {
if (preg_match('!\.(jpg|jpeg)$!si',$filename)) {
return 'Jpeg';
} else if (preg_match('!\.gif$!si',$filename)) {
return 'Gif';
} else if (preg_match('!\.png$!si',$filename)) {
return 'Png';
}
return 0;
}
$htxt = join('',unpack('H*',$_POST[txt]));
$htxt = ereg_replace("0d0a","0a",$htxt);
$_POST[txt] = pack('H*',$htxt);
$htxt='';
$height = 100;
$cchar=0;
for($i=0;$i<strlen($_POST[txt]);$i++) {
if (($_POST[txt][$i]=="\n")or(++$cchar>13)) {
$height += 80;
$cchar=0;
}
}
if ($_POST['act'] == 'view') {
header("Content-Type: image/jpeg");
header("Pragma:no-cache");
$im=imagecreatetruecolor(800,$height); // for GD 2.0
// $im = imagecreate(800, $height); // for GD 1.0
$white=ImageColorAllocate($im, 255, 255, 255);
ImageFilledRectangle($im,0,0,799,$height-1, $white);
//
$_POST[txt] = russtrtoupper($_POST[txt]);
$coordX = 10;
$coordY = 10;
$cchar=0;
for ($i=0;$i<strlen($_POST[txt]);$i++) {
if (++$cchar > 13) {
$cchar=1;
$coordX = 10;
$coordY += 70;
}
if ($_POST[txt][$i] == "\n") {
$coordX = 10;
$coordY += 70;
$cchar=0;
} else {
if ($_POST[txt][$i]=='.') {
$mychar = 'dot';
} else if (($_POST[txt][$i]==' ')or($_POST[txt][$i]=="\t")) {
$mychar = 'space';
} else if ($_POST[txt][$i]=='?') {
$mychar = 'question';
} else if ($_POST[txt][$i]=='"') {
$mychar = 'quates';
} else if ($_POST[txt][$i]=='*') {
$mychar = 'star';
} else if ($_POST[txt][$i]==':') {
$mychar = 'ddot';
} else if ($_POST[txt][$i]=='/') {
$mychar = 'slash';
} else if ($_POST[txt][$i]=='\\') {
$mychar = 'bslash';
} else if ($_POST[txt][$i]=='|') {
$mychar = 'pipe';
} else if ($_POST[txt][$i]=='<') {
$mychar = 'tagopen';
} else if ($_POST[txt][$i]=='>') {
$mychar = 'tagclose';
} else {
$mychar = $_POST[txt][$i];
}
if (!@$dir = dir('bukvi/'.$mychar)) {
$dir = dir('bukvi/question');
$mychar = 'question';
}
$dir -> rewind();
$mas = array();
while ($file=$dir->read()) {
if (($file != '.') and ($file != '..')) {
array_push($mas, $file);
}
}
$myfile = $mas[rand(0,count($mas)-1)];
$ftype=getImageType($myfile);
if ($ftype == 'Jpeg') {
$img = ImageCreateFromJPEG('bukvi/'.$mychar.'/'.$myfile);
} else if ($ftype == 'Gif') {
$img = ImageCreateFromGIF('bukvi/'.$mychar.'/'.$myfile);
} else {
$img = ImageCreateFromPNG('bukvi/'.$mychar.'/'.$myfile);
}
ImageCopyResized($im, $img, $coordX + rand(-1,6), $coordY + rand(-5,10), 0,0, 51, 58, 51, 58);
$coordX += 56;
ImageDestroy($img);
}
} //
ImageJPEG($im);
ImageDestroy($im);
exit;
}
?>
<HTML>
<head><title>My imgtext</title></head>
<BODY>
<FORM name="f1" action="index.php" method="POST">
<input type="hidden" name="act" value="view">
<TEXTAREA name="txt" size=32 rows=10 cols=13>
</TEXTAREA>
<BR>
<BR>
<INPUT TYPE="submit" value="Submit">
</FORM>
</BODY>
</HTML>
<?
?>

Перейти к рубрике --> PHP |