<?php
	
	function adminchecklogin($username='',$adminpassword='',$usertype,$adminid='')
	{
		$chklogin= false;
		if (($username!='')&&($adminpassword!='')&&($usertype!=''))
		{
			$UserRegistration = new AllTables();
			$adminemail 	= $username;
			$pass 			= $adminpassword;
			$passtocheck 	= $pass;
			$usertype 		= $usertype;	
		 	$sql = "select * from adminusers where adminemail='$username' and adminpassword='$passtocheck' and usertype='$usertype'";
			//echo $sql;
			$user = $UserRegistration -> getInfo('',$sql);
			//echo $user;
			if ($user)
			{
				$rowcount = count($user);
				//echo $rowcount;
				if ($rowcount > 0)
				{
					
					session::add_param('adminid',$user[0]['adminid']);
					session::add_param('adminemail',$user[0]['adminemail']);
					session::add_param('adminpassword',$user[0]['adminpassword']);
					session::add_param('adminname',$user[0]['adminname']);
					session::add_param('usertype',$user[0]['usertype']);
					
					$G_adminid					= 	session::get_param('adminid');
					$G_adminname				= 	session::get_param('adminname');
					$G_adminemail				= 	session::get_param('adminemail');
					$G_adminadminpassword		= 	session::get_param('adminadminpassword');
					$G_admintype				= 	session::get_param('usertype');
					
					
					setcookie(SITE_DOMAIN,(md5($user[0]['adminid'].COOKIE_SALT)));
					$chklogin= true;
				}
			}
			else
			{
					//echo 'Error';
					session::add_param('loginerrormessage',LOGIN_ERROR_MESSAGE);
			}
		}
		else if ($adminid!="")
		{
			$getuserid = session::get_param('adminid');
			if ($adminid === $getuserid)
			{
				$chklogin= true;
			}
			else
			{
				$chklogin= false;
			}
		}
		return $chklogin;
	}
	
?>