충돌수정

This commit is contained in:
thisgun
2020-11-24 11:38:32 +09:00
45 changed files with 359 additions and 648 deletions

View File

@ -30,8 +30,14 @@ define("SAVE_DIR", $data_dir);
define("SAVE_URL", $data_url);
function che_get_user_id() {
@session_start();
return session_id();
global $member;
if(session_id() == '') {
@session_start();
}
$add_str = (isset($member['mb_id']) && $member['mb_id']) ? $member['mb_id'] : '';
return session_id().$add_str;
}
function che_get_file_passname(){

View File

@ -215,14 +215,20 @@ class UploadHandler
substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
}
protected function get_user_id() {
@session_start();
return session_id();
protected function get_user_id($is_add=true) {
global $member;
if(session_id() == '') {
@session_start();
}
$add_str = ($is_add && isset($member['mb_id']) && $member['mb_id']) ? $member['mb_id'] : '';
return session_id().$add_str;
}
protected function get_user_path() {
if ($this->options['user_dirs']) {
return $this->get_user_id().'/';
return $this->get_user_id(false).'/';
}
return '';
}

View File

@ -19,7 +19,7 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
* default permissions
* {@inheritdoc}
*/
public $scope = "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.profile.emails.read https://www.google.com/m8/feeds/";
public $scope = "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.google.com/m8/feeds/";
/**
* {@inheritdoc}
@ -72,35 +72,22 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
// refresh tokens if needed
$this->refreshToken();
// ask google api for user infos
if (strpos($this->scope, '/auth/plus.profile.emails.read') !== false) {
$verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
if (!isset($verified->id) || isset($verified->error))
$verified = new stdClass();
} else {
$verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me/openIdConnect");
if (!isset($verified->sub) || isset($verified->error))
$verified = new stdClass();
}
$response = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
if (!isset($response->id) || isset($response->error)) {
$response = $this->api->api("https://www.googleapis.com/oauth2/v3/userinfo");
if (!isset($response->sub) || isset($response->error)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $response ), 6);
}
$this->user->profile->identifier = (property_exists($verified, 'id')) ? $verified->id : ((property_exists($response, 'id')) ? $response->id : "");
$this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name->givenName : "";
$this->user->profile->lastName = (property_exists($response, 'name')) ? $response->name->familyName : "";
$this->user->profile->displayName = (property_exists($response, 'displayName')) ? $response->displayName : "";
$this->user->profile->photoURL = (property_exists($response, 'image')) ? ((property_exists($response->image, 'url')) ? substr($response->image->url, 0, -2) . "200" : '') : '';
$this->user->profile->profileURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->description = (property_exists($response, 'aboutMe')) ? $response->aboutMe : "";
$this->user->profile->identifier = (property_exists($response, 'sub')) ? $response->sub : "";
$this->user->profile->firstName = (property_exists($response, 'given_name')) ? $response->given_name : "";
$this->user->profile->lastName = (property_exists($response, 'family_name')) ? $response->family_name : "";
$this->user->profile->displayName = (property_exists($response, 'name')) ? $response->name : "";
$this->user->profile->photoURL = (property_exists($response, 'picture')) ? $response->picture : "";
$this->user->profile->profileURL = (property_exists($response, 'profile')) ? $response->profile : "";
$this->user->profile->gender = (property_exists($response, 'gender')) ? $response->gender : "";
$this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : ((property_exists($verified, 'locale')) ? $verified->locale : "");
$this->user->profile->email = (property_exists($response, 'email')) ? $response->email : ((property_exists($verified, 'email')) ? $verified->email : "");
$this->user->profile->emailVerified = (property_exists($verified, 'email')) ? $verified->email : "";
$this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : "";
$this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";
$this->user->profile->emailVerified = (property_exists($response, 'email_verified')) ? ($response->email_verified === true || $response->email_verified === 1 ? $response->email : "") : "";
if (property_exists($response, 'emails')) {
if (count($response->emails) == 1) {
$this->user->profile->email = $response->emails[0]->value;
@ -125,69 +112,6 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
}
}
}
$this->user->profile->phone = (property_exists($response, 'phone')) ? $response->phone : "";
$this->user->profile->country = (property_exists($response, 'country')) ? $response->country : "";
$this->user->profile->region = (property_exists($response, 'region')) ? $response->region : "";
$this->user->profile->zip = (property_exists($response, 'zip')) ? $response->zip : "";
if (property_exists($response, 'placesLived')) {
$this->user->profile->city = "";
$this->user->profile->address = "";
foreach ($response->placesLived as $c) {
if (property_exists($c, 'primary')) {
if ($c->primary == true) {
$this->user->profile->address = $c->value;
$this->user->profile->city = $c->value;
break;
}
} else {
if (property_exists($c, 'value')) {
$this->user->profile->address = $c->value;
$this->user->profile->city = $c->value;
}
}
}
}
// google API returns multiple urls, but a "website" only if it is verified
// see http://support.google.com/plus/answer/1713826?hl=en
if (property_exists($response, 'urls')) {
foreach ($response->urls as $u) {
if (property_exists($u, 'primary') && $u->primary == true)
$this->user->profile->webSiteURL = $u->value;
}
} else {
$this->user->profile->webSiteURL = '';
}
// google API returns age ranges min and/or max as of https://developers.google.com/+/web/api/rest/latest/people#resource
if (property_exists($response, 'ageRange')) {
if (property_exists($response->ageRange, 'min') && property_exists($response->ageRange, 'max')) {
$this->user->profile->age = $response->ageRange->min . ' - ' . $response->ageRange->max;
} else {
if (property_exists($response->ageRange, 'min')) {
$this->user->profile->age = '>= ' . $response->ageRange->min;
} else {
if (property_exists($response->ageRange, 'max')) {
$this->user->profile->age = '<= ' . $response->ageRange->max;
} else {
$this->user->profile->age = '';
}
}
}
} else {
$this->user->profile->age = '';
}
// google API returns birthdays only if a user set 'show in my account'
if (property_exists($response, 'birthday')) {
list($birthday_year, $birthday_month, $birthday_day) = explode('-', $response->birthday);
$this->user->profile->birthDay = (int) $birthday_day;
$this->user->profile->birthMonth = (int) $birthday_month;
$this->user->profile->birthYear = (int) $birthday_year;
} else {
$this->user->profile->birthDay = 0;
$this->user->profile->birthMonth = 0;
$this->user->profile->birthYear = 0;
}
$this->user->profile->sid = get_social_convert_id( $this->user->profile->identifier, $this->providerId );

View File

@ -13,35 +13,35 @@
*/
class Hybrid_Providers_Payco extends Hybrid_Provider_Model_OAuth2 {
private $idNo;
private $idNo;
/**
* {@inheritdoc}
*/
function initialize() {
/**
* {@inheritdoc}
*/
function initialize() {
parent::initialize();
// Provider API end-points
// Provider API end-points
$this->api->api_base_url = 'https://id.payco.com/oauth2.0/';
$this->api->authorize_url = 'https://id.payco.com/oauth2.0/authorize';
$this->api->token_url = 'https://id.payco.com/oauth2.0/token';
$this->api->token_info = 'https://apis3.krp.toastoven.net/payco/friends/getIdNoByFriendsToken.json';
$this->api->profile_url = 'https://apis3.krp.toastoven.net/payco/friends/getMemberProfileByFriendsToken.json';
$this->api->profile_url = 'https://apis-payco.krp.toastoven.net/payco/friends/find_member_v2.json';
if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
}
if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
}
// redirect uri mismatches when authenticating with Payco.
if (isset($this->config['redirect_uri']) && !empty($this->config['redirect_uri'])) {
$this->api->redirect_uri = $this->config['redirect_uri'];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
// redirect uri mismatches when authenticating with Payco.
if (isset($this->config['redirect_uri']) && !empty($this->config['redirect_uri'])) {
$this->api->redirect_uri = $this->config['redirect_uri'];
}
}
/**
* {@inheritdoc}
*/
function loginBegin() {
$token = md5(uniqid(mt_rand(), true));
Hybrid_Auth::storage()->set('payco_auth_token', $token);
@ -59,16 +59,16 @@ class Hybrid_Providers_Payco extends Hybrid_Provider_Model_OAuth2 {
exit;
}
/**
* {@inheritdoc}
*/
function loginFinish() {
}
/**
* {@inheritdoc}
*/
function loginFinish() {
// in case we get error_reason=user_denied&error=access_denied
if (isset($_REQUEST['error']) && $_REQUEST['error'] == "access_denied") {
throw new Exception("Authentication failed! The user denied your request.", 5);
}
// in case we get error_reason=user_denied&error=access_denied
if (isset($_REQUEST['error']) && $_REQUEST['error'] == "access_denied") {
throw new Exception("Authentication failed! The user denied your request.", 5);
}
// try to authenicate user
$code = (array_key_exists('code', $_REQUEST)) ? $_REQUEST['code'] : "";
@ -91,7 +91,7 @@ class Hybrid_Providers_Payco extends Hybrid_Provider_Model_OAuth2 {
$this->setUserConnected();
}
}
function check_valid_access_token(){
@ -121,33 +121,33 @@ class Hybrid_Providers_Payco extends Hybrid_Provider_Model_OAuth2 {
return false;
}
/**
* {@inheritdoc}
*/
function logout() {
parent::logout();
}
/**
* {@inheritdoc}
*/
/**
* {@inheritdoc}
*/
function logout() {
parent::logout();
}
/**
* {@inheritdoc}
*/
/**
* set propper headers
*/
function getUserProfile() {
function getUserProfile() {
$data = null;
// request user profile
try {
// request user profile
try {
if( $this->check_valid_access_token() ){
$params = array(
'body' => array(
'client_id'=>$this->api->client_id,
'access_token'=>$this->api->access_token,
'MemberProfile'=>'idNo,id,name',
'idNo'=>$this->idNo,
'client_id'=>$this->api->client_id,
'access_token'=>$this->api->access_token,
'MemberProfile'=>'idNo,id,name',
'idNo'=>$this->idNo,
),
);
@ -161,52 +161,62 @@ class Hybrid_Providers_Payco extends Hybrid_Provider_Model_OAuth2 {
$response = $this->api->api( $this->api->profile_url, 'POST', $params );
}
} catch (Exception $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e->getMessage()}", 6, $e);
}
} catch (Exception $e) {
throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e->getMessage()}", 6, $e);
}
if( ! is_object($response) || property_exists($response, 'error_code') ){
$this->logout();
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
}
$data = array();
if( is_object($response) ){
$result = json_decode(json_encode($response), true);
$data = $result['memberProfile'];
// 성공이면
if(isset($result['header']) && isset($result['header']['isSuccessful']) && $result['header']['isSuccessful']){
$data = $result['data']['member'];
}
}
// if the provider identifier is not received, we assume the auth has failed
if (!isset($data["id"])) {
// if the provider identifier is not received, we assume the auth has failed
if (!isset($data["idNo"])) {
$this->logout();
throw new Exception("User profile request failed! {$this->providerId} api returned an invalid response: " . Hybrid_Logger::dumpData( $data ), 6);
}
throw new Exception("User profile request failed! {$this->providerId} api returned an invalid response: " . Hybrid_Logger::dumpData( $data ), 6);
}
# store the user profile.
$this->user->profile->identifier = (array_key_exists('idNo', $data)) ? $data['idNo'] : "";
$this->user->profile->username = (array_key_exists('name', $data)) ? $data['name'] : "";
$this->user->profile->displayName = (array_key_exists('name', $data)) ? $data['name'] : "";
# store the user profile.
$this->user->profile->identifier = (array_key_exists('idNo', $data)) ? $data['idNo'] : "";
$this->user->profile->username = (array_key_exists('name', $data)) ? $data['name'] : "";
$this->user->profile->displayName = (array_key_exists('name', $data)) ? $data['name'] : "";
$this->user->profile->age = (array_key_exists('ageGroup', $data)) ? $data['ageGroup'] : "";
$this->user->profile->hp = (array_key_exists('mobile', $data)) ? $data['mobile'] : "";
include_once(G5_LIB_PATH.'/register.lib.php');
$payco_no = substr(base_convert($this->user->profile->identifier, 16, 36), 0, 16);
$email = (array_key_exists('id', $data)) ? $data['id'] : "";
//$email = (array_key_exists('id', $data)) ? $data['id'] : "";
$this->user->profile->gender = (array_key_exists('sexCode', $data)) ? $data['sexCode'] : "";
$email = (array_key_exists('email', $data)) ? $data['email'] : "";
$this->user->profile->email = ! valid_mb_email($email) ? $email : "";
$this->user->profile->emailVerified = ! valid_mb_email($email) ? $email : "";
//$this->user->profile->gender = (array_key_exists('sexCode', $data)) ? $data['sexCode'] : "";
$this->user->profile->gender = (array_key_exists('genderCode', $data)) ? strtolower($data['genderCode']) : "";
$this->user->profile->email = ! valid_mb_email($email) ? $email : "";
$this->user->profile->emailVerified = ! valid_mb_email($email) ? $email : "";
if (array_key_exists('birthdayMMdd', $data)) {
$this->user->profile->birthMonth = substr($data['birthdayMMdd'], 0, 2);
$this->user->profile->birthDay = substr($data['birthdayMMdd'], 2, 4);
}
if (array_key_exists('birthdayMMdd', $data)) {
$this->user->profile->birthMonth = substr($data['birthdayMMdd'], 0, 2);
$this->user->profile->birthDay = substr($data['birthdayMMdd'], 2, 4);
}
$this->user->profile->sid = get_social_convert_id( $this->user->profile->identifier, $this->providerId );
return $this->user->profile;
} //end function getUserProfile
return $this->user->profile;
} //end function getUserProfile
}

View File

@ -2,8 +2,8 @@
/* !
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
* https://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
* (c) 2009-2012, HybridAuth authors | https://hybridauth.sourceforge.net/licenses.html
*/
/**
@ -127,7 +127,7 @@ class Hybrid_Providers_Twitter extends Hybrid_Provider_Model_OAuth1 {
$this->user->profile->description = (property_exists($response, 'description')) ? $response->description : "";
$this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name : "";
$this->user->profile->photoURL = (property_exists($response, 'profile_image_url')) ? (str_replace('_normal', '', $response->profile_image_url)) : "";
$this->user->profile->profileURL = (property_exists($response, 'screen_name')) ? ("http://twitter.com/" . $response->screen_name) : "";
$this->user->profile->profileURL = (property_exists($response, 'screen_name')) ? ("https://twitter.com/" . $response->screen_name) : "";
$this->user->profile->webSiteURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->region = (property_exists($response, 'location')) ? $response->location : "";
if($includeEmail) $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";
@ -174,7 +174,7 @@ class Hybrid_Providers_Twitter extends Hybrid_Provider_Model_OAuth1 {
$uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
$uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
$uc->profileURL = (property_exists($item, 'screen_name')) ? ("http://twitter.com/" . $item->screen_name) : "";
$uc->profileURL = (property_exists($item, 'screen_name')) ? ("https://twitter.com/" . $item->screen_name) : "";
$uc->photoURL = (property_exists($item, 'profile_image_url')) ? $item->profile_image_url : "";
$uc->description = (property_exists($item, 'description')) ? $item->description : "";
@ -254,7 +254,7 @@ class Hybrid_Providers_Twitter extends Hybrid_Provider_Model_OAuth1 {
$ua->user->identifier = (property_exists($item->user, 'id')) ? $item->user->id : "";
$ua->user->displayName = (property_exists($item->user, 'name')) ? $item->user->name : "";
$ua->user->profileURL = (property_exists($item->user, 'screen_name')) ? ("http://twitter.com/" . $item->user->screen_name) : "";
$ua->user->profileURL = (property_exists($item->user, 'screen_name')) ? ("https://twitter.com/" . $item->user->screen_name) : "";
$ua->user->photoURL = (property_exists($item->user, 'profile_image_url')) ? $item->user->profile_image_url : "";
$activities[] = $ua;

View File

@ -44,11 +44,11 @@ function get_social_convert_id($identifier, $service)
return strtolower($service).'_'.hash('adler32', md5($identifier));
}
function get_social_callbackurl($provider, $no_domain=false){
function get_social_callbackurl($provider, $no_domain=false, $no_params=false){
$base_url = G5_SOCIAL_LOGIN_BASE_URL;
if ( $provider === 'twitter' ){
if ( $provider === 'twitter' || ($provider === 'payco' && $no_params) ){
return $base_url;
}
@ -322,7 +322,7 @@ function social_extends_get_keys($provider){
"keys" => array("id" => $config['cf_facebook_appid'], "secret" => $config['cf_facebook_secret']),
"display" => "popup",
"redirect_uri" => get_social_callbackurl('facebook'),
"scope" => array('email'), // optional
"scope" => 'email', // optional
"trustForwarded" => false
);
@ -332,9 +332,12 @@ function social_extends_get_keys($provider){
"keys" => array("id" => $config['cf_google_clientid'],
"secret" => $config['cf_google_secret']),
"redirect_uri" => get_social_callbackurl('google'),
"scope" => "https://www.googleapis.com/auth/userinfo.profile "."https://www.googleapis.com/auth/userinfo.email",
/*
"scope" => "https://www.googleapis.com/auth/plus.login ". // optional
"https://www.googleapis.com/auth/plus.me ". // optional
"https://www.googleapis.com/auth/plus.profile.emails.read", // optional
*/
//"access_type" => "offline", // optional
//"approval_prompt" => "force", // optional
);