File: 1.04.6b/server/web/node.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 FreeNATS.  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&url=".urlencode($REQUEST_URI));
 29: 	exit();
 30: 	}
 31: if ($NATS_Session->userlevel<1) UL_Error("View Node");
 32: ob_end_flush();
 33: Screen_Header("Viewing Node ".$_REQUEST['nodeid'],1);
 34: ?>
 35: <br>
 36: <?php
 37: //echo "<b class=\"minortitle\">Node: ".$_REQUEST['nodeid']."</b><br><br>";
 38: 
 39: echo "<table border=0><tr><td align=left valign=top>";
 40: 
 41: $q="SELECT * FROM fnnode WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" LIMIT 0,1";
 42: $r=$NATS->DB->Query($q);
 43: if (!$row=$NATS->DB->Fetch_Array($r))
 44: 	{
 45: 	echo "No such node.<br><br>";
 46: 	Screen_Footer();
 47: 	exit();
 48: 	}
 49: $NATS->DB->Free($r);
 50: $node=$row;
 51: 
 52: echo "<table class=\"nicetable\">";
 53: 
 54: echo "<tr><td align=right>
 55: Node Name
 56: :</td><td align=left>";
 57: echo $row['nodename'];
 58: echo "</td></tr>";
 59: 
 60: echo "<tr><td align=right>
 61: Status
 62: :</td><td align=left>";
 63: echo "<b class=\"al".$row['alertlevel']."\">";
 64: echo oText($row['alertlevel']);
 65: echo "</b>";
 66: echo "</td></tr>";
 67: 
 68: echo "<tr><td align=right>
 69: Hostname
 70: :</td><td align=left>";
 71: echo $row['hostname'];
 72: echo "&nbsp;</td></tr>";
 73: 
 74: echo "<tr><td align=right>
 75: Description
 76: :</td><td align=left>";
 77: echo $row['nodedesc'];
 78: echo "&nbsp;</td></tr>";
 79: 
 80: echo "<tr><td align=right>
 81: Enabled
 82: :</td><td align=left>";
 83: if ($row['nodeenabled']==1) $s="Yes";
 84: else $s="No";
 85: echo $s;
 86: echo "</td></tr>";
 87: 
 88: $aq="SELECT alertid,alertlevel,openedx FROM fnalert WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND closedx=0 LIMIT 0,1";
 89: //echo $aq;
 90: $ar=$NATS->DB->Query($aq);
 91: echo "<tr><td align=right>
 92: Alert 
 93: :</td><td align=left>";
 94: if ($arow=$NATS->DB->Fetch_Array($ar))
 95: 	{
 96: 	echo "<a href=history.alert.php?nodeid=".$_REQUEST['nodeid']."><b class=\"al".$arow['alertlevel']."\">Yes - ".oText($arow['alertlevel'])."</b></a> ";
 97: 	echo "(Opened ".dtago($arow['openedx']).")";
 98: 	}
 99: else echo "<b>No</b> [ <a href=history.alert.php?nodeid=".$_REQUEST['nodeid'].">Alert History</a> ]";
100: echo "</td></tr>";
101: 
102: if ($NATS_Session->userlevel>4) echo "<tr><td align=right>Edit :</td><td align=left><a href=node.edit.php?nodeid=".$_REQUEST['nodeid'].">Edit Node Options</a></td></tr>";
103: 
104: echo "<tr><td align=right>Summary :</td><td align=left>";
105: $finishx=time();
106: $startx=$finishx-(60*60*24);
107: echo "<a href=summary.test.php?nodeid=".$_REQUEST['nodeid']."&startx=".$startx."&finishx=".$finishx.">Last 24hrs</a> | ";
108: echo "<a href=summary.test.php?nodeid=".$_REQUEST['nodeid'].">Today</a>";
109: echo "</td></tr>";
110: 
111: echo "</table>";
112: 
113: echo "</td><td style=\"width: 50px;\">&nbsp;</td><td align=left valign=top>";
114: np_tiny($_REQUEST['nodeid']);
115: echo "</td></tr></table>";
116: 
117: echo "<br><br>";
118: 
119: echo "<b class=\"subtitle\">Local Tests</b><br><br>";
120: 
121: echo "<table class=\"nicetable\">";
122: 
123: $q="SELECT * FROM fnlocaltest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" ORDER BY localtestid ASC";
124: $r=$NATS->DB->Query($q);
125: while ($row=$NATS->DB->Fetch_Array($r))
126: 	{
127: 	echo "<tr><td>";
128: 	
129: 	if ($row['testname']=="")
130: 		{
131: 		if (strlen($row['testparam'])>10) $tp=substr($row['testparam'],0,8)."..";
132: 		else $tp=$row['testparam'];
133: 		echo lText($row['testtype']);
134: 		if ($tp!="") echo " (".$tp.")";
135: 		}
136: 	else echo $row['testname'];
137: 	echo "</td>";
138: 
139: 	echo "<td><b class=\"al".$row['alertlevel']."\">".oText($row['alertlevel'])."</b></td>";
140: 	
141: 	echo "<td>(".dtago($row['lastrunx']).")</td>";
142: 	
143: 	echo "<td>";
144: 	if (($row['testrecord']==1)||($row['testtype']=="ICMP")) 
145: 		echo "[ <a href=\"history.test.php?testid=L".$row['localtestid']."\">History</a> ]";
146: 	else echo "&nbsp;";
147: 	echo "</td>";
148: 	
149: 	echo "</tr>";
150: 	}
151: 
152: echo "</table>";
153: echo "<br><br>";
154: if ($node['nsenabled']==1)
155: 	{
156: 	echo "<b class=\"subtitle\">Nodeside Tests</b><br><br>";
157: 	
158: 	echo "<table class=\"nicetable\">";
159: 	
160: 	$q="SELECT * FROM fnnstest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND testenabled=1";
161: 	$r=$NATS->DB->Query($q);
162: 	while ($row=$NATS->DB->Fetch_Array($r))
163: 		{
164: 		echo "<tr><td>";
165: 		
166: 		if ($row['testname']=="")
167: 			{
168: 			echo $row['testtype'];
169: 			}
170: 		else echo $row['testname'];
171: 		echo "</td>";
172: 	
173: 		echo "<td><b class=\"al".$row['alertlevel']."\">".oText($row['alertlevel'])."</b></td>";
174: 		
175: 		echo "<td>(".dtago($row['lastrunx']).")</td>";
176: 		
177: 		echo "<td>";
178: 		if (($row['testrecord']==1)) 
179: 			echo "[ <a href=\"history.test.php?testid=N".$row['nstestid']."\">History</a> ]";
180: 		else echo "&nbsp;";
181: 		echo "</td>";
182: 		
183: 		echo "</tr>";
184: 		}
185: 	
186: 	echo "</table>";
187: 	}
188: ?>
189: 
190: 
191: <?php
192: Screen_Footer();
193: ?>
194: