File:
0.02.63a/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 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<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).",";
53: $q.="testname=\"".ss($_REQUEST['testname'])."\",attempts=".ss($_REQUEST['attempts']).",timeout=".ss($_REQUEST['timeout'])." ";
54: $q.="WHERE localtestid=".ss($_REQUEST['localtestid']);
55: $NATS->DB->Query($q);
56: if ($NATS->DB->Affected_Rows()<=0) $msg="Save+Failed+or+Nothing+Changed";
57: else $msg="Changes+Saved";
58: header("Location: localtest.edit.php?localtestid=".$_REQUEST['localtestid']."&message=".$msg);
59: exit();
60: case "delete":
61: if (!isset($_REQUEST['confirmed']))
62: {
63: $back="localtest.action.php?action=delete&localtestid=".$_REQUEST['localtestid']."&confirmed=1";
64: $back=urlencode($back);
65: $url="confirm.php?action=Delete+test+and+all+historical+data&back=".$back;
66: header("Location: ".$url);
67: exit();
68: }
69: // history
70: $q="DELETE FROM fnrecord WHERE testid=\"L".ss($_REQUEST['localtestid'])."\"";
71: $NATS->DB->Query($q);
72: $hdel=$NATS->DB->Affected_Rows();
73: // test itself
74: $q="DELETE FROM fnlocaltest WHERE localtestid=".ss($_REQUEST['localtestid']);
75: $NATS->DB->Query($q);
76: $m="Deleted ".$NATS->DB->Affected_Rows()." test and ".$hdel." history items";
77: header("Location: main.php?message=".urlencode($m));
78: exit();
79:
80: default:
81: header("Location: main.php?message=Unknown+Local+Test+Action");
82: exit();
83: }
84:
85: ?>
86: