You'll need to manually build PHP5 or find and install RPM's for PHP 5 using shell. Unfortunately, this can't be done through Webmin. It is necessary to know which Linux distribution you are using in order to provide more detailed instructions on how to upgrade PHP.
Looking at the error you posted, I'm sure that the bug mentioned is not related to the problem you are having with fopen(). Your script does not crash and says that connection timed out. We are running PHP 4.4.2 and 4.4.1 on numerous servers and have never got into such issues. I would recommend to check the nameserver settings on your server and make sure that outbound connections are not being blocked in your firewall if you want to upgrade PHP only because of this problem. It is more than likely that one of above is causing the fucntion to fail.
I hope this helps.