File: 1.09.0a/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: // Utility Links
112: //if ($NATS->Cfg->Get("dev.links",0)==1)
113: //{
114: $shown_header=false;
115: for ($a=0; $a<3; $a++)
116: 	{
117: 	$ulink="ulink".$a;
118: 	$utitle=$ulink."_title";
119: 	$uurl=$ulink."_url";
120: 	if ($row[$ulink]==1)
121: 		{ // link is enabled
122: 		if (!$shown_header) // first one
123: 			{
124: 			echo "<tr><td align=right>Links :</td><td align=left>";
125: 			$shown_header=true;
126: 			}
127: 		$url=$row[$uurl];
128: 		$url=str_replace("{HOSTNAME}",$row['hostname'],$url);
129: 		$url=str_replace("{NODENAME}",$row['nodename'],$url);
130: 		$url=str_replace("{NODEID}",$row['nodeid'],$url);
131: 		if ($NATS->Cfg->Get("site.links.newwindow",0)==1) $tgt=" target=\"top\"";
132: 		else $tgt="";
133: 		echo "<a href=\"".$url."\"".$tgt.">".$row[$utitle]."</a> ";
134: 		}
135: 	}
136: if ($shown_header) echo "</td></tr>"; // if shown any
137: //}
138: 
139: echo "</table>";
140: 
141: echo "</td><td style=\"width: 50px;\">&nbsp;</td><td align=left valign=top>";
142: np_tiny($_REQUEST['nodeid']);
143: echo "</td></tr></table>";
144: 
145: echo "<br><br>";
146: 
147: echo "<b class=\"subtitle\">Local Tests</b><br><br>";
148: 
149: echo "<table class=\"nicetable\">";
150: 
151: $q="SELECT * FROM fnlocaltest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" ORDER BY localtestid ASC";
152: $r=$NATS->DB->Query($q);
153: while ($row=$NATS->DB->Fetch_Array($r))
154: 	{
155: 	echo "<tr><td>";
156: 	
157: 	if ($row['testname']=="")
158: 		{
159: 		if (strlen($row['testparam'])>10) $tp=substr($row['testparam'],0,8)."..";
160: 		else $tp=$row['testparam'];
161: 		echo lText($row['testtype']);
162: 		if ($tp!="") echo " (".$tp.")";
163: 		}
164: 	else echo $row['testname'];
165: 	echo "</td>";
166: 
167: 	echo "<td><b class=\"al".$row['alertlevel']."\">".oText($row['alertlevel'])."</b></td>";
168: 	
169: 	echo "<td>(".dtago($row['lastrunx']).")</td>";
170: 	
171: 	echo "<td>";
172: 	if (($row['testrecord']==1)||($row['testtype']=="ICMP")) 
173: 		echo "[ <a href=\"history.test.php?testid=L".$row['localtestid']."\">History</a> ]";
174: 	else echo "&nbsp;";
175: 	echo "</td>";
176: 	
177: 	echo "</tr>";
178: 	}
179: 
180: echo "</table>";
181: echo "<br><br>";
182: if ($node['nsenabled']==1)
183: 	{
184: 	echo "<b class=\"subtitle\">Nodeside Tests</b><br><br>";
185: 	
186: 	echo "<table class=\"nicetable\">";
187: 	
188: 	$q="SELECT * FROM fnnstest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND testenabled=1 ORDER BY testtype";
189: 	$r=$NATS->DB->Query($q);
190: 	while ($row=$NATS->DB->Fetch_Array($r))
191: 		{
192: 		echo "<tr><td>";
193: 		
194: 		if ($row['testname']=="")
195: 			{
196: 			echo $row['testdesc'];
197: 			}
198: 		else echo $row['testname'];
199: 		echo "</td>";
200: 	
201: 		echo "<td><b class=\"al".$row['alertlevel']."\">".oText($row['alertlevel'])."</b></td>";
202: 		
203: 		echo "<td>(".dtago($row['lastrunx']).")</td>";
204: 		
205: 		echo "<td>";
206: 		if (($row['testrecord']==1)) 
207: 			echo "[ <a href=\"history.test.php?testid=N".$row['nstestid']."\">History</a> ]";
208: 		else echo "&nbsp;";
209: 		echo "</td>";
210: 		
211: 		echo "</tr>";
212: 		}
213: 	
214: 	echo "</table>";
215: 	}
216: ?>
217: 
218: 
219: <?php
220: Screen_Footer();
221: ?>
222: