$fields_files[1]['name'] = "content";
$fields_files[1]['columnheader'] = "content";
$fields_files[1]['colwidth'] = "70%";
$fields_files[1]['type'] = "textarea";
$fields_files[1]['size'] = "70";
$fileslist = new HaproxyHtmlList("table_files", $fields_files);
$fileslist->keyfield = "name";
if ($_POST) {
    $pconfig = $_POST;
    if ($_POST['apply']) {
        $result = haproxy_check_and_run($savemsg, true);
        if ($result) {
            unlink_if_exists($d_haproxyconfdirty_path);
        }
    } else {
        $a_files = $fileslist->haproxy_htmllist_get_values($fields_files);
        $filedupcheck = array();
        foreach ($a_files as $key => $file) {
            $name = $file['name'];
            if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\.\\-_]*\$/", $file['name'])) {
                $input_errors[] = "The field 'Name' (" . htmlspecialchars($file['name']) . ") contains invalid characters. Use only: a-zA-Z0-9.-_ and start with a letter";
            }
            if (isset($filedupcheck[$name])) {
                $input_errors[] = "Duplicate names are not allowed: " . htmlspecialchars($name);
            }
            $filedupcheck[$name] = true;
        }
        // replace references in backends to renamed 'files'
        foreach ($a_pools as &$backend) {
            if (is_arrayset($backend, 'errorfiles', 'item')) {
                foreach ($backend['errorfiles']['item'] as &$errorfile) {
 }
 // the colon ":" can also be used in the password
 if (preg_match("/[^a-zA-Z0-9!-~ ]/", $_POST['stats_password'])) {
     $input_errors[] = "The field 'Stats Password' contains invalid characters.";
 }
 if (preg_match("/[^a-zA-Z0-9\\-_]/", $_POST['stats_node'])) {
     $input_errors[] = "The field 'Stats Node' contains invalid characters. Should be a string with digits(0-9), letters(A-Z, a-z), hyphen(-) or underscode(_)";
 }
 /* Ensure that our pool names are unique */
 for ($i = 0; isset($config['installedpackages']['haproxy']['ha_pools']['item'][$i]); $i++) {
     if ($_POST['name'] == $config['installedpackages']['haproxy']['ha_pools']['item'][$i]['name'] && $i != $id) {
         $input_errors[] = "This pool name has already been used.  Pool names must be unique.";
     }
 }
 $pconfig['a_acl'] = $htmllist_acls->haproxy_htmllist_get_values();
 $pconfig['a_actionitems'] = $htmllist_actions->haproxy_htmllist_get_values();
 $a_servers = $serverslist->haproxy_htmllist_get_values();
 foreach ($a_servers as $server) {
     $server_name = $server['name'];
     $server_address = $server['address'];
     $server_port = $server['port'];
     $server_weight = $server['weight'];
     if (preg_match("/[^a-zA-Z0-9\\.\\-_]/", $server_name)) {
         $input_errors[] = "The field 'Name' contains invalid characters.";
     }
     if (!isset($server['forwardto']) || $server['forwardto'] == "") {
         if (!is_ipaddr($server_address) && !is_hostname($server_address) && !haproxy_is_frontendname($server_address)) {
             $input_errors[] = "The field 'Address' for server {$server_name} is not a valid ip address or hostname." . $server_address;
         }
     } else {
         if ($server_address && $server_address != "" || $server_port && !is_numeric($server_port)) {
$fields_files[2]['name'] = "content";
$fields_files[2]['columnheader'] = "content";
$fields_files[2]['colwidth'] = "70%";
$fields_files[2]['type'] = "textarea";
$fields_files[2]['size'] = "70";
$fileslist = new HaproxyHtmlList("table_files", $fields_files);
$fileslist->keyfield = "name";
if ($_POST) {
    $pconfig = $_POST;
    if ($_POST['apply']) {
        $result = haproxy_check_and_run($savemsg, true);
        if ($result) {
            unlink_if_exists($d_haproxyconfdirty_path);
        }
    } else {
        $a_files = $fileslist->haproxy_htmllist_get_values();
        $filedupcheck = array();
        foreach ($a_files as $key => $file) {
            $name = $file['name'];
            if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\.\\-_]*\$/", $file['name'])) {
                $input_errors[] = "The field 'Name' (" . htmlspecialchars($file['name']) . ") contains invalid characters. Use only: a-zA-Z0-9.-_ and start with a letter";
            }
            if (isset($filedupcheck[$name])) {
                $input_errors[] = "Duplicate names are not allowed: " . htmlspecialchars($name);
            }
            $filedupcheck[$name] = true;
        }
        // replace references in backends to renamed 'files'
        foreach ($a_pools as &$backend) {
            if (is_arrayset($backend, 'errorfiles', 'item')) {
                foreach ($backend['errorfiles']['item'] as &$errorfile) {
Пример #4
0
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    if ($_POST['calculate_certificate_chain']) {
        $changed = haproxy_recalculate_certifcate_chain();
        if ($changed > 0) {
            touch($d_haproxyconfdirty_path);
        }
    } else {
        if ($_POST['apply']) {
            $result = haproxy_check_and_run($savemsg, true);
            if ($result) {
                unlink_if_exists($d_haproxyconfdirty_path);
            }
        } else {
            $a_mailers = $mailerslist->haproxy_htmllist_get_values();
            $pool['ha_servers']['item'] = $a_servers;
            if ($_POST['carpdev'] == "disabled") {
                unset($_POST['carpdev']);
            }
            if ($_POST['maxconn'] && !is_numeric($_POST['maxconn'])) {
                $input_errors[] = "The maximum number of connections should be numeric.";
            }
            if ($_POST['localstatsport'] && !is_numeric($_POST['localstatsport'])) {
                $input_errors[] = "The local stats port should be numeric or empty.";
            }
            if ($_POST['localstats_refreshtime'] && !is_numeric($_POST['localstats_refreshtime'])) {
                $input_errors[] = "The local stats refresh time should be numeric or empty.";
            }
            if ($_POST['localstats_sticktable_refreshtime'] && !is_numeric($_POST['localstats_sticktable_refreshtime'])) {
                $input_errors[] = "The local stats sticktable refresh time should be numeric or empty.";
Пример #5
0
 unset($input_errors);
 $pconfig = $_POST;
 if ($_POST['calculate_certificate_chain']) {
     $changed = haproxy_recalculate_certifcate_chain();
     if ($changed > 0) {
         touch($d_haproxyconfdirty_path);
     }
 } else {
     if ($_POST['apply']) {
         $result = haproxy_check_and_run($savemsg, true);
         if ($result) {
             unlink_if_exists($d_haproxyconfdirty_path);
         }
     } else {
         $a_mailers = $mailerslist->haproxy_htmllist_get_values();
         $a_resolvers = $resolverslist->haproxy_htmllist_get_values();
         if ($_POST['carpdev'] == "disabled") {
             unset($_POST['carpdev']);
         }
         if ($_POST['maxconn'] && !is_numeric($_POST['maxconn'])) {
             $input_errors[] = "The maximum number of connections should be numeric.";
         }
         if ($_POST['localstatsport'] && !is_numeric($_POST['localstatsport'])) {
             $input_errors[] = "The local stats port should be numeric or empty.";
         }
         if ($_POST['localstats_refreshtime'] && !is_numeric($_POST['localstats_refreshtime'])) {
             $input_errors[] = "The local stats refresh time should be numeric or empty.";
         }
         if ($_POST['localstats_sticktable_refreshtime'] && !is_numeric($_POST['localstats_sticktable_refreshtime'])) {
             $input_errors[] = "The local stats sticktable refresh time should be numeric or empty.";
         }
             $input_errors[] = "The field 'Port' value '" . htmlspecialchars($port) . "' is not a number or alias thereof.";
         }
     }
     if ($_POST['client_timeout'] !== "" && !is_numeric($_POST['client_timeout'])) {
         $input_errors[] = "The field 'Client timeout' value is not a number.";
     }
 }
 /* Ensure that our pool names are unique */
 for ($i = 0; isset($config['installedpackages']['haproxy']['ha_backends']['item'][$i]); $i++) {
     if ($_POST['name'] == $config['installedpackages']['haproxy']['ha_backends']['item'][$i]['name'] && $i != $id) {
         $input_errors[] = "This frontend name has already been used. Frontend names must be unique. {$i} != {$id}";
     }
 }
 $a_actionitems = $htmllist_actions->haproxy_htmllist_get_values();
 $pconfig['a_actionitems'] = $a_actionitems;
 $a_errorfiles = $errorfileslist->haproxy_htmllist_get_values();
 $pconfig['a_errorfiles'] = $a_errorfiles;
 $a_certificates = $htmllist_sslCertificates->haproxy_htmllist_get_values();
 $pconfig['a_certificates'] = $a_certificates;
 $a_clientcert_ca = $htmllist_caCertificates->haproxy_htmllist_get_values();
 $pconfig['clientcert_ca'] = $a_clientcert_ca;
 $a_clientcert_crl = $htmllist_crlCertificates->haproxy_htmllist_get_values();
 $pconfig['clientcert_crl'] = $a_clientcert_crl;
 $a_acl = $htmllist_acls->haproxy_htmllist_get_values();
 $pconfig['a_acl'] = $a_acl;
 $a_extaddr = $htmllist_extaddr->haproxy_htmllist_get_values();
 $pconfig['a_extaddr'] = $a_extaddr;
 foreach ($a_acl as $acl) {
     $acl_name = $acl['name'];
     $acl_value = $acl['value'];
     $acltype = haproxy_find_acl($acl['expression']);