Пример #1
0
    $regex = "/^{$rule['BeginWith']}[0-9]{{$rule['RestBetweenLow']},{$rule['RestBetweenHigh']}}\$/";
    if (!preg_match($regex, $called_ext)) {
        continue;
    }
    // Create new_number
    $new_number = substr($called_ext, $rule['TrimFront']);
    $new_number = $new_number . $rule['PrependDigits'];
    break;
}
// Exit if no rule was matched
if ($new_number == "") {
    $agi->verbose('Cannot match any outgoing rule for number :' . $called_ext);
    exit(0);
}
// Detect and Set the caller id information that we should set for this call
$CallerID = get_callerid($agi, $rule['PK_OutgoingRule'], $caller_ext);
$agi->set_variable('CALLERID(name)', $CallerID['Name']);
$agi->set_variable('CALLERID(number)', $CallerID['Number']);
// If matched rules ask us to route the number trought a SIP provider
if ($rule['ProviderType'] == 'SIP') {
    $agi->verbose("CALLING {$new_number} USING RULE {$rule['Name']}  AND SIP PROVIDER [{$rule['ProviderID']}]");
    //CDR : set entry type
    $cdr->set_type('OUT');
    // Get the needed information about this sip provider
    $query = "SELECT * FROM `SipProviders` WHERE PK_SipProvider = '{$rule['ProviderID']}' LIMIT 1";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    if ($mysqli->num_rows($result) != '1') {
        exit(0);
    }
    $SipProvider = $result->fetch_assoc();
    // If providers requires the P-Asserted-Identity for caller id setup
Пример #2
0
/**
 * GET the opencnam callerid information
 *
 * @param array $row Results from database call in build_item_list
 * @param object $current_user Global current_user object - allows db access
 * @return array $callerid Returns the callerid information
 *
 * @todo implement a number cleaner that always formats input into 10 digits
 */
function get_open_cnam_result($row, $current_user)
{
    require_once 'opencnam.php';
    // Check OpenCNAM if we don't already have the Company Name in Sugar.
    if (!isset($found['company']) && $GLOBALS['sugar_config']['asterisk_opencnam_enabled'] == "true") {
        if ($row['opencnam'] == NULL) {
            $opencnam = new opencnam();
            $tempCnamResult = $opencnam->fetch(get_callerid($row));
            $tempCnamResult = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $tempCnamResult);
            $tempCallRecordId = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $row['call_record_id']);
            $cnamUpdateQuery = "UPDATE asterisk_log SET opencnam='{$tempCnamResult}' WHERE call_record_id='{$tempCallRecordId}'";
            $current_user->db->query($cnamUpdateQuery, false);
            $callerid = $tempCnamResult;
        }
    }
    return $callerid;
}