File: 0.04.16a/server/web/view.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: $session=true; 27: if (!$NATS_Session->Check($NATS->DB)) 28: { 29: $session=false; 30: } 31: 32: $abs=GetAbsolute(); 33: 34: if (isset($_REQUEST['mode'])) $mode=$_REQUEST['mode']; 35: else $mode=""; 36: 37: $items=array(); // items 38: $ob=array(); // output buffer 39: 40: function show_output() 41: { 42: global $ob,$view,$mode; 43: foreach($ob as $oline) 44: { 45: echo $oline."
";
46: } 47: ob_end_flush(); 48: exit(); 49: } 50: 51: $q="SELECT * FROM fnview WHERE viewid=".ss($_REQUEST['viewid']); 52: $r=$NATS->DB->Query($q); 53: if ($NATS->DB->Num_Rows($r)<=0) 54: { 55: $ob[]="Invalid View ".$_REQUEST['viewid']; 56: show_output(); 57: } 58: $view=$NATS->DB->Fetch_Array($r); 59: if ($view['vpublic']!=1) // requires auth 60: { 61: if (!$session) 62: { 63: $ob[]="Sorry not a public view"; 64: show_output(); 65: } 66: } 67: 68: if ($view['vcolon']>0) $colon=":"; 69: else $colon=""; 70: if ($view['vdashes']>0) $dash=" -"; 71: else $dash=""; 72: if ($view['vtimeago']>0) $ago=true; 73: else $ago=false; 74: 75: function vdt($dt) 76: { 77: global $ago; 78: if ($ago) return dtago($dt); 79: return nicedt($dt); 80: } 81: 82: function ViewNode($nodeid,$detail=true) 83: { 84: global $NATS; 85: $ret=array(); 86: $q="SELECT * FROM fnnode WHERE nodeid=\"".ss($nodeid)."\""; 87: $r=$NATS->DB->Query($q); 88: if ($NATS->DB->Num_Rows($r)<=0) return $ret; 89: $row=$NATS->DB->Fetch_Array($r); 90: if ($row['nodename']!="") $ret['name']=$row['nodename']; 91: else $ret['name']=$nodeid; 92: $ret['item']=$ret['name']; 93: $ret['nodeid']=$nodeid; 94: $ret['status']=$row['alertlevel']; 95: $ret['link']="node.php?nodeid=".$nodeid; 96: $NATS->DB->Free($r); 97: 98: $ret['detail']=array(); 99: 100: if ($detail) 101: { 102: // get detail 103: $q="SELECT testtype,testparam,testname,alertlevel FROM fnlocaltest WHERE nodeid=\"".ss($nodeid)."\" ORDER BY alertlevel DESC"; 104: $r=$NATS->DB->Query($q); 105: $a=0; 106: while ($row=$NATS->DB->Fetch_Array($r)) 107: { 108: $an=$row['testtype']; 109: if ($row['testparam']!="") $an.=" (".$row['testparam'].")"; 110: if ($row['testname']=="") $nn=$an; // textify! 111: else $nn=$row['testname']; 112: $ret['detail'][$a]['item']=$nn; 113: $ret['detail'][$a]['status']=$row['alertlevel']; 114: $ret['detail'][$a]['link']=$ret['link']; 115: $a++; 116: } 117: $NATS->DB->Free($r); 118: } 119: return $ret; 120: } 121: 122: function ViewGroup($groupid,$detail=true) 123: { 124: global $NATS; 125: $ret=array(); 126: // Get Group Info 127: $ret['status']=$NATS->GroupAlertLevel($groupid); 128: $gq="SELECT * FROM fngroup WHERE groupid=".ss($groupid)." LIMIT 0,1"; 129: $gr=$NATS->DB->Query($gq); 130: $grow=$NATS->DB->Fetch_Array($gr); 131: $NATS->DB->Free($gr); 132: $ret['name']=$grow['groupname']; 133: $ret['desc']=$grow['groupdesc']; 134: $ret['icon']=$grow['groupicon']; 135: $ret['link']="group.php?groupid=".$groupid; 136: 137: // Node Detail 138: if ($detail) 139: { 140: $ret['detail']=array(); 141: $a=0; 142: $lq="SELECT nodeid FROM fngrouplink WHERE groupid=".ss($groupid); 143: $lr=$NATS->DB->Query($lq); 144: while ($link=$NATS->DB->Fetch_Array($lr)) 145: { 146: $nq="SELECT nodename,alertlevel FROM fnnode WHERE nodeid=\"".$link['nodeid']."\" AND nodeenabled=1 ORDER BY alertlevel DESC, weight ASC"; 147: //$nq="SELECT nodename,alertlevel FROM fnnode"; 148: $nq.=" LIMIT 0,1"; 149: $nr=$NATS->DB->Query($nq); 150: $node=$NATS->DB->Fetch_Array($nr); 151: $ret['detail'][$a]['nodeid']=$link['nodeid']; 152: $ret['detail'][$a]['nodename']=$node['nodename']; 153: $ret['detail'][$a]['status']=$node['alertlevel']; 154: $ret['detail'][$a]['link']="node.php?nodeid=".$link['nodeid']; 155: $a++; 156: $NATS->DB->Free($nr); 157: } 158: $NATS->DB->Free($lr); 159: } 160: 161: return $ret; 162: } 163: 164: $q="SELECT * FROM fnviewitem WHERE viewid=".ss($_REQUEST['viewid'])." ORDER BY iweight ASC"; 165: $r=$NATS->DB->Query($q); 166: while ($row=$NATS->DB->Fetch_Array($r)) 167: { 168: $id=$row['viewitemid']; 169: $items[$id]=$row; 170: // get name (varying), status and detail dependent... 171: switch ($row['itype']) 172: { 173: case "node": 174: $items[$id]['data']=ViewNode($row['ioption']); 175: break; 176: 177: case "allnodes": case "alertnodes": 178: $items[$id]['detail']=array(); 179: if ($row['itype']=="allnodes") $q="SELECT nodeid FROM fnnode WHERE nodeenabled=1 ORDER BY `weight` ASC"; 180: else if ($row['itype']=="alertnodes") $q="SELECT nodeid FROM fnnode WHERE nodeenabled=1 AND alertlevel>0 ORDER BY `weight` ASC"; 181: $ret=$NATS->DB->Query($q); 182: //echo "!".$q."
";
183: $a=0; 184: while ($noderow=$NATS->DB->Fetch_Array($ret)) 185: { 186: if ($row['idetail']==1) $det=true; 187: else $det=false; 188: $items[$id]['detail'][$a]['data']=ViewNode($noderow['nodeid'],$det); 189: $items[$id]['detail'][$a]['icolour']=$row['icolour']; 190: $items[$id]['detail'][$a]['idetail']=$row['idetail']; 191: $items[$id]['detail'][$a]['igraphic']=$row['igraphic']; 192: $items[$id]['detail'][$a++]['itextstatus']=$row['itextstatus']; 193: } 194: $NATS->DB->Free($ret); 195: break; 196: 197: case "allgroups": case "alertgroups": 198: $items[$id]['detail']=array(); 199: $q="SELECT groupid FROM fngroup ORDER BY weight ASC"; 200: $ret=$NATS->DB->Query($q); 201: $a=0; 202: while ($grouprow=$NATS->DB->Fetch_Array($ret)) 203: { 204: if ( ($row['itype']=="allgroups") || ($NATS->GroupAlertLevel($grouprow['groupid'])>0) ) 205: { 206: $items[$id]['detail'][$a]['data']=ViewGroup($grouprow['groupid'],$row['idetail']); 207: $items[$id]['detail'][$a]['icolour']=$row['icolour']; 208: $items[$id]['detail'][$a]['ioption']=$grouprow['groupid']; 209: $items[$id]['detail'][$a]['idetail']=$row['idetail']; 210: $items[$id]['detail'][$a]['igraphic']=$row['igraphic']; 211: $items[$id]['detail'][$a++]['itextstatus']=$row['itextstatus']; 212: } 213: } 214: $NATS->DB->Free($ret); 215: break; 216: 217: case "group": 218: $items[$id]['data']=ViewGroup($row['ioption'],$row['idetail']); 219: break; 220: 221: case "testgraph": 222: // can't be arsed to do link here 223: break; 224: 225: case "alerts": 226: $c=0; 227: $alev=0; 228: $items[$id]['detail']=array(); 229: $alq="SELECT nodeid,openedx,alertlevel FROM fnalert WHERE closedx=0"; 230: $alr=$NATS->DB->Query($alq); 231: while ($al=$NATS->DB->Fetch_Array($alr)) 232: { 233: $items[$id]['detail'][$c]['nodeid']=$al['nodeid']; 234: $items[$id]['detail'][$c]['link']="node.php?nodeid=".$al['nodeid']; 235: if ($al['alertlevel']>$alev) $alev=$al['alertlevel']; 236: $items[$id]['detail'][$c]['status']=$al['alertlevel']; 237: $c++; 238: } 239: $items[$id]['data']['status']=$alev; 240: $items[$id]['data']['alerts']=$c; 241: $NATS->DB->Free($alr); 242: break; 243: 244: case "testdetail": 245: // localtest only thus far 246: $tid=substr($row['ioption'],1,128); 247: $tquery="SELECT * FROM fnlocaltest WHERE localtestid=\"".ss($tid)."\" LIMIT 0,1"; 248: $tres=$NATS->DB->Query($tquery); 249: if ($trow=$NATS->DB->Fetch_Array($tres)) 250: { 251: $items[$id]['status']=$trow['alertlevel']; 252: $items[$id]['lastrunx']=$trow['lastrunx']; 253: $items[$id]['dtago']=dtago($trow['lastrunx']); 254: $items[$id]['vtime']=vdt($trow['lastrunx']); 255: $items[$id]['nodeid']=$trow['nodeid']; 256: } 257: $NATS->DB->Free($tres); 258: break; 259: 260: } 261: 262: } 263: 264: // begin the buffering of output... 265: 266: // title and header 267: if ($view['vstyle']=="plain") 268: { 269: $ob[]=""; 270: $ob[]=""; 279: $ob[]=""; 280: } 281: else if ($view['vstyle']=="mobile") 282: { 283: $ob[]=""; 284: if ($view['vrefresh']>0) $ob[]=""; 285: $ob[]=""; 294: $ob[]=""; 295: } 296: else // standard and catch-all 297: { 298: $ob[]=""; 299: if ($view['vrefresh']>0) $ob[]=""; 300: $ob[]="FreeNATS: ".$view['vtitle'].""; 301: $ob[]=""; 310: $ob[]=""; 311: $ob[]=""; 312: $ob[]=""; 314: $ob[]="
"; 313: $ob[]="FreeNATS: ".$view['vtitle']."
";
315: $ob[]="
";
316: } 317: 318: // now the items 319: 320: function small_node($item) 321: { 322: global $abs,$view,$colon,$dashes; 323: $ob=array(); // our local copy 324: $uri=$abs.$item['data']['link']; 325: if ($view['vlinkv']!=0) 326: { 327: $uri=$abs."view.php?viewid=".$view['vlinkv']; 328: } 329: $link=$view['vclick']; 330: if ($link=="disabled") $l=""; 331: else if ($link=="standard") $l="";
332: else if ($link=="frametop") $l=""; 333: else if ($link=="newwindow") $l=""; 334: else $l=""; 335: 336: // alert lights only as no fancy full-on tables etc yet 337: if ($item['igraphic']>0) // actually therefore should only be ==1 with 2 being the "proper" one 338: { 339: $is=" "; 340: $ob[]=$is; 341: } 342: 343: $ob[]=$l; 344: 345: if ($item['icolour']==1) $ob[]=""; 346: 347: $out=$item['data']['name']; 348: if ($item['itextstatus']==1) $out.=$colon." ".oText($item['data']['status']); 349: $ob[]=$out.""; 350: 351: if ($item['icolour']==1) $ob[]=""; 352: 353: // detail like tests etc... 354: if ($item['idetail']>0) 355: { 356: $a=0; 357: foreach($item['data']['detail'] as $dline) 358: { 359: $a++; 360: $ob[]="
 - ";
