Here is what I'm having trouble with: I've had the below script running for years and it's been fine. But my web host moved / upgraded servers a couple of weeks ago and ever since the script has failed to work.
<?
rename ("/home/website/public_html/feed", "/home/website/public_html/feedx");
file_put_contents('/home/website/public_html/feedx/rss.xml', file_get_contents('http://www.mywebsite.co.uk/feed/'));
file_put_contents('/home/website/public_html/feedx/podcast/rss.xml', file_get_contents('http://www.mywebsite.co.uk/feed/podcast/'));
rename ("/home/website/public_html/feedx", "/home/website/public_html/feed");
?>
Why it is needed and what it does:
- I run the Blubrry Powerpress podcast plug in for Wordpress. It works great but dynamically generates two RSS feed files every time its called. So for 10,000 subscribers polling the website every hours for new episodes it was spiking CPU usage like crazy.
- I then created the script which renames the feed directory, calls the URL location (which in turn causes the plugin to fire and generate the RSS files as it must use htaccess to have a virtual path) and saves them as static files on the server. It then renames the directory back and whenever a listener's app polls the server it returns the static file quickly.
Current situation:
If I manually do the steps as in rename the directory in my FTP client, load the URL in Chrome and then Save As the resultant website and upload it to the two locations and rename the folder back - it works fine.
If I run the script on the server it just generates a 0 byte file for each RSS.
Can anyone give me any thoughts and advice on why its not working now and what I can try to fix it?