Project

General

Profile

Download (36.7 KB) Statistics
| Branch: | Tag: | Revision:
1 615b27bc Scott Dale
<?php
2
/*
3
	firewall_schedule_edit.php
4
	Copyright (C) 2004 Scott Ullrich
5
	All rights reserved.
6
7
	originially part of m0n0wall (http://m0n0.ch/wall)
8
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
$pgtitle = "Firewall: Schedules: Edit";
34
require("guiconfig.inc");
35
36
$starttimehr = 00;
37
$starttimemin = 00;
38
39 bd080157 Scott Dale
$stoptimehr = 23;
40
$stoptimemin = 59;
41 615b27bc Scott Dale
42 6a6d2f63 Scott Dale
$dayArray = array ('Mon','Tues','Wed','Thur','Fri','Sat','Sun');
43 615b27bc Scott Dale
$monthArray = array ('January','February','March','April','May','June','July','August','September','October','November','December');
44
45
if (!is_array($config['schedules']['schedule']))
46
	$config['schedules']['schedule'] = array();
47
48
schedule_sort();
49
$a_schedules = &$config['schedules']['schedule'];
50
51 273c8b1c Scott Dale
52 615b27bc Scott Dale
$id = $_GET['id'];
53
if (isset($_POST['id']))
54
	$id = $_POST['id'];
55
56
if (isset($id) && $a_schedules[$id]) {
57
	$pconfig['name'] = $a_schedules[$id]['name'];
58
	$pconfig['descr'] = html_entity_decode($a_schedules[$id]['descr']);
59
	$pconfig['timerange'] = $a_schedules[$id]['timerange'];
60
	$getSchedule = true;
61
}
62
63
if ($_POST) {
64
	
65
	if(strtolower($_POST['name']) == "lan")
66
		$input_errors[] = "Schedule may not be named LAN.";
67
	if(strtolower($_POST['name']) == "wan")
68
		$input_errors[] = "Schedule may not be named WAN.";
69 273c8b1c Scott Dale
	if(strtolower($_POST['name']) == "")
70
		$input_errors[] = "Schedule name cannot be blank.";
71 615b27bc Scott Dale
72
	$x = is_validaliasname($_POST['name']);
73
	if (!isset($x)) {
74
		$input_errors[] = "Reserved word used for schedule name.";
75
	} else {
76
		if (is_validaliasname($_POST['name']) == false)
77 636a69e6 Scott Dale
			$input_errors[] = "The schedule name may only consist of the characters a-z, A-Z, 0-9";
78 615b27bc Scott Dale
	}
79
	
80
	/* check for name conflicts */
81
	foreach ($a_schedules as $schedule) {
82
		if (isset($id) && ($a_schedules[$id]) && ($a_schedules[$id] === $schedule))
83
			continue;
84
85
		if ($schedule['name'] == $_POST['name']) {
86
			$input_errors[] = "A Schedule with this name already exists.";
87
			break;
88
		}
89
	}
90 273c8b1c Scott Dale
	$schedule = array();
91
	
92
	$schedule['name'] = $_POST['name'];
93
	$schedule['descr'] = htmlentities($_POST['descr'], ENT_QUOTES, 'UTF-8');	
94
	
95 e56fcb71 Scott Dale
	$timerangeFound = false;
96 615b27bc Scott Dale
	for ($x=0; $x<99; $x++){
97
		if($_POST['schedule' . $x]) {
98 e56fcb71 Scott Dale
			$timerangeFound = true;
99 273c8b1c Scott Dale
			$timeparts = array();
100
			$firstprint = false;
101
			$timestr = $_POST['schedule' . $x];
102
			$timehourstr = $_POST['starttime' . $x];
103
			$timehourstr .= "-";
104
			$timehourstr .= $_POST['stoptime' . $x];
105
			$timedescrstr = htmlentities($_POST['timedescr' . $x], ENT_QUOTES, 'UTF-8'); 
106
			$dashpos = strpos($timestr, '-');
107
			if ($dashpos === false)
108
			{
109 fdb29c8a Scott Dale
				$timeparts['position'] = $timestr;
110 273c8b1c Scott Dale
			}
111
			else
112
			{
113
				$tempindarray = array();
114
				$monthstr = "";
115
				$daystr = "";
116
				$tempindarray = explode(",", $timestr);
117
				foreach ($tempindarray as $currentselection)
118
				{
119
					if ($currentselection){
120
						if ($firstprint)
121
						{
122
							$monthstr .= ",";
123
							$daystr .= ",";						
124
						}
125
						$tempstr = "";
126
						$monthpos = strpos($currentselection, "m");
127
						$daypos = strpos($currentselection, "d");
128
						$monthstr .= substr($currentselection, $monthpos+1, $daypos-$monthpos-1);
129 6a6d2f63 Scott Dale
						$daystr .=  substr($currentselection, $daypos+1);			
130 273c8b1c Scott Dale
						$firstprint = true;
131
					}
132
				}
133
				$timeparts['month'] = $monthstr;
134
				$timeparts['day'] = $daystr;
135
			}			
136
			$timeparts['hour'] = $timehourstr;
137
			$timeparts['rangedescr'] = $timedescrstr;
138
			$schedule['timerange'][$x] = $timeparts;
139 615b27bc Scott Dale
		}
140
	}
141
	
142 e56fcb71 Scott Dale
	if (!$timerangeFound)
143
		$input_errors[] = "The schedule must have at least one time range configured.";
144 615b27bc Scott Dale
		
145
	if (!$input_errors) {		
146
		
147 273c8b1c Scott Dale
		if (isset($id) && $a_schedules[$id]){
148 615b27bc Scott Dale
			$a_schedules[$id] = $schedule;
149 273c8b1c Scott Dale
		}
150
		else{
151 615b27bc Scott Dale
			$a_schedules[] = $schedule;
152 273c8b1c Scott Dale
		}
153 615b27bc Scott Dale
		write_config();
154 72aea38d Scott Ullrich
		
155
		filter_configure();
156 615b27bc Scott Dale
			
157
		header("Location: firewall_schedule.php");
158
		exit;
159
		
160
	}
161
	//we received input errors, copy data to prevent retype
162
	else
163
	{
164 101fd849 Scott Dale
		if (!$_POST['schedule0'])
165
			$getSchedule = false;
166
		else
167
			$getSchedule = true;
168 273c8b1c Scott Dale
		$pconfig['name'] = $schedule['name'];
169
		$pconfig['descr'] = $schedule['descr'];
170 615b27bc Scott Dale
		$pconfig['timerange'] = $schedule['timerange'];
171
	}	
172
173
}
174
include("head.inc");
175
176
/* put your custom HTML head content here        */
177
/* using some of the $pfSenseHead function calls */
178
$jscriptstr = <<<EOD
179
<script type="text/javascript">
180
181
var daysSelected = "";
182
var month_array = ['January','February','March','April','May','June','July','August','September','October','November','December'];
183 6a6d2f63 Scott Dale
var day_array = ['Mon','Tues','Wed','Thur','Fri','Sat','Sun'];
184 615b27bc Scott Dale
var schCounter = 0;
185
186 273c8b1c Scott Dale
187
188 615b27bc Scott Dale
function repeatExistingDays(){
189
	var tempstr, tempstrdaypos, week, daypos, dayposdone = "";
190
	
191
	var dayarray = daysSelected.split(",");
192
	for (i=0; i<=dayarray.length; i++){
193
		tempstr = dayarray[i];
194
		tempstrdaypos = tempstr.search("p");
195
		week = tempstr.substring(1,tempstrdaypos);
196
		week = parseInt(week);
197
		dashpos = tempstr.search("-");		
198
		daypos = tempstr.substring(tempstrdaypos+1, dashpos);
199
		daypos = parseInt(daypos);
200
		
201
		daydone = dayposdone.search(daypos);
202
		tempstr = 'w' + week + 'p' + daypos;
203
		daycell = eval('document.getElementById(tempstr)');
204
		if (daydone == "-1"){
205
			if (daycell.style.backgroundColor == "lightcoral")
206
				daytogglerepeating(week,daypos,true);
207
			else
208
				daytogglerepeating(week,daypos,false);
209
			dayposdone += daypos + ",";
210
		}
211
	}	
212
}
213
214
function daytogglerepeating(week,daypos,bExists){
215
	var tempstr, daycell, dayoriginal = "";
216
	for (j=1; j<=53; j++)
217
	{						
218
		tempstr = 'w' + j + 'p' + daypos;
219
		daycell = eval('document.getElementById(tempstr)');
220
		dayoriginalpos =  daysSelected.indexOf(tempstr);
221
		
222
		//if bExists set to true, means cell is already select it
223
		//unselect it and remove original day from daysSelected string		
224
	
225
		if (daycell != null)
226
		{
227
			if (bExists){	
228
				daycell.style.backgroundColor = "WHITE";
229
			}
230
			else
231
			{
232
				daycell.style.backgroundColor = "lightcoral";		
233
			}	
234
	
235
			if (dayoriginalpos != "-1")
236
			{						
237
				dayoriginalend = daysSelected.indexOf(',', dayoriginalpos);
238
				tempstr = daysSelected.substring(dayoriginalpos, dayoriginalend+1);
239
				daysSelected = daysSelected.replace(tempstr, "");
240
				
241
			}				
242
		}			
243
	}	
244
}
245
	
246
function daytoggle(id) {
247
	var runrepeat, tempstr = "";
248
	var bFoundValid = false;
249
	
250
	iddashpos = id.search("-");
251
	var tempstrdaypos = id.search("p");
252
	var week = id.substring(1,tempstrdaypos);
253
	week = parseInt(week);
254
	
255
	if (iddashpos == "-1")
256
	{
257
		idmod = id;
258
		runrepeat = true;
259
		var daypos = id.substr(tempstrdaypos+1);	
260
	}
261
	else
262
	{		
263
		idmod = id.substring(0,iddashpos);
264
		var daypos = id.substring(tempstrdaypos+1,iddashpos);
265
	}
266
	
267
	daypos = parseInt(daypos);
268
	
269
	while (!bFoundValid){
270
		var daycell = document.getElementById(idmod);		
271
	
272
		if (daycell != null){
273
			if (daycell.style.backgroundColor == "RED"){
274
				daycell.style.backgroundColor = "WHITE";
275
				str = id + ",";
276
				daysSelected = daysSelected.replace(str, "");
277
			}
278
			else if (daycell.style.backgroundColor == "lightcoral")
279
			{
280
				daytogglerepeating(week,daypos,true);
281
			}
282
			else //color is white cell
283
			{
284
				if (!runrepeat)
285
				{
286
					daycell.style.backgroundColor = "RED";
287
				}
288
				else
289
				{
290
					daycell.style.backgroundColor = "lightcoral";
291
					daytogglerepeating(week,daypos,false);								
292
				}
293
				daysSelected += id + ",";
294
			}
295
			bFoundValid = true;
296
		}
297
		else
298
		{
299
			//we found an invalid cell when column was clicked, move up to the next week
300
			week++;
301
			tempstr = "w" + week + "p" + daypos;
302
			idmod = tempstr;			
303
		}
304
	}
305
}
306
307
function update_month(){
308
	var indexNum = document.forms[0].monthsel.selectedIndex;
309
	var selected = document.forms[0].monthsel.options[indexNum].text;
310
311
	for (i=0; i<=11; i++){
312
		option = document.forms[0].monthsel.options[i].text;
313
		document.popupMonthLayer = eval('document.getElementById (option)');
314
		
315
		if(selected == option) {
316
			document.popupMonthLayer.style.display="block";
317
		}
318
		else
319
			document.popupMonthLayer.style.display="none";
320
	}
321
}
322
323 101fd849 Scott Dale
function checkForRanges(){
324
	if (daysSelected != "")
325
	{
326 636a69e6 Scott Dale
		alert("You have not saved the specified time range. Please click 'Add Time' button to save the time range.");
327 615b27bc Scott Dale
		return false;
328 101fd849 Scott Dale
	}
329 615b27bc Scott Dale
	else
330 101fd849 Scott Dale
	{
331 615b27bc Scott Dale
		return true;
332 101fd849 Scott Dale
	}
333 615b27bc Scott Dale
}
334
335
function processEntries(){
336
	var tempstr, starttimehour, starttimemin, stoptimehour, stoptimemin, errors = "";
337
	var passedValidiation = true;
338
	
339
	//get time specified
340
	starttimehour = parseInt(document.getElementById("starttimehour").value);
341
	starttimemin = parseInt(document.getElementById("starttimemin").value);
342
	stoptimehour = parseInt(document.getElementById("stoptimehour").value);
343
	stoptimemin = parseInt(document.getElementById("stoptimemin").value);
344
345 273c8b1c Scott Dale
346 615b27bc Scott Dale
	//do time checks	
347
	if (starttimehour > stoptimehour)
348
	{
349
		errors = "Error: Start Hour cannot be greater than Stop Hour.";
350
		passedValidiation = false;
351 273c8b1c Scott Dale
		
352 615b27bc Scott Dale
	}
353 273c8b1c Scott Dale
	else if (starttimehour == stoptimehour)
354 615b27bc Scott Dale
	{
355
		if (starttimemin > stoptimemin){
356
			errors = "Error: Start Minute cannot be greater than Stop Minute.";
357
			passedValidiation = false;
358
		}
359
	}	
360 273c8b1c Scott Dale
		
361 615b27bc Scott Dale
	if (passedValidiation){
362
		addTimeRange();
363
	}
364 273c8b1c Scott Dale
	else {
365
		if (errors != "")
366
			alert(errors);
367
	}
368 615b27bc Scott Dale
}
369
370
function addTimeRange(){
371
	var tempdayarray = daysSelected.split(",");
372 273c8b1c Scott Dale
	var tempstr, tempFriendlyDay, starttimehour, starttimemin, stoptimehour, nrtempFriendlyTime, rtempFriendlyTime, nrtempID, rtempID = "";
373 1a4f3123 Scott Dale
	var stoptimemin, timeRange, tempstrdaypos, week, daypos, day, month, dashpos, nrtempTime, rtempTime, monthstr, daystr = "";
374 273c8b1c Scott Dale
	rtempFriendlyTime = "";
375
	nrtempFriendlyTime = "";
376
	nrtempID = "";
377
	rtempID = "";
378
	nrtempTime = "";
379
	rtempTime = "";
380 615b27bc Scott Dale
	tempdayarray.sort();	
381 273c8b1c Scott Dale
	rtempFriendlyDay = "";
382 1a4f3123 Scott Dale
	monthstr = "";
383
	daystr = "";
384 615b27bc Scott Dale
	
385
	//check for existing entries
386
	var findCurrentCounter;
387
	for (u=0; u<99; u++){
388
		findCurrentCounter = document.getElementById("schedule" + u);
389
		if (!findCurrentCounter)
390
		{
391
			schCounter = u;
392
			break;
393
		}
394
	}
395 273c8b1c Scott Dale
		
396 615b27bc Scott Dale
	if (daysSelected != ""){
397
		//get days selected
398
		for (i=0; i<tempdayarray.length; i++)
399
		{
400
			tempstr = tempdayarray[i];
401
			if (tempstr != "")
402
			{			
403
				tempstrdaypos = tempstr.search("p");
404
				week = tempstr.substring(1,tempstrdaypos);
405
				week = parseInt(week);
406
				dashpos = tempstr.search("-");			
407
				
408
				if (dashpos != "-1")
409 273c8b1c Scott Dale
				{	
410
					var nonrepeatingfound = true;
411 615b27bc Scott Dale
					daypos = tempstr.substring(tempstrdaypos+1, dashpos);
412
					daypos = parseInt(daypos);	
413
					monthpos = tempstr.search("m");	
414
					tempstrdaypos = tempstr.search("d");
415
					month = tempstr.substring(monthpos+1, tempstrdaypos);
416
					month = parseInt(month);
417
					day = tempstr.substring(tempstrdaypos+1);
418
					day = parseInt(day);
419 1a4f3123 Scott Dale
					monthstr += month + ",";
420
					daystr += day + ",";
421 273c8b1c Scott Dale
					nrtempID += tempstr + ",";
422 615b27bc Scott Dale
				}
423
				else
424
				{	
425 273c8b1c Scott Dale
					var repeatingfound = true;
426 615b27bc Scott Dale
					daypos = tempstr.substr(tempstrdaypos+1);
427
					daypos = parseInt(daypos);	
428 273c8b1c Scott Dale
					rtempFriendlyDay += daypos + ",";
429
					rtempID += daypos + ",";					
430 615b27bc Scott Dale
				}		
431
			}				
432
		}	
433
		
434 1a4f3123 Scott Dale
		//code below spits out friendly look format for nonrepeating schedules
435 615b27bc Scott Dale
		var foundEnd = false;
436
		var firstDayFound = false;
437
		var firstprint = false;
438 1a4f3123 Scott Dale
		var tempFriendlyMonthArray = monthstr.split(",");
439
		var tempFriendlyDayArray = daystr.split(",");
440
		var currentDay, firstDay, nextDay, currentMonth, nextMonth, firstDay, firstMonth = "";
441
		for (k=0; k<tempFriendlyMonthArray.length; k++){
442
			tempstr = tempFriendlyMonthArray[k];
443
			if (tempstr != ""){
444
				if (!firstDayFound)
445
				{
446
					firstDay = tempFriendlyDayArray[k];
447
					firstDay = parseInt(firstDay);
448
					firstMonth = tempFriendlyMonthArray[k];
449
					firstMonth = parseInt(firstMonth);
450
					firstDayFound = true;
451
				}
452
				currentDay = tempFriendlyDayArray[k];
453
				currentDay = parseInt(currentDay);
454
				//get next day
455
				nextDay = tempFriendlyDayArray[k+1];
456
				nextDay = parseInt(nextDay);
457
				//get next month
458
				
459
				currentDay++;						
460
				if ((currentDay != nextDay) || (tempFriendlyMonthArray[k] != tempFriendlyMonthArray[k+1])){
461
					if (firstprint)
462
						nrtempFriendlyTime += ", ";
463
					currentDay--;
464
					if (currentDay != firstDay)
465
						nrtempFriendlyTime += month_array[firstMonth-1] + " " + firstDay + "-" + currentDay;
466
					else
467
						nrtempFriendlyTime += month_array[firstMonth-1] + " " + currentDay; 
468
					firstDayFound = false;	
469
					firstprint = true;			
470
				}
471
			}			
472
		}		
473
		
474
		//code below spits out friendly look format for repeating schedules
475
		foundEnd = false;
476
		firstDayFound = false;
477
		firstprint = false;
478
		tempFriendlyDayArray = rtempFriendlyDay.split(",");
479 273c8b1c Scott Dale
		tempFriendlyDayArray.sort();
480 1a4f3123 Scott Dale
		currentDay, firstDay, nextDay = "";
481 615b27bc Scott Dale
		for (k=0; k<tempFriendlyDayArray.length; k++){
482
			tempstr = tempFriendlyDayArray[k];
483
			if (tempstr != ""){
484
				if (!firstDayFound)
485
				{
486
					firstDay = tempFriendlyDayArray[k];
487
					firstDay = parseInt(firstDay);
488
					firstDayFound = true;
489
				}
490
				currentDay = tempFriendlyDayArray[k];
491
				currentDay = parseInt(currentDay);
492
				//get next day
493
				nextDay = tempFriendlyDayArray[k+1];
494
				nextDay = parseInt(nextDay);
495
				currentDay++;					
496
				if (currentDay != nextDay){
497
					if (firstprint)
498 273c8b1c Scott Dale
						rtempFriendlyTime += ", ";
499 615b27bc Scott Dale
					currentDay--;
500
					if (currentDay != firstDay)
501 6a6d2f63 Scott Dale
						rtempFriendlyTime += day_array[firstDay-1] + " - " + day_array[currentDay-1];
502 615b27bc Scott Dale
					else
503 6a6d2f63 Scott Dale
						rtempFriendlyTime += day_array[firstDay-1];
504 615b27bc Scott Dale
					firstDayFound = false;	
505
					firstprint = true;			
506
				}
507
			}
508
		}			
509
		
510 273c8b1c Scott Dale
		//sort the tempID
511
		var tempsortArray = rtempID.split(",");
512
		var isFirstdone = false;
513
		tempsortArray.sort();
514
		//clear tempID
515
		rtempID = "";
516
		for (t=0; t<tempsortArray.length; t++)
517
		{
518
			if (tempsortArray[t] != ""){
519
				if (!isFirstdone){
520
					rtempID += tempsortArray[t];
521
					isFirstdone = true;
522
				}
523
				else
524
					rtempID += "," + tempsortArray[t];
525
			}
526
		} 
527
		
528 615b27bc Scott Dale
		 
529
		//get time specified
530 101fd849 Scott Dale
		starttimehour =  document.getElementById("starttimehour").value
531 615b27bc Scott Dale
		starttimemin = document.getElementById("starttimemin").value;
532
		stoptimehour = document.getElementById("stoptimehour").value;
533
		stoptimemin = document.getElementById("stoptimemin").value;
534
		
535
		timeRange = "||" + starttimehour + ":";
536
		timeRange += starttimemin + "-";
537
		timeRange += stoptimehour + ":";	
538 273c8b1c Scott Dale
		timeRange += stoptimemin;		
539
				
540 615b27bc Scott Dale
		//get description for time range
541 273c8b1c Scott Dale
		var tempdescr = document.getElementById("timerangedescr").value		
542
		
543
		if (nonrepeatingfound){
544
			nrtempTime += nrtempID;
545
			//add time ranges
546
			nrtempTime += timeRange;			
547
			//add description
548
			nrtempTime += "||" + tempdescr;
549
			insertElements(nrtempFriendlyTime, starttimehour, starttimemin, stoptimehour, stoptimemin, tempdescr, nrtempTime, nrtempID);
550
		}
551 615b27bc Scott Dale
		
552 273c8b1c Scott Dale
		if (repeatingfound){
553
			rtempTime += rtempID;
554
			//add time ranges
555
			rtempTime += timeRange;
556
			//add description
557
			rtempTime += "||" + tempdescr;
558
			insertElements(rtempFriendlyTime, starttimehour, starttimemin, stoptimehour, stoptimemin, tempdescr, rtempTime, rtempID);
559
		}
560 615b27bc Scott Dale
		
561 273c8b1c Scott Dale
	}
562
	else
563
	{
564
		//no days were selected, alert user
565
		alert ("You must select at least 1 day before adding time");
566
	}
567
}
568
569
function insertElements(tempFriendlyTime, starttimehour, starttimemin, stoptimehour, stoptimemin, tempdescr, tempTime, tempID){
570
	
571 615b27bc Scott Dale
		//add it to the schedule list
572
		d = document;
573
		tbody = d.getElementById("scheduletable").getElementsByTagName("tbody").item(0);
574
		tr = d.createElement("tr");
575
		td = d.createElement("td");
576 1a4f3123 Scott Dale
		td.innerHTML= "<span class='vexpl'>" + tempFriendlyTime + "</span>";
577 615b27bc Scott Dale
		tr.appendChild(td);	
578
			
579
		td = d.createElement("td");
580 2a113ca9 Scott Dale
		td.innerHTML="<input type='text' readonly class='vexpl' name='starttime" + schCounter + "' id='starttime" + schCounter + "' style=' word-wrap:break-word; width:100%; border:0px solid;' value='" + starttimehour + ":" + starttimemin + "'>";
581 615b27bc Scott Dale
		tr.appendChild(td);
582
		
583
		td = d.createElement("td");
584 2a113ca9 Scott Dale
		td.innerHTML="<input type='text' readonly class='vexpl' name='stoptime" + schCounter + "' id='stoptime" + schCounter + "' style=' word-wrap:break-word; width:100%; border:0px solid;' value='" + stoptimehour + ":" + stoptimemin + "'>";
585 615b27bc Scott Dale
		tr.appendChild(td);
586
		
587
		td = d.createElement("td");
588 2a113ca9 Scott Dale
		td.innerHTML="<input type='text' readonly class='vexpl' name='timedescr" + schCounter + "' id='timedescr" + schCounter + "' style=' word-wrap:break-word; width:100%; border:0px solid;' value='" + tempdescr + "'>";
589 615b27bc Scott Dale
		tr.appendChild(td);
590
		
591
		td = d.createElement("td");
592 636a69e6 Scott Dale
		td.innerHTML = "<input type='image' src='/themes/" + theme + "/images/icons/icon_e.gif' onclick='editRow(\"" + tempTime + "\",this); return false;' value='Edit'>";
593 615b27bc Scott Dale
		tr.appendChild(td);
594
			
595
		td = d.createElement("td");
596
		td.innerHTML = "<input type='image' src='/themes/" + theme + "/images/icons/icon_x.gif' onclick='removeRow(this); return false;' value='Delete'>";
597
		tr.appendChild(td);
598
		
599
		td = d.createElement("td");		
600
		td.innerHTML="<input type='hidden' id='schedule" + schCounter + "' name='schedule" + schCounter + "' value='" + tempID + "'>";		
601
		tr.appendChild(td);
602
		tbody.appendChild(tr);
603
		
604
		schCounter++;
605
		
606
		//reset calendar and time and descr
607
		clearCalendar();
608
		clearTime();
609
		clearDescr();
610
}
611
612
613
function clearCalendar(){
614
	var tempstr, daycell = "";
615
	//clear days selected
616
	daysSelected = "";
617
	//loop through all 52 weeks
618
	for (j=1; j<=53; j++)
619
	{
620
		//loop through all 7 days
621 6a6d2f63 Scott Dale
		for (k=1; k<8; k++){
622 615b27bc Scott Dale
			tempstr = 'w' + j + 'p' + k;
623
			daycell = eval('document.getElementById(tempstr)');
624
			if (daycell != null){
625
				daycell.style.backgroundColor = "WHITE";	
626
			}	
627
		}
628
	}	
629
}
630
631
function clearTime(){
632
	document.getElementById("starttimehour").value = $starttimehr;
633
	document.getElementById("starttimemin").value = $starttimemin;
634
	document.getElementById("stoptimehour").value = $stoptimehr;
635
	document.getElementById("stoptimemin").value = $stoptimemin;
636
}
637
638
function clearDescr(){
639
	document.getElementById("timerangedescr").value = "";
640
}
641
642 636a69e6 Scott Dale
function editRow(incTime, el) {
643
	var check = checkForRanges();
644 615b27bc Scott Dale
	
645 636a69e6 Scott Dale
	if (check){  
646
		
647
		//reset calendar and time
648
		clearCalendar();
649
		clearTime();
650
		
651
		var starttimehour, descr, days, tempstr, starttimemin, hours, stoptimehour, stoptimemin = ""; 
652
		
653
		tempArray = incTime.split ("||");
654
		
655
		days = tempArray[0];
656
		hours = tempArray[1];
657
		descr = tempArray[2];
658
		
659
		var tempdayArray = days.split(",");
660
		var temphourArray = hours.split("-");
661
		tempstr = temphourArray[0];
662
		var temphourArray2 = tempstr.split(":");
663 615b27bc Scott Dale
	
664 636a69e6 Scott Dale
		document.getElementById("starttimehour").value = temphourArray2[0];
665
		document.getElementById("starttimemin").value = temphourArray2[1];	
666
		
667
		tempstr = temphourArray[1];
668
		temphourArray2 = tempstr.split(":");
669
		
670
		document.getElementById("stoptimehour").value = temphourArray2[0];
671
		document.getElementById("stoptimemin").value = temphourArray2[1];
672
		
673
		document.getElementById("timerangedescr").value = descr;
674 615b27bc Scott Dale
	
675 636a69e6 Scott Dale
		//toggle the appropriate days
676
		for (i=0; i<tempdayArray.length; i++)
677
		{
678
			if (tempdayArray[i]){
679
				var tempweekstr = tempdayArray[i];
680
				dashpos = tempweekstr.search("-");			
681
						
682
				if (dashpos == "-1")
683
				{
684
					tempstr = "w2p" + tempdayArray[i];
685
				}
686
				else
687
				{
688
					tempstr = tempdayArray[i];
689
				}
690
				daytoggle(tempstr);
691 273c8b1c Scott Dale
			}
692 615b27bc Scott Dale
		}
693 636a69e6 Scott Dale
		removeRownoprompt(el);
694 615b27bc Scott Dale
	}
695
}
696
697 636a69e6 Scott Dale
function removeRownoprompt(el) {
698 615b27bc Scott Dale
    var cel;
699
    while (el && el.nodeName.toLowerCase() != "tr")
700
	    el = el.parentNode;
701
702
    if (el && el.parentNode) {
703
	cel = el.getElementsByTagName("td").item(0);
704
	el.parentNode.removeChild(el);
705
    }
706
}
707
708 636a69e6 Scott Dale
709
function removeRow(el) {
710
	var check = confirm ("Do you really want to delete this time range?");
711
	if (check){
712
	    var cel;
713
	    while (el && el.nodeName.toLowerCase() != "tr")
714
		    el = el.parentNode;
715
	
716
	    if (el && el.parentNode) {
717
		cel = el.getElementsByTagName("td").item(0);
718
		el.parentNode.removeChild(el);
719
	    }
720
	}
721
}
722
723 615b27bc Scott Dale
</script>
724
EOD;
725
?>
726
727
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
728
729
730
<?php include("fbegin.inc");	echo $jscriptstr; ?>
731
732
<p class="pgtitle"><?=$pgtitle?></p>
733
734
<?php if ($input_errors) print_input_errors($input_errors); ?>
735
<div id="inputerrors"></div>
736
737
<form action="firewall_schedule_edit.php" method="post" name="iform" id="iform">
738
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
739
        <tr>
