<?php

class Captca
{
	protected function getRandHorA($n, $nn)
	{
		if($n == 1){
			$kode = rand(0, 9);
		}else{
		
			$abjat = array('1' => 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 
							'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
			$r = rand(1, 26);
			if($nn == 1){
				$h = $abjat[$r];
			}else{
				$h = strtolower($abjat[$r]);
			}
			$kode = $h;
		}
		
		return $kode;
	}
	
	public function getCaptCha($awal = 5, $akhir = 7)
	{
		$i = rand($awal, $akhir);
		
		$kode = $this->getRandHorA(rand(1, 2), rand(1, 2));

		for($n = 1; $n <= $i; $n++){
			$kode.= $this->getRandHorA(rand(1, 2), rand(1, 2));
		}
		
		return $kode;
	}
}