Why only paths and not full url?

Status
Not open for further replies.

Jim the Writer

I'm The Content Guy!
Hi

This is probably a stupid question, but I can't seem to find the answer...

I am currently running Maxmind on my server.

I want to be able to call the script from a few other sites, but when I put full URL's in the on page PHP, it doesn't work?

Does anyone know how to fix this? Or know of somewhere I can learn to fix this myself?

Eg.

database is located at http://www.mysite.com/GeoIP/database.dat (example)

Here is a section of the code that needs to be included on the page

$gi = geoip_open('/home/iptrack/public_html/GeoIP/GeoLiteCity.dat', GEOIP_STANDARD);

When I change "/home/iptrack/public_html/GeoIP/GeoLiteCity.dat" to "http://www.mysite.com/GeoIP/database.dat", the script no longer functions

Thanks in advance...
 


I assume that your other sites aren't hosted on the same server? If they are you should be able to leave it pointed at that working directory on those sites to if you have root.

Of course if you don't have root you are semi-fucked, but it isnt impossible.

Nathan
 
A lot of scripts work like that. They use the root path on the server, or the "real" path.

/home/iptrack/public_html/GeoIP/GeoLiteCity.dat

http:// is like the external address of the file, but since the script is hosted on your server you give it the "internal" address.

http://anything will not work here.


/home/iptrack/public_html/GeoIP/GeoLiteCity.dat is not short for http://domain.com/home/iptrack/public_html/GeoIP/GeoLiteCity.dat
 
You're much better off writing a PHP wrapper to obtain the data you want via a PHP script, trying to access the dat file from accross the web to be used in php (in an fopen fashion), is going to seriously slow down your scripts and reduce site performance.

By wrapper, I mean you call geo.php on your host server passing the IP you want to look up and the parameter for what you should receive back, that way you get a very quick reply for what you need... not transferring the entire binary database across the web every time the script runs.

PS: Alternatively, there is a way to convert the maxmind CSV file into a MySQL database which you can either use the wrapper with, or have the other server's php scripts access directly in a much faster fashion than trying to pull a 1.6mb file each time.
 
Status
Not open for further replies.