www_archline_hu/deployed/socialloginandsocialshare/plugins/system/socialloginandsocialshare/googlelogin.php
LÁZÁR Imre AI Agent 0233f2db81 feat(deployed): add Social Login and Social Share 4.0 (no-source, vetted live)
Social Login and Social Share (LoginRadius); repo deleted after CIAM pivot -> deployed files.

Signed-off-by: LÁZÁR Imre <imre@illusion.hu>
Assisted-by: claude-code@claude-opus-4-8
2026-07-16 11:24:47 +02:00

70 lines
2.8 KiB
PHP

<?php
/*------------------------------------------------------------------------
# mod_SocialLoginandSocialShare
# ------------------------------------------------------------------------
# author LoginRadius inc.
# copyright Copyright (C) 2013 loginradius.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.loginradius.com
# Technical Support: Forum - http://community.loginradius.com/
-------------------------------------------------------------------------*/
// no direct access
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
/**
* SocialLogin Google Login class.
*/
class googlelogin {
public static function acsses_token($code, $lr_settings){
$redirect = JURI::root();
$scope = urlencode('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email');
$params = array(
'client_id=' . $lr_settings['gapikey'],
'client_secret=' . $lr_settings['gapisecret'],
'grant_type=authorization_code',
'code=' . $code,
'redirect_uri=' . ($redirect.'?provider=google'),
'scope=' . $scope
);
$params = implode('&', $params);
$url = 'https://accounts.google.com/o/oauth2/token';
$request = json_decode(plgSystemSocialLoginTools::open_http($url, true, $params));
if(empty($request)){
echo 'Error - empty user data';
exit;
}
$url = 'https://www.googleapis.com/oauth2/v1/userinfo?access_token='.$request->access_token;
$request = json_decode(plgSystemSocialLoginTools::open_http($url));
if(empty($request)){
echo 'Error - empty user data';
exit;
}
else if(!empty($request->error)){
echo 'Error - '. $request->error;
exit;
}
return $request;
}
/*
* Function getting user data from loginradius.
*/
public static function userprofile_data($userprofile) {
$lrdata['id'] = (!empty($userprofile->id) ? $userprofile->id : "");
$lrdata['FullName'] = (!empty($userprofile->name) ? $userprofile->name : "");
$lrdata['ProfileName'] = (!empty( $userprofile->name) ? $userprofile->name : "");
$lrdata['fname'] = (!empty( $userprofile->given_name) ? $userprofile->given_name : "");
$lrdata['lname'] = (!empty($userprofile->family_name) ? $userprofile->family_name : "");
$lrdata['gender'] = (!empty($userprofile->gender) ? $userprofile->gender : '');
$lrdata['Provider'] = 'google';
$lrdata['email'] = (!empty($userprofile->email) ? $userprofile->email : "");
$lrdata['ProfileUrl'] = (!empty($userprofile->link) ? $userprofile->link : '');
$lrdata['dob'] = (!empty($userprofile->birthday) ? $userprofile->birthday : '');
$lrdata['thumbnail'] = '';
return $lrdata;
}
}
?>