.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* Include authentication routines */
/* THIS MUST BE ABOVE ALL OTHER CODE */
require_once("authgui.inc");
/* make sure nothing is cached */
if (!$omit_nocacheheaders) {
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/* parse the configuration and include all configuration functions */
require_once("functions.inc");
/* Pull in all the gui related display classes) */
foreach (scandir("/usr/local/www/classes/") as $file) {
if (stristr($file, ".inc") !== false) {
require_once("classes/{$file}");
}
}
/*
* if user has selected a custom template, use it.
* otherwise default to pfsense template
*/
if($config['theme'] <> "")
$g['theme'] = $config['theme'];
else
$g['theme'] = "pfsense";
/*
* If this device is an apple ipod/iphone
* switch the theme to one that works with it.
*/
$apple_ua = array("iPhone","iPod");
foreach($apple_ua as $useragent)
if(strstr($_SERVER['HTTP_USER_AGENT'], $useragent))
$g['theme'] = "pfsense";
/* used by progress bar */
$lastseen = "-1";
$navlevelsep = ": "; /* navigation level separator string */
$mandfldhtml = ""; /* display this before mandatory input fields */
$mandfldhtmlspc = ""; /* same as above, but with spacing */
if (is_subsystem_dirty('firmwarelock')) {
if (!$d_isfwfile) {
header("Location: system_firmware.php");
exit;
} else {
return;
}
}
$auth_server_types = array(
'ldap' => "LDAP",
'radius' => "Radius");
$ldap_urltypes = array(
'TCP - Standard' => 389,
'SSL - Encrypted' => 636);
$ldap_scopes = array(
'one' => "One Level",
'subtree' => "Entire Subtree");
$ldap_protvers = array(
2,
3);
$ldap_templates = array(
'open' => array(
'desc' => "OpenLDAP",
'attr_user' => "cn",
'attr_group' => "cn",
'attr_member' => "member"),
'msad' => array(
'desc' => "Microsoft AD",
'attr_user' => "samAccountNAme",
'attr_group' => "cn",
'attr_member' => "member"),
'edir' => array(
'desc' => "Novell eDirectory",
'attr_user' => "cn",
'attr_group' => "cn",
'attr_member' => "uniqueMember"));
$radius_srvcs = array(
'both' => "Authentication and Accounting",
'auth' => "Authentication",
'acct' => "Accounting");
$netbios_nodetypes = array(
'0' => "none",
'1' => "b-node",
'2' => "p-node",
'4' => "m-node",
'5' => "h-node");
/* some well knows ports */
$wkports = array(
5999 => "CVSup",
53 => "DNS",
21 => "FTP",
3000 => "HBCI",
80 => "HTTP",
443 => "HTTPS",
5190 => "ICQ",
113 => "IDENT/AUTH",
143 => "IMAP",
993 => "IMAP/S",
4500 => "IPsec NAT-T",
500 => "ISAKMP",
1701 => "L2TP",
389 => "LDAP",
1755 => "MMS/TCP",
7000 => "MMS/UDP",
445 => "MS DS",
3389 => "MS RDP",
1512 => "MS WINS",
1863 => "MSN",
119 => "NNTP",
123 => "NTP",
138 => "NetBIOS-DGM",
137 => "NetBIOS-NS",
139 => "NetBIOS-SSN",
1194 => "OpenVPN",
110 => "POP3",
995 => "POP3/S",
1723 => "PPTP",
1812 => "RADIUS",
1813 => "RADIUS accounting",
5004 => "RTP",
5060 => "SIP",
25 => "SMTP",
465 => "SMTP/S",
161 => "SNMP",
162 => "SNMP-Trap",
22 => "SSH",
3478 => "STUN",
23 => "Telnet",
69 => "TFTP",
5900 => "VNC");
$specialnets = array("wanip" => "WAN address", "lanip" => "LAN address", "lan" => "LAN net", "pptp" => "PPTP clients", "pppoe" => "PPPoE client", "l2tp" => "L2TP clients");
$spiflist = get_configured_interface_with_descr(true, true);
foreach ($spiflist as $ifgui => $ifdesc) {
$specialnets[$ifgui] = $ifdesc . " net";
}
$medias = array("auto" => "autoselect", "100full" => "100BASE-TX full-duplex",
"100half" => "100BASE-TX half-duplex", "10full" => "10BASE-T full-duplex",
"10half" => "10BASE-T half-duplex");
/* platforms that support firmware updating */
$fwupplatforms = array('pfSense', 'net45xx', 'net48xx', 'generic-pc', 'embedded', 'wrap', 'nanobsd');
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) {
/* check for bad control characters */
foreach ($postdata as $pn => $pd) {
if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
$input_errors[] = "The field '" . $pn . "' contains invalid characters.";
}
}
for ($i = 0; $i < count($reqdfields); $i++) {
if ($_POST[$reqdfields[$i]] == "") {
$input_errors[] = "The field '" . $reqdfieldsn[$i] . "' is required.";
}
}
}
function print_input_errors($input_errors) {
global $g;
print <<