740
          <td>
741
			  <table width="100%" border="0" cellpadding="6" cellspacing="0">
742
               	<tr>
743
				  <td width="15%" valign="top" class="vncellreq">Schedule Name</td>
744
				  <td width="85%" class="vtable">
745 636a69e6 Scott Dale
				  <?php if(is_schedule_inuse($pconfig['name']) == true): ?>
746
				  			<input name="name" type="hidden" id="name" size="40"  value="<?=htmlspecialchars($pconfig['name']);?>" />
747
						  <?php echo $pconfig['name']; ?>
748
						      <p>
749
						        <span class="vexpl">NOTE: This schedule is in use so the name may not be modified!</span>
750
						      </p>
751
				<?php else: ?>
752
				  <input name="name" type="text" id="name" size="40" maxlength="40" class="formfld" value="<?=htmlspecialchars($pconfig['name']);?>"><br>
753 615b27bc Scott Dale
				      	<span class="vexpl">
754 636a69e6 Scott Dale
     					   The name of the alias may only consist of the characters a-z, A-Z and 0-9
755
      					</span>
756
      			<?php endif; ?>   					
757 615b27bc Scott Dale
				  </td>
758
				</tr>
759
				<tr>
760
					<td width="15%" valign="top" class="vncell">Description</td>
761 636a69e6 Scott Dale
					<td width="85%" class="vtable"><input name="descr" type="text" id="descr" size="40" maxlength="40" class="formfld" value="<?=htmlspecialchars($pconfig['descr']);?>"><br>
762 615b27bc Scott Dale
 						<span class="vexpl">
763
				        	You may enter a description here for your reference (not parsed).
764 636a69e6 Scott Dale
				      	</span>
765
				  
766
					</td>
767 615b27bc Scott Dale
				</tr>
768
				<tr>
769
				</tr>
770
			    <tr>
771
				  <td width="15%" valign="top" class="vncellreq">Month</td>
772
				  <td width="85%" class="vtable">
773
                    <select name="monthsel" class="formselect" id="monthsel" onchange="update_month();">
774
                    	<?php 
775
                    	$monthcounter = date("n");
776
                    	$monthlimit = $monthcounter + 12;
777 6a6d2f63 Scott Dale
                    	$yearcounter = date("Y");
778 273c8b1c Scott Dale
                    	for ($k=0; $k<12; $k++){?>	             
779 6a6d2f63 Scott Dale
                    		<option value="<?php echo $monthcounter;?>"><?php echo date("F y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></option>
780 273c8b1c Scott Dale
                          <?php        	
781
                          if ($monthcounter == 12)
782
							{
783
								$monthcounter = 1;
784 6a6d2f63 Scott Dale
								$yearcounter++;
785 273c8b1c Scott Dale
							}
786
							else
787
							{
788
								$monthcounter++;
789
							}	
790
						} ?>      	
791 615b27bc Scott Dale
                    </select><br><br>
792
            		<?php
793
            		$firstmonth = TRUE;
794
            		$monthcounter = date("n");
795 6a6d2f63 Scott Dale
            		$yearcounter = date("Y");
796 273c8b1c Scott Dale
            		for ($k=0; $k<12; $k++){
797 6a6d2f63 Scott Dale
						$firstdayofmonth = date("w", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));
798
						if ($firstdayofmonth == 0)
799
							$firstdayofmonth = 7;
800
							
801 273c8b1c Scott Dale
						$daycounter = 1;
802
						//number of day in month
803 6a6d2f63 Scott Dale
						$numberofdays = date("t", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));
804 615b27bc Scott Dale
						$firstdayprinted = FALSE;
805
						$lasttr = FALSE;
806 6a6d2f63 Scott Dale
						$positioncounter = 1;//7 for Sun, 1 for Mon, 2 for Tues, etc						
807 615b27bc Scott Dale
						?>	
808 6a6d2f63 Scott Dale
	                        <div id="<?php echo date("F y",mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?>" z-index:-1000; style="position:relative; display:<?php if($firstmonth)echo "block";else echo "none";?>">    	
809 615b27bc Scott Dale
		                   	<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1 id="calTable" class="tabcont">
810 6a6d2f63 Scott Dale
								<TR><TD COLSPAN="7" ALIGN=center class="listbg"><B><font color="white"><?php echo date("F Y", mktime(0, 0, 0, date($monthcounter), 1, date($yearcounter)));?></B></TD>
811 273c8b1c Scott Dale
								</TR>							
812 6a6d2f63 Scott Dale
								<TR>																
813 615b27bc Scott Dale
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p1');"><u><b>Mon</b></u></TD>
814
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p2');"><u><b>Tue</b></u></TD>
815
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p3');"><u><b>Wed</b></u></TD>
816
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p4');"><u><b>Thu</b></u></TD>
817
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p5');"><u><b>Fri</b></u></TD>
818 273c8b1c Scott Dale
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p6');"><u><b>Sat</b></u></TD>
819 6a6d2f63 Scott Dale
									<TD ALIGN=center class="listhdrr" style="cursor: pointer;" onClick="daytoggle('w1p7');"><u><b>Sun</b></u></TD>
820 615b27bc Scott Dale
								</TR>
821
								<?php			
822
								$firstmonth = FALSE;				
823 273c8b1c Scott Dale
								while ($daycounter<=$numberofdays){
824 6a6d2f63 Scott Dale
									$weekcounter =  date("W", mktime(0, 0, 0, date($monthcounter), date($daycounter), date($yearcounter)));
825
									$weekcounter = ltrim($weekcounter, "0");
826
									if ($positioncounter == 1)
827 615b27bc Scott Dale
									{
828
										echo "<tr>";
829
									}											
830 273c8b1c Scott Dale
									if ($firstdayofmonth == $positioncounter){?>
831
										<TD ALIGN=center style="cursor: pointer;" class="listr" id="w<?=$weekcounter;?>p<?=$positioncounter;?>" onClick="daytoggle('w<?=$weekcounter;?>p<?=$positioncounter;?>-m<?=$monthcounter;?>d<?=$daycounter;?>');">
832 615b27bc Scott Dale
										<?php echo $daycounter;
833
										$daycounter++;
834
										$firstdayprinted = TRUE;
835
										echo "</td>";
836
									}
837
									elseif ($firstdayprinted == TRUE && $daycounter <= $numberofdays){?>
838 273c8b1c Scott Dale
										<TD ALIGN=center style="cursor: pointer;" class="listr" id="w<?=$weekcounter;?>p<?=$positioncounter;?>" onClick="daytoggle('w<?=$weekcounter;?>p<?=$positioncounter;?>-m<?=$monthcounter;?>d<?=$daycounter;?>');">
839 615b27bc Scott Dale
										<?php echo $daycounter;
840
										$daycounter++;
841
										echo "</td>";
842
									}
843
									else
844
									{
845
										echo "<td align=center class=\"listr\"></td>";
846
									}
847
									
848 6a6d2f63 Scott Dale
									if ($positioncounter ==7){
849
										$positioncounter = 1;
850 615b27bc Scott Dale
										echo "</tr>";
851
									}
852
									else{
853 273c8b1c Scott Dale
										$positioncounter++;
854 6a6d2f63 Scott Dale
									}
855
								
856 273c8b1c Scott Dale
								}//end while loop?>	
857 615b27bc Scott Dale
							</TABLE>
858
							</div>
859 273c8b1c Scott Dale
					<?php 
860
						
861
						if ($monthcounter == 12)
862
						{
863
							$monthcounter = 1;
864 6a6d2f63 Scott Dale
							$yearcounter++;
865 273c8b1c Scott Dale
						}
866
						else
867
						{
868
							$monthcounter++;
869
						}					
870
					} //end for loop
871 615b27bc Scott Dale
					?>
872
							<br/>
873
					Click individual date to select that date only. Click the appropriate weekday Header to select all occurences of that weekday.
874
	                 </td>
875
				</tr>
876
				<tr>
877
				  <td width="15%" valign="top" class="vncellreq">Time</td>
878
				  <td width="85%" class="vtable">
879
				  	<table cellspacing=2 class="tabcont">
880
				  		<tr>
881
				  			<td class="listhdrr" align="center">Start Time</td><td></td><td class="listhdrr" align="center">Stop Time</td>
882
				  		</tr>
883
				  		<tr>
884
				  			<td>
885 f124cb15 Scott Dale
				  				<select name="starttimehour" class="formfld" id="starttimehour">
886 101fd849 Scott Dale
				  					<?php 
887
				  						for ($i=0; $i<24; $i++)
888
				  						{				  							
889
				  							echo "<option value=\"$i\">";
890
				  							echo $i;
891
				  							echo "</option>";
892
				  						}
893
				  					?>
894
				  				</select>&nbsp;Hr&nbsp;&nbsp;
895 f124cb15 Scott Dale
				  				<select name="starttimemin" class="formfld" id="starttimemin">
896 b9f7b277 Scott Ullrich
				  					<option value="00">00</option>
897 101fd849 Scott Dale
				  					<option value="15">15</option>
898
				  					<option value="30">30</option>
899
				  					<option value="45">45</option>
900 ee3f99f1 Scott Ullrich
				  					<option value="59">59</option>
901 101fd849 Scott Dale
				  				</select>&nbsp;Min
902 615b27bc Scott Dale
				  			</td>
903
				  			<td></td>
904
				  			<td>
905 f124cb15 Scott Dale
				  				<select name="stoptimehour" class="formfld" id="stoptimehour">
906 101fd849 Scott Dale
				  				<?php 
907
				  						for ($i=0; $i<24; $i++)
908
				  						{
909
				  							if ($i==23)
910
				  								$selected = "SELECTED";
911
				  							else
912
				  								$selected = "";
913
				  								
914
				  							echo "<option value=\"$i\" $selected>";
915
				  							echo $i;
916
				  							echo "</option>";
917
				  						}
918
				  					?>
919
				  				</select>&nbsp;Hr&nbsp;&nbsp;
920 f124cb15 Scott Dale
				  				<select name="stoptimemin" class="formfld" id="stoptimemin">
921 2a113ca9 Scott Dale
				  					<option value="00">00</option>
922 101fd849 Scott Dale
				  					<option value="15">15</option>
923
				  					<option value="30">30</option>
924
				  					<option value="45">45</option>
925
				  					<option value="59" SELECTED>59</option>
926
				  				</select>&nbsp;Min
927 615b27bc Scott Dale
				  			</td>
928
				  		</tr>
929
				  	</table><br>
930 cd110adf Scott Dale
                    Select the time range for the day(s) selected on the Month(s) above. A full day is 0:00-23:59.
931 615b27bc Scott Dale
					</td>
932
				</tr>
933
				<tr>
934
					<td width="15%" valign="top" class="vncell">Time Range Description</td>
935 636a69e6 Scott Dale
					<td width="85%" class="vtable"><input name="timerangedescr" type="text" class="formfld" id="timerangedescr" size="40" maxlength="40"><br>
936 615b27bc Scott Dale
 						<span class="vexpl">
937
				        	You may enter a description here for your reference (not parsed).
938
				      	</span>     
939
				      </td>					
940
				</tr>
941
				<tr>
942
				  <td width="22%" valign="top">&nbsp;</td>
943
				  <td width="78%">
944
				  	<input type="button" value="Add Time"  class="formbtn"  onclick="javascript:processEntries();">&nbsp;&nbsp;&nbsp;
945
				  	<input type="button" value="Clear Selection" class="formbtn" onclick="javascript:clearCalendar(); clearTime(); clearDescr();">
946
                    </td>
947
				</tr>
948
				<tr>
949
				  <td width="15%" valign="top" class="vtable"></td>
950
				  <td width="85%" class="vtable">
951
                    </td>
952
				</tr>
953
954
				<tr>
955
					<td width="15%" valign="top" class="vncellreq">Configured Ranges</td>
956
					<td width="85%">
957
						<table id="scheduletable">
958
							<tbody>
959
								<tr>
960
									<TD  ALIGN=center class="listbg" width="35%"><font color="white">Day(s)</td>
961
									<TD  ALIGN=center class="listbg" width="12%"><font color="white">Start Time</td>
962
									<TD  ALIGN=center class="listbg" width="11%"><font color="white">Stop Time</td>
963
									<TD  ALIGN=center class="listbg" width="42%"><font color="white">Description</td>
964
								</tr>
965
								<?php
