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