Project

General

Profile

Download (34.5 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / guiconfig.inc @ a1b66bec

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-store, no-cache, must-revalidate");
51
	header("Cache-Control: post-check=0, pre-check=0", false);
52
	header("Pragma: no-cache");
53
}
54

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

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

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

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

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

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

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

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

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

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

    
111
$firewall_rules_dscp_types = array("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 knows 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("auto" => "autoselect", "100full" => "100BASE-TX full-duplex",
243
	"100half" => "100BASE-TX half-duplex", "10full" => "10BASE-T full-duplex",
244
	"10half" => "10BASE-T half-duplex");
245

    
246
$wlan_modes = array("bss" => "Infrastructure (BSS)", "adhoc" => "Ad-hoc (IBSS)",
247
	"hostap" => "Access Point");
248

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

    
252
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_errors) {
253

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

    
261
	for ($i = 0; $i < count($reqdfields); $i++) {
262
		if ($_POST[$reqdfields[$i]] == "" && $_REQUEST[$reqdfields[$i]] == "") {
263
			$input_errors[] = sprintf(gettext("The field %s is required."), $reqdfieldsn[$i]);
264
		}
265
	}
266
}
267

    
268
function print_input_errors($input_errors) {
269
	global $g;
270

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

    
285
	print <<<EOF2
286
				</ul>
287
		</td></tr>
288
	</table>
289
	</div>
290
	&nbsp;<br />
291
EOF2;
292

    
293
}
294

    
295
function verify_gzip_file($fname) {
296
	$returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
297
	if ($returnvar != 0)
298
		return 0;
299
	else
300
		return 1;
301
}
302

    
303
function print_info_box_np($msg, $name="apply",$value="", $showapply=false) {
304
	global $g, $nifty_redbox, $nifty_blackbox, $nifty_background;
305

    
306
	if(empty($value)) {
307
		$value = gettext("Apply changes");
308
	}
309

    
310
	// Set the Nifty background color if one is not set already (defaults to white)
311
	if($nifty_background == "")
312
		$nifty_background = "#FFF";
313

    
314
	if(stristr($msg, gettext("apply")) != false || stristr($msg, gettext("save")) != false || stristr($msg, gettext("create")) != false || $showapply) {
315
		$savebutton = "<td class=\"infoboxsave\">";
316
		$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\" />";
317
		if($_POST['if'])
318
			$savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />";
319
		$savebutton.="</td>";
320
	}
321
	$nifty_redbox = "#990000";
322
	$nifty_blackbox = "#000000";
323

    
324
	$themename = $g['theme'];
325

    
326
	if(file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
327
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
328
		eval($toeval);
329
	}
330

    
331
	if(file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
332
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
333
		eval($toeval);
334
	}
335

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

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

    
372
}
373

    
374
function print_info_box_np_undo($msg, $name="apply",$value="Apply changes", $undo) {
375
	global $g;
376

    
377
	if(stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) {
378
		$savebutton = "<td class=\"infoboxsave nowrap\">";
379
		$savebutton .= "<input type=\"button\" value=\"". gettext("Undo") . "\" onclick=\"document.location='{$undo}'\" />";
380
		$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\" />";
381
		$savebutton .= "</td>";
382
		if($_POST['if'])
383
			$savebutton .= "<input type=\"hidden\" name=\"if\" value=\"" . htmlspecialchars($_POST['if']) . "\" />";
384
	}
385
	$nifty_redbox = "#990000";
386
	$nifty_blackbox = "#000000";
387

    
388
	$themename = $g['theme'];
389

    
390
	if(file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
391
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
392
		eval($toeval);
393
	}
394

    
395
	if(file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
396
		$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
397
		eval($toeval);
398
	}
399

    
400

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

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

    
438
}
439

    
440
function print_info_box($msg) {
441
	print_info_box_np($msg);
442
}
443

    
444
function get_std_save_message($ok) {
445
	global $d_sysrebootreqd_path;
446
	$filter_related = false;
447
	$filter_pages = array("nat", "filter");
448
	$to_return = gettext("The changes have been applied successfully.");
449
	foreach($filter_pages as $fp)
450
		if(stristr($_SERVER['SCRIPT_FILENAME'], $fp))
451
			$filter_related = true;
452
	if($filter_related)
453
		$to_return .= "<br />" . gettext("You can also <a href=\"status_filter_reload.php\">monitor</a> the filter reload progress.");
454
	return $to_return;
455
}
456

    
457
function pprint_address($adr) {
458
	global $specialnets;
459

    
460
	if (isset($adr['any'])) {
461
		$padr = "*";
462
	} else if ($adr['network']) {
463
		$padr = $specialnets[$adr['network']];
464
	} else {
465
		$padr = $adr['address'];
466
	}
467

    
468
	if (isset($adr['not']))
469
		$padr = "! " . $padr;
470

    
471
	return $padr;
472
}
473

    
474
function pprint_port($port) {
475
	global $wkports;
476

    
477
	$pport = "";
478

    
479
	if (!$port)
480
		return "*";
481
	else {
482
		$srcport = explode("-", $port);
483
		if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
484
			$pport = $srcport[0];
485
			if ($wkports[$srcport[0]]) {
486
				$pport .= " (" . $wkports[$srcport[0]] . ")";
487
			}
488
		} else
489
			$pport .= $srcport[0] . " - " . $srcport[1];
490
	}
491

    
492
	return $pport;
493
}
494

    
495
function firewall_check_for_advanced_options(&$item) {
496
	$item_set = "";
497
	if($item['os'])
498
		$item_set .= "os {$item['os']} ";
499
	if($item['dscp'])
500
		$item_set .= "dscp {$item['dscp']} ";
501
	if($item['max'])
502
		$item_set .= "max {$item['max']} ";
503
	if($item['max-src-nodes'])
504
		$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
505
	if($item['max-src-conn'])
506
		$item_set .= "max-src-conn {$item['max-src-conn']} ";
507
	if($item['max-src-states'])
508
		$item_set .= "max-src-states {$item['max-src-states']} ";
509
	if(isset($item['nopfsync']))
510
		$item_set .= "nopfsync ";
511
	if($item['statetype'] != "keep state" && $item['statetype'] != "")
512
		$item_set .= "statetype {$item['statetype']} ";
513
	if($item['statetimeout'])
514
		$item_set .= "statetimeout {$item['statetimeout']} ";
515
	if(isset($item['nosync']))
516
		$item_set .= "no XMLRPC Sync ";
517
	if($item['max-src-conn-rate'])
518
		$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
519
	if($item['max-src-conn-rates'])
520
		$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
521
	if($item['vlanprio'])
522
		$item_set .= "vlanprio {$item['vlanprio']} ";
523
	if($item['vlanprioset'])
524
		$item_set .= "vlanprioset {$item['vlanprioset']} ";
525
	if($item['gateway'])
526
		$item_set .= "gateway {$item['gateway']} ";
527
	if($item['dnpipe'])
528
		$item_set .= "limiter {$item['dnpipe']} ";
529
	if($item['pdnpipe'])
530
		$item_set .= "limiter {$item['pdnpipe']} ";
531
	if($item['ackqueue'])
532
		$item_set .= "ackqueue {$item['ackqueue']} ";
533
	if($item['defaultqueue'])
534
		$item_set .= "defaultqueue {$item['defaultqueue']} ";
535
	if($item['l7container'])
536
		$item_set .= "layer7 {$item['l7container']} ";
537
	if($item['tag'])
538
		$item_set .= "tag {$item['tag']} ";
539
	if($item['tagged'])
540
		$item_set .= "tagged {$item['tagged']} ";
541
	if(isset($item['allowopts']))
542
		$item_set .= "allowopts ";
543
	if(isset($item['disablereplyto']))
544
		$item_set .= "disable reply-to ";
545
	if($item['tcpflags_any'] || $item['tcpflags1'] || $item['tcpflags2'])
546
		$item_set .= "tcpflags set";
547

    
548
	return $item_set;
549
}
550

    
551
function gentitle($title) {
552
	global $navlevelsep;
553
	if(!is_array($title))
554
		return $title;
555
	else
556
		return join($navlevelsep, $title);
557
}
558

    
559
function genhtmltitle($title) {
560
	global $config;
561
	return gentitle($title);
562
}
563

    
564
/* update the changedesc and changecount(er) variables */
565
function update_changedesc($update) {
566
	global $changedesc;
567
	global $changecount;
568

    
569
	$changedesc .= " {$update}";
570
	$changecount++;
571
}
572

    
573
function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = true) {
574
	global $config, $g;
575
	if ($restart_syslogd)
576
		exec("/usr/bin/killall syslogd");
577
	if(isset($config['system']['disablesyslogclog'])) {
578
		unlink($logfile);
579
		touch($logfile);
580
	} else {
581
		$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "511488";
582
		if(isset($config['system']['usefifolog']))
583
			exec("/usr/sbin/fifolog_create -s {$log_size} " . escapeshellarg($logfile));
584
		else
585
			exec("/usr/local/sbin/clog -i -s {$log_size} " . escapeshellarg($logfile));
586
	}
587
	if ($restart_syslogd)
588
		system_syslogd_start();
589
}
590

    
591
function clear_all_log_files() {
592
	global $g;
593
	exec("/usr/bin/killall syslogd");
594

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

    
600
	system_syslogd_start();
601
	killbyname("dhcpd");
602
	services_dhcpd_configure();
603
	return;
604
}
605

    
606
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
607
	global $g, $config;
608
	$sor = isset($config['syslog']['reverse']) ? "-r" : "";
609
	$logarr = "";
610
	$grepline = "  ";
611
	if(is_array($grepfor))
612
		$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
613
	if(is_array($grepinvert))
614
		$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
615
	if (is_dir($logfile)) {
616
		$logarr = array("File $logfile is a directory.");
617
	} elseif (file_exists($logfile) && filesize($logfile) == 0) {
618
		$logarr = array("Log file started.");
619
	} else {
620
		if($config['system']['disablesyslogclog']) {
621
			exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
622
		} else {
623
			if(isset($config['system']['usefifolog']))
624
				exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
625
			else
626
				exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
627
		}
628
	}
629
	foreach ($logarr as $logent) {
630
			$logent = preg_split("/\s+/", $logent, 6);
631
			echo "<tr valign=\"top\">\n";
632
			if ($withorig) {
633
					if(isset($config['system']['usefifolog'])) {
634
						$entry_date_time = htmlspecialchars(date("F j, Y, g:i a","" . $logent[1] . ""));
635
						$entry_text = htmlspecialchars($logent[5]);
636
					} else {
637
						$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
638
						$entry_text = ($logent[3] ==  $config['system']['hostname']) ? "" : $logent[3] . " ";
639
						$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
640
					}
641
					echo "<td class=\"listlr nowrap\">{$entry_date_time}</td>\n";
642
					echo "<td class=\"listr\">{$entry_text}</td>\n";
643

    
644
			} else {
645
					echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
646
			}
647
			echo "</tr>\n";
648
	}
649
}
650

    
651
function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "", $grepreverse = false) {
652
	global $g, $config;
653
	$sor = (isset($config['syslog']['reverse']) || $grepreverse) ? "-r" : "";
654
	$logarr = "";
655
	$grepline = "  ";
656
	if(is_array($grepfor))
657
		$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
658
	if(is_array($grepinvert))
659
		$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
660
	if($config['system']['disablesyslogclog']) {
661
		exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
662
	} else {
663
		if(isset($config['system']['usefifolog'])) {
664
			exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
665
		} else {
666
			exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
667
		}
668
	}
669
	return($logarr);
670
}
671

    
672
/* Check if variable has changed, update and log if it has
673
 * returns true if var changed
674
 * varname = variable name in plain text
675
 * orig = original value
676
 * new = new value
677
 */
678
function update_if_changed($varname, & $orig, $new) {
679
	if (is_array($orig) && is_array($new)) {
680
		$a_diff = array_diff($orig, $new);
681
		foreach ($a_diff as $diff) {
682
			update_changedesc("removed {$varname}: \"{$diff}\"");
683
		}
684
		$a_diff = array_diff($new, $orig);
685
		foreach ($a_diff as $diff) {
686
			update_changedesc("added {$varname}: \"{$diff}\"");
687
		}
688
		$orig = $new;
689
		return true;
690

    
691
	} else {
692
		if ($orig != $new) {
693
			update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
694
			$orig = $new;
695
			return true;
696
		}
697
	}
698
	return false;
699
}
700

    
701
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
702
	if (isset($adr['any']))
703
		$padr = "any";
704
	else if ($adr['network'])
705
		$padr = $adr['network'];
706
	else if ($adr['address']) {
707
		list($padr, $pmask) = explode("/", $adr['address']);
708
		if (!$pmask) {
709
			if (is_ipaddrv6($padr))
710
				$pmask = 128;
711
			else
712
				$pmask = 32;
713
		}
714
	}
715

    
716
	if (isset($adr['not']))
717
		$pnot = 1;
718
	else
719
		$pnot = 0;
720

    
721
	if ($adr['port']) {
722
		list($pbeginport, $pendport) = explode("-", $adr['port']);
723
		if (!$pendport)
724
			$pendport = $pbeginport;
725
	} else if (!is_alias($pbeginport) && !is_alias($pendport)) {
726
		$pbeginport = "any";
727
		$pendport = "any";
728
	}
729
}
730

    
731
function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
732
	$adr = array();
733

    
734
	if ($padr == "any")
735
		$adr['any'] = true;
736
	else if (is_specialnet($padr))
737
		$adr['network'] = $padr;
738
	else {
739
		$adr['address'] = $padr;
740
		if (is_ipaddrv6($padr)) {
741
			if ($pmask != 128)
742
				$adr['address'] .= "/" . $pmask;
743
		} else {
744
			if ($pmask != 32)
745
				$adr['address'] .= "/" . $pmask;
746
		}
747
	}
748

    
749
	if ($pnot)
750
		$adr['not'] = true;
751
	else
752
		unset($adr['not']);
753

    
754
	if (($pbeginport != 0) && ($pbeginport != "any")) {
755
		if ($pbeginport != $pendport)
756
			$adr['port'] = $pbeginport . "-" . $pendport;
757
		else
758
			$adr['port'] = $pbeginport;
759
	}
760

    
761
	if(is_alias($pbeginport)) {
762
		$adr['port'] = $pbeginport;
763
	}
764
}
765

    
766
function is_specialnet($net) {
767
	global $specialsrcdst;
768

    
769
	if(!$net)
770
		return false;
771
	if (in_array($net, $specialsrcdst))
772
		return true;
773
	else
774
		return false;
775
}
776

    
777
//function to create widget tabs when called
778
function display_widget_tabs(& $tab_array) {
779
	echo "<div id=\"tabs\">";
780
	$tabscounter = 0;
781
	foreach ($tab_array as $ta) {
782
	$dashpos = strpos($ta[2],'-');
783
	$tabname = $ta[2] . "-tab";
784
	$tabclass = substr($ta[2],0,$dashpos);
785
	$tabclass = $tabclass . "-class";
786
		if ($ta[1] == true) {
787
			$tabActive = "table-cell";
788
			$tabNonActive = "none";
789
		}
790
		else {
791
			$tabActive = "none";
792
			$tabNonActive = "table-cell";
793
		}
794
		echo "<div id=\"{$ta[2]}-active\" class=\"{$tabclass}-tabactive\" style=\"display:{$tabActive}; background-color:#EEEEEE; color:black;\">";
795
		echo "<b>&nbsp;&nbsp;&nbsp;{$ta[0]}";
796
		echo "&nbsp;&nbsp;&nbsp;</b>";
797
		echo "</div>";
798

    
799
		echo "<div id=\"{$ta[2]}-deactive\" class=\"{$tabclass}-tabdeactive\" style=\"display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;\" onclick=\"return changeTabDIV('{$ta[2]}')\">";
800
		echo "<b>&nbsp;&nbsp;&nbsp;{$ta[0]}";
801
		echo "&nbsp;&nbsp;&nbsp;</b>";
802
		echo "</div>";
803
	}
804

    
805
	echo "<script type=\"text/javascript\">";
806
	echo "\n//<![CDATA[\n";
807
	echo "NiftyCheck();\n";
808
	echo "Rounded(\"div.{$tabclass}-tabactive\",\"top\",\"#CCCCCC\",\"#EEEEEE\",\"smooth\");\n";
809
	echo "Rounded(\"div.{$tabclass}-tabdeactive\",\"top\",\"#CCCCCC\",\"#777777\",\"smooth\");\n";
810
	echo "//]]>\n";
811
	echo "</script>";
812
	echo "</div>";
813
}
814

    
815

    
816
// Return inline javascript file or CSS to minimizie
817
// request count going back to server.
818
function outputJavaScriptFileInline($javascript) {
819
	if(file_exists($javascript)) {
820
		echo "\n<script type=\"text/javascript\">\n";
821
		include($javascript);
822
		echo "\n</script>\n";
823
	} else {
824
		echo "\n\n<!-- Could not location file:  {$javascript} -->\n\n";
825
	}
826
}
827

    
828

    
829

    
830
function outputCSSPrintFileInline($css) {
831
	if(file_exists($css)) {
832
		echo "\n<style media=\"print\" type=\"text/css\">\n";
833
		include($css);
834
		echo "\n</style>\n";
835
	} else {
836
		echo "\n\n<!-- Could not location file:  {$css} -->\n\n";
837
	}
838
}
839

    
840

    
841
function outputCSSFileInline($css) {
842
	if(file_exists($css)) {
843
		echo "\n<style type=\"text/css\">\n";
844
		include($css);
845
		echo "\n</style>\n";
846
	} else {
847
		echo "\n\n<!-- Could not location file:  {$css} -->\n\n";
848
	}
849
}
850

    
851
$rfc2616 = array(
852
	100 => "100 Continue",
853
	101 => "101 Switching Protocols",
854
	200 => "200 OK",
855
	201 => "201 Created",
856
	202 => "202 Accepted",
857
	203 => "203 Non-Authoritative Information",
858
	204 => "204 No Content",
859
	205 => "205 Reset Content",
860
	206 => "206 Partial Content",
861
	300 => "300 Multiple Choices",
862
	301 => "301 Moved Permanently",
863
	302 => "302 Found",
864
	303 => "303 See Other",
865
	304 => "304 Not Modified",
866
	305 => "305 Use Proxy",
867
	306 => "306 (Unused)",
868
	307 => "307 Temporary Redirect",
869
	400 => "400 Bad Request",
870
	401 => "401 Unauthorized",
871
	402 => "402 Payment Required",
872
	403 => "403 Forbidden",
873
	404 => "404 Not Found",
874
	405 => "405 Method Not Allowed",
875
	406 => "406 Not Acceptable",
876
	407 => "407 Proxy Authentication Required",
877
	408 => "408 Request Timeout",
878
	409 => "409 Conflict",
879
	410 => "410 Gone",
880
	411 => "411 Length Required",
881
	412 => "412 Precondition Failed",
882
	413 => "413 Request Entity Too Large",
883
	414 => "414 Request-URI Too Long",
884
	415 => "415 Unsupported Media Type",
885
	416 => "416 Requested Range Not Satisfiable",
886
	417 => "417 Expectation Failed",
887
	500 => "500 Internal Server Error",
888
	501 => "501 Not Implemented",
889
	502 => "502 Bad Gateway",
890
	503 => "503 Service Unavailable",
891
	504 => "504 Gateway Timeout",
892
	505 => "505 HTTP Version Not Supported"
893
);
894

    
895
function is_rfc2616_code($code) {
896
	global $rfc2616;
897
	if (isset($rfc2616[$code]))
898
		return true;
899
	else
900
		return false;
901
}
902

    
903
function print_rfc2616_select($tag, $current){
904
	global $rfc2616;
905

    
906
	/* Default to 200 OK if not set */
907
	if ($current == "")
908
		$current = 200;
909

    
910
	echo "<select id=\"{$tag}\" name=\"{$tag}\">\n";
911
	foreach($rfc2616 as $code => $message) {
912
		if ($code == $current) {
913
			$sel = " selected=\"selected\"";
914
		} else {
915
			$sel = "";
916
		}
917
		echo "<option value=\"{$code}\"{$sel}>{$message}</option>\n";
918
	}
919
	echo "</select>\n";
920
}
921

    
922
// Useful debugging function, much cleaner than print_r
923
function echo_array($array,$return_me=false){
924
	if(is_array($array) == false){
925
		$return = "The provided variable is not an array.";
926
	}else{
927
		foreach($array as $name=>$value){
928
			if(is_array($value)){
929
				$return .= "";
930
				$return .= "['<b>$name</b>'] {<div style=\"margin-left:10px;\">\n";
931
				$return .= echo_array($value,true);
932
				$return .= "</div>}";
933
				$return .= "\n\n";
934
			}else{
935
				if(is_string($value)){
936
					$value = "\"$value\"";
937
				}
938
				$return .= "['<b>$name</b>'] = $value\n\n";
939
			}
940
		}
941
	}
942
	if($return_me == true){
943
		return $return;
944
	}else{
945
		echo "<pre>".$return."</pre>";
946
	}
947
}
948

    
949
/****f* pfsense-utils/display_top_tabs
950
 * NAME
951
 *   display_top_tabs - display tabs with rounded edges
952
 * INPUTS
953
 *   $text      - array of tabs
954
 * RESULT
955
 *   null
956
 ******/
957
function display_top_tabs(& $tab_array, $no_drop_down = false) {
958
	global $config;
959
	global $g;
960
	global $tab_array_indent;
961
	global $tab_array_space;
962
	global $tab_array_char_limit;
963

    
964
	/*  does the user have access to this tab?
965
	 *  master user has access to everything.
966
	 *  if the user does not have access, simply
967
	 *  unset the tab item.
968
	 */
969

    
970
	/* empty string code */
971
	if ($tab_array_indent == '') {
972
		$tab_array_indent = 0;
973
	}
974

    
975
	if ($tab_array_space == '') {
976
		$tab_array_space = 1;
977
	}
978

    
979
	if ($tab_array_char_limit == '') {
980
		$tab_array_char_limit = 92;
981
	}
982

    
983
	foreach ($tab_array as $tab_id => $ta){
984
		if(!isAllowedPage($ta[2]))
985
			unset ($tab_array[$tab_id]);
986
	}
987

    
988
	$tab_active_bg   = "#EEEEEE";
989
	$tab_inactive_bg = "#777777";
990
	$nifty_tabs_corners = "#FFF";
991
	$font_color = "white";
992

    
993
	/* if tabcontrols.php exist for a theme, allow it to be overriden */
994
	$themename = $config['theme'];
995
	$filename = "/usr/local/www/themes/{$themename}/tabcontrols.php";
996
	if(file_exists($filename)) {
997
		$eval_code = file_get_contents($filename);
998
		eval($eval_code);
999
	}
1000

    
1001
	$tabcharcount = 0;
1002
	foreach ($tab_array as $ta)
1003
		$tabcharcount = $tabcharcount + strlen($ta[0]);
1004

    
1005
	if($no_drop_down == true) {
1006
		$tabcharcount = 0;
1007
		unset($tab_array_char_limit);
1008
	}
1009

    
1010
	// If the character count of the tab names is > 670
1011
	// then show a select item dropdown menubox.
1012
	if($tabcharcount > $tab_array_char_limit) {
1013
		echo gettext("Currently viewing: ");
1014
		echo "<select name=\"TabSelect\" onchange=\"tabs_will_go(this)\">\n";
1015
		foreach ($tab_array as $ta) {
1016
			if($ta[1]=="true")
1017
				$selected = " selected=\"selected\"";
1018
			else
1019
				$selected = "";
1020
			// Onclick in option will not work in some browser
1021
			// echo "<option onclick=\"document.location='{$ta[2]}';\"{$selected}>{$ta['0']}</option>\n";
1022
			echo "<option value=\"{$ta[2]}\"{$selected}>{$ta['0']}</option>\n";
1023
		}
1024
		echo "</select>\n<p>&nbsp;</p>";
1025
		echo "<script type=\"text/javascript\">";
1026
		echo "\n//<![CDATA[\n";
1027
		echo " function tabs_will_go(obj){ document.location = obj.value; }\n";
1028
		echo "//]]>\n";
1029
		echo "</script>";
1030
	}  else {
1031
		echo "<div class=\"newtabmenu\" style=\"margin:{$tab_array_space}px {$tab_array_indent}px; width:775px;\">\n";
1032
		echo "<!-- Tabbed bar code-->\n";
1033
		echo "<ul class=\"newtabmenu\">\n";
1034
		$tabscounter = 0;
1035
		foreach ($tab_array as $ta) {
1036
			if ($ta[1] == true) {
1037
				echo "  <li class=\"newtabmenu_active\"><a href=\"{$ta[2]}\"><span>{$ta[0]}</span></a></li>\n";
1038
			} else {
1039
				echo "  <li><a href=\"{$ta[2]}\"><span>{$ta[0]}</span></a></li>\n";
1040
			}
1041
			$tabscounter++;
1042
		}
1043
		echo "</ul>\n</div>\n";
1044
	}
1045
}
1046

    
1047
function add_package_tabs($tabgroup, & $tab_array) {
1048
	global $config, $g;
1049

    
1050
	if(!is_array($config['installedpackages']))
1051
		return;
1052
	if(!is_array($config['installedpackages']['tab']))
1053
		return;
1054

    
1055
	foreach($config['installedpackages']['tab'] as $tab) {
1056
		if ($tab['group'] !== $group)
1057
			continue;
1058
		$tab_entry = array();
1059
		if($tab['name']) {
1060
			$tab_entry[] = $tab['name'];
1061
			$tab_entry[] = false;
1062
			$tab_entry[] = $tab['url'];
1063
			$tab_array[] = $tab_entry;
1064
		}
1065
	}
1066
}
1067

    
1068
function alias_info_popup($alias_id){
1069
	global $config;
1070
	$maxlength = 60;
1071
	$close_title="title='".gettext('move mouse out this alias to hide')."'";
1072
	if (is_array($config['aliases']['alias'][$alias_id])){
1073
		$alias_name=$config['aliases']['alias'][$alias_id];
1074
		$alias_objects_with_details = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" summary=\"alias info popup\">";
1075
		if ($alias_name['url']) {
1076
			// TODO: Change it when pf supports tables with ports
1077
			if ($alias_name['type'] == "urltable") {
1078
				exec("/sbin/pfctl -t {$alias_name['name']} -T show | wc -l", $total_entries);
1079
				$counter=preg_replace("/\D/","",$total_entries[0]);
1080
				exec("/sbin/pfctl -t {$alias_name['name']} -T show | head -10002", $alias_addresses);
1081
			} else {
1082
				$urlfn = alias_expand_urltable($alias_name['name']);
1083
				$alias_addresses = explode("\n", file_get_contents($urlfn));
1084
				$counter = count($alias_addresses);
1085
			}
1086
			$alias_objects_with_details .= "<tr><td colspan=\"3\" $close_title class=\"vncell\">{$alias_name['url']}</td></tr>";
1087
			$x=0;
1088
			foreach ($alias_addresses as $alias_ports_address ) {
1089
				switch ($x) {
1090
				case 0:
1091
					$x++;
1092
					$alias_objects_with_details .= "<tr><td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td>";
1093
					break;
1094
				case 1:
1095
					$x++;
1096
					$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td>";
1097
					break;
1098
				default:
1099
					$x=0;
1100
					$alias_objects_with_details .= "<td  $close_title class=\"vncell\" width=\"33%\" style=\"background: #FFFFFF;color: #000000;\">{$alias_ports_address}</td><tr>";
1101
					break;
1102
				}
1103
			}
1104
			for ($y = $x; $y <= $x; $y++) {
1105
				$alias_objects_with_details .= "<td $close_title class=\"vncell\" width=\"33%\">&nbsp;</td>";
1106
			}
1107
			if ($x > 0) {
1108
				$alias_objects_with_details .= "</tr>";
1109
			}
1110
			if ($counter > 10002) {
1111
				$alias_objects_with_details .= "<tr><td colspan=\"3\"> ". gettext("listing only first 10k items") . "</td><tr>";
1112
			}
1113
		}
1114
		else{
1115
			$alias_addresses = explode (" ", $alias_name['address']);
1116
			$alias_details = explode ("||", $alias_name['detail']);
1117
			$counter = 0;
1118
			foreach ($alias_addresses as $alias_ports_address) {
1119
				$alias_objects_with_details .= "<tr><td $close_title width=\"5%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">{$alias_addresses[$counter]}</td>";
1120
				$alias_detail_default = strpos ($alias_details[$counter],"Entry added");
1121
				if ($alias_details[$counter] != "" && $alias_detail_default === False)
1122
					$alias_objects_with_details .="<td $close_title width=\"95%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">{$alias_details[$counter]}</td>";
1123
				else
1124
					$alias_objects_with_details .="<td $close_title width=\"95%\" class=\"vncell\" style=\"background: #FFFFFF;color: #000000;\">&nbsp;</td>";
1125
				$alias_objects_with_details .= "</tr>";
1126
				$counter++;
1127
			}
1128
		}
1129
		$alias_objects_with_details .= "</table>";
1130
	}
1131
	$alias_descr_substr = $alias_name['descr'];
1132
	if ($strlength >= $maxlength)
1133
		$alias_descr_substr = substr($alias_descr_substr, 0, $maxlength) . "...";
1134
	$item_text = ($counter > 1 ? "items" : "item");
1135
	$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>";
1136
	$strlength = strlen ($alias_caption);
1137
	print "<h1>{$alias_caption}</h1>" . $alias_objects_with_details;
1138
}
1139

    
1140
function rule_popup($src,$srcport,$dst,$dstport){
1141
	global $config,$g;
1142
	$aliases_array = array();
1143
	if ($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias'])) {
1144
		$descriptions = array ();
1145
		foreach ($config['aliases']['alias'] as $alias_id=>$alias_name){
1146
			$loading_image="<a><img src=\'/themes/{$g['theme']}/images/misc/loader.gif\' alt=\'loader\' /> " .gettext("loading...")."</a>";
1147
			switch ($alias_name['type']){
1148
			case "port":
1149
				$width="250";
1150
				break;
1151
			case "urltable":
1152
				$width="500";
1153
				break;
1154
			default:
1155
				$width="350";
1156
				break;
1157
			}
1158
			$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>";
1159
			$span_end = "</u></span>";
1160
			if ($alias_name['name'] == $src) {
1161
				$descriptions['src'] = $span_begin;
1162
				$descriptions['src_end'] = $span_end;
1163
			}
1164
			if ($alias_name['name'] == $srcport) {
1165
				$descriptions['srcport'] = $span_begin;
1166
				$descriptions['srcport_end'] = $span_end;
1167
			}
1168
			if ($alias_name['name'] == $dst ) {
1169
				$descriptions['dst'] = $span_begin;
1170
				$descriptions['dst_end'] = $span_end;
1171
			}
1172
			if ($alias_name['name'] == $dstport) {
1173
				$descriptions['dstport'] = $span_begin;
1174
				$descriptions['dstport_end'] = $span_end;
1175
			}
1176
		}
1177
		return $descriptions;
1178
	}
1179
}
1180

    
1181
$timezone = $config['system']['timezone'];
1182
if (!$timezone)
1183
	$timezone = "Etc/UTC";
1184

    
1185
date_default_timezone_set($timezone);
1186

    
1187
?>
(88-88/256)