From 07f5140771388c9e0c8a99b0dd2e5d950bdb173b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 14 Oct 2021 15:16:42 +1100 Subject: moving h-source subdir out. --- h-source/admin/Library/Image/Gd/Captcha.php | 85 ----------------------------- 1 file changed, 85 deletions(-) delete mode 100644 h-source/admin/Library/Image/Gd/Captcha.php (limited to 'h-source/admin/Library/Image/Gd/Captcha.php') diff --git a/h-source/admin/Library/Image/Gd/Captcha.php b/h-source/admin/Library/Image/Gd/Captcha.php deleted file mode 100644 index ace4806..0000000 --- a/h-source/admin/Library/Image/Gd/Captcha.php +++ /dev/null @@ -1,85 +0,0 @@ - 150, - 'boxHeight' => 100, - 'charNumber' => 6, - 'fontPath' => $here.'/External/Fonts/FreeFont/FreeMono.ttf', - 'undulation' => true, - 'align' => false, - 'charHeight' => 28 - ); - - //set the $this->scaffold->params array - if (is_array($params)) - { - foreach ($params as $key => $value) - { - $defaultParams[$key] = $value; - } - } - $this->params = $defaultParams; - - $this->string = generateString($this->params['charNumber']); - } - - public function render() - { - //space among characters - $space = $this->params['boxWidth'] / ($this->params['charNumber']+1); - //create the image box - $img = imagecreatetruecolor($this->params['boxWidth'],$this->params['boxHeight']); - - $background = imagecolorallocate($img,255,255,255); - $border = imagecolorallocate($img,0,0,0); - $colors[] = imagecolorallocate($img,mt_rand(0,125),mt_rand(0,125),mt_rand(0,125)); - $colors[] = imagecolorallocate($img,mt_rand(0,125),mt_rand(0,125),mt_rand(0,125)); - $colors[] = imagecolorallocate($img,mt_rand(0,125),mt_rand(0,125),mt_rand(0,125)); - - //create the background - imagefilledrectangle($img,1,1,$this->params['boxWidth']-2,$this->params['boxHeight']-2,$background); - imagerectangle($img,0,0,$this->params['boxWidth']-1,$this->params['boxHeight']-2,$border); - - //set the text - for ($i=0; $i< $this->params['charNumber']; $i++) - { - $color = $colors[$i % count($colors)]; - $char = substr($this->string,$i,1); - $fontPath = $this->params['fontPath']; - $angle = $this->params['undulation'] === false ? 0 : -20+rand(0,40); - $yposFixed = (int)(($this->params['boxHeight'])/2); - $ypos = $this->params['align'] === true ? $yposFixed : $yposFixed + mt_rand(0,10); - $charHeight = $this->params['charHeight']; - imagettftext($img,$charHeight + rand(0,8),$angle,($i+0.3)*$space,$ypos,$color,$fontPath,$char); - } - - $noiseColor = imagecolorallocate($img, mt_rand(125,255), mt_rand(125,255), mt_rand(125,255)); - /* generate random dots in background */ - for( $i=0; $i<($this->params['boxWidth'] * $this->params['boxHeight'])/7; $i++ ) { - imagefilledellipse($img, mt_rand(0,$this->params['boxWidth']), mt_rand(0,$this->params['boxHeight']), 1, 1, $noiseColor); - } - - $_SESSION['captchaString'] = $this->string; - header('Content-Type: image/png'); - imagepng($img); - imagedestroy($img); - } - -} \ No newline at end of file -- cgit v1.2.3