PHP Captcha Security Images
Hello & Welcome to our community. Is this your first visit? Đăng Ký
Follow us on
Follow us on Facebook Follow us on Twitter Linked In Flickr Watch us on YouTube My Space Blogger
 
Kết quả 1 đến 1 của 1
  1. #1
    Thành Viên Tâm Huyết tuidangvui's Avatar
    Ngày tham gia
    Mar 2009
    Bài viết
    715
    Thanks
    114
    Thanked 477 Times in 243 Posts

    PHP Captcha Security Images

    <?php
    class CaptchaSecurityImages {

    var $font = 'monofont.ttf';

    function generateCode($characters) {
    /* list all possible characters, similar looking characters and vowels have been removed */
    $possible = '23456789bcdfghjkmnpqrstvwxyz';
    $code = '';
    $i = 0;
    while ($i < $characters) {
    $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
    $i++;
    }
    return $code;
    }

    function CaptchaSecurityImages($width='120',$height='40',$c haracters='6') {
    $code = $this->generateCode($characters);
    /* font size will be 75% of the image height */
    $font_size = $height * 0.75;
    $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
    /* set the colours */
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 20, 40, 100);
    $noise_color = imagecolorallocate($image, 100, 120, 180);
    /* generate random dots in background */
    for( $i=0; $i<($width*$height)/3; $i++ ) {
    imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
    }
    /* generate random lines in background */
    for( $i=0; $i<($width*$height)/150; $i++ ) {
    imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    }
    /* create textbox and add text */
    $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
    $x = ($width - $textbox[4])/2;
    $y = ($height - $textbox[5])/2;
    imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
    /* output captcha image to browser */
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
    $_SESSION['security_code'] = $code;
    }

    }

    $width = isset($_GET['width']) ? $_GET['width'] : '120';
    $height = isset($_GET['height']) ? $_GET['height'] : '40';
    $characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';

    $captcha = new CaptchaSecurityImages($width,$height,$characters);

    ?>


    Sử dụng .htaccess
    RewriteEngine onRewriteRule captcha.jpg /CaptchaSecurityImages.phpCaptchaSecurityImages.php
    <img src="CaptchaSecurityImages.php" alt="" />Security Code:<input id="security_code" name="security_code" type="text" />
    session_start();if(($_SESSION['security_code'] == $_POST['security_code']) && (!empty($_SESSION['security_code'])) ) { unset($_SESSION['security_code']);} else { // Insert your code for showing an error message here}
    Lần sửa cuối bởi tuidangvui, ngày 16-04-14 lúc 09:46 AM.
    yh, sky: nhatkiemthe [Only registered and activated users can see links. ]

 

 

Các Chủ đề tương tự

  1. [KT] Share lại Tool tạo SPR Images Creater
    Bởi kiemthienvn trong diễn đàn Releases
    Trả lời: 5
    Bài viết cuối: 10-03-14, 02:09 PM
  2. Enhanced Captcha Image Verification - stop bots from signing up
    Bởi KingSky trong diễn đàn vBulletin 3.8 Add-ons
    Trả lời: 0
    Bài viết cuối: 11-02-14, 10:52 AM
  3. Import External Images
    Bởi PandavB trong diễn đàn vBulletin 4.x Add-ons
    Trả lời: 0
    Bài viết cuối: 10-02-14, 10:29 AM
  4. [TLBB] đã ai fix code check thẻ vcoin của vtc id emobile ( vượt mã captcha ) chưa ?
    Bởi nhocshi trong diễn đàn Hỏi Đáp/ Yêu Cầu
    Trả lời: 0
    Bài viết cuối: 03-03-13, 03:40 PM
  5. [1.03C+Dev] ver Full + Images
    Bởi eddy trong diễn đàn Development
    Trả lời: 25
    Bài viết cuối: 02-05-09, 02:56 PM

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •  
Múi giờ GMT +7. Bây giờ là 08:07 PM.
vBulletin®, Copyright ©2000-2011, Jelsoft Enterprises Ltd.
CLBGamesVN không chịu trách nhiệm về Luật Bản Quyền của các tài liệu, bài viết v.v...được đăng tải trên diễn đàn này.
Diễn đàn phát triển dưới sự đóng góp của tất cả thành viên. BQT chỉ là những người thành lập ra sân chơi, quản lý và duy trì về mặt kỹ thuật, nội dung khi hợp lệ.