File: 1.19.3a/server/web/summary.test.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: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 29: exit(); 30: } 31: if ($NATS_Session->userlevel<1) UL_Error("View Test Summary"); 32: 33: if (isset($_REQUEST['nodeid'])) $nodeid=$_REQUEST['nodeid']; 34: else $nodeid=""; 35: 36: 37: Screen_Header("Summary for ".$nodeid,1); 38: ob_end_flush(); 39: 40: $td_day=date("d"); 41: $td_mon=date("m"); 42: $td_yr=date("Y"); 43: 44: function gtinfo($testid) 45: { 46: global $NATS; 47: $o="Error fetching test"; 48: 49: $test=$NATS->GetTest($testid); 50: if ($test['class']=="L") 51: { 52: $o=lText($test['testtype']); 53: if ($test['testparam']!="") $o.=" (".$test['testparam'].")"; 54: 55: if ($test['testname']!="") $o=$test['testname']; 56: 57: $u=lUnit($test['testtype']); 58: if ($u!="") $o.=" (".$u.")"; 59: } 60: else if ($test['name']!="") $o=$test['name']; 61: else $o=$test['testtype']; 62: /* 63: if ($testid[0]=="L") 64: { // local test 65: $q="SELECT testtype,testparam,testname FROM fnlocaltest WHERE localtestid=".ss(substr($testid,1,128)); 66: $r=$NATS->DB->Query($q); 67: if ($row=$NATS->DB->Fetch_Array($r)) 68: { 69: $o=lText($row['testtype']); 70: if ($row['testparam']!="") $o.=" (".$row['testparam'].")"; 71: 72: if ($row['testname']!="") $o=$row['testname']; 73: 74: $u=lUnit($row['testtype']); 75: if ($u!="") $o.=" (".$u.")"; 76: } 77: else $o="Error fetching test"; 78: } 79: */ 80: return $o; 81: } 82: 83: function outTime($timex,$name,$start=true,$checked=false) 84: { 85: echo " 86: if ($start) echo "startx"; 87: else echo "finishx"; 88: if ($checked) $c=" checked"; 89: else $c=""; 90: echo " value=".$timex.$c."> ".$name."
";
91: } 92: 93: if (isset($_REQUEST['mode'])&&($_REQUEST['mode']=="custom")) 94: { 95: echo "
Custom Summary

";
96: echo ""; 97: echo "
";
98: echo ""; // note the space - invalid normal nodeid 99: echo ""; 126: echo "
"; 100: echo "Nodes

";
101: $q="SELECT nodeid,nodename FROM fnnode ORDER BY weight ASC"; 102: $r=$NATS->DB->Query($q); 103: while ($row=$NATS->DB->Fetch_Array($r)) 104: { 105: if ($NATS->isUserAllowedNode($NATS_Session->username,$row['nodeid'])) 106: { 107: echo " "; 108: if ($row['nodename']=="") echo $row['nodeid']; 109: else echo $row['nodename']; 110: echo "
";
111: } 112: } 113: $NATS->DB->Free($r); 114: echo "
"; 115: echo "Start Time

";
116: outTime(mktime(0,0,0,$td_mon,$td_day,$td_yr),"0:00 Today",true,true); 117: outTime(time()-(60*60*24),"24 Hours Ago"); 118: outTime(time()-(60*60),"1 Hour Ago"); 119: 120: echo "
Finish Time

";
121: outTime(mktime(23,59,59,$td_mon,$td_day,$td_yr),"23:59:59 Today",false,true); 122: outTime(time(),"Now",false); 123: 124: echo "
";
125: echo "
";
127: } 128: 129: if (isset($_REQUEST['startx'])) $startx=$_REQUEST['startx']; 130: else $startx=mktime(0,0,0,$td_mon,$td_day,$td_yr); 131: if (isset($_REQUEST['finishx'])) $finishx=$_REQUEST['finishx']; 132: else $finishx=mktime(23,59,59,$td_mon,$td_day,$td_yr); 133: 134: echo "
From ".nicedt($startx)." to ".nicedt($finishx)."

";
135: 136: if ($nodeid=="*") 137: { 138: // 139: $q="SELECT testid,nodeid FROM fnrecord WHERE recordx>=".ss($startx)." AND recordx<=".ss($finishx); 140: $q.=" GROUP BY testid ORDER BY nodeid"; 141: } 142: else if ($nodeid==" custom") // use nodelist 143: { 144: $q="SELECT testid,nodeid FROM fnrecord WHERE recordx>=".ss($startx)." AND recordx<=".ss($finishx)." "; 145: $q.="AND nodeid IN ( "; 146: $first=true; 147: foreach($_REQUEST['nodelist'] as $node) 148: { 149: if ($first) $first=false; 150: else $q.=","; 151: $q.="\"".ss($node)."\""; 152: } 153: $q.=" ) GROUP BY testid ORDER BY nodeid"; 154: //echo $q; 155: //exit(); 156: } 157: else 158: { 159: $q="SELECT testid,nodeid FROM fnrecord WHERE nodeid=\"".ss($nodeid)."\" AND recordx>=".ss($startx)." AND recordx<=".ss($finishx); 160: $q.=" GROUP BY testid"; 161: } 162: $r=$NATS->DB->Query($q); 163: 164: 165: $name=""; 166: $first=true; 167: 168: while ($row=$NATS->DB->Fetch_Array($r)) 169: { 170: if ($NATS->isUserAllowedNode($NATS_Session->username,$row['nodeid'])) 171: { 172: if ($name!=$row['nodeid']) 173: { 174: if ($first) $first=false; 175: else echo "

";
176: echo "Node: ".$row['nodeid']."

";
177: $name=$row['nodeid']; 178: } 179: echo "".gtinfo($row['testid'])." on ".$row['nodeid']."
";
180: //echo "img src=\"test.graph.php?testid=".$row['testid']."&startx=".$startx."&finishx=".$finishx."\"
";
181: echo ""; 182: echo ""; 183: echo "";
184: echo "

 
";
185: } 186: } 187: 188: $NATS->DB->Free($r); 189: 190: Screen_Footer(); 191: ?> 192: