7d6c7ff5da8f12cf4785b49c26eb464f52c2e8c2.svn-base
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?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 = "localhost" ;
static function getAdminUser()
{
$cookieStr = $_COOKIE["admMap"] ;
if( LoginUtil::isAdminLogin() == false ){
$map['adminNo'] = "-1" ;
// $map['mem_id'] = session_id() ;
}
else
{
$cookieStr = pack("H*",$cookieStr);
$aUser = explode(chr(self::$spliter),$cookieStr);
$map['adminNo'] = $aUser[0] ;
$map['adminID'] = $aUser[1] ;
$map['adminName'] = $aUser[2] ;
$map['adminPhone'] = $aUser[3] ;
$map['regDate'] = $aUser[4] ;
}
return $map ;
}
// 로그인 유무
static function isAdminLogin(){
$cookieStr = $_COOKIE["admMap"] ;
return ( $cookieStr != "" ) ? true : false ;
}
//관리자 로그인
static function doAdminLogin($row){
if($row != null){
$cookieStr =
$row['adminNo'] . chr(self::$spliter) .
$row['adminID'] . chr(self::$spliter) .
$row['adminName'] . chr(self::$spliter) .
$row['adminPhone'] . chr(self::$spliter) .
$row['regDate'] . 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) ;
// echo json_encode($row);
$cookieStr = bin2hex($cookieStr) ; // 16진수로 암호화
setcookie("userMapForApp", $cookieStr, -1, "/", '') ;
return true ;
}else{
return false ;
}
}
// 어플 로그인 여부를 확인한다.
static function isAppLogin()
{
$aUser[0] = "";
if(isset($_COOKIE["userMapForApp"])) {
$cookieStr = $_COOKIE["userMapForApp"] ;
$cookieStr = pack("H*",$cookieStr);
$aUser = explode(chr(self::$spliter),$cookieStr);
}
return ( $aUser[0] != "" && $aUser[0] != "-1" ) ? true : false ;
}
static function getAppUser(){
$cookieStr = isset($_COOKIE["userMapForApp"]) ? $_COOKIE["userMapForApp"] : "" ;
if(isset($_COOKIE["userMapForApp"])){
$cookieStr = pack("H*",$cookieStr);
//echo $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("userMapForApp","",time() - 3600,"/",self::$cookieDomain) ;
}
}
}
?>