Changeset 7755

Show
Ignore:
Timestamp:
05/26/09 19:44:17 (3 years ago)
Author:
p_lindheimer
Message:

fixes #3694 honor ZAP2DAHDI setting generate_hints.php

Files:

Legend:

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

    r5868 r7755  
    1616    exit; 
    1717  } 
     18  $ast_with_dahdi = ast_with_dahdi(); 
    1819 
    1920  $var = $astman->database_show('AMPUSER'); 
     
    3233 
    3334  //--------------------------------------------------------------------- 
     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  } 
    3497 
    3598  function parse_amportal_conf_bootstrap($filename) { 
     
    47110    if (!isset($conf['ASTAGIDIR']) || $conf['ASTAGIDIR'] == '') { 
    48111      $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      } 
    49125    } 
    50126 
     
    82158    debug("get_dial_string: devices: $devices",8); 
    83159    global $astman; 
     160    global $ast_with_dahdi; 
    84161 
    85162    $device_array = explode( '&', $devices ); 
     
    87164      $dds = $astman->database_get('DEVICE',$adevice.'/dial'); 
    88165      $dialstring .= $dds.'&'; 
     166    } 
     167    if ($ast_with_dahdi) { 
     168      $dialstring = str_replace('ZAP/', 'DAHDI/', $dialstring); 
    89169    } 
    90170    return trim($dialstring," &");