socleverloginsharing - Version 1.2.0

Version Notes

Added Twitter Login Pop Up

Download this release

Release Info

Developer Soclever Social
Extension socleverloginsharing
Version 1.2.0
Comparing to
See all releases


Code changes from version 1.1.0 to 1.2.0

app/code/local/Soclever/Socialloginsharing/Model/Observer.php CHANGED
@@ -1,33 +1,32 @@
1
- <?php
2
- class Soclever_Socialloginsharing_Model_Observer
3
- {
4
-
5
-
6
- public function writejs(Varien_Event_Observer $observer)
7
- {
8
-
9
- $site_id=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid');
10
- $api_secret=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_appsecret');
11
- $api_key=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_appid');
12
-
13
-
14
-
15
- $valid_data=file_get_contents("https://www.socleversocial.com/dashboard/mage_sharelogin_activate.php?site_id=".$site_id."&api_key=".$api_key."&api_secret=".$api_secret."&csplatform=magentologin&type=preview");
16
- if($valid_data!='0')
17
- {
18
- Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/scsl_validated',"1");
19
- Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/valid_networks',$valid_data);
20
-
21
- }
22
- else
23
- {
24
- Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/scsl_validated',"0");
25
- }
26
-
27
-
28
- }
29
-
30
- }
31
-
32
-
33
  ?>
1
+ <?php
2
+ class Soclever_Socialloginsharing_Model_Observer
3
+ {
4
+
5
+
6
+ public function writejs(Varien_Event_Observer $observer)
7
+ {
8
+
9
+ $site_id=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid');
10
+ $api_secret=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_appsecret');
11
+ $api_key=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_appid');
12
+
13
+
14
+ $valid_data=file_get_contents("https://www.socleversocial.com/dashboard/mage_sharelogin_activate.php?site_id=".$site_id."&api_key=".$api_key."&api_secret=".$api_secret."&csplatform=magentologin&type=preview");
15
+ if($valid_data!='0')
16
+ {
17
+ Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/scsl_validated',"1");
18
+ Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/valid_networks',$valid_data);
19
+
20
+ }
21
+ else
22
+ {
23
+ Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/scsl_validated',"0");
24
+ }
25
+
26
+
27
+ }
28
+
29
+ }
30
+
31
+
 
32
  ?>
app/code/local/Soclever/Socialloginsharing/Model/Providers.php CHANGED
@@ -40,6 +40,7 @@ class Soclever_Socialloginsharing_Model_Providers
40
  array('value'=>4, 'label'=>'Google+'),
41
  array('value'=>7, 'label'=>'LinkedIN'),
42
  array('value'=>15, 'label'=>'Yahoo!'),
 
43
  array('value'=>16, 'label'=>'Paypal'),
44
  array('value'=>8, 'label'=>'Microsoft'),
45
  );
40
  array('value'=>4, 'label'=>'Google+'),
41
  array('value'=>7, 'label'=>'LinkedIN'),
42
  array('value'=>15, 'label'=>'Yahoo!'),
43
+ array('value'=>13, 'label'=>'Twitter'),
44
  array('value'=>16, 'label'=>'Paypal'),
45
  array('value'=>8, 'label'=>'Microsoft'),
46
  );
app/code/local/Soclever/Socialloginsharing/controllers/IndexController.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  class Soclever_Socialloginsharing_IndexController extends Mage_Core_Controller_Front_Action
3
  {
4
  public function indexAction()
@@ -9,6 +12,478 @@ class Soclever_Socialloginsharing_IndexController extends Mage_Core_Controller_F
9
  protected function getSession(){
10
  return Mage::getSingleton('customer/session');
11
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  public function fbloginAction()
13
  {
14
 
@@ -142,54 +617,38 @@ $customer = Mage::getModel("customer/customer");
142
  }
143
  $is_from='1';
144
  Mage::getSingleton('core/session')->setSessionVariable($is_from);
145
- ?>
 
 
 
 
146
  <script type="text/javascript">
147
 
148
  setTimeout(function(){
149
 
150
 
151
- window.location.href="<?php echo $redirect_location;?>";
 
152
 
153
  },1000);
154
-
155
- /*setTimeout(function(){
156
-
157
-
158
- window.close();
159
- //window.opener.location = window.opener.window.location;
160
-
161
- /*try{
162
- if(parent.window.opener != null && ! parent.window.opener)
163
- {
164
- alert("good");
165
- }
166
-
167
- }catch(e){ alert("message="+e.description);}
168
- */
169
-
170
- //alert("called redirection=="+top.window.opener.document.URL+"=");
171
- //top.window.location.assign("<?php echo Mage::getBaseUrl();?>customer/account/edit/");
172
-
173
- // top.window.location.href="<?php echo Mage::getBaseUrl();?>customer/account/edit/";
174
- //close();
175
- //return false;
176
- /*if(top.window.opener.document.URL.indexOf('login') > -1)
177
- {
178
- top.window.opener.location.href="<?php echo Mage::getBaseUrl();?>customer/account/edit/";
179
- close();
180
- }
181
- else
182
- {
183
- top.window.opener.location.href="<?php echo Mage::getBaseUrl();?>checkout/onepage/";
184
- close();
185
-
186
- }*/
187
-
188
- /*}, 3000);*/
189
  </script>
190
  <?php
 
 
191
  //echo"<img src='https://www.socleversocial.com/dashboard/images/pw.gif' alt='wait!' title='wait!'>";
192
  $this->getSession()->loginById($customer->getId());
 
 
 
 
 
 
 
 
 
 
 
 
193
  exit;
194
  }
195
  }
@@ -277,7 +736,7 @@ try
277
  {
278
 
279
 
280
- $openid = new LightOpenID($_SERVER['HTTP_HOST']);
281
 
282
 
283
  if(!$openid->mode)
@@ -315,6 +774,7 @@ try
315
  $is_from='5';
316
  Mage::getSingleton('core/session')->setSessionVariable($is_from);
317
  $d = $openid->getAttributes();
 
318
  //echo "https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=".Mage::getStoreConfig('socialloginsharing_options_options/apisettings/scsl_siteid')."&other=".json_encode($d)."";
319
  /*$response_content=file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=".Mage::getStoreConfig('socialloginsharing_options_options/apisettings/scsl_siteid')."&other=".json_encode($d)."");
320
  if($response_content)
1
  <?php
2
+ ini_set("display_errors","1");
3
+ error_reporting(E_ALL);
4
+
5
  class Soclever_Socialloginsharing_IndexController extends Mage_Core_Controller_Front_Action
6
  {
7
  public function indexAction()
12
  protected function getSession(){
13
  return Mage::getSingleton('customer/session');
14
  }
15
+
16
+
17
+ public function twloginAction()
18
+ {
19
+ $site_id=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid');
20
+ if(isset($_GET['lc']) && $_GET['lc']!='')
21
+ {
22
+ setcookie('lc',$_GET['lc'],time()+100,'/');
23
+ setcookie('lch',$_GET['lch'],time()-100,'/');
24
+
25
+ }
26
+ if(isset($_GET['lch']) && $_GET['lch']!='')
27
+ {
28
+ setcookie('lch',$_GET['lch'],time()+100,'/');
29
+ setcookie('lc',$_GET['lc'],time()-100,'/');
30
+
31
+ }
32
+ if(isset($_POST['submit']) && $_POST['submit']=='Login' )
33
+ {
34
+ $this->scsl_general_login($_POST['response_str'],'4',$_POST['email']);
35
+
36
+ exit;
37
+ }
38
+
39
+
40
+ $get_fb=file_get_contents("https://www.socleversocial.com/dashboard/get_fb_data.php?siteid=".Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid')."&is_tw=1");
41
+
42
+ $my_Api=explode("~",$get_fb);
43
+ if($my_Api[0]!='0')
44
+ {
45
+
46
+ require('http.php');
47
+ require('oauth_client.php');
48
+ $client = new oauth_client_class;
49
+ $client->server = 'Twitter';
50
+ $client->redirect_uri = ''.Mage::getBaseUrl().'soclever_socialloginsharing/index/twlogin';
51
+
52
+ $client->client_id = $my_Api[0];
53
+ $application_line = __LINE__;
54
+ $client->client_secret = $my_Api[1];
55
+
56
+
57
+
58
+ if(strlen($client->client_id) == 0
59
+ || strlen($client->client_secret) == 0)
60
+ die('twitter failed.');
61
+
62
+ /* API permissions
63
+ */
64
+ $client->scope = 'wl.basic wl.emails wl.birthday';
65
+ if(($success = $client->Initialize()))
66
+ {
67
+ if(($success = $client->Process()))
68
+ {
69
+ if(strlen($client->authorization_error))
70
+ {
71
+ $client->error = $client->authorization_error;
72
+ exit($client->error);
73
+ $success = false;
74
+ }
75
+ elseif(strlen($client->access_token))
76
+ {
77
+ $success = $client->CallAPI(
78
+ 'https://api.twitter.com/'. '1.1/account/'. 'verify_credentials.json',
79
+ 'GET', array(), array('FailOnAccessError'=>true), $user);
80
+ }
81
+ }
82
+ $success = $client->Finalize($success);
83
+ }
84
+ if($client->exit)
85
+ {
86
+ exit('82');
87
+ }
88
+ if($success)
89
+ {
90
+
91
+ $your_data=json_encode($user);
92
+ $content=json_decode($your_data);
93
+ $twitter_arr=array();
94
+ $twitter_arr['full_name']=$content->name;
95
+ $twitter_arr['profile_id']=$content->id;
96
+ $twitter_arr['screen_name']=$content->screen_name;
97
+ $twitter_arr['location']=$content->location;
98
+ $twitter_arr['description']=$content->description;
99
+ $twitter_arr['following_count']=$content->friends_count;
100
+ $twitter_arr['follower_count']=$content->followers_count;
101
+ $twitter_arr['tweet_count']=$content->statuses_count;
102
+ $twitter_arr['is_verified']=$content->verified;
103
+ $twitter_arr['lang']=$content->lang;
104
+ $twitter_arr['profile_pic']=$content->profile_image_url;
105
+ $twitter_arr['time_zone']=$content->time_zone;
106
+
107
+
108
+
109
+ $chk_twitter=file_get_contents("https://www.socleversocial.com/dashboard/track_twitter.php?site_id=".$site_id."&twitter_id=".$twitter_arr['profile_id']."&action=chk_tw");
110
+ //$chk_twitter='1';
111
+ if($chk_twitter=='0')
112
+ {
113
+ ?>
114
+ <style>
115
+ #container_demo{
116
+ text-align: left;
117
+ margin: 0;
118
+ padding: 0;
119
+ margin: 0 auto;
120
+ font-family: "Trebuchet MS","Myriad Pro",Arial,sans-serif;
121
+ }
122
+
123
+ #wrapper{
124
+
125
+ right: 0px;
126
+ height: 400px;
127
+ margin: 0px auto;
128
+
129
+ position: relative;
130
+ }
131
+ #wrapper a{
132
+ color: rgb(95, 155, 198);
133
+ text-decoration: underline;
134
+ }
135
+
136
+ #wrapper h1{
137
+ font-size: 48px;
138
+ color: rgb(6, 106, 117);
139
+ padding: 2px 0 10px 0;
140
+ font-family: 'FranchiseRegular','Arial Narrow',Arial,sans-serif;
141
+ font-weight: bold;
142
+ text-align: center;
143
+ padding-bottom: 30px;
144
+ }
145
+
146
+ #wrapper h1{
147
+ background: -webkit-repeating-linear-gradient(-45deg,
148
+ rgb(18, 83, 93) ,
149
+ rgb(18, 83, 93) 20px,
150
+ rgb(64, 111, 118) 20px,
151
+ rgb(64, 111, 118) 40px,
152
+ rgb(18, 83, 93) 40px);
153
+ -webkit-text-fill-color: transparent;
154
+ -webkit-background-clip: text;
155
+ }
156
+ #wrapper h1:after{
157
+ content: ' ';
158
+ display: block;
159
+ width: 100%;
160
+ height: 2px;
161
+ margin-top: 10px;
162
+ background: -moz-linear-gradient(left, rgba(147,184,189,0) 0%, rgba(147,184,189,0.8) 20%, rgba(147,184,189,1) 53%, rgba(147,184,189,0.8) 79%, rgba(147,184,189,0) 100%);
163
+ background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(147,184,189,0)), color-stop(20%,rgba(147,184,189,0.8)), color-stop(53%,rgba(147,184,189,1)), color-stop(79%,rgba(147,184,189,0.8)), color-stop(100%,rgba(147,184,189,0)));
164
+ background: -webkit-linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
165
+ background: -o-linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
166
+ background: -ms-linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
167
+ background: linear-gradient(left, rgba(147,184,189,0) 0%,rgba(147,184,189,0.8) 20%,rgba(147,184,189,1) 53%,rgba(147,184,189,0.8) 79%,rgba(147,184,189,0) 100%);
168
+ }
169
+
170
+ #wrapper p{
171
+ margin-bottom:15px;
172
+ }
173
+ #wrapper p:first-child{
174
+ margin: 0px;
175
+ }
176
+ #wrapper label{
177
+ color: rgb(64, 92, 96);
178
+ position: relative;
179
+ }
180
+
181
+ /**** advanced input styling ****/
182
+ /* placeholder */
183
+ ::-webkit-input-placeholder {
184
+ color: rgb(190, 188, 188);
185
+ font-style: italic;
186
+ }
187
+ input:-moz-placeholder,
188
+ textarea:-moz-placeholder{
189
+ color: rgb(190, 188, 188);
190
+ font-style: italic;
191
+ }
192
+ input {
193
+ outline: none;
194
+ }
195
+
196
+ /* all the input except submit and checkbox */
197
+ #wrapper input:not([type="checkbox"]){
198
+ width: 92%;
199
+ margin-top: 4px;
200
+ padding: 10px 5px 10px 32px;
201
+ border: 1px solid rgb(178, 178, 178);
202
+ -webkit-appearance: textfield;
203
+ -webkit-box-sizing: content-box;
204
+ -moz-box-sizing : content-box;
205
+ box-sizing : content-box;
206
+ -webkit-border-radius: 3px;
207
+ -moz-border-radius: 3px;
208
+ border-radius: 3px;
209
+ -webkit-box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.6) inset;
210
+ -moz-box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.6) inset;
211
+ box-shadow: 0px 1px 4px 0px rgba(168, 168, 168, 0.6) inset;
212
+ -webkit-transition: all 0.2s linear;
213
+ -moz-transition: all 0.2s linear;
214
+ -o-transition: all 0.2s linear;
215
+ transition: all 0.2s linear;
216
+ }
217
+
218
+ /*styling both submit buttons */
219
+ #wrapper p.button input{
220
+ width: 30%;
221
+ cursor: pointer;
222
+ background: rgb(61, 157, 179);
223
+ padding: 8px 5px;
224
+ font-family: 'BebasNeueRegular','Arial Narrow',Arial,sans-serif;
225
+ color: #fff;
226
+ font-size: 24px;
227
+ border: 1px solid rgb(28, 108, 122);
228
+ margin-bottom: 10px;
229
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
230
+ -webkit-border-radius: 3px;
231
+ -moz-border-radius: 3px;
232
+ border-radius: 3px;
233
+ -webkit-box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.07) inset,
234
+ 0px 0px 0px 3px rgb(254, 254, 254),
235
+ 0px 5px 3px 3px rgb(210, 210, 210);
236
+ -moz-box-shadow:0px 1px 6px 4px rgba(0, 0, 0, 0.07) inset,
237
+ 0px 0px 0px 3px rgb(254, 254, 254),
238
+ 0px 5px 3px 3px rgb(210, 210, 210);
239
+ box-shadow:0px 1px 6px 4px rgba(0, 0, 0, 0.07) inset,
240
+ 0px 0px 0px 3px rgb(254, 254, 254),
241
+ 0px 5px 3px 3px rgb(210, 210, 210);
242
+ -webkit-transition: all 0.2s linear;
243
+ -moz-transition: all 0.2s linear;
244
+ -o-transition: all 0.2s linear;
245
+ transition: all 0.2s linear;
246
+ }
247
+ #wrapper p.button input:hover{
248
+ background: rgb(74, 179, 198);
249
+ }
250
+ #wrapper p.button input:active,
251
+ #wrapper p.button input:focus{
252
+ background: rgb(40, 137, 154);
253
+ position: relative;
254
+ top: 1px;
255
+ border: 1px solid rgb(12, 76, 87);
256
+ -webkit-box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.2) inset;
257
+ -moz-box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.2) inset;
258
+ box-shadow: 0px 1px 6px 4px rgba(0, 0, 0, 0.2) inset;
259
+ }
260
+ p.login.button,
261
+ p.signin.button{
262
+ text-align: right;
263
+ margin: 5px 0;
264
+ }
265
+
266
+
267
+
268
+
269
+ #login{
270
+ position: absolute;
271
+ top: 0px;
272
+ width: 88%;
273
+ padding: 18px 6% 60px 6%;
274
+ margin: 0 0 35px 0;
275
+ background: rgb(247, 247, 247);
276
+ border: 1px solid rgba(147, 184, 189,0.8);
277
+ -webkit-box-shadow: 0pt 2px 5px rgba(105, 108, 109, 0.7), 0px 0px 8px 5px rgba(208, 223, 226, 0.4) inset;
278
+ -moz-box-shadow: 0pt 2px 5px rgba(105, 108, 109, 0.7), 0px 0px 8px 5px rgba(208, 223, 226, 0.4) inset;
279
+ box-shadow: 0pt 2px 5px rgba(105, 108, 109, 0.7), 0px 0px 8px 5px rgba(208, 223, 226, 0.4) inset;
280
+ -webkit-box-shadow: 5px;
281
+ -moz-border-radius: 5px;
282
+ border-radius: 5px;
283
+ }
284
+
285
+ #login{
286
+ z-index: 22;
287
+ }
288
+ #toregister:target ~ #wrapper #register,
289
+ #tologin:target ~ #wrapper #login{
290
+ z-index: 22;
291
+ -webkit-animation-name: fadeInLeft;
292
+ -moz-animation-name: fadeInLeft;
293
+ -ms-animation-name: fadeInLeft;
294
+ -o-animation-name: fadeInLeft;
295
+ animation-name: fadeInLeft;
296
+ -webkit-animation-delay: .1s;
297
+ -moz-animation-delay: .1s;
298
+ -o-animation-delay: .1s;
299
+ -ms-animation-delay: .1s;
300
+ animation-delay: .1s;
301
+ }
302
+
303
+ .lt8 #wrapper input{
304
+ padding: 10px 5px 10px 32px;
305
+ width: 92%;
306
+ }
307
+
308
+ </style>
309
+
310
+ <div class="container">
311
+
312
+ <div class="codrops-top">
313
+ <div class="clr"></div>
314
+ </div>
315
+ <section>
316
+ <div id="container_demo" >
317
+ <div id="wrapper">
318
+ <div id="login" class="animate form">
319
+ <form action="" autocomplete="on" method="post">
320
+ <input type="hidden" name="response_str" value="<?php echo stripslashes(implode("~~~",$twitter_arr)); ?>" />
321
+ <h1>You are almost done!</h1>
322
+ <p>
323
+ <label for="email" class="uname">Your email</label>
324
+ <input id="email" name="email" required="required" type="text" placeholder="mymail@mail.com"/>
325
+ </p>
326
+
327
+
328
+ <p class="login button">
329
+ <input type="submit" value="Login" name="submit" onclick="return chk_submit_email();" />
330
+ </p>
331
+
332
+ </form>
333
+ </div>
334
+
335
+
336
+
337
+ </div>
338
+ </div>
339
+ </section>
340
+ </div>
341
+ <script type="text/javascript">
342
+
343
+
344
+ function isvalidemail_form(str){
345
+
346
+ var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-zA-Z]{2,6}(?:\.[a-zA-Z]{2})?)$/i
347
+ return (filter.test(str));
348
+ }
349
+
350
+ function isWhitespace(charToCheck) {
351
+ var whitespaceChars = " \t\n\r\f";
352
+ return (whitespaceChars.indexOf(charToCheck) != -1);
353
+ }
354
+ function chk_submit_email()
355
+ {
356
+ var email=document.getElementById('email').value;
357
+ if(!isWhitespace(email))
358
+ {
359
+ if(!isvalidemail_form(email))
360
+ {
361
+ alert("Please enter valid email address");
362
+ return false;
363
+ }
364
+ }
365
+ else
366
+ {
367
+ alert("Please provide your email address.");
368
+ return false;
369
+ }
370
+
371
+
372
+ }
373
+
374
+ </script>
375
+ <?php
376
+ exit;
377
+ }
378
+ else
379
+ {
380
+ $this->scsl_general_login(stripslashes(implode("~~~",$twitter_arr)),'4',$chk_twitter);
381
+ }
382
+
383
+ }
384
+
385
+ }
386
+
387
+
388
+
389
+
390
+
391
+ }
392
+
393
+ public function scsl_general_login($response,$is_from,$email)
394
+ {
395
+
396
+
397
+ $site_id=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid');
398
+ if($is_from=='4')
399
+ {
400
+
401
+ $tw_login=file_get_contents("https://www.socleversocial.com/dashboard/track_twitter.php?action=trk_tw&siteid=".$site_id."&email=".urlencode($email)."&tw_data=".urlencode($response)."");
402
+ if($tw_login)
403
+ {
404
+ $loginl_data=json_decode($tw_login);
405
+
406
+ $resource = Mage::getSingleton('core/resource');
407
+ $tableName = $resource->getTableName('customer_entity');
408
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
409
+ $sql = "Select entity_id from ".$tableName." where email='".$loginl_data->email."' limit 1";
410
+ $rows= $connection->fetchAll($sql);
411
+
412
+ $customer = Mage::getModel("customer/customer");
413
+ if(count($rows) > 0)
414
+ {
415
+ $is_new='0';
416
+ $username=$loginl_data->email;
417
+ $customer_id=$rows[0]['entity_id'];
418
+ }
419
+ else
420
+ {
421
+ $is_new='1';
422
+ $store = Mage::app()->getStore();
423
+
424
+ $customer->website_id = $websiteId;
425
+ $customer->setStore($store);
426
+ $password=rand("111111","9999999");
427
+ $customer->firstname = $loginl_data->first_name;
428
+ $customer->lastname = $loginl_data->last_name;
429
+ $customer->email =$loginl_data->email;
430
+ $customer->password_hash = md5($password);
431
+ $customer->save();
432
+ $username=$loginl_data->email;
433
+ $sql= "Select entity_id from ".$tableName." where email='".$loginl_data->email."' limit 1";
434
+ $rows= $connection->fetchAll($sql);
435
+ $customer_id=$rows[0]['entity_id'];
436
+ }
437
+
438
+ file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_from=7&siteUid=".$customer_id."&is_new=".$is_new."&member_id=".$loginl_data->member_id."&siteid=".Mage::getStoreConfig('socialloginsc_options/apisettings/scsl_siteid')."&action=notifycs");
439
+ Mage::getModel('core/session', array('name' => 'frontend'));
440
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
441
+ $customer->loadByEmail($username);
442
+ $customer->setCustomerActivated(true);
443
+ $customer->save();
444
+
445
+ if($is_new=='1' && Mage::getStoreConfig('soclever_socialloginsharing/displaysettings/socialloginregemail')=='1')
446
+ {
447
+ $customer->sendNewAccountEmail();
448
+ }
449
+
450
+ $redirect_location=($_GET['lc']=='c')?Mage::getBaseUrl()."checkout/onepage/":Mage::getBaseUrl()."customer/account/";
451
+ $is_from='4';
452
+ Mage::getSingleton('core/session')->setSessionVariable($is_from);
453
+ $isIosChrome = (strpos($_SERVER['HTTP_USER_AGENT'], 'CriOS') !== false) ? true : false;
454
+ if(!$isIosChrome)
455
+ {
456
+ ?>
457
+ <script type="text/javascript">
458
+ setTimeout(function(){ opener.location.href="<?php echo $redirect_location; ?>";close(); },1000);
459
+ </script>
460
+ <?php
461
+ }
462
+
463
+ //echo"<img src='https://www.socleversocial.com/dashboard/images/pw.gif' alt='wait!' title='wait!'>";
464
+ $this->getSession()->loginById($customer->getId());
465
+
466
+ if(Mage::getSingleton('customer/session')->isLoggedIn() && $isIosChrome)
467
+ {
468
+ ?>
469
+ <script type="text/javascript">
470
+
471
+ window.location.href="<?php echo $redirect_location; ?>";
472
+ </script>
473
+ <?php
474
+ //header("location:".$redirect_location."");
475
+
476
+ }
477
+ exit;
478
+ }
479
+
480
+
481
+ }
482
+ }
483
+
484
+
485
+
486
+
487
  public function fbloginAction()
488
  {
489
 
617
  }
618
  $is_from='1';
619
  Mage::getSingleton('core/session')->setSessionVariable($is_from);
620
+
621
+ $isIosChrome = (strpos($_SERVER['HTTP_USER_AGENT'], 'CriOS') !== false) ? true : false;
622
+
623
+ if(!$isIosChrome) { ?>
624
+
625
  <script type="text/javascript">
626
 
627
  setTimeout(function(){
628
 
629
 
630
+ opener.location.href="<?php echo $redirect_location;?>";
631
+ this.close();
632
 
633
  },1000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
634
  </script>
635
  <?php
636
+ }
637
+
638
  //echo"<img src='https://www.socleversocial.com/dashboard/images/pw.gif' alt='wait!' title='wait!'>";
639
  $this->getSession()->loginById($customer->getId());
640
+
641
+ if(Mage::getSingleton('customer/session')->isLoggedIn() && $isIosChrome)
642
+ {
643
+ ?>
644
+ <script type="text/javascript">
645
+
646
+ window.location.href="<?php echo $redirect_location; ?>";
647
+ </script>
648
+ <?php
649
+ //header("location:".$redirect_location."");
650
+
651
+ }
652
  exit;
653
  }
654
  }
