more sophisticated remote_addr determining
This commit is contained in:
parent
6a4fd4973e
commit
1e76845e9c
2 changed files with 15 additions and 1 deletions
|
@ -796,7 +796,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,6 +1,20 @@
|
||||||
<?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'];
|
||||||
|
}elseif (!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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue