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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    fsockopen - Status

    Hello,

    At the moment, I have pulled together a simple PHP Script which tells the person viewing the page HOW LONG the page takes to load etc, I have gone brain dead now

    Code:
    <?php
    $ip = "youriphere"; 
    $port = "yourporthere";
    $start = microtime(true);
    if (!$sock = @fsockopen($ip, $port, $num, $error, 5)) 
    echo '<B><FONT COLOR=red>Offline</b></FONT>'; 
    else{ 
    $howlong = microtime(true) - $start;
    echo '<B><FONT COLOR=lime>Online</b></FONT> time: ' . $howlong . ' seconds'; 
    fclose($sock); 
    } 
    ?>
    I want it to look like this page http://www.spamsite.co.uk/status.php

    So, after x seconds the page would state it as SLOW
    after y seconds the page would state it as DOWN
    after z seconds the page would state it as ACTIVE


    Help is appreciated

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Maybe something like...

    PHP Code:

    if($howlong 60) {
        
    $message "Site Down";
    }
    elseif(
    $howlong 30) {
        
    $message "Slow";
    }
    else {
        
    $message "Active";
    }
    print 
    $message 

  • Users who have thanked bcarl314 for this post:

    Jake:) (10-21-2009)

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Could you add that to the original code, that way I can't go wrong


  •  

    Posting Permissions

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