Changeset 14149

Show
Ignore:
Timestamp:
06/18/12 11:48:21 (1 year ago)
Author:
mbrevda
Message:

re #5879, #5839 - add bootstrap hook; write writetimeout to mamanger.conf; cosmetics

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/amp_conf/astetc/manager.conf

    r10122 r14149  
    2222read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate 
    2323write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate 
     24writetimeout = 5000 
    2425 
    2526#include manager_additional.conf 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/bootstrap.php

    r13801 r14149  
    157157} 
    158158if (!isset($no_auth) && !defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }//we should never need this, just another line of defence 
     159bootstrap_include_hooks('pre_module_load', 'all_mods'); 
    159160 
    160161$restrict_mods_local = $restrict_mods; 
     
    171172      //include module functions if there not dissabled 
    172173      if ((!$restrict_mods_local || (is_array($restrict_mods_local) && isset($restrict_mods_local[$key]))) && is_file($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php")) { 
     174    bootstrap_include_hooks('pre_module_load', $key); 
    173175        require_once($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php"); 
    174176 
     
    180182          $force_autoload = true; 
    181183        } 
     184    bootstrap_include_hooks('post_module_load', $key); 
    182185      }  
    183186      //create an array of module sections to display 
     
    197200      } 
    198201    } 
     202  bootstrap_include_hooks('post_module_load', 'all_mods'); 
    199203    $bootstrap_settings['function_modules_included'] = true; 
    200204  } 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/functions.inc.php

    r13913 r14149  
    111111  } 
    112112 
    113   foreach ($class as $this_class) switch($this_class){ 
    114     case 'ampuser': 
    115       require_once($dirname . '/libraries/ampuser.class.php'); 
    116       break; 
    117     case 'CI_Email': 
    118       //make upstream scripts happy - for $CI_Email->_set_error_message() 
    119       if (!function_exists('log_message')) { 
    120         function log_message(){}; 
    121       } 
    122       if (!function_exists('get_instance')) { 
    123         function get_instance(){return new ci_def();} 
    124       } 
    125       if (!class_exists('ci_def')) { 
    126         class ci_def {function __construct(){$this->lang = new ci_lan_def();}} 
    127       } 
    128       if (!class_exists('ci_lan_def')) { 
    129         class ci_lan_def {function load(){return false;} function line(){return false;}}  
    130       } 
    131       if (!defined('BASEPATH')){ 
    132         define('BASEPATH', ''); 
    133       } 
    134       if (!defined('FOPEN_READ')) { 
    135         define('FOPEN_READ', 'rb'); 
    136       } 
    137       require_once($dirname . '/helpers/Email.php'); 
    138       break; 
    139     case 'CI_Table': 
    140       //make upstream scripts happy 
    141       if (!function_exists('log_message')) { 
    142         function log_message(){}; 
    143       } 
    144       if (!defined('BASEPATH')){define('BASEPATH', '');} 
    145       require_once($dirname . '/helpers/Table.php'); 
    146       break; 
    147     case 'CssMin': 
    148       require_once($dirname . '/libraries/cssmin.class.php'); 
    149       break; 
    150     case 'component': 
    151         require_once($dirname . '/libraries/components.class.php'); 
    152         break; 
    153     case 'featurecode': 
    154       require_once($dirname . '/libraries/featurecodes.class.php'); 
    155       break; 
    156     case 'cronmanager': 
    157       require_once($dirname . '/libraries/cronmanager.class.php'); 
    158       break; 
    159     case 'moduleHook': 
    160       require_once($dirname . '/libraries/moduleHook.class.php'); 
    161       break; 
    162     case 'modulelist': 
    163       require_once($dirname . '/libraries/modulelist.class.php'); 
    164       break; 
    165     case 'modgettext': 
    166       require_once($dirname . '/libraries/modgettext.class.php'); 
    167       break; 
    168     case 'notifications': 
    169       require_once($dirname . '/libraries/notifications.class.php'); 
    170       break; 
    171       case 'xml2Array': 
    172         require_once($dirname . '/libraries/xml2Array.class.php'); 
    173         break; 
    174     default: 
    175       //TODO: enable some logging here 
    176       break; 
     113  foreach ($class as $this_class) { 
     114    if (class_exists($this_class)) { 
     115      continue; 
     116    } 
     117    switch($this_class){ 
     118      case 'ampuser': 
     119        require_once($dirname . '/libraries/ampuser.class.php'); 
     120        break; 
     121      case 'CI_Email': 
     122        //make upstream scripts happy - for $CI_Email->_set_error_message() 
     123        if (!function_exists('log_message')) { 
     124          function log_message(){}; 
     125        } 
     126        if (!function_exists('get_instance')) { 
     127          function get_instance(){return new ci_def();} 
     128        } 
     129        if (!class_exists('ci_def')) { 
     130          class ci_def {function __construct(){$this->lang = new ci_lan_def();}} 
     131        } 
     132        if (!class_exists('ci_lan_def')) { 
     133          class ci_lan_def {function load(){return false;} function line(){return false;}}  
     134        } 
     135        if (!defined('BASEPATH')){ 
     136          define('BASEPATH', ''); 
     137        } 
     138        if (!defined('FOPEN_READ')) { 
     139          define('FOPEN_READ', 'rb'); 
     140        } 
     141        require_once($dirname . '/helpers/Email.php'); 
     142        break; 
     143      case 'CI_Table': 
     144        //make upstream scripts happy 
     145        if (!function_exists('log_message')) { 
     146          function log_message(){}; 
     147        } 
     148        if (!defined('BASEPATH')){define('BASEPATH', '');} 
     149        require_once($dirname . '/helpers/Table.php'); 
     150        break; 
     151      case 'CssMin': 
     152        require_once($dirname . '/libraries/cssmin.class.php'); 
     153        break; 
     154      case 'component': 
     155          require_once($dirname . '/libraries/components.class.php'); 
     156          break; 
     157      case 'featurecode': 
     158        require_once($dirname . '/libraries/featurecodes.class.php'); 
     159        break; 
     160      case 'cronmanager': 
     161        require_once($dirname . '/libraries/cronmanager.class.php'); 
     162        break; 
     163      case 'moduleHook': 
     164        require_once($dirname . '/libraries/moduleHook.class.php'); 
     165        break; 
     166      case 'modulelist': 
     167        require_once($dirname . '/libraries/modulelist.class.php'); 
     168        break; 
     169      case 'modgettext': 
     170        require_once($dirname . '/libraries/modgettext.class.php'); 
     171        break; 
     172      case 'notifications': 
     173        require_once($dirname . '/libraries/notifications.class.php'); 
     174        break; 
     175        case 'xml2Array': 
     176          require_once($dirname . '/libraries/xml2Array.class.php'); 
     177          break; 
     178      default: 
     179        //TODO: enable some logging here 
     180        break; 
     181    } 
    177182    } 
    178183} 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/libraries/utility.functions.php

    r14119 r14149  
    12241224 * allows FreePBX to update the manager credentials primarily used by Advanced Settings and Backup and Restore. 
    12251225 */ 
    1226 function fpbx_ami_update($user=false, $pass=false) { 
    1227   global $amp_conf; 
    1228   global $astman; 
    1229  
     1226function fpbx_ami_update($user=false, $pass=false, $writetimeout = false) { 
     1227  global $amp_conf, $astman; 
     1228  $conf_file = $amp_conf['ASTETCDIR'] . '/manager.conf'; 
    12301229  $ret = $ret2 = 0; 
    12311230  $output = array(); 
    12321231   
    12331232  if ($user !== false && $user != '') { 
    1234     exec('sed -i.bak "s/\s*\[general\].*$/TEMPCONTEXT/;s/\[.*\]/\[' . $amp_conf['AMPMGRUSER'] . '\]/;s/^TEMPCONTEXT$/\[general\]/" '. $amp_conf['ASTETCDIR'] . '/manager.conf', $output, $ret); 
     1233    exec('sed -i.bak "s/\s*\[general\].*$/TEMPCONTEXT/;s/\[.*\]/\[' . $amp_conf['AMPMGRUSER'] . '\]/;s/^TEMPCONTEXT$/\[general\]/" '. $conf_file, $output, $ret); 
    12351234    if ($ret) { 
    12361235      dbug($output); 
     
    12451244  if ($pass !== false && $pass != '') { 
    12461245    unset($output); 
    1247     exec('sed -i.bak "s/secret\s*=.*$/secret = ' . $amp_conf['AMPMGRPASS'] . '/" ' . $amp_conf['ASTETCDIR'] . '/manager.conf', $output, $ret2); 
     1246    exec('sed -i.bak "s/secret\s*=.*$/secret = ' . $amp_conf['AMPMGRPASS'] . '/" ' . $conf_file, $output, $ret2); 
    12481247    if ($ret2) { 
    12491248      dbug($output); 
     
    12551254    } 
    12561255  } 
    1257  
    1258   if ($ret || $ret2) { 
     1256   
     1257  //attempt to set writetimeout 
     1258  unset($output);i 
     1259  if ($writetimeout) { 
     1260    exec('sed -i.bak "s/writetimeout\s*=.*$/writetimeout = '  
     1261      . $amp_conf['ASTMGRWRITETIMEOUT'] . '/" ' . $conf_file, $output, $ret3); 
     1262    if ($ret3) { 
     1263      dbug($output); 
     1264      dbug($ret3); 
     1265      freepbx_log(FPBX_LOG_ERROR,sprintf(_("Failed changing AMI writetimout to [%s], internal failure details follow:"),$amp_conf['ASTMGRWRITETIMEOUT'])); 
     1266      foreach ($output as $line) { 
     1267        freepbx_log(FPBX_LOG_ERROR,sprintf(_("AMI failure details:"),$line)); 
     1268      } 
     1269    } 
     1270  } 
     1271  if ($ret || $ret2 || $ret3) { 
    12591272    dbug("aborting early because previous errors"); 
    12601273    return false; 
  • freepbx/branches/2.10/amp_conf/htdocs/recordings/includes/callme.php

    r13922 r14149  
    5353function callme_getnum($exten) 
    5454{ 
    55  global $astman; 
    56  $cmd     = "database get AMPUSER $exten/callmenum"; 
     55        global $astman; 
     56        $cmd    = "database get AMPUSER $exten/callmenum"; 
    5757  $callme_num   = ''; 
    58  $results   = $astman->Command($cmd); 
     58        $results  = $astman->Command($cmd); 
    5959 
    6060  if (is_array($results)) 
  • freepbx/branches/2.10/libfreepbx.install.php

    r14135 r14149  
    13151315  $set['level'] = 0; 
    13161316 
     1317  // ASTMGRWRITETIMEOUT 
     1318  $set['value'] = '5000'; 
     1319  $set['name'] = 'Asterisk Manager Write Timeout'; 
     1320  $set['description'] =  
     1321    'Timeout, im ms, for write timeouts for cases where Asterisk disconnects frequently'; 
     1322  $set['readonly'] = 1; 
     1323  $set['type'] = CONF_TYPE_INT; 
     1324  $set['emptyok'] = 1; 
     1325  $set['options'] = array(100,100000); 
     1326  $set['level'] = 2; 
     1327  $freepbx_conf->define_conf_setting('ASTMGRWRITETIMEOUT',$set); 
     1328  $set['level'] = 0; 
    13171329 
    13181330  //