Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server / Site Status 1

Status
Not open for further replies.

Billybonga

IS-IT--Management
Jun 22, 2002
72
GB
Hi

I'm working on a project at the moment for a captive portal for our wireless network (i.e. if someones IP address is not registered they get a Captive Portal Page). On the captive portal page I have two links which I want to show the status of (if they are alive/accessible or not) I am able to achieve this using the below php code (it checks the link and if active shows an ON button, else it shows an OFF button). Since the server we are running from does not support php, I have to look for alternative methods e.g. javascript, cgi

Can some-one help me?

function chkuri($link, $option)
{
if(substr($link,0,4)!="http"){
$link = " }

$timestart = microtime();

$churl = @fopen($link,'r');

$timeend = microtime();
$diff = number_format(((substr($timeend,0,9)) + (substr($timeend,-10)) - (substr($timestart,0,9)) - (substr($timestart,-10))),4);
$diff = $diff*100;

if (!$churl) {
$message="<img src=\" alt=\"OFFLINE\">";
}else{
$message="<img src=\" alt=\"ONLINE\">"; if($option==1){ $message = $message."[ ping: ".$diff."ms ]";}
}
echo $message;
}
?>



<?php chkuri(" ?>
 
Cheers Dan,

I reckon I might be able to do something with this.

Thanks for the help
 
ok I've hit a brick wall already. What I'm trying to do with the code is rather than having text saying "You are currently on-line" / "You are currently off-line", I want to show a small on/off image

Here is what I've come up with - only thing is : I doesn't work.


<html>
<head>

<script type="text/javascript">
<!--
var tempImage;

function checkOnlineStatus() {
var tempImage = new Image();
tempImage.onload = returnOnlineStatus;
tempImage.onerror = returnOfflineStatus;
tempImage.src = ' // this must point to the url of a valid image
}

function returnOnlineStatus() {
var onImage = new Image();
onImage.src = 'on.gif';
document.getElementById('onlineStatus').firstChild.nodeValue = onImage;
}

function returnOfflineStatus() {
var offImage = new Image();
offImage.src = 'off.gif';
document.getElementById('onlineStatus').firstChild.nodeValue = offImage;
}

//-->
</script>
</head>

<body onload="checkOnlineStatus();">

<div><img src="test.gif" id="onlineStatus" width="19" height="18"></div>
</body>
</html>


Thanks for any help with this
 
1DMF helped me in getting this to work :
Here is the final code for anyone who prefers to have a graphic displayed rather than text:
Code:
<html>
<head>
<script type="text/javascript">
<!--
var tempImage;

function checkOnlineStatus() {
var tempImage = new Image();
tempImage.onload = returnOnlineStatus;
tempImage.onerror = returnOfflineStatus;
tempImage.src = '[URL unfurl="true"]http://www.web-site.net/captive_portal/images/on.gif';[/URL] // this must point to the url of a valid image
}

function returnOnlineStatus() {
document.onlineStatus.src='on.gif';
}

function returnOfflineStatus() {
document.onlineStatus.src='off.gif';
}

//-->
</script>
</head>

<body onload="checkOnlineStatus();">
<div><img src="test.gif" name="onlineStatus" width="19" height="18"></div>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top