<?php
	session_start();
	
	class PublicView {
		function captchaimg() {
			$md5 = md5(rand(0,99999));
			$codeorig = substr($md5, 10, 10);
			$code = substr($codeorig, 0, 5).' '.substr($codeorig, 6, 9);
			$_SESSION['pointer'] = md5($code);
			$dir = 'css/';
			$width = 120;
			$height = 32;
			$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
			$background_color = imagecolorallocate($image, 255, 255, 255);
			$text_color = imagecolorallocate($image, 85, 85, 85);
			$noise_color = imagecolorallocate($image, 200, 200, 200);
			for( $i=0; $i<($width*$height)/5; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); }
			for( $i=0; $i<($width*$height)/200; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); }
			imagestring($image, 5, 15, 8, $code, $text_color); 
			header('Content-Type: image/jpeg');
			imagejpeg($image);
			imagedestroy($image);
		}
		
		function chckcapt() {
			echo $_SESSION['pointer'];
		}
	}
	
	if (isset($_GET['view']) && method_exists('PublicView',$_GET['view'])){
		$view = new PublicView();
		$view->$_GET['view']();
	} else {
		echo 'Function not found';
	}
?>