GLBasic forum

Main forum => GLBasic - en => Topic started by: Marmor on 2013-Mar-06

Title: IP Service on Glbasic Server
Post by: Marmor on 2013-Mar-06
some old sources which using http://www.glbasic.com/forum/index.php?topic=5400.msg42237#msg42237 (http://www.glbasic.com/forum/index.php?topic=5400.msg42237#msg42237) will not work now ,because
website has some changes.
i think a little extra website on GLBASIC.com can help a lot in the future.
Title: Re: IP Service on Glbasic Server
Post by: Moru on 2013-Mar-07
Such a service is always best to have on your own web-server. It's very simple to set up and you don't have to depend on someone elses server. If your game gets popular it does not risk killing this server either :-)

Make a file containing this code and upload to your server.
Code (glbasic) Select

<?php
echo $_SERVER['REMOTE_ADDR']
Title: Re: IP Service on Glbasic Server
Post by: spicypixel on 2013-Mar-07
On http://ip.spicypixel.net I use this...

Code (glbasic) Select

<?php
//--------------------------------------------
//  Get User IP Address
//--------------------------------------------
$myip getRealIpAddr();
echo 
$myip;

function 
getRealIpAddr()
{
    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;
}
?>