function validateEntry($action, $id, $data, $record_type)
{
    $messages = null;
    $html = null;
    $append = array('CNAME', 'NS', 'MX', 'SRV', 'DNAME', 'CERT', 'RP', 'NAPTR');
    if ($action == 'create' && !isset($data['record_append']) && in_array($record_type, $append) && substr($data['record_value'], -1) != '.') {
        $data['record_append'] = 'yes';
    } elseif (!isset($data['record_append']) && in_array($record_type, $append)) {
        $data['record_append'] = 'no';
    }
    if (!empty($data['record_value'])) {
        $data['record_value'] = str_replace(array('"', "'"), '', $data['record_value']);
        foreach ($data as $key => $val) {
            $data[$key] = trim($val, '"\'');
            if ($key == 'record_name' && $record_type != 'PTR') {
                if (!$val) {
                    $val = '@';
                    $data[$key] = $val;
                }
                if (!verifyName($val, $id, true, $record_type)) {
                    $messages['errors'][$key] = __('Invalid');
                }
            }
            if (in_array($key, array('record_ttl', 'record_priority', 'record_weight', 'record_port'))) {
                if (!empty($val) && verifyNumber($val) === false) {
                    $messages['errors'][$key] = __('Invalid');
                }
            }
            if ($record_type == 'A') {
                if ($key == 'record_value') {
                    if (verifyIPAddress($val) === false) {
                        $messages['errors'][$key] = __('Invalid IP');
                    }
                }
                if ($key == 'PTR') {
                    global $domain_id;
                    $retval = checkPTRZone($data['record_value'], $domain_id);
                    list($val, $error_msg) = $retval;
                    if ($val == null) {
                        $messages['errors']['record_value'] = $error_msg;
                    } else {
                        $messages['info']['record_value'] = $error_msg;
                    }
                }
            }
            if ($record_type == 'PTR') {
                if ($key == 'record_name') {
                    if ($domain_map == 'reverse') {
                        if (verifyIPAddress(buildFullIPAddress($data['record_name'], $domain)) === false) {
                            $messages['errors'][$key] = __('Invalid record');
                        }
                    } else {
                        if (!verifyCNAME('yes', $data['record_name'], false, true)) {
                            $messages['errors'][$key] = __('Invalid record');
                        }
                    }
                }
            }
            if (in_array($record_type, array('CNAME', 'DNAME', 'MX', 'NS', 'SRV', 'NAPTR')) || $record_type == 'PTR' && $key == 'record_value') {
                if ($key == 'record_value') {
                    $val = $data['record_append'] == 'yes' || $val == '@' ? trim($val, '.') : trim($val, '.') . '.';
                    $data[$key] = $val;
                    if (!verifyCNAME($data['record_append'], $val) || $record_type == 'NS' && !validateHostname($val)) {
                        $messages['errors'][$key] = __('Invalid value');
                    }
                }
            }
            if (!count($messages['errors'])) {
                $html .= buildInputReturn($action, $id, $key, $val);
            } else {
                $html = null;
            }
        }
    } elseif ($record_type == 'SOA') {
        if ($_POST['create']['soa_template_chosen']) {
            global $fm_dns_records;
            // Save the soa_template_chosen in domains table and end
            include_once ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
            $fm_dns_records->assignSOA($_POST['create']['soa_template_chosen'], $_POST['domain_id']);
            header('Location: zone-records.php?map=' . $_POST['map'] . '&domain_id=' . $_POST['domain_id'] . '&record_type=SOA');
        }
        if (!isset($data['soa_append'])) {
            $data['soa_append'] = 'no';
        }
        foreach ($data as $key => $val) {
            if (in_array($key, array('domain_id', 'soa_status'))) {
                continue;
            }
            if ($key == 'soa_email_address') {
                $val = strpos($val, '@') ? str_replace('@', '.', rtrim($val, '.') . '.') : $val;
                $data[$key] = $val;
            }
            if (in_array($key, array('soa_master_server', 'soa_email_address'))) {
                $val = rtrim($val, '.');
                if (strpos($_POST['update'][$id]['soa_master_server'], $domain) && strpos($_POST['update'][$id]['soa_email_address'], $domain)) {
                    $new_val = rtrim(str_replace($domain, '', $val), '.');
                    if ($new_val != rtrim($val, '.')) {
                        $data['soa_append'] = 'yes';
                    }
                    $val = $new_val;
                }
                if ($data['soa_append'] == 'no') {
                    $val .= '.';
                }
            }
            if ($key != 'soa_append') {
                if (in_array($key, array('soa_master_server', 'soa_email_address'))) {
                    $val = $data['soa_append'] == 'yes' ? trim($val, '.') : trim($val, '.') . '.';
                    $data[$key] = $val;
                    if (!verifyCNAME($data['soa_append'], $val, false) || $key == 'soa_master_server' && !validateHostname($val)) {
                        $messages['errors'][$key] = __('Invalid');
                    }
                } else {
                    if (array_key_exists('soa_template', $data) && $data['soa_template'] == 'yes') {
                        if (!verifyNAME($val, $id, false)) {
                            $messages['errors'][$key] = __('Invalid');
                        }
                    }
                }
            }
            if (!count($messages['errors'])) {
                $html .= buildInputReturn($action, $id, $key, $val);
            } else {
                $html = null;
            }
        }
    } else {
        unset($data);
    }
    return array($data, $html, $messages);
}
Пример #2
0
 function validatePost($post)
 {
     global $fmdb, $__FM_CONFIG;
     if (empty($post['object_name'])) {
         return __('No object name defined.');
     }
     if (empty($post['object_address'])) {
         return __('No object address defined.');
     }
     if ($post['object_type'] == 'network') {
         if (empty($post['object_mask'])) {
             return __('No object netmask defined.');
         }
     }
     /** Check name field length */
     $field_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_name');
     if ($field_length !== false && strlen($post['object_name']) > $field_length) {
         return sprintf(dngettext($_SESSION['module'], 'Object name is too long (maximum %d character).', 'Object name is too long (maximum %d characters).', $field_length), $field_length);
     }
     /** Does the record already exist for this account? */
     basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', $post['object_name'], 'object_', 'object_name', "AND object_type='{$post['object_type']}' AND object_id!={$post['object_id']}");
     if ($fmdb->num_rows) {
         return __('This object name already exists.');
     }
     /** Check address and mask */
     if (!verifyIPAddress($post['object_address'])) {
         return __('Address is invalid.');
     }
     if ($post['object_type'] == 'network') {
         if (!verifyIPAddress($post['object_mask'])) {
             return __('Netmask is invalid.');
         }
     }
     return $post;
 }
Пример #3
0
 function validatePost($post)
 {
     global $fmdb, $__FM_CONFIG;
     $post['cfg_comment'] = trim($post['cfg_comment']);
     if (is_array($post['cfg_data'])) {
         $post['cfg_data'] = join(' ', $post['cfg_data']);
     }
     if (isset($post['cfg_name'])) {
         $def_option = "'{$post['cfg_name']}'";
     } elseif (isset($post['cfg_id'])) {
         $def_option = "(SELECT cfg_name FROM fm_{$__FM_CONFIG[$_SESSION['module']]['prefix']}config WHERE cfg_id = {$post['cfg_id']})";
     } else {
         return false;
     }
     if (!isset($post['view_id'])) {
         $post['view_id'] = 0;
     }
     if (!isset($post['domain_id'])) {
         $post['domain_id'] = 0;
     }
     $query = "SELECT def_type,def_dropdown FROM fm_{$__FM_CONFIG[$_SESSION['module']]['prefix']}functions WHERE def_option = {$def_option}";
     $fmdb->get_results($query);
     if ($fmdb->num_rows) {
         $result = $fmdb->last_result;
         if ($result[0]->def_dropdown == 'no') {
             $valid_types = trim(str_replace(array('(', ')'), '', $result[0]->def_type));
             switch ($valid_types) {
                 case 'integer':
                 case 'seconds':
                 case 'minutes':
                 case 'size_in_bytes':
                     if (!verifyNumber($post['cfg_data'])) {
                         return $post['cfg_data'] . ' is an invalid number.';
                     }
                     break;
                 case 'port':
                     if (!verifyNumber($post['cfg_data'], 0, 65535)) {
                         return $post['cfg_data'] . ' is an invalid port number.';
                     }
                     break;
                 case 'quoted_string':
                     $post['cfg_data'] = '"' . trim($post['cfg_data'], '"') . '"';
                     break;
                 case 'quoted_string | none':
                     $post['cfg_data'] = '"' . trim($post['cfg_data'], '"') . '"';
                     if ($post['cfg_data'] == '"none"') {
                         $post['cfg_data'] = 'none';
                     }
                     break;
                 case 'address_match_element':
                     /** Need to check for valid ACLs or IP addresses */
                     break;
                 case 'ipv4_address | ipv6_address':
                     if (!verifyIPAddress($post['cfg_data'])) {
                         return $post['cfg_data'] . ' is an invalid IP address.';
                     }
                     break;
                 case 'ipv4_address | *':
                 case 'ipv6_address | *':
                     if ($post['cfg_data'] != '*') {
                         if (!verifyIPAddress($post['cfg_data'])) {
                             $post['cfg_data'] . ' is an invalid IP address.';
                         }
                     }
                     break;
             }
         }
     }
     return $post;
 }
Пример #4
0
 function validateDomainName($domain_name, $domain_mapping)
 {
     if (substr($domain_name, -5) == '.arpa') {
         /** .arpa is only for reverse zones */
         if ($domain_mapping == 'forward') {
             return false;
         }
         $domain_pieces = explode('.', $domain_name);
         $domain_parts = count($domain_pieces);
         /** IPv4 checks */
         if ($domain_pieces[$domain_parts - 2] == 'in-addr') {
             /** The first digit of a reverse zone must be numeric */
             if (!is_numeric(substr($domain_name, 0, 1))) {
                 return false;
             }
             /** Reverse zones with arpa must have at least three octets */
             if ($domain_parts < 3) {
                 return false;
             }
             /** Second to last octet must be valid for arpa */
             if (!in_array($domain_pieces[$domain_parts - 2], array('e164', 'in-addr-servers', 'in-addr', 'ip6-servers', 'ip6', 'iris', 'uri', 'urn'))) {
                 return false;
             }
             for ($i = 0; $i < $domain_parts - 2; $i++) {
                 /** Check if using classless */
                 if ($i == 0) {
                     if (preg_match("/^(\\d{1,3})\\-(\\d{1,3})\$/", $domain_pieces[$i])) {
                         /** Validate octet range */
                         $octet_range = explode('-', $domain_pieces[$i]);
                         if ($octet_range[0] >= $octet_range[1]) {
                             return false;
                         }
                         foreach ($octet_range as $octet) {
                             if (filter_var($octet, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0, 'max_range' => 255))) === false) {
                                 return false;
                             }
                         }
                         continue;
                     }
                 }
                 /** Remaining octects must be numeric */
                 if (filter_var($domain_pieces[$i], FILTER_VALIDATE_INT, array('options' => array('min_range' => 0, 'max_range' => 255))) === false) {
                     return false;
                 }
             }
             /** IPv6 checks */
         } elseif ($domain_pieces[$domain_parts - 2] == 'ip6') {
             return true;
             return verifyIPAddress(buildFullIPAddress(0, $domain_name));
         }
     } elseif ($domain_mapping == 'reverse') {
         /** If reverse zone does not contain arpa then it must only contain numbers, periods, letters, and colons */
         $domain_pieces = explode('.', $domain_name);
         /** IPv4 checks */
         if (strpos($domain_name, ':') === false) {
             foreach ($domain_pieces as $number) {
                 if (filter_var($number, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0, 'max_range' => 255))) === false) {
                     return false;
                 }
             }
             /** IPv6 checks */
         } elseif (!preg_match('/^[a-z\\d\\:]+$/i', $domain_name)) {
             return false;
         }
     } else {
         /** Forward zones should only contain letters, numbers, periods, and hyphens */
         return preg_match("/^(_*[a-z\\d](-*[a-z\\d])*)(\\.([a-z\\d](-*[a-z\\d])*))*\$/i", $domain_name) && preg_match("/^.{1,253}\$/", $domain_name) && preg_match("/^[^\\.]{1,63}(\\.[^\\.]{1,63})*\$/", $domain_name);
         // length of each label
     }
     return true;
 }
