Viewing File server/web/summary.test.php of 0.04.06a
|
1: <?php 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: if ($testid[0]=="L") 49: { // local test 50: $q="SELECT testtype,testparam,testname FROM fnlocaltest WHERE localtestid=".ss(substr($testid,1,128)); 51: $r=$NATS->DB->Query($q); 52: if ($row=$NATS->DB->Fetch_Array($r)) 53: { 54: $o=lText($row['testtype']); 55: if ($row['testparam']!="") $o.=" (".$row['testparam'].")"; 56: 57: if ($row['testname']!="") $o=$row['testname']; 58: 59: $u=lUnit($row['testtype']); 60: if ($u!="") $o.=" (".$u.")"; 61: } 62: else $o="Error fetching test"; 63: } 64: 65: return $o; 66: } 67: 68: function outTime($timex,$name,$start=true,$checked=false) 69: { 70: echo "<input type=radio name="; 71: if ($start) echo "startx"; 72: else echo "finishx"; 73: if ($checked) $c=" checked"; 74: else $c=""; 75: echo " value=".$timex.$c."> ".$name."<br>"; 76: } 77: 78: if (isset($_REQUEST['mode'])&&($_REQUEST['mode']=="custom")) 79: { 80: echo "<br><b class=\"subtitle\">Custom Summary</b><br><br>"; 81: echo "<table width=600 border=0>"; 82: echo "<form action=summary.test.php method=post>"; 83: echo "<input type=hidden name=nodeid value=\" custom\">"; // note the space - invalid normal nodeid 84: echo "<tr><td align=left valign=top>"; 85: echo "<b>Nodes</b><br><br>"; 86: $q="SELECT nodeid,nodename FROM fnnode ORDER BY weight ASC"; 87: $r=$NATS->DB->Query($q); 88: while ($row=$NATS->DB->Fetch_Array($r)) 89: { 90: echo "<input type=checkbox name=nodelist[] value=\"".$row['nodeid']."\"> "; 91: if ($row['nodename']=="") echo $row['nodeid']; 92: else echo $row['nodename']; 93: echo "<br>"; 94: } 95: $NATS->DB->Free($r); 96: echo "</td><td align=left valign=top>"; 97: echo "<b>Start Time</b><br><br>"; 98: outTime(mktime(0,0,0,$td_mon,$td_day,$td_yr),"0:00 Today",true,true); 99: outTime(time()-(60*60*24),"24 Hours Ago"); 100: outTime(time()-(60*60),"1 Hour Ago"); 101: 102: echo "<br><b>Finish Time</b><br><br>"; 103: outTime(mktime(23,59,59,$td_mon,$td_day,$td_yr),"23:59:59 Today",false,true); 104: outTime(time(),"Now",false); 105: 106: echo "<br><input type=submit value=\"View Summary\">"; 107: echo "</td></tr>"; 108: echo "</form></table>"; 109: } 110: 111: if (isset($_REQUEST['startx'])) $startx=$_REQUEST['startx']; 112: else $startx=mktime(0,0,0,$td_mon,$td_day,$td_yr); 113: if (isset($_REQUEST['finishx'])) $finishx=$_REQUEST['finishx']; 114: else $finishx=mktime(23,59,59,$td_mon,$td_day,$td_yr); 115: 116: echo "<br><b>From </b>".nicedt($startx)." <b>to</b> ".nicedt($finishx)."<br><br>"; 117: 118: if ($nodeid=="*") 119: { 120: // 121: $q="SELECT testid,nodeid FROM fnrecord WHERE recordx>=".ss($startx)." AND recordx<=".ss($finishx); 122: $q.=" GROUP BY testid ORDER BY nodeid"; 123: } 124: else if ($nodeid==" custom") // use nodelist 125: { 126: $q="SELECT testid,nodeid FROM fnrecord WHERE recordx>=".ss($startx)." AND recordx<=".ss($finishx)." "; 127: $q.="AND nodeid IN ( "; 128: $first=true; 129: foreach($_REQUEST['nodelist'] as $node) 130: { 131: if ($first) $first=false; 132: else $q.=","; 133: $q.="\"".ss($node)."\""; 134: } 135: $q.=" ) GROUP BY testid ORDER BY nodeid"; 136: //echo $q; 137: //exit(); 138: } 139: else 140: { 141: $q="SELECT testid,nodeid FROM fnrecord WHERE nodeid=\"".ss($nodeid)."\" AND recordx>=".ss($startx)." AND recordx<=".ss($finishx); 142: $q.=" GROUP BY testid"; 143: } 144: $r=$NATS->DB->Query($q); 145: 146: 147: $name=""; 148: $first=true; 149: 150: while ($row=$NATS->DB->Fetch_Array($r)) 151: { 152: if ($name!=$row['nodeid']) 153: { 154: if ($first) $first=false; 155: else echo "<br><br>"; 156: echo "<b class=\"subtitle\">Node: <a href=node.php?nodeid=".$row['nodeid'].">".$row['nodeid']."</a></b><br><br>"; 157: $name=$row['nodeid']; 158: } 159: echo "<b>".gtinfo($row['testid'])." on ".$row['nodeid']."</b><br>"; 160: //echo "img src=\"test.graph.php?testid=".$row['testid']."&startx=".$startx."&finishx=".$finishx."\"<br>"; 161: echo "<a href=history.test.php?nodeid=".$row['nodeid']."&testid=".$row['testid']."&startx=".$startx."&finishx=".$finishx.">"; 162: echo "<img src=\"test.graph.php?nodeid=".$row['nodeid']."&testid=".$row['testid']."&startx=".$startx."&finishx=".$finishx."\" border=0>"; 163: echo "</a>"; 164: echo "<br><br> <br>"; 165: } 166: 167: $NATS->DB->Free($r); 168: 169: Screen_Footer(); 170: ?> 171: