Having trouble with fopen() inside of ExpressionEngine
Posted: Sun Jan 11, 2009 11:25 pm
I've done a lot of homework on this - asked at the ExpressionEngine (EE) forums and more - and I'm hoping someone here has the brains to solve this.
I have an IP location script that works fine when called outside of EE (output viewable here: http://www.psaudio.com/IPTEST/sample-IP2Location.php). It returns the IP address, the country code, and the country long name just fine. The IP is grabbed using the standard getenv() function, while the country code and country long name are taken from a BIN file. The BIN file is in the same directory as the script.
When I call the script within EE, the IP is detected just fine, but the BIN file fails to load (output viewable here: http://www.psaudio.com/ps/home/zz_test_ip/).
Here is how I'm calling the script from within EE:
Note that I'm calling the exact same script that works perfectly well outside of EE. I've determined that no proprietary EE tags are getting in the way, so it is probably a path issue.
Here is the function call (within the script I'm calling) that loads the BIN file:
And here is the function:
The error indicates that the file is failing to load, but why? (you can see the error by visiting the links above) I've tried adjusting the paths in the function call and within the function, but have had no success. I've also checked file permissions - they are set to 644. I tried 777 just to check, but that made no difference.
Can anyone help?
I have an IP location script that works fine when called outside of EE (output viewable here: http://www.psaudio.com/IPTEST/sample-IP2Location.php). It returns the IP address, the country code, and the country long name just fine. The IP is grabbed using the standard getenv() function, while the country code and country long name are taken from a BIN file. The BIN file is in the same directory as the script.
When I call the script within EE, the IP is detected just fine, but the BIN file fails to load (output viewable here: http://www.psaudio.com/ps/home/zz_test_ip/).
Here is how I'm calling the script from within EE:
Code: Select all
include("/home/psaudio/public_html/IPTEST/sample-IP2Location.php");Here is the function call (within the script I'm calling) that loads the BIN file:
Code: Select all
$ip = IP2Location_open("IP-COUNTRY.BIN", IP2LOCATION_STANDARD);Code: Select all
function IP2Location_open ($filename, $flags) {
$ip = new IP2Location;
$ip->flags = $flags;
$ip->filehandle = fopen($filename,"rb");
if ($ip->filehandle === false) {
echo FILEHANDLE_NULL . $filename . ".\n";;
return 0;
}
$ip = IP2Location_initialize($ip);
return $ip;
}Can anyone help?