| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
error_reporting(E_ALL & ~E_STRICT); |
|---|
| 49 |
date_default_timezone_set(@date_default_timezone_get()); |
|---|
| 50 |
function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } |
|---|
| 51 |
$benchmark_starttime = microtime_float(); |
|---|
| 52 |
|
|---|
| 53 |
global $amp_conf; |
|---|
| 54 |
if (empty($amp_conf['AMPWEBROOT'])) { |
|---|
| 55 |
$amp_conf['AMPWEBROOT'] = dirname(dirname(__FILE__)); |
|---|
| 56 |
} |
|---|
| 57 |
$dirname = $amp_conf['AMPWEBROOT'] . '/admin'; |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
if (isset($bootstrap_settings['bootstrapped'])) { |
|---|
| 61 |
freepbx_log(FPBX_LOG_ERROR,"Bootstrap has already been called once, bad code somewhere"); |
|---|
| 62 |
return; |
|---|
| 63 |
} else { |
|---|
| 64 |
$bootstrap_settings['bootstrapped'] = true; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
if (!isset($bootstrap_settings['skip_astman'])) { |
|---|
| 68 |
$bootstrap_settings['skip_astman'] = isset($skip_astman) ? $skip_astman : false; |
|---|
| 69 |
} |
|---|
| 70 |
$bootstrap_settings['astman_config'] = isset($bootstrap_settings['astman_config']) ? $bootstrap_settings['astman_config'] : null; |
|---|
| 71 |
$bootstrap_settings['astman_options'] = isset($bootstrap_settings['astman_options']) && is_array($bootstrap_settings['astman_options']) ? $bootstrap_settings['astman_options'] : array(); |
|---|
| 72 |
$bootstrap_settings['astman_events'] = isset($bootstrap_settings['astman_events']) ? $bootstrap_settings['astman_events'] : 'off'; |
|---|
| 73 |
|
|---|
| 74 |
$bootstrap_settings['freepbx_error_handler'] = isset($bootstrap_settings['freepbx_error_handler']) ? $bootstrap_settings['freepbx_error_handler'] : true; |
|---|
| 75 |
$bootstrap_settings['freepbx_auth'] = isset($bootstrap_settings['freepbx_auth']) ? $bootstrap_settings['freepbx_auth'] : true; |
|---|
| 76 |
$bootstrap_settings['cdrdb'] = isset($bootstrap_settings['cdrdb']) ? $bootstrap_settings['cdrdb'] : false; |
|---|
| 77 |
|
|---|
| 78 |
$restrict_mods = isset($restrict_mods) ? $restrict_mods : false; |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
require_once($dirname . '/libraries/utility.functions.php'); |
|---|
| 83 |
$bootstrap_settings['framework_functions_included'] = false; |
|---|
| 84 |
require_once($dirname . '/functions.inc.php'); |
|---|
| 85 |
$bootstrap_settings['framework_functions_included'] = true; |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
if ($bootstrap_settings['freepbx_error_handler']) { |
|---|
| 89 |
$error_handler = $bootstrap_settings['freepbx_error_handler'] === true ? 'freepbx_error_handler' : $bootstrap_settings['freepbx_error_handler']; |
|---|
| 90 |
if (function_exists($error_handler)) { |
|---|
| 91 |
set_error_handler($error_handler, E_ALL & ~E_STRICT); |
|---|
| 92 |
} |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
require_once($dirname . '/libraries/db_connect.php'); |
|---|
| 99 |
|
|---|
| 100 |
// get settings |
|---|
| 101 |
$freepbx_conf =& freepbx_conf::create(); |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
$bootstrap_settings['amportal_conf_initialized'] = false; |
|---|
| 107 |
$amp_conf =& $freepbx_conf->parse_amportal_conf("/etc/amportal.conf",$amp_conf); |
|---|
| 108 |
$asterisk_conf =& $freepbx_conf->get_asterisk_conf(); |
|---|
| 109 |
$bootstrap_settings['amportal_conf_initialized'] = true; |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
if ($bootstrap_settings['cdrdb']) { |
|---|
| 113 |
$dsn = array( |
|---|
| 114 |
'phptype' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : $amp_conf['AMPDBENGINE'], |
|---|
| 115 |
'hostspec' => $amp_conf['CDRDBHOST'] ? $amp_conf['CDRDBHOST'] : $amp_conf['AMPDBHOST'], |
|---|
| 116 |
'username' => $amp_conf['CDRDBUSER'] ? $amp_conf['CDRDBUSER'] : $amp_conf['AMPDBUSER'], |
|---|
| 117 |
'password' => $amp_conf['CDRDBPASS'] ? $amp_conf['CDRDBPASS'] : $amp_conf['AMPDBPASS'], |
|---|
| 118 |
'port' => $amp_conf['CDRDBPORT'] ? $amp_conf['CDRDBPORT'] : '3306', |
|---|
| 119 |
|
|---|
| 120 |
'database' => $amp_conf['CDRDBNAME'] ? $amp_conf['CDRDBNAME'] : 'asteriskcdrdb', |
|---|
| 121 |
); |
|---|
| 122 |
$cdrdb = DB::connect($dsn); |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
$bootstrap_settings['astman_connected'] = false; |
|---|
| 126 |
if (!$bootstrap_settings['skip_astman']) { |
|---|
| 127 |
require_once($dirname . '/libraries/php-asmanager.php'); |
|---|
| 128 |
$astman = new AGI_AsteriskManager($bootstrap_settings['astman_config'], $bootstrap_settings['astman_options']); |
|---|
| 129 |
|
|---|
| 130 |
if (!$amp_conf["ASTMANAGERPROXYPORT"] || !$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events'])) { |
|---|
| 131 |
|
|---|
| 132 |
if (!$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events'])) { |
|---|
| 133 |
|
|---|
| 134 |
unset( $astman ); |
|---|
| 135 |
freepbx_log(FPBX_LOG_CRITICAL,"Connection attmempt to AMI failed"); |
|---|
| 136 |
} else { |
|---|
| 137 |
$bootstrap_settings['astman_connected'] = true; |
|---|
| 138 |
} |
|---|
| 139 |
} |
|---|
| 140 |
} else { |
|---|
| 141 |
$bootstrap_settings['astman_connected'] = true; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
if (!$bootstrap_settings['freepbx_auth'] || (php_sapi_name() == 'cli')) { |
|---|
| 151 |
if (!defined('FREEPBX_IS_AUTH')) { |
|---|
| 152 |
define('FREEPBX_IS_AUTH', 'TRUE'); |
|---|
| 153 |
} |
|---|
| 154 |
} else { |
|---|
| 155 |
require($dirname . '/libraries/gui_auth.php'); |
|---|
| 156 |
frameworkPasswordCheck(); |
|---|
| 157 |
} |
|---|
| 158 |
if (!isset($no_auth) && !defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } |
|---|
| 159 |
|
|---|
| 160 |
$restrict_mods_local = $restrict_mods; |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
if ($restrict_mods_local !== true && !isset($no_auth)) { |
|---|
| 165 |
$active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); |
|---|
| 166 |
|
|---|
| 167 |
if(is_array($active_modules)){ |
|---|
| 168 |
|
|---|
| 169 |
$force_autoload = false; |
|---|
| 170 |
foreach($active_modules as $key => $module) { |
|---|
| 171 |
|
|---|
| 172 |
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")) { |
|---|
| 173 |
require_once($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php"); |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
// we will include all the potential classes at this point. |
|---|
| 177 |
// |
|---|
| 178 |
if (!$force_autoload && isset($module['depends']['phpcomponent']) && stristr($module['depends']['phpcomponent'], 'zend')) { |
|---|
| 179 |
fpbx_framework_autoloader(true); |
|---|
| 180 |
$force_autoload = true; |
|---|
| 181 |
} |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
// stored as [items][$type][$category][$name] = $displayvalue |
|---|
| 185 |
if (isset($module['items']) && is_array($module['items'])) { |
|---|
| 186 |
|
|---|
| 187 |
foreach($module['items'] as $itemKey => $item) { |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
if (!isset($astman) || !$astman) { |
|---|
| 191 |
if (( isset($item['needsenginedb']) && strtolower($item['needsenginedb']) == 'yes') |
|---|
| 192 |
|| (isset($item['needsenginerunning']) && strtolower($item['needsenginerunning']) == 'yes')) { |
|---|
| 193 |
$active_modules[$key]['items'][$itemKey]['disabled'] = true; |
|---|
| 194 |
} |
|---|
| 195 |
} |
|---|
| 196 |
} |
|---|
| 197 |
} |
|---|
| 198 |
} |
|---|
| 199 |
$bootstrap_settings['function_modules_included'] = true; |
|---|
| 200 |
} |
|---|
| 201 |
} else { |
|---|
| 202 |
$bootstrap_settings['function_modules_included'] = false; |
|---|
| 203 |
} |
|---|
| 204 |
?> |
|---|
| 205 |
|
|---|