File: 1.19.1b/server/web/node.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008-2017 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: $p = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=="on" ? "https" : "http"; 29: $url = $p."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 30: header("Location: ./?login_msg=Invalid+Or+Expired+Session&url=".urlencode($url)); 31: exit(); 32: } 33: if ($NATS_Session->userlevel<1) UL_Error($NATS->Lang->Item("viewing.node")); 34: 35: if (!$NATS->isUserAllowedNode($NATS_Session->username,$_REQUEST['nodeid'])) 36: UL_Error($NATS->Lang->Item("viewing.node")); 37: 38: ob_end_flush(); 39: Screen_Header($NATS->Lang->Item("viewing.node")." ".$_REQUEST['nodeid'],1); 40: ?> 41:
42: 43: //echo "Node: ".$_REQUEST['nodeid']."

";
44: 45: echo "
"; 46: 47: $q="SELECT * FROM fnnode WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" LIMIT 0,1"; 48: $r=$NATS->DB->Query($q); 49: if (!$row=$NATS->DB->Fetch_Array($r)) 50: { 51: echo $NATS->Lang->Item("no.node")."

";
52: Screen_Footer(); 53: exit(); 54: } 55: $NATS->DB->Free($r); 56: $node=$row; 57: 58: echo ""; 59: 60: echo ""; 65: 66: echo ""; 73: 74: echo ""; 79: 80: echo ""; 85: 86: echo ""; 93: 94: $aq="SELECT alertid,alertlevel,openedx FROM fnalert WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND closedx=0 LIMIT 0,1"; 95: //echo $aq; 96: $ar=$NATS->DB->Query($aq); 97: echo ""; 107: 108: if ($NATS_Session->userlevel>4) echo ""; 109: echo ""; 110: 111: echo ""; 117: 118: // Utility Links 119: //if ($NATS->Cfg->Get("dev.links",0)==1) 120: //{ 121: $shown_header=false; 122: for ($a=0; $a<3; $a++) 123: { 124: $ulink="ulink".$a; 125: $utitle=$ulink."_title"; 126: $uurl=$ulink."_url"; 127: if ($row[$ulink]==1) 128: { // link is enabled 129: if (!$shown_header) // first one 130: { 131: echo ""; // if shown any 144: //} 145: 146: echo "
"; 61: echo $NATS->Lang->Item("node.name"); 62: echo " :"; 63: echo $row['nodename']; 64: echo "
"; 67: echo $NATS->Lang->Item("status"); 68: echo " :"; 69: echo ""; 70: echo oText($row['alertlevel']); 71: echo ""; 72: echo "
"; 75: echo $NATS->Lang->Item("hostname"); 76: echo ": "; 77: echo $row['hostname']; 78: echo " 
"; 81: echo $NATS->Lang->Item("description"); 82: echo " :"; 83: echo $row['nodedesc']; 84: echo " 
"; 87: echo $NATS->Lang->Item("enabled"); 88: echo ": "; 89: if ($row['nodeenabled']==1) $s=$NATS->Lang->Item("yes"); 90: else $s=$NATS->Lang->Item("no"); 91: echo $s; 92: echo "
98: Alert 99: :"; 100: if ($arow=$NATS->DB->Fetch_Array($ar)) 101: { 102: echo "".$NATS->Lang->Item("yes")." - ".oText($arow['alertlevel'])." "; 103: echo "(".$NATS->Lang->Item("opened")." ".dtago($arow['openedx']).")"; 104: } 105: else echo "".$NATS->Lang->Item("no")." [ ".$NATS->Lang->Item("alert.history")." ]"; 106: echo "
".$NATS->Lang->Item("edit")." :".$NATS->Lang->Item("edit.node.options")."
".$NATS->Lang->Item("summary")." :"; 112: $finishx=time(); 113: $startx=$finishx-(60*60*24); 114: echo "".$NATS->Lang->Item("last.24h")." | "; 115: echo "".$NATS->Lang->Item("today").""; 116: echo "
".$NATS->Lang->Item("links")." :"; 132: $shown_header=true; 133: } 134: $url=$row[$uurl]; 135: $url=str_replace("{HOSTNAME}",$row['hostname'],$url); 136: $url=str_replace("{NODENAME}",$row['nodename'],$url); 137: $url=str_replace("{NODEID}",$row['nodeid'],$url); 138: if ($NATS->Cfg->Get("site.links.newwindow",0)==1) $tgt=" target=\"top\""; 139: else $tgt=""; 140: echo "".$row[$utitle]." "; 141: } 142: } 143: if ($shown_header) echo "
";
147: 148: echo "
 "; 149: np_tiny($_REQUEST['nodeid']); 150: echo "
";
151: 152: echo "

";
153: 154: echo "".$NATS->Lang->Item("local.tests")."

";
155: 156: echo ""; 157: 158: $q="SELECT * FROM fnlocaltest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" ORDER BY localtestid ASC"; 159: $r=$NATS->DB->Query($q); 160: while ($row=$NATS->DB->Fetch_Array($r)) 161: { 162: echo ""; 173: 174: echo ""; 175: 176: echo ""; 177: 178: echo ""; 183: 184: echo ""; 185: } 186: 187: echo "
"; 163: 164: if ($row['testname']=="") 165: { 166: if (strlen($row['testparam'])>10) $tp=substr($row['testparam'],0,8).".."; 167: else $tp=$row['testparam']; 168: echo lText($row['testtype']); 169: if ($tp!="") echo " (".$tp.")"; 170: } 171: else echo $row['testname']; 172: echo "".oText($row['alertlevel'])."(".dtago($row['lastrunx']).")"; 179: if (($row['testrecord']==1)||($row['testtype']=="ICMP")) 180: echo "[ ".$NATS->Lang->Item("history")." ]"; 181: else echo " "; 182: echo "
";
188: echo "

";
189: if ($node['nsenabled']==1) 190: { 191: echo "".$NATS->Lang->Item("nodeside.tests")."

";
192: 193: echo ""; 194: 195: $q="SELECT * FROM fnnstest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND testenabled=1 ORDER BY testtype"; 196: $r=$NATS->DB->Query($q); 197: while ($row=$NATS->DB->Fetch_Array($r)) 198: { 199: echo ""; 207: 208: echo ""; 209: 210: echo ""; 211: 212: echo ""; 217: 218: echo ""; 219: } 220: 221: echo "
"; 200: 201: if ($row['testname']=="") 202: { 203: echo $row['testdesc']; 204: } 205: else echo $row['testname']; 206: echo "".oText($row['alertlevel'])."(".dtago($row['lastrunx']).")"; 213: if (($row['testrecord']==1)) 214: echo "[ ".$NATS->Lang->Item("history")." ]"; 215: else echo " "; 216: echo "
";
222: } 223: ?> 224: 225: 226: 227: Screen_Footer(); 228: ?> 229: