Project

General

Profile

Download (18.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	guiconfig.inc
5
	by Scott Ullrich, Copyright 2004, All rights reserved.
6
	originally based on of m0n0wall (http://m0n0.ch/wall)
7

    
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
/* make sure nothing is cached */
34
if (!$omit_nocacheheaders) {
35
	header("Expires: 0");
36
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
37
	header("Cache-Control: no-store, no-cache, must-revalidate");
38
	header("Cache-Control: post-check=0, pre-check=0", false);
39
	header("Pragma: no-cache");
40
}
41

    
42
/* Include authentication routines */
43
/* THIS MUST BE ABOVE ALL OTHER CODE */
44
require_once("auth.inc");
45

    
46
/* parse the configuration and include all configuration functions */
47
require_once("config.inc");
48
require_once("functions.inc");
49

    
50
/*
51
 *   if user has selected a custom template, use it.
52
 *   otherwise default to pfsense tempalte
53
 */
54
if($config['theme'] <> "")
55
        $g['theme'] = $config['theme'];
56
else
57
        $g['theme'] = "pfsense";
58

    
59
$d_landirty_path = $g['varrun_path'] . "/lan.conf.dirty";
60
$d_pppoeuserdirty_path = $g['varrun_path'] . "/vpn-pppoe-users-edit.dirty";
61
$d_hostsdirty_path = $g['varrun_path'] . "/hosts.dirty";
62
$d_natconfdirty_path = $g['varrun_path'] . "/nat.conf.dirty";
63
$d_filterconfdirty_path = $g['varrun_path'] . "/filter.conf.dirty";
64
$d_ipsecconfdirty_path = $g['varrun_path'] . "/ipsec.conf.dirty";
65
$d_shaperconfdirty_path = $g['varrun_path'] . "/shaper.conf.dirty";
66
$d_pptpuserdirty_path = $g['varrun_path'] . "/pptpd.user.dirty";
67
$d_dnsmasqdirty_path = $g['varrun_path'] . "/dnsmasq.dirty";
68
$d_staticmapsdirty_path = $g['varrun_path'] . "/staticmaps.dirty";
69
$d_staticroutesdirty_path = $g['varrun_path'] . "/staticroutes.dirty";
70
$d_aliasesdirty_path = $g['varrun_path'] . "/aliases.dirty";
71
$d_proxyarpdirty_path = $g['varrun_path'] . "/proxyarp.dirty";
72
$d_fwupenabled_path = $g['varrun_path'] . "/fwup.enabled";
73
$d_firmwarelock_path = $g['varrun_path'] . "/firmware.lock";
74
$d_sysrebootreqd_path = $g['varrun_path'] . "/sysreboot.reqd";
75
$d_passthrumacsdirty_path = $g['varrun_path'] . "/passthrumacs.dirty";
76
$d_allowedipsdirty_path = $g['varrun_path'] . "/allowedips.dirty";
77
$d_ovpnclidirty_path = $g['varrun_path'] . "/ovpnclient.dirty";
78
$d_vipconfdirty_path = $g['varrun_path'] . "/vip.conf.dirty";
79
$d_poolconfdirty_path = $g['varrun_path'] . "/pool.conf.dirty";
80
$d_vsconfdirty_path = $g['varrun_path'] . "/vs.conf.dirty";
81
/* used by progress bar */
82
$lastseen = "-1";
83

    
84
if (file_exists($d_firmwarelock_path)) {
85
	if (!$d_isfwfile) {
86
		header("Location: system_firmware.php");
87
		exit;
88
	} else {
89
		return;
90
	}
91
}
92

    
93
/* some well knows ports */
94
$wkports = array(3389 => "MS RDP", 21 => "FTP", 22 => "SSH", 23 => "Telnet", 25 => "SMTP",
95
		53 => "DNS", 80 => "HTTP", 110 => "POP3", 143 => "IMAP", 443 => "HTTPS");
96

    
97
$specialnets = array("lan" => "LAN net", "pptp" => "PPTP clients");
98

    
99
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
100
	$specialnets['opt' . $i] = $config['interfaces']['opt' . $i]['descr'] . " net";
101
}
102

    
103
$medias = array("auto" => "autoselect", "100full" => "100BASE-TX full-duplex",
104
	"100half" => "100BASE-TX half-duplex", "10full" => "10BASE-T full-duplex",
105
	"10half" => "10BASE-T half-duplex");
106

    
107
/* platforms that support firmware updating */
108
$fwupplatforms = array('pfSense', 'net45xx', 'net48xx', 'generic-pc', 'wrap');
109

    
110
/* IPsec defines */
111
$my_identifier_list = array('myaddress' => 'My IP address',
112
				'address' => 'IP address',
113
				'fqdn' => 'Domain name',
114
				'user_fqdn' => 'User FQDN',
115
				'dyn_dns' => 'Dynamic DNS');
116

    
117
$p1_ealgos = array('des' => 'DES', '3des' => '3DES', 'blowfish' => 'Blowfish',
118
                                        'cast128' => 'CAST128');
119
$p2_ealgos = array('des' => 'DES', '3des' => '3DES', 'blowfish' => 'Blowfish',
120
                                        'cast128' => 'CAST128', 'rijndael' => 'Rijndael (AES)');
121
$p1_halgos = array('sha1' => 'SHA1', 'md5' => 'MD5');
122
$p1_authentication_methods = array('pre_shared_key' => 'Pre-shared key', 'rsasig' => 'RSA signature');
123
$p2_halgos = array('hmac_sha1' => 'SHA1', 'hmac_md5' => 'MD5');
124
$p2_protos = array('esp' => 'ESP', 'ah' => 'AH');
125
$p2_pfskeygroups = array('0' => 'off', '1' => '1', '2' => '2', '5' => '5');
126

    
127
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) {
128

    
129
	/* check for bad control characters */
130
	foreach ($postdata as $pn => $pd) {
131
		if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
132
			$input_errors[] = "The field '" . $pn . "' contains invalid characters.";
133
		}
134
	}
135

    
136
	for ($i = 0; $i < count($reqdfields); $i++) {
137
		if (!$_POST[$reqdfields[$i]]) {
138
			$input_errors[] = "The field '" . $reqdfieldsn[$i] . "' is required.";
139
		}
140
	}
141
}
142

    
143
function print_input_errors($input_errors) {
144
	global $g;
145
	echo "<p><table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">\n";
146
	echo "<tr><td bgcolor=\"#990000\" width=\"36\" align=\"center\" valign=\"top\"><img src=\"./themes/".$g['theme']."/images/icons/icon_error.gif\" width=\"28\" height=\"32\"></td>\n";
147
	echo "<td bgcolor=\"#FFD9D1\" style=\"padding-left: 8px; padding-top: 6px\">";
148

    
149
	echo "<span class=\"errmsg\"><p>The following input errors were detected:<ul>\n";
150
	foreach ($input_errors as $ierr) {
151
		echo "<li>" . htmlspecialchars($ierr) . "</li>\n";
152
	}
153
	echo "</ul></span>";
154

    
155
	echo "</td></tr></table></p>";
156
}
157

    
158
function exec_rc_script($scriptname) {
159

    
160
	global $d_sysrebootreqd_path;
161

    
162
	if (file_exists($d_sysrebootreqd_path))
163
		return 0;
164

    
165
	exec($scriptname . " >/dev/null 2>&1", $execoutput, $retval);
166
	return $retval;
167
}
168

    
169
function exec_rc_script_async($scriptname) {
170

    
171
	global $d_sysrebootreqd_path;
172

    
173
	if (file_exists($d_sysrebootreqd_path))
174
		return 0;
175

    
176
	exec("nohup " . $scriptname . " >/dev/null 2>&1 &", $execoutput, $retval);
177
	return $retval;
178
}
179

    
180
function verify_gzip_file($fname) {
181

    
182
    $returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
183
	if ($returnvar != 0)
184
		return 0;
185
	else
186
		return 1;
187
}
188

    
189
function print_info_box_np($msg) {
190
	global $g;
191
	echo "<table height=\"32\" width=\"100%\">\n";
192
	echo "  <tr>\n";
193
	echo "   <td>\n";
194
	echo "      <div style='background-color:#990000' id='redbox'>\n";
195
	echo "       <table width='100%'><tr><td width='8%'>\n";
196
	echo "        &nbsp;&nbsp;&nbsp;<img style='vertical-align:middle' src=\"./themes/".$g['theme']."/images/icons/icon_exclam.gif\" width=\"28\" height=\"32\">\n";
197
	echo "        </td>\n";
198
	echo "        <td width='70%'><font color='white'><b>{$msg}</b></font>\n";
199
	echo "        </td>";
200
	if(stristr($msg, "apply") == true) {
201
		echo "         <td>";
202
		echo "           <input name=\"apply\" type=\"submit\" class=\"formbtn\" id=\"apply\" value=\"Apply changes\">\n";
203
		echo "         </td>";
204
	}
205
	echo "        </tr></table>\n";
206
	echo "       </div>\n";
207
	echo "    </td>\n";
208
	echo "</table>\n";
209
	echo "<script type=\"text/javascript\">\n";
210
	echo "NiftyCheck();\n";
211
	echo "Rounded(\"div#redbox\",\"all\",\"#FFF\",\"#990000\",\"smooth\");\n";
212
	echo "Rounded(\"td#blackbox\",\"all\",\"#FFF\",\"#000000\",\"smooth\");\n";
213
	echo "</script>\n";
214
	echo "\n<br>\n";
215
}
216

    
217
function print_info_box($msg) {
218
	echo "<p>";
219
	print_info_box_np($msg);
220
	echo "</p>";
221
}
222

    
223
function format_bytes($bytes) {
224
	if ($bytes >= 1073741824) {
225
		return sprintf("%.2f GB", $bytes/1073741824);
226
	} else if ($bytes >= 1048576) {
227
		return sprintf("%.2f MB", $bytes/1048576);
228
	} else if ($bytes >= 1024) {
229
		return sprintf("%.0f KB", $bytes/1024);
230
	} else {
231
		return sprintf("%d bytes", $bytes);
232
	}
233
}
234

    
235
function get_std_save_message($ok) {
236
	global $d_sysrebootreqd_path;
237

    
238
	return "The changes have been applied successfully.";
239
}
240

    
241
function pprint_address($adr) {
242
	global $specialnets;
243

    
244
	if (isset($adr['any'])) {
245
		$padr = "*";
246
	} else if ($adr['network']) {
247
		$padr = $specialnets[$adr['network']];
248
	} else {
249
		$padr = $adr['address'];
250
	}
251

    
252
	if (isset($adr['not']))
253
		$padr = "! " . $padr;
254

    
255
	return $padr;
256
}
257

    
258
function pprint_port($port) {
259
	global $wkports;
260

    
261
	$pport = "";
262

    
263
	if (!$port)
264
		echo "*";
265
	else {
266
		$srcport = explode("-", $port);
267
		if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
268
			$pport = $srcport[0];
269
			if ($wkports[$srcport[0]]) {
270
				$pport .= " (" . $wkports[$srcport[0]] . ")";
271
			}
272
		} else
273
			$pport .= $srcport[0] . " - " . $srcport[1];
274
	}
275

    
276
	return $pport;
277
}
278

    
279
/* sort by interface only, retain the original order of rules that apply to
280
   the same interface */
281
function filter_rules_sort() {
282
	global $config;
283

    
284
	/* mark each rule with the sequence number (to retain the order while sorting) */
285
	for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
286
		$config['filter']['rule'][$i]['seq'] = $i;
287

    
288
	function filtercmp($a, $b) {
289
		if ($a['interface'] == $b['interface'])
290
			return $a['seq'] - $b['seq'];
291
		else
292
			return -strcmp($a['interface'], $b['interface']);
293
	}
294

    
295
	usort($config['filter']['rule'], "filtercmp");
296

    
297
	/* strip the sequence numbers again */
298
	for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
299
		unset($config['filter']['rule'][$i]['seq']);
300
}
301

    
302
function nat_rules_sort() {
303
	global $config;
304

    
305
	function natcmp($a, $b) {
306
		if ($a['external-address'] == $b['external-address']) {
307
			if ($a['protocol'] == $b['protocol']) {
308
				if ($a['external-port'] == $b['external-port']) {
309
					return 0;
310
				} else {
311
					return ($a['external-port'] - $b['external-port']);
312
				}
313
			} else {
314
				return strcmp($a['protocol'], $b['protocol']);
315
			}
316
		} else if (!$a['external-address'])
317
			return 1;
318
		else if (!$b['external-address'])
319
			return -1;
320
		else
321
			return ipcmp($a['external-address'], $b['external-address']);
322
	}
323

    
324
	usort($config['nat']['rule'], "natcmp");
325
}
326

    
327
function nat_1to1_rules_sort() {
328
	global $g, $config;
329

    
330
	function nat1to1cmp($a, $b) {
331
		return ipcmp($a['external'], $b['external']);
332
	}
333

    
334
	usort($config['nat']['onetoone'], "nat1to1cmp");
335
}
336

    
337
function nat_server_rules_sort() {
338
	global $g, $config;
339

    
340
	function natservercmp($a, $b) {
341
		return ipcmp($a['ipaddr'], $b['ipaddr']);
342
	}
343

    
344
	usort($config['nat']['servernat'], "natservercmp");
345
}
346

    
347
function nat_out_rules_sort() {
348
	global $g, $config;
349

    
350
	function natoutcmp($a, $b) {
351
		return strcmp($a['source']['network'], $b['source']['network']);
352
	}
353

    
354
	usort($config['nat']['advancedoutbound']['rule'], "natoutcmp");
355
}
356

    
357
function pptpd_users_sort() {
358
	global $g, $config;
359

    
360
	function usercmp($a, $b) {
361
		return strcasecmp($a['name'], $b['name']);
362
	}
363

    
364
	usort($config['pptpd']['user'], "usercmp");
365
}
366

    
367
function pppoe_users_sort() {
368
	global $g, $config;
369

    
370
	function usercmp($a, $b) {
371
		return strcasecmp($a['name'], $b['name']);
372
	}
373

    
374
	usort($config['pppoe']['user'], "usercmp");
375
}
376

    
377
function staticroutes_sort() {
378
	global $g, $config;
379

    
380
	function staticroutecmp($a, $b) {
381
		return strcmp($a['network'], $b['network']);
382
	}
383

    
384
	usort($config['staticroutes']['route'], "staticroutecmp");
385
}
386

    
387
function hosts_sort() {
388
	global $g, $config;
389

    
390
	function hostcmp($a, $b) {
391
		return strcasecmp($a['host'], $b['host']);
392
	}
393

    
394
	usort($config['dnsmasq']['hosts'], "hostcmp");
395
}
396

    
397
function staticmaps_sort($if) {
398
	global $g, $config;
399

    
400
	function staticmapcmp($a, $b) {
401
		return ipcmp($a['ipaddr'], $b['ipaddr']);
402
	}
403

    
404
	usort($config['dhcpd'][$if]['staticmap'], "staticmapcmp");
405
}
406

    
407
function aliases_sort() {
408
	global $g, $config;
409

    
410
	function aliascmp($a, $b) {
411
		return strcmp($a['name'], $b['name']);
412
	}
413

    
414
	usort($config['aliases']['alias'], "aliascmp");
415
}
416

    
417
function ipsec_mobilekey_sort() {
418
	global $g, $config;
419

    
420
	function mobilekeycmp($a, $b) {
421
		return strcmp($a['ident'][0], $b['ident'][0]);
422
	}
423

    
424
	usort($config['ipsec']['mobilekey'], "mobilekeycmp");
425
}
426

    
427
function proxyarp_sort() {
428
	global $g, $config;
429

    
430
	function proxyarpcmp($a, $b) {
431
		if (isset($a['network']))
432
			list($ast,$asn) = explode("/", $a['network']);
433
		else if (isset($a['range'])) {
434
			$ast = $a['range']['from'];
435
			$asn = 32;
436
		}
437
		if (isset($b['network']))
438
			list($bst,$bsn) = explode("/", $b['network']);
439
		else if (isset($b['range'])) {
440
			$bst = $b['range']['from'];
441
			$bsn = 32;
442
		}
443
		if (ipcmp($ast, $bst) == 0)
444
			return ($asn - $bsn);
445
		else
446
			return ipcmp($ast, $bst);
447
	}
448

    
449
	usort($config['proxyarp']['proxyarpnet'], "proxyarpcmp");
450
}
451

    
452
function passthrumacs_sort() {
453
	global $g, $config;
454

    
455
	function passthrumacscmp($a, $b) {
456
		return strcmp($a['mac'], $b['mac']);
457
	}
458

    
459
	usort($config['captiveportal']['passthrumac'],"passthrumacscmp");
460
}
461

    
462
function allowedips_sort() {
463
	global $g, $config;
464

    
465
	function allowedipscmp($a, $b) {
466
		return strcmp($a['ip'], $b['ip']);
467
	}
468

    
469
	usort($config['captiveportal']['allowedip'],"allowedipscmp");
470
}
471

    
472
function wol_sort() {
473
	global $g, $config;
474

    
475
	function wolcmp($a, $b) {
476
		return strcmp($a['descr'], $b['descr']);
477
	}
478

    
479
	usort($config['wol']['wolentry'], "wolcmp");
480
}
481

    
482
function gentitle($pgname) {
483
	global $config;
484
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
485
}
486

    
487
/* update the changedesc and changecount(er) variables */
488
function update_changedesc($update) {
489
	global $changedesc;
490
	global $changecount;
491

    
492
	$changedesc .= " {$update}";
493
	$changecount++;
494
}
495

    
496
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
497
	global $g, $config;
498
        $sor = isset($config['syslog']['reverse']) ? "-r" : "";
499
	exec("/usr/sbin/clog {$logfile} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
500
	if($grepfor <> "") {  	 
501
                 $i = 0; 	 
502
                 foreach($grepfor as $agrep) { 	 
503
                         $regexp = "/" . $agrep . "/i"; 	 
504
                         if($grepinvert[$i] == true) { 	 
505
                                 $logarr = preg_grep($regexp, $logarr, PREG_GREP_INVERT); 	 
506
                         } else { 	 
507
                                 $logarr = preg_grep($regexp, $logarr); 	 
508
                         } 	 
509
                         $i++; 	 
510
                 } 	 
511
        }
512
        foreach ($logarr as $logent) {
513
                $logent = preg_split("/\s+/", $logent, 6);
514
                echo "<tr valign=\"top\">\n";
515
                if ($withorig) {
516
                        echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
517
                        echo "<td class=\"listr\">" . htmlspecialchars($logent[4] . " " . $logent[5]) . "</td>\n";
518
                } else {
519
                        echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
520
                }
521
                echo "</tr>\n";
522
        }
523
}
524

    
525
/* Check if variable has changed, update and log if it has
526
 * returns true if var changed
527
 * varname = variable name in plain text
528
 * orig = original value
529
 * new = new value
530
 */
