soclever_login - Version 1.0.1

Version Notes

Version 1.0.1

Download this release

Release Info

Developer Soclever Social
Extension soclever_login
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/local/Soclever/Sociallogin/Block/Adminhtml/Help.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Soclever_Sociallogin_Block_Adminhtml_Help extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+
8
+ $fileContent="<h1>Help is coming...Keep Visiting...Thanks....<a href='https://www.socleversocial.com' target='_blank'>Socleversocial.com</a></h1>";
9
+ return $fileContent;
10
+
11
+
12
+ }
13
+
14
+
15
+
16
+ }
17
+ ?>
app/code/local/Soclever/Sociallogin/Block/Adminhtml/Positions.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Soclever_Sociallogin_Block_Adminhtml_Positions extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+
5
+
6
+
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
9
+
10
+ $site_id=Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid');
11
+ $api_secret=Mage::getStoreConfig('sociallogin_options/apisettings/scsl_appsecret');
12
+ $api_key=Mage::getStoreConfig('sociallogin_options/apisettings/scsl_appid');
13
+
14
+ $valid_data=file_get_contents("https://www.socleversocial.com/dashboard/wp_activate.php?site_id=".$site_id."&api_key=".$api_key."&api_secret=".$api_secret."&csplatform=magentologin");
15
+ if($valid_data && $valid_data[0]!='0')
16
+ {
17
+ $selectedButtons=Mage::getStoreConfig('sociallogin_options/displaysettings/buttonstyle');
18
+ $selectedProviders="https://www.socleversocial.com/dashboard/img/social_icon/social_login_fc_30.png";
19
+ $btn_style=Mage::getStoreConfig('sociallogin_options/displaysettings/buttonstyle');
20
+ $button_size=Mage::getStoreConfig('sociallogin_options/displaysettings/buttonsize');
21
+ $SITE_URL="https://www.socleversocial.com/dashboard/";
22
+ if($btn_style=="ic") {
23
+ $btn_width=$button_size;
24
+ }
25
+ else if($btn_style=="fc" || $btn_style=="fg")
26
+ {
27
+ if($button_size=="30") {$btn_width="78"; }
28
+ if($button_size=="40") {$btn_width="104"; }
29
+ if($button_size=="50") {$btn_width="130"; }
30
+ if($button_size=="60") {$btn_width="156"; }
31
+ if($button_size=="65") {$btn_width="169"; }
32
+ }
33
+
34
+ $network=explode(",",$valid_data);
35
+ $imgdiv="";
36
+ $img='social_login_'.$btn_style.'_'.$button_size.'.png';
37
+ if(in_array('2',$network))
38
+ {
39
+ $bg_position=$btn_width;
40
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
41
+
42
+
43
+ }
44
+
45
+ if(in_array('4',$network))
46
+ {
47
+ $bg_position=((3)*$btn_width);
48
+
49
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
50
+
51
+
52
+ }
53
+
54
+ if(in_array('7',$network))
55
+ {
56
+ $bg_position=((6)*$btn_width);
57
+
58
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
59
+
60
+
61
+ }
62
+
63
+ if(in_array('13',$network))
64
+ {
65
+ $bg_position=((12)*$btn_width);
66
+
67
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
68
+
69
+
70
+ }
71
+
72
+ if(in_array('15',$network))
73
+ {
74
+ $bg_position=((14)*$btn_width);
75
+
76
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
77
+
78
+ }
79
+
80
+ if(in_array('16',$network))
81
+ {
82
+ $bg_position=((15)*$btn_width); //change when image is added
83
+
84
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
85
+
86
+ }
87
+
88
+ if(in_array('5',$network))
89
+ {
90
+ $bg_position=((4)*$btn_width);
91
+
92
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
93
+
94
+
95
+ }
96
+
97
+
98
+
99
+ return '<div style="margin-bottom:20px;width:360px;margin-bottom:10px;float:left;">'.$imgdiv.'</div>';
100
+
101
+ }
102
+ else
103
+ {
104
+ return "<h1>Please provide valid API setting</h1>";
105
+ }
106
+
107
+
108
+
109
+
110
+
111
+
112
+ }
113
+
114
+ }
115
+ ?>
app/code/local/Soclever/Sociallogin/Block/Scslhead.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Soclever_Sociallogin_Block_Scslhead extends Mage_Core_Block_Template
3
+ {
4
+ protected function _construct(){
5
+ parent::_construct();
6
+
7
+ }
8
+ public function _prepareLayout(){
9
+ return parent::_prepareLayout();
10
+ }
11
+ }
12
+
13
+ ?>
app/code/local/Soclever/Sociallogin/Block/Scslshow.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Soclever_Sociallogin_Block_Scslshow extends Mage_Core_Block_Template
3
+ {
4
+ protected function _construct(){
5
+ parent::_construct();
6
+ $this->setTemplate('sociallogin/scsl_buttons.phtml');
7
+ }
8
+ public function setPlace($place) {
9
+ $this->place = $place;
10
+ return $this;
11
+ }
12
+
13
+ /*public function _prepareLayout(){
14
+ return parent::_prepareLayout();
15
+ }*/
16
+ }
17
+
18
+ ?>
app/code/local/Soclever/Sociallogin/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Soclever_Sociallogin_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
6
+ ?>
app/code/local/Soclever/Sociallogin/Model/Providers.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Soclever_Sociallogin_Model_Providers
4
+ {
5
+ public function getbuttonstyles()
6
+ {
7
+ $buttonstylesarray=array("ic"=>"Icons","fc"=>"Full Logos - Colored","fg"=>"Full Logos - Grey");
8
+ return $buttonstylesarray;
9
+
10
+ }
11
+ public function getsizes()
12
+ {
13
+
14
+ $buttonsizearray=array("30"=>"30px","40"=>"40px","50"=>"50px","60"=>"60px","65"=>"65px");
15
+ return $buttonsizearray;
16
+ }
17
+
18
+
19
+ }
20
+
21
+
22
+ ?>
app/code/local/Soclever/Sociallogin/controllers/IndexController.php ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Soclever_Sociallogin_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ protected function getSession(){
10
+ return Mage::getSingleton('customer/session');
11
+ }
12
+ public function fbloginAction()
13
+ {
14
+
15
+ if(isset($_GET['lc']) && $_GET['lc']!='')
16
+ {
17
+ setcookie('lc',$_GET['lc'],time()+100,'/');
18
+
19
+ }
20
+
21
+ $get_fb=file_get_contents("https://www.socleversocial.com/dashboard/get_fb_data.php?siteid=".Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid')."");
22
+
23
+ if($get_fb!='0')
24
+ {
25
+ $app_arr=explode("~",$get_fb);
26
+ $app_id = $app_arr[0];
27
+ $my_url="".Mage::getBaseUrl()."soclever_sociallogin/index/fblogin";
28
+ $app_secret = $app_arr[1];
29
+ $code = $_REQUEST["code"];
30
+ if(isset($_REQUEST['error'])){
31
+ if(isset($_REQUEST['error_reason']) && $_REQUEST['error_reason']=='user_denied'){
32
+
33
+ echo $_REQUEST['error'];
34
+ echo"<br/><a href='".Mage::getBaseUrl()."'>Go to site</a>";
35
+ exit;
36
+ }
37
+ }
38
+
39
+ if(empty($code)) {
40
+ $dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
41
+ . $app_id . "&redirect_uri=" . urlencode($my_url)."&scope=email,user_birthday,user_relationships,user_location,user_hometown,user_friends,user_likes";
42
+
43
+ echo("<script>top.location.href='".$dialog_url."'</script>");
44
+ }
45
+
46
+ $token_url = "https://graph.facebook.com/oauth/access_token?client_id="
47
+ . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret="
48
+ . $app_secret . "&code=" . $code;
49
+
50
+ $ch = curl_init();
51
+
52
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
53
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
54
+ curl_setopt($ch, CURLOPT_VERBOSE, 1);
55
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
56
+ curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
57
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
58
+
59
+ //Get Access Token
60
+ curl_setopt($ch, CURLOPT_URL,$token_url);
61
+ $access_token = curl_exec($ch);
62
+
63
+ curl_close($ch);
64
+
65
+
66
+ $graph_url = "https://graph.facebook.com/v2.2/me?" . $access_token."&fields=id,name,first_name,last_name,timezone,email,picture,gender,locale,birthday,relationship_status,location,hometown,friends.limit%280%29,likes{id,name}";
67
+ $ch = curl_init();
68
+ curl_setopt($ch, CURLOPT_HEADER, 0);
69
+ curl_setopt($ch, CURLOPT_URL, $graph_url);
70
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
71
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
72
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
73
+ $temp_user = curl_exec($ch);
74
+ curl_close($ch);
75
+ $fbuser_old = $temp_user;
76
+ $fbuser=json_decode($fbuser_old);
77
+
78
+ if($fbuser_old && $fbuser->email!="")
79
+ {
80
+ $request_url="https://www.socleversocial.com/dashboard/track_register_new.php?app_id=".$app_id."&is_fb=1&friend_data=".$fbuser->friends->summary->total_count."&siteid=".Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid')."&other=".urlencode($fbuser_old);
81
+ $resPonse=file_get_contents($request_url);
82
+ if($resPonse)
83
+ {
84
+ $fb_data=json_decode($resPonse);
85
+
86
+ $resource = Mage::getSingleton('core/resource');
87
+ $tableName = $resource->getTableName('customer_entity');
88
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
89
+ $sql = "Select entity_id from ".$tableName." where email='".$fb_data->email."' limit 1";
90
+ $rows= $connection->fetchAll($sql);
91
+
92
+ $customer = Mage::getModel("customer/customer");
93
+ if(count($rows) > 0)
94
+ {
95
+ $is_new='0';
96
+ $username=$fb_data->email;
97
+ $customer_id=$rows[0]['entity_id'];
98
+ }
99
+ else
100
+ {
101
+ $is_new='1';
102
+ $store = Mage::app()->getStore();
103
+
104
+ $customer->website_id = $websiteId;
105
+ $customer->setStore($store);
106
+ $password=rand("111111","9999999");
107
+ $customer->firstname = $fb_data->first_name;
108
+ $customer->lastname = $fb_data->last_name;
109
+ $customer->email =$fb_data->email;
110
+ $customer->password_hash = md5($password);
111
+ $customer->save();
112
+ $username=$fb_data->email;
113
+ $sql= "Select entity_id from ".$tableName." where email='".$fb_data->email."' limit 1";
114
+ $rows= $connection->fetchAll($sql);
115
+ $customer_id=$rows[0]['entity_id'];
116
+ }
117
+
118
+ file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_from=1&siteUid=".$customer_id."&is_new=".$is_new."&member_id=".$fb_data->member_id."&siteid=".Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid')."&action=notifycs");
119
+ Mage::getModel('core/session', array('name' => 'frontend'));
120
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
121
+ $customer->loadByEmail($username);
122
+
123
+ $redirect_location=($_GET['lc']=='c')?Mage::getBaseUrl()."checkout/onepage/":Mage::getBaseUrl()."customer/account/";
124
+
125
+ ?>
126
+ <script type="text/javascript">
127
+
128
+ setTimeout(function(){
129
+
130
+
131
+ window.location.href="<?php echo $redirect_location;?>";
132
+
133
+ },1000);
134
+
135
+ /*setTimeout(function(){
136
+
137
+
138
+ window.close();
139
+ //window.opener.location = window.opener.window.location;
140
+
141
+ /*try{
142
+ if(parent.window.opener != null && ! parent.window.opener)
143
+ {
144
+ alert("good");
145
+ }
146
+
147
+ }catch(e){ alert("message="+e.description);}
148
+ */
149
+
150
+ //alert("called redirection=="+top.window.opener.document.URL+"=");
151
+ //top.window.location.assign("<?php echo Mage::getBaseUrl();?>customer/account/edit/");
152
+
153
+ // top.window.location.href="<?php echo Mage::getBaseUrl();?>customer/account/edit/";
154
+ //close();
155
+ //return false;
156
+ /*if(top.window.opener.document.URL.indexOf('login') > -1)
157
+ {
158
+ top.window.opener.location.href="<?php echo Mage::getBaseUrl();?>customer/account/edit/";
159
+ close();
160
+ }
161
+ else
162
+ {
163
+ top.window.opener.location.href="<?php echo Mage::getBaseUrl();?>checkout/onepage/";
164
+ close();
165
+
166
+ }*/
167
+
168
+ /*}, 3000);*/
169
+ </script>
170
+ <?php
171
+ echo"<img src='https://www.socleversocial.com/dashboard/images/pw.gif' alt='wait!' title='wait!'>";
172
+ $this->getSession()->loginById($customer->getId());
173
+ exit;
174
+ }
175
+ }
176
+ }
177
+ else
178
+ {
179
+
180
+ echo"<h1>Login failed.</h1><a href='".Mage::getBaseUrl()."'>Go back to site.</a>";
181
+ }
182
+ }
183
+ public function pploginAction()
184
+ {
185
+ $paypal_data=json_decode($_GET['data']);
186
+
187
+ $resource = Mage::getSingleton('core/resource');
188
+ $tableName = $resource->getTableName('customer_entity');
189
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
190
+ $sql = "Select entity_id from ".$tableName." where email='".$paypal_data->email."' limit 1";
191
+ $rows= $connection->fetchAll($sql);
192
+
193
+ $customer = Mage::getModel("customer/customer");
194
+ if(count($rows) > 0)
195
+ {
196
+ $is_new='0';
197
+ $username=$paypal_data->email;
198
+ $customer_id=$rows[0]['entity_id'];
199
+ }
200
+ else
201
+ {
202
+ $is_new='1';
203
+ $store = Mage::app()->getStore();
204
+
205
+ $customer->website_id = $websiteId;
206
+ $customer->setStore($store);
207
+ $password=rand("111111","9999999");
208
+ $customer->firstname = $paypal_data->first_name;
209
+ $customer->lastname = $paypal_data->last_name;
210
+ $customer->email =$paypal_data->email;
211
+ $customer->password_hash = md5($password);
212
+ $customer->save();
213
+ $username=$paypal_data->email;
214
+ $sql= "Select entity_id from ".$tableName." where email='".$paypal_data->email."' limit 1";
215
+ $rows= $connection->fetchAll($sql);
216
+ $customer_id=$rows[0]['entity_id'];
217
+ }
218
+
219
+ file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_from=7&siteUid=".$customer_id."&is_new=".$is_new."&member_id=".$paypal_data->member_id."&siteid=".Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid')."&action=notifycs");
220
+ Mage::getModel('core/session', array('name' => 'frontend'));
221
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
222
+ $customer->loadByEmail($username);
223
+ $redirect_location=($_GET['lc']=='c')?Mage::getBaseUrl()."checkout/onepage/":Mage::getBaseUrl()."customer/account/";
224
+ ?>
225
+ <script type="text/javascript">
226
+ setTimeout(function(){ window.location.href="<?php echo $redirect_location; ?>"; }, 3000);
227
+ </script>
228
+ <?php
229
+ echo"<img src='https://www.socleversocial.com/dashboard/images/pw.gif' alt='wait!' title='wait!'>";
230
+ $this->getSession()->loginById($customer->getId());
231
+ exit;
232
+ }
233
+
234
+
235
+ public function cs_redirect($red)
236
+ {
237
+ echo $red;
238
+ exit;
239
+ }
240
+ public function yahoologinAction()
241
+ {
242
+ require 'openid.php';
243
+
244
+ try
245
+ {
246
+
247
+
248
+ $openid = new LightOpenID($_SERVER['HTTP_HOST']);
249
+
250
+
251
+ if(!$openid->mode)
252
+ {
253
+
254
+ //do the login
255
+ if(isset($_GET['login']))
256
+ {
257
+ //The google openid url
258
+ $openid->identity = 'https://me.yahoo.com';
259
+
260
+ //Get additional google account information about the user , name , email , country
261
+ $openid->required = array('contact/email','person/guid','dob','birthDate','namePerson' , 'person/gender' , 'pref/language' , 'media/image/default','birthDate/birthday');
262
+
263
+ //start discovery
264
+
265
+
266
+ header('Location: ' . $openid->authUrl());
267
+ }
268
+
269
+
270
+ }
271
+
272
+ else if($openid->mode == 'cancel')
273
+ {
274
+ echo 'User has canceled authentication!';
275
+ //redirect back to login page ??
276
+ }
277
+
278
+ //Echo login information by default
279
+ else
280
+ {
281
+ if($openid->validate())
282
+ {
283
+ $d = $openid->getAttributes();
284
+ //echo "https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=".Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid')."&other=".json_encode($d)."";
285
+ /*$response_content=file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=".Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid')."&other=".json_encode($d)."");
286
+ if($response_content)
287
+ {
288
+ $response_final=json_decode($response_content);
289
+ print_r($response_final);
290
+ exit;
291
+ }*/
292
+ ?>
293
+ <script src="//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
294
+ <script type="text/javascript">
295
+ var xmlhttp;
296
+ if(window.XMLHttpRequest)
297
+ {
298
+ xmlhttp=new XMLHttpRequest();
299
+ }
300
+ else
301
+ {
302
+ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
303
+ }
304
+ function track_info_yh(info)
305
+ {
306
+ xmlhttp.onreadystatechange=function()
307
+ {
308
+ if (xmlhttp.readyState==4 && xmlhttp.status==200)
309
+ {
310
+ var gobj=JSON.parse(xmlhttp.responseText);
311
+ var login_src='5';
312
+
313
+ var request = new Ajax.Request("<?php echo Mage::getBaseUrl();?>soclever_sociallogin/index/login",
314
+ {
315
+ method: 'post',
316
+ parameters: {member_id: gobj.member_id, email:gobj.email,first_name:gobj.first_name,last_name:gobj.last_name,site_id:<?php echo Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid'); ?>,is_from:login_src},
317
+ onSuccess: function(transport){
318
+ if(transport.responseText)
319
+ {
320
+
321
+ if(opener.document.URL.indexOf('checkout') > -1)
322
+ {
323
+ opener.location.href="<?php echo Mage::getBaseUrl();?>checkout/onepage/";
324
+ close();
325
+
326
+ }
327
+ else
328
+ {
329
+ opener.location.href="<?php echo Mage::getBaseUrl();?>customer/account/";
330
+ close();
331
+
332
+ }
333
+ }
334
+
335
+ }
336
+ });
337
+
338
+
339
+
340
+ }
341
+ }
342
+ xmlhttp.open("GET",'https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=<?php echo Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid'); ?>&other='+encodeURIComponent(info),true);
343
+ xmlhttp.send();
344
+
345
+ }
346
+ track_info_yh('<?php echo json_encode($d); ?>');
347
+ </script>
348
+
349
+
350
+ <?php
351
+ exit("<img src='https://www.socleversocial.com/dashboard/images/pw.gif' alt='wait!' title='wait!'>");
352
+
353
+
354
+ }
355
+ else
356
+ {
357
+ //user is not logged in
358
+ }
359
+ }
360
+ }
361
+
362
+ catch(ErrorException $e)
363
+ {
364
+ echo $e->getMessage();
365
+ }
366
+
367
+ }
368
+ public function loginAction()
369
+ {
370
+
371
+ $resource = Mage::getSingleton('core/resource');
372
+ $tableName = $resource->getTableName('customer_entity');
373
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
374
+ $sql = "Select entity_id from ".$tableName." where email='{$_POST['email']}' limit 1";
375
+ $rows =$connection->fetchAll($sql);
376
+
377
+ $customer = Mage::getModel("customer/customer");
378
+ if(count($rows) > 0)
379
+ {
380
+ $is_new='0';
381
+ $username=$_POST['email'];
382
+ $customer_id=$rows[0]['entity_id'];
383
+ }
384
+ else
385
+ {
386
+ $is_new='1';
387
+ $store = Mage::app()->getStore();
388
+
389
+ $customer->website_id = $websiteId;
390
+ $customer->setStore($store);
391
+ $password=rand("111111","9999999");
392
+ $customer->firstname = $_POST['first_name'];
393
+ $customer->lastname = $_POST['last_name'];
394
+ $customer->email = $_POST['email'];
395
+ $customer->password_hash = md5($password);
396
+ $customer->save();
397
+ $username=$_POST['email'];
398
+ $sql = "Select entity_id from ".$tableName." where email='{$_POST['email']}' limit 1";
399
+ $rows= $connection->fetchAll($sql);
400
+ $customer_id=$rows[0]['entity_id'];
401
+ }
402
+
403
+ file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_from=".$_POST['is_from']."&siteUid=".$customer_id."&is_new=".$is_new."&member_id=".$_POST['member_id']."&siteid=".$_POST['site_id']."&action=notifycs");
404
+
405
+ Mage::getModel('core/session', array('name' => 'frontend'));
406
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
407
+ $customer->loadByEmail($username);
408
+ $this->getSession()->loginById($customer->getId());
409
+
410
+
411
+
412
+
413
+
414
+ }
415
+
416
+ }
417
+ ?>
app/code/local/Soclever/Sociallogin/controllers/openid.php ADDED
@@ -0,0 +1,797 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class LightOpenID
3
+ {
4
+
5
+ public $returnUrl
6
+ , $required = array()
7
+ , $optional = array()
8
+ , $verify_peer = null
9
+ , $capath = null
10
+ , $cainfo = null
11
+ , $data,$clientSite;
12
+ private $identity, $claimed_id;
13
+ protected $server, $version, $trustRoot, $aliases, $identifier_select = false
14
+ , $ax = false, $sreg = false, $setup_url = null, $headers = array();
15
+ static protected $ax_to_sreg = array(
16
+ 'namePerson/friendly' => 'nickname',
17
+ 'contact/email' => 'email',
18
+ 'namePerson' => 'fullname',
19
+ 'birthDate' => 'dob',
20
+ 'person/gender' => 'gender',
21
+ 'contact/postalCode/home' => 'postcode',
22
+ 'contact/country/home' => 'country',
23
+ 'pref/language' => 'language',
24
+ 'pref/timezone' => 'timezone',
25
+ );
26
+
27
+
28
+ function __construct($host)
29
+ {
30
+
31
+ $this->trustRoot = (strpos($host, '://') ? $host : 'http://' . $host);
32
+ if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
33
+ || (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
34
+ && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
35
+ ) {
36
+ $this->trustRoot = (strpos($host, '://') ? $host : 'https://' . $host);
37
+ }
38
+
39
+ if(($host_end = strpos($this->trustRoot, '/', 8)) !== false) {
40
+ $this->trustRoot = substr($this->trustRoot, 0, $host_end);
41
+ }
42
+
43
+ $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
44
+ $this->returnUrl = $this->trustRoot . $uri;
45
+
46
+ $this->data = ($_SERVER['REQUEST_METHOD'] === 'POST') ? $_POST : $_GET;
47
+
48
+ if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
49
+ throw new ErrorException('You must have either https wrappers or curl enabled.');
50
+ }
51
+ }
52
+
53
+ function __set($name, $value)
54
+ {
55
+ switch ($name) {
56
+ case 'identity':
57
+ if (strlen($value = trim((String) $value))) {
58
+ if (preg_match('#^xri:/*#i', $value, $m)) {
59
+ $value = substr($value, strlen($m[0]));
60
+ } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
61
+ $value = "http://$value";
62
+ }
63
+ if (preg_match('#^https?://[^/]+$#i', $value, $m)) {
64
+ $value .= '/';
65
+ }
66
+ }
67
+ $this->$name = $this->claimed_id = $value;
68
+ break;
69
+ case 'trustRoot':
70
+ case 'realm':
71
+ $this->trustRoot = trim($value);
72
+ }
73
+ }
74
+
75
+ function __get($name)
76
+ {
77
+ switch ($name) {
78
+ case 'identity':
79
+ # We return claimed_id instead of identity,
80
+ # because the developer should see the claimed identifier,
81
+ # i.e. what he set as identity, not the op-local identifier (which is what we verify)
82
+ return $this->claimed_id;
83
+ case 'trustRoot':
84
+ case 'realm':
85
+ return $this->trustRoot;
86
+ case 'mode':
87
+ return empty($this->data['openid_mode']) ? null : $this->data['openid_mode'];
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Checks if the server specified in the url exists.
93
+ *
94
+ * @param $url url to check
95
+ * @return true, if the server exists; false otherwise
96
+ */
97
+ function hostExists($url)
98
+ {
99
+ if (strpos($url, '/') === false) {
100
+ $server = $url;
101
+ } else {
102
+ $server = @parse_url($url, PHP_URL_HOST);
103
+ }
104
+
105
+ if (!$server) {
106
+ return false;
107
+ }
108
+
109
+ return !!gethostbynamel($server);
110
+ }
111
+
112
+ protected function request_curl($url, $method='GET', $params=array(), $update_claimed_id)
113
+ {
114
+ $params = http_build_query($params, '', '&');
115
+ $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
116
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
117
+ curl_setopt($curl, CURLOPT_HEADER, false);
118
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
119
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
120
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
121
+
122
+ if($this->verify_peer !== null) {
123
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
124
+ if($this->capath) {
125
+ curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
126
+ }
127
+
128
+ if($this->cainfo) {
129
+ curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
130
+ }
131
+ }
132
+
133
+ if ($method == 'POST') {
134
+ curl_setopt($curl, CURLOPT_POST, true);
135
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
136
+ } elseif ($method == 'HEAD') {
137
+ curl_setopt($curl, CURLOPT_HEADER, true);
138
+ curl_setopt($curl, CURLOPT_NOBODY, true);
139
+ } else {
140
+ curl_setopt($curl, CURLOPT_HEADER, true);
141
+ curl_setopt($curl, CURLOPT_HTTPGET, true);
142
+ }
143
+ $response = curl_exec($curl);
144
+
145
+ if($method == 'HEAD' && curl_getinfo($curl, CURLINFO_HTTP_CODE) == 405) {
146
+ curl_setopt($curl, CURLOPT_HTTPGET, true);
147
+ $response = curl_exec($curl);
148
+ $response = substr($response, 0, strpos($response, "\r\n\r\n"));
149
+ }
150
+
151
+ if($method == 'HEAD' || $method == 'GET') {
152
+ $header_response = $response;
153
+
154
+ # If it's a GET request, we want to only parse the header part.
155
+ if($method == 'GET') {
156
+ $header_response = substr($response, 0, strpos($response, "\r\n\r\n"));
157
+ }
158
+
159
+ $headers = array();
160
+ foreach(explode("\n", $header_response) as $header) {
161
+ $pos = strpos($header,':');
162
+ if ($pos !== false) {
163
+ $name = strtolower(trim(substr($header, 0, $pos)));
164
+ $headers[$name] = trim(substr($header, $pos+1));
165
+ }
166
+ }
167
+
168
+ if($update_claimed_id) {
169
+ # Updating claimed_id in case of redirections.
170
+ $effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
171
+ if($effective_url != $url) {
172
+ $this->identity = $this->claimed_id = $effective_url;
173
+ }
174
+ }
175
+
176
+ if($method == 'HEAD') {
177
+ return $headers;
178
+ } else {
179
+ $this->headers = $headers;
180
+ }
181
+ }
182
+
183
+ if (curl_errno($curl)) {
184
+ throw new ErrorException(curl_error($curl), curl_errno($curl));
185
+ }
186
+
187
+ return $response;
188
+ }
189
+
190
+ protected function parse_header_array($array, $update_claimed_id)
191
+ {
192
+ $headers = array();
193
+ foreach($array as $header) {
194
+ $pos = strpos($header,':');
195
+ if ($pos !== false) {
196
+ $name = strtolower(trim(substr($header, 0, $pos)));
197
+ $headers[$name] = trim(substr($header, $pos+1));
198
+
199
+ # Following possible redirections. The point is just to have
200
+ # claimed_id change with them, because the redirections
201
+ # are followed automatically.
202
+ # We ignore redirections with relative paths.
203
+ # If any known provider uses them, file a bug report.
204
+ if($name == 'location' && $update_claimed_id) {
205
+ if(strpos($headers[$name], 'http') === 0) {
206
+ $this->identity = $this->claimed_id = $headers[$name];
207
+ } elseif($headers[$name][0] == '/') {
208
+ $parsed_url = parse_url($this->claimed_id);
209
+ $this->identity =
210
+ $this->claimed_id = $parsed_url['scheme'] . '://'
211
+ . $parsed_url['host']
212
+ . $headers[$name];
213
+ }
214
+ }
215
+ }
216
+ }
217
+ return $headers;
218
+ }
219
+
220
+ protected function request_streams($url, $method='GET', $params=array(), $update_claimed_id)
221
+ {
222
+ if(!$this->hostExists($url)) {
223
+ throw new ErrorException("Could not connect to $url.", 404);
224
+ }
225
+
226
+ $params = http_build_query($params, '', '&');
227
+ switch($method) {
228
+ case 'GET':
229
+ $opts = array(
230
+ 'http' => array(
231
+ 'method' => 'GET',
232
+ 'header' => 'Accept: application/xrds+xml, */*',
233
+ 'ignore_errors' => true,
234
+ ), 'ssl' => array(
235
+ 'CN_match' => parse_url($url, PHP_URL_HOST),
236
+ ),
237
+ );
238
+ $url = $url . ($params ? '?' . $params : '');
239
+ break;
240
+ case 'POST':
241
+ $opts = array(
242
+ 'http' => array(
243
+ 'method' => 'POST',
244
+ 'header' => 'Content-type: application/x-www-form-urlencoded',
245
+ 'content' => $params,
246
+ 'ignore_errors' => true,
247
+ ), 'ssl' => array(
248
+ 'CN_match' => parse_url($url, PHP_URL_HOST),
249
+ ),
250
+ );
251
+ break;
252
+ case 'HEAD':
253
+ # We want to send a HEAD request,
254
+ # but since get_headers doesn't accept $context parameter,
255
+ # we have to change the defaults.
256
+ $default = stream_context_get_options(stream_context_get_default());
257
+ stream_context_get_default(
258
+ array(
259
+ 'http' => array(
260
+ 'method' => 'HEAD',
261
+ 'header' => 'Accept: application/xrds+xml, */*',
262
+ 'ignore_errors' => true,
263
+ ), 'ssl' => array(
264
+ 'CN_match' => parse_url($url, PHP_URL_HOST),
265
+ ),
266
+ )
267
+ );
268
+
269
+ $url = $url . ($params ? '?' . $params : '');
270
+ $headers = get_headers ($url);
271
+ if(!$headers) {
272
+ return array();
273
+ }
274
+
275
+ if(intval(substr($headers[0], strlen('HTTP/1.1 '))) == 405) {
276
+ # The server doesn't support HEAD, so let's emulate it with
277
+ # a GET.
278
+ $args = func_get_args();
279
+ $args[1] = 'GET';
280
+ call_user_func_array(array($this, 'request_streams'), $args);
281
+ return $this->headers;
282
+ }
283
+
284
+ $headers = $this->parse_header_array($headers, $update_claimed_id);
285
+
286
+ # And restore them.
287
+ stream_context_get_default($default);
288
+ return $headers;
289
+ }
290
+
291
+ if($this->verify_peer) {
292
+ $opts['ssl'] += array(
293
+ 'verify_peer' => true,
294
+ 'capath' => $this->capath,
295
+ 'cafile' => $this->cainfo,
296
+ );
297
+ }
298
+
299
+ $context = stream_context_create ($opts);
300
+ $data = file_get_contents($url, false, $context);
301
+ # This is a hack for providers who don't support HEAD requests.
302
+ # It just creates the headers array for the last request in $this->headers.
303
+ if(isset($http_response_header)) {
304
+ $this->headers = $this->parse_header_array($http_response_header, $update_claimed_id);
305
+ }
306
+
307
+ return $data;
308
+ }
309
+
310
+ protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
311
+ {
312
+ if (function_exists('curl_init')
313
+ && (!in_array('https', stream_get_wrappers()) || !ini_get('safe_mode') && !ini_get('open_basedir'))
314
+ ) {
315
+ return $this->request_curl($url, $method, $params, $update_claimed_id);
316
+ }
317
+ return $this->request_streams($url, $method, $params, $update_claimed_id);
318
+ }
319
+
320
+ protected function build_url($url, $parts)
321
+ {
322
+ if (isset($url['query'], $parts['query'])) {
323
+ $parts['query'] = $url['query'] . '&' . $parts['query'];
324
+ }
325
+
326
+ $url = $parts + $url;
327
+ $url = $url['scheme'] . '://'
328
+ . (empty($url['username'])?''
329
+ :(empty($url['password'])? "{$url['username']}@"
330
+ :"{$url['username']}:{$url['password']}@"))
331
+ . $url['host']
332
+ . (empty($url['port'])?'':":{$url['port']}")
333
+ . (empty($url['path'])?'':$url['path'])
334
+ . (empty($url['query'])?'':"?{$url['query']}")
335
+ . (empty($url['fragment'])?'':"#{$url['fragment']}");
336
+ return $url;
337
+ }
338
+
339
+ /**
340
+ * Helper function used to scan for <meta>/<link> tags and extract information
341
+ * from them
342
+ */
343
+ protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
344
+ {
345
+ preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
346
+ preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
347
+
348
+ $result = array_merge($matches1[1], $matches2[1]);
349
+ return empty($result)?false:$result[0];
350
+ }
351
+
352
+ /**
353
+ * Performs Yadis and HTML discovery. Normally not used.
354
+ * @param $url Identity URL.
355
+ * @return String OP Endpoint (i.e. OpenID provider address).
356
+ * @throws ErrorException
357
+ */
358
+ function discover($url)
359
+ {
360
+ if (!$url) throw new ErrorException('No identity supplied.');
361
+ # Use xri.net proxy to resolve i-name identities
362
+ if (!preg_match('#^https?:#', $url)) {
363
+ $url = "https://xri.net/$url";
364
+ }
365
+
366
+ # We save the original url in case of Yadis discovery failure.
367
+ # It can happen when we'll be lead to an XRDS document
368
+ # which does not have any OpenID2 services.
369
+ $originalUrl = $url;
370
+
371
+ # A flag to disable yadis discovery in case of failure in headers.
372
+ $yadis = true;
373
+
374
+ # We'll jump a maximum of 5 times, to avoid endless redirections.
375
+ for ($i = 0; $i < 5; $i ++) {
376
+ if ($yadis) {
377
+ $headers = $this->request($url, 'HEAD', array(), true);
378
+
379
+ $next = false;
380
+ if (isset($headers['x-xrds-location'])) {
381
+ $url = $this->build_url(parse_url($url), parse_url(trim($headers['x-xrds-location'])));
382
+ $next = true;
383
+ }
384
+
385
+ if (isset($headers['content-type'])
386
+ && (strpos($headers['content-type'], 'application/xrds+xml') !== false
387
+ || strpos($headers['content-type'], 'text/xml') !== false)
388
+ ) {
389
+ # Apparently, some providers return XRDS documents as text/html.
390
+ # While it is against the spec, allowing this here shouldn't break
391
+ # compatibility with anything.
392
+ # ---
393
+ # Found an XRDS document, now let's find the server, and optionally delegate.
394
+ $content = $this->request($url, 'GET');
395
+
396
+ preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
397
+ foreach($m[1] as $content) {
398
+ $content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
399
+
400
+ # OpenID 2
401
+ $ns = preg_quote('http://specs.openid.net/auth/2.0/', '#');
402
+ if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
403
+ if ($type[1] == 'server') $this->identifier_select = true;
404
+
405
+ preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
406
+ preg_match('#<(Local|Canonical)ID>(.*)</\1ID>#', $content, $delegate);
407
+ if (empty($server)) {
408
+ return false;
409
+ }
410
+ # Does the server advertise support for either AX or SREG?
411
+ $this->ax = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
412
+ $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
413
+ || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
414
+
415
+ $server = $server[1];
416
+ if (isset($delegate[2])) $this->identity = trim($delegate[2]);
417
+ $this->version = 2;
418
+
419
+ $this->server = $server;
420
+ // exit($server);
421
+ return $server;
422
+ }
423
+
424
+ # OpenID 1.1
425
+ $ns = preg_quote('http://openid.net/signon/1.1', '#');
426
+ if (preg_match('#<Type>\s*'.$ns.'\s*</Type>#s', $content)) {
427
+
428
+ preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
429
+ preg_match('#<.*?Delegate>(.*)</.*?Delegate>#', $content, $delegate);
430
+ if (empty($server)) {
431
+ return false;
432
+ }
433
+ # AX can be used only with OpenID 2.0, so checking only SREG
434
+ $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
435
+ || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
436
+
437
+ $server = $server[1];
438
+ if (isset($delegate[1])) $this->identity = $delegate[1];
439
+ $this->version = 1;
440
+
441
+ $this->server = $server;
442
+ return $server;
443
+ }
444
+ }
445
+
446
+ $next = true;
447
+ $yadis = false;
448
+ $url = $originalUrl;
449
+ $content = null;
450
+ break;
451
+ }
452
+ if ($next) continue;
453
+
454
+ # There are no relevant information in headers, so we search the body.
455
+ $content = $this->request($url, 'GET', array(), true);
456
+
457
+ if (isset($this->headers['x-xrds-location'])) {
458
+ $url = $this->build_url(parse_url($url), parse_url(trim($this->headers['x-xrds-location'])));
459
+ continue;
460
+ }
461
+
462
+ $location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content');
463
+ if ($location) {
464
+ $url = $this->build_url(parse_url($url), parse_url($location));
465
+ continue;
466
+ }
467
+ }
468
+
469
+ if (!$content) $content = $this->request($url, 'GET');
470
+
471
+ # At this point, the YADIS Discovery has failed, so we'll switch
472
+ # to openid2 HTML discovery, then fallback to openid 1.1 discovery.
473
+ $server = $this->htmlTag($content, 'link', 'rel', 'openid2.provider', 'href');
474
+ $delegate = $this->htmlTag($content, 'link', 'rel', 'openid2.local_id', 'href');
475
+ $this->version = 2;
476
+
477
+ if (!$server) {
478
+ # The same with openid 1.1
479
+ $server = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href');
480
+ $delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href');
481
+ $this->version = 1;
482
+ }
483
+
484
+ if ($server) {
485
+ # We found an OpenID2 OP Endpoint
486
+ if ($delegate) {
487
+ # We have also found an OP-Local ID.
488
+ $this->identity = $delegate;
489
+ }
490
+ $this->server = $server;
491
+ return $server;
492
+ }
493
+
494
+ throw new ErrorException("No OpenID Server found at $url", 404);
495
+ }
496
+ throw new ErrorException('Endless redirection!', 500);
497
+ }
498
+
499
+ protected function sregParams()
500
+ {
501
+
502
+ $params = array();
503
+ # We always use SREG 1.1, even if the server is advertising only support for 1.0.
504
+ # That's because it's fully backwards compatibile with 1.0, and some providers
505
+ # advertise 1.0 even if they accept only 1.1. One such provider is myopenid.com
506
+ $params['openid.ns.sreg'] = 'http://openid.net/extensions/sreg/1.1';
507
+ if ($this->required) {
508
+ $params['openid.sreg.required'] = array();
509
+ foreach ($this->required as $required) {
510
+ if (!isset(self::$ax_to_sreg[$required])) continue;
511
+ $params['openid.sreg.required'][] = self::$ax_to_sreg[$required];
512
+ }
513
+ $params['openid.sreg.required'] = implode(',', $params['openid.sreg.required']);
514
+ }
515
+
516
+ if ($this->optional) {
517
+ $params['openid.sreg.optional'] = array();
518
+ foreach ($this->optional as $optional) {
519
+ if (!isset(self::$ax_to_sreg[$optional])) continue;
520
+ $params['openid.sreg.optional'][] = self::$ax_to_sreg[$optional];
521
+ }
522
+ $params['openid.sreg.optional'] = implode(',', $params['openid.sreg.optional']);
523
+ }
524
+
525
+
526
+ return $params;
527
+ }
528
+
529
+ protected function axParams()
530
+ {
531
+ $params = array();
532
+ if ($this->required || $this->optional) {
533
+ $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
534
+ $params['openid.ax.mode'] = 'fetch_request';
535
+ $this->aliases = array();
536
+ $counts = array();
537
+ $required = array();
538
+ $optional = array();
539
+ foreach (array('required','optional') as $type) {
540
+ foreach ($this->$type as $alias => $field) {
541
+ if (is_int($alias)) $alias = strtr($field, '/', '_');
542
+ $this->aliases[$alias] = 'http://axschema.org/' . $field;
543
+ if (empty($counts[$alias])) $counts[$alias] = 0;
544
+ $counts[$alias] += 1;
545
+ ${$type}[] = $alias;
546
+ }
547
+ }
548
+ foreach ($this->aliases as $alias => $ns) {
549
+ $params['openid.ax.type.' . $alias] = $ns;
550
+ }
551
+ foreach ($counts as $alias => $count) {
552
+ if ($count == 1) continue;
553
+ $params['openid.ax.count.' . $alias] = $count;
554
+ }
555
+
556
+ # Don't send empty ax.requied and ax.if_available.
557
+ # Google and possibly other providers refuse to support ax when one of these is empty.
558
+ if($required) {
559
+ $params['openid.ax.required'] = implode(',', $required);
560
+ }
561
+ if($optional) {
562
+ $params['openid.ax.if_available'] = implode(',', $optional);
563
+ }
564
+ }
565
+ return $params;
566
+ }
567
+
568
+ protected function authUrl_v1($immediate)
569
+ {
570
+ $returnUrl = $this->returnUrl;
571
+ # If we have an openid.delegate that is different from our claimed id,
572
+ # we need to somehow preserve the claimed id between requests.
573
+ # The simplest way is to just send it along with the return_to url.
574
+ if($this->identity != $this->claimed_id) {
575
+ $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
576
+ }
577
+
578
+ $params = array(
579
+ 'openid.return_to' => $returnUrl,
580
+ 'openid.mode' => $immediate ? 'checkid_immediate' : 'checkid_setup',
581
+ 'openid.identity' => $this->identity,
582
+ 'openid.trust_root' => $this->trustRoot,
583
+ ) + $this->sregParams();
584
+
585
+ return $this->build_url(parse_url($this->server)
586
+ , array('query' => http_build_query($params, '', '&')));
587
+ }
588
+
589
+ function authUrl_v2($immediate=false)
590
+ {
591
+
592
+ $params = array(
593
+ 'openid.ns' => 'http://specs.openid.net/auth/2.0',
594
+ 'openid.mode' => $immediate ? 'checkid_immediate' : 'checkid_setup',
595
+ 'openid.return_to' => $this->returnUrl,
596
+ 'openid.realm' => $this->trustRoot,
597
+ );
598
+ if ($this->ax) {
599
+ $params += $this->axParams();
600
+ }
601
+ if ($this->sreg) {
602
+ $params += $this->sregParams();
603
+ }
604
+ if (!$this->ax && !$this->sreg) {
605
+ # If OP doesn't advertise either SREG, nor AX, let's send them both
606
+ # in worst case we don't get anything in return.
607
+ $params += $this->axParams() + $this->sregParams();
608
+ }
609
+
610
+ if ($this->identifier_select) {
611
+ $params['openid.identity'] = $params['openid.claimed_id']
612
+ = 'http://specs.openid.net/auth/2.0/identifier_select';
613
+ } else {
614
+ $params['openid.identity'] = $this->identity;
615
+ $params['openid.claimed_id'] = $this->claimed_id;
616
+ }
617
+
618
+
619
+ return $this->build_url(parse_url($this->server)
620
+ , array('query' => http_build_query($params, '', '&')));
621
+
622
+
623
+
624
+ }
625
+
626
+ /**
627
+ * Returns authentication url. Usually, you want to redirect your user to it.
628
+ * @return String The authentication url.
629
+ * @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
630
+ * @throws ErrorException
631
+ */
632
+ function authUrl($immediate = false)
633
+ {
634
+
635
+
636
+ if ($this->setup_url && !$immediate) return $this->setup_url;
637
+ if (!$this->server) { $this->discover($this->identity); }
638
+
639
+ if ($this->version == 2) {
640
+ return $this->authUrl_v2($immediate);
641
+ }
642
+ return $this->authUrl_v1($immediate);
643
+ }
644
+
645
+ /**
646
+ * Performs OpenID verification with the OP.
647
+ * @return Bool Whether the verification was successful.
648
+ * @throws ErrorException
649
+ */
650
+ function validate()
651
+ {
652
+ # If the request was using immediate mode, a failure may be reported
653
+ # by presenting user_setup_url (for 1.1) or reporting
654
+ # mode 'setup_needed' (for 2.0). Also catching all modes other than
655
+ # id_res, in order to avoid throwing errors.
656
+ if(isset($this->data['openid_user_setup_url'])) {
657
+ $this->setup_url = $this->data['openid_user_setup_url'];
658
+ return false;
659
+ }
660
+ if($this->mode != 'id_res') {
661
+ return false;
662
+ }
663
+
664
+ $this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
665
+ $params = array(
666
+ 'openid.assoc_handle' => $this->data['openid_assoc_handle'],
667
+ 'openid.signed' => $this->data['openid_signed'],
668
+ 'openid.sig' => $this->data['openid_sig'],
669
+ );
670
+
671
+ if (isset($this->data['openid_ns'])) {
672
+ # We're dealing with an OpenID 2.0 server, so let's set an ns
673
+ # Even though we should know location of the endpoint,
674
+ # we still need to verify it by discovery, so $server is not set here
675
+ $params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
676
+ } elseif (isset($this->data['openid_claimed_id'])
677
+ && $this->data['openid_claimed_id'] != $this->data['openid_identity']
678
+ ) {
679
+ # If it's an OpenID 1 provider, and we've got claimed_id,
680
+ # we have to append it to the returnUrl, like authUrl_v1 does.
681
+ $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
682
+ . 'openid.claimed_id=' . $this->claimed_id;
683
+ }
684
+
685
+ if ($this->data['openid_return_to'] != $this->returnUrl) {
686
+ # The return_to url must match the url of current request.
687
+ # I'm assuing that noone will set the returnUrl to something that doesn't make sense.
688
+ return false;
689
+ }
690
+
691
+ $server = $this->discover($this->claimed_id);
692
+
693
+ foreach (explode(',', $this->data['openid_signed']) as $item) {
694
+ # Checking whether magic_quotes_gpc is turned on, because
695
+ # the function may fail if it is. For example, when fetching
696
+ # AX namePerson, it might containg an apostrophe, which will be escaped.
697
+ # In such case, validation would fail, since we'd send different data than OP
698
+ # wants to verify. stripslashes() should solve that problem, but we can't
699
+ # use it when magic_quotes is off.
700
+ $value = $this->data['openid_' . str_replace('.','_',$item)];
701
+ $params['openid.' . $item] = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ? stripslashes($value) : $value;
702
+
703
+ }
704
+
705
+ $params['openid.mode'] = 'check_authentication';
706
+
707
+ $response = $this->request($server, 'POST', $params);
708
+
709
+ return preg_match('/is_valid\s*:\s*true/i', $response);
710
+ }
711
+
712
+ protected function getAxAttributes()
713
+ {
714
+ $alias = null;
715
+ if (isset($this->data['openid_ns_ax'])
716
+ && $this->data['openid_ns_ax'] != 'http://openid.net/srv/ax/1.0'
717
+ ) { # It's the most likely case, so we'll check it before
718
+ $alias = 'ax';
719
+ } else {
720
+ # 'ax' prefix is either undefined, or points to another extension,
721
+ # so we search for another prefix
722
+ foreach ($this->data as $key => $val) {
723
+ if (substr($key, 0, strlen('openid_ns_')) == 'openid_ns_'
724
+ && $val == 'http://openid.net/srv/ax/1.0'
725
+ ) {
726
+ $alias = substr($key, strlen('openid_ns_'));
727
+ break;
728
+ }
729
+ }
730
+ }
731
+ if (!$alias) {
732
+ # An alias for AX schema has not been found,
733
+ # so there is no AX data in the OP's response
734
+ return array();
735
+ }
736
+
737
+ $attributes = array();
738
+ foreach (explode(',', $this->data['openid_signed']) as $key) {
739
+ $keyMatch = $alias . '.value.';
740
+ if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
741
+ continue;
742
+ }
743
+ $key = substr($key, strlen($keyMatch));
744
+ if (!isset($this->data['openid_' . $alias . '_type_' . $key])) {
745
+ # OP is breaking the spec by returning a field without
746
+ # associated ns. This shouldn't happen, but it's better
747
+ # to check, than cause an E_NOTICE.
748
+ continue;
749
+ }
750
+ $value = $this->data['openid_' . $alias . '_value_' . $key];
751
+ $key = substr($this->data['openid_' . $alias . '_type_' . $key],
752
+ strlen('http://axschema.org/'));
753
+
754
+ $attributes[$key] = $value;
755
+ }
756
+ return $attributes;
757
+ }
758
+
759
+ protected function getSregAttributes()
760
+ {
761
+ $attributes = array();
762
+ $sreg_to_ax = array_flip(self::$ax_to_sreg);
763
+ foreach (explode(',', $this->data['openid_signed']) as $key) {
764
+ $keyMatch = 'sreg.';
765
+ if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
766
+ continue;
767
+ }
768
+ $key = substr($key, strlen($keyMatch));
769
+ if (!isset($sreg_to_ax[$key])) {
770
+ # The field name isn't part of the SREG spec, so we ignore it.
771
+ continue;
772
+ }
773
+ $attributes[$sreg_to_ax[$key]] = $this->data['openid_sreg_' . $key];
774
+ }
775
+ return $attributes;
776
+ }
777
+
778
+ /**
779
+ * Gets AX/SREG attributes provided by OP. should be used only after successful validaton.
780
+ * Note that it does not guarantee that any of the required/optional parameters will be present,
781
+ * or that there will be no other attributes besides those specified.
782
+ * In other words. OP may provide whatever information it wants to.
783
+ * * SREG names will be mapped to AX names.
784
+ * * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'
785
+ * @see http://www.axschema.org/types/
786
+ */
787
+ function getAttributes()
788
+ {
789
+ if (isset($this->data['openid_ns'])
790
+ && $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0'
791
+ ) { # OpenID 2.0
792
+ # We search for both AX and SREG attributes, with AX taking precedence.
793
+ return $this->getAxAttributes() + $this->getSregAttributes();
794
+ }
795
+ return $this->getSregAttributes();
796
+ }
797
+ }
app/code/local/Soclever/Sociallogin/etc/config.xml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Soclever SocialLogin Extension
5
+ *
6
+ * @category Extension
7
+ * @copyright Copyright (c) 2014 Soclever (https://www.socleversocial.com)
8
+ * @author Socleverteam
9
+ * @license GPL
10
+ * @terms of use https://www.socleversocial.com
11
+ * @version Release: 1.0
12
+ * @since Available since Release 1.0
13
+ */
14
+ -->
15
+
16
+ <config>
17
+ <modules>
18
+ <Soclever_Sociallogin>
19
+ <version>1.1.1</version>
20
+ </Soclever_Sociallogin>
21
+ </modules>
22
+ <default>
23
+ <sociallogin_options>
24
+ <displaysettings>
25
+ <buttonstyle>ic</buttonstyle>
26
+ </displaysettings>
27
+ </sociallogin_options>
28
+ </default>
29
+
30
+ <frontend>
31
+ <routers>
32
+ <soclever_sociallogin>
33
+ <use>standard</use>
34
+ <args>
35
+ <module>Soclever_Sociallogin</module>
36
+ <frontName>soclever_sociallogin</frontName>
37
+ </args>
38
+ </soclever_sociallogin>
39
+
40
+ </routers>
41
+ <layout>
42
+ <updates>
43
+ <Soclever_Sociallogin>
44
+ <file>sociallogin.xml</file>
45
+ </Soclever_Sociallogin>
46
+ </updates>
47
+ </layout>
48
+ </frontend>
49
+ <admin>
50
+ <routers>
51
+ <sociallogin>
52
+ <use>admin</use>
53
+ <args>
54
+ <module>Soclever_Sociallogin</module>
55
+ <frontName>Sociallogin admin</frontName>
56
+ </args>
57
+ </sociallogin>
58
+ </routers>
59
+ </admin>
60
+ <adminhtml>
61
+ <acl>
62
+ <resources>
63
+ <admin>
64
+ <children>
65
+ <system>
66
+ <children>
67
+ <config>
68
+ <children>
69
+ <sociallogin_options>
70
+ <title>Store Social Login Module Section</title>
71
+ </sociallogin_options>
72
+ </children>
73
+ </config>
74
+ </children>
75
+ </system>
76
+ </children>
77
+ </admin>
78
+ </resources>
79
+ </acl>
80
+ </adminhtml>
81
+ <global>
82
+ <models>
83
+ <sociallogin>
84
+ <class>Soclever_Sociallogin_Model</class>
85
+ </sociallogin>
86
+ </models>
87
+ <resources>
88
+ <soclever_sociallogin_setup>
89
+ <setup>
90
+ <module>Soclever_Sociallogin</module>
91
+ </setup>
92
+ <connection>
93
+ <use>core_setup</use>
94
+ </connection>
95
+ </soclever_sociallogin_setup>
96
+ <soclever_sociallogin_write>
97
+ <connection>
98
+ <use>core_write</use>
99
+ </connection>
100
+ </soclever_sociallogin_write>
101
+ <soclever_sociallogin_read>
102
+ <connection>
103
+ <use>core_read</use>
104
+ </connection>
105
+ </soclever_sociallogin_read>
106
+ </resources>
107
+ <blocks>
108
+ <sociallogin>
109
+ <class>Soclever_Sociallogin_Block</class>
110
+ </sociallogin>
111
+ </blocks>
112
+ <helpers>
113
+ <sociallogin>
114
+ <class>Soclever_Sociallogin_Helper</class>
115
+ </sociallogin>
116
+ </helpers>
117
+ </global>
118
+ </config>
app/code/local/Soclever/Sociallogin/etc/system.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <socialloginsetting translate="label" module="sociallogin">
5
+ <label>Soclever Social Login</label>
6
+ <sort_order>3</sort_order>
7
+ </socialloginsetting>
8
+ </tabs>
9
+ <sections>
10
+ <sociallogin_options translate="label" module="sociallogin">
11
+ <label>Soclever Social Login</label>
12
+ <tab>socialloginsetting</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1020</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <apisettings translate="label">
20
+ <label>SocleverSocial Login API Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <scsl_appid translate="label">
28
+ <label>Soclever API Key</label>
29
+ <frontend_type>text</frontend_type>
30
+ <comment><![CDATA[ Socelver API ]]></comment>
31
+ <sort_order>15</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </scsl_appid>
36
+ <scsl_appsecret translate="label">
37
+ <label>Soclever API Secret</label>
38
+ <frontend_type>text</frontend_type>
39
+ <comment><![CDATA[ Socelver API Secret ]]></comment>
40
+ <sort_order>16</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </scsl_appsecret>
45
+ <scsl_siteid translate="label">
46
+ <label>Soclever Client ID</label>
47
+ <frontend_type>text</frontend_type>
48
+ <comment><![CDATA[ Socelver Client ID ]]></comment>
49
+ <sort_order>17</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </scsl_siteid>
54
+ <scsl_validdomain translate="label">
55
+ <label>Soclever Valid Domain</label>
56
+ <frontend_type>text</frontend_type>
57
+ <comment><![CDATA[ Socelver Valid Domain ]]></comment>
58
+ <sort_order>18</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </scsl_validdomain>
63
+ </fields>
64
+ </apisettings>
65
+ <displaysettings translate="label">
66
+ <label>Soclever Social Login Display Settings</label>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>2</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ <fields>
73
+ <buttonstyle translate="label">
74
+ <label>Select Button Style</label>
75
+ <frontend_type>radios</frontend_type>
76
+ <source_model>sociallogin/providers::getbuttonstyles</source_model>
77
+ <sort_order>200</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </buttonstyle>
82
+ <buttonsize translate="label">
83
+ <label>Button Size</label>
84
+ <frontend_type>select</frontend_type>
85
+ <source_model>sociallogin/providers::getsizes</source_model>
86
+ <sort_order>199</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ </buttonsize>
91
+ </fields>
92
+ </displaysettings>
93
+ <currentpreview translate="label">
94
+ <label>Soclever Social Login Preview</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>3</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <fields>
101
+ <previewshow translate="label">
102
+ <label>Chosen Providers and Current Preview</label>
103
+ <frontend_model>sociallogin/adminhtml_positions</frontend_model>
104
+ <comment><![CDATA[Your chosen networks on socleversocial.com dashboard and current preview ]]></comment>
105
+ <sort_order>201</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </previewshow>
110
+ </fields>
111
+ </currentpreview>
112
+ </groups>
113
+ </sociallogin_options>
114
+ </sections>
115
+ </config>
app/design/frontend/base/default/layout/sociallogin.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="1.0.0">
3
+ <default>
4
+ <reference name="head">
5
+ <block type="sociallogin/scslhead" name="sociallogin_head" template="sociallogin/sociallogin_head.phtml" />
6
+ </reference>
7
+ </default>
8
+ <checkout_onepage_index>
9
+ <reference name="checkout.onepage.login.before">
10
+ <block type="sociallogin/scslshow" before="-" name="sociallogin_show">
11
+
12
+ </block>
13
+ </reference>
14
+ </checkout_onepage_index>
15
+ <customer_account_login>
16
+ <reference name="content">
17
+ <block type="sociallogin/scslshow" name="sociallogin_show">
18
+
19
+ </block>
20
+ </reference>
21
+ </customer_account_login>
22
+ </layout>
app/design/frontend/base/default/template/sociallogin/scsl_buttons.phtml ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $site_id=Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid');
3
+ $api_secret=Mage::getStoreConfig('sociallogin_options/apisettings/scsl_appsecret');
4
+ $api_key=Mage::getStoreConfig('sociallogin_options/apisettings/scsl_appid');
5
+
6
+ $valid_data=file_get_contents("https://www.socleversocial.com/dashboard/wp_activate.php?site_id=".$site_id."&api_key=".$api_key."&api_secret=".$api_secret."&csplatform=magentologin&rt=gp");
7
+
8
+ if($valid_data && $valid_data!='0~~0')
9
+ {
10
+ $valid_data_arr=explode("@@@",$valid_data);
11
+ $selectedButtons=Mage::getStoreConfig('sociallogin_options/displaysettings/buttonstyle');
12
+ $selectedProviders="https://www.socleversocial.com/dashboard/img/social_icon/social_login_fc_30.png";
13
+ $btn_style=Mage::getStoreConfig('sociallogin_options/displaysettings/buttonstyle');
14
+ $button_size=Mage::getStoreConfig('sociallogin_options/displaysettings/buttonsize');
15
+ $SITE_URL="https://www.socleversocial.com/dashboard/";
16
+ if($btn_style=="ic") {
17
+ $btn_width=$button_size;
18
+ }
19
+ else if($btn_style=="fc" || $btn_style=="fg")
20
+ {
21
+ if($button_size=="30") {$btn_width="78"; }
22
+ if($button_size=="40") {$btn_width="104"; }
23
+ if($button_size=="50") {$btn_width="130"; }
24
+ if($button_size=="60") {$btn_width="156"; }
25
+ if($button_size=="65") {$btn_width="169"; }
26
+ }
27
+
28
+ $network=explode(",",$valid_data_arr[0]);
29
+ $imgdiv="";
30
+ $img='social_login_'.$btn_style.'_'.$button_size.'.png';
31
+ /*if(in_array('2',$network))
32
+ {
33
+ $bg_position=$btn_width;
34
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px;width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
35
+
36
+
37
+ }
38
+
39
+ if(in_array('4',$network))
40
+ {
41
+ $bg_position=((3)*$btn_width);
42
+
43
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
44
+
45
+
46
+ }
47
+
48
+ if(in_array('7',$network))
49
+ {
50
+ $bg_position=((6)*$btn_width);
51
+
52
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
53
+
54
+
55
+ }
56
+
57
+ if(in_array('13',$network))
58
+ {
59
+ $bg_position=((12)*$btn_width);
60
+
61
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
62
+
63
+
64
+ }
65
+
66
+ if(in_array('15',$network))
67
+ {
68
+ $bg_position=((14)*$btn_width);
69
+
70
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
71
+
72
+ }
73
+
74
+ if(in_array('16',$network))
75
+ {
76
+ $bg_position=((15)*$btn_width); //change when image is added
77
+
78
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
79
+
80
+ }
81
+
82
+ if(in_array('5',$network))
83
+ {
84
+ $bg_position=((4)*$btn_width);
85
+
86
+ $imgdiv .='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
87
+
88
+
89
+ }
90
+ */
91
+
92
+ $fb_div="";
93
+ if(in_array('2',$network))
94
+ {
95
+ $bg_position=$btn_width;
96
+ $fb_div .='<script type="text/javascript">';
97
+ $imgdiv='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
98
+ $fb_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'\',\'login_fb\']);'.PHP_EOL;
99
+ $fb_div .='csbutton.putCsbutton();
100
+ </script>';
101
+
102
+
103
+ }
104
+ $gp_div="";
105
+ if(in_array('4',$network))
106
+ {
107
+ $bg_position=((3)*$btn_width);
108
+ $gp_div .='<script type="text/javascript">';
109
+ $imgdiv='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
110
+ $gp_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'px\',\'login\',\''.$valid_data_arr[1].'\']);'.PHP_EOL;
111
+ $gp_div .='csbutton.putCsbutton();
112
+ </script>';
113
+
114
+ }
115
+ $li_div="";
116
+ if(in_array('7',$network))
117
+ {
118
+ $bg_position=((6)*$btn_width);
119
+ $li_div .='<script type="text/javascript">';
120
+ $imgdiv='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
121
+ $li_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'px\',\'login\',\'li\']);'.PHP_EOL;
122
+ $li_div .='csbutton.putCsbutton();
123
+ </script>';
124
+
125
+ }
126
+ $tw_div="";
127
+ if(in_array('13',$network))
128
+ {
129
+ $bg_position=((12)*$btn_width);
130
+ $tw_div .='<script type="text/javascript">';
131
+ $imgdiv='<div style="float: left; margin-right: 10px; margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
132
+ $tw_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'px\',\'login\',\'twitter\']);'.PHP_EOL;
133
+ $tw_div .='csbutton.putCsbutton();
134
+ </script>';
135
+
136
+ }
137
+ $yh_div="";
138
+ if(in_array('15',$network))
139
+ {
140
+ $bg_position=((14)*$btn_width);
141
+ $yh_div .='<script type="text/javascript">';
142
+ $imgdiv='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
143
+ $yh_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'px\',\'login\',\'yahoo\']);'.PHP_EOL;
144
+ $yh_div .='csbutton.putCsbutton();
145
+ </script>';
146
+
147
+ }
148
+ $pp_div="";
149
+ if(in_array('16',$network))
150
+ {
151
+ $bg_position=((15)*$btn_width); //change when image is added
152
+ $pp_div .='<script type="text/javascript">';
153
+ $imgdiv='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
154
+ $pp_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'px\',\'login\',\'paypal\']);'.PHP_EOL;
155
+ $pp_div .='csbutton.putCsbutton();
156
+ </script>';
157
+
158
+ }
159
+ $ig_div="";
160
+ if(in_array('5',$network))
161
+ {
162
+ $bg_position=((4)*$btn_width);
163
+ $ig_div .='<script type="text/javascript">';
164
+ $imgdiv='<div style="float: left; margin-right: 10px;margin-top: 10px; width: '.$btn_width.'px; height: '.$button_size.'px; background-image: url('.$SITE_URL.'img/social_icon/'.$img.'); background-position: -'.$bg_position.'px 0px;"></div>';
165
+ $ig_div .='csbutton.init([\''.$imgdiv.'\',\''.$btn_width.'px\' ,\''.$button_size.'px\',\'login\',\'instagram\']);'.PHP_EOL;
166
+ $ig_div .='csbutton.putCsbutton();
167
+ </script>';
168
+
169
+ }
170
+
171
+ $imgdiv='<script type="text/javascript" src="https://www.socleversocial.com/dashboard/client_share_js/csloginbuttons_'.$site_id.'.js"></script>'.PHP_EOL.$fb_div.PHP_EOL.$gp_div.PHP_EOL.$li_div.PHP_EOL.$tw_div.PHP_EOL.$yh_div.PHP_EOL.$ig_div.PHP_EOL.$pp_div;
172
+
173
+
174
+ echo '<div style="margin-bottom:20px;width:96%;margin-bottom:10px;border:1px solid #bbb6a5;padding:14px 21px;clear:both;"><div><b>Login by your social profile.</b></div>'.$imgdiv.'<div style="clear: both;text-align:left;padding-top:10px;"><b>Powered by </b><a href="https://www.socleversocial.com/" target="_blank">Socleversocial.com</a></div></div>';
175
+
176
+
177
+ }
178
+ else
179
+ {
180
+ echo"<h1>Please provide valid API setting</h1>";
181
+ }
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+ ?>
app/design/frontend/base/default/template/sociallogin/sociallogin_head.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!Mage::getSingleton('customer/session')->isLoggedIn())
3
+ {
4
+ echo'<script type="text/javascript" src="https://www.socleversocial.com/dashboard/client_share_js/client_'.Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid').'_login.js"></script>'.PHP_EOL.
5
+ '<script type="text/javascript">'.PHP_EOL.
6
+ 'csloginjs.init([\''.Mage::getStoreConfig('sociallogin_options/apisettings/scsl_appid').'\', \''.Mage::getStoreConfig('sociallogin_options/apisettings/scsl_siteid').'\',\''.Mage::getStoreConfig('sociallogin_options/apisettings/scsl_appsecret').'\',\''.Mage::getStoreConfig('sociallogin_options/apisettings/scsl_validdomain').'\']);'.PHP_EOL.
7
+ 'csloginjs.validateCsApi();'.PHP_EOL.
8
+ '</script>'.PHP_EOL;
9
+
10
+ }
11
+ ?>
app/etc/modules/soclever_sociallogin.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Soclever_Sociallogin>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Soclever_Sociallogin>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>soclever_login</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module enables Social Login, User Profile Data &amp; Social Analytics on your Magento site. </summary>
10
+ <description>&lt;h3&gt;SoClever Social Login Facebook connect + other Social networks.&lt;/h3&gt;&#xD;
11
+ &lt;p&gt;SoClevers Social Login is a professionally developed, and FREE. Our Plugin works with Facebook, Google+ LinkedIn, PayPal, Yahoo! &amp; Instagram. Our JavaScript is asynchronous ensuring fast load time, and it&#x2019;s also dynamic so you can A-B test from our dashboard without needing to re-code.&lt;/p&gt;&#xD;
12
+ &lt;p&gt;SoClever&#x2019;s plugin is configured to work with Facebook&#x2019;s new API. No need to upgrade when FQL stops in April 2015. &#xD;
13
+ Customizable designs, size, shape and colour. Select ours or load your own logo designs.&#xD;
14
+ &lt;/p&gt;&#xD;
15
+ &lt;p&gt;Included in this plugin is our Social Buttons and Like bar &#x2013; (link) new tab&#xD;
16
+ PS: You'll need a SoClever API to use it. API Keys are free; paid subscriptions are available for advanced reporting, analytics and demographic data. Download now, Free to try, no contracts or credit card required.&lt;/p&gt;&#xD;
17
+ &lt;p&gt;Thanks for choosing our plugin, feel free to leave a review or contact us for any feedback.&#xA0;If you want to know more about the features we offer, keep reading below. &#xD;
18
+ &#xD;
19
+ &lt;/p&gt;&#xD;
20
+ &lt;h3&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/h3&gt;&#xD;
21
+ &lt;p&gt;&lt;strong&gt;Social Login&#xD;
22
+ &#xD;
23
+ &lt;/strong&gt;&lt;br&gt;&#xD;
24
+ Eliminate registration forms and let your customer / visitors sign-up in few seconds using trusted IDs like Facebook, Twitter, Google, Yahoo, and more. Increase your sign-up rates and start building a loyal customer list today &lt;/p&gt;&#xD;
25
+ &lt;p&gt;&lt;strong&gt;Track Revenue&lt;/strong&gt;&lt;br&gt;&#xD;
26
+ Have an e-commerce site? Track revenue per social user, download customer segments to personalise your messaging. &lt;/p&gt;&#xD;
27
+ &lt;p&gt;&lt;strong&gt;Top Facebook likes&lt;/strong&gt;&lt;br&gt;&#xD;
28
+ Download our reports on top Facebook Liked pages of your customers/visitors, filter to add top revenue customers and their top likes. Quick upload to Facebook to create a new advertising campaign. &lt;/p&gt;&#xD;
29
+ &lt;p&gt;&lt;strong&gt;User Profile Data &amp; Social Analytics&lt;/strong&gt;&lt;br&gt;&#xD;
30
+ Build a rich profile of your customers with our unique reporting dashboard. Get access to full name, email address, DOB, gender, relationship status, home town, place of birth, like, interests and much more with SoClever&#x2019;s social login.&lt;/p&gt;&#xD;
31
+ &lt;p&gt;&lt;strong&gt;Birthday Reports&lt;/strong&gt;&lt;br&gt;&#xD;
32
+ Send a personalised message to your visitors by using our birthday reports. &lt;/p&gt;</description>
33
+ <notes>Version 1.0.1</notes>
34
+ <authors><author><name>Soclever Social</name><user>soclever</user><email>hemang@socleversocial.com</email></author></authors>
35
+ <date>2015-01-12</date>
36
+ <time>05:40:29</time>
37
+ <contents><target name="magelocal"><dir name="Soclever"><dir name="Sociallogin"><dir name="Block"><dir name="Adminhtml"><file name="Help.php" hash="a7c10479a7065e82bbe616eef62e71dd"/><file name="Positions.php" hash="863edf6c7e3a295e3200a62e67b18b6c"/></dir><file name="Scslhead.php" hash="19915d8ad186673c4e068abcd2f700d8"/><file name="Scslshow.php" hash="3e868132953b63c93af6cb7b396b095a"/></dir><dir name="controllers"><file name="IndexController.php" hash="c953787824968b827bfe576a00165c41"/><file name="openid.php" hash="421d5936957b8ddda543b679d1876f04"/></dir><dir name="etc"><file name="config.xml" hash="b45be9b0c6d60cba1178f7b7c71a7916"/><file name="system.xml" hash="e46124b2c3fb57db8b88938469d52449"/></dir><dir name="Helper"><file name="Data.php" hash="89f8191f1442a7e56f7a4d0b54049d3a"/></dir><dir name="Model"><file name="Providers.php" hash="11cee6aa202a18a0a27a7e7526a712c5"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="sociallogin.xml" hash="dcc0306cab6e6018e48bd9ed0519693a"/></dir><dir name="template"><dir name="sociallogin"><file name="scsl_buttons.phtml" hash="e921e12c7b4068cda356b44a90ac14f6"/><file name="sociallogin_head.phtml" hash="0695cf4d2acdaf0ee2971604e016e8b4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="soclever_sociallogin.xml" hash="8f1fa6f55fc92b4474f696f3678c0281"/></dir></target></contents>
38
+ <compatible/>
39
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Magento_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package></required></dependencies>
40
+ </package>