966
								if ($getSchedule){
967
									$counter = 0;
968 273c8b1c Scott Dale
																		
969
									foreach($pconfig['timerange'] as $timerange) {
970 615b27bc Scott Dale
										$tempFriendlyTime = "";
971 273c8b1c Scott Dale
										$tempID = "";
972 615b27bc Scott Dale
										if ($timerange){
973 273c8b1c Scott Dale
											$dayFriendly = "";
974
											$tempFriendlyTime = "";
975 2a113ca9 Scott Dale
											$timedescr = $timerange['rangedescr'];			
976 273c8b1c Scott Dale
												
977
											//get hours
978
											$temptimerange = $timerange['hour'];
979 615b27bc Scott Dale
											$temptimeseparator = strrpos($temptimerange, "-");
980
											
981
											$starttime = substr ($temptimerange, 0, $temptimeseparator); 
982
											$stoptime = substr ($temptimerange, $temptimeseparator+1); 
983 1a4f3123 Scott Dale
											$currentDay = "";
984
											$firstDay = "";
985
											$nextDay = "";
986
											$foundEnd = false;
987
											$firstDayFound = false;
988
											$firstPrint = false;	
989
											$firstprint2 = false;
990
											
991 273c8b1c Scott Dale
											if ($timerange['month']){
992
												$tempmontharray = explode(",", $timerange['month']);
993
												$tempdayarray = explode(",",$timerange['day']);
994
												$arraycounter = 0;
995
												foreach ($tempmontharray as $monthtmp){
996
													$month = $tempmontharray[$arraycounter];
997
													$day = $tempdayarray[$arraycounter];
998
													$daypos = date("w", mktime(0, 0, 0, date($month), date($day), date("Y")));
999 6a6d2f63 Scott Dale
													//if sunday, set position to 7 to get correct week number. This is due to php limitations on ISO-8601. When we move to php5.1 we can change this.
1000 1a4f3123 Scott Dale
													if ($daypos == 0){
1001
														$daypos = 7;
1002
													}									
1003 6a6d2f63 Scott Dale
													$weeknumber = date("W", mktime(0, 0, 0, date($month), date($day), date("Y")));
1004 1a4f3123 Scott Dale
													$weeknumber = ltrim($weeknumber, "0");		
1005
																										
1006 6a6d2f63 Scott Dale
													if ($firstPrint)
1007 273c8b1c Scott Dale
													{
1008
														$tempID .= ",";
1009 615b27bc Scott Dale
													}
1010 6a6d2f63 Scott Dale
													$tempID .= "w" . $weeknumber . "p" . $daypos . "-m" .  $month . "d" . $day;
1011
													$firstPrint = true;
1012 1a4f3123 Scott Dale
													
1013
													if (!$firstDayFound)
1014
													{
1015
														$firstDay = $day;
1016
														$firstmonth = $month;
1017
														$firstDayFound = true;
1018
													}
1019
														
1020
													$currentDay = $day;
1021
													$nextDay = $tempdayarray[$arraycounter+1];
1022
													$currentDay++;
1023
													if (($currentDay != $nextDay) || ($tempmontharray[$arraycounter] != $tempmontharray[$arraycounter+1])){
1024
														if ($firstprint2)
1025
															$tempFriendlyTime .= ", ";
1026
														$currentDay--;
1027
														if ($currentDay != $firstDay)
1028
															$tempFriendlyTime .= $monthArray[$firstmonth-1] . " " . $firstDay . " - " . $currentDay ;
1029
														else
1030
															$tempFriendlyTime .=  $monthArray[$month-1] . " " . $day;
1031
														$firstDayFound = false;	
1032
														$firstprint2 = true;
1033
													}													
1034
													$arraycounter++;			
1035
												}																						
1036
												
1037 615b27bc Scott Dale
											}
1038 273c8b1c Scott Dale
											else
1039
											{
1040 fdb29c8a Scott Dale
												$dayFriendly = $timerange['position'];
1041 273c8b1c Scott Dale
												$tempID = $dayFriendly;
1042
											}											
1043 615b27bc Scott Dale
											
1044 273c8b1c Scott Dale
											$tempTime = $tempID . "||" . $starttime . "-" . $stoptime . "||" . $timedescr;
1045
									
1046
											//following code makes the days friendly appearing, IE instead of Mon, Tues, Wed it will show Mon - Wed
1047
											$foundEnd = false;
1048
											$firstDayFound = false;
1049
											$firstprint = false;
1050
											$tempFriendlyDayArray = explode(",", $dayFriendly);
1051
											$currentDay = "";
1052
											$firstDay = "";
1053
											$nextDay = "";
1054
											$i = 0;
1055
											if (!$timerange['month']){										
1056 615b27bc Scott Dale
												foreach ($tempFriendlyDayArray as $day){
1057
													if ($day != ""){
1058
														if (!$firstDayFound)
1059
														{
1060
															$firstDay = $tempFriendlyDayArray[$i];
1061
															$firstDayFound = true;
1062
														}
1063
														$currentDay =$tempFriendlyDayArray[$i];
1064
														//get next day
1065
														$nextDay = $tempFriendlyDayArray[$i+1];
1066
														$currentDay++;					
1067
														if ($currentDay != $nextDay){
1068
															if ($firstprint)
1069
																$tempFriendlyTime .= ", ";
1070
															$currentDay--;
1071
															if ($currentDay != $firstDay)
1072 6a6d2f63 Scott Dale
																$tempFriendlyTime .= $dayArray[$firstDay-1] . " - " . $dayArray[$currentDay-1];
1073 615b27bc Scott Dale
															else
1074 6a6d2f63 Scott Dale
																$tempFriendlyTime .= $dayArray[$firstDay-1];
1075 615b27bc Scott Dale
															$firstDayFound = false;	
1076
															$firstprint = true;			
1077
														}
1078
														$i++;
1079
													}
1080 273c8b1c Scott Dale
												}		
1081
											}	
1082 615b27bc Scott Dale
												
1083
																																													
1084
									?>
1085
						          <tr>
1086
						          	<td>
1087 1a4f3123 Scott Dale
						          		<span class="vexpl"><?php echo $tempFriendlyTime; ?><span>
1088 615b27bc Scott Dale
						          	</td>
1089
									<td>
1090 2a113ca9 Scott Dale
						              <input type='text' readonly class='vexpl' name='starttime<?php echo $counter; ?>' id='starttime<?php echo $counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?php echo $starttime; ?>'>
1091 615b27bc Scott Dale
							        </td>
1092
						            <td>
1093 2a113ca9 Scott Dale
						              <input type='text' readonly class='vexpl' name='stoptime<?php echo $counter; ?>' id='stoptime<?php echo $counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?php echo $stoptime; ?>'> 
1094 615b27bc Scott Dale
							        </td>
1095
							        <td>
1096 2a113ca9 Scott Dale
							        	<input type='text' readonly class='vexpl' name='timedescr<?php echo $counter; ?>' id='timedescr<?php echo $counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?php echo $timedescr; ?>'>
1097 615b27bc Scott Dale
							        </td>
1098
							        <td>
1099 636a69e6 Scott Dale
							        	<input type='image' src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_e.gif' onclick='editRow("<?php echo $tempTime; ?>",this); return false;' value='Edit'>
1100 615b27bc Scott Dale
							        </td>
1101
							        <td>
1102
							        	<input type='image' src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' onclick='removeRow(this); return false;' value='Delete'>
1103
							        </td>
1104
							        <td>
1105
							        	<input type='hidden' id='schedule<?php echo $counter; ?>' name='schedule<?php echo $counter; ?>' value='<?php echo $tempID; ?>'>
1106
							        </td>
1107
						          </tr>
1108
									<?php
1109
						        $counter++;
1110
									}//end if						
1111
						        } // end foreach	
1112
								}//end if							
1113
								?>
1114
							</tdody>	
1115
						</table>				
1116
					</td>
1117
				</tr>
1118
			 	<tr>
1119
				    <td width="15%" valign="top">&nbsp;</td>
1120
				    <td width="85%">
1121 101fd849 Scott Dale
				      <input id="submit" name="submit" type="submit" onclick="return checkForRanges();" class="formbtn" value="Save" />
1122 615b27bc Scott Dale
				      <input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
1123
				      <?php if (isset($id) && $a_schedules[$id]): ?>
1124
				      <input name="id" type="hidden" value="<?=$id;?>" />
1125
				      <?php endif; ?>
1126
				    </td>
1127
			  	</tr>
1128
			 </table>
1129
		
1130
</td></tr></table></form>
1131
<?php include("fend.inc"); ?>
1132
</body>
1133
</html>