0

OK I think I get the problem. You have to be careful with the version of the DB you download. I downloaded the full DB - but this is not free and is encoded! You need to download this file: http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/ .

It is a gunzip file, which you need to extract the file GeoIP.dat. If you can't do this, download a free extractor called 7-zip from http://www.7-zip.org/ .

Place the extracted file into a folder called "geoinc". Into that folder also include the file geoip.inc. I renamed the file to geoip.inc.php.

This code now works for me:

<?php
include("{$_SERVER['DOCUMENT_ROOT']}/geoinc/geoip.inc.php");

$gi = geoip_open("{$_SERVER['DOCUMENT_ROOT']}/geoinc/GeoIP.dat",GEOIP_STANDARD);
echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);
?>

I get the output:

US United States ES Spain

Just do this to get the code and country of an user:

<?php
include("{$_SERVER['DOCUMENT_ROOT']}/geoinc/geoip.inc.php");
$gi = geoip_open("{$_SERVER['DOCUMENT_ROOT']}/geoinc/GeoIP.dat",GEOIP_STANDARD);
echo geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']) . "\t" .
     geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']) . "\n";
geoip_close($gi);
?>

Just be aware, if you're testing this on localhost, the code won't work because the $_SERVER will return "127.0.0.1", which obviously does not have a country.

Edited by diafol: n/a

0

Reference to GeoIp what does it do is it a Proxy bypass or what i need to be clear before i can come in please some one should explaint to me

0

GeoIP = functions and a db file. The functions return the country code or the country name, based on the user's remote address (IP).

This does not involve proxies.

You can use the function output to redirect or refuse entry to users from specific countries.

0

I have a router and I think it is not a problem to show my real IP

0

Do you have a problem or does it work for you. If OK, mark this solved, otherwise tell me the problem.

0

Unfortunately does not work.
Prepared to explain what I do. Put this code

<?php
include("{$_SERVER['DOCUMENT_ROOT']}/geoinc/geoip.inc.php");

$gi = geoip_open("{$_SERVER['DOCUMENT_ROOT']}/geoinc/GeoIP.dat",GEOIP_STANDARD);
echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);
?>

You can look through here and the Mozilla source code
http://answer23.100free.com/
Look and write me where wrong.
I put geo.inc.php and Geoip.dat in geoinc
Thank you

0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<title>Untitled</title> 
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> 
<meta name="generator" content="Web Page Maker"> 
 
<style type="text/css"> 
 ... just styles in here took them out for now ...
</style> 
</head> 
<body bgColor="#000000"> 
<div id="container"> 
  <div id="image1" style="position:absolute; overflow:hidden; left:0px; top:173px; width:300px; height:300px; z-index:0">
     <img src="images/puma.gif" alt="" title="" border=0 width=300 height=300>
  </div> 
  <div id="html1" style="position:absolute; overflow:hidden; left:379px; top:177px; width:200px; height:125px; z-index:1"> 
  </div> 
</div>
</body> 
</html>

As you can see - this does not show any html output by the php script.

Can I suggest that you change that you change <body bgColor="#000000"> to <body> for now so that you can see any text that php outputs.

Please place

<?php
  echo "Sono qui!";
?>

or something similar anywhere after the body tag and look at it again. Does it show?

0

First off, if you did as I suggested, the php doesn't seem to be working.

You should see 'Sono qui!' on the page, but you don't - is this page called index.php?

0

I noticed that the hosting problem on php and tried to post another hosting and I have already shown

<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php
  echo "Sono qui!";
?>
 </body>
</html>

Now where should I write to ask the other code in the continuation of this.
Thank you

0

OK, I thought something was wrong.

<?php
include("{$_SERVER['DOCUMENT_ROOT']}/geoinc/geoip.inc.php");
$gi = geoip_open("{$_SERVER['DOCUMENT_ROOT']}/geoinc/GeoIP.dat",GEOIP_STANDARD);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<title>Untitled</title> 
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> 
<meta name="generator" content="Web Page Maker"> 
 
<style type="text/css"> 
 ... just styles in here took them out for now ...
</style> 
</head> 
<body bgColor="#000000"> 
<div id="container"> 

<?php
echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);
?>

  <div id="image1" style="position:absolute; overflow:hidden; left:0px; top:173px; width:300px; height:300px; z-index:0">
     <img src="images/puma.gif" alt="" title="" border=0 width=300 height=300>
  </div> 
  <div id="html1" style="position:absolute; overflow:hidden; left:379px; top:177px; width:200px; height:125px; z-index:1"> 
  </div> 
</div>
</body> 
</html>

This should work if you can get php to output text to the screen.

0

I put your code and give me error

Warning: include(/home/new/public_html/geoinc/geoip.inc.php) [function.include]: failed to open stream: No such file or directory in /home/new/public_html/test.php on line 2

Warning: include() [function.include]: Failed opening '/home/new/public_html/geoinc/geoip.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/new/public_html/test.php on line 2

Fatal error: Call to undefined function geoip_open() in /home/new/public_html/test.php on line 3

0

You have not got the geoip.inc.php file in the geoinc folder. Copy the file to that folder. Ensure you also have the GeoIP.dat file too.

0

Okay. Please Define me a php code which can be set up on my page to see if it will work on the new host.
Thank You

0

I've already done this. Do this again.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<title>Untitled</title> 
</head> 
<body> 
<?php
  include("{$_SERVER['DOCUMENT_ROOT']}/geoinc/geoip.inc.php");
  $gi = geoip_open("{$_SERVER['DOCUMENT_ROOT']}/geoinc/GeoIP.dat",GEOIP_STANDARD);
echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);
?>
</body> 
</html>

Look, if you've uploaded the geoip.inc.php and GeoIP.dat files to the geoinc folder and you run the code above, you should be OK.

I don't know what more I can do to help.

0

OK, but that IP can write like this or should not remain

echo geoip_country_code_by_addr($gi, "24.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "24.24.24.24") . "\n";
echo geoip_country_code_by_addr($gi, "80.24.24.24") . "\t" .
     geoip_country_name_by_addr($gi, "80.24.24.24") . "\n";
geoip_close($gi);

Thank you

0
echo geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']) . "<br />" .
     geoip_country_name_by_addr($gi,  $_SERVER['REMOTE_ADDR']);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.