session_start();
$font = "arial.ttf";
$width = "84";
$height = "22";
$hane = "6";
function rastgele($text)
{
    $mevcut = "abcdefghjkmnprstuxvyz23456789ABCDEFGHJKMNPRSTUXVYZ";
    $salla = '';
    for ($i = 0; $i < $text; $i++) {
        $salla .= $mevcut[rand(0, 48)];
    }
    return $salla;
}
$metin = rastgele($hane);
$resim_yaz = imagecreate($width, $height);
imagecolorallocate($resim_yaz, 255, 255, 255);
$text_renk = imagecolorallocate($resim_yaz, 255, 165, 0);
$bg1 = imagecolorallocate($resim_yaz, 244, 244, 244);
$bg2 = imagecolorallocate($resim_yaz, 227, 239, 253);
$bg3 = imagecolorallocate($resim_yaz, 207, 244, 204);
header('Content-type: image/png');
imagettftext($resim_yaz, 26, -4, 4, 25, $bg1, $font, $metin);
imagettftext($resim_yaz, 30, -7, 0, 15, $bg2, $font, $metin);
for ($i = 0; $i < $width * $height / 400; $i++) {
    imageline($resim_yaz, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $bg3);
}
imagettftext($resim_yaz, 14, 3, 7, 17, $text_renk, $font, $metin);
imagepng($resim_yaz);
imagedestroy($resim_yaz);
Exemple #2
0
{
    $key = '';
    switch ($type) {
        case 2:
            $pattern = "ABCDEFGHJKMNPQRSTUVWXYZABCDEFGHJKMNPQRSTUVWXYZ";
            break;
        case 3:
            $pattern = "2345678923456789234567892345678923456789";
            break;
        default:
            $pattern = "23456789ABCDEFGHJKMNPQRSTUVWXYZ";
            break;
    }
    for ($i = 0; $i < $length; $i++) {
        $key .= $pattern[rand(0, 35)];
    }
    return $key;
}
$en = 100;
$boy = 25;
$sayi = rastgele(7, 1);
$_SESSION['captcha'] = $sayi;
$sercankd = imagecreatefromgif("images/captchabg.gif");
$b = imagecolorallocate($sercankd, 100, 100, 50);
$s = imagecolorallocate($sercankd, 0, 0, 0);
imagefill($sercankd, 0, 0, $s);
imageline($sercankd, 20, 50, $en, $boy, $b);
imagestring($sercankd, 3, 27, 7, $sayi, $b);
Header("content-type:image/gif");
imagegif($sercankd);
imagedestroy($sercankd);
<?php

include "afmhacekirdek.php";
if ($_POST) {
    $sayi1 = @$_POST['sayi1'];
    $sayi2 = @$_POST['sayi2'];
    if (empty($sayi1)) {
        $sayi1 = 1;
    }
    if (empty($sayi2)) {
        $sayi2 = 5;
    }
    rastgele($sayi1, $sayi2);
} else {
    echo '
      <form action="" method="POST">
        1. Sayı : <input type="text" name="sayi1"><br>
        2. Sayı : <input type="text" name="sayi2"><br>
        <input type="submit" name="gonder" value="Rastgele Sayı">
      </form>
    ';
}