Changeset 10565 for modules/branches/2.9/callback
- Timestamp:
- 11/15/10 14:18:19 (3 years ago)
- Files:
-
- modules/branches/2.9/callback/bin/callback (modified) (4 diffs)
- modules/branches/2.9/callback/functions.inc.php (modified) (2 diffs)
- modules/branches/2.9/callback/module.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.9/callback/bin/callback
r8239 r10565 2 2 <?php 3 3 /* 4 This Callback script takes 3arguments:4 This Callback script takes 7 arguments: 5 5 1- number to dial 6 6 2- context.exten.priority to dump number into 7 7 3- time in seconds to sleep before calling back 8 4- path to the AMPWEBROOT 9 5- path to the ASTETCDIR 10 6- AMI USER 11 6- AMI PASSWORD 8 12 9 13 eg: callback 14032448089 ext-meetme.200.1 10 14 */ 11 15 //Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) 16 //Copyright (C) 2010 Astrogen LLC 12 17 //This file is part of FreePBX. 13 18 // … … 27 32 28 33 <?php 29 define("AMP_CONF", "/etc/amportal.conf");30 34 31 //sleep(10); 35 if ($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 } 38 echo "args: $argc\n"; 32 39 33 /**************************************************************/ 40 $callback_number = $argv[1]; 41 $callback_destination = $argv[2]; 42 $pause_seconds = $argv[3]; 34 43 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]; 58 48 59 49 // include manager functions 60 require_once($amp_conf['AMPWEBROOT']."/admin/functions.inc.php");61 50 include $amp_conf['AMPWEBROOT'].'/admin/common/php-asmanager.php'; 62 63 // **** Parse out command-line args64 // context, extension, and number of voicemails65 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];75 51 76 52 if($pause_seconds) … … 85 61 //define the args for Originate 86 62 $channel = "Local/".$callback_number."@from-internal"; 87 //$channel = "zap/g0/".$uservm[$vmcontext][$vmextension]['options']['callme'];88 63 $exten = $callback_exten; 89 64 $context = $callback_context; … … 105 80 $astman->disconnect(); 106 81 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 130 82 function fatal($text) { 131 83 echo "[FATAL] ".$text."\n"; modules/branches/2.9/callback/functions.inc.php
r7470 r10565 88 88 function callback_get_config($engine) { 89 89 global $ext; // is this the best way to pass this? 90 global $a sterisk_conf;90 global $amp_conf; 91 91 switch($engine) { 92 92 case "asterisk": … … 110 110 111 111 // kick off the callback script - run in background (&) so we can hangup 112 $ext->add('callback', $item['callback_id'], '', new ext_system((empty($a sterisk_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']).'&')); 113 113 114 114 //hangup modules/branches/2.9/callback/module.xml
r10085 r10565 2 2 <rawname>callback</rawname> 3 3 <name>Callback</name> 4 <version>2. 8.0.0</version>4 <version>2.9.0.0</version> 5 5 <publisher>FreePBX</publisher> 6 6 <license>GPLv2+</license> … … 11 11 </menuitems> 12 12 <changelog> 13 *2.9.0.0* #4639 13 14 *2.8.0.0* published 2.8 version 14 15 *2.7.0.0* localizations