Пример #5
0
    /**
     * Displays the user rows
     *
     * @since 1.0
     * @package facileManager
     */
    function displayRow($row)
    {
        global $__FM_CONFIG, $fm_name;
        $disabled_class = $row->user_status == 'disabled' ? ' class="disabled"' : null;
        if (currentUserCan('manage_users') && $_SESSION['user']['id'] != $row->user_id) {
            $edit_status = null;
            if ($row->user_template_only == 'yes') {
                $edit_status .= '<a class="copy_form_link" href="#">' . $__FM_CONFIG['icons']['copy'] . '</a>';
            }
            $edit_status .= '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            if ($row->user_template_only == 'no') {
                if ($row->user_id != $_SESSION['user']['id']) {
                    $edit_status .= '<a class="status_form_link" href="#" rel="';
                    $edit_status .= $row->user_status == 'active' ? 'disabled">' . $__FM_CONFIG['icons']['disable'] : 'active">' . $__FM_CONFIG['icons']['enable'];
                    $edit_status .= '</a>';
                    /** Cannot change password without mail_enable defined */
                    if (getOption('mail_enable') && $row->user_auth_type != 2 && $row->user_template_only == 'no') {
                        $edit_status .= '<a class="reset_password" id="' . $row->user_login . '" href="#">' . $__FM_CONFIG['icons']['pwd_reset'] . '</a>';
                    }
                } else {
                    $edit_status .= sprintf('<center>%s</center>', _('Enabled'));
                }
            }
            if ($row->user_id != 1) {
                $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            }
        } else {
            $user_actions = $row->user_id == $_SESSION['user']['id'] && getOption('auth_method') != 2 ? '<a style="width: 110px; margin: auto;" class="account_settings" id="' . $_SESSION['user']['id'] . '" href="#">' . $__FM_CONFIG['icons']['pwd_change'] . '</a>' : 'N/A';
            $edit_status = $user_actions;
        }
        $star = userCan($row->user_id, 'do_everything') ? $__FM_CONFIG['icons']['star'] : null;
        $template_user = $row->user_template_only == 'yes' ? $__FM_CONFIG['icons']['template_user'] : null;
        $last_login = $row->user_last_login == 0 ? _('Never') : date("F d, Y \\a\\t H:i T", $row->user_last_login);
        if ($row->user_ipaddr) {
            $user_ipaddr = verifyIPAddress($row->user_ipaddr) !== false ? @gethostbyaddr($row->user_ipaddr) : $row->user_ipaddr;
        } else {
            $user_ipaddr = _('None');
        }
        $super_admin_status = userCan($row->user_id, 'do_everything') ? 'yes' : 'no';
        if ($row->user_auth_type == 2) {
            $user_auth_type = 'LDAP';
        } elseif ($row->user_auth_type == 1) {
            $user_auth_type = $fm_name;
        } else {
            $user_auth_type = _('None');
        }
        echo <<<HTML
\t\t<tr id="{$row->user_id}"{$disabled_class}>
\t\t\t<td>{$star} {$template_user}</td>
\t\t\t<td>{$row->user_login}</td>
\t\t\t<td>{$last_login}</td>
\t\t\t<td>{$user_ipaddr}</td>
\t\t\t<td>{$user_auth_type}</td>
\t\t\t<td>{$super_admin_status}</td>
\t\t\t<td id="edit_delete_img">{$edit_status}</td>
\t\t</tr>

HTML;
    }
Пример #6
0
<?php

include_once $_SERVER["DOCUMENT_ROOT"] . "/222/inc/config.inc.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/222/inc/functions.inc.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/222/class/MulticastReceiver.class.php";
$receiver = $_GET["r"];
if (!verifyIPAddress($receiver)) {
    print "The ip address format is incorrect";
    exit;
}
$result = system("ping -c 4 " . $receiver);
Пример #7
0
 function validatePost($post)
 {
     global $fmdb, $__FM_CONFIG;
     if (!$post['control_id']) {
         unset($post['control_id']);
     }
     $post['control_comment'] = trim($post['control_comment']);
     if (is_array($post['control_keys'])) {
         $post['control_keys'] = join(',', $post['control_keys']);
     }
     if (!empty($post['control_ip']) && $post['control_ip'] != '*') {
         if (!verifyIPAddress($post['control_ip'])) {
             sprintf(__('%s is not a valid IP address.'), $post['control_ip']);
         }
     } else {
         $post['control_ip'] = '*';
     }
     if (empty($post['control_addresses'])) {
         return __('Allowed addresses not defined.');
     }
     if (!empty($post['control_port'])) {
         if (!verifyNumber($post['control_port'], 0, 65535)) {
             return sprintf(__('%d is not a valid port number.'), $post['control_port']);
         }
     } else {
         $post['control_port'] = 953;
     }
     return $post;
 }
Пример #8
0
<BODY ID="body" onLoad="setOption()">
<TABLE WIDTH="550px" ALIGN="CENTER"><TR><TD WIDTH="5%" VALIGN="MIDDLE" ALIGN="CENTER"><IMG SRC="images/arrow-left.png" onClick="goLeft()"></TD>
<TD WIDTH="90%" ALIGN="CENTER"><SPAN ID="info" STYLE="font-size:16px"><B>Average signal strength</B><BR><BR><IMG SRC="graphimage.php?r=all&g=0&t=0"></SPAN></TD>
<TD WIDTH="5%" VALIGN="MIDDLE" ALIGN="CENTER"><IMG SRC="images/arrow-right.png" onClick="goRight()"></TD>
</TR></TABLE></CENTER><BR>

