Exemple #1
0
$sipdriver = FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER');
if (!$tech && !$extdisplay) {
    //driver => label
    $default_trunk_types = array("DAHDI" => 'DAHDi', "IAX2" => 'IAX2', "ENUM" => 'ENUM', "DUNDI" => 'DUNDi', "CUSTOM" => 'Custom');
    $sip = $sipdriver == 'both' || $sipdriver == 'chan_sip' ? array("SIP" => sprintf(_('SIP (%s)'), 'chan_sip')) : array();
    $pjsip = $sipdriver == 'both' || $sipdriver == 'chan_pjsip' ? array("PJSIP" => sprintf(_('SIP (%s)'), 'chan_pjsip')) : array();
    $trunk_types = $pjsip + $sip + $default_trunk_types;
    // Added to enable the unsupported misdn module
    if (function_exists('misdn_ports_list_trunks') && count(misdn_ports_list_trunks())) {
        $trunk_types['MISDN'] = 'mISDN';
    }
    $displayvars['trunk_types'] = $trunk_types;
    show_view(dirname(__FILE__) . '/views/trunks/main.php', $displayvars);
} else {
    if ($extdisplay) {
        $trunk_details = core_trunks_getDetails($trunknum);
        $tech = htmlentities($trunk_details['tech']);
        $outcid = htmlentities($trunk_details['outcid']);
        $maxchans = htmlentities($trunk_details['maxchans']);
        $dialoutprefix = htmlentities($trunk_details['dialoutprefix']);
        $keepcid = htmlentities($trunk_details['keepcid']);
        $failtrunk = htmlentities($trunk_details['failscript']);
        $failtrunk_enable = $failtrunk == "" ? '' : 'CHECKED';
        $disabletrunk = htmlentities($trunk_details['disabled']);
        $continue = htmlentities($trunk_details['continue']);
        $provider = $trunk_details['provider'];
        $trunk_name = htmlentities($trunk_details['name']);
        $dialopts = $trunk_details['dialopts'] === false ? false : htmlentities($trunk_details['dialopts']);
        if ($tech != "enum") {
            $channelid = htmlentities($trunk_details['channelid']);
            if ($tech != "custom" && $tech != "dundi") {
Exemple #2
0
 function generate_iax_additional($ast_version)
 {
     global $db;
     $table_name = "iax";
     $additional = "";
     $output = "";
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $sql = "SELECT keyword,data from {$table_name} where id=-1 and keyword <> 'account' and flags <> 1";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if (DB::IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if ($ver12) {
             $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
         } else {
             $option = $result['data'];
             switch ($result['keyword']) {
                 case 'notransfer':
                     if (strtolower($option) == 'yes') {
                         $additional .= "transfer=no\n";
                     } else {
                         if (strtolower($option) == 'no') {
                             $additional .= "transfer=yes\n";
                         } else {
                             if (strtolower($option) == 'mediaonly') {
                                 $additional .= "transfer=mediaonly\n";
                             } else {
                                 $additional .= $result['keyword'] . "={$option}\n";
                             }
                         }
                     }
                     break;
                 case 'allow':
                 case 'disallow':
                 case 'accountcode':
                     if ($option != '') {
                         $additional .= $result['keyword'] . "={$option}\n";
                     }
                     break;
                 case 'requirecalltoken':
                     if ($option != '') {
                         $additional .= $result['keyword'] . "={$option}\n";
                     }
                     break;
                 default:
                     $additional .= $result['keyword'] . "={$option}\n";
             }
         }
     }
     $sql = "SELECT data,id from {$table_name} where keyword='account' and flags <> 1 group by data";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if (DB::IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         $account = $result['data'];
         $id = $result['id'];
         $output .= "[{$account}]\n";
         $sql = "SELECT keyword,data from {$table_name} where id='{$id}' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC";
         $results2_pre = $db->getAll($sql, DB_FETCHMODE_ASSOC);
         if (DB::IsError($results2_pre)) {
             die($results2_pre->getMessage());
         }
         // Move all 'disallow=all' and 'deny=' to the top to avoid errors
         //
         $results2 = array();
         foreach ($results2_pre as $element) {
             if (strtolower(trim($element['keyword'])) != 'secret') {
                 $options = explode("&", $element['data']);
                 foreach ($options as $option) {
                     if (($element['keyword'] == 'disallow' && $option == 'all') | $element['keyword'] == 'deny') {
                         array_unshift($results2, array('keyword' => $element['keyword'], 'data' => $option));
                     } else {
                         $results2[] = array('keyword' => $element['keyword'], 'data' => $option);
                     }
                 }
             } else {
                 $results2[] = array('keyword' => $element['keyword'], 'data' => str_replace(';', '\\;', $element['data']));
             }
         }
         unset($results2_pre);
         $context = '';
         foreach ($results2 as $result2) {
             $option = strtolower($result2['data']);
             if ($ver12) {
                 switch (strtolower($result2['keyword'])) {
                     case 'context':
                         $context = $result2['data'];
                         //fall-through
                     //fall-through
                     default:
                         $output .= $result2['keyword'] . "=" . $result2['data'] . "\n";
                 }
             } else {
                 switch ($result2['keyword']) {
                     case 'notransfer':
                         if (strtolower($option) == 'yes') {
                             $output .= "transfer=no\n";
                         } else {
                             if (strtolower($option) == 'no') {
                                 $output .= "transfer=yes\n";
                             } else {
                                 if (strtolower($option) == 'mediaonly') {
                                     $output .= "transfer=mediaonly\n";
                                 } else {
                                     $output .= $result2['keyword'] . "=" . $result2['data'] . "\n";
                                 }
                             }
                         }
                         break;
                     case 'allow':
                     case 'disallow':
                     case 'accountcode':
                         if ($option != '') {
                             $output .= $result2['keyword'] . "=" . $result2['data'] . "\n";
                         }
                         break;
                     case 'requirecalltoken':
                         if ($option != '') {
                             $output .= $result2['keyword'] . "=" . $result2['data'] . "\n";
                         }
                         break;
                     case 'callerid':
                     case 'mailbox':
                         $output .= $this->map_dev_user($account, $result2['keyword'], $result2['data']);
                         break;
                     case 'context':
                         $context = $option;
                         //fall-through
                     //fall-through
                     default:
                         $output .= $result2['keyword'] . "=" . $result2['data'] . "\n";
                 }
             }
         }
         switch (substr($id, 0, 8)) {
             case 'tr-peer-':
                 if ($context == '') {
                     $output .= "context=from-trunk-iax2-{$account}\n";
                 }
                 break;
             case 'tr-user-':
                 if ($context == '') {
                     $tn = substr($id, 8);
                     // this is a 'user' trunk, we need to get the name of the corresponding 'peer'
                     // trunk so we can set the context appropriately for the group count
                     //
                     $td = core_trunks_getDetails($tn);
                     if (isset($td['channelid'])) {
                         $output .= "context=from-trunk-iax2-" . $td['channelid'] . "\n";
                     }
                 }
                 break;
             default:
         }
         if (isset($this->_iax_additional[$account])) {
             foreach ($this->_iax_additional[$account] as $asetting) {
                 $output .= $asetting['key'] . "=" . $asetting['value'] . "\n";
             }
         }
         $output .= $additional . "\n";
     }
     return $output;
 }