Changeset 3955
- Timestamp:
- 05/02/07 11:11:44 (6 years ago)
- Files:
-
- freepbx/trunk/amp_conf/bin/archive_recordings (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/bin/archive_recordings
r3925 r3955 3 3 4 4 define("AMP_CONF", "/etc/amportal.conf"); 5 define("PHP_ASMANAGER", " /var/lib/asterisk/bin/php-asmanager.php");5 define("PHP_ASMANAGER", "php-asmanager.php"); 6 6 define("MONITOR_DIR", "/var/spool/asterisk/monitor"); 7 7 … … 40 40 41 41 function 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 42 55 $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 } 46 61 } 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 48 78 return $conf; 49 79 } … … 235 265 function check_recording_option($extension) { 236 266 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) { 239 270 return $astman->database_get("RECORD-IN",$extension); 240 271 } 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 243 275 } 244 276 … … 316 348 out("OK"); 317 349 318 // **** Make sure we have php-asmanager.php, and include it319 320 outn("Checking for PHP_ASMANAGER..");321 if (! @ include(PHP_ASMANAGER)) {322 out("FAILED");323 fatal("Cannot include ".PHP_ASMANAGER);324 }325 out("OK");326 350 327 351 // **** Parse out command-line options … … 387 411 out("OK"); 388 412 413 // **** Make sure we have php-asmanager.php, and include it 414 415 outn("Checking for PHP_ASMANAGER.."); 416 $myfile = $amp_conf['AMPWEBROOT'] . "/admin/common/" . PHP_ASMANAGER ; 417 if (! @ include( $myfile ) ) { 418 out("FAILED"); 419 fatal("Cannot include $myfile"); 420 } 421 out("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"] ); 426 if (!res) { 427 fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); 428 } 429 389 430 390 431 // **** Connect to database 391 392 432 outn("Connecting to database.."); 393 433 434 435 // note, sqlite3 not supported yet! 394 436 $db_user = $amp_conf["AMPDBUSER"]; 395 437 $db_pass = $amp_conf["AMPDBPASS"]; 396 $db_host = 'localhost'; 438 $db_host = $amp_conf["AMPDBHOST"]; 439 $db_engine = $amp_conf["AMPDBENGINE"]; 397 440 $db_name = 'asteriskcdrdb'; 398 $db_engine = 'mysql';399 441 400 442 $datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name;
