PDA

View Full Version : چجوری این کد کپتچا رو تو صفحات دیگه چاپ کنم؟



saeed-71
پنج شنبه 23 مرداد 1393, 17:29 عصر
سلام.
چجوری این کد کپتچا رو تو صفحات دیگه چاپ کنم؟منطورم عکس تولیذ شدست.
قاعدتا باید کار کنه اما جواب نمیده!



<?php
header('Content-text:image/png');
$alphabet = array_merge(range('A', 'Z'), range(0, 9));
$text = '';
for($i = 0; $i < 6; $i++) {
$text .= $alphabet[rand(0, count($alphabet) - 1)];
}
$im = ImageCreateTrueColor(200, 50);
$backColor = ImageColorAllocate($im, 0, 0, 0);
$font = 'font.ttf';
ImageFill($im, 25, 100, $backColor);
$position = 20;
$space = 25;
for($i = 0; $i < 6; $i++) {
$rotate = rand(-10, 10);
$box = ImageTTFBBox(24, $rotate, $font, $text);
$foreColor = ImageColorAllocate($im, rand(127, 255), rand(127,255), rand(127, 255));
ImageTTFText($im, 24, $rotate, $position, (50 - $box[5]) / 2, $foreColor, $font, $text[$i]);
$position += $space;
}
for($i = 0; $i < 3; $i++) {
$maskColor = ImageColorAllocate($im, rand(63, 191), rand(63, 191), rand(63, 191));
ImageLine($im, rand(0, 50), rand(10, 40), rand(150, 200), rand(10, 40), $maskColor);
ImageArc($im, rand(0, 200), rand(0, 50), rand(10, 20), rand(10, 20), rand(0, 359), rand(0, 359), $maskColor);
}
//ob_start();
imagepng($im);
//$imageData = base64_encode(ob_get_clean());
?>

فرزند کوروش
پنج شنبه 23 مرداد 1393, 17:48 عصر
عکس تولید شده رو باید داخل تگ image چاپ کنی

<img src="yourPage.php" />
جای yourPage.php مسیر فایل کپچا خودتو بزار

saeed-71
پنج شنبه 23 مرداد 1393, 21:10 عصر
این کارو کردم فایده نداشت!

vahidqara
پنج شنبه 23 مرداد 1393, 21:55 عصر
دوست خوب کلا نمایش نمیده ؟ یا اینکه خطایی میده؟

saeed-71
پنج شنبه 23 مرداد 1393, 22:11 عصر
چیزی نمایش داده نمیشه.
ولی وقتی اینجوری میکنم نمایش داده میشه




<?php
header('Content-text:image/png');
$alphabet = array_merge(range('A', 'Z'), range(0, 9));
$text = '';
for($i = 0; $i < 6; $i++) {
$text .= $alphabet[rand(0, count($alphabet) - 1)];
}
$im = ImageCreateTrueColor(200, 50);
$backColor = ImageColorAllocate($im, 0, 0, 0);
$font = 'font.ttf';
ImageFill($im, 25, 100, $backColor);
$position = 20;
$space = 25;
for($i = 0; $i < 6; $i++) {
$rotate = rand(-10, 10);
$box = ImageTTFBBox(24, $rotate, $font, $text);
$foreColor = ImageColorAllocate($im, rand(127, 255), rand(127,255), rand(127, 255));
ImageTTFText($im, 24, $rotate, $position, (50 - $box[5]) / 2, $foreColor, $font, $text[$i]);
$position += $space;
}
for($i = 0; $i < 3; $i++) {
$maskColor = ImageColorAllocate($im, rand(63, 191), rand(63, 191), rand(63, 191));
ImageLine($im, rand(0, 50), rand(10, 40), rand(150, 200), rand(10, 40), $maskColor);
ImageArc($im, rand(0, 200), rand(0, 50), rand(10, 20), rand(10, 20), rand(0, 359), rand(0, 359), $maskColor);
}
ob_start();
ImagePNG($im);
$imageData = base64_encode(ob_get_clean());
?>
<image src="data:image/png;base64,<?php echo $imageData; ?>" style="border-radius: 5px;" />

saeed-71
جمعه 24 مرداد 1393, 10:08 صبح
کسی نمیدونه؟گیرشم

یا این یکی کد میگه نمیتونه تصویرو نمایش بده چون ارور داره ولی ارورشو نشون نمیده



<?php
ob_start();

$alphabet = array_merge(range('A', 'Z'), range(0, 9));
$text = '';
for($i = 0; $i < 6; $i++) {
$text .= $alphabet[rand(0, count($alphabet) - 1)];
}
$im = @ImageCreateTrueColor(200, 50);
$backColor = ImageColorAllocate($im, 0, 0, 0);
$font = 'font.ttf';
ImageFill($im, 25, 100, $backColor);
$position = 20;
$space = 25;
for($i = 0; $i < 6; $i++) {
$rotate = rand(-10, 10);
$box = ImageTTFBBox(24, $rotate, $font, $text);
$foreColor = ImageColorAllocate($im, rand(127, 255), rand(127,255), rand(127, 255));
ImageTTFText($im, 24, $rotate, $position, (50 - $box[5]) / 2, $foreColor, $font, $text[$i]);
$position += $space;
}
for($i = 0; $i < 3; $i++) {
$maskColor = ImageColorAllocate($im, rand(63, 191), rand(63, 191), rand(63, 191));
ImageLine($im, rand(0, 50), rand(10, 40), rand(150, 200), rand(10, 40), $maskColor);
ImageArc($im, rand(0, 200), rand(0, 50), rand(10, 20), rand(10, 20), rand(0, 359), rand(0, 359), $maskColor);
}
//ob_start();

imagepng($im);
header('Content-type:image/png');

imagedestroy($im);
//$imageData = base64_encode(ob_get_clean());
?>

saeed-71
جمعه 24 مرداد 1393, 11:01 صبح
حل شد


<?php
header('Content-type:image/png');
$alphabet = array_merge(range('A', 'Z'), range(0, 9));
$text = '';
for($i = 0; $i < 6; $i++) {
$text .= $alphabet[rand(0, count($alphabet) - 1)];
};
$im = imagecreate(150, 40);
$backColor = imagecolorallocate($im, 227, 227, 227);
$font = 'font.ttf';
imagefill($im, 25, 100, $backColor);
$position = 5;
$space = 25;
for($i = 0; $i < 6; $i++) {
$rotate = rand(-5, 5);
$box = ImageTTFBBox(24, $rotate, $font, $text);
$font_size=20;
$foreColor = ImageColorAllocate($im, rand(0, 100), rand(0,100), rand(0, 100));
imagettftext($im, $font_size, $rotate, $position, (33 - $box[5]) / 2, $foreColor, $font, $text[$i]);
$position += $space;
}
for($i = 0; $i < 3; $i++) {
$maskColor = imagecolorallocate($im, rand(60, 100), rand(60, 100), rand(60, 100));
imageline($im, rand(0, 50), rand(10, 40), rand(150, 200), rand(10, 40), $maskColor);
imagearc($im, rand(0, 200), rand(0, 50), rand(10, 20), rand(10, 20), rand(0, 359), rand(0, 359), $maskColor);
}
imagepng($im);
imagedestroy($im);
?>