Project

General

Profile

Download (17.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system_crlmanager.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11
 *
12
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14
 *
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * 3. All advertising materials mentioning features or use of this software
21
 *    must display the following acknowledgment:
22
 *    "This product includes software developed by the pfSense Project
23
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
24
 *
25
 * 4. The names "pfSense" and "pfSense Project" must not be used to
26
 *    endorse or promote products derived from this software without
27
 *    prior written permission. For written permission, please contact
28
 *    coreteam@pfsense.org.
29
 *
30
 * 5. Products derived from this software may not be called "pfSense"
31
 *    nor may "pfSense" appear in their names without prior written
32
 *    permission of the Electric Sheep Fencing, LLC.
33
 *
34
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36
 *
37
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 * OF THE POSSIBILITY OF SUCH DAMAGE.
52
 */
53

    
54
##|+PRIV
55
##|*IDENT=page-system-crlmanager
56
##|*NAME=System: CRL Manager
57
##|*DESCR=Allow access to the 'System: CRL Manager' page.
58
##|*MATCH=system_crlmanager.php*
59
##|-PRIV
60

    
61
require_once("guiconfig.inc");
62
require_once("certs.inc");
63
require_once("openvpn.inc");
64
require_once("vpn.inc");
65

    
66
global $openssl_crl_status;
67

    
68
$crl_methods = array(
69
	"internal" => gettext("Create an internal Certificate Revocation List"),
70
	"existing" => gettext("Import an existing Certificate Revocation List"));
71

    
72
if (ctype_alnum($_GET['id'])) {
73
	$id = $_GET['id'];
74
}
75
if (isset($_POST['id']) && ctype_alnum($_POST['id'])) {
76
	$id = $_POST['id'];
77
}
78

    
79
if (!is_array($config['ca'])) {
80
	$config['ca'] = array();
81
}
82

    
83
$a_ca =& $config['ca'];
84

    
85
if (!is_array($config['cert'])) {
86
	$config['cert'] = array();
87
}
88

    
89
$a_cert =& $config['cert'];
90

    
91
if (!is_array($config['crl'])) {
92
	$config['crl'] = array();
93
}
94

    
95
$a_crl =& $config['crl'];
96

    
97
foreach ($a_crl as $cid => $acrl) {
98
	if (!isset($acrl['refid'])) {
99
		unset ($a_crl[$cid]);
100
	}
101
}
102

    
103
$act = $_GET['act'];
104
if ($_POST['act']) {
105
	$act = $_POST['act'];
106
}
107

    
108
if (!empty($id)) {
109
	$thiscrl =& lookup_crl($id);
110
}
111

    
112
// If we were given an invalid crlref in the id, no sense in continuing as it would only cause errors.
113
if (!$thiscrl && (($act != "") && ($act != "new"))) {
114
	pfSenseHeader("system_crlmanager.php");
115
	$act="";
116
	$savemsg = gettext("Invalid CRL reference.");
117
	$class = "danger";
118
}
119

    
120
if ($act == "del") {
121
	$name = htmlspecialchars($thiscrl['descr']);
122
	if (crl_in_use($id)) {
123
		$savemsg = sprintf(gettext("Certificate Revocation List %s is in use and cannot be deleted."), $name);
124
		$class = "danger";
125
	} else {
126
		foreach ($a_crl as $cid => $acrl) {
127
			if ($acrl['refid'] == $thiscrl['refid']) {
128
				unset($a_crl[$cid]);
129
			}
130
		}
131
		write_config("Deleted CRL {$name}.");
132
		$savemsg = sprintf(gettext("Certificate Revocation List %s successfully deleted."), $name);
133
		$class = "success";
134
	}
135
}
136

    
137
if ($act == "new") {
138
	$pconfig['method'] = $_GET['method'];
139
	$pconfig['caref'] = $_GET['caref'];
140
	$pconfig['lifetime'] = "9999";
141
	$pconfig['serial'] = "0";
142
}
143

    
144
if ($act == "exp") {
145
	crl_update($thiscrl);
146
	$exp_name = urlencode("{$thiscrl['descr']}.crl");
147
	$exp_data = base64_decode($thiscrl['text']);
148
	$exp_size = strlen($exp_data);
149

    
150
	header("Content-Type: application/octet-stream");
151
	header("Content-Disposition: attachment; filename={$exp_name}");
152
	header("Content-Length: $exp_size");
153
	echo $exp_data;
154
	exit;
155
}
156

    
157
if ($act == "addcert") {
158
	if ($_POST) {
159
		unset($input_errors);
160
		$pconfig = $_POST;
161

    
162
		if (!$pconfig['crlref'] || !$pconfig['certref']) {
163
			pfSenseHeader("system_crlmanager.php");
164
			exit;
165
		}
166

    
167
		// certref, crlref
168
		$crl =& lookup_crl($pconfig['crlref']);
169
		$cert = lookup_cert($pconfig['certref']);
170

    
171
		if (!$crl['caref'] || !$cert['caref']) {
172
			$input_errors[] = gettext("Both the Certificate and CRL must be specified.");
173
		}
174

    
175
		if ($crl['caref'] != $cert['caref']) {
176
			$input_errors[] = gettext("CA mismatch between the Certificate and CRL. Unable to Revoke.");
177
		}
178
		if (!is_crl_internal($crl)) {
179
			$input_errors[] = gettext("Cannot revoke certificates for an imported/external CRL.");
180
		}
181

    
182
		if (!$input_errors) {
183
			$reason = (empty($pconfig['crlreason'])) ? OCSP_REVOKED_STATUS_UNSPECIFIED : $pconfig['crlreason'];
184
			cert_revoke($cert, $crl, $reason);
185
			// refresh IPsec and OpenVPN CRLs
186
			openvpn_refresh_crls();
187
			vpn_ipsec_configure();
188
			write_config("Revoked cert {$cert['descr']} in CRL {$crl['descr']}.");
189
			pfSenseHeader("system_crlmanager.php");
190
			exit;
191
		}
192
	}
193
}
194

    
195
if ($act == "delcert") {
196
	if (!is_array($thiscrl['cert'])) {
197
		pfSenseHeader("system_crlmanager.php");
198
		exit;
199
	}
200
	$found = false;
201
	foreach ($thiscrl['cert'] as $acert) {
202
		if ($acert['refid'] == $_GET['certref']) {
203
			$found = true;
204
			$thiscert = $acert;
205
		}
206
	}
207
	if (!$found) {
208
		pfSenseHeader("system_crlmanager.php");
209
		exit;
210
	}
211
	$certname = htmlspecialchars($thiscert['descr']);
212
	$crlname = htmlspecialchars($thiscrl['descr']);
213
	if (cert_unrevoke($thiscert, $thiscrl)) {
214
		$savemsg = sprintf(gettext("Deleted Certificate %s from CRL %s."), $certname, $crlname);
215
		$class = "success";
216
		// refresh IPsec and OpenVPN CRLs
217
		openvpn_refresh_crls();
218
		vpn_ipsec_configure();
219
		write_config($savemsg);
220
	} else {
221
		$savemsg = sprintf(gettext("Failed to delete Certificate %s from CRL %s."), $certname, $crlname);
222
		$class = "danger";
223
	}
224
	$act="edit";
225
}
226

    
227
if ($_POST) {
228
	$input_errors = array();
229
	$pconfig = $_POST;
230

    
231
	/* input validation */
232
	if (($pconfig['method'] == "existing") || ($act == "editimported")) {
233
		$reqdfields = explode(" ", "descr crltext");
234
		$reqdfieldsn = array(
235
			gettext("Descriptive name"),
236
			gettext("Certificate Revocation List data"));
237
	}
238
	if ($pconfig['method'] == "internal") {
239
		$reqdfields = explode(" ", "descr caref");
240
		$reqdfieldsn = array(
241
			gettext("Descriptive name"),
242
			gettext("Certificate Authority"));
243
	}
244

    
245
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
246

    
247
	if (preg_match("/[\?\>\<\&\/\\\"\']/", $pconfig['descr'])) {
248
		array_push($input_errors, "The field 'Descriptive Name' contains invalid characters.");
249
	}
250

    
251
	/* save modifications */
252
	if (!$input_errors) {
253
		$result = false;
254

    
255
		if ($thiscrl) {
256
			$crl =& $thiscrl;
257
		} else {
258
			$crl = array();
259
			$crl['refid'] = uniqid();
260
		}
261

    
262
		$crl['descr'] = $pconfig['descr'];
263
		if ($act != "editimported") {
264
			$crl['caref'] = $pconfig['caref'];
265
			$crl['method'] = $pconfig['method'];
266
		}
267

    
268
		if (($pconfig['method'] == "existing") || ($act == "editimported")) {
269
			$crl['text'] = base64_encode($pconfig['crltext']);
270
		}
271

    
272
		if ($pconfig['method'] == "internal") {
273
			$crl['serial'] = empty($pconfig['serial']) ? 9999 : $pconfig['serial'];
274
			$crl['lifetime'] = empty($pconfig['lifetime']) ? 9999 : $pconfig['lifetime'];
275
			$crl['cert'] = array();
276
		}
277

    
278
		if (!$thiscrl) {
279
			$a_crl[] = $crl;
280
		}
281

    
282
		write_config("Saved CRL {$crl['descr']}");
283
		// refresh IPsec and OpenVPN CRLs
284
		openvpn_refresh_crls();
285
		vpn_ipsec_configure();
286
		pfSenseHeader("system_crlmanager.php");
287
	}
288
}
289

    
290
$pgtitle = array(gettext("System"), gettext("Certificate Manager"), gettext("Certificate Revocation"));
291
$pglinks = array("", "system_camanager.php", "system_crlmanager.php");
292

    
293
if ($act == "new" || $act == gettext("Save") || $input_errors || $act == "edit") {
294
	$pgtitle[] = gettext('Edit');
295
	$pglinks[] = "@self";
296
}
297
include("head.inc");
298
?>
299

    
300
<script type="text/javascript">
301
//<![CDATA[
302

    
303
function method_change() {
304

    
305
	method = document.iform.method.value;
306

    
307
	switch (method) {
308
		case "internal":
309
			document.getElementById("existing").style.display="none";
310
			document.getElementById("internal").style.display="";
311
			break;
312
		case "existing":
313
			document.getElementById("existing").style.display="";
314
			document.getElementById("internal").style.display="none";
315
			break;
316
	}
317
}
318

    
319
//]]>
320
</script>
321

    
322
<?php
323

    
324
function build_method_list() {
325
	global $_GET, $crl_methods;
326

    
327
	$list = array();
328

    
329
	foreach ($crl_methods as $method => $desc) {
330
		if (($_GET['importonly'] == "yes") && ($method != "existing")) {
331
			continue;
332
		}
333

    
334
		$list[$method] = $desc;
335
	}
336

    
337
	return($list);
338
}
339

    
340
function build_ca_list() {
341
	global $a_ca;
342

    
343
	$list = array();
344

    
345
	foreach ($a_ca as $ca) {
346
		$list[$ca['refid']] = $ca['descr'];
347
	}
348

    
349
	return($list);
350
}
351

    
352
function build_cacert_list() {
353
	global $ca_certs;
354

    
355
	$list = array();
356

    
357
	foreach ($ca_certs as $cert) {
358
		$list[$cert['refid']] = $cert['descr'];
359
	}
360

    
361
	return($list);
362
}
363

    
364
if ($input_errors) {
365
	print_input_errors($input_errors);
366
}
367

    
368
if ($savemsg) {
369
	print_info_box($savemsg, $class);
370
}
371

    
372
$tab_array = array();
373
$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
374
$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php");
375
$tab_array[] = array(gettext("Certificate Revocation"), true, "system_crlmanager.php");
376
display_top_tabs($tab_array);
377

    
378
if ($act == "new" || $act == gettext("Save") || $input_errors) {
379
	if (!isset($id)) {
380
		$form = new Form();
381

    
382
		$section = new Form_Section('Create new Revocation List');
383

    
384
		$section->addInput(new Form_Select(
385
			'method',
386
			'*Method',
387
			$pconfig['method'],
388
			build_method_list()
389
		));
390

    
391
	}
392

    
393
	$section->addInput(new Form_Input(
394
		'descr',
395
		'*Descriptive name',
396
		'text',
397
		$pconfig['descr']
398
	));
399

    
400
	$section->addInput(new Form_Select(
401
		'caref',
402
		'*Certificate Authority',
403
		$pconfig['caref'],
404
		build_ca_list()
405
	));
406

    
407
	$form->add($section);
408

    
409
	$section = new Form_Section('Existing Certificate Revocation List');
410
	$section->addClass('existing');
411

    
412
	$section->addInput(new Form_Textarea(
413
		'crltext',
414
		'*CRL data',
415
		$pconfig['crltext']
416
		))->setHelp('Paste a Certificate Revocation List in X.509 CRL format here.');
417

    
418
	$form->add($section);
419

    
420
	$section = new Form_Section('Internal Certificate Revocation List');
421
	$section->addClass('internal');
422

    
423
	$section->addInput(new Form_Input(
424
		'lifetime',
425
		'Lifetime (Days)',
426
		'number',
427
		$pconfig['lifetime'],
428
		[max => '9999']
429
	));
430

    
431
	$section->addInput(new Form_Input(
432
		'serial',
433
		'Serial',
434
		'number',
435
		$pconfig['serial'],
436
		['min' => '0', 'max' => '9999']
437
	));
438

    
439
	$form->add($section);
440

    
441
	if (isset($id) && $thiscrl) {
442
		$section->addInput(new Form_Input(
443
			'id',
444
			null,
445
			'hidden',
446
			$id
447
		));
448
	}
449

    
450
	print($form);
451

    
452
} elseif ($act == "editimported") {
453

    
454
	$form = new Form();
455

    
456
	$section = new Form_Section('Edit Imported Certificate Revocation List');
457

    
458
	$section->addInput(new Form_Input(
459
		'descr',
460
		'*Descriptive name',
461
		'text',
462
		$pconfig['descr']
463
	));
464

    
465
	$section->addInput(new Form_Textarea(
466
		'crltext',
467
		'*CRL data',
468
		$pconfig['crltext']
469
	))->setHelp('Paste a Certificate Revocation List in X.509 CRL format here.');
470

    
471
	$section->addInput(new Form_Input(
472
		'id',
473
		null,
474
		'hidden',
475
		$id
476
	));
477

    
478
	$section->addInput(new Form_Input(
479
		'act',
480
		null,
481
		'hidden',
482
		'editimported'
483
	));
484

    
485
	$form->add($section);
486

    
487
	print($form);
488

    
489
} elseif ($act == "edit") {
490
	$crl = $thiscrl;
491

    
492
	$form = new Form(false);
493
?>
494

    
495
	<div class="panel panel-default">
496
		<div class="panel-heading"><h2 class="panel-title"><?=gettext("Currently Revoked Certificates for CRL") . ': ' . $crl['descr']?></h2></div>
497
		<div class="panel-body table-responsive">
498
<?php
499
	if (!is_array($crl['cert']) || (count($crl['cert']) == 0)) {
500
		print_info_box(gettext("No certificates found for this CRL."), 'danger');
501
	} else {
502
?>
503
			<table class="table table-striped table-hover table-condensed">
504
				<thead>
505
					<tr>
506
						<th><?=gettext("Certificate Name")?></th>
507
						<th><?=gettext("Revocation Reason")?></th>
508
						<th><?=gettext("Revoked At")?></th>
509
						<th></th>
510
					</tr>
511
				</thead>
512
				<tbody>
513
<?php
514
		foreach ($crl['cert'] as $i => $cert):
515
			$name = htmlspecialchars($cert['descr']);
516
?>
517
					<tr>
518
						<td class="listlr">
519
							<?=$name; ?>
520
						</td>
521
						<td class="listlr">
522
							<?=$openssl_crl_status[$cert["reason"]]; ?>
523
						</td>
524
						<td class="listlr">
525
							<?=date("D M j G:i:s T Y", $cert["revoke_time"]); ?>
526
						</td>
527
						<td class="list">
528
							<a href="system_crlmanager.php?act=delcert&amp;id=<?=$crl['refid']; ?>&amp;certref=<?=$cert['refid']; ?>">
529
								<i class="fa fa-trash" title="<?=gettext("Delete this certificate from the CRL")?>" alt="<?=gettext("Delete this certificate from the CRL")?>"></i>
530
							</a>
531
						</td>
532
					</tr>
533
<?php
534
		endforeach;
535
?>
536
				</tbody>
537
			</table>
538
<?php
539
	}
540
?>
541
		</div>
542
	</div>
543
<?php
544

    
545
	$ca_certs = array();
546
	foreach ($a_cert as $cert) {
547
		if ($cert['caref'] == $crl['caref'] && !is_cert_revoked($cert, $id)) {
548
			$ca_certs[] = $cert;
549
		}
550
	}
551

    
552
	if (count($ca_certs) == 0) {
553
		print_info_box(gettext("No certificates found for this CA."), 'danger');
554
	} else {
555
		$section = new Form_Section('Choose a Certificate to Revoke');
556
		$group = new Form_Group(null);
557

    
558
		$group->add(new Form_Select(
559
			'certref',
560
			null,
561
			$pconfig['certref'],
562
			build_cacert_list()
563
			))->setWidth(4)->setHelp('Certificate');
564

    
565
		$group->add(new Form_Select(
566
			'crlreason',
567
			null,
568
			-1,
569
			$openssl_crl_status
570
			))->setHelp('Reason');
571

    
572
		$group->add(new Form_Button(
573
			'submit',
574
			'Add',
575
			null,
576
			'fa-plus'
577
			))->addClass('btn-success btn-sm');
578

    
579
		$section->add($group);
580

    
581
		$section->addInput(new Form_Input(
582
			'id',
583
			null,
584
			'hidden',
585
			$crl['refid']
586
		));
587

    
588
		$section->addInput(new Form_Input(
589
			'act',
590
			null,
591
			'hidden',
592
			'addcert'
593
		));
594

    
595
		$section->addInput(new Form_Input(
596
			'crlref',
597
			null,
598
			'hidden',
599
			$crl['refid']
600
		));
601

    
602
		$form->add($section);
603
	}
604

    
605
	print($form);
606
} else {
607
?>
608

    
609
	<div class="panel panel-default">
610
		<div class="panel-heading"><h2 class="panel-title"><?=gettext("Additional Certificate Revocation Lists")?></h2></div>
611
		<div class="panel-body table-responsive">
612
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
613
				<thead>
614
					<tr>
615
						<th><?=gettext("Name")?></th>
616
						<th><?=gettext("Internal")?></th>
617
						<th><?=gettext("Certificates")?></th>
618
						<th><?=gettext("In Use")?></th>
619
						<th><?=gettext("Actions")?></th>
620
					</tr>
621
				</thead>
622
				<tbody>
623
<?php
624
	// Map CRLs to CAs in one pass
625
	$ca_crl_map = array();
626
	foreach ($a_crl as $crl) {
627
		$ca_crl_map[$crl['caref']][] = $crl['refid'];
628
	}
629

    
630
	$i = 0;
631
	foreach ($a_ca as $ca):
632
		$name = htmlspecialchars($ca['descr']);
633

    
634
		if ($ca['prv']) {
635
			$cainternal = "YES";
636
		} else {
637
			$cainternal = "NO";
638
		}
639
?>
640
					<tr>
641
						<td colspan="4">
642
							<?=$name?>
643
						</td>
644
						<td>
645
<?php
646
		if ($cainternal == "YES"):
647
?>
648
							<a href="system_crlmanager.php?act=new&amp;caref=<?=$ca['refid']; ?>" class="btn btn-xs btn-success">
649
								<i class="fa fa-plus icon-embed-btn"></i>
650
								<?=gettext("Add or Import CRL")?>
651
							</a>
652
<?php
653
		else:
654
?>
655
							<a href="system_crlmanager.php?act=new&amp;caref=<?=$ca['refid']; ?>&amp;importonly=yes" class="btn btn-xs btn-success">
656
								<i class="fa fa-plus icon-embed-btn"></i>
657
								<?=gettext("Add or Import CRL")?>
658
							</a>
659
<?php
660
		endif;
661
?>
662
						</td>
663
					</tr>
664
<?php
665
		if (is_array($ca_crl_map[$ca['refid']])):
666
			foreach ($ca_crl_map[$ca['refid']] as $crl):
667
				$tmpcrl = lookup_crl($crl);
668
				$internal = is_crl_internal($tmpcrl);
669
				$inuse = crl_in_use($tmpcrl['refid']);
670
?>
671
					<tr>
672
						<td><?=$tmpcrl['descr']; ?></td>
673
						<td><i class="fa fa-<?=($internal) ? "check" : "times"; ?>"></i></td>
674
						<td><?=($internal) ? count($tmpcrl['cert']) : "Unknown (imported)"; ?></td>
675
						<td><i class="fa fa-<?=($inuse) ? "check" : "times"; ?>"></i></td>
676
						<td>
677
							<a href="system_crlmanager.php?act=exp&amp;id=<?=$tmpcrl['refid']?>" class="fa fa-download" title="<?=gettext("Export CRL")?>"></a>
678
<?php
679
				if ($internal): ?>
680
							<a href="system_crlmanager.php?act=edit&amp;id=<?=$tmpcrl['refid']?>" class="fa fa-pencil" title="<?=gettext("Edit CRL")?>"></a>
681
<?php
682
				else:
683
?>
684
							<a href="system_crlmanager.php?act=editimported&amp;id=<?=$tmpcrl['refid']?>" class="fa fa-pencil" title="<?=gettext("Edit CRL")?>"></a>
685
<?php			endif;
686
				if (!$inuse):
687
?>
688
							<a href="system_crlmanager.php?act=del&amp;id=<?=$tmpcrl['refid']?>" class="fa fa-trash" title="<?=gettext("Delete CRL")?>"></a>
689
<?php
690
				endif;
691
?>
692
						</td>
693
					</tr>
694
<?php
695
				$i++;
696
				endforeach;
697
			endif;
698
			$i++;
699
		endforeach;
700
?>
701
				</tbody>
702
			</table>
703
		</div>
704
	</div>
705

    
706

    
707
<?php
708
}
709
?>
710

    
711
<script type="text/javascript">
712
//<![CDATA[
713
events.push(function() {
714

    
715
	// Hides all elements of the specified class. This will usually be a section or group
716
	function hideClass(s_class, hide) {
717
		if (hide) {
718
			$('.' + s_class).hide();
719
		} else {
720
			$('.' + s_class).show();
721
		}
722
	}
723

    
724
	// When the 'method" selector is changed, we show/hide certain sections
725
	$('#method').on('change', function() {
726
		hideClass('internal', ($('#method').val() == 'existing'));
727
		hideClass('existing', ($('#method').val() == 'internal'));
728
	});
729

    
730
	hideClass('internal', ($('#method').val() == 'existing'));
731
	hideClass('existing', ($('#method').val() == 'internal'));
732
});
733
//]]>
734
</script>
735

    
736
<?php include("foot.inc");
737

    
(194-194/225)