Show
Ignore:
Timestamp:
11/13/10 18:47:36 (3 years ago)
Author:
mbrevda
Message:

re #4566; move amportal.conf settings to a module - Thanks mickecarlsson! closes #4469, #3561, #3571, #3572, #3573, #3547, #3576. untill we get a proper migration in place, please add your db values to /etc/environment, see common/db_connect.php for the varibles that need to be set

Files:

Legend:

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

    r10122 r10558  
    1616displayconnects=no ;only effects 1.6+ 
    1717 
    18 [AMPMGRUSER
    19 secret = AMPMGRPASS 
     18[admin
     19secret = amp111 
    2020deny=0.0.0.0/0.0.0.0 
    2121permit=127.0.0.1/255.255.255.0 
  • freepbx/branches/bootstrap/amp_conf/htdocs/admin/bootstrap.php

    r10556 r10558  
    11<?php 
    22error_reporting(1); 
     3function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 
     4$benchmark_starttime = microtime_float(); 
    35//require_once(getenv('FREEPBX_BOOTSTRAP') ? getenv('FREEPBX_BOOTSTRAP') : '/var/www/html/admin/bootstrap.php'); 
    4  
     6// connect to database 
     7require_once('common/db_connect.php'); //PEAR must be installed 
    58// include base functions 
    69require_once('functions.inc.php'); 
     10 
     11if (isset($amp_conf['php_error_reporting'])) { 
     12  error_reporting($amp_conf['php_error_reporting']); 
     13} 
    714 
    815// get settings 
     
    1017$asterisk_conf  = parse_asterisk_conf($amp_conf["ASTETCDIR"]."/asterisk.conf"); 
    1118if (!isset($skip_astman) || !$skip_astman) { 
    12   require_once('common/php-asmanager.php'); 
     19  require_once('libraries/php-asmanager.php'); 
    1320  $astman = new AGI_AsteriskManager(); 
    1421  // attempt to connect to asterisk manager proxy 
     
    2229} 
    2330 
    24 // connect to database 
    25 require_once('common/db_connect.php'); //PEAR must be installed 
    26  
    27 if ($amp_conf['DEVEL']) { 
    28   // benchmark 
    29   function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 
    30   $benchmark_starttime = microtime_float(); 
    31 } 
    3231 
    3332$active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); 
  • freepbx/branches/bootstrap/amp_conf/htdocs/admin/common/db_connect.php

    r6816 r10558  
    1414require_once('DB.php'); //PEAR must be installed 
    1515 
    16 $db_engine = $amp_conf["AMPDBENGINE"]
     16$db_engine = getenv('FREEPBX_DB_ENGINE') ? getenv('FREEPBX_DB_ENGINE') : 'mysql'
    1717 
    18 switch ($db_engine) 
    19 
     18switch ($db_engine) { 
    2019  case "pgsql": 
    2120  case "mysql": 
     
    2322    dbengine://username:password@host/database */ 
    2423     
    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'
    2928     
    30     $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
     29    $datasource = 'mysql://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
    3130    $db = DB::connect($datasource); // attempt connection 
    3231    break;   
     
    3736 
    3837  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   
    4539    /* on centos this extension is not loaded by default */ 
    4640    if (! extension_loaded('sqlite3') && ! extension_loaded('SQLITE3')) 
     
    5145      die_freepbx("Your PHP installation has no PEAR/SQLite3 support. Please install php-sqlite3 and php-pear."); 
    5246    } 
    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"; 
    5550                $options = array( 
    5651                    'debug'       => 4, 
    57       'portability' => DB_PORTABILITY_NUMROWS 
     52         'portability' => DB_PORTABILITY_NUMROWS 
    5853    ); 
    5954    $db = DB::connect($datasource, $options); 
     
    6964  die_freepbx($db->getMessage());  
    7065} 
    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 system 
    84   // 
    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 not 
    98   // 
    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  
    11<?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*/ 
    2714 
    2815$type = isset($_REQUEST['type'])?$_REQUEST['type']:'setup'; 
     
    7360// handle special requests 
    7461if (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   
    14567if (!$quietmode) { 
    14668  module_run_notification_checks(); 
  • freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/config.functions.php

    r10557 r10558  
    6262 
    6363function parse_amportal_conf($filename) { 
    64   global $amp_conf_defaults
     64  global $amp_conf_defaults, $db
    6565 
    6666  /* defaults 
     
    6969   *  
    7070   */ 
    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 
    8275  // set defaults 
    8376  foreach ($amp_conf_defaults as $key=>$arr) { 
  • freepbx/branches/bootstrap/amp_conf/htdocs/admin/libraries/framework_view.functions.php

    r10447 r10558  
    9696  } else { 
    9797    $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'); 
    98126  } 
    99127} 
  • freepbx/branches/bootstrap/amp_conf/htdocs/admin/views/freepbx_admin.php

    r10285 r10558  
    66<!-- begin menu --> 
    77<?php 
     8 
     9// This is ugly, but it is the only way I can think of to get the menu sections localized. MC 
     10if (false) { 
     11_("Internal Options & Configuration"); 
     12_("Inbound Call Control"); 
     13_("Module Admin"); 
     14_("System Administration"); 
     15_("Third Party Addon"); 
     16} 
     17 
     18 
    819global $amp_conf; 
    920$fd = $amp_conf['ASTETCDIR'].'/freepbx_menu.conf';