if ($validation_result === GS_VALIDATION_EMPTY) { $form_ntp4 = ''; } elseif ($validation_result === GS_VALIDATION_WARN) { $warn_cnt++; _complain_html($errmsg . ' (4)', true); } else { $err_cnt++; _complain_html($errmsg . ' (4)'); } } if ($err_cnt < 1 && ($warn_cnt < 1 || @$_REQUEST['dont_warn'])) { # some useful net calculations # $netmask_length = subStr($form_netmask, 1); # first char is "/" $dotted_netmask = ipv4_mask_length_to_dotted($netmask_length); if (!$dotted_netmask) { $dotted_netmask = '255.255.0.0'; } $dotted_network = ipv4_net_by_addr_and_mask($form_ipaddr, $dotted_netmask); if ($dotted_network === null || $dotted_network === false || $dotted_network === '') { $dotted_network = '0.0.0.0'; } $dotted_bcastaddr = ipv4_bcast_by_addr_and_mask($form_ipaddr, $dotted_netmask); if ($dotted_network === null || $dotted_network === false || $dotted_network === '') { $dotted_network = '255.255.255.255'; } # save the changes to the keyvals # //if ($form_ipaddr !== $current_ipaddr ) gs_keyval_set('vlan_0_ipaddr', $form_ipaddr);
function gs_prov_new_phone_find_boi_host_id($db, $phone_ip) { if (!gs_get_conf('GS_BOI_ENABLED')) { return null; # Gemeinschaft } # BOI $boi_branch_netmask = gs_get_conf('GS_BOI_BRANCH_NETMASK'); $boi_branch_netmask = subStr($boi_branch_netmask, 0, 1) === '/' ? (int) subStr($boi_branch_netmask, 1) : (int) $boi_branch_netmask; $dotted_netmask = ipv4_mask_length_to_dotted($boi_branch_netmask); if (!$dotted_netmask) { gs_log(GS_LOG_WARNING, "Invalid BOI_BRANCH_NETMASK {$boi_branch_netmask}"); return false; } $network = ipv4_net_by_addr_and_mask($phone_ip, $dotted_netmask); if (!$network) { gs_log(GS_LOG_WARNING, "Invalid branch net {$netmask}"); return false; } $boi_host_ip = ip_addr_network_add_sub($network, gs_get_conf('GS_BOI_BRANCH_PBX')); if (!$boi_host_ip) { gs_log(GS_LOG_WARNING, "Invalid branch pbx {$boi_host_ip}"); return false; } $host_id = (int) $db->executeGetOne('SELECT `id` ' . 'FROM `hosts` ' . 'WHERE ' . '`host`=\'' . $db->escape($boi_host_ip) . '\' AND ' . '`is_foreign`=1'); if ($host_id > 0) { gs_log(GS_LOG_DEBUG, "Phone {$phone_ip} => foreign PBX {$boi_host_ip} (ID {$host_id})"); return $host_id; } # no matching foreign host found, assume Gemeinschaft gs_log(GS_LOG_DEBUG, "Found no matching foreign PBX for phone {$phone_ip}, assuming Gemeinschaft"); return null; # Gemeinschaft }