<?php
	function adminchecklogin($username='',$adminpassword='',$usertype = "", $adminid='')
	{
		$chklogin= false;
		if (($username!='')&&($adminpassword!=''))
		{
			$UserRegistration = new AllTables();
			
          echo  $sql = "select * from ".USER_TABLE." where username = '".$username."' and password = '".$adminpassword."' and status = 1 limit 0,1";
			//echo $sql;
			$user = $UserRegistration -> getInfo('',$sql);
			
            if($user)
			{
				$rowcount = count($user);
				if ($rowcount > 0)
				{
					
					session::add_param('userid',$user[0]['userid']);
					session::add_param('username',$user[0]['username']);
					session::add_param('name',$user[0]['name']);
                    session::add_param('status',$user[0]['status']);
					session::add_param('usertype',$user[0]['usertype']);
					
                    $G_userid	   = 	session::get_param('userid');
                    $G_username	   = 	session::get_param('username');
                    $G_name		   = 	session::get_param('name');
                    $G_status	   = 	session::get_param('status');
                    $G_usertype	   = 	session::get_param('usertype');
                    
                    setcookie(SITE_DOMAIN,(md5($user[0]['userid'].COOKIE_SALT)));
					$chklogin= true;
                }
			}
			else
			{
					session::add_param('loginerrormessage',LOGIN_ERROR_MESSAGE);
			}
		}
		else if ($adminid!="")
		{
			$getuserid = session::get_param('userid');
			if ($adminid === $getuserid)
			{
				$chklogin= true;
			}
			else
			{
				$chklogin= false;
			}
		}
		return $chklogin;
	}
	
?>