File: 0.02.28a/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: $loc="localtest.edit.php?localtestid=".$NATS->DB->Insert_Id(); 42: header("Location: ".$loc); 43: exit(); 44: break; 45: case "save_form": 46: if (isset($_REQUEST['testrecord'])) $tr=$_REQUEST['testrecord']; 47: else $tr=0; 48: if (isset($_REQUEST['simpleeval'])) $se=$_REQUEST['simpleeval']; 49: else $se=0; 50: $q="UPDATE fnlocaltest SET testparam=\"".ss($_REQUEST['testparam'])."\",testrecord=".ss($tr).",simpleeval=".ss($se)." WHERE "; 51: $q.="localtestid=".ss($_REQUEST['localtestid']); 52: $NATS->DB->Query($q); 53: if ($NATS->DB->Affected_Rows()<=0) $msg="Save+Failed"; 54: else $msg="Changes+Saved"; 55: header("Location: localtest.edit.php?localtestid=".$_REQUEST['localtestid']."&message=".$msg); 56: exit(); 57: case "delete": 58: if (!isset($_REQUEST['confirmed'])) 59: { 60: $back="localtest.action.php?action=delete&localtestid=".$_REQUEST['localtestid']."&confirmed=1"; 61: $back=urlencode($back); 62: $url="confirm.php?action=Delete+test+and+all+historical+data&back=".$back; 63: header("Location: ".$url); 64: exit(); 65: } 66: // history 67: $q="DELETE FROM fnrecord WHERE testid=\"L".ss($_REQUEST['localtestid'])."\""; 68: $NATS->DB->Query($q); 69: $hdel=$NATS->DB->Affected_Rows(); 70: // test itself 71: $q="DELETE FROM fnlocaltest WHERE localtestid=".ss($_REQUEST['localtestid']); 72: $NATS->DB->Query($q); 73: $m="Deleted ".$NATS->DB->Affected_Rows()." test and ".$hdel." history items"; 74: header("Location: main.php?message=".urlencode($m)); 75: exit(); 76: 77: default: 78: header("Location: main.php?message=Unknown+Local+Test+Action"); 79: exit(); 80: } 81: 82: ?> 83: