LoginUtil.php 3.97 KB
<?php
/*
 * Created on 2006. 09. 25
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */ 
if(! class_exists("LoginUtil")){
	 class LoginUtil
	 {
	 	public static $spliter = 30 ;		// Seperator Ascii code
	 	//public static "211.110.140.155";
	 	// public static $cookieDomain = "localhost";
	 	public static $cookieDomain = "106.240.232.36" ;
			
		static function getAdminUser()
		{
			$cookieStr = $_COOKIE["admMap"] ;
	 		
			if( LoginUtil::isAdminLogin() == false )
			{	
				$map['adminNumber'] = "-1" ;
				// $map['mem_id'] = session_id() ;
			}
			else
			{
				$cookieStr = pack("H*",$cookieStr);
				
				$aUser = explode(chr(self::$spliter),$cookieStr);
	
				$map['no']					=	$aUser[0] ;
				$map['admin_type']			=	$aUser[1] ;
				$map['admin_name']			=	$aUser[2] ;
				$map['admin_phone']			=	$aUser[3] ;
				$map['target_fk']			=	$aUser[4] ;
			}
	
	 		return $map ;	
		}
		
		// 로그인 유무
		static function isAdminLogin(){
			$cookieStr = $_COOKIE["admMap"] ;
					
			return ( $cookieStr != "" ) ? true : false ;
		}
		
		//관리자 로그인
		static function doAdminLogin($row){
	
			if($row != null){
				$cookieStr =
	
				$row['no'] 					. chr(self::$spliter) .
				$row['admin_type']			. chr(self::$spliter) .
				$row['admin_name']			. chr(self::$spliter) .
				$row['admin_phone']			. chr(self::$spliter) .
				$row['target_fk']			. chr(self::$spliter) ;
								
				$cookieStr = bin2hex($cookieStr) ; // 16진수로 암호화
	
// 				setcookie("admMap",$cookieStr,-1,"/", self::$cookieDomain);
				setcookie("admMap",$cookieStr,-1,"/", '') ;
//				var_dump(self::$cookieDomain);
//				var_dump($_COOKIE);
				//exit;
	
				return true ;
				
			}else{
				
				return false ;
			}			
		}
		
		//admin 로그아웃
		static function doAdminLogout(){
			setcookie("admMap","",time() - 3600,"/",self::$cookieDomain) ;
		}
		
		
		
		//입력 후 로그인 - APP 로그인
		static function doAppLogin($row){
	
			if($row != null){
				$cookieStr =

				$row['userNo']			. chr(self::$spliter) .
				$row['userID']			. chr(self::$spliter) .
				$row['userPwd']			. chr(self::$spliter) .
				$row['userName']		. chr(self::$spliter) .
				$row['userType']	. chr(self::$spliter) .
				$row['userTel']			. chr(self::$spliter) .
				$row['deviceTypeID']			. chr(self::$spliter) .
				$row['deviceID']			. chr(self::$spliter) ;
								
				$cookieStr = bin2hex($cookieStr) ; // 16진수로 암호화
	
				//setcookie("userMap",$cookieStr,-1,"/", '.richware.co.kr') ;
				setcookie("userMap",$cookieStr,-1,"/", self::$cookieDomain) ;
	
				return true ;
				
			}else{
				
				return false ;
			}
		}
		
		
		// 어플 로그인 여부를 확인한다.
	 	static function isAppLogin()
	 	{
	 		$aUser[0] = "";
	 		if(isset($_COOKIE["userMap"])) {
		 		$cookieStr = $_COOKIE["userMap"] ;
		 		
				$cookieStr = pack("H*",$cookieStr);
					
				$aUser = explode(chr(self::$spliter),$cookieStr);		
	 		}
	 		return ( $aUser[0] != "" && $aUser[0] != "-1"  ) ? true : false ;
	 	}
		
		
		static function getAppUser(){
			$cookieStr = isset($_COOKIE["userMap"]) ? $_COOKIE["userMap"] : "" ;
			
			if(isset($_COOKIE["userMap"])){
				$cookieStr = pack("H*",$cookieStr);
				
				$aUser = explode(chr(self::$spliter),$cookieStr);
	
				$map['no']		=	$aUser[0] ;
				$map['id']			=	$aUser[1] ;
				$map['pwd']			=	$aUser[2] ;
				$map['name']		=	$aUser[3] ;
				$map['userType']	=	$aUser[4] ;
				$map['userTel']		=	$aUser[5] ;
				$map['deviceTypeID']=	$aUeser[6];
			}
			$aUser = explode(chr(self::$spliter),$cookieStr);

			$map['no']		=	$aUser[0] ;
			$map['id']			=	$aUser[1] ;
			$map['pwd']			=	$aUser[2] ;
			$map['name']		=	$aUser[3] ;
			$map['userType']	=	$aUser[4] ;
			$map['userTel']		=	$aUser[5] ;
			$map['deviceTypeID']=	$aUeser[6];
			
			if( LoginUtil::isAppLogin() == false )
			{	
				$map['no'] = "-1" ;
			}
	
	 		return $map ;	
		}
		
		
		static function doAppLogout(){
			setcookie("userMap","",time() - 3600,"/",self::$cookieDomain) ;
		}
		
	

 	}	
}
?>