Changeset 10785

Show
Ignore:
Timestamp:
12/30/10 17:46:13 (2 years ago)
Author:
p_lindheimer
Message:

adds standardized bootstrap_settings array but still retains the past globals for compatibility

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/bootstrap/amp_conf/htdocs/admin/bootstrap.php

    r10737 r10785  
    11<?php 
     2/* Bootstrap Settings: 
     3 * 
     4 * bootstrap_settings['skip_db']               - legacy $skip_db, default false 
     5 * bootstrap_settings['skip_astman']           - legacy $skip_astman, default false 
     6 * 
     7 * bootstrap_settings['astman_config']         - default null, config arguemnt when creating new Astman 
     8 * bootstrap_settings['astman_options']        - default array(), config options creating new Astman 
     9 *                                               e.g. array('cachemode' => true), see astman documentation 
     10 * bootstrap_settings['astman_events']         - default 'off' used when connecting, Astman defaults to 'on' 
     11 * 
     12 * bootstrap_settings['freepbx_error_handler'] - false don't set it, true use default, named use what is passed 
     13 * 
     14 * bootstrap_settings['freepbx_auth']          - true (default) - authorize, false - bypass authentication 
     15 * 
     16 * $restrict_mods: false means include all modules functions.inc.php 
     17 *                 array of hashes means each module where there is a hash 
     18 *                 e.g. ($restrict_mods = array('core' => true, 'dashboard' => true) 
     19 */ 
     20 
     21if (!isset($bootstrap_settings['skip_db'])) { 
     22  $bootstrap_settings['skip_db'] = isset($skip_db) ? $skip_db : false; 
     23} 
     24if (!isset($bootstrap_settings['skip_astman'])) { 
     25  $bootstrap_settings['skip_astman'] = isset($skip_astman) ? $skip_astman : false; 
     26} 
     27$bootstrap_settings['astman_config'] = isset($bootstrap_settings['astman_config']) ? $bootstrap_settings['astman_config'] : null; 
     28$bootstrap_settings['astman_options'] = isset($bootstrap_settings['astman_options']) && is_array($bootstrap_settings['astman_options']) ? $bootstrap_settings['astman_options'] : array(); 
     29$bootstrap_settings['astman_events'] = isset($bootstrap_settings['astman_events']) ? $bootstrap_settings['astman_events'] : 'off'; 
     30 
     31$bootstrap_settings['freepbx_error_handler'] = isset($bootstrap_settings['freepbx_error_handler']) ? $bootstrap_settings['freepbx_error_handler'] : true; 
     32$bootstrap_settings['freepbx_auth'] = isset($bootstrap_settings['freepbx_auth']) ? $bootstrap_settings['freepbx_auth'] : true; 
     33 
     34 
     35$restrict_mods = isset($restrict_mods) ? $restrict_mods : false; 
     36 
     37 
     38 
    239//enable error reporting and start benchmarking 
    340error_reporting(1); 
     
    946 
    1047//now that its been included, use our own error handler as it tends to be much more verbose. 
    11 set_error_handler('freepbx_error_handler', E_ALL & ~E_STRICT); 
     48if ($bootstrap_settings['freepbx_error_handler']) { 
     49  $error_handler = $bootstrap_settings['freepbx_error_handler'] === true ? 'freepbx_error_handler' : $bootstrap_settings['freepbx_error_handler']; 
     50  set_error_handler($error_handler, E_ALL & ~E_STRICT); 
     51
    1252 
    1353//include database conifguration 
     
    1757 
    1858// connect to database 
    19 if (isset($skip_db) || !$skip_db) { 
     59if (!$bootstrap_settings['skip_db']) { 
    2060  require_once(dirname(__FILE__) . '/common/db_connect.php'); //PEAR must be installed 
    2161  //keep old values as well so that we have the db settings handy 
     
    3070} 
    3171 
    32 if (!isset($skip_astman) || !$skip_astman) { 
     72if (!$bootstrap_settings['skip_astman']) { 
    3373  require_once(dirname(__FILE__) . '/libraries/php-asmanager.php'); 
    34   $astman = new AGI_AsteriskManager(); 
    35   $amp_conf['ASTMANAGEREVENTS'] = (isset($amp_conf['ASTMANAGEREVENTS']) && $amp_conf['ASTMANAGEREVENTS']) ? $amp_conf['ASTMANAGEREVENTS'] : 'off'; 
     74  $astman = new AGI_AsteriskManager($bootstrap_settings['astman_config'], $bootstrap_settings['astman_options']); 
    3675  // attempt to connect to asterisk manager proxy 
    37   if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
     76  if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events'])) { 
    3877    // attempt to connect directly to asterisk, if no proxy or if proxy failed 
    39     if (!$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $amp_conf['ASTMANAGEREVENTS'])) { 
     78    if (!$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events'])) { 
    4079      // couldn't connect at all 
    4180      unset( $astman ); 
     
    4685//include gui functions + auth if nesesarry 
    4786//TODO: PHP4 returns 'cgi', this needs to be addressed so it works properly -PL 
    48 if (php_sapi_name() == 'cli') { 
     87if (php_sapi_name() == 'cli' || !$bootstrap_settings['freepbx_auth']) { 
    4988  if (!defined('FREEPBX_IS_AUTH')) { 
    5089    define('FREEPBX_IS_AUTH', 'TRUE'); 
     
    64103    //echo '<pre>';print_r($active_modules[$key]['changelog']);echo '</pre>'; 
    65104    //include module functions if there not dissabled 
    66     //TODO: dont include files when there is a good reason not to. Idea: set $restrict_mods to <dont include any modules> 
    67     //if $_REQUEST['handler'] is set 
    68     if (isset($restrict_mods)) { 
    69       if ((!$restrict_mods || isset($restrict_mods[$key])) && is_file($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php")  
    70       ) { 
    71         require_once($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php"); 
    72       }  
    73     } else { 
    74       if(is_file($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php")) { 
    75         //echo 'including module '.$key."\n <br />"; 
    76         require_once($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php"); 
    77       } 
    78     } 
     105 
     106    if ((!$restrict_mods || isset($restrict_mods[$key])) && is_file($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php")) { 
     107      require_once($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php"); 
     108    }  
    79109     
    80110    //create an array of module sections to display 
     
    99129  } 
    100130} 
    101  
    102131?>