531
function update_if_changed($varname, & $orig, $new) {
532
	if (is_array($orig) && is_array($new)) {
533
		$a_diff = array_diff($orig, $new);
534
		foreach ($a_diff as $diff) {
535
			update_changedesc("removed {$varname}: \"{$diff}\"");
536
		}
537
		$a_diff = array_diff($new, $orig);
538
		foreach ($a_diff as $diff) {
539
			update_changedesc("added {$varname}: \"{$diff}\"");
540
		}
541
		$orig = $new;
542
		return true;
543
			
544
	} else { 
545
		if ($orig != $new) {
546
			update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
547
			$orig = $new;
548
			return true;
549
		}
550
	}
551
	return false;
552
}
553

    
554
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
555

    
556
        if (isset($adr['any']))
557
                $padr = "any";
558
        else if ($adr['network'])
559
                $padr = $adr['network'];
560
        else if ($adr['address']) {
561
                list($padr, $pmask) = explode("/", $adr['address']);
562
                if (!$pmask)
563
                        $pmask = 32;
564
        }
565

    
566
        if (isset($adr['not']))
567
                $pnot = 1;
568
        else
569
                $pnot = 0;
570

    
571
        if ($adr['port']) {
572
                list($pbeginport, $pendport) = explode("-", $adr['port']);
573
                if (!$pendport)
574
                        $pendport = $pbeginport;
575
        } else {
576
                if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
577
                        /* Item is a port alias */
578
                } else {
579
                        $pbeginport = "any";
580
                        $pendport = "any";
581
                }
582
        }
583
}
584

    
585
function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
586

    
587
        $adr = array();
588

    
589
        if ($padr == "any")
590
                $adr['any'] = true;
591
        else if (is_specialnet($padr))
592
                $adr['network'] = $padr;
593
        else {
594
                $adr['address'] = $padr;
595
                if ($pmask != 32)
596
                        $adr['address'] .= "/" . $pmask;
597
        }
598

    
599
        if ($pnot)
600
                $adr['not'] = true;
601
        else
602
                unset($adr['not']);
603

    
604
        if (($pbeginport != 0) && ($pbeginport != "any")) {
605
                if ($pbeginport != $pendport)
606
                        $adr['port'] = $pbeginport . "-" . $pendport;
607
                else
608
                        $adr['port'] = $pbeginport;
609
        }
610

    
611
        if(alias_expand($pbeginport)) {
612
                $adr['port'] = $pbeginport;
613
        }
614
}
615

    
616
function is_specialnet($net) {
617
        global $specialsrcdst;
618

    
619
        if (in_array($net, $specialsrcdst) || strstr($net, "opt"))
620
                return true;
621
        else
622
                return false;
623
}
624

    
625
function ipsec_ca_sort() {
626
        global $g, $config;
627

    
628
        function ipseccacmp($a, $b) {
629
                return strcmp($a['ident'], $b['ident']);
630
        }
631

    
632
        usort($config['ipsec']['cacert'], "ipseccacmp");
633
}
634

    
635

    
636
?>
(52-52/144)