File: 1.12.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-2010 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($NATS->Lang->Item("viewing.node"));
 32: ob_end_flush();
 33: Screen_Header($NATS->Lang->Item("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 $NATS->Lang->Item("no.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: echo $NATS->Lang->Item("node.name");
 56: echo " :</td><td align=left>";
 57: echo $row['nodename'];
 58: echo "</td></tr>";
 59: 
 60: echo "<tr><td align=right>";
 61: echo $NATS->Lang->Item("status");
 62: echo " :</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: echo $NATS->Lang->Item("hostname");
 70: echo ": </td><td align=left>";
 71: echo $row['hostname'];
 72: echo "&nbsp;</td></tr>";
 73: 
 74: echo "<tr><td align=right>";
 75: echo $NATS->Lang->Item("description");
 76: echo " :</td><td align=left>";
 77: echo $row['nodedesc'];
 78: echo "&nbsp;</td></tr>";
 79: 
 80: echo "<tr><td align=right>";
 81: echo $NATS->Lang->Item("enabled");
 82: echo ": </td><td align=left>";
 83: if ($row['nodeenabled']==1) $s=$NATS->Lang->Item("yes");
 84: else $s=$NATS->Lang->Item("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']."\">".$NATS->Lang->Item("yes")." - ".oText($arow['alertlevel'])."</b></a> ";
 97: 	echo "(".$NATS->Lang->Item("opened")." ".dtago($arow['openedx']).")";
 98: 	}
 99: else echo "<b>".$NATS->Lang->Item("no")."</b> [ <a href=history.alert.php?nodeid=".$_REQUEST['nodeid'].">".$NATS->Lang->Item("alert.history")."</a> ]";
100: echo "</td></tr>";
101: 
102: if ($NATS_Session->userlevel>4) echo "<tr><td align=right>".$NATS->Lang->Item("edit")." :</td>";
103: echo "<td align=left><a href=node.edit.php?nodeid=".$_REQUEST['nodeid'].">".$NATS->Lang->Item("edit.node.options")."</a></td></tr>";
104: 
105: echo "<tr><td align=right>".$NATS->Lang->Item("summary")." :</td><td align=left>";
106: $finishx=time();
107: $startx=$finishx-(60*60*24);
108: echo "<a href=summary.test.php?nodeid=".$_REQUEST['nodeid']."&startx=".$startx."&finishx=".$finishx.">".$NATS->Lang->Item("last.24h")."</a> | ";
109: echo "<a href=summary.test.php?nodeid=".$_REQUEST['nodeid'].">".$NATS->Lang->Item("today")."</a>";
110: echo "</td></tr>";
111: 
112: // Utility Links
113: //if ($NATS->Cfg->Get("dev.links",0)==1)
114: //{
115: $shown_header=false;
116: for ($a=0; $a<3; $a++)
117: 	{
118: 	$ulink="ulink".$a;
119: 	$utitle=$ulink."_title";
120: 	$uurl=$ulink."_url";
121: 	if ($row[$ulink]==1)
122: 		{ // link is enabled
123: 		if (!$shown_header) // first one
124: 			{
125: 			echo "<tr><td align=right>".$NATS->Lang->Item("links")." :</td><td align=left>";
126: 			$shown_header=true;
127: 			}
128: 		$url=$row[$uurl];
129: 		$url=str_replace("{HOSTNAME}",$row['hostname'],$url);
130: 		$url=str_replace("{NODENAME}",$row['nodename'],$url);
131: 		$url=str_replace("{NODEID}",$row['nodeid'],$url);
132: 		if ($NATS->Cfg->Get("site.links.newwindow",0)==1) $tgt=" target=\"top\"";
133: 		else $tgt="";
134: 		echo "<a href=\"".$url."\"".$tgt.">".$row[$utitle]."</a> ";
135: 		}
136: 	}
137: if ($shown_header) echo "</td></tr>"; // if shown any
138: //}
139: 
140: echo "</table>";
141: 
142: echo "</td><td style=\"width: 50px;\">&nbsp;</td><td align=left valign=top>";
143: np_tiny($_REQUEST['nodeid']);
144: echo "</td></tr></table>";
145: 
146: echo "<br><br>";
147: 
148: echo "<b class=\"subtitle\">".$NATS->Lang->Item("local.tests")."</b><br><br>";
149: 
150: echo "<table class=\"nicetable\">";
151: 
152: $q="SELECT * FROM fnlocaltest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" ORDER BY localtestid ASC";
153: $r=$NATS->DB->Query($q);
154: while ($row=$NATS->DB->Fetch_Array($r))
155: 	{
156: 	echo "<tr><td>";
157: 	
158: 	if ($row['testname']=="")
159: 		{
160: 		if (strlen($row['testparam'])>10) $tp=substr($row['testparam'],0,8)."..";
161: 		else $tp=$row['testparam'];
162: 		echo lText($row['testtype']);
163: 		if ($tp!="") echo " (".$tp.")";
164: 		}
165: 	else echo $row['testname'];
166: 	echo "</td>";
167: 
168: 	echo "<td><b class=\"al".$row['alertlevel']."\">".oText($row['alertlevel'])."</b></td>";
169: 	
170: 	echo "<td>(".dtago($row['lastrunx']).")</td>";
171: 	
172: 	echo "<td>";
173: 	if (($row['testrecord']==1)||($row['testtype']=="ICMP")) 
174: 		echo "[ <a href=\"history.test.php?testid=L".$row['localtestid']."\">".$NATS->Lang->Item("history")."</a> ]";
175: 	else echo "&nbsp;";
176: 	echo "</td>";
177: 	
178: 	echo "</tr>";
179: 	}
180: 
181: echo "</table>";
182: echo "<br><br>";
183: if ($node['nsenabled']==1)
184: 	{
185: 	echo "<b class=\"subtitle\">".$NATS->Lang->Item("nodeside.tests")."</b><br><br>";
186: 	
187: 	echo "<table class=\"nicetable\">";
188: 	
189: 	$q="SELECT * FROM fnnstest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND testenabled=1 ORDER BY testtype";
190: 	$r=$NATS->DB->Query($q);
191: 	while ($row=$NATS->DB->Fetch_Array($r))
192: 		{
193: 		echo "<tr><td>";
194: 		
195: 		if ($row['testname']=="")
196: 			{
197: 			echo $row['testdesc'];
198: 			}
199: 		else echo $row['testname'];
200: 		echo "</td>";
201: 	
202: 		echo "<td><b class=\"al".$row['alertlevel']."\">".oText($row['alertlevel'])."</b></td>";
203: 		
204: 		echo "<td>(".dtago($row['lastrunx']).")</td>";
205: 		
206: 		echo "<td>";
207: 		if (($row['testrecord']==1)) 
208: 			echo "[ <a href=\"history.test.php?testid=N".$row['nstestid']."\">".$NATS->Lang->Item("history")."</a> ]";
209: 		else echo "&nbsp;";
210: 		echo "</td>";
211: 		
212: 		echo "</tr>";
213: 		}
214: 	
215: 	echo "</table>";
216: 	}
217: ?>
218: 
219: 
220: <?php
221: Screen_Footer();
222: ?>
223: