createCode() public method

Create a code and save to the session
Since: 1.0.1
public createCode ( )
Ejemplo n.º 1
0
 /**
  * 生成验证码2
  * @param type $sessionName
  * @param type $width
  * @param type $height
  */
 static function validatePic2($sessionName = "defaultSess", $width = 0, $height = 0)
 {
     require Yii::app()->basePath . '/components/SecurImage.php';
     $validateImage = new Securimage();
     $validateImage->use_gd_font = true;
     $validateImage->gd_font_file = Yii::app()->basePath . "/components/font/crass.gdf";
     $validateImage->draw_lines = false;
     $validateImage->arc_linethrough = false;
     $validateImage->sess_name = $sessionName;
     if ($width != 0) {
         $validateImage->image_width = $width;
     }
     if ($height != 0) {
         $validateImage->image_height = $height;
     }
     $code = $validateImage->createCode();
     Yii::app()->session[$sessionName] = strtolower($code);
     $validateImage->show();
 }