File: 1.01.2a/server/web/summary.test.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: 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 ""; 123: 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: echo " "; 106: if ($row['nodename']=="") echo $row['nodeid']; 107: else echo $row['nodename']; 108: echo "
";
109: } 110: $NATS->DB->Free($r); 111: echo "
"; 112: echo "Start Time

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

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

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

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

";
172: $name=$row['nodeid']; 173: } 174: echo "".gtinfo($row['testid'])." on ".$row['nodeid']."
";
175: //echo "img src=\"test.graph.php?testid=".$row['testid']."&startx=".$startx."&finishx=".$finishx."\"
";
176: echo ""; 177: echo ""; 178: echo "";
179: echo "

 
";
180: } 181: 182: $NATS->DB->Free($r); 183: 184: Screen_Footer(); 185: ?> 186: