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",
95
	21 => "FTP",
96
	22 => "SSH",
97
	23 => "Telnet",
98
	25 => "SMTP",
99
	53 => "DNS",
100
	80 => "HTTP",
101
	110 => "POP3",
102
	113 => "IDENT/AUTH",
103
	123 => "NTP",
104
	143 => "IMAP",
105
	443 => "HTTPS",
106
	993 => "IMAP/S");
107

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

    
110
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
111
	$specialnets['opt' . $i] = $config['interfaces']['opt' . $i]['descr'] . " net";
112
}
113

    
114
$medias = array("auto" => "autoselect", "100full" => "100BASE-TX full-duplex",
115
	"100half" => "100BASE-TX half-duplex", "10full" => "10BASE-T full-duplex",
116
	"10half" => "10BASE-T half-duplex");
117

    
118
/* platforms that support firmware updating */
119
$fwupplatforms = array('pfSense', 'net45xx', 'net48xx', 'generic-pc', 'wrap');
120

    
121
/* IPsec defines */
122
$my_identifier_list = array('myaddress' => 'My IP address',
123
				'address' => 'IP address',
124
				'fqdn' => 'Domain name',
125
				'user_fqdn' => 'User FQDN',
126
				'dyn_dns' => 'Dynamic DNS');
127

    
128
$p1_ealgos = array('des' => 'DES', '3des' => '3DES', 'blowfish' => 'Blowfish',
129
                                        'cast128' => 'CAST128');
130
$p2_ealgos = array('des' => 'DES', '3des' => '3DES', 'blowfish' => 'Blowfish',
131
                                        'cast128' => 'CAST128', 'rijndael' => 'Rijndael (AES)');
132
$p1_halgos = array('sha1' => 'SHA1', 'md5' => 'MD5');
133
$p1_authentication_methods = array('pre_shared_key' => 'Pre-shared key', 'rsasig' => 'RSA signature');
134
$p2_halgos = array('hmac_sha1' => 'SHA1', 'hmac_md5' => 'MD5');
135
$p2_protos = array('esp' => 'ESP', 'ah' => 'AH');
136
$p2_pfskeygroups = array('0' => 'off', '1' => '1', '2' => '2', '5' => '5');
137

    
138
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) {
139

    
140
	/* check for bad control characters */
141
	foreach ($postdata as $pn => $pd) {
142
		if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
143
			$input_errors[] = "The field '" . $pn . "' contains invalid characters.";
144
		}
145
	}
146

    
147
	for ($i = 0; $i < count($reqdfields); $i++) {
148
		if (!$_POST[$reqdfields[$i]]) {
149
			$input_errors[] = "The field '" . $reqdfieldsn[$i] . "' is required.";
150
		}
151
	}
152
}
153

    
154
function print_input_errors($input_errors) {
155
	global $g;
156
	echo "<p><table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">\n";
157
	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";
158
	echo "<td bgcolor=\"#FFD9D1\" style=\"padding-left: 8px; padding-top: 6px\">";
159

    
160
	echo "<span class=\"errmsg\"><p>The following input errors were detected:<ul>\n";
161
	foreach ($input_errors as $ierr) {
162
		echo "<li>" . htmlspecialchars($ierr) . "</li>\n";
163
	}
164
	echo "</ul></span>";
165

    
166
	echo "</td></tr></table></p>&nbsp;<br>";
167
}
168

    
169
function exec_rc_script($scriptname) {
170

    
171
	global $d_sysrebootreqd_path;
172

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

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

    
180
function exec_rc_script_async($scriptname) {
181

    
182
	global $d_sysrebootreqd_path;
183

    
184
	if (file_exists($d_sysrebootreqd_path))
185
		return 0;
186

    
187
	exec("nohup " . $scriptname . " >/dev/null 2>&1 &", $execoutput, $retval);
188
	return $retval;
189
}
190

    
191
function verify_gzip_file($fname) {
192

    
193
    $returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
194
	if ($returnvar != 0)
195
		return 0;
196
	else
197
		return 1;
198
}
199

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

    
228
function print_info_box($msg) {
229
	echo "<p>";
230
	print_info_box_np($msg);
231
	echo "</p>";
232
}
233

    
234
function format_bytes($bytes) {
235
	if ($bytes >= 1073741824) {
236
		return sprintf("%.2f GB", $bytes/1073741824);
237
	} else if ($bytes >= 1048576) {
238
		return sprintf("%.2f MB", $bytes/1048576);
239
	} else if ($bytes >= 1024) {
240
		return sprintf("%.0f KB", $bytes/1024);
241
	} else {
242
		return sprintf("%d bytes", $bytes);
243
	}
244
}
245

    
246
function get_std_save_message($ok) {
247
	global $d_sysrebootreqd_path;
248

    
249
	return "The changes have been applied successfully.";
250
}
251

    
252
function pprint_address($adr) {
253
	global $specialnets;
254

    
255
	if (isset($adr['any'])) {
256
		$padr = "*";
257
	} else if ($adr['network']) {
258
		$padr = $specialnets[$adr['network']];
259
	} else {
260
		$padr = $adr['address'];
261
	}
262

    
263
	if (isset($adr['not']))
264
		$padr = "! " . $padr;
265

    
266
	return $padr;
267
}
268

    
269
function pprint_port($port) {
270
	global $wkports;
271

    
272
	$pport = "";
273

    
274
	if (!$port)
275
		echo "*";
276
	else {
277
		$srcport = explode("-", $port);
278
		if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
279
			$pport = $srcport[0];
280
			if ($wkports[$srcport[0]]) {
281
				$pport .= " (" . $wkports[$srcport[0]] . ")";
282
			}
283
		} else
284
			$pport .= $srcport[0] . " - " . $srcport[1];
285
	}
286

    
287
	return $pport;
288
}
289

    
290
/* sort by interface only, retain the original order of rules that apply to
291
   the same interface */
