Merge branch '2.1.x' into devel
Conflicts: airtime_mvc/application/models/ServiceRegister.php
This commit is contained in:
commit
1bd07eeaca
|
@ -285,7 +285,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.
|
$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");
|
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 {
|
} else {
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
print 'You are not allowed to access this resource. ';
|
print 'You are not allowed to access this resource. ';
|
||||||
|
@ -318,7 +320,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.
|
$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");
|
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 {
|
} else {
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
print 'You are not allowed to access this resource. ';
|
print 'You are not allowed to access this resource. ';
|
||||||
|
@ -726,7 +730,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
|
|
||||||
$component = $request->getParam('component');
|
$component = $request->getParam('component');
|
||||||
$remoteAddr = $_SERVER['REMOTE_ADDR'];
|
$remoteAddr = Application_Model_ServiceRegister::GetRemoteIpAddr();
|
||||||
Logging::log("Registered Component: ".$component."@".$remoteAddr);
|
Logging::log("Registered Component: ".$component."@".$remoteAddr);
|
||||||
|
|
||||||
Application_Model_ServiceRegister::Register($component, $remoteAddr);
|
Application_Model_ServiceRegister::Register($component, $remoteAddr);
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Model_ServiceRegister
|
class Application_Model_ServiceRegister
|
||||||
{
|
{
|
||||||
|
public static function GetRemoteIpAddr()
|
||||||
|
{
|
||||||
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||||
|
//check ip from share internet
|
||||||
|
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
||||||
|
} else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||||
|
//to check ip is pass from proxy
|
||||||
|
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
|
} else {
|
||||||
|
$ip=$_SERVER['REMOTE_ADDR'];
|
||||||
|
}
|
||||||
|
return $ip;
|
||||||
|
}
|
||||||
|
|
||||||
public static function Register($p_componentName, $p_ipAddress)
|
public static function Register($p_componentName, $p_ipAddress)
|
||||||
{
|
{
|
||||||
$component = CcServiceRegisterQuery::create()->findOneByDbName($p_componentName);
|
$component = CcServiceRegisterQuery::create()->findOneByDbName($p_componentName);
|
||||||
|
|
||||||
if ($component == NULL) {
|
if (is_null($component)) {
|
||||||
$component = new CcServiceRegister();
|
$component = new CcServiceRegister();
|
||||||
$component->setDbName($p_componentName);
|
$component->setDbName($p_componentName);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue