function CanonicalPhoneNumber($number) { $this->_INTL = $this->_cnf('GS_CANONIZE_INTL_PREFIX', '00'); if ($this->_INTL === '+' || $this->_INTL == '') { $this->_INTL = '00'; } $this->_CNTR = $this->_cnf('GS_CANONIZE_COUNTRY_CODE', '49'); $this->_NATL = $this->_cnf('GS_CANONIZE_NATL_PREFIX', '0'); $this->_NINT = gs_get_conf('GS_CANONIZE_NATL_PREFIX_INTL', false); $this->_AREA = $this->_cnf('GS_CANONIZE_AREA_CODE', '251'); $this->_LOCL = $this->_cnf('GS_CANONIZE_LOCAL_BRANCH', '99999999'); $this->_CBCP = $this->_cnf('GS_CANONIZE_CBC_PREFIX', '010'); $this->_SPCL = gs_get_conf('GS_CANONIZE_SPECIAL', '//'); if (!is_valid_pcre($this->_SPCL)) { gs_log(GS_LOG_WARNING, 'Your GS_CANONIZE_SPECIAL pattern is not a valid PCRE'); $this->_SPCL = '/^1(:1[0-9]{1,5}|9222)/'; # 110, 112, 116116, 118.*, 19222 etc. } //$n = preg_replace('/[^0-9A-Z+*\-\/ ]/', '', strToUpper(trim( $number ))); //$n = preg_replace('/[ \/\-]/', ' ', $n); $n = preg_replace('/[^0-9A-Z+*]/', '', strToUpper(trim($number))); // "+" is allowed as the first char only: $n = preg_replace('/(?!^)\\+/', '', $n); $this->orig = $n; if ($this->orig != '') { $this->norm = $this->_canonize(); $this->_to_intl(); $this->_to_natl(); $this->_to_locl(); $this->_check_prv_branch(); if ($this->is_call_by_call) { $this->in_prv_branch = false; } if ($this->is_call_by_call) { $this->dial = ''; $this->errt = 'cbc'; } elseif ($this->in_prv_branch) { $this->dial = $this->extn; $this->errt = 'self'; } elseif ($this->is_special) { $this->dial = $this->orig; } else { $this->dial = $this->natl; } } else { $this->errt = 'empty'; } }
$in_dest_replace = preg_replace('/[^0-9+a-zA-Z\\-_.,$]/', '', trim(@$_REQUEST['gg-in_dest_replace'])); if (!is_valid_pcre('/' . $in_dest_search . '/', $in_dest_replace)) { echo '<div class="errorbox">', sPrintF(htmlEnt(__("Ungültiges Suchen/Ersetzen-Muster %s für die eingehende Durchwahl wurde nicht gespeichert!")), '<tt>' . htmlEnt('s/' . $in_dest_search . '/' . $in_dest_replace . '/') . '</tt>'), '</div>', "\n"; $in_dest_search = $oldgg['in_dest_search']; $in_dest_replace = $oldgg['in_dest_replace']; } $in_cid_search = trim(@$_REQUEST['gg-in_cid_search']); $in_cid_replace = preg_replace('/[^0-9+a-zA-Z\\-_.,$]/', '', trim(@$_REQUEST['gg-in_cid_replace'])); if (!is_valid_pcre('/' . $in_cid_search . '/', $in_cid_replace)) { echo '<div class="errorbox">', sPrintF(htmlEnt(__("Ungültiges Suchen/Ersetzen-Muster %s für die eingehende Caller-ID wurde nicht gespeichert!")), '<tt>' . htmlEnt('s/' . $in_cid_search . '/' . $in_cid_replace . '/') . '</tt>'), '</div>', "\n"; $in_cid_search = $oldgg['in_cid_search']; $in_cid_replace = $oldgg['in_cid_replace']; } $out_cid_search = trim(@$_REQUEST['gg-out_cid_search']); $out_cid_replace = preg_replace('/[^0-9+a-zA-Z\\-_.,$]/', '', trim(@$_REQUEST['gg-out_cid_replace'])); if (!is_valid_pcre('/' . $out_cid_search . '/', $out_cid_replace)) { echo '<div class="errorbox">', sPrintF(htmlEnt(__("Ungültiges Suchen/Ersetzen-Muster %s für die ausgehende Caller-ID wurde nicht gespeichert!")), '<tt>' . htmlEnt('s/' . $out_cid_search . '/' . $out_cid_replace . '/') . '</tt>'), '</div>', "\n"; $out_cid_search = $oldgg['out_cid_search']; $out_cid_replace = $oldgg['out_cid_replace']; } if ($ggid > 0) { $DB->execute('UPDATE `gate_grps` SET `title`=\'' . $DB->escape($title) . '\', `type`=\'' . $DB->escape($type) . '\', `allow_in`=' . $allow_in . ', `in_dest_search`=\'' . $DB->escape($in_dest_search) . '\', `in_dest_replace`=\'' . $DB->escape($in_dest_replace) . '\', `in_cid_search`=\'' . $DB->escape($in_cid_search) . '\', `in_cid_replace`=\'' . $DB->escape($in_cid_replace) . '\', `out_cid_search`=\'' . $DB->escape($out_cid_search) . '\', `out_cid_replace`=\'' . $DB->escape($out_cid_replace) . '\'
##################################################################### if ($action === 'gsave') { if ($ggid > 0) { $rs = $DB->execute('SELECT `name`, `title`, `type`, `allow_in`, `in_dest_search`, `in_dest_replace` FROM `gate_grps` WHERE `id`=' . $ggid); $oldgg = $rs->fetchRow(); } if ($ggid < 1 || $ggid > 0 && !$oldgg) { $oldgg = array('name' => '', 'title' => '', 'type' => '', 'allow_in' => 0, 'in_dest_search' => '', 'in_dest_replace' => ''); } $title = trim(@$_REQUEST['gg-title']); $name = preg_replace('/[^a-z0-9\\-_]/', '', @$_REQUEST['gg-name']); $type = 'balance'; $allow_in = @$_REQUEST['gg-allow_in'] ? 1 : 0; $in_dest_search = trim(@$_REQUEST['gg-in_dest_search']); $in_dest_replace = trim(@$_REQUEST['gg-in_dest_replace']); if (!is_valid_pcre('/' . $in_dest_search . '/')) { echo 'Invalid pattern!<br />', "\n"; $in_dest_search = $oldgg['in_dest_search']; } if ($ggid > 0) { $DB->execute('UPDATE `gate_grps` SET `title`=\'' . $DB->escape($title) . '\', `type`=\'' . $DB->escape($type) . '\', `allow_in`=' . $allow_in . ', `in_dest_search`=\'' . $DB->escape($in_dest_search) . '\', `in_dest_replace`=\'' . $DB->escape($in_dest_replace) . '\' WHERE `id`=' . $ggid); // separate query because there's a "unique" constraint on the name // column: $DB->execute('UPDATE `gate_grps` SET `name`=\'' . $DB->escape($name) . '\'
$canonize_country_code = preg_replace('/[^0-9*#]/', '', $canonize_country_code); gs_keyval_set('canonize_country_code', $canonize_country_code); $canonize_natl_prefix = @$_REQUEST['canonize_natl_prefix']; $canonize_natl_prefix = preg_replace('/[^0-9*#]/', '', $canonize_natl_prefix); gs_keyval_set('canonize_natl_prefix', $canonize_natl_prefix); $canonize_natl_prefix_intl = (bool) @$_REQUEST['canonize_natl_prefix_intl']; gs_keyval_set('canonize_natl_prefix_intl', $canonize_natl_prefix_intl ? 'yes' : 'no'); $canonize_area_code = @$_REQUEST['canonize_area_code']; $canonize_area_code = preg_replace('/[^0-9*#]/', '', $canonize_area_code); gs_keyval_set('canonize_area_code', $canonize_area_code); $canonize_local_branch = @$_REQUEST['canonize_local_branch']; $canonize_local_branch = preg_replace('/[^0-9*#]/', '', $canonize_local_branch); gs_keyval_set('canonize_local_branch', $canonize_local_branch); $canonize_special = @$_REQUEST['canonize_special']; $canonize_special = trim($canonize_special); if (is_valid_pcre('/' . $canonize_special . '/')) { gs_keyval_set('canonize_special', $canonize_special); } else { echo '<b>', 'Invalid pattern!', '</b><br />', "\n"; } $canonize_cbc_prefix = @$_REQUEST['canonize_cbc_prefix']; $canonize_cbc_prefix = preg_replace('/[^0-9*#]/', '', $canonize_cbc_prefix); gs_keyval_set('canonize_cbc_prefix', $canonize_cbc_prefix); } ?> <p class="text"><?php echo __('Festlegung der vom Standort abhängigen Rufnummernteile, die sich auf die Kanonisierung auswirken. Bitte halten Sie sich an die angegebenen Beispiele!'); ?> </p> <form method="post" action="<?php
$db_ids = array(); while ($r = $rs->fetchRow()) { $db_ids[] = (string) (int) $r['id']; } $db_ids[] = 0; # add 0 for the new rule foreach ($db_ids as $dbid) { if (!array_key_exists('r_' . $dbid . '_pattern', $_REQUEST)) { continue; } $pattern = trim(@$_REQUEST['r_' . $dbid . '_pattern']); if ($dbid < 1 && $pattern == '') { continue; } $pattern = preg_replace('/[^0-9a-zA-Z\\-\\\\#*+\\[\\]\\{\\}\\(\\)|\\^$.,?!=:<>]/', '', $pattern); if (is_valid_pcre('/' . $pattern . '/')) { $set_pattern = '`pattern`=\'' . $DB->escape($pattern) . '\','; } else { if ($dbid < 1) { continue; } # do not add rule if pattern is invalid $set_pattern = ''; } $h_from_h = (int) lTrim(@$_REQUEST['r_' . $dbid . '_h_from_h'], ' 0'); if ($h_from_h < 0) { $h_from_h = 0; } elseif ($h_from_h > 23) { $h_from_h = 23; } $h_from_h = str_pad($h_from_h, 2, '0', STR_PAD_LEFT);