File: 1.00.6a/server/web/history.alert.php (View as Code)

1: 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:
36: 37: echo "Node Alerts for: ".$_REQUEST['nodeid']."

";
38: 39: function dal($arow) 40: { 41: global $NATS; 42: echo ""; 43: echo ""; 44: echo ""; 45: echo ""; 46: echo ""; 47: 48: if ($arow['closedx']>0) 49: { 50: $st="Resolved"; 51: $ct=nicedt($arow['closedx'])." (Open for ".nicediff($arow['closedx']-$arow['openedx']).")"; 52: } 53: else 54: { 55: $st="Open"; 56: $ct="n/a"; 57: } 58: 59: echo ""; 60: echo ""; 61: echo ""; 62: echo ""; 63: 64: echo ""; 65: echo ""; 66: 67: echo ""; 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 ""; // first ever px or not 78: else $first=false; 79: echo ""; 88: 89: 90: echo "
Alert : ".$arow['nodeid']."/".$arow['alertid']."
Opened : ".nicedt($arow['openedx'])."
Status : ".$st."
Closed : ".$ct."
Level : ".aText($arow['alertlevel'])."
 
Alert Log
"; 80: $px=$hrow['postedx']; 81: echo nicedt($px); 82: echo " : "; 83: echo ""; 84: } 85: echo $hrow['logentry']."
";
86: } 87: if (!$first) echo "
";
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 "Error Fetching AlertID

";
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 "

";
109: echo "Alert History for ".$_REQUEST['nodeid']."

";
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 ""; 117: while ($hrow=$NATS->DB->Fetch_Array($hr)) 118: { 119: echo ""; 122: echo ""; 126: echo ""; 131: 132: echo ""; 133: } 134: echo "
"; 120: echo $_REQUEST['nodeid']."/".$hrow['alertid']; 121: echo ""; 123: if ($hrow['closedx']<=0) echo "Open"; 124: else echo "Resolved"; 125: echo ""; 127: echo nicedt($hrow['openedx'])." - "; 128: if ($hrow['closedx']<=0) echo "n/a"; 129: else echo nicedt($hrow['closedx']); 130: echo "
";
135: 136: ?> 137: 138: 139: 140: Screen_Footer(); 141: ?> 142: