Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FTP Server status

    Does ayone know how to write a script which detects the status of an FTP server and then indicates on a web page whether the server is up or down.

    Any help would be appreciated.

    Thanks!

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    You could have an image file or something on the server, then maybe something like this would work

    PHP Code:
    <?php
    if(file_exists('ftp/url/to/image')){
      echo 
    'Server online';
    }else{
      echo 
    'Server offline';
    }
    ?>
    Or maybe this
    PHP Code:
    <?php
    $fp 
    fsockopen ("www.example.com"80$errno$errstr30);
    if (!
    $fp) {
        echo 
    "Server offline";
    } else {
        echo 
    "Server online";
    }

    ?>
    http://uk.php.net/function.fsockopen
    Last edited by Nightfire; 10-02-2003 at 11:50 PM.

  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool thanks!

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <?php
    $fp = fsockopen ("www.example.com", 21, $errno, $errstr, 30);
    if (!$fp) {
    echo "Server offline";
    } else {
    echo "Server online";
    }

    ?>

    ^^

    That should be port 21, no point in checking for HTTP traffic on an FTP now is there

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    lol well spotted


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •