Changeset 3955

Show
Ignore:
Timestamp:
05/02/07 11:11:44 (6 years ago)
Author:
diego_iastrubni
Message:

archiverecordings uses now the file found on the webroot.
fixes ticket:1914 and ticket:1915

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/bin/archive_recordings

    r3925 r3955  
    33 
    44define("AMP_CONF", "/etc/amportal.conf"); 
    5 define("PHP_ASMANAGER", "/var/lib/asterisk/bin/php-asmanager.php"); 
     5define("PHP_ASMANAGER", "php-asmanager.php"); 
    66define("MONITOR_DIR", "/var/spool/asterisk/monitor"); 
    77 
     
    4040 
    4141function parse_amportal_conf($filename) { 
     42  // defaults, if not specified in the file 
     43  $defaults = array( 
     44    'AMPDBENGINE' => 'mysql', 
     45    'AMPDBNAME' => 'asterisk', 
     46    'AMPENGINE' => 'asterisk', 
     47    'USECATEGORIES' => true, 
     48    'ASTETCDIR' => '/etc/asterisk', 
     49    'ASTMANAGERPORT' => '5038', 
     50    ); 
     51  // boolean values, will be converted to true/false 
     52  // "yes", "true", 1 (case-insensitive) will be treated as true, everything else is false 
     53  $booleans = array('USECATEGORIES'); 
     54 
    4255  $file = file($filename); 
    43   foreach ($file as $line) { 
    44     if (preg_match("/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/",$line,$matches)) {  
    45       $conf[ $matches[1] ] = $matches[2]; 
     56  if (is_array($file)) { 
     57    foreach ($file as $line) { 
     58      if (preg_match("/^\s*([a-zA-Z0-9_]+)=([a-zA-Z0-9 .&-@=_<>\"\']+)\s*$/",$line,$matches)) { 
     59        $conf[ $matches[1] ] = $matches[2]; 
     60      } 
    4661    } 
    47   } 
     62  } else { 
     63    die("<h1>Missing or unreadable config file ($filename)...cannot continue</h1>"); 
     64  } 
     65 
     66  // set defaults 
     67  foreach ($defaults as $key=>$val) { 
     68    if (!isset($conf[$key]) || $conf[$key] == '') { 
     69      $conf[$key] = $val; 
     70    } 
     71  } 
     72 
     73  // evaluate boolean values 
     74  foreach ($booleans as $key) { 
     75    $conf[$key] = isset($conf[$key]) && ($conf[$key] === true || strtolower($conf[$key]) == 'true' || $conf[$key] === 1 || $conf[$key] == '1' || strtolower($conf[$key]) == 'yes'); 
     76  } 
     77 
    4878  return $conf; 
    4979} 
     
    235265function check_recording_option($extension) { 
    236266  global $amp_conf; 
    237   $astman = new AGI_AsteriskManager(); 
    238   if ($res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) { 
     267  global $astman; 
     268 
     269  if ($astman) { 
    239270    return $astman->database_get("RECORD-IN",$extension); 
    240271  } else { 
    241     fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
    242   } 
     272    fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);   
     273  } 
     274   
    243275} 
    244276 
     
    316348out("OK"); 
    317349 
    318 // **** Make sure we have php-asmanager.php, and include it 
    319  
    320 outn("Checking for PHP_ASMANAGER.."); 
    321 if (! @ include(PHP_ASMANAGER)) { 
    322   out("FAILED"); 
    323   fatal("Cannot include ".PHP_ASMANAGER); 
    324 } 
    325 out("OK"); 
    326350 
    327351// **** Parse out command-line options 
     
    387411out("OK"); 
    388412 
     413// **** Make sure we have php-asmanager.php, and include it 
     414 
     415outn("Checking for PHP_ASMANAGER.."); 
     416$myfile = $amp_conf['AMPWEBROOT'] . "/admin/common/" .  PHP_ASMANAGER ; 
     417if (! @ include( $myfile  ) ) { 
     418  out("FAILED"); 
     419  fatal("Cannot include $myfile"); 
     420} 
     421out("OK"); 
     422 
     423// **** now make the global manager connection 
     424$astman = new AGI_AsteriskManager(); 
     425$res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"] ); 
     426if (!res) { 
     427  fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 
     428} 
     429 
    389430 
    390431// **** Connect to database 
    391  
    392432outn("Connecting to database.."); 
    393433 
     434 
     435// note, sqlite3 not supported yet! 
    394436$db_user = $amp_conf["AMPDBUSER"]; 
    395437$db_pass = $amp_conf["AMPDBPASS"]; 
    396 $db_host = 'localhost'; 
     438$db_host = $amp_conf["AMPDBHOST"]; 
     439$db_engine = $amp_conf["AMPDBENGINE"]; 
    397440$db_name = 'asteriskcdrdb'; 
    398 $db_engine = 'mysql'; 
    399441 
    400442$datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name;