File: 1.13.3b/server/base/eval.inc.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: function nats_eval($testid,$value) 24: { 25: global $NATS; 26: if (!is_numeric($value)) return 2; // fails if not numeric! 27: $lvl=0; 28: 29: $q="SELECT * FROM fneval WHERE testid=\"".ss($testid)."\""; 30: $r=$NATS->DB->Query($q); 31: //echo $q; 32: while ($row=$NATS->DB->Fetch_Array($r)) 33: { 34: //echo "\n".$row['eoperator']."\n"; 35: $nl=0; 36: switch ($row['eoperator']) 37: { 38: case "ET": 39: if ($row['evalue']==$value) $nl=$row['eoutcome']; 40: break; 41: case "GT": 42: if ($row['evalue']<$value) $nl=$row['eoutcome']; 43: break; 44: case "LT": 45: if ($row['evalue']>$value) $nl=$row['eoutcome']; 46: break; 47: } 48: if ($nl>$lvl) $lvl=$nl; 49: } 50: $NATS->DB->Free($r); 51: return $lvl; 52: } 53: 54: function eval_operator_text($operator) 55: { 56: switch($operator) 57: { 58: case "ET": return "Equal To"; 59: case "GT": return "Greater Than"; 60: case "LT": return "Less Than"; 61: 62: default: return "Unknown"; 63: } 64: } 65: 66: ?>