Requesting help troubleshooting.
William
Hi, thank you for posting in the community. Can you be a bit more specific about the issue and provide further details, please?
Until a few days ago âindex.phpâ was working; now throwing a couple of errors:
Warning : file_get_contents(http://ipinfo.io/2601:803:c600:a7f:dd6e:220c:190e:e0d5/json?token=mytoken): failed to open stream: Network is unreachable in /storage/ssd3/644/18898644/public_html/index.php on line 66
Notice : Undefined index: HTTP_REFERER in /storage/ssd3/644/18898644/public_html/index.php on line 87
William
Our engineer has provided the following context:
The error indicates a network issue, and theyâre using
000webhost
which is a free website host (that has been around since⌠the beginning of time) which is unreliable (due to the free nature, lots of abuse, no SLA).The ideal step would be to run some network checks from the server, but the user wonât have access to do that, so best option is to either:
- ask their host to investigate (unlikely to offer support)
- try an alternate address (e.g:
https://v6.ipinfo.io/
)- switch to a better host (e.g: fly.io has a free plan and wonât have these issues)
just saying, you leaked your token there, you should probably change it:)
I no longer have network unreachable; however, referer, City, Region,and Country are not populating.
I have posted to ooowebhost discord channel; awaiting their resonse, have opened support ticket.
William
Im honestly not sure what your problem is.
Thank you hibenji for the report that the Gist is working for you.
The php script worked good up until about the end of October; has been online since 2017, providing Referer, City, Region, and Country.
Will try thethered network connection and a new token. It is like I have been banned at ipinfo.io.
William
Yeah, maybe just try using curl with your ip and token and see if that works. Or print the entire response to the page to see the response and error:D
Benji
Entering my ipAddress manually; I get expected results:
{$_SERVER[âREMOTE_ADDRâ]} does not capture ipAddress.
Is there a syntax error?
William
Itâs possible that is something in your configuration that is wrong, I would recommend enable error output for your site by adding these two lines at the top of your php.
<?php
error_reporting(E_ALL); // Report all types of errors
ini_set('display_errors', 1); // Display errors on the web page
?>
Then just reload your page and you should be able to see what the issue is and why your ip isnât populating correctly.
Benji
seems like like your provider has some issues, maybe blocking outgoing connections?
if you want, you can try using curl since that should give you a little more info, but its most likely your provider blocking those connections. (maybe they are also only blocking ipinfo, though that would be weird.)
// The URL you want to send the GET request to
$url = "http://example.com";
// Initialize a cURL session
$ch = curl_init();
// Set the URL for the cURL session
curl_setopt($ch, CURLOPT_URL, $url);
// Return the transfer as a string instead of outputting it
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the cURL session and fetch the response
$response = curl_exec($ch);
// Check for errors and display the error message
if(curl_errno($ch)){
echo 'Request Error:' . curl_error($ch);
} else {
// Print the response if the request was successful
echo $response;
}
// Close the cURL session
curl_close($ch);
Benji
Seems like something worked at the top there?
Was that the curl request? If yes, just use that and change your code a little use the curl request instead.
Yes, that was a curl url.
How can this be coded to use ip from browser? I do not program in php or know how to switch to curl. Requesting help with conversion.
William
If you want Iâll change it out tomorrow, just send me a link to your code and Iâll switch it out, itâs just a few lines of code in the end:)
Benji
Thank you hibenji; I used ChatGPT to conert my code to use Curl.
Have Curl code working!!!
Thank you for all your help with this issue.
William
Wonderful, happy to help and good luck with your future endeavors:)