if ($homepageimage == "1") { $w = strlen($homepage); $wd = round($w / 4, 0, PHP_ROUND_HALF_UP); if ($w < 20) { $wd = '20'; } header("Content-type: image/png"); $size = 10; $width = '700'; $height = $wd; $string = $homepage; $im = imagecreatetruecolor(400, 30); $image = imagecreate($width, $height); $background = ImageColorAllocate($image, 255, 255, 255); $color = imagecolorallocate($image, 0, 0, 0); image_create($image, $size, 3, 2, $string, $color, $width); imagepng($image); imageDestroy($image); } function image_create($image, $size, $x, $y, $text, $color, $maxwidth) { $fontwidth = ImageFontWidth($size); $fontheight = ImageFontHeight($size); if ($maxwidth != NULL) { $maxchar = floor($maxwidth / $fontwidth); $text = wordwrap($text, $maxchar, "\n", 1); } $lines = explode("\n", $text); while (list($numl, $line) = each($lines)) { ImageString($image, $size, $x, $y, $line, $color); $y += $fontheight;
<?php session_start(); if (isset($_GET['act'])) { if ($_GET['act'] == "image") { image_create(); } else { if ($_GET['act'] == "chek") { if (isset($_GET['ans'])) { $tmp_answer = (int) $_GET['ans']; if ($_GET['ans'] == $_SESSION['answer']) { echo "true"; } else { echo "false"; } } } } } else { exit; } function image_create() { header("Content-type: image/png"); $string = $_GET['text']; $font = imageloadfont("font.gdf"); $im = imagecreatefrompng("captsource.png"); $color[0] = imagecolorallocate($im, 0, 0, 0); $color[1] = imagecolorallocate($im, 192, 192, 192); $color[2] = imagecolorallocate($im, 255, 255, 00); $color[3] = imagecolorallocate($im, 00, 128, 255);
function image_watermark(&$p, &$error = null) { if (empty($p['imgwidth'])) { list($p['imgwidth'], $p['imgheight'], $p['img-type']) = getimagesize($p['temp']); $p['img-type'] = image_type_to_mime_type($p['img-type']); } if (empty($p['watermark'])) { $p['watermark'] = 'images/watermark.png'; } $watermark = imagecreatefrompng($p['watermark']); imagealphablending($watermark, true); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $watermark_resized_width = $p['imgwidth'] * $p['watermark-ratio']; $watermark_resized_height = $p['imgheight'] * $p['watermark-ratio']; $watermark_resized = imagecreatetruecolor($watermark_resized_width, $watermark_resized_height); imagealphablending($watermark_resized, false); imagesavealpha($watermark_resized, true); imagecopyresampled($watermark_resized, $watermark, 0, 0, 0, 0, $watermark_resized_width, $watermark_resized_height, $watermark_width, $watermark_height); imagedestroy($watermark); $image = image_create($p); $dest_x = ($p['imgwidth'] - $watermark_resized_width) / 2; $dest_y = ($p['imgheight'] - $watermark_resized_height) / 2; imagecopymerge_alpha($image, $watermark_resized, $dest_x, $dest_y, 0, 0, $watermark_resized_width, $watermark_resized_height); $p['file'] = $p['file'] . '.' . $p['ext']; switch ($p['img-type']) { case 'image/gif': imagegif($image, $p['file']); break; case 'image/pjpeg': case 'image/jpeg': case 'image/jpg': imagejpeg($image, $p['file'], 75); break; case 'image/png': case 'image/x-png': imagealphablending($image, false); imagesavealpha($image, true); imagepng($image, $p['file']); break; } imagedestroy($image); imagedestroy($watermark_resized); }