Results 1 to 5 of 5

Thread: Script to show server status

  1. #1
    Join Date
    Aug 2010
    Posts
    34

    Script to show server status

    Hello,
    I have a problem with the following script , I am new to php language. I am trying to display the status of a server with this script

    Here is the script
    Code:
    <?php
    
     $ cn = TRUE; / / Allow or not the connection
     $ prt = 21; / / Server prt 
     $ ipaddress = "127.0.0.1", / / address (ipaddress) server 
     $ nm = "SERVER nm" / / Server nm
    
     / / Set the text of the nm server
       echo "Server: $''nm''"
     / / Verification status
       
    if (! $ sck = @fsockopen($ ipaddress, $ prt, $ num, $ error, 5))
     / / If it is offline
    echo ' is: <font color="#CC0000"> DISCONNECTED </ font> "';
     
    else(
     / / If it is online
    echo ' is <font color="#00CC00"> CONNECTED </ font> "';
    
    fclose($ sck);
    
    )
    ?>

  2. #2
    Join Date
    Dec 2007
    Posts
    765

    Re: Script to show server status

    Since you're a beginner you are doing well. In fact, it hurts me in your code is that finally, it just does fsockopen (). It's as if you thought over a code to make a simple echo applying a color? You had best hits with the socket extension, and socket_create () socket_connect () etc. What is the server you are trying to test on?

  3. #3
    Join Date
    Aug 2010
    Posts
    34

    Re: Script to show server status

    Here
    I choose a script to put a simple server status, and it only works when the server is online, while the precise else is a picture to put otherwise.

    Code:
    <Php
    $ ipadd = "861213";
    $ ipser = "861213";
    $ lgn = @ fsockopen ($ ipadd, 2106, $ errno, $ errstr, 1);
    $ = @ Fsockopen gme ($ ipser, 7777, $ errno, $ errstr, 1);
    if ($ lgn)
    if ($ gme)
    echo "
    <img src=http:"your image here"> <br>
    <img src=http:"your image here"> <br>
    "
    else
    echo "
    <img src=http:"your image here"> <br>
    <img src=http:"your image here"> <br>
    "
    ?>

  4. #4
    Join Date
    Apr 2008
    Posts
    3,341

    Re: Script to show server status

    Hey,
    You can try the following code
    Code:
    <Php
    $ ipaddress = "453132";
    echo ((@ fsockopen ($ ipaddress, 2106, $ er, $ strer, 2))? 
    "<img /> src='http:your address here'" " 
    src='http:your address here' <img /> "). "<br />". ((@ 
    Fsockopen ($ ipaddress, 7777, $ er, $ strer, 2))? "<img /> 
    Src='http:your address here'": "< img src = 
    'http:your address here' /> ");
    ?>

  5. #5
    Join Date
    Aug 2008
    Posts
    725

    Re: Script to show server status

    Hello,
    I have modified your code, please check if this is working now

    Code:
    <Php
    $ ipaddress = "91121148117";
    $ ipaddser = "91121148117", / / this useless line
    $ Flogin = @ fsckp ($ ipaddress, 2106, $ errno, $ errstr, 1);
    $ = @ fsckp fgame ($ ipaddser, 7777, $ errno, $ errstr, 1) / / So here we change / / useless variable sorting
    if ($ flogin) / / here is very bad
    if ($ fgame)
    echo "
    <img src=http:"your image here"> <br>
    <img src=http:"your image here"> <br>
    "
    else
    echo "
    <img src=http:"your image here"> <br>
    <img src=http:"your image here"> <br>
    "
    ?>

Similar Threads

  1. Most WSUS clients show status 'Not yet reported'
    By purvagarg in forum Server Update Service
    Replies: 3
    Last Post: 07-01-2014, 08:47 AM
  2. Replies: 6
    Last Post: 17-06-2011, 09:59 PM
  3. Windows Explorer Status Bar: does not show file size
    By Chakchiuma in forum Operating Systems
    Replies: 6
    Last Post: 11-09-2010, 06:40 AM
  4. SatelliteTV Box does not show POWER ON status
    By Delaware in forum India BroadBand
    Replies: 6
    Last Post: 10-07-2010, 12:07 AM
  5. Script for Advanced status clock
    By Aileen_L in forum Software Development
    Replies: 4
    Last Post: 04-02-2010, 09:48 PM

Posting Permissions

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