Location: PHPKode > scripts > qAdmin > jonathan-fielding-qAdmin-04ccc6a/classes/user_auth.class.php
<?php

//
// Name: User Authentication
// Decription: Class to handle the user authentication of the web application.
// Author: Jonathan Fielding
// 

class UserAuth
{
	function validateUser($sUsername, $sPassword){
		//Pass clear text username and MD5 password into this function to validate a user
		
		//Get a database connection
		$database_connection = new database_connection();
		
		//Run query
		$result = $database_connection->dataquery("SELECT * FROM tblUser WHERE username = '" . $sUsername . "' AND password = '" . $sPassword . "'");
		
		//If data returned, return to calling function
		if(is_resource($result))
		{
			if(mysql_num_rows($result) > 0) {
				return true;
			}
			else{
				return false;
			}
		}	
	}
	
	function getUser($sUsername, $sPassword){
		//Pass clear text username and MD5 password into this function to validate a user
		
		//Get a database connection
		$database_connection = new database_connection();
		
		//Run query
		$result = $database_connection->dataquery("SELECT * FROM tblUser WHERE username = '" . $sUsername . "' AND password = '" . $sPassword . "'");
		
		//If data returned, return to calling function
		if(is_resource($result))
		{
			while($row = mysql_fetch_array($result))
			{
				return $row;
			}
		}	
	}
	
	function getAuthLevel($sUsername){
		//Pass username to retrieve the authority of the user
		
		//Get a database connection
		$database_connection = new database_connection();
		
		//Run query
		$result = $database_connection->dataquery("SELECT authority FROM tblUser WHERE username = '" . $sUsername . "'");
		
		//If data returned, return to calling function
		if(mysql_num_rows($result) == 1)
		{
			while($row = mysql_fetch_array($result))
			{
				return $row['authority'];
			}	
		}
	}
	
	function checkPageAuth($sPage){
		//Pass username to retrieve the authority of the user
		
		//Get a database connection
		$database_connection = new database_connection();
		
		//Run query
		$result = $database_connection->dataquery("SELECT authority FROM tblPages WHERE file = '" . $sPage . "'");
		
		//If data returned, return to calling function
		if(is_resource($result))
		{
			while($row = mysql_fetch_array($result))
			{
				return $row['authority'];
			}	
		}
	}
}
?>
Return current item: qAdmin