rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: dardarlt on February 26, 2007, 09:52:25 PM

Title: how to check is HFS online using php?
Post by: dardarlt on February 26, 2007, 09:52:25 PM
My hfs site is not always online.
Is it possible to create like a gateway page like www.parent.com, where from I could simplye redirect to my hfs site if it is online and simply give a message like "visit later. page is offline temporary".

Or is it any other smart solution to that?
Title: Re: how to check is HFS online using php?
Post by: rejetto on February 26, 2007, 11:49:23 PM
to make something like that, you need to have 2 server.
the second computer should be online when the first is offline.
do you have such thing?
Title: Re: how to check is HFS online using php?
Post by: ledufe on February 27, 2007, 12:56:36 PM
well, hi guys! im slowly getting back to my old life with some free time, and lately im playing with php, and saw this question, in php i create a small status window in php wich tells me if my pages/web-services are running ok.
my hfs at home i check with this code
Code: [Select]
<?php
if(fsockopen('ledufe.no-ip.info'2222$errno$errstr5) !== false)
{
      echo 
'HFS' " Online!";
}
else
{
      echo 
'HFS' " Offline!";
}
?>

hope it helps

i also got a way to do this in javascript using xmlhttp request, and it works too, but since there are so many paranoics people that dont trust in javascript, i prefer to not use it...
Title: Re: how to check is HFS online using php?
Post by: Alons0 on February 27, 2007, 03:54:22 PM
well, hi guys! im slowly getting back to my old life with some free time, and lately im playing with php, and saw this question, in php i create a small status window in php wich tells me if my pages/web-services are running ok.
my hfs at home i check with this code
Code: [Select]
<?php
if(fsockopen('ledufe.no-ip.info'2222$errno$errstr5) !== false)
{
      echo 
'HFS' " Online!";
}
else
{
      echo 
'HFS' " Offline!";
}
?>

hope it helps

i also got a way to do this in javascript using xmlhttp request, and it works too, but since there are so many paranoics people that dont trust in javascript, i prefer to not use it...

where do you put this code or the file with it? And how does it work?
Title: Re: how to check is HFS online using php?
Post by: Giant Eagle on February 27, 2007, 04:02:28 PM
well, hi guys! im slowly getting back to my old life with some free time, and lately im playing with php, and saw this question, in php i create a small status window in php wich tells me if my pages/web-services are running ok.
my hfs at home i check with this code
Code: [Select]
<?php
if(fsockopen('ledufe.no-ip.info'2222$errno$errstr5) !== false)
{
      echo 
'HFS' " Online!";
}
else
{
      echo 
'HFS' " Offline!";
}
?>

hope it helps

i also got a way to do this in javascript using xmlhttp request, and it works too, but since there are so many paranoics people that dont trust in javascript, i prefer to not use it...


Welcome back! :D

Can you post the one that uses javascript aswell? Cause i might be interested in it^^

I'm not afraid of javascript at all.. in fact, if javascript is disabled, HFS Terayon will only work for 50%. Just like most other pages found on the internet.
Title: Re: how to check is HFS online using php?
Post by: Simon on February 27, 2007, 04:30:51 PM
My hfs site is not always online.
Is it possible to create like a gateway page like www.parent.com, where from I could simplye redirect to my hfs site if it is online and simply give a message like "visit later. page is offline temporary".

Or is it any other smart solution to that?

You can use DynDns to do that http://www.dyndns.com.
Title: Re: how to check is HFS online using php?
Post by: dardarlt on February 27, 2007, 04:57:50 PM
rejeto well understood the problem and ledufe gave an answer - I'll try it.
Yes, I have second server. But I didn't suceeded writing my own php script.

I'll writte after the try
Title: Re: how to check is HFS online using php?
Post by: dardarlt on February 27, 2007, 05:03:58 PM
Code: [Select]
<?php
if(fsockopen('ledufe.no-ip.info'2222$errno$errstr5) !== false)
{
      echo 
'HFS' " Online!";
}
else
{
      echo 
'HFS' " Offline!";
}
?>


This works- thank you very much - this is what I needed!
Just I think better to use @fsockopen instead of fsockopen (I've got a warning message using it).
Title: Re: how to check is HFS online using php?
Post by: ledufe on February 28, 2007, 01:19:54 AM
in parts - hahah

to dardarlt

thanks, im glad that it worked for you.... and also, im not getting this warning becouse of my php.ini config, in mine im using like this

Code: [Select]
error_reporting  =  E_ALL
instead the normal/original one:

Code: [Select]
error_reporting = E_ALL & ~E_NOTICE
to the Giant Eagle
about the javascript code is
Code: [Select]
<script type="text/javascript" language="javascript">

    var http_request = false;

    function makeRequest(url) {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, true);
        http_request.send(null);

    }

    function alertContents() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                alert(http_request.responseText);
            } else {
                alert('There was a problem with the request.');
            }
        }

    }
</script>
<span
    style="cursor: pointer; text-decoration: underline"
    onclick="makeRequest('test.html')">
        Make a request
</span>

the onlydrawback to the javascript it is that he looks for a specific file somewhere in the hfs filesystem in this case it looks to a file called test.html

well i don“t know much of javascript, but that_stevens_guy and flyns are very good with js, im getting the way with php now...

if you need some of my help or just to talk about codes and some tech stuffs, let me know....
bye...
Title: Re: how to check is HFS online using php?
Post by: rejetto on February 28, 2007, 08:06:34 AM
the onlydrawback to the javascript it is that he looks for a specific file somewhere in the hfs filesystem in this case it looks to a file called test.html

if that's an url, just use as URL the root of HFS. it is like a file, the javascript doesn't know the difference.
Title: Re: how to check is HFS online using php?
Post by: squall8985 on March 04, 2007, 12:24:43 PM
Code: [Select]
<?php
/*HFS Status */
error_reporting(0);
if(
fsockopen('server_name'port_number$errno$errstr5) !== false)
{
echo 
"<a href=\"http://server_name:port_number\">CONNECT</a></p><br><br>"//If ONLINE
} else {
echo 
"<font color=\"red\" face=\"verdana\" size=\"2\">OFF</font></p><br><br>"//If OFFLINE
}
?>


error_reporting(0) - It will switch off PHP error reporting.
It works for me  ;D
Title: Re: how to check is HFS online using php?
Post by: Giant Eagle on March 04, 2007, 07:47:52 PM
Thnx ledufe!

I'll take a look at it.