FatalTerror Posted July 14, 2013 Share Posted July 14, 2013 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
codeluaeveryday Posted July 14, 2013 Share Posted July 14, 2013 (edited) 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 July 14, 2013 by Guest Link to comment
FatalTerror Posted July 14, 2013 Author Share Posted July 14, 2013 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
codeluaeveryday Posted July 14, 2013 Share Posted July 14, 2013 Ok all good, I also made an edit for a more viable solution. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now