ApiUser.php
10.6 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBase.php" ;?>
<?
/*
* Admin process
* add by dev.lee
*/
if (! class_exists("ApiUser"))
{
class ApiUser extends ApiBase
{
function __construct($req)
{
parent::__construct($req);
}
// 회원가입 여부 판단 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.initLogin&id=aa)
function initLogin()
{
$userID = $this->req["userID"];
$sql = "
SELECT userID
FROM tblUser
WHERE userID='{$userID}' AND status=1
LIMIT 0,1
";
$userID = $this->getValue($sql, "userID");
$returnCode = - 1;
if ($userID != "")
{
$returnCode = 1;
}
return $this->makeResultJson($returnCode, "");
}
function removeSpecials($string){
return preg_replace("/[ #\&\+\-%@=\/\\\:;,\.'\"\^`~\_|\!\?\*$#<>()\[\]\{\}]/i", "", $string);
}
function checkIDRedundancy(){
$userID=$this->req["userID"];
$sql="
SELECT *
FROM tblUser
WHERE userID='{$userID}' AND status=1
LIMIT 0, 1
";
$result=$this->getRow($sql);
if($result != null)
return $this->makeResultJson(-100, "사용할 수 없는 아이디 입니다");
else
return $this->makeResultJson(1, "사용할 수 있는 아이디 입니다");
}
function checkNickRedundancy(){
$nickName=$this->req["nickName"];
$sql="
SELECT *
FROM tblUser
WHERE nickName='{$nickName}' AND status=1
LIMIT 0, 1
";
$result=$this->getRow($sql);
if($result != null)
return $this->makeResultJson(-100, "사용할 수 없는 닉네임 입니다");
else
return $this->makeResultJson(1, "사용할 수 있는 닉네임 입니다");
}
// 회원 가입 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.memberJoin)
function memberJoin()
{
$userID = $this->req["userID"];
$userPwd = md5($this->req["userPwd"]);
$userPwdConfirm=md5($this->req["userPwdConfirm"]);
$userName = $this->req["userName"];
$nickName = $this->req["nickName"];
$userTel = str_replace(" ", "", $this->req["userTel"]);
$userVehicleTON=$this->req["userVehicleTON"];
$userVehicleName=$this->req["userVehicleName"];
$userVehicleType=$this->req["userVehicleType"];
$userVehicleWish=$this->req["userVehicleWish"];
$deviceTypeID = $this->req["deviceTypeID"];
$deviceID = $this->req["deviceID"];
$registrationKey = $this->req["registrationKey"];
$appVersion = $this->req["appVersion"];
//if($nickName=="")
//$nickName=$userName;
// $status = ($memType == this.MEM_TYPE_NOMAL) ? "" : "" ;
$sql = "
SELECT *
FROM tblUser
WHERE `userID` = '{$userID}' AND `status` = 1
LIMIT 1
";
$regInfo = $this->getRow($sql);
if(strlen($userID) < 6)
return $this->makeResultJson(-106, "아이디는 여섯 자리 이상이어야 합니다.");
if($regInfo != null)
return $this->makeResultJson(-100, "아이디 중복을 확인해 주세요.");
$sql="SELECT * FROM tblUser WHERE nickName='{$nickName} AND status=1'";
$regInfo=$this->getRow($sql);
if($regInfo != null)
return $this->makeResultJson(-101, "닉네임 중복을 확인해 주세요.");
if(strlen($userPwd) != strlen($this->removeSpecials($userPwd))) {
return $this->makeResultJson(-103, "비밀번호에는 특수문자가 포함될 수 없습니다.");
}
else if(strlen($userPwd) < 4)
return $this->makeResultJson(-104, "비밀번호는 네 자리 이상이어야 합니다.");
if($userPwd != $userPwdConfirm)
return $this->makeResultJson(-105, "비밀번호가 일치하지 않습니다.");
/*
if($userTel == "")
return $this->makeResultJson(-105, "전화번호는 필수 입력사항입니다.");
*/
$insAssoc = Array(
"userType"=>1,
"userID" => $userID,
"userPwd"=> $userPwd,
"userName" => $userName,
"nickName" => $nickName,
"userTel" => $userTel,
"userVehicleTON" => $userVehicleTON,
"userVehicleName" => $userVehicleName,
"userVehicleType" => $userVehicleType,
"userVehicleWish" => $userVehicleWish,
"deviceTypeID" => $deviceTypeID,
"deviceID" => $deviceID,
"registrationKey" => $registrationKey,
"push" => 1,
"appVersion" => $appVersion,
"lastLoginDate"=>"now()",
"status" => 1,
"regDate" => "now()"
);
$result = $this->techOfInsertForUpdate("tblUser", $insAssoc);
$no = $this->mysql_insert_id();
/*
$file_vir_name = "";
$file_org_name = "";
if ($this->MEM_REGI_EMAIL == $regiType)
{
$updateFileData = $this->inFn_Common_fileSave($_FILES);
$file_vir_name = $updateFileData["file"]["saveURL"];
$file_org_name = $updateFileData["file"]["name"];
}
else
{
$file_vir_name = $this->req["fileName"];
}
$insFile = Array(
"file_org_name" => $file_org_name,
"file_vir_name" => $file_vir_name,
"reg_dt" => "now()",
"pa_no" => $no,
"file_type" => "ME"
);
$fileResult = $this->techOfInsertForUpdate("tbl_file", $insFile);
*/
if ($result > 0)
{
$returnCode = "1";
$returnMessage = "가입되었습니다.";
}
else
{
$returnCode = "-1";
$returnMessage = "오류가 발생했습니다.";
}
return $this->makeResultJson($returnCode, $returnMessage, $userInfo);
}
// 회원 로그인 (http://106.240.232.36:8004/action_front.php?cmd=ApiUser.userLogin)
function userLogin()
{
$userID = $this->req["userID"];
$userPwd= md5($this->req["userPwd"]);
$deviceID = $this->req["deviceID"];
$deviceTypeID = $this->req["deviceTypeID"];
$registrationKey = $this->req["registrationKey"];
$appVersion = $this->req["appVersion"];
$param = Array(
$userID,
$deviceID,
$deviceTypeID,
$registrationKey,
$appVersion
);
$sql = $this->strCallProc3("uspU_loginUser", $param);
$result = $this->getMultiArray($sql);
if ($result[0][0]["v_returnCode"] > 0)
{
$userInfo = $this->inFn_ApiBase_getInfoOfUser($result[0][0]["v_userNumber"]);
//echo $userPwd;
//echo $userInfo["userID"];
if($userInfo["userPwd"] != $userPwd)
return $this->makeResultJson("-1000", "비밀번호를 확인하세요");
LoginUtil::doAppLogin($userInfo);
return $this->makeResultJson($result[0][0]["v_returnCode"], $result[0][0]["v_returnMsg"], $userInfo);
}
else
{
return $this->makeResultJson($result[0][0]["v_returnCode"], $result[0][0]["v_returnMsg"]);
}
}
function userAutoLogin(){
$userNumber=$this->req["userNumber"];
$userID = $this->req["userID"];
$deviceID = $this->req["deviceID"];
$deviceTypeID = $this->req["deviceTypeID"];
$registrationKey = $this->req["registrationKey"];
$appVersion = $this->req["appVersion"];
$userPwd=md5($this->req["userPwd"]);
$param = Array(
$userNumber,
$deviceID,
$deviceTypeID,
$registrationKey,
$appVersion,
$userPwd
);
$result=$this->inFn_ApiBase_autoLogin($param);
return $this->makeResultJson($result["isLogin"], $result["loginMessage"], $result["loginInfo"]);
}
// 비동기 푸시키 갱신 API
function setUserRegistrationKey()
{
$userNo = $this->appUser["no"];
$registrationKey = $this->req["registrationKey"];
if ($no != "-1")
{
$sql = "
UPDATE tblUser
SET registrationKey = '{$registrationKey}'
WHERE userNo = '{$userNo}'
";
$this->update($sql);
}
}
// 푸시 설정
function setPushOnOff()
{
$userNo = $this->appUser["no"];
$push = $this->req["push"];
$sql = "
UPDATE tbl_user
SET push = '{$push}'
WHERE `userNo` = '{$userNo}'
";
$result = $this->update($sql);
return $this->makeResultJson("1", "");
}
// 로그아웃
function userLogout()
{
$userNo = $this->appUser["no"];
// 푸시키 초기화
$sql = "
UPDATE tblUser
SET registrationKey = ''
WHERE userNo = '{$userNo}'
";
$this->update($sql);
return $this->makeResultJson("1", "");
}
// 정보수정
function modifyUserInfo()
{
$userNo = $this->appUser["no"];
//$is_file_change = $this->req["is_file_change"]; // NEW / DEL / NON
$userPwd = $this->req["userPwd"];
$userPwdConfirm = $this->req["userPwdConfirm"];
$nickName = $this->req["nickName"];
$userTel = str_replace(" ", "", $this->req["userTel"]);
$userVehicleTON=$this->req["userVehicleTON"];
$userVehicleName=$this->req["userVehicleName"];
$userVehicleType=$this->req["userVehicleType"];
$userVehicleWish=$this->req["userVehicleWish"];
/*
// 삭제함
if ($is_file_change != "NON")
{
$sql = "
DELETE FROM tbl_file WHERE pa_no = '{$userNo}' AND file_type = '{$this->FILE_TYPE_MEM}'
";
$this->update($sql);
}
// 파일 업로드
if ($is_file_change == "NEW" && ($_FILES != null && sizeof($_FILES) > 0))
{
$updateFileData = $this->inFn_Common_fileSave($_FILES);
$file_vir_name = $updateFileData["file"]["saveURL"];
$file_org_name = $updateFileData["file"]["name"];
$insFile = Array(
"file_org_name" => $file_org_name,
"file_vir_name" => $file_vir_name,
"reg_dt" => "now()",
"pa_no" => $userNo,
"file_type" => $this->FILE_TYPE_MEM
);
$fileResult = $this->techOfInsertForUpdate("tbl_file", $insFile);
}
*/
$sql="SELECT * FROM tblUser WHERE nickName='{$nickName} AND status=1'";
$regInfo=$this->getRow($sql);
if($regInfo != null)
return $this->makeResultJson(-100, "닉네임 중복을 확인해 주세요");
if($userPwd != $userPwdConfirm)
return $this->makeResultJson(-101, "비밀번호 가 일치하지 않습니다");
$sql = "
UPDATE tbl_user
SET
userPwd='{$userPwd}',
nickName='{$nickName}',
userTel='{$userTel}',
userVehicleTON='{$userVehicleTON}',
userVehicleName='{$userVehicleName}',
userVehicleType='{$userVehicleType}',
userVehicleWish='{$userVehicleWish}'
WHERE `userNo` = '{$userNo}'
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다.", $this->inFn_ApiBase_getInfoOfUser($userNo));
}
/**
* 회원 정보 조회
*/
function getUserInfo()
{
$no = $this->req["no"];
$userInfo = $this->inFn_ApiBase_getInfoOfUser($no);
return $this->makeResultJson("1", "", $userInfo);
}
function delUser(){
$userNo=$this->appUser["no"];
$sql="
UPDATE tblUser
SET expireDate=DATE_FORMAT(NOW() + interval 3 DAY, '%Y%m%d')
WHERE userNo='{$userNo}' AND status=1
";
}
function delCancel(){
$userNo=$this->appUser["no"];
$sql="
UPDATE tblUser
SET expireDate=NULL
WHERE userNo='{$userNo}' AND status=1
";
}
} // 클래스 종료
}
?>