tmp_kakao를 경로 이동
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if(!defined('ROOT')){
|
||||
define('ROOT', '..');
|
||||
}
|
||||
require_once(ROOT.'/f_config/config.php');
|
||||
require_once(ROOT.'/f_config/app.php');
|
||||
require_once(ROOT.'/f_func/func.php');
|
||||
|
||||
CustomHeader();
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>카카오 로그인하기</title>
|
||||
<script src="../e_lib/jquery-3.2.1.min.js"></script>
|
||||
<script>
|
||||
|
||||
var oauthMode = null;
|
||||
|
||||
function getOAuthToken(mode='login', scope_list = null){
|
||||
oauthMode = mode;
|
||||
var url = 'https://kauth.kakao.com/oauth/authorize?client_id=<?=KakaoKey::REST_KEY?>&redirect_uri=<?=KakaoKey::REDIRECT_URI?>&response_type=code';
|
||||
if(Array.isArray(scope_list)){
|
||||
url += '&scope='+scope_list.join(',');
|
||||
}
|
||||
else if(typeof scope_list === 'string' || scope_list instanceof String){
|
||||
url += '&scope='+scope_list;
|
||||
}
|
||||
|
||||
window.open(url,"KakaoAccountLogin","width=600,height=450");
|
||||
|
||||
}
|
||||
|
||||
function sendTempPasswordToKakaoTalk(retry=false){
|
||||
$.post({
|
||||
url:'j_change_pw.php',
|
||||
dataType:'json'
|
||||
}).then(function(obj){
|
||||
if (!obj.result && retry) {
|
||||
getOAuthToken('change_pw', 'talk_message');
|
||||
}
|
||||
else if(!obj.result){
|
||||
alert(obj.reason);
|
||||
}
|
||||
else{
|
||||
alert('임시 비밀번호가 카카오톡으로 전송되었습니다.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function doLoginUsingOAuth(retry=false){
|
||||
$.post({
|
||||
url:'j_login_oauth.php',
|
||||
dataType:'json'
|
||||
}).then(function(obj){
|
||||
if(!obj.result){
|
||||
if(obj.noRetry || !retry){
|
||||
alert(obj.reason);
|
||||
}
|
||||
else{
|
||||
getOAuthToken('login');
|
||||
}
|
||||
}
|
||||
else{
|
||||
window.location.href = '../';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function postOAuthResult(result){
|
||||
if(result == 'join'){
|
||||
window.location.href = 'join.php';
|
||||
}
|
||||
else if(result == 'login'){
|
||||
console.log('로그인모드');
|
||||
if(oauthMode=='change_pw'){
|
||||
sendTempPasswordToKakaoTalk();
|
||||
}
|
||||
else{
|
||||
doLoginUsingOAuth();
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert('예외 발생!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a href="javascript:doLoginUsingOAuth(true);"><img src="kakao_btn.png"></a><br>
|
||||
<br>
|
||||
비밀번호 찾기<br>
|
||||
<a href="javascript:sendTempPasswordToKakaoTalk(true);"><img src="kakao_to_me.png"></a>
|
||||
<input type='hidden' name="login_mode" id="login_mode">
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Session.php');
|
||||
require(ROOT.'/f_config/DB.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require('kakao.php');
|
||||
|
||||
use utilphp\util as util;
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
|
||||
$SESSION = new _Session();
|
||||
if(!$SESSION->isLoggedIn()){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'로그인이 되어있지 않습니다'
|
||||
]);
|
||||
}
|
||||
$userID = $SESSION->NoMember();
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
$expires = util::array_get($_SESSION['expires']);
|
||||
$refresh_token = util::array_get($_SESSION['refresh_token']);
|
||||
$refresh_token_expires = util::array_get($_SESSION['refresh_token_expires']);
|
||||
|
||||
if(!$access_token || !$expires){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오로그인이 이루어지지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//TODO: join과 login의 동작이 비슷하다. helper class로 묶자.
|
||||
$restAPI = new Kakao_REST_API_Helper($access_token);
|
||||
|
||||
if($expires < $nowDate && (!$refresh_token || ($refresh_token_expires < $nowDate))){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'로그인 토큰 만료.'.$refresh_token_expires.' 다시 카카오로그인을 수행해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($expires < $nowDate){
|
||||
unset($_SESSION['kaccount_email']);
|
||||
$email = null;
|
||||
|
||||
$result = $restAPI->refresh_access_token($refresh_token);
|
||||
if(!isset($refresh_token)){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오 로그인 과정 중 추가 갱신 절차를 실패했습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
$access_token = $result['access_token'];
|
||||
$expires = _Time::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
if(isset($result['refresh_token'])){
|
||||
$refresh_token = util::array_get($result['refresh_token']);
|
||||
$refresh_token_expires = _Time::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
getRootDB()->query("lock tables member write, member_log write");
|
||||
|
||||
$isUser = getRootDB()->queryFirstRow(
|
||||
'SELECT count(`no`) from member where no=%i',$userID);
|
||||
if(!$isUser){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'회원이 아닙니다. 관리자에게 문의해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
$newPassword = random_str(6);
|
||||
$tmpPassword = hashPassword(getGlobalSalt(), $newPassword);
|
||||
$newSalt = bin2hex(random_bytes(8));
|
||||
$newFinalPassword = hashPassword($newSalt, $tmpPassword);
|
||||
|
||||
$sendResult = $restAPI->talk_to_me_default([
|
||||
"object_type"=> "text",
|
||||
"text"=> "임시 비밀번호는 $newPassword 입니다. 로그인 후 바로 다른 비밀번호로 변경해주세요.",
|
||||
"link"=> [
|
||||
"web_url"=> getServerBasepath(),
|
||||
"mobile_web_url" => getServerBasepath()
|
||||
],
|
||||
"button_title"=> "로그인 페이지 열기"
|
||||
]);
|
||||
$sendResult['code'] = util::array_get($sendResult['code'], 0);
|
||||
if($sendResult['code'] < 0){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오톡 메시지를 보내지 못했습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
getRootDB()->update('member', [
|
||||
'pw'=>$newFinalPassword,
|
||||
'salt'=>$newSalt
|
||||
],'no=%i', $userID);
|
||||
|
||||
getRootDB()->insert('member_log', [
|
||||
'member_no'=>$userID,
|
||||
'date'=>$nowDate,
|
||||
'action_type'=>'change_pw',
|
||||
'action'=>json_encode([
|
||||
'type'=>'kakao',
|
||||
'no'=>$userID,
|
||||
'token'=>$access_token
|
||||
], JSON_UNESCAPED_UNICODE)
|
||||
]);
|
||||
|
||||
getRootDB()->query("unlock tables");
|
||||
|
||||
|
||||
returnJson([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require('lib.join.php');
|
||||
|
||||
|
||||
use utilphp\util as util;
|
||||
|
||||
session_start();
|
||||
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
if(!$access_token){
|
||||
returnJson('로그인 토큰 에러. 다시 로그인을 수행해주세요.');
|
||||
}
|
||||
|
||||
|
||||
$value = util::array_get($_POST['value']);
|
||||
switch(util::array_get($_POST['type'])){
|
||||
case 'nickname':
|
||||
returnJson(checkNicknameDup($value));
|
||||
case 'username':
|
||||
returnJson(checkUsernameDup($value));
|
||||
}
|
||||
|
||||
returnJson(false);
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require('lib.join.php');
|
||||
require_once(ROOT.'/f_func/class._Time.php');
|
||||
require('kakao.php');
|
||||
|
||||
use utilphp\util as util;
|
||||
|
||||
session_start();
|
||||
|
||||
$canJoin = getRootDB()->queryFirstField('SELECT REG FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canJoin != 'Y'){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'현재는 가입이 금지되어있습니다!'
|
||||
]);
|
||||
}
|
||||
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
$expires = util::array_get($_SESSION['expires']);
|
||||
$refresh_token = util::array_get($_SESSION['refresh_token']);
|
||||
$refresh_token_expires = util::array_get($_SESSION['refresh_token_expires']);
|
||||
if(!$access_token){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'로그인 토큰 에러. 다시 카카오로그인을 수행해주세요.'
|
||||
]);
|
||||
}
|
||||
if($expires < $nowDate && (!$refresh_token || ($refresh_token_expires < $nowDate))){
|
||||
unset($_SESSION['access_token']);
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'로그인 토큰 만료.'.$refresh_token_expires.' 다시 카카오로그인을 수행해주세요.'
|
||||
]);
|
||||
}
|
||||
$secret_agree =util::array_get($_POST['secret_agree']);
|
||||
$username = util::array_get($_POST['username']);
|
||||
$password = util::array_get($_POST['password']);
|
||||
$nickname = util::array_get($_POST['nickname']);
|
||||
|
||||
if(!$username || !$password || !$nickname){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'입력값이 설정되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(strlen($password)!=128){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 비밀번호 해시 포맷입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(!$secret_agree){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'약관에 동의해야 가입하실 수 있습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$usernameChk = checkUsernameDup($username);
|
||||
if($usernameChk !== true){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>$usernameChk
|
||||
]);
|
||||
}
|
||||
|
||||
$nicknameChk = checkNicknameDup($nickname);
|
||||
if($nicknameChk !== true){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>$nicknameChk
|
||||
]);
|
||||
}
|
||||
|
||||
$userSalt = bin2hex(random_bytes(8));
|
||||
$finalPassword = hashPassword($userSalt, $password);
|
||||
|
||||
//클라이언트 단에서 보내준 데이터 준비가 끝났다.
|
||||
$restAPI = new Kakao_REST_API_Helper($access_token);
|
||||
|
||||
if($expires < $nowDate){
|
||||
$result = $restAPI->refresh_access_token($refresh_token);
|
||||
if(!isset($refresh_token)){
|
||||
unset($_SESSION['access_token']);
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오 로그인 과정 중 추가 갱신 절차를 실패했습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
$access_token = $result['access_token'];
|
||||
$expires = _Time::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
if(isset($result['refresh_token'])){
|
||||
$refresh_token = util::array_get($result['refresh_token']);
|
||||
$refresh_token_expires = _Time::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$signupResult = $restAPI->signup();
|
||||
$kakaoID = util::array_get($signupResult['id']);
|
||||
|
||||
if(!$kakaoID && util::array_get($signupResult['msg'])!='already registered'){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오 로그인 과정 중 앱 연결 절차를 실패했습니다'.json_encode($signupResult)
|
||||
]);
|
||||
}
|
||||
|
||||
$me = $restAPI->meWithEmail();
|
||||
$me['code'] = util::array_get($me['code'], 0);
|
||||
if ($me['code']< 0) {
|
||||
$restAPI->unlink();
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오로그인이 정상적으로 수행되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(!util::array_get($me['kaccount_email_verified'],false)){
|
||||
$restAPI->unlink();
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오 계정 이메일이 아직 인증되지 않았습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
$email = $me['kaccount_email'];
|
||||
$_SESSION['kaccount_email'] = $email;
|
||||
$emailChk = checkEmailDup($email);
|
||||
if($emailChk !== true){
|
||||
$restAPI->unlink();
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>$emailChk
|
||||
]);
|
||||
}
|
||||
|
||||
//모든 절차 종료. 등록.
|
||||
getRootDB()->insert('member',[
|
||||
'oauth_id' => $kakaoID,
|
||||
'oauth_type' => 'KAKAO',
|
||||
'id' => $username,
|
||||
'email' => $email,
|
||||
'pw' => $finalPassword,
|
||||
'salt' => $userSalt,
|
||||
'name'=>$nickname,
|
||||
'reg_date'=>$nowDate
|
||||
]);
|
||||
$userID = getRootDB()->insertId();
|
||||
|
||||
getRootDB()->insert('member_log', [
|
||||
'member_no'=>$userID,
|
||||
'date'=>$nowDate,
|
||||
'action_type'=>'reg',
|
||||
'action'=>json_encode([
|
||||
'type'=>'kakao',
|
||||
'id'=>$kakaoID,
|
||||
'email'=>$email, 'name'=>$nickname
|
||||
], JSON_UNESCAPED_UNICODE)
|
||||
]);
|
||||
|
||||
returnJson([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Session.php');
|
||||
require(ROOT.'/f_config/DB.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require('kakao.php');
|
||||
use utilphp\util as util;
|
||||
|
||||
$SESSION = new _Session();
|
||||
if($SESSION->isLoggedIn()){
|
||||
$SESSION->logout();
|
||||
}
|
||||
|
||||
$canLogin = getRootDB()->queryFirstField('SELECT `LOGIN` FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canLogin != 'Y'){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'현재는 로그인이 금지되어있습니다!',
|
||||
'noRetry'=>true
|
||||
]);
|
||||
}
|
||||
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
$expires = util::array_get($_SESSION['expires']);
|
||||
$refresh_token = util::array_get($_SESSION['refresh_token']);
|
||||
$refresh_token_expires = util::array_get($_SESSION['refresh_token_expires']);
|
||||
$email = util::array_get($_SESSION['kaccount_email']);
|
||||
|
||||
|
||||
if(!$access_token || !$expires){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오로그인이 이루어지지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
//TODO: join과 login의 동작이 비슷하다. helper class로 묶자.
|
||||
$restAPI = new Kakao_REST_API_Helper($access_token);
|
||||
|
||||
if($expires < $nowDate && (!$refresh_token || ($refresh_token_expires < $nowDate))){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'로그인 토큰 만료.'.$refresh_token_expires.' 다시 카카오로그인을 수행해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($expires < $nowDate){
|
||||
unset($_SESSION['kaccount_email']);
|
||||
$email = null;
|
||||
|
||||
$result = $restAPI->refresh_access_token($refresh_token);
|
||||
if(!isset($refresh_token)){
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오 로그인 과정 중 추가 갱신 절차를 실패했습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
$access_token = $result['access_token'];
|
||||
$expires = _Time::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
if(isset($result['refresh_token'])){
|
||||
$refresh_token = util::array_get($result['refresh_token']);
|
||||
$refresh_token_expires = _Time::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!$email){
|
||||
$me = $restAPI->meWithEmail();
|
||||
$me['code'] = util::array_get($me['code'], 0);
|
||||
if ($me['code']< 0) {
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오로그인이 정상적으로 수행되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(!util::array_get($me['kaccount_email_verified'],false)){
|
||||
$restAPI->unlink();
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오 계정 이메일이 아직 인증되지 않았습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
$email = $me['kaccount_email'];
|
||||
$_SESSION['kaccount_email'] = $email;
|
||||
}
|
||||
|
||||
|
||||
$userInfo = getRootDB()->queryFirstRow(
|
||||
'SELECT `no`, `id`, `name`, `grade`, `delete_after` from member where email=%s',$email);
|
||||
|
||||
if(!$userInfo){
|
||||
$restAPI->unlink();
|
||||
unset($_SESSION['access_token']);
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>'카카오로그인에 해당하는 계정이 없습니다. 재 가입을 시도해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
if($userInfo['delete_after']){
|
||||
if($userInfo['delete_after'] < $nowDate){
|
||||
$restAPI->unlink();
|
||||
unset($_SESSION['access_token']);
|
||||
getRootDB()->delete('member', 'no=%i', $userInfo['no']);
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>"기간 만기로 삭제되었습니다. 재 가입을 시도해주세요."
|
||||
]);
|
||||
}
|
||||
else{
|
||||
$restAPI->unlink();
|
||||
unset($_SESSION['access_token']);
|
||||
returnJson([
|
||||
'result'=>false,
|
||||
'reason'=>"삭제 요청된 계정입니다.[{$userInfo['delete_after']}]"
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$SESSION->login($userInfo['no'], $userInfo['id'], $userInfo['grade']);
|
||||
returnJson([
|
||||
'result'=>true,
|
||||
'reason'=>'로그인 되었습니다.'
|
||||
]);
|
||||
@@ -0,0 +1,67 @@
|
||||
body, html{
|
||||
height: 100%;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.main{
|
||||
margin-top: 70px;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
font-size: 50px;
|
||||
font-family: 'Passion One', cursive;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
hr{
|
||||
width: 10%;
|
||||
/*color: #fff;*/
|
||||
}
|
||||
|
||||
.form-group{
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
label{
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
input,
|
||||
input::-webkit-input-placeholder {
|
||||
font-size: 11px;
|
||||
padding-top: 3px;
|
||||
}
|
||||
|
||||
.main-login{
|
||||
/*background-color: #fff;*/
|
||||
/* shadows and rounded borders */
|
||||
-moz-border-radius: 2px;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
-moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
|
||||
|
||||
}
|
||||
|
||||
.main-center{
|
||||
margin-top: 30px;
|
||||
margin: 0 auto;
|
||||
max-width: 330px;
|
||||
padding: 40px 40px;
|
||||
|
||||
}
|
||||
|
||||
.login-button{
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.login-register{
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.terms{
|
||||
max-height: 200px; overflow: auto;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require_once(__dir__.'/../d_setting/conf.php');
|
||||
|
||||
use utilphp\util as util;
|
||||
|
||||
session_start();
|
||||
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
if(!$access_token){
|
||||
header('Location:oauth_fail.html');
|
||||
}
|
||||
|
||||
$canJoin = getRootDB()->queryFirstField('SELECT REG FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canJoin != 'Y'){
|
||||
die('현재는 가입이 금지되어있습니다!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
//session_write_close();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>회원가입</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/join.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>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="confirm_password" class="col-sm-3 col-form-label">비밀번호 확인</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="password" class="form-control" name="confirm_password" id="confirm_password" placeholder="비밀번호 확인"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="nickname" class="col-sm-3 col-form-label">닉네임</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" name="nickname" id="nickname" placeholder="닉네임"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="username" class="col-sm-3 col-form-label">약관</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="card">
|
||||
<div class="card-body terms" id="terms">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="secret_agree" name="secret_agree">
|
||||
<label class="custom-control-label" for="secret_agree">동의합니다.</label>
|
||||
<div class="invalid-feedback">
|
||||
동의해야만 가입하실 수 있습니다.
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
@@ -0,0 +1,468 @@
|
||||
<?php
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
//https://devtalk.kakao.com/t/php-rest-api/14602/3
|
||||
//header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class User_Management_Path
|
||||
{
|
||||
public static $TOKEN = "/oauth/token";
|
||||
public static $SIGNUP = "/v1/user/signup";
|
||||
public static $UNLINK = "/v1/user/unlink";
|
||||
public static $LOGOUT = "/v1/user/logout";
|
||||
public static $ME = "/v1/user/me";
|
||||
public static $UPDATE_PROFILE = "/v1/user/update_profile";
|
||||
public static $USER_IDS = "/v1/user/ids";
|
||||
}
|
||||
|
||||
class Story_Path
|
||||
{
|
||||
public static $PROFILE = "/v1/api/story/profile";
|
||||
public static $ISSTORYUSER = "/v1/api/story/isstoryuser";
|
||||
public static $MYSTORIES = "/v1/api/story/mystories";
|
||||
public static $MYSTORY = "/v1/api/story/mystory";
|
||||
public static $DELETE_MYSTORY = "/v1/api/story/delete/mystory";
|
||||
public static $POST_NOTE = "/v1/api/story/post/note";
|
||||
public static $UPLOAD_MULTI = "/v1/api/story/upload/multi";
|
||||
public static $POST_PHOTO = "/v1/api/story/post/photo";
|
||||
public static $LINKINFO = "/v1/api/story/linkinfo";
|
||||
public static $POST_LINK = "/v1/api/story/post/link";
|
||||
}
|
||||
|
||||
class Talk_Path
|
||||
{
|
||||
public static $TALK_PROFILE= "/v1/api/talk/profile";
|
||||
public static $TALK_TO_ME = "/v2/api/talk/memo/send";
|
||||
public static $TALK_TO_ME_DEFAULT = "/v2/api/talk/memo/default/send";
|
||||
}
|
||||
|
||||
class Push_Notification_Path
|
||||
{
|
||||
public static $REGISTER = "/v1/push/register";
|
||||
public static $TOKENS = "/v1/push/tokens";
|
||||
public static $DEREGISTER = "/v1/push/deregister";
|
||||
public static $SEND = "/v1/push/send";
|
||||
}
|
||||
|
||||
|
||||
class Kakao_REST_API_Helper
|
||||
{
|
||||
public static $OAUTH_HOST = "https://kauth.kakao.com";
|
||||
public static $API_HOST = "https://kapi.kakao.com";
|
||||
|
||||
private static $admin_apis;
|
||||
|
||||
private $access_token;
|
||||
private $admin_key;
|
||||
|
||||
public function __construct($access_token = '') {
|
||||
|
||||
if ($access_token) {
|
||||
$this->access_token = $access_token;
|
||||
}
|
||||
|
||||
self::$admin_apis = array(
|
||||
User_Management_Path::$USER_IDS,
|
||||
Push_Notification_Path::$REGISTER,
|
||||
Push_Notification_Path::$TOKENS,
|
||||
Push_Notification_Path::$DEREGISTER,
|
||||
Push_Notification_Path::$SEND
|
||||
);
|
||||
}
|
||||
|
||||
public function request($api_path, $params = '', $http_method = 'GET')
|
||||
{
|
||||
if ($api_path != Story_Path::$UPLOAD_MULTI && is_array($params)) { // except for uploading
|
||||
$params = http_build_query($params);
|
||||
}
|
||||
|
||||
$requestUrl = ($api_path == '/oauth/token' ? self::$OAUTH_HOST : self::$API_HOST) . $api_path;
|
||||
|
||||
if (($http_method == 'GET' || $http_method == 'DELETE') && !empty($params)) {
|
||||
$requestUrl .= '?'.$params;
|
||||
}
|
||||
|
||||
$opts = array(
|
||||
CURLOPT_URL => $requestUrl,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSLVERSION => 1,
|
||||
);
|
||||
|
||||
if ($api_path != '/oauth/token')
|
||||
{
|
||||
if (in_array($api_path, self::$admin_apis)) {
|
||||
|
||||
if (!$this->admin_key) {
|
||||
throw new Exception('admin key should not be null or empty.');
|
||||
}
|
||||
$headers = array('Authorization: KakaoAK ' . $this->admin_key);
|
||||
|
||||
} else {
|
||||
|
||||
if (!$this->access_token) {
|
||||
throw new Exception('access token should not be null or empty.');
|
||||
}
|
||||
$headers = array('Authorization: Bearer ' . $this->access_token);
|
||||
}
|
||||
|
||||
$opts[CURLOPT_HEADER] = false;
|
||||
$opts[CURLOPT_HTTPHEADER] = $headers;
|
||||
}
|
||||
|
||||
if ($http_method == 'POST') {
|
||||
$opts[CURLOPT_POST] = true;
|
||||
if ($params) {
|
||||
$opts[CURLOPT_POSTFIELDS] = $params;
|
||||
}
|
||||
} else if ($http_method == 'DELETE') {
|
||||
$opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
|
||||
}
|
||||
|
||||
$curl_session = curl_init();
|
||||
curl_setopt_array($curl_session, $opts);
|
||||
$return_data = curl_exec($curl_session);
|
||||
|
||||
if (curl_errno($curl_session)) {
|
||||
throw new Exception(curl_error($curl_session));
|
||||
} else {
|
||||
// 디버깅 시에 주석을 풀고 응답 내용 확인할 때
|
||||
//print_r(curl_getinfo($curl_session));
|
||||
curl_close($curl_session);
|
||||
return json_decode($return_data, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function set_access_token($access_token) {
|
||||
$this->access_token = $access_token;
|
||||
}
|
||||
|
||||
public function set_admin_key($admin_key) {
|
||||
$this->admin_key = $admin_key;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// User Management
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
private function _create_or_refresh_access_token($params) {
|
||||
return $this->request(User_Management_Path::$TOKEN, $params, 'POST');
|
||||
}
|
||||
|
||||
public function create_access_token($authorization_code){
|
||||
$this->AUTHORIZATION_CODE = $authorization_code;
|
||||
$params = [
|
||||
'grant_type'=>'authorization_code',
|
||||
'client_id'=>$this->REST_KEY,
|
||||
'redirect_uri'=>$this->REDIRECT_URI,
|
||||
'code'=>$this->AUTHORIZATION_CODE
|
||||
];
|
||||
$result = $this->_create_or_refresh_access_token($params);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function refresh_access_token($refresh_token){
|
||||
$params = [
|
||||
'grant_type'=>'refresh_token',
|
||||
'client_id'=>$this->REST_KEY,
|
||||
'redirect_uri'=>$this->REDIRECT_URI,
|
||||
'code'=>$refresh_token
|
||||
];
|
||||
$result = $this->_create_or_refresh_access_token($params);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function signup() {
|
||||
return $this->request(User_Management_Path::$SIGNUP);
|
||||
}
|
||||
|
||||
public function unlink() {
|
||||
return $this->request(User_Management_Path::$UNLINK);
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
return $this->request(User_Management_Path::$UNLINK);
|
||||
}
|
||||
|
||||
public function me() {
|
||||
return $this->request(User_Management_Path::$ME);
|
||||
}
|
||||
|
||||
public function meWithEmail(){
|
||||
$params = [
|
||||
'propertyKeys'=>'["id","kaacount_email","kaccount_email_verified"]'
|
||||
];
|
||||
return $this->request(User_Management_Path::$ME);
|
||||
}
|
||||
|
||||
public function update_profile($params) {
|
||||
return $this->request(User_Management_Path::$UPDATE_PROFILE, $params, 'POST');
|
||||
}
|
||||
|
||||
public function user_ids() {
|
||||
return $this->request(User_Management_Path::$USER_IDS);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Kakao Story
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
public function isstoryuser() {
|
||||
return $this->request(Story_Path::$ISSTORYUSER);
|
||||
}
|
||||
|
||||
public function story_profile() {
|
||||
return $this->request(Story_Path::$PROFILE);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Kakao Talk
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
public function talk_profile() {
|
||||
return $this->request(Talk_Path::$TALK_PROFILE);
|
||||
}
|
||||
|
||||
public function talk_to_me_default($req){
|
||||
|
||||
$params = [
|
||||
'template_object' => json_encode($req)
|
||||
];
|
||||
return $this->request(Talk_Path::$TALK_TO_ME_DEFAULT, $params, 'POST');
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// API Test
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
private $REST_KEY = KakaoKey::REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다.
|
||||
private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
|
||||
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
|
||||
private $REFRESH_TOKEN = '';
|
||||
|
||||
/*
|
||||
* 유저 관리 API 테스트
|
||||
*/
|
||||
public function test_user_management_api()
|
||||
{
|
||||
|
||||
/*
|
||||
// authorization code로 access token 얻기
|
||||
$params = array();
|
||||
$params['grant_type'] = 'authorization_code';
|
||||
$params['client_id'] = $this->REST_KEY;
|
||||
$params['redirect_uri'] = $this->REDIRECT_URI;
|
||||
$params['code'] = $this->AUTHORIZATION_CODE;
|
||||
$this->create_or_refresh_access_token($params);
|
||||
*/
|
||||
|
||||
/*
|
||||
// refresh token으로 access token 얻기
|
||||
$params = array();
|
||||
$params['grant_type'] = 'refresh_token';
|
||||
$params['client_id'] = $this->REST_KEY;
|
||||
$params['refresh_token'] = $this->REFRESH_TOKEN;
|
||||
echo $this->create_or_refresh_access_token($params);
|
||||
*/
|
||||
|
||||
/*
|
||||
// 앱 사용자 정보 요청 (signup 후에 사용 가능)
|
||||
echo $this->me();
|
||||
*/
|
||||
|
||||
/*
|
||||
// 앱 연결
|
||||
echo $this->signup();
|
||||
*/
|
||||
|
||||
/*
|
||||
// 앱 탈퇴 (unlink를 하면 access/refresh token이 삭제됩니다.)
|
||||
//echo $this->unlink();
|
||||
*/
|
||||
|
||||
/*
|
||||
// 앱 로그아웃 (로그아웃을 하면 access/refresh token이 삭제됩니다.)
|
||||
echo $this->logout();
|
||||
*/
|
||||
|
||||
/*
|
||||
// 앱 사용자 정보 업데이트
|
||||
$params = array();
|
||||
$params['properties'] = '{"nickname":"test11"}';
|
||||
echo $this->updateProfile($params);
|
||||
echo $this->me();
|
||||
*/
|
||||
|
||||
/*
|
||||
// 앱 사용자 리스트 요청 (파라미터)
|
||||
// 테스트하시려면 admin key 지정해야 합니다.
|
||||
echo $this->user_ids();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 카카오스토리 API 테스트
|
||||
*/
|
||||
public function test_story_api()
|
||||
{
|
||||
|
||||
/*
|
||||
// 스토리 프로파일 요청
|
||||
echo $this->story_profile();
|
||||
*/
|
||||
|
||||
/*
|
||||
// 스토리 유저인지 확인
|
||||
//echo $this->isstoryuser();
|
||||
*/
|
||||
|
||||
/*
|
||||
$story_common_params = array();
|
||||
|
||||
// 글 포스팅이면 필수
|
||||
$story_common_params['content'] = '더 나은 세상을 꿈꾸고 그것을 현실로 만드는 이를 위하여 카카오에서 앱 개발 플랫폼 서비스를 시작합니다.';
|
||||
|
||||
// 스토리 포스팅 공통 파라미터. 필요한 것만 선택하여 사용.
|
||||
//$story_common_params['permission'] = 'A'; // A : 전체공개, F: 친구에게만 공개, M: 나만보기
|
||||
//$story_common_params['enable_share'] = 'true'; // 공개 기능 허용 여부
|
||||
//$story_common_params['android_exec_param'] = 'cafe_id=1234'; // 앱 이동시 추가 파라미터
|
||||
//$story_common_params['ios_exec_param'] = 'cafe_id=1234';
|
||||
//$story_common_params['android_market_param'] = 'cafe_id=1234';
|
||||
//$story_common_params['ios_market_param'] = 'cafe_id=1234';
|
||||
|
||||
//$res = $helper->post_note($story_common_params);
|
||||
//echo $res;
|
||||
//$obj = json_decode($res);
|
||||
//this->delete_mystory($obj->id); // 포스팅된 스토리 삭제.
|
||||
*/
|
||||
|
||||
/*
|
||||
// 스토리 포스팅 공통 파라미터. 필요한 것만 선택하여 사용.
|
||||
$story_common_params = array();
|
||||
//$story_common_params['content'] = '더 나은 세상을 꿈꾸고 그것을 현실로 만드는 이를 위하여 카카오에서 앱 개발 플랫폼 서비스를 시작합니다.';
|
||||
//$story_common_params['permission'] = 'A'; // A : 전체공개, F: 친구에게만 공개, M: 나만보기
|
||||
//$story_common_params['enable_share'] = 'true'; // 공개 기능 허용 여부
|
||||
//$story_common_params['android_exec_param'] = 'cafe_id=1234'; // 앱 이동시 추가 파라미터
|
||||
//$story_common_params['ios_exec_param'] = 'cafe_id=1234';
|
||||
//$story_common_params['android_market_param'] = 'cafe_id=1234';
|
||||
//$story_common_params['ios_market_param'] = 'cafe_id=1234';
|
||||
|
||||
// 링크 포스팅
|
||||
$test_site_url = 'https://developers.kakao.com';
|
||||
$res = $this->post_link($test_site_url, $story_common_params);
|
||||
echo $res;
|
||||
$obj = json_decode($res);
|
||||
//$this->delete_mystory($obj->id); // 포스팅된 테스트 스토리 삭제.
|
||||
*/
|
||||
|
||||
/*
|
||||
// 스토리 포스팅 공통 파라미터. 필요한 것만 선택하여 사용.
|
||||
$story_common_params = array();
|
||||
$story_common_params['content'] = '더 나은 세상을 꿈꾸고 그것을 현실로 만드는 이를 위하여 카카오에서 앱 개발 플랫폼 서비스를 시작합니다.';
|
||||
//$story_common_params['permission'] = 'A'; // A : 전체공개, F: 친구에게만 공개, M: 나만보기
|
||||
//$story_common_params['enable_share'] = 'true'; // 공개 기능 허용 여부
|
||||
//$story_common_params['android_exec_param'] = 'cafe_id=1234'; // 앱 이동시 추가 파라미터
|
||||
//$story_common_params['ios_exec_param'] = 'cafe_id=1234';
|
||||
//$story_common_params['android_market_param'] = 'cafe_id=1234';
|
||||
//$story_common_params['ios_market_param'] = 'cafe_id=1234';
|
||||
|
||||
// 사진 포스팅 (최대 10개까지 가능)
|
||||
$file_params = array(
|
||||
'file[0]'=>"@/Users/tom/sample1.png",
|
||||
'file[1]'=>"@/Users/tom/sample2.png"
|
||||
);
|
||||
|
||||
// PHP 5 >= 5.5.0
|
||||
$file_params = array(
|
||||
'file[0]'=>new CurlFile('/Users/tom/sample1.png','image/png','sample1'),
|
||||
'file[1]'=>new CurlFile('/Users/tom/sample2.png','image/png','sample2')
|
||||
);
|
||||
|
||||
$res = $this->post_photo($file_params, $story_common_params);
|
||||
echo $res;
|
||||
$obj = json_decode($res);
|
||||
$this->delete_mystory($obj->id); // 포스팅된 테스트 스토리 삭제.
|
||||
*/
|
||||
|
||||
/*
|
||||
$test_mystory_id = '_cDLHO.GBNzGysmIZ9';
|
||||
|
||||
// 복수개의 내스토리 정보 요청
|
||||
echo $this->get_mystories();
|
||||
|
||||
// 복수개의 내스토리 정보 요청 (특정 아이디 부터)
|
||||
echo $this->get_mystories($test_mystory_id);
|
||||
|
||||
// 내스토리 정보 요청
|
||||
echo $this->get_mystory($test_mystory_id); // 포스팅된 테스트 스토리 삭제.
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 카카오톡 API 테스트
|
||||
*/
|
||||
public function test_talk_api()
|
||||
{
|
||||
// 카카오톡 프로필 요청
|
||||
//echo $this->talk_profile();
|
||||
}
|
||||
|
||||
/*
|
||||
* 푸시 알림 API 테스트
|
||||
*/
|
||||
public function test_push_notification_api()
|
||||
{
|
||||
// 파라미터 설명
|
||||
// @param uuid 사용자의 고유 ID. 1~(2^63 -1), 숫자만 가능
|
||||
// @param push_type gcm or apns
|
||||
// @param push_token apns(64자) or GCM으로부터 발급받은 push token
|
||||
// @param uuids 기기의 고유한 ID 리스트 (최대 100개까지 가능)
|
||||
|
||||
// 푸시 알림 관련 API를 테스트하시려면 admin key 지정해야 합니다.
|
||||
|
||||
/*
|
||||
// 푸시 등록
|
||||
$params = array(
|
||||
"uuid" => "10000",
|
||||
"push_type" => "gcm",
|
||||
"push_token" => "xxxxxxxxxx",
|
||||
"device_id" => ""
|
||||
);
|
||||
$this->register_push($params);
|
||||
*/
|
||||
|
||||
/*
|
||||
// 푸시 토큰 조회
|
||||
$param = array("uuid" => "10000");
|
||||
$this->get_push_tokens($param);
|
||||
*/
|
||||
|
||||
/*
|
||||
// 푸시 해제
|
||||
$params = array(
|
||||
"uuid" => "10000",
|
||||
"push_type" => "gcm",
|
||||
"push_token" => "xxxxxxxxxx"
|
||||
);
|
||||
$this->deregister_push($params);
|
||||
*/
|
||||
|
||||
/*
|
||||
// 푸시 보내기
|
||||
$param = array("uuids" => "[\"1\",\"2\", \"3\"]");
|
||||
$this->sendPush($param);
|
||||
*/
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
require_once('_common.php');
|
||||
require_once(__dir__.'/../d_setting/conf.php');
|
||||
require_once(__dir__.'/../f_func/func.php');
|
||||
require_once(ROOT.'/f_func/class._Time.php');
|
||||
|
||||
function checkUsernameDup($username){
|
||||
if(!$username){
|
||||
return '계정명을 입력해주세요';
|
||||
}
|
||||
|
||||
$length = strlen($username);
|
||||
if($length < 4 || $length > 64){
|
||||
return '적절하지 않은 길이입니다.';
|
||||
}
|
||||
|
||||
$cnt = getRootDB()->queryFirstField('SELECT count(no) FROM member WHERE `id` = %s LIMIT 1', $username);
|
||||
if($cnt != 0){
|
||||
return '이미 사용중인 계정명입니다';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkNicknameDup($nickname){
|
||||
if(!$nickname){
|
||||
return '닉네임을 입력해주세요';
|
||||
}
|
||||
|
||||
$length = strlen($nickname);
|
||||
if($length < 1 || $length > 6){
|
||||
return '적절하지 않은 길이입니다.';
|
||||
}
|
||||
|
||||
$cnt = getRootDB()->queryFirstField('SELECT count(no) FROM member WHERE `name` = %s LIMIT 1', $nickname);
|
||||
if($cnt != 0){
|
||||
return '이미 사용중인 닉네임입니다';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function checkEmailDup($email){
|
||||
if(!$email){
|
||||
return '이메일을 입력해주세요';
|
||||
}
|
||||
|
||||
$length = strlen($email);
|
||||
if($length < 1 || $length > 64){
|
||||
return '적절하지 않은 길이입니다.';
|
||||
}
|
||||
|
||||
$userInfo = getRootDB()->queryFirstField('SELECT `no`, `delete_after` FROM member WHERE `email` = %s LIMIT 1', $email);
|
||||
if($userInfo){
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
if (!$userInfo['delete_after']) {
|
||||
return '이미 사용중인 이메일입니다. 관리자에게 문의해주세요.';
|
||||
}
|
||||
|
||||
if($userInfo['delete_after'] >= $userInfo){
|
||||
return "삭제 요청된 계정입니다.[{$userInfo['delete_after']}]";
|
||||
}
|
||||
|
||||
//$userInfo['delete_after'] < $userInfo
|
||||
getRootDB()->delete('member', 'no=%i', $userInfo['no']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require('kakao.php');
|
||||
use utilphp\util as util;
|
||||
|
||||
$auth_code = util::array_get($_GET['code']);
|
||||
if(!$auth_code){
|
||||
|
||||
header('Location:oauth_fail.html');
|
||||
}
|
||||
|
||||
|
||||
//TODO: /oauth/token
|
||||
|
||||
$restAPI = new Kakao_REST_API_Helper();
|
||||
$result = $restAPI->create_access_token($auth_code);
|
||||
|
||||
//항상 scope = account_email profile임
|
||||
//항상 token_type = bearer임
|
||||
|
||||
//토큰을 받아옴.
|
||||
|
||||
|
||||
|
||||
if(util::array_get($result['expires_in'], -1) > 0){
|
||||
session_start();
|
||||
$restAPI->set_access_token($result['access_token']);
|
||||
$now = _Time::DatetimeNow();
|
||||
$_SESSION['access_token'] = $result['access_token'];
|
||||
$_SESSION['expires'] = _Time::DatetimeFromSecond($now, $result['expires_in']);
|
||||
$_SESSION['refresh_token'] = util::array_get($result['refresh_token']);
|
||||
$_SESSION['refresh_token_expires'] = _Time::DatetimeFromSecond($now, $result['refresh_token_expires_in']);
|
||||
}
|
||||
else{
|
||||
die('알 수 없는 에러:'.$me['msg']);
|
||||
}
|
||||
|
||||
$_SESSION['tmpx'] = json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
|
||||
//echo "<br>\n";
|
||||
$me = $restAPI->meWithEmail();
|
||||
|
||||
$oauth_mode = 'login';
|
||||
|
||||
$me['code'] = util::array_get($me['code'], 0);
|
||||
if($me['code']< 0){
|
||||
switch($me['msg']){
|
||||
case 'NotRegisteredUserException':
|
||||
$oauth_mode = 'join';
|
||||
break;
|
||||
default:
|
||||
$oauth_mode = 'error';
|
||||
}
|
||||
}
|
||||
else{
|
||||
$_SESSION['kaccount_email'] = $me['kaccount_email'];
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<script>
|
||||
opener.location.href="javascript:postOAuthResult('<?=$oauth_mode?>');";
|
||||
window.close();
|
||||
</script>
|
||||
</head>
|
||||
</html>
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">>
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>OAuth 로그인 실패</title>
|
||||
</head>
|
||||
<body>
|
||||
로그인에 실패하였습니다.
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
YES
|
||||
@@ -0,0 +1,5 @@
|
||||
<p>개인정보로써 <strong>이메일, 계정명, 닉네임</strong>을 수집하며, 유저 로그인 및 다중 접속 탐지를 위해 사용함. 이메일은 필요에 따라 공지사항 등 본 사이트의 정보를 전파하는데 사용될 수 있음. 위의 언급한 내용 이외의 용도로 개인정보를 사용하지 않음.</p>
|
||||
<p>수집된 개인정보는 탈퇴 후 1개월간 보관됨.</p>
|
||||
<p>게임 시스템을 오용하거나, 서버에 해킹시도하거나, 분란을 야기하는 경우 경고 처리 후 차단될 수 있으며, 경중에 따라 경고 처리 없이 바로 차단될 수 있음.</p>
|
||||
<p>개인정보 관리자 : Hide_D</p>
|
||||
<p>문의는 hided62@gmail.com 으로.</p>
|
||||
Reference in New Issue
Block a user