Ticket #2695: addprotocols.patch

File addprotocols.patch, 41.1 kB (added by robmac, 9 months 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['c