// security image
Kod:
<?php
require_once( "../inc/header.inc.php" );
ob_start();
session_start();
$chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
"k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T",
"u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$textstr = '';
for ($i = 0, $length = 8; $i < $length; $i++) {
$textstr .= $chars[rand(0, count($chars) - 1)];
}
$hashtext = "pohoda";
$tmpname = $hashtext.'.png';
$_SESSION['strSec'] = $hashtext;
$bgurl = rand(1, 3);
$cmd = $CONVERT;
$cmd .= ' '.$dir['root'].'simg/images/bg'.$bgurl.'.png';
$cmd .= ' -crop 200x35+'. rand(0,180) . '+' . rand(0,315);
$cmd .= ' '.$dir['root'].'tmp/bg'.$hashtext.'.png';
exec($cmd);
$im = $dir['root']."tmp/bg".$hashtext.".png";
$font = $dir['root']."simg/verdana.ttf";
$size = rand(24, 36);
$hexValues = array('0','1','2','3','4');
$numHex = count($hexValues);
$color = '';
for ($i = 0; $i < 6; $i++) {
$color .= $hexValues[rand(0, $numHex-1)];
}
$gravities = array('West', 'Center', 'East');
$gravity = $gravities[rand(0, count($gravities)-1)];
$angle = rand(-10, 10);
$cmd = $CONVERT;
$cmd .= ' -font "'.$font.'"';
$cmd .= ' -fill "#'.$color.'"';
$cmd .= ' -pointsize '.$size;
$cmd .= ' -gravity "'.$gravity.'"';
$cmd .= ' -draw "text 1,0 \''.$textstr.'\'"';
//$cmd .= ' -rotate '.$angle;
$cmd .= ' '.$im.' '.$dir['root'].'tmp/'.$tmpname;
exec($cmd);
unlink($im);
header("Content-Type: image/png");
print fread(fopen($dir['root'].'tmp/'.$tmpname, 'r'), filesize($dir['root'].'tmp/'.$tmpname));
unlink($dir['root'].'tmp/'.$tmpname);
ob_end_flush();
$cmd = "$CONVERT {$dir['root']}simg/images/bg{$backgroundIndex}.png -crop {$sizeX}x{$sizeY}+{$backgroundOffsetX}+{$backgroundOffsetY} $workFilename";
$cmd = "$CONVERT {$dir['root']}tmp/bg{$hash}.png -font $fontFile -fill \"{$color}\" -pointsize $fontSize -gravity NorthWest -draw \"translate {$textX},{$textY} rotate {$angle} text 0,0 '{$text}'\" $workFilename";
?>
|