File: 1.09.1a/server/web/history.alert.php (View as HTML)

  1: <?php
  2: /* -------------------------------------------------------------
  3: This file is part of FreeNATS
  4: 
  5: FreeNATS is (C) Copyright 2008 PurplePixie Systems
  6: 
  7: FreeNATS is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeNATS is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with Foobar.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freenats
 21: -------------------------------------------------------------- */
 22: 
 23: ob_start();
 24: require("include.php");
 25: $NATS->Start();
 26: if (!$NATS_Session->Check($NATS->DB))
 27: 	{
 28: 	header("Location: ./?login_msg=Invalid+Or+Expired+Session");
 29: 	exit();
 30: 	}
 31: if ($NATS_Session->userlevel<1) UL_Error("View Alert");
 32: ob_end_flush();
 33: Screen_Header("Alert History for ".$_REQUEST['nodeid'],1);
 34: ?>
 35: <br>
 36: <?php
 37: echo "<b class=\"minortitle\">Node Alerts for: <a href=node.php?nodeid=".$_REQUEST['nodeid'].">".$_REQUEST['nodeid']."</a></b><br><br>";
 38: 
 39: function dal($arow)
 40: {
 41: global $NATS;
 42: echo "<table border=0>";
 43: echo "<tr><td align=right><b>Alert : </b></td>";
 44: echo "<td align=left><b>".$arow['nodeid']."/".$arow['alertid']."</b></td></tr>";
 45: echo "<tr><td align=right>Opened : </td>";
 46: echo "<td align=left>".nicedt($arow['openedx'])."</td></tr>";
 47: 
 48: if ($arow['closedx']>0)
 49: 	{
 50: 	$st="<b class=\"al0\">Resolved</b>";
 51: 	$ct=nicedt($arow['closedx'])." (Open for ".nicediff($arow['closedx']-$arow['openedx']).")";
 52: 	}
 53: else
 54: 	{
 55: 	$st="<b>Open</b>";
 56: 	$ct="n/a";
 57: 	}
 58: 
 59: echo "<tr><td align=right>Status : </td>";
 60: echo "<td align=left>".$st."</td></tr>";
 61: echo "<tr><td align=right>Closed : </td>";
 62: echo "<td align=left>".$ct."</td></tr>";
 63: 
 64: echo "<tr><td align=right>Level : </td>";
 65: echo "<td align=left><b class=\"al".$arow['alertlevel']."\">".aText($arow['alertlevel'])."</td></tr>";
 66: 
 67: echo "<tr><td colspan=2>&nbsp;<br><b><u>Alert Log</u></b></td></tr>";
 68: 
 69: $hq="SELECT * FROM fnalertlog WHERE alertid=".$arow['alertid']." ORDER BY postedx DESC";
 70: $px=0;
 71: $first=true;
 72: $hr=$NATS->DB->Query($hq);
 73: while ($hrow=$NATS->DB->Fetch_Array($hr))
 74: 	{
 75: 	if ($hrow['postedx']!=$px) // first entry for that px
 76: 		{
 77: 		if (!$first) echo "</td></tr>"; // first ever px or not
 78: 		else $first=false;
 79: 		echo "<tr><td align=right valign=top>";
 80: 		$px=$hrow['postedx'];
 81: 		echo nicedt($px);
 82: 		echo " : ";
 83: 		echo "</td><td align=left valign=top>";
 84: 		}
 85: 	echo $hrow['logentry']."<br>";
 86: 	}
 87: if (!$first) echo "</td></tr>";
 88: 		
 89: 		
 90: echo "</table>";
 91: }
 92: 
 93: if (isset($_REQUEST['alertid']))
 94: 	{ // display this one
 95: 	$q="SELECT * FROM fnalert WHERE alertid=".ss($_REQUEST['alertid']);
 96: 	$r=$NATS->DB->Query($q);
 97: 	if ($row=$NATS->DB->Fetch_Array($r)) dal($row);
 98: 	else echo "<b>Error Fetching AlertID</b><br><br>";
 99: 	}
100: else
101: 	{ // see if one is open
102: 	$q="SELECT * FROM fnalert WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND closedx=0";
103: 	$r=$NATS->DB->Query($q);
104: 	if ($row=$NATS->DB->Fetch_Array($r)) dal($row);
105: 	// otherwise nothing open...
106: 	}
107: 	
108: echo "<br><br>";
109: echo "<b class=\"minortitle\">Alert History for ".$_REQUEST['nodeid']."</b><br><br>";
110: // display history
111: 
112: $hq="SELECT * FROM fnalert WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" ORDER BY alertid DESC";
113: $hr=$NATS->DB->Query($hq);
114: //echo $hq;
115: 
116: echo "<table border=0>";
117: while ($hrow=$NATS->DB->Fetch_Array($hr))
118: 	{
119: 	echo "<tr><td><a href=history.alert.php?alertid=".$hrow['alertid']."&nodeid=".$_REQUEST['nodeid'].">";
120: 	echo $_REQUEST['nodeid']."/".$hrow['alertid'];
121: 	echo "</td></td>";
122: 	echo "<td>";
123: 	if ($hrow['closedx']<=0) echo "<b>Open</b>";
124: 	else echo "Resolved";
125: 	echo "</td>";
126: 	echo "<td>";
127: 	echo nicedt($hrow['openedx'])." - ";
128: 	if ($hrow['closedx']<=0) echo "n/a";
129: 	else echo nicedt($hrow['closedx']);
130: 	echo "</td>";
131: 	
132: 	echo "</tr>";
133: 	}
134: echo "</table>";
135: 
136: ?>
137: 
138: 
139: <?php
140: Screen_Footer();
141: ?>
142: