function outputImage()
 {
     if (!function_exists('imagecreatetruecolor') || !function_exists('imagecolorallocate') || !function_exists('imagepng')) {
         header("ContentType: image/bmp");
         $code = $this->getCode(1);
         echo $this->Codebmp($code, $this->num);
         exit;
     }
     $code = $this->getCode();
     L::loadClass('graphic', 'utility/captcha', false);
     $graphic = new PW_Graphic($this->width, $this->height);
     $graphic->backGround = $this->style & 8 ? 'image' : 'random';
     if (!empty($_GET['nowtime'])) {
         $graphic->setCodes($code);
         $this->gdcontent == 3 && ($graphic->lang = 'ch');
         $graphic->fontSize = $this->height / ($this->gdcontent == 3 ? 2.4 : 2);
         if ($this->style & 64 && function_exists('imagegif')) {
             $graphic->imageType = 'gif';
         }
         $this->style & 16 && ($graphic->fontRandomColor = true);
         $this->style & 4 && ($graphic->fontRandomAngle = true);
         $this->style & 2 && ($graphic->fontRandomSize = true);
         ($this->style & 1 || $this->gdcontent == 3) && function_exists('imagettftext') && ($graphic->fontRandomFamily = true);
         $this->style & 32 && ($graphic->disturbImg = true);
     }
     $graphic->display();
 }
Exemple #2
0
    $question = $qkey < 0 ? getMachineQuestion_1() : $db_question[$qkey];
    $array = array();
    strtoupper($db_charset) == 'GBK' && ($question = pwConvert($question, 'UTF-8', 'GBK'));
    $len = strlen($question);
    for ($i = 0, $j = 0; $i < $len;) {
        ++$i;
        $ord = ord($question[$j]);
        if ($ord > 127) {
            if ($ord >= 192 && $ord <= 223) {
                ++$i;
            } elseif ($ord >= 224 && $ord <= 239) {
                $i = $i + 2;
            } elseif ($ord >= 240 && $ord <= 247) {
                $i = $i + 3;
            }
        }
        $array[] = substr($question, $j, $i - $j);
        $j = $i;
    }
    $strSize = count($array);
    if ($strSize) {
        L::loadClass('graphic', 'utility/captcha', false);
        $graphic = new PW_Graphic($strSize * 14, 24);
        $len > $strSize && ($graphic->lang = 'ch');
        $graphic->fontRandomPosition = false;
        $graphic->fontRandomFamily = true;
        $graphic->fontRandomColor = false;
        $graphic->setCodes($array);
        $graphic->display();
    }
}