tags:

views:

80

answers:

4

Hi.

I am currently writing a little application for my University radio station in PHP. It basically grabs the listener count from the status page (http://www.address.com:8000/status.xsl) and puts it in a database every minute.

Now the script seems to work fine when it's run off of my home machine. I have no issues retriving the information from that status page. However, when I load it onto my shared hosting package, it seems to time out. I have tried using file() on other sites like google.com using both the domain name and the IP and it works fine.

I am really confused as to what I should be checking for. I can't see any specific reference to timeout settings for file() in php.ini and the fact it works with other sites it making me think the University is blocking it. However if that is the case, why would it work at home?

Any ideas?

Thanks.

+1  A: 

Make sure the host isn't block fopen calls.

I would try using curl instead to fetch a remote webpages, as most hosts do allow that to fetch external webpages.

CodeJoust
+1  A: 

You might get some more mileage out of cUrl, it does the same job you are trying to achieve but was specifically designed for that job (loads more settings too). There are a few restrictions a sys admin can place on file() functions that would be stopping you from using this filesystem function in that way.

Check curl is installed by browsing to a file with <?php phpinfo(); ?> as the contents.

Good luck

Question Mark
Thanks alot. I tried cURL however I am getting similar results. It works like a charm on my home machine, however when uploaded to my shared hosting, it doesnt work. The weird thing is, if I use curl (and file for that matter) on google, or another site, it works fine (on the shared package as well as home).Is it possible my host is blocking the connection somehow? The only conistant thing is that with each fucntion I have used, I am tring port 8000.
Sam
If both `file()` and cURL don't work your web host is probably blocking outgoing requests above a certain port range. I've had the same problem with Godaddy shared hosting in the past.
pygorex1
+1  A: 

Your PHP configuration must have the allow_url_fopen directive enabled if you want be able to fetch files via a URL. It can't be set at runtime, so you must edit the php.ini file directly.

Atli
A: 

It's common for university firewalls to block access to ports other than HTTP or HTTPS. So the port 8000 may be the problem.

ZZ Coder
Thanks. I don't think the uni is blocking it because the station streams on 8000 and I can access it with the script I have written from my home server.
Sam