Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5

Thread: [PHP] Help

  1. #1
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default [PHP] Help

    Hey

    I have this script that will echo Online if its running and offline if its not....

    PHP Code:
    <?php 
     
    $data 
    .= 
    <style> 
    td,body 

        font-family: Arial, Helvetica, sans-serif; 
        font-size: 8pt; 
        color: #444444; 

    </style> 
    <br>"

     
    //configure script 
    $timeout "1"
     
    //set service checks 
    $port[1] = "80";       $service[1] = "Apache";                  $ip[1] =""
    $port[2] = "21";       $service[2] = "FTP";                     $ip[2] =""
    $port[3] = "3306";     $service[3] = "MYSQL";                   $ip[3] =""
    $port[4] = "25";       $service[4] = "Email (POP3)";            $ip[4] =""
    $port[5] = "143";      $service[5] = "Email (IMAP)";            $ip[5] =""
    $port[6] = "2095";     $service[6] = "Webmail";                 $ip[6] =""
    $port[7] = "2082";     $service[7] = "Cpanel";                  $ip[7] =""
    $port[8] = "80";       $service[8] = "Internet Connection";     $ip[8] ="google.com"
    $port[9] = "2086";     $service[9] = "WHM";                     $ip[9] ="";  
    // 
    // NO NEED TO EDIT BEYOND HERE  
    // UNLESS YOU WISH TO CHANGE STYLE OF RESULTS 
    // 
     
    //count arrays 
    $ports count($port); 
    $ports $ports 1
    $count 1
     
    //beggin table for status 
    $data .= "<table width='480' border='1' cellspacing='0' cellpadding='3' style='border-collapse:collapse' bordercolor='#333333' align='center'>"
     
    while(
    $count $ports){ 
     
         if(
    $ip[$count]==""){ 
           
    $ip[$count] = "localhost"
         } 
     
            
    $fp = @fsockopen("$ip[$count]"$port[$count], $errno$errstr$timeout); 
            if (!
    $fp) { 
                
    $data .= "<tr><td>$service[$count]</td><td bgcolor='#FFC6C6'>Down</td></tr>"
            } else { 
                
    $data .= "<tr><td>$service[$count]</td><td bgcolor='#D9FFB3'>Running</td></tr>"
                
    fclose($fp); 
            } 
        
    $count++; 
     
     
    }  
     
    //close table 
    $data .= "</table>"
     
    echo 
    $data
    ?>
    However i want to add some stuff
    1. Emails me when something gose down
    2. A file that will log when something gose down

    Can someone add this as im not sure on how to?


  2. #2
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    This will E-Mail it, edit the $email variable.

    PHP Code:

    <?php 
     
    $data 
    .= 
    <style> 
    td,body 

        font-family: Arial, Helvetica, sans-serif; 
        font-size: 8pt; 
        color: #444444; 

    </style> 
    <br>"

     
    //configure script 
    $timeout "1"

    $email "[email protected]";
     
    //set service checks 
    $port[1] = "80";       $service[1] = "Apache";                  $ip[1] =""
    $port[2] = "21";       $service[2] = "FTP";                     $ip[2] =""
    $port[3] = "3306";     $service[3] = "MYSQL";                   $ip[3] =""
    $port[4] = "25";       $service[4] = "Email (POP3)";            $ip[4] =""
    $port[5] = "143";      $service[5] = "Email (IMAP)";            $ip[5] =""
    $port[6] = "2095";     $service[6] = "Webmail";                 $ip[6] =""
    $port[7] = "2082";     $service[7] = "Cpanel";                  $ip[7] =""
    $port[8] = "80";       $service[8] = "Internet Connection";     $ip[8] ="google.com"
    $port[9] = "2086";     $service[9] = "WHM";                     $ip[9] ="";  
    // 
    // NO NEED TO EDIT BEYOND HERE  
    // UNLESS YOU WISH TO CHANGE STYLE OF RESULTS 
    // 
     
    //count arrays 
    $ports count($port); 
    $ports $ports 1
    $count 1
     
    //beggin table for status 
    $data .= "<table width='480' border='1' cellspacing='0' cellpadding='3' style='border-collapse:collapse' bordercolor='#333333' align='center'>"
     
    while(
    $count $ports){ 
     
         if(
    $ip[$count]==""){ 
           
    $ip[$count] = "localhost"
         } 
     
            
    $fp = @fsockopen("$ip[$count]"$port[$count], $errno$errstr$timeout); 
            if (!
    $fp) { 
                
    mail($email"$service[$count] is offline!""$service[$count] seems to be down.");
                
    $data .= "<tr><td>$service[$count]</td><td bgcolor='#FFC6C6'>Down</td></tr>"
            } else { 
                
    $data .= "<tr><td>$service[$count]</td><td bgcolor='#D9FFB3'>Running</td></tr>"
                
    fclose($fp); 
            } 
        
    $count++; 
     
     
    }  
     
    //close table 
    $data .= "</table>"
     
    echo 
    $data
    ?>

  3. #3
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    What about log it?


  4. #4
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    Log to MySQL or flatfile?

  5. #5
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    Can it be done to a .txt file please


Posting Permissions

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