Changeset 8162

Show
Ignore:
Timestamp:
08/25/09 12:38:39 (1 year ago)
Author:
p_lindheimer
Message:

add include of main functions.inc.php removing several duplicated functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.6/amp_conf/bin/generate_hints.php

    r7755 r8162  
    1111        $amp_conf = parse_amportal_conf_bootstrap("/etc/amportal.conf"); 
    1212 
     13        require_once($amp_conf['AMPWEBROOT'].'/admin/functions.inc.php'); 
    1314        require_once($amp_conf['AMPWEBROOT'].'/admin/common/php-asmanager.php'); 
     15 
     16        $amp_conf = parse_amportal_conf("/etc/amportal.conf"); 
     17 
    1418        $astman         = new AGI_AsteriskManager(); 
    1519        if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
     
    3337 
    3438        //--------------------------------------------------------------------- 
    35         function ast_with_dahdi() { 
    36                 global $astman; 
    37                 global $amp_conf; 
    38          
    39                 if (!$amp_conf['ZAP2DAHDICOMPAT']) { 
    40                         return false; 
    41                 } 
    42          
    43                 $engine_info = engine_getinfo(); 
    44                 $version = $engine_info['version']; 
    45                  
    46                 if (version_compare($version, '1.4', 'ge') && $amp_conf['AMPENGINE'] == 'asterisk') {            
    47                         if (isset($astman) && $astman->connected()) { 
    48                                 $response = $astman->send_request('Command', array('Command' => 'module show like chan_dahdi')); 
    49                                 if (preg_match('/1 modules loaded/', $response['data'])) { 
    50                                         return true; 
    51                                 } 
    52                         } 
    53                 } 
    54                 return false; 
    55         } 
    56  
    57         function engine_getinfo() { 
    58                 global $amp_conf; 
    59                 global $astman; 
    60  
    61                 switch ($amp_conf['AMPENGINE']) { 
    62                         case 'asterisk': 
    63                                 if (isset($astman) && $astman->connected()) { 
    64                                         //get version (1.4) 
    65                                         $response = $astman->send_request('Command', array('Command'=>'core show version')); 
    66                                         if (preg_match('/No such command/',$response['data'])) { 
    67                                                 // get version (1.2) 
    68                                                 $response = $astman->send_request('Command', array('Command'=>'show version')); 
    69                                         } 
    70                                         $verinfo = $response['data']; 
    71                                 } else { 
    72                                         // could not connect to asterisk manager, try console 
    73                                         $verinfo = exec('asterisk -V'); 
    74                                 } 
    75                          
    76                                 if (preg_match('/Asterisk (\d+(\.\d+)*)(-?(\S*))/', $verinfo, $matches)) { 
    77                                         return array('engine'=>'asterisk', 'version' => $matches[1], 'additional' => $matches[4], 'raw' => $verinfo); 
    78                                 } elseif (preg_match('/Asterisk SVN-(\d+(\.\d+)*)(-?(\S*))/', $verinfo, $matches)) { 
    79                                         return array('engine'=>'asterisk', 'version' => $matches[1], 'additional' => $matches[4], 'raw' => $verinfo); 
    80                                 } elseif (preg_match('/Asterisk SVN-branch-(\d+(\.\d+)*)-r(-?(\S*))/', $verinfo, $matches)) { 
    81                                         return array('engine'=>'asterisk', 'version' => $matches[1].'.'.$matches[4], 'additional' => $matches[4], 'raw' => $verinfo); 
    82                                 } elseif (preg_match('/Asterisk SVN-trunk-r(-?(\S*))/', $verinfo, $matches)) { 
    83                                         return array('engine'=>'asterisk', 'version' => '1.6', 'additional' => $matches[1], 'raw' => $verinfo); 
    84                                 } elseif (preg_match('/Asterisk SVN-.+-(\d+(\.\d+)*)-r(-?(\S*))-(.+)/', $verinfo, $matches)) { 
    85                                         return array('engine'=>'asterisk', 'version' => $matches[1], 'additional' => $matches[3], 'raw' => $verinfo); 
    86                                 } elseif (preg_match('/Asterisk [B].(\d+(\.\d+)*)(-?(\S*))/', $verinfo, $matches)) { 
    87                                         return array('engine'=>'asterisk', 'version' => '1.2', 'additional' => $matches[3], 'raw' => $verinfo); 
    88                                 } elseif (preg_match('/Asterisk [C].(\d+(\.\d+)*)(-?(\S*))/', $verinfo, $matches)) { 
    89                                         return array('engine'=>'asterisk', 'version' => '1.4', 'additional' => $matches[3], 'raw' => $verinfo); 
    90                                 } 
    91  
    92                                 return array('engine'=>'ERROR-UNABLE-TO-PARSE', 'version'=>'0', 'additional' => '0', 'raw' => $verinfo); 
    93                         break; 
    94                 } 
    95                 return array('engine'=>'ERROR-UNSUPPORTED-ENGINE-'.$amp_conf['AMPENGINE'], 'version'=>'0', 'additional' => '0', 'raw' => $verinfo); 
    96         } 
    9739 
    9840        function parse_amportal_conf_bootstrap($filename) { 
     
    10850                        $conf["AMPWEBROOT"] = rtrim($conf["AMPWEBROOT"],'/'); 
    10951                } 
    110                 if (!isset($conf['ASTAGIDIR']) || $conf['ASTAGIDIR'] == '') { 
    111                         $conf['ASTAGIDIR'] = '/var/lib/asterisk/agi-bin'; 
    112                 } 
    113                 if (!isset($conf['ZAP2DAHDICOMPAT'])) { 
    114                         $conf['ZAP2DAHDICOMPAT'] = false; 
    115                 } else { 
    116                         switch (strtoupper(trim($conf['ZAP2DAHDICOMPAT']))) { 
    117                                 case '1': 
    118                                 case 'TRUE': 
    119                                 case 'ON': 
    120                                         $conf['ZAP2DAHDICOMPAT'] = true; 
    121                                         break; 
    122                                 default: 
    123                                         $conf['ZAP2DAHDICOMPAT'] = false; 
    124                         } 
    125                 } 
    126  
    12752                return $conf; 
    12853        }