Ticket #2695: addprotocols.patch

File addprotocols.patch, 41.1 kB (added by robmac, 4 years ago)
  • functions.inc.php

    old new  
    33class core_conf { 
    44  var $_sip_general    = array(); 
    55  var $_iax_general    = array(); 
     6  var $_h323_general    = array(); 
     7  var $_mgcp_general    = array(); 
     8  var $_skinny_general    = array(); 
    69  var $_featuregeneral = array(); 
    710  var $_featuremap     = array(); 
    811  var $_applicationmap = array(); 
    912  // return an array of filenames to write 
    1013  function get_filename() { 
    1114    $files = array( 
     15      'zapata_additional.conf', 
    1216      'sip_additional.conf', 
    1317      'sip_registrations.conf', 
     18      'sip_general_additional.conf', 
    1419      'iax_additional.conf', 
    1520      'iax_registrations.conf', 
    16       'zapata_additional.conf', 
    17       'sip_general_additional.conf', 
    1821      'iax_general_additional.conf', 
     22      'ooh323_additional.conf', 
     23      'ooh323_registrations.conf', 
     24      'ooh323_general_additional.conf', 
     25      'mgcp_additional.conf', 
     26      'mgcp_registrations.conf', 
     27      'mgcp_general_additional.conf', 
     28      'skinny_additional.conf', 
     29      'skinny_registrations.conf', 
     30      'skinny_general_additional.conf', 
    1931      'features_general_additional.conf', 
    2032      'features_applicationmap_additional.conf', 
    2133      'features_featuremap_additional.conf', 
     
    4658      case 'iax_registrations.conf': 
    4759        return $this->generate_iax_registrations($version); 
    4860        break; 
    49       case 'zapata_additional.conf': 
     61      case 'ooh323_general_additional.conf': 
     62        return $this->generate_h323_general_additional($version); 
     63        break; 
     64      case 'ooh323_additional.conf': 
     65        return $this->generate_h323_additional($version); 
     66        break; 
     67      case 'ooh323_registrations.conf': 
     68        return $this->generate_h323_registrations($version); 
     69        break; 
     70      case 'mgcp_general_additional.conf': 
     71        return $this->generate_mgcp_general_additional($version); 
     72        break; 
     73      case 'mgcp_additional.conf': 
     74        return $this->generate_mgcp_additional($version); 
     75        break; 
     76      case 'mgcp_registrations.conf': 
     77        return $this->generate_mgcp_registrations($version); 
     78        break; 
     79      case 'skinny_general_additional.conf': 
     80        return $this->generate_skinny_general_additional($version); 
     81        break; 
     82      case 'skinny_additional.conf': 
     83        return $this->generate_skinny_additional($version); 
     84        break; 
     85      case 'skinny_registrations.conf': 
     86        return $this->generate_skinny_registrations($version); 
     87        break; 
     88      case 'zapata_additional.conf': 
    5089        return $this->generate_zapata_additional($version); 
    5190        break; 
    5291      case 'features_general_additional.conf': 
     
    91130    return $output; 
    92131  } 
    93132 
     133  function addH323General($key, $value) { 
     134    $this->_h323_general[] = array('key' => $key, 'value' => $value); 
     135  } 
     136 
     137  function generate_h323_general_additional($ast_version) { 
     138    $output = ''; 
     139 
     140    if (isset($this->_h323_general) && is_array($this->_h323_general)) { 
     141      foreach ($this->_h323_general as $values) { 
     142        $output .= $values['key']."=".$values['value']."\n"; 
     143      } 
     144    } 
     145    return $output; 
     146  } 
     147 
     148  function addMgcpGeneral($key, $value) { 
     149    $this->_mgcp_general[] = array('key' => $key, 'value' => $value); 
     150  } 
     151 
     152  function generate_mgcp_general_additional($ast_version) { 
     153    $output = ''; 
     154 
     155    if (isset($this->_mgcp_general) && is_array($this->_mgcp_general)) { 
     156      foreach ($this->_mgcp_general as $values) { 
     157        $output .= $values['key']."=".$values['value']."\n"; 
     158      } 
     159    } 
     160    return $output; 
     161  } 
     162 
     163  function addSkinnyGeneral($key, $value) { 
     164    $this->_skinny_general[] = array('key' => $key, 'value' => $value); 
     165  } 
     166 
     167  function generate_skinny_general_additional($ast_version) { 
     168    $output = ''; 
     169 
     170    if (isset($this->_skinny_general) && is_array($this->_skinny_general)) { 
     171      foreach ($this->_skinny_general as $values) { 
     172        $output .= $values['key']."=".$values['value']."\n"; 
     173      } 
     174    } 
     175    return $output; 
     176  } 
     177 
    94178  function addFeatureGeneral($key, $value) { 
    95179    $this->_featuregeneral[] = array('key' => $key, 'value' => $value); 
    96180  } 
     
    180264    if(DB::IsError($results)) { 
    181265      die($results->getMessage()); 
    182266    } 
    183  
     267 
     268    foreach ($results as $result) { 
     269      $account = $result['data']; 
     270      $id = $result['id']; 
     271      $output .= "[$account]\n"; 
     272   
     273      $sql = "SELECT keyword,data from $table_name where id='$id' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC"; 
     274      $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     275      if(DB::IsError($results2)) { 
     276        die($results2->getMessage()); 
     277      } 
     278      foreach ($results2 as $result2) { 
     279        $options = explode("&", $result2['data']); 
     280        if ($ver12) { 
     281          foreach ($options as $option) { 
     282            $output .= $result2['keyword']."=$option\n"; 
     283          } 
     284        } else { 
     285          foreach ($options as $option) { 
     286            switch ($result2['keyword']) { 
     287              case 'allow': 
     288              case 'disallow': 
     289                if ($option != '') 
     290                  $output .= $result2['keyword']."=$option\n"; 
     291                break; 
     292              default: 
     293                $output .= $result2['keyword']."=$option\n"; 
     294            } 
     295          } 
     296        } 
     297      } 
     298      if ($call_limit && (substr($id,0,4) != "9999" | $id < 99990)) { 
     299 
     300        $output .= $call_limit; 
     301      } 
     302      $output .= $additional."\n"; 
     303    } 
     304    return $output; 
     305  } 
     306 
     307  function generate_sip_registrations($ast_version) { 
     308    global $db; 
     309 
     310    $table_name = "sip"; 
     311    $output = ""; 
     312 
     313    // items with id like 9999999% get put in registrations file 
     314    // 
     315    $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; 
     316    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     317    if(DB::IsError($results)) { 
     318      die($results->getMessage()); 
     319    } 
     320 
     321    foreach ($results as $result) { 
     322      $output .= $result['keyword']."=".$result['data']."\n"; 
     323    } 
     324 
     325    return $output; 
     326  } 
     327 
     328  function generate_iax_additional($ast_version) { 
     329    global $db; 
     330 
     331    $table_name = "iax"; 
     332    $additional = ""; 
     333    $output = ""; 
     334 
     335    $ver12 = version_compare($ast_version, '1.4', 'lt'); 
     336 
     337    $sql = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1"; 
     338    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     339    if(DB::IsError($results)) { 
     340      die($results->getMessage()); 
     341    } 
     342    foreach ($results as $result) { 
     343      if ($ver12) { 
     344        $additional .= $result['keyword']."=".$result['data']."\n"; 
     345      } else { 
     346        $option = $result['data']; 
     347        switch ($result['keyword']) { 
     348          case 'notransfer': 
     349            if (strtolower($option) == 'yes') { 
     350              $additional .= "transfer=no\n"; 
     351            } else if (strtolower($option) == 'no') { 
     352              $additional .= "transfer=yes\n"; 
     353            } else if (strtolower($option) == 'mediaonly') { 
     354              $additional .= "transfer=mediaonly\n"; 
     355            } else { 
     356              $additional .= $result['keyword']."=$option\n"; 
     357            } 
     358            break; 
     359          case 'allow': 
     360          case 'disallow': 
     361            if ($option != '') 
     362              $additional .= $result['keyword']."=$option\n"; 
     363            break; 
     364          default: 
     365            $additional .= $result['keyword']."=$option\n"; 
     366        } 
     367      } 
     368    } 
     369 
     370    $sql = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data"; 
     371    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     372    if(DB::IsError($results)) { 
     373      die($results->getMessage()); 
     374    } 
     375     
     376    foreach ($results as $result) { 
     377      $account = $result['data']; 
     378      $id = $result['id']; 
     379      $output .= "[$account]\n"; 
     380   
     381      $sql = "SELECT keyword,data from $table_name where id='$id' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC"; 
     382      $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     383      if(DB::IsError($results2)) { 
     384        die($results2->getMessage()); 
     385      }  
     386      foreach ($results2 as $result2) { 
     387        $options = explode("&", $result2['data']); 
     388        if ($ver12) { 
     389          foreach ($options as $option) { 
     390            $output .= $result2['keyword']."=$option\n"; 
     391          } 
     392        } else { 
     393          foreach ($options as $option) { 
     394            switch ($result2['keyword']) { 
     395              case 'notransfer': 
     396                if (strtolower($option) == 'yes') { 
     397                  $output .= "transfer=no\n"; 
     398                } else if (strtolower($option) == 'no') { 
     399                  $output .= "transfer=yes\n"; 
     400                } else if (strtolower($option) == 'mediaonly') { 
     401                  $output .= "transfer=mediaonly\n"; 
     402                } else { 
     403                  $output .= $result2['keyword']."=$option\n"; 
     404                } 
     405                break; 
     406              case 'allow': 
     407              case 'disallow': 
     408                if ($option != '') 
     409                  $output .= $result2['keyword']."=$option\n"; 
     410                break; 
     411              default: 
     412                $output .= $result2['keyword']."=$option\n"; 
     413            } 
     414          } 
     415        } 
     416      } 
     417      $output .= $additional."\n"; 
     418    } 
     419    return $output; 
     420  } 
     421 
     422  function generate_iax_registrations($ast_version) { 
     423    global $db; 
     424 
     425    $table_name = "iax"; 
     426    $output = ""; 
     427 
     428    // items with id like 9999999% get put in the registration file 
     429    // 
     430    $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; 
     431    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     432    if(DB::IsError($results)) { 
     433      die($results->getMessage()); 
     434    } 
     435 
     436    foreach ($results as $result) { 
     437      $output .= $result['keyword']."=".$result['data']."\n"; 
     438    } 
     439 
     440    return $output; 
     441  } 
     442 
     443  function generate_h323_additional($ast_version) { 
     444    global $db; 
     445 
     446    $table_name = "h323"; 
     447    $additional = ""; 
     448    $output = ""; 
     449 
     450    $ver12 = version_compare($ast_version, '1.4', 'lt'); 
     451 
     452    $sql = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1"; 
     453    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     454    if(DB::IsError($results)) { 
     455      die($results->getMessage()); 
     456    } 
     457    foreach ($results as $result) { 
     458      if ($ver12) { 
     459        $additional .= $result['keyword']."=".$result['data']."\n"; 
     460      } else { 
     461        $option = $result['data']; 
     462        switch ($result['keyword']) { 
     463          case 'notransfer': 
     464            if (strtolower($option) == 'yes') { 
     465              $additional .= "transfer=no\n"; 
     466            } else if (strtolower($option) == 'no') { 
     467              $additional .= "transfer=yes\n"; 
     468            } else if (strtolower($option) == 'mediaonly') { 
     469              $additional .= "transfer=mediaonly\n"; 
     470            } else { 
     471              $additional .= $result['keyword']."=$option\n"; 
     472            } 
     473            break; 
     474          case 'allow': 
     475          case 'disallow': 
     476            if ($option != '') 
     477              $additional .= $result['keyword']."=$option\n"; 
     478            break; 
     479          default: 
     480            $additional .= $result['keyword']."=$option\n"; 
     481        } 
     482      } 
     483    } 
     484 
     485    $sql = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data"; 
     486    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     487    if(DB::IsError($results)) { 
     488      die($results->getMessage()); 
     489    } 
     490     
     491    foreach ($results as $result) { 
     492      $account = $result['data']; 
     493      $id = $result['id']; 
     494      $output .= "[$account]\n"; 
     495   
     496      $sql = "SELECT keyword,data from $table_name where id='$id' and keyword <> 'account' and flags <> 1 order by flags, keyword DESC"; 
     497      $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     498      if(DB::IsError($results2)) { 
     499        die($results2->getMessage()); 
     500      }  
     501      foreach ($results2 as $result2) { 
     502        $options = explode("&", $result2['data']); 
     503        if ($ver12) { 
     504          foreach ($options as $option) { 
     505            $output .= $result2['keyword']."=$option\n"; 
     506          } 
     507        } else { 
     508          foreach ($options as $option) { 
     509            switch ($result2['keyword']) { 
     510              case 'notransfer': 
     511                if (strtolower($option) == 'yes') { 
     512                  $output .= "transfer=no\n"; 
     513                } else if (strtolower($option) == 'no') { 
     514                  $output .= "transfer=yes\n"; 
     515                } else if (strtolower($option) == 'mediaonly') { 
     516                  $output .= "transfer=mediaonly\n"; 
     517                } else { 
     518                  $output .= $result2['keyword']."=$option\n"; 
     519                } 
     520                break; 
     521              case 'allow': 
     522              case 'disallow': 
     523                if ($option != '') 
     524                  $output .= $result2['keyword']."=$option\n"; 
     525                break; 
     526              default: 
     527                $output .= $result2['keyword']."=$option\n"; 
     528            } 
     529          } 
     530        } 
     531      } 
     532      $output .= $additional."\n"; 
     533    } 
     534    return $output; 
     535  } 
     536 
     537  function generate_h323_registrations($ast_version) { 
     538    global $db; 
     539 
     540    $table_name = "h323"; 
     541    $output = ""; 
     542 
     543    // items with id like 9999999% get put in the registration file 
     544    // 
     545    $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; 
     546    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     547    if(DB::IsError($results)) { 
     548      die($results->getMessage()); 
     549    } 
     550 
     551    foreach ($results as $result) { 
     552      $output .= $result['keyword']."=".$result['data']."\n"; 
     553    } 
     554 
     555    return $output; 
     556  } 
     557 
     558  function generate_mgcp_additional($ast_version) { 
     559    global $db; 
     560 
     561    $table_name = "mgcp"; 
     562    $additional = ""; 
     563    $output = ""; 
     564 
     565    $ver12 = version_compare($ast_version, '1.4', 'lt'); 
     566 
     567    $sql = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1"; 
     568    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     569    if(DB::IsError($results)) { 
     570      die($results->getMessage()); 
     571    } 
     572    foreach ($results as $result) { 
     573      if ($ver12) { 
     574        $additional .= $result['keyword']."=".$result['data']."\n"; 
     575      } else { 
     576        $option = $result['data']; 
     577        switch ($result['keyword']) { 
     578          case 'notransfer': 
     579            if (strtolower($option) == 'yes') { 
     580              $additional .= "transfer=no\n"; 
     581            } else if (strtolower($option) == 'no') { 
     582              $additional .= "transfer=yes\n"; 
     583            } else if (strtolower($option) == 'mediaonly') { 
     584              $additional .= "transfer=mediaonly\n"; 
     585            } else { 
     586              $additional .= $result['keyword']."=$option\n"; 
     587            } 
     588            break; 
     589          case 'allow': 
     590          case 'disallow': 
     591            if ($option != '') 
     592              $additional .= $result['keyword']."=$option\n"; 
     593            break; 
     594          default: 
     595            $additional .= $result['keyword']."=$option\n"; 
     596        } 
     597      } 
     598    } 
     599 
     600    $sql = "SELECT data,id from $table_name where keyword='account' and flags <> 1 group by data"; 
     601    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     602    if(DB::IsError($results)) { 
     603      die($results->getMessage()); 
     604    } 
     605     
    184606    foreach ($results as $result) { 
    185607      $account = $result['data']; 
    186608      $id = $result['id']; 
     
    190612      $results2 = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
    191613      if(DB::IsError($results2)) { 
    192614        die($results2->getMessage()); 
    193       } 
     615      }   
    194616      foreach ($results2 as $result2) { 
    195617        $options = explode("&", $result2['data']); 
    196618        if ($ver12) { 
     
    200622        } else { 
    201623          foreach ($options as $option) { 
    202624            switch ($result2['keyword']) { 
     625              case 'notransfer': 
     626                if (strtolower($option) == 'yes') { 
     627                  $output .= "transfer=no\n"; 
     628                } else if (strtolower($option) == 'no') { 
     629                  $output .= "transfer=yes\n"; 
     630                } else if (strtolower($option) == 'mediaonly') { 
     631                  $output .= "transfer=mediaonly\n"; 
     632                } else { 
     633                  $output .= $result2['keyword']."=$option\n"; 
     634                } 
     635                break; 
    203636              case 'allow': 
    204637              case 'disallow': 
    205638                if ($option != '') 
     
    211644          } 
    212645        } 
    213646      } 
    214       if ($call_limit && (substr($id,0,4) != "9999" | $id < 99990)) { 
    215  
    216         $output .= $call_limit; 
    217       } 
    218647      $output .= $additional."\n"; 
    219648    } 
    220649    return $output; 
    221650  } 
    222651 
    223   function generate_sip_registrations($ast_version) { 
     652  function generate_mgcp_registrations($ast_version) { 
    224653    global $db; 
    225654 
    226     $table_name = "sip"; 
     655    $table_name = "mgcp"; 
    227656    $output = ""; 
    228657 
    229     // items with id like 9999999% get put in registrations file 
     658    // items with id like 9999999% get put in the registration file 
    230659    // 
    231660    $sql = "SELECT keyword,data from $table_name where id LIKE '9999999%' and keyword <> 'account' and flags <> 1"; 
    232661    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 
     
    241670    return $output; 
    242671  } 
    243672 
    244   function generate_iax_additional($ast_version) { 
     673  function generate_skinny_additional($ast_version) { 
    245674    global $db; 
    246675 
    247     $table_name = "iax"; 
     676    $table_name = "skinny"; 
    248677    $additional = ""; 
    249678    $output = ""; 
    250679 
     
    335764    return $output; 
    336765  } 
    337766 
    338   function generate_iax_registrations($ast_version) { 
     767  function generate_skinny_registrations($ast_version) { 
    339768    global $db; 
    340769 
    341     $table_name = "iax"; 
     770    $table_name = "skinny"; 
    342771    $output = ""; 
    343772 
    344773    // items with id like 9999999% get put in the registration file 
     
    5981027        if (version_compare($version, '1.4', 'ge')) { 
    5991028          $core_conf->addIaxGeneral('tos','ef'); // Recommended setting from doc/ip-tos.txt 
    6001029        } 
     1030        $core_conf->addH323General('bindport','1720'); 
     1031        $core_conf->addH323General('bindaddr','0.0.0.0'); 
     1032        $core_conf->addH323General('h225portrange','12030,12230'); 
     1033        $core_conf->addH323General('h323id','ObjSysAsterisk'); 
     1034        $core_conf->addH323General('gatekeeper','DISABLE'); 
     1035        $core_conf->addH323General('faststart','no'); 
     1036        $core_conf->addH323General('rtptimeout','10'); 
     1037        $core_conf->addH323General('dtmfmode','rfc2833'); 
     1038        $core_conf->addH323General('canreinvite','no'); 
     1039        $core_conf->addH323General('disallow','all'); 
     1040        $core_conf->addH323General('allow','ulaw'); 
     1041        $core_conf->addH323General('allow','gsm'); 
     1042        $core_conf->addH323General('context','from-internal'); 
     1043        $core_conf->addMgcpGeneral('port','2427'); 
     1044        $core_conf->addMgcpGeneral('bindaddr','0.0.0.0'); 
     1045        $core_conf->addMgcpGeneral('canreinvite','no'); 
     1046        $core_conf->addMgcpGeneral('wcardep','*'); 
     1047        $core_conf->addSkinnyGeneral('port','2000'); 
     1048        $core_conf->addSkinnyGeneral('bindaddr','0.0.0.0'); 
     1049        $core_conf->addSkinnyGeneral('dateFormat','D-M-Y'); 
     1050        $core_conf->addSkinnyGeneral('keepAlive','120'); 
    6011051 
    6021052        $fcc = new featurecode($modulename, 'blindxfer'); 
    6031053        $code = $fcc->getCodeActive(); 
     
    9741424            continue; 
    9751425          } 
    9761426          switch ($trunkprops['tech']) { 
     1427            case 'H323': 
    9771428            case 'IAX': 
    9781429            case 'IAX2': 
     1430            case 'MGCP': 
     1431            case 'Skinny': 
    9791432            case 'SIP': 
    9801433              $trunkgroup = $trunkprops['globalvar']; 
    9811434              $trunkcontext  = "from-trunk-".strtolower($trunkprops['tech'])."-".$trunkprops['name']; 
     
    16472100    case "IAX": 
    16482101      $sql .= " WHERE tech = 'iax2'"; 
    16492102      break; 
     2103    case "H323": 
    16502104    case "IAX2": 
     2105    case "MGCP": 
    16512106    case "SIP": 
     2107    case "Skinny": 
    16522108    case "ZAP": 
    16532109      $sql .= " WHERE tech = '".strtolower($tech)."'"; 
    16542110      break; 
     
    17022158  } 
    17032159  //unless defined, $dial is TECH/id 
    17042160  if ( $dial == '' ) { 
    1705     //zap is an exception 
     2161    //zap, h323, mgcp & skinny are exceptions 
    17062162    if ( strtolower($tech) == "zap" ) { 
    17072163      $zapchan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 
    17082164      $dial = 'ZAP/'.$zapchan; 
     2165//    } else if ( strtolower($tech) == "h323" ) { 
     2166//      $h323chan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 
     2167//      $dial = 'OOH323/'.$h323id."@".$ip; 
     2168//    } else if ( strtolower($tech) == "mgcp" ) { 
     2169//      $mgcpchan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 
     2170//      $dial = 'MGCP/'.$line."@".$account; 
     2171//    } else if ( strtolower($tech) == "skinny" ) { 
     2172//      $skinnychan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 
     2173//      $dial = 'Skinny/'.$line."@".$account; 
    17092174    } else { 
    17102175      $dial = strtoupper($tech)."/".$id; 
    17112176    } 
     
    17802245    exec("/bin/ln -s /var/spool/asterisk/voicemail/".$vmcontext."/".$user."/ /var/spool/asterisk/voicemail/device/".$id); 
    17812246  } 
    17822247     
    1783   //take care of sip/iax/zap config 
     2248  //take care of sip/iax/zap/h323/mgcp/skinny config 
    17842249  $funct = "core_devices_add".strtolower($tech); 
    17852250  if(function_exists($funct)){ 
    17862251    $funct($id); 
     
    18442309    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
    18452310  } 
    18462311   
    1847   //take care of sip/iax/zap config 
     2312  //take care of sip/iax/zap/h323/mgcp/skinny config 
    18482313  $funct = "core_devices_del".strtolower($devinfo['tech']); 
    18492314  if(function_exists($funct)){ 
    18502315    $funct($account); 
     
    18562321  $sql = "SELECT * FROM devices WHERE id = '$account'"; 
    18572322  $results = sql($sql,"getRow",DB_FETCHMODE_ASSOC); 
    18582323   
    1859   //take care of sip/iax/zap config 
     2324  //take care of sip/iax/zap/h323/mgcp/skinny config 
    18602325  $funct = "core_devices_get".strtolower($results['tech']); 
    18612326  if (!empty($results['tech']) && function_exists($funct)) { 
    18622327    $devtech = $funct($account); 
     
    20372502    if ( substr($req, 0, 8) == 'devinfo_' ) { 
    20382503      $keyword = substr($req, 8); 
    20392504      if ( $keyword == 'dial' && $data == '' ) { 
    2040        $iaxfields[] = array($account, $keyword, 'IAX2/'.$account); 
     2505                                $iaxfields[] = array($account, $keyword, 'IAX2/'.$account); 
    20412506      } elseif ($keyword == 'mailbox' && $data == '') { 
    20422507        $iaxfields[] = array($account,'mailbox',$account.'@device'); 
    20432508      } else { 
     
    21102575  return $results; 
    21112576} 
    21122577 
     2578//add to h323 table 
     2579function core_devices_addh323($account) { 
     2580  global $db; 
     2581  global $currentFile; 
     2582   
     2583  foreach ($_REQUEST as $req=>$data) { 
     2584    if ( substr($req, 0, 8) == 'devinfo_' ) { 
     2585      $keyword = substr($req, 8); 
     2586      if ( $keyword == 'dial' && $data == '' ) { 
     2587                                $h323fields[] = array($account, $keyword, 'OOH323/'.$h323id."@".$ip); 
     2588//                                $h323fields[] = array($account, $keyword, 'OOH323/'.$account.'@'.$ip); 
     2589      } elseif ($keyword == 'mailbox' && $data == '') { 
     2590        $h323fields[] = array($account,'mailbox',$account.'@device'); 
     2591      } else { 
     2592        $h323fields[] = array($account, $keyword, $data); 
     2593      } 
     2594    } 
     2595  } 
     2596   
     2597  if ( !is_array($h323fields) ) { // left for compatibilty....lord knows why ! 
     2598    $h323fields = array( 
     2599      //array($account,'account',$account), 
     2600      array($account,'type',($_REQUEST['context'])?$_REQUEST['context']:'friend'), 
     2601      array($account,'ip',($_REQUEST['ip'])?$_REQUEST['ip']:''), 
     2602      array($account,'port',($_REQUEST['port'])?$_REQUEST['port']:'1720'), 
     2603      array($account,'h323id',($_REQUEST['h323id'])?$_REQUEST['h323id']:$account), 
     2604      array($account,'rtptimeout',($_REQUEST['rtptimeout'])?$_REQUEST['rtptimeout']:'60'), 
     2605      array($account,'dtmfmode',($_REQUEST['dtmfmode'])?$_REQUEST['dtmfmode']:'rfc2833'), 
     2606      array($account,'context',($_REQUEST['context'])?$_REQUEST['context']:'from-internal'), 
     2607      array($account,'mailbox',($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device'), 
     2608      array($account,'amaflags',($_REQUEST['amaflags'])?$_REQUEST['amaflags']:'default'), 
     2609      array($account,'disallow',($_REQUEST['disallow'])?$_REQUEST['disallow']:'all'), 
     2610      array($account,'allow',($_REQUEST['allow'])?$_REQUEST['allow']:'ulaw'), 
     2611      array($account,'accountcode',($_REQUEST['accountcode'])?$_REQUEST['accountcode']:''), 
     2612      array($account,'e164',($_REQUEST['e164'])?$_REQUEST['e164']:''), 
     2613      array($account,'email',($_REQUEST['email'])?$_REQUEST['email']:''), 
     2614      array($account,'url',($_REQUEST['url'])?$_REQUEST['url']:'') 
     2615      //array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'), 
     2616      //array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'), 
     2617      //array($account,'callerid',($_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>') 
     2618    ); 
     2619  } 
     2620 
     2621  // Very bad 
     2622  $h323fields[] = array($account,'account',$account);  
     2623  $h323fields[] = array($account,'callerid',(isset($_REQUEST['description']) && $_REQUEST['description'] != '')?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>'); 
     2624  // Asterisk treats no caller ID from an h323 device as 'hide callerid', and ignores the caller ID 
     2625  // set in h323.conf. As we rely on this for pretty much everything, we need to specify the  
     2626  // callerid as a variable which gets picked up in macro-callerid. 
     2627  // Ref - http://bugs.digium.com/view.php?id=456 
     2628  $h323fields[] = array($account,'setvar',"REALCALLERIDNUM=$account"); 
     2629   
     2630  // Where is this in the interface ?????? 
     2631  $h323fields[] = array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'); 
     2632  $h323fields[] = array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'); 
     2633   
     2634  $compiled = $db->prepare('INSERT INTO h323 (id, keyword, data) values (?,?,?)'); 
     2635  $result = $db->executeMultiple($compiled,$h323fields); 
     2636  if(DB::IsError($result)) { 
     2637    die_freepbx($result->getMessage()."<br><br>error adding to h323 table");   
     2638  } 
     2639} 
     2640 
     2641function core_devices_delh323($account) { 
     2642  global $db; 
     2643  global $currentFile; 
     2644   
     2645  $sql = "DELETE FROM h323 WHERE id = '$account'"; 
     2646  $result = $db->query($sql); 
     2647   
     2648  if(DB::IsError($result)) { 
     2649    die_freepbx($result->getMessage().$sql); 
     2650  } 
     2651} 
     2652 
     2653function core_devices_geth323($account) { 
     2654  global $db; 
     2655  $sql = "SELECT keyword,data FROM h323 WHERE id = '$account'"; 
     2656  $results = $db->getAssoc($sql); 
     2657  if(DB::IsError($results)) { 
     2658    $results = null; 
     2659  } 
     2660   
     2661  return $results; 
     2662} 
     2663 
     2664//add to mgcp table 
     2665function core_devices_addmgcp($account) { 
     2666  global $db; 
     2667  global $currentFile; 
     2668 
     2669  foreach ($_REQUEST as $req=>$data) { 
     2670    if ( substr($req, 0, 8) == 'devinfo_' ) { 
     2671      $keyword = substr($req, 8); 
     2672      if ( $keyword == 'dial' && $data == '' ) { 
     2673        $mgcpfields[] = array($account, $keyword, 'MGCP/'.$line."@".$account); 
     2674//        $mgcpfields[] = array($account, $keyword, 'MGCP/aaln/1/@'.$account); 
     2675      } elseif ($keyword == 'mailbox' && $data == '') { 
     2676        $mgcpfields[] = array($account,'mailbox',$account.'@device'); 
     2677      } else { 
     2678        $mgcpfields[] = array($account, $keyword, $data); 
     2679      } 
     2680    } 
     2681  } 
     2682   
     2683  if ( !is_array($mgcpfields) ) { // left for compatibilty....lord knows why ! 
     2684    $mgcpfields = array( 
     2685      //array($account,'account',$account), 
     2686      array($account,'type',($_REQUEST['context'])?$_REQUEST['context']:'friend'), 
     2687      array($account,'host',(isset($_REQUEST['host']))?$_REQUEST['host']:'dynamic'), 
     2688      array($account,'line',(isset($_REQUEST['line']))?$_REQUEST['line']:'aaln/1'), 
     2689      array($account,'slowsequence',(isset($_REQUEST['slowsequence']))?$_REQUEST['slowsequence']:'yes'), 
     2690      array($account,'dtmfmode',(isset($_REQUEST['dtmfmode']))?$_REQUEST['dtmfmode']:'rfc2833'), 
     2691      array($account,'nat',(isset($_REQUEST['nat']))?$_REQUEST['nat']:'no'), 
     2692      array($account,'disallow',(isset($_REQUEST['disallow']))?$_REQUEST['disallow']:'all'), 
     2693      array($account,'allow',(isset($_REQUEST['allow']))?$_REQUEST['allow']:'ulaw'), 
     2694      array($account,'context',(isset($_REQUEST['context']))?$_REQUEST['context']:'from-internal'), 
     2695      array($account,'mailbox',($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device'), 
     2696      array($account,'callgroup',(isset($_REQUEST['callgroup']))?$_REQUEST['callgroup']:''), 
     2697      array($account,'pickupgroup',(isset($_REQUEST['pickupgroup']))?$_REQUEST['pickupgroup']:''), 
     2698      array($account,'accountcode',(isset($_REQUEST['accountcode']))?$_REQUEST['accountcode']:'') 
     2699      //array($account,'record_in',(isset($_REQUEST['record_in']))?$_REQUEST['record_in']:'On-Demand'), 
     2700      //array($account,'record_out',(isset($_REQUEST['record_out']))?$_REQUEST['record_out']:'On-Demand'), 
     2701      //array($account,'callerid',(isset($_REQUEST['description']))?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>') 
     2702    ); 
     2703  } 
     2704 
     2705  // Very bad 
     2706  $mgcpfields[] = array($account,'account',$account);  
     2707  $mgcpfields[] = array($account,'callerid',(isset($_REQUEST['description']) && $_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>'); 
     2708   
     2709  // Where is this in the interface ?????? 
     2710  $mgcpfields[] = array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'); 
     2711  $mgcpfields[] = array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'); 
     2712 
     2713  $compiled = $db->prepare('INSERT INTO mgcp (id, keyword, data) values (?,?,?)'); 
     2714  $result = $db->executeMultiple($compiled,$mgcpfields); 
     2715  if(DB::IsError($result)) { 
     2716    die_freepbx($result->getDebugInfo()."<br><br>".'error adding to mgcp table');  
     2717  } 
     2718} 
     2719 
     2720function core_devices_delmgcp($account) { 
     2721  global $db; 
     2722  global $currentFile; 
     2723   
     2724  $sql = "DELETE FROM mgcp WHERE id = '$account'"; 
     2725  $result = $db->query($sql); 
     2726   
     2727  if(DB::IsError($result)) { 
     2728    die_freepbx($result->getMessage().$sql); 
     2729  } 
     2730} 
     2731 
     2732function core_devices_getmgcp($account) { 
     2733  global $db; 
     2734  $sql = "SELECT keyword,data FROM mgcp WHERE id = '$account'"; 
     2735  $results = $db->getAssoc($sql); 
     2736  if(DB::IsError($results)) { 
     2737    $results = null; 
     2738  } 
     2739   
     2740  return $results; 
     2741} 
     2742 
     2743//add to skinny table 
     2744function core_devices_addskinny($account) { 
     2745  global $db; 
     2746  global $currentFile; 
     2747 
     2748  foreach ($_REQUEST as $req=>$data) { 
     2749    if ( substr($req, 0, 8) == 'devinfo_' ) { 
     2750      $keyword = substr($req, 8); 
     2751      if ( $keyword == 'dial' && $data == '' ) { 
     2752        $skinnyfields[] = array($account, $keyword, 'skinny/'.$line."@".$account); 
     2753      } elseif ($keyword == 'mailbox' && $data == '') { 
     2754        $skinnyfields[] = array($account,'mailbox',$account.'@device'); 
     2755      } else { 
     2756        $skinnyfields[] = array($account, $keyword, $data); 
     2757      } 
     2758    } 
     2759  } 
     2760   
     2761  if ( !is_array($skinnyfields) ) { // left for compatibilty....lord knows why ! 
     2762    $skinnyfields = array( 
     2763      //array($account,'account',$account), 
     2764      array($account,'secret',($_REQUEST['secret'])?$_REQUEST['secret']:''), 
     2765      array($account,'type',($_REQUEST['context'])?$_REQUEST['context']:'friend'), 
     2766      array($account,'host',(isset($_REQUEST['host']))?$_REQUEST['host']:'dynamic'), 
     2767      array($account,'model',(isset($_REQUEST['model']))?$_REQUEST['model']:'79xx'), 
     2768      array($account,'device',(isset($_REQUEST['device']))?$_REQUEST['device']:'SEP0007EBxxxxxx'), 
     2769      array($account,'version',(isset($_REQUEST['version']))?$_REQUEST['version']:'P03-08-02'), 
     2770      array($account,'permit',(isset($_REQUEST['permit']))?$_REQUEST['permit']:'0.0.0.0/0.0.0.0'), 
     2771      array($account,'line',(isset($_REQUEST['line']))?$_REQUEST['line']:''), 
     2772      array($account,'linelabel',(isset($_REQUEST['linelabel']))?$_REQUEST['linelabel']:''), 
     2773      array($account,'context',(isset($_REQUEST['context']))?$_REQUEST['context']:'from-internal'), 
     2774      array($account,'nat',(isset($_REQUEST['nat']))?$_REQUEST['nat']:'no'), 
     2775      array($account,'dtmfmode',(isset($_REQUEST['dtmfmode']))?$_REQUEST['dtmfmode']:'inband'), 
     2776      array($account,'disallow',(isset($_REQUEST['disallow']))?$_REQUEST['disallow']:'all'), 
     2777      array($account,'allow',(isset($_REQUEST['allow']))?$_REQUEST['allow']:''), 
     2778      array($account,'mailbox',($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device'), 
     2779      array($account,'callwaiting',($_REQUEST['callwaiting'])?$_REQUEST['callwaiting']:'1'), 
     2780      array($account,'transfer',($_REQUEST['transfer'])?$_REQUEST['transfer']:'1'), 
     2781      array($account,'threewaycalling',($_REQUEST['threewaycalling'])?$_REQUEST['threewaycalling']:'1'), 
     2782      array($account,'callgroup',(isset($_REQUEST['callgroup']))?$_REQUEST['callgroup']:''), 
     2783      array($account,'pickupgroup',(isset($_REQUEST['pickupgroup']))?$_REQUEST['pickupgroup']:''), 
     2784      array($account,'accountcode',(isset($_REQUEST['accountcode']))?$_REQUEST['accountcode']:'') 
     2785      //array($account,'record_in',(isset($_REQUEST['record_in']))?$_REQUEST['record_in']:'On-Demand'), 
     2786      //array($account,'record_out',(isset($_REQUEST['record_out']))?$_REQUEST['record_out']:'On-Demand'), 
     2787      //array($account,'callerid',(isset($_REQUEST['description']))?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>') 
     2788    ); 
     2789  } 
     2790 
     2791  // Very bad 
     2792  $skinnyfields[] = array($account,'account',$account);  
     2793  $skinnyfields[] = array($account,'callerid',(isset($_REQUEST['description']) && $_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>'); 
     2794   
     2795  // Where is this in the interface ?????? 
     2796  $skinnyfields[] = array($account,'record_in',($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand'); 
     2797  $skinnyfields[] = array($account,'record_out',($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand'); 
     2798 
     2799  $compiled = $db->prepare('INSERT INTO skinny (id, keyword, data) values (?,?,?)'); 
     2800  $result = $db->executeMultiple($compiled,$skinnyfields); 
     2801  if(DB::IsError($result)) { 
     2802    die_freepbx($result->getDebugInfo()."<br><br>".'error adding to skinny table');  
     2803  } 
     2804} 
     2805 
     2806function core_devices_delskinny($account) { 
     2807  global $db; 
     2808  global $currentFile; 
     2809   
     2810  $sql = "DELETE FROM skinny WHERE id = '$account'"; 
     2811  $result = $db->query($sql); 
     2812   
     2813  if(DB::IsError($result)) { 
     2814    die_freepbx($result->getMessage().$sql); 
     2815  } 
     2816} 
     2817 
     2818function core_devices_getskinny($account) { 
     2819  global $db; 
     2820  $sql = "SELECT keyword,data FROM skinny WHERE id = '$account'"; 
     2821  $results = $db->getAssoc($sql); 
     2822  if(DB::IsError($results)) { 
     2823    $results = null; 
     2824  } 
     2825   
     2826  return $results; 
     2827} 
     2828 
    21132829function core_devices_addzap($account) { 
    21142830  global $db; 
    21152831  global $currentFile; 
     
    27513467 
    27523468  // conditionally, delete from iax or sip 
    27533469  switch (strtolower($tech)) { 
     3470    case "h323": 
     3471      sql("DELETE FROM h323 WHERE id = '9999$trunknum' OR id = '99999$trunknum' OR id = '9999999$trunknum'"); 
     3472    break; 
    27543473    case "iax": 
    27553474    case "iax2": 
    27563475      sql("DELETE FROM iax WHERE id = '9999$trunknum' OR id = '99999$trunknum' OR id = '9999999$trunknum'"); 
    27573476    break; 
     3477    case "mgcp": 
     3478      sql("DELETE FROM mgcp WHERE id = '9999$trunknum' OR id = '99999$trunknum' OR id = '9999999$trunknum'"); 
     3479    break; 
    27583480    case "sip":  
    27593481      sql("DELETE FROM sip WHERE id = '9999$trunknum' OR id = '99999$trunknum' OR id = '9999999$trunknum'"); 
    27603482    break; 
     3483    case "skinny": 
     3484      sql("DELETE FROM skinny WHERE id = '9999$trunknum' OR id = '99999$trunknum' OR id = '9999999$trunknum'"); 
     3485    break; 
    27613486  } 
    27623487} 
    27633488 
     
    28043529  $disable_flag = ($disabletrunk == "on")?1:0; 
    28053530   
    28063531  switch (strtolower($tech)) { 
     3532    case "h323": 
     3533      core_trunks_addSipOrIax($peerdetails,'h323',$channelid,$trunknum,$disable_flag); 
     3534      if ($usercontext != ""){ 
     3535        core_trunks_addSipOrIax($userconfig,'h323',$usercontext,'9'.$trunknum,$disable_flag); 
     3536      } 
     3537      if ($register != ""){ 
     3538        core_trunks_addRegister($trunknum,'h323',$register,$disable_flag); 
     3539      } 
     3540    break; 
    28073541    case "iax": 
    28083542    case "iax2": 
    28093543      core_trunks_addSipOrIax($peerdetails,'iax',$channelid,$trunknum,$disable_flag); 
     
    28143548        core_trunks_addRegister($trunknum,'iax',$register,$disable_flag); 
    28153549      } 
    28163550    break; 
     3551    case "mgcp": 
     3552      core_trunks_addSipOrIax($peerdetails,'mgcp',$channelid,$trunknum,$disable_flag); 
     3553      if ($usercontext != ""){ 
     3554        core_trunks_addSipOrIax($userconfig,'mgcp',$usercontext,'9'.$trunknum,$disable_flag); 
     3555      } 
     3556      if ($register != ""){ 
     3557        core_trunks_addRegister($trunknum,'mgcp',$register,$disable_flag); 
     3558      } 
     3559    break; 
    28173560    case "sip": 
    28183561      core_trunks_addSipOrIax($peerdetails,'sip',$channelid,$trunknum,$disable_flag); 
    28193562      if ($usercontext != ""){ 
     
    28233566        core_trunks_addRegister($trunknum,'sip',$register,$disable_flag); 
    28243567      } 
    28253568    break; 
     3569    case "skinny": 
     3570      core_trunks_addSipOrIax($peerdetails,'skinny',$channelid,$trunknum,$disable_flag); 
     3571      if ($usercontext != ""){ 
     3572        core_trunks_addSipOrIax($userconfig,'skinny',$usercontext,'9'.$trunknum,$disable_flag); 
     3573      } 
     3574      if ($register != ""){ 
     3575        core_trunks_addRegister($trunknum,'skinny',$register,$disable_flag); 
     3576      } 
     3577    break; 
    28263578  }  
    28273579} 
    28283580 
     
    28363588    $tech = "custom"; 
    28373589  } else { 
    28383590    $tech = strtolower( strtok($results[0][0],'/') ); // the technology.  ie: ZAP/g0 is ZAP 
    2839      
    28403591    if ($tech == "iax2") $tech = "iax"; // same thing, here 
    28413592  } 
    28423593  return $tech; 
     
    40754826    $msgInvalidDTMFMODE = _("Please enter the dtmfmode for this device"); 
    40764827    $msgInvalidChannel = _("Please enter the channel for this device"); 
    40774828    $msgConfirmSecret = _("You have not entered a Secret for this device, although this is possible it is generally bad practice to not assign a Secret to a device. Are you sure you want to leave the Secret empty?"); 
     4829    $msgH323ConfirmIP = _("You have not entered an IP Address for the endpoint, OOH323 requires an IP as it is not an H323 Gatekeeper and does not support host=dynamic."); 
     4830    $msgH323InvalidIP = _("You have not entered an IP Address for the endpoint, Asterisk will not be able to contact it."); 
    40784831    $msgInvalidSecret = _("Please enter a Secret for this device"); 
    40794832     
    40804833    // zap 
     
    40944847    $tmparr['mailbox'] = array('value' => '', 'level' => 1); 
    40954848    $currentcomponent->addgeneralarrayitem('devtechs', 'zap', $tmparr); 
    40964849    unset($tmparr); 
    4097      
     4850 
     4851    // h323 
     4852    $tmparr = array(); 
     4853    $tmparr['type'] = array('value' => 'friend', 'level' => 1); 
     4854    $tmparr['ip'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty() && !confirm("'.$msgH323ConfirmIP.'")', 'failvalidationmsg' => $msgH323InvalidIP); 
     4855    $tmparr['port'] = array('value' => '1720', 'level' => 1); 
     4856    $tmparr['h323id'] = array('value' => '', 'level' => 0); 
     4857    $tmparr['dial'] = array('value' => '', 'level' => 0); 
     4858    $tmparr['rtptimeout'] = array('value' => '60', 'level' => 1); 
     4859    $tmparr['canreinvite'] = array('value' => 'no', 'level' => 1); 
     4860    $tmparr['dtmfmode'] = array('value' => 'rfc2833', 'level' => 1); 
     4861    $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); 
     4862    $tmparr['disallow'] = array('value' => 'all', 'level' => 1); 
     4863    $tmparr['allow'] = array('value' => 'ulaw', 'level' => 1); 
     4864    $tmparr['mailbox'] = array('value' => '', 'level' => 1); 
     4865    $tmparr['accountcode'] = array('value' => '', 'level' => 1); 
     4866    $tmparr['amaflags'] = array('value' => '', 'level' => 1); 
     4867    $tmparr['e164'] = array('value' => '', 'level' => 1); 
     4868    $tmparr['email'] = array('value' => '', 'level' => 1); 
     4869    $tmparr['url'] = array('value' => '', 'level' => 1); 
     4870    $currentcomponent->addgeneralarrayitem('devtechs', 'h323', $tmparr); 
     4871    unset($tmparr); 
     4872 
    40984873    // iax2 
    40994874    $tmparr = array(); 
    41004875    $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty() && !confirm("'.$msgConfirmSecret.'")', 'failvalidationmsg' => $msgInvalidSecret); 
     
    41124887    $currentcomponent->addgeneralarrayitem('devtechs', 'iax2', $tmparr); 
    41134888    unset($tmparr); 
    41144889 
     4890    // mgcp 
     4891    $tmparr = array(); 
     4892    $tmparr['host'] = array('value' => 'dynamic', 'level' => 1); 
     4893    $tmparr['type'] = array('value' => 'friend', 'level' => 1); 
     4894    $tmparr['wcardep'] = array('value' => '*', 'level' => 1); 
     4895    $tmparr['slowsequence'] = array('value' => 'yes', 'level' => 1); 
     4896    $tmparr['line'] = array('value' => '', 'level' => 0); 
     4897    $tmparr['dial'] = array('value' => '', 'level' => 0); 
     4898    $tmparr['dtmfmode'] = array('value' => 'rfc2833', 'level' => 1); 
     4899    $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); 
     4900    $tmparr['canreinvite'] = array('value' => 'no', 'level' => 1); 
     4901    $tmparr['nat'] = array('value' => 'no', 'level' => 1); 
     4902    $tmparr['callgroup'] = array('value' => '', 'level' => 1); 
     4903    $tmparr['pickupgroup'] = array('value' => '', 'level' => 1); 
     4904    $tmparr['disallow'] = array('value' => 'all', 'level' => 1); 
     4905    $tmparr['allow'] = array('value' => 'ulaw', 'level' => 1); 
     4906    $tmparr['accountcode'] = array('value' => '', 'level' => 1); 
     4907    $tmparr['mailbox'] = array('value' => '', 'level' => 1); 
     4908    $currentcomponent->addgeneralarrayitem('devtechs', 'mgcp', $tmparr); 
     4909    unset($tmparr); 
     4910 
     4911    // skinny 
     4912    $tmparr = array(); 
     4913    $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty() && !confirm("'.$msgConfirmSecret.'")', 'failvalidationmsg' => $msgInvalidSecret); 
     4914    $tmparr['host'] = array('value' => 'dynamic', 'level' => 0); 
     4915    $tmparr['type'] = array('value' => 'friend', 'level' => 1); 
     4916    $tmparr['model'] = array('value' => '79xx', 'level' => 0); 
     4917    $tmparr['device'] = array('value' => 'SEP0007EBxxxxxx', 'level' => 0); 
     4918    $tmparr['version'] = array('value' => 'P03-0x-0x', 'level' => 0); 
     4919    $tmparr['permit'] = array('value' => '', 'level' => 0); 
     4920    $tmparr['line'] = array('value' => '', 'level' => 0); 
     4921    $tmparr['linelabel'] = array('value' => '', 'level' => 0); 
     4922    $tmparr['dial'] = array('value' => '', 'level' => 0); 
     4923    $tmparr['dtmfmode'] = array('value' => 'rfc2833', 'level' => 1); 
     4924    $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); 
     4925    $tmparr['canreinvite'] = array('value' => 'no', 'level' => 1); 
     4926    $tmparr['nat'] = array('value' => 'no', 'level' => 1); 
     4927    $tmparr['callgroup'] = array('value' => '', 'level' => 1); 
     4928    $tmparr['pickupgroup'] = array('value' => '', 'level' => 1); 
     4929    $tmparr['callwaiting'] = array('value' => '', 'level' => 1); 
     4930    $tmparr['transfer'] = array('value' => '', 'level' => 1); 
     4931    $tmparr['threewaycalling'] = array('value' => '', 'level' => 1); 
     4932    $tmparr['disallow'] = array('value' => 'all', 'level' => 1); 
     4933    $tmparr['allow'] = array('value' => 'ulaw', 'level' => 1); 
     4934    $tmparr['mailbox'] = array('value' => '', 'level' => 1); 
     4935    $tmparr['accountcode'] = array('value' => '', 'level' => 1); 
     4936 
     4937    $currentcomponent->addgeneralarrayitem('devtechs', 'skinny', $tmparr); 
     4938    unset($tmparr); 
     4939 
    41154940    // sip 
    41164941    $tmparr = array(); 
    41174942    $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty() && !confirm("'.$msgConfirmSecret.'")', 'failvalidationmsg' => $msgInvalidSecret); 
     
    41204945    $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); 
    41214946    $tmparr['host'] = array('value' => 'dynamic', 'level' => 1); 
    41224947    $tmparr['type'] = array('value' => 'friend', 'level' => 1); 
    4123     $tmparr['nat'] = array('value' => 'yes', 'level' => 1); 
     4948    $tmparr['nat'] = array('value' => 'no', 'level' => 1); 
    41244949    $tmparr['port'] = array('value' => '5060', 'level' => 1); 
    41254950    $tmparr['qualify'] = array('value' => 'yes', 'level' => 1); 
    41264951    $tmparr['callgroup'] = array('value' => '', 'level' => 1); 
     
    41414966     
    41424967    // Devices list 
    41434968    $currentcomponent->addoptlistitem('devicelist', 'sip_generic', _("Generic SIP Device")); 
     4969    $currentcomponent->addoptlistitem('devicelist', 'h323_generic', _("Generic H323 Device")); 
    41444970    $currentcomponent->addoptlistitem('devicelist', 'iax2_generic', _("Generic IAX2 Device")); 
     4971    $currentcomponent->addoptlistitem('devicelist', 'mgcp_generic', _("Generic MGCP Device")); 
     4972    $currentcomponent->addoptlistitem('devicelist', 'skinny_generic', _("Generic Skinny Device")); 
    41454973    $currentcomponent->addoptlistitem('devicelist', 'zap_generic', _("Generic ZAP Device")); 
    41464974    $currentcomponent->addoptlistitem('devicelist', 'custom_custom', _("Other (Custom) Device")); 
    41474975    $currentcomponent->setoptlistopts('devicelist', 'sort', false);