Quote:
Originally posted by POMATu
my host doesnt allow this
|
hence ...
Quote:
Originally posted by Brutish Sailor
If you can get a friend to host your now playing script...
|
a far simpler php ... simply retrieves 7.html (or played.html for that matter in fact ANY url)
PHP Code:
<?php
$url=$_GET["url"];
$cb=$_GET["cb"];
header("Content-type: text/javascript");
header("Cache-Control: no-cache");
header("Expires: -1");
ini_set("user_agent", "Mozilla/5.0");
echo "$cb('".urlencode(@file_get_contents($url))."');";
?>
the PHP HAS TO BE ON A SERVER THAT ALLOWS allow_url_fopen
the javascript on the webpage in question
PHP Code:
<script>
function addScript(url) {
// the following 4 lines remove the "old" script first
var x=document.getElementById('zzzreplaceme');
if(x) {
x.parentNode.removeChild(x);
}
var script = document.createElement('script');
script.src = url;
script.id = 'zzzreplaceme';
document.body.appendChild(script);
}
function getSeven() {
addScript('http://domain.com.xx/getSeven.php?url=http://yoursc.host.com.xx:8000/7.html&cb=sevenCb');
// change domain.com.xx and yoursc.host.com.xx:8000 as appropriate
}
function sevenCb(obj) { // this is the same as the cb=sevenCb argument above
var rawSeven = decodeURIComponent(s).replace(/%7E/g,'~').replace(/\+/g,' ');
// parse the 7.html data here ... do with it as you will, it's in variable rawSeven
}
window.setInterval(getSeven, 30000);
</script>
again ... the PHP HAS TO BE ON A SERVER THAT ALLOWS allow_url_fopen in the above case - there is no way around this problem
another consideration for the server side, it has to allow connections to arbitrary ports ... I've had a host with allow_url_fopen true ... but trying to retrieve external data on other than port 80 did not work
another consideration for the server ... cache the result of the read, for 30 seconds or more (not too much) ... if you expect a LOT of people to be using your web page
the above has been tested and proven to work