Project

General

Profile

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

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_MODULE:	base
33
*/
34

    
35
/* Include authentication routines */
36
/* THIS MUST BE ABOVE ALL OTHER CODE */
37
if (!$nocsrf) {
38
	function csrf_startup() {
39
		csrf_conf('rewrite-js', '/csrf/csrf-magic.js');
40
		$timeout_minutes = isset($config['system']['webgui']['session_timeout']) ? $config['system']['webgui']['session_timeout'] : 240;
41
		csrf_conf('expires', $timeout_minutes * 60);
42
	}
43
	require_once("csrf/csrf-magic.php");
44
}
45

    
46
/* make sure nothing is cached */
47
if (!$omit_nocacheheaders) {
48
	header("Expires: 0");
49
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
50
	header("Cache-Control: no-cache, no-store, must-revalidate");
51
	header("Pragma: no-cache");
52
}
53

    
54
header("X-Frame-Options: SAMEORIGIN");
55
require_once("authgui.inc");
56

    
57
/* parse the configuration and include all configuration functions */
58
require_once("functions.inc");
59

    
60
/* Pull in all the gui related display classes) */
61
foreach (scandir("/usr/local/www/classes/") as $file) {
62
	if (substr($file, -4) == ".inc") {
63
		require_once("classes/{$file}");
64
	}
65
}
66

    
67
$g['theme'] = get_current_theme();
68

    
69
/* Set the default interface language */
70
if ($config['system']['language'] <> "") {
71
	$g['language'] = $config['system']['language'];
72
} elseif ($g['language'] == "") {
73
	$g['language'] = 'en_US';
74
}
75

    
76
set_language($g['language']);
77

    
78
/* used by progress bar */
79
$lastseen = "-1";
80

    
81
$navlevelsep = ": ";	/* navigation level separator string */
82
$mandfldhtml = "";		/* display this before mandatory input fields */
83
$mandfldhtmlspc = "";	/* same as above, but with spacing */
84

    
85
/* Some ajax scripts still need access to GUI */
86
if (!$ignorefirmwarelock) {
87
	if (is_subsystem_dirty('firmwarelock')) {
88
		if (!$d_isfwfile) {
89
			header("Location: system_firmware.php");
90
			exit;
91
		} else {
92
			return;
93
		}
94
	}
95
}
96

    
97
/* Reserved table names to avoid collision */
98
$reserved_table_names = array(
99
	"bogons",
100
	"bogonsv6",
101
	"negate_networks",
102
	"snort2c",
103
	"sshlockout",
104
	"tonatsubnets",
105
	"virusprot",
106
	"vpn_networks",
107
	"webConfiguratorlockout"
108
);
109

    
110
$firewall_rules_dscp_types = array(
111
	"af11",
112
	"af12",
113
	"af13",
114
	"af21",
115
	"af22",
116
	"af23",
117
	"af31",
118
	"af32",
119
	"af33",
120
	"af41",
121
	"af42",
122
	"af43",
123
	"VA",
124
	"EF",
125
	"cs1",
126
	"cs2",
127
	"cs3",
128
	"cs4",
129
	"cs5",
130
	"cs6",
131
	"cs7",
132
	"0x01",
133
	"0x02",
134
	"0x04");
135

    
136
$auth_server_types = array(
137
	'ldap' => "LDAP",
138
	'radius' => "Radius");
139

    
140
$ldap_urltypes = array(
141
	'TCP - Standard' => 389,
142
	'SSL - Encrypted' => 636);
143

    
144
$ldap_scopes = array(
145
	'one' => "One Level",
146
	'subtree' => "Entire Subtree");
147

    
148
$ldap_protvers = array(
149
	2,
150
	3);
151

    
152
$ldap_templates = array(
153

    
154
	'open' => array(
155
		'desc' => "OpenLDAP",
156
		'attr_user' => "cn",
157
		'attr_group' => "cn",
158
		'attr_member' => "member"),
159

    
160
	'msad' => array(
161
		'desc' => "Microsoft AD",
162
		'attr_user' => "samAccountName",
163
		'attr_group' => "cn",
164
		'attr_member' => "memberOf"),
165

    
166
	'edir' => array(
167
		'desc' => "Novell eDirectory",
168
		'attr_user' => "cn",
169
		'attr_group' => "cn",
170
		'attr_member' => "uniqueMember"));
171

    
172
$radius_srvcs = array(
173
	'both' => "Authentication and Accounting",
174
	'auth' => "Authentication",
175
	'acct' => "Accounting");
176

    
177
$netbios_nodetypes = array(
178
	'0' => "none",
179
	'1' => "b-node",
180
	'2' => "p-node",
181
	'4' => "m-node",
182
	'8' => "h-node");
183

    
184
/* some well known ports */
185
$wkports = array(
186
	5999 => "CVSup",
187
	53 => "DNS",
188
	21 => "FTP",
189
	3000 => "HBCI",
190
	80 => "HTTP",
191
	443 => "HTTPS",
192
	5190 => "ICQ",
193
	113 => "IDENT/AUTH",
194
	143 => "IMAP",
195
	993 => "IMAP/S",
196
	4500 => "IPsec NAT-T",
197
	500 => "ISAKMP",
198
	1701 => "L2TP",
199
	389 => "LDAP",
200
	1755 => "MMS/TCP",
201
	7000 => "MMS/UDP",
202
	445 => "MS DS",
203
	3389 => "MS RDP",
204
	1512 => "MS WINS",
205
	1863 => "MSN",
206
	119 => "NNTP",
207
	123 => "NTP",
208
	138 => "NetBIOS-DGM",
209
	137 => "NetBIOS-NS",
210
	139 => "NetBIOS-SSN",
211
	1194 => "OpenVPN",
212
	110 => "POP3",
213
	995 => "POP3/S",
214
	1723 => "PPTP",
215
	1812 => "RADIUS",
216
	1813 => "RADIUS accounting",
217
	5004 => "RTP",
218
	5060 => "SIP",
219
	25 => "SMTP",
220
	465 => "SMTP/S",
221
	161 => "SNMP",
222
	162 => "SNMP-Trap",
223
	22 => "SSH",
224
	3478 => "STUN",
225
	587 => "SUBMISSION",
226
	3544 => "Teredo",
227
	23 => "Telnet",
228
	69 => "TFTP",
229
	5900 => "VNC");
230

    
231
/* TCP flags */
232
$tcpflags = array("fin", "syn", "rst", "psh", "ack", "urg", "ece", "cwr");
233

    
234
$specialnets = array("(self)" => "This Firewall", "pptp" => "PPTP clients", "pppoe" => "PPPoE clients", "l2tp" => "L2TP clients");
235

    
236
$spiflist = get_configured_interface_with_descr(false, true);
237
foreach ($spiflist as $ifgui => $ifdesc) {
238
	$specialnets[$ifgui] = $ifdesc . " net";
239
	$specialnets[$ifgui . 'ip'] = $ifdesc . " address";
240
}
241

    
242
$medias = array(
243
	"auto" => "autoselect",
244
	"100full" => "100BASE-TX full-duplex",
245
	"100half" => "100BASE-TX half-duplex",
246
	"10full" => "10BASE-T full-duplex",
247
	"10half" => "10BASE-T half-duplex");
248

    
249
$wlan_modes = array(
250
	"bss" => "Infrastructure (BSS)",
251
	"adhoc" => "Ad-hoc (IBSS)",
252
	"hostap" => "Access Point");
253

    
254
/* platforms that support firmware updating */
255
$fwupplatforms = array('pfSense', 'net45xx', 'net48xx', 'generic-pc', 'embedded', 'wrap', 'nanobsd');
256

    
257
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_errors) {
258

    
259
	/* check for bad control characters */
260
	foreach ($postdata as $pn => $pd) {
261
		if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
262
			$input_errors[] = sprintf(gettext("The field %s contains invalid characters."), $pn);
263
		}
264
	}
265

    
266
	for ($i = 0; $i < count($reqdfields); $i++) {
267
		if ($_POST[$reqdfields[$i]] == "" && $_REQUEST[$reqdfields[$i]] == "") {
268
			$input_errors[] = sprintf(gettext("The field %s is required."), $reqdfieldsn[$i]);
269
		}
270
	}
271
}
272

    
273
function print_input_errors($input_errors) {
274
	global $g;
275

    
276
	print <<<EOF
277
	<div id="inputerrorsdiv">
278
	<table border="0" cellspacing="0" cellpadding="4" width="100%" summary="input errors">
279
	<tr>
280
		<td class="inputerrorsleft">
281
			<img src="/themes/{$g['theme']}/images/icons/icon_error.gif" alt="errors" />
282
		</td>
283
		<td class="inputerrorsright errmsg">
284
EOF;
285
	echo "<p>" . gettext("The following input errors were detected:") . "</p>\n<ul>";
286
	foreach ($input_errors as $ierr) {
287
		echo "<li>" . htmlspecialchars($ierr) . "</li>";
288
	}
289

    
290
	print <<<EOF2
291
				</ul>
292
		</td>
293
	</tr>
294
	</table>
295
	</div>
296
	&nbsp;<br />
297
EOF2;
298

    
299
}
300

    
301
function verify_gzip_file($fname) {
302
	$returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
303
	if ($returnvar != 0) {
304
		return 0;
305
	} else {
306
		return 1;
307
	}
308
}
309

    
310
function print_info_box_np($msg, $name = "apply", $value = "", $showapply = false) {
311
	global $g, $nifty_redbox, $nifty_blackbox, $nifty_background;
312

    
313
	if (empty($value)) {
314
		$value = gettext("Apply changes");
315
	}
316

    
317
	// Set the Nifty background color if one is not set already (defaults to white)
318
	if ($nifty_background == "") {
319
		$nifty_background = "#FFF";
320
	}
321

    
322
	if (stristr($msg, gettext("apply")) != false || stristr($msg, gettext("save")) != false || stristr($msg, gettext("create")) != false || $showapply) {
323
		$savebutton = "<td class=\"infoboxsave\">";
324
		$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\" />";
325
		if ($_POST['if']) {
326
			$savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />";
327
		}
328
		$savebutton .= "</td>";
329
	}
330
	$nifty_redbox = "#990000";
331
	$nifty_blackbox = "#000000";
332

    
333
	$themename = $g['theme'];
334

    
335
	if (file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
336
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
337
		eval($toeval);
338
	}
339

    
340
	if (file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
341
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
342
		eval($toeval);
343
	}
344

    
345
	if (!$savebutton) {
346
		$savebutton = "<td class=\"infoboxsave\"><input value=\"" . gettext("Close") . "\" type=\"button\" onclick=\"jQuery(this).parents('table[id=redboxtable]').hide();\" /></td>";
347
	}
348

    
349
	echo <<<EOFnp
350
	<table class="infobox" id="redboxtable" summary="red box table">
351
		<tr>
352
			<td>
353
				<div class="infoboxnp" id="redbox">
354
					<table class="infoboxnptable2" summary="message">
355
						<tr>
356
							<td class="infoboxnptd">
357
								&nbsp;&nbsp;&nbsp;<img class="infoboxnpimg" src="/themes/{$g['theme']}/images/icons/icon_exclam.gif" alt="exclamation" />
358
							</td>
359
							<td class="infoboxnptd2">
360
								<b>{$msg}</b>
361
							</td>
362
							{$savebutton}
363
						</tr>
364
					</table>
365
				</div>
366
				<div>
367
					<p>&nbsp;</p>
368
				</div>
369
			</td>
370
		</tr>
371
	</table>
372
	<script type="text/javascript">
373
	//<![CDATA[
374
		NiftyCheck();
375
		Rounded("div#redbox","all","{$nifty_background}","{$nifty_redbox}","smooth");
376
		Rounded("td#blackbox","all","{$nifty_background}","{$nifty_blackbox}","smooth");
377
	//]]>
378
	</script>
379
EOFnp;
380

    
381
}
382

    
383
function print_info_box_np_undo($msg, $name = "apply", $value = "Apply changes", $undo) {
384
	global $g;
385

    
386
	if (stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) {
387
		$savebutton = "<td class=\"infoboxsave nowrap\">";
388
		$savebutton .= "<input type=\"button\" value=\"". gettext("Undo") . "\" onclick=\"document.location='{$undo}'\" />";
389
		$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\" />";
390
		$savebutton .= "</td>";
391
		if ($_POST['if']) {
392
			$savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />";
393
		}
394
	}
395
	$nifty_redbox = "#990000";
396
	$nifty_blackbox = "#000000";
397

    
398
	$themename = $g['theme'];
399

    
400
	if (file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
401
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
402
		eval($toeval);
403
	}
404

    
405
	if (file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
406
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
407
		eval($toeval);
408
	}
409

    
410

    
411
	if (!$savebutton) {
412
		$savebutton = "<td class=\"infoboxsave\"><input value=\"" . gettext("Close") . "\" type=\"button\" onclick=\"jQuery(this).parents('table[id=redboxtable]').hide();\" /></td>";
413
	}
414

    
415
	echo <<<EOFnp
416
	<table class="infobox" id="redboxtable" summary="red box table">
417
		<tr>
418
			<td>
419
				<div class="infoboxnp" id="redbox">
420
					<table class="infoboxnptable2" summary="message">
421
						<tr>
422
							<td class="infoboxnptd">
423
								&nbsp;&nbsp;&nbsp;<img class="infoboxnpimg" src="/themes/{$g['theme']}/images/icons/icon_exclam.gif" alt="exclamation" />
424
							</td>
425
							<td class="infoboxnptd2">
426
								<b>{$msg}</b>
427
							</td>
428
							{$savebutton}
429
							{$undobutton}
430
						</tr>
431
					</table>
432
				</div>
433
				<div>
434
					<p>&nbsp;</p>
435
				</div>
436
			</td>
437
		</tr>
438
	</table>
439
	<script type="text/javascript">
440
	//<![CDATA[
441
		NiftyCheck();
442
		Rounded("div#redbox","all","#FFF","{$nifty_redbox}","smooth");
443
		Rounded("td#blackbox","all","#FFF","{$nifty_blackbox}","smooth");
444
	//]]>
445
	</script>
446
EOFnp;
447

    
448
}
449

    
450
function print_info_box($msg) {
451
	print_info_box_np($msg);
452
}
453

    
454
function get_std_save_message($ok) {
455
	global $d_sysrebootreqd_path;
456
	$filter_related = false;
457
	$filter_pages = array("nat", "filter");
458
	$to_return = gettext("The changes have been applied successfully.");
459
	foreach ($filter_pages as $fp) {
460
		if (stristr($_SERVER['SCRIPT_FILENAME'], $fp)) {
461
			$filter_related = true;
462
		}
463
	}
464
	if ($filter_related) {
465
		$to_return .= "<br />" . gettext("You can also <a href=\"status_filter_reload.php\">monitor</a> the filter reload progress.");
466
	}
467
	return $to_return;
468
}
469

    
470
function pprint_address($adr) {
471
	global $specialnets;
472

    
473
	if (isset($adr['any'])) {
474
		$padr = "*";
475
	} else if ($adr['network']) {
476
		$padr = $specialnets[$adr['network']];
477
	} else {
478
		$padr = $adr['address'];
479
	}
480

    
481
	if (isset($adr['not'])) {
482
		$padr = "! " . $padr;
483
	}
484

    
485
	return $padr;
486
}
487

    
488
function pprint_port($port) {
489
	global $wkports;
490

    
491
	$pport = "";
492

    
493
	if (!$port) {
494
		return "*";
495
	} else {
496
		$srcport = explode("-", $port);
497
		if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
498
			$pport = $srcport[0];
499
			if ($wkports[$srcport[0]]) {
500
				$pport .= " (" . $wkports[$srcport[0]] . ")";
501
			}
502
		} else {
503
			$pport .= $srcport[0] . " - " . $srcport[1];
504
		}
505
	}
506

    
507
	return $pport;
508
}
509

    
510
function firewall_check_for_advanced_options(&$item) {
511
	$item_set = "";
512
	if ($item['os']) {
513
			$item_set .= "os {$item['os']} ";
514
	}
515
	if ($item['dscp']) {
516
		$item_set .= "dscp {$item['dscp']} ";
517
	}
518
	if ($item['max']) {
519
		$item_set .= "max {$item['max']} ";
520
	}
521
	if ($item['max-src-nodes']) {
522
		$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
523
	}
524
	if ($item['max-src-conn']) {
525
		$item_set .= "max-src-conn {$item['max-src-conn']} ";
526
	}
527
	if ($item['max-src-states']) {
528
		$item_set .= "max-src-states {$item['max-src-states']} ";
529
	}
530
	if (isset($item['nopfsync'])) {
531
		$item_set .= "nopfsync ";
532
	}
533
	if ($item['statetype'] != "keep state" && $item['statetype'] != "") {
534
		$item_set .= "statetype {$item['statetype']} ";
535
	}
536
	if ($item['statetimeout']) {
537
		$item_set .= "statetimeout {$item['statetimeout']} ";
538
	}
539
	if (isset($item['nosync'])) {
540
		$item_set .= "no XMLRPC Sync ";
541
	}
542
	if ($item['max-src-conn-rate']) {
543
		$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
544
	}
545
	if ($item['max-src-conn-rates']) {
546
		$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
547
	}
548
	if ($item['vlanprio']) {
549
		$item_set .= "vlanprio {$item['vlanprio']} ";
550
	}
551
	if ($item['vlanprioset']) {
552
		$item_set .= "vlanprioset {$item['vlanprioset']} ";
553
	}
554
	if ($item['gateway']) {
555
		$item_set .= "gateway {$item['gateway']} ";
556
	}
557
	if ($item['dnpipe']) {
558
		$item_set .= "limiter {$item['dnpipe']} ";
559
	}
560
	if ($item['pdnpipe']) {
561
		$item_set .= "limiter {$item['pdnpipe']} ";
562
	}
563
	if ($item['ackqueue']) {
564
		$item_set .= "ackqueue {$item['ackqueue']} ";
565
	}
566
	if ($item['defaultqueue']) {
567
		$item_set .= "defaultqueue {$item['defaultqueue']} ";
568
	}
569
	if ($item['l7container']) {
570
		$item_set .= "layer7 {$item['l7container']} ";
571
	}
572
	if ($item['tag']) {
573
		$item_set .= "tag {$item['tag']} ";
574
	}
575
	if ($item['tagged']) {
576
		$item_set .= "tagged {$item['tagged']} ";
577
	}
578
	if (isset($item['allowopts'])) {
579
		$item_set .= "allowopts ";
580
	}
581
	if (isset($item['disablereplyto'])) {
582
		$item_set .= "disable reply-to ";
583
	}
584
	if ($item['tcpflags_any'] || $item['tcpflags1'] || $item['tcpflags2']) {
585
		$item_set .= "tcpflags set";
586
	}
587

    
588
	return $item_set;
589
}
590

    
591
function gentitle($title) {
592
	global $navlevelsep;
593
	if (!is_array($title)) {
594
		return $title;
595
	} else {
596
		return join($navlevelsep, $title);
597
	}
598
}
599

    
600
function genhtmltitle($title) {
601
	global $config;
602
	return gentitle($title);
603
}
604

    
605
/* update the changedesc and changecount(er) variables */
606
function update_changedesc($update) {
607
	global $changedesc;
608
	global $changecount;
609

    
610
	$changedesc .= " {$update}";
611
	$changecount++;
612
}
613

    
614
function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = true) {
615
	global $config, $g;
616
	if ($restart_syslogd) {
617
		exec("/usr/bin/killall syslogd");
618
	}
619
	if (isset($config['system']['disablesyslogclog'])) {
620
		unlink($logfile);
621
		touch($logfile);
622
	} else {
623
		$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "511488";
624
		if (isset($config['system']['usefifolog'])) {
625
			exec("/usr/sbin/fifolog_create -s {$log_size} " . escapeshellarg($logfile));
626
		} else {
627
			exec("/usr/local/sbin/clog -i -s {$log_size} " . escapeshellarg($logfile));
628
		}
629
	}
630
	if ($restart_syslogd) {
631
		system_syslogd_start();
632
	}
633
}
634

    
635
function clear_all_log_files() {
636
	global $g;
637
	exec("/usr/bin/killall syslogd");
638

    
639
	$log_files = array("system", "filter", "dhcpd", "vpn", "pptps", "poes", "l2tps", "openvpn", "portalauth", "ipsec", "ppp", "relayd", "wireless", "lighttpd", "ntpd", "gateways", "resolver", "routing");
640
	foreach ($log_files as $lfile) {
641
		clear_log_file("{$g['varlog_path']}/{$lfile}.log", false);
642
	}
643

    
644
	system_syslogd_start();
645
	killbyname("dhcpd");
646
	services_dhcpd_configure();
647
	return;
648
}
649

    
650
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
651
	global $g, $config;
652
	$sor = isset($config['syslog']['reverse']) ? "-r" : "";
653
	$logarr = "";
654
	$grepline = "  ";
655
	if (is_array($grepfor)) {
656
		$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
657
	}
658
	if (is_array($grepinvert)) {
659
		$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
660
	}
661
	if (is_dir($logfile)) {
662
		$logarr = array("File $logfile is a directory.");
663
	} elseif (file_exists($logfile) && filesize($logfile) == 0) {
664
		$logarr = array("Log file started.");
665
	} else {
666
		if ($config['system']['disablesyslogclog']) {
667
			exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
668
		} else {
669
			if (isset($config['system']['usefifolog'])) {
670
				exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
671
			} else {
672
				exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
673
			}
674
		}
675
	}
676
	foreach ($logarr as $logent) {
677
		$logent = preg_split("/\s+/", $logent, 6);
678
		echo "<tr valign=\"top\">\n";
679
		if ($withorig) {
680
			if (isset($config['system']['usefifolog'])) {
681
				$entry_date_time = htmlspecialchars(date("F j, Y, g:i a", "" . $logent[1] . ""));
682
				$entry_text = htmlspecialchars($logent[5]);
683
			} else {
684
				$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
685
				$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
686
				$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
687
			}
688
			echo "<td class=\"listlr nowrap\">{$entry_date_time}</td>\n";
689
			echo "<td class=\"listr\">{$entry_text}</td>\n";
690
		} else {
691
				echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
692
		}
693
		echo "</tr>\n";
694
	}
695
}
696

    
697
function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "", $grepreverse = false) {
698
	global $g, $config;
699
	$sor = (isset($config['syslog']['reverse']) || $grepreverse) ? "-r" : "";
700
	$logarr = "";
701
	$grepline = "  ";
702
	if (is_array($grepfor)) {
703
		$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
704
	}
705
	if (is_array($grepinvert)) {
706
		$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
707
	}
708
	if ($config['system']['disablesyslogclog']) {
709
		exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
710
	} else {
711
		if (isset($config['system']['usefifolog'])) {
712
			exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
713
		} else {
714
			exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
715
		}
716
	}
717
	return($logarr);
718
}
719

    
720
/* Check if variable has changed, update and log if it has
721
 * returns true if var changed
722
 * varname = variable name in plain text
723
 * orig = original value
724
 * new = new value
725
 */
726
function update_if_changed($varname, & $orig, $new) {
727
	if (is_array($orig) && is_array($new)) {
728
		$a_diff = array_diff($orig, $new);
729
		foreach ($a_diff as $diff) {
730
			update_changedesc("removed {$varname}: \"{$diff}\"");
731
		}
732
		$a_diff = array_diff($new, $orig);
733
		foreach ($a_diff as $diff) {
734
			update_changedesc("added {$varname}: \"{$diff}\"");
735
		}
736
		$orig = $new;
737
		return true;
738

    
739
	} else {
740
		if ($orig != $new) {
741
			update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
742
			$orig = $new;
743
			return true;
744
		}
745
	}
746
	return false;
747
}
748

    
749
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
750
	if (isset($adr['any'])) {
751
		$padr = "any";
752
	} else if ($adr['network']) {
753
		$padr = $adr['network'];
754
	} else if ($adr['address']) {
755
		list($padr, $pmask) = explode("/", $adr['address']);
756
		if (!$pmask) {
757
			if (is_ipaddrv6($padr)) {
758
				$pmask = 128;
759
			} else {
760
				$pmask = 32;
761
			}
762
		}
763
	}
764

    
765
	if (isset($adr['not'])) {
766
		$pnot = 1;
767
	} else {
768
		$pnot = 0;
769
	}
770

    
771
	if ($adr['port']) {
772
		list($pbeginport, $pendport) = explode("-", $adr['port']);
773
		if (!$pendport) {
774
			$pendport = $pbeginport;
775
		}
776
	} else if (!is_alias($pbeginport) && !is_alias($pendport)) {
777
		$pbeginport = "any";
778
		$pendport = "any";
779
	}
780
}
781

    
782
function pconfig_to_address(&$adr, $padr, $pmask, $pnot = false, $pbeginport = 0, $pendport = 0) {
783
	$adr = array();
784

    
785
	if ($padr == "any") {
786
		$adr['any'] = true;
787
	} else if (is_specialnet($padr)) {
788
		$adr['network'] = $padr;
789
	} else {
790
		$adr['address'] = $padr;
791
		if (is_ipaddrv6($padr)) {
792
			if ($pmask != 128) {
793
				$adr['address'] .= "/" . $pmask;
794
			}
795
		} else {
796
			if ($pmask != 32) {
797
				$adr['address'] .= "/" . $pmask;
798
			}
799
		}
800
	}
801

    
802
	if ($pnot) {
803
		$adr['not'] = true;
804
	} else {
805
		unset($adr['not']);
806
	}
807

    
808
	if (($pbeginport != 0) && ($pbeginport != "any")) {
809
		if ($pbeginport != $pendport) {
810
			$adr['port'] = $pbeginport . "-" . $pendport;
811
		} else {
812
			$adr['port'] = $pbeginport;
813
		}
814
	}
815

    
816
	if (is_alias($pbeginport)) {
817
		$adr['port'] = $pbeginport;
818
	}
819
}
820

    
821
function is_specialnet($net) {
822
	global $specialsrcdst;
823

    
824
	if (!$net) {
825
		return false;
826
	}
827
	if (in_array($net, $specialsrcdst)) {
828
		return true;
829
	} else {
830
		return false;
831
	}
832
}
833

    
834
//function to create widget tabs when called
835
function display_widget_tabs(& $tab_array) {
836
	echo "<div id=\"tabs\">";
837
	$tabscounter = 0;
838
	foreach ($tab_array as $ta) {
839
		$dashpos = strpos($ta[2], '-');
840
		$tabname = $ta[2] . "-tab";
841
		$tabclass = substr($ta[2], 0, $dashpos);
842
		$tabclass = $tabclass . "-class";
843
		if ($ta[1] == true) {
844
			$tabActive = "table-cell";
845
			$tabNonActive = "none";
846
		} else {
847
			$tabActive = "none";
848
			$tabNonActive = "table-cell";
849
		}
850
		echo "<div id=\"{$ta[2]}-active\" class=\"{$tabclass}-tabactive\" style=\"display:{$tabActive}; background-color:#EEEEEE; color:black;\">";
851
		echo "<b>&nbsp;&nbsp;&nbsp;{$ta[0]}";
852
		echo "&nbsp;&nbsp;&nbsp;</b>";
853
		echo "</div>";
854

    
855
		echo "<div id=\"{$ta[2]}-deactive\" class=\"{$tabclass}-tabdeactive\" style=\"display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;\" onclick=\"return changeTabDIV('{$ta[2]}')\">";
856
		echo "<b>&nbsp;&nbsp;&nbsp;{$ta[0]}";
857
		echo "&nbsp;&nbsp;&nbsp;</b>";
858
		echo "</div>";
859
	}
860

    
861
	echo "<script type=\"text/javascript\">";
862
	echo "\n//<![CDATA[\n";
863
	echo "NiftyCheck();\n";
864
	echo "Rounded(\"div.{$tabclass}-tabactive\",\"top\",\"#CCCCCC\",\"#EEEEEE\",\"smooth\");\n";
865
	echo "Rounded(\"div.{$tabclass}-tabdeactive\",\"top\",\"#CCCCCC\",\"#777777\",\"smooth\");\n";
866
	echo "//]]>\n";
867
	echo "</script>";
868
	echo "</div>";
869
}
870

    
871

    
872
// Return inline javascript file or CSS to minimize
873
// request count going back to server.
874
function outputJavaScriptFileInline($javascript) {
875
	if (file_exists($javascript)) {
876
		echo "\n<script type=\"text/javascript\">\n";
877
		include($javascript);
878
		echo "\n</script>\n";
879
	} else {
880
		echo "\n\n<!-- Could not locate file:  {$javascript} -->\n\n";
881
	}
882
}
883

    
884

    
885

    
886
function outputCSSPrintFileInline($css) {
887
	if (file_exists($css)) {
888
		echo "\n<style media=\"print\" type=\"text/css\">\n";
889
		include($css);
890
		echo "\n</style>\n";
891
	} else {
892
		echo "\n\n<!-- Could not locate file:  {$css} -->\n\n";
893
	}
894
}
895

    
896

    
897
function outputCSSFileInline($css) {
898
	if (file_exists($css)) {
899
		echo "\n<style type=\"text/css\">\n";
900
		include($css);
901
		echo "\n</style>\n";
902
	} else {
903
		echo "\n\n<!-- Could not locate file:  {$css} -->\n\n";
904
	}
905
}
906

    
907
$rfc2616 = array(
908
	100 => "100 Continue",
909
	101 => "101 Switching Protocols",
910
	200 => "200 OK",
911
	201 => "201 Created",
912
	202 => "202 Accepted",
913
	203 => "203 Non-Authoritative Information",
914
	204 => "204 No Content",
915
	205 => "205 Reset Content",
916
	206 => "206 Partial Content",
917
	300 => "300 Multiple Choices",
918
	301 => "301 Moved Permanently",
919
	302 => "302 Found",
920
	303 => "303 See Other",
921
	304 => "304 Not Modified",
922
	305 => "305 Use Proxy",
923
	306 => "306 (Unused)",
924
	307 => "307 Temporary Redirect",
925
	400 => "400 Bad Request",
926
	401 => "401 Unauthorized",
927
	402 => "402 Payment Required",
928
	403 => "403 Forbidden",
929
	404 => "404 Not Found",
930
	405 => "405 Method Not Allowed",
931
	406 => "406 Not Acceptable",
932
	407 => "407 Proxy Authentication Required",
933
	408 => "408 Request Timeout",
934
	409 => "409 Conflict",
935
	410 => "410 Gone",
936
	411 => "411 Length Required",
937
	412 => "412 Precondition Failed",
938
	413 => "413 Request Entity Too Large",
939
	414 => "414 Request-URI Too Long",
940
	415 => "415 Unsupported Media Type",
941
	416 => "416 Requested Range Not Satisfiable",
942
	417 => "417 Expectation Failed",
943
	500 => "500 Internal Server Error",
944
	501 => "501 Not Implemented",
945
	502 => "502 Bad Gateway",
946
	503 => "503 Service Unavailable",
947
	504 => "504 Gateway Timeout",
948
	505 => "505 HTTP Version Not Supported"
949
);
950

    
951
function is_rfc2616_code($code) {
952
	global $rfc2616;
953
	if (isset($rfc2616[$code])) {
954
		return true;
955
	} else {
956
		return false;
957
	}
958
}
959

    
960
function print_rfc2616_select($tag, $current) {
961
	global $rfc2616;
962

    
963
	/* Default to 200 OK if not set */
964
	if ($current == "") {
965
		$current = 200;
966
	}
967

    
968
	echo "<select id=\"{$tag}\" name=\"{$tag}\">\n";
969
	foreach ($rfc2616 as $code => $message) {
970
		if ($code == $current) {
971
			$sel = " selected=\"selected\"";
972
		} else {
973
			$sel = "";
974
		}
975
		echo "<option value=\"{$code}\"{$sel}>{$message}</option>\n";
976
	}
977
	echo "</select>\n";
978
}
979

    
980
// Useful debugging function, much cleaner than print_r
981
function echo_array($array, $return_me = false) {
982
	if (is_array($array) == false) {
983
		$return = "The provided variable is not an array.";
984
	} else {
985
		foreach ($array as $name=>$value) {
986
			if (is_array($value)) {
987
				$return .= "";
988
				$return .= "['<b>$name</b>'] {<div style=\"margin-left:10px;\">\n";
989
				$return .= echo_array($value, true);
990
				$return .= "</div>}";
991
				$return .= "\n\n";
992
			} else {
993
				if (is_string($value)) {
994
					$value = "\"$value\"";
995
				}
996
				$return .= "['<b>$name</b>'] = $value\n\n";
997
			}
998
		}
999
	}
1000
	if ($return_me == true) {
1001
		return $return;
1002
	} else {
1003
		echo "<pre>".$return."</pre>";
1004
	}
1005
}
1006

    
1007
/****f* pfsense-utils/display_top_tabs
1008
 * NAME
1009
 *   display_top_tabs - display tabs with rounded edges
1010
 * INPUTS
1011
 *   $text      - array of tabs
1012
 * RESULT
1013
 *   null
1014
 ******/
1015
function display_top_tabs(& $tab_array, $no_drop_down = false) {
1016
	global $config;
1017
	global $g;
1018
	global $tab_array_indent;
1019
	global $tab_array_space;
1020
	global $tab_array_char_limit;
1021

    
1022
	/*  does the user have access to this tab?
1023
	 *  master user has access to everything.
1024
	 *  if the user does not have access, simply
1025
	 *  unset the tab item.
1026
	 */
1027

    
1028
	/* empty string code */
1029
	if ($tab_array_indent == '') {
1030
		$tab_array_indent = 0;
1031
	}
1032

    
1033
	if ($tab_array_space == '') {
1034
		$tab_array_space = 1;
1035
	}
1036

    
1037
	if ($tab_array_char_limit == '') {
1038
		$tab_array_char_limit = 92;
1039
	}
1040

    
1041
	foreach ($tab_array as $tab_id => $ta) {
1042
		if (!isAllowedPage($ta[2])) {
1043
			unset ($tab_array[$tab_id]);
1044
		}
1045
	}
1046

    
1047
	$tab_active_bg   = "#EEEEEE";
1048
	$tab_inactive_bg = "#777777";
1049
	$nifty_tabs_corners = "#FFF";
1050
	$font_color = "white";
1051

    
1052
	/* if tabcontrols.php exist for a theme, allow it to be overridden */
1053
	$themename = $config['theme'];
1054
	$filename = "/usr/local/www/themes/{$themename}/tabcontrols.php";
1055
	if (file_exists($filename)) {
1056
		$eval_code = file_get_contents($filename);
1057
		eval($eval_code);
1058
	}
1059

    
1060
	$tabcharcount = 0;
1061
	foreach ($tab_array as $ta) {
1062
		$tabcharcount = $tabcharcount + strlen($ta[0]);
1063
	}
1064

    
1065
	if ($no_drop_down == true) {
1066
		$tabcharcount = 0;
1067
		unset($tab_array_char_limit);
1068
	}
1069

    
1070
	// If the character count of the tab names is > 670
1071
	// then show a select item dropdown menubox.
1072
	if ($tabcharcount > $tab_array_char_limit) {
1073
		echo gettext("Currently viewing: ");
1074
		echo "<select name=\"TabSelect\" onchange=\"tabs_will_go(this)\">\n";
1075
		foreach ($tab_array as $ta) {
1076
			if ($ta[1] == "true") {
1077
				$selected = " selected=\"selected\"";
1078
			} else {
1079
				$selected = "";
1080
			}
1081
			// Onclick in option will not work in some browser
1082
			// echo "<option onclick=\"document.location='{$ta[2]}';\"{$selected}>{$ta['0']}</option>\n";
1083
			echo "<option value=\"{$ta[2]}\"{$selected}>{$ta['0']}</option>\n";
1084
		}
1085
		echo "</select>\n<p>&nbsp;</p>";
1086
		echo "<script type=\"text/javascript\">";
1087
		echo "\n//<![CDATA[\n";
1088
		echo " function tabs_will_go(obj) { document.location = obj.value; }\n";
1089
		echo "//]]>\n";
1090
		echo "</script>";
1091
	} else {
1092
		echo "<div class=\"newtabmenu\" style=\"margin:{$tab_array_space}px {$tab_array_indent}px; width:775px;\">\n";
1093
		echo "<!-- Tabbed bar code-->\n";
1094
		echo "<ul class=\"newtabmenu\">\n";
1095
		$tabscounter = 0;
1096
		foreach ($tab_array as $ta) {
1097
			if ($ta[1] == true) {
1098
				echo "  <li class=\"newtabmenu_active\"><a href=\"{$ta[2]}\"><span>{$ta[0]}</span></a></li>\n";
1099
			} else {
1100
				echo "  <li><a href=\"{$ta[2]}\"><span>{$ta[0]}</span></a></li>\n";
1101
			}
1102
			$tabscounter++;
1103
		}
1104
		echo "</ul>\n</div>\n";
1105
	}
1106
}
1107

    
1108
function add_package_tabs($pkgname, &$tab_array) {
1109
	global $config, $g;
1110

    
1111
	$pkg = get_pkg_data($pkgname);
1112

    
1113
	if (!isset($pkg['configurationfile']) || !file_exists('/usr/local/pkg/' . $pkg['configurationfile'])) {
1114
		return;
1115
	}
1116

    
1117
	$pkg_config = parse_xml_config_pkg('/usr/local/pkg/' . $pkg['configurationfile'], "packagegui");
1118

    
1119
	if (!isset($pkg_config['tabs']['tab'])) {
1120
		return;
1121
	}
1122

    
1123
	foreach ($pkg_config['tabs']['tab'] as $tab) {
1124
		$tab_entry = array();
1125
		if ($tab['name']) {
1126
			$tab_entry[] = $tab['name'];
1127
			$tab_entry[] = false;
1128
			$tab_entry[] = $tab['url'];
1129
			$tab_array[] = $tab_entry;
1130
		}
1131
	}
1132
}
1133

    
1134
function alias_info_popup($alias_id) {
1135
	global $config;
1136
	$maxlength = 60;
1137
	$close_title="title='".gettext('move mouse out of this alias to hide')."'";
1138
	if (is_array($config['aliases']['alias'][$alias_id])) {
1139
		$alias_name = $config['aliases']['alias'][$alias_id];
1140
		$alias_objects_with_details = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" summary=\"alias info popup\">";
1141
		if ($alias_name['url']) {
1142
			// TODO: Change it when pf supports tables with ports
1143
			if ($alias_name['type'] == "urltable") {
1144
				exec("/sbin/pfctl -t {$alias_name['name']} -T show | wc -l", $total_entries);
1145
				$counter = preg_replace("/\D/", "", $total_entries[0]);
1146
				exec("/sbin/pfctl -t {$alias_name['name']} -T show | head -10002", $alias_addresses);
1147
			} else {
1148
				$urlfn = alias_expand_urltable($alias_name['name']);
1149
				$alias_addresses = explode("\n", file_get_contents($urlfn));
1150
				$counter = count($alias_addresses);
1151
			}
1152
			$alias_objects_with_details .= "<tr><td colspan=\"3\" $close_title class=\"vncell\">{$alias_name['url']}</td></tr>";
1153
			$x = 0;
1154
			foreach ($alias_addresses as $alias_ports_address) {
1155
				switch ($x) {
1156
					case 0:
1157
						$x++;
1158
						$alias_objects_with_details .= "<tr><td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td>";
1159
						break;
1160
					case 1:
1161
						$x++;
1162
						$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td>";
1163
						break;
1164
					default:
1165
						$x = 0;
1166
						$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td><tr>";
1167
						break;
1168
				}
1169
			}
1170
			for ($y = $x; $y <= $x; $y++) {
1171
				$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\">&nbsp;</td>";
1172
			}
1173
			if ($x > 0) {
1174
				$alias_objects_with_details .= "</tr>";
1175
			}
1176
			if ($counter > 10002) {
1177
				$alias_objects_with_details .= "<tr><td colspan=\"3\"> ". gettext("listing only first 10k items") . "</td><tr>";
1178
			}
1179
		} else {
1180
			$alias_addresses = explode (" ", $alias_name['address']);
1181
			$alias_details = explode ("||", $alias_name['detail']);
1182
			$counter = 0;
1183
			foreach ($alias_addresses as $alias_ports_address) {
1184
				$alias_objects_with_details .= "<tr><td $close_title width=\"5%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">{$alias_addresses[$counter]}</td>";
1185
				$alias_detail_default = strpos ($alias_details[$counter], "Entry added");
1186
				if ($alias_details[$counter] != "" && $alias_detail_default === False) {
1187
					$alias_objects_with_details .="<td $close_title width=\"95%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">{$alias_details[$counter]}</td>";
1188
				} else {
1189
					$alias_objects_with_details .="<td $close_title width=\"95%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">&nbsp;</td>";
1190
				}
1191
				$alias_objects_with_details .= "</tr>";
1192
				$counter++;
1193
			}
1194
		}
1195
		$alias_objects_with_details .= "</table>";
1196
	}
1197
	$alias_descr_substr = $alias_name['descr'];
1198
	if ($strlength >= $maxlength) {
1199
		$alias_descr_substr = substr($alias_descr_substr, 0, $maxlength) . "...";
1200
	}
1201
	$item_text = ($counter > 1 ? "items" : "item");
1202
	$alias_caption = "{$alias_descr_substr} - {$counter} {$item_text}<a href=\"/firewall_aliases_edit.php?id={$alias_id}\" title=\"".gettext('edit this alias')."\">&nbsp;&nbsp;edit </a>";
1203
	$strlength = strlen ($alias_caption);
1204
	print "<h1>{$alias_caption}</h1>" . $alias_objects_with_details;
1205
}
1206

    
1207
function rule_popup($src, $srcport, $dst, $dstport) {
1208
	global $config, $g;
1209
	$aliases_array = array();
1210
	if ($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias'])) {
1211
		$descriptions = array ();
1212
		foreach ($config['aliases']['alias'] as $alias_id=>$alias_name) {
1213
			$loading_image="<a><img src=\'/themes/{$g['theme']}/images/misc/loader.gif\' alt=\'loader\' /> " .gettext("loading...")."</a>";
1214
			switch ($alias_name['type']) {
1215
				case "port":
1216
					$width="250";
1217
					break;
1218
				case "urltable":
1219
					$width="500";
1220
					break;
1221
				default:
1222
					$width="350";
1223
					break;
1224
			}
1225
			$span_begin = "<span style=\"cursor: help;\" onmouseover=\"var response_html=domTT_activate(this, event, 'id','ttalias_{$alias_id}','content','{$loading_image}', 'trail', true, 'delay', 300, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','type','velcro','width',{$width});alias_popup('{$alias_id}','{$g['theme']}','".gettext('loading...')."');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><u>";
1226
			$span_end = "</u></span>";
1227
			if ($alias_name['name'] == $src) {
1228
				$descriptions['src'] = $span_begin;
1229
				$descriptions['src_end'] = $span_end;
1230
			}
1231
			if ($alias_name['name'] == $srcport) {
1232
				$descriptions['srcport'] = $span_begin;
1233
				$descriptions['srcport_end'] = $span_end;
1234
			}
1235
			if ($alias_name['name'] == $dst) {
1236
				$descriptions['dst'] = $span_begin;
1237
				$descriptions['dst_end'] = $span_end;
1238
			}
1239
			if ($alias_name['name'] == $dstport) {
1240
				$descriptions['dstport'] = $span_begin;
1241
				$descriptions['dstport_end'] = $span_end;
1242
			}
1243
		}
1244
		return $descriptions;
1245
	}
1246
}
1247

    
1248
$timezone = $config['system']['timezone'];
1249
if (!$timezone) {
1250
	$timezone = "Etc/UTC";
1251
}
1252

    
1253
date_default_timezone_set($timezone);
1254

    
1255
?>
(88-88/252)