로그인 체크함수다.
Web에서 로그인하는 경우와 안드로이드에서 로그인하는 경우 2가지를 모두 수용할 수 있게 작성했다.
안드로이드폰 직접 접속시에는 폰의 장치정보를 인식하므로 deviceID 정보를 식별자로 사용하여 Web 접속과 Mobile 접속을 구분 처리했다.
<?php
if(!isset($_SESSION)) {
session_start();
}
if(isset($_POST['loginID']) && !empty($_POST['loginID']) && isset($_POST['loginPW']) && !empty($_POST['loginPW'])) {
$loginID = trim($_POST['loginID']);
$loginPW = trim($_POST['loginPW']);
$deviceID = trim($_POST['deviceID']);
$deviceID = $deviceID ? $deviceID : '';
if(empty($deviceID)){
require_once 'dbconnect.php'; // db접속
require_once 'phpclass/loginClass.php';
$c=new LoginClass();
$row = $c->WebUserAuthCheck($loginID,$loginPW);
if(is_array($row)) {
if($row['code'] > 0) {
$_SESSION['userID'] = $row['id'];
$_SESSION['userPW'] = md5($loginPW);
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['ua'] = $_SERVER['HTTP_USER_AGENT'];
echo("<meta http-equiv='Refresh' content='0; URL=list.php'>");
} else {
echo '권한 불가';
}
} else if($row == '0'){
$msg ='정보가 올바르지 않습니다';
echo "<script>alert('".$msg."');history.go(-1);</script>";
} else {
$msg ='정보가 올바르지 않습니다';
echo "<script>alert('".$msg."');history.go(-1);</script>";
}
} else {
require_once 'db.info.php';
require_once 'phpclass/dbClass.php';
$conn=new MySQLDbClass();
$DB_CONNECT = $conn->isConnectDb($DB); // 안드로이드폰에서는 반드시 객체로 생성해야 정상접속
require_once 'phpclass/loginClass.php';
$c=new LoginClass();
$result = $c->MobileUserAuthCheck($loginID,$loginPW,$deviceID);
if($result > 0 ) {
session_save_path('./_tmp/session');
$_SESSION['userID'] = $loginID;
$_SESSION['userPW'] = md5($loginPW);
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['ua'] = $_SERVER['HTTP_USER_AGENT'];
echo 'Login Success';
} else if($result == 0) {
echo 'Login Fail';
} else {
echo 'Phone Dismatch';
}
}
} else {
echo("<meta http-equiv='Refresh' content='0; URL=loginForm.php'>");
}
?>
'Web 프로그램 > 회원가입과 로그인' 카테고리의 다른 글
[PHP] 구글 로그인 연동 (0) | 2017.01.14 |
---|---|
HTML5 index 처리 흐름도 (0) | 2016.11.07 |
jQuery ajax POST 처리 - 아이디 중복 체크 (0) | 2016.08.10 |
[중급] SQL Injection 공격 방지를 위한 PHP 로그인 체크 함수 (0) | 2016.07.07 |
Form submit 및 로그인 jQuery (1) | 2016.04.06 |
보통 deprecate 되어도 이전 코드를 지우는 건 아니기 때문에, 전처럼 동작하기는 할 것이다.
향후, 유지보수단계에서 deprecate 코드에 대해서 안정성을 보장하지 않는다는 얘기이기 때문에, 안드로이드 차기 버전 에서는 비정상 동작을 할 가능성이 높아진다.
대체코드를 찾아서 새롭게 구현하는게 현명한 판단이다.
메모리 누수를 일으키는 현상에 대한 정리가 잘된 자료이다.
http://sjava.net/2016/05/%EB%B2%88%EC%97%AD-%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%95%B1%EC%9D%B4-%EB%A9%94%EB%AA%A8%EB%A6%AC-%EB%88%84%EC%88%98leak%EB%A5%BC-%EB%A7%8C%EB%93%9C%EB%8A%94-8%EA%B0%80%EC%A7%80/
depricated 로 나온 걸 하나 하나 해결하기 위해 찾은 걸 적어나갈 것이다.
URLDecoder.decode(getIntent().getExtras().getString("url"), "UTF-8");
getSettings().setUserAgent(0); => getSettings().setUserAgentString("Android");
URLEncoder.encode("","UTF-8")
Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead NetworkCheck.java
url = url.toLowerCase(); ==> url = url.toLowerCase(Locale.getDefault());
// http://beginnersbook.com/2013/12/java-string-tolowercase-method-example/
The method decode(String) from the type URLDecoder is deprecated
URLEncoder.encode(String s, String enc);
import java.net.URLEncoder;
URLEncoder.encode("This text must be encoded!", "UTF-8");
AlertDialog: BUTTON_POSITIVE, BUTTON_NEUTRAL and BUTTON_NEGATIVE.
AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
alertDialog.setTitle(" [ 알림 ]");
alertDialog.setMessage("등록된 휴대폰 번호가 없습니다.");
alertDialog.setButton("확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
alertDialog.setTitle(" [ 알림 ]")
.setMessage("등록된 휴대폰 번호가 없습니다.")
.setCancelable(false)
.setNegativeButton("확인",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = alertDialog.create();
alert.show();
alertDialog.setButton("확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,"확인", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
// http://www.technotalkative.com/issue-using-setjavascriptenabled-can-introduce-xss-vulnerabilities-application-review-carefully/
@SuppressLint("SetJavaScriptEnabled")
public class MyActivity extends Activity
{
...
}
// 내용 파악이 필요한 부분
showDialog(DIALOG_DOWNLOAD_PROGRESS);
The method showDialog(int) from the type Activity is deprecated
https://developer.android.com/reference/android/app/Activity.html#showDialog%28int%29
This method was deprecated in API level 13.
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,null,Charset.forName("UTF-8"));