gomage_social_connector - Version 1.4.0

Version Notes

Version 1.4.0

Download this release

Release Info

Developer GoMage
Extension gomage_social_connector
Version 1.4.0
Comparing to
See all releases


Code changes from version 1.3.0 to 1.4.0

Files changed (65) hide show
  1. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/AbstractRedirectUri.php +1 -1
  2. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/General.php +1 -1
  3. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/Information.php +1 -1
  4. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Amazon.php +1 -1
  5. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Google.php +1 -1
  6. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Instagram.php +21 -0
  7. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Linkedin.php +1 -1
  8. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Reddit.php +1 -1
  9. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Tumblr.php +1 -1
  10. app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Twitter.php +1 -1
  11. app/code/local/GoMage/Social/Block/Head.php +1 -1
  12. app/code/local/GoMage/Social/Block/Login.php +28 -18
  13. app/code/local/GoMage/Social/Block/Login/Facebook.php +1 -1
  14. app/code/local/GoMage/Social/Block/Login/Google.php +1 -1
  15. app/code/local/GoMage/Social/Block/Login/Service.php +1 -1
  16. app/code/local/GoMage/Social/Controller/Social.php +23 -18
  17. app/code/local/GoMage/Social/Controller/SocialNoMail.php +17 -16
  18. app/code/local/GoMage/Social/Helper/Data.php +137 -151
  19. app/code/local/GoMage/Social/Helper/Url.php +21 -0
  20. app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type.php +1 -1
  21. app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Facebook.php +1 -1
  22. app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Google.php +1 -1
  23. app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Services.php +10 -10
  24. app/code/local/GoMage/Social/Model/Entity.php +1 -1
  25. app/code/local/GoMage/Social/Model/Mysql4/Entity.php +1 -1
  26. app/code/local/GoMage/Social/Model/Mysql4/Entity/Collection.php +1 -1
  27. app/code/local/GoMage/Social/Model/Observer.php +14 -7
  28. app/code/local/GoMage/Social/Model/Observer/Notify.php +1 -1
  29. app/code/local/GoMage/Social/Model/Type.php +31 -26
  30. app/code/local/GoMage/Social/controllers/AmazonController.php +35 -21
  31. app/code/local/GoMage/Social/controllers/FacebookController.php +26 -21
  32. app/code/local/GoMage/Social/controllers/GoogleController.php +56 -60
  33. app/code/local/GoMage/Social/controllers/InstagramController.php +140 -0
  34. app/code/local/GoMage/Social/controllers/LinkedinController.php +59 -48
  35. app/code/local/GoMage/Social/controllers/RedditController.php +31 -16
  36. app/code/local/GoMage/Social/controllers/TumblrController.php +33 -25
  37. app/code/local/GoMage/Social/controllers/TwitterController.php +31 -22
  38. app/code/local/GoMage/Social/etc/adminhtml.xml +1 -1
  39. app/code/local/GoMage/Social/etc/config.xml +123 -112
  40. app/code/local/GoMage/Social/etc/system.xml +598 -497
  41. app/design/frontend/base/default/layout/gomage-social.xml +1 -1
  42. app/design/frontend/base/default/template/gomage/social/config.phtml +58 -56
  43. app/design/frontend/base/default/template/gomage/social/login.phtml +2 -2
  44. app/design/frontend/base/default/template/gomage/social/login/facebook.phtml +1 -1
  45. app/design/frontend/base/default/template/gomage/social/login/google.phtml +1 -1
  46. app/design/frontend/base/default/template/gomage/social/login/service.phtml +1 -1
  47. app/etc/modules/GoMage_Social.xml +23 -0
  48. js/gomage/social.js +1 -1
  49. lib/GoMage/Amazon/Credentials.php +3 -11
  50. lib/GoMage/Amazon/Service.php +4 -139
  51. lib/GoMage/Instagram/Credentials.php +17 -0
  52. lib/GoMage/Instagram/Service.php +21 -0
  53. lib/GoMage/Linkedin/OAuth.php +12 -19
  54. lib/GoMage/Linkedin/linkedinoauth.php +1 -1
  55. lib/GoMage/MobileDetect/Navigation_Mobile_Detect.php +0 -1350
  56. lib/GoMage/OAuth/Credentials.php +26 -0
  57. lib/GoMage/OAuth/OAuth.php +865 -0
  58. lib/GoMage/OAuth/Service.php +164 -0
  59. lib/GoMage/Tumblr/OAuth.php +0 -874
  60. lib/GoMage/Tumblr/tumblroauth.php +231 -231
  61. lib/GoMage/Twitter/OAuth.php +0 -870
  62. lib/GoMage/Twitter/twitteroauth.php +226 -226
  63. package.xml +9 -7
  64. skin/frontend/base/default/css/gomage/social.css +1 -1
  65. skin/frontend/rwd/default/css/gomage/social.css +1 -1
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/AbstractRedirectUri.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/General.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/Fieldset/Information.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Amazon.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Google.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Instagram.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * GoMage Social Connector Extension
5
+ *
6
+ * @category Extension
7
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
8
+ * @author GoMage
9
+ * @license http://www.gomage.com/license-agreement/ Single domain license
10
+ * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
+ * @since Class available since Release 1.2.0
13
+ */
14
+ class GoMage_Social_Block_Adminhtml_System_Config_RedirectUri_Instagram
15
+ extends GoMage_Social_Block_Adminhtml_System_Config_AbstractRedirectUri
16
+ {
17
+ public function getTypeService()
18
+ {
19
+ return GoMage_Social_Model_Type::getTypeService(GoMage_Social_Model_Type::INSTAGRAM);
20
+ }
21
+ }
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Linkedin.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Reddit.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Tumblr.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Adminhtml/System/Config/RedirectUri/Twitter.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Head.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.1.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Login.php CHANGED
@@ -7,15 +7,16 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
14
- class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
15
-
16
  protected $place;
17
 
18
- public function __construct() {
 
19
  parent::__construct();
20
 
21
  if (! $this->getSession()->isLoggedIn() && Mage::helper('gomage_social')->isActive()) {
@@ -23,21 +24,25 @@ class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
23
  }
24
  }
25
 
26
- private function getSession() {
 
27
  return Mage::getSingleton('customer/session');
28
  }
29
 
30
- public function setPlace($place) {
 
31
  $this->place = $place;
32
 
33
  return $this;
34
  }
35
 
36
- public function getPlace() {
 
37
  return $this->place;
38
  }
39
 
40
- public function getImage($service = '') {
 
41
  if ($service) {
42
  $image = Mage::getStoreConfig('gomage_social/' . $service . '/image');
43
 
@@ -49,7 +54,8 @@ class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
49
  return false;
50
  }
51
 
52
- public function getText($service = '') {
 
53
  if ($service) {
54
  $text = Mage::getStoreConfig('gomage_social/' . $service . '/text');
55
 
@@ -61,21 +67,25 @@ class GoMage_Social_Block_Login extends Mage_Core_Block_Template {
61
  return $this->__('Login');
62
  }
63
 
64
- public function getLoginType($service = '') {
 
65
  return Mage::getStoreConfig('gomage_social/'. $service .'/' . $this->getPlace() . '_type');
66
  }
67
 
68
- public function getServiceBlock($type, $is_last) {
69
- $service = GoMage_Social_Model_Type::getTypeService($type);
70
- $block = $this->getLayout()->createBlock('gomage_social/login_' . $service);
71
 
72
- if (!$block) {
73
- $block = $this->getLayout()->createBlock('gomage_social/login_service');
74
- }
 
 
 
 
75
 
76
  return $block->setData('is_last', $is_last)
77
  ->setData('service', $service)
78
- ->setPlace($this->getPlace())
79
- ->toHtml();
80
  }
81
  }
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
14
+ class GoMage_Social_Block_Login extends Mage_Core_Block_Template
15
+ {
16
  protected $place;
17
 
18
+ public function __construct()
19
+ {
20
  parent::__construct();
21
 
22
  if (! $this->getSession()->isLoggedIn() && Mage::helper('gomage_social')->isActive()) {
24
  }
25
  }
26
 
27
+ private function getSession()
28
+ {
29
  return Mage::getSingleton('customer/session');
30
  }
31
 
32
+ public function setPlace($place)
33
+ {
34
  $this->place = $place;
35
 
36
  return $this;
37
  }
38
 
39
+ public function getPlace()
40
+ {
41
  return $this->place;
42
  }
43
 
44
+ public function getImage($service = '')
45
+ {
46
  if ($service) {
47
  $image = Mage::getStoreConfig('gomage_social/' . $service . '/image');
48
 
54
  return false;
55
  }
56
 
57
+ public function getText($service = '')
58
+ {
59
  if ($service) {
60
  $text = Mage::getStoreConfig('gomage_social/' . $service . '/text');
61
 
67
  return $this->__('Login');
68
  }
69
 
70
+ public function getLoginType($service = '')
71
+ {
72
  return Mage::getStoreConfig('gomage_social/'. $service .'/' . $this->getPlace() . '_type');
73
  }
74
 
75
+ public function getServiceBlock($type, $is_last)
76
+ {
77
+ $service = GoMage_Social_Model_Type::getTypeService($type);
78
 
79
+ switch ($service) {
80
+ case 'facebook' :
81
+ case 'google' :
82
+ $block = $this->getLayout()->createBlock('gomage_social/login_' . $service);
83
+ break;
84
+ default : $block = $this->getLayout()->createBlock('gomage_social/login_service');
85
+ }
86
 
87
  return $block->setData('is_last', $is_last)
88
  ->setData('service', $service)
89
+ ->setPlace($this->getPlace());
 
90
  }
91
  }
app/code/local/GoMage/Social/Block/Login/Facebook.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Login/Google.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Block/Login/Service.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Controller/Social.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,19 +8,20 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
-
14
- abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Front_Action {
15
-
16
  abstract function getSocialType();
17
 
18
- protected function getSession() {
 
19
  return Mage::getSingleton('customer/session');
20
  }
21
 
22
- protected function createSocial($social_id, $customer_id) {
 
23
  return Mage::getModel('gomage_social/entity')
24
  ->setData('social_id', $social_id)
25
  ->setData('type_id', $this->getSocialType())
@@ -28,12 +30,13 @@ abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Fron
28
  ->save();
29
  }
30
 
31
- protected function createCustomer($profile) {
 
32
  $customer = Mage::getModel('customer/customer');
33
  $password = $customer->generatePassword(8);
34
 
35
  if (is_array($profile)) {
36
- $profile = (object)$profile;
37
  }
38
 
39
  $customer->setData('firstname', $profile->first_name)
@@ -58,18 +61,14 @@ abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Fron
58
  return $customer;
59
  }
60
 
61
- protected function _getRedirectUrl($url = '') {
 
62
  if (!$url) {
63
  $url = $this->getRequest()->getParam('gs_url', '');
64
 
65
- if (!$url && Mage::getSingleton('core/session')->getData('gs_url')) {
66
- $url = Mage::getSingleton('core/session')->getData('gs_url');
67
- Mage::getSingleton('core/session')->unsetData('gs_url');
68
- }
69
-
70
- if ($url) {
71
- $url = Mage::helper('core')->urlDecode($url);
72
- }
73
  }
74
 
75
  if (!$url) {
@@ -79,7 +78,13 @@ abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Fron
79
  return $url;
80
  }
81
 
82
- protected function _redirectUrl($url = '') {
 
83
  return parent::_redirectUrl($this->_getRedirectUrl($url));
84
  }
 
 
 
 
 
85
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
14
+ abstract class GoMage_Social_Controller_Social extends Mage_Core_Controller_Front_Action
15
+ {
 
16
  abstract function getSocialType();
17
 
18
+ protected function getSession()
19
+ {
20
  return Mage::getSingleton('customer/session');
21
  }
22
 
23
+ protected function createSocial($social_id, $customer_id)
24
+ {
25
  return Mage::getModel('gomage_social/entity')
26
  ->setData('social_id', $social_id)
27
  ->setData('type_id', $this->getSocialType())
30
  ->save();
31
  }
32
 
33
+ protected function createCustomer($profile)
34
+ {
35
  $customer = Mage::getModel('customer/customer');
36
  $password = $customer->generatePassword(8);
37
 
38
  if (is_array($profile)) {
39
+ $profile = (object) $profile;
40
  }
41
 
42
  $customer->setData('firstname', $profile->first_name)
61
  return $customer;
62
  }
63
 
64
+ protected function _getRedirectUrl($url = '')
65
+ {
66
  if (!$url) {
67
  $url = $this->getRequest()->getParam('gs_url', '');
68
 
69
+ if (!$url && Mage::getSingleton('core/session')->getGsProfile()) {
70
+ $url = Mage::getSingleton('core/session')->getGsProfile()->url_backward;
71
+ }
 
 
 
 
 
72
  }
73
 
74
  if (!$url) {
78
  return $url;
79
  }
80
 
81
+ protected function _redirectUrl($url = '')
82
+ {
83
  return parent::_redirectUrl($this->_getRedirectUrl($url));
84
  }
85
+
86
+ protected function _clear()
87
+ {
88
+ Mage::getSingleton('core/session')->unsGsProfile();
89
+ }
90
  }
app/code/local/GoMage/Social/Controller/SocialNoMail.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,13 +8,13 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
-
14
- abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Controller_Social {
15
-
16
- protected function createCustomer($profile) {
17
  $customer = Mage::getModel('customer/customer');
18
  $password = $customer->generatePassword(8);
19
 
@@ -37,13 +38,13 @@ abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Contr
37
  }
38
 
39
  $customer->save();
40
-
41
  $customer->sendNewAccountEmail(
42
  'confirmation',
43
  Mage::getSingleton('core/session')->getBeforeAuthUrl(),
44
  Mage::app()->getStore()
45
  ->getId()
46
  );
 
47
  Mage::getSingleton('core/session')->addSuccess(
48
  $this->__(
49
  'Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.',
@@ -54,7 +55,8 @@ abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Contr
54
  return $customer;
55
  }
56
 
57
- public function checkEmailAction() {
 
58
  $message = array();
59
  $message['redirect'] = null;
60
 
@@ -65,9 +67,7 @@ abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Contr
65
 
66
  if ($profile = Mage::getSingleton('core/session')->getGsProfile()) {
67
  if ($customer->getId()) {
68
- $message['redirect'] = Mage::getUrl('customer/account/login',array('_secure'=>true));
69
- $profile->url = null;
70
- Mage::getSingleton('core/session')->setGsProfile($profile);
71
  Mage::getSingleton('core/session')->addNotice('There is already an account with this email address. We suggest using the standard login form.');
72
  } else {
73
  $social_collection = Mage::getModel('gomage_social/entity')
@@ -126,11 +126,11 @@ abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Contr
126
  if (!$customer->getConfirmation()) {
127
  $this->getSession()->loginById($customer->getId());
128
  }
129
- }
130
-
131
- Mage::getSingleton('core/session')->unsGsProfile();
132
- }
133
  }
 
 
134
  }
135
  }
136
 
@@ -141,7 +141,8 @@ abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Contr
141
  return $this->getResponse()->setBody(Zend_Json::encode($message));
142
  }
143
 
144
- public function emailCloseAction() {
145
- Mage::getSingleton('core/session')->unsGsProfile();
 
146
  }
147
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.1.0
13
  */
14
+ abstract class GoMage_Social_Controller_SocialNoMail extends GoMage_Social_Controller_Social
15
+ {
16
+ protected function createCustomer($profile)
17
+ {
18
  $customer = Mage::getModel('customer/customer');
19
  $password = $customer->generatePassword(8);
20
 
38
  }
39
 
40
  $customer->save();
 
41
  $customer->sendNewAccountEmail(
42
  'confirmation',
43
  Mage::getSingleton('core/session')->getBeforeAuthUrl(),
44
  Mage::app()->getStore()
45
  ->getId()
46
  );
47
+
48
  Mage::getSingleton('core/session')->addSuccess(
49
  $this->__(
50
  'Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.',
55
  return $customer;
56
  }
57
 
58
+ public function checkEmailAction()
59
+ {
60
  $message = array();
61
  $message['redirect'] = null;
62
 
67
 
68
  if ($profile = Mage::getSingleton('core/session')->getGsProfile()) {
69
  if ($customer->getId()) {
70
+ $message['redirect'] = Mage::getUrl('customer/account/login', array('_secure' => true));
 
 
71
  Mage::getSingleton('core/session')->addNotice('There is already an account with this email address. We suggest using the standard login form.');
72
  } else {
73
  $social_collection = Mage::getModel('gomage_social/entity')
126
  if (!$customer->getConfirmation()) {
127
  $this->getSession()->loginById($customer->getId());
128
  }
129
+ }
130
+ }
 
 
131
  }
132
+
133
+ $this->_clear();
134
  }
135
  }
136
 
141
  return $this->getResponse()->setBody(Zend_Json::encode($message));
142
  }
143
 
144
+ public function emailCloseAction()
145
+ {
146
+ $this->_clear();
147
  }
148
  }
app/code/local/GoMage/Social/Helper/Data.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,192 +8,177 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract {
15
-
16
- public function isFBActive() {
17
- return Mage::getStoreConfig('gomage_social/facebook/enable') && Mage::getStoreConfig('gomage_social/facebook/id') && Mage::getStoreConfig('gomage_social/facebook/secret');
18
- }
19
-
20
- public function isGActive() {
21
- return Mage::getStoreConfig('gomage_social/google/enable') && Mage::getStoreConfig('gomage_social/google/id') && Mage::getStoreConfig('gomage_social/google/secret') && Mage::getStoreConfig('gomage_social/google/api');
22
- }
23
-
24
- public function isLIActive() {
25
- return Mage::getStoreConfig('gomage_social/linkedin/enable') && Mage::getStoreConfig('gomage_social/linkedin/id') && Mage::getStoreConfig('gomage_social/linkedin/secret');
26
- }
27
 
28
- public function isTWActive() {
 
29
  return Mage::getStoreConfig('gomage_social/twitter/enable') && Mage::getStoreConfig('gomage_social/twitter/id') && Mage::getStoreConfig('gomage_social/twitter/secret');
30
  }
31
-
32
- public function isTUActive() {
 
33
  return Mage::getStoreConfig('gomage_social/tumblr/enable') && Mage::getStoreConfig('gomage_social/tumblr/id') && Mage::getStoreConfig('gomage_social/tumblr/secret');
34
  }
35
-
36
- public function isREActive() {
 
37
  return Mage::getStoreConfig('gomage_social/reddit/enable') && Mage::getStoreConfig('gomage_social/reddit/id') && Mage::getStoreConfig('gomage_social/reddit/secret');
38
  }
39
-
40
- public function isAMActive() {
 
41
  return Mage::getStoreConfig('gomage_social/amazon/enable') && Mage::getStoreConfig('gomage_social/amazon/id') && Mage::getStoreConfig('gomage_social/amazon/secret');
42
  }
43
-
44
- public function isActive() {
45
- return Mage::getStoreConfig('gomage_social/general/enable') && ($this->isFBActive() || $this->isGActive() || $this->isLIActive() || $this->isTWActive() || $this->isTUActive() || $this->isREActive() || $this->isAMActive());
46
- }
47
-
48
- public function getServices($place = '') {
49
- $result = array();
50
-
51
- if (! $place) {
52
- return $result;
53
- }
54
-
55
- $selected_services = Mage::getStoreConfig('gomage_social/general/' . $place);
56
-
57
- $selected_services = explode(',', $selected_services);
58
-
59
- if ($this->isFBActive() && in_array(GoMage_Social_Model_Type::FACEBOOK, $selected_services)) {
60
- $result[GoMage_Social_Model_Type::FACEBOOK] = Mage::getStoreConfig('gomage_social/facebook/order');
61
- }
62
-
63
- if ($this->isGActive() && in_array(GoMage_Social_Model_Type::GOOGLE, $selected_services)) {
64
- $result[GoMage_Social_Model_Type::GOOGLE] = Mage::getStoreConfig('gomage_social/google/order');
65
- }
66
-
67
- if ($this->isLIActive() && in_array(GoMage_Social_Model_Type::LINKEDIN, $selected_services)) {
68
- $result[GoMage_Social_Model_Type::LINKEDIN] = Mage::getStoreConfig('gomage_social/linkedin/order');
69
- }
70
-
71
  if ($this->isTWActive() && in_array(GoMage_Social_Model_Type::TWITTER, $selected_services)) {
72
  $result[GoMage_Social_Model_Type::TWITTER] = Mage::getStoreConfig('gomage_social/twitter/order');
73
  }
74
-
75
  if ($this->isTUActive() && in_array(GoMage_Social_Model_Type::TUMBLR, $selected_services)) {
76
  $result[GoMage_Social_Model_Type::TUMBLR] = Mage::getStoreConfig('gomage_social/tumblr/order');
77
  }
78
-
79
  if ($this->isREActive() && in_array(GoMage_Social_Model_Type::REDDIT, $selected_services)) {
80
  $result[GoMage_Social_Model_Type::REDDIT] = Mage::getStoreConfig('gomage_social/reddit/order');
81
  }
82
-
83
- if ($this->isAMActive() && in_array(GoMage_Social_Model_Type::AMAZON, $selected_services)) {
84
  $result[GoMage_Social_Model_Type::AMAZON] = Mage::getStoreConfig('gomage_social/amazon/order');
85
  }
 
 
 
 
86
 
87
- natcasesort($result);
88
-
89
- return $result;
90
- }
91
-
92
- public function getAllStoreDomains() {
93
- $domains = array();
94
-
95
- foreach (Mage::app()->getWebsites() as $website) {
96
- $url = $website->getConfig('web/unsecure/base_url');
97
-
98
- if ($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))) {
99
- $domains[] = $domain;
100
- }
101
-
102
- $url = $website->getConfig('web/secure/base_url');
103
-
104
- if ($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))) {
105
- $domains[] = $domain;
106
- }
107
- }
108
-
109
- return array_unique($domains);
110
- }
111
-
112
- public function setInformation() {
113
- $value = "";
114
-
115
- try {
116
- $ch = curl_init();
117
- curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_downloadable/key/getinformation'));
118
- curl_setopt($ch, CURLOPT_POST, true);
119
- curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector&domains=' . urlencode(implode(',', $this->getAllStoreDomains())) . '&ver=' . urlencode('1.2'));
120
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
121
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
122
-
123
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
124
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
125
-
126
- $value = curl_exec($ch);
127
- } catch (Exception $e) {
128
-
129
- }
130
-
131
- if ($value && ($value != Mage::getStoreConfig('gomage_social/information/text'))) {
132
- Mage::getModel('core/config')->saveConfig('gomage_social/information/text', $value);
133
- Mage::getConfig()->reinit();
134
- Mage::app()->reinitStores();
135
- }
136
-
137
- }
138
-
139
- public function notify() {
140
- $frequency = intval(Mage::app()->loadCache('gomage_notifications_frequency'));
141
-
142
- if (!$frequency) {
143
- $frequency = 24;
144
- }
145
-
146
- $last_update = intval(Mage::app()->loadCache('gomage_notifications_last_update'));
147
-
148
- if (($frequency * 60 * 60 + $last_update) > time()) {
149
- return false;
150
- }
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  $timestamp = $last_update;
153
-
154
  if (!$timestamp) {
155
- $timestamp = time();
156
  }
157
-
158
  try {
159
- $ch = curl_init();
160
- curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_notification/index/data'));
161
- curl_setopt($ch, CURLOPT_POST, true);
162
- curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector&timestamp=' . $timestamp . '&ver=' . urlencode('1.2'));
163
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
164
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
165
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
166
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
167
-
168
- $content = curl_exec($ch);
169
-
170
- $result = Zend_Json::decode($content);
171
-
172
- if ($result && isset($result['frequency']) && ($result['frequency'] != $frequency)) {
173
- Mage::app()->saveCache($result['frequency'], 'gomage_notifications_frequency');
174
- }
175
-
176
- if ($result && isset($result['data'])) {
177
- if (!empty($result['data'])) {
178
- Mage::getModel('adminnotification/inbox')->parse($result['data']);
179
- }
180
- }
181
- } catch (Exception $e){
182
-
183
- }
184
-
185
- Mage::app()->saveCache(time(), 'gomage_notifications_last_update');
186
  }
187
 
188
-
189
- public function getIsAnymoreVersion($major, $minor, $revision = 0) {
190
  $version_info = Mage::getVersion();
191
  $version_info = explode('.', $version_info);
192
-
193
  if ($version_info[0] > $major) {
194
  return true;
195
- } elseif ($version_info[0] == $major){
196
  if ($version_info[1] > $minor) {
197
  return true;
198
  } elseif ($version_info[1] == $minor) {
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
14
+ class GoMage_Social_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+ public function isActive()
17
+ {
18
+ return Mage::getStoreConfig('gomage_social/general/enable') && ($this->isFBActive() || $this->isGActive() || $this->isLIActive() || $this->isTWActive() || $this->isTUActive() || $this->isREActive() || $this->isAMActive());
19
+ }
20
+
21
+ public function isFBActive()
22
+ {
23
+ return Mage::getStoreConfig('gomage_social/facebook/enable') && Mage::getStoreConfig('gomage_social/facebook/id') && Mage::getStoreConfig('gomage_social/facebook/secret');
24
+ }
25
 
26
+ public function isGActive()
27
+ {
28
+ return Mage::getStoreConfig('gomage_social/google/enable') && Mage::getStoreConfig('gomage_social/google/id') && Mage::getStoreConfig('gomage_social/google/secret') && Mage::getStoreConfig('gomage_social/google/api');
29
+ }
30
+
31
+ public function isLIActive()
32
+ {
33
+ return Mage::getStoreConfig('gomage_social/linkedin/enable') && Mage::getStoreConfig('gomage_social/linkedin/id') && Mage::getStoreConfig('gomage_social/linkedin/secret');
34
+ }
 
 
 
 
35
 
36
+ public function isTWActive()
37
+ {
38
  return Mage::getStoreConfig('gomage_social/twitter/enable') && Mage::getStoreConfig('gomage_social/twitter/id') && Mage::getStoreConfig('gomage_social/twitter/secret');
39
  }
40
+
41
+ public function isTUActive()
42
+ {
43
  return Mage::getStoreConfig('gomage_social/tumblr/enable') && Mage::getStoreConfig('gomage_social/tumblr/id') && Mage::getStoreConfig('gomage_social/tumblr/secret');
44
  }
45
+
46
+ public function isREActive()
47
+ {
48
  return Mage::getStoreConfig('gomage_social/reddit/enable') && Mage::getStoreConfig('gomage_social/reddit/id') && Mage::getStoreConfig('gomage_social/reddit/secret');
49
  }
50
+
51
+ public function isAMActive()
52
+ {
53
  return Mage::getStoreConfig('gomage_social/amazon/enable') && Mage::getStoreConfig('gomage_social/amazon/id') && Mage::getStoreConfig('gomage_social/amazon/secret');
54
  }
55
+
56
+ public function getServices($place = '')
57
+ {
58
+ $result = array();
59
+ if (!$place) {
60
+ return $result;
61
+ }
62
+ $selected_services = Mage::getStoreConfig('gomage_social/general/' . $place);
63
+ $selected_services = explode(',', $selected_services);
64
+ if ($this->isFBActive() && in_array(GoMage_Social_Model_Type::FACEBOOK, $selected_services)) {
65
+ $result[GoMage_Social_Model_Type::FACEBOOK] = Mage::getStoreConfig('gomage_social/facebook/order');
66
+ }
67
+ if ($this->isGActive() && in_array(GoMage_Social_Model_Type::GOOGLE, $selected_services)) {
68
+ $result[GoMage_Social_Model_Type::GOOGLE] = Mage::getStoreConfig('gomage_social/google/order');
69
+ }
70
+ if ($this->isLIActive() && in_array(GoMage_Social_Model_Type::LINKEDIN, $selected_services)) {
71
+ $result[GoMage_Social_Model_Type::LINKEDIN] = Mage::getStoreConfig('gomage_social/linkedin/order');
72
+ }
 
 
 
 
 
 
 
 
 
 
73
  if ($this->isTWActive() && in_array(GoMage_Social_Model_Type::TWITTER, $selected_services)) {
74
  $result[GoMage_Social_Model_Type::TWITTER] = Mage::getStoreConfig('gomage_social/twitter/order');
75
  }
 
76
  if ($this->isTUActive() && in_array(GoMage_Social_Model_Type::TUMBLR, $selected_services)) {
77
  $result[GoMage_Social_Model_Type::TUMBLR] = Mage::getStoreConfig('gomage_social/tumblr/order');
78
  }
 
79
  if ($this->isREActive() && in_array(GoMage_Social_Model_Type::REDDIT, $selected_services)) {
80
  $result[GoMage_Social_Model_Type::REDDIT] = Mage::getStoreConfig('gomage_social/reddit/order');
81
  }
82
+ if ($this->isAMActive() && in_array(GoMage_Social_Model_Type::AMAZON, $selected_services)) {
 
83
  $result[GoMage_Social_Model_Type::AMAZON] = Mage::getStoreConfig('gomage_social/amazon/order');
84
  }
85
+ if ($this->isINSTActive() && in_array(GoMage_Social_Model_Type::INSTAGRAM, $selected_services)) {
86
+ $result[GoMage_Social_Model_Type::INSTAGRAM] = Mage::getStoreConfig('gomage_social/instagram/order');
87
+ }
88
+ natcasesort($result);
89
 
90
+ return $result;
91
+ }
92
+
93
+ public function isINSTActive()
94
+ {
95
+ return Mage::getStoreConfig('gomage_social/instagram/enable') && Mage::getStoreConfig('gomage_social/instagram/id') && Mage::getStoreConfig('gomage_social/instagram/secret');
96
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ public function setInformation()
99
+ {
100
+ $value = "";
101
+ try {
102
+ $ch = curl_init();
103
+ curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_downloadable/key/getinformation'));
104
+ curl_setopt($ch, CURLOPT_POST, true);
105
+ curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector&domains=' . urlencode(implode(',', $this->getAllStoreDomains())) . '&ver=' . urlencode('1.2'));
106
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
107
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
108
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
109
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
110
+ $value = curl_exec($ch);
111
+ } catch (Exception $e) {
112
+ }
113
+ if ($value && ($value != Mage::getStoreConfig('gomage_social/information/text'))) {
114
+ Mage::getModel('core/config')->saveConfig('gomage_social/information/text', $value);
115
+ Mage::getConfig()->reinit();
116
+ Mage::app()->reinitStores();
117
+ }
118
+ }
119
+
120
+ public function getAllStoreDomains()
121
+ {
122
+ $domains = array();
123
+ foreach (Mage::app()->getWebsites() as $website) {
124
+ $url = $website->getConfig('web/unsecure/base_url');
125
+ if ($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))) {
126
+ $domains[] = $domain;
127
+ }
128
+ $url = $website->getConfig('web/secure/base_url');
129
+ if ($domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $url))) {
130
+ $domains[] = $domain;
131
+ }
132
+ }
133
+
134
+ return array_unique($domains);
135
+ }
136
+
137
+ public function notify()
138
+ {
139
+ $frequency = intval(Mage::app()->loadCache('gomage_notifications_frequency'));
140
+ if (!$frequency) {
141
+ $frequency = 24;
142
+ }
143
+ $last_update = intval(Mage::app()->loadCache('gomage_notifications_last_update'));
144
+ if (($frequency * 60 * 60 + $last_update) > time()) {
145
+ return false;
146
+ }
147
  $timestamp = $last_update;
 
148
  if (!$timestamp) {
149
+ $timestamp = time();
150
  }
 
151
  try {
152
+ $ch = curl_init();
153
+ curl_setopt($ch, CURLOPT_URL, sprintf('https://www.gomage.com/index.php/gomage_notification/index/data'));
154
+ curl_setopt($ch, CURLOPT_POST, true);
155
+ curl_setopt($ch, CURLOPT_POSTFIELDS, 'sku=social-connector&timestamp=' . $timestamp . '&ver=' . urlencode('1.2'));
156
+ curl_setopt($ch, CURLOPT_TIMEOUT, 30);
157
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
158
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
159
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
160
+ $content = curl_exec($ch);
161
+ $result = Zend_Json::decode($content);
162
+ if ($result && isset($result['frequency']) && ($result['frequency'] != $frequency)) {
163
+ Mage::app()->saveCache($result['frequency'], 'gomage_notifications_frequency');
164
+ }
165
+ if ($result && isset($result['data'])) {
166
+ if (!empty($result['data'])) {
167
+ Mage::getModel('adminnotification/inbox')->parse($result['data']);
168
+ }
169
+ }
170
+ } catch (Exception $e) {
171
+ }
172
+ Mage::app()->saveCache(time(), 'gomage_notifications_last_update');
 
 
 
 
 
 
173
  }
174
 
175
+ public function getIsAnymoreVersion($major, $minor, $revision = 0)
176
+ {
177
  $version_info = Mage::getVersion();
178
  $version_info = explode('.', $version_info);
 
179
  if ($version_info[0] > $major) {
180
  return true;
181
+ } elseif ($version_info[0] == $major) {
182
  if ($version_info[1] > $minor) {
183
  return true;
184
  } elseif ($version_info[1] == $minor) {
app/code/local/GoMage/Social/Helper/Url.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class GoMage_Social_Helper_Url extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function isSecure($url = null)
6
+ {
7
+ return
8
+ ($url)
9
+ ? (parse_url($url, PHP_URL_SCHEME) == 'https')
10
+ : (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on');
11
+ }
12
+
13
+ public function getUrl($route = '', array $params = array())
14
+ {
15
+ $this->detectProtocol();
16
+
17
+ $params['_secure'] = $this->isSecure();;
18
+
19
+ return Mage::getUrl($route, $params);
20
+ }
21
+ }
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 11.1.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Facebook.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Login/Type/Google.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Adminhtml/System/Config/Source/Services.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,26 +8,25 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
- */
13
-
14
- class GoMage_Social_Model_Adminhtml_System_Config_Source_Services{
15
-
16
  public function toOptionArray()
17
  {
18
- $helper = Mage::helper('gomage_social');
19
-
20
  return array(
21
- array('value' => '', 'label' => ''),
22
  array('value' => GoMage_Social_Model_Type::FACEBOOK, 'label' => $helper->__('Facebook')),
23
  array('value' => GoMage_Social_Model_Type::LINKEDIN, 'label' => $helper->__('LinkedIn')),
24
  array('value' => GoMage_Social_Model_Type::GOOGLE, 'label' => $helper->__('Google')),
25
  array('value' => GoMage_Social_Model_Type::TWITTER, 'label' => $helper->__('Twitter')),
26
  array('value' => GoMage_Social_Model_Type::TUMBLR, 'label' => $helper->__('Tumblr')),
27
  array('value' => GoMage_Social_Model_Type::REDDIT, 'label' => $helper->__('Reddit')),
28
- array('value' => GoMage_Social_Model_Type::AMAZON, 'label' => $helper->__('Amazon')),
 
29
  );
30
  }
31
-
32
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
+ */
14
+ class GoMage_Social_Model_Adminhtml_System_Config_Source_Services
15
+ {
 
16
  public function toOptionArray()
17
  {
18
+ $helper = Mage::helper('gomage_social');
19
+
20
  return array(
21
+ array('value' => '', 'label' => ''),
22
  array('value' => GoMage_Social_Model_Type::FACEBOOK, 'label' => $helper->__('Facebook')),
23
  array('value' => GoMage_Social_Model_Type::LINKEDIN, 'label' => $helper->__('LinkedIn')),
24
  array('value' => GoMage_Social_Model_Type::GOOGLE, 'label' => $helper->__('Google')),
25
  array('value' => GoMage_Social_Model_Type::TWITTER, 'label' => $helper->__('Twitter')),
26
  array('value' => GoMage_Social_Model_Type::TUMBLR, 'label' => $helper->__('Tumblr')),
27
  array('value' => GoMage_Social_Model_Type::REDDIT, 'label' => $helper->__('Reddit')),
28
+ array('value' => GoMage_Social_Model_Type::AMAZON, 'label' => $helper->__('Amazon')),
29
+ array('value' => GoMage_Social_Model_Type::INSTAGRAM, 'label' => $helper->__('Instagram')),
30
  );
31
  }
 
32
  }
app/code/local/GoMage/Social/Model/Entity.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Mysql4/Entity.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Mysql4/Entity/Collection.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Observer.php CHANGED
@@ -7,23 +7,30 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
14
- class GoMage_Social_Model_Observer {
15
-
16
- public static function saveConfig() {
 
17
  Mage::helper('gomage_social')->setInformation();
18
  }
19
 
20
- public function GSCustomerLoggedIn() {
21
- if($profile = Mage::getSingleton('core/session')->getGsProfile() && Mage::getSingleton('core/session')->getGsProfile()->url == null ){
 
 
 
 
 
22
  $this->createSocial();
23
  }
24
  }
25
 
26
- private function createSocial(){
 
27
  $customer = Mage::getSingleton('customer/session')->getCustomer();
28
 
29
  return Mage::getModel('gomage_social/entity')
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
14
+ class GoMage_Social_Model_Observer
15
+ {
16
+ public static function saveConfig()
17
+ {
18
  Mage::helper('gomage_social')->setInformation();
19
  }
20
 
21
+ public function GSCustomerLoggedIn()
22
+ {
23
+ if(
24
+ Mage::getSingleton('core/session')->getGsProfile() &&
25
+ isset(Mage::getSingleton('core/session')->getGsProfile()->url_check_email) &&
26
+ Mage::getSingleton('core/session')->getGsProfile()->url_check_email == null
27
+ ){
28
  $this->createSocial();
29
  }
30
  }
31
 
32
+ private function createSocial()
33
+ {
34
  $customer = Mage::getSingleton('customer/session')->getCustomer();
35
 
36
  return Mage::getModel('gomage_social/entity')
app/code/local/GoMage/Social/Model/Observer/Notify.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
app/code/local/GoMage/Social/Model/Type.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,43 +8,47 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
- */
13
-
14
- class GoMage_Social_Model_Type {
15
-
16
- const FACEBOOK = 1;
17
- const LINKEDIN = 2;
18
- const GOOGLE = 3;
19
- const TWITTER = 4;
20
- const TUMBLR = 5;
21
- const REDDIT = 6;
22
- const AMAZON = 7;
23
 
24
- public static function getTypeService($type) {
 
25
  switch ($type) {
26
- case self::FACEBOOK :
27
  return 'facebook';
28
- break;
29
  case self::LINKEDIN :
30
  return 'linkedin';
31
- break;
32
- case self::GOOGLE :
33
  return 'google';
34
- break;
35
  case self::TWITTER :
36
  return 'twitter';
37
- break;
38
  case self::TUMBLR :
39
- return 'tumblr';
40
- break;
41
  case self::REDDIT :
42
- return 'reddit';
43
- break;
44
- case self::AMAZON :
45
- return 'amazon';
46
- break;
 
 
 
47
  }
48
  }
49
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
+ */
14
+ class GoMage_Social_Model_Type
15
+ {
16
+ const FACEBOOK = 1;
17
+ const LINKEDIN = 2;
18
+ const GOOGLE = 3;
19
+ const TWITTER = 4;
20
+ const TUMBLR = 5;
21
+ const REDDIT = 6;
22
+ const AMAZON = 7;
23
+ const INSTAGRAM = 8;
24
 
25
+ public static function getTypeService($type)
26
+ {
27
  switch ($type) {
28
+ case self::FACEBOOK :
29
  return 'facebook';
30
+ break;
31
  case self::LINKEDIN :
32
  return 'linkedin';
33
+ break;
34
+ case self::GOOGLE :
35
  return 'google';
36
+ break;
37
  case self::TWITTER :
38
  return 'twitter';
39
+ break;
40
  case self::TUMBLR :
41
+ return 'tumblr';
42
+ break;
43
  case self::REDDIT :
44
+ return 'reddit';
45
+ break;
46
+ case self::AMAZON :
47
+ return 'amazon';
48
+ break;
49
+ case self::INSTAGRAM :
50
+ return 'instagram';
51
+ break;
52
  }
53
  }
54
  }
app/code/local/GoMage/Social/controllers/AmazonController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,23 +8,23 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
-
14
- class GoMage_Social_AmazonController extends GoMage_Social_Controller_Social {
15
-
16
  protected $credentials;
17
 
18
- public function getSocialType() {
 
19
  return GoMage_Social_Model_Type::AMAZON;
20
  }
21
 
22
- public function getCredentials() {
 
23
  if (!$this->credentials) {
24
- $redirect_uri = Mage::getUrl('gomage_social/amazon/callback', array('_secure' => true));
25
-
26
- $this->credentials = new GoMage_Amazon_Credentials(array(
27
  'client_id' => Mage::getStoreConfig('gomage_social/amazon/id'),
28
  'client_secret' => Mage::getStoreConfig('gomage_social/amazon/secret'),
29
  'redirect_uri' => $redirect_uri,
@@ -33,22 +34,36 @@ class GoMage_Social_AmazonController extends GoMage_Social_Controller_Social {
33
  return $this->credentials;
34
  }
35
 
36
- public function loginAction() {
 
37
  try {
38
  if ($this->getSession()->isLoggedIn()) {
39
  return $this->_redirectUrl();
40
  }
41
 
42
  $service = new GoMage_Amazon_Service($this->getCredentials());
43
- $redirect_url = $service->getAuthorizationUrl(array('scope' => 'profile'));
44
- } catch(Exception $e) {
 
 
 
 
 
 
 
 
 
 
 
45
  $this->getSession()->addError($this->__($e->getMessage()));
46
- }
 
47
 
48
  return $this->_redirectUrl($redirect_url);
49
  }
50
 
51
- public function callbackAction() {
 
52
  try {
53
  $code = $this->getRequest()->getParam('code');
54
 
@@ -57,10 +72,10 @@ class GoMage_Social_AmazonController extends GoMage_Social_Controller_Social {
57
  }
58
 
59
  $credentials = $this->getCredentials();
 
60
  $credentials->setData('code', $code);
61
 
62
  $service = new GoMage_Amazon_Service($credentials);
63
- //GoMage_Amazon_Service::$return_request_error = true;
64
  $oauth_token = $service->requestToken();
65
 
66
  if ($oauth_token->getAccessToken()) {
@@ -113,17 +128,16 @@ class GoMage_Social_AmazonController extends GoMage_Social_Controller_Social {
113
  }
114
  }
115
  }
116
-
117
- return $this->_redirectUrl();
118
  } else {
119
  $this->getSession()->addError($this->__('Could not connect to Amazon. Refresh the page or try again later.'));
120
-
121
- return $this->_redirectUrl();
122
  }
123
  } catch(Exception $e) {
124
  $this->getSession()->addError($this->__($e->getMessage()));
125
-
126
- return $this->_redirectUrl();
127
  }
 
 
 
 
 
128
  }
129
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.2.0
13
  */
14
+ class GoMage_Social_AmazonController extends GoMage_Social_Controller_Social
15
+ {
 
16
  protected $credentials;
17
 
18
+ public function getSocialType()
19
+ {
20
  return GoMage_Social_Model_Type::AMAZON;
21
  }
22
 
23
+ public function getCredentials()
24
+ {
25
  if (!$this->credentials) {
26
+ $redirect_uri = Mage::getUrl('gomage_social/amazon/callback', array('_secure' => true));
27
+ $this->credentials = new GoMage_Amazon_Credentials(array(
 
28
  'client_id' => Mage::getStoreConfig('gomage_social/amazon/id'),
29
  'client_secret' => Mage::getStoreConfig('gomage_social/amazon/secret'),
30
  'redirect_uri' => $redirect_uri,
34
  return $this->credentials;
35
  }
36
 
37
+ public function loginAction()
38
+ {
39
  try {
40
  if ($this->getSession()->isLoggedIn()) {
41
  return $this->_redirectUrl();
42
  }
43
 
44
  $service = new GoMage_Amazon_Service($this->getCredentials());
45
+ $redirect_url = $service->getAuthorizationUrl(array('scope' => 'profile'));
46
+
47
+ $url_backward =
48
+ ($this->getRequest()->getParam('gs_url', ''))
49
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
50
+ : Mage::getBaseUrl();
51
+
52
+ $_profile = array(
53
+ 'url_backward' => $url_backward
54
+ );
55
+
56
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
57
+ } catch (Exception $e) {
58
  $this->getSession()->addError($this->__($e->getMessage()));
59
+ $redirect_url = null;
60
+ }
61
 
62
  return $this->_redirectUrl($redirect_url);
63
  }
64
 
65
+ public function callbackAction()
66
+ {
67
  try {
68
  $code = $this->getRequest()->getParam('code');
69
 
72
  }
73
 
74
  $credentials = $this->getCredentials();
75
+
76
  $credentials->setData('code', $code);
77
 
78
  $service = new GoMage_Amazon_Service($credentials);
 
79
  $oauth_token = $service->requestToken();
80
 
81
  if ($oauth_token->getAccessToken()) {
128
  }
129
  }
130
  }
 
 
131
  } else {
132
  $this->getSession()->addError($this->__('Could not connect to Amazon. Refresh the page or try again later.'));
 
 
133
  }
134
  } catch(Exception $e) {
135
  $this->getSession()->addError($this->__($e->getMessage()));
 
 
136
  }
137
+
138
+ $url_backward = Mage::getSingleton('core/session')->getGsProfile()->url_backward;
139
+ $this->_clear();
140
+
141
+ return $this->_redirectUrl($url_backward);
142
  }
143
  }
app/code/local/GoMage/Social/controllers/FacebookController.php CHANGED
@@ -7,20 +7,21 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Facebook' . DS . 'facebook.php');
15
 
16
- class GoMage_Social_FacebookController extends GoMage_Social_Controller_Social {
17
-
18
- public function getSocialType(){
 
19
  return GoMage_Social_Model_Type::FACEBOOK;
20
  }
21
 
22
- public function loginAction() {
23
-
24
  if ($this->getSession()->isLoggedIn()){
25
  return $this->_redirectUrl();
26
  }
@@ -32,8 +33,7 @@ class GoMage_Social_FacebookController extends GoMage_Social_Controller_Social {
32
 
33
  $social_id = $facebook->getUser();
34
 
35
- if ($social_id) {
36
-
37
  $social_collection = Mage::getModel('gomage_social/entity')
38
  ->getCollection()
39
  ->addFieldToFilter('social_id', $social_id)
@@ -42,15 +42,17 @@ class GoMage_Social_FacebookController extends GoMage_Social_Controller_Social {
42
  if(Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
43
  $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
44
  }
45
- $social = $social_collection->getFirstItem();
46
-
47
- $customer = null;
48
 
49
- if ($social && $social->getId()){
 
 
 
50
  $customer = Mage::getModel('customer/customer');
51
- if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
 
52
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
53
  }
 
54
  $customer->load($social->getData('customer_id'));
55
  }
56
 
@@ -64,28 +66,31 @@ class GoMage_Social_FacebookController extends GoMage_Social_Controller_Social {
64
  $profile = null;
65
  }
66
 
67
- if (! is_null($profile)){
68
  $customer = Mage::getModel('customer/customer');
69
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
70
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
71
  }
 
72
  $customer->loadByEmail($profile['email']);
73
 
74
  if (!$customer->getId()){
75
  $customer = $this->createCustomer($profile);
76
- }
 
77
  if ($customer && $customer->getId()){
78
  $this->createSocial($profile['id'], $customer->getId());
79
  $this->getSession()->loginById($customer->getId());
80
  }
81
  }
82
-
83
  }
84
-
85
  }
86
 
87
- return $this->_redirectUrl();
88
-
89
- }
90
-
 
 
 
91
  }
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Facebook' . DS . 'facebook.php');
15
 
16
+ class GoMage_Social_FacebookController extends GoMage_Social_Controller_Social
17
+ {
18
+ public function getSocialType()
19
+ {
20
  return GoMage_Social_Model_Type::FACEBOOK;
21
  }
22
 
23
+ public function loginAction()
24
+ {
25
  if ($this->getSession()->isLoggedIn()){
26
  return $this->_redirectUrl();
27
  }
33
 
34
  $social_id = $facebook->getUser();
35
 
36
+ if ($social_id) {
 
37
  $social_collection = Mage::getModel('gomage_social/entity')
38
  ->getCollection()
39
  ->addFieldToFilter('social_id', $social_id)
42
  if(Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
43
  $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
44
  }
 
 
 
45
 
46
+ $social = $social_collection->getFirstItem();
47
+ $customer = null;
48
+
49
+ if ($social && $social->getId()) {
50
  $customer = Mage::getModel('customer/customer');
51
+
52
+ if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
53
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
54
  }
55
+
56
  $customer->load($social->getData('customer_id'));
57
  }
58
 
66
  $profile = null;
67
  }
68
 
69
+ if (!is_null($profile)){
70
  $customer = Mage::getModel('customer/customer');
71
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
72
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
73
  }
74
+
75
  $customer->loadByEmail($profile['email']);
76
 
77
  if (!$customer->getId()){
78
  $customer = $this->createCustomer($profile);
79
+ }
80
+
81
  if ($customer && $customer->getId()){
82
  $this->createSocial($profile['id'], $customer->getId());
83
  $this->getSession()->loginById($customer->getId());
84
  }
85
  }
 
86
  }
 
87
  }
88
 
89
+ $url_backward =
90
+ ($this->getRequest()->getParam('gs_url', ''))
91
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
92
+ : Mage::getBaseUrl();
93
+
94
+ return $this->_redirectUrl($url_backward);
95
+ }
96
  }
app/code/local/GoMage/Social/controllers/GoogleController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,21 +8,22 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
-
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'Google_Client.php');
15
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'contrib' . DS . 'Google_Oauth2Service.php');
16
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'contrib' . DS . 'Google_PlusService.php');
17
 
18
- class GoMage_Social_GoogleController extends GoMage_Social_Controller_Social {
19
-
20
- public function getSocialType(){
 
21
  return GoMage_Social_Model_Type::GOOGLE;
22
  }
23
 
24
- private function getGoogleClient(){
 
25
 
26
  $client = new Google_Client();
27
  $client->setApplicationName($this->__('Login with Google'));
@@ -30,9 +32,8 @@ class GoMage_Social_GoogleController extends GoMage_Social_Controller_Social {
30
 
31
  if ($this->getRequest()->getParam('google_plus', 0) == 1) {
32
  $client->setRedirectUri('postmessage');
33
- }else {
34
- $callback_params = array('_secure' => true);
35
- $callback_url = Mage::getUrl('gomage_social/google/callback', $callback_params);
36
  $client->setRedirectUri($callback_url);
37
  }
38
 
@@ -41,35 +42,38 @@ class GoMage_Social_GoogleController extends GoMage_Social_Controller_Social {
41
  return $client;
42
  }
43
 
44
- public function loginAction() {
45
-
46
  if ($this->getSession()->isLoggedIn()) {
47
  return $this->_redirectUrl();
48
  }
49
 
50
  $client = $this->getGoogleClient();
51
 
52
- $google_oauthV2 = new Google_Oauth2Service($client);
53
- $auth_url = $client->createAuthUrl();
54
 
55
- if ($this->getRequest()->getParam('gs_url', '')) {
56
- Mage::getSingleton('core/session')->setData('gs_url', $this->getRequest()->getParam('gs_url'));
57
- }
58
-
59
- return $this->_redirectUrl($auth_url);
 
 
 
60
 
 
 
 
61
  }
62
 
63
-
64
- public function callbackAction(){
65
-
66
  $code = $this->getRequest()->getParam('code');
67
 
68
- if ($code){
69
-
70
- $client = $this->getGoogleClient();
71
-
72
- $google_oauthV2 = new Google_Oauth2Service($client);
73
 
74
  if ($this->getRequest()->getParam('google_plus', 0) == 1) {
75
  $plus = new Google_PlusService($client);
@@ -77,25 +81,23 @@ class GoMage_Social_GoogleController extends GoMage_Social_Controller_Social {
77
 
78
  $client->authenticate($code);
79
 
80
- if ($client->getAccessToken()){
81
-
82
  $profile = $google_oauthV2->userinfo->get();
83
 
84
- if ($profile && is_array($profile) && isset($profile['id'])) {
85
-
86
  $social_collection = Mage::getModel('gomage_social/entity')
87
  ->getCollection()
88
  ->addFieldToFilter('social_id', $profile['id'])
89
  ->addFieldToFilter('type_id', GoMage_Social_Model_Type::GOOGLE);
90
 
91
- if(Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
92
  $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
93
  }
94
- $social = $social_collection->getFirstItem();
95
-
96
- $customer = null;
97
 
98
- if ($social && $social->getId()){
99
  $customer = Mage::getModel('customer/customer');
100
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
101
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
@@ -103,51 +105,45 @@ class GoMage_Social_GoogleController extends GoMage_Social_Controller_Social {
103
  $customer->load($social->getData('customer_id'));
104
  }
105
 
106
- if ($customer && $customer->getId()){
107
  $this->getSession()->loginById($customer->getId());
108
- } else {
109
-
110
  $customer = Mage::getModel('customer/customer');
 
111
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
112
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
113
  }
 
114
  $customer->loadByEmail($profile['email']);
115
 
116
- if (!$customer->getId()){
117
  $profile['first_name'] = $profile['given_name'];
118
  $profile['last_name'] = $profile['family_name'];
119
  $customer = $this->createCustomer($profile);
120
- }
121
- if ($customer && $customer->getId()){
 
122
  $this->createSocial($profile['id'], $customer->getId());
123
  $this->getSession()->loginById($customer->getId());
124
  }
125
-
126
  }
127
-
128
- }
129
-
130
- }else{
131
  $this->getSession()->addError($this->__('Could not connect to Google. Refresh the page or try again later.'));
132
- }
133
-
134
- }else{
135
  $this->getSession()->addError($this->__('Could not connect to Google. Refresh the page or try again later.'));
136
  }
137
 
 
 
 
138
  if ($this->getRequest()->getParam('google_plus', 0) == 1) {
139
-
140
  $result = array();
141
- $result['redirect'] = $this->_getRedirectUrl();
142
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
143
-
144
- }else{
145
-
146
- return $this->_redirectUrl();
147
-
148
  }
149
-
150
- }
151
-
152
-
153
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.1.0
13
  */
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'Google_Client.php');
15
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'contrib' . DS . 'Google_Oauth2Service.php');
16
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Google' . DS . 'contrib' . DS . 'Google_PlusService.php');
17
 
18
+ class GoMage_Social_GoogleController extends GoMage_Social_Controller_Social
19
+ {
20
+ public function getSocialType()
21
+ {
22
  return GoMage_Social_Model_Type::GOOGLE;
23
  }
24
 
25
+ private function getGoogleClient()
26
+ {
27
 
28
  $client = new Google_Client();
29
  $client->setApplicationName($this->__('Login with Google'));
32
 
33
  if ($this->getRequest()->getParam('google_plus', 0) == 1) {
34
  $client->setRedirectUri('postmessage');
35
+ } else {
36
+ $callback_url = Mage::getUrl('gomage_social/google/callback', array('_secure' => true));
 
37
  $client->setRedirectUri($callback_url);
38
  }
39
 
42
  return $client;
43
  }
44
 
45
+ public function loginAction()
46
+ {
47
  if ($this->getSession()->isLoggedIn()) {
48
  return $this->_redirectUrl();
49
  }
50
 
51
  $client = $this->getGoogleClient();
52
 
53
+ $google_oauthV2 = new Google_Oauth2Service($client);
54
+ $auth_url = $client->createAuthUrl();
55
 
56
+ $url_backward =
57
+ ($this->getRequest()->getParam('gs_url', ''))
58
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
59
+ : Mage::getBaseUrl();
60
+
61
+ $_profile = array(
62
+ 'url_backward' => $url_backward
63
+ );
64
 
65
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
66
+
67
+ return $this->_redirectUrl($auth_url);
68
  }
69
 
70
+ public function callbackAction()
71
+ {
 
72
  $code = $this->getRequest()->getParam('code');
73
 
74
+ if ($code) {
75
+ $client = $this->getGoogleClient();
76
+ $google_oauthV2 = new Google_Oauth2Service($client);
 
 
77
 
78
  if ($this->getRequest()->getParam('google_plus', 0) == 1) {
79
  $plus = new Google_PlusService($client);
81
 
82
  $client->authenticate($code);
83
 
84
+ if ($client->getAccessToken()) {
 
85
  $profile = $google_oauthV2->userinfo->get();
86
 
87
+ if ($profile && is_array($profile) && isset($profile['id'])) {
 
88
  $social_collection = Mage::getModel('gomage_social/entity')
89
  ->getCollection()
90
  ->addFieldToFilter('social_id', $profile['id'])
91
  ->addFieldToFilter('type_id', GoMage_Social_Model_Type::GOOGLE);
92
 
93
+ if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
94
  $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
95
  }
96
+
97
+ $social = $social_collection->getFirstItem();
98
+ $customer = null;
99
 
100
+ if ($social && $social->getId()) {
101
  $customer = Mage::getModel('customer/customer');
102
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
103
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
105
  $customer->load($social->getData('customer_id'));
106
  }
107
 
108
+ if ($customer && $customer->getId()) {
109
  $this->getSession()->loginById($customer->getId());
110
+ } else {
 
111
  $customer = Mage::getModel('customer/customer');
112
+
113
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
114
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
115
  }
116
+
117
  $customer->loadByEmail($profile['email']);
118
 
119
+ if (!$customer->getId()) {
120
  $profile['first_name'] = $profile['given_name'];
121
  $profile['last_name'] = $profile['family_name'];
122
  $customer = $this->createCustomer($profile);
123
+ }
124
+
125
+ if ($customer && $customer->getId()) {
126
  $this->createSocial($profile['id'], $customer->getId());
127
  $this->getSession()->loginById($customer->getId());
128
  }
 
129
  }
130
+ }
131
+ } else {
 
 
132
  $this->getSession()->addError($this->__('Could not connect to Google. Refresh the page or try again later.'));
133
+ }
134
+ } else {
 
135
  $this->getSession()->addError($this->__('Could not connect to Google. Refresh the page or try again later.'));
136
  }
137
 
138
+ $url_backward = Mage::getSingleton('core/session')->getGsProfile()->url_backward;
139
+ $this->_clear();
140
+
141
  if ($this->getRequest()->getParam('google_plus', 0) == 1) {
 
142
  $result = array();
143
+ $result['redirect'] = $url_backward;
144
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
145
+ } else {
146
+ return $this->_redirectUrl($url_backward);
 
 
 
147
  }
148
+ }
 
 
 
149
  }
app/code/local/GoMage/Social/controllers/InstagramController.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * GoMage Social Connector Extension
5
+ *
6
+ * @category Extension
7
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
8
+ * @author GoMage
9
+ * @license http://www.gomage.com/license-agreement/ Single domain license
10
+ * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
+ * @since Class available since Release 1.2.0
13
+ */
14
+ class GoMage_Social_InstagramController extends GoMage_Social_Controller_SocialNoMail
15
+ {
16
+ protected $credentials;
17
+
18
+ public function getSocialType()
19
+ {
20
+ return GoMage_Social_Model_Type::INSTAGRAM;
21
+ }
22
+
23
+ public function getCredentials()
24
+ {
25
+ if (!$this->credentials) {
26
+ $redirect_uri = Mage::getUrl('gomage_social/instagram/callback', array('_secure' => true));
27
+ $this->credentials = new GoMage_Instagram_Credentials(array(
28
+ 'client_id' => Mage::getStoreConfig('gomage_social/instagram/id'),
29
+ 'client_secret' => Mage::getStoreConfig('gomage_social/instagram/secret'),
30
+ 'redirect_uri' => $redirect_uri,
31
+ ));
32
+ }
33
+
34
+ return $this->credentials;
35
+ }
36
+
37
+ public function loginAction()
38
+ {
39
+ try {
40
+ if ($this->getSession()->isLoggedIn()) {
41
+ return $this->_redirectUrl();
42
+ }
43
+
44
+ $service = new GoMage_Instagram_Service($this->getCredentials());
45
+ $redirect_url = $service->getAuthorizationUrl(array('scope' => 'basic'));
46
+
47
+ $url_backward =
48
+ ($this->getRequest()->getParam('gs_url', ''))
49
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
50
+ : Mage::getBaseUrl();
51
+
52
+ $_profile = array(
53
+ 'url_backward' => $url_backward,
54
+ 'url_check_email' => Mage::getUrl('gomage_social/instagram/checkEmail', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
55
+ 'url_email_close' => Mage::getUrl('gomage_social/instagram/emailClose', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
56
+ 'type_id' => $this->getSocialType()
57
+ );
58
+
59
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
60
+ } catch (Exception $e) {
61
+ $this->getSession()->addError($this->__($e->getMessage()));
62
+ $redirect_url = null;
63
+ }
64
+
65
+ return $this->_redirectUrl($redirect_url);
66
+ }
67
+
68
+ public function callbackAction()
69
+ {
70
+ try {
71
+ $code = $this->getRequest()->getParam('code');
72
+
73
+ if ($this->getSession()->isLoggedIn() || empty($code)) {
74
+ return $this->_redirectUrl();
75
+ }
76
+
77
+ $credentials = $this->getCredentials();
78
+
79
+ $credentials->setData('code', $code);
80
+
81
+ $service = new GoMage_Instagram_Service($credentials);
82
+ $oauth_token = $service->requestToken();
83
+
84
+ if ($oauth_token->getAccessToken()) {
85
+ Mage::getSingleton('core/session')->setData('oauth_token', $oauth_token);
86
+ $service->getCredentials()->setData('oauth_token', $oauth_token);
87
+
88
+ $profile = new Varien_Object($service->requestUserProfile()->getData('data'));
89
+
90
+ if ($profile->getData('id')) {
91
+ $social_collection = Mage::getModel('gomage_social/entity')
92
+ ->getCollection()
93
+ ->addFieldToFilter('social_id', $profile->getData('id'))
94
+ ->addFieldToFilter('type_id', $this->getSocialType());
95
+
96
+ if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
97
+ $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
98
+ }
99
+
100
+ $social = $social_collection->getFirstItem();
101
+
102
+ if ($social && $social->getId()) {
103
+ if ($social->social_id == $profile->getData('id')) {
104
+ $customer = Mage::getModel('customer/customer');
105
+
106
+ if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
107
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
108
+ }
109
+
110
+ $customer->load($social->getData('customer_id'));
111
+
112
+ if ($customer && $customer->getId()) {
113
+ if (!$customer->getConfirmation()) {
114
+ $this->getSession()->loginById($customer->getId());
115
+ } else {
116
+ $this->getSession()->addError($this->__('This account is not confirmed.'));
117
+ }
118
+ }
119
+ }
120
+ } else {
121
+ $_profile = array_merge((array) Mage::getSingleton('core/session')->getGsProfile(), array(
122
+ 'id' => $profile->getData('id'),
123
+ 'name' => $profile->getData('username') . ' ' . $profile->getData('username'),
124
+ 'first_name' => $profile->getData('username'),
125
+ 'last_name' => $profile->getData('username'),
126
+ ));
127
+
128
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
129
+ }
130
+ }
131
+ } else {
132
+ $this->getSession()->addError($this->__('Could not connect to Instagram. Refresh the page or try again later.'));
133
+ }
134
+ } catch (Exception $e) {
135
+ $this->getSession()->addError($this->__($e->getMessage()));
136
+ }
137
+
138
+ return $this->_redirectUrl();
139
+ }
140
+ }
app/code/local/GoMage/Social/controllers/LinkedinController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,43 +8,49 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
-
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Linkedin' . DS . 'linkedinoauth.php');
15
 
16
- class GoMage_Social_LinkedinController extends GoMage_Social_Controller_Social {
17
-
18
- public function getSocialType() {
 
19
  return GoMage_Social_Model_Type::LINKEDIN;
20
  }
21
 
22
- public function loginAction() {
23
-
24
  if ($this->getSession()->isLoggedIn()) {
25
  return $this->_redirectUrl();
26
  }
27
 
28
- $connection = new LinkedInOAuth(Mage::getStoreConfig('gomage_social/linkedin/id'), Mage::getStoreConfig('gomage_social/linkedin/secret'));
29
-
30
- $callback_params = array('_secure' => true);
31
- if ($this->getRequest()->getParam('gs_url', '')) {
32
- $callback_params['gs_url'] = $this->getRequest()->getParam('gs_url');
33
- }
34
-
35
- $callback_url = Mage::getUrl('gomage_social/linkedin/callback', $callback_params);
36
- $request_token = $connection->getRequestToken($callback_url);
37
 
38
  switch ($connection->http_code) {
39
- case 200:
40
  Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
41
  Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
42
 
43
- $url = $connection->getAuthorizeURL($request_token['oauth_token']);
 
 
 
 
 
 
 
 
 
 
 
 
44
  return $this->_redirectUrl($url);
45
- break;
46
- default:
47
  $this->getSession()->addError($this->__('Could not connect to LinkedIn. Refresh the page or try again later.'));
48
  }
49
 
@@ -51,21 +58,21 @@ class GoMage_Social_LinkedinController extends GoMage_Social_Controller_Social {
51
 
52
  }
53
 
54
- public function callbackAction(){
55
-
56
- $oauth_token = $this->getRequest()->getParam('oauth_token');
57
- $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
58
 
59
- if (!$oauth_token || !$oauth_verifier){
60
  return $this->_redirectUrl();
61
  }
62
 
63
- if ($oauth_token != Mage::getSingleton('core/session')->getData('oauth_token')){
64
  return $this->_redirectUrl();
65
  }
66
 
67
- $connection = new LinkedInOAuth(Mage::getStoreConfig('gomage_social/linkedin/id'), Mage::getStoreConfig('gomage_social/linkedin/secret'), Mage::getSingleton('core/session')->getData('oauth_token'), Mage::getSingleton('core/session')->getData('oauth_token_secret'));
68
- $access_token = $connection->getAccessToken($oauth_verifier);
69
 
70
  Mage::getSingleton('core/session')->unsetData('oauth_token');
71
  Mage::getSingleton('core/session')->unsetData('oauth_token_secret');
@@ -82,53 +89,57 @@ class GoMage_Social_LinkedinController extends GoMage_Social_Controller_Social {
82
  }
83
 
84
  if ($profile) {
85
-
86
  $social_collection = Mage::getModel('gomage_social/entity')
87
  ->getCollection()
88
  ->addFieldToFilter('social_id', $profile->id)
89
  ->addFieldToFilter('type_id', GoMage_Social_Model_Type::LINKEDIN);
90
 
91
- if(Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
92
  $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
93
  }
94
- $social = $social_collection->getFirstItem();
95
-
96
- $customer = null;
97
 
98
- if ($social && $social->getId()){
 
 
 
99
  $customer = Mage::getModel('customer/customer');
100
- if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
 
101
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
102
  }
 
103
  $customer->load($social->getData('customer_id'));
104
  }
105
 
106
- if ($customer && $customer->getId()){
107
  $this->getSession()->loginById($customer->getId());
108
- } else {
109
-
110
  $customer = Mage::getModel('customer/customer');
 
111
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
112
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
113
  }
114
 
115
- $profile->email = $profile->emailAddress;
116
- $profile->first_name = $profile->firstName;
117
- $profile->last_name = $profile->lastName;
118
-
119
  $customer->loadByEmail($profile->email);
120
 
121
- if (!$customer->getId()){
122
  $customer = $this->createCustomer($profile);
123
- }
124
- if ($customer && $customer->getId()){
 
125
  $this->createSocial($profile->id, $customer->getId());
126
  $this->getSession()->loginById($customer->getId());
127
- }
128
-
129
  }
130
  }
131
 
132
- return $this->_redirectUrl();
 
 
 
133
  }
134
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Linkedin' . DS . 'linkedinoauth.php');
15
 
16
+ class GoMage_Social_LinkedinController extends GoMage_Social_Controller_Social
17
+ {
18
+ public function getSocialType()
19
+ {
20
  return GoMage_Social_Model_Type::LINKEDIN;
21
  }
22
 
23
+ public function loginAction()
24
+ {
25
  if ($this->getSession()->isLoggedIn()) {
26
  return $this->_redirectUrl();
27
  }
28
 
29
+ $connection = new LinkedInOAuth(Mage::getStoreConfig('gomage_social/linkedin/id'), Mage::getStoreConfig('gomage_social/linkedin/secret'));
30
+ $callback_url = Mage::getUrl('gomage_social/linkedin/callback', array('_secure' => true));
31
+ $request_token = $connection->getRequestToken($callback_url);
 
 
 
 
 
 
32
 
33
  switch ($connection->http_code) {
34
+ case 200 :
35
  Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
36
  Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
37
 
38
+ $url = $connection->getAuthorizeURL($request_token['oauth_token']);
39
+
40
+ $url_backward =
41
+ ($this->getRequest()->getParam('gs_url', ''))
42
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
43
+ : Mage::getBaseUrl();
44
+
45
+ $_profile = array(
46
+ 'url_backward' => $url_backward
47
+ );
48
+
49
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
50
+
51
  return $this->_redirectUrl($url);
52
+ break;
53
+ default :
54
  $this->getSession()->addError($this->__('Could not connect to LinkedIn. Refresh the page or try again later.'));
55
  }
56
 
58
 
59
  }
60
 
61
+ public function callbackAction()
62
+ {
63
+ $oauth_token = $this->getRequest()->getParam('oauth_token');
64
+ $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
65
 
66
+ if (!$oauth_token || !$oauth_verifier) {
67
  return $this->_redirectUrl();
68
  }
69
 
70
+ if ($oauth_token != Mage::getSingleton('core/session')->getData('oauth_token')) {
71
  return $this->_redirectUrl();
72
  }
73
 
74
+ $connection = new LinkedInOAuth(Mage::getStoreConfig('gomage_social/linkedin/id'), Mage::getStoreConfig('gomage_social/linkedin/secret'), Mage::getSingleton('core/session')->getData('oauth_token'), Mage::getSingleton('core/session')->getData('oauth_token_secret'));
75
+ $access_token = $connection->getAccessToken($oauth_verifier);
76
 
77
  Mage::getSingleton('core/session')->unsetData('oauth_token');
78
  Mage::getSingleton('core/session')->unsetData('oauth_token_secret');
89
  }
90
 
91
  if ($profile) {
 
92
  $social_collection = Mage::getModel('gomage_social/entity')
93
  ->getCollection()
94
  ->addFieldToFilter('social_id', $profile->id)
95
  ->addFieldToFilter('type_id', GoMage_Social_Model_Type::LINKEDIN);
96
 
97
+ if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
98
  $social_collection->addFieldToFilter('website_id', Mage::app()->getWebsite()->getId());
99
  }
 
 
 
100
 
101
+ $social = $social_collection->getFirstItem();
102
+ $customer = null;
103
+
104
+ if ($social && $social->getId()) {
105
  $customer = Mage::getModel('customer/customer');
106
+
107
+ if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
108
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
109
  }
110
+
111
  $customer->load($social->getData('customer_id'));
112
  }
113
 
114
+ if ($customer && $customer->getId()) {
115
  $this->getSession()->loginById($customer->getId());
116
+ } else {
 
117
  $customer = Mage::getModel('customer/customer');
118
+
119
  if (Mage::getSingleton('customer/config_share')->isWebsiteScope()) {
120
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
121
  }
122
 
123
+ $profile->email = $profile->emailAddress;
124
+ $profile->first_name = $profile->firstName;
125
+ $profile->last_name = $profile->lastName;
126
+
127
  $customer->loadByEmail($profile->email);
128
 
129
+ if (!$customer->getId()) {
130
  $customer = $this->createCustomer($profile);
131
+ }
132
+
133
+ if ($customer && $customer->getId()) {
134
  $this->createSocial($profile->id, $customer->getId());
135
  $this->getSession()->loginById($customer->getId());
136
+ }
 
137
  }
138
  }
139
 
140
+ $url_backward = Mage::getSingleton('core/session')->getGsProfile()->url_backward;
141
+ $this->_clear();
142
+
143
+ return $this->_redirectUrl($url_backward);
144
  }
145
  }
app/code/local/GoMage/Social/controllers/RedditController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,24 +8,25 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
-
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'Client.php');
15
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'GrantType/IGrantType.php');
16
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'GrantType/AuthorizationCode.php');
17
 
18
- class GoMage_Social_RedditController extends GoMage_Social_Controller_SocialNoMail {
 
 
 
19
 
20
- protected $authorizeUrl = 'https://ssl.reddit.com/api/v1/authorize';
21
- protected $accessTokenUrl = 'https://ssl.reddit.com/api/v1/access_token';
22
-
23
- public function getSocialType() {
24
  return GoMage_Social_Model_Type::REDDIT;
25
  }
26
 
27
- public function loginAction() {
 
28
  $callback_url = Mage::getUrl('gomage_social/reddit/callback', array('_secure' => true));
29
  $client = new OAuth2\Client(
30
  Mage::getStoreConfig('gomage_social/reddit/id'),
@@ -32,7 +34,7 @@ class GoMage_Social_RedditController extends GoMage_Social_Controller_SocialNoMa
32
  OAuth2\Client::AUTH_TYPE_AUTHORIZATION_BASIC
33
  );
34
 
35
- $authUrl = $client->getAuthenticationUrl(
36
  $this->authorizeUrl,
37
  $callback_url,
38
  array(
@@ -41,17 +43,32 @@ class GoMage_Social_RedditController extends GoMage_Social_Controller_SocialNoMa
41
  )
42
  );
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  return $this->_redirectUrl($authUrl);
45
  }
46
 
47
- public function callbackAction() {
 
48
  $callback_url = Mage::getUrl('gomage_social/reddit/callback', array('_secure' => true));
49
  $client = new OAuth2\Client(
50
  Mage::getStoreConfig('gomage_social/reddit/id'),
51
  Mage::getStoreConfig('gomage_social/reddit/secret'),
52
  OAuth2\Client::AUTH_TYPE_AUTHORIZATION_BASIC
53
- );
54
- $params = array(
55
  "code" => $this->getRequest()->getParam('code'),
56
  "redirect_uri" => $callback_url
57
  );
@@ -108,11 +125,9 @@ class GoMage_Social_RedditController extends GoMage_Social_Controller_SocialNoMa
108
  }
109
  }
110
  } else {
111
- $profile->url = Mage::getUrl('gomage_social/reddit/checkEmail', array('_secure' => true));
112
- $profile->urlEmailClose = Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => true));
113
- $profile->type_id = GoMage_Social_Model_Type::REDDIT;
114
 
115
- Mage::getSingleton('core/session')->setGsProfile($profile);
116
  }
117
  }
118
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.1.0
13
  */
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'Client.php');
15
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'GrantType/IGrantType.php');
16
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Reddit' . DS . 'GrantType/AuthorizationCode.php');
17
 
18
+ class GoMage_Social_RedditController extends GoMage_Social_Controller_SocialNoMail
19
+ {
20
+ protected $authorizeUrl = 'https://ssl.reddit.com/api/v1/authorize';
21
+ protected $accessTokenUrl = 'https://ssl.reddit.com/api/v1/access_token';
22
 
23
+ public function getSocialType()
24
+ {
 
 
25
  return GoMage_Social_Model_Type::REDDIT;
26
  }
27
 
28
+ public function loginAction()
29
+ {
30
  $callback_url = Mage::getUrl('gomage_social/reddit/callback', array('_secure' => true));
31
  $client = new OAuth2\Client(
32
  Mage::getStoreConfig('gomage_social/reddit/id'),
34
  OAuth2\Client::AUTH_TYPE_AUTHORIZATION_BASIC
35
  );
36
 
37
+ $authUrl = $client->getAuthenticationUrl(
38
  $this->authorizeUrl,
39
  $callback_url,
40
  array(
43
  )
44
  );
45
 
46
+ $url_backward =
47
+ ($this->getRequest()->getParam('gs_url', ''))
48
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
49
+ : Mage::getBaseUrl();
50
+
51
+ $_profile = array(
52
+ 'url_backward' => $url_backward,
53
+ 'url_check_email' => Mage::getUrl('gomage_social/reddit/checkEmail', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
54
+ 'url_email_close' => Mage::getUrl('gomage_social/reddit/emailClose', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
55
+ 'type_id' => $this->getSocialType()
56
+ );
57
+
58
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
59
+
60
  return $this->_redirectUrl($authUrl);
61
  }
62
 
63
+ public function callbackAction()
64
+ {
65
  $callback_url = Mage::getUrl('gomage_social/reddit/callback', array('_secure' => true));
66
  $client = new OAuth2\Client(
67
  Mage::getStoreConfig('gomage_social/reddit/id'),
68
  Mage::getStoreConfig('gomage_social/reddit/secret'),
69
  OAuth2\Client::AUTH_TYPE_AUTHORIZATION_BASIC
70
+ );
71
+ $params = array(
72
  "code" => $this->getRequest()->getParam('code'),
73
  "redirect_uri" => $callback_url
74
  );
125
  }
126
  }
127
  } else {
128
+ $_profile = array_merge((array) Mage::getSingleton('core/session')->getGsProfile(), (array) $profile);
 
 
129
 
130
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
131
  }
132
  }
133
  }
app/code/local/GoMage/Social/controllers/TumblrController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,42 +8,51 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
-
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Tumblr' . DS . 'tumblroauth.php');
15
 
16
- class GoMage_Social_TumblrController extends GoMage_Social_Controller_SocialNoMail {
17
-
18
- public function getSocialType() {
 
19
  return GoMage_Social_Model_Type::TUMBLR;
20
  }
21
 
22
- public function loginAction() {
 
23
  if ($this->getSession()->isLoggedIn()) {
24
  return $this->_redirectUrl();
25
  }
26
 
27
- $connection = new TumblrOAuth(Mage::getStoreConfig('gomage_social/tumblr/id'), Mage::getStoreConfig('gomage_social/tumblr/secret'));
28
- $callback_params = array('_secure' => true);
29
-
30
- if ($this->getRequest()->getParam('gs_url', '')) {
31
- $callback_params['gs_url'] = $this->getRequest()->getParam('gs_url');
32
- }
33
-
34
- $callback_url = Mage::getUrl('gomage_social/tumblr/callback', $callback_params);
35
  $request_token = $connection->getRequestToken($callback_url);
36
-
37
  switch ($connection->http_code) {
38
  case 200 :
39
  Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
40
  Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
41
 
42
- $url = $connection->getAuthorizeURL($request_token['oauth_token']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  return $this->_redirectUrl($url);
45
- break;
46
  default :
47
  $this->getSession()->addError($this->__('Could not connect to Tumblr. Refresh the page or try again later.'));
48
  }
@@ -50,7 +60,8 @@ class GoMage_Social_TumblrController extends GoMage_Social_Controller_SocialNoMa
50
  return $this->_redirectUrl();
51
  }
52
 
53
- public function callbackAction() {
 
54
  $oauth_token = $this->getRequest()->getParam('oauth_token');
55
  $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
56
 
@@ -78,8 +89,7 @@ class GoMage_Social_TumblrController extends GoMage_Social_Controller_SocialNoMa
78
  switch ($connection->http_code) {
79
  case 200 :
80
  $profile = $connection->get("http://api.tumblr.com/v2/user/info");
81
-
82
- break;
83
  default :
84
  $this->getSession()->addError($this->__('Could not connect to Tumblr. Refresh the page or try again later.'));
85
 
@@ -121,11 +131,9 @@ class GoMage_Social_TumblrController extends GoMage_Social_Controller_SocialNoMa
121
  }
122
  }
123
  } else {
124
- $profile->url = Mage::getUrl('gomage_social/tumblr/checkEmail', array('_secure' => true));
125
- $profile->urlEmailClose = Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => true));
126
- $profile->type_id = GoMage_Social_Model_Type::TUMBLR;
127
-
128
- Mage::getSingleton('core/session')->setGsProfile($profile);
129
  }
130
  }
131
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.1.0
13
  */
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Tumblr' . DS . 'tumblroauth.php');
15
 
16
+ class GoMage_Social_TumblrController extends GoMage_Social_Controller_SocialNoMail
17
+ {
18
+ public function getSocialType()
19
+ {
20
  return GoMage_Social_Model_Type::TUMBLR;
21
  }
22
 
23
+ public function loginAction()
24
+ {
25
  if ($this->getSession()->isLoggedIn()) {
26
  return $this->_redirectUrl();
27
  }
28
 
29
+ $connection = new TumblrOAuth(Mage::getStoreConfig('gomage_social/tumblr/id'), Mage::getStoreConfig('gomage_social/tumblr/secret'));
30
+ $callback_url = Mage::getUrl('gomage_social/tumblr/callback', array('_secure' => true));
 
 
 
 
 
 
31
  $request_token = $connection->getRequestToken($callback_url);
32
+
33
  switch ($connection->http_code) {
34
  case 200 :
35
  Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
36
  Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
37
 
38
+ $url = $connection->getAuthorizeURL($request_token['oauth_token']);
39
+
40
+ $url_backward =
41
+ ($this->getRequest()->getParam('gs_url', ''))
42
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
43
+ : Mage::getBaseUrl();
44
+
45
+ $_profile = array(
46
+ 'url_backward' => $url_backward,
47
+ 'url_check_email' => Mage::getUrl('gomage_social/reddit/checkEmail', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
48
+ 'url_email_close' => Mage::getUrl('gomage_social/reddit/emailClose', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
49
+ 'type_id' => $this->getSocialType()
50
+ );
51
+
52
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
53
 
54
  return $this->_redirectUrl($url);
55
+ break;
56
  default :
57
  $this->getSession()->addError($this->__('Could not connect to Tumblr. Refresh the page or try again later.'));
58
  }
60
  return $this->_redirectUrl();
61
  }
62
 
63
+ public function callbackAction()
64
+ {
65
  $oauth_token = $this->getRequest()->getParam('oauth_token');
66
  $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
67
 
89
  switch ($connection->http_code) {
90
  case 200 :
91
  $profile = $connection->get("http://api.tumblr.com/v2/user/info");
92
+ break;
 
93
  default :
94
  $this->getSession()->addError($this->__('Could not connect to Tumblr. Refresh the page or try again later.'));
95
 
131
  }
132
  }
133
  } else {
134
+ $_profile = array_merge((array) Mage::getSingleton('core/session')->getGsProfile(), (array) $profile);
135
+
136
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
 
 
137
  }
138
  }
139
  }
app/code/local/GoMage/Social/controllers/TwitterController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * GoMage Social Connector Extension
4
  *
@@ -7,31 +8,26 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
-
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Twitter' . DS . 'twitteroauth.php');
15
 
16
- class GoMage_Social_TwitterController extends GoMage_Social_Controller_SocialNoMail {
17
-
18
- public function getSocialType() {
 
19
  return GoMage_Social_Model_Type::TWITTER;
20
  }
21
 
22
- public function loginAction() {
 
23
  if ($this->getSession()->isLoggedIn()) {
24
  return $this->_redirectUrl();
25
  }
26
 
27
- $connection = new TwitterOAuth(Mage::getStoreConfig('gomage_social/twitter/id'), Mage::getStoreConfig('gomage_social/twitter/secret'));
28
- $callback_params = array('_secure' => true);
29
-
30
- if ($this->getRequest()->getParam('gs_url', '')) {
31
- $callback_params['gs_url'] = $this->getRequest()->getParam('gs_url');
32
- }
33
-
34
- $callback_url = Mage::getUrl('gomage_social/twitter/callback', $callback_params);
35
  $request_token = $connection->getRequestToken($callback_url);
36
 
37
  switch ($connection->http_code) {
@@ -39,10 +35,24 @@ class GoMage_Social_TwitterController extends GoMage_Social_Controller_SocialNoM
39
  Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
40
  Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
41
 
42
- $url = $connection->getAuthorizeURL($request_token['oauth_token']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  return $this->_redirectUrl($url);
45
- break;
46
  default :
47
  $this->getSession()->addError($this->__('Could not connect to Twitter. Refresh the page or try again later.'));
48
  }
@@ -50,7 +60,8 @@ class GoMage_Social_TwitterController extends GoMage_Social_Controller_SocialNoM
50
  return $this->_redirectUrl();
51
  }
52
 
53
- public function callbackAction() {
 
54
  $oauth_token = $this->getRequest()->getParam('oauth_token');
55
  $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
56
 
@@ -117,11 +128,9 @@ class GoMage_Social_TwitterController extends GoMage_Social_Controller_SocialNoM
117
  }
118
  }
119
  } else {
120
- $profile->url = Mage::getUrl('gomage_social/twitter/checkEmail', array('_secure' => true));
121
- $profile->urlEmailClose = Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => true));
122
- $profile->type_id = GoMage_Social_Model_Type::TWITTER;
123
-
124
- Mage::getSingleton('core/session')->setGsProfile($profile);
125
  }
126
  }
127
  }
1
  <?php
2
+
3
  /**
4
  * GoMage Social Connector Extension
5
  *
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.1.0
13
  */
 
14
  require_once (Mage::getBaseDir('lib') . DS . 'GoMage' . DS . 'Twitter' . DS . 'twitteroauth.php');
15
 
16
+ class GoMage_Social_TwitterController extends GoMage_Social_Controller_SocialNoMail
17
+ {
18
+ public function getSocialType()
19
+ {
20
  return GoMage_Social_Model_Type::TWITTER;
21
  }
22
 
23
+ public function loginAction()
24
+ {
25
  if ($this->getSession()->isLoggedIn()) {
26
  return $this->_redirectUrl();
27
  }
28
 
29
+ $connection = new TwitterOAuth(Mage::getStoreConfig('gomage_social/twitter/id'), Mage::getStoreConfig('gomage_social/twitter/secret'));
30
+ $callback_url = Mage::getUrl('gomage_social/twitter/callback', array('_secure' => true));
 
 
 
 
 
 
31
  $request_token = $connection->getRequestToken($callback_url);
32
 
33
  switch ($connection->http_code) {
35
  Mage::getSingleton('core/session')->setData('oauth_token', $request_token['oauth_token']);
36
  Mage::getSingleton('core/session')->setData('oauth_token_secret', $request_token['oauth_token_secret']);
37
 
38
+ $url = $connection->getAuthorizeURL($request_token['oauth_token']);
39
+
40
+ $url_backward =
41
+ ($this->getRequest()->getParam('gs_url', ''))
42
+ ? Mage::helper('core')->urlDecode($this->getRequest()->getParam('gs_url'))
43
+ : Mage::getBaseUrl();
44
+
45
+ $_profile = array(
46
+ 'url_backward' => $url_backward,
47
+ 'url_check_email' => Mage::getUrl('gomage_social/twitter/checkEmail', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
48
+ 'url_email_close' => Mage::getUrl('gomage_social/twitter/emailClose', array('_secure' => Mage::helper('gomage_social/url')->isSecure($url_backward))),
49
+ 'type_id' => $this->getSocialType()
50
+ );
51
+
52
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
53
 
54
  return $this->_redirectUrl($url);
55
+ break;
56
  default :
57
  $this->getSession()->addError($this->__('Could not connect to Twitter. Refresh the page or try again later.'));
58
  }
60
  return $this->_redirectUrl();
61
  }
62
 
63
+ public function callbackAction()
64
+ {
65
  $oauth_token = $this->getRequest()->getParam('oauth_token');
66
  $oauth_verifier = $this->getRequest()->getParam('oauth_verifier');
67
 
128
  }
129
  }
130
  } else {
131
+ $_profile = array_merge((array) Mage::getSingleton('core/session')->getGsProfile(), (array) $profile);
132
+
133
+ Mage::getSingleton('core/session')->setGsProfile((object) $_profile);
 
 
134
  }
135
  }
136
  }
app/code/local/GoMage/Social/etc/adminhtml.xml CHANGED
@@ -8,7 +8,7 @@
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
- * @version Release: 1.3.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
app/code/local/GoMage/Social/etc/config.xml CHANGED
@@ -8,39 +8,39 @@
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
- * @version Release: 1.3.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
15
  <config>
16
- <modules>
17
- <GoMage_Social>
18
- <version>1.3.0</version>
19
- </GoMage_Social>
20
- </modules>
21
- <frontend>
22
- <routers>
23
- <gomage_social>
24
- <use>standard</use>
25
- <args>
26
- <module>GoMage_Social</module>
27
- <frontName>gomage_social</frontName>
28
- </args>
29
- </gomage_social>
30
- </routers>
31
- <layout>
32
- <updates>
33
- <gomage_social module="gomage_social">
34
- <file>gomage-social.xml</file>
35
- </gomage_social>
36
- </updates>
37
- </layout>
38
- </frontend>
39
- <adminhtml>
40
- <events>
41
- <admin_system_config_changed_section_gomage_social>
42
  <observers>
43
- <gomage_social_changed>
44
  <class>gomage_social/observer</class>
45
  <method>saveConfig</method>
46
  </gomage_social_changed>
@@ -55,13 +55,13 @@
55
  </observers>
56
  </controller_action_predispatch>
57
  </events>
58
- </adminhtml>
59
- <global>
60
- <blocks>
61
- <gomage_social>
62
- <class>GoMage_Social_Block</class>
63
- </gomage_social>
64
- </blocks>
65
  <events>
66
  <customer_login>
67
  <observers>
@@ -73,77 +73,81 @@
73
  </observers>
74
  </customer_login>
75
  </events>
76
- <models>
77
- <gomage_social>
78
- <class>GoMage_Social_Model</class>
79
- <resourceModel>gomage_social_mysql4</resourceModel>
80
- </gomage_social>
81
- <gomage_social_mysql4>
82
- <class>GoMage_Social_Model_Mysql4</class>
83
- <entities>
84
- <entity>
85
- <table>gomage_social_entity</table>
86
- </entity>
87
- </entities>
88
- </gomage_social_mysql4>
89
- </models>
90
- <resources>
91
- <gomage_social_setup>
92
- <setup>
93
- <module>GoMage_Social</module>
94
- </setup>
95
- <connection>
96
- <use>core_setup</use>
97
- </connection>
98
- </gomage_social_setup>
99
- <gomage_social_write>
100
- <connection>
101
- <use>core_write</use>
102
- </connection>
103
- </gomage_social_write>
104
- <gomage_social_read>
105
- <connection>
106
- <use>core_read</use>
107
- </connection>
108
- </gomage_social_read>
109
- </resources>
110
- <helpers>
111
- <gomage_social>
112
- <class>GoMage_Social_Helper</class>
113
- </gomage_social>
114
- </helpers>
115
- </global>
116
- <crontab>
117
  <jobs>
118
- <gomage_social_information>
119
- <schedule><cron_expr>0 2 10 * *</cron_expr></schedule>
120
- <run><model>gomage_social/observer::saveConfig</model></run>
121
- </gomage_social_information>
 
 
 
 
122
  </jobs>
123
- </crontab>
124
- <default>
125
- <gomage_social>
126
- <facebook>
127
- <fast_links_type>1</fast_links_type>
128
- <login_type>1</login_type>
129
- <checkout_type>1</checkout_type>
130
- <text>Login with Facebook</text>
131
- <order>1</order>
132
- </facebook>
133
- <linkedin>
134
- <fast_links_type>1</fast_links_type>
135
- <login_type>1</login_type>
136
- <checkout_type>1</checkout_type>
137
- <text>Login with LinkedIn</text>
138
- <order>2</order>
139
- </linkedin>
140
- <google>
141
- <fast_links_type>1</fast_links_type>
142
- <login_type>1</login_type>
143
- <checkout_type>1</checkout_type>
144
- <text>Login with Google</text>
145
- <order>3</order>
146
- </google>
147
  <twitter>
148
  <fast_links_type>1</fast_links_type>
149
  <login_type>1</login_type>
@@ -165,20 +169,27 @@
165
  <text>Login with Reddit</text>
166
  <order>6</order>
167
  </reddit>
168
- <amazon>
169
  <fast_links_type>1</fast_links_type>
170
  <login_type>1</login_type>
171
  <checkout_type>1</checkout_type>
172
  <text>Login with Amazon</text>
173
  <order>7</order>
174
  </amazon>
175
- <information>
176
- <text>
177
- <![CDATA[<h2>GoMage Extensions</h2>
 
 
 
 
 
 
 
178
  <p><a href="http://www.gomage.com/extensions/gomage-lightcheckout.html"><img title="GoMage LightCheckout - only one step on the checkout page" src="http://www.gomage.com/media/magentoconnect_image/lightcheckout.png" alt="GoMage LightCheckout" /></a> <a href="http://www.gomage.com/extensions/gomage-feed-pro.html"><img title="GoMage Feed Pro - send your product data to all Search Engines you know" src="http://www.gomage.com/media/magentoconnect_image/feed_pro.png" alt="GoMage Feed Pro" /></a> <a href="http://www.gomage.com/extensions/gomage-advanced-navigation.html"><img title="GoMage Advanced Navigation - helps you to optimize and improve navigation on your site" src="http://www.gomage.com/media/magentoconnect_image/advanced_navigation.png" alt="GoMage Advanced Navigation" /></a> <a href="http://www.gomage.com/extensions/promo.html"><img title="GoMage Ads &amp; Promo - simple, flexible, yet powerful solution for advertising and promoting your products" src="http://www.gomage.com/media/magentoconnect_image/ads_and_promo.png" alt="GoMage Ads &amp; Promo" /></a> <a href="http://www.gomage.com/extensions/procart.html"><img title="GoMage ProCart - allows your customers to add products to cart without page reloading or redirecting" src="http://www.gomage.com/media/magentoconnect_image/procart.png" alt="GoMage ProCart" /></a> <a href="http://www.gomage.com/extensions/gomage-sales-and-deals.html"><img title="GoMage Sales and Deals extension is all about providing the best deals for your customers" src="http://www.gomage.com/media/magentoconnect_image/sales_and_deals.png" alt="GoMage Sales and Deals" /></a> <a href="https://www.gomage.com/extensions/gomage-product-designer.html"><img title="GoMage Product Designer the superior extension for Magento which will help you to personalize the products using, cliparts, texts and uploading images" src="https://www.gomage.com/media/magentoconnect_image/product_designer.png" alt="GoMage Product Designer" /></a> <a href="https://www.gomage. com/extensions/gomage-seo-booster.html"><img title="The GoMage SEO Booster extension helps you improve the search engine optimization and the visibility of your store in the search engines' results without any technical knowledge" src="http://www.gomage.com/media/magentoconnect_image/seo_booster.png" alt="GoMage SEO Booster" /></a></p>]]>
179
- </text>
180
- </information>
181
- </gomage_social>
182
 
183
  <gomage_notification>
184
  <notification>
@@ -186,5 +197,5 @@
186
  </notification>
187
  </gomage_notification>
188
 
189
- </default>
190
  </config>
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
15
  <config>
16
+ <modules>
17
+ <GoMage_Social>
18
+ <version>1.4.0</version>
19
+ </GoMage_Social>
20
+ </modules>
21
+ <frontend>
22
+ <routers>
23
+ <gomage_social>
24
+ <use>standard</use>
25
+ <args>
26
+ <module>GoMage_Social</module>
27
+ <frontName>gomage_social</frontName>
28
+ </args>
29
+ </gomage_social>
30
+ </routers>
31
+ <layout>
32
+ <updates>
33
+ <gomage_social module="gomage_social">
34
+ <file>gomage-social.xml</file>
35
+ </gomage_social>
36
+ </updates>
37
+ </layout>
38
+ </frontend>
39
+ <adminhtml>
40
+ <events>
41
+ <admin_system_config_changed_section_gomage_social>
42
  <observers>
43
+ <gomage_social_changed>
44
  <class>gomage_social/observer</class>
45
  <method>saveConfig</method>
46
  </gomage_social_changed>
55
  </observers>
56
  </controller_action_predispatch>
57
  </events>
58
+ </adminhtml>
59
+ <global>
60
+ <blocks>
61
+ <gomage_social>
62
+ <class>GoMage_Social_Block</class>
63
+ </gomage_social>
64
+ </blocks>
65
  <events>
66
  <customer_login>
67
  <observers>
73
  </observers>
74
  </customer_login>
75
  </events>
76
+ <models>
77
+ <gomage_social>
78
+ <class>GoMage_Social_Model</class>
79
+ <resourceModel>gomage_social_mysql4</resourceModel>
80
+ </gomage_social>
81
+ <gomage_social_mysql4>
82
+ <class>GoMage_Social_Model_Mysql4</class>
83
+ <entities>
84
+ <entity>
85
+ <table>gomage_social_entity</table>
86
+ </entity>
87
+ </entities>
88
+ </gomage_social_mysql4>
89
+ </models>
90
+ <resources>
91
+ <gomage_social_setup>
92
+ <setup>
93
+ <module>GoMage_Social</module>
94
+ </setup>
95
+ <connection>
96
+ <use>core_setup</use>
97
+ </connection>
98
+ </gomage_social_setup>
99
+ <gomage_social_write>
100
+ <connection>
101
+ <use>core_write</use>
102
+ </connection>
103
+ </gomage_social_write>
104
+ <gomage_social_read>
105
+ <connection>
106
+ <use>core_read</use>
107
+ </connection>
108
+ </gomage_social_read>
109
+ </resources>
110
+ <helpers>
111
+ <gomage_social>
112
+ <class>GoMage_Social_Helper</class>
113
+ </gomage_social>
114
+ </helpers>
115
+ </global>
116
+ <crontab>
117
  <jobs>
118
+ <gomage_social_information>
119
+ <schedule>
120
+ <cron_expr>0 2 10 * *</cron_expr>
121
+ </schedule>
122
+ <run>
123
+ <model>gomage_social/observer::saveConfig</model>
124
+ </run>
125
+ </gomage_social_information>
126
  </jobs>
127
+ </crontab>
128
+ <default>
129
+ <gomage_social>
130
+ <facebook>
131
+ <fast_links_type>1</fast_links_type>
132
+ <login_type>1</login_type>
133
+ <checkout_type>1</checkout_type>
134
+ <text>Login with Facebook</text>
135
+ <order>1</order>
136
+ </facebook>
137
+ <linkedin>
138
+ <fast_links_type>1</fast_links_type>
139
+ <login_type>1</login_type>
140
+ <checkout_type>1</checkout_type>
141
+ <text>Login with LinkedIn</text>
142
+ <order>2</order>
143
+ </linkedin>
144
+ <google>
145
+ <fast_links_type>1</fast_links_type>
146
+ <login_type>1</login_type>
147
+ <checkout_type>1</checkout_type>
148
+ <text>Login with Google</text>
149
+ <order>3</order>
150
+ </google>
151
  <twitter>
152
  <fast_links_type>1</fast_links_type>
153
  <login_type>1</login_type>
169
  <text>Login with Reddit</text>
170
  <order>6</order>
171
  </reddit>
172
+ <amazon>
173
  <fast_links_type>1</fast_links_type>
174
  <login_type>1</login_type>
175
  <checkout_type>1</checkout_type>
176
  <text>Login with Amazon</text>
177
  <order>7</order>
178
  </amazon>
179
+ <instagram>
180
+ <fast_links_type>1</fast_links_type>
181
+ <login_type>1</login_type>
182
+ <checkout_type>1</checkout_type>
183
+ <text>Login with Instagram</text>
184
+ <order>8</order>
185
+ </instagram>
186
+ <information>
187
+ <text>
188
+ <![CDATA[<h2>GoMage Extensions</h2>
189
  <p><a href="http://www.gomage.com/extensions/gomage-lightcheckout.html"><img title="GoMage LightCheckout - only one step on the checkout page" src="http://www.gomage.com/media/magentoconnect_image/lightcheckout.png" alt="GoMage LightCheckout" /></a> <a href="http://www.gomage.com/extensions/gomage-feed-pro.html"><img title="GoMage Feed Pro - send your product data to all Search Engines you know" src="http://www.gomage.com/media/magentoconnect_image/feed_pro.png" alt="GoMage Feed Pro" /></a> <a href="http://www.gomage.com/extensions/gomage-advanced-navigation.html"><img title="GoMage Advanced Navigation - helps you to optimize and improve navigation on your site" src="http://www.gomage.com/media/magentoconnect_image/advanced_navigation.png" alt="GoMage Advanced Navigation" /></a> <a href="http://www.gomage.com/extensions/promo.html"><img title="GoMage Ads &amp; Promo - simple, flexible, yet powerful solution for advertising and promoting your products" src="http://www.gomage.com/media/magentoconnect_image/ads_and_promo.png" alt="GoMage Ads &amp; Promo" /></a> <a href="http://www.gomage.com/extensions/procart.html"><img title="GoMage ProCart - allows your customers to add products to cart without page reloading or redirecting" src="http://www.gomage.com/media/magentoconnect_image/procart.png" alt="GoMage ProCart" /></a> <a href="http://www.gomage.com/extensions/gomage-sales-and-deals.html"><img title="GoMage Sales and Deals extension is all about providing the best deals for your customers" src="http://www.gomage.com/media/magentoconnect_image/sales_and_deals.png" alt="GoMage Sales and Deals" /></a> <a href="https://www.gomage.com/extensions/gomage-product-designer.html"><img title="GoMage Product Designer the superior extension for Magento which will help you to personalize the products using, cliparts, texts and uploading images" src="https://www.gomage.com/media/magentoconnect_image/product_designer.png" alt="GoMage Product Designer" /></a> <a href="https://www.gomage. com/extensions/gomage-seo-booster.html"><img title="The GoMage SEO Booster extension helps you improve the search engine optimization and the visibility of your store in the search engines' results without any technical knowledge" src="http://www.gomage.com/media/magentoconnect_image/seo_booster.png" alt="GoMage SEO Booster" /></a></p>]]>
190
+ </text>
191
+ </information>
192
+ </gomage_social>
193
 
194
  <gomage_notification>
195
  <notification>
197
  </notification>
198
  </gomage_notification>
199
 
200
+ </default>
201
  </config>
app/code/local/GoMage/Social/etc/system.xml CHANGED
@@ -8,376 +8,379 @@
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
- * @version Release: 1.3.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
15
  <config>
16
- <tabs>
17
- <gomage translate="label">
18
- <label>GoMage</label>
19
- <sort_order>200</sort_order>
20
- </gomage>
21
- </tabs>
22
- <sections>
23
- <gomage_social>
24
- <label>Social Connector v.1.3</label>
25
- <tab>gomage</tab>
26
- <frontend_type>text</frontend_type>
27
- <sort_order>250</sort_order>
28
- <show_in_default>1</show_in_default>
29
- <show_in_website>1</show_in_website>
30
- <show_in_store>1</show_in_store>
31
- <groups>
32
- <information translate="label">
33
- <label>GoMage Advertisment</label>
34
- <frontend_type>text</frontend_type>
35
- <frontend_model>gomage_social/adminhtml_system_config_fieldset_information</frontend_model>
36
- <sort_order>1</sort_order>
37
- <show_in_default>1</show_in_default>
38
- <show_in_website>1</show_in_website>
39
- <show_in_store>1</show_in_store>
40
- </information>
41
- <general translate="label">
42
- <label>General</label>
43
- <frontend_type>text</frontend_type>
44
- <frontend_model>gomage_social/adminhtml_system_config_fieldset_general</frontend_model>
45
- <sort_order>5</sort_order>
46
- <show_in_default>1</show_in_default>
47
- <show_in_website>1</show_in_website>
48
- <show_in_store>1</show_in_store>
49
- <fields>
50
- <enable>
51
- <label>Enable Social Connector</label>
52
- <frontend_type>select</frontend_type>
53
- <source_model>adminhtml/system_config_source_yesno</source_model>
54
- <sort_order>10</sort_order>
55
- <show_in_default>1</show_in_default>
56
- <show_in_website>1</show_in_website>
57
- <show_in_store>1</show_in_store>
58
- </enable>
59
- <fast_links>
60
- <label>Show in Fast Links</label>
61
- <frontend_type>multiselect</frontend_type>
62
- <source_model>gomage_social/adminhtml_system_config_source_services</source_model>
63
- <sort_order>15</sort_order>
64
- <show_in_default>1</show_in_default>
65
- <show_in_website>1</show_in_website>
66
- <show_in_store>1</show_in_store>
67
- </fast_links>
68
- <login>
69
- <label>Show on Login Page</label>
70
- <frontend_type>multiselect</frontend_type>
71
- <source_model>gomage_social/adminhtml_system_config_source_services</source_model>
72
- <sort_order>20</sort_order>
73
- <show_in_default>1</show_in_default>
74
- <show_in_website>1</show_in_website>
75
- <show_in_store>1</show_in_store>
76
- </login>
77
- <checkout>
78
- <label>Show On Checkout Page</label>
79
- <frontend_type>multiselect</frontend_type>
80
- <source_model>gomage_social/adminhtml_system_config_source_services</source_model>
81
- <sort_order>25</sort_order>
82
- <show_in_default>1</show_in_default>
83
- <show_in_website>1</show_in_website>
84
- <show_in_store>1</show_in_store>
85
- </checkout>
86
- </fields>
87
- </general>
88
- <facebook translate="label">
89
- <label>Facebook</label>
90
- <frontend_type>text</frontend_type>
91
- <sort_order>10</sort_order>
92
- <show_in_default>1</show_in_default>
93
- <show_in_website>1</show_in_website>
94
- <show_in_store>1</show_in_store>
95
- <fields>
96
- <enable>
97
- <label>Enable</label>
98
- <frontend_type>select</frontend_type>
99
- <source_model>adminhtml/system_config_source_yesno</source_model>
100
- <sort_order>10</sort_order>
101
- <show_in_default>1</show_in_default>
102
- <show_in_website>1</show_in_website>
103
- <show_in_store>1</show_in_store>
104
- </enable>
105
- <id>
106
- <label>Application API</label>
107
- <frontend_type>text</frontend_type>
108
- <sort_order>20</sort_order>
109
- <show_in_default>1</show_in_default>
110
- <show_in_website>1</show_in_website>
111
- <show_in_store>1</show_in_store>
112
- </id>
113
- <secret>
114
- <label>Secret Key</label>
115
- <frontend_type>text</frontend_type>
116
- <sort_order>30</sort_order>
117
- <show_in_default>1</show_in_default>
118
- <show_in_website>1</show_in_website>
119
- <show_in_store>1</show_in_store>
120
- </secret>
121
- <fast_links_type>
122
- <label>Fast Links View</label>
123
- <frontend_type>select</frontend_type>
124
- <source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
125
- <sort_order>40</sort_order>
126
- <show_in_default>1</show_in_default>
127
- <show_in_website>1</show_in_website>
128
- <show_in_store>1</show_in_store>
129
- </fast_links_type>
130
- <login_type>
131
- <label>Login Page View</label>
132
- <frontend_type>select</frontend_type>
133
- <source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
134
- <sort_order>43</sort_order>
135
- <show_in_default>1</show_in_default>
136
- <show_in_website>1</show_in_website>
137
- <show_in_store>1</show_in_store>
138
- </login_type>
139
- <checkout_type>
140
- <label>Checkout View</label>
141
- <frontend_type>select</frontend_type>
142
- <source_model>gomage_social/adminhtml_system_config_source_login_type_facebook</source_model>
143
- <sort_order>46</sort_order>
144
- <show_in_default>1</show_in_default>
145
- <show_in_website>1</show_in_website>
146
- <show_in_store>1</show_in_store>
147
- </checkout_type>
148
- <image>
149
- <label>Login Image</label>
150
- <frontend_type>image</frontend_type>
151
- <backend_model>adminhtml/system_config_backend_image</backend_model>
152
- <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
153
- <base_url type="media" scope_info="1">gomage/social</base_url>
154
- <sort_order>50</sort_order>
155
- <show_in_default>1</show_in_default>
156
- <show_in_website>1</show_in_website>
157
- <show_in_store>1</show_in_store>
158
- </image>
159
- <text>
160
- <label>Login Text</label>
161
- <frontend_type>text</frontend_type>
162
- <sort_order>60</sort_order>
163
- <show_in_default>1</show_in_default>
164
- <show_in_website>1</show_in_website>
165
- <show_in_store>1</show_in_store>
166
- </text>
167
- <order>
168
- <label>Sort Order</label>
169
- <frontend_type>text</frontend_type>
170
- <sort_order>70</sort_order>
171
- <show_in_default>1</show_in_default>
172
- <show_in_website>1</show_in_website>
173
- <show_in_store>1</show_in_store>
174
- </order>
175
- </fields>
176
- </facebook>
177
- <linkedin translate="label">
178
- <label>LinkedIn</label>
179
- <frontend_type>text</frontend_type>
180
- <sort_order>20</sort_order>
181
- <show_in_default>1</show_in_default>
182
- <show_in_website>1</show_in_website>
183
- <show_in_store>1</show_in_store>
184
- <fields>
185
- <enable>
186
- <label>Enable</label>
187
- <frontend_type>select</frontend_type>
188
- <source_model>adminhtml/system_config_source_yesno</source_model>
189
- <sort_order>10</sort_order>
190
- <show_in_default>1</show_in_default>
191
- <show_in_website>1</show_in_website>
192
- <show_in_store>1</show_in_store>
193
- </enable>
194
- <redirect_uri>
195
- <label>Redirect Uri</label>
196
- <frontend_type>text</frontend_type>
197
- <frontend_model>gomage_social/adminhtml_system_config_redirectUri_linkedin</frontend_model>
198
- <sort_order>11</sort_order>
199
- <show_in_default>1</show_in_default>
200
- <show_in_website>1</show_in_website>
201
- <show_in_store>1</show_in_store>
202
- </redirect_uri>
203
- <id>
204
- <label>API Key</label>
205
- <frontend_type>text</frontend_type>
206
- <sort_order>20</sort_order>
207
- <show_in_default>1</show_in_default>
208
- <show_in_website>1</show_in_website>
209
- <show_in_store>1</show_in_store>
210
- </id>
211
- <secret>
212
- <label>Secret Key</label>
213
- <frontend_type>text</frontend_type>
214
- <sort_order>30</sort_order>
215
- <show_in_default>1</show_in_default>
216
- <show_in_website>1</show_in_website>
217
- <show_in_store>1</show_in_store>
218
- </secret>
219
- <fast_links_type>
220
- <label>Fast Links View</label>
221
- <frontend_type>select</frontend_type>
222
- <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
223
- <sort_order>40</sort_order>
224
- <show_in_default>1</show_in_default>
225
- <show_in_website>1</show_in_website>
226
- <show_in_store>1</show_in_store>
227
- </fast_links_type>
228
- <login_type>
229
- <label>Login Page View</label>
230
- <frontend_type>select</frontend_type>
231
- <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
232
- <sort_order>43</sort_order>
233
- <show_in_default>1</show_in_default>
234
- <show_in_website>1</show_in_website>
235
- <show_in_store>1</show_in_store>
236
- </login_type>
237
- <checkout_type>
238
- <label>Checkout View</label>
239
- <frontend_type>select</frontend_type>
240
- <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
241
- <sort_order>46</sort_order>
242
- <show_in_default>1</show_in_default>
243
- <show_in_website>1</show_in_website>
244
- <show_in_store>1</show_in_store>
245
- </checkout_type>
246
- <image>
247
- <label>Login Image</label>
248
- <frontend_type>image</frontend_type>
249
- <backend_model>adminhtml/system_config_backend_image</backend_model>
250
- <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
251
- <base_url type="media" scope_info="1">gomage/social</base_url>
252
- <sort_order>50</sort_order>
253
- <show_in_default>1</show_in_default>
254
- <show_in_website>1</show_in_website>
255
- <show_in_store>1</show_in_store>
256
- </image>
257
- <text>
258
- <label>Login Text</label>
259
- <frontend_type>text</frontend_type>
260
- <sort_order>60</sort_order>
261
- <show_in_default>1</show_in_default>
262
- <show_in_website>1</show_in_website>
263
- <show_in_store>1</show_in_store>
264
- </text>
265
- <order>
266
- <label>Sort Order</label>
267
- <frontend_type>text</frontend_type>
268
- <sort_order>70</sort_order>
269
- <show_in_default>1</show_in_default>
270
- <show_in_website>1</show_in_website>
271
- <show_in_store>1</show_in_store>
272
- </order>
273
- </fields>
274
- </linkedin>
275
- <google translate="label">
276
- <label>Google</label>
277
- <frontend_type>text</frontend_type>
278
- <sort_order>30</sort_order>
279
- <show_in_default>1</show_in_default>
280
- <show_in_website>1</show_in_website>
281
- <show_in_store>1</show_in_store>
282
- <fields>
283
- <enable>
284
- <label>Enable</label>
285
- <frontend_type>select</frontend_type>
286
- <source_model>adminhtml/system_config_source_yesno</source_model>
287
- <sort_order>10</sort_order>
288
- <show_in_default>1</show_in_default>
289
- <show_in_website>1</show_in_website>
290
- <show_in_store>1</show_in_store>
291
- </enable>
292
- <redirect_uri>
293
- <label>Redirect Uri</label>
294
- <frontend_type>text</frontend_type>
295
- <frontend_model>gomage_social/adminhtml_system_config_redirectUri_google</frontend_model>
296
- <sort_order>11</sort_order>
297
- <show_in_default>1</show_in_default>
298
- <show_in_website>1</show_in_website>
299
- <show_in_store>1</show_in_store>
300
- </redirect_uri>
301
- <id>
302
- <label>Client ID</label>
303
- <frontend_type>text</frontend_type>
304
- <sort_order>20</sort_order>
305
- <show_in_default>1</show_in_default>
306
- <show_in_website>1</show_in_website>
307
- <show_in_store>1</show_in_store>
308
- </id>
309
- <secret>
310
- <label>Client Secret</label>
311
- <frontend_type>text</frontend_type>
312
- <sort_order>30</sort_order>
313
- <show_in_default>1</show_in_default>
314
- <show_in_website>1</show_in_website>
315
- <show_in_store>1</show_in_store>
316
- </secret>
317
- <api>
318
- <label>API Key</label>
319
- <frontend_type>text</frontend_type>
320
- <sort_order>40</sort_order>
321
- <show_in_default>1</show_in_default>
322
- <show_in_website>1</show_in_website>
323
- <show_in_store>1</show_in_store>
324
- </api>
325
- <fast_links_type>
326
- <label>Fast Links View</label>
327
- <frontend_type>select</frontend_type>
328
- <source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
329
- <sort_order>50</sort_order>
330
- <show_in_default>1</show_in_default>
331
- <show_in_website>1</show_in_website>
332
- <show_in_store>1</show_in_store>
333
- </fast_links_type>
334
- <login_type>
335
- <label>Login Page View</label>
336
- <frontend_type>select</frontend_type>
337
- <source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
338
- <sort_order>53</sort_order>
339
- <show_in_default>1</show_in_default>
340
- <show_in_website>1</show_in_website>
341
- <show_in_store>1</show_in_store>
342
- </login_type>
343
- <checkout_type>
344
- <label>Checkout View</label>
345
- <frontend_type>select</frontend_type>
346
- <source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
347
- <sort_order>56</sort_order>
348
- <show_in_default>1</show_in_default>
349
- <show_in_website>1</show_in_website>
350
- <show_in_store>1</show_in_store>
351
- </checkout_type>
352
- <image>
353
- <label>Login Image</label>
354
- <frontend_type>image</frontend_type>
355
- <backend_model>adminhtml/system_config_backend_image</backend_model>
356
- <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
357
- <base_url type="media" scope_info="1">gomage/social</base_url>
358
- <sort_order>60</sort_order>
359
- <show_in_default>1</show_in_default>
360
- <show_in_website>1</show_in_website>
361
- <show_in_store>1</show_in_store>
362
- </image>
363
- <text>
364
- <label>Login Text</label>
365
- <frontend_type>text</frontend_type>
366
- <sort_order>70</sort_order>
367
- <show_in_default>1</show_in_default>
368
- <show_in_website>1</show_in_website>
369
- <show_in_store>1</show_in_store>
370
- </text>
371
- <order>
372
- <label>Sort Order</label>
373
- <frontend_type>text</frontend_type>
374
- <sort_order>80</sort_order>
375
- <show_in_default>1</show_in_default>
376
- <show_in_website>1</show_in_website>
377
- <show_in_store>1</show_in_store>
378
- </order>
379
- </fields>
380
- </google>
 
 
 
381
  <twitter translate="label">
382
  <label>Twitter</label>
383
  <frontend_type>text</frontend_type>
@@ -395,15 +398,15 @@
395
  <show_in_website>1</show_in_website>
396
  <show_in_store>1</show_in_store>
397
  </enable>
398
- <redirect_uri>
399
- <label>Redirect Uri</label>
400
- <frontend_type>text</frontend_type>
401
- <frontend_model>gomage_social/adminhtml_system_config_redirectUri_twitter</frontend_model>
402
- <sort_order>11</sort_order>
403
- <show_in_default>1</show_in_default>
404
- <show_in_website>1</show_in_website>
405
- <show_in_store>1</show_in_store>
406
- </redirect_uri>
407
  <id>
408
  <label>Application API</label>
409
  <frontend_type>text</frontend_type>
@@ -493,15 +496,15 @@
493
  <show_in_website>1</show_in_website>
494
  <show_in_store>1</show_in_store>
495
  </enable>
496
- <redirect_uri>
497
- <label>Redirect Uri</label>
498
- <frontend_type>text</frontend_type>
499
- <frontend_model>gomage_social/adminhtml_system_config_redirectUri_tumblr</frontend_model>
500
- <sort_order>11</sort_order>
501
- <show_in_default>1</show_in_default>
502
- <show_in_website>1</show_in_website>
503
- <show_in_store>1</show_in_store>
504
- </redirect_uri>
505
  <id>
506
  <label>Application API</label>
507
  <frontend_type>text</frontend_type>
@@ -591,15 +594,15 @@
591
  <show_in_website>1</show_in_website>
592
  <show_in_store>1</show_in_store>
593
  </enable>
594
- <redirect_uri>
595
- <label>Redirect Uri</label>
596
- <frontend_type>text</frontend_type>
597
- <frontend_model>gomage_social/adminhtml_system_config_redirectUri_reddit</frontend_model>
598
- <sort_order>11</sort_order>
599
- <show_in_default>1</show_in_default>
600
- <show_in_website>1</show_in_website>
601
- <show_in_store>1</show_in_store>
602
- </redirect_uri>
603
  <id>
604
  <label>Application API</label>
605
  <frontend_type>text</frontend_type>
@@ -672,109 +675,207 @@
672
  </order>
673
  </fields>
674
  </reddit>
675
- <amazon translate="label">
676
- <label>Amazon</label>
677
- <frontend_type>text</frontend_type>
678
- <sort_order>70</sort_order>
679
- <show_in_default>1</show_in_default>
680
- <show_in_website>1</show_in_website>
681
- <show_in_store>1</show_in_store>
682
- <fields>
683
- <enable>
684
- <label>Enable</label>
685
- <frontend_type>select</frontend_type>
686
- <source_model>adminhtml/system_config_source_yesno</source_model>
687
- <comment>
688
- <![CDATA[Amazon uses the HTTPS protocol to access the system authorization. Please keep this in mind when registering and configuring applications.]]>
689
- </comment>
690
- <sort_order>10</sort_order>
691
- <show_in_default>1</show_in_default>
692
- <show_in_website>1</show_in_website>
693
- <show_in_store>1</show_in_store>
694
- </enable>
695
- <redirect_uri>
696
- <label>Redirect Uri</label>
697
- <frontend_type>text</frontend_type>
698
- <frontend_model>gomage_social/adminhtml_system_config_redirectUri_amazon</frontend_model>
699
- <sort_order>11</sort_order>
700
- <show_in_default>1</show_in_default>
701
- <show_in_website>1</show_in_website>
702
- <show_in_store>1</show_in_store>
703
- </redirect_uri>
704
- <id>
705
- <label>Client ID</label>
706
- <frontend_type>text</frontend_type>
707
- <sort_order>20</sort_order>
708
- <show_in_default>1</show_in_default>
709
- <show_in_website>1</show_in_website>
710
- <show_in_store>1</show_in_store>
711
- </id>
712
- <secret>
713
- <label>Client Secret</label>
714
- <frontend_type>text</frontend_type>
715
- <sort_order>30</sort_order>
716
- <show_in_default>1</show_in_default>
717
- <show_in_website>1</show_in_website>
718
- <show_in_store>1</show_in_store>
719
- </secret>
720
- <fast_links_type>
721
- <label>Fast Links View</label>
722
- <frontend_type>select</frontend_type>
723
- <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
724
- <sort_order>40</sort_order>
725
- <show_in_default>1</show_in_default>
726
- <show_in_website>1</show_in_website>
727
- <show_in_store>1</show_in_store>
728
- </fast_links_type>
729
- <login_type>
730
- <label>Login Page View</label>
731
- <frontend_type>select</frontend_type>
732
- <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
733
- <sort_order>43</sort_order>
734
- <show_in_default>1</show_in_default>
735
- <show_in_website>1</show_in_website>
736
- <show_in_store>1</show_in_store>
737
- </login_type>
738
- <checkout_type>
739
- <label>Checkout View</label>
740
- <frontend_type>select</frontend_type>
741
- <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
742
- <sort_order>46</sort_order>
743
- <show_in_default>1</show_in_default>
744
- <show_in_website>1</show_in_website>
745
- <show_in_store>1</show_in_store>
746
- </checkout_type>
747
- <image>
748
- <label>Login Image</label>
749
- <frontend_type>image</frontend_type>
750
- <backend_model>adminhtml/system_config_backend_image</backend_model>
751
- <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
752
- <base_url type="media" scope_info="1">gomage/social</base_url>
753
- <sort_order>50</sort_order>
754
- <show_in_default>1</show_in_default>
755
- <show_in_website>1</show_in_website>
756
- <show_in_store>1</show_in_store>
757
- </image>
758
- <text>
759
- <label>Login Text</label>
760
- <frontend_type>text</frontend_type>
761
- <sort_order>60</sort_order>
762
- <show_in_default>1</show_in_default>
763
- <show_in_website>1</show_in_website>
764
- <show_in_store>1</show_in_store>
765
- </text>
766
- <order>
767
- <label>Sort Order</label>
768
- <frontend_type>text</frontend_type>
769
- <sort_order>70</sort_order>
770
- <show_in_default>1</show_in_default>
771
- <show_in_website>1</show_in_website>
772
- <show_in_store>1</show_in_store>
773
- </order>
774
- </fields>
775
- </amazon>
776
- </groups>
777
- </gomage_social>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  <gomage_notification>
779
  <label>Notifications</label>
780
  <tab>gomage</tab>
@@ -805,5 +906,5 @@
805
  </notification>
806
  </groups>
807
  </gomage_notification>
808
- </sections>
809
  </config>
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
15
  <config>
16
+ <tabs>
17
+ <gomage translate="label">
18
+ <label>GoMage</label>
19
+ <sort_order>200</sort_order>
20
+ </gomage>
21
+ </tabs>
22
+ <sections>
23
+ <gomage_social>
24
+ <label>Social Connector v.1.4</label>
25
+ <tab>gomage</tab>
26
+ <frontend_type>text</frontend_type>
27
+ <sort_order>250</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <groups>
32
+ <information translate="label">
33
+ <label>GoMage Advertisment</label>
34
+ <frontend_type>text</frontend_type>
35
+ <frontend_model>gomage_social/adminhtml_system_config_fieldset_information</frontend_model>
36
+ <sort_order>1</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ </information>
41
+ <general translate="label">
42
+ <label>General</label>
43
+ <frontend_type>text</frontend_type>
44
+ <frontend_model>gomage_social/adminhtml_system_config_fieldset_general</frontend_model>
45
+ <sort_order>5</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <fields>
50
+ <enable>
51
+ <label>Enable Social Connector</label>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>adminhtml/system_config_source_yesno</source_model>
54
+ <sort_order>10</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </enable>
59
+ <fast_links>
60
+ <label>Show in Fast Links</label>
61
+ <frontend_type>multiselect</frontend_type>
62
+ <source_model>gomage_social/adminhtml_system_config_source_services</source_model>
63
+ <sort_order>15</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </fast_links>
68
+ <login>
69
+ <label>Show on Login Page</label>
70
+ <frontend_type>multiselect</frontend_type>
71
+ <source_model>gomage_social/adminhtml_system_config_source_services</source_model>
72
+ <sort_order>20</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </login>
77
+ <checkout>
78
+ <label>Show On Checkout Page</label>
79
+ <frontend_type>multiselect</frontend_type>
80
+ <source_model>gomage_social/adminhtml_system_config_source_services</source_model>
81
+ <sort_order>25</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ </checkout>
86
+ </fields>
87
+ </general>
88
+ <facebook translate="label">
89
+ <label>Facebook</label>
90
+ <frontend_type>text</frontend_type>
91
+ <sort_order>10</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ <fields>
96
+ <enable>
97
+ <label>Enable</label>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>adminhtml/system_config_source_yesno</source_model>
100
+ <sort_order>10</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </enable>
105
+ <id>
106
+ <label>Application API</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>20</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>1</show_in_store>
112
+ </id>
113
+ <secret>
114
+ <label>Secret Key</label>
115
+ <frontend_type>text</frontend_type>
116
+ <sort_order>30</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </secret>
121
+ <fast_links_type>
122
+ <label>Fast Links View</label>
123
+ <frontend_type>select</frontend_type>
124
+ <source_model>gomage_social/adminhtml_system_config_source_login_type_facebook
125
+ </source_model>
126
+ <sort_order>40</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>1</show_in_store>
130
+ </fast_links_type>
131
+ <login_type>
132
+ <label>Login Page View</label>
133
+ <frontend_type>select</frontend_type>
134
+ <source_model>gomage_social/adminhtml_system_config_source_login_type_facebook
135
+ </source_model>
136
+ <sort_order>43</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ </login_type>
141
+ <checkout_type>
142
+ <label>Checkout View</label>
143
+ <frontend_type>select</frontend_type>
144
+ <source_model>gomage_social/adminhtml_system_config_source_login_type_facebook
145
+ </source_model>
146
+ <sort_order>46</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>1</show_in_store>
150
+ </checkout_type>
151
+ <image>
152
+ <label>Login Image</label>
153
+ <frontend_type>image</frontend_type>
154
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
155
+ <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
156
+ <base_url type="media" scope_info="1">gomage/social</base_url>
157
+ <sort_order>50</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>1</show_in_store>
161
+ </image>
162
+ <text>
163
+ <label>Login Text</label>
164
+ <frontend_type>text</frontend_type>
165
+ <sort_order>60</sort_order>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>1</show_in_store>
169
+ </text>
170
+ <order>
171
+ <label>Sort Order</label>
172
+ <frontend_type>text</frontend_type>
173
+ <sort_order>70</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </order>
178
+ </fields>
179
+ </facebook>
180
+ <linkedin translate="label">
181
+ <label>LinkedIn</label>
182
+ <frontend_type>text</frontend_type>
183
+ <sort_order>20</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ <fields>
188
+ <enable>
189
+ <label>Enable</label>
190
+ <frontend_type>select</frontend_type>
191
+ <source_model>adminhtml/system_config_source_yesno</source_model>
192
+ <sort_order>10</sort_order>
193
+ <show_in_default>1</show_in_default>
194
+ <show_in_website>1</show_in_website>
195
+ <show_in_store>1</show_in_store>
196
+ </enable>
197
+ <redirect_uri>
198
+ <label>Redirect Uri</label>
199
+ <frontend_type>text</frontend_type>
200
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_linkedin</frontend_model>
201
+ <sort_order>11</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ </redirect_uri>
206
+ <id>
207
+ <label>API Key</label>
208
+ <frontend_type>text</frontend_type>
209
+ <sort_order>20</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>1</show_in_store>
213
+ </id>
214
+ <secret>
215
+ <label>Secret Key</label>
216
+ <frontend_type>text</frontend_type>
217
+ <sort_order>30</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ </secret>
222
+ <fast_links_type>
223
+ <label>Fast Links View</label>
224
+ <frontend_type>select</frontend_type>
225
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
226
+ <sort_order>40</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ </fast_links_type>
231
+ <login_type>
232
+ <label>Login Page View</label>
233
+ <frontend_type>select</frontend_type>
234
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
235
+ <sort_order>43</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </login_type>
240
+ <checkout_type>
241
+ <label>Checkout View</label>
242
+ <frontend_type>select</frontend_type>
243
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
244
+ <sort_order>46</sort_order>
245
+ <show_in_default>1</show_in_default>
246
+ <show_in_website>1</show_in_website>
247
+ <show_in_store>1</show_in_store>
248
+ </checkout_type>
249
+ <image>
250
+ <label>Login Image</label>
251
+ <frontend_type>image</frontend_type>
252
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
253
+ <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
254
+ <base_url type="media" scope_info="1">gomage/social</base_url>
255
+ <sort_order>50</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>1</show_in_store>
259
+ </image>
260
+ <text>
261
+ <label>Login Text</label>
262
+ <frontend_type>text</frontend_type>
263
+ <sort_order>60</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>1</show_in_store>
267
+ </text>
268
+ <order>
269
+ <label>Sort Order</label>
270
+ <frontend_type>text</frontend_type>
271
+ <sort_order>70</sort_order>
272
+ <show_in_default>1</show_in_default>
273
+ <show_in_website>1</show_in_website>
274
+ <show_in_store>1</show_in_store>
275
+ </order>
276
+ </fields>
277
+ </linkedin>
278
+ <google translate="label">
279
+ <label>Google</label>
280
+ <frontend_type>text</frontend_type>
281
+ <sort_order>30</sort_order>
282
+ <show_in_default>1</show_in_default>
283
+ <show_in_website>1</show_in_website>
284
+ <show_in_store>1</show_in_store>
285
+ <fields>
286
+ <enable>
287
+ <label>Enable</label>
288
+ <frontend_type>select</frontend_type>
289
+ <source_model>adminhtml/system_config_source_yesno</source_model>
290
+ <sort_order>10</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ </enable>
295
+ <redirect_uri>
296
+ <label>Redirect Uri</label>
297
+ <frontend_type>text</frontend_type>
298
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_google</frontend_model>
299
+ <sort_order>11</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>1</show_in_store>
303
+ </redirect_uri>
304
+ <id>
305
+ <label>Client ID</label>
306
+ <frontend_type>text</frontend_type>
307
+ <sort_order>20</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>1</show_in_store>
311
+ </id>
312
+ <secret>
313
+ <label>Client Secret</label>
314
+ <frontend_type>text</frontend_type>
315
+ <sort_order>30</sort_order>
316
+ <show_in_default>1</show_in_default>
317
+ <show_in_website>1</show_in_website>
318
+ <show_in_store>1</show_in_store>
319
+ </secret>
320
+ <api>
321
+ <label>API Key</label>
322
+ <frontend_type>text</frontend_type>
323
+ <sort_order>40</sort_order>
324
+ <show_in_default>1</show_in_default>
325
+ <show_in_website>1</show_in_website>
326
+ <show_in_store>1</show_in_store>
327
+ </api>
328
+ <fast_links_type>
329
+ <label>Fast Links View</label>
330
+ <frontend_type>select</frontend_type>
331
+ <source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
332
+ <sort_order>50</sort_order>
333
+ <show_in_default>1</show_in_default>
334
+ <show_in_website>1</show_in_website>
335
+ <show_in_store>1</show_in_store>
336
+ </fast_links_type>
337
+ <login_type>
338
+ <label>Login Page View</label>
339
+ <frontend_type>select</frontend_type>
340
+ <source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
341
+ <sort_order>53</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_website>1</show_in_website>
344
+ <show_in_store>1</show_in_store>
345
+ </login_type>
346
+ <checkout_type>
347
+ <label>Checkout View</label>
348
+ <frontend_type>select</frontend_type>
349
+ <source_model>gomage_social/adminhtml_system_config_source_login_type_google</source_model>
350
+ <sort_order>56</sort_order>
351
+ <show_in_default>1</show_in_default>
352
+ <show_in_website>1</show_in_website>
353
+ <show_in_store>1</show_in_store>
354
+ </checkout_type>
355
+ <image>
356
+ <label>Login Image</label>
357
+ <frontend_type>image</frontend_type>
358
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
359
+ <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
360
+ <base_url type="media" scope_info="1">gomage/social</base_url>
361
+ <sort_order>60</sort_order>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>1</show_in_website>
364
+ <show_in_store>1</show_in_store>
365
+ </image>
366
+ <text>
367
+ <label>Login Text</label>
368
+ <frontend_type>text</frontend_type>
369
+ <sort_order>70</sort_order>
370
+ <show_in_default>1</show_in_default>
371
+ <show_in_website>1</show_in_website>
372
+ <show_in_store>1</show_in_store>
373
+ </text>
374
+ <order>
375
+ <label>Sort Order</label>
376
+ <frontend_type>text</frontend_type>
377
+ <sort_order>80</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>1</show_in_store>
381
+ </order>
382
+ </fields>
383
+ </google>
384
  <twitter translate="label">
385
  <label>Twitter</label>
386
  <frontend_type>text</frontend_type>
398
  <show_in_website>1</show_in_website>
399
  <show_in_store>1</show_in_store>
400
  </enable>
401
+ <redirect_uri>
402
+ <label>Redirect Uri</label>
403
+ <frontend_type>text</frontend_type>
404
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_twitter</frontend_model>
405
+ <sort_order>11</sort_order>
406
+ <show_in_default>1</show_in_default>
407
+ <show_in_website>1</show_in_website>
408
+ <show_in_store>1</show_in_store>
409
+ </redirect_uri>
410
  <id>
411
  <label>Application API</label>
412
  <frontend_type>text</frontend_type>
496
  <show_in_website>1</show_in_website>
497
  <show_in_store>1</show_in_store>
498
  </enable>
499
+ <redirect_uri>
500
+ <label>Redirect Uri</label>
501
+ <frontend_type>text</frontend_type>
502
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_tumblr</frontend_model>
503
+ <sort_order>11</sort_order>
504
+ <show_in_default>1</show_in_default>
505
+ <show_in_website>1</show_in_website>
506
+ <show_in_store>1</show_in_store>
507
+ </redirect_uri>
508
  <id>
509
  <label>Application API</label>
510
  <frontend_type>text</frontend_type>
594
  <show_in_website>1</show_in_website>
595
  <show_in_store>1</show_in_store>
596
  </enable>
597
+ <redirect_uri>
598
+ <label>Redirect Uri</label>
599
+ <frontend_type>text</frontend_type>
600
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_reddit</frontend_model>
601
+ <sort_order>11</sort_order>
602
+ <show_in_default>1</show_in_default>
603
+ <show_in_website>1</show_in_website>
604
+ <show_in_store>1</show_in_store>
605
+ </redirect_uri>
606
  <id>
607
  <label>Application API</label>
608
  <frontend_type>text</frontend_type>
675
  </order>
676
  </fields>
677
  </reddit>
678
+ <amazon translate="label">
679
+ <label>Amazon</label>
680
+ <frontend_type>text</frontend_type>
681
+ <sort_order>70</sort_order>
682
+ <show_in_default>1</show_in_default>
683
+ <show_in_website>1</show_in_website>
684
+ <show_in_store>1</show_in_store>
685
+ <fields>
686
+ <enable>
687
+ <label>Enable</label>
688
+ <frontend_type>select</frontend_type>
689
+ <source_model>adminhtml/system_config_source_yesno</source_model>
690
+ <comment>
691
+ <![CDATA[Amazon uses the HTTPS protocol to access the system authorization. Please keep this in mind when registering and configuring applications.]]>
692
+ </comment>
693
+ <sort_order>10</sort_order>
694
+ <show_in_default>1</show_in_default>
695
+ <show_in_website>1</show_in_website>
696
+ <show_in_store>1</show_in_store>
697
+ </enable>
698
+ <redirect_uri>
699
+ <label>Redirect Uri</label>
700
+ <frontend_type>text</frontend_type>
701
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_amazon</frontend_model>
702
+ <sort_order>11</sort_order>
703
+ <show_in_default>1</show_in_default>
704
+ <show_in_website>1</show_in_website>
705
+ <show_in_store>1</show_in_store>
706
+ </redirect_uri>
707
+ <id>
708
+ <label>Client ID</label>
709
+ <frontend_type>text</frontend_type>
710
+ <sort_order>20</sort_order>
711
+ <show_in_default>1</show_in_default>
712
+ <show_in_website>1</show_in_website>
713
+ <show_in_store>1</show_in_store>
714
+ </id>
715
+ <secret>
716
+ <label>Client Secret</label>
717
+ <frontend_type>text</frontend_type>
718
+ <sort_order>30</sort_order>
719
+ <show_in_default>1</show_in_default>
720
+ <show_in_website>1</show_in_website>
721
+ <show_in_store>1</show_in_store>
722
+ </secret>
723
+ <fast_links_type>
724
+ <label>Fast Links View</label>
725
+ <frontend_type>select</frontend_type>
726
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
727
+ <sort_order>40</sort_order>
728
+ <show_in_default>1</show_in_default>
729
+ <show_in_website>1</show_in_website>
730
+ <show_in_store>1</show_in_store>
731
+ </fast_links_type>
732
+ <login_type>
733
+ <label>Login Page View</label>
734
+ <frontend_type>select</frontend_type>
735
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
736
+ <sort_order>43</sort_order>
737
+ <show_in_default>1</show_in_default>
738
+ <show_in_website>1</show_in_website>
739
+ <show_in_store>1</show_in_store>
740
+ </login_type>
741
+ <checkout_type>
742
+ <label>Checkout View</label>
743
+ <frontend_type>select</frontend_type>
744
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
745
+ <sort_order>46</sort_order>
746
+ <show_in_default>1</show_in_default>
747
+ <show_in_website>1</show_in_website>
748
+ <show_in_store>1</show_in_store>
749
+ </checkout_type>
750
+ <image>
751
+ <label>Login Image</label>
752
+ <frontend_type>image</frontend_type>
753
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
754
+ <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
755
+ <base_url type="media" scope_info="1">gomage/social</base_url>
756
+ <sort_order>50</sort_order>
757
+ <show_in_default>1</show_in_default>
758
+ <show_in_website>1</show_in_website>
759
+ <show_in_store>1</show_in_store>
760
+ </image>
761
+ <text>
762
+ <label>Login Text</label>
763
+ <frontend_type>text</frontend_type>
764
+ <sort_order>60</sort_order>
765
+ <show_in_default>1</show_in_default>
766
+ <show_in_website>1</show_in_website>
767
+ <show_in_store>1</show_in_store>
768
+ </text>
769
+ <order>
770
+ <label>Sort Order</label>
771
+ <frontend_type>text</frontend_type>
772
+ <sort_order>70</sort_order>
773
+ <show_in_default>1</show_in_default>
774
+ <show_in_website>1</show_in_website>
775
+ <show_in_store>1</show_in_store>
776
+ </order>
777
+ </fields>
778
+ </amazon>
779
+ <instagram translate="label">
780
+ <label>Instagram</label>
781
+ <frontend_type>text</frontend_type>
782
+ <sort_order>80</sort_order>
783
+ <show_in_default>1</show_in_default>
784
+ <show_in_website>1</show_in_website>
785
+ <show_in_store>1</show_in_store>
786
+ <fields>
787
+ <enable>
788
+ <label>Enable</label>
789
+ <frontend_type>select</frontend_type>
790
+ <source_model>adminhtml/system_config_source_yesno</source_model>
791
+ <sort_order>10</sort_order>
792
+ <show_in_default>1</show_in_default>
793
+ <show_in_website>1</show_in_website>
794
+ <show_in_store>1</show_in_store>
795
+ </enable>
796
+ <redirect_uri>
797
+ <label>Redirect Uri</label>
798
+ <frontend_type>text</frontend_type>
799
+ <frontend_model>gomage_social/adminhtml_system_config_redirectUri_instagram</frontend_model>
800
+ <sort_order>11</sort_order>
801
+ <show_in_default>1</show_in_default>
802
+ <show_in_website>1</show_in_website>
803
+ <show_in_store>1</show_in_store>
804
+ </redirect_uri>
805
+ <id>
806
+ <label>Client ID</label>
807
+ <frontend_type>text</frontend_type>
808
+ <sort_order>20</sort_order>
809
+ <show_in_default>1</show_in_default>
810
+ <show_in_website>1</show_in_website>
811
+ <show_in_store>1</show_in_store>
812
+ </id>
813
+ <secret>
814
+ <label>Client Secret</label>
815
+ <frontend_type>text</frontend_type>
816
+ <sort_order>30</sort_order>
817
+ <show_in_default>1</show_in_default>
818
+ <show_in_website>1</show_in_website>
819
+ <show_in_store>1</show_in_store>
820
+ </secret>
821
+ <fast_links_type>
822
+ <label>Fast Links View</label>
823
+ <frontend_type>select</frontend_type>
824
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
825
+ <sort_order>40</sort_order>
826
+ <show_in_default>1</show_in_default>
827
+ <show_in_website>1</show_in_website>
828
+ <show_in_store>1</show_in_store>
829
+ </fast_links_type>
830
+ <login_type>
831
+ <label>Login Page View</label>
832
+ <frontend_type>select</frontend_type>
833
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
834
+ <sort_order>43</sort_order>
835
+ <show_in_default>1</show_in_default>
836
+ <show_in_website>1</show_in_website>
837
+ <show_in_store>1</show_in_store>
838
+ </login_type>
839
+ <checkout_type>
840
+ <label>Checkout View</label>
841
+ <frontend_type>select</frontend_type>
842
+ <source_model>gomage_social/adminhtml_system_config_source_login_type</source_model>
843
+ <sort_order>46</sort_order>
844
+ <show_in_default>1</show_in_default>
845
+ <show_in_website>1</show_in_website>
846
+ <show_in_store>1</show_in_store>
847
+ </checkout_type>
848
+ <image>
849
+ <label>Login Image</label>
850
+ <frontend_type>image</frontend_type>
851
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
852
+ <upload_dir config="system/filesystem/media" scope_info="1">gomage/social</upload_dir>
853
+ <base_url type="media" scope_info="1">gomage/social</base_url>
854
+ <sort_order>50</sort_order>
855
+ <show_in_default>1</show_in_default>
856
+ <show_in_website>1</show_in_website>
857
+ <show_in_store>1</show_in_store>
858
+ </image>
859
+ <text>
860
+ <label>Login Text</label>
861
+ <frontend_type>text</frontend_type>
862
+ <sort_order>60</sort_order>
863
+ <show_in_default>1</show_in_default>
864
+ <show_in_website>1</show_in_website>
865
+ <show_in_store>1</show_in_store>
866
+ </text>
867
+ <order>
868
+ <label>Sort Order</label>
869
+ <frontend_type>text</frontend_type>
870
+ <sort_order>70</sort_order>
871
+ <show_in_default>1</show_in_default>
872
+ <show_in_website>1</show_in_website>
873
+ <show_in_store>1</show_in_store>
874
+ </order>
875
+ </fields>
876
+ </instagram>
877
+ </groups>
878
+ </gomage_social>
879
  <gomage_notification>
880
  <label>Notifications</label>
881
  <tab>gomage</tab>
906
  </notification>
907
  </groups>
908
  </gomage_notification>
909
+ </sections>
910
  </config>
app/design/frontend/base/default/layout/gomage-social.xml CHANGED
@@ -8,7 +8,7 @@
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
- * @version Release: 1.3.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
8
  * @author GoMage
9
  * @license http://www.gomage.com/license-agreement/ Single domain license
10
  * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
  * @since Class available since Release 1.0.0
13
  */
14
  -->
app/design/frontend/base/default/template/gomage/social/config.phtml CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
  ?>
@@ -160,60 +160,62 @@
160
  //]]>
161
  </script>
162
  <?php endif; ?>
163
-
164
-
165
- <?php if (Mage::getSingleton('core/session')->getGsProfile()) : ?>
166
- <?php if (Mage::getSingleton('core/session')->getGsProfile()->url) : ?>
167
- <script type="text/javascript">
168
- var GomageSocialClass = new GomageSocialClass ;
169
- </script>
170
-
171
- <div id="gs-popup-content" style="display:none;">
172
- <div id="gs-validate-detail">
173
- <form onsubmit="GomageSocialClass.sendEmail('<?php echo Mage::getSingleton('core/session')->getGsProfile()->url; ?>'); return false;" action="<?php echo Mage::getSingleton('core/session')->getGsProfile()->url; ?>" method="post" id="gs-form" >
174
- <ul class="form-list">
175
- <li>
176
- <label for="gs-email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
177
- <div class="input-box">
178
- <input type="text" name="email" value="" id="gs-email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
179
- </div>
180
- </li>
181
- <li>
182
- <div class="actions">
183
- <button type="submit" class="button validation-passed" ><span><span><?php echo $this->__('Login') ?></span></span></button>
184
- <span style="display: none;" id="gs-please-wait" class="please-wait">
185
- <img class="v-middle" title="<?php echo $this->__('Loading...') ?>" alt="<?php echo $this->__('Loading...') ?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" />
186
- </span>
187
- <div id="gs-message" ></div>
188
- </div>
189
- </li>
190
- </ul>
191
- </form>
192
- </div>
 
 
193
  </div>
194
-
195
- <script type="text/javascript">
196
- //<![CDATA[
197
- win = GomageSocialClass.createWindow("<?php echo __('Enter your email'); ?>", 300, 100);
198
- win.getContent().update($('gs-popup-content').innerHTML);
199
- win.showCenter();
200
-
201
- if (GomageSocialClass.overlay) {
202
- GomageSocialClass.overlay.show();
203
- }
204
-
205
- var gs_id_window = GomageSocialClass.id_window();
206
- $(gs_id_window.replace('_close','')).className = 'dialog dialog-gs';
207
-
208
- $(gs_id_window).onclick = function() {
209
- GomageSocialClass.unsGsProfile('<?php echo Mage::getSingleton('core/session')->getGsProfile()->urlEmailClose; ?>');
210
- window.parent.Windows.close(gs_id_window.replace('_close',''));
211
-
212
- if(GomageSocialClass.overlay){
213
- GomageSocialClass.overlay.hide();
214
- }
215
- }
216
- //]]>
217
- </script>
218
- <?php endif; ?>
219
  <?php endif; ?>
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
  ?>
160
  //]]>
161
  </script>
162
  <?php endif; ?>
163
+ <?php
164
+ if (
165
+ Mage::getSingleton('core/session')->getGsProfile() &&
166
+ isset(Mage::getSingleton('core/session')->getGsProfile()->id) &&
167
+ isset(Mage::getSingleton('core/session')->getGsProfile()->url_check_email)
168
+ ) :
169
+ ?>
170
+ <script type="text/javascript">
171
+ var GomageSocialClass = new GomageSocialClass ;
172
+ </script>
173
+
174
+ <div id="gs-popup-content" style="display:none;">
175
+ <div id="gs-validate-detail">
176
+ <form onsubmit="GomageSocialClass.sendEmail('<?php echo Mage::getSingleton('core/session')->getGsProfile()->url_check_email; ?>'); return false;" action="<?php echo Mage::getSingleton('core/session')->getGsProfile()->url_check_email; ?>" method="post" id="gs-form" >
177
+ <ul class="form-list">
178
+ <li>
179
+ <label for="gs-email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
180
+ <div class="input-box">
181
+ <input type="text" name="email" value="" id="gs-email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
182
+ </div>
183
+ </li>
184
+ <li>
185
+ <div class="actions">
186
+ <button type="submit" class="button validation-passed" ><span><span><?php echo $this->__('Login') ?></span></span></button>
187
+ <span style="display: none;" id="gs-please-wait" class="please-wait">
188
+ <img class="v-middle" title="<?php echo $this->__('Loading...') ?>" alt="<?php echo $this->__('Loading...') ?>" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" />
189
+ </span>
190
+ <div id="gs-message" ></div>
191
+ </div>
192
+ </li>
193
+ </ul>
194
+ </form>
195
  </div>
196
+ </div>
197
+
198
+ <script type="text/javascript">
199
+ //<![CDATA[
200
+ win = GomageSocialClass.createWindow("<?php echo __('Enter your email'); ?>", 300, 100);
201
+ win.getContent().update($('gs-popup-content').innerHTML);
202
+ win.showCenter();
203
+
204
+ if (GomageSocialClass.overlay) {
205
+ GomageSocialClass.overlay.show();
206
+ }
207
+
208
+ var gs_id_window = GomageSocialClass.id_window();
209
+ $(gs_id_window.replace('_close','')).className = 'dialog dialog-gs';
210
+
211
+ $(gs_id_window).onclick = function() {
212
+ GomageSocialClass.unsGsProfile('<?php echo Mage::getSingleton('core/session')->getGsProfile()->url_email_close; ?>');
213
+ window.parent.Windows.close(gs_id_window.replace('_close',''));
214
+
215
+ if(GomageSocialClass.overlay){
216
+ GomageSocialClass.overlay.hide();
217
+ }
218
+ }
219
+ //]]>
220
+ </script>
221
  <?php endif; ?>
app/design/frontend/base/default/template/gomage/social/login.phtml CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.0.0
12
  */
13
  ?>
@@ -22,7 +22,7 @@
22
  $last_type = key($services);
23
 
24
  foreach ($services as $type => $value) {
25
- echo $this->getServiceBlock($type, $type == $last_type);
26
  }
27
  ?>
28
  </ul>
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0.0
12
  */
13
  ?>
22
  $last_type = key($services);
23
 
24
  foreach ($services as $type => $value) {
25
+ echo $this->getServiceBlock($type, $type == $last_type)->toHtml();
26
  }
27
  ?>
28
  </ul>
app/design/frontend/base/default/template/gomage/social/login/facebook.phtml CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
  ?>
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
  ?>
app/design/frontend/base/default/template/gomage/social/login/google.phtml CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
  ?>
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
  ?>
app/design/frontend/base/default/template/gomage/social/login/service.phtml CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.1.0
12
  */
13
  ?>
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.1.0
12
  */
13
  ?>
app/etc/modules/GoMage_Social.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * GoMage Social Connector Extension
5
+ *
6
+ * @category Extension
7
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
8
+ * @author GoMage
9
+ * @license http://www.gomage.com/license-agreement/ Single domain license
10
+ * @terms of use http://www.gomage.com/terms-of-use
11
+ * @version Release: 1.4.0
12
+ * @since Class available since Release 1.0.0
13
+ */
14
+ -->
15
+ <config>
16
+ <modules>
17
+ <GoMage_Social>
18
+ <active>true</active>
19
+ <codePool>local</codePool>
20
+ <version>1.4.0</version>
21
+ </GoMage_Social>
22
+ </modules>
23
+ </config>
js/gomage/social.js CHANGED
@@ -6,7 +6,7 @@
6
  * @author GoMage
7
  * @license http://www.gomage.com/license-agreement/ Single domain license
8
  * @terms of use http://www.gomage.com/terms-of-use
9
- * @version Release: 1.3.0
10
  * @since Class available since Release 1.1.0
11
  */
12
 
6
  * @author GoMage
7
  * @license http://www.gomage.com/license-agreement/ Single domain license
8
  * @terms of use http://www.gomage.com/terms-of-use
9
+ * @version Release: 1.4.0
10
  * @since Class available since Release 1.1.0
11
  */
12
 
lib/GoMage/Amazon/Credentials.php CHANGED
@@ -7,19 +7,11 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
14
- class GoMage_Amazon_Credentials extends Varien_Object {
 
15
 
16
- public function _construct() {
17
- if (!$this->getClientId()) {
18
- throw new Exception('client_id is required');
19
- } else if (!$this->getClientSecret()) {
20
- throw new Exception('client_secret is required');
21
- } else if (!$this->getRedirectUri()) {
22
- throw new Exception('redirect_uri is required');
23
- }
24
- }
25
  }
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
14
+ class GoMage_Amazon_Credentials extends GoMage_OAuth_Credentials
15
+ {
16
 
 
 
 
 
 
 
 
 
 
17
  }
lib/GoMage/Amazon/Service.php CHANGED
@@ -7,150 +7,15 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.3.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
14
- class GoMage_Amazon_Service {
15
-
16
- const SERVICE_ENDPOINT = 'https://www.amazon.com/ap';
17
  const AUTHORIZATION_ENDPOINT = 'https://www.amazon.com/ap/oa';
18
  const ACCESS_TOKEN_ENDPOINT = 'https://www.amazon.com/ap/oatoken';
19
 
20
- public static $return_request_error = false;
21
-
22
- public $http_info = array();
23
- public $http_response = '';
24
  public $useragent = 'Amazon OAuth';
25
- public $connecttimeout = 30;
26
- public $timeout = 30;
27
- public $ssl_verifypeer = false;
28
-
29
- protected $credentials;
30
-
31
- public function __construct(GoMage_Amazon_Credentials $credentials) {
32
- $this->credentials = $credentials;
33
- }
34
-
35
- public function getCredentials() {
36
- return $this->credentials;
37
- }
38
-
39
- public function request($url, $method, $parameters = array(), $extraHeaders = array()) {
40
- $this->http_info = array();
41
- $this->http_response = '';
42
- $ci = curl_init();
43
- curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
44
- curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
45
- curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
46
- curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
47
- curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
48
- curl_setopt($ci, CURLOPT_HEADER, false);
49
-
50
- switch ($method) {
51
- case 'GET' :
52
- if (!empty($parameters)) {
53
- $url .= '?' . http_build_query($parameters);
54
- }
55
- break;
56
- case 'POST' :
57
- curl_setopt($ci, CURLOPT_POST, true);
58
-
59
- if (!empty($parameters)) {
60
- curl_setopt($ci, CURLOPT_POSTFIELDS, $parameters);
61
- }
62
- break;
63
- }
64
-
65
- curl_setopt($ci, CURLOPT_HTTPHEADER, $extraHeaders);
66
- curl_setopt($ci, CURLOPT_URL, $url);
67
-
68
- $this->http_response = curl_exec($ci);
69
- $this->http_info = curl_getinfo($ci);
70
- $error = curl_error($ci);
71
-
72
- curl_close($ci);
73
-
74
- if ($error) {
75
- throw new Exception($error);
76
- }
77
-
78
- if ($this->http_info['http_code'] !== 200) {
79
- switch (self::$return_request_error) {
80
- case false :
81
- throw new Exception('Could not connect to Amazon. Refresh the page or try again later.');
82
- break;
83
- case true :
84
- throw new Exception(
85
- "Amazon OAuth request failed: " .
86
- "\t\r\n HTTP code: " . $this->http_info['http_code'] .
87
- "\t\r\n HTTP response: " . $this->http_response
88
- );
89
- break;
90
- }
91
- }
92
-
93
- return $this->http_response;
94
- }
95
-
96
- public function getAuthorizationUrl($parameters = array()) {
97
- $parameters = array_merge(
98
- $parameters,
99
- array(
100
- 'type' => 'web_server',
101
- 'client_id' => $this->credentials->getClientId(),
102
- 'redirect_uri' => $this->credentials->getRedirectUri(),
103
- 'response_type' => 'code',
104
- )
105
- );
106
-
107
- return self::AUTHORIZATION_ENDPOINT . '?' . http_build_query($parameters);
108
- }
109
-
110
- public function getTokenUrl($parameters = array()) {
111
- $parameters = array_merge(
112
- $parameters,
113
- array(
114
- 'code' => $this->credentials->getCode(),
115
- 'client_id' => $this->credentials->getClientId(),
116
- 'client_secret' => $this->credentials->getClientSecret(),
117
- 'redirect_uri' => $this->credentials->getRedirectUri(),
118
- 'grant_type' => 'authorization_code',
119
- )
120
- );
121
-
122
- return self::ACCESS_TOKEN_ENDPOINT . '?' . http_build_query($parameters);
123
- }
124
-
125
- public function requestToken($parameters = array()) {
126
- $parameters = array_merge(
127
- $parameters,
128
- array(
129
- 'code' => $this->credentials->getCode(),
130
- 'client_id' => $this->credentials->getClientId(),
131
- 'client_secret' => $this->credentials->getClientSecret(),
132
- 'redirect_uri' => $this->credentials->getRedirectUri(),
133
- 'grant_type' => 'authorization_code',
134
- )
135
- );
136
-
137
- $this->request(self::ACCESS_TOKEN_ENDPOINT, 'POST', $parameters);
138
-
139
- return new Varien_Object(Zend_Json::decode($this->http_response));
140
- }
141
-
142
- public function requestUserProfile($parameters = array()) {
143
- $parameters = array_merge(
144
- $parameters,
145
- array(
146
- 'access_token' => $this->credentials
147
- ->getOauthToken()
148
- ->getAccessToken(),
149
- )
150
- );
151
-
152
- $this->request(self::SERVICE_ENDPOINT . '/user/profile', 'GET', $parameters);
153
-
154
- return new Varien_Object(Zend_Json::decode($this->http_response));
155
- }
156
  }
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.2.0
12
  */
13
 
14
+ class GoMage_Amazon_Service extends GoMage_OAuth_Service
15
+ {
16
+ const SERVICE_ENDPOINT = 'https://www.amazon.com/ap/user/profile';
17
  const AUTHORIZATION_ENDPOINT = 'https://www.amazon.com/ap/oa';
18
  const ACCESS_TOKEN_ENDPOINT = 'https://www.amazon.com/ap/oatoken';
19
 
 
 
 
 
20
  public $useragent = 'Amazon OAuth';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
lib/GoMage/Instagram/Credentials.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GoMage Social Connector Extension
4
+ *
5
+ * @category Extension
6
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
7
+ * @author GoMage
8
+ * @license http://www.gomage.com/license-agreement/ Single domain license
9
+ * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
+ * @since Class available since Release 1.2.0
12
+ */
13
+
14
+ class GoMage_Instagram_Credentials extends GoMage_OAuth_Credentials
15
+ {
16
+
17
+ }
lib/GoMage/Instagram/Service.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GoMage Social Connector Extension
4
+ *
5
+ * @category Extension
6
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
7
+ * @author GoMage
8
+ * @license http://www.gomage.com/license-agreement/ Single domain license
9
+ * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
+ * @since Class available since Release 1.2.0
12
+ */
13
+
14
+ class GoMage_Instagram_Service extends GoMage_OAuth_Service
15
+ {
16
+ const SERVICE_ENDPOINT = 'https://api.instagram.com/v1/users/self';
17
+ const AUTHORIZATION_ENDPOINT = 'https://api.instagram.com/oauth/authorize';
18
+ const ACCESS_TOKEN_ENDPOINT = 'https://api.instagram.com/oauth/access_token';
19
+
20
+ public $useragent = 'Instagram OAuth';
21
+ }
lib/GoMage/Linkedin/OAuth.php CHANGED
@@ -1,11 +1,4 @@
1
  <?php
2
- // vim: foldmethod=marker
3
-
4
- /* Generic exception class
5
- */
6
- class OAuthException extends Exception {
7
- // pass
8
- }
9
 
10
  class OAuthConsumer {
11
  public $key;
@@ -428,7 +421,7 @@ class OAuthRequest {
428
  foreach ($this->parameters as $k => $v) {
429
  if (substr($k, 0, 5) != "oauth") continue;
430
  if (is_array($v)) {
431
- throw new OAuthException('Arrays not supported in headers');
432
  }
433
  $out .= ($first) ? ' ' : ',';
434
  $out .= OAuthUtil::urlencode_rfc3986($k) .
@@ -561,7 +554,7 @@ class OAuthServer {
561
  $version = '1.0';
562
  }
563
  if ($version !== $this->version) {
564
- throw new OAuthException("OAuth version '$version' not supported");
565
  }
566
  return $version;
567
  }
@@ -576,12 +569,12 @@ class OAuthServer {
576
  if (!$signature_method) {
577
  // According to chapter 7 ("Accessing Protected Ressources") the signature-method
578
  // parameter is required, and we can't just fallback to PLAINTEXT
579
- throw new OAuthException('No signature method parameter. This parameter is required');
580
  }
581
 
582
  if (!in_array($signature_method,
583
  array_keys($this->signature_methods))) {
584
- throw new OAuthException(
585
  "Signature method '$signature_method' not supported " .
586
  "try one of the following: " .
587
  implode(", ", array_keys($this->signature_methods))
@@ -596,12 +589,12 @@ class OAuthServer {
596
  private function get_consumer(&$request) {
597
  $consumer_key = @$request->get_parameter("oauth_consumer_key");
598
  if (!$consumer_key) {
599
- throw new OAuthException("Invalid consumer key");
600
  }
601
 
602
  $consumer = $this->data_store->lookup_consumer($consumer_key);
603
  if (!$consumer) {
604
- throw new OAuthException("Invalid consumer");
605
  }
606
 
607
  return $consumer;
@@ -616,7 +609,7 @@ class OAuthServer {
616
  $consumer, $token_type, $token_field
617
  );
618
  if (!$token) {
619
- throw new OAuthException("Invalid $token_type token: $token_field");
620
  }
621
  return $token;
622
  }
@@ -644,7 +637,7 @@ class OAuthServer {
644
  );
645
 
646
  if (!$valid_sig) {
647
- throw new OAuthException("Invalid signature");
648
  }
649
  }
650
 
@@ -653,14 +646,14 @@ class OAuthServer {
653
  */
654
  private function check_timestamp($timestamp) {
655
  if( ! $timestamp )
656
- throw new OAuthException(
657
  'Missing timestamp parameter. The parameter is required'
658
  );
659
 
660
  // verify that timestamp is recentish
661
  $now = time();
662
  if (abs($now - $timestamp) > $this->timestamp_threshold) {
663
- throw new OAuthException(
664
  "Expired timestamp, yours $timestamp, ours $now"
665
  );
666
  }
@@ -671,7 +664,7 @@ class OAuthServer {
671
  */
672
  private function check_nonce($consumer, $token, $nonce, $timestamp) {
673
  if( ! $nonce )
674
- throw new OAuthException(
675
  'Missing nonce parameter. The parameter is required'
676
  );
677
 
@@ -683,7 +676,7 @@ class OAuthServer {
683
  $timestamp
684
  );
685
  if ($found) {
686
- throw new OAuthException("Nonce already used: $nonce");
687
  }
688
  }
689
 
1
  <?php
 
 
 
 
 
 
 
2
 
3
  class OAuthConsumer {
4
  public $key;
421
  foreach ($this->parameters as $k => $v) {
422
  if (substr($k, 0, 5) != "oauth") continue;
423
  if (is_array($v)) {
424
+ throw new Exception('Arrays not supported in headers');
425
  }
426
  $out .= ($first) ? ' ' : ',';
427
  $out .= OAuthUtil::urlencode_rfc3986($k) .
554
  $version = '1.0';
555
  }
556
  if ($version !== $this->version) {
557
+ throw new Exception("OAuth version '$version' not supported");
558
  }
559
  return $version;
560
  }
569
  if (!$signature_method) {
570
  // According to chapter 7 ("Accessing Protected Ressources") the signature-method
571
  // parameter is required, and we can't just fallback to PLAINTEXT
572
+ throw new Exception('No signature method parameter. This parameter is required');
573
  }
574
 
575
  if (!in_array($signature_method,
576
  array_keys($this->signature_methods))) {
577
+ throw new Exception(
578
  "Signature method '$signature_method' not supported " .
579
  "try one of the following: " .
580
  implode(", ", array_keys($this->signature_methods))
589
  private function get_consumer(&$request) {
590
  $consumer_key = @$request->get_parameter("oauth_consumer_key");
591
  if (!$consumer_key) {
592
+ throw new Exception("Invalid consumer key");
593
  }
594
 
595
  $consumer = $this->data_store->lookup_consumer($consumer_key);
596
  if (!$consumer) {
597
+ throw new Exception("Invalid consumer");
598
  }
599
 
600
  return $consumer;
609
  $consumer, $token_type, $token_field
610
  );
611
  if (!$token) {
612
+ throw new Exception("Invalid $token_type token: $token_field");
613
  }
614
  return $token;
615
  }
637
  );
638
 
639
  if (!$valid_sig) {
640
+ throw new Exception("Invalid signature");
641
  }
642
  }
643
 
646
  */
647
  private function check_timestamp($timestamp) {
648
  if( ! $timestamp )
649
+ throw new Exception(
650
  'Missing timestamp parameter. The parameter is required'
651
  );
652
 
653
  // verify that timestamp is recentish
654
  $now = time();
655
  if (abs($now - $timestamp) > $this->timestamp_threshold) {
656
+ throw new Exception(
657
  "Expired timestamp, yours $timestamp, ours $now"
658
  );
659
  }
664
  */
665
  private function check_nonce($consumer, $token, $nonce, $timestamp) {
666
  if( ! $nonce )
667
+ throw new Exception(
668
  'Missing nonce parameter. The parameter is required'
669
  );
670
 
676
  $timestamp
677
  );
678
  if ($found) {
679
+ throw new Exception("Nonce already used: $nonce");
680
  }
681
  }
682
 
lib/GoMage/Linkedin/linkedinoauth.php CHANGED
@@ -7,7 +7,7 @@
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 1.0
11
  * @since Class available since Release 1.0
12
  */
13
 
7
  * @author GoMage
8
  * @license http://www.gomage.com/license-agreement/ Single domain license
9
  * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
  * @since Class available since Release 1.0
12
  */
13
 
lib/GoMage/MobileDetect/Navigation_Mobile_Detect.php DELETED
@@ -1,1350 +0,0 @@
1
- <?php
2
- /**
3
- * Mobile Detect Library
4
- * =====================
5
- *
6
- * Motto: "Every business should have a mobile detection script to detect mobile readers"
7
- *
8
- * Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets).
9
- * It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
10
- *
11
- * @author Current authors: Serban Ghita <serbanghita@gmail.com>
12
- * Nick Ilyin <nick.ilyin@gmail.com>
13
- *
14
- * Original author: Victor Stanciu <vic.stanciu@gmail.com>
15
- *
16
- * @license Code and contributions have 'MIT License'
17
- * More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
18
- *
19
- * @link Homepage: http://mobiledetect.net
20
- * GitHub Repo: https://github.com/serbanghita/Mobile-Detect
21
- * Google Code: http://code.google.com/p/php-mobile-detect/
22
- * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
23
- * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
24
- *
25
- * @version 2.8.12
26
- */
27
-
28
- class Navigation_Mobile_Detect
29
- {
30
- /**
31
- * Mobile detection type.
32
- *
33
- * @deprecated since version 2.6.9
34
- */
35
- const DETECTION_TYPE_MOBILE = 'mobile';
36
-
37
- /**
38
- * Extended detection type.
39
- *
40
- * @deprecated since version 2.6.9
41
- */
42
- const DETECTION_TYPE_EXTENDED = 'extended';
43
-
44
- /**
45
- * A frequently used regular expression to extract version #s.
46
- *
47
- * @deprecated since version 2.6.9
48
- */
49
- const VER = '([\w._\+]+)';
50
-
51
- /**
52
- * Top-level device.
53
- */
54
- const MOBILE_GRADE_A = 'A';
55
-
56
- /**
57
- * Mid-level device.
58
- */
59
- const MOBILE_GRADE_B = 'B';
60
-
61
- /**
62
- * Low-level device.
63
- */
64
- const MOBILE_GRADE_C = 'C';
65
-
66
- /**
67
- * Stores the version number of the current release.
68
- */
69
- const VERSION = '2.8.12';
70
-
71
- /**
72
- * A type for the version() method indicating a string return value.
73
- */
74
- const VERSION_TYPE_STRING = 'text';
75
-
76
- /**
77
- * A type for the version() method indicating a float return value.
78
- */
79
- const VERSION_TYPE_FLOAT = 'float';
80
-
81
- /**
82
- * A cache for resolved matches
83
- * @var array
84
- */
85
- protected $cache = array();
86
-
87
- /**
88
- * The User-Agent HTTP header is stored in here.
89
- * @var string
90
- */
91
- protected $userAgent = null;
92
-
93
- /**
94
- * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
95
- * @var array
96
- */
97
- protected $httpHeaders = array();
98
-
99
- /**
100
- * The matching Regex.
101
- * This is good for debug.
102
- * @var string
103
- */
104
- protected $matchingRegex = null;
105
-
106
- /**
107
- * The matches extracted from the regex expression.
108
- * This is good for debug.
109
- * @var string
110
- */
111
- protected $matchesArray = null;
112
-
113
- /**
114
- * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED.
115
- *
116
- * @deprecated since version 2.6.9
117
- *
118
- * @var string
119
- */
120
- protected $detectionType = self::DETECTION_TYPE_MOBILE;
121
-
122
- /**
123
- * HTTP headers that trigger the 'isMobile' detection
124
- * to be true.
125
- *
126
- * @var array
127
- */
128
- protected static $mobileHeaders = array(
129
-
130
- 'HTTP_ACCEPT' => array('matches' => array(
131
- // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
132
- 'application/x-obml2d',
133
- // BlackBerry devices.
134
- 'application/vnd.rim.html',
135
- 'text/vnd.wap.wml',
136
- 'application/vnd.wap.xhtml+xml'
137
- )),
138
- 'HTTP_X_WAP_PROFILE' => null,
139
- 'HTTP_X_WAP_CLIENTID' => null,
140
- 'HTTP_WAP_CONNECTION' => null,
141
- 'HTTP_PROFILE' => null,
142
- // Reported by Opera on Nokia devices (eg. C3).
143
- 'HTTP_X_OPERAMINI_PHONE_UA' => null,
144
- 'HTTP_X_NOKIA_GATEWAY_ID' => null,
145
- 'HTTP_X_ORANGE_ID' => null,
146
- 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
147
- 'HTTP_X_HUAWEI_USERID' => null,
148
- // Reported by Windows Smartphones.
149
- 'HTTP_UA_OS' => null,
150
- // Reported by Verizon, Vodafone proxy system.
151
- 'HTTP_X_MOBILE_GATEWAY' => null,
152
- // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
153
- 'HTTP_X_ATT_DEVICEID' => null,
154
- // Seen this on a HTC.
155
- 'HTTP_UA_CPU' => array('matches' => array('ARM')),
156
- );
157
-
158
- /**
159
- * List of mobile devices (phones).
160
- *
161
- * @var array
162
- */
163
- protected static $phoneDevices = array(
164
- 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
165
- 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+',
166
- 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m',
167
- 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
168
- // @todo: Is 'Dell Streak' a tablet or a phone? ;)
169
- 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
170
- 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925',
171
- 'Samsung' => 'Samsung|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8',
172
- 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802)',
173
- 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
174
- 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
175
- // http://www.micromaxinfo.com/mobiles/smartphones
176
- // Added because the codes might conflict with Acer Tablets.
177
- 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
178
- // @todo Complete the regex.
179
- 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ;
180
- 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;)
181
- // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
182
- // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android.
183
- 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
184
- // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones.
185
- 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
186
- // http://fr.wikomobile.com
187
- 'Wiko' => 'KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM',
188
- 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)',
189
- // Added simvalley mobile just for fun. They have some interesting devices.
190
- // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
191
- 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b',
192
- // Wolfgang - a brand that is sold by Aldi supermarkets.
193
- // http://www.wolfgangmobile.com/
194
- 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
195
- 'Alcatel' => 'Alcatel',
196
- 'Nintendo' => 'Nintendo 3DS',
197
- // http://en.wikipedia.org/wiki/Amoi
198
- 'Amoi' => 'Amoi',
199
- // http://en.wikipedia.org/wiki/INQ
200
- 'INQ' => 'INQ',
201
- // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
202
- 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser',
203
- );
204
-
205
- /**
206
- * List of tablet devices.
207
- *
208
- * @var array
209
- */
210
- protected static $tabletDevices = array(
211
- 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic.
212
- 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)|^.*Android.*Nexus(?:(?!Mobile).)*$',
213
- 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237P|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone.
214
- // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
215
- 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI)\b',
216
- // Only the Surface tablets with Windows RT are considered mobile.
217
- // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
218
- 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)',
219
- // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
220
- 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
221
- // Watch out for PadFone, see #132.
222
- // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
223
- 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL',
224
- 'BlackBerryTablet' => 'PlayBook|RIM Tablet',
225
- 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
226
- 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
227
- 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2',
228
- // http://www.acer.ro/ac/ro/RO/content/drivers
229
- // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer)
230
- // http://us.acer.com/ac/en/US/content/group/tablets
231
- // http://www.acer.de/ac/de/DE/content/models/tablets/
232
- // Can conflict with Micromax and Motorola phones codes.
233
- 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b',
234
- // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
235
- // http://us.toshiba.com/tablets/tablet-finder
236
- // http://www.toshiba.co.jp/regza/tablet/
237
- 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
238
- // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
239
- // http://www.lg.com/us/tablets
240
- 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
241
- 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
242
- // Prestigio Tablets http://www.prestigio.com/support
243
- 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD',
244
- // http://support.lenovo.com/en_GB/downloads/default.page?#
245
- 'LenovoTablet' => 'Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)',
246
- // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
247
- 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7',
248
- // http://www.yarvik.com/en/matrix/tablets/
249
- 'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
250
- 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
251
- 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
252
- // http://www.intenso.de/kategorie_en.php?kategorie=33
253
- // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate
254
- 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
255
- // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
256
- 'IRUTablet' => 'M702pro',
257
- 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b',
258
- // http://www.e-boda.ro/tablete-pc.html
259
- 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)',
260
- // http://www.allview.ro/produse/droseries/lista-tablete-pc/
261
- 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
262
- // http://wiki.archosfans.com/index.php?title=Main_Page
263
- 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
264
- // http://www.ainol.com/plugin.php?identifier=ainol&module=product
265
- 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
266
- // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
267
- // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
268
- // http://www.sony.jp/support/tablet/
269
- 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP612',
270
- // http://www.support.philips.com/support/catalog/worldproducts.jsp?userLanguage=en&userCountry=cn&categoryid=3G_LTE_TABLET_SU_CN_CARE&title=3G%20tablets%20/%20LTE%20range&_dyncharset=UTF-8
271
- 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
272
- // db + http://www.cube-tablet.com/buy-products.html
273
- 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT',
274
- // http://www.cobyusa.com/?p=pcat&pcat_id=3001
275
- 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
276
- // http://www.match.net.cn/products.asp
277
- 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733',
278
- // http://www.msi.com/support
279
- // @todo Research the Windows Tablets.
280
- 'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
281
- // @todo http://www.kyoceramobile.com/support/drivers/
282
- // 'KyoceraTablet' => null,
283
- // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/
284
- // 'IntextTablet' => null,
285
- // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets)
286
- // http://www.imp3.net/14/show.php?itemid=20454
287
- 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
288
- // http://www.rock-chips.com/index.php?do=prod&pid=2
289
- 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
290
- // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/
291
- 'FlyTablet' => 'IQ310|Fly Vision',
292
- // http://www.bqreaders.com/gb/tablets-prices-sale.html
293
- 'bqTablet' => '(bq)?.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris E10)|Maxwell.*Lite|Maxwell.*Plus',
294
- // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
295
- // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets)
296
- 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim',
297
- // Nec or Medias Tab
298
- 'NecTablet' => '\bN-06D|\bN-08D',
299
- // Pantech Tablets: http://www.pantechusa.com/phones/
300
- 'PantechTablet' => 'Pantech.*P4100',
301
- // Broncho Tablets: http://www.broncho.cn/ (hard to find)
302
- 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)',
303
- // http://versusuk.com/support.html
304
- 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
305
- // http://www.zync.in/index.php/our-products/tablet-phablets
306
- 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900',
307
- // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
308
- 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA',
309
- // https://www.nabitablet.com/
310
- 'NabiTablet' => 'Android.*\bNabi',
311
- 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build',
312
- // French Danew Tablets http://www.danew.com/produits-tablette.php
313
- 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
314
- // Texet Tablets and Readers http://www.texet.ru/tablet/
315
- 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE',
316
- // Avoid detecting 'PLAYSTATION 3' as mobile.
317
- 'PlaystationTablet' => 'Playstation.*(Portable|Vita)',
318
- // http://www.trekstor.de/surftabs.html
319
- 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
320
- // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
321
- 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
322
- // http://www.advandigital.com/index.php?link=content-product&jns=JP001
323
- // because of the short codenames we have to include whitespaces to reduce the possible conflicts.
324
- 'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ',
325
- // http://www.danytech.com/category/tablet-pc
326
- 'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1',
327
- // http://www.galapad.net/product.html
328
- 'GalapadTablet' => 'Android.*\bG1\b',
329
- // http://www.micromaxinfo.com/tablet/funbook
330
- 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
331
- // http://www.karbonnmobiles.com/products_tablet.php
332
- 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
333
- // http://www.myallfine.com/Products.asp
334
- 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
335
- // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
336
- 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b',
337
- // http://www.yonesnav.com/products/products.php
338
- 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
339
- // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
340
- // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html)
341
- 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503',
342
- // http://www.gloryunion.cn/products.asp
343
- // http://www.allwinnertech.com/en/apply/mobile.html
344
- // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
345
- // @todo: Softwiner tablets?
346
- // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions.
347
- 'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G
348
- // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
349
- 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10',
350
- // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
351
- // @todo: add more tests.
352
- 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)',
353
- // http://hclmetablet.com/India/index.php
354
- 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync',
355
- // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
356
- 'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
357
- // http://www.visture.com/index.asp
358
- 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10',
359
- // http://www.mijncresta.nl/tablet
360
- 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
361
- // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
362
- 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b',
363
- // Concorde tab
364
- 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan',
365
- // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
366
- 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042',
367
- // Modecom Tablets - http://www.modecom.eu/tablets/portal/
368
- 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003',
369
- // Vonino Tablets - http://www.vonino.eu/tablets
370
- 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b',
371
- // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
372
- 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1',
373
- // Storex Tablets - http://storex.fr/espace_client/support.html
374
- // @note: no need to add all the tablet codes since they are guided by the first regex.
375
- 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
376
- // Generic Vodafone tablets.
377
- 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7',
378
- // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
379
- // Aka: http://www.essentielb.fr/
380
- 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2',
381
- // Ross & Moor - http://ross-moor.ru/
382
- 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
383
- // i-mobile http://product.i-mobilephone.com/Mobile_Device
384
- 'iMobileTablet' => 'i-mobile i-note',
385
- // http://www.tolino.de/de/vergleichen/
386
- 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine',
387
- // AudioSonic - a Kmart brand
388
- // http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72&currentPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1
389
- 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b',
390
- // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
391
- // @todo: add them gradually to avoid conflicts.
392
- 'AMPETablet' => 'Android.* A78 ',
393
- // Skk Mobile - http://skkmobile.com.ph/product_tablets.php
394
- 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)',
395
- // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
396
- 'TecnoTablet' => 'TECNO P9',
397
- // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3
398
- 'JXDTablet' => 'Android.*\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
399
- // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
400
- 'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
401
- // http://www.intracon.eu/tablet
402
- 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
403
- // http://www.xoro.de/produkte/
404
- // @note: Might be the same brand with 'Simply tablets'
405
- 'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151',
406
- // http://www1.viewsonic.com/products/computing/tablets/
407
- 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a',
408
- // http://www.odys.de/web/internet-tablet_en.html
409
- 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
410
- // http://www.captiva-power.de/products.html#tablets-en
411
- 'CaptivaTablet' => 'CAPTIVA PAD',
412
- // IconBIT - http://www.iconbit.com/products/tablets/
413
- 'IconbitTablet' => 'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S',
414
- // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
415
- 'TeclastTablet' => 'T98 4G|\bP80\b|\bX90HD\b|X98 Air|X98 Air 3G|\bX89\b|P80 3G|\bX80h\b|P98 Air|\bX89HD\b|P98 3G|\bP90HD\b|P89 3G|X98 3G|\bP70h\b|P79HD 3G|G18d 3G|\bP79HD\b|\bP89s\b|\bA88\b|\bP10HD\b|\bP19HD\b|G18 3G|\bP78HD\b|\bA78\b|\bP75\b|G17s 3G|G17h 3G|\bP85t\b|\bP90\b|\bP11\b|\bP98t\b|\bP98HD\b|\bG18d\b|\bP85s\b|\bP11HD\b|\bP88s\b|\bA80HD\b|\bA80se\b|\bA10h\b|\bP89\b|\bP78s\b|\bG18\b|\bP85\b|\bA70h\b|\bA70\b|\bG17\b|\bP18\b|\bA80s\b|\bA11s\b|\bP88HD\b|\bA80h\b|\bP76s\b|\bP76h\b|\bP98\b|\bA10HD\b|\bP78\b|\bP88\b|\bA11\b|\bA10t\b|\bP76a\b|\bP76t\b|\bP76e\b|\bP85HD\b|\bP85a\b|\bP86\b|\bP75HD\b|\bP76v\b|\bA12\b|\bP75a\b|\bA15\b|\bP76Ti\b|\bP81HD\b|\bA10\b|\bT760VE\b|\bT720HD\b|\bP76\b|\bP73\b|\bP71\b|\bP72\b|\bT720SE\b|\bC520Ti\b|\bT760\b|\bT720VE\b|T720-3GE|T720-WiFi',
416
- 'JaytechTablet' => 'TPC-PA762',
417
- 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010',
418
- // http://www.digma.ru/support/download/
419
- // @todo: Ebooks also (if requested)
420
- 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
421
- // http://www.evolioshop.com/ro/tablete-pc.html
422
- // http://www.evolio.ro/support/downloads_static.html?cat=2
423
- // @todo: Research some more
424
- 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
425
- // @todo http://www.lavamobiles.com/tablets-data-cards
426
- 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY',
427
- // https://www.celkonmobiles.com/?_a=categoryphones&sid=2
428
- 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
429
- // http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
430
- 'WolderTablet' => 'miTab \b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\b',
431
- // http://www.mi.com/en
432
- 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b',
433
- // http://www.nbru.cn/index.html
434
- 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One',
435
- // http://navroad.com/products/produkty/tablety/
436
- 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI',
437
- // http://www.datawind.com/ubislate/
438
- 'UbislateTablet' => 'UbiSlate[\s]?7C',
439
- // http://www.pocketbook-int.com/ru/support
440
- 'PocketBookTablet' => 'Pocketbook',
441
- // http://www.tesco.com/direct/hudl/
442
- 'Hudl' => 'Hudl HT7S3',
443
- // http://www.telstra.com.au/home-phone/thub-2/
444
- 'TelstraTablet' => 'T-Hub2',
445
- 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bJolla\b'
446
- );
447
-
448
- /**
449
- * List of mobile Operating Systems.
450
- *
451
- * @var array
452
- */
453
- protected static $operatingSystems = array(
454
- 'AndroidOS' => 'Android',
455
- 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
456
- 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
457
- 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
458
- // @reference: http://en.wikipedia.org/wiki/Windows_Mobile
459
- 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;',
460
- // @reference: http://en.wikipedia.org/wiki/Windows_Phone
461
- // http://wifeng.cn/?r=blog&a=view&id=106
462
- // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
463
- // http://msdn.microsoft.com/library/ms537503.aspx
464
- 'WindowsPhoneOS' => 'Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;',
465
- 'iOS' => '\biPhone.*Mobile|\biPod|\biPad',
466
- // http://en.wikipedia.org/wiki/MeeGo
467
- // @todo: research MeeGo in UAs
468
- 'MeeGoOS' => 'MeeGo',
469
- // http://en.wikipedia.org/wiki/Maemo
470
- // @todo: research Maemo in UAs
471
- 'MaemoOS' => 'Maemo',
472
- 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135
473
- 'webOS' => 'webOS|hpwOS',
474
- 'badaOS' => '\bBada\b',
475
- 'BREWOS' => 'BREW',
476
- );
477
-
478
- /**
479
- * List of mobile User Agents.
480
- *
481
- * @var array
482
- */
483
- protected static $browsers = array(
484
- // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
485
- 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
486
- 'Dolfin' => '\bDolfin\b',
487
- 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+',
488
- 'Skyfire' => 'Skyfire',
489
- 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+
490
- 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile',
491
- 'Bolt' => 'bolt',
492
- 'TeaShark' => 'teashark',
493
- 'Blazer' => 'Blazer',
494
- // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
495
- 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
496
- // http://en.wikipedia.org/wiki/Midori_(web_browser)
497
- //'Midori' => 'midori',
498
- 'Tizen' => 'Tizen',
499
- 'UCBrowser' => 'UC.*Browser|UCWEB',
500
- 'baiduboxapp' => 'baiduboxapp',
501
- 'baidubrowser' => 'baidubrowser',
502
- // https://github.com/serbanghita/Mobile-Detect/issues/7
503
- 'DiigoBrowser' => 'DiigoBrowser',
504
- // http://www.puffinbrowser.com/index.php
505
- 'Puffin' => 'Puffin',
506
- // http://mercury-browser.com/index.html
507
- 'Mercury' => '\bMercury\b',
508
- // http://en.wikipedia.org/wiki/Obigo_Browser
509
- 'ObigoBrowser' => 'Obigo',
510
- // http://en.wikipedia.org/wiki/NetFront
511
- 'NetFront' => 'NF-Browser',
512
- // @reference: http://en.wikipedia.org/wiki/Minimo
513
- // http://en.wikipedia.org/wiki/Vision_Mobile_Browser
514
- 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
515
- );
516
-
517
- /**
518
- * Utilities.
519
- *
520
- * @var array
521
- */
522
- protected static $utilities = array(
523
- // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
524
- // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
525
- // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
526
- // https://developers.facebook.com/docs/sharing/best-practices
527
- 'Bot' => 'Googlebot|facebookexternalhit|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor',
528
- 'MobileBot' => 'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
529
- 'DesktopMode' => 'WPDesktop',
530
- 'TV' => 'SonyDTV|HbbTV', // experimental
531
- 'WebKit' => '(webkit)[ /]([\w.]+)',
532
- // @todo: Include JXD consoles.
533
- 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b',
534
- 'Watch' => 'SM-V700',
535
- );
536
-
537
- /**
538
- * All possible HTTP headers that represent the
539
- * User-Agent string.
540
- *
541
- * @var array
542
- */
543
- protected static $uaHttpHeaders = array(
544
- // The default User-Agent string.
545
- 'HTTP_USER_AGENT',
546
- // Header can occur on devices using Opera Mini.
547
- 'HTTP_X_OPERAMINI_PHONE_UA',
548
- // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
549
- 'HTTP_X_DEVICE_USER_AGENT',
550
- 'HTTP_X_ORIGINAL_USER_AGENT',
551
- 'HTTP_X_SKYFIRE_PHONE',
552
- 'HTTP_X_BOLT_PHONE_UA',
553
- 'HTTP_DEVICE_STOCK_UA',
554
- 'HTTP_X_UCBROWSER_DEVICE_UA'
555
- );
556
-
557
- /**
558
- * The individual segments that could exist in a User-Agent string. VER refers to the regular
559
- * expression defined in the constant self::VER.
560
- *
561
- * @var array
562
- */
563
- protected static $properties = array(
564
-
565
- // Build
566
- 'Mobile' => 'Mobile/[VER]',
567
- 'Build' => 'Build/[VER]',
568
- 'Version' => 'Version/[VER]',
569
- 'VendorID' => 'VendorID/[VER]',
570
-
571
- // Devices
572
- 'iPad' => 'iPad.*CPU[a-z ]+[VER]',
573
- 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
574
- 'iPod' => 'iPod.*CPU[a-z ]+[VER]',
575
- //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'),
576
- 'Kindle' => 'Kindle/[VER]',
577
-
578
- // Browser
579
- 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
580
- 'Coast' => array('Coast/[VER]'),
581
- 'Dolfin' => 'Dolfin/[VER]',
582
- // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference
583
- 'Firefox' => 'Firefox/[VER]',
584
- 'Fennec' => 'Fennec/[VER]',
585
- // @reference: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
586
- 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];'),
587
- // http://en.wikipedia.org/wiki/NetFront
588
- 'NetFront' => 'NetFront/[VER]',
589
- 'NokiaBrowser' => 'NokiaBrowser/[VER]',
590
- 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ),
591
- 'Opera Mini' => 'Opera Mini/[VER]',
592
- 'Opera Mobi' => 'Version/[VER]',
593
- 'UC Browser' => 'UC Browser[VER]',
594
- 'MQQBrowser' => 'MQQBrowser/[VER]',
595
- 'MicroMessenger' => 'MicroMessenger/[VER]',
596
- 'baiduboxapp' => 'baiduboxapp/[VER]',
597
- 'baidubrowser' => 'baidubrowser/[VER]',
598
- 'Iron' => 'Iron/[VER]',
599
- // @note: Safari 7534.48.3 is actually Version 5.1.
600
- // @note: On BlackBerry the Version is overwriten by the OS.
601
- 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
602
- 'Skyfire' => 'Skyfire/[VER]',
603
- 'Tizen' => 'Tizen/[VER]',
604
- 'Webkit' => 'webkit[ /][VER]',
605
-
606
- // Engine
607
- 'Gecko' => 'Gecko/[VER]',
608
- 'Trident' => 'Trident/[VER]',
609
- 'Presto' => 'Presto/[VER]',
610
-
611
- // OS
612
- 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
613
- 'Android' => 'Android [VER]',
614
- 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'),
615
- 'BREW' => 'BREW [VER]',
616
- 'Java' => 'Java/[VER]',
617
- // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
618
- // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
619
- 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'),
620
- 'Windows Phone' => 'Windows Phone [VER]',
621
- 'Windows CE' => 'Windows CE/[VER]',
622
- // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
623
- 'Windows NT' => 'Windows NT [VER]',
624
- 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
625
- 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
626
- );
627
-
628
- /**
629
- * Construct an instance of this class.
630
- *
631
- * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored.
632
- * If left empty, will use the global _SERVER['HTTP_*'] vars instead.
633
- * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT
634
- * from the $headers array instead.
635
- */
636
- public function __construct(
637
- array $headers = null,
638
- $userAgent = null
639
- ) {
640
- $this->setHttpHeaders($headers);
641
- $this->setUserAgent($userAgent);
642
- }
643
-
644
- /**
645
- * Get the current script version.
646
- * This is useful for the demo.php file,
647
- * so people can check on what version they are testing
648
- * for mobile devices.
649
- *
650
- * @return string The version number in semantic version format.
651
- */
652
- public static function getScriptVersion()
653
- {
654
- return self::VERSION;
655
- }
656
-
657
- /**
658
- * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
659
- *
660
- * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
661
- * the headers. The default null is left for backwards compatibilty.
662
- */
663
- public function setHttpHeaders($httpHeaders = null)
664
- {
665
- // use global _SERVER if $httpHeaders aren't defined
666
- if (!is_array($httpHeaders) || !count($httpHeaders)) {
667
- $httpHeaders = $_SERVER;
668
- }
669
-
670
- // clear existing headers
671
- $this->httpHeaders = array();
672
-
673
- // Only save HTTP headers. In PHP land, that means only _SERVER vars that
674
- // start with HTTP_.
675
- foreach ($httpHeaders as $key => $value) {
676
- if (substr($key, 0, 5) === 'HTTP_') {
677
- $this->httpHeaders[$key] = $value;
678
- }
679
- }
680
- }
681
-
682
- /**
683
- * Retrieves the HTTP headers.
684
- *
685
- * @return array
686
- */
687
- public function getHttpHeaders()
688
- {
689
- return $this->httpHeaders;
690
- }
691
-
692
- /**
693
- * Retrieves a particular header. If it doesn't exist, no exception/error is caused.
694
- * Simply null is returned.
695
- *
696
- * @param string $header The name of the header to retrieve. Can be HTTP compliant such as
697
- * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the
698
- * all-caps, HTTP_ prefixed, underscore seperated awesomeness.
699
- *
700
- * @return string|null The value of the header.
701
- */
702
- public function getHttpHeader($header)
703
- {
704
- // are we using PHP-flavored headers?
705
- if (strpos($header, '_') === false) {
706
- $header = str_replace('-', '_', $header);
707
- $header = strtoupper($header);
708
- }
709
-
710
- // test the alternate, too
711
- $altHeader = 'HTTP_' . $header;
712
-
713
- //Test both the regular and the HTTP_ prefix
714
- if (isset($this->httpHeaders[$header])) {
715
- return $this->httpHeaders[$header];
716
- } elseif (isset($this->httpHeaders[$altHeader])) {
717
- return $this->httpHeaders[$altHeader];
718
- }
719
-
720
- return null;
721
- }
722
-
723
- public function getMobileHeaders()
724
- {
725
- return self::$mobileHeaders;
726
- }
727
-
728
- /**
729
- * Get all possible HTTP headers that
730
- * can contain the User-Agent string.
731
- *
732
- * @return array List of HTTP headers.
733
- */
734
- public function getUaHttpHeaders()
735
- {
736
- return self::$uaHttpHeaders;
737
- }
738
-
739
- /**
740
- * Set the User-Agent to be used.
741
- *
742
- * @param string $userAgent The user agent string to set.
743
- *
744
- * @return string|null
745
- */
746
- public function setUserAgent($userAgent = null)
747
- {
748
- if (false === empty($userAgent)) {
749
- return $this->userAgent = $userAgent;
750
- } else {
751
- $this->userAgent = null;
752
- foreach ($this->getUaHttpHeaders() as $altHeader) {
753
- if (false === empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
754
- $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
755
- }
756
- }
757
-
758
- return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
759
-
760
- }
761
- }
762
-
763
- /**
764
- * Retrieve the User-Agent.
765
- *
766
- * @return string|null The user agent if it's set.
767
- */
768
- public function getUserAgent()
769
- {
770
- return $this->userAgent;
771
- }
772
-
773
- /**
774
- * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
775
- * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
776
- *
777
- * @deprecated since version 2.6.9
778
- *
779
- * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default
780
- * parameter is null which will default to self::DETECTION_TYPE_MOBILE.
781
- */
782
- public function setDetectionType($type = null)
783
- {
784
- if ($type === null) {
785
- $type = self::DETECTION_TYPE_MOBILE;
786
- }
787
-
788
- if ($type !== self::DETECTION_TYPE_MOBILE && $type !== self::DETECTION_TYPE_EXTENDED) {
789
- return;
790
- }
791
-
792
- $this->detectionType = $type;
793
- }
794
-
795
- public function getMatchingRegex()
796
- {
797
- return $this->matchingRegex;
798
- }
799
-
800
- public function getMatchesArray()
801
- {
802
- return $this->matchesArray;
803
- }
804
-
805
- /**
806
- * Retrieve the list of known phone devices.
807
- *
808
- * @return array List of phone devices.
809
- */
810
- public static function getPhoneDevices()
811
- {
812
- return self::$phoneDevices;
813
- }
814
-
815
- /**
816
- * Retrieve the list of known tablet devices.
817
- *
818
- * @return array List of tablet devices.
819
- */
820
- public static function getTabletDevices()
821
- {
822
- return self::$tabletDevices;
823
- }
824
-
825
- /**
826
- * Alias for getBrowsers() method.
827
- *
828
- * @return array List of user agents.
829
- */
830
- public static function getUserAgents()
831
- {
832
- return self::getBrowsers();
833
- }
834
-
835
- /**
836
- * Retrieve the list of known browsers. Specifically, the user agents.
837
- *
838
- * @return array List of browsers / user agents.
839
- */
840
- public static function getBrowsers()
841
- {
842
- return self::$browsers;
843
- }
844
-
845
- /**
846
- * Retrieve the list of known utilities.
847
- *
848
- * @return array List of utilities.
849
- */
850
- public static function getUtilities()
851
- {
852
- return self::$utilities;
853
- }
854
-
855
- /**
856
- * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*().
857
- *
858
- * @deprecated since version 2.6.9
859
- *
860
- * @return array All the rules (but not extended).
861
- */
862
- public static function getMobileDetectionRules()
863
- {
864
- static $rules;
865
-
866
- if (!$rules) {
867
- $rules = array_merge(
868
- self::$phoneDevices,
869
- self::$tabletDevices,
870
- self::$operatingSystems,
871
- self::$browsers
872
- );
873
- }
874
-
875
- return $rules;
876
-
877
- }
878
-
879
- /**
880
- * Method gets the mobile detection rules + utilities.
881
- * The reason this is separate is because utilities rules
882
- * don't necessary imply mobile. This method is used inside
883
- * the new $detect->is('stuff') method.
884
- *
885
- * @deprecated since version 2.6.9
886
- *
887
- * @return array All the rules + extended.
888
- */
889
- public function getMobileDetectionRulesExtended()
890
- {
891
- static $rules;
892
-
893
- if (!$rules) {
894
- // Merge all rules together.
895
- $rules = array_merge(
896
- self::$phoneDevices,
897
- self::$tabletDevices,
898
- self::$operatingSystems,
899
- self::$browsers,
900
- self::$utilities
901
- );
902
- }
903
-
904
- return $rules;
905
- }
906
-
907
- /**
908
- * Retrieve the current set of rules.
909
- *
910
- * @deprecated since version 2.6.9
911
- *
912
- * @return array
913
- */
914
- public function getRules()
915
- {
916
- if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) {
917
- return self::getMobileDetectionRulesExtended();
918
- } else {
919
- return self::getMobileDetectionRules();
920
- }
921
- }
922
-
923
- /**
924
- * Retrieve the list of mobile operating systems.
925
- *
926
- * @return array The list of mobile operating systems.
927
- */
928
- public static function getOperatingSystems()
929
- {
930
- return self::$operatingSystems;
931
- }
932
-
933
- /**
934
- * Check the HTTP headers for signs of mobile.
935
- * This is the fastest mobile check possible; it's used
936
- * inside isMobile() method.
937
- *
938
- * @return bool
939
- */
940
- public function checkHttpHeadersForMobile()
941
- {
942
-
943
- foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
944
- if (isset($this->httpHeaders[$mobileHeader])) {
945
- if (is_array($matchType['matches'])) {
946
- foreach ($matchType['matches'] as $_match) {
947
- if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false) {
948
- return true;
949
- }
950
- }
951
-
952
- return false;
953
- } else {
954
- return true;
955
- }
956
- }
957
- }
958
-
959
- return false;
960
-
961
- }
962
-
963
- /**
964
- * Magic overloading method.
965
- *
966
- * @method boolean is[...]()
967
- * @param string $name
968
- * @param array $arguments
969
- * @return mixed
970
- * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is'
971
- */
972
- public function __call($name, $arguments)
973
- {
974
- // make sure the name starts with 'is', otherwise
975
- if (substr($name, 0, 2) !== 'is') {
976
- throw new BadMethodCallException("No such method exists: $name");
977
- }
978
-
979
- $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
980
-
981
- $key = substr($name, 2);
982
-
983
- return $this->matchUAAgainstKey($key);
984
- }
985
-
986
- /**
987
- * Find a detection rule that matches the current User-agent.
988
- *
989
- * @param null $userAgent deprecated
990
- * @return boolean
991
- */
992
- protected function matchDetectionRulesAgainstUA($userAgent = null)
993
- {
994
- // Begin general search.
995
- foreach ($this->getRules() as $_regex) {
996
- if (empty($_regex)) {
997
- continue;
998
- }
999
-
1000
- if ($this->match($_regex, $userAgent)) {
1001
- return true;
1002
- }
1003
- }
1004
-
1005
- return false;
1006
- }
1007
-
1008
- /**
1009
- * Search for a certain key in the rules array.
1010
- * If the key is found the try to match the corresponding
1011
- * regex against the User-Agent.
1012
- *
1013
- * @param string $key
1014
- *
1015
- * @return boolean
1016
- */
1017
- protected function matchUAAgainstKey($key)
1018
- {
1019
- // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc.
1020
- $key = strtolower($key);
1021
- if (false === isset($this->cache[$key])) {
1022
-
1023
- // change the keys to lower case
1024
- $_rules = array_change_key_case($this->getRules());
1025
-
1026
- if (false === empty($_rules[$key])) {
1027
- $this->cache[$key] = $this->match($_rules[$key]);
1028
- }
1029
-
1030
- if (false === isset($this->cache[$key])) {
1031
- $this->cache[$key] = false;
1032
- }
1033
- }
1034
-
1035
- return $this->cache[$key];
1036
- }
1037
-
1038
- /**
1039
- * Check if the device is mobile.
1040
- * Returns true if any type of mobile device detected, including special ones
1041
- * @param null $userAgent deprecated
1042
- * @param null $httpHeaders deprecated
1043
- * @return bool
1044
- */
1045
- public function isMobile($userAgent = null, $httpHeaders = null)
1046
- {
1047
-
1048
- if ($httpHeaders) {
1049
- $this->setHttpHeaders($httpHeaders);
1050
- }
1051
-
1052
- if ($userAgent) {
1053
- $this->setUserAgent($userAgent);
1054
- }
1055
-
1056
- $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
1057
-
1058
- if ($this->checkHttpHeadersForMobile()) {
1059
- return true;
1060
- } else {
1061
- return $this->matchDetectionRulesAgainstUA();
1062
- }
1063
-
1064
- }
1065
-
1066
- /**
1067
- * Check if the device is a tablet.
1068
- * Return true if any type of tablet device is detected.
1069
- *
1070
- * @param string $userAgent deprecated
1071
- * @param array $httpHeaders deprecated
1072
- * @return bool
1073
- */
1074
- public function isTablet($userAgent = null, $httpHeaders = null)
1075
- {
1076
- $this->setDetectionType(self::DETECTION_TYPE_MOBILE);
1077
-
1078
- foreach (self::$tabletDevices as $_regex) {
1079
- if ($this->match($_regex, $userAgent)) {
1080
- return true;
1081
- }
1082
- }
1083
-
1084
- return false;
1085
- }
1086
-
1087
- /**
1088
- * This method checks for a certain property in the
1089
- * userAgent.
1090
- * @todo: The httpHeaders part is not yet used.
1091
- *
1092
- * @param string $key
1093
- * @param string $userAgent deprecated
1094
- * @param string $httpHeaders deprecated
1095
- * @return bool|int|null
1096
- */
1097
- public function is($key, $userAgent = null, $httpHeaders = null)
1098
- {
1099
- // Set the UA and HTTP headers only if needed (eg. batch mode).
1100
- if ($httpHeaders) {
1101
- $this->setHttpHeaders($httpHeaders);
1102
- }
1103
-
1104
- if ($userAgent) {
1105
- $this->setUserAgent($userAgent);
1106
- }
1107
-
1108
- $this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
1109
-
1110
- return $this->matchUAAgainstKey($key);
1111
- }
1112
-
1113
- /**
1114
- * Some detection rules are relative (not standard),
1115
- * because of the diversity of devices, vendors and
1116
- * their conventions in representing the User-Agent or
1117
- * the HTTP headers.
1118
- *
1119
- * This method will be used to check custom regexes against
1120
- * the User-Agent string.
1121
- *
1122
- * @param $regex
1123
- * @param string $userAgent
1124
- * @return bool
1125
- *
1126
- * @todo: search in the HTTP headers too.
1127
- */
1128
- public function match($regex, $userAgent = null)
1129
- {
1130
- $match = (bool) preg_match(sprintf('#%s#is', $regex), (false === empty($userAgent) ? $userAgent : $this->userAgent), $matches);
1131
- // If positive match is found, store the results for debug.
1132
- if ($match) {
1133
- $this->matchingRegex = $regex;
1134
- $this->matchesArray = $matches;
1135
- }
1136
-
1137
- return $match;
1138
- }
1139
-
1140
- /**
1141
- * Get the properties array.
1142
- *
1143
- * @return array
1144
- */
1145
- public static function getProperties()
1146
- {
1147
- return self::$properties;
1148
- }
1149
-
1150
- /**
1151
- * Prepare the version number.
1152
- *
1153
- * @todo Remove the error supression from str_replace() call.
1154
- *
1155
- * @param string $ver The string version, like "2.6.21.2152";
1156
- *
1157
- * @return float
1158
- */
1159
- public function prepareVersionNo($ver)
1160
- {
1161
- $ver = str_replace(array('_', ' ', '/'), '.', $ver);
1162
- $arrVer = explode('.', $ver, 2);
1163
-
1164
- if (isset($arrVer[1])) {
1165
- $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions.
1166
- }
1167
-
1168
- return (float) implode('.', $arrVer);
1169
- }
1170
-
1171
- /**
1172
- * Check the version of the given property in the User-Agent.
1173
- * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31)
1174
- *
1175
- * @param string $propertyName The name of the property. See self::getProperties() array
1176
- * keys for all possible properties.
1177
- * @param string $type Either self::VERSION_TYPE_STRING to get a string value or
1178
- * self::VERSION_TYPE_FLOAT indicating a float value. This parameter
1179
- * is optional and defaults to self::VERSION_TYPE_STRING. Passing an
1180
- * invalid parameter will default to the this type as well.
1181
- *
1182
- * @return string|float The version of the property we are trying to extract.
1183
- */
1184
- public function version($propertyName, $type = self::VERSION_TYPE_STRING)
1185
- {
1186
- if (empty($propertyName)) {
1187
- return false;
1188
- }
1189
-
1190
- // set the $type to the default if we don't recognize the type
1191
- if ($type !== self::VERSION_TYPE_STRING && $type !== self::VERSION_TYPE_FLOAT) {
1192
- $type = self::VERSION_TYPE_STRING;
1193
- }
1194
-
1195
- $properties = self::getProperties();
1196
-
1197
- // Check if the property exists in the properties array.
1198
- if (true === isset($properties[$propertyName])) {
1199
-
1200
- // Prepare the pattern to be matched.
1201
- // Make sure we always deal with an array (string is converted).
1202
- $properties[$propertyName] = (array) $properties[$propertyName];
1203
-
1204
- foreach ($properties[$propertyName] as $propertyMatchString) {
1205
-
1206
- $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
1207
-
1208
- // Identify and extract the version.
1209
- preg_match(sprintf('#%s#is', $propertyPattern), $this->userAgent, $match);
1210
-
1211
- if (false === empty($match[1])) {
1212
- $version = ($type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1]);
1213
-
1214
- return $version;
1215
- }
1216
-
1217
- }
1218
-
1219
- }
1220
-
1221
- return false;
1222
- }
1223
-
1224
- /**
1225
- * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
1226
- *
1227
- * @return string One of the self::MOBILE_GRADE_* constants.
1228
- */
1229
- public function mobileGrade()
1230
- {
1231
- $isMobile = $this->isMobile();
1232
-
1233
- if (
1234
- // Apple iOS 4-7.0 – Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3 / 5.1 / 6.1), iPad 3 (5.1 / 6.0), iPad Mini (6.1), iPad Retina (7.0), iPhone 3GS (4.3), iPhone 4 (4.3 / 5.1), iPhone 4S (5.1 / 6.0), iPhone 5 (6.0), and iPhone 5S (7.0)
1235
- $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
1236
- $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3 ||
1237
- $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
1238
-
1239
- // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5)
1240
- // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
1241
- // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
1242
- // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
1243
- ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) ||
1244
-
1245
- // Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy (7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520 (8), Nokia Lumia 920 (8), HTC 8x (8)
1246
- $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
1247
-
1248
- // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10)
1249
- $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 6.0 ||
1250
- // Blackberry Playbook (1.0-2.0) - Tested on PlayBook
1251
- $this->match('Playbook.*Tablet') ||
1252
-
1253
- // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
1254
- ( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) ||
1255
- // Palm WebOS 3.0 - Tested on HP TouchPad
1256
- $this->match('hp.*TouchPad') ||
1257
-
1258
- // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
1259
- ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) ||
1260
-
1261
- // Chrome for Android - Tested on Android 4.0, 4.1 device
1262
- ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) ||
1263
-
1264
- // Skyfire 4.1 - Tested on Android 2.3 device
1265
- ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
1266
-
1267
- // Opera Mobile 11.5-12: Tested on Android 2.3
1268
- ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) ||
1269
-
1270
- // Meego 1.2 - Tested on Nokia 950 and N9
1271
- $this->is('MeeGoOS') ||
1272
-
1273
- // Tizen (pre-release) - Tested on early hardware
1274
- $this->is('Tizen') ||
1275
-
1276
- // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
1277
- // @todo: more tests here!
1278
- $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
1279
-
1280
- // UC Browser - Tested on Android 2.3 device
1281
- ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) ||
1282
-
1283
- // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
1284
- ( $this->match('Kindle Fire') ||
1285
- $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
1286
-
1287
- // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
1288
- $this->is('AndroidOS') && $this->is('NookTablet') ||
1289
-
1290
- // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
1291
- $this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16 && !$isMobile ||
1292
-
1293
- // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
1294
- $this->version('Safari', self::VERSION_TYPE_FLOAT) >= 5.0 && !$isMobile ||
1295
-
1296
- // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
1297
- $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 10.0 && !$isMobile ||
1298
-
1299
- // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
1300
- $this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0 && !$isMobile ||
1301
-
1302
- // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
1303
- $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
1304
- ){
1305
- return self::MOBILE_GRADE_A;
1306
- }
1307
-
1308
- if (
1309
- $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 ||
1310
- $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 ||
1311
- $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 ||
1312
-
1313
- // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
1314
- $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 ||
1315
-
1316
- //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
1317
- ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
1318
- ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) ||
1319
-
1320
- // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
1321
- $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
1322
-
1323
- // @todo: report this (tested on Nokia N71)
1324
- $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
1325
- ){
1326
- return self::MOBILE_GRADE_B;
1327
- }
1328
-
1329
- if (
1330
- // Blackberry 4.x - Tested on the Curve 8330
1331
- $this->version('BlackBerry', self::VERSION_TYPE_FLOAT) <= 5.0 ||
1332
- // Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
1333
- $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT) <= 5.2 ||
1334
-
1335
- // Tested on original iPhone (3.1), iPhone 3 (3.2)
1336
- $this->is('iOS') && $this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
1337
- $this->is('iOS') && $this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2 ||
1338
- $this->is('iOS') && $this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
1339
-
1340
- // Internet Explorer 7 and older - Tested on Windows XP
1341
- $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
1342
- ){
1343
- return self::MOBILE_GRADE_C;
1344
- }
1345
-
1346
- // All older smartphone platforms and featurephones - Any device that doesn't support media queries
1347
- // will receive the basic, C grade experience.
1348
- return self::MOBILE_GRADE_C;
1349
- }
1350
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/GoMage/OAuth/Credentials.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GoMage Social Connector Extension
4
+ *
5
+ * @category Extension
6
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
7
+ * @author GoMage
8
+ * @license http://www.gomage.com/license-agreement/ Single domain license
9
+ * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
+ * @since Class available since Release 1.2.0
12
+ */
13
+
14
+ class GoMage_OAuth_Credentials extends Varien_Object
15
+ {
16
+ public function _construct()
17
+ {
18
+ if (!$this->getClientId()) {
19
+ throw new Exception('client_id is required');
20
+ } else if (!$this->getClientSecret()) {
21
+ throw new Exception('client_secret is required');
22
+ } else if (!$this->getRedirectUri()) {
23
+ throw new Exception('redirect_uri is required');
24
+ }
25
+ }
26
+ }
lib/GoMage/OAuth/OAuth.php ADDED
@@ -0,0 +1,865 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class OAuthConsumer {
4
+ public $key;
5
+ public $secret;
6
+
7
+ function __construct($key, $secret, $callback_url=NULL) {
8
+ $this->key = $key;
9
+ $this->secret = $secret;
10
+ $this->callback_url = $callback_url;
11
+ }
12
+
13
+ function __toString() {
14
+ return "OAuthConsumer[key=$this->key,secret=$this->secret]";
15
+ }
16
+ }
17
+
18
+ class OAuthToken {
19
+ // access tokens and request tokens
20
+ public $key;
21
+ public $secret;
22
+
23
+ /**
24
+ * key = the token
25
+ * secret = the token secret
26
+ */
27
+ function __construct($key, $secret) {
28
+ $this->key = $key;
29
+ $this->secret = $secret;
30
+ }
31
+
32
+ /**
33
+ * generates the basic string serialization of a token that a server
34
+ * would respond to request_token and access_token calls with
35
+ */
36
+ function to_string() {
37
+ return "oauth_token=" .
38
+ OAuthUtil::urlencode_rfc3986($this->key) .
39
+ "&oauth_token_secret=" .
40
+ OAuthUtil::urlencode_rfc3986($this->secret);
41
+ }
42
+
43
+ function __toString() {
44
+ return $this->to_string();
45
+ }
46
+ }
47
+
48
+ /**
49
+ * A class for implementing a Signature Method
50
+ * See section 9 ("Signing Requests") in the spec
51
+ */
52
+ abstract class OAuthSignatureMethod {
53
+ /**
54
+ * Needs to return the name of the Signature Method (ie HMAC-SHA1)
55
+ * @return string
56
+ */
57
+ abstract public function get_name();
58
+
59
+ /**
60
+ * Build up the signature
61
+ * NOTE: The output of this function MUST NOT be urlencoded.
62
+ * the encoding is handled in OAuthRequest when the final
63
+ * request is serialized
64
+ * @param OAuthRequest $request
65
+ * @param OAuthConsumer $consumer
66
+ * @param OAuthToken $token
67
+ * @return string
68
+ */
69
+ abstract public function build_signature($request, $consumer, $token);
70
+
71
+ /**
72
+ * Verifies that a given signature is correct
73
+ * @param OAuthRequest $request
74
+ * @param OAuthConsumer $consumer
75
+ * @param OAuthToken $token
76
+ * @param string $signature
77
+ * @return bool
78
+ */
79
+ public function check_signature($request, $consumer, $token, $signature) {
80
+ $built = $this->build_signature($request, $consumer, $token);
81
+ return $built == $signature;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
87
+ * where the Signature Base String is the text and the key is the concatenated values (each first
88
+ * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
89
+ * character (ASCII code 38) even if empty.
90
+ * - Chapter 9.2 ("HMAC-SHA1")
91
+ */
92
+ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
93
+ function get_name() {
94
+ return "HMAC-SHA1";
95
+ }
96
+
97
+ public function build_signature($request, $consumer, $token) {
98
+ $base_string = $request->get_signature_base_string();
99
+ $request->base_string = $base_string;
100
+
101
+ $key_parts = array(
102
+ $consumer->secret,
103
+ ($token) ? $token->secret : ""
104
+ );
105
+
106
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
107
+ $key = implode('&', $key_parts);
108
+
109
+ return base64_encode(hash_hmac('sha1', $base_string, $key, true));
110
+ }
111
+ }
112
+
113
+ /**
114
+ * The PLAINTEXT method does not provide any security protection and SHOULD only be used
115
+ * over a secure channel such as HTTPS. It does not use the Signature Base String.
116
+ * - Chapter 9.4 ("PLAINTEXT")
117
+ */
118
+ class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
119
+ public function get_name() {
120
+ return "PLAINTEXT";
121
+ }
122
+
123
+ /**
124
+ * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
125
+ * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
126
+ * empty. The result MUST be encoded again.
127
+ * - Chapter 9.4.1 ("Generating Signatures")
128
+ *
129
+ * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
130
+ * OAuthRequest handles this!
131
+ */
132
+ public function build_signature($request, $consumer, $token) {
133
+ $key_parts = array(
134
+ $consumer->secret,
135
+ ($token) ? $token->secret : ""
136
+ );
137
+
138
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
139
+ $key = implode('&', $key_parts);
140
+ $request->base_string = $key;
141
+
142
+ return $key;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
148
+ * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
149
+ * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
150
+ * verified way to the Service Provider, in a manner which is beyond the scope of this
151
+ * specification.
152
+ * - Chapter 9.3 ("RSA-SHA1")
153
+ */
154
+ abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
155
+ public function get_name() {
156
+ return "RSA-SHA1";
157
+ }
158
+
159
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
160
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
161
+ // (2) fetch via http using a url provided by the requester
162
+ // (3) some sort of specific discovery code based on request
163
+ //
164
+ // Either way should return a string representation of the certificate
165
+ protected abstract function fetch_public_cert(&$request);
166
+
167
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
168
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
169
+ //
170
+ // Either way should return a string representation of the certificate
171
+ protected abstract function fetch_private_cert(&$request);
172
+
173
+ public function build_signature($request, $consumer, $token) {
174
+ $base_string = $request->get_signature_base_string();
175
+ $request->base_string = $base_string;
176
+
177
+ // Fetch the private key cert based on the request
178
+ $cert = $this->fetch_private_cert($request);
179
+
180
+ // Pull the private key ID from the certificate
181
+ $privatekeyid = openssl_get_privatekey($cert);
182
+
183
+ // Sign using the key
184
+ $ok = openssl_sign($base_string, $signature, $privatekeyid);
185
+
186
+ // Release the key resource
187
+ openssl_free_key($privatekeyid);
188
+
189
+ return base64_encode($signature);
190
+ }
191
+
192
+ public function check_signature($request, $consumer, $token, $signature) {
193
+ $decoded_sig = base64_decode($signature);
194
+
195
+ $base_string = $request->get_signature_base_string();
196
+
197
+ // Fetch the public key cert based on the request
198
+ $cert = $this->fetch_public_cert($request);
199
+
200
+ // Pull the public key ID from the certificate
201
+ $publickeyid = openssl_get_publickey($cert);
202
+
203
+ // Check the computed signature against the one passed in the query
204
+ $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
205
+
206
+ // Release the key resource
207
+ openssl_free_key($publickeyid);
208
+
209
+ return $ok == 1;
210
+ }
211
+ }
212
+
213
+ class OAuthRequest {
214
+ private $parameters;
215
+ private $http_method;
216
+ private $http_url;
217
+ // for debug purposes
218
+ public $base_string;
219
+ public static $version = '1.0';
220
+ public static $POST_INPUT = 'php://input';
221
+
222
+ function __construct($http_method, $http_url, $parameters=NULL) {
223
+ @$parameters or $parameters = array();
224
+ $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
225
+ $this->parameters = $parameters;
226
+ $this->http_method = $http_method;
227
+ $this->http_url = $http_url;
228
+ }
229
+
230
+
231
+ /**
232
+ * attempt to build up a request from what was passed to the server
233
+ */
234
+ public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
235
+ $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
236
+ ? 'http'
237
+ : 'https';
238
+ @$http_url or $http_url = $scheme .
239
+ '://' . $_SERVER['HTTP_HOST'] .
240
+ ':' .
241
+ $_SERVER['SERVER_PORT'] .
242
+ $_SERVER['REQUEST_URI'];
243
+ @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
244
+
245
+ // We weren't handed any parameters, so let's find the ones relevant to
246
+ // this request.
247
+ // If you run XML-RPC or similar you should use this to provide your own
248
+ // parsed parameter-list
249
+ if (!$parameters) {
250
+ // Find request headers
251
+ $request_headers = OAuthUtil::get_headers();
252
+
253
+ // Parse the query-string to find GET parameters
254
+ $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
255
+
256
+ // It's a POST request of the proper content-type, so parse POST
257
+ // parameters and add those overriding any duplicates from GET
258
+ if ($http_method == "POST"
259
+ && @strstr($request_headers["Content-Type"],
260
+ "application/x-www-form-urlencoded")
261
+ ) {
262
+ $post_data = OAuthUtil::parse_parameters(
263
+ file_get_contents(self::$POST_INPUT)
264
+ );
265
+ $parameters = array_merge($parameters, $post_data);
266
+ }
267
+
268
+ // We have a Authorization-header with OAuth data. Parse the header
269
+ // and add those overriding any duplicates from GET or POST
270
+ if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
271
+ $header_parameters = OAuthUtil::split_header(
272
+ $request_headers['Authorization']
273
+ );
274
+ $parameters = array_merge($parameters, $header_parameters);
275
+ }
276
+
277
+ }
278
+
279
+ return new OAuthRequest($http_method, $http_url, $parameters);
280
+ }
281
+
282
+ /**
283
+ * pretty much a helper function to set up the request
284
+ */
285
+ public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
286
+ @$parameters or $parameters = array();
287
+ $defaults = array("oauth_version" => OAuthRequest::$version,
288
+ "oauth_nonce" => OAuthRequest::generate_nonce(),
289
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
290
+ "oauth_consumer_key" => $consumer->key);
291
+ if ($token)
292
+ $defaults['oauth_token'] = $token->key;
293
+
294
+ $parameters = array_merge($defaults, $parameters);
295
+
296
+ return new OAuthRequest($http_method, $http_url, $parameters);
297
+ }
298
+
299
+ public function set_parameter($name, $value, $allow_duplicates = true) {
300
+ if ($allow_duplicates && isset($this->parameters[$name])) {
301
+ // We have already added parameter(s) with this name, so add to the list
302
+ if (is_scalar($this->parameters[$name])) {
303
+ // This is the first duplicate, so transform scalar (string)
304
+ // into an array so we can add the duplicates
305
+ $this->parameters[$name] = array($this->parameters[$name]);
306
+ }
307
+
308
+ $this->parameters[$name][] = $value;
309
+ } else {
310
+ $this->parameters[$name] = $value;
311
+ }
312
+ }
313
+
314
+ public function get_parameter($name) {
315
+ return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
316
+ }
317
+
318
+ public function get_parameters() {
319
+ return $this->parameters;
320
+ }
321
+
322
+ public function unset_parameter($name) {
323
+ unset($this->parameters[$name]);
324
+ }
325
+
326
+ /**
327
+ * The request parameters, sorted and concatenated into a normalized string.
328
+ * @return string
329
+ */
330
+ public function get_signable_parameters() {
331
+ // Grab all parameters
332
+ $params = $this->parameters;
333
+
334
+ // Remove oauth_signature if present
335
+ // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
336
+ if (isset($params['oauth_signature'])) {
337
+ unset($params['oauth_signature']);
338
+ }
339
+
340
+ return OAuthUtil::build_http_query($params);
341
+ }
342
+
343
+ /**
344
+ * Returns the base string of this request
345
+ *
346
+ * The base string defined as the method, the url
347
+ * and the parameters (normalized), each urlencoded
348
+ * and the concated with &.
349
+ */
350
+ public function get_signature_base_string() {
351
+ $parts = array(
352
+ $this->get_normalized_http_method(),
353
+ $this->get_normalized_http_url(),
354
+ $this->get_signable_parameters()
355
+ );
356
+
357
+ $parts = OAuthUtil::urlencode_rfc3986($parts);
358
+
359
+ return implode('&', $parts);
360
+ }
361
+
362
+ /**
363
+ * just uppercases the http method
364
+ */
365
+ public function get_normalized_http_method() {
366
+ return strtoupper($this->http_method);
367
+ }
368
+
369
+ /**
370
+ * parses the url and rebuilds it to be
371
+ * scheme://host/path
372
+ */
373
+ public function get_normalized_http_url() {
374
+ $parts = parse_url($this->http_url);
375
+
376
+ $port = @$parts['port'];
377
+ $scheme = $parts['scheme'];
378
+ $host = $parts['host'];
379
+ $path = @$parts['path'];
380
+
381
+ $port or $port = ($scheme == 'https') ? '443' : '80';
382
+
383
+ if (($scheme == 'https' && $port != '443')
384
+ || ($scheme == 'http' && $port != '80')) {
385
+ $host = "$host:$port";
386
+ }
387
+ return "$scheme://$host$path";
388
+ }
389
+
390
+ /**
391
+ * builds a url usable for a GET request
392
+ */
393
+ public function to_url() {
394
+ $post_data = $this->to_postdata();
395
+ $out = $this->get_normalized_http_url();
396
+ if ($post_data) {
397
+ $out .= '?'.$post_data;
398
+ }
399
+ return $out;
400
+ }
401
+
402
+ /**
403
+ * builds the data one would send in a POST request
404
+ */
405
+ public function to_postdata() {
406
+ return OAuthUtil::build_http_query($this->parameters);
407
+ }
408
+
409
+ /**
410
+ * builds the Authorization: header
411
+ */
412
+ public function to_header($realm=null) {
413
+ $first = true;
414
+ if($realm) {
415
+ $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
416
+ $first = false;
417
+ } else
418
+ $out = 'Authorization: OAuth';
419
+
420
+ $total = array();
421
+ foreach ($this->parameters as $k => $v) {
422
+ if (substr($k, 0, 5) != "oauth") continue;
423
+ if (is_array($v)) {
424
+ throw new OAuthException('Arrays not supported in headers');
425
+ }
426
+ $out .= ($first) ? ' ' : ',';
427
+ $out .= OAuthUtil::urlencode_rfc3986($k) .
428
+ '="' .
429
+ OAuthUtil::urlencode_rfc3986($v) .
430
+ '"';
431
+ $first = false;
432
+ }
433
+ return $out;
434
+ }
435
+
436
+ public function __toString() {
437
+ return $this->to_url();
438
+ }
439
+
440
+
441
+ public function sign_request($signature_method, $consumer, $token) {
442
+ $this->set_parameter(
443
+ "oauth_signature_method",
444
+ $signature_method->get_name(),
445
+ false
446
+ );
447
+ $signature = $this->build_signature($signature_method, $consumer, $token);
448
+ $this->set_parameter("oauth_signature", $signature, false);
449
+ }
450
+
451
+ public function build_signature($signature_method, $consumer, $token) {
452
+ $signature = $signature_method->build_signature($this, $consumer, $token);
453
+ return $signature;
454
+ }
455
+
456
+ /**
457
+ * util function: current timestamp
458
+ */
459
+ private static function generate_timestamp() {
460
+ return time();
461
+ }
462
+
463
+ /**
464
+ * util function: current nonce
465
+ */
466
+ private static function generate_nonce() {
467
+ $mt = microtime();
468
+ $rand = mt_rand();
469
+
470
+ return md5($mt . $rand); // md5s look nicer than numbers
471
+ }
472
+ }
473
+
474
+ class OAuthServer {
475
+ protected $timestamp_threshold = 300; // in seconds, five minutes
476
+ protected $version = '1.0'; // hi blaine
477
+ protected $signature_methods = array();
478
+
479
+ protected $data_store;
480
+
481
+ function __construct($data_store) {
482
+ $this->data_store = $data_store;
483
+ }
484
+
485
+ public function add_signature_method($signature_method) {
486
+ $this->signature_methods[$signature_method->get_name()] =
487
+ $signature_method;
488
+ }
489
+
490
+ // high level functions
491
+
492
+ /**
493
+ * process a request_token request
494
+ * returns the request token on success
495
+ */
496
+ public function fetch_request_token(&$request) {
497
+ $this->get_version($request);
498
+
499
+ $consumer = $this->get_consumer($request);
500
+
501
+ // no token required for the initial token request
502
+ $token = NULL;
503
+
504
+ $this->check_signature($request, $consumer, $token);
505
+
506
+ // Rev A change
507
+ $callback = $request->get_parameter('oauth_callback');
508
+ $new_token = $this->data_store->new_request_token($consumer, $callback);
509
+
510
+ return $new_token;
511
+ }
512
+
513
+ /**
514
+ * process an access_token request
515
+ * returns the access token on success
516
+ */
517
+ public function fetch_access_token(&$request) {
518
+ $this->get_version($request);
519
+
520
+ $consumer = $this->get_consumer($request);
521
+
522
+ // requires authorized request token
523
+ $token = $this->get_token($request, $consumer, "request");
524
+
525
+ $this->check_signature($request, $consumer, $token);
526
+
527
+ // Rev A change
528
+ $verifier = $request->get_parameter('oauth_verifier');
529
+ $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
530
+
531
+ return $new_token;
532
+ }
533
+
534
+ /**
535
+ * verify an api call, checks all the parameters
536
+ */
537
+ public function verify_request(&$request) {
538
+ $this->get_version($request);
539
+ $consumer = $this->get_consumer($request);
540
+ $token = $this->get_token($request, $consumer, "access");
541
+ $this->check_signature($request, $consumer, $token);
542
+ return array($consumer, $token);
543
+ }
544
+
545
+ // Internals from here
546
+ /**
547
+ * version 1
548
+ */
549
+ private function get_version(&$request) {
550
+ $version = $request->get_parameter("oauth_version");
551
+ if (!$version) {
552
+ // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
553
+ // Chapter 7.0 ("Accessing Protected Ressources")
554
+ $version = '1.0';
555
+ }
556
+ if ($version !== $this->version) {
557
+ throw new OAuthException("OAuth version '$version' not supported");
558
+ }
559
+ return $version;
560
+ }
561
+
562
+ /**
563
+ * figure out the signature with some defaults
564
+ */
565
+ private function get_signature_method(&$request) {
566
+ $signature_method =
567
+ @$request->get_parameter("oauth_signature_method");
568
+
569
+ if (!$signature_method) {
570
+ // According to chapter 7 ("Accessing Protected Ressources") the signature-method
571
+ // parameter is required, and we can't just fallback to PLAINTEXT
572
+ throw new OAuthException('No signature method parameter. This parameter is required');
573
+ }
574
+
575
+ if (!in_array($signature_method,
576
+ array_keys($this->signature_methods))) {
577
+ throw new OAuthException(
578
+ "Signature method '$signature_method' not supported " .
579
+ "try one of the following: " .
580
+ implode(", ", array_keys($this->signature_methods))
581
+ );
582
+ }
583
+ return $this->signature_methods[$signature_method];
584
+ }
585
+
586
+ /**
587
+ * try to find the consumer for the provided request's consumer key
588
+ */
589
+ private function get_consumer(&$request) {
590
+ $consumer_key = @$request->get_parameter("oauth_consumer_key");
591
+ if (!$consumer_key) {
592
+ throw new OAuthException("Invalid consumer key");
593
+ }
594
+
595
+ $consumer = $this->data_store->lookup_consumer($consumer_key);
596
+ if (!$consumer) {
597
+ throw new OAuthException("Invalid consumer");
598
+ }
599
+
600
+ return $consumer;
601
+ }
602
+
603
+ /**
604
+ * try to find the token for the provided request's token key
605
+ */
606
+ private function get_token(&$request, $consumer, $token_type="access") {
607
+ $token_field = @$request->get_parameter('oauth_token');
608
+ $token = $this->data_store->lookup_token(
609
+ $consumer, $token_type, $token_field
610
+ );
611
+ if (!$token) {
612
+ throw new OAuthException("Invalid $token_type token: $token_field");
613
+ }
614
+ return $token;
615
+ }
616
+
617
+ /**
618
+ * all-in-one function to check the signature on a request
619
+ * should guess the signature method appropriately
620
+ */
621
+ private function check_signature(&$request, $consumer, $token) {
622
+ // this should probably be in a different method
623
+ $timestamp = @$request->get_parameter('oauth_timestamp');
624
+ $nonce = @$request->get_parameter('oauth_nonce');
625
+
626
+ $this->check_timestamp($timestamp);
627
+ $this->check_nonce($consumer, $token, $nonce, $timestamp);
628
+
629
+ $signature_method = $this->get_signature_method($request);
630
+
631
+ $signature = $request->get_parameter('oauth_signature');
632
+ $valid_sig = $signature_method->check_signature(
633
+ $request,
634
+ $consumer,
635
+ $token,
636
+ $signature
637
+ );
638
+
639
+ if (!$valid_sig) {
640
+ throw new OAuthException("Invalid signature");
641
+ }
642
+ }
643
+
644
+ /**
645
+ * check that the timestamp is new enough
646
+ */
647
+ private function check_timestamp($timestamp) {
648
+ if( ! $timestamp )
649
+ throw new OAuthException(
650
+ 'Missing timestamp parameter. The parameter is required'
651
+ );
652
+
653
+ // verify that timestamp is recentish
654
+ $now = time();
655
+ if (abs($now - $timestamp) > $this->timestamp_threshold) {
656
+ throw new OAuthException(
657
+ "Expired timestamp, yours $timestamp, ours $now"
658
+ );
659
+ }
660
+ }
661
+
662
+ /**
663
+ * check that the nonce is not repeated
664
+ */
665
+ private function check_nonce($consumer, $token, $nonce, $timestamp) {
666
+ if( ! $nonce )
667
+ throw new OAuthException(
668
+ 'Missing nonce parameter. The parameter is required'
669
+ );
670
+
671
+ // verify that the nonce is uniqueish
672
+ $found = $this->data_store->lookup_nonce(
673
+ $consumer,
674
+ $token,
675
+ $nonce,
676
+ $timestamp
677
+ );
678
+ if ($found) {
679
+ throw new OAuthException("Nonce already used: $nonce");
680
+ }
681
+ }
682
+
683
+ }
684
+
685
+ class OAuthDataStore {
686
+ function lookup_consumer($consumer_key) {
687
+ // implement me
688
+ }
689
+
690
+ function lookup_token($consumer, $token_type, $token) {
691
+ // implement me
692
+ }
693
+
694
+ function lookup_nonce($consumer, $token, $nonce, $timestamp) {
695
+ // implement me
696
+ }
697
+
698
+ function new_request_token($consumer, $callback = null) {
699
+ // return a new token attached to this consumer
700
+ }
701
+
702
+ function new_access_token($token, $consumer, $verifier = null) {
703
+ // return a new access token attached to this consumer
704
+ // for the user associated with this token if the request token
705
+ // is authorized
706
+ // should also invalidate the request token
707
+ }
708
+
709
+ }
710
+
711
+ class OAuthUtil {
712
+ public static function urlencode_rfc3986($input) {
713
+ if (is_array($input)) {
714
+ return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
715
+ } else if (is_scalar($input)) {
716
+ return str_replace(
717
+ '+',
718
+ ' ',
719
+ str_replace('%7E', '~', rawurlencode($input))
720
+ );
721
+ } else {
722
+ return '';
723
+ }
724
+ }
725
+
726
+
727
+ // This decode function isn't taking into consideration the above
728
+ // modifications to the encoding process. However, this method doesn't
729
+ // seem to be used anywhere so leaving it as is.
730
+ public static function urldecode_rfc3986($string) {
731
+ return urldecode($string);
732
+ }
733
+
734
+ // Utility function for turning the Authorization: header into
735
+ // parameters, has to do some unescaping
736
+ // Can filter out any non-oauth parameters if needed (default behaviour)
737
+ public static function split_header($header, $only_allow_oauth_parameters = true) {
738
+ $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
739
+ $offset = 0;
740
+ $params = array();
741
+ while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
742
+ $match = $matches[0];
743
+ $header_name = $matches[2][0];
744
+ $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
745
+ if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
746
+ $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
747
+ }
748
+ $offset = $match[1] + strlen($match[0]);
749
+ }
750
+
751
+ if (isset($params['realm'])) {
752
+ unset($params['realm']);
753
+ }
754
+
755
+ return $params;
756
+ }
757
+
758
+ // helper to try to sort out headers for people who aren't running apache
759
+ public static function get_headers() {
760
+ if (function_exists('apache_request_headers')) {
761
+ // we need this to get the actual Authorization: header
762
+ // because apache tends to tell us it doesn't exist
763
+ $headers = apache_request_headers();
764
+
765
+ // sanitize the output of apache_request_headers because
766
+ // we always want the keys to be Cased-Like-This and arh()
767
+ // returns the headers in the same case as they are in the
768
+ // request
769
+ $out = array();
770
+ foreach( $headers AS $key => $value ) {
771
+ $key = str_replace(
772
+ " ",
773
+ "-",
774
+ ucwords(strtolower(str_replace("-", " ", $key)))
775
+ );
776
+ $out[$key] = $value;
777
+ }
778
+ } else {
779
+ // otherwise we don't have apache and are just going to have to hope
780
+ // that $_SERVER actually contains what we need
781
+ $out = array();
782
+ if( isset($_SERVER['CONTENT_TYPE']) )
783
+ $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
784
+ if( isset($_ENV['CONTENT_TYPE']) )
785
+ $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
786
+
787
+ foreach ($_SERVER as $key => $value) {
788
+ if (substr($key, 0, 5) == "HTTP_") {
789
+ // this is chaos, basically it is just there to capitalize the first
790
+ // letter of every word that is not an initial HTTP and strip HTTP
791
+ // code from przemek
792
+ $key = str_replace(
793
+ " ",
794
+ "-",
795
+ ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
796
+ );
797
+ $out[$key] = $value;
798
+ }
799
+ }
800
+ }
801
+ return $out;
802
+ }
803
+
804
+ // This function takes a input like a=b&a=c&d=e and returns the parsed
805
+ // parameters like this
806
+ // array('a' => array('b','c'), 'd' => 'e')
807
+ public static function parse_parameters( $input ) {
808
+ if (!isset($input) || !$input) return array();
809
+
810
+ $pairs = explode('&', $input);
811
+
812
+ $parsed_parameters = array();
813
+ foreach ($pairs as $pair) {
814
+ $split = explode('=', $pair, 2);
815
+ $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
816
+ $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
817
+
818
+ if (isset($parsed_parameters[$parameter])) {
819
+ // We have already recieved parameter(s) with this name, so add to the list
820
+ // of parameters with this name
821
+
822
+ if (is_scalar($parsed_parameters[$parameter])) {
823
+ // This is the first duplicate, so transform scalar (string) into an array
824
+ // so we can add the duplicates
825
+ $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
826
+ }
827
+
828
+ $parsed_parameters[$parameter][] = $value;
829
+ } else {
830
+ $parsed_parameters[$parameter] = $value;
831
+ }
832
+ }
833
+ return $parsed_parameters;
834
+ }
835
+
836
+ public static function build_http_query($params) {
837
+ if (!$params) return '';
838
+
839
+ // Urlencode both keys and values
840
+ $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
841
+ $values = OAuthUtil::urlencode_rfc3986(array_values($params));
842
+ $params = array_combine($keys, $values);
843
+
844
+ // Parameters are sorted by name, using lexicographical byte value ordering.
845
+ // Ref: Spec: 9.1.1 (1)
846
+ uksort($params, 'strcmp');
847
+
848
+ $pairs = array();
849
+ foreach ($params as $parameter => $value) {
850
+ if (is_array($value)) {
851
+ // If two or more parameters share the same name, they are sorted by their value
852
+ // Ref: Spec: 9.1.1 (1)
853
+ natsort($value);
854
+ foreach ($value as $duplicate_value) {
855
+ $pairs[] = $parameter . '=' . $duplicate_value;
856
+ }
857
+ } else {
858
+ $pairs[] = $parameter . '=' . $value;
859
+ }
860
+ }
861
+ // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
862
+ // Each name-value pair is separated by an '&' character (ASCII code 38)
863
+ return implode('&', $pairs);
864
+ }
865
+ }
lib/GoMage/OAuth/Service.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GoMage Social Connector Extension
4
+ *
5
+ * @category Extension
6
+ * @copyright Copyright (c) 2013-2015 GoMage (http://www.gomage.com)
7
+ * @author GoMage
8
+ * @license http://www.gomage.com/license-agreement/ Single domain license
9
+ * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 1.4.0
11
+ * @since Class available since Release 1.2.0
12
+ */
13
+
14
+ class GoMage_OAuth_Service
15
+ {
16
+ const SERVICE_ENDPOINT = null;
17
+ const AUTHORIZATION_ENDPOINT = null;
18
+ const ACCESS_TOKEN_ENDPOINT = null;
19
+
20
+ public static $return_request_error = false;
21
+
22
+ public $http_info = array();
23
+ public $http_response = '';
24
+ public $useragent = '';
25
+ public $connecttimeout = 30;
26
+ public $timeout = 30;
27
+ public $ssl_verifypeer = false;
28
+
29
+ protected $credentials;
30
+
31
+ public function __construct(GoMage_OAuth_Credentials $credentials)
32
+ {
33
+ $this->credentials = $credentials;
34
+ }
35
+
36
+ public function getCredentials()
37
+ {
38
+ return $this->credentials;
39
+ }
40
+
41
+ public function request($url, $method, $parameters = array(), $extraHeaders = array())
42
+ {
43
+ $this->http_info = array();
44
+ $this->http_response = '';
45
+ $ci = curl_init();
46
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
47
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
48
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
49
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);
50
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
51
+ curl_setopt($ci, CURLOPT_HEADER, false);
52
+
53
+ switch ($method) {
54
+ case 'GET' :
55
+ if (!empty($parameters)) {
56
+ $url .= '?' . http_build_query($parameters);
57
+ }
58
+ break;
59
+ case 'POST' :
60
+ curl_setopt($ci, CURLOPT_POST, true);
61
+
62
+ if (!empty($parameters)) {
63
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $parameters);
64
+ }
65
+ break;
66
+ }
67
+
68
+ curl_setopt($ci, CURLOPT_HTTPHEADER, $extraHeaders);
69
+ curl_setopt($ci, CURLOPT_URL, $url);
70
+
71
+ $this->http_response = curl_exec($ci);
72
+ $this->http_info = curl_getinfo($ci);
73
+ $error = curl_error($ci);
74
+
75
+ curl_close($ci);
76
+
77
+ if ($error) {
78
+ throw new Exception($error);
79
+ }
80
+
81
+ if ($this->http_info['http_code'] !== 200) {
82
+ switch (static::$return_request_error) {
83
+ case false :
84
+ throw new Exception('Could not connect to OAuth server. Refresh the page or try again later.');
85
+ break;
86
+ case true :
87
+ throw new Exception(
88
+ "Server OAuth request failed: " .
89
+ "\t\r\n HTTP url: " . $this->http_info['url'] .
90
+ "\t\r\n HTTP code: " . $this->http_info['http_code'] .
91
+ "\t\r\n HTTP response: " . $this->http_response
92
+ );
93
+ break;
94
+ }
95
+ }
96
+
97
+ return $this->http_response;
98
+ }
99
+
100
+ public function getAuthorizationUrl($parameters = array())
101
+ {
102
+ $parameters = array_merge(
103
+ $parameters,
104
+ array(
105
+ 'type' => 'web_server',
106
+ 'client_id' => $this->credentials->getClientId(),
107
+ 'redirect_uri' => $this->credentials->getRedirectUri(),
108
+ 'response_type' => 'code',
109
+ )
110
+ );
111
+
112
+ return static::AUTHORIZATION_ENDPOINT . '?' . http_build_query($parameters);
113
+ }
114
+
115
+ public function getTokenUrl($parameters = array())
116
+ {
117
+ $parameters = array_merge(
118
+ $parameters,
119
+ array(
120
+ 'code' => $this->credentials->getCode(),
121
+ 'client_id' => $this->credentials->getClientId(),
122
+ 'client_secret' => $this->credentials->getClientSecret(),
123
+ 'redirect_uri' => $this->credentials->getRedirectUri(),
124
+ 'grant_type' => 'authorization_code',
125
+ )
126
+ );
127
+
128
+ return static::ACCESS_TOKEN_ENDPOINT . '?' . http_build_query($parameters);
129
+ }
130
+
131
+ public function requestToken($parameters = array())
132
+ {
133
+ $parameters = array_merge(
134
+ $parameters,
135
+ array(
136
+ 'code' => $this->credentials->getCode(),
137
+ 'client_id' => $this->credentials->getClientId(),
138
+ 'client_secret' => $this->credentials->getClientSecret(),
139
+ 'redirect_uri' => $this->credentials->getRedirectUri(),
140
+ 'grant_type' => 'authorization_code',
141
+ )
142
+ );
143
+
144
+ $this->request(static::ACCESS_TOKEN_ENDPOINT, 'POST', $parameters);
145
+
146
+ return new Varien_Object(Zend_Json::decode($this->http_response));
147
+ }
148
+
149
+ public function requestUserProfile($parameters = array())
150
+ {
151
+ $parameters = array_merge(
152
+ $parameters,
153
+ array(
154
+ 'access_token' => $this->credentials
155
+ ->getOauthToken()
156
+ ->getAccessToken(),
157
+ )
158
+ );
159
+
160
+ $this->request(static::SERVICE_ENDPOINT, 'GET', $parameters);
161
+
162
+ return new Varien_Object(Zend_Json::decode($this->http_response));
163
+ }
164
+ }
lib/GoMage/Tumblr/OAuth.php DELETED
@@ -1,874 +0,0 @@
1
- <?php
2
- // vim: foldmethod=marker
3
-
4
- /* Generic exception class
5
- */
6
- class OAuthException extends Exception {
7
- // pass
8
- }
9
-
10
- class OAuthConsumer {
11
- public $key;
12
- public $secret;
13
-
14
- function __construct($key, $secret, $callback_url=NULL) {
15
- $this->key = $key;
16
- $this->secret = $secret;
17
- $this->callback_url = $callback_url;
18
- }
19
-
20
- function __toString() {
21
- return "OAuthConsumer[key=$this->key,secret=$this->secret]";
22
- }
23
- }
24
-
25
- class OAuthToken {
26
- // access tokens and request tokens
27
- public $key;
28
- public $secret;
29
-
30
- /**
31
- * key = the token
32
- * secret = the token secret
33
- */
34
- function __construct($key, $secret) {
35
- $this->key = $key;
36
- $this->secret = $secret;
37
- }
38
-
39
- /**
40
- * generates the basic string serialization of a token that a server
41
- * would respond to request_token and access_token calls with
42
- */
43
- function to_string() {
44
- return "oauth_token=" .
45
- OAuthUtil::urlencode_rfc3986($this->key) .
46
- "&oauth_token_secret=" .
47
- OAuthUtil::urlencode_rfc3986($this->secret);
48
- }
49
-
50
- function __toString() {
51
- return $this->to_string();
52
- }
53
- }
54
-
55
- /**
56
- * A class for implementing a Signature Method
57
- * See section 9 ("Signing Requests") in the spec
58
- */
59
- abstract class OAuthSignatureMethod {
60
- /**
61
- * Needs to return the name of the Signature Method (ie HMAC-SHA1)
62
- * @return string
63
- */
64
- abstract public function get_name();
65
-
66
- /**
67
- * Build up the signature
68
- * NOTE: The output of this function MUST NOT be urlencoded.
69
- * the encoding is handled in OAuthRequest when the final
70
- * request is serialized
71
- * @param OAuthRequest $request
72
- * @param OAuthConsumer $consumer
73
- * @param OAuthToken $token
74
- * @return string
75
- */
76
- abstract public function build_signature($request, $consumer, $token);
77
-
78
- /**
79
- * Verifies that a given signature is correct
80
- * @param OAuthRequest $request
81
- * @param OAuthConsumer $consumer
82
- * @param OAuthToken $token
83
- * @param string $signature
84
- * @return bool
85
- */
86
- public function check_signature($request, $consumer, $token, $signature) {
87
- $built = $this->build_signature($request, $consumer, $token);
88
- return $built == $signature;
89
- }
90
- }
91
-
92
- /**
93
- * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
94
- * where the Signature Base String is the text and the key is the concatenated values (each first
95
- * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
96
- * character (ASCII code 38) even if empty.
97
- * - Chapter 9.2 ("HMAC-SHA1")
98
- */
99
- class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
100
- function get_name() {
101
- return "HMAC-SHA1";
102
- }
103
-
104
- public function build_signature($request, $consumer, $token) {
105
- $base_string = $request->get_signature_base_string();
106
- $request->base_string = $base_string;
107
-
108
- $key_parts = array(
109
- $consumer->secret,
110
- ($token) ? $token->secret : ""
111
- );
112
-
113
- $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
114
- $key = implode('&', $key_parts);
115
-
116
- return base64_encode(hash_hmac('sha1', $base_string, $key, true));
117
- }
118
- }
119
-
120
- /**
121
- * The PLAINTEXT method does not provide any security protection and SHOULD only be used
122
- * over a secure channel such as HTTPS. It does not use the Signature Base String.
123
- * - Chapter 9.4 ("PLAINTEXT")
124
- */
125
- class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
126
- public function get_name() {
127
- return "PLAINTEXT";
128
- }
129
-
130
- /**
131
- * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
132
- * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
133
- * empty. The result MUST be encoded again.
134
- * - Chapter 9.4.1 ("Generating Signatures")
135
- *
136
- * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
137
- * OAuthRequest handles this!
138
- */
139
- public function build_signature($request, $consumer, $token) {
140
- $key_parts = array(
141
- $consumer->secret,
142
- ($token) ? $token->secret : ""
143
- );
144
-
145
- $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
146
- $key = implode('&', $key_parts);
147
- $request->base_string = $key;
148
-
149
- return $key;
150
- }
151
- }
152
-
153
- /**
154
- * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
155
- * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
156
- * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
157
- * verified way to the Service Provider, in a manner which is beyond the scope of this
158
- * specification.
159
- * - Chapter 9.3 ("RSA-SHA1")
160
- */
161
- abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
162
- public function get_name() {
163
- return "RSA-SHA1";
164
- }
165
-
166
- // Up to the SP to implement this lookup of keys. Possible ideas are:
167
- // (1) do a lookup in a table of trusted certs keyed off of consumer
168
- // (2) fetch via http using a url provided by the requester
169
- // (3) some sort of specific discovery code based on request
170
- //
171
- // Either way should return a string representation of the certificate
172
- protected abstract function fetch_public_cert(&$request);
173
-
174
- // Up to the SP to implement this lookup of keys. Possible ideas are:
175
- // (1) do a lookup in a table of trusted certs keyed off of consumer
176
- //
177
- // Either way should return a string representation of the certificate
178
- protected abstract function fetch_private_cert(&$request);
179
-
180
- public function build_signature($request, $consumer, $token) {
181
- $base_string = $request->get_signature_base_string();
182
- $request->base_string = $base_string;
183
-
184
- // Fetch the private key cert based on the request
185
- $cert = $this->fetch_private_cert($request);
186
-
187
- // Pull the private key ID from the certificate
188
- $privatekeyid = openssl_get_privatekey($cert);
189
-
190
- // Sign using the key
191
- $ok = openssl_sign($base_string, $signature, $privatekeyid);
192
-
193
- // Release the key resource
194
- openssl_free_key($privatekeyid);
195
-
196
- return base64_encode($signature);
197
- }
198
-
199
- public function check_signature($request, $consumer, $token, $signature) {
200
- $decoded_sig = base64_decode($signature);
201
-
202
- $base_string = $request->get_signature_base_string();
203
-
204
- // Fetch the public key cert based on the request
205
- $cert = $this->fetch_public_cert($request);
206
-
207
- // Pull the public key ID from the certificate
208
- $publickeyid = openssl_get_publickey($cert);
209
-
210
- // Check the computed signature against the one passed in the query
211
- $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
212
-
213
- // Release the key resource
214
- openssl_free_key($publickeyid);
215
-
216
- return $ok == 1;
217
- }
218
- }
219
-
220
- class OAuthRequest {
221
- private $parameters;
222
- private $http_method;
223
- private $http_url;
224
- // for debug purposes
225
- public $base_string;
226
- public static $version = '1.0';
227
- public static $POST_INPUT = 'php://input';
228
-
229
- function __construct($http_method, $http_url, $parameters=NULL) {
230
- @$parameters or $parameters = array();
231
- $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
232
- $this->parameters = $parameters;
233
- $this->http_method = $http_method;
234
- $this->http_url = $http_url;
235
- }
236
-
237
-
238
- /**
239
- * attempt to build up a request from what was passed to the server
240
- */
241
- public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
242
- $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
243
- ? 'http'
244
- : 'https';
245
- @$http_url or $http_url = $scheme .
246
- '://' . $_SERVER['HTTP_HOST'] .
247
- ':' .
248
- $_SERVER['SERVER_PORT'] .
249
- $_SERVER['REQUEST_URI'];
250
- @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
251
-
252
- // We weren't handed any parameters, so let's find the ones relevant to
253
- // this request.
254
- // If you run XML-RPC or similar you should use this to provide your own
255
- // parsed parameter-list
256
- if (!$parameters) {
257
- // Find request headers
258
- $request_headers = OAuthUtil::get_headers();
259
-
260
- // Parse the query-string to find GET parameters
261
- $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
262
-
263
- // It's a POST request of the proper content-type, so parse POST
264
- // parameters and add those overriding any duplicates from GET
265
- if ($http_method == "POST"
266
- && @strstr($request_headers["Content-Type"],
267
- "application/x-www-form-urlencoded")
268
- ) {
269
- $post_data = OAuthUtil::parse_parameters(
270
- file_get_contents(self::$POST_INPUT)
271
- );
272
- $parameters = array_merge($parameters, $post_data);
273
- }
274
-
275
- // We have a Authorization-header with OAuth data. Parse the header
276
- // and add those overriding any duplicates from GET or POST
277
- if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
278
- $header_parameters = OAuthUtil::split_header(
279
- $request_headers['Authorization']
280
- );
281
- $parameters = array_merge($parameters, $header_parameters);
282
- }
283
-
284
- }
285
-
286
- return new OAuthRequest($http_method, $http_url, $parameters);
287
- }
288
-
289
- /**
290
- * pretty much a helper function to set up the request
291
- */
292
- public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
293
- @$parameters or $parameters = array();
294
- $defaults = array("oauth_version" => OAuthRequest::$version,
295
- "oauth_nonce" => OAuthRequest::generate_nonce(),
296
- "oauth_timestamp" => OAuthRequest::generate_timestamp(),
297
- "oauth_consumer_key" => $consumer->key);
298
- if ($token)
299
- $defaults['oauth_token'] = $token->key;
300
-
301
- $parameters = array_merge($defaults, $parameters);
302
-
303
- return new OAuthRequest($http_method, $http_url, $parameters);
304
- }
305
-
306
- public function set_parameter($name, $value, $allow_duplicates = true) {
307
- if ($allow_duplicates && isset($this->parameters[$name])) {
308
- // We have already added parameter(s) with this name, so add to the list
309
- if (is_scalar($this->parameters[$name])) {
310
- // This is the first duplicate, so transform scalar (string)
311
- // into an array so we can add the duplicates
312
- $this->parameters[$name] = array($this->parameters[$name]);
313
- }
314
-
315
- $this->parameters[$name][] = $value;
316
- } else {
317
- $this->parameters[$name] = $value;
318
- }
319
- }
320
-
321
- public function get_parameter($name) {
322
- return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
323
- }
324
-
325
- public function get_parameters() {
326
- return $this->parameters;
327
- }
328
-
329
- public function unset_parameter($name) {
330
- unset($this->parameters[$name]);
331
- }
332
-
333
- /**
334
- * The request parameters, sorted and concatenated into a normalized string.
335
- * @return string
336
- */
337
- public function get_signable_parameters() {
338
- // Grab all parameters
339
- $params = $this->parameters;
340
-
341
- // Remove oauth_signature if present
342
- // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
343
- if (isset($params['oauth_signature'])) {
344
- unset($params['oauth_signature']);
345
- }
346
-
347
- return OAuthUtil::build_http_query($params);
348
- }
349
-
350
- /**
351
- * Returns the base string of this request
352
- *
353
- * The base string defined as the method, the url
354
- * and the parameters (normalized), each urlencoded
355
- * and the concated with &.
356
- */
357
- public function get_signature_base_string() {
358
- $parts = array(
359
- $this->get_normalized_http_method(),
360
- $this->get_normalized_http_url(),
361
- $this->get_signable_parameters()
362
- );
363
-
364
- $parts = OAuthUtil::urlencode_rfc3986($parts);
365
-
366
- return implode('&', $parts);
367
- }
368
-
369
- /**
370
- * just uppercases the http method
371
- */
372
- public function get_normalized_http_method() {
373
- return strtoupper($this->http_method);
374
- }
375
-
376
- /**
377
- * parses the url and rebuilds it to be
378
- * scheme://host/path
379
- */
380
- public function get_normalized_http_url() {
381
- $parts = parse_url($this->http_url);
382
-
383
- $port = @$parts['port'];
384
- $scheme = $parts['scheme'];
385
- $host = $parts['host'];
386
- $path = @$parts['path'];
387
-
388
- $port or $port = ($scheme == 'https') ? '443' : '80';
389
-
390
- if (($scheme == 'https' && $port != '443')
391
- || ($scheme == 'http' && $port != '80')) {
392
- $host = "$host:$port";
393
- }
394
- return "$scheme://$host$path";
395
- }
396
-
397
- /**
398
- * builds a url usable for a GET request
399
- */
400
- public function to_url() {
401
- $post_data = $this->to_postdata();
402
- $out = $this->get_normalized_http_url();
403
- if ($post_data) {
404
- $out .= '?'.$post_data;
405
- }
406
- return $out;
407
- }
408
-
409
- /**
410
- * builds the data one would send in a POST request
411
- */
412
- public function to_postdata() {
413
- return OAuthUtil::build_http_query($this->parameters);
414
- }
415
-
416
- /**
417
- * builds the Authorization: header
418
- */
419
- public function to_header($realm=null) {
420
- $first = true;
421
- if($realm) {
422
- $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
423
- $first = false;
424
- } else
425
- $out = 'Authorization: OAuth';
426
-
427
- $total = array();
428
- foreach ($this->parameters as $k => $v) {
429
- if (substr($k, 0, 5) != "oauth") continue;
430
- if (is_array($v)) {
431
- throw new OAuthException('Arrays not supported in headers');
432
- }
433
- $out .= ($first) ? ' ' : ',';
434
- $out .= OAuthUtil::urlencode_rfc3986($k) .
435
- '="' .
436
- OAuthUtil::urlencode_rfc3986($v) .
437
- '"';
438
- $first = false;
439
- }
440
- return $out;
441
- }
442
-
443
- public function __toString() {
444
- return $this->to_url();
445
- }
446
-
447
-
448
- public function sign_request($signature_method, $consumer, $token) {
449
- $this->set_parameter(
450
- "oauth_signature_method",
451
- $signature_method->get_name(),
452
- false
453
- );
454
- $signature = $this->build_signature($signature_method, $consumer, $token);
455
- $this->set_parameter("oauth_signature", $signature, false);
456
- }
457
-
458
- public function build_signature($signature_method, $consumer, $token) {
459
- $signature = $signature_method->build_signature($this, $consumer, $token);
460
- return $signature;
461
- }
462
-
463
- /**
464
- * util function: current timestamp
465
- */
466
- private static function generate_timestamp() {
467
- return time();
468
- }
469
-
470
- /**
471
- * util function: current nonce
472
- */
473
- private static function generate_nonce() {
474
- $mt = microtime();
475
- $rand = mt_rand();
476
-
477
- return md5($mt . $rand); // md5s look nicer than numbers
478
- }
479
- }
480
-
481
- class OAuthServer {
482
- protected $timestamp_threshold = 300; // in seconds, five minutes
483
- protected $version = '1.0'; // hi blaine
484
- protected $signature_methods = array();
485
-
486
- protected $data_store;
487
-
488
- function __construct($data_store) {
489
- $this->data_store = $data_store;
490
- }
491
-
492
- public function add_signature_method($signature_method) {
493
- $this->signature_methods[$signature_method->get_name()] =
494
- $signature_method;
495
- }
496
-
497
- // high level functions
498
-
499
- /**
500
- * process a request_token request
501
- * returns the request token on success
502
- */
503
- public function fetch_request_token(&$request) {
504
- $this->get_version($request);
505
-
506
- $consumer = $this->get_consumer($request);
507
-
508
- // no token required for the initial token request
509
- $token = NULL;
510
-
511
- $this->check_signature($request, $consumer, $token);
512
-
513
- // Rev A change
514
- $callback = $request->get_parameter('oauth_callback');
515
- $new_token = $this->data_store->new_request_token($consumer, $callback);
516
-
517
- return $new_token;
518
- }
519
-
520
- /**
521
- * process an access_token request
522
- * returns the access token on success
523
- */
524
- public function fetch_access_token(&$request) {
525
- $this->get_version($request);
526
-
527
- $consumer = $this->get_consumer($request);
528
-
529
- // requires authorized request token
530
- $token = $this->get_token($request, $consumer, "request");
531
-
532
- $this->check_signature($request, $consumer, $token);
533
-
534
- // Rev A change
535
- $verifier = $request->get_parameter('oauth_verifier');
536
- $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
537
-
538
- return $new_token;
539
- }
540
-
541
- /**
542
- * verify an api call, checks all the parameters
543
- */
544
- public function verify_request(&$request) {
545
- $this->get_version($request);
546
- $consumer = $this->get_consumer($request);
547
- $token = $this->get_token($request, $consumer, "access");
548
- $this->check_signature($request, $consumer, $token);
549
- return array($consumer, $token);
550
- }
551
-
552
- // Internals from here
553
- /**
554
- * version 1
555
- */
556
- private function get_version(&$request) {
557
- $version = $request->get_parameter("oauth_version");
558
- if (!$version) {
559
- // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
560
- // Chapter 7.0 ("Accessing Protected Ressources")
561
- $version = '1.0';
562
- }
563
- if ($version !== $this->version) {
564
- throw new OAuthException("OAuth version '$version' not supported");
565
- }
566
- return $version;
567
- }
568
-
569
- /**
570
- * figure out the signature with some defaults
571
- */
572
- private function get_signature_method(&$request) {
573
- $signature_method =
574
- @$request->get_parameter("oauth_signature_method");
575
-
576
- if (!$signature_method) {
577
- // According to chapter 7 ("Accessing Protected Ressources") the signature-method
578
- // parameter is required, and we can't just fallback to PLAINTEXT
579
- throw new OAuthException('No signature method parameter. This parameter is required');
580
- }
581
-
582
- if (!in_array($signature_method,
583
- array_keys($this->signature_methods))) {
584
- throw new OAuthException(
585
- "Signature method '$signature_method' not supported " .
586
- "try one of the following: " .
587
- implode(", ", array_keys($this->signature_methods))
588
- );
589
- }
590
- return $this->signature_methods[$signature_method];
591
- }
592
-
593
- /**
594
- * try to find the consumer for the provided request's consumer key
595
- */
596
- private function get_consumer(&$request) {
597
- $consumer_key = @$request->get_parameter("oauth_consumer_key");
598
- if (!$consumer_key) {
599
- throw new OAuthException("Invalid consumer key");
600
- }
601
-
602
- $consumer = $this->data_store->lookup_consumer($consumer_key);
603
- if (!$consumer) {
604
- throw new OAuthException("Invalid consumer");
605
- }
606
-
607
- return $consumer;
608
- }
609
-
610
- /**
611
- * try to find the token for the provided request's token key
612
- */
613
- private function get_token(&$request, $consumer, $token_type="access") {
614
- $token_field = @$request->get_parameter('oauth_token');
615
- $token = $this->data_store->lookup_token(
616
- $consumer, $token_type, $token_field
617
- );
618
- if (!$token) {
619
- throw new OAuthException("Invalid $token_type token: $token_field");
620
- }
621
- return $token;
622
- }
623
-
624
- /**
625
- * all-in-one function to check the signature on a request
626
- * should guess the signature method appropriately
627
- */
628
- private function check_signature(&$request, $consumer, $token) {
629
- // this should probably be in a different method
630
- $timestamp = @$request->get_parameter('oauth_timestamp');
631
- $nonce = @$request->get_parameter('oauth_nonce');
632
-
633
- $this->check_timestamp($timestamp);
634
- $this->check_nonce($consumer, $token, $nonce, $timestamp);
635
-
636
- $signature_method = $this->get_signature_method($request);
637
-
638
- $signature = $request->get_parameter('oauth_signature');
639
- $valid_sig = $signature_method->check_signature(
640
- $request,
641
- $consumer,
642
- $token,
643
- $signature
644
- );
645
-
646
- if (!$valid_sig) {
647
- throw new OAuthException("Invalid signature");
648
- }
649
- }
650
-
651
- /**
652
- * check that the timestamp is new enough
653
- */
654
- private function check_timestamp($timestamp) {
655
- if( ! $timestamp )
656
- throw new OAuthException(
657
- 'Missing timestamp parameter. The parameter is required'
658
- );
659
-
660
- // verify that timestamp is recentish
661
- $now = time();
662
- if (abs($now - $timestamp) > $this->timestamp_threshold) {
663
- throw new OAuthException(
664
- "Expired timestamp, yours $timestamp, ours $now"
665
- );
666
- }
667
- }
668
-
669
- /**
670
- * check that the nonce is not repeated
671
- */
672
- private function check_nonce($consumer, $token, $nonce, $timestamp) {
673
- if( ! $nonce )
674
- throw new OAuthException(
675
- 'Missing nonce parameter. The parameter is required'
676
- );
677
-
678
- // verify that the nonce is uniqueish
679
- $found = $this->data_store->lookup_nonce(
680
- $consumer,
681
- $token,
682
- $nonce,
683
- $timestamp
684
- );
685
- if ($found) {
686
- throw new OAuthException("Nonce already used: $nonce");
687
- }
688
- }
689
-
690
- }
691
-
692
- class OAuthDataStore {
693
- function lookup_consumer($consumer_key) {
694
- // implement me
695
- }
696
-
697
- function lookup_token($consumer, $token_type, $token) {
698
- // implement me
699
- }
700
-
701
- function lookup_nonce($consumer, $token, $nonce, $timestamp) {
702
- // implement me
703
- }
704
-
705
- function new_request_token($consumer, $callback = null) {
706
- // return a new token attached to this consumer
707
- }
708
-
709
- function new_access_token($token, $consumer, $verifier = null) {
710
- // return a new access token attached to this consumer
711
- // for the user associated with this token if the request token
712
- // is authorized
713
- // should also invalidate the request token
714
- }
715
-
716
- }
717
-
718
- class OAuthUtil {
719
- public static function urlencode_rfc3986($input) {
720
- if (is_array($input)) {
721
- return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
722
- } else if (is_scalar($input)) {
723
- return str_replace(
724
- '+',
725
- ' ',
726
- str_replace('%7E', '~', rawurlencode($input))
727
- );
728
- } else {
729
- return '';
730
- }
731
- }
732
-
733
-
734
- // This decode function isn't taking into consideration the above
735
- // modifications to the encoding process. However, this method doesn't
736
- // seem to be used anywhere so leaving it as is.
737
- public static function urldecode_rfc3986($string) {
738
- return urldecode($string);
739
- }
740
-
741
- // Utility function for turning the Authorization: header into
742
- // parameters, has to do some unescaping
743
- // Can filter out any non-oauth parameters if needed (default behaviour)
744
- public static function split_header($header, $only_allow_oauth_parameters = true) {
745
- $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
746
- $offset = 0;
747
- $params = array();
748
- while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
749
- $match = $matches[0];
750
- $header_name = $matches[2][0];
751
- $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
752
- if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
753
- $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
754
- }
755
- $offset = $match[1] + strlen($match[0]);
756
- }
757
-
758
- if (isset($params['realm'])) {
759
- unset($params['realm']);
760
- }
761
-
762
- return $params;
763
- }
764
-
765
- // helper to try to sort out headers for people who aren't running apache
766
- public static function get_headers() {
767
- if (function_exists('apache_request_headers')) {
768
- // we need this to get the actual Authorization: header
769
- // because apache tends to tell us it doesn't exist
770
- $headers = apache_request_headers();
771
-
772
- // sanitize the output of apache_request_headers because
773
- // we always want the keys to be Cased-Like-This and arh()
774
- // returns the headers in the same case as they are in the
775
- // request
776
- $out = array();
777
- foreach( $headers AS $key => $value ) {
778
- $key = str_replace(
779
- " ",
780
- "-",
781
- ucwords(strtolower(str_replace("-", " ", $key)))
782
- );
783
- $out[$key] = $value;
784
- }
785
- } else {
786
- // otherwise we don't have apache and are just going to have to hope
787
- // that $_SERVER actually contains what we need
788
- $out = array();
789
- if( isset($_SERVER['CONTENT_TYPE']) )
790
- $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
791
- if( isset($_ENV['CONTENT_TYPE']) )
792
- $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
793
-
794
- foreach ($_SERVER as $key => $value) {
795
- if (substr($key, 0, 5) == "HTTP_") {
796
- // this is chaos, basically it is just there to capitalize the first
797
- // letter of every word that is not an initial HTTP and strip HTTP
798
- // code from przemek
799
- $key = str_replace(
800
- " ",
801
- "-",
802
- ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
803
- );
804
- $out[$key] = $value;
805
- }
806
- }
807
- }
808
- return $out;
809
- }
810
-
811
- // This function takes a input like a=b&a=c&d=e and returns the parsed
812
- // parameters like this
813
- // array('a' => array('b','c'), 'd' => 'e')
814
- public static function parse_parameters( $input ) {
815
- if (!isset($input) || !$input) return array();
816
-
817
- $pairs = explode('&', $input);
818
-
819
- $parsed_parameters = array();
820
- foreach ($pairs as $pair) {
821
- $split = explode('=', $pair, 2);
822
- $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
823
- $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
824
-
825
- if (isset($parsed_parameters[$parameter])) {
826
- // We have already recieved parameter(s) with this name, so add to the list
827
- // of parameters with this name
828
-
829
- if (is_scalar($parsed_parameters[$parameter])) {
830
- // This is the first duplicate, so transform scalar (string) into an array
831
- // so we can add the duplicates
832
- $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
833
- }
834
-
835
- $parsed_parameters[$parameter][] = $value;
836
- } else {
837
- $parsed_parameters[$parameter] = $value;
838
- }
839
- }
840
- return $parsed_parameters;
841
- }
842
-
843
- public static function build_http_query($params) {
844
- if (!$params) return '';
845
-
846
- // Urlencode both keys and values
847
- $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
848
- $values = OAuthUtil::urlencode_rfc3986(array_values($params));
849
- $params = array_combine($keys, $values);
850
-
851
- // Parameters are sorted by name, using lexicographical byte value ordering.
852
- // Ref: Spec: 9.1.1 (1)
853
- uksort($params, 'strcmp');
854
-
855
- $pairs = array();
856
- foreach ($params as $parameter => $value) {
857
- if (is_array($value)) {
858
- // If two or more parameters share the same name, they are sorted by their value
859
- // Ref: Spec: 9.1.1 (1)
860
- natsort($value);
861
- foreach ($value as $duplicate_value) {
862
- $pairs[] = $parameter . '=' . $duplicate_value;
863
- }
864
- } else {
865
- $pairs[] = $parameter . '=' . $value;
866
- }
867
- }
868
- // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
869
- // Each name-value pair is separated by an '&' character (ASCII code 38)
870
- return implode('&', $pairs);
871
- }
872
- }
873
-
874
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/GoMage/Tumblr/tumblroauth.php CHANGED
@@ -3,243 +3,243 @@
3
  /*
4
  * Abraham Williams (abraham@abrah.am) http://abrah.am
5
  *
6
- * The first PHP Library to support OAuth for Tumblr's REST API. (Originally for Twitter, modified for Tumblr by Lucas)
7
  */
8
 
9
  /* Load OAuth lib. You can find it at http://oauth.net */
10
- require_once('OAuth.php');
11
 
12
  /**
13
  * Tumblr OAuth class
14
  */
15
  class TumblrOAuth {
16
- /* Contains the last HTTP status code returned. */
17
- public $http_code;
18
- /* Contains the last API call. */
19
- public $url;
20
- /* Set up the API root URL. */
21
- public $host = "http://api.tumblr.com/v2/";
22
- /* Set timeout default. */
23
- public $timeout = 30;
24
- /* Set connect timeout. */
25
- public $connecttimeout = 30;
26
- /* Verify SSL Cert. */
27
- public $ssl_verifypeer = FALSE;
28
- /* Respons format. */
29
- public $format = 'json';
30
- /* Decode returned json data. */
31
- public $decode_json = TRUE;
32
- /* Contains the last HTTP headers returned. */
33
- public $http_info;
34
- /* Set the useragnet. */
35
- public $useragent = 'TumblrOAuth v0.2.0-beta2';
36
- /* Immediately retry the API call if the response was not successful. */
37
- //public $retry = TRUE;
38
-
39
-
40
-
41
-
42
- /**
43
- * Set API URLS
44
- */
45
- function accessTokenURL() { return 'http://www.tumblr.com/oauth/access_token'; }
46
- function authenticateURL() { return 'http://www.tumblr.com/oauth/authorize'; }
47
- function authorizeURL() { return 'http://www.tumblr.com/oauth/authorize'; }
48
- function requestTokenURL() { return 'http://www.tumblr.com/oauth/request_token'; }
49
-
50
- /**
51
- * Debug helpers
52
- */
53
- function lastStatusCode() { return $this->http_status; }
54
- function lastAPICall() { return $this->last_api_call; }
55
-
56
- /**
57
- * construct TumblrOAuth object
58
- */
59
- function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
60
- $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
61
- $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
62
- if (!empty($oauth_token) && !empty($oauth_token_secret)) {
63
- $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
64
- } else {
65
- $this->token = NULL;
66
- }
67
- }
68
-
69
-
70
- /**
71
- * Get a request_token from Tumblr
72
- *
73
- * @returns a key/value array containing oauth_token and oauth_token_secret
74
- */
75
- function getRequestToken($oauth_callback = NULL) {
76
- $parameters = array();
77
- if (!empty($oauth_callback)) {
78
- $parameters['oauth_callback'] = $oauth_callback;
79
- }
80
- $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
81
- $token = OAuthUtil::parse_parameters($request);
82
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
83
- return $token;
84
- }
85
-
86
- /**
87
- * Get the authorize URL
88
- *
89
- * @returns a string
90
- */
91
- function getAuthorizeURL($token, $sign_in_with_tumblr = TRUE) {
92
- if (is_array($token)) {
93
- $token = $token['oauth_token'];
94
- }
95
- if (empty($sign_in_with_tumblr)) {
96
- return $this->authorizeURL() . "?oauth_token={$token}";
97
- } else {
98
- return $this->authenticateURL() . "?oauth_token={$token}";
99
- }
100
- }
101
-
102
- /**
103
- * Exchange request token and secret for an access token and
104
- * secret, to sign API calls.
105
- *
106
- * @returns array("oauth_token" => "the-access-token",
107
- * "oauth_token_secret" => "the-access-secret",
108
- * "user_id" => "9436992",
109
- * "screen_name" => "abraham")
110
- */
111
- function getAccessToken($oauth_verifier = FALSE) {
112
- $parameters = array();
113
- if (!empty($oauth_verifier)) {
114
- $parameters['oauth_verifier'] = $oauth_verifier;
115
- }
116
- $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
117
- $token = OAuthUtil::parse_parameters($request);
118
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
119
- return $token;
120
- }
121
-
122
- /**
123
- * One time exchange of username and password for access token and secret.
124
- *
125
- * @returns array("oauth_token" => "the-access-token",
126
- * "oauth_token_secret" => "the-access-secret",
127
- * "user_id" => "9436992",
128
- * "screen_name" => "abraham",
129
- * "x_auth_expires" => "0")
130
- */
131
- function getXAuthToken($username, $password) {
132
- $parameters = array();
133
- $parameters['x_auth_username'] = $username;
134
- $parameters['x_auth_password'] = $password;
135
- $parameters['x_auth_mode'] = 'client_auth';
136
- $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
137
- $token = OAuthUtil::parse_parameters($request);
138
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
139
- return $token;
140
- }
141
-
142
- /**
143
- * GET wrapper for oAuthRequest.
144
- */
145
- function get($url, $parameters = array()) {
146
- $response = $this->oAuthRequest($url, 'GET', $parameters);
147
- if ($this->format === 'json' && $this->decode_json) {
148
- return json_decode($response);
149
- }
150
- return $response;
151
- }
152
-
153
- /**
154
- * POST wrapper for oAuthRequest.
155
- */
156
- function post($url, $parameters = array()) {
157
- $response = $this->oAuthRequest($url, 'POST', $parameters);
158
- if ($this->format === 'json' && $this->decode_json) {
159
- return json_decode($response);
160
- }
161
- return $response;
162
- }
163
-
164
- /**
165
- * DELETE wrapper for oAuthReqeust.
166
- */
167
- function delete($url, $parameters = array()) {
168
- $response = $this->oAuthRequest($url, 'DELETE', $parameters);
169
- if ($this->format === 'json' && $this->decode_json) {
170
- return json_decode($response);
171
- }
172
- return $response;
173
- }
174
-
175
- /**
176
- * Format and sign an OAuth / API request
177
- */
178
- function oAuthRequest($url, $method, $parameters) {
179
- if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
180
- $url = "{$this->host}{$url}";
181
- }
182
- $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
183
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
184
- switch ($method) {
185
- case 'GET':
186
- return $this->http($request->to_url(), 'GET');
187
- default:
188
- return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
189
- }
190
- }
191
-
192
- /**
193
- * Make an HTTP request
194
- *
195
- * @return API results
196
- */
197
- function http($url, $method, $postfields = NULL) {
198
- $this->http_info = array();
199
- $ci = curl_init();
200
- /* Curl settings */
201
- curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
202
- curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
203
- curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
204
- curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
205
- curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
206
- curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
207
- curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
208
- curl_setopt($ci, CURLOPT_HEADER, FALSE);
209
-
210
- switch ($method) {
211
- case 'POST':
212
- curl_setopt($ci, CURLOPT_POST, TRUE);
213
- if (!empty($postfields)) {
214
- curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
215
- }
216
- break;
217
- case 'DELETE':
218
- curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
219
- if (!empty($postfields)) {
220
- $url = "{$url}?{$postfields}";
221
- }
222
- }
223
-
224
- curl_setopt($ci, CURLOPT_URL, $url);
225
- $response = curl_exec($ci);
226
- $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
227
- $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
228
- $this->url = $url;
229
- curl_close ($ci);
230
- return $response;
231
- }
232
-
233
- /**
234
- * Get the header info to store.
235
- */
236
- function getHeader($ch, $header) {
237
- $i = strpos($header, ':');
238
- if (!empty($i)) {
239
- $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
240
- $value = trim(substr($header, $i + 2));
241
- $this->http_header[$key] = $value;
242
- }
243
- return strlen($header);
244
- }
245
  }
3
  /*
4
  * Abraham Williams (abraham@abrah.am) http://abrah.am
5
  *
6
+ * The first PHP Library to support OAuth for Tumblr's REST API. (Originally for Twitter, modified for Tumblr by Lucas)
7
  */
8
 
9
  /* Load OAuth lib. You can find it at http://oauth.net */
10
+ require_once(__DIR__ . DS . '..' . DS . 'OAuth' . DS . 'OAuth.php');
11
 
12
  /**
13
  * Tumblr OAuth class
14
  */
15
  class TumblrOAuth {
16
+ /* Contains the last HTTP status code returned. */
17
+ public $http_code;
18
+ /* Contains the last API call. */
19
+ public $url;
20
+ /* Set up the API root URL. */
21
+ public $host = "http://api.tumblr.com/v2/";
22
+ /* Set timeout default. */
23
+ public $timeout = 30;
24
+ /* Set connect timeout. */
25
+ public $connecttimeout = 30;
26
+ /* Verify SSL Cert. */
27
+ public $ssl_verifypeer = FALSE;
28
+ /* Respons format. */
29
+ public $format = 'json';
30
+ /* Decode returned json data. */
31
+ public $decode_json = TRUE;
32
+ /* Contains the last HTTP headers returned. */
33
+ public $http_info;
34
+ /* Set the useragnet. */
35
+ public $useragent = 'TumblrOAuth v0.2.0-beta2';
36
+ /* Immediately retry the API call if the response was not successful. */
37
+ //public $retry = TRUE;
38
+
39
+
40
+
41
+
42
+ /**
43
+ * Set API URLS
44
+ */
45
+ function accessTokenURL() { return 'http://www.tumblr.com/oauth/access_token'; }
46
+ function authenticateURL() { return 'http://www.tumblr.com/oauth/authorize'; }
47
+ function authorizeURL() { return 'http://www.tumblr.com/oauth/authorize'; }
48
+ function requestTokenURL() { return 'http://www.tumblr.com/oauth/request_token'; }
49
+
50
+ /**
51
+ * Debug helpers
52
+ */
53
+ function lastStatusCode() { return $this->http_status; }
54
+ function lastAPICall() { return $this->last_api_call; }
55
+
56
+ /**
57
+ * construct TumblrOAuth object
58
+ */
59
+ function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
60
+ $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
61
+ $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
62
+ if (!empty($oauth_token) && !empty($oauth_token_secret)) {
63
+ $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
64
+ } else {
65
+ $this->token = NULL;
66
+ }
67
+ }
68
+
69
+
70
+ /**
71
+ * Get a request_token from Tumblr
72
+ *
73
+ * @returns a key/value array containing oauth_token and oauth_token_secret
74
+ */
75
+ function getRequestToken($oauth_callback = NULL) {
76
+ $parameters = array();
77
+ if (!empty($oauth_callback)) {
78
+ $parameters['oauth_callback'] = $oauth_callback;
79
+ }
80
+ $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
81
+ $token = OAuthUtil::parse_parameters($request);
82
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
83
+ return $token;
84
+ }
85
+
86
+ /**
87
+ * Get the authorize URL
88
+ *
89
+ * @returns a string
90
+ */
91
+ function getAuthorizeURL($token, $sign_in_with_tumblr = TRUE) {
92
+ if (is_array($token)) {
93
+ $token = $token['oauth_token'];
94
+ }
95
+ if (empty($sign_in_with_tumblr)) {
96
+ return $this->authorizeURL() . "?oauth_token={$token}";
97
+ } else {
98
+ return $this->authenticateURL() . "?oauth_token={$token}";
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Exchange request token and secret for an access token and
104
+ * secret, to sign API calls.
105
+ *
106
+ * @returns array("oauth_token" => "the-access-token",
107
+ * "oauth_token_secret" => "the-access-secret",
108
+ * "user_id" => "9436992",
109
+ * "screen_name" => "abraham")
110
+ */
111
+ function getAccessToken($oauth_verifier = FALSE) {
112
+ $parameters = array();
113
+ if (!empty($oauth_verifier)) {
114
+ $parameters['oauth_verifier'] = $oauth_verifier;
115
+ }
116
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
117
+ $token = OAuthUtil::parse_parameters($request);
118
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
119
+ return $token;
120
+ }
121
+
122
+ /**
123
+ * One time exchange of username and password for access token and secret.
124
+ *
125
+ * @returns array("oauth_token" => "the-access-token",
126
+ * "oauth_token_secret" => "the-access-secret",
127
+ * "user_id" => "9436992",
128
+ * "screen_name" => "abraham",
129
+ * "x_auth_expires" => "0")
130
+ */
131
+ function getXAuthToken($username, $password) {
132
+ $parameters = array();
133
+ $parameters['x_auth_username'] = $username;
134
+ $parameters['x_auth_password'] = $password;
135
+ $parameters['x_auth_mode'] = 'client_auth';
136
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
137
+ $token = OAuthUtil::parse_parameters($request);
138
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
139
+ return $token;
140
+ }
141
+
142
+ /**
143
+ * GET wrapper for oAuthRequest.
144
+ */
145
+ function get($url, $parameters = array()) {
146
+ $response = $this->oAuthRequest($url, 'GET', $parameters);
147
+ if ($this->format === 'json' && $this->decode_json) {
148
+ return json_decode($response);
149
+ }
150
+ return $response;
151
+ }
152
+
153
+ /**
154
+ * POST wrapper for oAuthRequest.
155
+ */
156
+ function post($url, $parameters = array()) {
157
+ $response = $this->oAuthRequest($url, 'POST', $parameters);
158
+ if ($this->format === 'json' && $this->decode_json) {
159
+ return json_decode($response);
160
+ }
161
+ return $response;
162
+ }
163
+
164
+ /**
165
+ * DELETE wrapper for oAuthReqeust.
166
+ */
167
+ function delete($url, $parameters = array()) {
168
+ $response = $this->oAuthRequest($url, 'DELETE', $parameters);
169
+ if ($this->format === 'json' && $this->decode_json) {
170
+ return json_decode($response);
171
+ }
172
+ return $response;
173
+ }
174
+
175
+ /**
176
+ * Format and sign an OAuth / API request
177
+ */
178
+ function oAuthRequest($url, $method, $parameters) {
179
+ if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
180
+ $url = "{$this->host}{$url}";
181
+ }
182
+ $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
183
+ $request->sign_request($this->sha1_method, $this->consumer, $this->token);
184
+ switch ($method) {
185
+ case 'GET':
186
+ return $this->http($request->to_url(), 'GET');
187
+ default:
188
+ return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Make an HTTP request
194
+ *
195
+ * @return API results
196
+ */
197
+ function http($url, $method, $postfields = NULL) {
198
+ $this->http_info = array();
199
+ $ci = curl_init();
200
+ /* Curl settings */
201
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
202
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
203
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
204
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
205
+ curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
206
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
207
+ curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
208
+ curl_setopt($ci, CURLOPT_HEADER, FALSE);
209
+
210
+ switch ($method) {
211
+ case 'POST':
212
+ curl_setopt($ci, CURLOPT_POST, TRUE);
213
+ if (!empty($postfields)) {
214
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
215
+ }
216
+ break;
217
+ case 'DELETE':
218
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
219
+ if (!empty($postfields)) {
220
+ $url = "{$url}?{$postfields}";
221
+ }
222
+ }
223
+
224
+ curl_setopt($ci, CURLOPT_URL, $url);
225
+ $response = curl_exec($ci);
226
+ $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
227
+ $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
228
+ $this->url = $url;
229
+ curl_close ($ci);
230
+ return $response;
231
+ }
232
+
233
+ /**
234
+ * Get the header info to store.
235
+ */
236
+ function getHeader($ch, $header) {
237
+ $i = strpos($header, ':');
238
+ if (!empty($i)) {
239
+ $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
240
+ $value = trim(substr($header, $i + 2));
241
+ $this->http_header[$key] = $value;
242
+ }
243
+ return strlen($header);
244
+ }
245
  }
lib/GoMage/Twitter/OAuth.php DELETED
@@ -1,870 +0,0 @@
1
- <?php
2
- // vim: foldmethod=marker
3
-
4
- /* Generic exception class
5
- */
6
-
7
-
8
- class OAuthConsumer {
9
- public $key;
10
- public $secret;
11
-
12
- function __construct($key, $secret, $callback_url=NULL) {
13
- $this->key = $key;
14
- $this->secret = $secret;
15
- $this->callback_url = $callback_url;
16
- }
17
-
18
- function __toString() {
19
- return "OAuthConsumer[key=$this->key,secret=$this->secret]";
20
- }
21
- }
22
-
23
- class OAuthToken {
24
- // access tokens and request tokens
25
- public $key;
26
- public $secret;
27
-
28
- /**
29
- * key = the token
30
- * secret = the token secret
31
- */
32
- function __construct($key, $secret) {
33
- $this->key = $key;
34
- $this->secret = $secret;
35
- }
36
-
37
- /**
38
- * generates the basic string serialization of a token that a server
39
- * would respond to request_token and access_token calls with
40
- */
41
- function to_string() {
42
- return "oauth_token=" .
43
- OAuthUtil::urlencode_rfc3986($this->key) .
44
- "&oauth_token_secret=" .
45
- OAuthUtil::urlencode_rfc3986($this->secret);
46
- }
47
-
48
- function __toString() {
49
- return $this->to_string();
50
- }
51
- }
52
-
53
- /**
54
- * A class for implementing a Signature Method
55
- * See section 9 ("Signing Requests") in the spec
56
- */
57
- abstract class OAuthSignatureMethod {
58
- /**
59
- * Needs to return the name of the Signature Method (ie HMAC-SHA1)
60
- * @return string
61
- */
62
- abstract public function get_name();
63
-
64
- /**
65
- * Build up the signature
66
- * NOTE: The output of this function MUST NOT be urlencoded.
67
- * the encoding is handled in OAuthRequest when the final
68
- * request is serialized
69
- * @param OAuthRequest $request
70
- * @param OAuthConsumer $consumer
71
- * @param OAuthToken $token
72
- * @return string
73
- */
74
- abstract public function build_signature($request, $consumer, $token);
75
-
76
- /**
77
- * Verifies that a given signature is correct
78
- * @param OAuthRequest $request
79
- * @param OAuthConsumer $consumer
80
- * @param OAuthToken $token
81
- * @param string $signature
82
- * @return bool
83
- */
84
- public function check_signature($request, $consumer, $token, $signature) {
85
- $built = $this->build_signature($request, $consumer, $token);
86
- return $built == $signature;
87
- }
88
- }
89
-
90
- /**
91
- * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
92
- * where the Signature Base String is the text and the key is the concatenated values (each first
93
- * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
94
- * character (ASCII code 38) even if empty.
95
- * - Chapter 9.2 ("HMAC-SHA1")
96
- */
97
- class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
98
- function get_name() {
99
- return "HMAC-SHA1";
100
- }
101
-
102
- public function build_signature($request, $consumer, $token) {
103
- $base_string = $request->get_signature_base_string();
104
- $request->base_string = $base_string;
105
-
106
- $key_parts = array(
107
- $consumer->secret,
108
- ($token) ? $token->secret : ""
109
- );
110
-
111
- $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
112
- $key = implode('&', $key_parts);
113
-
114
- return base64_encode(hash_hmac('sha1', $base_string, $key, true));
115
- }
116
- }
117
-
118
- /**
119
- * The PLAINTEXT method does not provide any security protection and SHOULD only be used
120
- * over a secure channel such as HTTPS. It does not use the Signature Base String.
121
- * - Chapter 9.4 ("PLAINTEXT")
122
- */
123
- class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
124
- public function get_name() {
125
- return "PLAINTEXT";
126
- }
127
-
128
- /**
129
- * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
130
- * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
131
- * empty. The result MUST be encoded again.
132
- * - Chapter 9.4.1 ("Generating Signatures")
133
- *
134
- * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
135
- * OAuthRequest handles this!
136
- */
137
- public function build_signature($request, $consumer, $token) {
138
- $key_parts = array(
139
- $consumer->secret,
140
- ($token) ? $token->secret : ""
141
- );
142
-
143
- $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
144
- $key = implode('&', $key_parts);
145
- $request->base_string = $key;
146
-
147
- return $key;
148
- }
149
- }
150
-
151
- /**
152
- * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
153
- * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
154
- * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
155
- * verified way to the Service Provider, in a manner which is beyond the scope of this
156
- * specification.
157
- * - Chapter 9.3 ("RSA-SHA1")
158
- */
159
- abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
160
- public function get_name() {
161
- return "RSA-SHA1";
162
- }
163
-
164
- // Up to the SP to implement this lookup of keys. Possible ideas are:
165
- // (1) do a lookup in a table of trusted certs keyed off of consumer
166
- // (2) fetch via http using a url provided by the requester
167
- // (3) some sort of specific discovery code based on request
168
- //
169
- // Either way should return a string representation of the certificate
170
- protected abstract function fetch_public_cert(&$request);
171
-
172
- // Up to the SP to implement this lookup of keys. Possible ideas are:
173
- // (1) do a lookup in a table of trusted certs keyed off of consumer
174
- //
175
- // Either way should return a string representation of the certificate
176
- protected abstract function fetch_private_cert(&$request);
177
-
178
- public function build_signature($request, $consumer, $token) {
179
- $base_string = $request->get_signature_base_string();
180
- $request->base_string = $base_string;
181
-
182
- // Fetch the private key cert based on the request
183
- $cert = $this->fetch_private_cert($request);
184
-
185
- // Pull the private key ID from the certificate
186
- $privatekeyid = openssl_get_privatekey($cert);
187
-
188
- // Sign using the key
189
- $ok = openssl_sign($base_string, $signature, $privatekeyid);
190
-
191
- // Release the key resource
192
- openssl_free_key($privatekeyid);
193
-
194
- return base64_encode($signature);
195
- }
196
-
197
- public function check_signature($request, $consumer, $token, $signature) {
198
- $decoded_sig = base64_decode($signature);
199
-
200
- $base_string = $request->get_signature_base_string();
201
-
202
- // Fetch the public key cert based on the request
203
- $cert = $this->fetch_public_cert($request);
204
-
205
- // Pull the public key ID from the certificate
206
- $publickeyid = openssl_get_publickey($cert);
207
-
208
- // Check the computed signature against the one passed in the query
209
- $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
210
-
211
- // Release the key resource
212
- openssl_free_key($publickeyid);
213
-
214
- return $ok == 1;
215
- }
216
- }
217
-
218
- class OAuthRequest {
219
- private $parameters;
220
- private $http_method;
221
- private $http_url;
222
- // for debug purposes
223
- public $base_string;
224
- public static $version = '1.0';
225
- public static $POST_INPUT = 'php://input';
226
-
227
- function __construct($http_method, $http_url, $parameters=NULL) {
228
- @$parameters or $parameters = array();
229
- $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
230
- $this->parameters = $parameters;
231
- $this->http_method = $http_method;
232
- $this->http_url = $http_url;
233
- }
234
-
235
-
236
- /**
237
- * attempt to build up a request from what was passed to the server
238
- */
239
- public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
240
- $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
241
- ? 'http'
242
- : 'https';
243
- @$http_url or $http_url = $scheme .
244
- '://' . $_SERVER['HTTP_HOST'] .
245
- ':' .
246
- $_SERVER['SERVER_PORT'] .
247
- $_SERVER['REQUEST_URI'];
248
- @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
249
-
250
- // We weren't handed any parameters, so let's find the ones relevant to
251
- // this request.
252
- // If you run XML-RPC or similar you should use this to provide your own
253
- // parsed parameter-list
254
- if (!$parameters) {
255
- // Find request headers
256
- $request_headers = OAuthUtil::get_headers();
257
-
258
- // Parse the query-string to find GET parameters
259
- $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
260
-
261
- // It's a POST request of the proper content-type, so parse POST
262
- // parameters and add those overriding any duplicates from GET
263
- if ($http_method == "POST"
264
- && @strstr($request_headers["Content-Type"],
265
- "application/x-www-form-urlencoded")
266
- ) {
267
- $post_data = OAuthUtil::parse_parameters(
268
- file_get_contents(self::$POST_INPUT)
269
- );
270
- $parameters = array_merge($parameters, $post_data);
271
- }
272
-
273
- // We have a Authorization-header with OAuth data. Parse the header
274
- // and add those overriding any duplicates from GET or POST
275
- if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
276
- $header_parameters = OAuthUtil::split_header(
277
- $request_headers['Authorization']
278
- );
279
- $parameters = array_merge($parameters, $header_parameters);
280
- }
281
-
282
- }
283
-
284
- return new OAuthRequest($http_method, $http_url, $parameters);
285
- }
286
-
287
- /**
288
- * pretty much a helper function to set up the request
289
- */
290
- public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
291
- @$parameters or $parameters = array();
292
- $defaults = array("oauth_version" => OAuthRequest::$version,
293
- "oauth_nonce" => OAuthRequest::generate_nonce(),
294
- "oauth_timestamp" => OAuthRequest::generate_timestamp(),
295
- "oauth_consumer_key" => $consumer->key);
296
- if ($token)
297
- $defaults['oauth_token'] = $token->key;
298
-
299
- $parameters = array_merge($defaults, $parameters);
300
-
301
- return new OAuthRequest($http_method, $http_url, $parameters);
302
- }
303
-
304
- public function set_parameter($name, $value, $allow_duplicates = true) {
305
- if ($allow_duplicates && isset($this->parameters[$name])) {
306
- // We have already added parameter(s) with this name, so add to the list
307
- if (is_scalar($this->parameters[$name])) {
308
- // This is the first duplicate, so transform scalar (string)
309
- // into an array so we can add the duplicates
310
- $this->parameters[$name] = array($this->parameters[$name]);
311
- }
312
-
313
- $this->parameters[$name][] = $value;
314
- } else {
315
- $this->parameters[$name] = $value;
316
- }
317
- }
318
-
319
- public function get_parameter($name) {
320
- return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
321
- }
322
-
323
- public function get_parameters() {
324
- return $this->parameters;
325
- }
326
-
327
- public function unset_parameter($name) {
328
- unset($this->parameters[$name]);
329
- }
330
-
331
- /**
332
- * The request parameters, sorted and concatenated into a normalized string.
333
- * @return string
334
- */
335
- public function get_signable_parameters() {
336
- // Grab all parameters
337
- $params = $this->parameters;
338
-
339
- // Remove oauth_signature if present
340
- // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
341
- if (isset($params['oauth_signature'])) {
342
- unset($params['oauth_signature']);
343
- }
344
-
345
- return OAuthUtil::build_http_query($params);
346
- }
347
-
348
- /**
349
- * Returns the base string of this request
350
- *
351
- * The base string defined as the method, the url
352
- * and the parameters (normalized), each urlencoded
353
- * and the concated with &.
354
- */
355
- public function get_signature_base_string() {
356
- $parts = array(
357
- $this->get_normalized_http_method(),
358
- $this->get_normalized_http_url(),
359
- $this->get_signable_parameters()
360
- );
361
-
362
- $parts = OAuthUtil::urlencode_rfc3986($parts);
363
-
364
- return implode('&', $parts);
365
- }
366
-
367
- /**
368
- * just uppercases the http method
369
- */
370
- public function get_normalized_http_method() {
371
- return strtoupper($this->http_method);
372
- }
373
-
374
- /**
375
- * parses the url and rebuilds it to be
376
- * scheme://host/path
377
- */
378
- public function get_normalized_http_url() {
379
- $parts = parse_url($this->http_url);
380
-
381
- $port = @$parts['port'];
382
- $scheme = $parts['scheme'];
383
- $host = $parts['host'];
384
- $path = @$parts['path'];
385
-
386
- $port or $port = ($scheme == 'https') ? '443' : '80';
387
-
388
- if (($scheme == 'https' && $port != '443')
389
- || ($scheme == 'http' && $port != '80')) {
390
- $host = "$host:$port";
391
- }
392
- return "$scheme://$host$path";
393
- }
394
-
395
- /**
396
- * builds a url usable for a GET request
397
- */
398
- public function to_url() {
399
- $post_data = $this->to_postdata();
400
- $out = $this->get_normalized_http_url();
401
- if ($post_data) {
402
- $out .= '?'.$post_data;
403
- }
404
- return $out;
405
- }
406
-
407
- /**
408
- * builds the data one would send in a POST request
409
- */
410
- public function to_postdata() {
411
- return OAuthUtil::build_http_query($this->parameters);
412
- }
413
-
414
- /**
415
- * builds the Authorization: header
416
- */
417
- public function to_header($realm=null) {
418
- $first = true;
419
- if($realm) {
420
- $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
421
- $first = false;
422
- } else
423
- $out = 'Authorization: OAuth';
424
-
425
- $total = array();
426
- foreach ($this->parameters as $k => $v) {
427
- if (substr($k, 0, 5) != "oauth") continue;
428
- if (is_array($v)) {
429
- throw new OAuthException('Arrays not supported in headers');
430
- }
431
- $out .= ($first) ? ' ' : ',';
432
- $out .= OAuthUtil::urlencode_rfc3986($k) .
433
- '="' .
434
- OAuthUtil::urlencode_rfc3986($v) .
435
- '"';
436
- $first = false;
437
- }
438
- return $out;
439
- }
440
-
441
- public function __toString() {
442
- return $this->to_url();
443
- }
444
-
445
-
446
- public function sign_request($signature_method, $consumer, $token) {
447
- $this->set_parameter(
448
- "oauth_signature_method",
449
- $signature_method->get_name(),
450
- false
451
- );
452
- $signature = $this->build_signature($signature_method, $consumer, $token);
453
- $this->set_parameter("oauth_signature", $signature, false);
454
- }
455
-
456
- public function build_signature($signature_method, $consumer, $token) {
457
- $signature = $signature_method->build_signature($this, $consumer, $token);
458
- return $signature;
459
- }
460
-
461
- /**
462
- * util function: current timestamp
463
- */
464
- private static function generate_timestamp() {
465
- return time();
466
- }
467
-
468
- /**
469
- * util function: current nonce
470
- */
471
- private static function generate_nonce() {
472
- $mt = microtime();
473
- $rand = mt_rand();
474
-
475
- return md5($mt . $rand); // md5s look nicer than numbers
476
- }
477
- }
478
-
479
- class OAuthServer {
480
- protected $timestamp_threshold = 300; // in seconds, five minutes
481
- protected $version = '1.0'; // hi blaine
482
- protected $signature_methods = array();
483
-
484
- protected $data_store;
485
-
486
- function __construct($data_store) {
487
- $this->data_store = $data_store;
488
- }
489
-
490
- public function add_signature_method($signature_method) {
491
- $this->signature_methods[$signature_method->get_name()] =
492
- $signature_method;
493
- }
494
-
495
- // high level functions
496
-
497
- /**
498
- * process a request_token request
499
- * returns the request token on success
500
- */
501
- public function fetch_request_token(&$request) {
502
- $this->get_version($request);
503
-
504
- $consumer = $this->get_consumer($request);
505
-
506
- // no token required for the initial token request
507
- $token = NULL;
508
-
509
- $this->check_signature($request, $consumer, $token);
510
-
511
- // Rev A change
512
- $callback = $request->get_parameter('oauth_callback');
513
- $new_token = $this->data_store->new_request_token($consumer, $callback);
514
-
515
- return $new_token;
516
- }
517
-
518
- /**
519
- * process an access_token request
520
- * returns the access token on success
521
- */
522
- public function fetch_access_token(&$request) {
523
- $this->get_version($request);
524
-
525
- $consumer = $this->get_consumer($request);
526
-
527
- // requires authorized request token
528
- $token = $this->get_token($request, $consumer, "request");
529
-
530
- $this->check_signature($request, $consumer, $token);
531
-
532
- // Rev A change
533
- $verifier = $request->get_parameter('oauth_verifier');
534
- $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
535
-
536
- return $new_token;
537
- }
538
-
539
- /**
540
- * verify an api call, checks all the parameters
541
- */
542
- public function verify_request(&$request) {
543
- $this->get_version($request);
544
- $consumer = $this->get_consumer($request);
545
- $token = $this->get_token($request, $consumer, "access");
546
- $this->check_signature($request, $consumer, $token);
547
- return array($consumer, $token);
548
- }
549
-
550
- // Internals from here
551
- /**
552
- * version 1
553
- */
554
- private function get_version(&$request) {
555
- $version = $request->get_parameter("oauth_version");
556
- if (!$version) {
557
- // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
558
- // Chapter 7.0 ("Accessing Protected Ressources")
559
- $version = '1.0';
560
- }
561
- if ($version !== $this->version) {
562
- throw new OAuthException("OAuth version '$version' not supported");
563
- }
564
- return $version;
565
- }
566
-
567
- /**
568
- * figure out the signature with some defaults
569
- */
570
- private function get_signature_method(&$request) {
571
- $signature_method =
572
- @$request->get_parameter("oauth_signature_method");
573
-
574
- if (!$signature_method) {
575
- // According to chapter 7 ("Accessing Protected Ressources") the signature-method
576
- // parameter is required, and we can't just fallback to PLAINTEXT
577
- throw new OAuthException('No signature method parameter. This parameter is required');
578
- }
579
-
580
- if (!in_array($signature_method,
581
- array_keys($this->signature_methods))) {
582
- throw new OAuthException(
583
- "Signature method '$signature_method' not supported " .
584
- "try one of the following: " .
585
- implode(", ", array_keys($this->signature_methods))
586
- );
587
- }
588
- return $this->signature_methods[$signature_method];
589
- }
590
-
591
- /**
592
- * try to find the consumer for the provided request's consumer key
593
- */
594
- private function get_consumer(&$request) {
595
- $consumer_key = @$request->get_parameter("oauth_consumer_key");
596
- if (!$consumer_key) {
597
- throw new OAuthException("Invalid consumer key");
598
- }
599
-
600
- $consumer = $this->data_store->lookup_consumer($consumer_key);
601
- if (!$consumer) {
602
- throw new OAuthException("Invalid consumer");
603
- }
604
-
605
- return $consumer;
606
- }
607
-
608
- /**
609
- * try to find the token for the provided request's token key
610
- */
611
- private function get_token(&$request, $consumer, $token_type="access") {
612
- $token_field = @$request->get_parameter('oauth_token');
613
- $token = $this->data_store->lookup_token(
614
- $consumer, $token_type, $token_field
615
- );
616
- if (!$token) {
617
- throw new OAuthException("Invalid $token_type token: $token_field");
618
- }
619
- return $token;
620
- }
621
-
622
- /**
623
- * all-in-one function to check the signature on a request
624
- * should guess the signature method appropriately
625
- */
626
- private function check_signature(&$request, $consumer, $token) {
627
- // this should probably be in a different method
628
- $timestamp = @$request->get_parameter('oauth_timestamp');
629
- $nonce = @$request->get_parameter('oauth_nonce');
630
-
631
- $this->check_timestamp($timestamp);
632
- $this->check_nonce($consumer, $token, $nonce, $timestamp);
633
-
634
- $signature_method = $this->get_signature_method($request);
635
-
636
- $signature = $request->get_parameter('oauth_signature');
637
- $valid_sig = $signature_method->check_signature(
638
- $request,
639
- $consumer,
640
- $token,
641
- $signature
642
- );
643
-
644
- if (!$valid_sig) {
645
- throw new OAuthException("Invalid signature");
646
- }
647
- }
648
-
649
- /**
650
- * check that the timestamp is new enough
651
- */
652
- private function check_timestamp($timestamp) {
653
- if( ! $timestamp )
654
- throw new OAuthException(
655
- 'Missing timestamp parameter. The parameter is required'
656
- );
657
-
658
- // verify that timestamp is recentish
659
- $now = time();
660
- if (abs($now - $timestamp) > $this->timestamp_threshold) {
661
- throw new OAuthException(
662
- "Expired timestamp, yours $timestamp, ours $now"
663
- );
664
- }
665
- }
666
-
667
- /**
668
- * check that the nonce is not repeated
669
- */
670
- private function check_nonce($consumer, $token, $nonce, $timestamp) {
671
- if( ! $nonce )
672
- throw new OAuthException(
673
- 'Missing nonce parameter. The parameter is required'
674
- );
675
-
676
- // verify that the nonce is uniqueish
677
- $found = $this->data_store->lookup_nonce(
678
- $consumer,
679
- $token,
680
- $nonce,
681
- $timestamp
682
- );
683
- if ($found) {
684
- throw new OAuthException("Nonce already used: $nonce");
685
- }
686
- }
687
-
688
- }
689
-
690
- class OAuthDataStore {
691
- function lookup_consumer($consumer_key) {
692
- // implement me
693
- }
694
-
695
- function lookup_token($consumer, $token_type, $token) {
696
- // implement me
697
- }
698
-
699
- function lookup_nonce($consumer, $token, $nonce, $timestamp) {
700
- // implement me
701
- }
702
-
703
- function new_request_token($consumer, $callback = null) {
704
- // return a new token attached to this consumer
705
- }
706
-
707
- function new_access_token($token, $consumer, $verifier = null) {
708
- // return a new access token attached to this consumer
709
- // for the user associated with this token if the request token
710
- // is authorized
711
- // should also invalidate the request token
712
- }
713
-
714
- }
715
-
716
- class OAuthUtil {
717
- public static function urlencode_rfc3986($input) {
718
- if (is_array($input)) {
719
- return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
720
- } else if (is_scalar($input)) {
721
- return str_replace(
722
- '+',
723
- ' ',
724
- str_replace('%7E', '~', rawurlencode($input))
725
- );
726
- } else {
727
- return '';
728
- }
729
- }
730
-
731
-
732
- // This decode function isn't taking into consideration the above
733
- // modifications to the encoding process. However, this method doesn't
734
- // seem to be used anywhere so leaving it as is.
735
- public static function urldecode_rfc3986($string) {
736
- return urldecode($string);
737
- }
738
-
739
- // Utility function for turning the Authorization: header into
740
- // parameters, has to do some unescaping
741
- // Can filter out any non-oauth parameters if needed (default behaviour)
742
- public static function split_header($header, $only_allow_oauth_parameters = true) {
743
- $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
744
- $offset = 0;
745
- $params = array();
746
- while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
747
- $match = $matches[0];
748
- $header_name = $matches[2][0];
749
- $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
750
- if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
751
- $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
752
- }
753
- $offset = $match[1] + strlen($match[0]);
754
- }
755
-
756
- if (isset($params['realm'])) {
757
- unset($params['realm']);
758
- }
759
-
760
- return $params;
761
- }
762
-
763
- // helper to try to sort out headers for people who aren't running apache
764
- public static function get_headers() {
765
- if (function_exists('apache_request_headers')) {
766
- // we need this to get the actual Authorization: header
767
- // because apache tends to tell us it doesn't exist
768
- $headers = apache_request_headers();
769
-
770
- // sanitize the output of apache_request_headers because
771
- // we always want the keys to be Cased-Like-This and arh()
772
- // returns the headers in the same case as they are in the
773
- // request
774
- $out = array();
775
- foreach( $headers AS $key => $value ) {
776
- $key = str_replace(
777
- " ",
778
- "-",
779
- ucwords(strtolower(str_replace("-", " ", $key)))
780
- );
781
- $out[$key] = $value;
782
- }
783
- } else {
784
- // otherwise we don't have apache and are just going to have to hope
785
- // that $_SERVER actually contains what we need
786
- $out = array();
787
- if( isset($_SERVER['CONTENT_TYPE']) )
788
- $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
789
- if( isset($_ENV['CONTENT_TYPE']) )
790
- $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
791
-
792
- foreach ($_SERVER as $key => $value) {
793
- if (substr($key, 0, 5) == "HTTP_") {
794
- // this is chaos, basically it is just there to capitalize the first
795
- // letter of every word that is not an initial HTTP and strip HTTP
796
- // code from przemek
797
- $key = str_replace(
798
- " ",
799
- "-",
800
- ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
801
- );
802
- $out[$key] = $value;
803
- }
804
- }
805
- }
806
- return $out;
807
- }
808
-
809
- // This function takes a input like a=b&a=c&d=e and returns the parsed
810
- // parameters like this
811
- // array('a' => array('b','c'), 'd' => 'e')
812
- public static function parse_parameters( $input ) {
813
- if (!isset($input) || !$input) return array();
814
-
815
- $pairs = explode('&', $input);
816
-
817
- $parsed_parameters = array();
818
- foreach ($pairs as $pair) {
819
- $split = explode('=', $pair, 2);
820
- $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
821
- $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
822
-
823
- if (isset($parsed_parameters[$parameter])) {
824
- // We have already recieved parameter(s) with this name, so add to the list
825
- // of parameters with this name
826
-
827
- if (is_scalar($parsed_parameters[$parameter])) {
828
- // This is the first duplicate, so transform scalar (string) into an array
829
- // so we can add the duplicates
830
- $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
831
- }
832
-
833
- $parsed_parameters[$parameter][] = $value;
834
- } else {
835
- $parsed_parameters[$parameter] = $value;
836
- }
837
- }
838
- return $parsed_parameters;
839
- }
840
-
841
- public static function build_http_query($params) {
842
- if (!$params) return '';
843
-
844
- // Urlencode both keys and values
845
- $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
846
- $values = OAuthUtil::urlencode_rfc3986(array_values($params));
847
- $params = array_combine($keys, $values);
848
-
849
- // Parameters are sorted by name, using lexicographical byte value ordering.
850
- // Ref: Spec: 9.1.1 (1)
851
- uksort($params, 'strcmp');
852
-
853
- $pairs = array();
854
- foreach ($params as $parameter => $value) {
855
- if (is_array($value)) {
856
- // If two or more parameters share the same name, they are sorted by their value
857
- // Ref: Spec: 9.1.1 (1)
858
- natsort($value);
859
- foreach ($value as $duplicate_value) {
860
- $pairs[] = $parameter . '=' . $duplicate_value;
861
- }
862
- } else {
863
- $pairs[] = $parameter . '=' . $value;
864
- }
865
- }
866
- // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
867
- // Each name-value pair is separated by an '&' character (ASCII code 38)
868
- return implode('&', $pairs);
869
- }
870
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/GoMage/Twitter/twitteroauth.php CHANGED
@@ -7,235 +7,235 @@
7
  */
8
 
9
  /* Load OAuth lib. You can find it at http://oauth.net */
10
- require_once('OAuth.php');
11
 
12
  /**
13
  * Twitter OAuth class
14
  */
15
  class TwitterOAuth {
16
- /* Contains the last HTTP status code returned. */
17
- public $http_code;
18
- /* Contains the last API call. */
19
- public $url;
20
- /* Set up the API root URL. */
21
- public $host = "https://api.twitter.com/1.1/";
22
- /* Set timeout default. */
23
- public $timeout = 30;
24
- /* Set connect timeout. */
25
- public $connecttimeout = 30;
26
- /* Verify SSL Cert. */
27
- public $ssl_verifypeer = FALSE;
28
- /* Respons format. */
29
- public $format = 'json';
30
- /* Decode returned json data. */
31
- public $decode_json = TRUE;
32
- /* Contains the last HTTP headers returned. */
33
- public $http_info;
34
- /* Set the useragnet. */
35
- public $useragent = 'TwitterOAuth v0.2.0-beta2';
36
- /* Immediately retry the API call if the response was not successful. */
37
- //public $retry = TRUE;
38
-
39
-
40
-
41
-
42
- /**
43
- * Set API URLS
44
- */
45
- function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
46
- function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
47
- function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
48
- function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
49
-
50
- /**
51
- * Debug helpers
52
- */
53
- function lastStatusCode() { return $this->http_status; }
54
- function lastAPICall() { return $this->last_api_call; }
55
-
56
- /**
57
- * construct TwitterOAuth object
58
- */
59
- function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
60
- $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
61
- $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
62
- if (!empty($oauth_token) && !empty($oauth_token_secret)) {
63
- $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
64
- } else {
65
- $this->token = NULL;
66
- }
67
- }
68
-
69
-
70
- /**
71
- * Get a request_token from Twitter
72
- *
73
- * @returns a key/value array containing oauth_token and oauth_token_secret
74
- */
75
- function getRequestToken($oauth_callback) {
76
- $parameters = array();
77
- $parameters['oauth_callback'] = $oauth_callback;
78
- $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
79
- $token = OAuthUtil::parse_parameters($request);
80
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
81
- return $token;
82
- }
83
-
84
- /**
85
- * Get the authorize URL
86
- *
87
- * @returns a string
88
- */
89
- function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
90
- if (is_array($token)) {
91
- $token = $token['oauth_token'];
92
- }
93
- if (empty($sign_in_with_twitter)) {
94
- return $this->authorizeURL() . "?oauth_token={$token}";
95
- } else {
96
- return $this->authenticateURL() . "?oauth_token={$token}";
97
- }
98
- }
99
-
100
- /**
101
- * Exchange request token and secret for an access token and
102
- * secret, to sign API calls.
103
- *
104
- * @returns array("oauth_token" => "the-access-token",
105
- * "oauth_token_secret" => "the-access-secret",
106
- * "user_id" => "9436992",
107
- * "screen_name" => "abraham")
108
- */
109
- function getAccessToken($oauth_verifier) {
110
- $parameters = array();
111
- $parameters['oauth_verifier'] = $oauth_verifier;
112
- $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
113
- $token = OAuthUtil::parse_parameters($request);
114
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
115
- return $token;
116
- }
117
-
118
- /**
119
- * One time exchange of username and password for access token and secret.
120
- *
121
- * @returns array("oauth_token" => "the-access-token",
122
- * "oauth_token_secret" => "the-access-secret",
123
- * "user_id" => "9436992",
124
- * "screen_name" => "abraham",
125
- * "x_auth_expires" => "0")
126
- */
127
- function getXAuthToken($username, $password) {
128
- $parameters = array();
129
- $parameters['x_auth_username'] = $username;
130
- $parameters['x_auth_password'] = $password;
131
- $parameters['x_auth_mode'] = 'client_auth';
132
- $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
133
- $token = OAuthUtil::parse_parameters($request);
134
- $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
135
- return $token;
136
- }
137
-
138
- /**
139
- * GET wrapper for oAuthRequest.
140
- */
141
- function get($url, $parameters = array()) {
142
- $response = $this->oAuthRequest($url, 'GET', $parameters);
143
- if ($this->format === 'json' && $this->decode_json) {
144
- return json_decode($response);
145
- }
146
- return $response;
147
- }
148
-
149
- /**
150
- * POST wrapper for oAuthRequest.
151
- */
152
- function post($url, $parameters = array()) {
153
- $response = $this->oAuthRequest($url, 'POST', $parameters);
154
- if ($this->format === 'json' && $this->decode_json) {
155
- return json_decode($response);
156
- }
157
- return $response;
158
- }
159
-
160
- /**
161
- * DELETE wrapper for oAuthReqeust.
162
- */
163
- function delete($url, $parameters = array()) {
164
- $response = $this->oAuthRequest($url, 'DELETE', $parameters);
165
- if ($this->format === 'json' && $this->decode_json) {
166
- return json_decode($response);
167
- }
168
- return $response;
169
- }
170
-
171
- /**
172
- * Format and sign an OAuth / API request
173
- */
174
- function oAuthRequest($url, $method, $parameters) {
175
- if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
176
- $url = "{$this->host}{$url}.{$this->format}";
177
- }
178
- $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
179
- $request->sign_request($this->sha1_method, $this->consumer, $this->token);
180
- switch ($method) {
181
- case 'GET':
182
- return $this->http($request->to_url(), 'GET');
183
- default:
184
- return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
185
- }
186
- }
187
-
188
- /**
189
- * Make an HTTP request
190
- *
191
- * @return API results
192
- */
193
- function http($url, $method, $postfields = NULL) {
194
- $this->http_info = array();
195
- $ci = curl_init();
196
- /* Curl settings */
197
- curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
198
- curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
199
- curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
200
- curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
201
- curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
202
- curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
203
- curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
204
- curl_setopt($ci, CURLOPT_HEADER, FALSE);
205
-
206
- switch ($method) {
207
- case 'POST':
208
- curl_setopt($ci, CURLOPT_POST, TRUE);
209
- if (!empty($postfields)) {
210
- curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
211
- }
212
- break;
213
- case 'DELETE':
214
- curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
215
- if (!empty($postfields)) {
216
- $url = "{$url}?{$postfields}";
217
- }
218
- }
219
-
220
- curl_setopt($ci, CURLOPT_URL, $url);
221
- $response = curl_exec($ci);
222
- $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
223
- $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
224
- $this->url = $url;
225
- curl_close ($ci);
226
- return $response;
227
- }
228
-
229
- /**
230
- * Get the header info to store.
231
- */
232
- function getHeader($ch, $header) {
233
- $i = strpos($header, ':');
234
- if (!empty($i)) {
235
- $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
236
- $value = trim(substr($header, $i + 2));
237
- $this->http_header[$key] = $value;
238
- }
239
- return strlen($header);
240
- }
241
  }
7
  */
8
 
9
  /* Load OAuth lib. You can find it at http://oauth.net */
10
+ require_once(__DIR__ . DS . '..' . DS . 'OAuth' . DS . 'OAuth.php');
11
 
12
  /**
13
  * Twitter OAuth class
14
  */
15
  class TwitterOAuth {
16
+ /* Contains the last HTTP status code returned. */
17
+ public $http_code;
18
+ /* Contains the last API call. */
19
+ public $url;
20
+ /* Set up the API root URL. */
21
+ public $host = "https://api.twitter.com/1.1/";
22
+ /* Set timeout default. */
23
+ public $timeout = 30;
24
+ /* Set connect timeout. */
25
+ public $connecttimeout = 30;
26
+ /* Verify SSL Cert. */
27
+ public $ssl_verifypeer = FALSE;
28
+ /* Respons format. */
29
+ public $format = 'json';
30
+ /* Decode returned json data. */
31
+ public $decode_json = TRUE;
32
+ /* Contains the last HTTP headers returned. */
33
+ public $http_info;
34
+ /* Set the useragnet. */
35
+ public $useragent = 'TwitterOAuth v0.2.0-beta2';
36
+ /* Immediately retry the API call if the response was not successful. */
37
+ //public $retry = TRUE;
38
+
39
+
40
+
41
+
42
+ /**
43
+ * Set API URLS
44
+ */
45
+ function accessTokenURL() { return 'https://api.twitter.com/oauth/access_token'; }
46
+ function authenticateURL() { return 'https://api.twitter.com/oauth/authenticate'; }
47
+ function authorizeURL() { return 'https://api.twitter.com/oauth/authorize'; }
48
+ function requestTokenURL() { return 'https://api.twitter.com/oauth/request_token'; }
49
+
50
+ /**
51
+ * Debug helpers
52
+ */
53
+ function lastStatusCode() { return $this->http_status; }
54
+ function lastAPICall() { return $this->last_api_call; }
55
+
56
+ /**
57
+ * construct TwitterOAuth object
58
+ */
59
+ function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
60
+ $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
61
+ $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
62
+ if (!empty($oauth_token) && !empty($oauth_token_secret)) {
63
+ $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
64
+ } else {
65
+ $this->token = NULL;
66
+ }
67
+ }
68
+
69
+
70
+ /**
71
+ * Get a request_token from Twitter
72
+ *
73
+ * @returns a key/value array containing oauth_token and oauth_token_secret
74
+ */
75
+ function getRequestToken($oauth_callback) {
76
+ $parameters = array();
77
+ $parameters['oauth_callback'] = $oauth_callback;
78
+ $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
79
+ $token = OAuthUtil::parse_parameters($request);
80
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
81
+ return $token;
82
+ }
83
+
84
+ /**
85
+ * Get the authorize URL
86
+ *
87
+ * @returns a string
88
+ */
89
+ function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
90
+ if (is_array($token)) {
91
+ $token = $token['oauth_token'];
92
+ }
93
+ if (empty($sign_in_with_twitter)) {
94
+ return $this->authorizeURL() . "?oauth_token={$token}";
95
+ } else {
96
+ return $this->authenticateURL() . "?oauth_token={$token}";
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Exchange request token and secret for an access token and
102
+ * secret, to sign API calls.
103
+ *
104
+ * @returns array("oauth_token" => "the-access-token",
105
+ * "oauth_token_secret" => "the-access-secret",
106
+ * "user_id" => "9436992",
107
+ * "screen_name" => "abraham")
108
+ */
109
+ function getAccessToken($oauth_verifier) {
110
+ $parameters = array();
111
+ $parameters['oauth_verifier'] = $oauth_verifier;
112
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
113
+ $token = OAuthUtil::parse_parameters($request);
114
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
115
+ return $token;
116
+ }
117
+
118
+ /**
119
+ * One time exchange of username and password for access token and secret.
120
+ *
121
+ * @returns array("oauth_token" => "the-access-token",
122
+ * "oauth_token_secret" => "the-access-secret",
123
+ * "user_id" => "9436992",
124
+ * "screen_name" => "abraham",
125
+ * "x_auth_expires" => "0")
126
+ */
127
+ function getXAuthToken($username, $password) {
128
+ $parameters = array();
129
+ $parameters['x_auth_username'] = $username;
130
+ $parameters['x_auth_password'] = $password;
131
+ $parameters['x_auth_mode'] = 'client_auth';
132
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
133
+ $token = OAuthUtil::parse_parameters($request);
134
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
135
+ return $token;
136
+ }
137
+
138
+ /**
139
+ * GET wrapper for oAuthRequest.
140
+ */
141
+ function get($url, $parameters = array()) {
142
+ $response = $this->oAuthRequest($url, 'GET', $parameters);
143
+ if ($this->format === 'json' && $this->decode_json) {
144
+ return json_decode($response);
145
+ }
146
+ return $response;
147
+ }
148
+
149
+ /**
150
+ * POST wrapper for oAuthRequest.
151
+ */
152
+ function post($url, $parameters = array()) {
153
+ $response = $this->oAuthRequest($url, 'POST', $parameters);
154
+ if ($this->format === 'json' && $this->decode_json) {
155
+ return json_decode($response);
156
+ }
157
+ return $response;
158
+ }
159
+
160
+ /**
161
+ * DELETE wrapper for oAuthReqeust.
162
+ */
163
+ function delete($url, $parameters = array()) {
164
+ $response = $this->oAuthRequest($url, 'DELETE', $parameters);
165
+ if ($this->format === 'json' && $this->decode_json) {
166
+ return json_decode($response);
167
+ }
168
+ return $response;
169
+ }
170
+
171
+ /**
172
+ * Format and sign an OAuth / API request
173
+ */
174
+ function oAuthRequest($url, $method, $parameters) {
175
+ if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
176
+ $url = "{$this->host}{$url}.{$this->format}";
177
+ }
178
+ $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
179
+ $request->sign_request($this->sha1_method, $this->consumer, $this->token);
180
+ switch ($method) {
181
+ case 'GET':
182
+ return $this->http($request->to_url(), 'GET');
183
+ default:
184
+ return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Make an HTTP request
190
+ *
191
+ * @return API results
192
+ */
193
+ function http($url, $method, $postfields = NULL) {
194
+ $this->http_info = array();
195
+ $ci = curl_init();
196
+ /* Curl settings */
197
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
198
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
199
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
200
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
201
+ curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
202
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
203
+ curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
204
+ curl_setopt($ci, CURLOPT_HEADER, FALSE);
205
+
206
+ switch ($method) {
207
+ case 'POST':
208
+ curl_setopt($ci, CURLOPT_POST, TRUE);
209
+ if (!empty($postfields)) {
210
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
211
+ }
212
+ break;
213
+ case 'DELETE':
214
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
215
+ if (!empty($postfields)) {
216
+ $url = "{$url}?{$postfields}";
217
+ }
218
+ }
219
+
220
+ curl_setopt($ci, CURLOPT_URL, $url);
221
+ $response = curl_exec($ci);
222
+ $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
223
+ $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
224
+ $this->url = $url;
225
+ curl_close ($ci);
226
+ return $response;
227
+ }
228
+
229
+ /**
230
+ * Get the header info to store.
231
+ */
232
+ function getHeader($ch, $header) {
233
+ $i = strpos($header, ':');
234
+ if (!empty($i)) {
235
+ $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
236
+ $value = trim(substr($header, $i + 2));
237
+ $this->http_header[$key] = $value;
238
+ }
239
+ return strlen($header);
240
+ }
241
  }
package.xml CHANGED
@@ -1,12 +1,12 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>gomage_social_connector</name>
4
- <version>1.3.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gomage.com/license-agreement/">Single domain license</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>GoMage Social Connector allows your customers to login with the most popular social connectors: Amazon, Facebook, LinkedIn, Google and Google+!, Twitter, Tumblr and Reddit.</summary>
10
  <description>Features of GoMage Social Connector:&#xD;
11
  Connect with Amazon;&#xD;
12
  Connect with Facebook;&#xD;
@@ -15,14 +15,16 @@ Connect with LinkedIn;&#xD;
15
  Connect with Twitter;&#xD;
16
  Connect with Tumblr;&#xD;
17
  Connect with Reddit;&#xD;
 
 
18
  No connections to the 3rd party services and monthly fees;&#xD;
19
  No core modifications require;&#xD;
20
  Easy installation of the extension allows you to just upload files and use it.</description>
21
- <notes>Version 1.3.0</notes>
22
  <authors><author><name>GoMage</name><user>GoMage</user><email>support@gomage.com</email></author></authors>
23
- <date>2015-07-31</date>
24
- <time>14:27:39</time>
25
- <contents><target name="magelocal"><dir name="GoMage"><dir name="Social"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="AbstractRedirectUri.php" hash="588745a16f11c579c9be670f16673e60"/><dir name="Fieldset"><file name="General.php" hash="e903a1904b8ca1f0f5d6a872da91492c"/><file name="Information.php" hash="266c00d8af42922e55562ce4cb55864b"/></dir><dir name="RedirectUri"><file name="Amazon.php" hash="815a2a4c30e1d66733f2b3286ee5427e"/><file name="Google.php" hash="193eacd7ec7045b5be8f4fc69dfca454"/><file name="Linkedin.php" hash="6a011d4342022daaa6c58444fe201645"/><file name="Reddit.php" hash="dec9a1ad6979d301c0be71d55252a328"/><file name="Tumblr.php" hash="a9eee39bd02f6aa71315ec4d87e7ac7c"/><file name="Twitter.php" hash="258207c6915ae4927a12029ac3bec9f8"/></dir></dir></dir></dir><file name="Head.php" hash="c20839e8f2a0773e0a3b3f85cd46e838"/><dir name="Login"><file name="Facebook.php" hash="771e073b452930b80a4acb52e3edc6e3"/><file name="Google.php" hash="2c3a5216e13dec31559f74f3ff2b4cae"/><file name="Service.php" hash="5163a6d8487fff284a1cbe88952a2f1c"/></dir><file name="Login.php" hash="eeb332a9d3d021e627140218a52b4216"/></dir><dir name="Controller"><file name="Social.php" hash="4f7d0c0b4a3d97168d4bc52ef691f136"/><file name="SocialNoMail.php" hash="4a865a3f9c153339e86c12845df59dad"/></dir><dir name="Helper"><file name="Data.php" hash="36abe6e5f8222a42dc4638acfbd0752b"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Login"><dir name="Type"><file name="Facebook.php" hash="992d30420bc0acdca493e739fd04d858"/><file name="Google.php" hash="11da1b2411b75976ef86b1b6ddc5df5c"/></dir><file name="Type.php" hash="2585b5260c1c70b94460592fda6a7c00"/></dir><file name="Services.php" hash="96859f2c7945c5d1636e56e6c51233cf"/></dir></dir></dir></dir><file name="Entity.php" hash="5ce57b56e77712a6a6e79b13b18f71fa"/><dir name="Mysql4"><dir name="Entity"><file name="Collection.php" hash="289a6d1b6b5ab54df057c5c655018809"/></dir><file name="Entity.php" hash="f272cdb9c60e8550f49d7a697fc0e486"/></dir><dir name="Observer"><file name="Notify.php" hash="473b3022e339341331d762058300dfba"/></dir><file name="Observer.php" hash="b974c01b97bd087ccf1b303c9fd1a388"/><file name="Type.php" hash="2a190ce4d364a2785ccc0e6a491a5d74"/></dir><dir name="controllers"><file name="AmazonController.php" hash="7c5b998c78ab313d42de1e51c0808f61"/><file name="FacebookController.php" hash="e914faa64216652d1ccae336d66b2c77"/><file name="GoogleController.php" hash="32ed76bc4f8a1bc67805bc37f1349846"/><file name="LinkedinController.php" hash="73718d7b945cb05e43b166786d785311"/><file name="RedditController.php" hash="8971c441fbb921a194ee14509743a73b"/><file name="TumblrController.php" hash="023dd72ff26f4baa0aebc7f514b46d73"/><file name="TwitterController.php" hash="87b8db5340e2c81e2d0b178a1cab8222"/></dir><dir name="etc"><file name="adminhtml.xml" hash="253b7fdb6dde64973d74ba34973525a0"/><file name="config.xml" hash="47f9122c72e511719831deae6278985b"/><file name="system.xml" hash="4151c621e5a0c14a9fc714625f9cf900"/></dir><dir name="sql"><dir name="gomage_social_setup"><file name="mysql4-install-1.0.0.php" hash="8cb49d7aa72ae13c3b62787ff31b24d7"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="624c3202f151a91714171d34f02faef2"/><file name="mysql4-upgrade-1.1.0-1.2.0.php" hash="362b01a230b9ddbe2e54f754c710f73b"/></dir></dir></dir></dir></target><target name="magecore"><dir name="modules"><file name="GoMage_Social.xml" hash=""/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="gomage-social.xml" hash="109741b7e5bc033d908eb28e4352eabe"/></dir><dir name="template"><dir name="gomage"><dir name="social"><file name="config.phtml" hash="4e54807d44e7eef7e354fabf7338f678"/><dir name="login"><file name="facebook.phtml" hash="5d78532a6127cd4c100557a49600b632"/><file name="google.phtml" hash="80c3a9d63c54fb9a4ef55d57bcd86fb1"/><file name="service.phtml" hash="0e0d3467174c93bbabae8a5636b8ae25"/></dir><file name="login.phtml" hash="9b35a5a608f26f20fe7e6086c3a155e3"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="GoMage"><dir name="Amazon"><file name="Credentials.php" hash="3ad43e8bb1bebec645921e57428c7d68"/><file name="Service.php" hash="8d403445be01e5bb84acfd36527d8025"/></dir><dir name="Facebook"><file name="base_facebook.php" hash="f2a629c25efa36fc02f699f7e52dc61e"/><file name="facebook.php" hash="dcb23268876023d6fa7e1d3349d13819"/><file name="fb_ca_chain_bundle.crt" hash="c4290b9deb70d0bef2f88b67fc68c8ec"/></dir><dir name="Google"><file name="Google_Client.php" hash="7b85279df4c0d845415c97a579df614e"/><dir name="auth"><file name="Google_AssertionCredentials.php" hash="19ec1a0bc3ffdeb07083e225f3e0ac7b"/><file name="Google_Auth.php" hash="15873dc9c390eadbd5da2c0297062d7c"/><file name="Google_AuthNone.php" hash="093b237c59e2e085a97e664c0ce88ebe"/><file name="Google_LoginTicket.php" hash="4397ba773564c0c73f32ae118c24b5d2"/><file name="Google_OAuth2.php" hash="39f54796674f476271ce8d5c05c9ec71"/><file name="Google_P12Signer.php" hash="e33e570503ed42cf7d25dd6c32d67263"/><file name="Google_PemVerifier.php" hash="e9fb745bc98981953a270e0374e77e58"/><file name="Google_Signer.php" hash="b89eb963b836860aa622c2111915e5ac"/><file name="Google_Verifier.php" hash="08c9de305f4824c6d94d7c40bfe7be58"/></dir><dir name="cache"><file name="Google_ApcCache.php" hash="38942168cb94c15a9064aa8faa6c1817"/><file name="Google_Cache.php" hash="98c92b5d919c9143e68230e612298a9b"/><file name="Google_FileCache.php" hash="7cb3f047c1e3774474de8e8b2f5bd638"/><file name="Google_MemcacheCache.php" hash="48f2b20eb2481b40954d0a7a130fa766"/></dir><file name="config.php" hash="a26b007bba5cd5ca2a48bb13f8e7b663"/><dir name="contrib"><file name="Google_AdExchangeSellerService.php" hash="318705a28a809a1d23e3cb834dcf32be"/><file name="Google_AdexchangebuyerService.php" hash="9998193782e0677dc8cba52a126bb3d5"/><file name="Google_AdsenseService.php" hash="7acdc4933f20648c8b4122c9650dc6df"/><file name="Google_AdsensehostService.php" hash="5b2907beaca5a177fc4e06558b20e711"/><file name="Google_AnalyticsService.php" hash="1c1b987a22ed153cc4cf64adf1ff4cb9"/><file name="Google_BigqueryService.php" hash="52cdc203a5959b43c6a8a69b9cb16f45"/><file name="Google_BloggerService.php" hash="65336d21d58f8f2c983246b2a768064c"/><file name="Google_BooksService.php" hash="1d3ea79436b063f95f1b1995217ff105"/><file name="Google_CalendarService.php" hash="1828cfdabcded687997e5cad9999b4bb"/><file name="Google_ComputeService.php" hash="6e02a8f3a711bd99f5c1a5d2fb7c472f"/><file name="Google_CustomsearchService.php" hash="71e240765a29ee901ad1f5f30a7164e6"/><file name="Google_DfareportingService.php" hash="3f2e8a38a9a2ce577a07510785fcf38d"/><file name="Google_DriveService.php" hash="e55201ec487c65eea2dcbbc957d50e0e"/><file name="Google_FreebaseService.php" hash="eb53801d59a2edd1c16e5c5b33fba221"/><file name="Google_FusiontablesService.php" hash="2e484e55d79e219246a7ef8f56dfd5ee"/><file name="Google_GanService.php" hash="0f82b88d1f736652fb0568885329515c"/><file name="Google_LatitudeService.php" hash="165096ab7a3a8b05f97ea3a3f02d28d6"/><file name="Google_LicensingService.php" hash="8f55c323fb03447bab1b7403fd4ab2f6"/><file name="Google_ModeratorService.php" hash="f20f92b05539441192ccf98ef0d6cc90"/><file name="Google_Oauth2Service.php" hash="9273a2ae188738ccd091017212495197"/><file name="Google_OrkutService.php" hash="d0cd466c78cd9c8dcd1e0cfef384696b"/><file name="Google_PagespeedonlineService.php" hash="b73efb6889f190c4aeb01758f8cfc43a"/><file name="Google_PlusMomentsService.php" hash="a4455c8ef47558346a85d2e47588146a"/><file name="Google_PlusService.php" hash="7749cc0a3927896cb3ec038417f65938"/><file name="Google_PredictionService.php" hash="2c4739a3ef181178eb4f76f9ab2d56f6"/><file name="Google_ShoppingService.php" hash="3dbda05eb3f7f8baa7f0188a0a391eac"/><file name="Google_SiteVerificationService.php" hash="9792e2bbe628fdae91dbfae35c00df14"/><file name="Google_StorageService.php" hash="51b240f63170d0c0dd27a2c6e435ddbe"/><file name="Google_TaskqueueService.php" hash="e34f538ffc1e2e412431e85c7cdec662"/><file name="Google_TasksService.php" hash="3065ef4ba7b95317e149191432cb8440"/><file name="Google_TranslateService.php" hash="5dc38b483a051aab0ded6c327beb0025"/><file name="Google_UrlshortenerService.php" hash="ef4fe776c3fa2324dde4afbe0494f979"/><file name="Google_WebfontsService.php" hash="04260525d97d2a1701821eced43fd96e"/><file name="Google_YouTubeService.php" hash="41740022788c34e3bba26abb889855a7"/></dir><dir name="external"><file name="URITemplateParser.php" hash="dc829ddd424801e2bc4bf83bfb5e698c"/></dir><dir name="io"><file name="Google_CacheParser.php" hash="a8524de4f95bc1d237a7bf22dd3dfb8a"/><file name="Google_CurlIO.php" hash="9f5d2871c87ba61cced0efab8c57d4dc"/><file name="Google_HttpRequest.php" hash="01f22c8d762d21fd7c93d4d60737b041"/><file name="Google_IO.php" hash="872ddfd60a5ef638517ef81c7c0b6b95"/><file name="Google_REST.php" hash="61d31688aa7d280b1e7a7ba4d2fcacb3"/><file name="cacerts.pem" hash="2dc185f345f7ca634aec690243f346d8"/></dir><dir name="service"><file name="Google_BatchRequest.php" hash="3c5f95b98e16d1a4a3fe2cc5cf48e9b6"/><file name="Google_MediaFileUpload.php" hash="90cc23d99dd18df03372a02a67de1cce"/><file name="Google_Model.php" hash="2c2d018441c8e8971d6b0528f3f34d85"/><file name="Google_Service.php" hash="213627cf943f19478ecd263b1f253195"/><file name="Google_ServiceResource.php" hash="6aa5fb58563b8c00f5210a9b3db67def"/><file name="Google_Utils.php" hash="612e0e3add05f9cf52d64065b7ccca0a"/></dir></dir><dir name="Linkedin"><file name="OAuth.php" hash="d645162e3e8906ab8c24d1ce54bf0279"/><file name="linkedinoauth.php" hash="9f2758f8acd31780d79fc63c8d391ec5"/></dir><dir name="MobileDetect"><file name="Navigation_Mobile_Detect.php" hash="16a21f3fe70e82451b33b2376026f5f8"/></dir><dir name="Reddit"><file name="Client.php" hash="50cc076cfc7dbc0eb06a847c85291878"/><dir name="GrantType"><file name="AuthorizationCode.php" hash="62826c19d8e800bf0ab0a9670911c2c2"/><file name="IGrantType.php" hash="a40c9dfd20b347b518284ab52bb8394c"/></dir></dir><dir name="Tumblr"><file name="OAuth.php" hash="d645162e3e8906ab8c24d1ce54bf0279"/><file name="tumblroauth.php" hash="f43b428616dfb3f2b0938dfd3d334f7e"/></dir><dir name="Twitter"><file name="OAuth.php" hash="b5d02968f42da08c1b80ea70f9aacef6"/><file name="twitteroauth.php" hash="5aed3de5ecb0cd985f670ba8c79526b8"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="gomage"><file name="social.css" hash="171f6cc07e0d043635acadba990bf704"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="css"><dir name="gomage"><file name="social.css" hash="aabc7ba1c5746716d080b3b3a2b04bee"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="gomage"><file name="social.js" hash="514a8a1b5be01bd9257a0fee8bc1acc7"/></dir></dir></target></contents>
26
  <compatible/>
27
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>gomage_social_connector</name>
4
+ <version>1.4.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gomage.com/license-agreement/">Single domain license</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>GoMage Social Connector allows your customers to login with the most popular social connectors: Amazon, Facebook, LinkedIn, Google and Google+!, Twitter, Tumblr, Reddit, Amazon and Instagram.</summary>
10
  <description>Features of GoMage Social Connector:&#xD;
11
  Connect with Amazon;&#xD;
12
  Connect with Facebook;&#xD;
15
  Connect with Twitter;&#xD;
16
  Connect with Tumblr;&#xD;
17
  Connect with Reddit;&#xD;
18
+ Connect with Amazon;&#xD;
19
+ Connect with Instagram;&#xD;
20
  No connections to the 3rd party services and monthly fees;&#xD;
21
  No core modifications require;&#xD;
22
  Easy installation of the extension allows you to just upload files and use it.</description>
23
+ <notes>Version 1.4.0</notes>
24
  <authors><author><name>GoMage</name><user>GoMage</user><email>support@gomage.com</email></author></authors>
25
+ <date>2015-09-09</date>
26
+ <time>06:11:30</time>
27
+ <contents><target name="magelocal"><dir name="GoMage"><dir name="Social"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="AbstractRedirectUri.php" hash="164c95506bc2a5f3879713dbaa087b75"/><dir name="Fieldset"><file name="General.php" hash="32ffa14e159d4aa9d039fefebd028489"/><file name="Information.php" hash="b89d7a4eac9f53871cdb61c0700009d7"/></dir><dir name="RedirectUri"><file name="Amazon.php" hash="9aaac3d585f07a352796c1faa278b32d"/><file name="Google.php" hash="94d4ec7c0d30d5e85f06e3677c4c0f40"/><file name="Instagram.php" hash="72298104ba1705808157580871450b6b"/><file name="Linkedin.php" hash="659940cda9cae972d49f87a81c20730b"/><file name="Reddit.php" hash="0263a6d4e1eec516594cd83746aee634"/><file name="Tumblr.php" hash="91e4d3fe1eef5594194f47ca93664ea7"/><file name="Twitter.php" hash="b25697d80c289d61b23f40f9bbc13947"/></dir></dir></dir></dir><file name="Head.php" hash="2e242529de52f1d1c91e3ba029d9e19a"/><dir name="Login"><file name="Facebook.php" hash="16c81b813ab0661aa93208b3aa94e072"/><file name="Google.php" hash="8c887aa3b6eaba8dc1c4287a3a92cd52"/><file name="Service.php" hash="e6712d0c51bb69a8e03a4598b9f42bb9"/></dir><file name="Login.php" hash="47cf604920cfa84193e9f72294a18816"/></dir><dir name="Controller"><file name="Social.php" hash="fd2d7fe85d0d36418f20193eac28574c"/><file name="SocialNoMail.php" hash="c5700992759cfda686a57e752051412f"/></dir><dir name="Helper"><file name="Data.php" hash="12cee9e3b48b6d9a0f220d7c31d043cc"/><file name="Url.php" hash="c8e81846391aa476aa833bef38d20917"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Login"><dir name="Type"><file name="Facebook.php" hash="9740c497446e5abe7fc75625a00f72b8"/><file name="Google.php" hash="6a023e46c9139dfcddc040db315c43a8"/></dir><file name="Type.php" hash="9bd3b702510e226ac9bfc4735e078af5"/></dir><file name="Services.php" hash="29ed71971b1323208b5fde22d96390fe"/></dir></dir></dir></dir><file name="Entity.php" hash="0378ca9cc5a6bbea4ef86fbc75e1f202"/><dir name="Mysql4"><dir name="Entity"><file name="Collection.php" hash="5a0eee20275a2ecf8b1681f5dd00b8ac"/></dir><file name="Entity.php" hash="69f7c42b80a164d4bd2cdc1a0e69b2b3"/></dir><dir name="Observer"><file name="Notify.php" hash="9f8bde4fca2b2810267fe38f199db1b2"/></dir><file name="Observer.php" hash="2155e8c8ad07ee5adb5f19d5dafc71b1"/><file name="Type.php" hash="5f5fb1da854e478b1e473285e45f9dc1"/></dir><dir name="controllers"><file name="AmazonController.php" hash="05014d52c3de1069b06baa5131dc8620"/><file name="FacebookController.php" hash="513be6c83c450bc8ca57a80dc2ea92c6"/><file name="GoogleController.php" hash="7efad26c4dadc3132b267125ab381ec4"/><file name="InstagramController.php" hash="5a8165339804ff80e4330bd29c0ecdce"/><file name="LinkedinController.php" hash="04fbf096b94778ad9b74b5fc505b0157"/><file name="RedditController.php" hash="32e52e3a079e661606b1f87e6275f45a"/><file name="TumblrController.php" hash="299557887f36acf31987c7adab61ba91"/><file name="TwitterController.php" hash="d953e936b719aca232e086cd134c12fa"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1ee6a17d2d2939a7229e46526ca2269a"/><file name="config.xml" hash="37a9d5562c80541d402581d30d38dc32"/><file name="system.xml" hash="dab2629b5e2d0f5a328ed9920ddbc05d"/></dir><dir name="sql"><dir name="gomage_social_setup"><file name="mysql4-install-1.0.0.php" hash="8cb49d7aa72ae13c3b62787ff31b24d7"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="624c3202f151a91714171d34f02faef2"/><file name="mysql4-upgrade-1.1.0-1.2.0.php" hash="362b01a230b9ddbe2e54f754c710f73b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GoMage_Social.xml" hash="a837a50fd9f94404aeb5222bd3e1fc08"/></dir></target><target name="magelib"><dir name="GoMage"><dir name="Amazon"><file name="Credentials.php" hash="81623f3294b508e799d903876b4b9f46"/><file name="Service.php" hash="21d161fb791a611d0d8c7f47328564b8"/></dir><dir name="Facebook"><file name="base_facebook.php" hash="f2a629c25efa36fc02f699f7e52dc61e"/><file name="facebook.php" hash="dcb23268876023d6fa7e1d3349d13819"/><file name="fb_ca_chain_bundle.crt" hash="c4290b9deb70d0bef2f88b67fc68c8ec"/></dir><dir name="Google"><file name="Google_Client.php" hash="7b85279df4c0d845415c97a579df614e"/><dir name="auth"><file name="Google_AssertionCredentials.php" hash="19ec1a0bc3ffdeb07083e225f3e0ac7b"/><file name="Google_Auth.php" hash="15873dc9c390eadbd5da2c0297062d7c"/><file name="Google_AuthNone.php" hash="093b237c59e2e085a97e664c0ce88ebe"/><file name="Google_LoginTicket.php" hash="4397ba773564c0c73f32ae118c24b5d2"/><file name="Google_OAuth2.php" hash="39f54796674f476271ce8d5c05c9ec71"/><file name="Google_P12Signer.php" hash="e33e570503ed42cf7d25dd6c32d67263"/><file name="Google_PemVerifier.php" hash="e9fb745bc98981953a270e0374e77e58"/><file name="Google_Signer.php" hash="b89eb963b836860aa622c2111915e5ac"/><file name="Google_Verifier.php" hash="08c9de305f4824c6d94d7c40bfe7be58"/></dir><dir name="cache"><file name="Google_ApcCache.php" hash="38942168cb94c15a9064aa8faa6c1817"/><file name="Google_Cache.php" hash="98c92b5d919c9143e68230e612298a9b"/><file name="Google_FileCache.php" hash="7cb3f047c1e3774474de8e8b2f5bd638"/><file name="Google_MemcacheCache.php" hash="48f2b20eb2481b40954d0a7a130fa766"/></dir><file name="config.php" hash="a26b007bba5cd5ca2a48bb13f8e7b663"/><dir name="contrib"><file name="Google_AdExchangeSellerService.php" hash="318705a28a809a1d23e3cb834dcf32be"/><file name="Google_AdexchangebuyerService.php" hash="9998193782e0677dc8cba52a126bb3d5"/><file name="Google_AdsenseService.php" hash="7acdc4933f20648c8b4122c9650dc6df"/><file name="Google_AdsensehostService.php" hash="5b2907beaca5a177fc4e06558b20e711"/><file name="Google_AnalyticsService.php" hash="1c1b987a22ed153cc4cf64adf1ff4cb9"/><file name="Google_BigqueryService.php" hash="52cdc203a5959b43c6a8a69b9cb16f45"/><file name="Google_BloggerService.php" hash="65336d21d58f8f2c983246b2a768064c"/><file name="Google_BooksService.php" hash="1d3ea79436b063f95f1b1995217ff105"/><file name="Google_CalendarService.php" hash="1828cfdabcded687997e5cad9999b4bb"/><file name="Google_ComputeService.php" hash="6e02a8f3a711bd99f5c1a5d2fb7c472f"/><file name="Google_CustomsearchService.php" hash="71e240765a29ee901ad1f5f30a7164e6"/><file name="Google_DfareportingService.php" hash="3f2e8a38a9a2ce577a07510785fcf38d"/><file name="Google_DriveService.php" hash="e55201ec487c65eea2dcbbc957d50e0e"/><file name="Google_FreebaseService.php" hash="eb53801d59a2edd1c16e5c5b33fba221"/><file name="Google_FusiontablesService.php" hash="2e484e55d79e219246a7ef8f56dfd5ee"/><file name="Google_GanService.php" hash="0f82b88d1f736652fb0568885329515c"/><file name="Google_LatitudeService.php" hash="165096ab7a3a8b05f97ea3a3f02d28d6"/><file name="Google_LicensingService.php" hash="8f55c323fb03447bab1b7403fd4ab2f6"/><file name="Google_ModeratorService.php" hash="f20f92b05539441192ccf98ef0d6cc90"/><file name="Google_Oauth2Service.php" hash="9273a2ae188738ccd091017212495197"/><file name="Google_OrkutService.php" hash="d0cd466c78cd9c8dcd1e0cfef384696b"/><file name="Google_PagespeedonlineService.php" hash="b73efb6889f190c4aeb01758f8cfc43a"/><file name="Google_PlusMomentsService.php" hash="a4455c8ef47558346a85d2e47588146a"/><file name="Google_PlusService.php" hash="7749cc0a3927896cb3ec038417f65938"/><file name="Google_PredictionService.php" hash="2c4739a3ef181178eb4f76f9ab2d56f6"/><file name="Google_ShoppingService.php" hash="3dbda05eb3f7f8baa7f0188a0a391eac"/><file name="Google_SiteVerificationService.php" hash="9792e2bbe628fdae91dbfae35c00df14"/><file name="Google_StorageService.php" hash="51b240f63170d0c0dd27a2c6e435ddbe"/><file name="Google_TaskqueueService.php" hash="e34f538ffc1e2e412431e85c7cdec662"/><file name="Google_TasksService.php" hash="3065ef4ba7b95317e149191432cb8440"/><file name="Google_TranslateService.php" hash="5dc38b483a051aab0ded6c327beb0025"/><file name="Google_UrlshortenerService.php" hash="ef4fe776c3fa2324dde4afbe0494f979"/><file name="Google_WebfontsService.php" hash="04260525d97d2a1701821eced43fd96e"/><file name="Google_YouTubeService.php" hash="41740022788c34e3bba26abb889855a7"/></dir><dir name="external"><file name="URITemplateParser.php" hash="dc829ddd424801e2bc4bf83bfb5e698c"/></dir><dir name="io"><file name="Google_CacheParser.php" hash="a8524de4f95bc1d237a7bf22dd3dfb8a"/><file name="Google_CurlIO.php" hash="9f5d2871c87ba61cced0efab8c57d4dc"/><file name="Google_HttpRequest.php" hash="01f22c8d762d21fd7c93d4d60737b041"/><file name="Google_IO.php" hash="872ddfd60a5ef638517ef81c7c0b6b95"/><file name="Google_REST.php" hash="61d31688aa7d280b1e7a7ba4d2fcacb3"/><file name="cacerts.pem" hash="2dc185f345f7ca634aec690243f346d8"/></dir><dir name="service"><file name="Google_BatchRequest.php" hash="3c5f95b98e16d1a4a3fe2cc5cf48e9b6"/><file name="Google_MediaFileUpload.php" hash="90cc23d99dd18df03372a02a67de1cce"/><file name="Google_Model.php" hash="2c2d018441c8e8971d6b0528f3f34d85"/><file name="Google_Service.php" hash="213627cf943f19478ecd263b1f253195"/><file name="Google_ServiceResource.php" hash="6aa5fb58563b8c00f5210a9b3db67def"/><file name="Google_Utils.php" hash="612e0e3add05f9cf52d64065b7ccca0a"/></dir></dir><dir name="Instagram"><file name="Credentials.php" hash="fefcba9c3d07a383c0ebc751e09b3042"/><file name="Service.php" hash="a93e95e48fdbe95c795bb22adb2eff37"/></dir><dir name="Linkedin"><file name="OAuth.php" hash="6a5e787104d1e971ec6b2a247e1474dd"/><file name="linkedinoauth.php" hash="d35bb109490a20635006cf44ba5076cc"/></dir><dir name="OAuth"><file name="Credentials.php" hash="5f52fc9f5dda451939471edbbd28ed5b"/><file name="OAuth.php" hash="f3e5e5b34291f27d9b1b2868f9d59d38"/><file name="Service.php" hash="3b1c8970b0243bc0d3579cb3a4f79a0d"/></dir><dir name="Reddit"><file name="Client.php" hash="50cc076cfc7dbc0eb06a847c85291878"/><dir name="GrantType"><file name="AuthorizationCode.php" hash="62826c19d8e800bf0ab0a9670911c2c2"/><file name="IGrantType.php" hash="a40c9dfd20b347b518284ab52bb8394c"/></dir></dir><dir name="Tumblr"><file name="tumblroauth.php" hash="879417818a187caeebd77b3b7aeb5839"/></dir><dir name="Twitter"><file name="twitteroauth.php" hash="fca09ca5e8227fe31efc9763fcc03237"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="gomage-social.xml" hash="444173c377f7b716f5f96962d6e8e546"/></dir><dir name="template"><dir name="gomage"><dir name="social"><file name="config.phtml" hash="f3b4b3a745c3a97fa8266235f9317452"/><dir name="login"><file name="facebook.phtml" hash="38978e6d418f44eb65efc5cb738be3e1"/><file name="google.phtml" hash="8000a4948659b2ba0edda56896d9f7d9"/><file name="service.phtml" hash="06366b1767a6d5c3c9a98c80622d284f"/></dir><file name="login.phtml" hash="d76c5a50c6bd69b5e33e11311c58fc43"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="gomage"><file name="social.css" hash="657c117ab77a195364ba83c96ed59893"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="css"><dir name="gomage"><file name="social.css" hash="53c179c98dad1a6cc7d07b1193488fad"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="gomage"><file name="social.js" hash="338adff45dbd1a1c6f0ad86289de7c34"/></dir></dir></target></contents>
28
  <compatible/>
29
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
30
  </package>
skin/frontend/base/default/css/gomage/social.css CHANGED
@@ -6,7 +6,7 @@
6
  * @author GoMage
7
  * @license http://www.gomage.com/license-agreement/ Single domain license
8
  * @terms of use http://www.gomage.com/terms-of-use
9
- * @version Release: 1.3.0
10
  * @since Class available since Release 1.0.0
11
  */
12
 
6
  * @author GoMage
7
  * @license http://www.gomage.com/license-agreement/ Single domain license
8
  * @terms of use http://www.gomage.com/terms-of-use
9
+ * @version Release: 1.4.0
10
  * @since Class available since Release 1.0.0
11
  */
12
 
skin/frontend/rwd/default/css/gomage/social.css CHANGED
@@ -6,7 +6,7 @@
6
  * @author GoMage
7
  * @license http://www.gomage.com/license-agreement/ Single domain license
8
  * @terms of use http://www.gomage.com/terms-of-use
9
- * @version Release: 1.1.0
10
  * @since Class available since Release 1.0.0
11
  */
12
 
6
  * @author GoMage
7
  * @license http://www.gomage.com/license-agreement/ Single domain license
8
  * @terms of use http://www.gomage.com/terms-of-use
9
+ * @version Release: 1.4.0
10
  * @since Class available since Release 1.0.0
11
  */
12