361: if ($item['icolour']==1) $ob[]=""; 362: $out=$dline['item']; 363: if ($item['itextstatus']==1) $out.=$colon." ".oText($dline['status']); 364: $ob[]=$out; 365: if ($item['icolour']==1) $ob[]=""; 366: } 367: //if ($a>0) $ob[]="
";
368: } 369: 370: return $ob; 371: } 372: 373: function large_node($item) 374: { 375: global $abs,$view,$colon,$dashes; 376: $ob=array(); // our local copy 377: $uri=$abs.$item['data']['link']; 378: if ($view['vlinkv']!=0) 379: { 380: $uri=$abs."view.php?viewid=".$view['vlinkv']; 381: } 382: $link=$view['vclick']; 383: if ($link=="disabled") $l=""; 384: else if ($link=="standard") $l=""; 385: else if ($link=="frametop") $l=""; 386: else if ($link=="newwindow") $l=""; 387: else $l=""; 388: 389: if ($item['icolour']==1) $col=true; 390: else $col=false; 391: 392: if ($col) 393: { 394: switch($item['data']['status']) 395: { 396: case -1: $c="#a0a0a0"; break; 397: case 0: $c="green"; break; 398: case 1: $c="orange"; break; 399: case 2: $c="red"; break; 400: default: $c="black"; break; 401: } 402: } 403: else $c="#a0a0a0"; 404: $ss="width: 250; border: dotted 1px ".$c.";"; 405: 406: $ob[]=""; 407: 408: if ($item['igraphic']==1) 409: { 410: $is=" "; 411: } 412: else if ($item['igraphic']>0) 413: { 414: $is=" "; 415: } 416: else $is=" "; 417: 418: $ob[]=""; 430: // detail like tests etc... 431: if ($item['idetail']>0) 432: { 433: $ob[]=""; 447: //if ($a>0) $ob[]="
";
448: } 449: 450: 451: $ob[]="
"; 419: $ob[]=$l; 420: if ($item['icolour']==1) $ob[]=""; 421: 422: $out=$item['data']['name']; 423: if ($item['itextstatus']==1) $out.=$colon." ".oText($item['data']['status']); 424: $ob[]=$out.""; 425: 426: if ($item['icolour']==1) $ob[]=""; 427: $ob[]=""; 428: $ob[]=$is; 429: $ob[]="
"; 434: $a=0; 435: foreach($item['data']['detail'] as $dline) 436: { 437: $a++; 438: $ob[]=" - "; 439: if ($item['icolour']==1) $ob[]=""; 440: $out=$dline['item']; 441: if ($item['itextstatus']==1) $out.=$colon." ".oText($dline['status']); 442: $ob[]=$out; 443: if ($item['icolour']==1) $ob[]=""; 444: $ob[]="
";
445: } 446: $ob[]="
";
452: return $ob; 453: } 454: 455: function large_group($item) 456: { 457: global $abs,$view,$colon,$dashes; 458: $ob=array(); // our local copy 459: $uri=$abs.$item['data']['link']; 460: if ($view['vlinkv']!=0) 461: { 462: $uri=$abs."view.php?viewid=".$view['vlinkv']; 463: } 464: $link=$view['vclick']; 465: if ($link=="disabled") $l="
"; 466: else if ($link=="standard") $l=""; 467: else if ($link=="frametop") $l=""; 468: else if ($link=="newwindow") $l=""; 469: else $l=""; 470: 471: if ($item['icolour']==1) $col=true; 472: else $col=false; 473: 474: if ($col) 475: { 476: switch($item['data']['status']) 477: { 478: case -1: $c="#a0a0a0"; break; 479: case 0: $c="green"; break; 480: case 1: $c="orange"; break; 481: case 2: $c="red"; break; 482: default: $c="black"; break; 483: } 484: } 485: else $c="#a0a0a0"; 486: $ss="width: 250; border: dotted 1px ".$c.";"; 487: 488: $ob[]=""; 489: 490: if ($item['igraphic']==1) 491: { 492: $is=" "; 493: } 494: else if ($item['igraphic']>0) 495: { 496: $is=" "; 497: } 498: else $is=" "; 499: 500: $ob[]=""; 512: 513: if ($item['data']['desc']!="") $ob[]=""; 514: 515: // detail like tests etc... 516: if ($item['idetail']>0) 517: { 518: $ob[]=""; 546: //if ($a>0) $ob[]="
";
547: } 548: 549: 550: $ob[]="
"; 501: $ob[]=$l; 502: if ($item['icolour']==1) $ob[]=""; 503: 504: $out=$item['data']['name']; 505: if ($item['itextstatus']==1) $out.=$colon." ".oText($item['data']['status']); 506: $ob[]=$out.""; 507: 508: if ($item['icolour']==1) $ob[]=""; 509: $ob[]=""; 510: $ob[]=$is; 511: $ob[]="
".$item['data']['desc']."
"; 519: $a=0; 520: foreach($item['data']['detail'] as $dline) 521: { 522: $a++; 523: $ob[]=" - "; 524: 525: $uri=$abs.$item['data']['link']; 526: if ($view['vlinkv']!=0) 527: { 528: $uri=$abs."view.php?viewid=".$view['vlinkv']; 529: } 530: $link=$view['vclick']; 531: if ($link=="disabled") $l=""; 532: else if ($link=="standard") $l=""; 533: else if ($link=="frametop") $l=""; 534: else if ($link=="newwindow") $l=""; 535: else $l=""; 536: $ob[]=$l; 537: if ($item['icolour']==1) $ob[]=""; 538: if ($dline['nodename']!="") $out=$dline['nodename']; 539: else $out=$dline['nodeid']; 540: if ($item['itextstatus']==1) $out.=$colon." ".oText($dline['status']); 541: $ob[]=$out.""; 542: if ($item['icolour']==1) $ob[]=""; 543: $ob[]="
";
544: } 545: $ob[]="
";
551: return $ob; 552: } 553: 554: function small_group($item) 555: { 556: global $abs,$view,$colon,$dashes; 557: $ob=array(); // our local copy 558: $uri=$abs.$item['data']['link']; 559: if ($view['vlinkv']!=0) 560: { 561: $uri=$abs."view.php?viewid=".$view['vlinkv']; 562: } 563: $link=$view['vclick']; 564: if ($link=="disabled") $l="
"; 565: else if ($link=="standard") $l=""; 566: else if ($link=="frametop") $l=""; 567: else if ($link=="newwindow") $l=""; 568: else $l=""; 569: 570: // alert lights only as no fancy full-on tables etc yet 571: if ($item['igraphic']>0) // actually therefore should only be ==1 with 2 being the "proper" one 572: { 573: $is=" "; 574: $ob[]=$is; 575: } 576: 577: $ob[]=$l; 578: 579: if ($item['icolour']==1) $ob[]=""; 580: 581: $out=$item['data']['name']; 582: if ($item['itextstatus']==1) $out.=$colon." ".oText($item['data']['status']); 583: $ob[]=$out.""; 584: 585: if ($item['icolour']==1) $ob[]=""; 586: 587: // detail like tests etc... 588: if ($item['idetail']>0) 589: { 590: $a=0; 591: foreach($item['data']['detail'] as $dline) 592: { 593: $a++; 594: $uri=$abs.$item['data']['link']; 595: if ($view['vlinkv']!=0) 596: { 597: $uri=$abs."view.php?viewid=".$view['vlinkv']; 598: } 599: $link=$view['vclick']; 600: if ($link=="disabled") $l=""; 601: else if ($link=="standard") $l=""; 602: else if ($link=="frametop") $l=""; 603: else if ($link=="newwindow") $l=""; 604: else $l=""; 605: $ob[]="
 - ";
606: $ob[]=$l; 607: if ($item['icolour']==1) $ob[]=""; 608: if ($dline['nodename']=="") $out=$dline['nodeid']; 609: else $out=$dline['nodename']; 610: if ($item['itextstatus']==1) $out.=$colon." ".oText($dline['status']); 611: $ob[]=$out."
"; 612: if ($item['icolour']==1) $ob[]=""; 613: } 614: //if ($a>0) $ob[]="
";
615: } 616: 617: return $ob; 618: } 619: 620: function small_alerts($item) 621: { 622: global $abs,$view,$colon,$dashes; 623: $ob=array(); // our local copy 624: $uri=$abs."monitor.php"; 625: if ($view['vlinkv']!=0) 626: { 627: $uri=$abs."view.php?viewid=".$view['vlinkv']; 628: } 629: $link=$view['vclick']; 630: if ($link=="disabled") $l=""; 631: else if ($link=="standard") $l=""; 632: else if ($link=="frametop") $l=""; 633: else if ($link=="newwindow") $l=""; 634: else $l=""; 635: 636: // alert lights only as no fancy full-on tables etc yet 637: if ($item['igraphic']>0) // actually therefore should only be ==1 with 2 being the "proper" one 638: { 639: $is=" "; 640: //$ob[]=$is; 641: } 642: 643: $ob[]=$l; 644: 645: if ($item['icolour']==1) $ob[]=""; 646: 647: if ($item['data']['alerts']==0) $out="No System Alerts"; 648: else $out="System Alerts (".$item['data']['alerts'].")"; 649: $ob[]=$out.""; 650: 651: if ($item['icolour']==1) $ob[]=""; 652: 653: // detail like tests etc... 654: if ($item['idetail']>0) 655: { 656: $a=0; 657: if ($item['data']['alerts']==0) 658: { 659: $ob[]="
 - There are no alerts";
660: } 661: else 662: { 663: foreach($item['detail'] as $dline) 664: { 665: $a++; 666: $ob[]="
 - ";
667: $uri=$abs.$dline['link']; 668: if ($view['vlinkv']!=0) 669: { 670: $uri=$abs."view.php?viewid=".$view['vlinkv']; 671: } 672: $link=$view['vclick']; 673: if ($link=="disabled") $l=""; 674: else if ($link=="standard") $l=""; 675: else if ($link=="frametop") $l=""; 676: else if ($link=="newwindow") $l=""; 677: else $l=""; 678: $ob[]=$l; 679: 680: if ($item['icolour']==1) $ob[]=""; 681: $out=$dline['nodeid']; 682: if ($item['itextstatus']==1) $out.=$colon." ".oText($dline['status']); 683: $ob[]=$out.""; 684: if ($item['icolour']==1) $ob[]=""; 685: } 686: //if ($a>0) $ob[]="
";
687: } 688: } 689: $ob[]="
";
690: 691: return $ob; 692: } 693: 694: 695: function large_alerts($item) 696: { 697: global $abs,$view,$colon,$dashes; 698: $ob=array(); // our local copy 699: $uri=$abs."monitor.php"; 700: if ($view['vlinkv']!=0) 701: { 702: $uri=$abs."view.php?viewid=".$view['vlinkv']; 703: } 704: $link=$view['vclick']; 705: if ($link=="disabled") $l=""; 706: else if ($link=="standard") $l=""; 707: else if ($link=="frametop") $l=""; 708: else if ($link=="newwindow") $l=""; 709: else $l=""; 710: 711: if ($item['icolour']==1) $col=true; 712: else $col=false; 713: 714: if ($col) 715: { 716: switch($item['data']['status']) 717: { 718: case -1: $c="#a0a0a0"; break; 719: case 0: $c="green"; break; 720: case 1: $c="orange"; break; 721: case 2: $c="red"; break; 722: default: $c="black"; break; 723: } 724: } 725: else $c="#a0a0a0"; 726: $ss="width: 250; border: dotted 1px ".$c.";"; 727: 728: $ob[]=""; 729: 730: 731: 732: // alert lights only as no fancy full-on tables etc yet 733: if ($item['igraphic']>0) // actually therefore should only be ==1 with 2 being the "proper" one 734: { 735: $is=" "; 736: //$ob[]=$is; 737: } 738: else $is=" "; 739: 740: $ob[]=""; 753: 754: // detail like tests etc... 755: if ($item['idetail']>0) 756: { 757: $a=0; 758: if ($item['data']['alerts']==0) 759: { 760: $ob[]=""; 761: } 762: else 763: { 764: foreach($item['detail'] as $dline) 765: { 766: $a++; 767: $ob[]=""; 787: } 788: //if ($a>0) $ob[]="
";
789: } 790: } 791: $ob[]="
"; 741: 742: if ($item['icolour']==1) $ob[]=""; 743: 744: if ($item['data']['alerts']==0) $out="No System Alerts"; 745: else $out="System Alerts (".$item['data']['alerts'].")"; 746: $ob[]=$out.""; 747: 748: if ($item['icolour']==1) $ob[]=""; 749: 750: $ob[]=""; 751: $ob[]=$is; 752: $ob[]="
 - There are no alerts
 - "; 768: $uri=$abs.$dline['link']; 769: if ($view['vlinkv']!=0) 770: { 771: $uri=$abs."view.php?viewid=".$view['vlinkv']; 772: } 773: $link=$view['vclick']; 774: if ($link=="disabled") $l=""; 775: else if ($link=="standard") $l=""; 776: else if ($link=="frametop") $l=""; 777: else if ($link=="newwindow") $l=""; 778: else $l=""; 779: $ob[]=$l; 780: 781: if ($item['icolour']==1) $ob[]=""; 782: $out=$dline['nodeid']; 783: if ($item['itextstatus']==1) $out.=$colon." ".oText($dline['status']); 784: $ob[]=$out.""; 785: if ($item['icolour']==1) $ob[]=""; 786: $ob[]="
