View Single Post
Old 21st June 2009, 10:47   #6
jaromanda
Forum King
 
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,289
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(getSeven30000);
</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

"If you don't like DNAS, write your own damn system"

So I did

Last edited by jaromanda; 21st June 2009 at 11:11.
jaromanda is offline   Reply With Quote