로그인 기능 임시 추가
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
require_once('_common.php');
|
||||||
|
require_once(ROOT.'/f_func/class._Session.php');
|
||||||
|
require_once(ROOT.'/f_func/class._String.php');
|
||||||
|
require_once(ROOT.'/f_config/DB.php');
|
||||||
|
|
||||||
|
use utilphp\util as util;
|
||||||
|
|
||||||
|
$SESSION = new _Session();
|
||||||
|
if($SESSION->isLoggedIn()){
|
||||||
|
$SESSION->logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
$username = util::array_get($_POST['username']);
|
||||||
|
$password = util::array_get($_POST['password']);
|
||||||
|
|
||||||
|
if(!$username || !$password){
|
||||||
|
returnJson([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'올바르지 않은 입력입니다.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$userInfo = getRootDB()->queryFirstRow(
|
||||||
|
'SELECT `no`, `id`, `name`, `grade` '.
|
||||||
|
'from member where id=%s_username AND '.
|
||||||
|
'pw=sha2(concat(salt, %s_password, salt), 512)',[
|
||||||
|
'username'=>$username,
|
||||||
|
'password'=>$password
|
||||||
|
]);
|
||||||
|
|
||||||
|
if(!$userInfo){
|
||||||
|
returnJson([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'아이디나 비밀번호가 올바르지 않습니다.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$SESSION->login($userInfo['no'], $userInfo['id'], $userInfo['grade']);
|
||||||
|
returnJson([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'로그인 되었습니다.'
|
||||||
|
]);
|
||||||
@@ -2,9 +2,85 @@
|
|||||||
require('_common.php');
|
require('_common.php');
|
||||||
require(ROOT.'/f_config/SETTING.php');
|
require(ROOT.'/f_config/SETTING.php');
|
||||||
|
|
||||||
if($SETTING->isExist()){
|
if(!$SETTING->isExist()){
|
||||||
header ("Location:i_login/login.php");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
header ('Location:install.php');
|
header ('Location:install.php');
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require(ROOT.'/f_config/DB.php');
|
||||||
|
require(ROOT.'/f_func/class._Session.php');
|
||||||
|
|
||||||
|
$SESSION = new _SESSION();
|
||||||
|
|
||||||
|
use utilphp\util as util;
|
||||||
|
|
||||||
|
if($SESSION->isLoggedIn()){
|
||||||
|
header ('Location:i_entrance/entrance.php');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$access_token = $SESSION->get('access_token');
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>삼국지 모의전투 HiD 서버</title>
|
||||||
|
<script src="e_lib/jquery-3.2.1.min.js"></script>
|
||||||
|
<script src="e_lib/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="e_lib/jquery.validate.min.js"></script>
|
||||||
|
<script src="e_lib/sha512.min.js"></script>
|
||||||
|
<script src="js/login.js"></script>
|
||||||
|
<link type="text/css" rel="stylesheet" href="e_lib/bootstrap.min.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="css/login.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="row justify-content-md-center">삼국지 모의전투 HiD</h1>
|
||||||
|
<div class="row justify-content-md-center">
|
||||||
|
<div class="col col-12 col-md-10 col-lg-7">
|
||||||
|
<div class="card">
|
||||||
|
<h3 class="card-header">
|
||||||
|
로그인
|
||||||
|
</h3>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<form id="main_form" method="post" action="#">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="username" class="col-sm-3 col-form-label">계정명</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="text" class="form-control" name="username" id="username" placeholder="계정명"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="password" class="col-sm-3 col-form-label">비밀번호</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<input type="password" class="form-control" name="password" id="password" placeholder="비밀번호"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="hidden" id="global_salt" name="global_salt" value="<?=getGlobalSalt()?>">
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-sm-3"></div>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<button type="submit" class="btn btn-primary btn-lg btn-block login-button">로그인</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
$(document).ready( function () {
|
||||||
|
$( "#main_form" ).validate( {
|
||||||
|
rules: {
|
||||||
|
username: {
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
username: {
|
||||||
|
required: "유저명을 입력해주세요"
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
required: "비밀번호를 입력해주세요"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errorElement: "div",
|
||||||
|
errorPlacement: function ( error, element ) {
|
||||||
|
// Add the `help-block` class to the error element
|
||||||
|
error.addClass( "invalid-feedback" );
|
||||||
|
|
||||||
|
if ( element.prop( "type" ) === "checkbox" ) {
|
||||||
|
error.insertAfter( element.parent( "label" ) );
|
||||||
|
} else {
|
||||||
|
error.insertAfter( element );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
highlight: function ( element, errorClass, validClass ) {
|
||||||
|
$( element ).addClass( "is-invalid" ).removeClass( "is-valid" );
|
||||||
|
},
|
||||||
|
unhighlight: function (element, errorClass, validClass) {
|
||||||
|
$( element ).addClass( "is-valid" ).removeClass( "is-invalid" );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
$( "#main_form" ).submit(function(){
|
||||||
|
var raw_password = $('#password').val();
|
||||||
|
var salt = $('#global_salt').val();
|
||||||
|
var hash_pw = sha512(salt + raw_password + salt);
|
||||||
|
|
||||||
|
$.post({
|
||||||
|
url:'i_login/j_login.php',
|
||||||
|
dataType:'json',
|
||||||
|
data:{
|
||||||
|
'username':$('#username').val(),
|
||||||
|
'password':hash_pw
|
||||||
|
}
|
||||||
|
}).then(function(obj){
|
||||||
|
if(!obj.result){
|
||||||
|
alert(obj.reason);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
alert('로그인!');
|
||||||
|
window.location.href = 'i_entrance/entrance.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} );
|
||||||
Reference in New Issue
Block a user