Location: PHPKode > projects > Kwalbum > kwalbum/include/JoinValidate.php
<?php 
/* 2.1: 2008-10-04
 * Kwalbum 2.0, 0.9.0
 */
if (!isset ($DB))
{
	require_once pathinfo(__FILE__, PATHINFO_DIRNAME) . '/DBConnection.php';
	$DB = new DBConnection();
}

class JoinValidate
{
	public $passLength = 6;
	public function validateAJAX($inputValue, $fieldID)
	{
		switch($fieldID)
		{
			case 'txtName':
				return $this->validateName($inputValue);
				break;
			case 'txtTitle':
				return $this->validateTitle($inputValue);
				break;
			case 'txtEmail':
				return $this->validateEmail($inputValue);
				break;
			case 'txtPass1':
				return $this->validatePassword($inputValue);
				break;
			case 'txtCode':
				return $this->validateCode($inputValue);
				break;
			default:
				return 0;
		}
	}

	private function validateName($unsafeValue)
	{
		global $DB;
		$value = htmlspecialchars(stripslashes(trim($unsafeValue)), ENT_QUOTES);
		if ($value == null or $value != $unsafeValue)
			return 0;
		$query = 'SELECT UserName FROM '.USER_TABLE." WHERE UserName='$value'";
		$result = $DB->Query($query);
		if ($result->num_rows > 0)
			return 0;
		return 1;
	}

	private function validateTitle($unsafeValue)
	{
		$value = htmlspecialchars(stripslashes(trim($unsafeValue)), ENT_QUOTES);
		if ($value == null or $value != $unsafeValue)
			return 0;
		return 1;
	}

	private function validateEmail($value)
	{
		return (!eregi('^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$', $value)) ? 0 : 1;
	}

	private function validatePassword($value)
	{
		return ($this->passLength > strlen($value)) ? 0 : 1;
	}
	
	private function validateCode($code)
	{
		if (empty($code))
			return 0;
		session_start();
		if (strtoupper($code) != strtoupper($_SESSION['REGcharstr']))
			return 0;
		return 1;
	}
}
?>
Return current item: Kwalbum