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);
)
?>
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?
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>
"
?>
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' /> ");
?>
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>
"
?>