Changeset 10865 for freepbx/trunk

Show
Ignore:
Timestamp:
01/09/11 12:01:44 (2 years ago)
Author:
p_lindheimer
Message:

merge bootstrap branch back to trunk (fingers crossed) re #4566

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk

    • Property svnmerge-integrated changed from /freepbx/branches/bootstrap:1-10361,10536-10545,10548-10555,10557,10561,10563-10617,10619-10621,10623-10635,10637-10638,10640-10642,10644-10645,10647-10650,10655-10670,10672-10677,10679-10703,10705-10715,10718-10725,10728,10780 /freepbx/branches/2.8:1-10634 to /freepbx/branches/bootstrap:1-10446,10448-10638,10640-10847 /freepbx/branches/2.8:1-10634
  • freepbx/trunk/amp_conf/agi-bin/phpagi.php

    r8648 r10865  
    180180        global $phpagi_error_handler_email; 
    181181        $phpagi_error_handler_email = $this->config['phpagi']['admin']; 
    182         error_reporting(E_ALL); 
     182//        error_reporting(E_ALL); 
    183183      } 
    184184 
  • freepbx/trunk/amp_conf/bin/archive_recordings

    r10635 r10865  
    11#!/usr/bin/php -q 
    22<?php 
    3  
    4 define("AMP_CONF", "/etc/amportal.conf"); 
     3//include bootstrap 
     4$bootstrap_settings['freepbx_auth'] = false; 
     5if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     6  include_once('/etc/asterisk/freepbx.conf'); 
     7
     8 
    59define("MONITOR_DIR", "/var/spool/asterisk/monitor"); 
    610 
     
    3640  out("  --mp3            Recursively convert all .WAV to .mp3"); 
    3741  out("  --delwav         Use with --mp3 to delete orignal files after converting to .mp3"); 
    38 } 
    39  
    40 function parse_amportal_conf($filename) { 
    41   // defaults, if not specified in the file 
    42   $defaults = array( 
    43     'AMPDBENGINE' => 'mysql', 
    44     'AMPDBNAME' => 'asterisk', 
    45     'AMPENGINE' => 'asterisk', 
    46     'USECATEGORIES' => true, 
    47     'ASTETCDIR' => '/etc/asterisk', 
    48     'CDRDBNAME' => 'asteriskcdrdb', 
    49     ); 
    50   // boolean values, will be converted to true/false 
    51   // "yes", "true", 1 (case-insensitive) will be treated as true, everything else is false 
    52   $booleans = array('USECATEGORIES'); 
    53  
    54   $file = file($filename); 
    55   if (is_array($file)) { 
    56     foreach ($file as $line) { 
    57       if (preg_match("/^\s*([a-zA-Z0-9_]+)=([a-zA-Z0-9 .&-@=_!<>\"\']+)\s*$/",$line,$matches)) { 
    58         $conf[ $matches[1] ] = $matches[2]; 
    59       } 
    60     } 
    61   } else { 
    62     fatal("<h1>Missing or unreadable config file ($filename)...cannot continue</h1>"); 
    63   } 
    64  
    65   // set defaults 
    66   foreach ($defaults as $key=>$val) { 
    67     if (!isset($conf[$key]) || $conf[$key] == '') { 
    68       $conf[$key] = $val; 
    69     } 
    70   } 
    71  
    72   // evaluate boolean values 
    73   foreach ($booleans as $key) { 
    74     $conf[$key] = isset($conf[$key]) && ($conf[$key] === true || strtolower($conf[$key]) == 'true' || $conf[$key] === 1 || $conf[$key] == '1' || strtolower($conf[$key]) == 'yes'); 
    75   } 
    76  
    77   return $conf; 
    7842} 
    7943 
     
    296260/********************************************************************************************************************/ 
    297261 
    298 // **** Make sure we have STDIN etc 
    299  
    300 // from  ben-php dot net at efros dot com   at  php.net/install.unix.commandline 
    301 if (version_compare(phpversion(),'4.3.0','<') || !defined("STDIN")) { 
    302   define('STDIN',fopen("php://stdin","r")); 
    303   define('STDOUT',fopen("php://stdout","r")); 
    304   define('STDERR',fopen("php://stderr","r")); 
    305   register_shutdown_function( create_function( '' , 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;' ) ); 
    306 } 
    307     
    308     
    309 // **** Make sure we have PEAR's DB.php, and include it 
    310  
    311 outn("Checking for PEAR DB.."); 
    312 if (! @ include('DB.php')) { 
    313   out("FAILED"); 
    314   fatal("PEAR must be installed (requires DB.php). Include path: ".ini_get("include_path")); 
    315 } 
    316 out("OK"); 
    317  
    318  
    319262// **** Make sure we have PEAR's GetOpts.php, and include it 
    320263 
     
    380323 
    381324 
    382 // **** read amportal.conf 
    383  
    384 outn("Reading ".AMP_CONF.".."); 
    385 $amp_conf = parse_amportal_conf(AMP_CONF); 
    386 if (count($amp_conf) == 0) { 
    387   fatal("FAILED"); 
    388 } 
    389 out("OK"); 
    390  
    391 // **** Connect to database 
    392 outn("Connecting to database.."); 
    393  
    394  
    395 // note, sqlite3 not supported yet! 
    396 $db_user = $amp_conf["AMPDBUSER"]; 
    397 $db_pass = $amp_conf["AMPDBPASS"]; 
    398 $db_host = $amp_conf["AMPDBHOST"]; 
    399 $db_engine = $amp_conf["AMPDBENGINE"]; 
    400 $db_name = $amp_conf["CDRDBNAME"]; 
    401  
    402 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
    403  
    404 $db = DB::connect($datasource); // attempt connection 
    405  
    406 if(DB::isError($db)) { 
    407   out("FAILED"); 
    408   debug($db->userinfo); 
    409   fatal("Cannot connect to database"); 
    410    
    411 } 
    412 out("OK"); 
    413  
    414325check_table(); 
    415326process_files(); 
  • freepbx/trunk/amp_conf/bin/freepbx-cron-scheduler.php

    r5838 r10865  
    11#!/usr/bin/php -q 
    22<?php 
    3  
    4 define("AMP_CONF", "/etc/amportal.conf"); 
    5 $amportalconf = AMP_CONF; 
    6  
    7 // Emulate gettext extension functions if gettext is not available 
    8 if (!function_exists('_')) { 
    9   function _($str) { 
    10     return $str; 
    11   } 
     3//include bootstrap 
     4$bootstrap_settings['freepbx_auth'] = false; 
     5if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     6  include_once('/etc/asterisk/freepbx.conf'); 
    127} 
    13  
    14 function out($text) { 
    15   //echo $text."\n"; 
    16 } 
    17  
    18 function outn($text) { 
    19   //echo $text; 
    20 } 
    21  
    22 function error($text) { 
    23   echo "[ERROR] ".$text."\n"; 
    24 } 
    25  
    26 function fatal($text, $extended_text="", $type="FATAL") { 
    27   global $db; 
    28  
    29   echo "[$type] ".$text." ".$extended_text."\n"; 
    30  
    31   if(!DB::isError($db)) { 
    32     $nt = notifications::create($db); 
    33     $nt->add_critical('cron_manager', $type, $text, $extended_text); 
    34   } 
    35  
    36   exit(1); 
    37 } 
    38  
    39 function debug($text) { 
    40   global $debug; 
    41    
    42   if ($debug) echo "[DEBUG-preDB] ".$text."\n"; 
    43 } 
    44  
    45 // bootstrap retrieve_conf by getting the AMPWEBROOT since that is currently where the necessary 
    46 // functions.inc.php resides, and then use that parser to properly parse the file and get all 
    47 // the defaults as needed. 
    48 // 
    49 function parse_amportal_conf_bootstrap($filename) { 
    50   $file = file($filename); 
    51   foreach ($file as $line) { 
    52     if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\*\%-]*)\"?\s*([;#].*)?/",$line,$matches)) { 
    53       $conf[ $matches[1] ] = $matches[2]; 
    54     } 
    55   } 
    56   if ( !isset($conf["AMPWEBROOT"]) || ($conf["AMPWEBROOT"] == "")) { 
    57     $conf["AMPWEBROOT"] = "/var/www/html"; 
    58   } else { 
    59     $conf["AMPWEBROOT"] = rtrim($conf["AMPWEBROOT"],'/'); 
    60   } 
    61  
    62   return $conf; 
    63 } 
    64  
    65 /********************************************************************************************************************/ 
    66  
    67 // **** Make sure we have STDIN etc 
    68  
    69 // from  ben-php dot net at efros dot com   at  php.net/install.unix.commandline 
    70 if (version_compare(phpversion(),'4.3.0','<') || !defined("STDIN")) { 
    71   define('STDIN',fopen("php://stdin","r")); 
    72   define('STDOUT',fopen("php://stdout","r")); 
    73   define('STDERR',fopen("php://stderr","r")); 
    74   register_shutdown_function( create_function( '' , 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;' ) ); 
    75 } 
    76     
    77 // **** Make sure we have PEAR's DB.php, and include it 
    78  
    79 outn(_("Checking for PEAR DB..")); 
    80 if (! @ include('DB.php')) { 
    81   out(_("FAILED")); 
    82   fatal(_("PEAR Missing"),sprintf(_("PEAR must be installed (requires DB.php). Include path: %s "), ini_get("include_path"))); 
    83 } 
    84 out(_("OK")); 
    85  
    86  
    87 // **** Check for amportal.conf 
    88  
    89 outn(sprintf(_("Checking for %s "), $amportalconf)._("..")); 
    90 if (!file_exists($amportalconf)) { 
    91   fatal(_("amportal.conf access problem: "),sprintf(_("The %s file does not exist, or is inaccessible"), $amportalconf)); 
    92 } 
    93 out(_("OK")); 
    94  
    95 // **** read amportal.conf 
    96  
    97 outn(sprintf(_("Bootstrapping %s .."), $amportalconf)); 
    98 $amp_conf = parse_amportal_conf_bootstrap($amportalconf); 
    99 if (count($amp_conf) == 0) { 
    100   fatal(_("amportal.conf parsing failure"),sprintf(_("no entries found in %s"), $amportalconf)); 
    101 } 
    102 out(_("OK")); 
    103  
    104 outn(sprintf(_("Parsing %s .."), $amportalconf)); 
    105 require_once($amp_conf['AMPWEBROOT']."/admin/functions.inc.php"); 
    106 $amp_conf = parse_amportal_conf($amportalconf); 
    107 if (count($amp_conf) == 0) { 
    108   fatal(_("amportal.conf parsing failure"),sprintf(_("no entries found in %s"), $amportalconf)); 
    109 } 
    110 out(_("OK")); 
    111  
    112 $asterisk_conf_file = $amp_conf["ASTETCDIR"]."/asterisk.conf"; 
    113 outn(sprintf(_("Parsing %s .."), $asterisk_conf_file)); 
    114 $asterisk_conf = parse_asterisk_conf($asterisk_conf_file); 
    115 if (count($asterisk_conf) == 0) { 
    116   fatal(_("asterisk.conf parsing failure"),sprintf(_("no entries found in %s"), $asterisk_conf_file)); 
    117 } 
    118 out(_("OK")); 
    119  
    120 // **** Connect to database 
    121  
    122 outn(_("Connecting to database..")); 
    123  
    124 # the engine to be used for the SQL queries, 
    125 # if none supplied, backfall to mysql 
    126 $db_engine = "mysql"; 
    127 if (isset($amp_conf["AMPDBENGINE"])){ 
    128   $db_engine = $amp_conf["AMPDBENGINE"]; 
    129 } 
    130  
    1318// Define the notification class for logging to the dashboard 
    1329// 
    13310$nt = notifications::create($db); 
    134  
    135 switch ($db_engine) 
    136 { 
    137   case "pgsql": 
    138   case "mysql": 
    139     /* datasource in in this style: 
    140     dbengine://username:password@host/database */ 
    141    
    142     $db_user = $amp_conf["AMPDBUSER"]; 
    143     $db_pass = $amp_conf["AMPDBPASS"]; 
    144     $db_host = $amp_conf["AMPDBHOST"]; 
    145     $db_name = $amp_conf["AMPDBNAME"]; 
    146    
    147     $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
    148     $db = DB::connect($datasource); // attempt connection 
    149     break; 
    150    
    151   case "sqlite": 
    152     require_once('DB/sqlite.php'); 
    153    
    154     if (!isset($amp_conf["AMPDBFILE"])) 
    155       fatal(_("AMPDBFILE not setup properly"),sprintf(_("You must setup properly AMPDBFILE in %s "), $amportalconf)); 
    156    
    157     if (isset($amp_conf["AMPDBFILE"]) == "") 
    158       fatal(_("AMPDBFILE not setup properly"),sprintf(_("AMPDBFILE in %s cannot be blank"), $amportalconf)); 
    159    
    160     $DSN = array ( 
    161       "database" => $amp_conf["AMPDBFILE"], 
    162       "mode" => 0666 
    163     ); 
    164    
    165     $db = new DB_sqlite(); 
    166     $db->connect( $DSN ); 
    167     break; 
    168    
    169   case "sqlite3": 
    170     if (!isset($amp_conf["AMPDBFILE"])) 
    171       fatal("You must setup properly AMPDBFILE in $amportalconf"); 
    172        
    173     if (isset($amp_conf["AMPDBFILE"]) == "") 
    174       fatal("AMPDBFILE in $amportalconf cannot be blank"); 
    175  
    176     require_once('DB/sqlite3.php'); 
    177     $datasource = "sqlite3:///" . $amp_conf["AMPDBFILE"] . "?mode=0666"; 
    178     $db = DB::connect($datasource); 
    179     break; 
    180  
    181   default: 
    182     fatal( "Unknown SQL engine: [$db_engine]"); 
    183 } 
    184  
    185 if(DB::isError($db)) { 
    186   out(_("FAILED")); 
    187   debug($db->userinfo); 
    188   fatal(_("database connection failure"),("failed trying to connect to the configured database")); 
    189    
    190 } 
    191 out(_("OK")); 
    19211 
    19312// Check to see if email should be sent 
  • freepbx/trunk/amp_conf/bin/freepbx_engine

    r10122 r10865  
    11#!/usr/bin/env bash 
    22 
    3 # Formating variables 
     3# Visual formating variables 
    44# use like: ${b}text$bx - ${b} starts bold, $bx end it, etc. 
    55# you must use echo -e for formating to be valid 
     
    1010 
    1111ROOT_UID=0   # root uid is 0 
    12 E_NOTROOT=67   # Non-root exit error 
    13  
     12E_NOTROOT=67 # Non-root exit error 
     13# define freepbx config file if not alreaddy set 
     14if [ ! -n "$FREEPBX_CONF" ]; then 
     15  FREEPBX_CONF="/etc/freepbx.conf" 
     16fi 
    1417 
    1518echo 
     
    2225fi 
    2326 
    24 # make sure config file exists 
    25 if [ ! -e "/etc/amportal.conf" ]       # Check if file exists. 
    26   then 
    27     echo; 
    28     echo "/etc/amportal.conf does not exist!"; 
    29   echo "Have you installed the AMP configuration?"; 
    30   exit; 
    31 fi 
    32 # Set some defaults which can be re-defined in amportal.conf 
     27 
     28# Set some defaults which can be re-defined from the config file/db 
    3329AMPDEVUSER=asterisk 
    3430AMPDEVGROUP=asterisk 
     
    4137FPBXDBUGFILE=/tmp/freepbx_debug.log 
    4238 
    43 . /etc/amportal.conf 
     39write_freepbxconf() { 
     40  if [ ! -e $FREEPBX_CONF  ]; then 
     41    cat > $FREEPBX_CONF <<-EOF 
     42    <?php 
     43    \$amp_conf['AMPDBUSER'] = '$AMPDBUSER'; 
     44    \$amp_conf['AMPDBPASS'] = '$AMPDBPASS'; 
     45    \$amp_conf['AMPDBHOST'] = '$AMPDBHOST'; 
     46    \$amp_conf['AMPDBNAME'] = '$AMPENGINE'; 
     47    \$amp_conf['AMPDBENGINE'] = '$AMPDBENGINE'; 
     48    \$amp_conf['datasource']  = ''; //for sqlite3 
     49 
     50    require_once('${AMPWEBROOT}/admin/bootstrap.php'); 
     51 
     52    EOF 
     53  fi 
     54  if [ -e /etc/asterisk/freepbx.conf ]; then 
     55    rm /etc/asterisk/freepbx.conf 
     56  fi 
     57
     58 
     59# get settings from db/config file 
     60if [[ -e $FREEPBX_CONF && -w "/etc/amportal.conf" ]]; then  
     61  # get the path of this file to call the gen_amp_conf.php script which will 
     62  # generate all the amp_conf variables that can be exported 
     63  # 
     64  progdir=`dirname $0` 
     65  sv_pwd=$PWD 
     66        cd $progdir 
     67        gen_path=$PWD 
     68        cd $sv_pwd 
     69  `$gen_path/gen_amp_conf.php` 
     70elif [ -e "/etc/amportal.conf" ]; then # Check if file exists, if it dose read it and then write out /etc/freepbx.conf 
     71  . /etc/amportal.conf 
     72  write_freepbxconf 
     73else  
     74  echo; 
     75    echo "FreePBX config file not found!"; 
     76  echo "Have you installed FreePBX?"; 
     77  exit; 
     78fi 
    4479 
    4580if [ -z $PIDOF ]; then 
     
    4782fi 
    4883 
    49 if [ $ASTRUNDIR = /var/run ] 
     84if [ -e $AMPBIN/amportal ]; then 
     85  echo "new amportal script detected, moving it to $AMPSBIN and attempting to backup up old" 
     86  # just in case it isn't there though it should be 
     87  if [ -e $AMPSBIN/amportal ]; then 
     88    mv $AMPSBIN/amportal $AMPSBIN/amportal.bak 
     89  else 
     90    echo "no exiting $AMPSBIN/amportal to make a backup of" 
     91  fi 
     92  mv $AMPBIN/amportal $AMPSBIN/amportal 
     93  if [ "$?" -ne "0" ]; then 
     94    echo "unable to update to new amportal, check permissions and try again" 
     95  fi 
     96  chown root:root $AMPSBIN/amportal 
     97  chmod +x $AMPSBIN/amportal 
     98fi 
     99 
     100if [ "$ASTRUNDIR" = "/var/run" ] 
    50101  then 
    51102    echo "**** ERROR IN CONFIGURATION ****" 
     
    75126chown_asterisk() { 
    76127  echo SETTING FILE PERMISSIONS 
    77  
     128   
     129  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP /etc/amportal.conf 
     130  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $FREEPBX_CONF 
     131  chmod g+w /etc/amportal.conf 
     132  chmod g+w $FREEPBX_CONF 
    78133  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTRUNDIR 
    79134  chown -R $AMPASTERISKUSER:$AMPASTERISKGROUP $ASTETCDIR 
     
    226281} 
    227282 
     283 
    228284case "$1" in 
    229285  start) 
     
    246302    stop_fop 
    247303    sleep 1 
     304    write_freepbxconf 
    248305    chown_asterisk 
    249306    run_asterisk 
     
    315372      ;; 
    316373      dbug) 
    317         if [ -f $FPBXDBUGFILE ]; then  
    318           tail -f $FPBXDBUGFILE  
    319         else  
     374        if [ ! -f $FPBXDBUGFILE ]; then  
    320375          touch tail -f $FPBXDBUGFILE 
    321376          chown $AMPASTERISKUSER:$AMPASTERISKGROUP $FPBXDBUGFILE 
    322           tail -f $FPBXDBUGFILE 
    323377        fi 
     378        if [ -f '/var/log/httpd/error_log' ]; then 
     379          httpd_error='/var/log/httpd/error_log' 
     380        fi  
     381        tail -f $FPBXDBUGFILE $httpd_error 
    324382      ;; 
    325383    *) 
     
    380438  ;; 
    381439esac 
    382  
  • freepbx/trunk/amp_conf/bin/generate_hints.php

    r10635 r10865  
    11#!/usr/bin/php -q 
    22<?php 
     3//include bootstrap 
     4$restrict_mods = true; 
     5$bootstrap_settings['freepbx_auth'] = false; 
     6$bootstrap_settings['skip_db'] = true; 
     7if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     8  include_once('/etc/asterisk/freepbx.conf'); 
     9} 
     10$debug = -1; 
    311 
    4   $debug = -1; 
     12// If set to nointercom then don't generate any hints 
     13// 
     14$intercom_code = isset($argv[1]) ? $argv[1] : ''; 
     15$dnd_mode      = isset($argv[2]) ? $argv[2] : ''; 
    516 
    6   // If set to nointercom then don't generate any hints 
    7   // 
    8   $intercom_code = isset($argv[1]) ? $argv[1] : ''; 
    9   $dnd_mode      = isset($argv[2]) ? $argv[2] : ''; 
     17$ast_with_dahdi = ast_with_dahdi(); 
    1018 
    11   $amp_conf = parse_amportal_conf_bootstrap("/etc/amportal.conf"); 
     19$var = $astman->database_show('AMPUSER'); 
     20foreach ($var as $key => $value) { 
     21  $myvar = explode('/',trim($key,'/')); 
     22  $user_hash[$myvar[1]] = true; 
     23
    1224 
    13   require_once($amp_conf['AMPWEBROOT'].'/admin/functions.inc.php'); 
    14   require_once($amp_conf['AMPWEBROOT'].'/admin/common/php-asmanager.php'); 
     25foreach (array_keys($user_hash) as $user) { 
     26  if ($user != 'none' && $user != '') { 
     27    $devices = get_devices($user); 
     28    debug("Set hints for user: $user for devices:  ".$devices,5); 
     29    set_hint($user, $devices); 
     30  } 
     31
    1532 
    16   $amp_conf = parse_amportal_conf("/etc/amportal.conf"); 
     33//--------------------------------------------------------------------- 
    1734 
    18   $astman = new AGI_AsteriskManager(null, array('cachemode' => true)); 
     35// Set the hint for a user based on the devices in their AMPUSER object 
     36// 
     37function set_hint($user, $devices) { 
     38  debug("set_hint: user: $user, devices: $devices",8); 
     39  global $astman; 
     40  global $dnd_mode; 
     41  global $intercom_code; 
    1942 
    20   $astmanagerhost = (isset($amp_conf['ASTMANAGERHOST']) && trim($amp_conf['ASTMANAGERHOST']) != '')?$amp_conf['ASTMANAGERHOST']:'127.0.0.1'; 
    21   if (isset($amp_conf['ASTMANAGERPORT']) && trim($amp_conf['ASTMANAGERPORT']) != '') { 
    22     $astmanagerhost .= ':'.$amp_conf['ASTMANAGERPORT']; 
    23   } 
     43  $dnd_string = ($dnd_mode == 'dnd')?"&Custom:DND$user":''; 
    2444 
    25   if (! $res = $astman->connect($astmanagerhost, $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], 'off')) { 
    26     exit; 
    27   } 
    28   $ast_with_dahdi = ast_with_dahdi(); 
    29  
    30   $var = $astman->database_show('AMPUSER'); 
    31   foreach ($var as $key => $value) { 
    32     $myvar = explode('/',trim($key,'/')); 
    33     $user_hash[$myvar[1]] = true; 
    34   } 
    35  
    36   foreach (array_keys($user_hash) as $user) { 
    37     if ($user != 'none' && $user != '') { 
    38       $devices = get_devices($user); 
    39       debug("Set hints for user: $user for devices:  ".$devices,5); 
    40       set_hint($user, $devices); 
     45  if ($devices) { 
     46    $dial_string = get_dial_string($devices); 
     47    echo "exten => $user,hint,$dial_string"."$dnd_string\n"; 
     48    if ($intercom_code != 'nointercom' && $intercom_code != '') { 
     49      echo "exten => $intercom_code"."$user,hint,$dial_string"."$dnd_string\n"; 
     50    } 
     51  } else if ($dnd_mode == 'dnd') { 
     52    echo "exten => $user,hint,Custom:DND$user\n"; 
     53    if ($intercom_code != 'nointercom' && $intercom_code != '') { 
     54      echo "exten => $intercom_code"."$user,hint,Custom:DND$user\n"; 
    4155    } 
    4256  } 
     57} 
    4358 
    44   //--------------------------------------------------------------------- 
     59// Get the actual technology dialstrings from the DEVICE objects (used 
     60// to create proper hints) 
     61// 
     62function get_dial_string($devices) { 
     63  debug("get_dial_string: devices: $devices",8); 
     64  global $astman; 
     65  global $ast_with_dahdi; 
    4566 
    46   function parse_amportal_conf_bootstrap($filename) { 
    47     $file = file($filename); 
    48     foreach ($file as $line) { 
    49       if (preg_match("/^\s*([\w]+)\s*=\s*\"?([\w\/\:\.\*\%-]*)\"?\s*([;#].*)?/",$line,$matches)) { 
    50         $conf[ $matches[1] ] = $matches[2]; 
    51       } 
    52     } 
    53     if ( !isset($conf["AMPWEBROOT"]) || ($conf["AMPWEBROOT"] == "")) { 
    54       $conf["AMPWEBROOT"] = "/var/www/html"; 
    55     } else { 
    56       $conf["AMPWEBROOT"] = rtrim($conf["AMPWEBROOT"],'/'); 
    57     } 
    58     return $conf; 
     67  $device_array = explode( '&', $devices ); 
     68  $dialstring = '';  
     69  foreach ($device_array as $adevice) { 
     70    $dds = $astman->database_get('DEVICE',$adevice.'/dial'); 
     71    $dialstring .= $dds.'&'; 
    5972  } 
     73  if ($ast_with_dahdi) { 
     74    $dialstring = str_replace('ZAP/', 'DAHDI/', $dialstring); 
     75  } 
     76  return trim($dialstring," &"); 
     77} 
    6078 
    61   // Set the hint for a user based on the devices in their AMPUSER object 
    62   // 
    63   function set_hint($user, $devices) { 
    64     debug("set_hint: user: $user, devices: $devices",8); 
    65     global $astman; 
    66     global $dnd_mode; 
    67     global $intercom_code; 
     79// Get the list of current devices for this user 
     80// 
     81function get_devices($user) { 
     82  debug("get_devices: user: $user", 8); 
     83  global $astman; 
    6884 
    69     $dnd_string = ($dnd_mode == 'dnd')?"&Custom:DND$user":''; 
     85  $devices = $astman->database_get('AMPUSER',$user.'/device'); 
     86  return trim($devices); 
     87
    7088 
    71     if ($devices) { 
    72       $dial_string = get_dial_string($devices); 
    73       echo "exten => $user,hint,$dial_string"."$dnd_string\n"; 
    74       if ($intercom_code != 'nointercom' && $intercom_code != '') { 
    75         echo "exten => $intercom_code"."$user,hint,$dial_string"."$dnd_string\n"; 
    76       } 
    77     } else if ($dnd_mode == 'dnd') { 
    78       echo "exten => $user,hint,Custom:DND$user\n"; 
    79       if ($intercom_code != 'nointercom' && $intercom_code != '') { 
    80         echo "exten => $intercom_code"."$user,hint,Custom:DND$user\n"; 
    81       } 
    82     } 
     89function debug($string, $level=3) { 
     90  global $debug; 
     91  if ($debug >= $level) { 
     92    echo $string."\n"; 
    8393  } 
    84  
    85   // Get the actual technology dialstrings from the DEVICE objects (used 
    86   // to create proper hints) 
    87   // 
    88   function get_dial_string($devices) { 
    89     debug("get_dial_string: devices: $devices",8); 
    90     global $astman; 
    91     global $ast_with_dahdi; 
    92  
    93     $device_array = explode( '&', $devices ); 
    94     $dialstring = ''; 
    95     foreach ($device_array as $adevice) { 
    96       $dds = $astman->database_get('DEVICE',$adevice.'/dial'); 
    97       $dialstring .= $dds.'&'; 
    98     } 
    99     if ($ast_with_dahdi) { 
    100       $dialstring = str_replace('ZAP/', 'DAHDI/', $dialstring); 
    101     } 
    102     return trim($dialstring," &"); 
    103   } 
    104  
    105   // Get the list of current devices for this user 
    106   // 
    107   function get_devices($user) { 
    108     debug("get_devices: user: $user", 8); 
    109     global $astman; 
    110  
    111     $devices = $astman->database_get('AMPUSER',$user.'/device'); 
    112     return trim($devices); 
    113   } 
    114  
    115   function debug($string, $level=3) { 
    116     global $debug; 
    117     if ($debug >= $level) { 
    118       echo $string."\n"; 
    119     } 
    120   } 
     94
  • freepbx/trunk/amp_conf/bin/module_admin

    r10416 r10865  
    1616 */ 
    1717 
    18 define("AMP_CONF", "/etc/amportal.conf"); 
    19  
     18$bootstrap_settings['freepbx_auth'] = false; 
     19// don't include any of the functions.inc.php files from modules, this CLI version of 
     20// module_admin is somtimes the only way to recover from a bad module being loaded into 
     21// a system. 
     22// 
     23$restrict_mods = true; 
     24if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     25  include_once('/etc/asterisk/freepbx.conf'); 
     26
    2027function out($text) { 
    2128  echo $text."\n"; 
     
    4148} 
    4249 
    43  
    44 function install_parse_amportal_conf($filename) { 
    45   $file = file($filename); 
    46   foreach ($file as $line) { 
    47     if (preg_match("/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/",$line,$matches)) {  
    48       $conf[ $matches[1] ] = $matches[2]; 
    49     } 
    50   } 
    51   return $conf; 
    52 } 
    53  
    54 function init_amportal_environment($ampconfpath) { 
    55   global $amp_conf, $asterisk_conf, $db, $astman; 
    56   global $amp_conf_defaults; 
    57    
    58   if (!file_exists($ampconfpath)) { 
    59     fatal('Cannot find conf file: '.$ampconfpath); 
    60   } 
    61    
    62   // primitive parse function, just to grab AMPWEBROOT 
    63   $inst_amp_conf = install_parse_amportal_conf(AMP_CONF); 
    64    
    65   define('AMP_BASE_INCLUDE_PATH', $inst_amp_conf['AMPWEBROOT'].'/admin'); 
    66    
    67   if (!file_exists(AMP_BASE_INCLUDE_PATH.'/functions.inc.php')) { 
    68     fatal('Cannot locate '.AMP_BASE_INCLUDE_PATH.'/functions.inc.php'); 
    69   }  
    70   // include the functions file from WEBROOT 
    71   include(AMP_BASE_INCLUDE_PATH.'/functions.inc.php'); 
    72   // include astman api 
    73   include(AMP_BASE_INCLUDE_PATH.'/common/php-asmanager.php'); 
    74    
    75   // now apply the real parse function (this makes some default assumptions and does a bit more error checking) 
    76   $amp_conf = parse_amportal_conf($ampconfpath); 
    77    
    78   $asterisk_conf = parse_asterisk_conf($amp_conf['ASTETCDIR']); 
    79  
    80   // connect to database 
    81   if (!file_exists(AMP_BASE_INCLUDE_PATH.'/common/db_connect.php')) { 
    82     fatal('Cannot locate '.AMP_BASE_INCLUDE_PATH.'/common/db_connect.php'); 
    83   } 
    84   require_once(AMP_BASE_INCLUDE_PATH.'/common/db_connect.php'); //PEAR must be installed 
    85  
    86   $astman= new AGI_AsteriskManager(); 
    87   if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
    88     unset( $astman ); 
    89   } 
    90 } 
    9150 
    9251function doReload() { 
     
    559518  } 
    560519} 
    561 /**************************************************************************************************** 
    562  ****************************************************************************************************/ 
    563  
    564 // from  ben-php dot net at efros dot com   at  php.net/install.unix.commandline 
    565 if (version_compare(phpversion(),'4.3.0','<') || !defined("STDIN")) { 
    566   define('STDIN',fopen("php://stdin","r")); 
    567   define('STDOUT',fopen("php://stdout","r")); 
    568   define('STDERR',fopen("php://stderr","r")); 
    569   register_shutdown_function( create_function( '' , 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;' ) ); 
    570 
    571     
    572 // **** Make sure we have PEAR's DB.php, and include it 
    573 if (! @ include('DB.php')) { 
    574   fatal("PEAR must be installed (requires DB.php). Include path: ".ini_get("include_path")); 
    575 
     520//**************************************************************************************************** 
     521 
    576522 
    577523// **** Make sure we have PEAR's GetOpts.php, and include it 
     
    591537} 
    592538 
    593 $ampconfpath = AMP_CONF; 
    594  
    595539// force operations 
    596540$force = false; 
     
    627571} 
    628572 
    629 // create $amp_conf, $db, etc 
    630 init_amportal_environment($ampconfpath); 
    631  
    632 require_once( $amp_conf["AMPWEBROOT"].'/admin/common/php-asmanager.php' ); 
    633 $astman = new AGI_AsteriskManager(); 
    634 if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
    635   unset( $astman ); 
    636 } 
    637573 
    638574$operation = $args[1][0]; 
  • freepbx/trunk/amp_conf/htdocs/admin/bootstrap.php

    r10367 r10865  
    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, true skip all modules 
     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 
     39//enable error reporting and start benchmarking 
     40error_reporting(1); 
     41function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 
     42$benchmark_starttime = microtime_float(); 
    243 
    344// include base functions 
    4 require_once('functions.inc.php'); 
     45require_once(dirname(__FILE__) . '/functions.inc.php'); 
    546 
    6 // get settings 
    7 $amp_conf = parse_amportal_conf("/etc/amportal.conf"); 
    8 $asterisk_conf  = parse_asterisk_conf($amp_conf["ASTETCDIR"]."/asterisk.conf"); 
    9 if (!$skip_astman) { 
    10   require_once('common/php-asmanager.php'); 
    11   $astman = new AGI_AsteriskManager(); 
     47//now that its been included, use our own error handler as it tends to be much more verbose. 
     48if ($bootstrap_settings['freepbx_error_handler']) { 
     49  $error_handler = $bootstrap_settings['freepbx_error_handler'] === true ? 'freepbx_error_handler' : $bootstrap_settings['freepbx_error_handler']; 
     50  if (function_exists($error_handler)) { 
     51    set_error_handler($error_handler, E_ALL & ~E_STRICT); 
     52  } 
     53
    1254 
     55//include database conifguration 
     56if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     57  include_once('/etc/asterisk/freepbx.conf'); 
     58} 
     59 
     60// connect to database 
     61if (!$bootstrap_settings['skip_db']) { 
     62  require_once(dirname(__FILE__) . '/common/db_connect.php'); //PEAR must be installed 
     63  //keep old values as well so that we have the db settings handy 
     64  // get settings 
     65  $amp_conf = $amp_conf + parse_amportal_conf("/etc/amportal.conf"); 
     66  $asterisk_conf = parse_asterisk_conf($amp_conf["ASTETCDIR"] . "/asterisk.conf"); 
     67} 
     68 
     69//set error reporting level if set 
     70if (isset($amp_conf['php_error_reporting'])) { 
     71  error_reporting($amp_conf['php_error_reporting']); 
     72} 
     73 
     74if (!$bootstrap_settings['skip_astman']) { 
     75  require_once(dirname(__FILE__) . '/libraries/php-asmanager.php'); 
     76  $astman = new AGI_AsteriskManager($bootstrap_settings['astman_config'], $bootstrap_settings['astman_options']); 
    1377  // attempt to connect to asterisk manager proxy 
    14   if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
     78 if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events'])) { 
    1579    // attempt to connect directly to asterisk, if no proxy or if proxy failed 
    16     if (!$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], 'off')) { 
     80    if (!$res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events'])) { 
    1781      // couldn't connect at all 
    1882      unset( $astman ); 
     
    2185} 
    2286 
    23 // connect to database 
    24 require_once('common/db_connect.php'); //PEAR must be installed 
     87//include gui functions + auth if nesesarry 
     88// If set to freepbx_auth but we are in a cli mode, then don't bother authenticating either way. 
     89// TODO: is it ever possible through an apache or httplite configuration to run a web launched php script 
     90//       as 'cli' ? Also, from a security perspective, should we just require this always be set to false 
     91//       if we want to bypass authentication and not try to be automatic about it? 
     92// 
     93if (!$bootstrap_settings['freepbx_auth'] || (php_sapi_name() == 'cli')) { 
     94  if (!defined('FREEPBX_IS_AUTH')) { 
     95    define('FREEPBX_IS_AUTH', 'TRUE'); 
     96  } 
     97} else { 
     98  require(dirname(__FILE__) . '/libraries/framework_view.functions.php'); 
     99  frameworkPasswordCheck(); 
     100
     101if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }//we should never need this, just another line of defence 
    25102 
    26 if ($amp_conf['DEVEL']) { 
    27   // benchmark 
    28   function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 
    29   $benchmark_starttime = microtime_float(); 
     103// I'm pretty sure if this is == true then there is no need to even pull all the module info as we are going down a path 
     104// such as an ajax path that this is just overhead. (We'll no soon enough if this is too restrcitive). 
     105// 
     106if ($restrict_mods !== true) { 
     107  $active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); 
     108 
     109  if(is_array($active_modules)){ 
     110 
     111    foreach($active_modules as $key => $module) { 
     112      //include module functions if there not dissabled 
     113      if ((!$restrict_mods || (is_array($restrict_mods) && isset($restrict_mods[$key]))) && is_file($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php")) { 
     114        require_once($amp_conf['AMPWEBROOT']."/admin/modules/{$key}/functions.inc.php"); 
     115      }  
     116     
     117      //create an array of module sections to display 
     118      // stored as [items][$type][$category][$name] = $displayvalue 
     119      if (isset($module['items']) && is_array($module['items'])) { 
     120        // loop through the types 
     121        foreach($module['items'] as $itemKey => $item) { 
     122         
     123          //if asterisk isnt running, mark moduels that depend on asterisk as disbaled 
     124          if (!isset($astman) || !$astman) { 
     125            if (( isset($item['needsenginedb']) && strtolower($item['needsenginedb']) == 'yes')  
     126            || (isset($item['needsenginerunning']) && strtolower($item['needsenginerunning']) == 'yes')) { 
     127              $active_modules[$key]['items'][$itemKey]['disabled'] = true; 
     128            } 
     129          } 
     130         
     131          // reference to the actual module 
     132          //$active_modules[$key][$itemKey]['module'] =& $active_modules[$key]; 
     133 
     134        } 
     135      } 
     136    } 
     137  } 
    30138} 
    31  
    32 $active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); 
    33  
    34 if(is_array($active_modules)){ 
    35   foreach($active_modules as $key => $module) {  
    36     unset($active_modules[$key]['changelog']); 
    37     //include module functions if there not dissabled 
    38     if ((!$restrict_mods || isset($restrict_mods[$key])) && is_file("modules/{$key}/functions.inc.php")) { 
    39       require_once("modules/{$key}/functions.inc.php"); 
    40     } 
    41      
    42     //create an array of module sections to display 
    43     // stored as [items][$type][$category][$name] = $displayvalue 
    44     if (isset($module['items']) && is_array($module['items'])) { 
    45       // loop through the types 
    46       foreach($module['items'] as $itemKey => $item) { 
    47          
    48         //if asterisk isnt running, mark moduels that depend on asterisk as disbaled 
    49         if (!checkAstMan()) { 
    50           if (( isset($item['needsenginedb']) && strtolower($item['needsenginedb']) == 'yes')  
    51           || (isset($item['needsenginerunning']) && strtolower($item['needsenginerunning']) == 'yes')) { 
    52             $active_modules[$key][$itemKey]['disabled'] = true; 
    53           } else { 
    54             $active_modules[$key][$itemKey]['disabled'] = false; 
    55           } 
    56         } 
    57          
    58         // reference to the actual module 
    59         //$active_modules[$key][$itemKey]['module'] =& $active_modules[$key]; 
    60  
    61       } 
    62     } 
    63   } 
    64 } 
    65  
    66139?> 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/call-comp.php

    r10274 r10865  
    11<?php /* $Id$ */ 
    2 include_once(dirname(__FILE__) . "/../header.php"); 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33include_once(dirname(__FILE__) . "/lib/defines.php"); 
    44include_once(dirname(__FILE__) . "/lib/Class.Table.php"); 
     
    4848Calldate Clid Src Dst Dcontext Channel Dstchannel Lastapp Lastdata Duration Billsec Disposition Amaflags Accountcode Uniqueid Serverid 
    4949*******/ 
    50 if (!@include($amp_conf['ASTETCDIR'].'/call-comp-table.php')) { 
     50if (!file_exists($amp_conf['ASTETCDIR'].'/call-log-table.php') || !@include($amp_conf['ASTETCDIR'].'/call-log-table.php')) { 
    5151 
    5252  $FG_TABLE_COL[]=array ("Calldate", "calldate", "18%", "center", "SORT", "19"); 
     
    202202/* --AMP BEGIN-- */ 
    203203//enforce restrictions for this AMP User 
    204 session_start(); 
     204@session_start(); 
    205205$AMP_CLAUSE = $_SESSION['AMP_SQL']; 
    206206if (!isset($AMP_CLAUSE)) { 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/call-daily-load.php

    r10274 r10865  
    11<?php /* $Id$ */ 
    2 include_once(dirname(__FILE__) . "/../header.php"); 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33include_once(dirname(__FILE__) . "/lib/defines.php"); 
    44include_once(dirname(__FILE__) . "/lib/Class.Table.php"); 
     
    4242$FG_TABLE_COL = array(); 
    4343 
    44 if (!@include($amp_conf['ASTETCDIR'].'/call-daily-load-table.php')) { 
     44if (!file_exists($amp_conf['ASTETCDIR'].'/call-log-table.php') || !@include($amp_conf['ASTETCDIR'].'/call-log-table.php')) { 
    4545  // The variable Var_col would define the col that we want show in your table 
    4646  // First Name of the column in the html page, second name of the field 
     
    184184/* --AMP BEGIN-- */ 
    185185//enforce restrictions for this AMP User 
    186 session_start(); 
     186@session_start(); 
    187187$AMP_CLAUSE = $_SESSION['AMP_SQL']; 
    188188if (!isset($AMP_CLAUSE)) { 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/call-last-month.php

    r10274 r10865  
    11<?php /* $Id$ */ 
    2 include_once(dirname(__FILE__) . "/../header.php"); 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33include_once(dirname(__FILE__) . "/lib/defines.php"); 
    44include_once(dirname(__FILE__) . "/lib/Class.Table.php"); 
     
    4848*******/ 
    4949 
    50 if (!@include($amp_conf['ASTETCDIR'].'/call-last-month-table.php')) { 
     50if (!file_exists($amp_conf['ASTETCDIR'].'/call-log-table.php') || !@include($amp_conf['ASTETCDIR'].'/call-log-table.php')) { 
    5151 
    5252  $FG_TABLE_COL[]=array ("Calldate", "calldate", "18%", "center", "SORT", "19"); 
     
    195195/* --AMP BEGIN-- */ 
    196196//enforce restrictions for this AMP User 
    197 session_start(); 
     197@session_start(); 
    198198$AMP_CLAUSE = $_SESSION['AMP_SQL']; 
    199199if (!isset($AMP_CLAUSE)) { 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/call-log.php

    r10274 r10865  
    11<?php /* $Id$ */ 
    2 include_once(dirname(__FILE__) . "/../header.php"); 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33include_once(dirname(__FILE__) . "/lib/defines.php"); 
    44include_once(dirname(__FILE__) . "/lib/Class.Table.php"); 
    55 
    6  
    76// correct 31 +1 = 32 for the date 
    8 //session_start(); 
     7@session_start(); 
    98 
    109getpost_ifset(array('posted', 'Period', 'frommonth', 'fromstatsmonth', 'tomonth', 'tostatsmonth', 'fromday', 'fromstatsday_sday', 'fromstatsmonth_sday', 'today', 'tostatsday_sday', 'tostatsmonth_sday', 'dsttype', 'srctype', 'clidtype', 'channel', 'resulttype', 'stitle', 'atmenu', 'current_page', 'order', 'sens', 'dst', 'src', 'clid', 'userfieldtype', 'userfield', 'accountcodetype', 'accountcode', 'duration1', 'duration1type', 'duration2', 'duration2type')); 
     
    4443 
    4544 
    46 //$link = DbConnect(); 
    47 $DBHandle  = DbConnect(); 
     45$DBHandle = DbConnect(); 
    4846 
    4947// The variable Var_col would define the col that we want show in your table 
     
    8583 
    8684/* --AMP Begin-- */ 
    87 if (!@include($amp_conf['ASTETCDIR'].'/call-log-table.php')) { 
     85if (!file_exists($amp_conf['ASTETCDIR'].'/call-log-table.php') || !@include($amp_conf['ASTETCDIR'].'/call-log-table.php')) { 
    8886 
    8987  $FG_TABLE_COL[]=array ("Calldate", "calldate", "18%", "center", "SORT", "19"); 
     
    268266/* --AMP BEGIN-- */ 
    269267//enforce restrictions for this AMP User 
    270 @session_start(); 
     268if(!isset($_SESSION)) { 
     269  @session_start(); 
     270
     271 
    271272$AMP_CLAUSE = $_SESSION['AMP_SQL']; 
    272273if (!isset($AMP_CLAUSE)) { 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/cdr.php

    r10274 r10865  
    11<?php /* $Id$ */ 
    2 include_once(dirname(__FILE__) . "/../header.php"); 
    3 session_start(); 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    43 
    54 
    65/* -- AMP Begin -- */ 
     6 
     7$low = $_SESSION["AMP_user"]->_extension_low; 
     8$high = $_SESSION["AMP_user"]->_extension_high; 
     9if ((!empty($low)) && (!empty($high))) { 
     10  $channelfilter="OR (FIELD( SUBSTRING_INDEX( channel, '/', 1 ) , 'SIP', 'IAX2' ) > 0 AND SUBSTRING_INDEX(SUBSTRING(channel,2+LENGTH(SUBSTRING_INDEX( channel, '/', 1 ))),'-',1) BETWEEN $low and $high)"; 
     11  $channelfilter.="OR (dstchannel<>'' AND FIELD( SUBSTRING_INDEX( dstchannel, '/', 1 ) , 'SIP', 'IAX2' ) > 0 AND SUBSTRING_INDEX(SUBSTRING(dstchannel,2+LENGTH(SUBSTRING_INDEX( dstchannel, '/', 1 ))),'-',1) BETWEEN $low and $high)"; 
     12 
     13        $_SESSION["AMP_SQL"] = " AND ((src+0 BETWEEN $low AND $high) OR (dst+0 BETWEEN $low AND $high) OR (dst+0 BETWEEN 8$low AND 8$high) $channelfilter)"; 
     14} else { 
     15  $_SESSION["AMP_SQL"] = ""; 
     16} 
     17 
    718$AMP_CLAUSE = $_SESSION['AMP_SQL']; 
    819if (!isset($AMP_CLAUSE)) { 
     
    1021  echo "<font color=red>YOU MUST ACCESS THE CDR THROUGH THE ASTERISK MANAGEMENT PORTAL!</font>"; 
    1122} 
     23 
    1224//echo 'AMP_CLAUSE='.$AMP_CLAUSE.'<hr>'; 
    1325/* -- AMP End -- */ 
     
    2941} 
    3042 
    31  
    32  
    3343cdrpage_getpost_ifset(array('s', 't')); 
    3444 
     45$get_vars = array( 
     46/* 
     47'accountcode', 
     48'accountcodetype', 
     49'after', 
     50'atmenu', 
     51'before', 
     52'channel', 
     53'clid', 
     54'clidtype', 
     55'duration1', 
     56'duration1type', 
     57'duration2', 
     58'duration2type', 
     59'dst', 
     60'dsttype', 
     61'fromday', 
     62'frommonth', 
     63'fromstatsday_sday', 
     64'fromstatsmonth', 
     65'fromstatsmonth_sday', 
     66'letter',  
     67'list', 
     68'list_total', 
     69'list_total_day', 
     70'min_call', 
     71'name', 
     72'nb_record', 
     73'order', 
     74*/ 
     75'posted', 
     76/* 
     77'resulttype', 
     78's', 
     79'sens', 
     80'sql_limit', 
     81'src', 
     82'srctype', 
     83'stitle', 
     84't', 
     85'today', 
     86'tomonth', 
     87'tostatsday_sday', 
     88'tostatsmonth_sday', 
     89'tostatsmonth', 
     90'totalcall', 
     91'userfield', 
     92'userfieldtype', 
     93'AMP_SQL', 
     94'FG_ACTION_SIZE_COLUMN', 
     95'FG_DELETION', 
     96'Period', 
     97'SQLcmd', 
     98*/ 
     99); 
    35100 
     101foreach ($get_vars as $gv) { 
     102  if (!isset($$gv) || !$$gv) { 
     103    $$gv = isset($_REQUEST[$gv]) ? $_REQUEST[$gv] : ''; 
     104  } 
     105} 
    36106$array = array ("INTRO", "CDR REPORT", "CALLS COMPARE", "MONTHLY TRAFFIC","DAILY LOAD", "CONTACT"); 
    37 $s = $s ? $s : 0
     107$s = $s ? $s : 1
    38108$t = (isset($t))?$t:null; 
    39109$section="section$s$t"; 
     
    63133   
    64134 
    65    
    66 <?php /* --AMP--   
    67     <!-- header BEGIN --> 
    68     <div id="fedora-header"> 
    69        
    70       <div id="fedora-header-logo"> 
    71          <table border="0" cellpadding="0" cellspacing="0"><tr><td><img src="images/asterisk.gif"  alt="CDR (Call Detail Records)"></td><td> 
    72          <H1><font color=#990000>&nbsp;&nbsp;&nbsp;CDR (Call Detail Records)</font></H1></td></tr></table> 
    73       </div> 
    74  
    75     </div> 
    76     <div id="fedora-nav"></div> 
    77     <!-- header END --> 
    78      
    79     <!-- leftside BEGIN --> 
    80     <div id="fedora-side-left"> 
    81     <div id="fedora-side-nav-label">Site Navigation:</div>  <ul id="fedora-side-nav"> 
    82     <?php   
    83       $nkey=array_keys($array); 
    84         $i=0; 
    85         while($i<sizeof($nkey)){ 
    86        
    87         $op_strong = (($i==$s) && (!is_string($t))) ? '<strong>' : ''; 
    88         $cl_strong = (($i==$s) && (!is_string($t))) ? '</strong>' : ''; 
    89                    
    90             if(is_array($array[$nkey[$i]])){ 
    91            
    92            
    93            
    94           echo "\n\t<li>$op_strong<a href=\"$racine?s=$i\">".$nkey[$i]."</a>$cl_strong"; 
    95                    
    96           $j=0; 
    97           while($j<sizeof($array[$nkey[$i]] )){ 
    98             $op_strong = (($i==$s) && (isset($t)) && ($j==intval($t))) ? '<strong>' : ''; 
    99             $cl_strong = (($i==$s) && (isset($t))&& ($j==intval($t))) ? '</strong>' : '';            
    100             echo "<ul>";             
    101             echo "\n\t<li>$op_strong<a href=\"$racine?s=$i&t=$j\">".$array[$nkey[$i]][$j]."</a>$cl_strong"; 
    102             echo "</ul>"; 
    103             $j++;            
    104           } 
    105              
    106             }else{           
    107           echo "\n\t<li>$op_strong<a href=\"$racine?s=$i\">".$array[$nkey[$i]]."</a>$cl_strong"; 
    108         } 
    109         echo "</li>\n"; 
    110              
    111             $i++; 
    112         } 
    113        
    114     ?> 
    115  
    116       </ul> 
    117        
    118     <?php  if ($paypal=="OK"){?> 
    119     <center> 
    120       <br><br> 
    121 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
    122 <input type="hidden" name="cmd" value="_xclick"> 
    123 <input type="hidden" name="business" value="info@areski.net"> 
    124 <input type="hidden" name="no_note" value="1"> 
    125 <input type="hidden" name="currency_code" value="EUR"> 
    126 <input type="hidden" name="tax" value="0"> 
    127 <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> 
    128 </form> 
    129 </center> 
    130       <?php  } ?> 
    131        
    132     </div> 
    133  
    134     <!-- leftside END --> 
    135  
    136     <!-- content BEGIN --> 
    137     <div id="fedora-middle-two"> 
    138       <div class="fedora-corner-tr">&nbsp;</div> 
    139       <div class="fedora-corner-tl">&nbsp;</div> 
    140       <div id="fedora-content"> 
    141        
    142 --AMP-- */?> 
    143135 
    144136 
    145137<?php if ($section=="section0"){?> 
    146  
    147 <h1> 
    148  <center>ASTERISK : CDR ANALYSER</center> 
    149 </h1> 
    150             <h3>Call data collection</h3> 
    151             <p>Regardless of their size, most telephone PBX (public branch exchange) and PMS (property management systems) 
    152             output <b>Call Detail Records (CDR)</b>. Generally, these get created at the end of a call but on some phone systems 
    153             the data is available during the call. This data is output from the phone system by a serial link known as the 
    154             Station Message Detail Recording port (SMDR). <b>Some of the details included in call records are: Time, Date, Call 
    155             Duration, Number dialed, Caller ID information, Extension, Line/trunk location, Cost, Call completion status.</b><br> 
    156             <br> 
    157             Call detail records, both local and long distance, can be used for usage verification, billing reconciliation, 
    158             network management and to monitor telephone usage to determine volume of phone usage, as well as abuse of the system.  
    159             CDR's aid in the planning for future telecommunications needs. <br> 
    160             <br> 
    161             Control with CDR analysis: 
    162             <ul> 
    163  
    164               <li>review all CDR's for accuracy  
    165               <li>verify usage  
    166               <li>resolve discrepancies with vendors 
    167               <li>disconnect unused service  
    168               <li>terminate leases on unused equipment  
    169               <li>deter or detect fraud 
    170               <li>etc ... 
    171             </ul> 
    172138 
    173139<?php }elseif ($section=="section1"){?> 
     
    175141  <?php require("call-log.php");?> 
    176142 
    177  
    178143<?php }elseif ($section=="section2"){?> 
    179144 
    180145  <?php require("call-comp.php");?> 
    181  
    182146 
    183147<?php }elseif ($section=="section3"){?> 
     
    188152 
    189153  <?php require("call-daily-load.php");?> 
    190  
    191  
    192 <?php }elseif ($section=="section5"){?> 
    193     <h1>Contact</h1>             
    194         <table width="90%"> 
    195            
    196       <tr>  
    197             <td> 
    198         <h3>Arezqui Bela&iuml;d <br> <i>Barcelona - Belgium</i></h3>         
    199         <br> 
    200         <a href='javascript:bite("3721 945 4728 2762 3565 3554 2008 1380 654 3721 3554 4468 3007 3877 4828 654",5123,2981)'>Click to email me</a> 
    201         <br><br><i>Feel free to send me your suggestions to improve the application ;)</i> 
    202             </td> 
    203           </tr>           
    204            
    205         </table> 
    206     <br><br><em><strong>Last update:</strong></em> <?php echo $update?><br> 
    207  
    208154 
    209155<?php }else{?> 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/common/graph_hourdetail.php

    r10243 r10865  
    11<?php /* $Id: graph_hourdetail.php 6816 2008-09-19 18:33:18Z p_lindheimer $ */ 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    23include_once(dirname(__FILE__) . "/../lib/defines.php"); 
    34include_once(dirname(__FILE__) . "/../lib/Class.Table.php"); 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/common/graph_pie.php

    r10243 r10865  
    11<?php /* $Id: graph_pie.php 6816 2008-09-19 18:33:18Z p_lindheimer $ */ 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    23include_once(dirname(__FILE__) . "/../lib/defines.php"); 
    34include_once(dirname(__FILE__) . "/../lib/Class.Table.php"); 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/common/graph_stat.php

    r10243 r10865  
    11<?php 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    23include_once(dirname(__FILE__) . "/../lib/defines.php"); 
    34include_once(dirname(__FILE__) . "/../lib/Class.Table.php"); 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/common/graph_statbar.php

    r10243 r10865  
    11<?php /* $Id: graph_statbar.php 6816 2008-09-19 18:33:18Z p_lindheimer $ */ 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    23include_once(dirname(__FILE__) . "/../lib/defines.php"); 
    34include_once(dirname(__FILE__) . "/../lib/Class.Table.php"); 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/export_csv.php

    r173 r10865  
    11<?php 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    23include_once(dirname(__FILE__) . "/lib/defines.php"); 
    34include_once(dirname(__FILE__) . "/lib/Class.Table.php"); 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/export_pdf.php

    r188 r10865  
    11<?php 
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    23include_once(dirname(__FILE__) . "/lib/defines.php"); 
    34include_once(dirname(__FILE__) . "/lib/Class.Table.php"); 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/lib/Class.Table.php

    r6002 r10865  
    11<?php 
    2  
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33class Table { 
    44 
     
    1616      $this -> table = $table; 
    1717      $this -> fields = $liste_fields; 
     18    $this->db = DbConnect(); 
    1819 
    1920  } 
     
    3940 
    4041  function Get_list ($clause=null, $order=null, $sens=null, $field_order_letter=null, $letters = null, $limite=null, $current_record=NULL) { 
    41     //global $link; 
    42     global $DBHandle; 
    43  
    44  
    4542    $sql = 'SELECT '.$this -> fields.' FROM '.trim($this -> table); 
    4643 
     
    7875    $QUERY = $sql.$sql_clause.$sql_orderby.$sql_limit;     
    7976    if ($this -> debug_st) echo "<br>QUERY:".$QUERY; 
    80          
    81     //$res=DbExec($link, $QUERY); 
    82     $res = $DBHandle -> query($QUERY); 
     77 
     78    $res = $this->db->query($QUERY); 
    8379    if(DB::isError($res)) 
    8480    { 
     
    108104 
    109105  function Table_count ($clause=null) { 
    110     //global $link; 
    111     global $DBHandle; 
    112  
    113  
    114106    $sql = 'SELECT count(*) FROM '.trim($this -> table); 
    115107 
     
    124116    //echo $sql; 
    125117     
    126     if ($this -> debug_st) echo "<br>QUERY:".$QUERY; 
    127     //$res=DbExec($link, $QUERY);    
    128     $res = $DBHandle -> query($QUERY); 
     118    if ($this -> debug_st) echo "<br>QUERY:".$QUERY;     
     119    $res = $this->db->query($QUERY); 
    129120 
    130121    /////$num=DbCount($res); 
     
    143134 
    144135  function Add_table ($value, $func_fields = null, $func_table = null, $id_name = null) { 
    145     //global $link; 
    146     global $DBHandle; 
    147  
    148136    if ($func_fields!=""){     
    149137      $this -> fields = $func_fields; 
     
    158146    if ($this -> debug_st) echo "<br>QUERY:".$QUERY; 
    159147 
    160     $res = $DBHandle -> query($QUERY); 
     148    $res = dbquery($QUERY); 
    161149 
    162150    if (DB::isError($res)){ 
    163151    //if (! $res=DbExec($link, $QUERY)) { 
    164152      //$this -> errstr = "Could not create a new instance in the table '".$this -> table."'";         
    165             $this -> errstr = $DBHandle -> getMessage();                                       
     153            $this -> errstr = $this->db->getMessage();                                       
    166154 
    167155       
     
    177165        $sql = 'SELECT "'.$id_name.'" FROM "'.$this -> table.'" WHERE oid=\''.$oid.'\''; 
    178166 
    179         if (! $res = $DBHandle -> query($sql)) return (false); 
     167        if (! $res = $this->db->query($sql)) return (false); 
    180168         
    181169        $row [] =$res -> fetchRow(); 
     
    189177 
    190178  function Update_table ($param_update, $clause, $func_table = null) { 
    191     //global $link; 
    192     global $DBHandle; 
    193  
    194179    if ($param_update=="" || $clause==""){ 
    195180      echo "<br>Update parameters wasn't correctly defined.<br>Check the function call 'Update_table'."; 
     
    206191 
    207192     
    208     if (! $res = $DBHandle -> query($QUERY)){ 
     193    if (! $res = $this->db->query($QUERY)){ 
    209194    //if (! $res=DbExec($link, $QUERY)) { 
    210195      $this -> errstr = "Could not update the instances of the table '".$this -> table."'";    
     
    218203 
    219204  function Delete_table ($clause, $func_table = null) { 
    220     //global $link; 
    221     global $DBHandle; 
    222  
    223205    if ($clause==""){ 
    224206      echo "<br>Delete parameters wasn't correctly defined.<br>Check the function call 'Update_table'."; 
     
    234216    if ($this -> debug_st) echo "<br>QUERY:".$QUERY; 
    235217     
    236     if (! $res = $DBHandle -> query($QUERY)){ 
     218    if (! $res = $this->db->query($QUERY)){ 
    237219    //if (! $res=DbExec($link, $QUERY)) { 
    238220      $this -> errstr = "Could not delete the instances of the table '".$this -> table."'";    
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/lib/defines.php

    r10122 r10865  
    11<?php /* $Id$ */ 
    2  
     2$restrict_mods = true; 
     3$skip_db = true; 
     4$skip_astman = true; 
     5if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     6  include_once('/etc/asterisk/freepbx.conf'); 
     7
     8if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    39require_once('DB.php'); // PEAR 
    4  
    5 if (!function_exists('parse_amportal_conf')) { 
    6 function parse_amportal_conf($filename) { 
    7         $file = file($filename); 
    8         foreach ($file as $line) { 
    9                 if (preg_match("/^\s*([a-zA-Z0-9_]+)=([a-zA-Z0-9 .&-@=_!<>\"\']+)\s*$/",$line,$matches)) { 
    10                         $conf[ $matches[1] ] = $matches[2]; 
    11                 } 
    12         } 
    13         return $conf; 
    14 } 
    15 } 
    16  
    17 $amp_conf = parse_amportal_conf("/etc/amportal.conf"); 
    18  
    1910 
    2011if (isset($amp_conf["AMPWEBADDRESS"])) { 
     
    2314define ("FSROOT", $amp_conf["AMPWEBROOT"]."/admin/cdr/"); 
    2415 
    25  
    26  
    2716define ("LIBDIR", FSROOT."lib/"); 
    2817 
    29 define ("HOST", (( !isset($amp_conf["CDRDBHOST"]) ? $amp_conf["AMPDBHOST"] : $amp_conf["CDRDBHOST"] )) ); 
    30 define ("PORT", (( !isset($amp_conf["CDRDBPORT"]) ? "5432" : $amp_conf["CDRDBPORT"] )) ); 
    31 define ("USER", (( !isset($amp_conf["CDRDBUSER"]) ? $amp_conf["AMPDBUSER"] : $amp_conf["CDRDBUSER"] )) ); 
    32 define ("PASS", (( !isset($amp_conf["CDRDBPASS"]) ? $amp_conf["AMPDBPASS"] : $amp_conf["CDRDBPASS"] )) ); 
    33 define ("DBNAME", (( !isset($amp_conf["CDRDBNAME"]) ? "asteriskcdrdb" : $amp_conf["CDRDBNAME"] )) ); 
    34 define ("DB_TYPE", (( !isset($amp_conf["CDRDBTYPE"]) ? $amp_conf["AMPDBENGINE"] : $amp_conf["CDRDBTYPE"] )) ); // mysql or postgres 
    35 define ("DB_TABLENAME", (( !isset($amp_conf["CDRDBTABLENAME"]) ? "cdr" : $amp_conf["CDRDBTABLENAME"] )) ); 
    36   
     18define ("HOST", (( (!isset($amp_conf["CDRDBHOST"]) || !$amp_conf["CDRDBHOST"]) ? $amp_conf["AMPDBHOST"] : $amp_conf["CDRDBHOST"] )) ); 
     19define ("PORT", (( (!isset($amp_conf["CDRDBPORT"]) || !$amp_conf["CDRDBPORT"]) ? "5432" : $amp_conf["CDRDBPORT"] )) ); 
     20define ("USER", (( (!isset($amp_conf["CDRDBUSER"]) || !$amp_conf["CDRDBUSER"]) ? $amp_conf["AMPDBUSER"] : $amp_conf["CDRDBUSER"] )) ); 
     21define ("PASS", (( (!isset($amp_conf["CDRDBPASS"]) || !$amp_conf["CDRDBPASS"]) ? $amp_conf["AMPDBPASS"] : $amp_conf["CDRDBPASS"] )) ); 
     22define ("DBNAME", (( (!isset($amp_conf["CDRDBNAME"]) || !$amp_conf["CDRDBNAME"]) ? "asteriskcdrdb" : $amp_conf["CDRDBNAME"] )) ); 
     23define ("DB_TYPE", (( (!isset($amp_conf["CDRDBTYPE"]) ||!$amp_conf["CDRDBTYPE"]) ? $amp_conf["AMPDBENGINE"] : $amp_conf["CDRDBTYPE"] )) ); // mysql or postgres 
     24define ("DB_TABLENAME", (( (!isset($amp_conf["CDRDBTABLENAME"]) || !$amp_conf["CDRDBTABLENAME"]) ? "cdr" : $amp_conf["CDRDBTABLENAME"] )) ); 
     25 
    3726// Regarding to the dst you can setup an application name 
    3827// Make more sense to have a text that just a number 
     
    4736 
    4837 
    49 function DbConnect() 
    50 
     38function DbConnect() { 
    5139  $options = array(); 
    52   if (DB_TYPE == "postgres") 
    53     {  
    54       $datasource = 'pgsql://'.USER.':'.PASS.'@'.HOST.'/'.DBNAME; 
    55     } 
    56   else if (DB_TYPE == "sqlite3") 
    57     { 
     40  if (DB_TYPE == "postgres") {  
     41    $datasource = 'pgsql://'.USER.':'.PASS.'@'.HOST.'/'.DBNAME; 
     42  } else if (DB_TYPE == "sqlite3") { 
    5843                /* on centos this extension is not loaded by default */ 
    5944                if (! extension_loaded('sqlite3')  && ! extension_loaded('SQLITE3')) 
     
    7055                        'portability' => DB_PORTABILITY_NUMROWS 
    7156                ); 
    72     } 
    73   else 
    74     {  
     57    }else{  
    7558      $datasource = DB_TYPE.'://'.USER.':'.PASS.'@'.HOST.'/'.DBNAME; 
     59 
    7660    } 
    7761  if(!empty($options)) 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/lib/fpdf.php

    r173 r10865  
    99* Vous pouvez utiliser et modifier ce logiciel comme vous le souhaitez.        * 
    1010*******************************************************************************/ 
    11  
     11if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    1212if(!class_exists('FPDF')) 
    1313{ 
  • freepbx/trunk/amp_conf/htdocs/admin/cdr/lib/iam_csvdump.php

    r173 r10865  
    11<?php 
    2  
     2if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    33/** 
    44 *  IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download. 
     
    88 /** 
    99 *  IAM_CSVDump A class form performing a query dump and sending it to the browser or setting it or download. 
    10  *  @author     Iván Ariel Melgrati <phpclasses@imelgrat.mailshell.com> 
     10 *  @author     Iván Ariel Melgrati <phpclasses@imelgrat.mailshell.com> 
    1111 *  @package    iam_csvdump 
    1212 *  @version 1.0 
  • freepbx/trunk/amp_conf/htdocs/admin/common/db_connect.php

    r6816 r10865  
    1414require_once('DB.php'); //PEAR must be installed 
    1515 
    16 $db_engine = $amp_conf["AMPDBENGINE"]; 
    17  
    18 switch ($db_engine) 
    19 
     16switch ($amp_conf['AMPDBENGINE']) { 
    2017  case "pgsql": 
    2118  case "mysql": 
     
    2320    dbengine://username:password@host/database */ 
    2421     
    25     $db_user = $amp_conf["AMPDBUSER"]; 
    26     $db_pass = $amp_conf["AMPDBPASS"]; 
    27     $db_host = $amp_conf["AMPDBHOST"]; 
    28     $db_name = $amp_conf["AMPDBNAME"]; 
    29      
    30     $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name; 
     22    $datasource = 'mysql://' 
     23          . $amp_conf['AMPDBUSER'] 
     24          . ':' 
     25          . $amp_conf['AMPDBPASS'] 
     26          . '@' 
     27          . $amp_conf['AMPDBHOST'] 
     28          . '/' 
     29          . $amp_conf['AMPDBNAME']; 
    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 = "sqlite3:///" . $amp_conf['AMPDBFILE'] . "?mode=0666"; 
    5549                $options = array( 
    5650                    'debug'       => 4, 
    57       'portability' => DB_PORTABILITY_NUMROWS 
     51         'portability' => DB_PORTABILITY_NUMROWS 
    5852    ); 
    5953    $db = DB::connect($datasource, $options); 
     
    6963  die_freepbx($db->getMessage());  
    7064} 
    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/trunk/amp_conf/htdocs/admin/config.php

    r10763 r10865  
    1515*/ 
    1616 
    17 // This is ugly, but it is the only way I can think of to get the menu sections localized. MC 
    18 if (false) { 
    19 _("Internal Options & Configuration"); 
    20 _("Inbound Call Control"); 
    21 _("Module Admin"); 
    22 _("System Administration"); 
    23 _("Third Party Addon"); 
    24 } 
    25  
    26 /* benchmark */ 
    27 function microtime_float() { list($usec,$sec) = explode(' ',microtime()); return ((float)$usec+(float)$sec); } 
    28 $benchmark_starttime = microtime_float(); 
    29 /*************/ 
    30  
    3117$type = isset($_REQUEST['type'])?$_REQUEST['type']:'setup'; 
    3218$display = isset($_REQUEST['display'])?$_REQUEST['display']:''; 
     
    4026$action = isset($_REQUEST['action'])?$_REQUEST['action']:null; 
    4127$quietmode = isset($_REQUEST['quietmode'])?$_REQUEST['quietmode']:''; 
    42 $skip_astman = isset($_REQUEST['skip_astman'])?$_REQUEST['skip_astman']:false; 
     28$bootstrap_settings['skip_astman'] = isset($_REQUEST['skip_astman'])?$_REQUEST['skip_astman']:false; 
    4329if (isset($_REQUEST['restrictmods'])) { 
    4430  $restrict_mods = explode('/',$_REQUEST['restrictmods']); 
     
    5541); 
    5642 
    57 include('header.php'); 
     43@header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); 
     44@header('Expires: Sat, 01 Jan 2000 00:00:00 GMT'); 
     45@header('Cache-Control: post-check=0, pre-check=0',false); 
     46@header('Pragma: no-cache'); 
     47//session_cache_limiter('public, no-store'); 
     48if (isset($_REQUEST['handler'])) { 
     49  $restrict_mods = true; 
     50  // I think reload is the only handler that requires astman, so skip it for others 
     51  switch ($_REQUEST['handler']) { 
     52  case 'reload': 
     53    break; 
     54  default: 
     55    $bootstrap_settings['skip_astman'] = true; 
     56  } 
     57
     58require('bootstrap.php'); 
     59 
    5860/* If there is an action request then some sort of update is usually being done. 
    5961   This will protect from cross site request forgeries unless disabled. 
     
    7577// handle special requests 
    7678if (isset($_REQUEST['handler'])) { 
    77   switch ($_REQUEST['handler']) { 
    78     case 'cdr': 
    79       include('cdr/cdr.php'); 
    80       break; 
    81     case 'cdr_export_csv': 
    82       include('cdr/export_csv.php'); 
    83       break; 
    84     case 'cdr_export_pdf': 
    85       include('cdr/export_pdf.php'); 
    86       break; 
    87     case 'reload': 
    88       /** AJAX handler for reload event 
    89        */ 
    90       include_once('common/json.inc.php'); 
    91       $response = do_reload(); 
    92       $json = new Services_JSON(); 
    93       header("Content-type: application/json"); 
    94       echo $json->encode($response); 
    95     break; 
    96     case 'file': 
    97       /** Handler to pass-through file requests  
    98        * Looks for "module" and "file" variables, strips .. and only allows normal filename characters. 
    99        * Accepts only files of the type listed in $allowed_exts below, and sends the corresponding mime-type,  
    100        * and always interprets files through the PHP interpreter. (Most of?) the FreePBX environment is available, 
    101        * including $db and $astman, and the user is authenticated. 
    102        */ 
    103       if (!isset($_REQUEST['module']) || !isset($_REQUEST['file'])) { 
    104         die_freepbx("unknown"); 
    105       } 
    106       //TODO: this could probably be more efficient 
    107       $module = str_replace('..','.', preg_replace('/[^a-zA-Z0-9-\_\.]/','',$_REQUEST['module'])); 
    108       $file = str_replace('..','.', preg_replace('/[^a-zA-Z0-9-\_\.]/','',$_REQUEST['file'])); 
    109        
    110       $allowed_exts = array( 
    111         '.js' => 'text/javascript', 
    112         '.js.php' => 'text/javascript', 
    113         '.css' => 'text/css', 
    114         '.css.php' => 'text/css', 
    115         '.html.php' => 'text/html', 
    116         '.jpg.php' => 'image/jpeg', 
    117         '.jpeg.php' => 'image/jpeg', 
    118         '.png.php' => 'image/png', 
    119         '.gif.php' => 'image/gif', 
    120       ); 
    121       foreach ($allowed_exts as $ext=>$mimetype) { 
    122         if (substr($file, -1*strlen($ext)) == $ext) { 
    123           $fullpath = 'modules/'.$module.'/'.$file; 
    124           if (file_exists($fullpath)) { 
    125             // file exists, and is allowed extension 
    126  
    127             // image, css, js types - set Expires to an hour in advance so the client does 
    128             // not keep checking for them. Replace from header.php 
    129             if (!$amp_conf['DEVEL']) { 
    130               @header('Expires: '.gmdate('D, d M Y H:i:s', time()+3600).' GMT', true); 
    131               @header('Cache-Control: ',true);  
    132               @header('Pragma: ', true);  
    133             } 
    134             @header("Content-type: ".$mimetype); 
    135             include($fullpath); 
    136             exit(); 
    137           } 
    138           break; 
    139         } 
    140       } 
    141       die_freepbx("not allowed"); 
    142     break; 
    143   } 
    144   exit(); 
    145 
    146  
     79  $module = isset($_REQUEST['module'])  ? $_REQUEST['module'] : ''; 
     80  $file   = isset($_REQUEST['file'])    ? $_REQUEST['file']   : ''; 
     81  fileRequestHandler($_REQUEST['handler'], $module, $file); 
     82
     83   
    14784if (!$quietmode) { 
    14885  module_run_notification_checks(); 
    14986} 
    15087 
    151 $framework_asterisk_running =  checkAstMan(); 
    152  
    153 // get all enabled modules 
    154 // active_modules array used below and in drawselects function and genConf function 
    155 $active_modules = module_getinfo(false, MODULE_STATUS_ENABLED); 
    156  
     88//draw up freepbx menu 
    15789$fpbx_menu = array(); 
    158  
    159  
    16090// pointer to current item in $fpbx_menu, if applicable 
    16191$cur_menuitem = null; 
     
    16393// add module sections to $fpbx_menu 
    16494$types = array(); 
     95 
    16596if(is_array($active_modules)){ 
    16697  foreach($active_modules as $key => $module) { 
    167     //include module functions 
    168     if ((!$restrict_mods || isset($restrict_mods[$key])) && is_file("modules/{$key}/functions.inc.php")) { 
    169       require_once("modules/{$key}/functions.inc.php"); 
    170     } 
    171      
     98   
    17299    //create an array of module sections to display 
    173100    // stored as [items][$type][$category][$name] = $displayvalue 
     
    177104 
    178105        // check access, unless module.xml defines all have access 
     106        //TODO: move this to bootstrap and make it work 
    179107        if (!isset($item['access']) || strtolower($item['access']) != 'all') { 
    180108          if (!$_SESSION["AMP_user"]->checkSection($itemKey)) { 
     
    184112        } 
    185113 
    186         if (!$framework_asterisk_running &&  
    187             ((isset($item['needsenginedb']) && strtolower($item['needsenginedb'] == 'yes')) ||  
    188             (isset($item['needsenginerunning']) && strtolower($item['needsenginerunning'] == 'yes'))) 
    189            ) 
    190         { 
    191           $item['disabled'] = true; 
    192         } else { 
    193           $item['disabled'] = false; 
    194         } 
    195  
    196114        if (!in_array($item['type'], $types)) { 
    197115          $types[] = $item['type']; 
     
    222140  } 
    223141} 
     142 
    224143sort($types); 
    225144 
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r10763 r10865  
    1313 
    1414//include all necessary classes TODO: include them dynamically as needed 
    15 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/config.functions.php'); 
    16 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/featurecodes.class.php'); 
    17 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/components.class.php'); 
    18 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/notifications.class.php'); 
    19 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/moduleHook.class.php'); 
    20 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/modulelist.class.php'); 
    21 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/cronmanager.class.php'); 
    22 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/ampuser.class.php'); 
    23 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/xml2Array.class.php'); 
     15$dirname = dirname(__FILE__); 
     16 
     17require_once($dirname . '/libraries/components.class.php'); 
     18require_once($dirname . '/libraries/xml2Array.class.php'); 
     19require_once($dirname . '/libraries/cronmanager.class.php'); 
     20require_once($dirname . '/libraries/moduleHook.class.php'); 
     21require_once($dirname . '/libraries/notifications.class.php'); 
     22require_once($dirname . '/libraries/ampuser.class.php'); 
     23require_once($dirname . '/libraries/components.class.php'); 
     24require_once($dirname . '/libraries/modulelist.class.php'); 
     25require_once($dirname . '/libraries/config.functions.php'); 
     26require_once($dirname . '/libraries/featurecodes.class.php'); 
    2427 
    2528//include other files 
    26 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/module.functions.php'); 
    27 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/usage_registry.functions.php'); 
    28 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/php-upgrade.functions.php'); 
    29 require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/sql.functions.php'); 
     29require_once($dirname . '/libraries/module.functions.php'); 
     30require_once($dirname . '/libraries/usage_registry.functions.php'); 
     31require_once($dirname . '/libraries/php-upgrade.functions.php'); 
     32require_once($dirname . '/libraries/sql.functions.php'); 
    3033 
    3134// returns true if extension is within allowed range 
     
    888891function dbug(){ 
    889892  $opts = func_get_args(); 
     893  $disc = $msg = $dump = null; 
    890894 
    891895  $dump = 0; 
     
    951955   
    952956} 
     957 
     958//http://php.net/manual/en/function.set-error-handler.php 
     959function freepbx_error_handler($errno, $errstr, $errfile, $errline,  $errcontext) { 
     960  $txt = date("Y-M-d H:i:s") 
     961    . "\t" . $errfile . ':' . $errline  
     962    . "\n\n" 
     963    . 'ERROR[' . $errno . ']: ' 
     964    . $errstr 
     965    . "\n\n\n"; 
     966  dbug_write($txt,$check=''); 
     967} 
     968 
    953969/** Log an error to the (database-based) log 
    954970 * @param  string   The section or script where the error occurred 
  • freepbx/trunk/amp_conf/htdocs/admin/libraries/config.functions.php

    r10843 r10865  
    6464 
    6565function parse_amportal_conf($filename) { 
    66   global $amp_conf_defaults
     66  global $amp_conf_defaults, $db
    6767 
    6868  /* defaults 
     
    7070   * components don't have to keep being 'gun shy' about these variables. 
    7171   *  
     72   * we will read these settings out of the db, but only when $filename is writeable 
     73   * otherwise, we read the $filename 
    7274   */ 
    73   $file = file($filename); 
    74   if (is_array($file)) { 
    75     foreach ($file as $line) { 
    76       if (preg_match("/^\s*([a-zA-Z0-9_]+)=([a-zA-Z0-9 .&-@=_!<>\"\']+)\s*$/",$line,$matches)) { 
    77         $conf[ $matches[1] ] = $matches[2]; 
     75  if (!is_writable($filename)) { 
     76    $file = file($filename);  
     77      if (is_array($file)) {  
     78        foreach ($file as $line) {  
     79          if (preg_match("/^\s*([a-zA-Z0-9_]+)=([a-zA-Z0-9 .&-@=_!<>\"\']+)\s*$/",$line,$matches)) {  
     80            $conf[ $matches[1] ] = $matches[2];  
     81          }  
     82        }  
     83        $conf['amportal_canwrite'] = false; 
     84      } else {  
     85        die_freepbx("<h1>".sprintf(_("Missing or unreadable config file (%s)...cannot continue"), $filename)."</h1>");  
    7886      } 
     87  } else { 
     88    $sql = 'SELECT `key`, value FROM freepbx_settings'; 
     89    $conf = $db->getAssoc($sql); 
     90    if(DB::IsError($conf)) {      
     91      die_freepbx($conf->getMessage());  
     92    } else { 
     93      $conf['amportal_canwrite'] = true; 
    7994    } 
    80   } else { 
    81     die_freepbx("<h1>".sprintf(_("Missing or unreadable config file (%s)...cannot continue"), $filename)."</h1>"); 
     95     
    8296  } 
    8397   
     98 
    8499  // set defaults 
    85100  foreach ($amp_conf_defaults as $key=>$arr) { 
  • freepbx/trunk/amp_conf/htdocs/admin/libraries/framework_view.functions.php

    r10763 r10865  
    11<?php 
    22 
     3@session_start(); 
    34if (isset($_REQUEST['logout'])) { 
    45  // logging out.. 
     
    3435    if (!isset($_SESSION['AMP_user'])) { 
    3536      // not logged in, send headers 
    36       @header('WWW-Authenticate: Basic realm="FreePBX '._('Administration').'"'); 
     37      @header('WWW-Authenticate: Basic realm="'._('FreePBX Administration').'"'); 
    3738      @header('HTTP/1.0 401 Unauthorized'); 
    3839      showview("unauthorized"); 
    3940      exit; 
    4041    } 
     42    define('FREEPBX_IS_AUTH', 'TRUE'); 
    4143  case 'none': 
    4244    if (!isset($_SESSION['AMP_user'])) { 
     
    4446      $_SESSION['AMP_user']->setAdmin(); 
    4547    } 
     48    define('FREEPBX_IS_AUTH', 'TRUE'); 
    4649  break; 
    4750  case 'database': 
     
    6467            // set admin access 
    6568            $_SESSION['AMP_user']->setAdmin(); 
     69            define('FREEPBX_IS_AUTH', 'TRUE'); 
    6670          } else { 
    6771            // password failed and admin user fall-back failed 
     
    7478    if (!isset($_SESSION['AMP_user'])) { 
    7579      // not logged in, send headers 
    76       @header('WWW-Authenticate: Basic realm="FreePBX '._('Administration').'"'); 
     80      @header('WWW-Authenticate: Basic realm=" '._('FreePBX Administration').'"'); 
    7781      @header('HTTP/1.0 401 Unauthorized'); 
    7882      showview("unauthorized"); 
    7983      exit; 
     84    } 
     85    if (!defined('FREEPBX_IS_AUTH')) { 
     86      define('FREEPBX_IS_AUTH', 'TRUE'); 
    8087    } 
    8188  break; 
     
    96103  } else { 
    97104    $nt->delete('ari', 'ARI_ADMIN_PASSWORD'); 
     105  } 
     106   
     107  if ($amp_conf['AMPDBPASS'] == $amp_conf_defaults['AMPDBPASS'][1]) { 
     108    $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")); 
     109  } else { 
     110    $nt->delete('core', 'AMPDBPASS'); 
     111  } 
     112   
     113  // Check and increase php memory_limit if needed and if allowed on the system 
     114  // 
     115  $current_memory_limit = rtrim(ini_get('memory_limit'),'M'); 
     116  $proper_memory_limit = '100'; 
     117  if ($current_memory_limit < $proper_memory_limit) { 
     118    if (ini_set('memory_limit',$proper_memory_limit.'M') !== false) { 
     119      $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)); 
     120    } else { 
     121      $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)); 
     122    } 
     123  } else { 
     124    $nt->delete('core', 'MEMLIMIT'); 
     125  } 
     126 
     127  // send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not 
     128  // 
     129  if(get_magic_quotes_gpc()) { 
     130    $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")); 
     131  } else { 
     132    $nt->delete('core', 'MQGPC'); 
    98133  } 
    99134} 
     
    118153 */ 
    119154function showview($viewname, $parameters = false) { 
     155  global $amp_conf, $db; 
    120156  if (is_array($parameters)) { 
    121157    extract($parameters); 
    122158  } 
    123    
     159 
    124160  $viewname = str_replace('..','.',$viewname); // protect against going to subdirectories 
    125161  if (file_exists('views/'.$viewname.'.php')) { 
     
    159195    case 'reload': 
    160196      // AJAX handler for reload event 
    161       //include_once('../common/json.inc.php'); 
    162197      $response = do_reload(); 
    163       //$json = new Services_JSON(); 
    164198      header("Content-type: application/json"); 
    165       //echo $json->encode($response); 
    166199      echo json_encode($response); 
    167200    break; 
  • freepbx/trunk/amp_conf/htdocs/admin/libraries/module.functions.php

    r10699 r10865  
    10551055  // Now make sure all feature codes are uninstalled in case the module has not already done it 
    10561056  // 
    1057   require_once( (defined('AMP_BASE_INCLUDE_PATH') ? AMP_BASE_INCLUDE_PATH.'/' : '').'libraries/featurecodes.class.php'); 
     1057  require_once(dirname(__FILE__) . '/featurecodes.class.php'); //TODO: do we need this, now that we have bootstrap? -MB 
    10581058  featurecodes_delModuleFeatures($modulename); 
    10591059   
  • freepbx/trunk/amp_conf/htdocs/admin/libraries/php-asmanager.php

    r10558 r10865  
    2727* 
    2828*/ 
    29   if(!defined("AMP_CONF")) { define("AMP_CONF", "/etc/amportal.conf"); } 
     29  
     30$restrict_mods = false; 
     31$skip_astman = true; 
     32 
     33if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     34  include_once('/etc/asterisk/freepbx.conf'); 
     35
    3036 
    3137  define('AST_CONFIG_DIR', $amp_conf['ASTETCDIR']); 
  • freepbx/trunk/amp_conf/htdocs/admin/libraries/xml2Array.class.php

    r10244 r10865  
    134134  } 
    135135} 
    136  
    137136 
    138137/* 
     
    203202  } 
    204203} 
    205  
    206 ?> 
  • freepbx/trunk/amp_conf/htdocs/admin/panel.php

    r6976 r10865  
    1212//GNU General Public License for more details. 
    1313 
     14$restrict_mods = true; 
     15$skip_astman = true; 
    1416$quietmode = isset($_REQUEST['quietmode'])?$_REQUEST['quietmode']:''; 
    15  
    16 include 'header.php'; 
     17if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     18  include_once('/etc/asterisk/freepbx.conf'); 
     19
     20if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    1721 
    1822$title=_("FreePBX: Flash Operator Panel"); 
  • freepbx/trunk/amp_conf/htdocs/admin/reports.php

    r10243 r10865  
    1111//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1212//GNU General Public License for more details. 
    13  
     13$restrict_mods = true; 
     14if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     15  include_once('/etc/asterisk/freepbx.conf'); 
     16
     17if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } 
    1418$quietmode = isset($_REQUEST['quietmode'])?$_REQUEST['quietmode']:''; 
    15  
    16 include 'header.php'; 
    1719 
    1820$title=_("FreePBX: Call Detail Reports"); 
  • freepbx/trunk/amp_conf/htdocs/admin/views/freepbx_admin.php

    r10285 r10865  
    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'; 
  • freepbx/trunk/amp_conf/htdocs/recordings/includes/bootstrap.php

    r9663 r10865  
    100100  global $SETTINGS_MAX_FILES; 
    101101  $SETTINGS_MAX_FILES = isset($SETTINGS_MAX_FILES) ? $SETTINGS_MAX_FILES : 3000; 
    102  
    103   $files = array(); 
     102  $fileCount=0; 
     103 $files = array(); 
    104104 
    105105  if (@is_dir($path) && @is_readable($path)) { 
     
    262262    set_time_limit(360); 
    263263    session_start(); 
     264  $_SESSION['ari_error'] = ''; 
    264265  } 
    265266} 
     
    274275 
    275276  // set error reporting 
    276   error_reporting (E_ALL & ~ E_NOTICE);   
     277//  error_reporting (E_ALL & ~ E_NOTICE);   
    277278} 
    278279 
     
    315316include_once("./includes/login.php"); 
    316317 
    317  
    318318?> 
  • freepbx/trunk/amp_conf/htdocs/recordings/includes/common.php

    r10317 r10865  
    1212 
    1313  if ($_SESSION['ari_error']) { 
    14     $ret .= "<div class='error'> 
     14    $ret = "<div class='error'> 
    1515               " . $_SESSION['ari_error'] . " 
    1616             </div> 
     
    9292 */ 
    9393function databaseLogon() { 
    94  
    95   global $STANDALONE; 
    96  
    97   global $ASTERISKMGR_DBHOST; 
    98  
    99   global $AMP_FUNCTIONS_FILES; 
    100   global $AMPORTAL_CONF_FILE; 
    101  
    102   global $LEGACY_AMP_DBENGINE; 
    103   global $LEGACY_AMP_DBFILE; 
    104   global $LEGACY_AMP_DBHOST; 
    105   global $LEGACY_AMP_DBNAME; 
    106  
    107   global $ASTERISKCDR_DBENGINE; 
    108   global $ASTERISKCDR_DBFILE; 
    109   global $ASTERISKCDR_DBHOST; 
    110   global $ASTERISKCDR_DBNAME; 
    111  
    112   global $ARI_DISABLED_MODULES; 
    113    
    114   global $ARI_ADMIN_USERNAME; 
    115   global $ARI_ADMIN_PASSWORD; 
    116   global $ariadminusername; 
    117   global $ariadminpassword; 
    118  
    119   global $loaded_modules; 
     94  global $STANDALONE; 
     95 
     96  global $ASTERISKMGR_DBHOST; 
     97 
     98  global $AMP_FUNCTIONS_FILES; 
     99  global $AMPORTAL_CONF_FILE; 
     100 
     101  global $LEGACY_AMP_DBENGINE; 
     102  global $LEGACY_AMP_DBFILE; 
     103  global $LEGACY_AMP_DBHOST; 
     104  global $LEGACY_AMP_DBNAME; 
     105 
     106  global $ASTERISKCDR_DBENGINE; 
     107  global $ASTERISKCDR_DBFILE; 
     108  global $ASTERISKCDR_DBHOST; 
     109  global $ASTERISKCDR_DBNAME; 
     110 
     111  global $ARI_DISABLED_MODULES; 
     112 
     113  global $ARI_ADMIN_USERNAME; 
     114  global $ARI_ADMIN_PASSWORD; 
     115  global $ariadminusername; 
     116  global $ariadminpassword; 
     117 
     118  global $loaded_modules; 
    120119 
    121120  // This variable is a global in the FreePBX function.inc.php but needs to be 
     
    126125 
    127126  // get user 
    128   if ($STANDALONE['use']) { 
    129  
    130     $mgrhost = $ASTERISKMGR_DBHOST; 
    131     $mgruser = $STANDALONE['asterisk_mgruser']; 
    132     $mgrpass = $STANDALONE['asterisk_mgrpass']; 
    133  
    134     $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; 
    135     $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; 
    136     $asteriskcdr_dbuser = $STANDALONE['asteriskcdr_dbuser']; 
    137     $asteriskcdr_dbpass = $STANDALONE['asteriskcdr_dbpass']; 
    138     $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; 
    139     $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; 
    140   }  
    141   else { 
    142  
    143     $include = 0; 
    144     $files = preg_split('/;/',$AMP_FUNCTIONS_FILES); 
    145     foreach ($files as $file) { 
    146       if (is_file($file)) { 
    147         include_once($file); 
    148         $include = 1; 
    149       } 
    150     } 
    151  
    152     if ($include) { 
    153       global $amp_conf; 
    154       $amp_conf = parse_amportal_conf($AMPORTAL_CONF_FILE); 
    155       $ariadminusername = isset($amp_conf["ARI_ADMIN_USERNAME"]) ? $amp_conf["ARI_ADMIN_USERNAME"] : $ARI_ADMIN_USERNAME; 
    156       $ariadminpassword = isset($amp_conf["ARI_ADMIN_PASSWORD"]) ? $amp_conf["ARI_ADMIN_PASSWORD"] : $ARI_ADMIN_PASSWORD; 
    157       $mgrhost = $ASTERISKMGR_DBHOST; 
    158       $mgruser = $amp_conf['AMPMGRUSER']; 
    159       $mgrpass = $amp_conf['AMPMGRPASS']; 
    160  
    161       $amp_dbengine = isset($amp_conf["AMPDBENGINE"]) ? $amp_conf["AMPDBENGINE"] : $LEGACY_AMP_DBENGINE; 
    162       $amp_dbfile = isset($amp_conf["AMPDBFILE"]) ? $amp_conf["AMPDBFILE"] : $LEGACY_AMP_DBFILE; 
    163       $amp_dbuser = $amp_conf["AMPDBUSER"]; 
    164       $amp_dbpass = $amp_conf["AMPDBPASS"]; 
    165       $amp_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $LEGACY_AMP_DBHOST; 
    166       $amp_dbname = isset($amp_conf["AMPDBNAME"]) ? $amp_conf["AMPDBNAME"] : $LEGACY_AMP_DBNAME; 
    167  
    168       $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; 
    169       $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; 
    170       $asteriskcdr_dbuser = $amp_conf["AMPDBUSER"]; 
    171       $asteriskcdr_dbpass = $amp_conf["AMPDBPASS"]; 
    172       $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; 
    173       $asteriskcdr_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $ASTERISKCDR_DBHOST; 
    174       $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; 
    175  
    176       global $amp_usedevstate; 
    177       $amp_usedevstate = isset($amp_conf["USEDEVSTATE"]) ? strtolower(trim($amp_conf["USEDEVSTATE"])) : 0; 
    178       if ($amp_usedevstate == 'yes' || $amp_usedevstate == 'true' || $amp_usedevstate == 'on' || $amp_usedevstate == '1') { 
    179         $amp_usedevstate = 1; 
    180       } else { 
    181         $amp_usedevstate = 0; 
    182       } 
    183  
    184     }  
    185   } 
    186  
    187   // asterisk manager interface (berkeley database I think) 
    188   global $asterisk_manager_interface; 
    189   $asterisk_manager_interface = new AsteriskManagerInterface(); 
    190  
    191   $success = $asterisk_manager_interface->Connect($mgrhost,$mgruser,$mgrpass); 
    192   if (!$success) { 
    193     $_SESSION['ari_error'] =   
    194       _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" .  
    195       _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" .  
    196       _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
    197       _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
    198     return FALSE; 
    199   } 
    200  
    201   // php-agi asterisk manager interface proxy 
    202   global $astman; 
    203   $astman = new AGI_AsteriskManager(); 
    204  
    205   // attempt to connect to asterisk manager proxy 
    206   if (!isset($amp_conf["ASTMANAGERPROXYPORT"]) || !$res = $astman->connect("127.0.0.1:".$amp_conf["ASTMANAGERPROXYPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], 'off')) 
    207   { 
    208         // attempt to connect directly to asterisk, if no proxy or if proxy failed 
    209         if (!$res = $astman->connect("127.0.0.1:".$amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"], 'off')) 
    210         { 
    211                 // couldn't connect at all 
    212                 unset( $astman ); 
    213                 $_SESSION['ari_error'] = 
    214                 _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" . 
    215                 _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" . 
    216                 _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
    217                 _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
    218         } 
    219   } 
    220  
    221   // pear interface databases 
    222   $db = new Database(); 
    223  
    224   // AMP asterisk database 
    225   if (!$STANDALONE['use']) { 
    226     $_SESSION['dbh_asterisk'] = $db->logon($amp_dbengine, 
    227                                            $amp_dbfile, 
    228                                            $amp_dbuser,  
    229                                            $amp_dbpass, 
    230                                            $amp_dbhost, 
    231                                            $amp_dbname); 
    232     if (!isset($_SESSION['dbh_asterisk'])) { 
    233       $_SESSION['ari_error'] .= _("Cannot connect to the $amp_dbname database") . "<br>" . 
    234                                _("Check AMP installation, asterisk, and ARI main.conf"); 
    235       return FALSE; 
    236     } 
    237   } 
     127  if ($STANDALONE['use']) { 
     128    $mgrhost = $ASTERISKMGR_DBHOST; 
     129    $mgruser = $STANDALONE['asterisk_mgruser']; 
     130    $mgrpass = $STANDALONE['asterisk_mgrpass']; 
     131    $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; 
     132    $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; 
     133    $asteriskcdr_dbuser = $STANDALONE['asteriskcdr_dbuser']; 
     134    $asteriskcdr_dbpass = $STANDALONE['asteriskcdr_dbpass']; 
     135    $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; 
     136    $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; 
     137  } else { 
     138     
     139    global $amp_conf, $amp_usedevstate; 
     140    $ariadminusername = isset($amp_conf["ARI_ADMIN_USERNAME"]) ? $amp_conf["ARI_ADMIN_USERNAME"] : $ARI_ADMIN_USERNAME; 
     141    $ariadminpassword = isset($amp_conf["ARI_ADMIN_PASSWORD"]) ? $amp_conf["ARI_ADMIN_PASSWORD"] : $ARI_ADMIN_PASSWORD; 
     142    $mgrhost = $ASTERISKMGR_DBHOST; 
     143    $mgruser = $amp_conf['AMPMGRUSER']; 
     144    $mgrpass = $amp_conf['AMPMGRPASS']; 
     145 
     146    $amp_dbengine = isset($amp_conf["AMPDBENGINE"]) ? $amp_conf["AMPDBENGINE"] : $LEGACY_AMP_DBENGINE; 
     147    $amp_dbfile = isset($amp_conf["AMPDBFILE"]) ? $amp_conf["AMPDBFILE"] : $LEGACY_AMP_DBFILE; 
     148    $amp_dbuser = $amp_conf["AMPDBUSER"]; 
     149    $amp_dbpass = $amp_conf["AMPDBPASS"]; 
     150    $amp_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $LEGACY_AMP_DBHOST; 
     151    $amp_dbname = isset($amp_conf["AMPDBNAME"]) ? $amp_conf["AMPDBNAME"] : $LEGACY_AMP_DBNAME; 
     152 
     153    $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; 
     154    $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; 
     155    $asteriskcdr_dbuser = $amp_conf["AMPDBUSER"]; 
     156    $asteriskcdr_dbpass = $amp_conf["AMPDBPASS"]; 
     157    $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; 
     158    $asteriskcdr_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $ASTERISKCDR_DBHOST; 
     159    $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; 
     160     
     161    $amp_usedevstate = isset($amp_conf["USEDEVSTATE"]) ? strtolower(trim($amp_conf["USEDEVSTATE"])) : 0; 
     162    if ($amp_usedevstate == 'yes' || $amp_usedevstate == 'true' || $amp_usedevstate == 'on' || $amp_usedevstate == '1') { 
     163      $amp_usedevstate = 1; 
     164    } else { 
     165      $amp_usedevstate = 0; 
     166    } 
     167 
     168  } 
     169 
     170  // asterisk manager interface (berkeley database I think) 
     171  global $asterisk_manager_interface; 
     172  $asterisk_manager_interface = new AsteriskManagerInterface(); 
     173 
     174  $success = $asterisk_manager_interface->Connect($mgrhost,$mgruser,$mgrpass); 
     175  if (!$success) { 
     176    $_SESSION['ari_error'] =   
     177      _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" .  
     178      _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" .  
     179      _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
     180      _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
     181    return FALSE; 
     182  } 
     183 
     184 
     185  global $astman; 
     186  if (!isset($astman) || !$astman) { 
     187    // couldn't connect to astman 
     188        $_SESSION['ari_error'] = 
     189        _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" . 
     190        _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" . 
     191        _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . 
     192        _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); 
     193  } 
     194 
     195 
     196  global $db; 
     197  if (isset($db) && $db) { 
     198    $_SESSION['dbh_asterisk'] = $db; 
     199  } else { 
     200    $_SESSION['ari_error'] .= _("Cannot connect to the $amp_dbname database") . "<br>" . 
     201                              _("Check AMP installation, asterisk, and ARI main.conf"); 
     202     return FALSE; 
     203
    238204 
    239205  // cdr database 
    240206  if (in_array('callmonitor',array_keys($loaded_modules))) { 
    241     $_SESSION['dbh_cdr'] = $db->logon($asteriskcdr_dbengine, 
     207   $cdrdb = new Database(); 
     208    $_SESSION['dbh_cdr'] = $cdrdb->logon($asteriskcdr_dbengine, 
    242209                                      $asteriskcdr_dbfile, 
    243210                                      $asteriskcdr_dbuser,  
     
    433400  // login to database 
    434401  $success = databaseLogon(); 
     402 
    435403  if ($success) { 
    436404 
     
    444412 
    445413    $display = new Display(); 
    446  
     414   
     415  $content = ''; 
    447416    $content .= $display->displayHeaderText("ARI"); 
    448417    $content .= $display->displayLine(); 
     
    486455include_once("./includes/callme.php"); 
    487456include_once("../admin/functions.inc.php"); 
    488 include_once("../admin/common/php-asmanager.php"); 
     457include_once("../admin/libraries/php-asmanager.php"); 
    489458 
    490459?> 
  • freepbx/trunk/amp_conf/htdocs/recordings/includes/main.conf.php

    r9651 r10865  
    1515$AMPORTAL_CONF_FILE = "/etc/amportal.conf"; 
    1616 
    17 $amp_conf = parse_amportal_conf($AMPORTAL_CONF_FILE); 
     17//$amp_conf = parse_amportal_conf($AMPORTAL_CONF_FILE); 
    1818# 
    1919# Host for Asterisk Manager Interface 
  • freepbx/trunk/amp_conf/htdocs/recordings/index.php

    r1065 r10865  
    55 * main 
    66 */ 
    7  
     7if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { 
     8  include_once('/etc/asterisk/freepbx.conf'); 
     9
    810include_once("includes/bootstrap.php"); 
    911ariPageHeader(); 
  • freepbx/trunk/amp_conf/htdocs/recordings/theme/page.tpl.php

    r9462 r10865  
    3636          <div><img height=4 src="theme/spacer.gif" alt=""></div>  
    3737          <div class="nav"> 
    38             <?php if ($nav_menu != '') { ?> 
     38            <?php if (isset($nav_menu) && $nav_menu != '') { ?> 
    3939              <b class='nav_b1'></b><b class='nav_b2'></b><b class='nav_b3'></b><b class='nav_b4'></b> 
    4040              <div id='nav_menu'> 
     
    4545          </div> 
    4646          <div><img height=14 src="theme/spacer.gif" alt=""></div>  
    47           <?php if ($subnav_menu != '') { ?> 
     47          <?php if (isset($subnav_menu) && $subnav_menu != '') { ?> 
    4848            <div class="subnav"> 
    4949              <div class="subnav_title"><?php echo _("Folders")?>:</div> 
     
    5959      <span class="right"> 
    6060        <div id="center"> 
    61           <?php if ($login != "") { ?> 
     61          <?php if (isset($login) && $login != "") { ?> 
    6262            <?php print($login) ?> 
    6363          <?php } ?> 
     
    8686  </body> 
    8787</html> 
    88  
  • freepbx/trunk/amp_conf/sbin/amportal

    r4993 r10865  
    33ROOT_UID=0   # root uid is 0 
    44E_NOTROOT=67   # Non-root exit error 
    5  
     5# define freepbx config file if not alreaddy set 
     6if [ ! -n "$FREEPBX_CONF" ]; then 
     7  FREEPBX_CONF="/etc/freepbx.conf" 
     8fi 
    69 
    710echo 
     
    1417fi 
    1518 
    16 # make sure config file exists 
    17 if [ ! -e "/etc/amportal.conf" ]       # Check if file exists. 
    18   then 
    19     echo; 
    20     echo "/etc/amportal.conf does not exist!"; 
    21   echo "Have you installed the AMP configuration?"; 
     19# get settings from db/config file 
     20 
     21if [[ -e $FREEPBX_CONF && -w "/etc/amportal.conf" ]]; then        # Check if file exists. 
     22 
     23  php -r > /dev/null 2>&1 
     24  if [ $? -eq 0 ]; then 
     25    echo "running php" 
     26      `php -r ' 
     27    $bootstrap_settings["freepbx_auth"] = false; 
     28    $bootstrap_settings["skip_astman"] = true; 
     29    $restrict_mods = true; 
     30    if (!@include_once(getenv("FREEPBX_CONF") ? getenv("FREEPBX_CONF") : "/etc/freepbx.conf")) { 
     31      include_once("/etc/asterisk/freepbx.conf"); 
     32    } 
     33    foreach($amp_conf as $key => $val) { 
     34      if (is_bool($val)) { 
     35        echo "export " . trim($key) . "=" . ($val?"TRUE":"FALSE") ."\n"; 
     36      } else { 
     37        echo "export " . trim($key) . "=" . escapeshellcmd(trim($val)) ."\n"; 
     38      } 
     39    } 
     40    '` 
     41  elif [ -e "/var/lib/asterisk/bin/gen_amp_conf.php" ]; then 
     42    echo "running gen_amp_conf.php" 
     43    `/var/lib/asterisk/bin/gen_amp_conf.php` 
     44  elif [ -e "/etc/amportal.conf" ]; then # Check if file exists. 
     45    echo "running amportal.conf" 
     46    . /etc/amportal.conf 
     47  else 
     48    echo; 
     49    echo "FreePBX config file not found!"; 
     50    echo "Have you installed FreePBX?"; 
     51    exit; 
     52  fi 
     53elif [ -e "/etc/amportal.conf" ]; then # Check if file exists. 
     54  . /etc/amportal.conf 
     55else  
     56  echo; 
     57  echo "FreePBX config file not found!"; 
     58  echo "Have you installed FreePBX?"; 
    2259  exit; 
    2360fi 
    24 . /etc/amportal.conf 
    2561 
    26 if [ -x ${AMPBIN}/freepbx_engine ] 
    27 then 
     62if [ -x ${AMPBIN}/freepbx_engine ]; then 
    2863  ${AMPBIN}/freepbx_engine $@ 
    29 elif [ -x ${ASTVARLIBDIR}/bin/freepbx_engine ] 
    30 then 
     64elif [ -x ${ASTVARLIBDIR}/bin/freepbx_engine ]; then 
    3165  ${ASTVARLIBDIR}/bin/freepbx_engine $@ 
    32 elif [ -x /var/lib/asterisk/bin/freepbx_engine ] 
    33 then 
     66elif [ -x /var/lib/asterisk/bin/freepbx_engine ]; then 
    3467  /var/lib/asterisk/bin/freepbx_engine $@ 
    3568else 
  • freepbx/trunk/upgrades/2.9.0alpha1/migrate_ampconf.php

    r10579 r10865  
    11<?php 
     2//TODO: revisit migration once we have further refined the amportal.conf in a db 
     3//      architecture. We need a class that allows modules to add their own values 
     4//      or remove them much like feature codes, also need some concept of sections 
     5//      which is not necessarily per module. 
     6if (! function_exists("out")) { 
     7  function out($text) { 
     8    echo $text."<br />"; 
     9  } 
     10} 
     11 
     12if (! function_exists("outn")) { 
     13  function outn($text) { 
     14    echo $text; 
     15  } 
     16} 
     17 
    218global $db, $amp_conf; 
    319 
     20outn(_("Preparing to migrate amportal.conf settings..")); 
    421$sql = 'SELECT count(*) FROM freepbx_settings'; 
    522$result = $db->query($sql); 
     
    724if(DB::IsError($result)){ 
    825  $sql[] = "CREATE TABLE `freepbx_settings` ( 
    9     `key` varchar(25) default NULL, 
    10     `value` varchar(100) default NULL, 
     26    `key` varchar(50) default NULL, 
     27    `value` varchar(255) default NULL, 
    1128    `level` int(11) default '0', 
    1229    `description` text default NULL, 
    1330    `type` varchar(25) default NULL, 
    14     `options` varchar(500) default NULL, 
    15     `defaultval` varchar(100) default NULL, 
     31    `options` blob default NULL, 
     32    `defaultval` varchar(255) default NULL, 
    1633    `readonly` varchar(15) default NULL, 
    1734    `hidden` varchar(15) default NULL, 
     
    2845    ('AMPDBHOST','localhost',0,'Hostname where the database asterisk is located<br>Default = localhost','text',NULL,'localhost',NULL,NULL), 
    2946    ('AMPDBNAME','asterisk',0,'Name of the FreePBX database<br>Default = asterisk','text',NULL,'asterisk',NULL,NULL), 
    30     ('AMPDBPASS','fpbx',0,'Password for accessing the database asterisk. Used in combination with AMPDBUSER<br>Default = amp109','text',NULL,NULL,NULL,NULL), 
    31     ('AMPDBUSER','freepbx',0,'Username for accessing the database asterisk<br>Default = asteriskuser','text',NULL,NULL,NULL,NULL), 
     47    ('AMPDBPASS','amp109',0,'Password for accessing the database asterisk. Used in combination with AMPDBUSER<br>Default = amp109','text',NULL,NULL,NULL,NULL), 
     48    ('AMPDBUSER','asteriskuser',0,'Username for accessing the database asterisk<br>Default = asteriskuser','text',NULL,NULL,NULL,NULL), 
    3249    ('AMPDISABLELOG','TRUE',0,'Whether or not to invoke the FreePBX log facility<br>Default = true','select','TRUE,FALSE','TRUE',NULL,NULL), 
    3350    ('AMPENABLEDEVELDEBUG','FALSE',0,'Whether or not to include log messages marked as <b>devel-debug</b> in the log system<br>Default = false','select','TRUE,FALSE','FALSE',NULL,NULL), 
     
    4461    ('ARI_ADMIN_PASSWORD','ari_password',0,'This is the default admin password to allow an administrator to login to ARI bypassing all security. Change this to a secure password.Default = not set','text',NULL,'ari_password',NULL,NULL), 
    4562    ('ARI_ADMIN_USERNAME','',0,'This is the default admin name used to allow an administrator to login to ARI bypassing all security. Change this to whatever you want, dont forget to change the ARI_ADMIN_PASSWORD as well.Default = not set','text',NULL,'admin',NULL,NULL), 
    46     ('ASTMANAGER','',0,'Port for the Asterisk Manager<br>Default = 5028','text',NULL,'5038',NULL,NULL), 
    47     ('ASTMANAGERHOST','localhost',0,'Hostname for the Asterisk Manager<br>Default = localhost','text',NULL,'localhost',NULL,NULL), 
     63    ('ASTAGIDIR','/var/lib/asterisk/agi-bin',0,'This is the default directory for Asterisks agi files<br>Default = /var/lib/asterisk/agi-bin','text',NULL,'/var/lib/asterisk/agi-bin',NULL,NULL),  
     64    ('ASTETCDIR','/etc/asterisk',0,'This is the default directory for Asterisks configuration files<br>Default = /etc/asterisk','text',NULL,'/etc/asterisk',NULL,NULL),  
     65    ('ASTLOGDIR','/var/log/asterisk',0,'This is the default directory for Asterisks log files<br>Default = /var/log/asterisk','text',NULL,'/var/log/asterisk',NULL,NULL),  
     66    ('ASTMODDIR','/usr/lib/asterisk/modules',0,'This is the default directory for Asterisks modules<br>Default = /usr/lib/asterisk/modules','text',NULL,'/usr/lib/asterisk/modules',NULL,NULL),  
     67    ('ASTSPOOLDIR','/var/spool/asterisk',0,'This is the default directory for Asterisks spool directory<br>Default = /var/spool/asterisk','text',NULL,'/var/spool/asterisk',NULL,NULL),  
     68    ('ASTRUNDIR','/var/run/asterisk',0,'This is the default directory for Asterisks run files<br>Default = /var/run/asterisk','text',NULL,'/var/run/asterisk',NULL,NULL),  
     69    ('ASTVARLIBDIR','/var/lib/asterisk',0,'This is the default directory for Asterisks lib files<br>Default = /var/lib/asterisk','text',NULL,'/var/lib/asterisk',NULL,NULL),  
     70    ('ASTMANAGERPORT','5038',0,'Port for the Asterisk Manager<br>Default = 5038','text',NULL,'5038',NULL,NULL),  
     71    ('ASTMANAGERHOST','localhost',0,'Hostname for the Asterisk Manager<br>Default = 5038','text',NULL,'5038',NULL,NULL),  
    4872    ('AUTHTYPE','database',0,'Authentication type to use for web admin. If type set to <b>database</b>, the primary AMP admin credentials will be the AMPDBUSER/AMPDBPASS above. Valid settings are: none, database<br>Default = database','select','none,database','database',NULL,NULL), 
    4973    ('BADDESTABORT','FALSE',0,'Setting either of these to true will result in retrieve_conf aborting during a reload if an extension conflict is detected or a destination is detected. It is usually better to allow the reload to go through and then correct the problem but these can be set if a more strict behavior is desired<br>Default = false','select','TRUE,FALSE','FALSE',NULL,NULL), 
     
    5882    ('CUSTOMASERROR','TRUE',0,'If false, then the Destination Registry will not report unknown destinations as errors. This should be left to the default true and custom destinations should be moved into the new custom apps registry<br>Default = true','select','TRUE,FALSE','TRUE',NULL,NULL), 
    5983    ('CWINUSEBUSY','TRUE',0,'For extensions that have CW enabled, report unanswered CW calls as <b>busy</b> (resulting in busy voicemail greeting). If set to no, unanswered CW calls simply report as <b>no-answer</b><br>Default = true','select','TRUE,FALSE','TRUE',NULL,NULL), 
    60     ('DASHBOARD_INFO_UPDATE_TIM','',0,'These can be used to change the refresh rate of the System Status Panel. Most of the stats are updated based on the STATS interval but a few items are','text',NULL,NULL,NULL,NULL), 
    61     ('DASHBOARD_STATS_UPDATE_TI','',0,'These can be used to change the refresh rate of the System Status Panel. Most of the stats are updated based on the STATS interval but a few items are','text',NULL,NULL,NULL,NULL), 
     84    ('DASHBOARD_INFO_UPDATE_TIME','',0,'These can be used to change the refresh rate of the System Status Panel. Most of the stats are updated based on the STATS interval but a few items are','text',NULL,NULL,NULL,NULL), 
     85    ('DASHBOARD_STATS_UPDATE_TIME','',0,'These can be used to change the refresh rate of the System Status Panel. Most of the stats are updated based on the STATS interval but a few items are','text',NULL,NULL,NULL,NULL), 
     86    ('DAYNIGHTTCHOOK','FALSE',0,'By default, the Day/Night module will not hook Time Conditions allowing one to associate a daynight manual override with a time condition since now time conditions have their own feature code. If there is already an associaiton configured (on an upgraded system), this will have no affect for the Time Conditions that # are effected. Setting this to true reverts the previous behavior by allowing for the continued use of a daynight toggle to be associated with a time conditon. This can be useful for two scenarios. First, to override a Time Condition without the automatic resetting that occurs with the built in Time Condition overrides. The second use is the ability to associate a single daynight toggle with multiple time conditions thus creating a <b>master switch</b> that can be used to override several possible call flows through different time conditions.<br>Default = false','select','TRUE,FALSE','TRUE',NULL,NULL),      
    6287    ('DEVEL','FALSE',0,'Needs to be documented<br>Default = false','select','TRUE,FALSE','FALSE',NULL,NULL), 
    6388    ('DEVELRELOAD','FALSE',0,'Needs to be documented<br>Default = false','select','TRUE,FALSE','FALSE',NULL,NULL), 
     
    77102    ('POST_RELOAD_DEBUG','',0,'Display debug output for script used if POST_RELOAD is used<br>Default = not set','select','TRUE,FALSE','FALSE',NULL,NULL), 
    78103    ('RELOADCONFIRM','TRUE',0,'When set to false, will bypass the confirm on Reload Box<br>Default = true','select','TRUE,FALSE','TRUE',NULL,NULL), 
    79     ('SERVERINTITLE','FALSE',0,'Precede browser title with the server name<br>Default = false','select','TRUE,FALSE','TRUE',NULL,NULL), 
     104    ('SERVERINTITLE','FALSE',0,'Precede browser title with the server name<br>Default = false','select','TRUE,FALSE','TRUE',NULL,NULL),  
     105    ('TCINTERVAL','60',0,'The polling interval used by the Time Conditions manintenace task, launched by an Asterisk call file used to update Time Conditions override states as well as keep custom device state hint values up-to-date when being used with BLF. This interval should be shorter than the shortest time condition true (open) or false (closed) interval to assure that an override is reset after the current time period has expired that it was set in.<br>Default value 60 seconds.','text',NULL,'60',NULL,NULL), 
     106    ('TCMAINT','TRUE',0,'If set to false, this will override the execution of the Time Conditons maintenace task launched by call files. If all the feature codes for time conditions are disabled, the maintenance task will not be launched so this is not needed for that condition. Setting this to false would be fairly un-common. On an extremely active system that has constant calls flowing throught all time conditions of interest that might be overriden one might set this to avoid the additional polling that would otherwise occur since calls traversing the time conditions contexts will also maintain all the necessary state information. You may also set this temporarily if debugging a system to avoid the periodic dialplan running through the CLI that the maintenance task otherwise creates.<br>Default = true','select','TRUE,FALSE','TRUE',NULL,NULL),  
    80107    ('USECATEGORIES','TRUE',0,'Controls if the menu items in the admin interface are sorted by category (true) or sorted alphebetically with no categories shown (false). Defaults = true','select','TRUE,FALSE','TRUE',NULL,NULL), 
    81108    ('USEDEVSTATE','TRUE',0,'If this is set, it assumes that you are running Asterisk 1.4 or higher and want to take advantage of the func_devstate.c backport available from Asterisk 1.6. This allows custom hints to be created to support BLF for server side feature codes such as daynight, followme, etc<br>Default = false','select','TRUE,FALSE','TRUE',NULL,NULL), 
     
    83110    ('USEQUEUESTATE','FALSE',0,'Setting this flag will generate the required dialplan to integrate with the following Asterisk patch: <b>https://issues.asterisk.org/view.php?id=15168</b>. This feature is planned for a future 1.6 release but given the existence of the patch can be used prior. Once the release version is known, code will be added to automatically enable this format in versions of Asterisk that support it<br>Default = false','select','TRUE,FALSE','FALSE',NULL,NULL), 
    84111    ('XTNCONFLICTABORT','FALSE',0,'Setting either of these to true will result in retrieve_conf aborting during a reload if an extension conflict is detected or a destination is detected. It is usually better to allow the reload to go through and then correct the problem but these can be set if a more strict behavior is desired<br>Default = false','select','TRUE,FALSE','FALSE',NULL,NULL), 
    85     ('ZAP2DAHDICOMPAT','TRUE',0,'If set to true, FreePBX will check if you have chan_dadhi installed. If so, it will automatically use all your ZAP configuration settings (devices and trunks) and silently convert them, under the covers, to DAHDI so no changes are needed. The GUI will continue to refer to these as ZAP but it will use the proper DAHDI channels. This will also keep Zap Channel DIDs working<br>Default = false','select','TRUE,FALSE','TRUE',NULL,NULL), 
    86     ('AMPBACKUPSUDO','',0,'This option allows you to use sudo when backing up files. Useful ONLY when using AMPPROVROOT. Allows backup and restore of files specified in AMPPROVROOT, based on permissions in /etc/sudoers for example, adding the following to sudoers would allow the user asterisk to run tar on ANY file on the system:<br>asterisk localhost=(root)NOPASSWD: /bin/tar<br>Defaults:asterisk !requiretty<br>PLEASE KEEP IN MIND THE SECURITY RISKS INVOLVED IN ALLOWING THE ASTERISK USER TO TAR/UNTAR ANY FILE<br>Default = false','select','TRUE,FALSE',NULL,NULL,NULL)"; 
     112    ('ZAP2DAHDICOMPAT','FALSE',0,'If set to true, FreePBX will check if you have chan_dadhi installed. If so, it will automatically use all your ZAP configuration settings (devices and trunks) and silently convert them, under the covers, to DAHDI so no changes are needed. The GUI will continue to refer to these as ZAP but it will use the proper DAHDI channels. This will also keep Zap Channel DIDs working<br>Default = false','select','TRUE,FALSE','TRUE',NULL,NULL)"; 
     113     
    87114   
    88115  foreach ($sql as $q) { 
     
    115142    die_freepbx($result->getDebugInfo()); 
    116143  } 
     144  out(_("migrated")); 
     145} else { 
     146  out(_("previously migrated")); 
    117147} 
    118148//TODO: set crucial options to readonly 
     149//build freepbx.conf if it doesnt already exists 
     150 
     151 
     152outn(_("checking for freepbx.conf..")); 
     153 
     154$freepbx_conf = getenv('FREEPBX_CONF'); 
     155if ($freepbx_conf && file_exists($freepbx_conf)) { 
     156  out(sprintf(_("%s already exists"),$freepbx_conf)); 
     157} else if (file_exists('/etc/freepbx.conf')) { 
     158  out(_("/etc/freepbx.conf already exists")); 
     159} else if (file_exists('/etc/asterisk/freepbx.conf')) { 
     160  out(_("/etc/asterisk/freepbx.conf already exists")); 
     161} else { 
     162 
     163  if ($freepbx_conf) { 
     164    $filename = $freepbx_conf; 
     165  } else { 
     166    $filename = is_writable('/etc') ? '/etc/freepbx.conf' : '/etc/asterisk/freepbx.conf'; 
     167  } 
     168   
     169  $txt = ''; 
     170  $txt .= '<?php' . "\n"; 
     171  $txt .= '$amp_conf[\'AMPDBUSER\'] = "' . $amp_conf['AMPDBUSER'] . '";' . "\n"; 
     172  $txt .= '$amp_conf[\'AMPDBPASS\'] = "' . $amp_conf['AMPDBPASS'] . '";' . "\n"; 
     173  $txt .= '$amp_conf[\'AMPDBHOST\'] = "' . $amp_conf['AMPDBHOST'] . '";' . "\n"; 
     174  $txt .= '$amp_conf[\'AMPDBNAME\'] = "' . $amp_conf['AMPDBNAME'] . '";' . "\n"; 
     175  $txt .= '$amp_conf[\'AMPDBENGINE\'] = "' . $amp_conf['AMPDBENGINE'] . '";' . "\n"; 
     176  $txt .= '$amp_conf[\'datasource\']  = "' . $amp_conf['datasource'] . '";' . "\n"; 
     177  $txt .= 'require_once(\'' . $amp_conf['AMPWEBROOT'] . '/admin/bootstrap.php\');' . "\n"; 
     178 
     179  // don't use file_put_contents re php4 compatibility for framework/core 
     180  $fh = fopen($filename,'w'); 
     181  if ($fh === false || (fwrite($fh,$txt) === false)) { 
     182    out(sprintf(_("FATAL error writing  %s"),$filename)); 
     183    die_freepbx(_("You must have a proper freepbx.conf file to proceed")); 
     184  } 
     185  fclose($fh); 
     186  out(sprintf(_("created %s"),$filename)); 
     187} 
    119188?> 
  • freepbx/trunk/upgrades/2.9.0alpha1/removefiles.php

    r10643 r10865  
    1414  $amp_conf['AMPWEBROOT']."/admin/common/content.css", 
    1515  "$htdocs/admin/common/content.css", 
    16   $amp_conf['AMPWEBROOT']."/admin/common/json.inc.php", 
    17   "$htdocs/admin/common/json.inc.php", 
    1816  $amp_conf['AMPWEBROOT']."/admin/common/docbook.css", 
    1917  "$htdocs/admin/common/docbook.css",