From 183fa7b3a3b8eeaaf0274714e4a6baa6d4e7bbce Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Mon, 1 Dec 2014 16:10:03 -0500 Subject: [PATCH] Bind CURL calls to WHMCS to ipv4 adapter because WHMCS IP whitelist doesn't support IPv6 * Fixes WHMCS login for all airtime.pro users --- .../application/controllers/BillingController.php | 3 ++- .../application/controllers/ShowbuilderController.php | 3 ++- .../application/controllers/WhmcsLoginController.php | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/controllers/BillingController.php b/airtime_mvc/application/controllers/BillingController.php index ca2f7594d..fd7f90c10 100644 --- a/airtime_mvc/application/controllers/BillingController.php +++ b/airtime_mvc/application/controllers/BillingController.php @@ -572,6 +572,7 @@ class BillingController extends Zend_Controller_Action { try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 5); //Aggressive 5 second timeout curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -598,4 +599,4 @@ class BillingController extends Zend_Controller_Action { throw new Exception("Invalid client ID: " . Application_Model_Preference::GetClientId()); } } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 09314a432..b88d4e2e7 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -35,7 +35,7 @@ class ShowbuilderController extends Zend_Controller_Action $user = Application_Model_User::GetCurrentUser(); $userType = $user->getType(); $this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );"); - //$this->view->headScript()->appendScript($this->generateGoogleTagManagerDataLayerJavaScript()); + $this->view->headScript()->appendScript($this->generateGoogleTagManagerDataLayerJavaScript()); $this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); @@ -439,6 +439,7 @@ class ShowbuilderController extends Zend_Controller_Action $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 curl_setopt($ch, CURLOPT_TIMEOUT, 5); //Aggressive 5 second timeout curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); diff --git a/airtime_mvc/application/controllers/WhmcsLoginController.php b/airtime_mvc/application/controllers/WhmcsLoginController.php index b8573c557..0b8a00a83 100644 --- a/airtime_mvc/application/controllers/WhmcsLoginController.php +++ b/airtime_mvc/application/controllers/WhmcsLoginController.php @@ -155,6 +155,7 @@ class WHMCS_Auth_Adapter implements Zend_Auth_Adapter_Interface { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, WHMCS_API_URL); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_FAILONERROR, 1); @@ -164,7 +165,8 @@ class WHMCS_Auth_Adapter implements Zend_Auth_Adapter_Interface { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $jsondata = curl_exec($ch); if (curl_error($ch)) { - die(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); + Logging::error("Failed to reach WHMCS server in " . __FUNCTION__ . ": " + . curl_errno($ch) . ' - ' . curl_error($ch) . ' - ' . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); //die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); } curl_close($ch); @@ -201,6 +203,7 @@ class WHMCS_Auth_Adapter implements Zend_Auth_Adapter_Interface { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, WHMCS_API_URL); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // WHMCS IP whitelist doesn't support IPv6 curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_FAILONERROR, 1); @@ -210,7 +213,8 @@ class WHMCS_Auth_Adapter implements Zend_Auth_Adapter_Interface { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $jsondata = curl_exec($ch); if (curl_error($ch)) { - die(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); + Logging::error("Failed to reach WHMCS server in " . __FUNCTION__ . ": " + . curl_errno($ch) . ' - ' . curl_error($ch) . ' - ' . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); //die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); } curl_close($ch); @@ -255,4 +259,4 @@ class WHMCS_Auth_Adapter implements Zend_Auth_Adapter_Interface { } return false; } -} \ No newline at end of file +}