Jump to content

Server IP


Recommended Posts

Hi there,

I want to know why we don't have a function to get the current server IP ?

I'm searching about it for weeks and I can't found it.

The only think i found is that function: getServerConfigSetting ( string name ) but some servers don't specifie they IP on the tags.

If you know why we don't have a getServerIP and you know an alternative that would be useful.

Thanks for your help.

FatalTerror.

Link to comment

Man I thought you were a web developer.

Php code (basic):

<?php 
    echo $_SERVER['REMOTE_ADDR']; 
?> 

It is more effective to use this, as some servers might be configured retard-idly:

<?php 
    $ipaddress = ''; 
    if ($_SERVER['HTTP_CLIENT_IP']) 
        $ipaddress = $_SERVER['HTTP_CLIENT_IP']; 
    else if($_SERVER['HTTP_X_FORWARDED_FOR']) 
        $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; 
    else if($_SERVER['HTTP_X_FORWARDED']) 
        $ipaddress = $_SERVER['HTTP_X_FORWARDED']; 
    else if($_SERVER['HTTP_FORWARDED_FOR']) 
        $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; 
    else if($_SERVER['HTTP_FORWARDED']) 
        $ipaddress = $_SERVER['HTTP_FORWARDED']; 
    else if($_SERVER['REMOTE_ADDR']) 
        $ipaddress = $_SERVER['REMOTE_ADDR']; 
    else 
        $ipaddress = 'UNKNOWN'; 
    echo $ipaddress; 
?> 

Lua code:

fetchRemote("example.com/path/to/php/file", doStuff) 
  
function doStuff(responseData, errno) 
    -- put shit here, responseData is the ip 
end 

Edited by Guest
Link to comment
Man I thought you were a web developer.

Php code:

<?php 
    echo $_SERVER['REMOTE_ADDR']; 
?> 

Lua code:

fetchRemote("example.com/path/to/php/file", doStuff) 
  
function doStuff(responseData, errno) 
    -- put :~ here, responseData is the ip 
end 

I thought not use this solution, they should make a getServerIP function. That would be more easy.

But thanks anyway.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...