File: 0.02.35a/server/web/localtest.action.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 Foobar. 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<5) UL_Error("Action Local Test"); 32: 33: switch ($_REQUEST['action']) 34: { 35: case "create": 36: $q="INSERT INTO fnlocaltest(nodeid,testtype,testparam) VALUES("; 37: $q.="\"".ss($_REQUEST['nodeid'])."\",\"".ss($_REQUEST['testtype'])."\",\"".ss($_REQUEST['testparam'])."\")"; 38: $NATS->DB->Query($q); 39: //echo $q; 40: //exit(); 41: // Following user feedback (added to 0.02.35a) 42: //$loc="localtest.edit.php?localtestid=".$NATS->DB->Insert_Id(); 43: $loc="node.edit.php?nodeid=".$_REQUEST['nodeid']; // no message - just appears in list like evals 44: header("Location: ".$loc); 45: exit(); 46: break; 47: case "save_form": 48: if (isset($_REQUEST['testrecord'])) $tr=$_REQUEST['testrecord']; 49: else $tr=0; 50: if (isset($_REQUEST['simpleeval'])) $se=$_REQUEST['simpleeval']; 51: else $se=0; 52: $q="UPDATE fnlocaltest SET testparam=\"".ss($_REQUEST['testparam'])."\",testrecord=".ss($tr).",simpleeval=".ss($se)." WHERE "; 53: $q.="localtestid=".ss($_REQUEST['localtestid']); 54: $NATS->DB->Query($q); 55: if ($NATS->DB->Affected_Rows()<=0) $msg="Save+Failed+or+Nothing+Changed"; 56: else $msg="Changes+Saved"; 57: header("Location: localtest.edit.php?localtestid=".$_REQUEST['localtestid']."&message=".$msg); 58: exit(); 59: case "delete": 60: if (!isset($_REQUEST['confirmed'])) 61: { 62: $back="localtest.action.php?action=delete&localtestid=".$_REQUEST['localtestid']."&confirmed=1"; 63: $back=urlencode($back); 64: $url="confirm.php?action=Delete+test+and+all+historical+data&back=".$back; 65: header("Location: ".$url); 66: exit(); 67: } 68: // history 69: $q="DELETE FROM fnrecord WHERE testid=\"L".ss($_REQUEST['localtestid'])."\""; 70: $NATS->DB->Query($q); 71: $hdel=$NATS->DB->Affected_Rows(); 72: // test itself 73: $q="DELETE FROM fnlocaltest WHERE localtestid=".ss($_REQUEST['localtestid']); 74: $NATS->DB->Query($q); 75: $m="Deleted ".$NATS->DB->Affected_Rows()." test and ".$hdel." history items"; 76: header("Location: main.php?message=".urlencode($m)); 77: exit(); 78: 79: default: 80: header("Location: main.php?message=Unknown+Local+Test+Action"); 81: exit(); 82: } 83: 84: ?> 85: