How to change the captcha.lib

Discussion in 'PHP' started by Lukas, Jun 15, 2007.

  1. #1
    My captcha images and text are very hard to see.

    would someone help me to modify the script a little to make it bold and get the slanty lines out of the middle.

    
    <?php
    # ----------------------------------------------------
    // DO NOT EDIT
    require_once("config.php");
    error_reporting(E_ALL );
    function Get_Text()
    {
    global $text_length;
    	$letters =  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");
    mt_srand((double)microtime()*1000000);
     $txt = "";
     //$rand_keys = array_rand($letters, $text_length);
     //foreach($rand_keys as $key)
    // {
     // $txt .= $letters[$key];
    // }
    shuffle($letters);
    for($i=0;$i<$text_length;$i++)
    {
      $key = rand(0,count($letters)-1);
      $txt .= $letters[$key];	
    }
    return $txt;
    }
    
    function create_image()
    {
        global $width,$hight,$text_length,$border;
        $im = imagecreate($width,$hight);
        $bgc = imagecolorallocate($im, rand(235,255), rand(235,255),rand(235,255));
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefill($im,0,0,$tc);
        imagefilledrectangle($im,$border,$border,$width-$border,$hight-$border,$bgc);
        return $im;
    
    }
    
    function draw_string($txt,$im)
    {
       global $hight,$width,$font,$text_length;
       $space1 = $width/($text_length+1);   //space between characters
       $space2 = ($width - $space1)/3  ;   //space between lines
       $center = $hight/2;
    
    
       for($f=0;$f<3;$f++)
       {
       	$y1 =  $center/2;
      	$y2 =  1.5*$center;
      	$x1 = ($space1/2) + ($f * $space2);
      	$x2 = ($space1/2) + (($f +1) * $space2);
      	// echo "$x1,$x2 + $y1,$y2 <br>";
         for($k=0;$k<2;$k++)
    	  {
               $lc =  imagecolorallocate($im,rand(0,200), rand(0,200), rand(0,200));
               imageline($im,rand($x1,$x2),rand($y1,$y2),rand($x1,$x2),rand($y1,$y2),$lc);
          }
        }
    
    	for($i=0;$i<$text_length;$i++)
    	{
    	 $txtc =  imagecolorallocate($im,rand(0,160), rand(0,160), rand(0,160));
    	 $x = ($space1+($i*$space1)); //x  coordinate of each character
    	 
    	 imagestring($im,$font,$x,rand($center-($center/2),$center),$txt[$i],$txtc);
    	}
    
    }
    ?>
    
    
    PHP:

    
    <?php
    // DO NOT EDIT
    session_start();
    error_reporting(E_ALL ^ E_NOTICE);
    require_once("captchalib.php");
    header("Content-type: image/png");
    
    $str = Get_Text();
    $im = create_image();
    draw_string($str,$im);
    imagepng($im);
    if($CaseSenstive==true)
    {
    $_SESSION['pfw_text']=md5($str);
    }
    else
    {
    $str = strtolower($str);
    $_SESSION['pfw_text']=md5($str);
    }
    ?>
    
    PHP:
    
    <?php
    //this file includes the settings of form captcha
    $error = 'security code is not correct'  ;
    $error_display_mode = 2 ;
    $error_page=  '' ;
    $font =  5  ;
    $hight = 40  ;
    $width =  120  ;
    $text_length = 3  ;
    $border =  0  ;
    
    //Make sure you change this to refelct the proper contact form name.
    $form =  contact.htm'  ;
    $CaseSenstive = false  ;
    $user = 'max'  ;
    $pass =  'dde2790ce930e3d425305c36afd4e69c' ;
    $redirect = false ;
    $success_page = 'thank-you.htm'  ;
    ?>
    
    PHP:
     
    Lukas, Jun 15, 2007 IP
  2. dzysyak

    dzysyak Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First of all try to change the $font.
     
    dzysyak, Jun 15, 2007 IP
  3. Lukas

    Lukas Well-Known Member

    Messages:
    1,299
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    130
    #3
    tried that already...it worked somewhat
    I want to get rid of those pesky slanted lines on image.
     
    Lukas, Jun 16, 2007 IP