736
  {
737
 
738
 
739
+ $openid = new LightOpenID('eurekadigital.com.au');
740
 
741
 
742
  if(!$openid->mode)
774
  $is_from='5';
775
  Mage::getSingleton('core/session')->setSessionVariable($is_from);
776
  $d = $openid->getAttributes();
777
+
778
  //echo "https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=".Mage::getStoreConfig('socialloginsharing_options_options/apisettings/scsl_siteid')."&other=".json_encode($d)."";
779
  /*$response_content=file_get_contents("https://www.socleversocial.com/dashboard/track_register_new.php?is_yh=1&is_from=5&siteid=".Mage::getStoreConfig('socialloginsharing_options_options/apisettings/scsl_siteid')."&other=".json_encode($d)."");
780
  if($response_content)
app/code/local/Soclever/Socialloginsharing/controllers/http.php ADDED
@@ -0,0 +1,2080 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ define('HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR', -1);
3
+ define('HTTP_CLIENT_ERROR_NO_ERROR', 0);
4
+ define('HTTP_CLIENT_ERROR_INVALID_SERVER_ADDRESS', 1);
5
+ define('HTTP_CLIENT_ERROR_CANNOT_CONNECT', 2);
6
+ define('HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE', 3);
7
+ define('HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE', 4);
8
+ define('HTTP_CLIENT_ERROR_PROTOCOL_FAILURE', 5);
9
+ define('HTTP_CLIENT_ERROR_INVALID_PARAMETERS', 6);
10
+
11
+ class http_class
12
+ {
13
+ var $host_name="";
14
+ var $host_port=0;
15
+ var $proxy_host_name="";
16
+ var $proxy_host_port=80;
17
+ var $socks_host_name = '';
18
+ var $socks_host_port = 1080;
19
+ var $socks_version = '5';
20
+
21
+ var $protocol="http";
22
+ var $request_method="GET";
23
+ var $user_agent='httpclient (http://www.phpclasses.org/httpclient $Revision: 1.89 $)';
24
+ var $accept='';
25
+ var $authentication_mechanism="";
26
+ var $user;
27
+ var $password;
28
+ var $realm;
29
+ var $workstation;
30
+ var $proxy_authentication_mechanism="";
31
+ var $proxy_user;
32
+ var $proxy_password;
33
+ var $proxy_realm;
34
+ var $proxy_workstation;
35
+ var $request_uri="";
36
+ var $request="";
37
+ var $request_headers=array();
38
+ var $request_user;
39
+ var $request_password;
40
+ var $request_realm;
41
+ var $request_workstation;
42
+ var $proxy_request_user;
43
+ var $proxy_request_password;
44
+ var $proxy_request_realm;
45
+ var $proxy_request_workstation;
46
+ var $request_body="";
47
+ var $request_arguments=array();
48
+ var $protocol_version="1.1";
49
+ var $timeout=0;
50
+ var $data_timeout=0;
51
+ var $debug=0;
52
+ var $log_debug=0;
53
+ var $debug_response_body=1;
54
+ var $html_debug=0;
55
+ var $support_cookies=1;
56
+ var $cookies=array();
57
+ var $error="";
58
+ var $error_code = HTTP_CLIENT_ERROR_NO_ERROR;
59
+ var $exclude_address="";
60
+ var $follow_redirect=0;
61
+ var $redirection_limit=5;
62
+ var $response_status="";
63
+ var $response_message="";
64
+ var $file_buffer_length=8000;
65
+ var $force_multipart_form_post=0;
66
+ var $prefer_curl = 0;
67
+ var $keep_alive = 1;
68
+ var $sasl_authenticate = 1;
69
+
70
+ var $state="Disconnected";
71
+ var $use_curl=0;
72
+ var $connection=0;
73
+ var $content_length=0;
74
+ var $response="";
75
+ var $read_response=0;
76
+ var $read_length=0;
77
+ var $request_host="";
78
+ var $next_token="";
79
+ var $redirection_level=0;
80
+ var $chunked=0;
81
+ var $remaining_chunk=0;
82
+ var $last_chunk_read=0;
83
+ var $months=array(
84
+ "Jan"=>"01",
85
+ "Feb"=>"02",
86
+ "Mar"=>"03",
87
+ "Apr"=>"04",
88
+ "May"=>"05",
89
+ "Jun"=>"06",
90
+ "Jul"=>"07",
91
+ "Aug"=>"08",
92
+ "Sep"=>"09",
93
+ "Oct"=>"10",
94
+ "Nov"=>"11",
95
+ "Dec"=>"12");
96
+ var $session='';
97
+ var $connection_close=0;
98
+ var $force_close = 0;
99
+ var $connected_host = '';
100
+ var $connected_port = -1;
101
+ var $connected_ssl = 0;
102
+
103
+ Function Tokenize($string,$separator="")
104
+ {
105
+ if(!strcmp($separator,""))
106
+ {
107
+ $separator=$string;
108
+ $string=$this->next_token;
109
+ }
110
+ for($character=0;$character<strlen($separator);$character++)
111
+ {
112
+ if(GetType($position=strpos($string,$separator[$character]))=="integer")
113
+ $found=(IsSet($found) ? min($found,$position) : $position);
114
+ }
115
+ if(IsSet($found))
116
+ {
117
+ $this->next_token=substr($string,$found+1);
118
+ return(substr($string,0,$found));
119
+ }
120
+ else
121
+ {
122
+ $this->next_token="";
123
+ return($string);
124
+ }
125
+ }
126
+
127
+ Function CookieEncode($value, $name)
128
+ {
129
+ return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
130
+ }
131
+
132
+ Function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
133
+ {
134
+ $this->error_code = $error_code;
135
+ return($this->error=$error);
136
+ }
137
+
138
+ Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
139
+ {
140
+ if(IsSet($php_error_message)
141
+ && strlen($php_error_message))
142
+ $error.=": ".$php_error_message;
143
+ return($this->SetError($error, $error_code));
144
+ }
145
+
146
+ Function SetDataAccessError($error,$check_connection=0)
147
+ {
148
+ $this->error=$error;
149
+ $this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
150
+ if(!$this->use_curl
151
+ && function_exists("socket_get_status"))
152
+ {
153
+ $status=socket_get_status($this->connection);
154
+ if($status["timed_out"])
155
+ $this->error.=": data access time out";
156
+ elseif($status["eof"])
157
+ {
158
+ if($check_connection)
159
+ $this->error="";
160
+ else
161
+ $this->error.=": the server disconnected";
162
+ }
163
+ }
164
+ }
165
+
166
+ Function OutputDebug($message)
167
+ {
168
+ if($this->log_debug)
169
+ error_log($message);
170
+ else
171
+ {
172
+ $message.="\n";
173
+ if($this->html_debug)
174
+ $message=str_replace("\n","<br />\n",HtmlEntities($message));
175
+ echo $message;
176
+ flush();
177
+ }
178
+ }
179
+
180
+ Function GetLine()
181
+ {
182
+ for($line="";;)
183
+ {
184
+ if($this->use_curl)
185
+ {
186
+ $eol=strpos($this->response,"\n",$this->read_response);
187
+ $data=($eol ? substr($this->response,$this->read_response,$eol+1-$this->read_response) : "");
188
+ $this->read_response+=strlen($data);
189
+ }
190
+ else
191
+ {
192
+ if(feof($this->connection))
193
+ {
194
+ $this->SetDataAccessError("reached the end of data while reading from the HTTP server connection");
195
+ return(0);
196
+ }
197
+ $data=fgets($this->connection,100);
198
+ }
199
+ if(GetType($data)!="string"
200
+ || strlen($data)==0)
201
+ {
202
+ $this->SetDataAccessError("it was not possible to read line from the HTTP server");
203
+ return(0);
204
+ }
205
+ $line.=$data;
206
+ $length=strlen($line);
207
+ if($length
208
+ && !strcmp(substr($line,$length-1,1),"\n"))
209
+ {
210
+ $length-=(($length>=2 && !strcmp(substr($line,$length-2,1),"\r")) ? 2 : 1);
211
+ $line=substr($line,0,$length);
212
+ if($this->debug)
213
+ $this->OutputDebug("S $line");
214
+ return($line);
215
+ }
216
+ }
217
+ }
218
+
219
+ Function PutLine($line)
220
+ {
221
+ if($this->debug)
222
+ $this->OutputDebug("C $line");
223
+ if(!fputs($this->connection,$line."\r\n"))
224
+ {
225
+ $this->SetDataAccessError("it was not possible to send a line to the HTTP server");
226
+ return(0);
227
+ }
228
+ return(1);
229
+ }
230
+
231
+ Function PutData($data)
232
+ {
233
+ if(strlen($data))
234
+ {
235
+ if($this->debug)
236
+ $this->OutputDebug('C '.$data);
237
+ if(!fputs($this->connection,$data))
238
+ {
239
+ $this->SetDataAccessError("it was not possible to send data to the HTTP server");
240
+ return(0);
241
+ }
242
+ }
243
+ return(1);
244
+ }
245
+
246
+ Function FlushData()
247
+ {
248
+ if(!fflush($this->connection))
249
+ {
250
+ $this->SetDataAccessError("it was not possible to send data to the HTTP server");
251
+ return(0);
252
+ }
253
+ return(1);
254
+ }
255
+
256
+ Function ReadChunkSize()
257
+ {
258
+ if($this->remaining_chunk==0)
259
+ {
260
+ $debug=$this->debug;
261
+ if(!$this->debug_response_body)
262
+ $this->debug=0;
263
+ $line=$this->GetLine();
264
+ $this->debug=$debug;
265
+ if(GetType($line)!="string")
266
+ return($this->SetError("could not read chunk start: ".$this->error, $this->error_code));
267
+ $this->remaining_chunk=hexdec($line);
268
+ if($this->remaining_chunk == 0)
269
+ {
270
+ if(!$this->debug_response_body)
271
+ $this->debug=0;
272
+ $line=$this->GetLine();
273
+ $this->debug=$debug;
274
+ if(GetType($line)!="string")
275
+ return($this->SetError("could not read chunk end: ".$this->error, $this->error_code));
276
+ }
277
+ }
278
+ return("");
279
+ }
280
+
281
+ Function ReadBytes($length)
282
+ {
283
+ if($this->use_curl)
284
+ {
285
+ $bytes=substr($this->response,$this->read_response,min($length,strlen($this->response)-$this->read_response));
286
+ $this->read_response+=strlen($bytes);
287
+ if($this->debug
288
+ && $this->debug_response_body
289
+ && strlen($bytes))
290
+ $this->OutputDebug("S ".$bytes);
291
+ }
292
+ else
293
+ {
294
+ if($this->chunked)
295
+ {
296
+ for($bytes="",$remaining=$length;$remaining;)
297
+ {
298
+ if(strlen($this->ReadChunkSize()))
299
+ return("");
300
+ if($this->remaining_chunk==0)
301
+ {
302
+ $this->last_chunk_read=1;
303
+ break;
304
+ }
305
+ $ask=min($this->remaining_chunk,$remaining);
306
+ $chunk=@fread($this->connection,$ask);
307
+ $read=strlen($chunk);
308
+ if($read==0)
309
+ {
310
+ $this->SetDataAccessError("it was not possible to read data chunk from the HTTP server");
311
+ return("");
312
+ }
313
+ if($this->debug
314
+ && $this->debug_response_body)
315
+ $this->OutputDebug("S ".$chunk);
316
+ $bytes.=$chunk;
317
+ $this->remaining_chunk-=$read;
318
+ $remaining-=$read;
319
+ if($this->remaining_chunk==0)
320
+ {
321
+ if(feof($this->connection))
322
+ return($this->SetError("reached the end of data while reading the end of data chunk mark from the HTTP server", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
323
+ $data=@fread($this->connection,2);
324
+ if(strcmp($data,"\r\n"))
325
+ {
326
+ $this->SetDataAccessError("it was not possible to read end of data chunk from the HTTP server");
327
+ return("");
328
+ }
329
+ }
330
+ }
331
+ }
332
+ else
333
+ {
334
+ $bytes=@fread($this->connection,$length);
335
+ if(strlen($bytes))
336
+ {
337
+ if($this->debug
338
+ && $this->debug_response_body)
339
+ $this->OutputDebug("S ".$bytes);
340
+ }
341
+ else
342
+ $this->SetDataAccessError("it was not possible to read data from the HTTP server", $this->connection_close);
343
+ }
344
+ }
345
+ return($bytes);
346
+ }
347
+
348
+ Function EndOfInput()
349
+ {
350
+ if($this->use_curl)
351
+ return($this->read_response>=strlen($this->response));
352
+ if($this->chunked)
353
+ return($this->last_chunk_read);
354
+ if($this->content_length_set)
355
+ return($this->content_length <= $this->read_length);
356
+ return(feof($this->connection));
357
+ }
358
+
359
+ Function Resolve($domain, &$ip, $server_type)
360
+ {
361
+ if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain))
362
+ $ip=$domain;
363
+ else
364
+ {
365
+ if($this->debug)
366
+ $this->OutputDebug('Resolving '.$server_type.' server domain "'.$domain.'"...');
367
+ if(!strcmp($ip=@gethostbyname($domain),$domain))
368
+ $ip="";
369
+ }
370
+ if(strlen($ip)==0
371
+ || (strlen($this->exclude_address)
372
+ && !strcmp(@gethostbyname($this->exclude_address),$ip)))
373
+ return($this->SetError("could not resolve the host domain \"".$domain."\"", HTTP_CLIENT_ERROR_INVALID_SERVER_ADDRESS));
374
+ return('');
375
+ }
376
+
377
+ Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
378
+ {
379
+ $domain=$host_name;
380
+ $port = $host_port;
381
+ if(strlen($error = $this->Resolve($domain, $ip, $server_type)))
382
+ return($error);
383
+ if(strlen($this->socks_host_name))
384
+ {
385
+ switch($this->socks_version)
386
+ {
387
+ case '4':
388
+ $version = 4;
389
+ break;
390
+ case '5':
391
+ $version = 5;
392
+ break;
393
+ default:
394
+ return('it was not specified a supported SOCKS protocol version');
395
+ break;
396
+ }
397
+ $host_ip = $ip;
398
+ $port = $this->socks_host_port;
399
+ $host_server_type = $server_type;
400
+ $server_type = 'SOCKS';
401
+ if(strlen($error = $this->Resolve($this->socks_host_name, $ip, $server_type)))
402
+ return($error);
403
+ }
404
+ if($this->debug)
405
+ $this->OutputDebug('Connecting to '.$server_type.' server IP '.$ip.' port '.$port.'...');
406
+ if($ssl)
407
+ $ip="ssl://".$host_name;
408
+ if(($this->connection=($this->timeout ? @fsockopen($ip, $port, $errno, $error, $this->timeout) : @fsockopen($ip, $port, $errno)))==0)
409
+ {
410
+ $error_code = HTTP_CLIENT_ERROR_CANNOT_CONNECT;
411
+ switch($errno)
412
+ {
413
+ case -3:
414
+ return($this->SetError("socket could not be created", $error_code));
415
+ case -4:
416
+ return($this->SetError("dns lookup on hostname \"".$host_name."\" failed", $error_code));
417
+ case -5:
418
+ return($this->SetError("connection refused or timed out", $error_code));
419
+ case -6:
420
+ return($this->SetError("fdopen() call failed", $error_code));
421
+ case -7:
422
+ return($this->SetError("setvbuf() call failed", $error_code));
423
+ default:
424
+ return($this->SetPHPError($errno." could not connect to the host \"".$host_name."\"",$php_errormsg, $error_code));
425
+ }
426
+ }
427
+ else
428
+ {
429
+ if($this->data_timeout
430
+ && function_exists("socket_set_timeout"))
431
+ socket_set_timeout($this->connection,$this->data_timeout,0);
432
+ if(strlen($this->socks_host_name))
433
+ {
434
+ if($this->debug)
435
+ $this->OutputDebug('Connected to the SOCKS server '.$this->socks_host_name);
436
+ $send_error = 'it was not possible to send data to the SOCKS server';
437
+ $receive_error = 'it was not possible to receive data from the SOCKS server';
438
+ switch($version)
439
+ {
440
+ case 4:
441
+ $command = 1;
442
+ $user = '';
443
+ if(!fputs($this->connection, chr($version).chr($command).pack('nN', $host_port, ip2long($host_ip)).$user.Chr(0)))
444
+ $error = $this->SetDataAccessError($send_error);
445
+ else
446
+ {
447
+ $response = fgets($this->connection, 9);
448
+ if(strlen($response) != 8)
449
+ $error = $this->SetDataAccessError($receive_error);
450
+ else
451
+ {
452
+ $socks_errors = array(
453
+ "\x5a"=>'',
454
+ "\x5b"=>'request rejected',
455
+ "\x5c"=>'request failed because client is not running identd (or not reachable from the server)',
456
+ "\x5d"=>'request failed because client\'s identd could not confirm the user ID string in the request',
457
+ );
458
+ $error_code = $response[1];
459
+ $error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown');
460
+ if(strlen($error))
461
+ $error = 'SOCKS error: '.$error;
462
+ }
463
+ }
464
+ break;
465
+ case 5:
466
+ if($this->debug)
467
+ $this->OutputDebug('Negotiating the authentication method ...');
468
+ $methods = 1;
469
+ $method = 0;
470
+ if(!fputs($this->connection, chr($version).chr($methods).chr($method)))
471
+ $error = $this->SetDataAccessError($send_error);
472
+ else
473
+ {
474
+ $response = fgets($this->connection, 3);
475
+ if(strlen($response) != 2)
476
+ $error = $this->SetDataAccessError($receive_error);
477
+ elseif(Ord($response[1]) != $method)
478
+ $error = 'the SOCKS server requires an authentication method that is not yet supported';
479
+ else
480
+ {
481
+ if($this->debug)
482
+ $this->OutputDebug('Connecting to '.$host_server_type.' server IP '.$host_ip.' port '.$host_port.'...');
483
+ $command = 1;
484
+ $address_type = 1;
485
+ if(!fputs($this->connection, chr($version).chr($command)."\x00".chr($address_type).pack('Nn', ip2long($host_ip), $host_port)))
486
+ $error = $this->SetDataAccessError($send_error);
487
+ else
488
+ {
489
+ $response = fgets($this->connection, 11);
490
+ if(strlen($response) != 10)
491
+ $error = $this->SetDataAccessError($receive_error);
492
+ else
493
+ {
494
+ $socks_errors = array(
495
+ "\x00"=>'',
496
+ "\x01"=>'general SOCKS server failure',
497
+ "\x02"=>'connection not allowed by ruleset',
498
+ "\x03"=>'Network unreachable',
499
+ "\x04"=>'Host unreachable',
500
+ "\x05"=>'Connection refused',
501
+ "\x06"=>'TTL expired',
502
+ "\x07"=>'Command not supported',
503
+ "\x08"=>'Address type not supported'
504
+ );
505
+ $error_code = $response[1];
506
+ $error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown');
507
+ if(strlen($error))
508
+ $error = 'SOCKS error: '.$error;
509
+ }
510
+ }
511
+ }
512
+ }
513
+ break;
514
+ default:
515
+ $error = 'support for SOCKS protocol version '.$this->socks_version.' is not yet implemented';
516
+ break;
517
+ }
518
+ if(strlen($error))
519
+ {
520
+ fclose($this->connection);
521
+ return($error);
522
+ }
523
+ }
524
+ if($this->debug)
525
+ $this->OutputDebug("Connected to $host_name");
526
+ if(strlen($this->proxy_host_name)
527
+ && !strcmp(strtolower($this->protocol), 'https'))
528
+ {
529
+ if(function_exists('stream_socket_enable_crypto')
530
+ && in_array('ssl', stream_get_transports()))
531
+ $this->state = "ConnectedToProxy";
532
+ else
533
+ {
534
+ $this->OutputDebug("It is not possible to start SSL after connecting to the proxy server. If the proxy refuses to forward the SSL request, you may need to upgrade to PHP 5.1 or later with OpenSSL support enabled.");
535
+ $this->state="Connected";
536
+ }
537
+ }
538
+ else
539
+ $this->state="Connected";
540
+ return("");
541
+ }
542
+ }
543
+
544
+ Function Disconnect()
545
+ {
546
+ if($this->debug)
547
+ $this->OutputDebug("Disconnected from ".$this->connected_host);
548
+ if($this->use_curl)
549
+ {
550
+ curl_close($this->connection);
551
+ $this->response="";
552
+ }
553
+ else
554
+ fclose($this->connection);
555
+ $this->state="Disconnected";
556
+ return("");
557
+ }
558
+
559
+ /* Public methods */
560
+
561
+ Function GetRequestArguments($url, &$arguments)
562
+ {
563
+ $this->error = '';
564
+ $this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
565
+ $arguments=array();
566
+ $url = str_replace(' ', '%20', $url);
567
+ $parameters=@parse_url($url);
568
+ if(!$parameters)
569
+ return($this->SetError("it was not specified a valid URL", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
570
+ if(!IsSet($parameters["scheme"]))
571
+ return($this->SetError("it was not specified the protocol type argument", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
572
+ switch(strtolower($parameters["scheme"]))
573
+ {
574
+ case "http":
575
+ case "https":
576
+ $arguments["Protocol"]=$parameters["scheme"];
577
+ break;
578
+ default:
579
+ return($parameters["scheme"]." connection scheme is not yet supported");
580
+ }
581
+ if(!IsSet($parameters["host"]))
582
+ return($this->SetError("it was not specified the connection host argument", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
583
+ $arguments["HostName"]=$parameters["host"];
584
+ $arguments["Headers"]=array("Host"=>$parameters["host"].(IsSet($parameters["port"]) ? ":".$parameters["port"] : ""));
585
+ if(IsSet($parameters["user"]))
586
+ {
587
+ $arguments["AuthUser"]=UrlDecode($parameters["user"]);
588
+ if(!IsSet($parameters["pass"]))
589
+ $arguments["AuthPassword"]="";
590
+ }
591
+ if(IsSet($parameters["pass"]))
592
+ {
593
+ if(!IsSet($parameters["user"]))
594
+ $arguments["AuthUser"]="";
595
+ $arguments["AuthPassword"]=UrlDecode($parameters["pass"]);
596
+ }
597
+ if(IsSet($parameters["port"]))
598
+ {
599
+ if(strcmp($parameters["port"],strval(intval($parameters["port"]))))
600
+ return($this->SetError("it was not specified a valid connection host argument", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
601
+ $arguments["HostPort"]=intval($parameters["port"]);
602
+ }
603
+ else
604
+ $arguments["HostPort"]=0;
605
+ $arguments["RequestURI"]=(IsSet($parameters["path"]) ? $parameters["path"] : "/").(IsSet($parameters["query"]) ? "?".$parameters["query"] : "");
606
+ if(strlen($this->user_agent))
607
+ $arguments["Headers"]["User-Agent"]=$this->user_agent;
608
+ if(strlen($this->accept))
609
+ $arguments["Headers"]["Accept"]=$this->accept;
610
+ return("");
611
+ }
612
+
613
+ Function Open($arguments)
614
+ {
615
+ if(strlen($this->error))
616
+ return($this->error);
617
+ $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR;
618
+ if(IsSet($arguments["HostName"]))
619
+ $this->host_name=$arguments["HostName"];
620
+ if(IsSet($arguments["HostPort"]))
621
+ $this->host_port=$arguments["HostPort"];
622
+ if(IsSet($arguments["ProxyHostName"]))
623
+ $this->proxy_host_name=$arguments["ProxyHostName"];
624
+ if(IsSet($arguments["ProxyHostPort"]))
625
+ $this->proxy_host_port=$arguments["ProxyHostPort"];
626
+ if(IsSet($arguments["SOCKSHostName"]))
627
+ $this->socks_host_name=$arguments["SOCKSHostName"];
628
+ if(IsSet($arguments["SOCKSHostPort"]))
629
+ $this->socks_host_port=$arguments["SOCKSHostPort"];
630
+ if(IsSet($arguments["SOCKSVersion"]))
631
+ $this->socks_version=$arguments["SOCKSVersion"];
632
+ if(IsSet($arguments["Protocol"]))
633
+ $this->protocol=$arguments["Protocol"];
634
+ switch(strtolower($this->protocol))
635
+ {
636
+ case "http":
637
+ $default_port=80;
638
+ break;
639
+ case "https":
640
+ $default_port=443;
641
+ break;
642
+ default:
643
+ return($this->SetError("it was not specified a valid connection protocol", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
644
+ }
645
+ if(strlen($this->proxy_host_name)==0)
646
+ {
647
+ if(strlen($this->host_name)==0)
648
+ return($this->SetError("it was not specified a valid hostname", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
649
+ $host_name=$this->host_name;
650
+ $host_port=($this->host_port ? $this->host_port : $default_port);
651
+ $server_type = 'HTTP';
652
+ }
653
+ else
654
+ {
655
+ $host_name=$this->proxy_host_name;
656
+ $host_port=$this->proxy_host_port;
657
+ $server_type = 'HTTP proxy';
658
+ }
659
+ $ssl=(strtolower($this->protocol)=="https" && strlen($this->proxy_host_name)==0);
660
+ if($ssl
661
+ && strlen($this->socks_host_name))
662
+ return($this->SetError('establishing SSL connections via a SOCKS server is not yet supported', HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
663
+ $this->use_curl=($ssl && $this->prefer_curl && function_exists("curl_init"));
664
+ switch($this->state)
665
+ {
666
+ case 'Connected':
667
+ if(!strcmp($host_name, $this->connected_host)
668
+ && intval($host_port) == $this->connected_port
669
+ && intval($ssl) == $this->connected_ssl)
670
+ {
671
+ if($this->debug)
672
+ $this->OutputDebug("Reusing connection to ".$this->connected_host);
673
+ return('');
674
+ }
675
+ if(strlen($error = $this->Disconnect()))
676
+ return($error);
677
+ case "Disconnected":
678
+ break;
679
+ default:
680
+ return("1 already connected");
681
+ }
682
+ if($this->debug)
683
+ $this->OutputDebug("Connecting to ".$this->host_name);
684
+ if($this->use_curl)
685
+ {
686
+ $error=(($this->connection=curl_init($this->protocol."://".$this->host_name.($host_port==$default_port ? "" : ":".strval($host_port))."/")) ? "" : "Could not initialize a CURL session");
687
+ if(strlen($error)==0)
688
+ {
689
+ if(IsSet($arguments["SSLCertificateFile"]))
690
+ curl_setopt($this->connection,CURLOPT_SSLCERT,$arguments["SSLCertificateFile"]);
691
+ if(IsSet($arguments["SSLCertificatePassword"]))
692
+ curl_setopt($this->connection,CURLOPT_SSLCERTPASSWD,$arguments["SSLCertificatePassword"]);
693
+ if(IsSet($arguments["SSLKeyFile"]))
694
+ curl_setopt($this->connection,CURLOPT_SSLKEY,$arguments["SSLKeyFile"]);
695
+ if(IsSet($arguments["SSLKeyPassword"]))
696
+ curl_setopt($this->connection,CURLOPT_SSLKEYPASSWD,$arguments["SSLKeyPassword"]);
697
+ }
698
+ $this->state="Connected";
699
+ }
700
+ else
701
+ {
702
+ $error="";
703
+ if(strlen($this->proxy_host_name)
704
+ && (IsSet($arguments["SSLCertificateFile"])
705
+ || IsSet($arguments["SSLCertificateFile"])))
706
+ $error="establishing SSL connections using certificates or private keys via non-SSL proxies is not supported";
707
+ else
708
+ {
709
+ if($ssl)
710
+ {
711
+ if(IsSet($arguments["SSLCertificateFile"]))
712
+ $error="establishing SSL connections using certificates is only supported when the cURL extension is enabled";
713
+ elseif(IsSet($arguments["SSLKeyFile"]))
714
+ $error="establishing SSL connections using a private key is only supported when the cURL extension is enabled";
715
+ else
716
+ {
717
+ $version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7");
718
+ $php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]);
719
+ if($php_version<4003000)
720
+ $error="establishing SSL connections requires at least PHP version 4.3.0 or having the cURL extension enabled";
721
+ elseif(!function_exists("extension_loaded")
722
+ || !extension_loaded("openssl"))
723
+ $error="establishing SSL connections requires the OpenSSL extension enabled";
724
+ }
725
+ }
726
+ if(strlen($error)==0)
727
+ {
728
+ $error=$this->Connect($host_name, $host_port, $ssl, $server_type);
729
+ $error_code = $this->error_code;
730
+ }
731
+ }
732
+ }
733
+ if(strlen($error))
734
+ return($this->SetError($error, $error_code));
735
+ $this->session=md5(uniqid(""));
736
+ $this->connected_host = $host_name;
737
+ $this->connected_port = intval($host_port);
738
+ $this->connected_ssl = intval($ssl);
739
+ return("");
740
+ }
741
+
742
+ Function Close($force = 0)
743
+ {
744
+ if($this->state=="Disconnected")
745
+ return("1 already disconnected");
746
+ if(!$this->force_close
747
+ && $this->keep_alive
748
+ && !$force
749
+ && $this->state == 'ResponseReceived')
750
+ {
751
+ if($this->debug)
752
+ $this->OutputDebug('Keeping the connection alive to '.$this->connected_host);
753
+ $this->state = 'Connected';
754
+ return('');
755
+ }
756
+ return($this->Disconnect());
757
+ }
758
+
759
+ Function PickCookies(&$cookies,$secure)
760
+ {
761
+ if(IsSet($this->cookies[$secure]))
762
+ {
763
+ $now=gmdate("Y-m-d H-i-s");
764
+ for($domain=0,Reset($this->cookies[$secure]);$domain<count($this->cookies[$secure]);Next($this->cookies[$secure]),$domain++)
765
+ {
766
+ $domain_pattern=Key($this->cookies[$secure]);
767
+ $match=strlen($this->request_host)-strlen($domain_pattern);
768
+ if($match>=0
769
+ && !strcmp($domain_pattern,substr($this->request_host,$match))
770
+ && ($match==0
771
+ || $domain_pattern[0]=="."
772
+ || $this->request_host[$match-1]=="."))
773
+ {
774
+ for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++)
775
+ {
776
+ $path=Key($this->cookies[$secure][$domain_pattern]);
777
+ if(strlen($this->request_uri)>=strlen($path)
778
+ && substr($this->request_uri,0,strlen($path))==$path)
779
+ {
780
+ for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++)
781
+ {
782
+ $cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]);
783
+ $expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"];
784
+ if($expires==""
785
+ || strcmp($now,$expires)<0)
786
+ $cookies[$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name];
787
+ }
788
+ }
789
+ }
790
+ }
791
+ }
792
+ }
793
+ }
794
+
795
+ Function GetFileDefinition($file, &$definition)
796
+ {
797
+ $name="";
798
+ if(IsSet($file["FileName"]))
799
+ $name=basename($file["FileName"]);
800
+ if(IsSet($file["Name"]))
801
+ $name=$file["Name"];
802
+ if(strlen($name)==0)
803
+ return("it was not specified the file part name");
804
+ if(IsSet($file["Content-Type"]))
805
+ {
806
+ $content_type=$file["Content-Type"];
807
+ $type=$this->Tokenize(strtolower($content_type),"/");
808
+ $sub_type=$this->Tokenize("");
809
+ switch($type)
810
+ {
811
+ case "text":
812
+ case "image":
813
+ case "audio":
814
+ case "video":
815
+ case "application":
816
+ case "message":
817
+ break;
818
+ case "automatic":
819
+ switch($sub_type)
820
+ {
821
+ case "name":
822
+ switch(GetType($dot=strrpos($name,"."))=="integer" ? strtolower(substr($name,$dot)) : "")
823
+ {
824
+ case ".xls":
825
+ $content_type="application/excel";
826
+ break;
827
+ case ".hqx":
828
+ $content_type="application/macbinhex40";
829
+ break;
830
+ case ".doc":
831
+ case ".dot":
832
+ case ".wrd":
833
+ $content_type="application/msword";
834
+ break;
835
+ case ".pdf":
836
+ $content_type="application/pdf";
837
+ break;
838
+ case ".pgp":
839
+ $content_type="application/pgp";
840
+ break;
841
+ case ".ps":
842
+ case ".eps":
843
+ case ".ai":
844
+ $content_type="application/postscript";
845
+ break;
846
+ case ".ppt":
847
+ $content_type="application/powerpoint";
848
+ break;
849
+ case ".rtf":
850
+ $content_type="application/rtf";
851
+ break;
852
+ case ".tgz":
853
+ case ".gtar":
854
+ $content_type="application/x-gtar";
855
+ break;
856
+ case ".gz":
857
+ $content_type="application/x-gzip";
858
+ break;
859
+ case ".php":
860
+ case ".php3":
861
+ $content_type="application/x-httpd-php";
862
+ break;
863
+ case ".js":
864
+ $content_type="application/x-javascript";
865
+ break;
866
+ case ".ppd":
867
+ case ".psd":
868
+ $content_type="application/x-photoshop";
869
+ break;
870
+ case ".swf":
871
+ case ".swc":
872
+ case ".rf":
873
+ $content_type="application/x-shockwave-flash";
874
+ break;
875
+ case ".tar":
876
+ $content_type="application/x-tar";
877
+ break;
878
+ case ".zip":
879
+ $content_type="application/zip";
880
+ break;
881
+ case ".mid":
882
+ case ".midi":
883
+ case ".kar":
884
+ $content_type="audio/midi";
885
+ break;
886
+ case ".mp2":
887
+ case ".mp3":
888
+ case ".mpga":
889
+ $content_type="audio/mpeg";
890
+ break;
891
+ case ".ra":
892
+ $content_type="audio/x-realaudio";
893
+ break;
894
+ case ".wav":
895
+ $content_type="audio/wav";
896
+ break;
897
+ case ".bmp":
898
+ $content_type="image/bitmap";
899
+ break;
900
+ case ".gif":
901
+ $content_type="image/gif";
902
+ break;
903
+ case ".iff":
904
+ $content_type="image/iff";
905
+ break;
906
+ case ".jb2":
907
+ $content_type="image/jb2";
908
+ break;
909
+ case ".jpg":
910
+ case ".jpe":
911
+ case ".jpeg":
912
+ $content_type="image/jpeg";
913
+ break;
914
+ case ".jpx":
915
+ $content_type="image/jpx";
916
+ break;
917
+ case ".png":
918
+ $content_type="image/png";
919
+ break;
920
+ case ".tif":
921
+ case ".tiff":
922
+ $content_type="image/tiff";
923
+ break;
924
+ case ".wbmp":
925
+ $content_type="image/vnd.wap.wbmp";
926
+ break;
927
+ case ".xbm":
928
+ $content_type="image/xbm";
929
+ break;
930
+ case ".css":
931
+ $content_type="text/css";
932
+ break;
933
+ case ".txt":
934
+ $content_type="text/plain";
935
+ break;
936
+ case ".htm":
937
+ case ".html":
938
+ $content_type="text/html";
939
+ break;
940
+ case ".xml":
941
+ $content_type="text/xml";
942
+ break;
943
+ case ".mpg":
944
+ case ".mpe":
945
+ case ".mpeg":
946
+ $content_type="video/mpeg";
947
+ break;
948
+ case ".qt":
949
+ case ".mov":
950
+ $content_type="video/quicktime";
951
+ break;
952
+ case ".avi":
953
+ $content_type="video/x-ms-video";
954
+ break;
955
+ case ".eml":
956
+ $content_type="message/rfc822";
957
+ break;
958
+ default:
959
+ $content_type="application/octet-stream";
960
+ break;
961
+ }
962
+ break;
963
+ default:
964
+ return($content_type." is not a supported automatic content type detection method");
965
+ }
966
+ break;
967
+ default:
968
+ return($content_type." is not a supported file content type");
969
+ }
970
+ }
971
+ else
972
+ $content_type="application/octet-stream";
973
+ $definition=array(
974
+ "Content-Type"=>$content_type,
975
+ "NAME"=>$name
976
+ );
977
+ if(IsSet($file["FileName"]))
978
+ {
979
+ if(GetType($length=@filesize($file["FileName"]))!="integer")
980
+ {
981
+ $error="it was not possible to determine the length of the file ".$file["FileName"];
982
+ if(IsSet($php_errormsg)
983
+ && strlen($php_errormsg))
984
+ $error.=": ".$php_errormsg;
985
+ if(!file_exists($file["FileName"]))
986
+ $error="it was not possible to access the file ".$file["FileName"];
987
+ return($error);
988
+ }
989
+ $definition["FILENAME"]=$file["FileName"];
990
+ $definition["Content-Length"]=$length;
991
+ }
992
+ elseif(IsSet($file["Data"]))
993
+ $definition["Content-Length"]=strlen($definition["DATA"]=$file["Data"]);
994
+ else
995
+ return("it was not specified a valid file name");
996
+ return("");
997
+ }
998
+
999
+ Function ConnectFromProxy($arguments, &$headers)
1000
+ {
1001
+ if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
1002
+ || (strlen($this->user_agent)
1003
+ && !$this->PutLine('User-Agent: '.$this->user_agent))
1004
+ || (strlen($this->accept)
1005
+ && !$this->PutLine('Accept: '.$this->accept))
1006
+ || (IsSet($arguments['Headers']['Proxy-Authorization'])
1007
+ && !$this->PutLine('Proxy-Authorization: '.$arguments['Headers']['Proxy-Authorization']))
1008
+ || !$this->PutLine(''))
1009
+ {
1010
+ $this->Disconnect();
1011
+ return($this->error);
1012
+ }
1013
+ $this->state = "ConnectSent";
1014
+ if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
1015
+ return($error);
1016
+ $proxy_authorization="";
1017
+ while(!strcmp($this->response_status, "100"))
1018
+ {
1019
+ $this->state="ConnectSent";
1020
+ if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
1021
+ return($error);
1022
+ }
1023
+ switch($this->response_status)
1024
+ {
1025
+ case "200":
1026
+ if(!@stream_socket_enable_crypto($this->connection, 1, STREAM_CRYPTO_METHOD_SSLv23_CLIENT))
1027
+ {
1028
+ $this->SetPHPError('it was not possible to start a SSL encrypted connection via this proxy', $php_errormsg, HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE);
1029
+ $this->Disconnect();
1030
+ return($this->error);
1031
+ }
1032
+ $this->state = "Connected";
1033
+ break;
1034
+ case "407":
1035
+ if(strlen($error=$this->Authenticate($headers, -1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation)))
1036
+ return($error);
1037
+ break;
1038
+ default:
1039
+ return($this->SetError("unable to send request via proxy", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1040
+ }
1041
+ return("");
1042
+ }
1043
+
1044
+ Function SendRequest($arguments)
1045
+ {
1046
+ if(strlen($this->error))
1047
+ return($this->error);
1048
+ if(IsSet($arguments["ProxyUser"]))
1049
+ $this->proxy_request_user=$arguments["ProxyUser"];
1050
+ elseif(IsSet($this->proxy_user))
1051
+ $this->proxy_request_user=$this->proxy_user;
1052
+ if(IsSet($arguments["ProxyPassword"]))
1053
+ $this->proxy_request_password=$arguments["ProxyPassword"];
1054
+ elseif(IsSet($this->proxy_password))
1055
+ $this->proxy_request_password=$this->proxy_password;
1056
+ if(IsSet($arguments["ProxyRealm"]))
1057
+ $this->proxy_request_realm=$arguments["ProxyRealm"];
1058
+ elseif(IsSet($this->proxy_realm))
1059
+ $this->proxy_request_realm=$this->proxy_realm;
1060
+ if(IsSet($arguments["ProxyWorkstation"]))
1061
+ $this->proxy_request_workstation=$arguments["ProxyWorkstation"];
1062
+ elseif(IsSet($this->proxy_workstation))
1063
+ $this->proxy_request_workstation=$this->proxy_workstation;
1064
+ switch($this->state)
1065
+ {
1066
+ case "Disconnected":
1067
+ return($this->SetError("connection was not yet established", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1068
+ case "Connected":
1069
+ $connect = 0;
1070
+ break;
1071
+ case "ConnectedToProxy":
1072
+ if(strlen($error = $this->ConnectFromProxy($arguments, $headers)))
1073
+ return($error);
1074
+ $connect = 1;
1075
+ break;
1076
+ default:
1077
+ return($this->SetError("can not send request in the current connection state", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1078
+ }
1079
+ if(IsSet($arguments["RequestMethod"]))
1080
+ $this->request_method=$arguments["RequestMethod"];
1081
+ if(IsSet($arguments["User-Agent"]))
1082
+ $this->user_agent=$arguments["User-Agent"];
1083
+ if(!IsSet($arguments["Headers"]["User-Agent"])
1084
+ && strlen($this->user_agent))
1085
+ $arguments["Headers"]["User-Agent"]=$this->user_agent;
1086
+ if(IsSet($arguments["KeepAlive"]))
1087
+ $this->keep_alive=intval($arguments["KeepAlive"]);
1088
+ if(!IsSet($arguments["Headers"]["Connection"])
1089
+ && $this->keep_alive)
1090
+ $arguments["Headers"]["Connection"]='Keep-Alive';
1091
+ if(IsSet($arguments["Accept"]))
1092
+ $this->user_agent=$arguments["Accept"];
1093
+ if(!IsSet($arguments["Headers"]["Accept"])
1094
+ && strlen($this->accept))
1095
+ $arguments["Headers"]["Accept"]=$this->accept;
1096
+ if(strlen($this->request_method)==0)
1097
+ return($this->SetError("it was not specified a valid request method", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1098
+ if(IsSet($arguments["RequestURI"]))
1099
+ $this->request_uri=$arguments["RequestURI"];
1100
+ if(strlen($this->request_uri)==0
1101
+ || substr($this->request_uri,0,1)!="/")
1102
+ return($this->SetError("it was not specified a valid request URI", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1103
+ $this->request_arguments=$arguments;
1104
+ $this->request_headers=(IsSet($arguments["Headers"]) ? $arguments["Headers"] : array());
1105
+ $body_length=0;
1106
+ $this->request_body="";
1107
+ $get_body=1;
1108
+ if($this->request_method=="POST"
1109
+ || $this->request_method=="PUT")
1110
+ {
1111
+ if(IsSet($arguments['StreamRequest']))
1112
+ {
1113
+ $get_body = 0;
1114
+ $this->request_headers["Transfer-Encoding"]="chunked";
1115
+ }
1116
+ elseif(IsSet($arguments["PostFiles"])
1117
+ || ($this->force_multipart_form_post
1118
+ && IsSet($arguments["PostValues"])))
1119
+ {
1120
+ $boundary="--".md5(uniqid(time()));
1121
+ $this->request_headers["Content-Type"]="multipart/form-data; boundary=".$boundary.(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : "");
1122
+ $post_parts=array();
1123
+ if(IsSet($arguments["PostValues"]))
1124
+ {
1125
+ $values=$arguments["PostValues"];
1126
+ if(GetType($values)!="array")
1127
+ return($this->SetError("it was not specified a valid POST method values array", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1128
+ for(Reset($values),$value=0;$value<count($values);Next($values),$value++)
1129
+ {
1130
+ $input=Key($values);
1131
+ $headers="--".$boundary."\r\nContent-Disposition: form-data; name=\"".$input."\"\r\n\r\n";
1132
+ $data=$values[$input];
1133
+ $post_parts[]=array("HEADERS"=>$headers,"DATA"=>$data);
1134
+ $body_length+=strlen($headers)+strlen($data)+strlen("\r\n");
1135
+ }
1136
+ }
1137
+ $body_length+=strlen("--".$boundary."--\r\n");
1138
+ $files=(IsSet($arguments["PostFiles"]) ? $arguments["PostFiles"] : array());
1139
+ Reset($files);
1140
+ $end=(GetType($input=Key($files))!="string");
1141
+ for(;!$end;)
1142
+ {
1143
+ if(strlen($error=$this->GetFileDefinition($files[$input],$definition)))
1144
+ return("3 ".$error);
1145
+ $headers="--".$boundary."\r\nContent-Disposition: form-data; name=\"".$input."\"; filename=\"".$definition["NAME"]."\"\r\nContent-Type: ".$definition["Content-Type"]."\r\n\r\n";
1146
+ $part=count($post_parts);
1147
+ $post_parts[$part]=array("HEADERS"=>$headers);
1148
+ if(IsSet($definition["FILENAME"]))
1149
+ {
1150
+ $post_parts[$part]["FILENAME"]=$definition["FILENAME"];
1151
+ $data="";
1152
+ }
1153
+ else
1154
+ $data=$definition["DATA"];
1155
+ $post_parts[$part]["DATA"]=$data;
1156
+ $body_length+=strlen($headers)+$definition["Content-Length"]+strlen("\r\n");
1157
+ Next($files);
1158
+ $end=(GetType($input=Key($files))!="string");
1159
+ }
1160
+ $get_body=0;
1161
+ }
1162
+ elseif(IsSet($arguments["PostValues"]))
1163
+ {
1164
+ $values=$arguments["PostValues"];
1165
+ if(GetType($values)!="array")
1166
+ return($this->SetError("it was not specified a valid POST method values array", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1167
+ for(Reset($values),$value=0;$value<count($values);Next($values),$value++)
1168
+ {
1169
+ $k=Key($values);
1170
+ if(GetType($values[$k])=="array")
1171
+ {
1172
+ for($v = 0; $v < count($values[$k]); $v++)
1173
+ {
1174
+ if($value+$v>0)
1175
+ $this->request_body.="&";
1176
+ $this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k][$v]);
1177
+ }
1178
+ }
1179
+ else
1180
+ {
1181
+ if($value>0)
1182
+ $this->request_body.="&";
1183
+ $this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k]);
1184
+ }
1185
+ }
1186
+ $this->request_headers["Content-Type"]="application/x-www-form-urlencoded".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : "");
1187
+ $get_body=0;
1188
+ }
1189
+ }
1190
+ if($get_body
1191
+ && (IsSet($arguments["Body"])
1192
+ || IsSet($arguments["BodyStream"])))
1193
+ {
1194
+ if(IsSet($arguments["Body"]))
1195
+ $this->request_body=$arguments["Body"];
1196
+ else
1197
+ {
1198
+ $stream=$arguments["BodyStream"];
1199
+ $this->request_body="";
1200
+ for($part=0; $part<count($stream); $part++)
1201
+ {
1202
+ if(IsSet($stream[$part]["Data"]))
1203
+ $this->request_body.=$stream[$part]["Data"];
1204
+ elseif(IsSet($stream[$part]["File"]))
1205
+ {
1206
+ if(!($file=@fopen($stream[$part]["File"],"rb")))
1207
+ return($this->SetPHPError("could not open upload file ".$stream[$part]["File"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE));
1208
+ while(!feof($file))
1209
+ {
1210
+ if(GetType($block=@fread($file,$this->file_buffer_length))!="string")
1211
+ {
1212
+ $error=$this->SetPHPError("could not read body stream file ".$stream[$part]["File"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
1213
+ fclose($file);
1214
+ return($error);
1215
+ }
1216
+ $this->request_body.=$block;
1217
+ }
1218
+ fclose($file);
1219
+ }
1220
+ else
1221
+ return("5 it was not specified a valid file or data body stream element at position ".$part);
1222
+ }
1223
+ }
1224
+ if(!IsSet($this->request_headers["Content-Type"]))
1225
+ $this->request_headers["Content-Type"]="application/octet-stream".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : "");
1226
+ }
1227
+ if(IsSet($arguments["AuthUser"]))
1228
+ $this->request_user=$arguments["AuthUser"];
1229
+ elseif(IsSet($this->user))
1230
+ $this->request_user=$this->user;
1231
+ if(IsSet($arguments["AuthPassword"]))
1232
+ $this->request_password=$arguments["AuthPassword"];
1233
+ elseif(IsSet($this->password))
1234
+ $this->request_password=$this->password;
1235
+ if(IsSet($arguments["AuthRealm"]))
1236
+ $this->request_realm=$arguments["AuthRealm"];
1237
+ elseif(IsSet($this->realm))
1238
+ $this->request_realm=$this->realm;
1239
+ if(IsSet($arguments["AuthWorkstation"]))
1240
+ $this->request_workstation=$arguments["AuthWorkstation"];
1241
+ elseif(IsSet($this->workstation))
1242
+ $this->request_workstation=$this->workstation;
1243
+ if(strlen($this->proxy_host_name)==0
1244
+ || $connect)
1245
+ $request_uri=$this->request_uri;
1246
+ else
1247
+ {
1248
+ switch(strtolower($this->protocol))
1249
+ {
1250
+ case "http":
1251
+ $default_port=80;
1252
+ break;
1253
+ case "https":
1254
+ $default_port=443;
1255
+ break;
1256
+ }
1257
+ $request_uri=strtolower($this->protocol)."://".$this->host_name.(($this->host_port==0 || $this->host_port==$default_port) ? "" : ":".$this->host_port).$this->request_uri;
1258
+ }
1259
+ if($this->use_curl)
1260
+ {
1261
+ $version=(GetType($v=curl_version())=="array" ? (IsSet($v["version"]) ? $v["version"] : "0.0.0") : (preg_match("/^libcurl\\/([0-9]+\\.[0-9]+\\.[0-9]+)/",$v,$m) ? $m[1] : "0.0.0"));
1262
+ $curl_version=100000*intval($this->Tokenize($version,"."))+1000*intval($this->Tokenize("."))+intval($this->Tokenize(""));
1263
+ $protocol_version=($curl_version<713002 ? "1.0" : $this->protocol_version);
1264
+ }
1265
+ else
1266
+ $protocol_version=$this->protocol_version;
1267
+ $this->request=$this->request_method." ".$request_uri." HTTP/".$protocol_version;
1268
+ if($body_length
1269
+ || ($body_length=strlen($this->request_body)))
1270
+ $this->request_headers["Content-Length"]=$body_length;
1271
+ for($headers=array(),$host_set=0,Reset($this->request_headers),$header=0;$header<count($this->request_headers);Next($this->request_headers),$header++)
1272
+ {
1273
+ $header_name=Key($this->request_headers);
1274
+ $header_value=$this->request_headers[$header_name];
1275
+ if(GetType($header_value)=="array")
1276
+ {
1277
+ for(Reset($header_value),$value=0;$value<count($header_value);Next($header_value),$value++)
1278
+ $headers[]=$header_name.": ".$header_value[Key($header_value)];
1279
+ }
1280
+ else
1281
+ $headers[]=$header_name.": ".$header_value;
1282
+ if(strtolower(Key($this->request_headers))=="host")
1283
+ {
1284
+ $this->request_host=strtolower($header_value);
1285
+ $host_set=1;
1286
+ }
1287
+ }
1288
+ if(!$host_set)
1289
+ {
1290
+ $headers[]="Host: ".$this->host_name;
1291
+ $this->request_host=strtolower($this->host_name);
1292
+ }
1293
+ if(count($this->cookies))
1294
+ {
1295
+ $cookies=array();
1296
+ $this->PickCookies($cookies,0);
1297
+ if(strtolower($this->protocol)=="https")
1298
+ $this->PickCookies($cookies,1);
1299
+ if(count($cookies))
1300
+ {
1301
+ $h=count($headers);
1302
+ $headers[$h]="Cookie:";
1303
+ for(Reset($cookies),$cookie=0;$cookie<count($cookies);Next($cookies),$cookie++)
1304
+ {
1305
+ $cookie_name=Key($cookies);
1306
+ $headers[$h].=" ".$cookie_name."=".$cookies[$cookie_name]["value"].";";
1307
+ }
1308
+ }
1309
+ }
1310
+ $next_state = "RequestSent";
1311
+ if($this->use_curl)
1312
+ {
1313
+ if(IsSet($arguments['StreamRequest']))
1314
+ return($this->SetError("Streaming request data is not supported when using Curl", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1315
+ if($body_length
1316
+ && strlen($this->request_body)==0)
1317
+ {
1318
+ for($request_body="",$success=1,$part=0;$part<count($post_parts);$part++)
1319
+ {
1320
+ $request_body.=$post_parts[$part]["HEADERS"].$post_parts[$part]["DATA"];
1321
+ if(IsSet($post_parts[$part]["FILENAME"]))
1322
+ {
1323
+ if(!($file=@fopen($post_parts[$part]["FILENAME"],"rb")))
1324
+ {
1325
+ $this->SetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
1326
+ $success=0;
1327
+ break;
1328
+ }
1329
+ while(!feof($file))
1330
+ {
1331
+ if(GetType($block=@fread($file,$this->file_buffer_length))!="string")
1332
+ {
1333
+ $this->SetPHPError("could not read upload file", $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
1334
+ $success=0;
1335
+ break;
1336
+ }
1337
+ $request_body.=$block;
1338
+ }
1339
+ fclose($file);
1340
+ if(!$success)
1341
+ break;
1342
+ }
1343
+ $request_body.="\r\n";
1344
+ }
1345
+ $request_body.="--".$boundary."--\r\n";
1346
+ }
1347
+ else
1348
+ $request_body=$this->request_body;
1349
+ curl_setopt($this->connection,CURLOPT_HEADER,1);
1350
+ curl_setopt($this->connection,CURLOPT_RETURNTRANSFER,1);
1351
+ if($this->timeout)
1352
+ curl_setopt($this->connection,CURLOPT_TIMEOUT,$this->timeout);
1353
+ curl_setopt($this->connection,CURLOPT_SSL_VERIFYPEER,0);
1354
+ curl_setopt($this->connection,CURLOPT_SSL_VERIFYHOST,0);
1355
+ $request=$this->request."\r\n".implode("\r\n",$headers)."\r\n\r\n".$request_body;
1356
+ curl_setopt($this->connection,CURLOPT_CUSTOMREQUEST,$request);
1357
+ if($this->debug)
1358
+ $this->OutputDebug("C ".$request);
1359
+ if(!($success=(strlen($this->response=curl_exec($this->connection))!=0)))
1360
+ {
1361
+ $error=curl_error($this->connection);
1362
+ $this->SetError("Could not execute the request".(strlen($error) ? ": ".$error : ""), HTTP_CLIENT_ERROR_PROTOCOL_FAILURE);
1363
+ }
1364
+ }
1365
+ else
1366
+ {
1367
+ if(($success=$this->PutLine($this->request)))
1368
+ {
1369
+ for($header=0;$header<count($headers);$header++)
1370
+ {
1371
+ if(!$success=$this->PutLine($headers[$header]))
1372
+ break;
1373
+ }
1374
+ if($success
1375
+ && ($success=$this->PutLine("")))
1376
+ {
1377
+ if(IsSet($arguments['StreamRequest']))
1378
+ $next_state = "SendingRequestBody";
1379
+ elseif($body_length)
1380
+ {
1381
+ if(strlen($this->request_body))
1382
+ $success=$this->PutData($this->request_body);
1383
+ else
1384
+ {
1385
+ for($part=0;$part<count($post_parts);$part++)
1386
+ {
1387
+ if(!($success=$this->PutData($post_parts[$part]["HEADERS"]))
1388
+ || !($success=$this->PutData($post_parts[$part]["DATA"])))
1389
+ break;
1390
+ if(IsSet($post_parts[$part]["FILENAME"]))
1391
+ {
1392
+ if(!($file=@fopen($post_parts[$part]["FILENAME"],"rb")))
1393
+ {
1394
+ $this->SetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
1395
+ $success=0;
1396
+ break;
1397
+ }
1398
+ while(!feof($file))
1399
+ {
1400
+ if(GetType($block=@fread($file,$this->file_buffer_length))!="string")
1401
+ {
1402
+ $this->SetPHPError("could not read upload file", $php_errormsg, HTTP_CLIENT_ERROR_CANNOT_ACCESS_LOCAL_FILE);
1403
+ $success=0;
1404
+ break;
1405
+ }
1406
+ if(!($success=$this->PutData($block)))
1407
+ break;
1408
+ }
1409
+ fclose($file);
1410
+ if(!$success)
1411
+ break;
1412
+ }
1413
+ if(!($success=$this->PutLine("")))
1414
+ break;
1415
+ }
1416
+ if($success)
1417
+ $success=$this->PutLine("--".$boundary."--");
1418
+ }
1419
+ if($success)
1420
+ $sucess=$this->FlushData();
1421
+ }
1422
+ }
1423
+ }
1424
+ }
1425
+ if(!$success)
1426
+ return($this->SetError("could not send the HTTP request: ".$this->error, $this->error_code));
1427
+ $this->state=$next_state;
1428
+ return("");
1429
+ }
1430
+
1431
+ Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
1432
+ {
1433
+ if(strlen($this->error))
1434
+ return($this->error);
1435
+ if(strlen($name)==0)
1436
+ return($this->SetError("it was not specified a valid cookie name", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1437
+ if(strlen($path)==0
1438
+ || strcmp($path[0],"/"))
1439
+ return($this->SetError($path." is not a valid path for setting cookie ".$name, HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1440
+ if($domain==""
1441
+ || !strpos($domain,".",$domain[0]=="." ? 1 : 0))
1442
+ return($this->SetError($domain." is not a valid domain for setting cookie ".$name, HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1443
+ $domain=strtolower($domain);
1444
+ if(!strcmp($domain[0],"."))
1445
+ $domain=substr($domain,1);
1446
+ if(!$verbatim)
1447
+ {
1448
+ $name=$this->CookieEncode($name,1);
1449
+ $value=$this->CookieEncode($value,0);
1450
+ }
1451
+ $secure=intval($secure);
1452
+ $this->cookies[$secure][$domain][$path][$name]=array(
1453
+ "name"=>$name,
1454
+ "value"=>$value,
1455
+ "domain"=>$domain,
1456
+ "path"=>$path,
1457
+ "expires"=>$expires,
1458
+ "secure"=>$secure
1459
+ );
1460
+ return("");
1461
+ }
1462
+
1463
+ Function SendRequestBody($data, $end_of_data)
1464
+ {
1465
+ if(strlen($this->error))
1466
+ return($this->error);
1467
+ switch($this->state)
1468
+ {
1469
+ case "Disconnected":
1470
+ return($this->SetError("connection was not yet established", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1471
+ case "Connected":
1472
+ case "ConnectedToProxy":
1473
+ return($this->SetError("request was not sent", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1474
+ case "SendingRequestBody":
1475
+ break;
1476
+ case "RequestSent":
1477
+ return($this->SetError("request body was already sent", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1478
+ default:
1479
+ return($this->SetError("can not send the request body in the current connection state", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1480
+ }
1481
+ $length = strlen($data);
1482
+ if($length)
1483
+ {
1484
+ $size = dechex($length)."\r\n";
1485
+ if(!$this->PutData($size)
1486
+ || !$this->PutData($data))
1487
+ return($this->error);
1488
+ }
1489
+ if($end_of_data)
1490
+ {
1491
+ $size = "0\r\n";
1492
+ if(!$this->PutData($size))
1493
+ return($this->error);
1494
+ $this->state = "RequestSent";
1495
+ }
1496
+ return("");
1497
+ }
1498
+
1499
+ Function ReadReplyHeadersResponse(&$headers)
1500
+ {
1501
+ $headers=array();
1502
+ if(strlen($this->error))
1503
+ return($this->error);
1504
+ switch($this->state)
1505
+ {
1506
+ case "Disconnected":
1507
+ return($this->SetError("connection was not yet established", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1508
+ case "Connected":
1509
+ return($this->SetError("request was not sent", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1510
+ case "ConnectedToProxy":
1511
+ return($this->SetError("connection from the remote server from the proxy was not yet established", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1512
+ case "SendingRequestBody":
1513
+ return($this->SetError("request body data was not completely sent", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1514
+ case "ConnectSent":
1515
+ $connect = 1;
1516
+ break;
1517
+ case "RequestSent":
1518
+ $connect = 0;
1519
+ break;
1520
+ default:
1521
+ return($this->SetError("can not get request headers in the current connection state", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1522
+ }
1523
+ $this->content_length=$this->read_length=$this->read_response=$this->remaining_chunk=0;
1524
+ $this->content_length_set=$this->chunked=$this->last_chunk_read=$chunked=0;
1525
+ $this->force_close = $this->connection_close=0;
1526
+ for($this->response_status="";;)
1527
+ {
1528
+ $line=$this->GetLine();
1529
+ if(GetType($line)!="string")
1530
+ return($this->SetError("could not read request reply: ".$this->error, $this->error_code));
1531
+ if(strlen($this->response_status)==0)
1532
+ {
1533
+ if(!preg_match($match="/^http\\/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$/i",$line,$matches))
1534
+ return($this->SetError("it was received an unexpected HTTP response status", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1535
+ $this->response_status=$matches[1];
1536
+ $this->response_message=$matches[2];
1537
+ }
1538
+ if($line=="")
1539
+ {
1540
+ if(strlen($this->response_status)==0)
1541
+ return($this->SetError("it was not received HTTP response status", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1542
+ $this->state=($connect ? "GotConnectHeaders" : "GotReplyHeaders");
1543
+ break;
1544
+ }
1545
+ $header_name=strtolower($this->Tokenize($line,":"));
1546
+ $header_value=Trim(Chop($this->Tokenize("\r\n")));
1547
+ if(IsSet($headers[$header_name]))
1548
+ {
1549
+ if(GetType($headers[$header_name])=="string")
1550
+ $headers[$header_name]=array($headers[$header_name]);
1551
+ $headers[$header_name][]=$header_value;
1552
+ }
1553
+ else
1554
+ $headers[$header_name]=$header_value;
1555
+ if(!$connect)
1556
+ {
1557
+ switch($header_name)
1558
+ {
1559
+ case "content-length":
1560
+ $this->content_length=intval($headers[$header_name]);
1561
+ $this->content_length_set=1;
1562
+ break;
1563
+ case "transfer-encoding":
1564
+ $encoding=$this->Tokenize($header_value,"; \t");
1565
+ if(!$this->use_curl
1566
+ && !strcmp($encoding,"chunked"))
1567
+ $chunked=1;
1568
+ break;
1569
+ case "set-cookie":
1570
+ if($this->support_cookies)
1571
+ {
1572
+ if(GetType($headers[$header_name])=="array")
1573
+ $cookie_headers=$headers[$header_name];
1574
+ else
1575
+ $cookie_headers=array($headers[$header_name]);
1576
+ for($cookie=0;$cookie<count($cookie_headers);$cookie++)
1577
+ {
1578
+ $cookie_name=trim($this->Tokenize($cookie_headers[$cookie],"="));
1579
+ $cookie_value=$this->Tokenize(";");
1580
+ $domain=$this->request_host;
1581
+ $path="/";
1582
+ $expires="";
1583
+ $secure=0;
1584
+ while(($name = strtolower(trim(UrlDecode($this->Tokenize("=")))))!="")
1585
+ {
1586
+ $value=UrlDecode($this->Tokenize(";"));
1587
+ switch($name)
1588
+ {
1589
+ case "domain":
1590
+ $domain=$value;
1591
+ break;
1592
+ case "path":
1593
+ $path=$value;
1594
+ break;
1595
+ case "expires":
1596
+ if(preg_match("/^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT\$/",$value,$matches))
1597
+ {
1598
+ $year=intval($matches[5]);
1599
+ if($year<1900)
1600
+ $year+=($year<70 ? 2000 : 1900);
1601
+ $expires="$year-".$this->months[$matches[4]]."-".$matches[3]." ".$matches[6].":".$matches[7].":".$matches[8];
1602
+ }
1603
+ break;
1604
+ case "secure":
1605
+ $secure=1;
1606
+ break;
1607
+ }
1608
+ }
1609
+ if(strlen($this->SetCookie($cookie_name, $cookie_value, $expires, $path , $domain, $secure, 1)))
1610
+ $this->error="";
1611
+ }
1612
+ }
1613
+ break;
1614
+ case "connection":
1615
+ $this->force_close = $this->connection_close=!strcmp(strtolower($header_value),"close");
1616
+ break;
1617
+ }
1618
+ }
1619
+ }
1620
+ $this->chunked=$chunked;
1621
+ if($this->content_length_set)
1622
+ $this->connection_close=0;
1623
+ return("");
1624
+ }
1625
+
1626
+ Function Redirect(&$headers)
1627
+ {
1628
+ if($this->follow_redirect)
1629
+ {
1630
+ if(!IsSet($headers["location"])
1631
+ || (GetType($headers["location"])!="array"
1632
+ && strlen($location=$headers["location"])==0)
1633
+ || (GetType($headers["location"])=="array"
1634
+ && strlen($location=$headers["location"][0])==0))
1635
+ return($this->SetError("it was received a redirect without location URL", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1636
+ if(strcmp($location[0],"/"))
1637
+ {
1638
+ if(!($location_arguments=@parse_url($location)))
1639
+ return($this->SetError("the server did not return a valid redirection location URL", HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1640
+ if(!IsSet($location_arguments["scheme"]))
1641
+ $location=((GetType($end=strrpos($this->request_uri,"/"))=="integer" && $end>1) ? substr($this->request_uri,0,$end) : "")."/".$location;
1642
+ }
1643
+ if(!strcmp($location[0],"/"))
1644
+ $location=$this->protocol."://".$this->host_name.($this->host_port ? ":".$this->host_port : "").$location;
1645
+ $error=$this->GetRequestArguments($location,$arguments);
1646
+ if(strlen($error))
1647
+ return($this->SetError("could not process redirect url: ".$error, HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1648
+ $arguments["RequestMethod"]="GET";
1649
+ if(strlen($error=$this->Close())==0
1650
+ && strlen($error=$this->Open($arguments))==0
1651
+ && strlen($error=$this->SendRequest($arguments))==0)
1652
+ {
1653
+ $this->redirection_level++;
1654
+ if($this->redirection_level>$this->redirection_limit)
1655
+ {
1656
+ $error="it was exceeded the limit of request redirections";
1657
+ $this->error_code = HTTP_CLIENT_ERROR_PROTOCOL_FAILURE;
1658
+ }
1659
+ else
1660
+ $error=$this->ReadReplyHeaders($headers);
1661
+ $this->redirection_level--;
1662
+ }
1663
+ if(strlen($error))
1664
+ return($this->SetError($error, $this->error_code));
1665
+ }
1666
+ return("");
1667
+ }
1668
+
1669
+ Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
1670
+ {
1671
+ if($proxy)
1672
+ {
1673
+ $authenticate_header="proxy-authenticate";
1674
+ $authorization_header="Proxy-Authorization";
1675
+ $authenticate_status="407";
1676
+ $authentication_mechanism=$this->proxy_authentication_mechanism;
1677
+ }
1678
+ else
1679
+ {
1680
+ $authenticate_header="www-authenticate";
1681
+ $authorization_header="Authorization";
1682
+ $authenticate_status="401";
1683
+ $authentication_mechanism=$this->authentication_mechanism;
1684
+ }
1685
+ if(IsSet($headers[$authenticate_header])
1686
+ && $this->sasl_authenticate)
1687
+ {
1688
+ if(function_exists("class_exists")
1689
+ && !class_exists("sasl_client_class"))
1690
+ return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1691
+ if(GetType($headers[$authenticate_header])=="array")
1692
+ $authenticate=$headers[$authenticate_header];
1693
+ else
1694
+ $authenticate=array($headers[$authenticate_header]);
1695
+ for($response="", $mechanisms=array(),$m=0;$m<count($authenticate);$m++)
1696
+ {
1697
+ $mechanism=$this->Tokenize($authenticate[$m]," ");
1698
+ $response=$this->Tokenize("");
1699
+ if(strlen($authentication_mechanism))
1700
+ {
1701
+ if(!strcmp($authentication_mechanism,$mechanism))
1702
+ {
1703
+ $mechanisms[]=$mechanism;
1704
+ break;
1705
+ }
1706
+ }
1707
+ else
1708
+ $mechanisms[]=$mechanism;
1709
+ }
1710
+ $sasl=new sasl_client_class;
1711
+ if(IsSet($user))
1712
+ $sasl->SetCredential("user",$user);
1713
+ if(IsSet($password))
1714
+ $sasl->SetCredential("password",$password);
1715
+ if(IsSet($realm))
1716
+ $sasl->SetCredential("realm",$realm);
1717
+ if(IsSet($workstation))
1718
+ $sasl->SetCredential("workstation",$workstation);
1719
+ $sasl->SetCredential("uri",$this->request_uri);
1720
+ $sasl->SetCredential("method",$this->request_method);
1721
+ $sasl->SetCredential("session",$this->session);
1722
+ do
1723
+ {
1724
+ $status=$sasl->Start($mechanisms,$message,$interactions);
1725
+ }
1726
+ while($status==SASL_INTERACT);
1727
+ switch($status)
1728
+ {
1729
+ case SASL_CONTINUE:
1730
+ break;
1731
+ case SASL_NOMECH:
1732
+ return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".(strlen($authentication_mechanism) ? "authentication mechanism ".$authentication_mechanism." may not be used: " : "").$sasl->error, HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1733
+ default:
1734
+ return($this->SetError("Could not start the SASL ".($proxy ? "proxy " : "")."authentication client: ".$sasl->error, HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1735
+ }
1736
+ if($proxy >= 0)
1737
+ {
1738
+ for(;;)
1739
+ {
1740
+ if(strlen($error=$this->ReadReplyBody($body,$this->file_buffer_length)))
1741
+ return($error);
1742
+ if(strlen($body)==0)
1743
+ break;
1744
+ }
1745
+ }
1746
+ $authorization_value=$sasl->mechanism.(IsSet($message) ? " ".($sasl->encode_response ? base64_encode($message) : $message) : "");
1747
+ $request_arguments=$this->request_arguments;
1748
+ $arguments=$request_arguments;
1749
+ $arguments["Headers"][$authorization_header]=$authorization_value;
1750
+ if(!$proxy
1751
+ && strlen($proxy_authorization))
1752
+ $arguments["Headers"]["Proxy-Authorization"]=$proxy_authorization;
1753
+ if(strlen($error=$this->Close())
1754
+ || strlen($error=$this->Open($arguments)))
1755
+ return($this->SetError($error, $this->error_code));
1756
+ $authenticated=0;
1757
+ if(IsSet($message))
1758
+ {
1759
+ if($proxy < 0)
1760
+ {
1761
+ if(strlen($error=$this->ConnectFromProxy($arguments, $headers)))
1762
+ return($this->SetError($error, $this->error_code));
1763
+ }
1764
+ else
1765
+ {
1766
+ if(strlen($error=$this->SendRequest($arguments))
1767
+ || strlen($error=$this->ReadReplyHeadersResponse($headers)))
1768
+ return($this->SetError($error, $this->error_code));
1769
+ }
1770
+ if(!IsSet($headers[$authenticate_header]))
1771
+ $authenticate=array();
1772
+ elseif(GetType($headers[$authenticate_header])=="array")
1773
+ $authenticate=$headers[$authenticate_header];
1774
+ else
1775
+ $authenticate=array($headers[$authenticate_header]);
1776
+ for($mechanism=0;$mechanism<count($authenticate);$mechanism++)
1777
+ {
1778
+ if(!strcmp($this->Tokenize($authenticate[$mechanism]," "),$sasl->mechanism))
1779
+ {
1780
+ $response=$this->Tokenize("");
1781
+ break;
1782
+ }
1783
+ }
1784
+ switch($this->response_status)
1785
+ {
1786
+ case $authenticate_status:
1787
+ break;
1788
+ case "301":
1789
+ case "302":
1790
+ case "303":
1791
+ case "307":
1792
+ if($proxy >= 0)
1793
+ return($this->Redirect($headers));
1794
+ default:
1795
+ if(intval($this->response_status/100)==2)
1796
+ {
1797
+ if($proxy)
1798
+ $proxy_authorization=$authorization_value;
1799
+ $authenticated=1;
1800
+ break;
1801
+ }
1802
+ if($proxy
1803
+ && !strcmp($this->response_status,"401"))
1804
+ {
1805
+ $proxy_authorization=$authorization_value;
1806
+ $authenticated=1;
1807
+ break;
1808
+ }
1809
+ return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".$this->response_status." ".$this->response_message, HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1810
+ }
1811
+ }
1812
+ for(;!$authenticated;)
1813
+ {
1814
+ do
1815
+ {
1816
+ $status=$sasl->Step($response,$message,$interactions);
1817
+ }
1818
+ while($status==SASL_INTERACT);
1819
+ switch($status)
1820
+ {
1821
+ case SASL_CONTINUE:
1822
+ $authorization_value=$sasl->mechanism.(IsSet($message) ? " ".($sasl->encode_response ? base64_encode($message) : $message) : "");
1823
+ $arguments=$request_arguments;
1824
+ $arguments["Headers"][$authorization_header]=$authorization_value;
1825
+ if(!$proxy
1826
+ && strlen($proxy_authorization))
1827
+ $arguments["Headers"]["Proxy-Authorization"]=$proxy_authorization;
1828
+ if($proxy < 0)
1829
+ {
1830
+ if(strlen($error=$this->ConnectFromProxy($arguments, $headers)))
1831
+ return($this->SetError($error, $this->error_code));
1832
+ }
1833
+ else
1834
+ {
1835
+ if(strlen($error=$this->SendRequest($arguments))
1836
+ || strlen($error=$this->ReadReplyHeadersResponse($headers)))
1837
+ return($this->SetError($error, $this->error_code));
1838
+ }
1839
+ switch($this->response_status)
1840
+ {
1841
+ case $authenticate_status:
1842
+ if(GetType($headers[$authenticate_header])=="array")
1843
+ $authenticate=$headers[$authenticate_header];
1844
+ else
1845
+ $authenticate=array($headers[$authenticate_header]);
1846
+ for($response="",$mechanism=0;$mechanism<count($authenticate);$mechanism++)
1847
+ {
1848
+ if(!strcmp($this->Tokenize($authenticate[$mechanism]," "),$sasl->mechanism))
1849
+ {
1850
+ $response=$this->Tokenize("");
1851
+ break;
1852
+ }
1853
+ }
1854
+ if($proxy >= 0)
1855
+ {
1856
+ for(;;)
1857
+ {
1858
+ if(strlen($error=$this->ReadReplyBody($body,$this->file_buffer_length)))
1859
+ return($error);
1860
+ if(strlen($body)==0)
1861
+ break;
1862
+ }
1863
+ }
1864
+ $this->state="Connected";
1865
+ break;
1866
+ case "301":
1867
+ case "302":
1868
+ case "303":
1869
+ case "307":
1870
+ if($proxy >= 0)
1871
+ return($this->Redirect($headers));
1872
+ default:
1873
+ if(intval($this->response_status/100)==2)
1874
+ {
1875
+ if($proxy)
1876
+ $proxy_authorization=$authorization_value;
1877
+ $authenticated=1;
1878
+ break;
1879
+ }
1880
+ if($proxy
1881
+ && !strcmp($this->response_status,"401"))
1882
+ {
1883
+ $proxy_authorization=$authorization_value;
1884
+ $authenticated=1;
1885
+ break;
1886
+ }
1887
+ return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".$this->response_status." ".$this->response_message));
1888
+ }
1889
+ break;
1890
+ default:
1891
+ return($this->SetError("Could not process the SASL ".($proxy ? "proxy " : "")."authentication step: ".$sasl->error, HTTP_CLIENT_ERROR_PROTOCOL_FAILURE));
1892
+ }
1893
+ }
1894
+ }
1895
+ return("");
1896
+ }
1897
+
1898
+ Function ReadReplyHeaders(&$headers)
1899
+ {
1900
+ if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
1901
+ return($error);
1902
+ $proxy_authorization="";
1903
+ while(!strcmp($this->response_status, "100"))
1904
+ {
1905
+ $this->state="RequestSent";
1906
+ if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
1907
+ return($error);
1908
+ }
1909
+ switch($this->response_status)
1910
+ {
1911
+ case "301":
1912
+ case "302":
1913
+ case "303":
1914
+ case "307":
1915
+ if(strlen($error=$this->Redirect($headers)))
1916
+ return($error);
1917
+ break;
1918
+ case "407":
1919
+ if(strlen($error=$this->Authenticate($headers, 1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation)))
1920
+ return($error);
1921
+ if(strcmp($this->response_status,"401"))
1922
+ return("");
1923
+ case "401":
1924
+ return($this->Authenticate($headers, 0, $proxy_authorization, $this->request_user, $this->request_password, $this->request_realm, $this->request_workstation));
1925
+ }
1926
+ return("");
1927
+ }
1928
+
1929
+ Function ReadReplyBody(&$body,$length)
1930
+ {
1931
+ $body="";
1932
+ if(strlen($this->error))
1933
+ return($this->error);
1934
+ switch($this->state)
1935
+ {
1936
+ case "Disconnected":
1937
+ return($this->SetError("connection was not yet established", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1938
+ case "Connected":
1939
+ case "ConnectedToProxy":
1940
+ return($this->SetError("request was not sent", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1941
+ case "RequestSent":
1942
+ if(($error=$this->ReadReplyHeaders($headers))!="")
1943
+ return($error);
1944
+ break;
1945
+ case "GotReplyHeaders":
1946
+ break;
1947
+ case 'ResponseReceived':
1948
+ $body = '';
1949
+ return('');
1950
+ default:
1951
+ return($this->SetError("can not get request headers in the current connection state", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
1952
+ }
1953
+ if($this->content_length_set)
1954
+ $length=min($this->content_length-$this->read_length,$length);
1955
+ $body = '';
1956
+ if($length>0)
1957
+ {
1958
+ if(!$this->EndOfInput()
1959
+ && ($body=$this->ReadBytes($length))=="")
1960
+ {
1961
+ if(strlen($this->error))
1962
+ return($this->SetError("could not get the request reply body: ".$this->error, $this->error_code));
1963
+ }
1964
+ $this->read_length+=strlen($body);
1965
+ if($this->EndOfInput())
1966
+ $this->state = 'ResponseReceived';
1967
+ }
1968
+ return("");
1969
+ }
1970
+
1971
+ Function ReadWholeReplyBody(&$body)
1972
+ {
1973
+ $body = '';
1974
+ for(;;)
1975
+ {
1976
+ if(strlen($error = $this->ReadReplyBody($block, $this->file_buffer_length)))
1977
+ return($error);
1978
+ if(strlen($block) == 0)
1979
+ return('');
1980
+ $body .= $block;
1981
+ }
1982
+ }
1983
+
1984
+ Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
1985
+ {
1986
+ $now=gmdate("Y-m-d H-i-s");
1987
+ $cookies=array();
1988
+ for($secure_cookies=0,Reset($this->cookies);$secure_cookies<count($this->cookies);Next($this->cookies),$secure_cookies++)
1989
+ {
1990
+ $secure=Key($this->cookies);
1991
+ if(!$secure_only
1992
+ || $secure)
1993
+ {
1994
+ for($cookie_domain=0,Reset($this->cookies[$secure]);$cookie_domain<count($this->cookies[$secure]);Next($this->cookies[$secure]),$cookie_domain++)
1995
+ {
1996
+ $domain_pattern=Key($this->cookies[$secure]);
1997
+ $match=strlen($domain)-strlen($domain_pattern);
1998
+ if(strlen($domain)==0
1999
+ || ($match>=0
2000
+ && !strcmp($domain_pattern,substr($domain,$match))
2001
+ && ($match==0
2002
+ || $domain_pattern[0]=="."
2003
+ || $domain[$match-1]==".")))
2004
+ {
2005
+ for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++)
2006
+ {
2007
+ $path=Key($this->cookies[$secure][$domain_pattern]);
2008
+ for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++)
2009
+ {
2010
+ $cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]);
2011
+ $expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"];
2012
+ if((!$persistent_only
2013
+ && strlen($expires)==0)
2014
+ || (strlen($expires)
2015
+ && strcmp($now,$expires)<0))
2016
+ $cookies[$secure][$domain_pattern][$path][$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name];
2017
+ }
2018
+ }
2019
+ }
2020
+ }
2021
+ }
2022
+ }
2023
+ }
2024
+
2025
+ Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
2026
+ {
2027
+ $this->SaveCookies($cookies, $domain, $secure_only, 1);
2028
+ }
2029
+
2030
+ Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
2031
+ {
2032
+ $this->SavePersistentCookies($cookies, $domain, $secure_only);
2033
+ }
2034
+
2035
+ Function RestoreCookies($cookies, $clear=1)
2036
+ {
2037
+ $new_cookies=($clear ? array() : $this->cookies);
2038
+ for($secure_cookies=0, Reset($cookies); $secure_cookies<count($cookies); Next($cookies), $secure_cookies++)
2039
+ {
2040
+ $secure=Key($cookies);
2041
+ if(GetType($secure)!="integer")
2042
+ return($this->SetError("invalid cookie secure value type (".serialize($secure).")", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
2043
+ for($cookie_domain=0,Reset($cookies[$secure]);$cookie_domain<count($cookies[$secure]);Next($cookies[$secure]),$cookie_domain++)
2044
+ {
2045
+ $domain_pattern=Key($cookies[$secure]);
2046
+ if(GetType($domain_pattern)!="string")
2047
+ return($this->SetError("invalid cookie domain value type (".serialize($domain_pattern).")", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
2048
+ for(Reset($cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($cookies[$secure][$domain_pattern]);Next($cookies[$secure][$domain_pattern]),$path_part++)
2049
+ {
2050
+ $path=Key($cookies[$secure][$domain_pattern]);
2051
+ if(GetType($path)!="string"
2052
+ || strcmp(substr($path, 0, 1), "/"))
2053
+ return($this->SetError("invalid cookie path value type (".serialize($path).")", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
2054
+ for(Reset($cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($cookies[$secure][$domain_pattern][$path]);Next($cookies[$secure][$domain_pattern][$path]),$cookie++)
2055
+ {
2056
+ $cookie_name=Key($cookies[$secure][$domain_pattern][$path]);
2057
+ $expires=$cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"];
2058
+ $value=$cookies[$secure][$domain_pattern][$path][$cookie_name]["value"];
2059
+ if(GetType($expires)!="string"
2060
+ || (strlen($expires)
2061
+ && !preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\$/", $expires)))
2062
+ return($this->SetError("invalid cookie expiry value type (".serialize($expires).")", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
2063
+ $new_cookies[$secure][$domain_pattern][$path][$cookie_name]=array(
2064
+ "name"=>$cookie_name,
2065
+ "value"=>$value,
2066
+ "domain"=>$domain_pattern,
2067
+ "path"=>$path,
2068
+ "expires"=>$expires,
2069
+ "secure"=>$secure
2070
+ );
2071
+ }
2072
+ }
2073
+ }
2074
+ }
2075
+ $this->cookies=$new_cookies;
2076
+ return("");
2077
+ }
2078
+ };
2079
+
2080
+ ?>
app/code/local/Soclever/Socialloginsharing/controllers/oauth_client.php ADDED
@@ -0,0 +1,1850 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * oauth_client.php
4
+ *
5
+ * @(#) $Id: oauth_client.php,v 1.46 2013/01/10 10:11:33 mlemos Exp $
6
+ *
7
+ */
8
+
9
+ /*
10
+ {metadocument}<?xml version="1.0" encoding="ISO-8859-1" ?>
11
+ <class>
12
+
13
+ <package>net.manuellemos.oauth</package>
14
+
15
+ <version>@(#) $Id: oauth_client.php,v 1.46 2013/01/10 10:11:33 mlemos Exp $</version>
16
+ <copyright>Copyright � (C) Manuel Lemos 2012</copyright>
17
+ <title>OAuth client</title>
18
+ <author>Manuel Lemos</author>
19
+ <authoraddress>mlemos-at-acm.org</authoraddress>
20
+
21
+ <documentation>
22
+ <idiom>en</idiom>
23
+ <purpose>This class serves two main purposes:<paragraphbreak />
24
+ 1) Implement the OAuth protocol to retrieve a token from a server to
25
+ authorize the access to an API on behalf of the current
26
+ user.<paragraphbreak />
27
+ 2) Perform calls to a Web services API using a token previously
28
+ obtained using this class or a token provided some other way by the
29
+ Web services provider.</purpose>
30
+ <usage>Regardless of your purposes, you always need to start calling
31
+ the class <functionlink>Initialize</functionlink> function after
32
+ initializing setup variables. After you are done with the class,
33
+ always call the <functionlink>Finalize</functionlink> function at
34
+ the end.<paragraphbreak />
35
+ This class supports either OAuth protocol versions 1.0, 1.0a and
36
+ 2.0. It abstracts the differences between these protocol versions,
37
+ so the class usage is the same independently of the OAuth
38
+ version of the server.<paragraphbreak />
39
+ The class also provides built-in support to several popular OAuth
40
+ servers, so you do not have to manually configure all the details to
41
+ access those servers. Just set the
42
+ <variablelink>server</variablelink> variable to configure the class
43
+ to access one of the built-in supported servers.<paragraphbreak />
44
+ If you need to access one type of server that is not yet directly
45
+ supported by the class, you need to configure it explicitly setting
46
+ the variables: <variablelink>oauth_version</variablelink>,
47
+ <variablelink>url_parameters</variablelink>,
48
+ <variablelink>authorization_header</variablelink>,
49
+ <variablelink>request_token_url</variablelink>,
50
+ <variablelink>dialog_url</variablelink>,
51
+ <variablelink>append_state_to_redirect_uri</variablelink> and
52
+ <variablelink>access_token_url</variablelink>.<paragraphbreak />
53
+ Before proceeding to the actual OAuth authorization process, you
54
+ need to have registered your application with the OAuth server. The
55
+ registration provides you values to set the variables
56
+ <variablelink>client_id</variablelink> and
57
+ <variablelink>client_secret</variablelink>.<paragraphbreak />
58
+ You also need to set the variables
59
+ <variablelink>redirect_uri</variablelink> and
60
+ <variablelink>scope</variablelink> before calling the
61
+ <functionlink>Process</functionlink> function to make the class
62
+ perform the necessary interactions with the OAuth
63
+ server.<paragraphbreak />
64
+ The OAuth protocol involves multiple steps that include redirection
65
+ to the OAuth server. There it asks permission to the current user to
66
+ grant your application access to APIs on his/her behalf. When there
67
+ is a redirection, the class will set the
68
+ <variablelink>exit</variablelink> variable to
69
+ <booleanvalue>1</booleanvalue>. Then your script should exit
70
+ immediately without outputting anything.<paragraphbreak />
71
+ When the OAuth access token is successfully obtained, the following
72
+ variables are set by the class with the obtained values:
73
+ <variablelink>access_token</variablelink>,
74
+ <variablelink>access_token_secret</variablelink>,
75
+ <variablelink>access_token_expiry</variablelink>,
76
+ <variablelink>access_token_type</variablelink>. You may want to
77
+ store these values to use them later when calling the server
78
+ APIs.<paragraphbreak />
79
+ If there was a problem during OAuth authorization process, check the
80
+ variable <variablelink>authorization_error</variablelink> to
81
+ determine the reason.<paragraphbreak />
82
+ Once you get the access token, you can call the server APIs using
83
+ the <functionlink>CallAPI</functionlink> function. Check the
84
+ <variablelink>access_token_error</variablelink> variable to
85
+ determine if there was an error when trying to to call the
86
+ API.<paragraphbreak />
87
+ If for some reason the user has revoked the access to your
88
+ application, you need to ask the user to authorize your application
89
+ again. First you may need to call the function
90
+ <functionlink>ResetAccessToken</functionlink> to reset the value of
91
+ the access token that may be cached in session variables.</usage>
92
+ </documentation>
93
+
94
+ {/metadocument}
95
+ */
96
+
97
+ class oauth_client_class
98
+ {
99
+ /*
100
+ {metadocument}
101
+ <variable>
102
+ <name>error</name>
103
+ <type>STRING</type>
104
+ <value></value>
105
+ <documentation>
106
+ <purpose>Store the message that is returned when an error
107
+ occurs.</purpose>
108
+ <usage>Check this variable to understand what happened when a call to
109
+ any of the class functions has failed.<paragraphbreak />
110
+ This class uses cumulative error handling. This means that if one
111
+ class functions that may fail is called and this variable was
112
+ already set to an error message due to a failure in a previous call
113
+ to the same or other function, the function will also fail and does
114
+ not do anything.<paragraphbreak />
115
+ This allows programs using this class to safely call several
116
+ functions that may fail and only check the failure condition after
117
+ the last function call.<paragraphbreak />
118
+ Just set this variable to an empty string to clear the error
119
+ condition.</usage>
120
+ </documentation>
121
+ </variable>
122
+ {/metadocument}
123
+ */
124
+ var $error = '';
125
+
126
+ /*
127
+ {metadocument}
128
+ <variable>
129
+ <name>debug</name>
130
+ <type>BOOLEAN</type>
131
+ <value>0</value>
132
+ <documentation>
133
+ <purpose>Control whether debug output is enabled</purpose>
134
+ <usage>Set this variable to <booleanvalue>1</booleanvalue> if you
135
+ need to check what is going on during calls to the class. When
136
+ enabled, the debug output goes either to the variable
137
+ <variablelink>debug_output</variablelink> and the PHP error log.</usage>
138
+ </documentation>
139
+ </variable>
140
+ {/metadocument}
141
+ */
142
+ var $debug = false;
143
+
144
+ /*
145
+ {metadocument}
146
+ <variable>
147
+ <name>debug_http</name>
148
+ <type>BOOLEAN</type>
149
+ <value>0</value>
150
+ <documentation>
151
+ <purpose>Control whether the dialog with the remote Web server
152
+ should also be logged.</purpose>
153
+ <usage>Set this variable to <booleanvalue>1</booleanvalue> if you
154
+ want to inspect the data exchange with the OAuth server.</usage>
155
+ </documentation>
156
+ </variable>
157
+ {/metadocument}
158
+ */
159
+ var $debug_http = false;
160
+
161
+ /*
162
+ {metadocument}
163
+ <variable>
164
+ <name>exit</name>
165
+ <type>BOOLEAN</type>
166
+ <value>0</value>
167
+ <documentation>
168
+ <purpose>Determine if the current script should be exited.</purpose>
169
+ <usage>Check this variable after calling the
170
+ <functionlink>Process</functionlink> function and exit your script
171
+ immediately if the variable is set to
172
+ <booleanvalue>1</booleanvalue>.</usage>
173
+ </documentation>
174
+ </variable>
175
+ {/metadocument}
176
+ */
177
+ var $exit = false;
178
+
179
+ /*
180
+ {metadocument}
181
+ <variable>
182
+ <name>debug_output</name>
183
+ <type>STRING</type>
184
+ <value></value>
185
+ <documentation>
186
+ <purpose>Capture the debug output generated by the class</purpose>
187
+ <usage>Inspect this variable if you need to see what happened during
188
+ the class function calls.</usage>
189
+ </documentation>
190
+ </variable>
191
+ {/metadocument}
192
+ */
193
+ var $debug_output = '';
194
+
195
+ /*
196
+ {metadocument}
197
+ <variable>
198
+ <name>debug_prefix</name>
199
+ <type>STRING</type>
200
+ <value>OAuth client: </value>
201
+ <documentation>
202
+ <purpose>Mark the lines of the debug output to identify actions
203
+ performed by this class.</purpose>
204
+ <usage>Change this variable if you prefer the debug output lines to
205
+ be prefixed with a different text.</usage>
206
+ </documentation>
207
+ </variable>
208
+ {/metadocument}
209
+ */
210
+ var $debug_prefix = 'OAuth client: ';
211
+
212
+ /*
213
+ {metadocument}
214
+ <variable>
215
+ <name>server</name>
216
+ <type>STRING</type>
217
+ <value></value>
218
+ <documentation>
219
+ <purpose>Identify the type of OAuth server to access.</purpose>
220
+ <usage>The class provides built-in support to several types of OAuth
221
+ servers. This means that the class can automatically initialize
222
+ several configuration variables just by setting this server
223
+ variable.<paragraphbreak />
224
+ Currently it supports the following servers:
225
+ <stringvalue>Bitbucket</stringvalue>,
226
+ <stringvalue>Dropbox</stringvalue>,
227
+ <stringvalue>Facebook</stringvalue>,
228
+ <stringvalue>Fitbit</stringvalue>,
229
+ <stringvalue>Flickr</stringvalue>,
230
+ <stringvalue>Foursquare</stringvalue>,
231
+ <stringvalue>github</stringvalue>,
232
+ <stringvalue>Google</stringvalue>,
233
+ <stringvalue>Instagram</stringvalue>,
234
+ <stringvalue>LinkedIn</stringvalue>,
235
+ <stringvalue>Microsoft</stringvalue>,
236
+ <stringvalue>Scoop.it</stringvalue>,
237
+ <stringvalue>Tumblr</stringvalue>,
238
+ <stringvalue>Twitter</stringvalue> and
239
+ <stringvalue>Yahoo</stringvalue>. Please contact the author if you
240
+ would like to ask to add built-in support for other types of OAuth
241
+ servers.<paragraphbreak />
242
+ If you want to access other types of OAuth servers that are not
243
+ yet supported, set this variable to an empty string and configure
244
+ other variables with values specific to those servers.</usage>
245
+ </documentation>
246
+ </variable>
247
+ {/metadocument}
248
+ */
249
+ var $server = '';
250
+
251
+ /*
252
+ {metadocument}
253
+ <variable>
254
+ <name>request_token_url</name>
255
+ <type>STRING</type>
256
+ <value></value>
257
+ <documentation>
258
+ <purpose>URL of the OAuth server to request the initial token for
259
+ OAuth 1.0 and 1.0a servers.</purpose>
260
+ <usage>Set this variable to the OAuth request token URL when you are
261
+ not accessing one of the built-in supported OAuth
262
+ servers.<paragraphbreak />
263
+ For OAuth 1.0 and 1.0a servers, the request token URL can have
264
+ certain marks that will act as template placeholders which will be
265
+ replaced with given values before requesting the authorization
266
+ token. Currently it supports the following placeholder
267
+ marks:<paragraphbreak />
268
+ {SCOPE} - scope of the requested permissions to the granted by the
269
+ OAuth server with the user permissions</usage>
270
+ </documentation>
271
+ </variable>
272
+ {/metadocument}
273
+ */
274
+ var $request_token_url = '';
275
+
276
+ /*
277
+ {metadocument}
278
+ <variable>
279
+ <name>dialog_url</name>
280
+ <type>STRING</type>
281
+ <value></value>
282
+ <documentation>
283
+ <purpose>URL of the OAuth server to redirect the browser so the user
284
+ can grant access to your application.</purpose>
285
+ <usage>Set this variable to the OAuth request token URL when you are
286
+ not accessing one of the built-in supported OAuth servers.<paragraphbreak />
287
+ For OAuth 2.0 servers, the dialog URL can have certain marks that
288
+ will act as template placeholders which will be replaced with
289
+ values defined before redirecting the users browser. Currently it
290
+ supports the following placeholder marks:<paragraphbreak />
291
+ {REDIRECT_URI} - URL to redirect when returning from the OAuth
292
+ server authorization page<paragraphbreak />
293
+ {CLIENT_ID} - client application identifier registered at the
294
+ server<paragraphbreak />
295
+ {SCOPE} - scope of the requested permissions to the granted by the
296
+ OAuth server with the user permissions<paragraphbreak />
297
+ {STATE} - identifier of the OAuth session state</usage>
298
+ </documentation>
299
+ </variable>
300
+ {/metadocument}
301
+ */
302
+ var $dialog_url = '';
303
+
304
+ /*
305
+ {metadocument}
306
+ <variable>
307
+ <name>append_state_to_redirect_uri</name>
308
+ <type>STRING</type>
309
+ <value></value>
310
+ <documentation>
311
+ <purpose>Pass the OAuth session state in a variable with a different
312
+ name to work around implementation bugs of certain OAuth
313
+ servers</purpose>
314
+ <usage>Set this variable when you are not accessing one of the
315
+ built-in supported OAuth servers if the OAuth server has a bug
316
+ that makes it not pass back the OAuth state identifier in a
317
+ request variable named state.</usage>
318
+ </documentation>
319
+ </variable>
320
+ {/metadocument}
321
+ */
322
+ var $append_state_to_redirect_uri = '';
323
+
324
+ /*
325
+ {metadocument}
326
+ <variable>
327
+ <name>access_token_url</name>
328
+ <type>STRING</type>
329
+ <value></value>
330
+ <documentation>
331
+ <purpose>OAuth server URL that will return the access token
332
+ URL.</purpose>
333
+ <usage>Set this variable to the OAuth access token URL when you are
334
+ not accessing one of the built-in supported OAuth servers.</usage>
335
+ </documentation>
336
+ </variable>
337
+ {/metadocument}
338
+ */
339
+ var $access_token_url = '';
340
+
341
+
342
+ /*
343
+ {metadocument}
344
+ <variable>
345
+ <name>oauth_version</name>
346
+ <type>STRING</type>
347
+ <value>2.0</value>
348
+ <documentation>
349
+ <purpose>Version of the protocol version supported by the OAuth
350
+ server.</purpose>
351
+ <usage>Set this variable to the OAuth server protocol version when
352
+ you are not accessing one of the built-in supported OAuth
353
+ servers.</usage>
354
+ </documentation>
355
+ </variable>
356
+ {/metadocument}
357
+ */
358
+ var $oauth_version = '2.0';
359
+
360
+ /*
361
+ {metadocument}
362
+ <variable>
363
+ <name>url_parameters</name>
364
+ <type>BOOLEAN</type>
365
+ <value>0</value>
366
+ <documentation>
367
+ <purpose>Determine if the API call parameters should be moved to the
368
+ call URL.</purpose>
369
+ <usage>Set this variable to <booleanvalue>1</booleanvalue> if the
370
+ API you need to call requires that the call parameters always be
371
+ passed via the API URL.</usage>
372
+ </documentation>
373
+ </variable>
374
+ {/metadocument}
375
+ */
376
+ var $url_parameters = false;
377
+
378
+ /*
379
+ {metadocument}
380
+ <variable>
381
+ <name>authorization_header</name>
382
+ <type>BOOLEAN</type>
383
+ <value>1</value>
384
+ <documentation>
385
+ <purpose>Determine if the OAuth parameters should be passed via HTTP
386
+ Authorization request header.</purpose>
387
+ <usage>Set this variable to <booleanvalue>1</booleanvalue> if the
388
+ OAuth server requires that the OAuth parameters be passed using
389
+ the HTTP Authorization instead of the request URI parameters.</usage>
390
+ </documentation>
391
+ </variable>
392
+ {/metadocument}
393
+ */
394
+ var $authorization_header = true;
395
+
396
+ /*
397
+ {metadocument}
398
+ <variable>
399
+ <name>redirect_uri</name>
400
+ <type>STRING</type>
401
+ <value></value>
402
+ <documentation>
403
+ <purpose>URL of the current script page that is calling this
404
+ class</purpose>
405
+ <usage>Set this variable to the current script page URL before
406
+ proceeding the the OAuth authorization process.</usage>
407
+ </documentation>
408
+ </variable>
409
+ {/metadocument}
410
+ */
411
+ var $redirect_uri = '';
412
+
413
+ /*
414
+ {metadocument}
415
+ <variable>
416
+ <name>client_id</name>
417
+ <type>STRING</type>
418
+ <value></value>
419
+ <documentation>
420
+ <purpose>Identifier of your application registered with the OAuth
421
+ server</purpose>
422
+ <usage>Set this variable to the application identifier that is
423
+ provided by the OAuth server when you register the
424
+ application.</usage>
425
+ </documentation>
426
+ </variable>
427
+ {/metadocument}
428
+ */
429
+ var $client_id = '';
430
+
431
+ /*
432
+ {metadocument}
433
+ <variable>
434
+ <name>client_secret</name>
435
+ <type>STRING</type>
436
+ <value></value>
437
+ <documentation>
438
+ <purpose>Secret value assigned to your application when it is
439
+ registered with the OAuth server.</purpose>
440
+ <usage>Set this variable to the application secret that is provided
441
+ by the OAuth server when you register the application.</usage>
442
+ </documentation>
443
+ </variable>
444
+ {/metadocument}
445
+ */
446
+ var $client_secret = '';
447
+
448
+ /*
449
+ {metadocument}
450
+ <variable>
451
+ <name>scope</name>
452
+ <type>STRING</type>
453
+ <value></value>
454
+ <documentation>
455
+ <purpose>Permissions that your application needs to call the OAuth
456
+ server APIs</purpose>
457
+ <usage>Check the documentation of the APIs that your application
458
+ needs to call to set this variable with the identifiers of the
459
+ permissions that the user needs to grant to your application.</usage>
460
+ </documentation>
461
+ </variable>
462
+ {/metadocument}
463
+ */
464
+ var $scope = '';
465
+
466
+ /*
467
+ {metadocument}
468
+ <variable>
469
+ <name>access_token</name>
470
+ <type>STRING</type>
471
+ <value></value>
472
+ <documentation>
473
+ <purpose>Access token obtained from the OAuth server</purpose>
474
+ <usage>Check this variable to get the obtained access token upon
475
+ successful OAuth authorization.</usage>
476
+ </documentation>
477
+ </variable>
478
+ {/metadocument}
479
+ */
480
+ var $access_token = '';
481
+
482
+ /*
483
+ {metadocument}
484
+ <variable>
485
+ <name>access_token_secret</name>
486
+ <type>STRING</type>
487
+ <value></value>
488
+ <documentation>
489
+ <purpose>Access token secret obtained from the OAuth server</purpose>
490
+ <usage>If the OAuth protocol version is 1.0 or 1.0a, check this
491
+ variable to get the obtained access token secret upon successful
492
+ OAuth authorization.</usage>
493
+ </documentation>
494
+ </variable>
495
+ {/metadocument}
496
+ */
497
+ var $access_token_secret = '';
498
+
499
+ /*
500
+ {metadocument}
501
+ <variable>
502
+ <name>access_token_expiry</name>
503
+ <type>STRING</type>
504
+ <value></value>
505
+ <documentation>
506
+ <purpose>Timestamp of the expiry of the access token obtained from
507
+ the OAuth server.</purpose>
508
+ <usage>Check this variable to get the obtained access token expiry
509
+ time upon successful OAuth authorization. If this variable is
510
+ empty, that means no expiry time was set.</usage>
511
+ </documentation>
512
+ </variable>
513
+ {/metadocument}
514
+ */
515
+ var $access_token_expiry = '';
516
+
517
+ /*
518
+ {metadocument}
519
+ <variable>
520
+ <name>access_token_type</name>
521
+ <type>STRING</type>
522
+ <value></value>
523
+ <documentation>
524
+ <purpose>Type of access token obtained from the OAuth server.</purpose>
525
+ <usage>Check this variable to get the obtained access token type
526
+ upon successful OAuth authorization.</usage>
527
+ </documentation>
528
+ </variable>
529
+ {/metadocument}
530
+ */
531
+ var $access_token_type = '';
532
+
533
+ /*
534
+ {metadocument}
535
+ <variable>
536
+ <name>access_token_error</name>
537
+ <type>STRING</type>
538
+ <value></value>
539
+ <documentation>
540
+ <purpose>Error message returned when a call to the API fails.</purpose>
541
+ <usage>Check this variable to determine if there was an error while
542
+ calling the Web services API when using the
543
+ <functionlink>CallAPI</functionlink> function.</usage>
544
+ </documentation>
545
+ </variable>
546
+ {/metadocument}
547
+ */
548
+ var $access_token_error = '';
549
+
550
+ /*
551
+ {metadocument}
552
+ <variable>
553
+ <name>authorization_error</name>
554
+ <type>STRING</type>
555
+ <value></value>
556
+ <documentation>
557
+ <purpose>Error message returned when it was not possible to obtain
558
+ an OAuth access token</purpose>
559
+ <usage>Check this variable to determine if there was an error while
560
+ trying to obtain the OAuth access token.</usage>
561
+ </documentation>
562
+ </variable>
563
+ {/metadocument}
564
+ */
565
+ var $authorization_error = '';
566
+
567
+ /*
568
+ {metadocument}
569
+ <variable>
570
+ <name>response_status</name>
571
+ <type>INTEGER</type>
572
+ <value>0</value>
573
+ <documentation>
574
+ <purpose>HTTP response status returned by the server when calling an
575
+ API</purpose>
576
+ <usage>Check this variable after calling the
577
+ <functionlink>CallAPI</functionlink> function if the API calls and you
578
+ need to process the error depending the response status.
579
+ <integervalue>200</integervalue> means no error.
580
+ <integervalue>0</integervalue> means the server response was not
581
+ retrieved.</usage>
582
+ </documentation>
583
+ </variable>
584
+ {/metadocument}
585
+ */
586
+ var $response_status = 0;
587
+
588
+ var $oauth_user_agent = 'PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.46 $)';
589
+ var $session_started = false;
590
+
591
+ Function SetError($error)
592
+ {
593
+ $this->error = $error;
594
+ if($this->debug)
595
+ $this->OutputDebug('Error: '.$error);
596
+ return(false);
597
+ }
598
+
599
+ Function SetPHPError($error, &$php_error_message)
600
+ {
601
+ if(IsSet($php_error_message)
602
+ && strlen($php_error_message))
603
+ $error.=": ".$php_error_message;
604
+ return($this->SetError($error));
605
+ }
606
+
607
+ Function OutputDebug($message)
608
+ {
609
+ if($this->debug)
610
+ {
611
+ $message = $this->debug_prefix.$message;
612
+ $this->debug_output .= $message."\n";;
613
+ error_log($message);
614
+ }
615
+ return(true);
616
+ }
617
+
618
+ Function GetRequestTokenURL(&$request_token_url)
619
+ {
620
+ $request_token_url = $this->request_token_url;
621
+ return(true);
622
+ }
623
+
624
+ Function GetDialogURL(&$redirect_url)
625
+ {
626
+ $redirect_url = $this->dialog_url;
627
+ return(true);
628
+ }
629
+
630
+ Function GetAccessTokenURL(&$access_token_url)
631
+ {
632
+ $access_token_url = $this->access_token_url;
633
+ return(true);
634
+ }
635
+
636
+ Function GetStoredState(&$state)
637
+ {
638
+ if(IsSet($_SESSION['OAUTH_STATE']))
639
+ $state = $_SESSION['OAUTH_STATE'];
640
+ else
641
+ $state = $_SESSION['OAUTH_STATE'] = time().'-'.substr(md5(rand().time()), 0, 6);
642
+ return(true);
643
+ }
644
+
645
+ Function GetRequestState(&$state)
646
+ {
647
+ $check = (strlen($this->append_state_to_redirect_uri) ? $this->append_state_to_redirect_uri : 'state');
648
+ $state = (IsSet($_GET[$check]) ? $_GET[$check] : null);
649
+ return(true);
650
+ }
651
+
652
+ Function GetRequestCode(&$code)
653
+ {
654
+ $code = (IsSet($_GET['code']) ? $_GET['code'] : null);
655
+ return(true);
656
+ }
657
+
658
+ Function GetRequestError(&$error)
659
+ {
660
+ $error = (IsSet($_GET['error']) ? $_GET['error'] : null);
661
+ return(true);
662
+ }
663
+
664
+ Function GetRequestDenied(&$denied)
665
+ {
666
+ $denied = (IsSet($_GET['denied']) ? $_GET['denied'] : null);
667
+ return(true);
668
+ }
669
+
670
+ Function GetRequestToken(&$token, &$verifier)
671
+ {
672
+ $token = (IsSet($_GET['oauth_token']) ? $_GET['oauth_token'] : null);
673
+ $verifier = (IsSet($_GET['oauth_verifier']) ? $_GET['oauth_verifier'] : null);
674
+ return(true);
675
+ }
676
+
677
+ Function GetRedirectURI(&$redirect_uri)
678
+ {
679
+ if(strlen($this->redirect_uri))
680
+ $redirect_uri = $this->redirect_uri;
681
+ else
682
+ $redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
683
+ return true;
684
+ }
685
+
686
+ /*
687
+ {metadocument}
688
+ <function>
689
+ <name>StoreAccessToken</name>
690
+ <type>BOOLEAN</type>
691
+ <documentation>
692
+ <purpose>Store the values of the access token when it is succefully
693
+ retrieved from the OAuth server.</purpose>
694
+ <usage>This function is meant to be only be called from inside the
695
+ class. By default it stores access tokens in a session variable
696
+ named <stringvalue>OAUTH_ACCESS_TOKEN</stringvalue>.<paragraphbreak />
697
+ Actual implementations should create a sub-class and override this
698
+ function to make the access token values be stored in other types
699
+ of containers, like for instance databases.</usage>
700
+ <returnvalue>This function should return
701
+ <booleanvalue>1</booleanvalue> if the access token was stored
702
+ successfully.</returnvalue>
703
+ </documentation>
704
+ <argument>
705
+ <name>access_token</name>
706
+ <type>HASH</type>
707
+ <documentation>
708
+ <purpose>Associative array with properties of the access token.
709
+ The array may have set the following
710
+ properties:<paragraphbreak />
711
+ <stringvalue>value</stringvalue>: string value of the access
712
+ token<paragraphbreak />
713
+ <stringvalue>authorized</stringvalue>: boolean value that
714
+ determines if the access token was obtained
715
+ successfully<paragraphbreak />
716
+ <stringvalue>expiry</stringvalue>: (optional) timestamp in ISO
717
+ format relative to UTC time zone of the access token expiry
718
+ time<paragraphbreak />
719
+ <stringvalue>type</stringvalue>: (optional) type of OAuth token
720
+ that may determine how it should be used when sending API call
721
+ requests.</purpose>
722
+ </documentation>
723
+ </argument>
724
+ <do>
725
+ {/metadocument}
726
+ */
727
+ Function StoreAccessToken($access_token)
728
+ {
729
+ $_SESSION['OAUTH_ACCESS_TOKEN'][$this->access_token_url] = $access_token;
730
+ return true;
731
+ }
732
+ /*
733
+ {metadocument}
734
+ </do>
735
+ </function>
736
+ {/metadocument}
737
+ */
738
+
739
+ /*
740
+ {metadocument}
741
+ <function>
742
+ <name>GetAccessToken</name>
743
+ <type>BOOLEAN</type>
744
+ <documentation>
745
+ <purpose>Retrieve the OAuth access token if it was already
746
+ previously stored by the
747
+ <functionlink>StoreAccessToken</functionlink> function.</purpose>
748
+ <usage>This function is meant to be only be called from inside the
749
+ class. By default it retrieves access tokens stored in a session
750
+ variable named
751
+ <stringvalue>OAUTH_ACCESS_TOKEN</stringvalue>.<paragraphbreak />
752
+ Actual implementations should create a sub-class and override this
753
+ function to retrieve the access token values from other types of
754
+ containers, like for instance databases.</usage>
755
+ <returnvalue>This function should return
756
+ <booleanvalue>1</booleanvalue> if the access token was retrieved
757
+ successfully.</returnvalue>
758
+ </documentation>
759
+ <argument>
760
+ <name>access_token</name>
761
+ <type>STRING</type>
762
+ <out />
763
+ <documentation>
764
+ <purpose>Return the properties of the access token in an
765
+ associative array. If the access token was not yet stored, it
766
+ returns an empty array. Otherwise, the properties it may return
767
+ are the same that may be passed to the
768
+ <functionlink>StoreAccessToken</functionlink>.</purpose>
769
+ </documentation>
770
+ </argument>
771
+ <do>
772
+ {/metadocument}
773
+ */
774
+ Function GetAccessToken(&$access_token)
775
+ {
776
+ if(!$this->session_started
777
+ && !session_start())
778
+ return($this->SetPHPError('it was not possible to start the PHP session', $php_error_message));
779
+ $this->session_started = true;
780
+ if(IsSet($_SESSION['OAUTH_ACCESS_TOKEN'][$this->access_token_url]))
781
+ $access_token = $_SESSION['OAUTH_ACCESS_TOKEN'][$this->access_token_url];
782
+ else
783
+ $access_token = array();
784
+ return true;
785
+ }
786
+ /*
787
+ {metadocument}
788
+ </do>
789
+ </function>
790
+ {/metadocument}
791
+ */
792
+
793
+ /*
794
+ {metadocument}
795
+ <function>
796
+ <name>ResetAccessToken</name>
797
+ <type>BOOLEAN</type>
798
+ <documentation>
799
+ <purpose>Reset the access token to a state back when the user has
800
+ not yet authorized the access to the OAuth server API.</purpose>
801
+ <usage>Call this function if for some reason the token to access
802
+ the API was revoked and you need to ask the user to authorize
803
+ the access again.<paragraphbreak />
804
+ By default the class stores and retrieves access tokens in a
805
+ session variable named
806
+ <stringvalue>OAUTH_ACCESS_TOKEN</stringvalue>.<paragraphbreak />
807
+ This function must be called when the user is accessing your site
808
+ pages, so it can reset the information stored in session variables
809
+ that cache the state of a previously retrieved access
810
+ token.<paragraphbreak />
811
+ Actual implementations should create a sub-class and override this
812
+ function to reset the access token state when it is stored in
813
+ other types of containers, like for instance databases.</usage>
814
+ <returnvalue>This function should return
815
+ <booleanvalue>1</booleanvalue> if the access token was resetted
816
+ successfully.</returnvalue>
817
+ </documentation>
818
+ <do>
819
+ {/metadocument}
820
+ */
821
+ Function ResetAccessToken()
822
+ {
823
+ if($this->debug)
824
+ $this->OutputDebug('Resetting the access token status for OAuth server located at '.$this->access_token_url);
825
+ if(!$this->session_started
826
+ && !session_start())
827
+ return($this->SetPHPError('it was not possible to start the PHP session', $php_error_message));
828
+ $this->session_started = true;
829
+ if(IsSet($_SESSION['OAUTH_ACCESS_TOKEN'][$this->access_token_url]))
830
+ Unset($_SESSION['OAUTH_ACCESS_TOKEN'][$this->access_token_url]);
831
+ return true;
832
+ }
833
+ /*
834
+ {metadocument}
835
+ </do>
836
+ </function>
837
+ {/metadocument}
838
+ */
839
+
840
+ Function Encode($value)
841
+ {
842
+ return(is_array($value) ? $this->EncodeArray($value) : str_replace('%7E', '~', str_replace('+',' ', RawURLEncode($value))));
843
+ }
844
+
845
+ Function EncodeArray($array)
846
+ {
847
+ foreach($array as $key => $value)
848
+ $array[$key] = $this->Encode($value);
849
+ return $array;
850
+ }
851
+
852
+ Function HMAC($function, $data, $key)
853
+ {
854
+ switch($function)
855
+ {
856
+ case 'sha1':
857
+ $pack = 'H40';
858
+ break;
859
+ default:
860
+ if($this->debug)
861
+ $this->OutputDebug($function.' is not a supported an HMAC hash type');
862
+ return('');
863
+ }
864
+ if(strlen($key) > 64)
865
+ $key = pack($pack, $function($key));
866
+ if(strlen($key) < 64)
867
+ $key = str_pad($key, 64, "\0");
868
+ return(pack($pack, $function((str_repeat("\x5c", 64) ^ $key).pack($pack, $function((str_repeat("\x36", 64) ^ $key).$data)))));
869
+ }
870
+
871
+ Function SendAPIRequest($url, $method, $parameters, $oauth, $options, &$response)
872
+ {
873
+ $this->response_status = 0;
874
+ $http = new http_class;
875
+ $http->debug = ($this->debug && $this->debug_http);
876
+ $http->log_debug = true;
877
+ $http->sasl_authenticate = 0;
878
+ $http->user_agent = $this->oauth_user_agent;
879
+ if($this->debug)
880
+ $this->OutputDebug('Accessing the '.$options['Resource'].' at '.$url);
881
+ $arguments = array();
882
+ $method = strtoupper($method);
883
+ $authorization = '';
884
+ $type = (IsSet($options['RequestContentType']) ? strtolower(trim(strtok($options['RequestContentType'], ';'))) : 'application/x-www-form-urlencoded');
885
+ if(IsSet($oauth))
886
+ {
887
+ $values = array(
888
+ 'oauth_consumer_key'=>$this->client_id,
889
+ 'oauth_nonce'=>md5(uniqid(rand(), true)),
890
+ 'oauth_signature_method'=>'HMAC-SHA1',
891
+ 'oauth_timestamp'=>time(),
892
+ 'oauth_version'=>'1.0',
893
+ );
894
+ if($this->url_parameters
895
+ && $type === 'application/x-www-form-urlencoded'
896
+ && count($parameters))
897
+ {
898
+ $first = (strpos($url, '?') === false);
899
+ foreach($parameters as $parameter => $value)
900
+ $url .= ($first ? '?' : '&').UrlEncode($parameter).'='.UrlEncode($value);
901
+ $parameters = array();
902
+ }
903
+ $value_parameters = ($type !== 'application/x-www-form-urlencoded' ? array() : $parameters);
904
+ $values = array_merge($values, $oauth, $value_parameters);
905
+ $uri = strtok($url, '?');
906
+ $sign = $method.'&'.$this->Encode($uri).'&';
907
+ $first = true;
908
+ $sign_values = $values;
909
+ $u = parse_url($url);
910
+ if(IsSet($u['query']))
911
+ {
912
+ parse_str($u['query'], $q);
913
+ foreach($q as $parameter => $value)
914
+ $sign_values[$parameter] = $value;
915
+ }
916
+ KSort($sign_values);
917
+ foreach($sign_values as $parameter => $value)
918
+ {
919
+ $sign .= $this->Encode(($first ? '' : '&').$parameter.'='.$this->Encode($value));
920
+ $first = false;
921
+ }
922
+ $key = $this->Encode($this->client_secret).'&'.$this->Encode($this->access_token_secret);
923
+ $values['oauth_signature'] = base64_encode($this->HMAC('sha1', $sign, $key));
924
+ if($this->authorization_header)
925
+ {
926
+ $authorization = 'OAuth';
927
+ $first = true;
928
+ foreach($values as $parameter => $value)
929
+ {
930
+ $authorization .= ($first ? ' ' : ',').$parameter.'="'.$this->Encode($value).'"';
931
+ $first = false;
932
+ }
933
+ }
934
+ else
935
+ {
936
+ if($method === 'GET')
937
+ {
938
+ $first = (strcspn($url, '?') == strlen($url));
939
+ foreach($values as $parameter => $value)
940
+ {
941
+ $url .= ($first ? '?' : '&').$parameter.'='.$this->Encode($value);
942
+ $first = false;
943
+ }
944
+ $post_values = array();
945
+ }
946
+ else
947
+ $post_values = $values;
948
+ }
949
+ }
950
+ if(strlen($error = $http->GetRequestArguments($url, $arguments)))
951
+ return($this->SetError('it was not possible to open the '.$options['Resource'].' URL: '.$error));
952
+ if(strlen($error = $http->Open($arguments)))
953
+ return($this->SetError('it was not possible to open the '.$options['Resource'].' URL: '.$error));
954
+ $arguments['RequestMethod'] = $method;
955
+ switch($type)
956
+ {
957
+ case 'application/x-www-form-urlencoded':
958
+ if(IsSet($options['RequestBody']))
959
+ return($this->SetError('the request body is defined automatically from the parameters'));
960
+ $arguments['PostValues'] = $parameters;
961
+ break;
962
+ case 'application/json':
963
+ $arguments['Headers']['Content-Type'] = $options['RequestContentType'];
964
+ if(!IsSet($options['RequestBody']))
965
+ {
966
+ $arguments['Body'] = json_encode($parameters);
967
+ break;
968
+ }
969
+ default:
970
+ if(!IsSet($options['RequestBody']))
971
+ return($this->SetError('it was not specified the body value of the of the API call request'));
972
+ $arguments['Headers']['Content-Type'] = $options['RequestContentType'];
973
+ $arguments['Body'] = $options['RequestBody'];
974
+ break;
975
+ }
976
+ $arguments['Headers']['Accept'] = (IsSet($options['Accept']) ? $options['Accept'] : '*/*');
977
+ if(strlen($authorization))
978
+ $arguments['Headers']['Authorization'] = $authorization;
979
+ if(strlen($error = $http->SendRequest($arguments))
980
+ || strlen($error = $http->ReadReplyHeaders($headers)))
981
+ {
982
+ $http->Close();
983
+ return($this->SetError('it was not possible to retrieve the '.$options['Resource'].': '.$error));
984
+ }
985
+ $error = $http->ReadWholeReplyBody($data);
986
+ $http->Close();
987
+ if(strlen($error))
988
+ {
989
+ return($this->SetError('it was not possible to access the '.$options['Resource'].': '.$error));
990
+ }
991
+ $this->response_status = intval($http->response_status);
992
+ $content_type = (IsSet($headers['content-type']) ? strtolower(trim(strtok($headers['content-type'], ';'))) : 'unspecified');
993
+ switch($content_type)
994
+ {
995
+ case 'text/javascript':
996
+ case 'application/json':
997
+ if(!function_exists('json_decode'))
998
+ return($this->SetError('the JSON extension is not available in this PHP setup'));
999
+ $object = json_decode($data);
1000
+ switch(GetType($object))
1001
+ {
1002
+ case 'object':
1003
+ if(!IsSet($options['ConvertObjects'])
1004
+ || !$options['ConvertObjects'])
1005
+ $response = $object;
1006
+ else
1007
+ {
1008
+ $response = array();
1009
+ foreach($object as $property => $value)
1010
+ $response[$property] = $value;
1011
+ }
1012
+ break;
1013
+ case 'array':
1014
+ $response = $object;
1015
+ break;
1016
+ default:
1017
+ if(!IsSet($object))
1018
+ return($this->SetError('it was not returned a valid JSON definition of the '.$options['Resource'].' values'));
1019
+ $response = $object;
1020
+ break;
1021
+ }
1022
+ break;
1023
+ case 'application/x-www-form-urlencoded':
1024
+ case 'text/plain':
1025
+ case 'text/html':
1026
+ parse_str($data, $response);
1027
+ break;
1028
+ default:
1029
+ $response = $data;
1030
+ break;
1031
+ }
1032
+ if($this->response_status >= 200
1033
+ && $this->response_status < 300)
1034
+ $this->access_token_error = '';
1035
+ else
1036
+ {
1037
+ $this->access_token_error = 'it was not possible to access the '.$options['Resource'].': it was returned an unexpected response status '.$http->response_status.' Response: '.$data;
1038
+ if($this->debug)
1039
+ $this->OutputDebug('Could not retrieve the OAuth access. Error: '.$this->access_token_error);
1040
+ if(IsSet($options['FailOnAccessError'])
1041
+ && $options['FailOnAccessError'])
1042
+ {
1043
+ $this->error = $this->access_token_error;
1044
+ return false;
1045
+ }
1046
+ }
1047
+ return true;
1048
+ }
1049
+
1050
+ /*
1051
+ {metadocument}
1052
+ <function>
1053
+ <name>CallAPI</name>
1054
+ <type>BOOLEAN</type>
1055
+ <documentation>
1056
+ <purpose>Send a HTTP request to the Web services API using a
1057
+ previously obtained authorization token via OAuth.</purpose>
1058
+ <usage>This function can be used to call an API after having
1059
+ previously obtained an access token through the OAuth protocol
1060
+ using the <functionlink>Process</functionlink> function, or by
1061
+ directly setting the variables
1062
+ <variablelink>access_token</variablelink>, as well as
1063
+ <variablelink>access_token_secret</variablelink> in case of using
1064
+ OAuth 1.0 or 1.0a services.</usage>
1065
+ <returnvalue>This function returns <booleanvalue>1</booleanvalue> if
1066
+ the call was done successfully.</returnvalue>
1067
+ </documentation>
1068
+ <argument>
1069
+ <name>url</name>
1070
+ <type>STRING</type>
1071
+ <documentation>
1072
+ <purpose>URL of the API where the HTTP request will be sent.</purpose>
1073
+ </documentation>
1074
+ </argument>
1075
+ <argument>
1076
+ <name>method</name>
1077
+ <type>STRING</type>
1078
+ <documentation>
1079
+ <purpose>HTTP method that will be used to send the request. It can
1080
+ be <stringvalue>GET</stringvalue>,
1081
+ <stringvalue>POST</stringvalue>,
1082
+ <stringvalue>DELETE</stringvalue>, <stringvalue>PUT</stringvalue>,
1083
+ etc..</purpose>
1084
+ </documentation>
1085
+ </argument>
1086
+ <argument>
1087
+ <name>parameters</name>
1088
+ <type>HASH</type>
1089
+ <documentation>
1090
+ <purpose>Associative array with the names and values of the API
1091
+ call request parameters.</purpose>
1092
+ </documentation>
1093
+ </argument>
1094
+ <argument>
1095
+ <name>options</name>
1096
+ <type>HASH</type>
1097
+ <documentation>
1098
+ <purpose>Associative array with additional options to configure
1099
+ the request. Currently it supports the following
1100
+ options:<paragraphbreak />
1101
+ <stringvalue>Resource</stringvalue>: string with a label that
1102
+ will be used in the error messages and debug log entries to
1103
+ identify what operation the request is performing. The default
1104
+ value is <stringvalue>API call</stringvalue>.<paragraphbreak />
1105
+ <stringvalue>ConvertObjects</stringvalue>: boolean option that
1106
+ determines if objects should be converted into arrays when the
1107
+ response is returned in JSON format. The default value is
1108
+ <booleanvalue>0</booleanvalue>.<paragraphbreak />
1109
+ <stringvalue>FailOnAccessError</stringvalue>: boolean option
1110
+ that determines if this functions should fail when the server
1111
+ response status is not between 200 and 299. The default value
1112
+ is <booleanvalue>0</booleanvalue>.<paragraphbreak />
1113
+ <stringvalue>Accept</stringvalue>: content type value of the
1114
+ Accept HTTP header to be sent in the API call HTTP request.
1115
+ Some APIs require that a certain value be sent to specify
1116
+ which version of the API is being called. The default value is
1117
+ <stringvalue>*&#47;*</stringvalue>.<paragraphbreak />
1118
+ <stringvalue>RequestContentType</stringvalue>: content type that
1119
+ should be used to send the request values. It can be either
1120
+ <stringvalue>application/x-www-form-urlencoded</stringvalue>
1121
+ for sending values like from Web forms, or
1122
+ <stringvalue>application/json</stringvalue> for sending the
1123
+ values encoded in JSON format. Other types are accepted if the
1124
+ <stringvalue>RequestBody</stringvalue> option is specified.
1125
+ The default value is
1126
+ <stringvalue>application/x-www-form-urlencoded</stringvalue>.<paragraphbreak />
1127
+ <stringvalue>RequestBody</stringvalue>: request body data of a
1128
+ custom type. The <stringvalue>RequestContentType</stringvalue>
1129
+ option must be specified, so the
1130
+ <stringvalue>RequestBody</stringvalue> option is considered.</purpose>
1131
+ </documentation>
1132
+ </argument>
1133
+ <argument>
1134
+ <name>response</name>
1135
+ <type>STRING</type>
1136
+ <out />
1137
+ <documentation>
1138
+ <purpose>Return the value of the API response. If the value is
1139
+ JSON encoded, this function will decode it and return the value
1140
+ converted to respective types. If the value is form encoded,
1141
+ this function will decode the response and return it as an
1142
+ array. Otherwise, the class will return the value as a
1143
+ string.</purpose>
1144
+ </documentation>
1145
+ </argument>
1146
+ <do>
1147
+ {/metadocument}
1148
+ */
1149
+ Function CallAPI($url, $method, $parameters, $options, &$response)
1150
+ {
1151
+ if(!IsSet($options['Resource']))
1152
+ $options['Resource'] = 'API call';
1153
+ if(!IsSet($options['ConvertObjects']))
1154
+ $options['ConvertObjects'] = false;
1155
+ switch(intval($this->oauth_version))
1156
+ {
1157
+ case 1:
1158
+ $oauth = array(
1159
+ 'oauth_token'=>$this->access_token
1160
+ );
1161
+ break;
1162
+
1163
+ case 2:
1164
+ $oauth = null;
1165
+ $url .= (strcspn($url, '?') < strlen($url) ? '&' : '?').'access_token='.UrlEncode($this->access_token);
1166
+ break;
1167
+
1168
+ default:
1169
+ return($this->SetError($this->oauth_version.' is not a supported version of the OAuth protocol'));
1170
+ }
1171
+ return($this->SendAPIRequest($url, $method, $parameters, $oauth, $options, $response));
1172
+ }
1173
+ /*
1174
+ {metadocument}
1175
+ </do>
1176
+ </function>
1177
+ {/metadocument}
1178
+ */
1179
+
1180
+ /*
1181
+ {metadocument}
1182
+ <function>
1183
+ <name>Initialize</name>
1184
+ <type>BOOLEAN</type>
1185
+ <documentation>
1186
+ <purpose>Initialize the class variables and internal state. It must
1187
+ be called before calling other class functions.</purpose>
1188
+ <usage>Set the <variablelink>server</variablelink> variable before
1189
+ calling this function to let it initialize the class variables to
1190
+ work with the specified server type. Alternatively, you can set
1191
+ other class variables manually to make it work with servers that
1192
+ are not yet built-in supported.</usage>
1193
+ <returnvalue>This function returns <booleanvalue>1</booleanvalue> if
1194
+ it was able to successfully initialize the class for the specified
1195
+ server type.</returnvalue>
1196
+ </documentation>
1197
+ <do>
1198
+ {/metadocument}
1199
+ */
1200
+ Function Initialize()
1201
+ {
1202
+ switch($this->server)
1203
+ {
1204
+ case '';
1205
+ break;
1206
+
1207
+ case 'Bitbucket':
1208
+ $this->oauth_version = '1.0a';
1209
+ $this->request_token_url = 'https://bitbucket.org/!api/1.0/oauth/request_token';
1210
+ $this->dialog_url = 'https://bitbucket.org/!api/1.0/oauth/authenticate';
1211
+ $this->append_state_to_redirect_uri = '';
1212
+ $this->access_token_url = 'https://bitbucket.org/!api/1.0/oauth/access_token';
1213
+ $this->authorization_header = true;
1214
+ $this->url_parameters = true;
1215
+ break;
1216
+
1217
+ case 'Dropbox':
1218
+ $this->oauth_version = '1.0';
1219
+ $this->request_token_url = 'https://api.dropbox.com/1/oauth/request_token';
1220
+ $this->dialog_url = 'https://www.dropbox.com/1/oauth/authorize';
1221
+ $this->append_state_to_redirect_uri = '';
1222
+ $this->access_token_url = 'https://api.dropbox.com/1/oauth/access_token';
1223
+ $this->authorization_header = false;
1224
+ $this->url_parameters = false;
1225
+ break;
1226
+
1227
+ case 'Facebook':
1228
+ $this->oauth_version = '2.0';
1229
+ $this->request_token_url = '';
1230
+ $this->dialog_url = 'https://www.facebook.com/dialog/oauth?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}';
1231
+ $this->append_state_to_redirect_uri = '';
1232
+ $this->access_token_url = 'https://graph.facebook.com/oauth/access_token';
1233
+ $this->authorization_header = true;
1234
+ $this->url_parameters = false;
1235
+ break;
1236
+
1237
+ case 'Fitbit':
1238
+ $this->oauth_version = '1.0a';
1239
+ $this->request_token_url = 'http://api.fitbit.com/oauth/request_token';
1240
+ $this->dialog_url = 'http://api.fitbit.com/oauth/authorize';
1241
+ $this->append_state_to_redirect_uri = '';
1242
+ $this->access_token_url = 'http://api.fitbit.com/oauth/access_token';
1243
+ $this->authorization_header = true;
1244
+ $this->url_parameters = false;
1245
+ break;
1246
+
1247
+ case 'Flickr':
1248
+ $this->oauth_version = '1.0a';
1249
+ $this->request_token_url = 'http://www.flickr.com/services/oauth/request_token';
1250
+ $this->dialog_url = 'http://www.flickr.com/services/oauth/authorize';
1251
+ $this->append_state_to_redirect_uri = '';
1252
+ $this->access_token_url = 'http://www.flickr.com/services/oauth/access_token';
1253
+ $this->authorization_header = false;
1254
+ $this->url_parameters = false;
1255
+ break;
1256
+
1257
+ case 'Foursquare':
1258
+ $this->oauth_version = '2.0';
1259
+ $this->request_token_url = '';
1260
+ $this->dialog_url = 'https://foursquare.com/oauth2/authorize?client_id={CLIENT_ID}&scope={SCOPE}&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}';
1261
+ $this->append_state_to_redirect_uri = '';
1262
+ $this->access_token_url = 'https://foursquare.com/oauth2/access_token';
1263
+ $this->authorization_header = true;
1264
+ $this->url_parameters = false;
1265
+ break;
1266
+
1267
+ case 'github':
1268
+ $this->oauth_version = '2.0';
1269
+ $this->request_token_url = '';
1270
+ $this->dialog_url = 'https://github.com/login/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}';
1271
+ $this->append_state_to_redirect_uri = '';
1272
+ $this->access_token_url = 'https://github.com/login/oauth/access_token';
1273
+ $this->authorization_header = true;
1274
+ $this->url_parameters = false;
1275
+ break;
1276
+
1277
+ case 'Google':
1278
+ $this->oauth_version = '2.0';
1279
+ $this->request_token_url = '';
1280
+ $this->dialog_url = 'https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&state={STATE}';
1281
+ $this->append_state_to_redirect_uri = '';
1282
+ $this->access_token_url = 'https://accounts.google.com/o/oauth2/token';
1283
+ $this->authorization_header = true;
1284
+ $this->url_parameters = false;
1285
+ break;
1286
+
1287
+ case 'Instagram':
1288
+ $this->oauth_version = '2.0';
1289
+ $this->request_token_url = '';
1290
+ $this->dialog_url ='https://api.instagram.com/oauth/authorize/?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPE}&response_type=code&state={STATE}';
1291
+ $this->append_state_to_redirect_uri = '';
1292
+ $this->access_token_url = 'https://api.instagram.com/oauth/access_token';
1293
+ $this->authorization_header = true;
1294
+ $this->url_parameters = false;
1295
+ break;
1296
+
1297
+ case 'LinkedIn':
1298
+ $this->oauth_version = '1.0a';
1299
+ $this->request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken?scope={SCOPE}';
1300
+ $this->dialog_url = 'https://api.linkedin.com/uas/oauth/authenticate';
1301
+ $this->access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken';
1302
+ $this->append_state_to_redirect_uri = '';
1303
+ $this->authorization_header = true;
1304
+ $this->url_parameters = true;
1305
+ break;
1306
+
1307
+ case 'Microsoft':
1308
+ $this->oauth_version = '2.0';
1309
+ $this->request_token_url = '';
1310
+ $this->dialog_url = 'https://login.live.com/oauth20_authorize.srf?client_id={CLIENT_ID}&scope={SCOPE}&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}';
1311
+ $this->append_state_to_redirect_uri = '';
1312
+ $this->access_token_url = 'https://login.live.com/oauth20_token.srf';
1313
+ $this->authorization_header = true;
1314
+ $this->url_parameters = false;
1315
+ break;
1316
+
1317
+ case 'Scoop.it':
1318
+ $this->oauth_version = '1.0a';
1319
+ $this->request_token_url = 'https://www.scoop.it/oauth/request';
1320
+ $this->dialog_url = 'https://www.scoop.it/oauth/authorize';
1321
+ $this->append_state_to_redirect_uri = '';
1322
+ $this->access_token_url = 'https://www.scoop.it/oauth/access';
1323
+ $this->authorization_header = false;
1324
+ $this->url_parameters = false;
1325
+ break;
1326
+
1327
+ case 'Tumblr':
1328
+ $this->oauth_version = '1.0a';
1329
+ $this->request_token_url = 'http://www.tumblr.com/oauth/request_token';
1330
+ $this->dialog_url = 'http://www.tumblr.com/oauth/authorize';
1331
+ $this->append_state_to_redirect_uri = '';
1332
+ $this->access_token_url = 'http://www.tumblr.com/oauth/access_token';
1333
+ $this->authorization_header = true;
1334
+ $this->url_parameters = false;
1335
+ break;
1336
+
1337
+ case 'Twitter':
1338
+ $this->oauth_version = '1.0a';
1339
+ $this->request_token_url = 'https://api.twitter.com/oauth/request_token';
1340
+ $this->dialog_url = 'https://api.twitter.com/oauth/authenticate';
1341
+ $this->append_state_to_redirect_uri = '';
1342
+ $this->access_token_url = 'https://api.twitter.com/oauth/access_token';
1343
+ $this->authorization_header = true;
1344
+ $this->url_parameters = true;
1345
+ break;
1346
+
1347
+ case 'Yahoo':
1348
+ $this->oauth_version = '1.0a';
1349
+ $this->request_token_url = 'https://api.login.yahoo.com/oauth/v2/get_request_token';
1350
+ $this->dialog_url = 'https://api.login.yahoo.com/oauth/v2/request_auth';
1351
+ $this->access_token_url = 'https://api.login.yahoo.com/oauth/v2/get_token';
1352
+ $this->append_state_to_redirect_uri = '';
1353
+ $this->authorization_header = false;
1354
+ $this->url_parameters = false;
1355
+ break;
1356
+
1357
+ default:
1358
+ return($this->SetError($this->server.' is not yet a supported type of OAuth server. Please contact the author Manuel Lemos <mlemos@acm.org> to request adding built-in support to this type of OAuth server.'));
1359
+ }
1360
+ return(true);
1361
+ }
1362
+ /*
1363
+ {metadocument}
1364
+ </do>
1365
+ </function>
1366
+ {/metadocument}
1367
+ */
1368
+
1369
+ /*
1370
+ {metadocument}
1371
+ <function>
1372
+ <name>Process</name>
1373
+ <type>BOOLEAN</type>
1374
+ <documentation>
1375
+ <purpose>Process the OAuth protocol interaction with the OAuth
1376
+ server.</purpose>
1377
+ <usage>Call this function when you need to retrieve the OAuth access
1378
+ token. Check the <variablelink>access_token</variablelink> to
1379
+ determine if the access token was obtained successfully.</usage>
1380
+ <returnvalue>This function returns <booleanvalue>1</booleanvalue> if
1381
+ the OAuth protocol was processed without errors.</returnvalue>
1382
+ </documentation>
1383
+ <do>
1384
+ {/metadocument}
1385
+ */
1386
+ Function Process()
1387
+ {
1388
+ switch(intval($this->oauth_version))
1389
+ {
1390
+ case 1:
1391
+ $one_a = ($this->oauth_version === '1.0a');
1392
+ if($this->debug)
1393
+ $this->OutputDebug('Checking the OAuth token authorization state');
1394
+ if(!$this->GetAccessToken($access_token))
1395
+ return false;
1396
+ if(IsSet($access_token['authorized'])
1397
+ && IsSet($access_token['value']))
1398
+ {
1399
+ $expired = (IsSet($access_token['expiry']) && strcmp($access_token['expiry'], gmstrftime('%Y-%m-%d %H:%M:%S')) <= 0);
1400
+ if(!$access_token['authorized']
1401
+ || $expired)
1402
+ {
1403
+ if($this->debug)
1404
+ {
1405
+ if($expired)
1406
+ $this->OutputDebug('The OAuth token expired on '.$access_token['expiry'].'UTC');
1407
+ else
1408
+ $this->OutputDebug('The OAuth token is not yet authorized');
1409
+ $this->OutputDebug('Checking the OAuth token and verifier');
1410
+ }
1411
+ if(!$this->GetRequestToken($token, $verifier))
1412
+ return false;
1413
+ if(!IsSet($token)
1414
+ || ($one_a
1415
+ && !IsSet($verifier)))
1416
+ {
1417
+ if(!$this->GetRequestDenied($denied))
1418
+ return false;
1419
+ if(IsSet($denied)
1420
+ && $denied === $access_token['value'])
1421
+ {
1422
+ if($this->debug)
1423
+ $this->OutputDebug('The authorization request was denied');
1424
+ $this->authorization_error = 'the request was denied';
1425
+ return true;
1426
+ }
1427
+ else
1428
+ {
1429
+ if($this->debug)
1430
+ $this->OutputDebug('Reset the OAuth token state because token and verifier are not both set');
1431
+ $access_token = array();
1432
+ }
1433
+ }
1434
+ elseif($token !== $access_token['value'])
1435
+ {
1436
+ if($this->debug)
1437
+ $this->OutputDebug('Reset the OAuth token state because token does not match what as previously retrieved');
1438
+ $access_token = array();
1439
+ }
1440
+ else
1441
+ {
1442
+ if(!$this->GetAccessTokenURL($url))
1443
+ return false;
1444
+ $oauth = array(
1445
+ 'oauth_token'=>$token,
1446
+ );
1447
+ if($one_a)
1448
+ $oauth['oauth_verifier'] = $verifier;
1449
+ $this->access_token_secret = $access_token['secret'];
1450
+ if(!$this->SendAPIRequest($url, 'GET', array(), $oauth, array('Resource'=>'OAuth access token'), $response))
1451
+ return false;
1452
+ if(strlen($this->access_token_error))
1453
+ {
1454
+ $this->authorization_error = $this->access_token_error;
1455
+ return true;
1456
+ }
1457
+ if(!IsSet($response['oauth_token'])
1458
+ || !IsSet($response['oauth_token_secret']))
1459
+ {
1460
+ $this->authorization_error= 'it was not returned the access token and secret';
1461
+ return true;
1462
+ }
1463
+ $access_token = array(
1464
+ 'value'=>$response['oauth_token'],
1465
+ 'secret'=>$response['oauth_token_secret'],
1466
+ 'authorized'=>true
1467
+ );
1468
+ if(IsSet($response['oauth_expires_in']))
1469
+ {
1470
+ $expires = $response['oauth_expires_in'];
1471
+ if(strval($expires) !== strval(intval($expires))
1472
+ || $expires <= 0)
1473
+ return($this->SetError('OAuth server did not return a supported type of access token expiry time'));
1474
+ $this->access_token_expiry = gmstrftime('%Y-%m-%d %H:%M:%S', time() + $expires);
1475
+ if($this->debug)
1476
+ $this->OutputDebug('Access token expiry: '.$this->access_token_expiry.' UTC');
1477
+ $access_token['expiry'] = $this->access_token_expiry;
1478
+ }
1479
+ else
1480
+ $this->access_token_expiry = '';
1481
+
1482
+ if(!$this->StoreAccessToken($access_token))
1483
+ return false;
1484
+ if($this->debug)
1485
+ $this->OutputDebug('The OAuth token was authorized');
1486
+ }
1487
+ }
1488
+ elseif($this->debug)
1489
+ $this->OutputDebug('The OAuth token was already authorized');
1490
+ if(IsSet($access_token['authorized'])
1491
+ && $access_token['authorized'])
1492
+ {
1493
+ $this->access_token = $access_token['value'];
1494
+ $this->access_token_secret = $access_token['secret'];
1495
+ return true;
1496
+ }
1497
+ }
1498
+ else
1499
+ {
1500
+ if($this->debug)
1501
+ $this->OutputDebug('The OAuth access token is not set');
1502
+ $access_token = array();
1503
+ }
1504
+ if(!IsSet($access_token['authorized']))
1505
+ {
1506
+ if($this->debug)
1507
+ $this->OutputDebug('Requesting the unauthorized OAuth token');
1508
+ if(!$this->GetRequestTokenURL($url))
1509
+ return false;
1510
+ $url = str_replace('{SCOPE}', UrlEncode($this->scope), $url);
1511
+ if(!$this->GetRedirectURI($redirect_uri))
1512
+ return false;
1513
+ $oauth = array(
1514
+ 'oauth_callback'=>$redirect_uri,
1515
+ );
1516
+ if(!$this->SendAPIRequest($url, 'GET', array(), $oauth, array('Resource'=>'OAuth request token'), $response))
1517
+ return false;
1518
+ if(strlen($this->access_token_error))
1519
+ {
1520
+ $this->authorization_error = $this->access_token_error;
1521
+ return true;
1522
+ }
1523
+ if(!IsSet($response['oauth_token'])
1524
+ || !IsSet($response['oauth_token_secret']))
1525
+ {
1526
+ $this->authorization_error = 'it was not returned the requested token';
1527
+ return true;
1528
+ }
1529
+ $access_token = array(
1530
+ 'value'=>$response['oauth_token'],
1531
+ 'secret'=>$response['oauth_token_secret'],
1532
+ 'authorized'=>false
1533
+ );
1534
+ if(!$this->StoreAccessToken($access_token))
1535
+ return false;
1536
+ }
1537
+ if(!$this->GetDialogURL($url))
1538
+ return false;
1539
+ $url .= '?oauth_token='.$access_token['value'];
1540
+ if(!$one_a)
1541
+ {
1542
+ if(!$this->GetRedirectURI($redirect_uri))
1543
+ return false;
1544
+ $url .= '&oauth_callback='.UrlEncode($redirect_uri);
1545
+ }
1546
+ if($this->debug)
1547
+ $this->OutputDebug('Redirecting to OAuth authorize page '.$url);
1548
+ Header('HTTP/1.0 302 OAuth Redirection');
1549
+ Header('Location: '.$url);
1550
+ $this->exit = true;
1551
+ return true;
1552
+
1553
+ case 2:
1554
+ if($this->debug)
1555
+ $this->OutputDebug('Checking if OAuth access token was already retrieved from '.$this->access_token_url);
1556
+ if(!$this->GetAccessToken($access_token))
1557
+ return false;
1558
+ if(IsSet($access_token['value']))
1559
+ {
1560
+ if(IsSet($access_token['expiry'])
1561
+ && strcmp($this->access_token_expiry = $access_token['expiry'], gmstrftime('%Y-%m-%d %H:%M:%S')) < 0)
1562
+ {
1563
+ if($this->debug)
1564
+ $this->OutputDebug('The OAuth access token expired in '.$this->access_token_expiry);
1565
+ }
1566
+ else
1567
+ {
1568
+ $this->access_token = $access_token['value'];
1569
+ if(IsSet($access_token['type']))
1570
+ $this->access_token_type = $access_token['type'];
1571
+ if($this->debug)
1572
+ $this->OutputDebug('The OAuth access token '.$this->access_token.' is valid');
1573
+ if(strlen($this->access_token_type)
1574
+ && $this->debug)
1575
+ $this->OutputDebug('The OAuth access token is of type '.$this->access_token_type);
1576
+ return true;
1577
+ }
1578
+ }
1579
+ if($this->debug)
1580
+ $this->OutputDebug('Checking the authentication state in URI '.$_SERVER['REQUEST_URI']);
1581
+ if(!$this->GetStoredState($stored_state))
1582
+ return false;
1583
+ if(strlen($stored_state) == 0)
1584
+ return($this->SetError('it was not set the OAuth state'));
1585
+ if(!$this->GetRequestState($state))
1586
+ return false;
1587
+ if($state === $stored_state)
1588
+ {
1589
+ if($this->debug)
1590
+ $this->OutputDebug('Checking the authentication code');
1591
+ if(!$this->GetRequestCode($code))
1592
+ return false;
1593
+ if(strlen($code) == 0)
1594
+ {
1595
+ if(!$this->GetRequestError($this->authorization_error))
1596
+ return false;
1597
+ if(IsSet($this->authorization_error))
1598
+ {
1599
+ if($this->debug)
1600
+ $this->OutputDebug('Authorization failed with error code '.$this->authorization_error);
1601
+ switch($this->authorization_error)
1602
+ {
1603
+ case 'invalid_request':
1604
+ case 'unauthorized_client':
1605
+ case 'access_denied':
1606
+ case 'unsupported_response_type':
1607
+ case 'invalid_scope':
1608
+ case 'server_error':
1609
+ case 'temporarily_unavailable':
1610
+ case 'user_denied':
1611
+ return true;
1612
+ default:
1613
+ return($this->SetError('it was returned an unknown OAuth error code'));
1614
+ }
1615
+ }
1616
+ return($this->SetError('it was not returned the OAuth dialog code'));
1617
+ }
1618
+ if(!$this->GetAccessTokenURL($url))
1619
+ return false;
1620
+ if(!$this->GetRedirectURI($redirect_uri))
1621
+ return false;
1622
+ $values = array(
1623
+ 'code'=>$code,
1624
+ 'client_id'=>$this->client_id,
1625
+ 'client_secret'=>$this->client_secret,
1626
+ 'redirect_uri'=>$redirect_uri,
1627
+ 'grant_type'=>'authorization_code'
1628
+ );
1629
+ if(!$this->SendAPIRequest($url, 'POST', $values, null, array('Resource'=>'OAuth access token', 'ConvertObjects'=>true), $response))
1630
+ return false;
1631
+ if(strlen($this->access_token_error))
1632
+ {
1633
+ $this->authorization_error = $this->access_token_error;
1634
+ return true;
1635
+ }
1636
+ if(!IsSet($response['access_token']))
1637
+ {
1638
+ if(IsSet($response['error']))
1639
+ {
1640
+ $this->authorization_error = 'it was not possible to retrieve the access token: it was returned the error: '.$response['error'];
1641
+ return true;
1642
+ }
1643
+ return($this->SetError('OAuth server did not return the access token'));
1644
+ }
1645
+ $access_token = array(
1646
+ 'value'=>$this->access_token = $response['access_token'],
1647
+ 'authorized'=>true
1648
+ );
1649
+ if($this->debug)
1650
+ $this->OutputDebug('Access token: '.$this->access_token);
1651
+ if(IsSet($response['expires'])
1652
+ || IsSet($response['expires_in']))
1653
+ {
1654
+ $expires = (IsSet($response['expires']) ? $response['expires'] : $response['expires_in']);
1655
+ if(strval($expires) !== strval(intval($expires))
1656
+ || $expires <= 0)
1657
+ return($this->SetError('OAuth server did not return a supported type of access token expiry time'));
1658
+ $this->access_token_expiry = gmstrftime('%Y-%m-%d %H:%M:%S', time() + $expires);
1659
+ if($this->debug)
1660
+ $this->OutputDebug('Access token expiry: '.$this->access_token_expiry.' UTC');
1661
+ $access_token['expiry'] = $this->access_token_expiry;
1662
+ }
1663
+ else
1664
+ $this->access_token_expiry = '';
1665
+ if(IsSet($response['token_type']))
1666
+ {
1667
+ $this->access_token_type = $response['token_type'];
1668
+ if($this->debug)
1669
+ $this->OutputDebug('Access token type: '.$this->access_token_type);
1670
+ $access_token['type'] = $this->access_token_type;
1671
+ }
1672
+ else
1673
+ $this->access_token_type = '';
1674
+ if(!$this->StoreAccessToken($access_token))
1675
+ return false;
1676
+ }
1677
+ else
1678
+ {
1679
+ if(!$this->GetDialogURL($url))
1680
+ return false;
1681
+ if(strlen($url) == 0)
1682
+ return($this->SetError('it was not set the OAuth dialog URL'));
1683
+ if(!$this->GetRedirectURI($redirect_uri))
1684
+ return false;
1685
+ if(strlen($this->append_state_to_redirect_uri))
1686
+ $redirect_uri .= (strpos($redirect_uri, '?') === false ? '?' : '&').$this->append_state_to_redirect_uri.'='.$stored_state;
1687
+ $url = str_replace(
1688
+ '{REDIRECT_URI}', UrlEncode($redirect_uri), str_replace(
1689
+ '{CLIENT_ID}', UrlEncode($this->client_id), str_replace(
1690
+ '{SCOPE}', UrlEncode($this->scope), str_replace(
1691
+ '{STATE}', UrlEncode($stored_state),
1692
+ $url))));
1693
+ if($this->debug)
1694
+ $this->OutputDebug('Redirecting to OAuth Dialog '.$url);
1695
+ Header('HTTP/1.0 302 OAuth Redirection');
1696
+ Header('Location: '.$url);
1697
+ $this->exit = true;
1698
+ }
1699
+ break;
1700
+
1701
+ default:
1702
+ return($this->SetError($this->oauth_version.' is not a supported version of the OAuth protocol'));
1703
+ }
1704
+ return(true);
1705
+ }
1706
+ /*
1707
+ {metadocument}
1708
+ </do>
1709
+ </function>
1710
+ {/metadocument}
1711
+ */
1712
+
1713
+ /*
1714
+ {metadocument}
1715
+ <function>
1716
+ <name>Finalize</name>
1717
+ <type>BOOLEAN</type>
1718
+ <documentation>
1719
+ <purpose>Cleanup any resources that may have been used during the
1720
+ OAuth protocol processing or execution of API calls.</purpose>
1721
+ <usage>Always call this function as the last step after calling the
1722
+ functions <functionlink>Process</functionlink> or
1723
+ <functionlink>CallAPI</functionlink>.</usage>
1724
+ <returnvalue>This function returns <booleanvalue>1</booleanvalue> if
1725
+ the function cleaned up any resources successfully.</returnvalue>
1726
+ </documentation>
1727
+ <argument>
1728
+ <name>success</name>
1729
+ <type>BOOLEAN</type>
1730
+ <documentation>
1731
+ <purpose>Pass the last success state returned by the class or any
1732
+ external code processing the class function results.</purpose>
1733
+ </documentation>
1734
+ </argument>
1735
+ <do>
1736
+ {/metadocument}
1737
+ */
1738
+ Function Finalize($success)
1739
+ {
1740
+ return($success);
1741
+ }
1742
+ /*
1743
+ {metadocument}
1744
+ </do>
1745
+ </function>
1746
+ {/metadocument}
1747
+ */
1748
+
1749
+ /*
1750
+ {metadocument}
1751
+ <function>
1752
+ <name>Output</name>
1753
+ <type>VOID</type>
1754
+ <documentation>
1755
+ <purpose>Display the results of the OAuth protocol processing.</purpose>
1756
+ <usage>Only call this function if you are debugging the OAuth
1757
+ authorization process and you need to view what was its
1758
+ results.</usage>
1759
+ </documentation>
1760
+ <do>
1761
+ {/metadocument}
1762
+ */
1763
+ Function Output()
1764
+ {
1765
+ if(strlen($this->authorization_error)
1766
+ || strlen($this->access_token_error)
1767
+ || strlen($this->access_token))
1768
+ {
1769
+ ?>
1770
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1771
+ <html>
1772
+ <head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
1773
+ <title>OAuth client result</title>
1774
+ </head>
1775
+ <body>
1776
+ <h1>OAuth client result</h1>
1777
+ <?php
1778
+ if(strlen($this->authorization_error))
1779
+ {
1780
+ ?>
1781
+ <p>It was not possible to authorize the application.<?php
1782
+ if($this->debug)
1783
+ {
1784
+ ?>
1785
+ <br>Authorization error: <?php echo HtmlSpecialChars($this->authorization_error);
1786
+ }
1787
+ ?></p>
1788
+ <?php
1789
+ }
1790
+ elseif(strlen($this->access_token_error))
1791
+ {
1792
+ ?>
1793
+ <p>It was not possible to use the application access token.
1794
+ <?php
1795
+ if($this->debug)
1796
+ {
1797
+ ?>
1798
+ <br>Error: <?php echo HtmlSpecialChars($this->access_token_error);
1799
+ }
1800
+ ?></p>
1801
+ <?php
1802
+ }
1803
+ elseif(strlen($this->access_token))
1804
+ {
1805
+ ?>
1806
+ <p>The application authorization was obtained successfully.
1807
+ <?php
1808
+ if($this->debug)
1809
+ {
1810
+ ?>
1811
+ <br>Access token: <?php echo HtmlSpecialChars($this->access_token);
1812
+ if(IsSet($this->access_token_secret))
1813
+ {
1814
+ ?>
1815
+ <br>Access token secret: <?php echo HtmlSpecialChars($this->access_token_secret);
1816
+ }
1817
+ }
1818
+ ?></p>
1819
+ <?php
1820
+ if(strlen($this->access_token_expiry))
1821
+ {
1822
+ ?>
1823
+ <p>Access token expiry: <?php echo $this->access_token_expiry; ?> UTC</p>
1824
+ <?php
1825
+ }
1826
+ }
1827
+ ?>
1828
+ </body>
1829
+ </html>
1830
+ <?php
1831
+ }
1832
+ }
1833
+ /*
1834
+ {metadocument}
1835
+ </do>
1836
+ </function>
1837
+ {/metadocument}
1838
+ */
1839
+
1840
+ };
1841
+
1842
+ /*
1843
+
1844
+ {metadocument}
1845
+ </class>
1846
+ {/metadocument}
1847
+
1848
+ */
1849
+
1850
+ ?>
app/code/local/Soclever/Socialloginsharing/etc/system.xml CHANGED
@@ -115,6 +115,15 @@
115
  <show_in_website>1</show_in_website>
116
  <show_in_store>1</show_in_store>
117
  </displaystyle>
 
 
 
 
 
 
 
 
 
118
  <yourstyle translate="label">
119
  <label>Button Style</label>
120
  <frontend_type>select</frontend_type>
115
  <show_in_website>1</show_in_website>
116
  <show_in_store>1</show_in_store>
117
  </displaystyle>
118
+ <mobilefriendly translate="label">
119
+ <label>Mobile Friendly</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_yesno</source_model>
122
+ <sort_order>155</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ </mobilefriendly>
127
  <yourstyle translate="label">
128
  <label>Button Style</label>
129
  <frontend_type>select</frontend_type>
app/design/frontend/base/default/template/socialloginsharing/socialshare_footer.phtml CHANGED
@@ -5,7 +5,7 @@ if(!Mage::getStoreConfig('advanced/modules_disable_output/Soclever_Socialsharesc
5
 
6
  Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/scsl_footer_added',"1");
7
  $footer_code='<script type="text/javascript">var sid=\''.Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid').'\';(function()
8
- { var u=((\'https:\'==document.location.protocol)?\'http://\':\'http://\')+\'s3.socleversocial.com/\'; var su=u;var s=document.createElement(\'script\'); s.type=\'text/javascript\'; s.defer=true; s.async=true; s.src=su+\'scs.js\'; var p=document.getElementsByTagName(\'script\')[0]; p.parentNode.insertBefore(s,p); }
9
  )();
10
  </script>'.PHP_EOL;
11
 
5
 
6
  Mage::getModel('core/config')->saveConfig('socialloginsharing_options/apisettings/scsl_footer_added',"1");
7
  $footer_code='<script type="text/javascript">var sid=\''.Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid').'\';(function()
8
+ { var u=((\'https:\'==document.location.protocol)?\'https://\':\'https://\')+\'s3.socleversocial.com/\'; var su=u;var s=document.createElement(\'script\'); s.type=\'text/javascript\'; s.defer=true; s.async=true; s.src=su+\'scs.js\'; var p=document.getElementsByTagName(\'script\')[0]; p.parentNode.insertBefore(s,p); }
9
  )();
10
  </script>'.PHP_EOL;
11
 
app/design/frontend/base/default/template/socialloginsharing/socialshare_product.phtml CHANGED
@@ -1,354 +1,409 @@
1
- <?php
2
- $is_validated=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_validated');
3
- if($is_validated=='1')
4
- {
5
- $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
6
- if($display_style=='0')
7
- {
8
- if(!function_exists('cs_get_plusones'))
9
- {
10
-
11
- function cs_get_plusones($url) {
12
- $curl = curl_init();
13
- curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
14
- curl_setopt($curl, CURLOPT_POST, true);
15
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
16
- curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.rawurldecode($url).'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
17
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
18
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
19
- $curl_results = curl_exec ($curl);
20
- curl_close ($curl);
21
- $json = json_decode($curl_results, true);
22
- return isset($json[0]['result']['metadata']['globalCounts']['count'])?intval( $json[0]['result']['metadata']['globalCounts']['count'] ):0;
23
- }
24
-
25
- }
26
- if(!function_exists('cs_format_share_url'))
27
- {
28
- function cs_format_share_url($url,$source)
29
- {
30
-
31
- $name = "scsource";
32
- $value = $source;
33
-
34
-
35
- $separator = "?";
36
- if (strpos($url,"?")!==false)
37
- $separator = "&";
38
-
39
-
40
- $insertPosition = strlen($url);
41
- if (strpos($url,"#")!==false)
42
- $insertPosition = strpos($url,"#");
43
-
44
-
45
- $newUrl = substr_replace($url,"$separator$name=$value",$insertPosition,0);
46
-
47
- return $newUrl;
48
- }
49
-
50
- }
51
- $iwidth=explode("x",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/iconsize'));
52
- $button_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyle');
53
- $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
54
- $gap=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/gapsetting');
55
- $counter_type=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/countersetting');
56
- $share_button=explode(",",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/socialproviders'));
57
-
58
- $vartical_top=$counter_position="";
59
- $main_div='height:'.$iwidth[0].'px';
60
- $cspageURL = 'http';
61
- if($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
62
- $cspageURL .= "://";
63
- if ($_SERVER["SERVER_PORT"] != "80") {
64
- $cspageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
65
- } else {
66
- $cspageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
67
- }
68
- $url=$cspageURL;
69
- if($counter_type=='0' || $counter_type=='1')
70
- {
71
-
72
- $counter_position='.arrow_box:after, .arrow_box:before { top: 100%; left: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-top-color: #fff; border-width: 6px; margin-left: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-top-color: #cccccb; border-width: 7px; margin-left: -7px; }';
73
- if($counter_type=='0')
74
- {
75
- $main_div='float:left;margin-top:0px;margin-left:8px;height:'.$iwidth[0].'px;margin-right:8px;';
76
-
77
- $counter_position='.arrow_box:after, .arrow_box:before { right: 100%; top: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-right-color: #fff; border-width: 6px; margin-top: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-right-color: #cccccb; border-width: 7px; margin-top: -7px; }';
78
- }
79
- $js_code .='<style>'.PHP_EOL.
80
- '.arrow_box { width: '.($iwidth[0]-5).'px; margin-bottom:8px;'.$main_div.' border-radius: 1px; position: relative; background: #fff; border: 1px solid #cccccb; }'.$counter_position.''.PHP_EOL.
81
- '</style>'.PHP_EOL;
82
- }
83
- $useragent=$_SERVER['HTTP_USER_AGENT'];
84
- $mobile_Display="display:none;";
85
- $comon_counter_start='<div class="arrow_box" ><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
86
- $comon_counter_start_18='<div class="arrow_box" style="display:none;"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
87
- if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))
88
- {
89
-
90
- $mobile_Display="display:inline-block;";
91
- $comon_counter_start_18='<div class="arrow_box"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
92
- }
93
-
94
- if($button_style=='custom')
95
- {
96
- $fb_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylefb');
97
- $gp_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylegp');
98
- $li_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyleli');
99
- $tw_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletw');
100
- $pi_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylepi');
101
- $wa_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylewa');
102
- $su_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylesu');
103
- $rd_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylerd');
104
- $tm_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletm');
105
-
106
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($fb_style)?$fb_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png').'\'';
107
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($gp_style)?$gp_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png').'\'';
108
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($li_style)?$li_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
109
- $src_style13='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tw_style)?$tw_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png').'\'';
110
- $src_style17='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($pi_style)?$pi_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png').'\'';
111
- $src_style18='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'\' src=\''.(($wa_style)?$wa_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
112
- $src_style19='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($su_style)?$su_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png').'\'';
113
- $src_style20='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($rd_style)?$rd_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png').'\'';
114
- $src_style21='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tm_style)?$tm_style:'https://www.socleversocial.com/dashboard/img/social_icon/square/tumblr_square.png').'\'';
115
-
116
- }
117
- else if($button_style=='1')
118
- {
119
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png"';
120
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png"';
121
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png\'';
122
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png"';
123
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png"';
124
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_square.png"';
125
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png"';
126
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png"';
127
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_square.png"';
128
-
129
- }
130
- else if($button_style=='2')
131
- {
132
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook.png"';
133
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus.png"';
134
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin.png\'';
135
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter.png"';
136
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest.png"';
137
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp.png"';
138
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon.png"';
139
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit.png"';
140
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr.png"';
141
-
142
- }
143
- else if($button_style=='3')
144
- {
145
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey.png"';
146
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey.png"';
147
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey.png\'';
148
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey.png"';
149
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey.png"';
150
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey.png"';
151
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey.png"';
152
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey.png"';
153
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_grey.png"';
154
- }
155
- else if($button_style=='4')
156
- {
157
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey_circle.png"';
158
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey_circle.png"';
159
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey_circle.png\'';
160
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey_circle.png"';
161
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey_circle.png"';
162
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey_circle.png"';
163
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey_circle.png"';
164
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey_circle.png"';
165
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/grey_circle/tumblr_grey_circle.png"';
166
- }
167
- else if($button_style=='5')
168
- {
169
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/facebook_flower.png"';
170
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/google_flower.png"';
171
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/flower/linkedin_flower.png\'';
172
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/twitter_flower.png"';
173
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/pinterest_flower.png"';
174
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
175
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/stumbleupon_flower.png"';
176
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/reddit_flower.png"';
177
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/tumblr_flower.png"';
178
-
179
- }
180
- else if($button_style=='6')
181
- {
182
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/facebook_glossy.png"';
183
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/google_glossy.png"';
184
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/glossy/linkedin_glossy.png\'';
185
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/twitter_glossy.png"';
186
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/pinterest_glossy.png"';
187
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
188
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/stumbleupon_glossy.png"';
189
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/reddit_glossy.png"';
190
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/tumblr_glossy.png"';
191
-
192
-
193
- }
194
- else if($button_style=='7')
195
- {
196
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/facebook_leaf.png"';
197
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/google_leaf.png"';
198
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/leaf/linkedin_leaf.png\'';
199
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/twitter_leaf.png"';
200
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/pinterest_leaf.png"';
201
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
202
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/stumbleupon_leaf.png"';
203
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/reddit_leaf.png"';
204
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/tumblr_leaf.png"';
205
-
206
-
207
- }
208
- else if($button_style=='8')
209
- {
210
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/facebook_polygon.png"';
211
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/google_polygon.png"';
212
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/polygon/linkedin_polygon.png\'';
213
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/twitter_polygon.png"';
214
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/pinterest_polygon.png"';
215
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
216
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/stumbleupon_polygon.png"';
217
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/reddit_polygon.png"';
218
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/tumblr_polygon.png"';
219
-
220
-
221
- }
222
- else if($button_style=='9')
223
- {
224
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/facebook_rectangular.png"';
225
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/google_rectangular.png"';
226
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rectangular/linkedin_rectangular.png\'';
227
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/twitter_rectangular.png"';
228
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/pinterest_rectangular.png"';
229
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
230
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/stumbleupon_rectangular.png"';
231
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/reddit_rectangular.png"';
232
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/tumblr_rectangular.png"';
233
-
234
- }
235
- else if($button_style=='10')
236
- {
237
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/facebook_rounded_corners.png"';
238
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/google_rounded_corners.png"';
239
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/linkedin_rounded_corners.png\'';
240
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/twitter_rounded_corners.png"';
241
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/pinterest_rounded_corners.png"';
242
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
243
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/stumbleupon_rounded_corners.png"';
244
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/reddit_rounded_corners.png"';
245
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/tumblr_rounded_corners.png"';
246
-
247
-
248
- }
249
- else if($button_style=='11')
250
- {
251
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/facebook_waterdrop.png"';
252
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/google_waterdrop.png"';
253
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/linkedin_waterdrop.png\'';
254
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/twitter_waterdrop.png"';
255
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/pinterest_waterdrop.png"';
256
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
257
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/stumbleupon_waterdrop.png"';
258
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/reddit_waterdrop.png"';
259
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/tumblr_waterdrop.png"';
260
- }
261
-
262
- if($display_style=='1')
263
- {
264
- $gap_string='<div style=\'float:left;height:'.$gap.'px;\'>&nbsp;</div>';
265
- }
266
- else
267
- {
268
- $gap_string='<div style=\'float:left;width:'.$gap.'px;\'>&nbsp;</div>';
269
- }
270
-
271
- if($counter_type=='0' || $counter_type=='1')
272
- {
273
-
274
-
275
-
276
-
277
- $counter_top_margin='';
278
- if($counter_type=='0')
279
- {
280
- $counter_top_margin='margin-top:'.intval($iwidth[0]/4).'px;';
281
- }
282
-
283
- $comon_counter_end='</div></div>';
284
- $other_count=file_get_contents("https://www.socleversocial.com/dashboard/get_other_counts.php?site_id=".Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid')."&url=".$url."");
285
- $row_count=explode("~",$other_count);
286
- $comon_counter_end='</div></div>';
287
- $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
288
- $count2r=$count2=''.$comon_counter_start.''.intval($row_count[4]).''.$comon_counter_end.'';
289
- $count4r=$count4=''.$comon_counter_start.''.intval($row_count[6]).''.$comon_counter_end.'';
290
- $count7r=$count7=''.$comon_counter_start.''.intval($row_count[5]).''.$comon_counter_end.'';
291
- $count13r=$count13=''.$comon_counter_start.''.intval($row_count[7]).''.$comon_counter_end.'';
292
- $count17r=$count17=''.$comon_counter_start.''.intval($row_count[8]).''.$comon_counter_end.'';
293
- $count18r=$count18=''.$comon_counter_start_18.''.intval($row_count[0]).''.$comon_counter_end.'';
294
- $count19r=$count19=''.$comon_counter_start.''.intval($row_count[1]).''.$comon_counter_end.'';
295
- $count20r=$count20=''.$comon_counter_start.''.intval($row_count[2]).''.$comon_counter_end.'';
296
- $count21r=$count21=''.$comon_counter_start.''.intval($row_count[3]).''.$comon_counter_end.'';
297
-
298
-
299
- }
300
- if($counter_type=='0')
301
- {
302
- $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
303
- }
304
- else
305
- {
306
- $count2r=$count4r=$count7r=$count13r=$count17r=$count18r=$count19r=$count20r=$count21r="";
307
- }
308
-
309
- if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
310
- $customerData = Mage::getSingleton('customer/session')->getCustomer();
311
-
312
- $user_ID=$customerData->getId();
313
-
314
- }
315
- $title=$this->getLayout()->getBlock('head')->getTitle();
316
- $share_arr[2]='<div style="float:left;">'.$count2.'<img '.$src_style2.' onclick="share_on_cs(\'1\',\''.$user_ID.'\');window.open(\'http://www.facebook.com/sharer.php?u='.urlencode(cs_format_share_url($url,'1')).'&t='.urlencode($title).'\',\'_new\');" alt="Share on Facebook" ></div>'.$count2r.''.$gap_string.'';
317
- $share_arr[4]='<div style=\'float:left;\'>'.$count4.'<img '.$src_style4.' onclick="share_on_cs(\'3\',\''.$user_ID.'\');window.open(\'https://plus.google.com/share?url='.urlencode(cs_format_share_url($url,'3')).'&title='.urlencode($title).'\',\'_new\');" alt="Share on Google+"></div>'.$count4r.''.$gap_string.'';
318
- $share_arr[7]='<div style=\'float:left;\'>'.$count7.'<img '.$src_style7.' onclick="share_on_cs(\'2\',\''.$user_ID.'\');window.open(\'https://www.linkedin.com/cws/share?url='.urlencode(cs_format_share_url($url,'2')).'&title='.urlencode($title).'\',\'_new\');" alt="Share on LinkedIN" ></div>'.$count7r.''.$gap_string.'';
319
- $share_arr[13]='<div style=\'float:left;\'>'.$count13.'<img '.$src_style13.' onclick="share_on_cs(\'4\',\''.$user_ID.'\');window.open(\'http://twitter.com/share?url='.urlencode(cs_format_share_url($url,'4')).'&text='.urlencode($title).'\',\'_new\');" alt="Share on Twitter"></div>'.$count13r.''.$gap_string.'';
320
- $share_arr[17]='<div style=\'float:left;\'>'.$count17.'<img '.$src_style17.' onclick="share_on_cs(\'5\',\''.$user_ID.'\');" alt="Pin It"></div>'.$count17r.''.$gap_string.'';
321
- $share_arr[18]='<div style=\'float:left;\'>'.$count18.'<img '.$src_style18.' onclick="share_on_cs(\'6\',\''.$user_ID.'\');" alt="Share on Whatsapp"></div>'.$count18r.''.$gap_string.'';
322
- $share_arr[19]='<div style=\'float:left;\'>'.$count19.'<img '.$src_style19.' onclick="share_on_cs(\'7\',\''.$user_ID.'\');window.open(\'http://www.stumbleupon.com/submit?url='.urlencode(cs_format_share_url($url,'7')).'&title='.urlencode($title).'\',\'_new\');"" alt="Share on StumbleUpon"></div>'.$count19r.''.$gap_string.'';
323
- $share_arr[20]='<div style=\'float:left;\'>'.$count20.'<img '.$src_style20.' onclick="share_on_cs(\'8\',\''.$user_ID.'\');window.open(\'http://www.reddit.com/submit?url='.urlencode(cs_format_share_url($url,'8')).'&title='.urlencode($title).'\',\'_new\');"" alt="Share on Reddit"></div>'.$count20r.''.$gap_string.'';
324
- $share_arr[21]='<div style=\'float:left;\'>'.$count21.'<img '.$src_style21.' onclick="share_on_cs(\'9\',\''.$user_ID.'\');window.open(\'http://www.tumblr.com/share/link?url='.urlencode(cs_format_share_url($url,'9')).'&name='.urlencode($title).'\',\'_new\');"" alt="Pin It"></div>'.$count21r.''.$gap_string.'';
325
-
326
-
327
- $start_div='<div id="scssdiv" style="clear:both;wdth:100%;height:100%;z-index:999;display:inline-block;">';
328
- $end_div='</div>';
329
- if($display_style=='1' || $display_style=='2' )
330
- {
331
-
332
- $left_right=($display_style=='2')?'right:0;':'left:0;';
333
- $multiplier_div=($counter_type=='0')?'2':'1';
334
- $add_extra=($counter_type=='0')?'20':'0';
335
- $start_div='<div id="scssdiv" style="width:'.intval(($iwidth[0]*$multiplier_div)+$add_extra).'px;position:fixed;top:30%;'.$left_right.'display:inline-block;height:100%;z-index:999;display:inline-block;">';
336
- $end_div='</div>';
337
- }
338
-
339
-
340
- $js_code .= PHP_EOL;
341
- $js_code .=$start_div;
342
- foreach($share_button as $key=>$val)
343
- {
344
-
345
- $js_code .=$share_arr[$val];
346
- }
347
- $js_code .=$end_div;
348
-
349
-
350
-
351
- echo $js_code;
352
- }
353
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  ?>
1
+ <?php
2
+ $is_validated=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_validated');
3
+ if($is_validated=='1')
4
+ {
5
+ $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
6
+
7
+ if(!function_exists('scs_is_mobile'))
8
+ {
9
+ function scs_is_mobile()
10
+ {
11
+ $useragent=$_SERVER['HTTP_USER_AGENT'];
12
+
13
+
14
+
15
+ return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4));
16
+
17
+
18
+ }
19
+ }
20
+
21
+
22
+
23
+ if($display_style=='0')
24
+ {
25
+ if(!function_exists('cs_get_plusones'))
26
+ {
27
+
28
+ function cs_get_plusones($url) {
29
+ $curl = curl_init();
30
+ curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
31
+ curl_setopt($curl, CURLOPT_POST, true);
32
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
33
+ curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.rawurldecode($url).'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
34
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
35
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
36
+ $curl_results = curl_exec ($curl);
37
+ curl_close ($curl);
38
+ $json = json_decode($curl_results, true);
39
+ return isset($json[0]['result']['metadata']['globalCounts']['count'])?intval( $json[0]['result']['metadata']['globalCounts']['count'] ):0;
40
+ }
41
+
42
+ }
43
+ if(!function_exists('cs_format_share_url'))
44
+ {
45
+ function cs_format_share_url($url,$source)
46
+ {
47
+
48
+ $name = "scsource";
49
+ $value = $source;
50
+
51
+
52
+ $separator = "?";
53
+ if (strpos($url,"?")!==false)
54
+ $separator = "&";
55
+
56
+
57
+ $insertPosition = strlen($url);
58
+ if (strpos($url,"#")!==false)
59
+ $insertPosition = strpos($url,"#");
60
+
61
+
62
+ $newUrl = substr_replace($url,"$separator$name=$value",$insertPosition,0);
63
+
64
+ return $newUrl;
65
+ }
66
+
67
+ }
68
+ $iwidth=explode("x",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/iconsize'));
69
+ $mobilefriendly=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/mobilefriendly');
70
+ $button_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyle');
71
+ $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
72
+ $gap=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/gapsetting');
73
+ $counter_type=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/countersetting');
74
+ $share_button=explode(",",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/socialproviders'));
75
+
76
+ $vartical_top=$counter_position="";
77
+ $main_div='height:'.$iwidth[0].'px';
78
+ $cspageURL = 'http';
79
+ if($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
80
+ $cspageURL .= "://";
81
+ if ($_SERVER["SERVER_PORT"] != "80") {
82
+ $cspageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
83
+ } else {
84
+ $cspageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
85
+ }
86
+ $url=$cspageURL;
87
+ if($counter_type=='0' || $counter_type=='1')
88
+ {
89
+
90
+ $counter_position='.arrow_box:after, .arrow_box:before { top: 100%; left: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-top-color: #fff; border-width: 6px; margin-left: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-top-color: #cccccb; border-width: 7px; margin-left: -7px; }';
91
+ if($counter_type=='0')
92
+ {
93
+ $main_div='float:left;margin-top:0px;margin-left:8px;height:'.$iwidth[0].'px;margin-right:8px;';
94
+
95
+ $counter_position='.arrow_box:after, .arrow_box:before { right: 100%; top: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-right-color: #fff; border-width: 6px; margin-top: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-right-color: #cccccb; border-width: 7px; margin-top: -7px; }';
96
+ }
97
+ $js_code .='<style>'.PHP_EOL.
98
+ '.arrow_box { width: '.($iwidth[0]-5).'px; margin-bottom:8px;'.$main_div.' border-radius: 1px; position: relative; background: #fff; border: 1px solid #cccccb; }'.$counter_position.''.PHP_EOL.
99
+ '</style>'.PHP_EOL;
100
+ }
101
+
102
+ $is_mobile='0';
103
+ $mobile_Display="display:none !important;";
104
+ $comon_counter_start='<div class="arrow_box" ><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
105
+ $comon_counter_start_18='<div class="arrow_box" style="display:none;"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
106
+ if(scs_is_mobile())
107
+ {
108
+ $is_mobile='1';
109
+ $iwidth=explode("x","40x40");
110
+ $mobile_Display="display:inline-block;";
111
+ $comon_counter_start_18='<div class="arrow_box"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
112
+ }
113
+
114
+ if($button_style=='custom')
115
+ {
116
+ $fb_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylefb');
117
+ $gp_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylegp');
118
+ $li_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyleli');
119
+ $tw_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletw');
120
+ $pi_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylepi');
121
+ $wa_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylewa');
122
+ $su_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylesu');
123
+ $rd_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylerd');
124
+ $tm_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletm');
125
+
126
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($fb_style)?$fb_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png').'\'';
127
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($gp_style)?$gp_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png').'\'';
128
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($li_style)?$li_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
129
+ $src_style13='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tw_style)?$tw_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png').'\'';
130
+ $src_style17='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($pi_style)?$pi_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png').'\'';
131
+ $src_style18='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'\' src=\''.(($wa_style)?$wa_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
132
+ $src_style19='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($su_style)?$su_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png').'\'';
133
+ $src_style20='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($rd_style)?$rd_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png').'\'';
134
+ $src_style21='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tm_style)?$tm_style:'https://www.socleversocial.com/dashboard/img/social_icon/square/tumblr_square.png').'\'';
135
+
136
+ }
137
+ else if($button_style=='1')
138
+ {
139
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png"';
140
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png"';
141
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png\'';
142
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png"';
143
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png"';
144
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_square.png"';
145
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png"';
146
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png"';
147
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_square.png"';
148
+
149
+ }
150
+ else if($button_style=='2')
151
+ {
152
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook.png"';
153
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus.png"';
154
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin.png\'';
155
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter.png"';
156
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest.png"';
157
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp.png"';
158
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon.png"';
159
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit.png"';
160
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr.png"';
161
+
162
+ }
163
+ else if($button_style=='3')
164
+ {
165
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey.png"';
166
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey.png"';
167
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey.png\'';
168
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey.png"';
169
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey.png"';
170
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey.png"';
171
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey.png"';
172
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey.png"';
173
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_grey.png"';
174
+ }
175
+ else if($button_style=='4')
176
+ {
177
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey_circle.png"';
178
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey_circle.png"';
179
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey_circle.png\'';
180
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey_circle.png"';
181
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey_circle.png"';
182
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey_circle.png"';
183
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey_circle.png"';
184
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey_circle.png"';
185
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/grey_circle/tumblr_grey_circle.png"';
186
+ }
187
+ else if($button_style=='5')
188
+ {
189
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/facebook_flower.png"';
190
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/google_flower.png"';
191
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/flower/linkedin_flower.png\'';
192
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/twitter_flower.png"';
193
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/pinterest_flower.png"';
194
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
195
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/stumbleupon_flower.png"';
196
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/reddit_flower.png"';
197
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/tumblr_flower.png"';
198
+
199
+ }
200
+ else if($button_style=='6')
201
+ {
202
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/facebook_glossy.png"';
203
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/google_glossy.png"';
204
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/glossy/linkedin_glossy.png\'';
205
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/twitter_glossy.png"';
206
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/pinterest_glossy.png"';
207
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
208
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/stumbleupon_glossy.png"';
209
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/reddit_glossy.png"';
210
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/tumblr_glossy.png"';
211
+
212
+
213
+ }
214
+ else if($button_style=='7')
215
+ {
216
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/facebook_leaf.png"';
217
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/google_leaf.png"';
218
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/leaf/linkedin_leaf.png\'';
219
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/twitter_leaf.png"';
220
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/pinterest_leaf.png"';
221
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
222
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/stumbleupon_leaf.png"';
223
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/reddit_leaf.png"';
224
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/tumblr_leaf.png"';
225
+
226
+
227
+ }
228
+ else if($button_style=='8')
229
+ {
230
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/facebook_polygon.png"';
231
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/google_polygon.png"';
232
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/polygon/linkedin_polygon.png\'';
233
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/twitter_polygon.png"';
234
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/pinterest_polygon.png"';
235
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
236
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/stumbleupon_polygon.png"';
237
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/reddit_polygon.png"';
238
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/tumblr_polygon.png"';
239
+
240
+
241
+ }
242
+ else if($button_style=='9')
243
+ {
244
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/facebook_rectangular.png"';
245
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/google_rectangular.png"';
246
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rectangular/linkedin_rectangular.png\'';
247
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/twitter_rectangular.png"';
248
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/pinterest_rectangular.png"';
249
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
250
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/stumbleupon_rectangular.png"';
251
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/reddit_rectangular.png"';
252
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/tumblr_rectangular.png"';
253
+
254
+ }
255
+ else if($button_style=='10')
256
+ {
257
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/facebook_rounded_corners.png"';
258
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/google_rounded_corners.png"';
259
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/linkedin_rounded_corners.png\'';
260
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/twitter_rounded_corners.png"';
261
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/pinterest_rounded_corners.png"';
262
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
263
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/stumbleupon_rounded_corners.png"';
264
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/reddit_rounded_corners.png"';
265
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/tumblr_rounded_corners.png"';
266
+
267
+
268
+ }
269
+ else if($button_style=='11')
270
+ {
271
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/facebook_waterdrop.png"';
272
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/google_waterdrop.png"';
273
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/linkedin_waterdrop.png\'';
274
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/twitter_waterdrop.png"';
275
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/pinterest_waterdrop.png"';
276
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
277
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/stumbleupon_waterdrop.png"';
278
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/reddit_waterdrop.png"';
279
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/tumblr_waterdrop.png"';
280
+ }
281
+
282
+ if($display_style=='1')
283
+ {
284
+ $gap_string='<span style=\'float:left;height:'.$gap.'px;\'>&nbsp;</span>';
285
+ }
286
+ else
287
+ {
288
+ $gap_string='<span style=\'float:left;width:'.$gap.'px;\'>&nbsp;</span>';
289
+ }
290
+
291
+ if($mobilefriendly=='1' && scs_is_mobile())
292
+ {
293
+ $gap_string='';
294
+ }
295
+
296
+
297
+
298
+ if($counter_type=='0' || $counter_type=='1')
299
+ {
300
+
301
+
302
+
303
+
304
+ $counter_top_margin='';
305
+ if($counter_type=='0')
306
+ {
307
+ $counter_top_margin='margin-top:'.intval($iwidth[0]/4).'px;';
308
+ }
309
+
310
+ $comon_counter_end='</div></div>';
311
+
312
+ $comon_counter_end='</div></div>';
313
+ $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
314
+ if(!scs_is_mobile())
315
+ {
316
+ $other_count=file_get_contents("https://www.socleversocial.com/dashboard/get_other_counts.php?site_id=".Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid')."&url=".$url."");
317
+ $row_count=explode("~",$other_count);
318
+ $count2r=$count2=''.$comon_counter_start.''.intval($row_count[4]).''.$comon_counter_end.'';
319
+ $count4r=$count4=''.$comon_counter_start.''.intval($row_count[6]).''.$comon_counter_end.'';
320
+ $count7r=$count7=''.$comon_counter_start.''.intval($row_count[5]).''.$comon_counter_end.'';
321
+ $count13r=$count13=''.$comon_counter_start.''.intval($row_count[7]).''.$comon_counter_end.'';
322
+ $count17r=$count17=''.$comon_counter_start.''.intval($row_count[8]).''.$comon_counter_end.'';
323
+ $count18r=$count18=''.$comon_counter_start_18.''.intval($row_count[0]).''.$comon_counter_end.'';
324
+ $count19r=$count19=''.$comon_counter_start.''.intval($row_count[1]).''.$comon_counter_end.'';
325
+ $count20r=$count20=''.$comon_counter_start.''.intval($row_count[2]).''.$comon_counter_end.'';
326
+ $count21r=$count21=''.$comon_counter_start.''.intval($row_count[3]).''.$comon_counter_end.'';
327
+ }
328
+
329
+ }
330
+ if($counter_type=='0')
331
+ {
332
+ $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
333
+ }
334
+ else
335
+ {
336
+ $count2r=$count4r=$count7r=$count13r=$count17r=$count18r=$count19r=$count20r=$count21r="";
337
+ }
338
+
339
+ if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
340
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
341
+
342
+ $user_ID=$customerData->getId();
343
+
344
+ }
345
+
346
+ if($mobilefriendly=='1' && scs_is_mobile())
347
+ {
348
+ $ic_div='margin:0px 0px;width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;';
349
+ }
350
+ else
351
+ {
352
+ $ic_div='float:left;';
353
+ }
354
+ $title=$this->getLayout()->getBlock('head')->getTitle();
355
+ $share_arr[2]='<span style="float:left;">'.$count2.'<img '.$src_style2.' onclick="share_on_cs(\'1\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.facebook.com/sharer.php?u='.urlencode(cs_format_share_url($url,'1')).'&t='.urlencode($title).'\',\'Share on Facebook\',\'600\',\'400\');" alt="Share on Facebook" ></span>'.$count2r.''.$gap_string.'';
356
+ $share_arr[4]='<span style=\'float:left;\'>'.$count4.'<img '.$src_style4.' onclick="share_on_cs(\'3\',\''.$user_ID.'\');cspopupCenterMagento(\'https://plus.google.com/share?url='.urlencode(cs_format_share_url($url,'3')).'&title='.urlencode($title).'\',\'Share on Google\',\'600\',\'400\');" alt="Share on Google+"></span>'.$count4r.''.$gap_string.'';
357
+ $share_arr[7]='<span style=\'float:left;\'>'.$count7.'<img '.$src_style7.' onclick="share_on_cs(\'2\',\''.$user_ID.'\');cspopupCenterMagento(\'https://www.linkedin.com/cws/share?url='.urlencode(cs_format_share_url($url,'2')).'&title='.urlencode($title).'\',\'Share on LinkedIN\',\'600\',\'400\');" alt="Share on LinkedIN" ></span>'.$count7r.''.$gap_string.'';
358
+ $share_arr[13]='<span style=\'float:left;\'>'.$count13.'<img '.$src_style13.' onclick="share_on_cs(\'4\',\''.$user_ID.'\');cspopupCenterMagento(\'http://twitter.com/share?url='.urlencode(cs_format_share_url($url,'4')).'&text='.urlencode($title).'\',\'Share on Twitter\',\'600\',\'400\',);" alt="Share on Twitter"></span>'.$count13r.''.$gap_string.'';
359
+ $share_arr[17]='<span style=\'float:left;\'>'.$count17.'<img '.$src_style17.' onclick="share_on_cs(\'5\',\''.$user_ID.'\');" alt="Pin It"></span>'.$count17r.''.$gap_string.'';
360
+ $share_arr[18]='<span style=\'float:left;\'>'.$count18.'<img '.$src_style18.' onclick="share_on_cs(\'6\',\''.$user_ID.'\');" alt="Share on Whatsapp"></span>'.$count18r.''.$gap_string.'';
361
+ $share_arr[19]='<span style=\'float:left;\'>'.$count19.'<img '.$src_style19.' onclick="share_on_cs(\'7\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.stumbleupon.com/submit?url='.urlencode(cs_format_share_url($url,'7')).'&title='.urlencode($title).'\',\'Share on StumbleUpon\',\'600\',\'400\');"" alt="Share on StumbleUpon"></span>'.$count19r.''.$gap_string.'';
362
+ $share_arr[20]='<span style=\'float:left;\'>'.$count20.'<img '.$src_style20.' onclick="share_on_cs(\'8\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.reddit.com/submit?url='.urlencode(cs_format_share_url($url,'8')).'&title='.urlencode($title).'\',\'Share on Reddit\',\'600\',\'400\');"" alt="Share on Reddit"></span>'.$count20r.''.$gap_string.'';
363
+ $share_arr[21]='<span style=\'float:left;\'>'.$count21.'<img '.$src_style21.' onclick="share_on_cs(\'9\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.tumblr.com/share/link?url='.urlencode(cs_format_share_url($url,'9')).'&name='.urlencode($title).'\',\'Share on Tumblr\',\'600\',\'400\');"" alt="Share on Tumblr"></span>'.$count21r.''.$gap_string.'';
364
+
365
+
366
+ $start_div='<div id="scssdiv" style="clear:both;wdth:100%;height:100%;z-index:999;display:inline-block;">';
367
+ $end_div='</div>';
368
+ if($display_style=='1' || $display_style=='2' )
369
+ {
370
+
371
+ $left_right=($display_style=='2')?'right:0;':'left:0;';
372
+ $multiplier_div=($counter_type=='0')?'2':'1';
373
+ $add_extra=($counter_type=='0')?'20':'0';
374
+ $start_div='<div id="scssdiv" style="width:'.intval(($iwidth[0]*$multiplier_div)+$add_extra).'px;position:fixed;top:30%;'.$left_right.'display:inline-block;height:100%;z-index:999;display:inline-block;">';
375
+ $end_div='</div>';
376
+ }
377
+
378
+ if($mobilefriendly=='1' && scs_is_mobile())
379
+ {
380
+ $start_div='<div id="scssdiv" style="width: 90%;position:fixed;bottom:0;height: 40px; background-color:transparent;z-index:999;text-align:center;margin:0 auto;">';
381
+ }
382
+
383
+ $js_code .= PHP_EOL;
384
+ $js_code .=$start_div;
385
+ foreach($share_button as $key=>$val)
386
+ {
387
+
388
+ $js_code .=$share_arr[$val];
389
+ }
390
+ $js_code .=$end_div;
391
+ $js_code .= PHP_EOL;
392
+ $js_code .='<script type="text/javascript">
393
+ if(typeof cspopupCenterMagento !== \'function\' )
394
+ {
395
+ function cspopupCenterMagento(url, title, w, h) {
396
+ var left = (screen.width/2)-(w/2);
397
+ var top = (screen.height/2)-(h/2);
398
+ return window.open(url, title, \'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=\'+w+\', height=\'+h+\', top=\'+top+\', left=\'+left);
399
+ }
400
+ }
401
+ </script>'.PHP_EOL;
402
+ $js_code .='<style>#scssdiv img { display:inline !important; }</style>';
403
+
404
+
405
+
406
+ echo $js_code;
407
+ }
408
+ }
409
  ?>
app/design/frontend/base/default/template/socialloginsharing/socialshare_show.phtml CHANGED
@@ -1,363 +1,418 @@
1
- <?php
2
- $is_validated=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_validated');
3
- if($is_validated=='1')
4
- {
5
- /*$scss_product_page=false;
6
- if(Mage::registry('current_product')) {
7
- $scss_product_page = true;
8
- }
9
- */
10
- $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
11
- if(!function_exists('cs_get_plusones'))
12
- {
13
-
14
- function cs_get_plusones($url) {
15
- $curl = curl_init();
16
- curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
17
- curl_setopt($curl, CURLOPT_POST, true);
18
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
19
- curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.rawurldecode($url).'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
20
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
21
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
22
- $curl_results = curl_exec ($curl);
23
- curl_close ($curl);
24
- $json = json_decode($curl_results, true);
25
- return isset($json[0]['result']['metadata']['globalCounts']['count'])?intval( $json[0]['result']['metadata']['globalCounts']['count'] ):0;
26
- }
27
-
28
- }
29
- if(!function_exists('cs_format_share_url'))
30
- {
31
- function cs_format_share_url($url,$source)
32
- {
33
-
34
- $name = "scsource";
35
- $value = $source;
36
-
37
-
38
- $separator = "?";
39
- if (strpos($url,"?")!==false)
40
- $separator = "&";
41
-
42
-
43
- $insertPosition = strlen($url);
44
- if (strpos($url,"#")!==false)
45
- $insertPosition = strpos($url,"#");
46
-
47
-
48
- $newUrl = substr_replace($url,"$separator$name=$value",$insertPosition,0);
49
-
50
- return $newUrl;
51
- }
52
-
53
- }
54
-
55
- if($display_style=='1' || $display_style=='2')
56
- {
57
-
58
- $iwidth=explode("x",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/iconsize'));
59
- $button_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyle');
60
- $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
61
- $gap=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/gapsetting');
62
- $counter_type=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/countersetting');
63
- $share_button=explode(",",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/socialproviders'));
64
-
65
- $vartical_top=$counter_position="";
66
- $main_div='height:'.$iwidth[0].'px';
67
- $cspageURL = 'http';
68
- if($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
69
- $cspageURL .= "://";
70
- if ($_SERVER["SERVER_PORT"] != "80") {
71
- $cspageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
72
- } else {
73
- $cspageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
74
- }
75
- $url=$cspageURL;
76
- if($counter_type=='0' || $counter_type=='1')
77
- {
78
-
79
- $counter_position='.arrow_box:after, .arrow_box:before { top: 100%; left: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-top-color: #fff; border-width: 6px; margin-left: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-top-color: #cccccb; border-width: 7px; margin-left: -7px; }';
80
- if($counter_type=='0')
81
- {
82
- $main_div='float:left;margin-top:0px;margin-left:8px;height:'.$iwidth[0].'px;margin-right:8px;';
83
-
84
- $counter_position='.arrow_box:after, .arrow_box:before { right: 100%; top: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-right-color: #fff; border-width: 6px; margin-top: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-right-color: #cccccb; border-width: 7px; margin-top: -7px; }';
85
- }
86
- $js_code .='<style>'.PHP_EOL.
87
- '.arrow_box { width: '.($iwidth[0]-5).'px; margin-bottom:8px;'.$main_div.' border-radius: 1px; position: relative; background: #fff; border: 1px solid #cccccb; }'.$counter_position.''.PHP_EOL.
88
- '</style>'.PHP_EOL;
89
- }
90
- $useragent=$_SERVER['HTTP_USER_AGENT'];
91
- $mobile_Display="display:none;";
92
- $comon_counter_start='<div class="arrow_box" ><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
93
- $comon_counter_start_18='<div class="arrow_box" style="display:none;"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
94
- if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))
95
- {
96
-
97
- $mobile_Display="display:inline-block;";
98
- $comon_counter_start_18='<div class="arrow_box"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
99
- }
100
- if($button_style=='custom')
101
- {
102
-
103
- $fb_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylefb');
104
- $gp_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylegp');
105
- $li_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyleli');
106
- $tw_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletw');
107
- $pi_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylepi');
108
- $wa_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylewa');
109
- $su_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylesu');
110
- $rd_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylerd');
111
- $tm_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletm');
112
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($fb_style)?$fb_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png').'\'';
113
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($gp_style)?$gp_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png').'\'';
114
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($li_style)?$li_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
115
- $src_style13='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tw_style)?$tw_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png').'\'';
116
- $src_style17='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($pi_style)?$pi_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png').'\'';
117
- $src_style18='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'\' src=\''.(($wa_style)?$wa_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
118
- $src_style19='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($su_style)?$su_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png').'\'';
119
- $src_style20='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($rd_style)?$rd_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png').'\'';
120
- $src_style21='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tm_style)?$tm_style:'https://www.socleversocial.com/dashboard/img/social_icon/square/tumblr_square.png').'\'';
121
-
122
- }
123
- else if($button_style=='1')
124
- {
125
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png"';
126
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png"';
127
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png\'';
128
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png"';
129
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png"';
130
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_square.png"';
131
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png"';
132
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png"';
133
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_square.png"';
134
-
135
- }
136
- else if($button_style=='2')
137
- {
138
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook.png"';
139
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus.png"';
140
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin.png\'';
141
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter.png"';
142
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest.png"';
143
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp.png"';
144
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon.png"';
145
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit.png"';
146
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr.png"';
147
-
148
- }
149
- else if($button_style=='3')
150
- {
151
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey.png"';
152
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey.png"';
153
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey.png\'';
154
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey.png"';
155
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey.png"';
156
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey.png"';
157
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey.png"';
158
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey.png"';
159
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_grey.png"';
160
- }
161
- else if($button_style=='4')
162
- {
163
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey_circle.png"';
164
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey_circle.png"';
165
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey_circle.png\'';
166
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey_circle.png"';
167
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey_circle.png"';
168
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey_circle.png"';
169
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey_circle.png"';
170
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey_circle.png"';
171
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/grey_circle/tumblr_grey_circle.png"';
172
- }
173
- else if($button_style=='5')
174
- {
175
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/facebook_flower.png"';
176
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/google_flower.png"';
177
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/flower/linkedin_flower.png\'';
178
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/twitter_flower.png"';
179
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/pinterest_flower.png"';
180
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
181
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/stumbleupon_flower.png"';
182
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/reddit_flower.png"';
183
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/tumblr_flower.png"';
184
-
185
- }
186
- else if($button_style=='6')
187
- {
188
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/facebook_glossy.png"';
189
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/google_glossy.png"';
190
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/glossy/linkedin_glossy.png\'';
191
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/twitter_glossy.png"';
192
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/pinterest_glossy.png"';
193
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
194
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/stumbleupon_glossy.png"';
195
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/reddit_glossy.png"';
196
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/tumblr_glossy.png"';
197
-
198
-
199
- }
200
- else if($button_style=='7')
201
- {
202
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/facebook_leaf.png"';
203
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/google_leaf.png"';
204
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/leaf/linkedin_leaf.png\'';
205
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/twitter_leaf.png"';
206
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/pinterest_leaf.png"';
207
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
208
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/stumbleupon_leaf.png"';
209
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/reddit_leaf.png"';
210
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/tumblr_leaf.png"';
211
-
212
-
213
- }
214
- else if($button_style=='8')
215
- {
216
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/facebook_polygon.png"';
217
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/google_polygon.png"';
218
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/polygon/linkedin_polygon.png\'';
219
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/twitter_polygon.png"';
220
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/pinterest_polygon.png"';
221
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
222
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/stumbleupon_polygon.png"';
223
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/reddit_polygon.png"';
224
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/tumblr_polygon.png"';
225
-
226
-
227
- }
228
- else if($button_style=='9')
229
- {
230
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/facebook_rectangular.png"';
231
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/google_rectangular.png"';
232
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rectangular/linkedin_rectangular.png\'';
233
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/twitter_rectangular.png"';
234
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/pinterest_rectangular.png"';
235
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
236
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/stumbleupon_rectangular.png"';
237
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/reddit_rectangular.png"';
238
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/tumblr_rectangular.png"';
239
-
240
- }
241
- else if($button_style=='10')
242
- {
243
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/facebook_rounded_corners.png"';
244
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/google_rounded_corners.png"';
245
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/linkedin_rounded_corners.png\'';
246
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/twitter_rounded_corners.png"';
247
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/pinterest_rounded_corners.png"';
248
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
249
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/stumbleupon_rounded_corners.png"';
250
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/reddit_rounded_corners.png"';
251
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/tumblr_rounded_corners.png"';
252
-
253
-
254
- }
255
- else if($button_style=='11')
256
- {
257
- $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/facebook_waterdrop.png"';
258
- $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/google_waterdrop.png"';
259
- $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/linkedin_waterdrop.png\'';
260
- $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/twitter_waterdrop.png"';
261
- $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/pinterest_waterdrop.png"';
262
- $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
263
- $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/stumbleupon_waterdrop.png"';
264
- $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/reddit_waterdrop.png"';
265
- $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/tumblr_waterdrop.png"';
266
- }
267
- if($display_style=='1')
268
- {
269
- $gap_string='<div style=\'float:left;height:'.$gap.'px;\'>&nbsp;</div>';
270
- }
271
- else
272
- {
273
- $gap_string='<div style=\'float:left;width:'.$gap.'px;\'>&nbsp;</div>';
274
- }
275
-
276
- if($counter_type=='0' || $counter_type=='1')
277
- {
278
- //$url=$this->helper('core/url')->getCurrentUrl();
279
-
280
-
281
-
282
- $counter_top_margin='';
283
- if($counter_type=='0')
284
- {
285
- $counter_top_margin='margin-top:'.intval($iwidth[0]/4).'px;';
286
- }
287
-
288
- $comon_counter_end='</div></div>';
289
-
290
-
291
- $other_count=file_get_contents("https://www.socleversocial.com/dashboard/get_other_counts.php?site_id=".Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid')."&url=".$url."");
292
- $row_count=explode("~",$other_count);
293
- $comon_counter_end='</div></div>';
294
- $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
295
- $count2r=$count2=''.$comon_counter_start.''.intval($row_count[4]).''.$comon_counter_end.'';
296
- $count4r=$count4=''.$comon_counter_start.''.intval($row_count[6]).''.$comon_counter_end.'';
297
- $count7r=$count7=''.$comon_counter_start.''.intval($row_count[5]).''.$comon_counter_end.'';
298
- $count13r=$count13=''.$comon_counter_start.''.intval($row_count[7]).''.$comon_counter_end.'';
299
- $count17r=$count17=''.$comon_counter_start.''.intval($row_count[8]).''.$comon_counter_end.'';
300
- $count18r=$count18=''.$comon_counter_start_18.''.intval($row_count[0]).''.$comon_counter_end.'';
301
- $count19r=$count19=''.$comon_counter_start.''.intval($row_count[1]).''.$comon_counter_end.'';
302
- $count20r=$count20=''.$comon_counter_start.''.intval($row_count[2]).''.$comon_counter_end.'';
303
- $count21r=$count21=''.$comon_counter_start.''.intval($row_count[3]).''.$comon_counter_end.'';
304
-
305
-
306
- }
307
- if($counter_type=='0')
308
- {
309
- $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
310
- }
311
- else
312
- {
313
- $count2r=$count4r=$count7r=$count13r=$count17r=$count18r=$count19r=$count20r=$count21r="";
314
- }
315
-
316
- if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
317
-
318
- $customerData = Mage::getSingleton('customer/session')->getCustomer();
319
- //$customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
320
-
321
- $user_ID=$customerData->getId();
322
-
323
- }
324
- $title=$this->getLayout()->getBlock('head')->getTitle();
325
- $share_arr[2]='<div style="float:left;">'.$count2.'<img '.$src_style2.' onclick="share_on_cs(\'1\',\''.$user_ID.'\');window.open(\'http://www.facebook.com/sharer.php?u='.urlencode(cs_format_share_url($url,'1')).'&t='.urlencode($title).'\',\'_new\');" alt="Share on Facebook" ></div>'.$count2r.''.$gap_string.'';
326
- $share_arr[4]='<div style=\'float:left;\'>'.$count4.'<img '.$src_style4.' onclick="share_on_cs(\'3\',\''.$user_ID.'\');window.open(\'https://plus.google.com/share?url='.urlencode(cs_format_share_url($url,'3')).'&title='.urlencode($title).'\',\'_new\');" alt="Share on Google+"></div>'.$count4r.''.$gap_string.'';
327
- $share_arr[7]='<div style=\'float:left;\'>'.$count7.'<img '.$src_style7.' onclick="share_on_cs(\'2\',\''.$user_ID.'\');window.open(\'https://www.linkedin.com/cws/share?url='.urlencode(cs_format_share_url($url,'2')).'&title='.urlencode($title).'\',\'_new\');" alt="Share on LinkedIN" ></div>'.$count7r.''.$gap_string.'';
328
- $share_arr[13]='<div style=\'float:left;\'>'.$count13.'<img '.$src_style13.' onclick="share_on_cs(\'4\',\''.$user_ID.'\');window.open(\'http://twitter.com/share?url='.urlencode(cs_format_share_url($url,'4')).'&text='.urlencode($title).'\',\'_new\');" alt="Share on Twitter"></div>'.$count13r.''.$gap_string.'';
329
- $share_arr[17]='<div style=\'float:left;\'>'.$count17.'<img '.$src_style17.' onclick="share_on_cs(\'5\',\''.$user_ID.'\');" alt="Pin It"></div>'.$count17r.''.$gap_string.'';
330
- $share_arr[18]='<div style=\'float:left;\'>'.$count18.'<img '.$src_style18.' onclick="share_on_cs(\'6\',\''.$user_ID.'\');" alt="Share on Whatsapp"></div>'.$count18r.''.$gap_string.'';
331
- $share_arr[19]='<div style=\'float:left;\'>'.$count19.'<img '.$src_style19.' onclick="share_on_cs(\'7\',\''.$user_ID.'\');window.open(\'http://www.stumbleupon.com/submit?url='.urlencode(cs_format_share_url($url,'7')).'&title='.urlencode($title).'\',\'_new\');"" alt="Share on StumbleUpon"></div>'.$count19r.''.$gap_string.'';
332
- $share_arr[20]='<div style=\'float:left;\'>'.$count20.'<img '.$src_style20.' onclick="share_on_cs(\'8\',\''.$user_ID.'\');window.open(\'http://www.reddit.com/submit?url='.urlencode(cs_format_share_url($url,'8')).'&title='.urlencode($title).'\',\'_new\');"" alt="Share on Reddit"></div>'.$count20r.''.$gap_string.'';
333
- $share_arr[21]='<div style=\'float:left;\'>'.$count21.'<img '.$src_style21.' onclick="share_on_cs(\'9\',\''.$user_ID.'\');window.open(\'http://www.tumblr.com/share/link?url='.urlencode(cs_format_share_url($url,'9')).'&name='.urlencode($title).'\',\'_new\');"" alt="Pin It"></div>'.$count21r.''.$gap_string.'';
334
-
335
-
336
- $start_div='<div id="scssdiv" style="clear:both;wdth:100%;height:100%;display:inline-block;z-index:999;">';
337
- $end_div='</div>';
338
- if($display_style=='1' || $display_style=='2' )
339
- {
340
-
341
- $left_right=($display_style=='2')?'right:0;':'left:0;';
342
- $multiplier_div=($counter_type=='0')?'2':'1';
343
- $add_extra=($counter_type=='0')?'20':'0';
344
- $start_div='<div id="scssdiv" style="width:'.intval(($iwidth[0]*$multiplier_div)+$add_extra).'px;position:fixed;top:30%;'.$left_right.'display:inline-block;height:100%;z-index:999;">';
345
- $end_div='</div>';
346
- }
347
-
348
-
349
- $js_code .= PHP_EOL;
350
- $js_code .=$start_div;
351
- foreach($share_button as $key=>$val)
352
- {
353
-
354
- $js_code .=$share_arr[$val];
355
- }
356
- $js_code .=$end_div;
357
-
358
-
359
-
360
- echo $js_code;
361
- }
362
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  ?>
1
+ <?php
2
+ $scss_product_page=false;
3
+ if(Mage::registry('current_product')) {
4
+ $scss_product_page = true;
5
+ }
6
+ if(!$scss_product_page)
7
+ {
8
+ $is_validated=Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_validated');
9
+
10
+ if($is_validated=='1')
11
+ {
12
+ /*$scss_product_page=false;
13
+ if(Mage::registry('current_product')) {
14
+ $scss_product_page = true;
15
+ }
16
+ */
17
+ $display_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/displaystyle');
18
+ if(!function_exists('scs_is_mobile'))
19
+ {
20
+ function scs_is_mobile()
21
+ {
22
+ $useragent=$_SERVER['HTTP_USER_AGENT'];
23
+
24
+
25
+ return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4));
26
+
27
+
28
+ }
29
+ }
30
+ if(!function_exists('cs_get_plusones'))
31
+ {
32
+
33
+ function cs_get_plusones($url) {
34
+ $curl = curl_init();
35
+ curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
36
+ curl_setopt($curl, CURLOPT_POST, true);
37
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
38
+ curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.rawurldecode($url).'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
39
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
40
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
41
+ $curl_results = curl_exec ($curl);
42
+ curl_close ($curl);
43
+ $json = json_decode($curl_results, true);
44
+ return isset($json[0]['result']['metadata']['globalCounts']['count'])?intval( $json[0]['result']['metadata']['globalCounts']['count'] ):0;
45
+ }
46
+
47
+ }
48
+ if(!function_exists('cs_format_share_url'))
49
+ {
50
+ function cs_format_share_url($url,$source)
51
+ {
52
+
53
+ $name = "scsource";
54
+ $value = $source;
55
+
56
+
57
+ $separator = "?";
58
+ if (strpos($url,"?")!==false)
59
+ $separator = "&";
60
+
61
+
62
+ $insertPosition = strlen($url);
63
+ if (strpos($url,"#")!==false)
64
+ $insertPosition = strpos($url,"#");
65
+
66
+
67
+ $newUrl = substr_replace($url,"$separator$name=$value",$insertPosition,0);
68
+
69
+ return $newUrl;
70
+ }
71
+
72
+ }
73
+
74
+
75
+
76
+ $iwidth=explode("x",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/iconsize'));
77
+ $mobilefriendly=Mage::getStoreConfig('socialloginsharing_options/displaysettings/mobilefriendly');
78
+ $button_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyle');
79
+ $gap=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/gapsetting');
80
+ $counter_type=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/countersetting');
81
+ $share_button=explode(",",Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/socialproviders'));
82
+
83
+ $vartical_top=$counter_position="";
84
+ $main_div='height:'.$iwidth[0].'px';
85
+ $cspageURL = 'http';
86
+ if($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
87
+ $cspageURL .= "://";
88
+ if ($_SERVER["SERVER_PORT"] != "80") {
89
+ $cspageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
90
+ } else {
91
+ $cspageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
92
+ }
93
+ $url=$cspageURL;
94
+ if($counter_type=='0' || $counter_type=='1')
95
+ {
96
+
97
+ $counter_position='.arrow_box:after, .arrow_box:before { top: 100%; left: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-top-color: #fff; border-width: 6px; margin-left: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-top-color: #cccccb; border-width: 7px; margin-left: -7px; }';
98
+ if($counter_type=='0')
99
+ {
100
+ $main_div='float:left;margin-top:0px;margin-left:8px;height:'.$iwidth[0].'px;margin-right:8px;';
101
+
102
+ $counter_position='.arrow_box:after, .arrow_box:before { right: 100%; top: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(255, 255, 255, 0); border-right-color: #fff; border-width: 6px; margin-top: -6px; } .arrow_box:before { border-color: rgba(204, 204, 203, 0); border-right-color: #cccccb; border-width: 7px; margin-top: -7px; }';
103
+ }
104
+ $js_code .='<style>'.PHP_EOL.
105
+ '.arrow_box { width: '.($iwidth[0]-5).'px; margin-bottom:8px;'.$main_div.' border-radius: 1px; position: relative; background: #fff; border: 1px solid #cccccb; }'.$counter_position.''.PHP_EOL.
106
+ '</style>'.PHP_EOL;
107
+ }
108
+ $is_mobile='0';
109
+ $mobile_Display="display:none !important;";
110
+ $comon_counter_start='<div class="arrow_box" ><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
111
+ $comon_counter_start_18='<div class="arrow_box" style="display:none;"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
112
+ if(scs_is_mobile())
113
+ {
114
+ $is_mobile='1';
115
+ $iwidth=explode("x","40x40");
116
+ $mobile_Display="display:inline-block !important;";
117
+ $comon_counter_start_18='<div class="arrow_box"><div style="color:#000;font-weight:bold;position: relative;width: 100%;text-align: center;'.$counter_top_margin.'">';
118
+ }
119
+ if($button_style=='custom')
120
+ {
121
+
122
+ $fb_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylefb');
123
+ $gp_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylegp');
124
+ $li_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyleli');
125
+ $tw_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletw');
126
+ $pi_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylepi');
127
+ $wa_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylewa');
128
+ $su_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylesu');
129
+ $rd_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstylerd');
130
+ $tm_style=Mage::getStoreConfig('socialloginsharing_options/displaysettingshare/yourstyletm');
131
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($fb_style)?$fb_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png').'\'';
132
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src=\''.(($gp_style)?$gp_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png').'\'';
133
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($li_style)?$li_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
134
+ $src_style13='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tw_style)?$tw_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png').'\'';
135
+ $src_style17='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($pi_style)?$pi_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png').'\'';
136
+ $src_style18='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'\' src=\''.(($wa_style)?$wa_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png').'\'';
137
+ $src_style19='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($su_style)?$su_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png').'\'';
138
+ $src_style20='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($rd_style)?$rd_style:'https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png').'\'';
139
+ $src_style21='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\''.(($tm_style)?$tm_style:'https://www.socleversocial.com/dashboard/img/social_icon/square/tumblr_square.png').'\'';
140
+
141
+ }
142
+ else if($button_style=='1')
143
+ {
144
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_square.png"';
145
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_square.png"';
146
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_square.png\'';
147
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_square.png"';
148
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_square.png"';
149
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_square.png"';
150
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_square.png"';
151
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_square.png"';
152
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_square.png"';
153
+
154
+ }
155
+ else if($button_style=='2')
156
+ {
157
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook.png"';
158
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus.png"';
159
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin.png\'';
160
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter.png"';
161
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest.png"';
162
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp.png"';
163
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon.png"';
164
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit.png"';
165
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr.png"';
166
+
167
+ }
168
+ else if($button_style=='3')
169
+ {
170
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey.png"';
171
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey.png"';
172
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey.png\'';
173
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey.png"';
174
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey.png"';
175
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey.png"';
176
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey.png"';
177
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey.png"';
178
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/tumblr_grey.png"';
179
+ }
180
+ else if($button_style=='4')
181
+ {
182
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/facebook_grey_circle.png"';
183
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/google_plus_grey_circle.png"';
184
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded/linkedin_grey_circle.png\'';
185
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/twitter_grey_circle.png"';
186
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/pinterest_grey_circle.png"';
187
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/whatsapp_grey_circle.png"';
188
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/stumbleupon_grey_circle.png"';
189
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded/reddit_grey_circle.png"';
190
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/grey_circle/tumblr_grey_circle.png"';
191
+ }
192
+ else if($button_style=='5')
193
+ {
194
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/facebook_flower.png"';
195
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/google_flower.png"';
196
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/flower/linkedin_flower.png\'';
197
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/twitter_flower.png"';
198
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/pinterest_flower.png"';
199
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
200
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/stumbleupon_flower.png"';
201
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/reddit_flower.png"';
202
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/flower/tumblr_flower.png"';
203
+
204
+ }
205
+ else if($button_style=='6')
206
+ {
207
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/facebook_glossy.png"';
208
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/google_glossy.png"';
209
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/glossy/linkedin_glossy.png\'';
210
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/twitter_glossy.png"';
211
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/pinterest_glossy.png"';
212
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
213
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/stumbleupon_glossy.png"';
214
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/reddit_glossy.png"';
215
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/glossy/tumblr_glossy.png"';
216
+
217
+
218
+ }
219
+ else if($button_style=='7')
220
+ {
221
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/facebook_leaf.png"';
222
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/google_leaf.png"';
223
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/leaf/linkedin_leaf.png\'';
224
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/twitter_leaf.png"';
225
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/pinterest_leaf.png"';
226
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
227
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/stumbleupon_leaf.png"';
228
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/reddit_leaf.png"';
229
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/leaf/tumblr_leaf.png"';
230
+
231
+
232
+ }
233
+ else if($button_style=='8')
234
+ {
235
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/facebook_polygon.png"';
236
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/google_polygon.png"';
237
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/polygon/linkedin_polygon.png\'';
238
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/twitter_polygon.png"';
239
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/pinterest_polygon.png"';
240
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
241
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/stumbleupon_polygon.png"';
242
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/reddit_polygon.png"';
243
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/polygon/tumblr_polygon.png"';
244
+
245
+
246
+ }
247
+ else if($button_style=='9')
248
+ {
249
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/facebook_rectangular.png"';
250
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/google_rectangular.png"';
251
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rectangular/linkedin_rectangular.png\'';
252
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/twitter_rectangular.png"';
253
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/pinterest_rectangular.png"';
254
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
255
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/stumbleupon_rectangular.png"';
256
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/reddit_rectangular.png"';
257
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rectangular/tumblr_rectangular.png"';
258
+
259
+ }
260
+ else if($button_style=='10')
261
+ {
262
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/facebook_rounded_corners.png"';
263
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/google_rounded_corners.png"';
264
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/linkedin_rounded_corners.png\'';
265
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/twitter_rounded_corners.png"';
266
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/pinterest_rounded_corners.png"';
267
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
268
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/stumbleupon_rounded_corners.png"';
269
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/reddit_rounded_corners.png"';
270
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/rounded_corners/tumblr_rounded_corners.png"';
271
+
272
+
273
+ }
274
+ else if($button_style=='11')
275
+ {
276
+ $src_style2='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/facebook_waterdrop.png"';
277
+ $src_style4='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/google_waterdrop.png"';
278
+ $src_style7='style=\'width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;\' src=\'https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/linkedin_waterdrop.png\'';
279
+ $src_style13='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/twitter_waterdrop.png"';
280
+ $src_style17='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/pinterest_waterdrop.png"';
281
+ $src_style18='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;'.$mobile_Display.'" src="https://www.socleversocial.com/dashboard/img/social_icon/square/whatsapp_square.png"';
282
+ $src_style19='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/stumbleupon_waterdrop.png"';
283
+ $src_style20='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/reddit_waterdrop.png"';
284
+ $src_style21='style="width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;cursor:pointer;" src="https://www.socleversocial.com/dashboard/img/social_icon/waterdrop/tumblr_waterdrop.png"';
285
+ }
286
+ if($display_style=='1')
287
+ {
288
+ $gap_string='<span style=\'float:left;height:'.$gap.'px;\'>&nbsp;</span>';
289
+ }
290
+ else
291
+ {
292
+ $gap_string='<span style=\'float:left;width:'.$gap.'px;\'>&nbsp;</span>';
293
+ }
294
+
295
+ if($mobilefriendly=='1' && scs_is_mobile())
296
+ {
297
+ $gap_string='';
298
+ }
299
+
300
+
301
+
302
+ if($counter_type=='0' || $counter_type=='1')
303
+ {
304
+ //$url=$this->helper('core/url')->getCurrentUrl();
305
+
306
+
307
+
308
+ $counter_top_margin='';
309
+ if($counter_type=='0')
310
+ {
311
+ $counter_top_margin='margin-top:'.intval($iwidth[0]/4).'px;';
312
+ }
313
+
314
+ $comon_counter_end='</div></div>';
315
+
316
+
317
+ $comon_counter_end='</div></div>';
318
+ $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
319
+ if(!scs_is_mobile())
320
+ {
321
+ $other_count=file_get_contents("https://www.socleversocial.com/dashboard/get_other_counts.php?site_id=".Mage::getStoreConfig('socialloginsharing_options/apisettings/scsl_siteid')."&url=".$url."");
322
+ $row_count=explode("~",$other_count);
323
+
324
+ $count2r=$count2=''.$comon_counter_start.''.intval($row_count[4]).''.$comon_counter_end.'';
325
+ $count4r=$count4=''.$comon_counter_start.''.intval($row_count[6]).''.$comon_counter_end.'';
326
+ $count7r=$count7=''.$comon_counter_start.''.intval($row_count[5]).''.$comon_counter_end.'';
327
+ $count13r=$count13=''.$comon_counter_start.''.intval($row_count[7]).''.$comon_counter_end.'';
328
+ $count17r=$count17=''.$comon_counter_start.''.intval($row_count[8]).''.$comon_counter_end.'';
329
+ $count18r=$count18=''.$comon_counter_start_18.''.intval($row_count[0]).''.$comon_counter_end.'';
330
+ $count19r=$count19=''.$comon_counter_start.''.intval($row_count[1]).''.$comon_counter_end.'';
331
+ $count20r=$count20=''.$comon_counter_start.''.intval($row_count[2]).''.$comon_counter_end.'';
332
+ $count21r=$count21=''.$comon_counter_start.''.intval($row_count[3]).''.$comon_counter_end.'';
333
+ }
334
+
335
+ }
336
+ if($counter_type=='0')
337
+ {
338
+ $count2=$count4=$count7=$count13=$count17=$count18=$count19=$count20=$count21="";
339
+ }
340
+ else
341
+ {
342
+ $count2r=$count4r=$count7r=$count13r=$count17r=$count18r=$count19r=$count20r=$count21r="";
343
+ }
344
+
345
+ if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
346
+
347
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
348
+ //$customerData = Mage::getModel('customer/customer')->load($customer->getId())->getData();
349
+
350
+ $user_ID=$customerData->getId();
351
+
352
+ }
353
+ $title=$this->getLayout()->getBlock('head')->getTitle();
354
+
355
+ if($mobilefriendly=='1' && scs_is_mobile())
356
+ {
357
+ $ic_div='margin:0px 0px;width:'.$iwidth[0].'px;height:'.$iwidth[0].'px;';
358
+ }
359
+ else
360
+ {
361
+ $ic_div='float:left;';
362
+ }
363
+
364
+
365
+ $share_arr[2]='<span style="float:left;">'.$count2.'<img '.$src_style2.' onclick="share_on_cs(\'1\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.facebook.com/sharer.php?u='.urlencode(cs_format_share_url($url,'1')).'&t='.urlencode($title).'\',\'Share on Facebook\',\'600\',\'400\');" alt="Share on Facebook" ></span>'.$count2r.''.$gap_string.'';
366
+ $share_arr[4]='<span style=\'float:left;\'>'.$count4.'<img '.$src_style4.' onclick="share_on_cs(\'3\',\''.$user_ID.'\');cspopupCenterMagento(\'https://plus.google.com/share?url='.urlencode(cs_format_share_url($url,'3')).'&title='.urlencode($title).'\',\'Share on Google\',\'600\',\'400\');" alt="Share on Google+"></span>'.$count4r.''.$gap_string.'';
367
+ $share_arr[7]='<span style=\'float:left;\'>'.$count7.'<img '.$src_style7.' onclick="share_on_cs(\'2\',\''.$user_ID.'\');cspopupCenterMagento(\'https://www.linkedin.com/cws/share?url='.urlencode(cs_format_share_url($url,'2')).'&title='.urlencode($title).'\',\'Share on LinkedIN\',\'600\',\'400\');" alt="Share on LinkedIN" ></span>'.$count7r.''.$gap_string.'';
368
+ $share_arr[13]='<span style=\'float:left;\'>'.$count13.'<img '.$src_style13.' onclick="share_on_cs(\'4\',\''.$user_ID.'\');cspopupCenterMagento(\'http://twitter.com/share?url='.urlencode(cs_format_share_url($url,'4')).'&text='.urlencode($title).'\',\'Share on Twitter\',\'600\',\'400\');" alt="Share on Twitter"></span>'.$count13r.''.$gap_string.'';
369
+ $share_arr[17]='<span style=\'float:left;\'>'.$count17.'<img '.$src_style17.' onclick="share_on_cs(\'5\',\''.$user_ID.'\');" alt="Pin It"></span>'.$count17r.''.$gap_string.'';
370
+ $share_arr[18]='<span style=\'float:left;\'>'.$count18.'<img '.$src_style18.' onclick="share_on_cs(\'6\',\''.$user_ID.'\');" alt="Share on Whatsapp"></span>'.$count18r.''.$gap_string.'';
371
+ $share_arr[19]='<span style=\'float:left;\'>'.$count19.'<img '.$src_style19.' onclick="share_on_cs(\'7\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.stumbleupon.com/submit?url='.urlencode(cs_format_share_url($url,'7')).'&title='.urlencode($title).'\',\'Share on StumbleUpon\',\'600\',\'400\');"" alt="Share on StumbleUpon"></span>'.$count19r.''.$gap_string.'';
372
+ $share_arr[20]='<span style=\'float:left;\'>'.$count20.'<img '.$src_style20.' onclick="share_on_cs(\'8\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.reddit.com/submit?url='.urlencode(cs_format_share_url($url,'8')).'&title='.urlencode($title).'\',\'Share on Reddit\',\'600\',\'400\');"" alt="Share on Reddit"></span>'.$count20r.''.$gap_string.'';
373
+ $share_arr[21]='<span style=\'float:left;\'>'.$count21.'<img '.$src_style21.' onclick="share_on_cs(\'9\',\''.$user_ID.'\');cspopupCenterMagento(\'http://www.tumblr.com/share/link?url='.urlencode(cs_format_share_url($url,'9')).'&name='.urlencode($title).'\',\'Share on Tumblr\',\'600\',\'400\');"" alt="Share on Tumblr"></span>'.$count21r.''.$gap_string.'';
374
+
375
+
376
+ $start_div='<div id="scssdiv" style="clear:both;wdth:100%;height:100%;display:inline-block;z-index:999;">';
377
+ $end_div='</div>';
378
+ if($display_style=='1' || $display_style=='2' )
379
+ {
380
+
381
+ $left_right=($display_style=='2')?'right:0;':'left:0;';
382
+ $multiplier_div=($counter_type=='0')?'2':'1';
383
+ $add_extra=($counter_type=='0')?'20':'0';
384
+ $start_div='<div id="scssdiv" style="width:'.intval(($iwidth[0]*$multiplier_div)+$add_extra).'px;position:fixed;top:30%;'.$left_right.'display:inline-block;height:100%;z-index:999;">';
385
+ $end_div='</div>';
386
+ }
387
+
388
+ if($mobilefriendly=='1' && scs_is_mobile())
389
+ {
390
+ $start_div='<div id="scssdiv" style="width: 90%;position:fixed;bottom:0;height: 40px; background-color:transparent;z-index:999;text-align:center;margin:0 auto;">';
391
+ }
392
+
393
+ $js_code .= PHP_EOL;
394
+ $js_code .=$start_div;
395
+ foreach($share_button as $key=>$val)
396
+ {
397
+
398
+ $js_code .=$share_arr[$val];
399
+ }
400
+ $js_code .=$end_div;
401
+
402
+ $js_code .= PHP_EOL;
403
+ $js_code .='<script type="text/javascript">
404
+ function cspopupCenterMagento(url, title, w, h) {
405
+ var left = (screen.width/2)-(w/2);
406
+ var top = (screen.height/2)-(h/2);
407
+ return window.open(url, title, \'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=\'+w+\', height=\'+h+\', top=\'+top+\', left=\'+left);
408
+ }
409
+ </script>'.PHP_EOL;
410
+
411
+ $js_code .='<style>#scssdiv img { display:inline !important; }</style>';
412
+
413
+
414
+ echo $js_code;
415
+
416
+ }
417
+ }
418
  ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>socleverloginsharing</name>
4
- <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
@@ -29,11 +29,11 @@
29
  Send personalised message to your visitors by using our birthday reports. &lt;/p&gt;&#xD;
30
  &lt;p&gt;&lt;strong&gt;Dynamic JavaScript&lt;/strong&gt;&lt;br /&gt;&#xD;
31
  Our asynchronous javascript loads faster without interfearing with the display or behaviour of the page. Dynamic JavaScript makes it easy to choose/sort social netork buttons for display.&lt;/p&gt;</description>
32
- <notes>Stable Version 1.1.0</notes>
33
  <authors><author><name>Soclever Social</name><user>Socleversocial</user><email>hemang@socleversocial.com</email></author></authors>
34
- <date>2015-04-14</date>
35
- <time>05:31:57</time>
36
- <contents><target name="magelocal"><dir name="Soclever"><dir name="Socialloginsharing"><dir name="Model"><file name="Observer.php" hash="475751edc201b924a7d0f78eb34032f0"/><file name="Providers.php" hash="671f7b43bc77ea8a734290025fd3f42f"/></dir><dir name="Block"><file name="Scslhead.php" hash="219920fc652715e4383509b0ceedf82f"/><file name="Scslshow.php" hash="e979ec3119f18b8d0b8a2dc38b2d0341"/><file name="Scsltrackpixel.php" hash="dcb7add6ba6acd6cfd8080b40d2b0e24"/><file name="Scslheadfb.php" hash="4298e17782026f4003694ebcb1149376"/><file name="Scsshead.php" hash="173c515d7a83f8b42cd00d38bcd47a5e"/><file name="Scsshow.php" hash="392625a6c38bec962120fa40f0cf68ed"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Customopt1toggle.php" hash="f5b951998e7d4181c5461dce81661876"/></dir></dir></dir></dir></dir><file name="Scssfooter.php" hash="1437931932e9c6c6c0b7c3ab173dc51a"/></dir><dir name="controllers"><file name="IndexController.php" hash="cc9c19668874454a411ee40b48ec1d10"/><file name="openid.php" hash="421d5936957b8ddda543b679d1876f04"/></dir><dir name="etc"><file name="config.xml" hash="ef6aec9ea5f1d5713b39df2baf71ee41"/><file name="system.xml" hash="a74a88bd862525a2e6314c597eeb41e5"/></dir><dir name="Helper"><file name="Data.php" hash="035a7f9b50f1e92c9955e427d4e7a73e"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="socialloginsharing.xml" hash="dece49ed90e3ab16196ecaf878e505ab"/></dir><dir name="template"><dir name="socialloginsharing"><file name="scsl_buttons.phtml" hash="6096dae3f64f11dc006cd575ee5914d4"/><file name="sociallogin_fb.phtml" hash="718d8596a14d123d83afb0d5d6d6fd96"/><file name="sociallogin_head.phtml" hash="f9a4331ee933427b6c3f36ae88b840e9"/><file name="sociallogin_trackpixel.phtml" hash="542ceb3ba7d5314f2f9aad416636d349"/><file name="socialshare_head.phtml" hash="f35a4bdaad57d1731be186f9e0ac612e"/><file name="socialshare_product.phtml" hash="3462fab856f8d6584612906760bd8fab"/><file name="socialshare_show.phtml" hash="0d4ab68544834c5f970463ae71333a8e"/><file name="socialshare_footer.phtml" hash="8872368942684475955f03550625c385"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="soclever_socialloginsharing.xml" hash="17a99813f44f3aa85a4781558133ac5c"/></dir></target></contents>
37
  <compatible/>
38
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
39
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>socleverloginsharing</name>
4
+ <version>1.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
29
  Send personalised message to your visitors by using our birthday reports. &lt;/p&gt;&#xD;
30
  &lt;p&gt;&lt;strong&gt;Dynamic JavaScript&lt;/strong&gt;&lt;br /&gt;&#xD;
31
  Our asynchronous javascript loads faster without interfearing with the display or behaviour of the page. Dynamic JavaScript makes it easy to choose/sort social netork buttons for display.&lt;/p&gt;</description>
32
+ <notes>Added Twitter Login Pop Up</notes>
33
  <authors><author><name>Soclever Social</name><user>Socleversocial</user><email>hemang@socleversocial.com</email></author></authors>
34
+ <date>2015-06-11</date>
35
+ <time>12:07:39</time>
36
+ <contents><target name="magelocal"><dir name="Soclever"><dir name="Socialloginsharing"><dir name="Model"><file name="Observer.php" hash="e030057738d89a0b186ff25ce5e5dbfe"/><file name="Providers.php" hash="7247569d4fa1a33879893341dbcebb57"/></dir><dir name="Block"><file name="Scslhead.php" hash="219920fc652715e4383509b0ceedf82f"/><file name="Scslshow.php" hash="e979ec3119f18b8d0b8a2dc38b2d0341"/><file name="Scsltrackpixel.php" hash="dcb7add6ba6acd6cfd8080b40d2b0e24"/><file name="Scslheadfb.php" hash="4298e17782026f4003694ebcb1149376"/><file name="Scsshead.php" hash="173c515d7a83f8b42cd00d38bcd47a5e"/><file name="Scsshow.php" hash="392625a6c38bec962120fa40f0cf68ed"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Customopt1toggle.php" hash="f5b951998e7d4181c5461dce81661876"/></dir></dir></dir></dir></dir><file name="Scssfooter.php" hash="1437931932e9c6c6c0b7c3ab173dc51a"/></dir><dir name="controllers"><file name="IndexController.php" hash="c3bfa821dece756047c1680e59a2b341"/><file name="openid.php" hash="421d5936957b8ddda543b679d1876f04"/><file name="http.php" hash=""/><file name="oauth_client.php" hash=""/></dir><dir name="etc"><file name="config.xml" hash="ef6aec9ea5f1d5713b39df2baf71ee41"/><file name="system.xml" hash="96d646ec830109f84dfed21344c65403"/></dir><dir name="Helper"><file name="Data.php" hash="035a7f9b50f1e92c9955e427d4e7a73e"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="socialloginsharing.xml" hash="dece49ed90e3ab16196ecaf878e505ab"/></dir><dir name="template"><dir name="socialloginsharing"><file name="scsl_buttons.phtml" hash="6096dae3f64f11dc006cd575ee5914d4"/><file name="sociallogin_fb.phtml" hash="718d8596a14d123d83afb0d5d6d6fd96"/><file name="sociallogin_head.phtml" hash="f9a4331ee933427b6c3f36ae88b840e9"/><file name="sociallogin_trackpixel.phtml" hash="542ceb3ba7d5314f2f9aad416636d349"/><file name="socialshare_head.phtml" hash="f35a4bdaad57d1731be186f9e0ac612e"/><file name="socialshare_product.phtml" hash="66c0c9ba5380fa74baa0283dc163e15a"/><file name="socialshare_show.phtml" hash="49b7e88099e39550efdba024330dd1e0"/><file name="socialshare_footer.phtml" hash="d11a5014fc6b326123df5a1322582399"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="soclever_socialloginsharing.xml" hash="17a99813f44f3aa85a4781558133ac5c"/></dir></target></contents>
37
  <compatible/>
38
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
39
  </package>