<?php 
$cur = getAllReceivers();
$receivers = array();
$tuners = array();
$callLetters = array();
$i = 0;
do {
    $ip = $cur->getIP();
    $tuner = $cur->getTuner();
    if (verifyIPAddress($ip) && verifyTuner($tuner)) {
        $receivers[$i] = $ip;
        $tuners[$i] = $tuner;
        $callLetters[$i] = $cur->getChannelName();
    }
    $cur = $cur->getNextMulticastReceiver();
    $i++;
} while ($cur != null);
print "<CENTER>View info for a receiver (ip:tuner) ";
print "<SELECT NAME=\"receivers\" ID=\"receivers\" onChange=\"changeGraph('this','r')\"><OPTION SELECTED VALUE=\"Average\">Average</OPTION>";
for ($i = 0; $i < count($receivers); $i++) {
    print "<OPTION VALUE=\"" . $receivers[$i] . ":" . $tuners[$i] . " (" . $callLetters[$i] . ")\">" . $receivers[$i] . ":" . $tuners[$i] . " (" . $callLetters[$i] . ")</OPTION>";
}
print "</SELECT><BR>\n";
print "View info for this timeframe: ";
print "<SELECT NAME=\"timeFrame\" ID=\"timeFrame\" onChange=\"changeGraphTime()\"><OPTION SELECTED VALUE=\"12 hours\">12 hours</OPTION><OPTION VALUE=\"24 hours\">24 hours</OPTION><OPTION VALUE=\"7 days\">7 days</OPTION><OPTION VALUE=\"Month\">Month</OPTION><OPTION VALUE=\"Year\">Year</OPTION>\n";
Пример #9
0
/**
 * Cleans addresses for future parsing
 *
 * @since 1.0
 * @package facileManager
 * @subpackage fmDNS
 */
function verifyAndCleanAddresses($data, $subnets_allowed = 'subnets-allowed')
{
    /** Remove extra spaces */
    $data = preg_replace('/\\s\\s+/', ' ', $data);
    /** Swap delimiters for ; */
    $data = str_replace(array("\n", ';', ' ', ','), ',', $data);
    $data = str_replace(',,', ',', $data);
    $data = trim($data, ',');
    $addresses = explode(',', $data);
    foreach ($addresses as $ip_address) {
        $cidr = null;
        $ip_address = rtrim(trim($ip_address), '.');
        if (!strlen($ip_address)) {
            continue;
        }
        /** Handle negated addresses */
        if (strpos($ip_address, '!') === 0) {
            $ip_address = substr($ip_address, 1);
        }
        if (strpos($ip_address, '/') !== false && $subnets_allowed == 'subnets-allowed') {
            $cidr_array = explode('/', $ip_address);
            list($ip_address, $cidr) = $cidr_array;
        }
        /** IPv4 checks */
        if (strpos($ip_address, ':') === false) {
            /** Valid CIDR? */
            if ($cidr && !checkCIDR($cidr, 32)) {
                return sprintf(__('%s is not valid.'), "{$ip_address}/{$cidr}");
            }
            /** Create full IP */
            $ip_octets = explode('.', $ip_address);
            if (count($ip_octets) < 4) {
                $ip_octets = array_merge($ip_octets, array_fill(count($ip_octets), 4 - count($ip_octets), 0));
            }
            $ip_address = implode('.', $ip_octets);
        } else {
            /** IPv6 checks */
            if ($cidr && !checkCIDR($cidr, 128)) {
                return sprintf(__('%s is not valid.'), "{$ip_address}/{$cidr}");
            }
        }
        if (verifyIPAddress($ip_address) === false) {
            return sprintf(__('%s is not valid.'), $ip_address);
        }
    }
    return $data;
}
Пример #10
0
<?php

include_once "inc/config.inc.php";
include_once "inc/functions.inc.php";
$ip = $_GET["r"];
$tuner = $_GET["t"];
$type = $_GET["g"];
$file = $SOAP_DIR . $ip . "-" . $tuner . "-" . $type . ".png";
if (file_exists($file) && verifyIPAddress($ip) && verifyTuner($tuner) && $type >= 0 && $type <= 4) {
    header("Content-Type: image/png");
    readfile($file);
} else {
    if ($ip == "all" && $tuner <= 4 && $tuner >= 0) {
        header("Content-Type: image/png");
        readfile($SOAP_DIR . "total-" . $type . ".png");
    } else {
        exit;
    }
}