PDA

View Full Version : PHP



Casio
17-01-2011, 10:31 PM
<?php
function getscdata($server, $port) {
$open = fsockopen($server, $port);
if($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$text = explode("content-type:text/html",$read);
}
return $text[1];
}
$count = getscdata("SERVER IP HERE", "PORT HERE");
$datacount = explode(",", $count);
$count = $datacount[4];
$viewerCount = '<font color="black"><center><b>Listeners:</b> <i>'.$count.'</i><br /><b>Song:</b> <i>'.$datacount[6].'</i></center></font>';
if($_GET['ajaxsync'] == "counter") {
echo $viewerCount;
die();
}
?>
<html>
<script>
function createRequestObject() {
var ro;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
ro = new ActiveXObject("Microsoft.XMLHTTP");
} else {
ro = new XMLHttpRequest();
}
return ro;
}
var xmlHttp = createRequestObject();
var lastapidata = null;
function runapipull() {
xmlHttp.open('get', '<?php echo $_SERVER['PHP_SELF'];?>?ajaxsync=counter&ms='+ new Date().getTime());
xmlHttp.onreadystatechange = readapidata;
xmlHttp.send(null);
}
function readapidata() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.responseText != lastapidata) {
lastapidata = xmlHttp.responseText;
if (document.getElementById("livecount")) {
document.getElementById("livecount").innerHTML = xmlHttp.responseText;
}
}
setTimeout("runapipull()", 15000);
}
}
runapipull();
</script>
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<title> MY SITE TITLE HERE</title>
<background="/images/background.png">
<body>
<div id="livecount"><?php echo $viewerCount; ?></div>
<center><script type="text/javascript" src="http://player.wavestreamer.com/cgi-bin/swf.js?id=EKG9W7S2LFZUEVY3"></script><script type="text/javascript" src="http://player.wavestreaming.com/?id=EKG9W7S2LFZUEVY3"></script></center></div>
</p></div>
</body>
</html>



Ok, so I have this coding, as I have a background code in there but when i load the page the background doesnt actually show, any help please +REP

Fiendly
18-01-2011, 06:37 AM
Change "<background="/images/background.png">" to:


<style type=text/css>
body {
background-image: src('images/backgroung.png');
}
</style>


Just needed to add a stylesheet property :)
Hope I helped, will help if needed.

LMS16
18-01-2011, 09:01 AM
if its showing just a white page with nothing else then it is "dying"...


<?php
function getscdata($server, $port) {
$open = fsockopen($server, $port);
if($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$text = explode("content-type:text/html",$read);
}
return $text[1];
}
$count = getscdata("SERVER IP HERE", "PORT HERE");
$datacount = explode(",", $count);
$count = $datacount[4];
$viewerCount = '<font color="black"><center><b>Listeners:</b> <i>'.$count.'</i><br /><b>Song:</b> <i>'.$datacount[6].'</i></center></font>';
if($_GET['ajaxsync'] == "counter") {
echo $viewerCount;
die(); // <------------------------ !!!!THIS DIE!!!!
}
?>
<html>
<script>
function createRequestObject() {
var ro;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
ro = new ActiveXObject("Microsoft.XMLHTTP");
} else {
ro = new XMLHttpRequest();
}
return ro;
}
var xmlHttp = createRequestObject();
var lastapidata = null;
function runapipull() {
xmlHttp.open('get', '<?php echo $_SERVER['PHP_SELF'];?>?ajaxsync=counter&ms='+ new Date().getTime());
xmlHttp.onreadystatechange = readapidata;
xmlHttp.send(null);
}
function readapidata() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.responseText != lastapidata) {
lastapidata = xmlHttp.responseText;
if (document.getElementById("livecount")) {
document.getElementById("livecount").innerHTML = xmlHttp.responseText;
}
}
setTimeout("runapipull()", 15000);
}
}
runapipull();
</script>
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<title> MY SITE TITLE HERE</title>
<background="/images/background.png">
<body>
<div id="livecount"><?php echo $viewerCount; ?></div>
<center><script type="text/javascript" src="http://player.wavestreamer.com/cgi-bin/swf.js?id=EKG9W7S2LFZUEVY3"></script><script type="text/javascript" src="http://player.wavestreaming.com/?id=EKG9W7S2LFZUEVY3"></script></center></div>
</p></div>
</body>
</html>

If not then try change "<body>" to "<body background="link/to/image.png">"

Edit: It seems the script maybe told toe die(); before it can output the background command. Remove the die(); and see how it goes :)

Lew.

Fiendly
18-01-2011, 10:08 AM
Snipped from your quote.
Simply just needed the <body background="source">

Demo is here for you to look :): Click here (http://crossfireblog.com/radio2.php)

Source:


<?php
function getscdata($server, $port) {
$open = fsockopen($server, $port);
if($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$text = explode("content-type:text/html",$read);
}
return $text[1];
}
$count = getscdata("206.217.213.16", "8012");
$datacount = explode(",", $count);
$count = $datacount[4];
$viewerCount = '<font color="black"><center><b>Listeners:</b> <i>'.$count.'</i><br /><b>Song:</b> <i>'.$datacount[6].'</i></center></font>';
if($_GET['ajaxsync'] == "counter") {
echo $viewerCount;
die();
}
?>
<html>
<script>
function createRequestObject() {
var ro;
var browser = navigator.appName;
if (browser == "Microsoft Internet Explorer") {
ro = new ActiveXObject("Microsoft.XMLHTTP");
} else {
ro = new XMLHttpRequest();
}
return ro;
}
var xmlHttp = createRequestObject();
var lastapidata = null;
function runapipull() {
xmlHttp.open('get', '<?php echo $_SERVER['PHP_SELF'];?>?ajaxsync=counter&ms='+ new Date().getTime());
xmlHttp.onreadystatechange = readapidata;
xmlHttp.send(null);
}
function readapidata() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.responseText != lastapidata) {
lastapidata = xmlHttp.responseText;
if (document.getElementById("livecount")) {
document.getElementById("livecount").innerHTML = xmlHttp.responseText;
}
}
setTimeout("runapipull()", 15000);
}
}
runapipull();
</script>
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<title> MY SITE TITLE HERE</title>
<body background="http://www.durastill.com/images/blue_gradient_background.jpg">
<div id="livecount"><?php echo $viewerCount; ?></div>
<center><script type="text/javascript" src="http://player.wavestreamer.com/cgi-bin/swf.js?id=EKG9W7S2LFZUEVY3"></script><script type="text/javascript" src="http://player.wavestreaming.com/?id=EKG9W7S2LFZUEVY3"></script></center></div>
</p></div>
</body>
</html>

Want to hide these adverts? Register an account for free!