Changeset 10558 for freepbx/branches/bootstrap
- Timestamp:
- 11/13/10 18:47:36 (3 years ago)
- Files:
-
- freepbx/branches/bootstrap/amp_conf/astetc/manager.conf (modified) (1 diff)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/bootstrap.php (modified) (3 diffs)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/common/db_connect.php (modified) (5 diffs)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/common/php-asmanager.php (deleted)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/config.php (modified) (2 diffs)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/config.functions.php (modified) (2 diffs)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/framework_view.functions.php (modified) (1 diff)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/php-asmanager.php (added)
- freepbx/branches/bootstrap/amp_conf/htdocs/admin/views/freepbx_admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/bootstrap/amp_conf/astetc/manager.conf
r10122 r10558 16 16 displayconnects=no ;only effects 1.6+ 17 17 18 [ AMPMGRUSER]19 secret = AMPMGRPASS18 [admin] 19 secret = amp111 20 20 deny=0.0.0.0/0.0.0.0 21 21 permit=127.0.0.1/255.255.255.0 freepbx/branches/bootstrap/amp_conf/htdocs/admin/bootstrap.php
r10556 r10558 1 1 <?php 2 2 error_reporting(1); 3 function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 4 $benchmark_starttime = microtime_float(); 3 5 //require_once(getenv('FREEPBX_BOOTSTRAP') ? getenv('FREEPBX_BOOTSTRAP') : '/var/www/html/admin/bootstrap.php'); 4 6 // connect to database 7 require_once('common/db_connect.php'); //PEAR must be installed 5 8 // include base functions 6 9 require_once('functions.inc.php'); 10 11 if (isset($amp_conf['php_error_reporting'])) { 12 error_reporting($amp_conf['php_error_reporting']); 13 } 7 14 8 15 // get settings … … 10 17 $asterisk_conf = parse_asterisk_conf($amp_conf["ASTETCDIR"]."/asterisk.conf"); 11 18 if (!isset($skip_astman) || !$skip_astman) { 12 require_once(' common/php-asmanager.php');19 require_once('libraries/php-asmanager.php'); 13 20 $astman = new AGI_AsteriskManager(); 14 21 // attempt to connect to asterisk manager proxy … … 22 29 } 23 30 24 // connect to database25 require_once('common/db_connect.php'); //PEAR must be installed26 27 if ($amp_conf['DEVEL']) {28 // benchmark29 function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); }30 $benchmark_starttime = microtime_float();31 }32 31 33 32 $active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); freepbx/branches/bootstrap/amp_conf/htdocs/admin/common/db_connect.php
r6816 r10558 14 14 require_once('DB.php'); //PEAR must be installed 15 15 16 $db_engine = $amp_conf["AMPDBENGINE"];16 $db_engine = getenv('FREEPBX_DB_ENGINE') ? getenv('FREEPBX_DB_ENGINE') : 'mysql'; 17 17 18 switch ($db_engine) 19 { 18 switch ($db_engine) { 20 19 case "pgsql": 21 20 case "mysql": … … 23 22 dbengine://username:password@host/database */ 24 23 25 $db_user = $amp_conf["AMPDBUSER"];26 $db_pass = $amp_conf["AMPDBPASS"];27 $db_host = $amp_conf["AMPDBHOST"];28 $db_name = $amp_conf["AMPDBNAME"];24 $db_user = getenv('FREEPBX_DB_USER') ? getenv('FREEPBX_DB_USER') : 'freepbx'; 25 $db_pass = getenv('FREEPBX_DB_PASS') ? getenv('FREEPBX_DB_PASS') : 'fpbx'; 26 $db_host = getenv('FREEPBX_DB_HOST') ? getenv('FREEPBX_DB_HOST') : 'localhost'; 27 $db_name = getenv('FREEPBX_DB_NAME') ? getenv('FREEPBX_DB_NAME') : 'asterisk'; 29 28 30 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name;29 $datasource = 'mysql://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 31 30 $db = DB::connect($datasource); // attempt connection 32 31 break; … … 37 36 38 37 case "sqlite3": 39 if (!isset($amp_conf["AMPDBFILE"])) 40 die_freepbx("You must setup properly AMPDBFILE in /etc/amportal.conf"); 41 42 if (isset($amp_conf["AMPDBFILE"]) == "") 43 die_freepbx("AMPDBFILE in /etc/amportal.conf cannot be blank"); 44 38 45 39 /* on centos this extension is not loaded by default */ 46 40 if (! extension_loaded('sqlite3') && ! extension_loaded('SQLITE3')) … … 51 45 die_freepbx("Your PHP installation has no PEAR/SQLite3 support. Please install php-sqlite3 and php-pear."); 52 46 } 53 54 $datasource = "sqlite3:///" . $amp_conf["AMPDBFILE"] . "?mode=0666"; 47 48 $datasource = getenv('FREEPBX_DB_FILE') ? getenv('FREEPBX_DB_FILE') : ''; 49 $datasource = "sqlite3:///" . $datasource . "?mode=0666"; 55 50 $options = array( 56 51 'debug' => 4, 57 'portability' => DB_PORTABILITY_NUMROWS52 'portability' => DB_PORTABILITY_NUMROWS 58 53 ); 59 54 $db = DB::connect($datasource, $options); … … 69 64 die_freepbx($db->getMessage()); 70 65 } 71 72 // Now send or delete warning wrt to default passwords:73 //74 if (!isset($quietmode) || !$quietmode) {75 $nt = notifications::create($db);76 77 if ($amp_conf['AMPDBPASS'] == $amp_conf_defaults['AMPDBPASS'][1]) {78 $nt->add_warning('core', 'AMPDBPASS', _("Default SQL Password Used"), _("You are using the default SQL password that is widely known, you should set a secure password"));79 } else {80 $nt->delete('core', 'AMPDBPASS');81 }82 83 // Check and increase php memory_limit if needed and if allowed on the system84 //85 $current_memory_limit = rtrim(ini_get('memory_limit'),'M');86 $proper_memory_limit = '100';87 if ($current_memory_limit < $proper_memory_limit) {88 if (ini_set('memory_limit',$proper_memory_limit.'M') !== false) {89 $nt->add_notice('core', 'MEMLIMIT', _("Memory Limit Changed"), sprintf(_("Your memory_limit, %sM, is set too low and has been increased to %sM. You may want to change this in you php.ini config file"),$current_memory_limit,$proper_memory_limit));90 } else {91 $nt->add_warning('core', 'MEMERR', _("Low Memory Limit"), sprintf(_("Your memory_limit, %sM, is set too low and may cause problems. FreePBX is not able to change this on your system. You should increase this to %sM in you php.ini config file"),$current_memory_limit,$proper_memory_limit));92 }93 } else {94 $nt->delete('core', 'MEMLIMIT');95 }96 97 // send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not98 //99 if(get_magic_quotes_gpc()) {100 $nt->add_error('core', 'MQGPC', _("Magic Quotes GPC"), _("You have magic_quotes_gpc enabled in your php.ini, http or .htaccess file which will cause errors in some modules. FreePBX expects this to be off and runs under that assumption"));101 } else {102 $nt->delete('core', 'MQGPC');103 }104 }freepbx/branches/bootstrap/amp_conf/htdocs/admin/config.php
r10556 r10558 1 1 <?php /* $Id$ */ 2 //Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) 3 // 4 //This program is free software; you can redistribute it and/or 5 //modify it under the terms of the GNU General Public License 6 //as published by the Free Software Foundation; either version 2 7 //of the License, or (at your option) any later version. 8 // 9 //This program is distributed in the hope that it will be useful, 10 //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 //GNU General Public License for more details. 13 14 // This is ugly, but it is the only way I can think of to get the menu sections localized. MC 15 if (false) { 16 _("Internal Options & Configuration"); 17 _("Inbound Call Control"); 18 _("Module Admin"); 19 _("System Administration"); 20 _("Third Party Addon"); 21 } 22 23 /* benchmark */ 24 function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 25 $benchmark_starttime = microtime_float(); 26 /*************/ 2 /* 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 27 14 28 15 $type = isset($_REQUEST['type'])?$_REQUEST['type']:'setup'; … … 73 60 // handle special requests 74 61 if (isset($_REQUEST['handler'])) { 75 switch ($_REQUEST['handler']) { 76 case 'cdr': 77 include('cdr/cdr.php'); 78 break; 79 case 'cdr_export_csv': 80 include('cdr/export_csv.php'); 81 break; 82 case 'cdr_export_pdf': 83 include('cdr/export_pdf.php'); 84 break; 85 case 'reload': 86 /** AJAX handler for reload event 87 */ 88 include_once('common/json.inc.php'); 89 $response = do_reload(); 90 $json = new Services_JSON(); 91 header("Content-type: application/json"); 92 echo $json->encode($response); 93 break; 94 case 'file': 95 /** Handler to pass-through file requests 96 * Looks for "module" and "file" variables, strips .. and only allows normal filename characters. 97 * Accepts only files of the type listed in $allowed_exts below, and sends the corresponding mime-type, 98 * and always interprets files through the PHP interpreter. (Most of?) the FreePBX environment is available, 99 * including $db and $astman, and the user is authenticated. 100 */ 101 if (!isset($_REQUEST['module']) || !isset($_REQUEST['file'])) { 102 die_freepbx("unknown"); 103 } 104 //TODO: this could probably be more efficient 105 $module = str_replace('..','.', preg_replace('/[^a-zA-Z0-9-\_\.]/','',$_REQUEST['module'])); 106 $file = str_replace('..','.', preg_replace('/[^a-zA-Z0-9-\_\.]/','',$_REQUEST['file'])); 107 108 $allowed_exts = array( 109 '.js' => 'text/javascript', 110 '.js.php' => 'text/javascript', 111 '.css' => 'text/css', 112 '.css.php' => 'text/css', 113 '.html.php' => 'text/html', 114 '.jpg.php' => 'image/jpeg', 115 '.jpeg.php' => 'image/jpeg', 116 '.png.php' => 'image/png', 117 '.gif.php' => 'image/gif', 118 ); 119 foreach ($allowed_exts as $ext=>$mimetype) { 120 if (substr($file, -1*strlen($ext)) == $ext) { 121 $fullpath = 'modules/'.$module.'/'.$file; 122 if (file_exists($fullpath)) { 123 // file exists, and is allowed extension 124 125 // image, css, js types - set Expires to an hour in advance so the client does 126 // not keep checking for them. Replace from header.php 127 if (!$amp_conf['DEVEL']) { 128 @header('Expires: '.gmdate('D, d M Y H:i:s', time()+3600).' GMT', true); 129 @header('Cache-Control: ',true); 130 @header('Pragma: ', true); 131 } 132 @header("Content-type: ".$mimetype); 133 include($fullpath); 134 exit(); 135 } 136 break; 137 } 138 } 139 die_freepbx("not allowed"); 140 break; 141 } 142 exit(); 143 } 144 62 $module = isset($_REQUEST['module']) ? $_REQUEST['module'] : ''; 63 $file = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; 64 fileRequestHandler($_REQUEST['handler'], $module, $file); 65 } 66 145 67 if (!$quietmode) { 146 68 module_run_notification_checks(); freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/config.functions.php
r10557 r10558 62 62 63 63 function parse_amportal_conf($filename) { 64 global $amp_conf_defaults ;64 global $amp_conf_defaults, $db; 65 65 66 66 /* defaults … … 69 69 * 70 70 */ 71 $file = file($filename); 72 if (is_array($file)) { 73 foreach ($file as $line) { 74 if (preg_match("/^\s*([a-zA-Z0-9_]+)=([a-zA-Z0-9 .&-@=_!<>\"\']+)\s*$/",$line,$matches)) { 75 $conf[ $matches[1] ] = $matches[2]; 76 } 77 } 78 } else { 79 die_freepbx("<h1>".sprintf(_("Missing or unreadable config file (%s)...cannot continue"), $filename)."</h1>"); 80 } 81 71 72 $sql = 'SELECT `key`, value FROM freepbx_settings'; 73 $conf = $db->getAssoc($sql); 74 82 75 // set defaults 83 76 foreach ($amp_conf_defaults as $key=>$arr) { freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/framework_view.functions.php
r10447 r10558 96 96 } else { 97 97 $nt->delete('ari', 'ARI_ADMIN_PASSWORD'); 98 } 99 100 if ($amp_conf['AMPDBPASS'] == $amp_conf_defaults['AMPDBPASS'][1]) { 101 $nt->add_warning('core', 'AMPDBPASS', _("Default SQL Password Used"), _("You are using the default SQL password that is widely known, you should set a secure password")); 102 } else { 103 $nt->delete('core', 'AMPDBPASS'); 104 } 105 106 // Check and increase php memory_limit if needed and if allowed on the system 107 // 108 $current_memory_limit = rtrim(ini_get('memory_limit'),'M'); 109 $proper_memory_limit = '100'; 110 if ($current_memory_limit < $proper_memory_limit) { 111 if (ini_set('memory_limit',$proper_memory_limit.'M') !== false) { 112 $nt->add_notice('core', 'MEMLIMIT', _("Memory Limit Changed"), sprintf(_("Your memory_limit, %sM, is set too low and has been increased to %sM. You may want to change this in you php.ini config file"),$current_memory_limit,$proper_memory_limit)); 113 } else { 114 $nt->add_warning('core', 'MEMERR', _("Low Memory Limit"), sprintf(_("Your memory_limit, %sM, is set too low and may cause problems. FreePBX is not able to change this on your system. You should increase this to %sM in you php.ini config file"),$current_memory_limit,$proper_memory_limit)); 115 } 116 } else { 117 $nt->delete('core', 'MEMLIMIT'); 118 } 119 120 // send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not 121 // 122 if(get_magic_quotes_gpc()) { 123 $nt->add_error('core', 'MQGPC', _("Magic Quotes GPC"), _("You have magic_quotes_gpc enabled in your php.ini, http or .htaccess file which will cause errors in some modules. FreePBX expects this to be off and runs under that assumption")); 124 } else { 125 $nt->delete('core', 'MQGPC'); 98 126 } 99 127 } freepbx/branches/bootstrap/amp_conf/htdocs/admin/views/freepbx_admin.php
r10285 r10558 6 6 <!-- begin menu --> 7 7 <?php 8 9 // This is ugly, but it is the only way I can think of to get the menu sections localized. MC 10 if (false) { 11 _("Internal Options & Configuration"); 12 _("Inbound Call Control"); 13 _("Module Admin"); 14 _("System Administration"); 15 _("Third Party Addon"); 16 } 17 18 8 19 global $amp_conf; 9 20 $fd = $amp_conf['ASTETCDIR'].'/freepbx_menu.conf';
