File: 1.09.2b/server/web/node.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 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:
36: 37: //echo "Node: ".$_REQUEST['nodeid']."

";
38: 39: echo "
"; 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.

";
46: Screen_Footer(); 47: exit(); 48: } 49: $NATS->DB->Free($r); 50: $node=$row; 51: 52: echo ""; 53: 54: echo ""; 59: 60: echo ""; 67: 68: echo ""; 73: 74: echo ""; 79: 80: echo ""; 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 ""; 101: 102: if ($NATS_Session->userlevel>4) echo ""; 103: 104: echo ""; 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 ""; // if shown any 137: //} 138: 139: echo "
55: Node Name 56: :"; 57: echo $row['nodename']; 58: echo "
61: Status 62: :"; 63: echo ""; 64: echo oText($row['alertlevel']); 65: echo ""; 66: echo "
69: Hostname 70: :"; 71: echo $row['hostname']; 72: echo " 
75: Description 76: :"; 77: echo $row['nodedesc']; 78: echo " 
81: Enabled 82: :"; 83: if ($row['nodeenabled']==1) $s="Yes"; 84: else $s="No"; 85: echo $s; 86: echo "
92: Alert 93: :"; 94: if ($arow=$NATS->DB->Fetch_Array($ar)) 95: { 96: echo "Yes - ".oText($arow['alertlevel'])." "; 97: echo "(Opened ".dtago($arow['openedx']).")"; 98: } 99: else echo "No [ Alert History ]"; 100: echo "
Edit :Edit Node Options
Summary :"; 105: $finishx=time(); 106: $startx=$finishx-(60*60*24); 107: echo "Last 24hrs | "; 108: echo "Today"; 109: echo "
Links :"; 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 "".$row[$utitle]." "; 134: } 135: } 136: if ($shown_header) echo "
";
140: 141: echo "
 "; 142: np_tiny($_REQUEST['nodeid']); 143: echo "
";
144: 145: echo "

";
146: 147: echo "Local Tests

";
148: 149: echo ""; 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 ""; 166: 167: echo ""; 168: 169: echo ""; 170: 171: echo ""; 176: 177: echo ""; 178: } 179: 180: echo "
"; 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 "".oText($row['alertlevel'])."(".dtago($row['lastrunx']).")"; 172: if (($row['testrecord']==1)||($row['testtype']=="ICMP")) 173: echo "[ History ]"; 174: else echo " "; 175: echo "
";
181: echo "

";
182: if ($node['nsenabled']==1) 183: { 184: echo "Nodeside Tests

";
185: 186: echo ""; 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 ""; 200: 201: echo ""; 202: 203: echo ""; 204: 205: echo ""; 210: 211: echo ""; 212: } 213: 214: echo "
"; 193: 194: if ($row['testname']=="") 195: { 196: echo $row['testdesc']; 197: } 198: else echo $row['testname']; 199: echo "".oText($row['alertlevel'])."(".dtago($row['lastrunx']).")"; 206: if (($row['testrecord']==1)) 207: echo "[ History ]"; 208: else echo " "; 209: echo "
";
215: } 216: ?> 217: 218: 219: 220: Screen_Footer(); 221: ?> 222: