Location: PHPKode > projects > Limph > limph-1.9.7/history_data.php
<?php
 /*
   Limph Is Monitoring Pingable Hosts
   Copyright (C) 2006 Jonathan Ciesla
   
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
require_once("config.php");
require_once("functionlib.php");
session_start();
favicon();

$link = dbms_connect($dbhost, $dbuser, $dbpass, $dbname);

authentication(0,0);

echo "<link rel=stylesheet href=css.php>";

$hostname = $_GET['hostname'];
$place = $_GET['place'];
if(!$place){$place = "0";};

echo "<br />";
echo "<table align=center border=1 cellpadding=2>";
$query = "SELECT type,datetime,hostname FROM history WHERE hostname = '$hostname' ORDER BY datetime DESC;";
$result = dbms_query($query);

$dataset = array();
while($line = dbms_fetch_array($result, "NUM")){
  array_push($dataset, $line);
 };
dbms_free_result($result);
dbms_close($link);

$chunks = array_chunk($dataset, 14);

echo "<tr><th colspan=3>";

echo "<form action=history_data.php method=get>";
$count = 0;
echo "<input type=submit value=\"History Data\">";
echo "<select name=place>";
foreach($chunks as $chunk){
  $flag = "";
  if($count==$place){$flag = "selected";};
  echo "<option value=$count $flag>$count";
  $count++;
};
echo "</select>";
echo "<input type=hidden name=hostname value=$hostname>";

echo "</form>";

echo "</th></tr>";

echo "<tr><th>Hostname</th><th>Type</th><th>Date/Time</th></th>";

$batch = $chunks[$place];

foreach($batch as $line){
  echo "<tr>";
  echo "<td>{$line['2']}</td>";
  if($line[0]=="Down"){
    $bgcolor = "bgcolor=#FF0000";
  } else {
    $bgcolor = "bgcolor=#00FF00";
  };
  echo "<td $bgcolor>{$line['0']}</td>";
  echo "<td>{$line['1']}</td>";
  echo "</tr>";
};
echo "</table>";

?>
Return current item: Limph