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

";
1004: foreach($ob as $l) 1005: echo htmlspecialchars($l)."\n"; 1006: break; 1007: 1008: case "js": 1009: //echo "\n"; 1018: echo "\n"; 1019: break; 1020: 1021: default: 1022: foreach($ob as $l) 1023: { 1024: echo $l; 1025: echo "\n"; 1026: } 1027: } 1028: 1029: ?>