From 1e76845e9cc96041385f78240218172edef5608e Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sat, 30 Jun 2012 01:57:01 +0400 Subject: [PATCH 1/2] more sophisticated remote_addr determining --- .../application/controllers/ApiController.php | 2 +- airtime_mvc/application/models/ServiceRegister.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 739285e64..72900d873 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -796,7 +796,7 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $component = $request->getParam('component'); - $remoteAddr = $_SERVER['REMOTE_ADDR']; + $remoteAddr = Application_Model_ServiceRegister::GetRemoteIpAddr(); Logging::log("Registered Component: ".$component."@".$remoteAddr); Application_Model_ServiceRegister::Register($component, $remoteAddr); diff --git a/airtime_mvc/application/models/ServiceRegister.php b/airtime_mvc/application/models/ServiceRegister.php index 47c647829..0f793e93a 100644 --- a/airtime_mvc/application/models/ServiceRegister.php +++ b/airtime_mvc/application/models/ServiceRegister.php @@ -1,6 +1,20 @@ findOneByDbName($p_componentName); From eba4b688c4a5de66d6174681f5decb336408a4da Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 17 Jul 2012 14:47:13 -0400 Subject: [PATCH 2/2] User Patch: If a callback is not given, then just provide the raw JSON. Submitted by Ross Masters --- airtime_mvc/application/controllers/ApiController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 72900d873..b9d302008 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -296,7 +296,9 @@ class ApiController extends Zend_Controller_Action $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. header("Content-type: text/javascript"); - echo $_GET['callback'].'('.json_encode($result).')'; + + // If a callback is not given, then just provide the raw JSON. + echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); } else { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource. '; @@ -329,7 +331,9 @@ class ApiController extends Zend_Controller_Action } $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. header("Content-type: text/javascript"); - echo $_GET['callback'].'('.json_encode($result).')'; + + // If a callback is not given, then just provide the raw JSON. + echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result); } else { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource. ';