Changeset 10785
- Timestamp:
- 12/30/10 17:46:13 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/bootstrap/amp_conf/htdocs/admin/bootstrap.php
r10737 r10785 1 1 <?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 21 if (!isset($bootstrap_settings['skip_db'])) { 22 $bootstrap_settings['skip_db'] = isset($skip_db) ? $skip_db : false; 23 } 24 if (!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 2 39 //enable error reporting and start benchmarking 3 40 error_reporting(1); … … 9 46 10 47 //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); 48 if ($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 } 12 52 13 53 //include database conifguration … … 17 57 18 58 // connect to database 19 if ( isset($skip_db) || !$skip_db) {59 if (!$bootstrap_settings['skip_db']) { 20 60 require_once(dirname(__FILE__) . '/common/db_connect.php'); //PEAR must be installed 21 61 //keep old values as well so that we have the db settings handy … … 30 70 } 31 71 32 if (! isset($skip_astman) || !$skip_astman) {72 if (!$bootstrap_settings['skip_astman']) { 33 73 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']); 36 75 // 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'])) { 38 77 // 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'])) { 40 79 // couldn't connect at all 41 80 unset( $astman ); … … 46 85 //include gui functions + auth if nesesarry 47 86 //TODO: PHP4 returns 'cgi', this needs to be addressed so it works properly -PL 48 if (php_sapi_name() == 'cli' ) {87 if (php_sapi_name() == 'cli' || !$bootstrap_settings['freepbx_auth']) { 49 88 if (!defined('FREEPBX_IS_AUTH')) { 50 89 define('FREEPBX_IS_AUTH', 'TRUE'); … … 64 103 //echo '<pre>';print_r($active_modules[$key]['changelog']);echo '</pre>'; 65 104 //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 } 79 109 80 110 //create an array of module sections to display … … 99 129 } 100 130 } 101 102 131 ?>
