All pastes #813984 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-12 22:31 UTC
rendered paste body
<?php 
class user { #Add the su_vcode (sign up vcode) into this page
  function generate_code(){
  /*This function will generate a validation code (vcode) which the user
    will input to prevent against spam bots*/
    
    $code="";
    //set up code and validation  
    $letter = range( 'A', 'Z' );
    $numbers = range( '0', '9' );
    $all = array_merge( $letter, $numbers );
    for ( $counter1 = 0; $counter1 < 6; $counter1++ ) {
      shuffle( $all );
      $random = rand( 0, 35 );
      // generate code
      $code = $code.' '.$all[$random];        
    }
    return $code;
  }
  function image_validation(){
  /* This function will take the vcode generated in generate_code() and 
    create an image which the user can see on the registration form*/
    
    $vcode = $this -> generate_code();
    require('conf_system.php');
  
    $_SESSION['validation_image']=str_replace(" ","",$vcode);
    $im = @imagecreate(135, 30);
    // white background and blue text
    $bg = imagecolorallocate($im, 255, 255, 255);
    $textcolor = imagecolorallocate($im, 0, 0, 0);
    
    // write the string at the top left
    imagettftext($im, 12, 0, 40, 18, $textcolor, "{$conf_s['font']}", $vcode);
    #imagestring($im, 5, 10, 5, $code, );

    // output the image

    imagejpeg ($im, $conf_s['validate_image']."verify.jpg");
    imagedestroy($im);
    
    echo "<img src=\"template/vimage/verify.jpg\" alt=\"verification image\" />";
  }
  
}
?>