$callerid['Number'] = $rule['PrependDigits'] . $callerid['Number']; } } return $callerid; } $agi = new AGI(); $logger = new AGI_Logger($agi); $cdr = new AGI_CDR($agi); //CDR : Flush existing entry if both called and caller are known if ($cdr->caller_known() && $cdr->called_known()) { $cdr->flush_cdr(); } // Get Called Extension informations $called_ext = $agi->request['agi_extension']; // Get Caller Extension infomation $cid = $agi->parse_callerid(); $caller_ext = $cid['username']; $Extension_S = DB_Extension($caller_ext); //CDR: Set caller information $cdr->set_caller($Extension_S['PK_Extension'], $Extension_S['Type'], DB_Extension_Name($caller_ext), $caller_ext); //CDR: Set called information $cdr->set_called(0, '', '', $called_ext); // CDR: Push dial event $cdr->push_event("DIAL", $called_ext); // See if we can match any outgoing rule $query = "SELECT * FROM OutgoingRules ORDER BY RuleOrder"; $result = $mysqli->query($query) or $agi->verbose($mysqli->error . $query); while ($rule = $result->fetch_assoc()) { // Check if rule matches $regex = "/^{$rule['BeginWith']}[0-9]{{$rule['RestBetweenLow']},{$rule['RestBetweenHigh']}}\$/"; if (!preg_match($regex, $called_ext)) {