Changeset 10565

Show
Ignore:
Timestamp:
11/15/10 14:18:19 (3 years ago)
Author:
p_lindheimer
Message:

closes #4639 remove amportal.conf parsing requirements and some other cleanup, requires recently checked in change to php-asmanger.php where unnecessary parsing was also removed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.9/callback/bin/callback

    r8239 r10565  
    22<?php 
    33/* 
    4 This Callback script takes 3 arguments: 
     4This Callback script takes 7 arguments: 
    551- number to dial 
    662- context.exten.priority to dump number into 
    773- time in seconds to sleep before calling back 
     84- path to the AMPWEBROOT 
     95- path to the ASTETCDIR 
     106- AMI USER 
     116- AMI PASSWORD 
    812 
    913eg: callback 14032448089 ext-meetme.200.1 
    1014*/ 
    1115//Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) 
     16//Copyright (C) 2010 Astrogen LLC 
    1217//This file is part of FreePBX. 
    1318// 
     
    2732 
    2833<?php 
    29 define("AMP_CONF", "/etc/amportal.conf"); 
    3034 
    31 //sleep(10); 
     35if ($args != 8) { 
     36  fatal("Wrong number of arguments, should be:\n".$argv[0]." callback_number callback_destination delay_seconds AMPWEBROOT ASTETCDIR AMPMGRUSER AMPMGRPASS\n"); 
     37
     38echo "args: $argc\n"; 
    3239 
    33 /**************************************************************/ 
     40$callback_number = $argv[1]; 
     41$callback_destination = $argv[2]; 
     42$pause_seconds = $argv[3]; 
    3443 
    35 // from  ben-php dot net at efros dot com   at  php.net/install.unix.commandline 
    36 if (version_compare(phpversion(),'4.3.0','<') || !defined("STDIN")) { 
    37   define('STDIN',fopen("php://stdin","r")); 
    38   define('STDOUT',fopen("php://stdout","r")); 
    39   define('STDERR',fopen("php://stderr","r")); 
    40   register_shutdown_function( create_function( '' , 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;' ) ); 
    41 
    42  
    43 // **** Make sure we have PEAR's GetOpts.php, and include it 
    44  
    45 outn("Checking for PEAR Console::Getopt.."); 
    46 if (! @ include("Console/Getopt.php")) { 
    47   out("FAILED"); 
    48   fatal("PEAR must be installed (requires Console/Getopt.php). Include path: ".ini_get("include_path")); 
    49 
    50 out("OK"); 
    51  
    52 outn("Reading ".AMP_CONF.".."); 
    53 $amp_conf = parse_amportal_conf_bootstrap(AMP_CONF); 
    54 if (count($amp_conf) == 0) { 
    55   fatal("FAILED"); 
    56 
    57 out("OK"); 
     44$amp_conf['AMPWEBROOT'] = $argv[4]; 
     45$amp_conf['ASTETCDIR']  = $argv[5]; 
     46$amp_conf['AMPMGRUSER'] = $argv[6]; 
     47$amp_conf['AMPMGRPASS'] = $argv[7]; 
    5848 
    5949// include manager functions 
    60 require_once($amp_conf['AMPWEBROOT']."/admin/functions.inc.php"); 
    6150include $amp_conf['AMPWEBROOT'].'/admin/common/php-asmanager.php'; 
    62  
    63 // **** Parse out command-line args 
    64 // context, extension, and number of voicemails 
    65 out("Getting passed arguments:"); 
    66 $con  = new Console_Getopt; 
    67 $args = $con->readPHPArgv(); 
    68 array_shift($args); 
    69 //system("echo \"".$args[0].substr($args[1],0,strpos($args[1],"@")).$args[2]."\" > on.txt"); ; 
    70 print_r($args); 
    71  
    72 $callback_number = $args[0]; 
    73 $callback_destination = $args[1]; 
    74 $pause_seconds = $args[2]; 
    7551 
    7652if($pause_seconds) 
     
    8561//define the args for Originate 
    8662$channel = "Local/".$callback_number."@from-internal"; 
    87 //$channel = "zap/g0/".$uservm[$vmcontext][$vmextension]['options']['callme']; 
    8863$exten = $callback_exten; 
    8964$context = $callback_context; 
     
    10580$astman->disconnect(); 
    10681 
    107  
    108 function parse_amportal_conf_bootstrap($filename) { 
    109   $file = file($filename); 
    110   foreach ($file as $line) { 
    111     if (preg_match("/^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/",$line,$matches)) {  
    112       $conf[ $matches[1] ] = $matches[2]; 
    113     } 
    114   } 
    115   return $conf; 
    116 } 
    117  
    118 function out($text) { 
    119   echo $text."\n"; 
    120 } 
    121  
    122 function outn($text) { 
    123   echo $text; 
    124 } 
    125  
    126 function error($text) { 
    127   echo "[ERROR] ".$text."\n"; 
    128 } 
    129  
    13082function fatal($text) { 
    13183  echo "[FATAL] ".$text."\n"; 
  • modules/branches/2.9/callback/functions.inc.php

    r7470 r10565  
    8888function callback_get_config($engine) { 
    8989  global $ext;  // is this the best way to pass this? 
    90   global $asterisk_conf; 
     90  global $amp_conf; 
    9191  switch($engine) { 
    9292    case "asterisk": 
     
    110110           
    111111          // kick off the callback script - run in background (&) so we can hangup 
    112           $ext->add('callback', $item['callback_id'], '', new ext_system((empty($asterisk_conf['astvarlib']) ? '/var/lib/asterisk' : $asterisk_conf['astvarlib']).'/bin/callback ${CALL} ${DESTINATION} ${SLEEP} &')); 
     112          $ext->add('callback', $item['callback_id'], '', new ext_system((empty($amp_conf['ASTVARLIBDIR']) ? '/var/lib/asterisk' : $amp_conf['ASTVARLIBDIR']).'/bin/callback ${CALL} ${DESTINATION} ${SLEEP} '.escapeshellarg($amp_conf['AMPWEBROOT']).' '.escapeshellarg($amp_conf['ASTETCDIR']).' '.escapeshellarg($amp_conf['AMPMGRUSER']).' '.escapeshellarg($amp_conf['AMPMGRPASS']).'&')); 
    113113           
    114114          //hangup 
  • modules/branches/2.9/callback/module.xml

    r10085 r10565  
    22  <rawname>callback</rawname> 
    33  <name>Callback</name> 
    4   <version>2.8.0.0</version> 
     4  <version>2.9.0.0</version> 
    55  <publisher>FreePBX</publisher> 
    66  <license>GPLv2+</license> 
     
    1111  </menuitems> 
    1212  <changelog> 
     13  *2.9.0.0* #4639 
    1314  *2.8.0.0* published 2.8 version 
    1415  *2.7.0.0* localizations