";
792: 793: return $ob; 794: 795: 796: 797: } 798: 799: 800: 801: 802: 803: if ($view['vcolumns']>1) 804: { 805: $usecols=true; 806: $colcount=$view['vcolumns']; 807: } 808: else $usecols=false; 809: 810: foreach($items as $item) 811: { 812: switch ($item['itype']) 813: { 814: case "node": 815: if ($item['isize']>0) $output=large_node($item); 816: else $output=small_node($item); 817: foreach($output as $line) $ob[]=$line; 818: 819: break; 820: 821: case "group": 822: if ($item['isize']>0) $output=large_group($item); 823: else $output=small_group($item); 824: foreach($output as $line) $ob[]=$line; 825: break; 826: 827: case "alerts": 828: if ($item['isize']>0) $output=large_alerts($item); 829: else $output=small_alerts($item); 830: foreach($output as $line) $ob[]=$line; 831: break; 832: 833: case "allnodes": case "alertnodes": 834: $c=0; 835: if ($usecols) $ob[]=""; 836: foreach($item['detail'] as $node) 837: { 838: if ($usecols) 839: { 840: if ($c==0) $ob[]=""; 841: $ob[]=""; 850: $c++; 851: if ($c>=$colcount) 852: { 853: $ob[]=""; 854: $ob[]=""; 855: $c=0; 856: } 857: } 858: else $ob[]="
";
859: } 860: if (($usecols) && ($c<3)) $ob[]=""; 861: if ($usecols) $ob[]="
"; 842: } 843: if ($item['isize']==1) $output=large_node($node); 844: else $output=small_node($node); 845: foreach($output as $line) $ob[]=$line; 846: 847: if ($usecols) 848: { 849: $ob[]="
 
";
862: break; 863: 864: case "allgroups": case "alertgroups": 865: $c=0; 866: if ($usecols) $ob[]=""; 867: foreach($item['detail'] as $group) 868: { 869: if ($usecols) 870: { 871: if ($c==0) $ob[]=""; 872: $ob[]=""; 881: $c++; 882: if ($c>=$colcount) 883: { 884: $ob[]=""; 885: $ob[]=""; 886: $c=0; 887: } 888: } 889: else $ob[]="
";
890: } 891: if (($usecols) && ($c<3)) $ob[]=""; 892: if ($usecols) $ob[]="
"; 873: } 874: if ($item['isize']==1) $output=large_group($group); 875: else $output=small_group($group); 876: foreach($output as $line) $ob[]=$line; 877: 878: if ($usecols) 879: { 880: $ob[]="
 
";
893: break; 894: 895: case "title": 896: if ($item['isize']>0) $ob[]=""; 897: else if ($item['icolour']==1) $ob[]=""; 898: $ob[]=$item['ioption']; 899: if ( ($item['isize']>0) || ($item['icolour']==1) ) $ob[]=""; 900: break; 901: 902: case "testdetail": 903: 904: $is=""; 905: if ($item['igraphic']>0) 906: { 907: $is=" "; 908: } 909: 910: if ($is!="") $ob[]=$is; 911: 912: $uri=$abs."node.php?nodeid=".$item['nodeid']; 913: if ($view['vlinkv']!=0) 914: { 915: $uri=$abs."view.php?viewid=".$view['vlinkv']; 916: } 917: $link=$view['vclick']; 918: if ($link=="disabled") $l="
"; 919: else if ($link=="standard") $l=""; 920: else if ($link=="frametop") $l=""; 921: else if ($link=="newwindow") $l=""; 922: else $l=""; 923: $ob[]=$l; 924: 925: if ($item['icolour']==1) $ob[]=""; 926: else $ob[]=""; 927: 928: $s=$item['iname']; 929: if ($item['itextstatus']==1) $s.=$colon." ".oText($item['status']); 930: $s.=""; 931: $ob[]=$s; 932: if ($item['idetail']>0) 933: { 934: if ($item['isize']>0) $ob[]="
 ".$dash." tested ";
935: else $ob[]=$dash." "; 936: $ob[]=$item['vtime']; 937: } 938: $ob[]="
"; 939: 940: break; 941: 942: case "testgraph": 943: $p=strpos($item['ioption'],"/"); 944: if ($p===false) 945: { 946: $hrs=24; 947: $tid=$item['ioption']; 948: } 949: else 950: { 951: $tid=substr($item['ioption'],0,$p); 952: $hrs=substr($item['ioption'],$p+1,20); 953: } 954: if ($item['isize']>0) 955: { 956: $width=700; 957: $height=150; 958: } 959: else 960: { 961: $width=350; 962: $height=100; 963: } 964: // colours eventually... 965: 966: $uri=$abs."history.test.php?testid=".$tid; 967: if ($view['vlinkv']!=0) 968: { 969: $uri=$abs."view.php?viewid=".$view['vlinkv']; 970: } 971: $link=$view['vclick']; 972: if ($link=="disabled") $l=""; 973: else if ($link=="standard") $l=""; 974: else if ($link=="frametop") $l=""; 975: else if ($link=="newwindow") $l=""; 976: else $l=""; 977: 978: 979: $i=$abs."test.graph.php?testid=".$tid."&startx="; 980: $now=time(); 981: $startx=$now-($hrs*60*60); 982: $i.=$startx."&finishx=".$now."&width=".$width."&height=".$height; 983: $ob[]=$l.""; 984: break; 985: 986: } 987: $ob[]="
";
988: 989: } 990: 991: // footer 992: if ($view['vstyle']=="mobile") 993: { 994: $ob[]=""; 995: } 996: else if ($view['vstyle']=="plain") 997: { 998: $ob[]=""; 999: } 1000: else // standard and catch-all 1001: { 1002: $ob[]=""; 1003: $ob[]=""; 1007: $ob[]="
Powered by FreeNATS"; 1004: $ob[]=""; 1005: $ob[]="Login to System"; 1006: $ob[]="
";
1008: } 1009: 1010: 1011: 1012: // finally the output 1013: switch ($mode) 1014: { 1015: case "debug": 1016: echo "
";
1017: 	var_dump($items);
1018: 	echo "

";
1019: foreach($ob as $l) 1020: echo htmlspecialchars($l)."\n"; 1021: break; 1022: 1023: case "js": 1024: //echo "\n"; 1033: echo "\n"; 1034: break; 1035: 1036: default: 1037: foreach($ob as $l) 1038: { 1039: echo $l; 1040: echo "\n"; 1041: } 1042: } 1043: 1044: ?>