Viewing File server/web/monitor.php of 1.17.5a
|
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: 27: // Timeskip check - means this page skips timecheck/reset if site.monitor.keepalive is 0 28: if ($NATS->Cfg->Get("site.monitor.keepalive",1)==0) $timeskip=true; 29: else $timeskip=false; 30: 31: if (!$NATS_Session->Check($NATS->DB,$timeskip)) 32: { 33: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 34: exit(); 35: } 36: if ($NATS_Session->userlevel<1) UL_Error($NATS->Lang->Item("live.monitor")); 37: 38: if (isset($_REQUEST['style'])) 39: { 40: $style=$_REQUEST['style']; 41: setcookie("fn_monitorstyle",$style); 42: } 43: else if (isset($_COOKIE['fn_monitorstyle'])) 44: { 45: $style=$_COOKIE['fn_monitorstyle']; 46: } 47: else $style="standard"; 48: 49: if ($style=="") $style="standard"; 50: 51: Screen_Header($NATS->Lang->Item("live.monitor"),1,1,"<meta http-equiv=\"refresh\" content=\"60\">"); 52: ?> 53: <br> 54: 55: <div class="monitorviews" id="monitorviews_div"> 56: <a href="javascript:showMonitorViews()"><?php echo $NATS->Lang->Item("mon.options"); ?></a> 57: </div> 58: 59: <?php 60: /* 61: echo "<style type=\"text/css\">\n"; 62: include("css/monitor.css"); 63: echo "\n</style>\n"; 64: */ 65: ?> 66: <link rel="stylesheet" type="text/css" href="css/monitor.css" /> 67: <?php 68: if ($NATS->Cfg->Get("site.monitor.popup",1)==0) $monpopup=false; 69: else $monpopup=true; 70: 71: if ($monpopup) 72: { 73: echo "<div class=\"monitor_popup\" id=\"popup_div\"></div>"; 74: echo "<script type=\"text/javascript\" src=\"js/monitor.popup.js\">\n"; 75: echo "</script>\n"; 76: } 77: ?> 78: 79: <script type="text/javascript"> 80: var dispOptions=new Array(); 81: var dispLink=new Array(); 82: 83: var optCount=0; 84: dispOptions[optCount]='standard'; 85: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.std"); ?>'; 86: dispOptions[optCount]='groups'; 87: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.grp"); ?>'; 88: dispOptions[optCount]='nodes'; 89: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.nodes"); ?>'; 90: dispOptions[optCount]='alerting'; 91: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.alerting"); ?>'; 92: 93: function showMonitorViews() 94: { 95: var content=''; 96: for (var a=0; a<optCount; a++) 97: { 98: content=content+'<a href=monitor.php?style='+dispOptions[a]+'>'; 99: content=content+'<img src=images/monitor_thumb/'+dispOptions[a]+'.png border=0><br>'+dispLink[a]+'</a><br><br>'; 100: } 101: content=content+'<a href="javascript:hideMonitorViews()"><?php echo $NATS->Lang->Item("mon.hide"); ?></a>'; 102: document.getElementById('monitorviews_div').innerHTML=content; 103: } 104: 105: function hideMonitorViews() 106: { 107: document.getElementById('monitorviews_div').innerHTML='<a href="javascript:showMonitorViews()"><?php echo $NATS->Lang->Item("mon.options"); ?></a>'; 108: } 109: 110: <?php 111: if (isset($_REQUEST['showviewoption'])) echo "showMonitorViews();\n"; 112: ?> 113: </script> 114: 115: <?php 116: 117: 118: ob_end_flush(); 119: 120: if ($style=="standard") 121: { 122: 123: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 124: $r=$NATS->DB->Query($q); 125: 126: if ($NATS->DB->Num_Rows($r)>0) 127: { 128: echo "<table border=0>"; 129: $a=0; 130: while ($row=$NATS->DB->Fetch_Array($r)) 131: { 132: if ($NATS->isUserAllowedGroup($NATS_Session->username,$row['groupid'])) 133: { 134: if ($a==0) echo "<tr>"; 135: echo "<td>"; 136: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 137: echo "</td>"; 138: $a++; 139: if ($a==2) 140: { 141: $a=0; 142: echo "</tr>"; 143: } 144: } 145: } 146: if ($a>0) echo "</tr>"; 147: echo "</table>"; 148: echo "<br><br>"; 149: } 150: 151: 152: $NATS->DB->Free($r); 153: 154: 155: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 156: $r=$NATS->DB->Query($q); 157: 158: echo "<table border=0>"; 159: $a=0; 160: while ($row=$NATS->DB->Fetch_Array($r)) 161: { 162: if ($NATS->isUserAllowedNode($NATS_Session->username,$row['nodeid'])) 163: { 164: if ($a==0) echo "<tr>"; 165: echo "<td>"; 166: np_tiny($row['nodeid'],true,$row['nodename'],$monpopup); 167: echo "</td>"; 168: $a++; 169: if ($a==5) 170: { 171: $a=0; 172: echo "</tr>"; 173: } 174: } 175: } 176: if ($a>0) echo "</tr>"; 177: echo "</table>"; 178: $NATS->DB->Free($r); 179: } 180: 181: else if ($style=="alerting") 182: { 183: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 184: $r=$NATS->DB->Query($q); 185: 186: echo "<table border=0>"; 187: $a=0; 188: while ($row=$NATS->DB->Fetch_Array($r)) 189: { 190: if ($NATS->GroupAlertLevel($row['groupid'])>0 && $NATS->isUserAllowedGroup($NATS_Session->username,$row['groupid'])) 191: { 192: if ($a==0) echo "<tr>"; 193: echo "<td>"; 194: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 195: echo "</td>"; 196: $a++; 197: if ($a==2) 198: { 199: $a=0; 200: echo "</tr>"; 201: } 202: } 203: } 204: if ($a>0) echo "</tr>"; 205: echo "</table>"; 206: 207: 208: $NATS->DB->Free($r); 209: 210: echo "<br><br>"; 211: 212: $q="SELECT * FROM fnnode WHERE alertlevel!=0 ORDER BY alertlevel DESC, weight ASC"; 213: $r=$NATS->DB->Query($q); 214: 215: echo "<table border=0>"; 216: $a=0; 217: while ($row=$NATS->DB->Fetch_Array($r)) 218: { 219: if ($NATS->isUserAllowedNode($NATS_Session->username,$row['nodeid'])) 220: { 221: if ($a==0) echo "<tr>"; 222: echo "<td>"; 223: np_tiny($row['nodeid'],true,$row['nodename'],$monpopup); 224: echo "</td>"; 225: $a++; 226: if ($a==5) 227: { 228: $a=0; 229: echo "</tr>"; 230: } 231: } 232: } 233: if ($a>0) echo "</tr>"; 234: echo "</table>"; 235: $NATS->DB->Free($r); 236: } 237: 238: else if ($style=="groups") 239: { 240: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 241: $r=$NATS->DB->Query($q); 242: 243: echo "<table border=0>"; 244: $a=0; 245: while ($row=$NATS->DB->Fetch_Array($r)) 246: { 247: if ($NATS->isUserAllowedGroup($NATS_Session->username,$row['groupid'])) 248: { 249: if ($a==0) echo "<tr>"; 250: echo "<td>"; 251: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon'],$monpopup); 252: echo "</td>"; 253: $a++; 254: if ($a==2) 255: { 256: $a=0; 257: echo "</tr>"; 258: } 259: } 260: } 261: if ($a>0) echo "</tr>"; 262: echo "</table>"; 263: 264: 265: $NATS->DB->Free($r); 266: } 267: 268: else if ($style=="nodes") 269: { 270: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 271: $r=$NATS->DB->Query($q); 272: 273: echo "<table border=0>"; 274: $a=0; 275: while ($row=$NATS->DB->Fetch_Array($r)) 276: { 277: if ($NATS->isUserAllowedNode($NATS_Session->username,$row['nodeid'])) 278: { 279: if ($a==0) echo "<tr>"; 280: echo "<td>"; 281: np_big($row['nodeid'],$row['nodename'],$row['nodedesc'],$row['nodeicon'],$monpopup); 282: echo "</td>"; 283: $a++; 284: if ($a==2) 285: { 286: $a=0; 287: echo "</tr>"; 288: } 289: } 290: } 291: if ($a>0) echo "</tr>"; 292: echo "</table>"; 293: 294: 295: $NATS->DB->Free($r); 296: } 297: 298: else 299: { 300: echo "<b>Sorry - unknown display style type</b><br><br>"; 301: } 302: 303: mt_srand(microtime()*1000000); 304: if (mt_rand(0,100)==50) $track_if_enabled=true; 305: else $track_if_enabled=false; 306: 307: Screen_Footer($track_if_enabled); 308: ?> 309: