Example #1
0
     preg_match("/\\-\$/", $_POST['hostname'], $matches);
     if ($matches) {
         $input_errors[] = gettext("The hostname cannot end with a hyphen according to RFC952");
     }
     if (!is_hostname($_POST['hostname'])) {
         $input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'.");
     } else {
         if (!is_unqualified_hostname($_POST['hostname'])) {
             $input_errors[] = gettext("A valid hostname is specified, but the domain name part should be omitted");
         }
     }
 }
 if ($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr'])) {
     $input_errors[] = gettext("A valid IP address must be specified.");
 }
 if ($_POST['mac'] && !is_macaddr($_POST['mac'])) {
     $input_errors[] = gettext("A valid MAC address must be specified.");
 }
 if ($static_arp_enabled && !$_POST['ipaddr']) {
     $input_errors[] = gettext("Static ARP is enabled.  You must specify an IP address.");
 }
 /* check for overlaps */
 foreach ($a_maps as $mapent) {
     if (isset($id) && $a_maps[$id] && $a_maps[$id] === $mapent) {
         continue;
     }
     /* The fully qualified hostname (hostname + '.' + domainname) must be unique.
      * The unqualified hostname does not have to be unique as long as the fully
      * qualified hostname is unique. */
     $existingFqn = "{$mapent['hostname']}.{$mapent['domain']}";
     $candidateFqn = "{$_POST['hostname']}.{$_POST['domain']}";
Example #2
0
 if ($_POST['pppoe_resetdate'] != "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
     $input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
 }
 if ($_POST['pptp_local0'] && !is_ipaddrv4($_POST['pptp_local0'])) {
     $input_errors[] = gettext("A valid PPTP local IP address must be specified.");
 }
 if ($_POST['pptp_subnet0'] && !is_numeric($_POST['pptp_subnet0'])) {
     $input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
 }
 if ($_POST['pptp_remote0'] && !is_ipaddrv4($_POST['pptp_remote0']) && !is_hostname($_POST['gateway'][$iface])) {
     $input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
 }
 if ($_POST['pptp_idletimeout'] != "" && !is_numericint($_POST['pptp_idletimeout'])) {
     $input_errors[] = gettext("The idle timeout value must be an integer.");
 }
 if ($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac'])) {
     $input_errors[] = gettext("A valid MAC address must be specified.");
 }
 if ($_POST['mtu']) {
     if (!is_numericint($_POST['mtu'])) {
         $input_errors[] = "MTU must be an integer.";
     }
     if (substr($wancfg['if'], 0, 3) == 'gif') {
         $min_mtu = 1280;
         $max_mtu = 8192;
     } else {
         $min_mtu = 576;
         $max_mtu = 9000;
     }
     if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu) {
         $input_errors[] = sprintf(gettext("The MTU must be between %d and %d bytes."), $min_mtu, $max_mtu);
Example #3
0
function validate_partial_mac_list($maclist)
{
    $macs = explode(',', $maclist);
    // Loop through and look for invalid MACs.
    foreach ($macs as $mac) {
        if (!is_macaddr($mac, true)) {
            return false;
        }
    }
    return true;
}
    $pconfig['mac'] = $a_passthrumacs[$id]['mac'];
    $pconfig['bw_up'] = $a_passthrumacs[$id]['bw_up'];
    $pconfig['bw_down'] = $a_passthrumacs[$id]['bw_down'];
    $pconfig['descr'] = $a_passthrumacs[$id]['descr'];
    $pconfig['username'] = $a_passthrumacs[$id]['username'];
}
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    /* input validation */
    $reqdfields = explode(" ", "action mac");
    $reqdfieldsn = array(gettext("Action"), gettext("MAC address"));
    do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
    $_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
    if ($_POST['mac']) {
        if (is_macaddr($_POST['mac'])) {
            $iflist = get_interface_list();
            foreach ($iflist as $if) {
                if ($_POST['mac'] == strtolower($if['mac'])) {
                    $input_errors[] = sprintf(gettext("The MAC address %s belongs to a local interface. It cannot be used here."), $_POST['mac']);
                    break;
                }
            }
        } else {
            $input_errors[] = sprintf("%s. [%s]", gettext("A valid MAC address must be specified"), $_POST['mac']);
        }
    }
    if ($_POST['bw_up'] && !is_numeric($_POST['bw_up'])) {
        $input_errors[] = gettext("Upload speed needs to be an integer");
    }
    if ($_POST['bw_down'] && !is_numeric($_POST['bw_down'])) {
Example #5
0
}
if ($_POST || $_GET['mac']) {
    unset($input_errors);
    if ($_GET['mac']) {
        /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
        $_GET['mac'] = strtolower(str_replace("-", ":", $_GET['mac']));
        $mac = $_GET['mac'];
        $if = $_GET['if'];
    } else {
        /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
        $_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac']));
        $mac = $_POST['mac'];
        $if = $_POST['interface'];
    }
    /* input validation */
    if (!$mac || !is_macaddr($mac)) {
        $input_errors[] = gettext("A valid MAC address must be specified.");
    }
    if (!$if) {
        $input_errors[] = gettext("A valid interface must be specified.");
    }
    if (!$input_errors) {
        /* determine broadcast address */
        $ipaddr = get_interface_ip($if);
        if (!is_ipaddr($ipaddr)) {
            $input_errors[] = gettext("A valid ip could not be found!");
        } else {
            $bcip = gen_subnet_max($ipaddr, get_interface_subnet($if));
            /* Execute wol command and check return code. */
            if (!mwexec("/usr/local/bin/wol -i {$bcip} " . escapeshellarg($mac))) {
                $savemsg .= sprintf(gettext("Sent magic packet to %s."), $mac);
Example #6
0
         $input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
     }
 }
 if (!empty($pconfig['localip']) && !is_ipaddrv4($pconfig['localip'])) {
     $input_errors[] = gettext("A valid PPTP local IP address must be specified.");
 }
 if (!empty($pconfig['pptp_subnet']) && !is_numeric($pconfig['pptp_subnet'])) {
     $input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
 }
 if (!empty($pconfig['pptp_remote']) && !is_ipaddrv4($pconfig['pptp_remote']) && !is_hostname($pconfig['gateway'][$iface])) {
     $input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
 }
 if (!empty($pconfig['pptp_idletimeout']) && !is_numericint($pconfig['pptp_idletimeout'])) {
     $input_errors[] = gettext("The idle timeout value must be an integer.");
 }
 if (!empty($pconfig['spoofmac']) && !is_macaddr($pconfig['spoofmac'])) {
     $input_errors[] = gettext("A valid MAC address must be specified.");
 }
 if (!empty($pconfig['mtu'])) {
     if ($pconfig['mtu'] < 576 || $pconfig['mtu'] > 9000) {
         $input_errors[] = gettext("The MTU must be greater than 576 bytes and less than 9000.");
     }
     if (stristr($a_interfaces[$if]['if'], "_vlan")) {
         $realhwif_array = get_parent_interface($a_interfaces[$if]['if']);
         // Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
         $parent_realhwif = $realhwif_array[0];
         $parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
         if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
             if ($pconfig['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) {
                 $input_errors[] = gettext("MTU of a vlan should not be bigger than parent interface.");
             }