292
function filter_rules_sort() {
293
	global $config;
294

    
295
	/* mark each rule with the sequence number (to retain the order while sorting) */
296
	for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
297
		$config['filter']['rule'][$i]['seq'] = $i;
298

    
299
	function filtercmp($a, $b) {
300
		if ($a['interface'] == $b['interface'])
301
			return $a['seq'] - $b['seq'];
302
		else
303
			return -strcmp($a['interface'], $b['interface']);
304
	}
305

    
306
	usort($config['filter']['rule'], "filtercmp");
307

    
308
	/* strip the sequence numbers again */
309
	for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
310
		unset($config['filter']['rule'][$i]['seq']);
311
}
312

    
313
function nat_rules_sort() {
314
	global $config;
315

    
316
	function natcmp($a, $b) {
317
		if ($a['external-address'] == $b['external-address']) {
318
			if ($a['protocol'] == $b['protocol']) {
319
				if ($a['external-port'] == $b['external-port']) {
320
					return 0;
321
				} else {
322
					return ($a['external-port'] - $b['external-port']);
323
				}
324
			} else {
325
				return strcmp($a['protocol'], $b['protocol']);
326
			}
327
		} else if (!$a['external-address'])
328
			return 1;
329
		else if (!$b['external-address'])
330
			return -1;
331
		else
332
			return ipcmp($a['external-address'], $b['external-address']);
333
	}
334

    
335
	usort($config['nat']['rule'], "natcmp");
336
}
337

    
338
function nat_1to1_rules_sort() {
339
	global $g, $config;
340

    
341
	function nat1to1cmp($a, $b) {
342
		return ipcmp($a['external'], $b['external']);
343
	}
344

    
345
	usort($config['nat']['onetoone'], "nat1to1cmp");
346
}
347

    
348
function nat_server_rules_sort() {
349
	global $g, $config;
350

    
351
	function natservercmp($a, $b) {
352
		return ipcmp($a['ipaddr'], $b['ipaddr']);
353
	}
354

    
355
	usort($config['nat']['servernat'], "natservercmp");
356
}
357

    
358
function nat_out_rules_sort() {
359
	global $g, $config;
360

    
361
	function natoutcmp($a, $b) {
362
		return strcmp($a['source']['network'], $b['source']['network']);
363
	}
364

    
365
	usort($config['nat']['advancedoutbound']['rule'], "natoutcmp");
366
}
367

    
368
function pptpd_users_sort() {
369
	global $g, $config;
370

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

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

    
378
function pppoe_users_sort() {
379
	global $g, $config;
380

    
381
	function usercmp($a, $b) {
382
		return strcasecmp($a['name'], $b['name']);
383
	}
384

    
385
	usort($config['pppoe']['user'], "usercmp");
386
}
387

    
388
function staticroutes_sort() {
389
	global $g, $config;
390

    
391
	function staticroutecmp($a, $b) {
392
		return strcmp($a['network'], $b['network']);
393
	}
394

    
395
	usort($config['staticroutes']['route'], "staticroutecmp");
396
}
397

    
398
function hosts_sort() {
399
	global $g, $config;
400

    
401
	function hostcmp($a, $b) {
402
		return strcasecmp($a['host'], $b['host']);
403
	}
404

    
405
	usort($config['dnsmasq']['hosts'], "hostcmp");
406
}
407

    
408
function staticmaps_sort($if) {
409
	global $g, $config;
410

    
411
	function staticmapcmp($a, $b) {
412
		return ipcmp($a['ipaddr'], $b['ipaddr']);
413
	}
414

    
415
	usort($config['dhcpd'][$if]['staticmap'], "staticmapcmp");
416
}
417

    
418
function aliases_sort() {
419
	global $g, $config;
420

    
421
	function aliascmp($a, $b) {
422
		return strcmp($a['name'], $b['name']);
423
	}
424

    
425
	usort($config['aliases']['alias'], "aliascmp");
426
}
427

    
428
function ipsec_mobilekey_sort() {
429
	global $g, $config;
430

    
431
	function mobilekeycmp($a, $b) {
432
		return strcmp($a['ident'][0], $b['ident'][0]);
433
	}
434

    
435
	usort($config['ipsec']['mobilekey'], "mobilekeycmp");
436
}
437

    
438
function proxyarp_sort() {
439
	global $g, $config;
440

    
441
	function proxyarpcmp($a, $b) {
442
		if (isset($a['network']))
443
			list($ast,$asn) = explode("/", $a['network']);
444
		else if (isset($a['range'])) {
445
			$ast = $a['range']['from'];
446
			$asn = 32;
447
		}
448
		if (isset($b['network']))
449
			list($bst,$bsn) = explode("/", $b['network']);
450
		else if (isset($b['range'])) {
451
			$bst = $b['range']['from'];
452
			$bsn = 32;
453
		}
454
		if (ipcmp($ast, $bst) == 0)
455
			return ($asn - $bsn);
456
		else
457
			return ipcmp($ast, $bst);
458
	}
459

    
460
	usort($config['proxyarp']['proxyarpnet'], "proxyarpcmp");
461
}
462

    
463
function passthrumacs_sort() {
464
	global $g, $config;
465

    
466
	function passthrumacscmp($a, $b) {
467
		return strcmp($a['mac'], $b['mac']);
468
	}
469

    
470
	usort($config['captiveportal']['passthrumac'],"passthrumacscmp");
471
}
472

    
473
function allowedips_sort() {
474
	global $g, $config;
475

    
476
	function allowedipscmp($a, $b) {
477
		return strcmp($a['ip'], $b['ip']);
478
	}
479

    
480
	usort($config['captiveportal']['allowedip'],"allowedipscmp");
481
}
482

    
483
function wol_sort() {
484
	global $g, $config;
485

    
486
	function wolcmp($a, $b) {
487
		return strcmp($a['descr'], $b['descr']);
488
	}
489

    
490
	usort($config['wol']['wolentry'], "wolcmp");
491
}
492

    
493
function gentitle($pgname) {
494
	global $config;
495
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
496
}
497

    
498
/* update the changedesc and changecount(er) variables */
499
function update_changedesc($update) {
500
	global $changedesc;
501
	global $changecount;
502

    
503
	$changedesc .= " {$update}";
504
	$changecount++;
505
}
506

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

    
536
/* Check if variable has changed, update and log if it has
537
 * returns true if var changed
538
 * varname = variable name in plain text
539
 * orig = original value
540
 * new = new value
541
 */
542
function update_if_changed($varname, & $orig, $new) {
543
	if (is_array($orig) && is_array($new)) {
544
		$a_diff = array_diff($orig, $new);
545
		foreach ($a_diff as $diff) {
546
			update_changedesc("removed {$varname}: \"{$diff}\"");
547
		}
548
		$a_diff = array_diff($new, $orig);
549
		foreach ($a_diff as $diff) {
550
			update_changedesc("added {$varname}: \"{$diff}\"");
551
		}
552
		$orig = $new;
553
		return true;
554
			
555
	} else { 
556
		if ($orig != $new) {
557
			update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
558
			$orig = $new;
559
			return true;
560
		}
561
	}
562
	return false;
563
}
564

    
565
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
566

    
567
        if (isset($adr['any']))
568
                $padr = "any";
569
        else if ($adr['network'])
570
                $padr = $adr['network'];
571
        else if ($adr['address']) {
572
                list($padr, $pmask) = explode("/", $adr['address']);
573
                if (!$pmask)
574
                        $pmask = 32;
575
        }
576

    
577
        if (isset($adr['not']))
578
                $pnot = 1;
579
        else
580
                $pnot = 0;
581

    
582
        if ($adr['port']) {
583
                list($pbeginport, $pendport) = explode("-", $adr['port']);
584
                if (!$pendport)
585
                        $pendport = $pbeginport;
586
        } else {
587
                if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
588
                        /* Item is a port alias */
589
                } else {
590
                        $pbeginport = "any";
591
                        $pendport = "any";
592
                }
593
        }
594
}
595

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

    
598
        $adr = array();
599

    
600
        if ($padr == "any")
601
                $adr['any'] = true;
602
        else if (is_specialnet($padr))
603
                $adr['network'] = $padr;
604
        else {
605
                $adr['address'] = $padr;
606
                if ($pmask != 32)
607
                        $adr['address'] .= "/" . $pmask;
608
        }
609

    
610
        if ($pnot)
611
                $adr['not'] = true;
612
        else
613
                unset($adr['not']);
614

    
615
        if (($pbeginport != 0) && ($pbeginport != "any")) {
616
                if ($pbeginport != $pendport)
617
                        $adr['port'] = $pbeginport . "-" . $pendport;
618
                else
619
                        $adr['port'] = $pbeginport;
620
        }
621

    
622
        if(alias_expand($pbeginport)) {
623
                $adr['port'] = $pbeginport;
624
        }
625
}
626

    
627
function is_specialnet($net) {
628
        global $specialsrcdst;
629

    
630
        if (in_array($net, $specialsrcdst) || strstr($net, "opt"))
631
                return true;
632
        else
633
                return false;
634
}
635

    
636
function ipsec_ca_sort() {
637
        global $g, $config;
638

    
639
        function ipseccacmp($a, $b) {
640
                return strcmp($a['ident'], $b['ident']);
641
        }
642

    
643
        usort($config['ipsec']['cacert'], "ipseccacmp");
644
}
645

    
646

    
647
?>
(54-54/147)