mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
hybridAuth work - still some issues.
This commit is contained in:
@@ -63,7 +63,7 @@ if(isset($_POST['updateprefs']))
|
||||
|
||||
unset($_POST['updateprefs'], $_POST['sitelanguage']);
|
||||
|
||||
print_a($_POST);
|
||||
|
||||
|
||||
$_POST['cookie_name'] = str_replace(array(" ", "."), "_", $_POST['cookie_name']);
|
||||
$_POST['cookie_name'] = preg_replace("#[^a-zA-Z0-9_]#", "", $_POST['cookie_name']);
|
||||
@@ -133,6 +133,7 @@ if(isset($_POST['updateprefs']))
|
||||
{
|
||||
$newValue = $tp->toDB($value);
|
||||
}
|
||||
|
||||
$core_pref->update($key, $newValue);
|
||||
/*if($newValue != $core_pref->get($key))
|
||||
{ // Changed value
|
||||
@@ -733,8 +734,8 @@ $single_logins = array (
|
||||
|
||||
|
||||
$text .= "
|
||||
<fieldset class='e-hideme' id='core-prefs-single-login'>
|
||||
<legend>Single Login Options</legend>
|
||||
<fieldset class='e-hideme' id='core-prefs-sociallogin'>
|
||||
<legend>Social Login Options</legend>
|
||||
<div>Note: This section is not functional at the moment</div>
|
||||
<table class='adminform'>
|
||||
<colgroup>
|
||||
@@ -743,14 +744,20 @@ $text .= "
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class='label'>Enable Single Logins</td>
|
||||
<td class='label'>Enable Social Logins</td>
|
||||
<td class='control'>
|
||||
".$frm->radio_switch('single_login_active', $pref['single_login_active'])."
|
||||
".$frm->radio_switch('social_login_active', $pref['social_login_active'])."
|
||||
</td>
|
||||
</tr>";
|
||||
|
||||
if(!is_array($pref['social_login']))
|
||||
{
|
||||
$pref['social_login'] = array();
|
||||
}
|
||||
|
||||
foreach($single_logins as $prov=>$val)
|
||||
{
|
||||
{
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='label'>".$prov."</td>
|
||||
@@ -761,22 +768,26 @@ $text .= "
|
||||
switch ($k) {
|
||||
case 'enabled':
|
||||
$eopt = array('class'=>'e-expandit');
|
||||
$text .= $frm->radio_switch('single_login['.$prov.'][enabled]', $pref['single_login'][$prov]['enabled'],'','',$eopt);
|
||||
$text .= $frm->radio_switch('social_login['.$prov.'][enabled]', $pref['social_login'][$prov]['enabled'],'','',$eopt);
|
||||
break;
|
||||
|
||||
case 'keys':
|
||||
// $cls = vartrue($pref['single_login'][$prov]['keys'][$tk]) ? "class='e-hideme'" : '';
|
||||
$sty = vartrue($pref['single_login'][$prov]['keys'][$tk]) ? "" : "display:none";
|
||||
$sty = vartrue($pref['social_login'][$prov]['keys'][$tk]) ? "" : "display:none";
|
||||
$text .= "<div id='option-{$prov}' style='padding:10px;{$sty}'>";
|
||||
foreach($v as $tk=>$idk)
|
||||
{
|
||||
$opt['placeholder'] = $tk;
|
||||
$text .= "<br />".$frm->text('single_login['.$prov.'][keys]['.$tk.']', $pref['single_login'][$prov]['keys'][$tk],20,$opt);
|
||||
$text .= "<br />".$frm->text('social_login['.$prov.'][keys]['.$tk.']', $pref['social_login'][$prov]['keys'][$tk],20,$opt);
|
||||
}
|
||||
$text .= "</div>";
|
||||
|
||||
break;
|
||||
|
||||
case 'scope':
|
||||
$text .= $frm->hidden('social_login['.$prov.'][scope]','email');
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
@@ -793,7 +804,7 @@ $text .= "
|
||||
$text .= "
|
||||
</tbody>
|
||||
</table>
|
||||
".pref_submit('single-login')."
|
||||
".pref_submit('sociallogin')."
|
||||
</fieldset>
|
||||
";
|
||||
|
||||
@@ -1600,7 +1611,7 @@ function prefs_adminmenu()
|
||||
$var['core-prefs-date']['text'] = PRFLAN_21;
|
||||
$var['core-prefs-registration']['text'] = PRFLAN_28;
|
||||
$var['core-prefs-signup']['text'] = PRFLAN_19;
|
||||
$var['core-prefs-single-login']['text'] = "Single-Login";
|
||||
$var['core-prefs-sociallogin']['text'] = "Social Logins";
|
||||
$var['core-prefs-textpost']['text'] = PRFLAN_101;
|
||||
$var['core-prefs-security']['text'] = PRFLAN_47;
|
||||
$var['core-prefs-comments']['text'] = PRFLAN_210;
|
||||
|
@@ -519,7 +519,7 @@ CREATE TABLE user (
|
||||
user_perms text NOT NULL,
|
||||
user_realm text NOT NULL,
|
||||
user_pwchange int(10) unsigned NOT NULL default '0',
|
||||
user_xup varchar(100) NOT NULL default '',
|
||||
user_xup text NOT NULL,
|
||||
PRIMARY KEY (user_id),
|
||||
UNIQUE KEY user_name (user_name),
|
||||
UNIQUE KEY user_loginname (user_loginname),
|
||||
|
@@ -53,10 +53,10 @@ class signup_shortcodes extends e_shortcode
|
||||
if(vartrue($pref['single_login_active']))
|
||||
{
|
||||
$text = "";
|
||||
$providers = array('facebook','twitter','google','yahoo');
|
||||
$providers = array('facebook','twitter','google','yahoo','blogger');
|
||||
foreach($providers as $p)
|
||||
{
|
||||
$text .= "<a href='".e_SELF."?provider={$p}'><img src='".e_HANDLER."hybridauth/icons/{$p}.png' alt='' /></a>";
|
||||
$text .= "<a href='".e_SELF."?provider={$p}'><img class='e-tip' title='Register using your {$p} account' src='".e_HANDLER."hybridauth/icons/{$p}.png' alt='' /></a>";
|
||||
}
|
||||
|
||||
$text .= "<hr />";
|
||||
|
@@ -210,6 +210,8 @@ City, State, Country
|
||||
<core name="sitetheme_pref"></core>
|
||||
<core name="siteurl">/</core>
|
||||
<core name="smiley_activate">1</core>
|
||||
<core name="social_login_active">0</core>
|
||||
<core name="social_login"><![CDATA[array()]]></core>
|
||||
<core name="ssl_enabled">0</core>
|
||||
<core name="subnews_attach"></core>
|
||||
<core name="subnews_class">0</core>
|
||||
|
79
index.php
79
index.php
@@ -58,6 +58,85 @@
|
||||
}
|
||||
$response->sendMeta();
|
||||
|
||||
|
||||
|
||||
// -------------- Experimental -----------------
|
||||
|
||||
unset($_SESSION['E:SOCIAL']);
|
||||
|
||||
if(!isset($_SESSION['E:SOCIAL']) && e107::getPref('social_login_active', false) && (e_ADMIN_AREA !== true))
|
||||
{
|
||||
require_once(e_HANDLER."hybridauth/Hybrid/Auth.php");
|
||||
|
||||
$config = array(
|
||||
"base_url" => SITEURL.$HANDLERS_DIRECTORY."hybridauth/",
|
||||
"providers" => e107::getPref('social_login', array())
|
||||
);
|
||||
|
||||
print_a($config);
|
||||
// $params = array("hauth_return_to" => e_SELF);
|
||||
|
||||
$hybridauth = new Hybrid_Auth($config);
|
||||
|
||||
$prov = (!isset($config['providers'][$_GET['provider']])) ? "Facebook" : $_GET['provider'];
|
||||
|
||||
|
||||
$adapter = $hybridauth->authenticate( $prov);
|
||||
$user_profile = $adapter->getUserProfile();
|
||||
|
||||
$prov_id = $prov."_".$user_profile->identifier;
|
||||
|
||||
if($user_profile->identifier >0)
|
||||
{
|
||||
if (!$sql->db_Select("user", "*", "user_xup = '".$prov_id."' ")) // New User
|
||||
{
|
||||
$user_join = time();
|
||||
$user_pass = md5($user_profile->identifier.$user_join);
|
||||
$user_loginname = "xup_".$user_profile->identifier;
|
||||
|
||||
$insert = array(
|
||||
'user_name' => $user_profile->displayName,
|
||||
'user_email' => $user_profile->email,
|
||||
'user_loginname' => $user_loginname,
|
||||
'user_password' => $user_pass,
|
||||
'user_login' => $user_profile->displayName,
|
||||
'user_join' => $user_join,
|
||||
'user_xup' => $prov_id
|
||||
);
|
||||
|
||||
if($newid = $sql->db_Insert('user',$insert,true))
|
||||
{
|
||||
e107::getEvent()->trigger('usersup', $insert);
|
||||
if(!USERID)
|
||||
{
|
||||
require_once(e_HANDLER.'login.php');
|
||||
$usr = new userlogin($user_loginname, $user_pass, 'signup', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Existing User.
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// echo "CHECKING";
|
||||
$_SESSION['E:SOCIAL'] = (array) $user_profile;
|
||||
echo "USERNAME=".USERNAME;
|
||||
echo "<br />USEREMAIL=".USEREMAIL;
|
||||
echo "<br />USERIMAGE=".USERIMAGE;
|
||||
// print_a($_SESSION['E:SOCIAL']);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
include_once(HEADERF);
|
||||
eFront::instance()->getResponse()->send('default', false, true);
|
||||
include_once(FOOTERF);
|
||||
|
Reference in New Issue
Block a user