Freeware SERVER_ONLINE_TEST PHP script - Check status (online/offline) of the chosen web server(s).

Jaromir Adamek logo

Menu:   Jaromír Adámek - www.Adamek.biz


table design
table design Freeware SERVER_ONLINE_TEST PHP script 1.00 table design
table design
table design

Description:

  • Check status (online/offline) of the chosen web server(s).
  • Whole script Is written In the pure PHP and don't need any special things (only one .txt file on the monitored server side).
  • You may monitor as many servers as you will need.
  • Main advantage against the others checking scripts Is, that checking of the server accessibility Is saved via the special file on the checked server side. If this check pass, you may be 100% sure, that not only the web server Is running, but that the web server sending the pages to the your visitors correctly.
  • SERVER_ONLINE_TEST PHP script main functionality Is separated to the severals simply functions and whole script Is well commented, so you may easily changed It without any stress.

How It will look?

Sample with one good (Adamek.biz on the green background) server:

Adamek.biz
Server online test (www.Adamek.biz/server_online_test/).

Usage/installation:

  1. Upload "server_online_test__test_file.txt" file to the your checked server.
  2. Insert exact URL of the checked file from the 1) to the "$URL_array" array in the main script.
  3. Upload "server_online_test.php" and "server_online_test__test_file.txt" to the main server (file "server_online_test__test_file.txt" on the main server Is required for the comparing).
  4. Run the PHP script "server_online_test.php" on the main server.

Terms:

  1. This PHP script may be used freely without any charge (include free usage for the commercial companies and government)!
  2. This PHP script may be changed in any way EXCEPT the all copyrights of the JA Adamek.biz author and included link to this page ("Server online test (www.Adamek.biz/server_online_test/)")! THIS STRINGS MUST STAY WITHOUT ANY CHANGE!
  3. Only note. If you will find any BUG or If you will implement some good new feature to this script, please send me your version via email (contact Is on the page http://www.Adamek.biz/).

Download:

Download server_online_test package: server_online_test__1_00.zip

table design
table design

SERVER_ONLINE_TEST source:

<? // *************************************************************************************** // * Copyright 1999-2005 JA Adamek.biz All rights reserved. WWW:"http://www.Adamek.biz/" * // *************************************************************************************** // // SERVER ONLINE TEST PHP SCRIPT 1.00, Homepage: http://www.Adamek.biz/server_online_test/ // // Description: // 1) Check status (offline/online) of the chosen web server(s). // 2) Whole script Is written In the pure PHP and don't need any special things (only one .txt file on the monitored server side). // 3) You may monitor as many servers as you will need. // 4) Main advantage against the others checking scripts Is, that checking of the server accessibility // Is saved via the special file on the checked server side. If this check pass, you may be 100% sure, // that not only the web server Is running, but that the web server sending the pages to the your visitors correctly. // 5) SERVER_ONLINE_TEST PHP script main functionality Is separated to the severals simply functions and // whole script Is well commented, so you may easily changed It without any stress. // // Usage/installation: // 1) Upload "server_online_test__test_file.txt" file to the your checked server. // 2) Insert exact URL of the checked file from the 1) to the "$URL_array" array in this script (look little down). // 3) Upload "server_online_test.php" and "server_online_test__test_file.txt" to the main server // (file "server_online_test__test_file.txt" on the main server Is required for the comparing). // 4) Run the PHP script "server_online_test.php" on the main server. // // Terms: // 1) This PHP script may be used freely without any charge (include free usage for the commercial companies and government)! // 2) This PHP script may be changed in any way EXCEPT the all copyrights of the JA Adamek.biz author // and included link to this page ("Server online test (www.Adamek.biz/server_online_test/)")! THIS STRINGS MUST STAY WITHOUT ANY CHANGE! // 3) Only note. If you will find any BUG or If you will implement some good new feature to this script, // please send me your version via email (contact Is on the page "http://www.Adamek.biz/"). // SERVER ONLINE TEST PHP SCRIPT 1.00 START // START OF THE USER AREA * START OF THE USER AREA * START OF THE USER AREA * // fill the exact URL of the "server_online_test__test_file.txt" files on the yours checked servers // you may specify 1,2,3 or 999, this Isn't interesting $URL_array[] = 'http://www.Adamek.biz/server_online_test__test_file.txt'; // END OF THE USER AREA * END OF THE USER AREA *END OF THE USER AREA * $debug = 0; // debug mode (0-off, 1-on) If ($debug == 1){ // debug mode var_dump ($URL_array); echo '<BR><BR>'."\n"; } // Main loop echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4>'."\n"; echo '<TR>'."\n"; for ( $URL_counter = 0; $URL_counter < Count($URL_array); $URL_counter++ ){ // For every domain in the array If ( server_online_test($URL_array[$URL_counter], $debug) ) // Check domain echo '<TD BGCOLOR="#99FF99"><FONT COLOR="#000000" SIZE="-1">'.get_host_name_from_url($URL_array[$URL_counter]).'</FONT></TD>'; // OK - Domain Is running else echo '<TD BGCOLOR="#FF9999"><FONT COLOR="#000000" SIZE="+1"><B>'.get_host_name_from_url($URL_array[$URL_counter]).' KO!!!</B></FONT></TD>'; // KO - Domain Isn't running! If ( ($URL_counter != 0) && (($URL_counter % 10) == 0) ) // new table row after each 7th column echo '<TR>'."\n".'<TR>'; } echo '</TR>'."\n"; echo '<TR>'. '<TD ALIGN=CENTER COLSPAN='.Count($URL_array).'>'. 'Server online test (<A HREF="http://www.Adamek.biz/server_online_test/"><FONT SIZE="-1">www.Adamek.biz/server_online_test/</FONT></A>).'. '</TD>'. '</TR>'."\n"; echo '</TABLE>'."\n"; // Check domain status and return boolean value (true-OK domain Is running, false-KO domain Is offline) function server_online_test ($URL, $debug = 0){ // $domain sample imput: "www.Adamek.biz" $controlled_file = load_file_string($URL, 0); $original_file = load_file_string('./server_online_test__test_file.txt', 0); If ($debug == 1){ // debug mode echo '$original_file: '; var_dump ($original_file); echo '<BR><BR>'."\n"; echo '$controlled_file: '; var_dump ($controlled_file); echo '<BR><BR>'."\n"; } If ($controlled_file == $original_file) // comparing of the files $is_server_online = TRUE; // If Is connection to the server successfully opened else $is_server_online = FALSE; // If connection to the server can't be opened If ($debug == 1) var_dump ($is_server_online); // debug mode return $is_server_online; // return value of the function } // *************************************************************************************** // * Copyright 1999-2005 JA Adamek.biz All rights reserved. WWW:"http://www.Adamek.biz/" * // *************************************************************************************** // Load file to the string variable. // usage: // $name_of_file = 'a.txt'; // definice jména souboru // $file_in_string = load_file_string($name_of_file,$debug); // load file to the string $file_in_string // // load_file_string 1.02 BEGIN function load_file_string($file_in_disk, $debug = 0){ If ($debug == 1) echo 'Loading of file: "<B>'.$file_in_disk.'"</B><BR>'; $pointer_to_file = @fopen ($file_in_disk, "r"); if ($pointer_to_file != 0){ while (!feof ($pointer_to_file)){ $nacteny_redek = fgets($pointer_to_file, 100000); // načte řádek $file_in_memory = $file_in_memory.$nacteny_redek; // připojí ho na konec řetězce } If ($debug == 1) echo ' &nbsp; &nbsp; <FONT COLOR=LIME><B>Is finished</B></FONT> ('.StrLen($file_in_memory).' chars).<BR>'; } else { If ($debug == 1) echo ' &nbsp; &nbsp; <FONT COLOR=RED><B>FAILED ! </B></FONT> file <FONT COLOR=RED>'.$file_in_disk.'</FONT> don\'t exist<BR>'; } @fclose ($pointer_to_file); return $file_in_memory; } // load_file_string END // *************************************************************************************** // * Copyright 1999-2005 JA Adamek.biz All rights reserved. WWW:"http://www.Adamek.biz/" * // *************************************************************************************** // separate domain hostname from the URL // usage: // $url = 'http://www.aaa.bbb.cz/aaa/i.php'; // $host_name = get_host_name_from_url($url); // If Is input something as "http://www.aaa.bbb.cz/aaa/i.php" return "bbb.cz" // echo "domain name is: $host_name<BR>\n"; // // get_host_name_from_url 1.0 START function get_host_name_from_url($url){ // get host name from URL preg_match("/^(http:\/\/)?([^\/]+)/i", $url, $matches); $host = $matches[2]; // get last two segments of host name preg_match("/[^\.\/]+\.[^\.\/]+$/",$host,$matches); $domain_name = $matches[0]; return ($domain_name); } // get_host_name_from_url END // SERVER ONLINE TEST PHP SCRIPT 1.00 END ?>


Copyright 1999-2017 www.Adamek.biz   Jaromir Adamek   All rights reserved.

Made by Jaromir Adamek in loved EU :).