rejetto forum

how to check is HFS online using php?

0 Members and 1 Guest are viewing this topic.

Offline dardarlt

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
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?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
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?


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
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...
<<LeDuFe>>


Offline Alons0

  • Tireless poster
  • ****
    • Posts: 197
    • View Profile
    • Alons0's site
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?


Offline Giant Eagle

  • Tireless poster
  • ****
    • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com
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.


Simon

  • Guest
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.


Offline dardarlt

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
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


Offline dardarlt

  • Occasional poster
  • *
    • Posts: 11
    • View Profile
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).


Offline ledufe

  • Tireless poster
  • ****
    • Posts: 272
  • LEandro DUpont FErreira
    • View Profile
    • http://ledufe.no-ip.info:2222
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...
<<LeDuFe>>


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
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.


Offline squall8985

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
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


Offline Giant Eagle

  • Tireless poster
  • ****
    • Posts: 535
  • >=3 RAWR!
    • View Profile
    • RAWR-Designs.com