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<9) UL_Error("Admin Interface");
32:
33: // Actions Here
34: if (isset($_REQUEST['action']))
35: {
36: switch($_REQUEST['action'])
37: { // create delete save_edit
38: // create_item delete_item save_item
39: case "create":
40: $q="INSERT INTO fnschedule(schedulename) VALUES(\"".ss($_REQUEST['schedulename'])."\")";
41: $NATS->DB->Query($q);
42: $_REQUEST['scheduleid']=$NATS->DB->Insert_Id();
43: break;
44:
45: case "delete":
46: if (!isset($_REQUEST['confirmed']))
47: {
48: $back="schedule.php?delscheduleid=".$_REQUEST['delscheduleid']."&action=delete&confirmed=1";
49: $msg="Delete Schedule and All Associated Items";
50: $u="confirm.php?action=".urlencode($msg)."&back=".urlencode($back);
51: header("Location: ".$u);
52: exit();
53: }
54: $q="DELETE FROM fnscheditem WHERE scheduleid=".ss($_REQUEST['delscheduleid']);
55: $NATS->DB->Query($q);
56: $q="UPDATE fnnode SET scheduleid=0 WHERE scheduleid=".ss($_REQUEST['delscheduleid']);
57: $NATS->DB->Query($q);
58: $q="DELETE FROM fnschedule WHERE scheduleid=".ss($_REQUEST['delscheduleid']);
59: $NATS->DB->Query($q);
60: break;
61:
62: case "save_edit":
63: $q="UPDATE fnschedule SET schedulename=\"".ss($_REQUEST['schedulename'])."\",defaultaction=".ss($_REQUEST['defaultaction'])." ";
64: $q.="WHERE scheduleid=".ss($_REQUEST['scheduleid']);
65: $NATS->DB->Query($q);
66: break;
67:
68: case "create_item":
69: if ($_REQUEST['year']=="") $year=0;
70: else $year=ss($_REQUEST['year']);
71: $q="INSERT INTO fnscheditem(scheduleid,dayofweek,dayofmonth,monthofyear,year,starthour,startmin,finishhour,finishmin) VALUES(";
72: $q.=ss($_REQUEST['scheduleid']).",\"".ss($_REQUEST['dayofweek'])."\",".ss($_REQUEST['dayofmonth']).",".ss($_REQUEST['monthofyear']).",".$year.",";
73: $q.=ss($_REQUEST['starthour']).",".ss($_REQUEST['startmin']).",".ss($_REQUEST['finishhour']).",".ss($_REQUEST['finishmin']).")";
74: $NATS->DB->Query($q);
75: break;
76: //echo $q;
77:
78: case "save_item":
79: if ($_REQUEST['year']=="") $year=0;
80: else $year=ss($_REQUEST['year']);
81: $q="UPDATE fnscheditem SET ";
82: //(scheduleid,dayofweek,dayofmonth,monthofyear,year,starthour,startmin,finishhour,finishmin) VALUES(";
83: $q.="dayofweek=\"".ss($_REQUEST['dayofweek'])."\",";
84: $q.="dayofmonth=".ss($_REQUEST['dayofmonth']).",monthofyear=".ss($_REQUEST['monthofyear']).",year=".$year.",";
85: $q.="starthour=".ss($_REQUEST['starthour']).",startmin=".ss($_REQUEST['startmin']).",";
86: $q.="finishhour=".ss($_REQUEST['finishhour']).",finishmin=".ss($_REQUEST['finishmin'])." WHERE scheditemid=".ss($_REQUEST['scheditemid']);
87: $NATS->DB->Query($q);
88: break;
89:
90: case "delete_item";
91: $q="DELETE FROM fnscheditem WHERE scheditemid=".ss($_REQUEST['scheditemid']);
92: $NATS->DB->Query($q);
93: break;
94: }
95:
96: }
97:
98:
99: Screen_Header("Schedule Management",1,1,"","main","admin");
100:
101: echo " System Settings > Schedule Manager
";
102: $q="SELECT scheduleid,schedulename FROM fnschedule";
103: $r=$NATS->DB->Query($q);
104: if ($NATS->DB->Num_Rows($r)<=0) echo "No Schedules ";
105: else
106: {
107: echo "
";
108: while ($row=$NATS->DB->Fetch_Array($r))
109: {
110: echo "
";
154: echo "Exceptions are the times when your schedule will not perform its default action i.e. not test the node or send the alert. ";
155: echo "See the documentation for more information.
";
156:
157: echo "
";
158: echo "
Weekday
Day
Month
Year
From (HH:MM) =>
";
159: echo "
To HH:MM
";
160:
161: $q="SELECT * FROM fnscheditem WHERE scheduleid=".ss($_REQUEST['scheduleid']);
162: $r=$NATS->DB->Query($q);
163: while ($row=$NATS->DB->Fetch_Array($r))
164: {
165: echo "