Project

General

Profile

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