Hacked By AnonymousFox

Current Path : C:/AppServ/www/new_msd1/webengine/mod_circle/captcha/
Upload File :
Current File : C:/AppServ/www/new_msd1/webengine/mod_circle/captcha/class.captcha.php

<?
class js3_captcha{
	var $show;
	var $img;
	var $stringSize;

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	function js3_captcha($stringSize=5, $lang="en", $string="" , $imgType="gif"){	# เป็น constructor ของคลาสนี้
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
		if($stringSize > 10) $stringSize=10;
		if($imgType!=="gif" || $imgType!=="jpg" || $imgType!=="jpeg" || $imgType!=="png") $imgType="gif";

		$this->stringSize=$stringSize;
		
		if(strtolower($lang)=="th" || strtolower($lang)=="thai")
			$this->show=($string=="") ? $this->_randomStringThai($this->stringSize) : $string;
		else if(strtolower($lang)=="num" || strtolower($lang)=="number")
			$this->show=($string=="") ? $this->_randomStringThai($this->stringSize, "0123456789") : $string;
		else
			$this->show=($string=="") ? $this->_randomString($this->stringSize) : $string;

		$this->img=$this->_create($this->show);
		$this->_show($this->img,$imgType);
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	function _create($string){	#	เมทธอด หลัก ในการสร้างรูปภาพ
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		
		# จัดแจงสร้าง set ของสีไว้รอ ซัก 5 ชุดขึ้นไป (R,G,B) ;
		$colors = array(); 
		$colors[0]=array(174,0,174);
		$colors[1]=array(85,178,85);
		$colors[2]=array(226,108,97);
		$colors[3]=array(67,188,182);
		$colors[4]=array(100,100,100);
		$colors[5]=array(100,138,204); 

		$positionX = 10;
		$size = 30; 

		# เริ่มสร้างรูปกันเลยครับ .. เอา noise.png มาทำ background ระวังเรื่อง พาธ ด้วย
		$image=imagecreatefrompng("fonts/noise.png"); 

		# กำหนดสีให้กับตัวอักษรแต่ละตัว ต้องแยก วนลูป กับการสร้างตัวอักษร
		for($i=0; $i<$this->stringSize; $i++)
		{
			$color= rand(0, 5);	# สุ่มกำหนดสีให้แต่ละอักษรครับ
			$textColor[] = imagecolorallocate ($image, $colors[$color][0], $colors[$color][1], $colors[$color][2]);
		}

		# วนลูปสร้างตัวอักษร และ แปะ ลงพื้นหลัง
		for($i=0; $i<$this->stringSize; $i++)
		{
			$angle = rand(-30, 20);		# หักมุมกันนิดๆหน่อยๆ
			$font = "fonts/".rand(1, 2).".ttf"; # Font ใช้ตัวใหญ่ๆ จากเว็บ f0nt.com จะได้ไม่มีปัญหาลิขสิทธิ์

			# และแล้วก็บรรจงแปะตัวอักษรลงไป
			imagettftext($image, $size, $angle, $positionX , $size, $textColor[$i], $font, $string{$i});
			$positionX += 25;
		}

		return $image;
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	function _randomString($len=5 , $string="1234567890") {	# สุ่มเอาอักษร และตัวเลข
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
		# ฟังก์ชั่นในการสุ่มเลือกตัวอักษร ตามจำนวนที่ต้องการ
		$txtRandom = "";
		for($i=1; $i<=$len; $i++)
		{
				$txtRandom .= $string{rand(0, (strlen($string)-1))};
		}
		return $txtRandom;
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	function _randomStringThai($len=5 , $string="ถคจลบยนรฟหกสวงมทอปธ") {	# สุ่มเอาอักษร และตัวเลข
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
		# ฟังก์ชั่นในการสุ่มเลือกตัวอักษร ตามจำนวนที่ต้องการ
		$txtRandom = "";
		for($i=1; $i<=$len; $i++)
		{
				$txtRandom .= $string{rand(0, (strlen($string)-1))};
		}
		return $txtRandom;
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	function _show($image, $type="gif"){	# สำหรับแสดงรูปภาพ ตรงนี้สามารถกำหนดได้ 3 ชนิด
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
		switch($type){
			case "gif":
						header("Content-type: image/".$type);
						imagegif($image);
						break;						
			case "jpg":
			case "jpeg":
						header("Content-type: image/".$type);
						imagejpeg($image);
						break;
			case "png":
						header("Content-type: image/".$type);
						imagepng($image);
						break;
			default:
						die("Type error");
		}
		imagedestroy($image);
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	function _getString(){	# สำหรับเช็คความถูกต้อง ในการตรวจสอบ
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
		return $this->show;
	}

} # จบ class

?>

Hacked By AnonymousFox1.0, Coded By AnonymousFox