feat(pkg): add OneAll Social Login 5.5.0 (pristine upstream)
Pristine OneAll 5.5.0 manifest-mapped from github.com/oneall/social-login-joomla @5.5.0 via lib/jmap.py to deployed layout. The next commit reconciles to the live bytes; the diff is the full delta vs upstream (line-endings + install files + Cadline CRM modification). Signed-off-by: LÁZÁR Imre <imre@illusion.hu> Assisted-by: claude-code@claude-opus-4-8
This commit is contained in:
parent
a9eeddbc3b
commit
a32ef4a815
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Supported Providers
|
||||
*/
|
||||
$social_login_providers = array(
|
||||
'amazon' => array(
|
||||
'name' => 'Amazon'
|
||||
),
|
||||
'battlenet' => array(
|
||||
'name' => 'Battle.net'
|
||||
),
|
||||
'blogger' => array(
|
||||
'name' => 'Blogger'
|
||||
),
|
||||
'discord' => array(
|
||||
'name' => 'Discord'
|
||||
),
|
||||
'disqus' => array(
|
||||
'name' => 'Disqus'
|
||||
),
|
||||
'draugiem' => array(
|
||||
'name' => 'Draugiem'
|
||||
),
|
||||
'dribbble' => array(
|
||||
'name' => 'Dribbble'
|
||||
),
|
||||
'facebook' => array(
|
||||
'name' => 'Facebook'
|
||||
),
|
||||
'foursquare' => array(
|
||||
'name' => 'Foursquare'
|
||||
),
|
||||
'github' => array(
|
||||
'name' => 'Github.com'
|
||||
),
|
||||
'google' => array(
|
||||
'name' => 'Google'
|
||||
),
|
||||
'instagram' => array(
|
||||
'name' => 'Instagram'
|
||||
),
|
||||
'line' => array(
|
||||
'name' => 'Line'
|
||||
),
|
||||
'linkedin' => array(
|
||||
'name' => 'LinkedIn'
|
||||
),
|
||||
'livejournal' => array(
|
||||
'name' => 'LiveJournal'
|
||||
),
|
||||
'mailru' => array(
|
||||
'name' => 'Mail.ru'
|
||||
),
|
||||
'meetup' => array(
|
||||
'name' => 'Meetup'
|
||||
),
|
||||
'mixer' => array(
|
||||
'name' => 'Mixer'
|
||||
),
|
||||
'odnoklassniki' => array(
|
||||
'name' => 'Odnoklassniki'
|
||||
),
|
||||
'openid' => array(
|
||||
'name' => 'OpenID'
|
||||
),
|
||||
'paypal' => array(
|
||||
'name' => 'PayPal'
|
||||
),
|
||||
'pinterest' => array(
|
||||
'name' => 'Pinterest'
|
||||
),
|
||||
'pixelpin' => array(
|
||||
'name' => 'PixelPin'
|
||||
),
|
||||
'reddit' => array(
|
||||
'name' => 'Reddit'
|
||||
),
|
||||
'skyrock' => array(
|
||||
'name' => 'Skyrock.com'
|
||||
),
|
||||
'soundcloud' => array(
|
||||
'name' => 'SoundCloud'
|
||||
),
|
||||
'stackexchange' => array(
|
||||
'name' => 'StackExchange'
|
||||
),
|
||||
'steam' => array(
|
||||
'name' => 'Steam'
|
||||
),
|
||||
'tumblr' => array(
|
||||
'name' => 'Tumblr'
|
||||
),
|
||||
'twitch' => array(
|
||||
'name' => 'Twitch.tv'
|
||||
),
|
||||
'twitter' => array(
|
||||
'name' => 'Twitter'
|
||||
),
|
||||
'vimeo' => array(
|
||||
'name' => 'Vimeo'
|
||||
),
|
||||
'vkontakte' => array(
|
||||
'name' => 'VKontakte'
|
||||
),
|
||||
'weibo' => array(
|
||||
'name' => 'Weibo'
|
||||
),
|
||||
'windowslive' => array(
|
||||
'name' => 'Windows Live'
|
||||
),
|
||||
'wordpress' => array(
|
||||
'name' => 'WordPress.com'
|
||||
),
|
||||
'xing' => array(
|
||||
'name' => 'Xing'
|
||||
),
|
||||
'yahoo' => array(
|
||||
'name' => 'Yahoo'
|
||||
),
|
||||
'youtube' => array(
|
||||
'name' => 'YouTube'
|
||||
)
|
||||
);
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,343 @@
|
||||
.oa_social_login_admin h4 {
|
||||
font-size: 18px;
|
||||
line-height: 16px;
|
||||
margin-top: 30px !important;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.oa_social_login_admin .error_message {
|
||||
color: red;
|
||||
background: url("../img/status_error.png") no-repeat scroll 0 50% #F6F6F6;
|
||||
padding-left: 25px;
|
||||
font-weight: bold;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.oa_social_login_admin .success_message {
|
||||
color: green;
|
||||
background: url("../img/status_ok.png") no-repeat scroll 0 50% #F6F6F6;
|
||||
padding-left: 25px;
|
||||
font-weight: bold;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.oa_social_login_admin .working_message {
|
||||
color: blue;
|
||||
background: url("../img/status_loading.gif") no-repeat scroll 0 50% #F6F6F6;
|
||||
padding-left: 25px;
|
||||
font-weight: bold;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider {
|
||||
background-image: url("../img/sprite_35_35.png");
|
||||
text-indent: -9999px;
|
||||
height: 35px;
|
||||
width: 35px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.social_login_form {
|
||||
width: 800px;
|
||||
padding: 0px;
|
||||
background-color: #fff;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.social_login_form a {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.social_login_form a:hover {
|
||||
text-decoration: none !important;;
|
||||
}
|
||||
|
||||
.social_login_form legend {
|
||||
margin: 0;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.social_login_form input[type="text"] {
|
||||
display: block;
|
||||
width: 97%;
|
||||
}
|
||||
|
||||
.social_login_form input[type="radio"] {
|
||||
float: left;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row {
|
||||
padding: 5px 10px;
|
||||
font-size: 12px;
|
||||
clear: both;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_provider {
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_provider .provider_icon {
|
||||
float: left;
|
||||
clear: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_provider .provider_check {
|
||||
float: left;
|
||||
clear: none;
|
||||
margin: 12px;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_provider .provider_name {
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
line-height: 40px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_odd {
|
||||
background-color: #ddd;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_even {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_button {
|
||||
background-color: #F6F6F6;
|
||||
border-top: 1px dotted #ddd;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_button_link {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.social_login_form .social_login_form_row_description {
|
||||
padding: 5px 0 10px 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.social_login_form_info {
|
||||
background-color: #FFFFE0;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.social_login_form_info .social_login_form_row {
|
||||
padding: 0 10px 10px !important;
|
||||
}
|
||||
|
||||
.social_login_form_welcome {
|
||||
background-color: #E1EDFF;
|
||||
border: 1px solid #CACFF2;
|
||||
}
|
||||
|
||||
.social_login_form_saved {
|
||||
background-color: #DFF0D8;
|
||||
border: 1px solid #D6E9C6;
|
||||
color: #468847;
|
||||
}
|
||||
|
||||
.social_login_form_saved .social_login_form_row_title {
|
||||
margin: 10px 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.social_login_form_welcome .social_login_form_row {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.social_login_form_welcome .social_login_form_row_button {
|
||||
padding-bottom: 0 !important;
|
||||
background-color: #E1EDFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Buttons */
|
||||
.oa_social_login_provider_vimeo {
|
||||
background-position: -2px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_blogger {
|
||||
background-position: -39px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_facebook {
|
||||
background-position: -76px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_foursquare {
|
||||
background-position: -113px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_google {
|
||||
background-position: -150px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_reddit {
|
||||
background-position: -187px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_linkedin {
|
||||
background-position: -224px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_windowslive {
|
||||
background-position: -261px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_livejournal {
|
||||
background-position: -298px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_myspace {
|
||||
background-position: -372px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_openid {
|
||||
background-position: -409px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_draugiem {
|
||||
background-position: -446px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_twitter {
|
||||
background-position: -520px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_vkontakte {
|
||||
background-position: -631px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_wordpress {
|
||||
background-position: -668px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_yahoo {
|
||||
background-position: -705px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_paypal {
|
||||
background-position: -742px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_stackexchange {
|
||||
background-position: -779px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_steam {
|
||||
background-position: -816px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_mailru {
|
||||
background-position: -853px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_skyrock {
|
||||
background-position: -890px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_github {
|
||||
background-position: -927px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_disqus {
|
||||
background-position: -964px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_youtube {
|
||||
background-position: -1001px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_odnoklassniki {
|
||||
background-position: -1038px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_deviantart {
|
||||
background-position: -1075px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_twitch {
|
||||
background-position: -1112px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_amazon {
|
||||
background-position: -1149px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_instagram {
|
||||
background-position: -1186px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_battlenet {
|
||||
background-position: -1223px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_dribbble {
|
||||
background-position: -1260px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_pinterest {
|
||||
background-position: -1297px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_pixelpin {
|
||||
background-position: -1334px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_storage {
|
||||
background-position: -1371px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_meetup {
|
||||
background-position: -1408px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_line {
|
||||
background-position: -1445px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_soundcloud {
|
||||
background-position: -1482px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_discord {
|
||||
background-position: -1519px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_weibo {
|
||||
background-position: -1556px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_tumblr {
|
||||
background-position: -1593px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_xing {
|
||||
background-position: -372px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_mixer {
|
||||
background-position: -1667px -1px;
|
||||
}
|
||||
|
||||
.oa_social_login_provider_google {
|
||||
background-position: -1704px -1px;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 655 B |
Binary file not shown.
|
After Width: | Height: | Size: 673 B |
Binary file not shown.
|
After Width: | Height: | Size: 781 B |
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
4
packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/js/jquery.js
vendored
Executable file
4
packages/oneallsociallogin/administrator/components/com_oneallsociallogin/assets/js/jquery.js
vendored
Executable file
File diff suppressed because one or more lines are too long
@ -0,0 +1,147 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
/* Autodetect API Connection Handler */
|
||||
$('#oa_social_login_autodetect_api_connection_handler').click(function(){
|
||||
var message_string;
|
||||
var message_container;
|
||||
var is_success;
|
||||
|
||||
var data = {'action' : 'autodetect_api_connection_handler'};
|
||||
var ajaxurl = 'index.php?option=com_oneallsociallogin&task=autodetect_api_connection_handler';
|
||||
|
||||
|
||||
message_container = jQuery('#oa_social_login_api_connection_handler_result');
|
||||
message_container.removeClass('success_message error_message').addClass('working_message');
|
||||
message_container.html('Contacting API - please wait ...');
|
||||
|
||||
jQuery.post(ajaxurl,data, function(response) {
|
||||
|
||||
/* Radio Boxes */
|
||||
var radio_curl = jQuery("#oa_social_login_api_connection_handler_curl");
|
||||
var radio_fsockopen = jQuery("#oa_social_login_api_connection_handler_fsockopen");
|
||||
var radio_443 = jQuery("#oa_social_login_api_connection_port_443");
|
||||
var radio_80 = jQuery("#oa_social_login_api_connection_port_80");
|
||||
|
||||
radio_curl.removeAttr("checked");
|
||||
radio_fsockopen.removeAttr("checked");
|
||||
radio_443.removeAttr("checked");
|
||||
radio_80.removeAttr("checked");
|
||||
|
||||
|
||||
/* CURL detected */
|
||||
if (response == 'success_autodetect_api_curl_443')
|
||||
{
|
||||
is_success = true;
|
||||
radio_curl.attr("checked", "checked");
|
||||
radio_443.attr("checked", "checked");
|
||||
message_string = 'Autodetected CURL on port 443 - do not forget to save your changes!';
|
||||
}
|
||||
else if (response == 'success_autodetect_api_fsockopen_443')
|
||||
{
|
||||
is_success = true;
|
||||
radio_fsockopen.attr("checked", "checked");
|
||||
radio_443.attr("checked", "checked");
|
||||
message_string = 'Autodetected FSOCKOPEN on port 443 - do not forget to save your changes!';
|
||||
}
|
||||
else if (response == 'success_autodetect_api_curl_80')
|
||||
{
|
||||
is_success = true;
|
||||
radio_curl.attr("checked", "checked");
|
||||
radio_80.attr("checked", "checked");
|
||||
message_string = 'Autodetected CURL on port 80 - do not forget to save your changes!';
|
||||
}
|
||||
else if (response == 'success_autodetect_api_fsockopen_80')
|
||||
{
|
||||
is_success = true;
|
||||
radio_fsockopen.attr("checked", "checked");
|
||||
radio_80.attr("checked", "checked");
|
||||
message_string = 'Autodetected FSOCKOPEN on port 80 - do not forget to save your changes!';
|
||||
}
|
||||
/* No handler detected */
|
||||
else
|
||||
{
|
||||
is_success = false;
|
||||
radio_curl.attr("checked", "checked");
|
||||
message_string = 'Autodetection Error - our <a href="http://docs.oneall.com/plugins/guide/social-login-joomla/" target="_blank">documentation</a> might help you fix this issue.';
|
||||
}
|
||||
|
||||
message_container.removeClass('working_message');
|
||||
message_container.html(message_string);
|
||||
|
||||
if (is_success){
|
||||
message_container.addClass('success_message');
|
||||
} else {
|
||||
message_container.addClass('error_message');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
/* Test API Settings */
|
||||
$('#oa_social_login_test_api_settings').click(function() {
|
||||
|
||||
var message_string;
|
||||
var message_container;
|
||||
var is_success;
|
||||
|
||||
var radio_curl_val = jQuery("#oa_social_login_api_connection_handler_curl:checked").val();
|
||||
var radio_fsockopen_val = jQuery("#oa_social_login_api_connection_handler_fsockopen:checked").val();
|
||||
var radio_use_port_443 = jQuery("#oa_social_login_api_connection_port_443:checked").val();
|
||||
var radio_use_port_80 = jQuery("#oa_social_login_api_connection_port_80:checked").val();
|
||||
|
||||
var subdomain = jQuery('#settings_api_subdomain').val();
|
||||
var key = jQuery('#settings_api_key').val();
|
||||
var secret = jQuery('#settings_api_secret').val();
|
||||
var handler = (radio_fsockopen_val == 'fsockopen' ? 'fsockopen' : 'curl');
|
||||
var port = (radio_use_port_80 == 1 ? 80 : 443);
|
||||
|
||||
var data = {
|
||||
'action' : 'check_api_settings',
|
||||
'api_subdomain' : subdomain,
|
||||
'api_key' : key,
|
||||
'api_secret' : secret,
|
||||
'api_connection_port': port,
|
||||
'api_connection_handler' : handler
|
||||
};
|
||||
|
||||
var ajaxurl = 'index.php?option=com_oneallsociallogin&task=check_api_settings';
|
||||
|
||||
message_container = jQuery('#oa_social_login_api_test_result');
|
||||
message_container.removeClass('success_message error_message').addClass('working_message');
|
||||
message_container.html('Contacting API - please wait ...');
|
||||
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
is_success = false;
|
||||
|
||||
if (response == 'error_selected_handler_faulty') {
|
||||
message_string = 'The API Connection cannot be made, try using the API Connection autodetection';
|
||||
} else if (response == 'error_not_all_fields_filled_out') {
|
||||
message_string = 'Please fill out each of the fields above'
|
||||
} else if (response == 'error_subdomain_wrong') {
|
||||
message_string = 'The subdomain does not exist. Have you filled it out correctly?'
|
||||
} else if (response == 'error_subdomain_wrong_syntax') {
|
||||
message_string = 'The subdomain has a wrong syntax!'
|
||||
} else if (response == 'error_communication') {
|
||||
message_string = 'Could not contact API. Try using another connection handler'
|
||||
} else if (response == 'error_authentication_credentials_wrong') {
|
||||
message_string = 'The API credentials are wrong';
|
||||
} else if (response == 'success') {
|
||||
is_success = true;
|
||||
message_string = 'The settings are correct - do not forget to save your changes!';
|
||||
} else {
|
||||
message_string = 'An unknow error occured! The settings could not be verified.';
|
||||
}
|
||||
|
||||
message_container.removeClass('working_message');
|
||||
message_container.html(message_string);
|
||||
|
||||
if (is_success){
|
||||
message_container.addClass('success_message');
|
||||
} else {
|
||||
message_container.addClass('error_message');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,399 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
jimport ('joomla.application.component.controller');
|
||||
|
||||
/**
|
||||
* General Controller of OneAllSocialLogin component
|
||||
*/
|
||||
class OneAllSocialLoginController extends JControllerLegacy
|
||||
{
|
||||
|
||||
/**
|
||||
* Display task
|
||||
*/
|
||||
public function display ($cachable = false, $urlparams = array())
|
||||
{
|
||||
// Set default view if not set
|
||||
JRequest::setVar ('view', JRequest::getCmd ('view', 'OneAllSocialLogin'));
|
||||
|
||||
// Call parent behavior
|
||||
parent::display ($cachable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings
|
||||
*/
|
||||
public function apply ()
|
||||
{
|
||||
$model = $this->getModel ();
|
||||
$model->saveSettings ();
|
||||
$this->setRedirect (JRoute::_ ('index.php?option=com_oneallsociallogin&action=save', false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Autodetect API Connection Handler
|
||||
*/
|
||||
public function autodetect_api_connection_handler ()
|
||||
{
|
||||
// CURL Works on port 443
|
||||
if ($this->is_curl_available (true) === true)
|
||||
{
|
||||
die ('success_autodetect_api_curl_443');
|
||||
}
|
||||
|
||||
// FSOCKOPEN works on port 443
|
||||
if ($this->is_fsockopen_available (true) == true)
|
||||
{
|
||||
die ('success_autodetect_api_fsockopen_443');
|
||||
}
|
||||
|
||||
// CURL Works on port 80
|
||||
if ($this->is_curl_available (false) === true)
|
||||
{
|
||||
die ('success_autodetect_api_curl_80');
|
||||
}
|
||||
|
||||
// FSOCKOPEN works on port 80
|
||||
if ($this->is_fsockopen_available (false) == true)
|
||||
{
|
||||
die ('success_autodetect_api_fsockopen_80');
|
||||
}
|
||||
|
||||
// No working handler found
|
||||
die ('error_autodetect_api_no_handler');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check API Settings
|
||||
*/
|
||||
public function check_api_settings ()
|
||||
{
|
||||
$model = $this->getModel ();
|
||||
|
||||
// Check if all fields have been filled out
|
||||
if (empty ($_POST ['api_subdomain']) or empty ($_POST ['api_key']) or empty ($_POST ['api_secret']))
|
||||
{
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_not_all_fields_filled_out');
|
||||
}
|
||||
|
||||
// Check the handler
|
||||
$api_connection_handler = ((!empty ($_POST ['api_connection_handler']) and $_POST ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl');
|
||||
$api_connection_port = ((!empty ($_POST ['api_connection_port']) and $_POST ['api_connection_port'] == 80) ? 80 : 443);
|
||||
$api_connection_secure = ($api_connection_port == 443);
|
||||
|
||||
// FSOCKOPEN
|
||||
if ($api_connection_handler == 'fsockopen')
|
||||
{
|
||||
if ($this->is_fsockopen_available ($api_connection_secure) !== true)
|
||||
{
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_selected_handler_faulty');
|
||||
}
|
||||
}
|
||||
// CURL
|
||||
else
|
||||
{
|
||||
if ($this->is_curl_available ($api_connection_secure) !== true)
|
||||
{
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_selected_handler_faulty');
|
||||
}
|
||||
}
|
||||
|
||||
// Parameters
|
||||
$api_subdomain = trim (strtolower ($_POST ['api_subdomain']));
|
||||
$api_key = $_POST ['api_key'];
|
||||
$api_secret = $_POST ['api_secret'];
|
||||
|
||||
// Full domain entered
|
||||
if (preg_match ("/([a-z0-9\-]+)\.api\.oneall\.com/i", $api_subdomain, $matches))
|
||||
{
|
||||
$api_subdomain = trim ($matches [1]);
|
||||
}
|
||||
|
||||
// Check subdomain format
|
||||
if (!preg_match ("/^[a-z0-9\-]+$/i", $api_subdomain))
|
||||
{
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_subdomain_wrong_syntax');
|
||||
}
|
||||
|
||||
// Domain
|
||||
$api_domain = $api_subdomain . '.api.oneall.com';
|
||||
|
||||
// Resource URI
|
||||
$api_resource_url = ($api_connection_secure ? 'https' : 'http') . '://' . $api_domain . '/tools/ping.json';
|
||||
|
||||
// Get connection details
|
||||
$result = $this->make_api_request ($api_connection_handler, $api_resource_url, array(
|
||||
'api_key' => $api_key,
|
||||
'api_secret' => $api_secret
|
||||
), 15);
|
||||
|
||||
// Parse result
|
||||
if (is_object ($result) and property_exists ($result, 'http_code') and property_exists ($result, 'http_data'))
|
||||
{
|
||||
switch ($result->http_code)
|
||||
{
|
||||
// Success
|
||||
case 200 :
|
||||
$model->setSetting ('api_settings_verified', 1);
|
||||
die ('success');
|
||||
break;
|
||||
|
||||
// Authentication Error
|
||||
case 401 :
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_authentication_credentials_wrong');
|
||||
break;
|
||||
|
||||
// Wrong Subdomain
|
||||
case 404 :
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_subdomain_wrong');
|
||||
break;
|
||||
|
||||
// Other error
|
||||
default :
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_communication');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$model->setSetting ('api_settings_verified', 0);
|
||||
die ('error_communication');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an API request by using the given handler
|
||||
*/
|
||||
function make_api_request ($handler, $url, $options = array (), $timeout = 15)
|
||||
{
|
||||
// FSOCKOPEN
|
||||
if ($handler == 'fsockopen')
|
||||
{
|
||||
return $this->make_fsockopen_request ($url, $options, $timeout);
|
||||
}
|
||||
// CURL
|
||||
else
|
||||
{
|
||||
return $this->make_curl_request ($url, $options, $timeout);
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
// CURL
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Check if CURL can be used
|
||||
*/
|
||||
public function is_curl_available ($secure = true)
|
||||
{
|
||||
if (in_array ('curl', get_loaded_extensions ()) and function_exists ('curl_exec'))
|
||||
{
|
||||
$result = $this->make_curl_request (($secure ? 'https' : 'http') . '://www.oneall.com/ping.html');
|
||||
if (is_object ($result) and property_exists ($result, 'http_code') and $result->http_code == 200)
|
||||
{
|
||||
if (property_exists ($result, 'http_data'))
|
||||
{
|
||||
if (strtolower ($result->http_data) == 'ok')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a CURL request
|
||||
*/
|
||||
public function make_curl_request ($url, $options = array (), $timeout = 15)
|
||||
{
|
||||
// Store the result
|
||||
$result = new stdClass ();
|
||||
|
||||
// Send request
|
||||
$curl = curl_init ();
|
||||
curl_setopt ($curl, CURLOPT_URL, $url);
|
||||
curl_setopt ($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt ($curl, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt ($curl, CURLOPT_USERAGENT, OA_USERAGENT);
|
||||
|
||||
// BASIC AUTH?
|
||||
if (isset ($options ['api_key']) and isset ($options ['api_secret']))
|
||||
{
|
||||
curl_setopt ($curl, CURLOPT_USERPWD, $options ['api_key'] . ":" . $options ['api_secret']);
|
||||
}
|
||||
|
||||
// Make request
|
||||
if (($http_data = curl_exec ($curl)) !== false)
|
||||
{
|
||||
$result->http_code = curl_getinfo ($curl, CURLINFO_HTTP_CODE);
|
||||
$result->http_data = $http_data;
|
||||
$result->http_error = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result->http_code = -1;
|
||||
$result->http_data = null;
|
||||
$result->http_error = curl_error ($curl);
|
||||
}
|
||||
|
||||
// Done
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
// FSOCKOPEN
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Check if fsockopen can be used
|
||||
*/
|
||||
public function is_fsockopen_available ($secure = true)
|
||||
{
|
||||
$result = $this->make_fsockopen_request (($secure ? 'https' : 'http') . '://www.oneall.com/ping.html');
|
||||
if (is_object ($result) and property_exists ($result, 'http_code') and $result->http_code == 200)
|
||||
{
|
||||
if (property_exists ($result, 'http_data'))
|
||||
{
|
||||
if (strtolower ($result->http_data) == 'ok')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a FSOCKOPEN request
|
||||
*/
|
||||
public function make_fsockopen_request ($url, $options = array (), $timeout = 15)
|
||||
{
|
||||
// Store the result
|
||||
$result = new stdClass ();
|
||||
|
||||
// Make that this is a valid URL
|
||||
if (($uri = parse_url ($url)) == false)
|
||||
{
|
||||
$result->http_code = -1;
|
||||
$result->http_data = null;
|
||||
$result->http_error = 'invalid_uri';
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Make sure we can handle the schema
|
||||
switch ($uri ['scheme'])
|
||||
{
|
||||
case 'http' :
|
||||
$port = (isset ($uri ['port']) ? $uri ['port'] : 80);
|
||||
$host = ($uri ['host'] . ($port != 80 ? ':' . $port : ''));
|
||||
$fp = @fsockopen ($uri ['host'], $port, $errno, $errstr, $timeout);
|
||||
break;
|
||||
|
||||
case 'https' :
|
||||
$port = (isset ($uri ['port']) ? $uri ['port'] : 443);
|
||||
$host = ($uri ['host'] . ($port != 443 ? ':' . $port : ''));
|
||||
$fp = @fsockopen ('ssl://' . $uri ['host'], $port, $errno, $errstr, $timeout);
|
||||
break;
|
||||
|
||||
default :
|
||||
$result->http_code = -1;
|
||||
$result->http_data = null;
|
||||
$result->http_error = 'invalid_schema';
|
||||
return $result;
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure the socket opened properly
|
||||
if (!$fp)
|
||||
{
|
||||
$result->http_code = -$errno;
|
||||
$result->http_data = null;
|
||||
$result->http_error = trim ($errstr);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Construct the path to act on
|
||||
$path = (isset ($uri ['path']) ? $uri ['path'] : '/');
|
||||
if (isset ($uri ['query']))
|
||||
{
|
||||
$path .= '?' . $uri ['query'];
|
||||
}
|
||||
|
||||
// Create HTTP request
|
||||
$defaults = array(
|
||||
'Host' => "Host: $host",
|
||||
'User-Agent' => 'User-Agent: ' . OA_USERAGENT
|
||||
);
|
||||
|
||||
// BASIC AUTH?
|
||||
if (isset ($options ['api_key']) and isset ($options ['api_secret']))
|
||||
{
|
||||
$defaults ['Authorization'] = 'Authorization: Basic ' . base64_encode ($options ['api_key'] . ":" . $options ['api_secret']);
|
||||
}
|
||||
|
||||
// Build and send request
|
||||
$request = 'GET ' . $path . " HTTP/1.0\r\n";
|
||||
$request .= implode ("\r\n", $defaults);
|
||||
$request .= "\r\n\r\n";
|
||||
fwrite ($fp, $request);
|
||||
|
||||
// Fetch response
|
||||
$response = '';
|
||||
while ( !feof ($fp) )
|
||||
{
|
||||
$response .= fread ($fp, 1024);
|
||||
}
|
||||
|
||||
// Close connection
|
||||
fclose ($fp);
|
||||
|
||||
// Parse response
|
||||
list ($response_header, $response_body) = explode ("\r\n\r\n", $response, 2);
|
||||
|
||||
// Parse header
|
||||
$response_header = preg_split ("/\r\n|\n|\r/", $response_header);
|
||||
list ($header_protocol, $header_code, $header_status_message) = explode (' ', trim (array_shift ($response_header)), 3);
|
||||
|
||||
// Build result
|
||||
$result->http_code = $header_code;
|
||||
$result->http_data = $response_body;
|
||||
|
||||
// Done
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,33 @@
|
||||
CREATE TABLE IF NOT EXISTS `#__oasl_settings` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`setting` varchar(255) NOT NULL,
|
||||
`value` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `setting` (`setting`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__oasl_user_mapping` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`token` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
UNIQUE KEY `token` (`token`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
INSERT IGNORE INTO `#__oasl_settings` SET
|
||||
`setting` = 'api_connection_handler',
|
||||
`value` = 'curl';
|
||||
|
||||
INSERT IGNORE INTO `#__oasl_settings` SET
|
||||
`setting` = 'link_verified_accounts',
|
||||
`value` = '1';
|
||||
|
||||
INSERT IGNORE INTO `#__oasl_settings` SET
|
||||
`setting` = 'mod_caption',
|
||||
`value` = 'Sign in with a social network:';
|
||||
|
||||
INSERT IGNORE INTO `#__oasl_settings` SET
|
||||
`setting` = 'providers',
|
||||
`value` = 'a:4:{i:0;s:8:"facebook";i:1;s:7:"twitter";i:2;s:6:"google";i:3;s:8:"linkedin";}';
|
||||
@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS `#__oasl_settings`;
|
||||
DROP TABLE IF EXISTS `#__oasl_user_mapping`;
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct access to this location is not allowed.');
|
||||
jimport ('joomla.application.component.modellist');
|
||||
|
||||
/**
|
||||
* OneAllSocialLogin Model
|
||||
*/
|
||||
class OneAllSocialLoginModelOneAllSocialLogin extends JModelList
|
||||
{
|
||||
|
||||
/**
|
||||
* Save Settings
|
||||
*/
|
||||
public function saveSettings ()
|
||||
{
|
||||
// Get database handle
|
||||
$db = $this->getDbo ();
|
||||
|
||||
// Read Settings
|
||||
$settings = JRequest::getVar ('settings');
|
||||
|
||||
// Cleanup subdomain
|
||||
if (!empty ($settings ['api_subdomain']))
|
||||
{
|
||||
$settings ['api_subdomain'] = strtolower (trim ($settings ['api_subdomain']));
|
||||
|
||||
// Full domain entered
|
||||
if (preg_match ("/([a-z0-9\-]+)\.api\.oneall\.com/i", $settings ['api_subdomain'], $matches))
|
||||
{
|
||||
$settings ['api_subdomain'] = trim ($matches [1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Save providers
|
||||
$providers = array();
|
||||
if (isset ($settings ['providers']) and is_array ($settings ['providers']))
|
||||
{
|
||||
foreach ($settings ['providers'] as $key => $value)
|
||||
{
|
||||
if (!empty ($value))
|
||||
{
|
||||
$providers [] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
$settings ['providers'] = serialize ($providers);
|
||||
|
||||
// Remove current settings
|
||||
$sql = "DELETE FROM #__oasl_settings WHERE setting <> 'api_settings_verified'";
|
||||
$db->setQuery ($sql);
|
||||
$db->query ();
|
||||
|
||||
// Insert new settings
|
||||
foreach ($settings as $k => $v)
|
||||
{
|
||||
$sql = "INSERT INTO #__oasl_settings ( setting, value )" . " VALUES ( " . $db->Quote ($k) . ", " . $db->Quote ($v) . " )";
|
||||
$db->setQuery ($sql);
|
||||
$db->query ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Settings
|
||||
*/
|
||||
public function getSettings ()
|
||||
{
|
||||
// Container
|
||||
$settings = array();
|
||||
|
||||
// Get database handle
|
||||
$db = $this->getDbo ();
|
||||
|
||||
// Read settings
|
||||
$sql = "SELECT * FROM #__oasl_settings";
|
||||
$db->setQuery ($sql);
|
||||
$rows = $db->LoadAssocList ();
|
||||
|
||||
if (is_array ($rows))
|
||||
{
|
||||
foreach ($rows as $key => $data)
|
||||
{
|
||||
if ($data ['setting'] == 'providers')
|
||||
{
|
||||
$tmp = @unserialize ($data ['value']);
|
||||
if (is_array ($tmp))
|
||||
{
|
||||
$settings [$data ['setting']] = $tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings [$data ['setting']] = array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings [$data ['setting']] = $data ['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a given setting
|
||||
*/
|
||||
public function setSetting ($key, $value)
|
||||
{
|
||||
// Get database handle
|
||||
$db = $this->getDbo ();
|
||||
|
||||
// Delete setting
|
||||
$sql = "DELETE FROM #__oasl_settings WHERE setting = " . $db->Quote ($key) . "";
|
||||
$db->setQuery ($sql);
|
||||
$db->query ();
|
||||
|
||||
// Insert new value
|
||||
$sql = "INSERT INTO #__oasl_settings ( setting, value )" . " VALUES ( " . $db->Quote ($key) . ", " . $db->Quote ($value) . " )";
|
||||
$db->setQuery ($sql);
|
||||
$db->query ();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
jimport ('joomla.application.component.controller');
|
||||
|
||||
// Get an instance of the controller
|
||||
$controller = JControllerLegacy::getInstance ('OneAllSocialLogin');
|
||||
|
||||
// Perform the requested task
|
||||
$controller->execute (JRequest::getCmd ('task', 'display'));
|
||||
|
||||
// Redirect if set by the controller
|
||||
$controller->redirect ();
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
|
||||
?>
|
||||
<h1>OneAll Social Login</h1>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_oneallsociallogin'); ?>" method="post" id="adminForm" class="oa_social_login_admin">
|
||||
|
||||
<?php
|
||||
if (JRequest::getVar ('action') == 'save')
|
||||
{
|
||||
?>
|
||||
<fieldset class="social_login_form social_login_form_saved">
|
||||
<div class="social_login_form_row social_login_form_row_title">
|
||||
The settings have been saved
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<fieldset class="social_login_form social_login_form_welcome">
|
||||
<?php
|
||||
|
||||
if ( empty ($this->settings ['api_settings_verified']))
|
||||
{
|
||||
?>
|
||||
<div class="social_login_form_row social_login_form_row_title">
|
||||
Make your Joomla Portal social!
|
||||
</div>
|
||||
<div class="social_login_form_row">
|
||||
Allow your users to comment, login and register with social networks like for example Twitter, Facebook, LinkedIn, Pinterest, Instagram, Вконтакте, Google or Yahoo.
|
||||
<strong>Draw a larger audience and increase user engagement in a few simple steps.</strong>
|
||||
</div>
|
||||
<div class="social_login_form_row">
|
||||
To be able to use this plugin you first of all need to create a free account at <a href="https://app.oneall.com/signup/" target="_blank">http://www.oneall.com</a>
|
||||
and setup a Site. After having created your account and setup your Site, please enter the Site settings in the form below. <strong>You are in good company, more than 50,000 websites already trust us!</strong>
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_button">
|
||||
<div class="social_login_form_row_button_link"><a href="https://app.oneall.com/signup/" target="_blank">Click here to create your free OneAll account! Get started in 60 seconds!</a></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<div class="social_login_form_row social_login_form_row_title">
|
||||
Your API Connection is setup correctly!
|
||||
</div>
|
||||
<div class="social_login_form_row">
|
||||
<a href="https://app.oneall.com/signin/" target="_blank">Login to your OneAll account</a> to manage your Social Networks and to access your <a href="https://app.oneall.com/insights/" target="_blank">Social Insights</a>.
|
||||
Determine which social networks are popular amongst your users and tailor your registration experience to increase your users' engagement.
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_button">
|
||||
<div class="social_login_form_row_button_link"><a href="https://app.oneall.com/signin/" target="_blank">Click here to login to your OneAll account</a></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<h4>Help, Updates & Documentation</h4>
|
||||
<fieldset class="social_login_form social_login_form_info">
|
||||
<div class="social_login_form_row">
|
||||
<ul>
|
||||
<li>
|
||||
<a target="_blank" href="http://www.twitter.com/oneall">Follow us on Twitter</a> to stay informed about updates;
|
||||
</li>
|
||||
<li>
|
||||
<a target="_blank" href="http://docs.oneall.com/plugins/">Read the online documentation</a> for more information about this plugin;</li>
|
||||
<li>
|
||||
<a target="_blank" href="http://www.oneall.com/company/contact-us/">Contact us</a> if you have feedback or need assistance;
|
||||
</li>
|
||||
<li>
|
||||
<a target="_blank" href="http://docs.oneall.com/plugins/">Discover our plugins</a> for WordPress, Drupal and phpBB.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>API Connection</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label><strong>Connection Handler</strong></label>
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_odd">
|
||||
<?php
|
||||
$api_connection_handler = ((isset ($this->settings ['api_connection_handler']) AND $this->settings ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl');
|
||||
?>
|
||||
<input id="oa_social_login_api_connection_handler_curl" type="radio" name="settings[api_connection_handler]" value="curl" <?php echo ($api_connection_handler <> 'fsockopen' ? 'checked="checked"' : ''); ?> />
|
||||
<label for="oa_social_login_api_connection_handler_curl" style="clear:none">Use CURL to communicate with the API <strong>(Recommended, but might be disabled on some servers.)</strong></label>
|
||||
<div class="clr"></div>
|
||||
<input id="oa_social_login_api_connection_handler_fsockopen" type="radio" name="settings[api_connection_handler]" value="fsockopen" <?php echo ($api_connection_handler == 'fsockopen' ? 'checked="checked"' : ''); ?> />
|
||||
<label for="oa_social_login_api_connection_handler_fsockopen" style="clear:none">Use FSOCKOPEN to communicate with the API</label>
|
||||
</div>
|
||||
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label><strong>Connection Port</strong></label>
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_odd">
|
||||
<?php
|
||||
$api_connection_port = ((isset ($this->settings ['api_connection_port']) AND $this->settings ['api_connection_port'] == 80) ? 80 : 443);
|
||||
?>
|
||||
<input id="oa_social_login_api_connection_port_443" type="radio" name="settings[api_connection_port]" value="443" <?php echo ($api_connection_port <> 80 ? 'checked="checked"' : ''); ?> />
|
||||
<label for="oa_social_login_api_connection_port_443" style="clear:none">Connection on port 443/https <strong>(Recommended, but requires OpenSSL to be installed)</strong></label>
|
||||
<div class="clr"></div>
|
||||
<input id="oa_social_login_api_connection_port_80" type="radio" name="settings[api_connection_port]" value="80" <?php echo ($api_connection_port == 80 ? 'checked="checked"' : ''); ?> />
|
||||
<label for="oa_social_login_api_connection_port_80" style="clear:none">Connection on port 80/http</label>
|
||||
</div>
|
||||
|
||||
<div class="social_login_form_row social_login_form_row_even social_login_form_row_button">
|
||||
<div class="social_login_form_row_button_link"><a href="#" id="oa_social_login_autodetect_api_connection_handler">Click here to autodetect the API Connection Handler</a></div>
|
||||
<div class="social_login_form_row_button_result" id="oa_social_login_api_connection_handler_result"></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<h4>API Settings</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even social_login_form_row_description">
|
||||
<strong><a href="https://app.oneall.com/" target="_blank">Click here to create and view your API Credentials</a></strong>
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_odd">
|
||||
<label for="oneall_api_subdomain" style="width: 200px;">API Subdomain:</label>
|
||||
<input type="text" id="settings_api_subdomain" name="settings[api_subdomain]" size="60" value="<?php echo (isset ($this->settings ['api_subdomain']) ? htmlspecialchars ($this->settings ['api_subdomain']) : ''); ?>" />
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_odd">
|
||||
<label for="oneall_api_public_key" style="width: 200px;">API Public Key:</label>
|
||||
<input type="text" id="settings_api_key" name="settings[api_key]" size="60" value="<?php echo (isset ($this->settings ['api_key']) ? htmlspecialchars ($this->settings ['api_key']) : ''); ?>" />
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_odd">
|
||||
<label for="oneall_api_private_key" style="width: 200px;">API Private Key:</label>
|
||||
<input type="text" id="settings_api_secret" name="settings[api_secret]" size="60" value="<?php echo (isset ($this->settings ['api_secret']) ? htmlspecialchars ($this->settings ['api_secret']) : ''); ?>" />
|
||||
</div>
|
||||
<div class="social_login_form_row social_login_form_row_even social_login_form_row_button">
|
||||
<div class="social_login_form_row_button_link"><a href="#" id="oa_social_login_test_api_settings">Click here to verify the API Connection Settings</a></div>
|
||||
<div class="social_login_form_row_button_result" id="oa_social_login_api_test_result"></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Choose the social networks to use</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($this->providers AS $key => $provider_data)
|
||||
{
|
||||
?>
|
||||
<div class="social_login_form_row <?php echo ((($i++) % 2) == 0) ? 'social_login_form_row_even' : 'social_login_form_row_odd' ?> social_login_form_row_provider">
|
||||
<label class="provider_icon" for="oneall_social_login_provider_<?php echo $key; ?>"><span class="oa_social_login_provider oa_social_login_provider_<?php echo $key; ?>" title="<?php echo htmlspecialchars ($provider_data['name']); ?>"><?php echo htmlspecialchars ($provider_data['name']); ?></span></label>
|
||||
<input class="provider_check" type="checkbox" id="oneall_social_login_provider_<?php echo $key; ?>" name="settings[providers][<?php echo $key; ?>]" value="1" <?php echo (in_array($key, $this->settings ['providers']) ? 'checked="checked"' : ''); ?> />
|
||||
<label class="provider_name" for="oneall_social_login_provider_<?php echo $key; ?>"><?php echo htmlspecialchars ($provider_data['name']); ?></label>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<h4>Enter the text to be displayed above the social network login buttons:</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label for="mod_caption">Leave empty if you do not want to use a caption. <strong>(Default: <em>Connect with:</em>)</strong></label>
|
||||
<input type="text" id="mod_caption" name="settings[mod_caption]" size="86" value="<?php echo (isset ($this->settings ['mod_caption']) ? htmlspecialchars ($this->settings ['mod_caption']) : 'Connect with:'); ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Should social network profiles with verified email addresses be linked to existing accounts?</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<?php
|
||||
$link_verified_accounts = (! isset ($this->settings ['link_verified_accounts']) OR !empty($this->settings ['link_verified_accounts']));
|
||||
?>
|
||||
<input id="link_verified_accounts_yes" type="radio" name="settings[link_verified_accounts]" value="1" <?php echo ($link_verified_accounts ? 'checked="checked"' : ''); ?> />
|
||||
<label for="link_verified_accounts_yes" style="clear:none">Yes, try to link verified social network profiles to existing accounts <strong>(Default)</strong></label>
|
||||
<div class="clr"></div>
|
||||
|
||||
<input id="link_verified_accounts_no" type="radio" name="settings[link_verified_accounts]" value="0" <?php echo ( ! $link_verified_accounts ? 'checked="checked"' : ''); ?> />
|
||||
<label for="link_verified_accounts_no" style="clear:none">No, disable account linking </label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Redirect the user to this page after having registered a new account using Social Login:</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label for="redirect_register_url">Leave empty to use the default Joomla! setting. <strong>(Default)</strong></label>
|
||||
<input type="text" id="redirect_register_url" name="settings[redirect_register_url]" size="86" value="<?php echo (isset ($this->settings ['redirect_register_url']) ? htmlspecialchars ($this->settings ['redirect_register_url']) : ''); ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Redirect the user to this page after having logged in using Social Login:</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label for="redirect_login_url">Leave empty to use the default Joomla! setting. <strong>(Default)</strong></label>
|
||||
<input type="text" id="redirect_login_url" name="settings[redirect_login_url]" size="86" value="<?php echo (isset ($this->settings ['redirect_login_url']) ? htmlspecialchars ($this->settings ['redirect_login_url']) : ''); ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Should the module display a logout button for users that are logged in?</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<?php
|
||||
$show_logout_button = (isset ($this->settings ['show_logout_button']) AND $this->settings ['show_logout_button'] == '1');
|
||||
?>
|
||||
<input id="show_logout_button_yes" type="radio" name="settings[show_logout_button]" value="1" <?php echo ($show_logout_button ? 'checked="checked"' : ''); ?> />
|
||||
<label for="show_logout_button_yes" style="clear:none">Yes, display a logout button</label>
|
||||
<div class="clr"></div>
|
||||
|
||||
<input id="show_logout_button_no" type="radio" name="settings[show_logout_button]" value="0" <?php echo ( ! $show_logout_button ? 'checked="checked"' : ''); ?> />
|
||||
<label for="show_logout_button_no" style="clear:none">No, do not display a logout button <strong>(Default)</strong></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Enter the text to be displayed above the logout button:</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label for="logout_button_text">You may use the placeholder %s, it will be replaced by the user's name</label>
|
||||
<input type="text" id="logout_button_text" name="settings[logout_button_text]" size="86" value="<?php echo (isset ($this->settings ['logout_button_text']) ? htmlspecialchars ($this->settings ['logout_button_text']) : 'Hi %s'); ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h4>Enter an URL to a CSS stylesheet to be used by Social Login:</h4>
|
||||
<fieldset class="social_login_form">
|
||||
<div class="social_login_form_row social_login_form_row_even">
|
||||
<label for="css_theme_uri">You need a <a href="http://www.oneall.com/pricing-and-plans/" target="_blank">Starter</a> (or higher plan) to use your own CSS Stylesheet</label>
|
||||
<input type="text" id="css_theme_uri" name="settings[css_theme_uri]" size="86" value="<?php echo (isset ($this->settings ['css_theme_uri']) ? htmlspecialchars ($this->settings ['css_theme_uri']) : ''); ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<input type="hidden" name="task" value="" />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
</form>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Restricted access');
|
||||
jimport ('joomla.application.component.view');
|
||||
|
||||
/**
|
||||
* OneallSocialLogin View
|
||||
*/
|
||||
class oneallsocialloginViewOneAllSocialLogin extends JViewLegacy
|
||||
{
|
||||
//Config
|
||||
public $settings;
|
||||
public $providers;
|
||||
|
||||
/**
|
||||
* OneAllSocialLogin - Display administration area
|
||||
* @return void
|
||||
*/
|
||||
public function display ($tpl = null)
|
||||
{
|
||||
//Require settings
|
||||
require_once(JPATH_BASE . '/components/com_oneallsociallogin/assets/cfg.php');
|
||||
|
||||
//Build document
|
||||
$document = JFactory::getDocument ();
|
||||
$document->addStyleSheet ('components/com_oneallsociallogin/assets/css/oneallsociallogin.css');
|
||||
$document->addScript ('components/com_oneallsociallogin/assets/js/jquery.js');
|
||||
$document->addScript ('components/com_oneallsociallogin/assets/js/oneallsociallogin.js');
|
||||
|
||||
//Read settings
|
||||
$model = $this->getModel ();
|
||||
$this->settings = $model->getSettings ();
|
||||
|
||||
//Read providers
|
||||
$this->providers = $social_login_providers;
|
||||
|
||||
//Build page
|
||||
$this->form = $this->get ('Form');
|
||||
$this->addToolbar ();
|
||||
|
||||
// Display the template
|
||||
parent::display ($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* OneAllSocialLogin - Add Toolbar
|
||||
* @return void
|
||||
*/
|
||||
protected function addToolbar ()
|
||||
{
|
||||
JRequest::setVar ('hidemainmenu', false);
|
||||
JToolBarHelper::title (JText::_ ('Social Login Configuration'), 'weblinks.png');
|
||||
JToolBarHelper::apply ('apply');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
COM_ONEALLSOCIALLOGIN="OneAll Social Login"
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Oneall Social Login Component
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
jimport ('joomla.application.component.controller');
|
||||
|
||||
// Get an instance of the controller
|
||||
$controller = JControllerLegacy::getInstance ('OneAllSocialLogin');
|
||||
|
||||
// Perform the requested task
|
||||
$controller->execute (JRequest::getCmd ('task', 'display'));
|
||||
|
||||
// Redirect if set by the controller
|
||||
$controller->redirect ();
|
||||
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login Module
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
class mod_oneallsocialloginHelper
|
||||
{
|
||||
/**
|
||||
* Is HTTPS enabled?
|
||||
*/
|
||||
public static function is_https_on ()
|
||||
{
|
||||
if (!empty ($_SERVER ['SERVER_PORT']))
|
||||
{
|
||||
if (trim ($_SERVER ['SERVER_PORT']) == '443')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty ($_SERVER ['HTTP_X_FORWARDED_PROTO']))
|
||||
{
|
||||
if (strtolower (trim ($_SERVER ['HTTP_X_FORWARDED_PROTO'])) == 'https')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty ($_SERVER ['HTTPS']))
|
||||
{
|
||||
if (strtolower (trim ($_SERVER ['HTTPS'])) == 'on' or trim ($_SERVER ['HTTPS']) == '1')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
*/
|
||||
public static function getSettings ()
|
||||
{
|
||||
// Container
|
||||
$settings = array();
|
||||
|
||||
// Get database handle
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Read settings
|
||||
$sql = "SELECT * FROM #__oasl_settings";
|
||||
$db->setQuery ($sql);
|
||||
$rows = $db->LoadAssocList ();
|
||||
|
||||
if (is_array ($rows))
|
||||
{
|
||||
foreach ($rows as $key => $data)
|
||||
{
|
||||
if ($data ['setting'] == 'providers')
|
||||
{
|
||||
$tmp = @unserialize ($data ['value']);
|
||||
if (is_array ($tmp))
|
||||
{
|
||||
$settings [$data ['setting']] = $tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings [$data ['setting']] = array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings [$data ['setting']] = $data ['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login Module
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
require_once (dirname (__FILE__) . '/classes/helper.php');
|
||||
$params->def ('greeting', 1);
|
||||
|
||||
// Get settings
|
||||
$widget_settings = mod_oneallsocialloginHelper::getSettings ();
|
||||
|
||||
// Add library
|
||||
if (!empty ($widget_settings ['api_subdomain']))
|
||||
{
|
||||
$document = JFactory::getDocument ();
|
||||
$document->addScriptDeclaration (" var oa = document.createElement('script');
|
||||
oa.type = 'text/javascript'; oa.async = true;
|
||||
oa.src = '//" . trim ($widget_settings ['api_subdomain']) . ".api.oneall.com/socialize/library.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(oa, s);");
|
||||
}
|
||||
|
||||
// Get user status
|
||||
$user = JFactory::getUser ();
|
||||
$user_status = ((!$user->get ('guest')) ? 'logout' : 'login');
|
||||
|
||||
// Return URL
|
||||
$return_url = JURI::getInstance ()->toString ();
|
||||
|
||||
// Get Module Class Suffix
|
||||
$moduleclass_sfx = htmlspecialchars ($params->get ('moduleclass_sfx'));
|
||||
|
||||
// Show template
|
||||
require JModuleHelper::getLayoutPath ('mod_oneallsociallogin', $params->get ('layout', 'default'));
|
||||
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="module" version="3.0" client="site">
|
||||
<name>OneAll Social Login</name>
|
||||
<license>Open Source License, GPL v2 based</license>
|
||||
<author>OneAll LLC</author>
|
||||
<authorEmail>support@oneall.com</authorEmail>
|
||||
<authorUrl>http://www.oneall.com</authorUrl>
|
||||
<creationDate>2014-10-29</creationDate>
|
||||
<copyright>2011 - Today, OneAll LLC</copyright>
|
||||
<version>2.1</version>
|
||||
<description>
|
||||
<![CDATA[Part of the OneAll Social Login component.<br />
|
||||
The module displays the social network buttons.<br /><br />
|
||||
Visit us at <a target="_blank" href="http://www.oneall.com">http://www.oneall.com/</a><br />
|
||||
Contact our support at: <a target="_blank" href="http://www.oneall.com/company/contact-us/">http://www.oneall.com/company/contact-us/</a>
|
||||
]]></description>
|
||||
<files>
|
||||
<file module="mod_oneallsociallogin">mod_oneallsociallogin.php</file>
|
||||
<folder>classes</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="advanced">
|
||||
<field name="moduleclass_sfx" type="text" label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL" description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Oneall Social Login Module
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
|
||||
// User is logged in
|
||||
if ($user_status == 'logout')
|
||||
{
|
||||
// Display a Logout button?
|
||||
if (isset ($widget_settings ['show_logout_button']) and $widget_settings ['show_logout_button'] == '1')
|
||||
{
|
||||
?>
|
||||
<div class="oa_social_login<?php echo $moduleclass_sfx; ?>">
|
||||
<form action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" method="post" id="login-form">
|
||||
<?php
|
||||
// Display text above the Logout button?
|
||||
if (isset ($widget_settings ['logout_button_text']) and strlen (trim ($widget_settings ['logout_button_text'])) > 0)
|
||||
{
|
||||
?>
|
||||
<div class="login-greeting">
|
||||
<?php
|
||||
$username = htmlspecialchars (($params->get ('name') == 0) ? $user->get ('name') : $user->get ('username'));
|
||||
echo str_replace ('%s', $username, $widget_settings ['logout_button_text']);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="logout-button">
|
||||
<input type="submit" name="Submit" class="btn btn-primary" value="<?php echo JText::_('JLOGOUT'); ?>" />
|
||||
<input type="hidden" name="option" value="com_users" /> <input type="hidden" name="task" value="user.logout" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
// User is logged out
|
||||
else
|
||||
{
|
||||
// Custom CSS
|
||||
$widget_settings ['css_theme_uri'] = (!isset ($widget_settings ['css_theme_uri']) ? '' : trim ($widget_settings ['css_theme_uri']));
|
||||
|
||||
// Check if the subdomain is set
|
||||
if (isset ($widget_settings ['api_subdomain']) and strlen (trim ($widget_settings ['api_subdomain'])) > 0)
|
||||
{
|
||||
// Check if providers have been selected
|
||||
if (isset ($widget_settings ['providers']) and is_array ($widget_settings ['providers']))
|
||||
{
|
||||
// Random integer for unique dom element ids;
|
||||
$rnd = rand ();
|
||||
|
||||
?>
|
||||
<div class="oa_social_login<?php echo $moduleclass_sfx ?>">
|
||||
<?php
|
||||
// Check if we have a caption
|
||||
if (isset ($widget_settings ['mod_caption']) and strlen (trim ($widget_settings ['mod_caption'])) > 0)
|
||||
{
|
||||
?>
|
||||
<p class="oa_social_login_caption<?php echo $moduleclass_sfx ?>">
|
||||
<strong><?php echo JText::_($widget_settings['mod_caption']);?></strong>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div id="oa_social_login_container<?php echo $rnd.$moduleclass_sfx ?>"></div>
|
||||
<script type="text/javascript">
|
||||
var _oneall = _oneall || [];
|
||||
_oneall.push(['social_login', 'set_providers', ['<?php echo implode ("','", $widget_settings['providers']); ?>']]);
|
||||
_oneall.push(['social_login', 'set_callback_uri', '<?php echo $return_url; ?>']);
|
||||
_oneall.push(['social_login', 'set_custom_css_uri', '<?php echo $widget_settings['css_theme_uri']; ?>']);
|
||||
_oneall.push(['social_login', 'do_render_ui', 'oa_social_login_container<?php echo $rnd.$moduleclass_sfx ?>']);
|
||||
</script>
|
||||
<!-- http://www.oneall.com / OneAll Social Login for Joomla! -->
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<div style="background-color: red; color: white; padding: 5px; text-align: center">
|
||||
[<strong>Social Login</strong>] Please select at least one Social Network (Admin: Components\OneAll Social Login)
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<div style="background-color: red; color: white; padding: 5px; text-align: center">
|
||||
[<strong>Social Login</strong>] Please complete your API Settings (Admin: Components\OneAll Social Login)
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,390 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login Plugin
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined ('_JEXEC') or die ('Direct Access to this location is not allowed.');
|
||||
|
||||
/**
|
||||
* OneAllSocialLogin Plugin Helper
|
||||
*/
|
||||
class plgSystemOneAllSocialLoginHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* Check if the given username exists
|
||||
*/
|
||||
public static function usernameExists ($username)
|
||||
{
|
||||
// Database handler
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Get user for username
|
||||
$sql = "SELECT id FROM #__users WHERE username = " . $db->quote ($username);
|
||||
$db->setQuery ($sql);
|
||||
$user_id = $db->loadResult ();
|
||||
|
||||
// Done
|
||||
return (!empty ($user_id) and is_numeric ($user_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given email exists
|
||||
*/
|
||||
public static function useremailExists ($email)
|
||||
{
|
||||
// Database handler
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Get user for email
|
||||
$sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email);
|
||||
$db->setQuery ($sql);
|
||||
$user_id = $db->loadResult ();
|
||||
|
||||
// Done
|
||||
return (!empty ($user_id) and is_numeric ($user_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create random email
|
||||
*/
|
||||
public static function getRandomUseremail ()
|
||||
{
|
||||
// Create unique email
|
||||
do
|
||||
{
|
||||
$email = md5 (uniqid (rand (10000, 99000))) . "@example.com";
|
||||
}
|
||||
while ( self::useremailExists ($email) );
|
||||
|
||||
// Done
|
||||
return $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link token to userid
|
||||
*/
|
||||
public static function setUserIdForToken ($token, $user_id)
|
||||
{
|
||||
// Database handler
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Remove
|
||||
$sql = "DELETE FROM #__oasl_user_mapping WHERE token = " . $db->quote ($token);
|
||||
$db->setQuery ($sql);
|
||||
if ($db->query ())
|
||||
{
|
||||
// Add
|
||||
$sql = "INSERT INTO #__oasl_user_mapping SET token = " . $db->quote ($token) . ", user_id = " . $db->Quote ($user_id);
|
||||
$db->setQuery ($sql);
|
||||
if ($db->query ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have a userid for the given token
|
||||
*/
|
||||
public static function getUserIdForToken ($token)
|
||||
{
|
||||
// Database handler
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Read user
|
||||
$sql = "SELECT u.ID FROM #__oasl_user_mapping AS um INNER JOIN #__users AS u ON (um.user_id=u.ID) WHERE um.token = " . $db->quote ($token);
|
||||
$db->setQuery ($sql);
|
||||
$user_id = $db->loadResult ();
|
||||
if ($user_id)
|
||||
{
|
||||
return $user_id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the userid for a given email
|
||||
*/
|
||||
public static function getUserIdForEmail ($email)
|
||||
{
|
||||
// Database handler
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Read user
|
||||
$sql = "SELECT id FROM #__users WHERE email = " . $db->quote ($email);
|
||||
$db->setQuery ($sql);
|
||||
$user_id = $db->loadResult ();
|
||||
if ($user_id)
|
||||
{
|
||||
return $user_id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an API Request to obtain the data for a given connection_token
|
||||
*/
|
||||
public static function makeTokenLookup ($token)
|
||||
{
|
||||
// Read settings
|
||||
$settings = self::getSettings ();
|
||||
|
||||
// API Settings
|
||||
$api_subdomain = (!empty ($settings ['api_subdomain']) ? trim ($settings ['api_subdomain']) : '');
|
||||
$api_key = (!empty ($settings ['api_key']) ? $settings ['api_key'] : '');
|
||||
$api_secret = (!empty ($settings ['api_secret']) ? $settings ['api_secret'] : '');
|
||||
|
||||
// API Connection
|
||||
$api_connection_handler = ((!empty ($settings ['api_connection_handler']) and $settings ['api_connection_handler'] == 'fsockopen') ? 'fsockopen' : 'curl');
|
||||
$api_connection_port = ((!empty ($settings ['api_connection_port']) and $settings ['api_connection_port'] == 80) ? 80 : 443);
|
||||
$api_connection_secure = ($api_connection_port == 443);
|
||||
|
||||
$api_resource = ($api_connection_secure ? 'https' : 'http') . '://' . $api_subdomain . '.api.oneall.com/connections/' . $token . '.json';
|
||||
|
||||
// Send request to the API
|
||||
$result = self::makeHttpRequest ($api_connection_handler, $api_resource, array(
|
||||
'api_key' => $api_key,
|
||||
'api_secret' => $api_secret
|
||||
));
|
||||
|
||||
// Parse result
|
||||
if (is_object ($result) and property_exists ($result, 'http_data') and property_exists ($result, 'http_code') and $result->http_code == 200)
|
||||
{
|
||||
// Result
|
||||
$json = $result->http_data;
|
||||
|
||||
// Decode
|
||||
$json_decoded = @json_decode ($json);
|
||||
|
||||
// Check format
|
||||
if (is_object ($json_decoded) and !empty ($json_decoded->response->request->status->code) and $json_decoded->response->request->status->code == 200)
|
||||
{
|
||||
$social_data = $json_decoded;
|
||||
}
|
||||
}
|
||||
|
||||
return ((isset ($social_data) and is_object ($social_data)) ? $social_data : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a HTTP request by using the given handler
|
||||
*/
|
||||
public static function makeHttpRequest ($handler, $url, $options = array (), $timeout = 15)
|
||||
{
|
||||
// FSOCKOPEN
|
||||
if ($handler == 'fsockopen')
|
||||
{
|
||||
return self::makeFsockopenRequest ($url, $options, $timeout);
|
||||
}
|
||||
// CURL
|
||||
else
|
||||
{
|
||||
return self::makeCurlRequest ($url, $options, $timeout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a HTTP request by using CURL
|
||||
*/
|
||||
public static function makeCurlRequest ($url, $options = array (), $timeout = 15)
|
||||
{
|
||||
// Store the result
|
||||
$result = new stdClass ();
|
||||
|
||||
// Send request
|
||||
$curl = curl_init ();
|
||||
curl_setopt ($curl, CURLOPT_URL, $url);
|
||||
curl_setopt ($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt ($curl, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt ($curl, CURLOPT_USERAGENT, OA_USERAGENT);
|
||||
|
||||
// BASIC AUTH?
|
||||
if (isset ($options ['api_key']) and isset ($options ['api_secret']))
|
||||
{
|
||||
curl_setopt ($curl, CURLOPT_USERPWD, $options ['api_key'] . ":" . $options ['api_secret']);
|
||||
}
|
||||
|
||||
// Make request
|
||||
if (($http_data = curl_exec ($curl)) !== false)
|
||||
{
|
||||
$result->http_code = curl_getinfo ($curl, CURLINFO_HTTP_CODE);
|
||||
$result->http_data = $http_data;
|
||||
$result->http_error = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result->http_code = -1;
|
||||
$result->http_data = null;
|
||||
$result->http_error = curl_error ($curl);
|
||||
}
|
||||
|
||||
// Done
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a HTTP request by using FSOCKOPEN
|
||||
*/
|
||||
public static function makeFsockopenRequest ($url, $options = array (), $timeout = 15)
|
||||
{
|
||||
// Store the result
|
||||
$result = new stdClass ();
|
||||
|
||||
// Make that this is a valid URL
|
||||
if (($uri = parse_url ($url)) == false)
|
||||
{
|
||||
$result->http_code = -1;
|
||||
$result->http_data = null;
|
||||
$result->http_error = 'invalid_uri';
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Make sure we can handle the schema
|
||||
switch ($uri ['scheme'])
|
||||
{
|
||||
case 'http' :
|
||||
$port = (isset ($uri ['port']) ? $uri ['port'] : 80);
|
||||
$host = ($uri ['host'] . ($port != 80 ? ':' . $port : ''));
|
||||
$fp = @fsockopen ($uri ['host'], $port, $errno, $errstr, $timeout);
|
||||
break;
|
||||
|
||||
case 'https' :
|
||||
$port = (isset ($uri ['port']) ? $uri ['port'] : 443);
|
||||
$host = ($uri ['host'] . ($port != 443 ? ':' . $port : ''));
|
||||
$fp = @fsockopen ('ssl://' . $uri ['host'], $port, $errno, $errstr, $timeout);
|
||||
break;
|
||||
|
||||
default :
|
||||
$result->http_code = -1;
|
||||
$result->http_data = null;
|
||||
$result->http_error = 'invalid_schema';
|
||||
return $result;
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure the socket opened properly
|
||||
if (!$fp)
|
||||
{
|
||||
$result->http_code = -$errno;
|
||||
$result->http_data = null;
|
||||
$result->http_error = trim ($errstr);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Construct the path to act on
|
||||
$path = (isset ($uri ['path']) ? $uri ['path'] : '/');
|
||||
if (isset ($uri ['query']))
|
||||
{
|
||||
$path .= '?' . $uri ['query'];
|
||||
}
|
||||
|
||||
// Create HTTP request
|
||||
$defaults = array(
|
||||
'Host' => "Host: $host",
|
||||
'User-Agent' => 'User-Agent: ' . OA_USERAGENT
|
||||
);
|
||||
|
||||
// BASIC AUTH?
|
||||
if (isset ($options ['api_key']) and isset ($options ['api_secret']))
|
||||
{
|
||||
$defaults ['Authorization'] = 'Authorization: Basic ' . base64_encode ($options ['api_key'] . ":" . $options ['api_secret']);
|
||||
}
|
||||
|
||||
// Build and send request
|
||||
$request = 'GET ' . $path . " HTTP/1.0\r\n";
|
||||
$request .= implode ("\r\n", $defaults);
|
||||
$request .= "\r\n\r\n";
|
||||
fwrite ($fp, $request);
|
||||
|
||||
// Fetch response
|
||||
$response = '';
|
||||
while ( !feof ($fp) )
|
||||
{
|
||||
$response .= fread ($fp, 1024);
|
||||
}
|
||||
|
||||
// Close connection
|
||||
fclose ($fp);
|
||||
|
||||
// Parse response
|
||||
list ($response_header, $response_body) = explode ("\r\n\r\n", $response, 2);
|
||||
|
||||
// Parse header
|
||||
$response_header = preg_split ("/\r\n|\n|\r/", $response_header);
|
||||
list ($header_protocol, $header_code, $header_status_message) = explode (' ', trim (array_shift ($response_header)), 3);
|
||||
|
||||
// Build result
|
||||
$result->http_code = $header_code;
|
||||
$result->http_data = $response_body;
|
||||
|
||||
// Done
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
*/
|
||||
public static function getSettings ()
|
||||
{
|
||||
// Container
|
||||
$settings = array();
|
||||
|
||||
// Get database handle
|
||||
$db = JFactory::getDBO ();
|
||||
|
||||
// Read settings
|
||||
$sql = "SELECT * FROM #__oasl_settings";
|
||||
$db->setQuery ($sql);
|
||||
$rows = $db->LoadAssocList ();
|
||||
|
||||
if (is_array ($rows))
|
||||
{
|
||||
foreach ($rows as $key => $data)
|
||||
{
|
||||
if ($data ['setting'] == 'providers')
|
||||
{
|
||||
$tmp = @unserialize ($data ['value']);
|
||||
if ($tmp !== false and is_array ($tmp))
|
||||
{
|
||||
$settings [$data ['setting']] = $tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings [$data ['setting']] = array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings [$data ['setting']] = $data ['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#fff"></body></html>
|
||||
@ -0,0 +1,421 @@
|
||||
<?php
|
||||
/**
|
||||
* @package OneAll Social Login Plugin
|
||||
* @copyright Copyright 2011-Today http://www.oneall.com, all rights reserved
|
||||
* @license GNU/GPL 2 or later
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||||
*
|
||||
* The "GNU General Public License" (GPL) is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*/
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
jimport('joomla.plugin.plugin');
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
// Directory Separator
|
||||
if (!defined('DS'))
|
||||
{
|
||||
define('DS', defined('DIRECTORY_SEPARATOR') ? DIRECTORY_SEPARATOR : '/');
|
||||
}
|
||||
|
||||
// Check if plugin correctly installed
|
||||
if (!JFile::exists(dirname(__FILE__) . DS . 'helper.php'))
|
||||
{
|
||||
JError::raiseNotice('no_oneallsociallogin_plugin', JText::_('The OneAll Social Login plugin is not installed correctly. Plugin not executed'));
|
||||
|
||||
return;
|
||||
}
|
||||
require_once dirname(__FILE__) . DS . 'helper.php';
|
||||
|
||||
define('OA_USERAGENT', 'SocialLogin/5.5.0 Joomla/3.0 (+http://www.oneall.com/)');
|
||||
class plgSystemOneAllSocialLogin extends JPlugin
|
||||
{
|
||||
/**
|
||||
* Authentication
|
||||
*/
|
||||
private function doAuth($token)
|
||||
{
|
||||
// Settings
|
||||
$settings = plgSystemOneAllSocialLoginHelper::getSettings();
|
||||
|
||||
// Check settings
|
||||
if (empty($settings['api_subdomain']) or empty($settings['api_key']) or empty($settings['api_secret']))
|
||||
{
|
||||
JError::raiseNotice('no_oneallsociallogin_plugin', JText::_('The OneAll Social Login API settings are missing. Please correct these in the Joomla administration area.'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Read user data
|
||||
$social_data = plgSystemOneAllSocialLoginHelper::makeTokenLookup($token);
|
||||
if (is_object($social_data))
|
||||
{
|
||||
$identity = $social_data->response->result->data->user->identity;
|
||||
$user_token = $social_data->response->result->data->user->user_token;
|
||||
|
||||
// Identity
|
||||
$user_identity_id = $identity->id;
|
||||
$user_identity_provider = $identity->source->name;
|
||||
|
||||
// ***** Firstname *****
|
||||
if (isset($identity->name->givenName) and !empty($identity->name->givenName))
|
||||
{
|
||||
$user_first_name = $identity->name->givenName;
|
||||
}
|
||||
elseif (isset($identity->preferredUsername))
|
||||
{
|
||||
$user_first_name = $identity->preferredUsername;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_first_name = 'noname';
|
||||
}
|
||||
|
||||
// ***** Lastname *****
|
||||
if (isset($identity->name->familyName) and !empty($identity->name->familyName))
|
||||
{
|
||||
$user_last_name = $identity->name->familyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_last_name = '';
|
||||
}
|
||||
|
||||
// ***** Fullname *****
|
||||
if (!empty($identity->name->formatted))
|
||||
{
|
||||
$user_full_name = $identity->name->formatted;
|
||||
}
|
||||
elseif (!empty($identity->name->displayName))
|
||||
{
|
||||
$user_full_name = $identity->name->displayName;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_full_name = trim($user_first_name . ' ' . $user_last_name);
|
||||
}
|
||||
|
||||
// ***** Email *****
|
||||
$user_email = '';
|
||||
if (property_exists($identity, 'emails') and is_array($identity->emails))
|
||||
{
|
||||
foreach ($identity->emails as $email)
|
||||
{
|
||||
$user_email = $email->value;
|
||||
$user_email_is_verified = ($email->is_verified == '1');
|
||||
}
|
||||
}
|
||||
|
||||
// ***** Thumbnail *****
|
||||
if (property_exists($identity, 'thumbnailUrl') and !empty($identity->thumbnailUrl))
|
||||
{
|
||||
$user_thumbnail = trim($identity->thumbnailUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_thumbnail = '';
|
||||
}
|
||||
|
||||
// ***** User Website *****
|
||||
if (property_exists($identity, 'profileUrl') and !empty($identity->profileUrl))
|
||||
{
|
||||
$user_website = $identity->profileUrl;
|
||||
}
|
||||
elseif (property_exists($identity, 'urls') and !empty($identity->urls[0]->value))
|
||||
{
|
||||
$user_website = $identity->urls[0]->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_website = '';
|
||||
}
|
||||
|
||||
// ***** Preferred Username *****
|
||||
if (!empty($identity->preferredUsername))
|
||||
{
|
||||
$user_login = $identity->preferredUsername;
|
||||
}
|
||||
elseif (!empty($identity->displayName))
|
||||
{
|
||||
$user_login = $identity->displayName;
|
||||
}
|
||||
elseif (!empty($identity->name->formatted))
|
||||
{
|
||||
$user_login = $identity->name->formatted;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_login = '';
|
||||
}
|
||||
|
||||
// Get user by token
|
||||
$user_id = plgSystemOneAllSocialLoginHelper::getUserIdForToken($user_token);
|
||||
|
||||
// Not linked, try to link to existing account
|
||||
if (!is_numeric($user_id))
|
||||
{
|
||||
// Linking enabled?
|
||||
if (!empty($settings['link_verified_accounts']))
|
||||
{
|
||||
// Only of email is verified
|
||||
if (!empty($user_email) and $user_email_is_verified === true)
|
||||
{
|
||||
// Read existing user
|
||||
if (($user_id_tmp = plgSystemOneAllSocialLoginHelper::getUserIdForEmail($user_email)) !== false)
|
||||
{
|
||||
// Link user to token
|
||||
if (is_numeric($user_id_tmp))
|
||||
{
|
||||
if (plgSystemOneAllSocialLoginHelper::setUserIdForToken($user_token, $user_id_tmp))
|
||||
{
|
||||
$user_id = $user_id_tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ***** New User *****
|
||||
if (!is_numeric($user_id))
|
||||
{
|
||||
// Import libraries
|
||||
jimport('joomla.user.helper');
|
||||
jimport('joomla.application.component.helper');
|
||||
|
||||
// New user
|
||||
$new_user = true;
|
||||
|
||||
// Get the com_user params
|
||||
$usersParams = JComponentHelper::getParams('com_users');
|
||||
|
||||
// Make sure user registration is allowed.
|
||||
if ($usersParams->get('allowUserRegistration') == '0' && !$usersParams->get('override_allow_user_registration', 0))
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage(JText::_('Sorry, but your account could not be created as the registration of new users has been disabled by the administrator of this website.'), 'error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Replace characters that are now allowed by Joomla
|
||||
// See JLIB_DATABASE_ERROR_VALID_AZ09 in libraries/joomla/table/user.php
|
||||
$user_login = preg_replace('#[<>"\'%;()&\s\\\\]|\\.\\./#', "", $user_login);
|
||||
$user_login = trim(trim($user_login), '.');
|
||||
|
||||
// Username must be at least 2 characters long
|
||||
if (strlen($user_login) < 2)
|
||||
{
|
||||
$user_login = $user_identity_provider . 'User';
|
||||
}
|
||||
|
||||
// Username must be unique
|
||||
if (plgSystemOneAllSocialLoginHelper::usernameExists($user_login))
|
||||
{
|
||||
$i = 1;
|
||||
$user_login_tmp = $user_login;
|
||||
do
|
||||
{
|
||||
$user_login_tmp = $user_login . ($i++);
|
||||
} while (plgSystemOneAllSocialLoginHelper::usernameExists($user_login_tmp));
|
||||
|
||||
// Unique user login
|
||||
$user_login = $user_login_tmp;
|
||||
}
|
||||
|
||||
// Email must be unique
|
||||
if (empty($user_email) or plgSystemOneAllSocialLoginHelper::useremailExists($user_email))
|
||||
{
|
||||
$user_email = plgSystemOneAllSocialLoginHelper::getRandomUseremail();
|
||||
}
|
||||
|
||||
// Get the ACL
|
||||
$acl = JFactory::getACL();
|
||||
|
||||
// Ggenerate a new JUser Object
|
||||
$user = JFactory::getUser(0);
|
||||
|
||||
// Array for all user settings
|
||||
$data = array();
|
||||
|
||||
// Get the default usertype
|
||||
$defaultUserGroups = $usersParams->get('new_usertype', 2);
|
||||
if (!$defaultUserGroups)
|
||||
{
|
||||
$defaultUserGroups = 'Registered';
|
||||
}
|
||||
|
||||
// Setup the "main" user information
|
||||
$data['name'] = $user_full_name;
|
||||
$data['username'] = $user_login;
|
||||
$data['email'] = $user_email;
|
||||
$data['usertype'] = 'deprecated';
|
||||
$data['language'] = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
|
||||
$data['groups'] = array(
|
||||
$defaultUserGroups
|
||||
);
|
||||
$data['registerDate'] = JFactory::getDate()->toSQL();
|
||||
$data['password'] = JUserHelper::genRandomPassword();
|
||||
$data['password2'] = $data['password'];
|
||||
$data['sendEmail'] = 0;
|
||||
$data['block'] = 0;
|
||||
|
||||
// Bind the data to the JUser Object
|
||||
if (!$user->bind($data))
|
||||
{
|
||||
JError::raiseWarning('', JText::_('Could not bind data to user') . ': ' . JText::_($user->getError()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save the user
|
||||
if (!$user->save())
|
||||
{
|
||||
JError::raiseWarning('', JText::_('Could not create user') . ': ' . JText::_($user->getError()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store userid
|
||||
$user_id = $user->get('id');
|
||||
|
||||
// Link to token
|
||||
plgSystemOneAllSocialLoginHelper::setUserIdForToken($user_token, $user_id);
|
||||
}
|
||||
// Returning user
|
||||
else
|
||||
{
|
||||
$new_user = false;
|
||||
}
|
||||
|
||||
// Sucess
|
||||
if (isset($user_id) and is_numeric($user_id) and !empty($user_id))
|
||||
{
|
||||
// User exists
|
||||
$user = JFactory::getUser($user_id);
|
||||
if (is_object($user))
|
||||
{
|
||||
// Get the application object.
|
||||
$app = JFactory::getApplication();
|
||||
$db = JFactory::getDBO();
|
||||
$query = 'SELECT `id`, `username`, `password` FROM `#__users` WHERE id = ' . $db->Quote($user->get('id'));
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadObject();
|
||||
|
||||
// Login user
|
||||
if ($result and !empty($result->username))
|
||||
{
|
||||
JPluginHelper::importPlugin('user');
|
||||
|
||||
// Setup options
|
||||
$options = array();
|
||||
$options['action'] = 'core.login.site';
|
||||
|
||||
// Return to the original URL
|
||||
/*
|
||||
* if ( ! empty ($_REQUEST['return']))
|
||||
* {
|
||||
* $url = base64_decode (urldecode ($_REQUEST['return']));
|
||||
*
|
||||
* //Registration
|
||||
* $settings['redirect_register_url'] = $url;
|
||||
*
|
||||
* //Login
|
||||
* $settings['redirect_login_url'] = $url;
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
// Setup return url for new users
|
||||
if ($new_user === true)
|
||||
{
|
||||
if (isset($settings['redirect_register_url']) and strlen(trim($settings['redirect_register_url'])) > 0)
|
||||
{
|
||||
$session = JFactory::getSession();
|
||||
$session->set('redirect_url', trim($settings['redirect_register_url']), 'plg_oneallsociallogin');
|
||||
}
|
||||
}
|
||||
// Setup return url for returning users
|
||||
elseif ($new_user === false)
|
||||
{
|
||||
if (isset($settings['redirect_login_url']) and strlen(trim($settings['redirect_login_url'])) > 0)
|
||||
{
|
||||
$session = JFactory::getSession();
|
||||
$session->set('redirect_url', trim($settings['redirect_login_url']), 'plg_oneallsociallogin');
|
||||
}
|
||||
}
|
||||
|
||||
$response = new stdClass();
|
||||
$response->username = $result->username;
|
||||
$response->fullname = $result->username;
|
||||
$response->password = $result->password;
|
||||
$response->type = 'oneall-social-login';
|
||||
$response->status = \JAuthentication::STATUS_SUCCESS;
|
||||
|
||||
$loginResult = $app->triggerEvent('onUserLogin', array((array) $response, $options));
|
||||
|
||||
$user = \JFactory::getUser();
|
||||
if (in_array(false, $loginResult, true) == false)
|
||||
{
|
||||
$options['user'] = $user;
|
||||
$options['responseType'] = $response->type;
|
||||
|
||||
// The user is successfully logged in. Run the after login events
|
||||
$app->triggerEvent('onUserAfterLogin', array($options));
|
||||
}
|
||||
|
||||
//Done
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for token
|
||||
*/
|
||||
public function onAfterInitialise()
|
||||
{
|
||||
// Check if we have a connection token
|
||||
if (isset($_POST) and !empty($_POST['oa_action']) and $_POST['oa_action'] == 'social_login' and !empty($_POST['connection_token']))
|
||||
{
|
||||
$this->doAuth($_POST['connection_token']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect if necessary
|
||||
*/
|
||||
public function onAfterRoute()
|
||||
{
|
||||
// Read session
|
||||
$session = JFactory::getSession();
|
||||
|
||||
// Check for uri
|
||||
$redirect_url = $session->get('redirect_url', null, 'plg_oneallsociallogin');
|
||||
if (!empty($redirect_url))
|
||||
{
|
||||
// Clear uri
|
||||
$session->clear('redirect_url', 'plg_oneallsociallogin');
|
||||
|
||||
// Redirect
|
||||
$app = JFactory::getApplication();
|
||||
$app->redirect($redirect_url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="3.0" group="system" method="upgrade">
|
||||
<name>System - OneAll Social Login</name>
|
||||
<license>Open Source License, GPL v2 based</license>
|
||||
<author>OneAll LLC</author>
|
||||
<authorEmail>support@oneall.com</authorEmail>
|
||||
<authorUrl>http://www.oneall.com</authorUrl>
|
||||
<creationDate>2014-10-29</creationDate>
|
||||
<copyright>2011 - Today, OneAll LLC</copyright>
|
||||
<version>2.1</version>
|
||||
<description>
|
||||
<![CDATA[Part of the Social Login component.<br />
|
||||
The plugin handles the authentication process through a social network account.<br /><br />
|
||||
Visit us at <a target="_blank" href="http://www.oneall.com">http://www.oneall.com/</a><br />
|
||||
Contact our support at: <a target="_blank" href="http://www.oneall.com/company/contact-us/">http://www.oneall.com/company/contact-us/</a>
|
||||
]]></description>
|
||||
<files>
|
||||
<file plugin="oneallsociallogin">oneallsociallogin.php</file>
|
||||
<file>index.html</file>
|
||||
<file>helper.php</file>
|
||||
</files>
|
||||
</extension>
|
||||
Loading…
Reference in New Issue
Block a user