Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianberm authored Dec 7, 2018
2 parents 2993fb3 + 006d143 commit e609e51
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion phpagi-asmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AGI_AsteriskManager
* @access private
* @var AGI
*/
private $pagi;
public $pagi = false;

/**
* Event Handlers
Expand Down
106 changes: 55 additions & 51 deletions phpagi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* phpagi.php : PHP AGI Functions for Asterisk
* @see https://github.com/welltime/phpagi
* @filesource http://phpagi.sourceforge.net/
*
*
* $Id: phpagi.php,v 2.20 2010/09/30 02:21:00 masham Exp $
*
* Copyright (c) 2003 - 2010 Matthew Asham <[email protected]>, David Eder <[email protected]> and others
Expand All @@ -15,7 +15,7 @@
*
* We would be happy to list your phpagi based application on the phpagi
* website. Drop me an Email if you'd like us to list your program.
*
*
*
* Written for PHP 4.3.4, should work with older PHP 4.x versions.
*
Expand Down Expand Up @@ -131,11 +131,11 @@ class AGI

/**
* Application option delimiter
*
*
* @access public
*/
public $option_delim = ",";

/**
* Constructor
*
Expand Down Expand Up @@ -377,19 +377,19 @@ function exec($application, $options)
* Asterisk looks for the file to play in /var/lib/asterisk/sounds by default.
*
* If the user doesn't press any keys when the message plays, there is $timeout milliseconds
* of silence then the command ends.
* of silence then the command ends.
*
* The user has the opportunity to press a key at any time during the message or the
* post-message silence. If the user presses a key while the message is playing, the
* message stops playing. When the first key is pressed a timer starts counting for
* $timeout milliseconds. Every time the user presses another key the timer is restarted.
* The command ends when the counter goes to zero or the maximum number of digits is entered,
* whichever happens first.
* whichever happens first.
*
* If you don't specify a time out then a default timeout of 2000 is used following a pressed
* digit. If no digits are pressed then 6 seconds of silence follow the message.
* digit. If no digits are pressed then 6 seconds of silence follow the message.
*
* If you don't specify $max_digits then the user can enter as many digits as they want.
* If you don't specify $max_digits then the user can enter as many digits as they want.
*
* Pressing the # key has the same effect as the timer running out: the command ends and
* any previously keyed digits are returned. A side effect of this is that there is no
Expand Down Expand Up @@ -440,7 +440,7 @@ function get_variable($variable,$getvalue=FALSE)
* @link http://www.voip-info.org/wiki-Asterisk+variables
* @param string $variable name
* @param string $channel channel
* @param boolean $getvalue return the value only
* @param boolean $getvalue return the value only
* @return array, see evaluate for return information. ['result'] is 0 if variable hasn't been set, 1 if it has. ['data'] holds the value. returns value if $getvalue is TRUE
*/
function get_fullvariable($variable,$channel=FALSE,$getvalue=FALSE)
Expand All @@ -450,14 +450,14 @@ function get_fullvariable($variable,$channel=FALSE,$getvalue=FALSE)
} else {
$req = $variable.' '.$channel;
}

$res=$this->evaluate('GET FULL VARIABLE '.$req);

if($getvalue==FALSE)
return($res);

return($res['data']);

}

/**
Expand Down Expand Up @@ -496,7 +496,7 @@ function noop($string="")
*
* @link http://www.voip-info.org/wiki-receive+char
* @param integer $timeout milliseconds
* @return array, see evaluate for return information. ['result'] is 0 on timeout or not supported, -1 on failure. Otherwise
* @return array, see evaluate for return information. ['result'] is 0 on timeout or not supported, -1 on failure. Otherwise
* it is the decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function receive_char($timeout=-1)
Expand All @@ -515,9 +515,9 @@ function receive_char($timeout=-1)
* @param integer $timeout is the maximum record time in milliseconds, or -1 for no timeout.
* @param integer $offset to seek to without exceeding the end of the file.
* @param boolean $beep
* @param integer $silence number of seconds of silence allowed before the function returns despite the
* @param integer $silence number of seconds of silence allowed before the function returns despite the
* lack of dtmf digits or reaching timeout.
* @return array, see evaluate for return information. ['result'] is -1 on error, 0 on hangup, otherwise a decimal value of the
* @return array, see evaluate for return information. ['result'] is -1 on error, 0 on hangup, otherwise a decimal value of the
* DTMF tone. Use chr() to convert to ASCII.
*/
function record_file($file, $format, $escape_digits='', $timeout=-1, $offset=NULL, $beep=false, $silence=NULL)
Expand All @@ -534,7 +534,7 @@ function record_file($file, $format, $escape_digits='', $timeout=-1, $offset=NUL
* @link http://www.voip-info.org/wiki-say+digits
* @param integer $digits
* @param string $escape_digits
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function say_digits($digits, $escape_digits='')
Expand All @@ -548,7 +548,7 @@ function say_digits($digits, $escape_digits='')
* @link http://www.voip-info.org/wiki-say+number
* @param integer $number
* @param string $escape_digits
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function say_number($number, $escape_digits='')
Expand All @@ -562,7 +562,7 @@ function say_number($number, $escape_digits='')
* @link http://www.voip-info.org/wiki-say+phonetic
* @param string $text
* @param string $escape_digits
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function say_phonetic($text, $escape_digits='')
Expand All @@ -576,7 +576,7 @@ function say_phonetic($text, $escape_digits='')
* @link http://www.voip-info.org/wiki-say+time
* @param integer $time number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
* @param string $escape_digits
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function say_time($time=NULL, $escape_digits='')
Expand All @@ -592,7 +592,7 @@ function say_time($time=NULL, $escape_digits='')
*
* @link http://www.voip-info.org/wiki-send+image
* @param string $image without extension, often in /var/lib/asterisk/images
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the image is sent or
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the image is sent or
* channel does not support image transmission.
*/
function send_image($image)
Expand All @@ -607,7 +607,7 @@ function send_image($image)
*
* @link http://www.voip-info.org/wiki-send+text
* @param $text
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the text is sent or
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the text is sent or
* channel does not support text transmission.
*/
function send_text($text)
Expand Down Expand Up @@ -635,7 +635,7 @@ function set_autohangup($time=0)
*
* @link http://www.voip-info.org/wiki-set+callerid
* @param string $cid example: "John Smith"<1234567>
* This command will let you take liberties with the <caller ID specification> but the format shown in the example above works
* This command will let you take liberties with the <caller ID specification> but the format shown in the example above works
* well: the name enclosed in double quotes followed immediately by the number inside angle brackets. If there is no name then
* you can omit it. If the name contains no spaces you can omit the double quotes around it. The number must follow the name
* immediately; don't put a space between them. The angle brackets around the number are necessary; if you omit them the
Expand All @@ -650,14 +650,14 @@ function set_callerid($cid)
/**
* Sets the context for continuation upon exiting the application.
*
* Setting the context does NOT automatically reset the extension and the priority; if you want to start at the top of the new
* context you should set extension and priority yourself.
* Setting the context does NOT automatically reset the extension and the priority; if you want to start at the top of the new
* context you should set extension and priority yourself.
*
* If you specify a non-existent context you receive no error indication (['result'] is still 0) but you do get a
* If you specify a non-existent context you receive no error indication (['result'] is still 0) but you do get a
* warning message on the Asterisk console.
*
* @link http://www.voip-info.org/wiki-set+context
* @param string $context
* @param string $context
* @return array, see evaluate for return information.
*/
function set_context($context)
Expand All @@ -668,10 +668,10 @@ function set_context($context)
/**
* Set the extension to be used for continuation upon exiting the application.
*
* Setting the extension does NOT automatically reset the priority. If you want to start with the first priority of the
* extension you should set the priority yourself.
* Setting the extension does NOT automatically reset the priority. If you want to start with the first priority of the
* extension you should set the priority yourself.
*
* If you specify a non-existent extension you receive no error indication (['result'] is still 0) but you do
* If you specify a non-existent extension you receive no error indication (['result'] is still 0) but you do
* get a warning message on the Asterisk console.
*
* @link http://www.voip-info.org/wiki-set+extension
Expand Down Expand Up @@ -716,8 +716,8 @@ function set_priority($priority)
* Sets a variable to the specified value. The variables so created can later be used by later using ${<variablename>}
* in the dialplan.
*
* These variables live in the channel Asterisk creates when you pickup a phone and as such they are both local and temporary.
* Variables created in one channel can not be accessed by another channel. When you hang up the phone, the channel is deleted
* These variables live in the channel Asterisk creates when you pickup a phone and as such they are both local and temporary.
* Variables created in one channel can not be accessed by another channel. When you hang up the phone, the channel is deleted
* and any variables in that channel are deleted as well.
*
* @link http://www.voip-info.org/wiki-set+variable
Expand All @@ -732,8 +732,8 @@ function set_variable($variable, $value)
}

/**
* Play the given audio file, allowing playback to be interrupted by a DTMF digit. This command is similar to the GET DATA
* command but this command returns after the first DTMF digit has been pressed while GET DATA can accumulated any number of
* Play the given audio file, allowing playback to be interrupted by a DTMF digit. This command is similar to the GET DATA
* command but this command returns after the first DTMF digit has been pressed while GET DATA can accumulated any number of
* digits before returning.
*
* @example examples/ping.php Ping an IP address
Expand All @@ -742,7 +742,7 @@ function set_variable($variable, $value)
* @param string $filename without extension, often in /var/lib/asterisk/sounds
* @param string $escape_digits
* @param integer $offset
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function stream_file($filename, $escape_digits='', $offset=0)
Expand All @@ -767,9 +767,9 @@ function tdd_mode($setting)
*
* If the Asterisk verbosity level is $level or greater, send $message to the console.
*
* The Asterisk verbosity system works as follows. The Asterisk user gets to set the desired verbosity at startup time or later
* using the console 'set verbose' command. Messages are displayed on the console if their verbose level is less than or equal
* to desired verbosity set by the user. More important messages should have a low verbose level; less important messages
* The Asterisk verbosity system works as follows. The Asterisk user gets to set the desired verbosity at startup time or later
* using the console 'set verbose' command. Messages are displayed on the console if their verbose level is less than or equal
* to desired verbosity set by the user. More important messages should have a low verbose level; less important messages
* should have a high verbose level.
*
* @link http://www.voip-info.org/wiki-verbose
Expand All @@ -792,7 +792,7 @@ function verbose($message, $level=1)
*
* @link http://www.voip-info.org/wiki-wait+for+digit
* @param integer $timeout in millisecons. Use -1 for the timeout value if you want the call to wait indefinitely.
* @return array, see evaluate for return information. ['result'] is 0 if wait completes with no
* @return array, see evaluate for return information. ['result'] is 0 if wait completes with no
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
*/
function wait_for_digit($timeout=-1)
Expand All @@ -808,9 +808,9 @@ function wait_for_digit($timeout=-1)
/**
* Set absolute maximum time of call.
*
* Note that the timeout is set from the current time forward, not counting the number of seconds the call has already been up.
* Each time you call AbsoluteTimeout(), all previous absolute timeouts are cancelled.
* Will return the call to the T extension so that you can playback an explanatory note to the calling party (the called party
* Note that the timeout is set from the current time forward, not counting the number of seconds the call has already been up.
* Each time you call AbsoluteTimeout(), all previous absolute timeouts are cancelled.
* Will return the call to the T extension so that you can playback an explanatory note to the calling party (the called party
* will not hear that)
*
* @link http://www.voip-info.org/wiki-Asterisk+-+documentation+of+application+commands
Expand Down Expand Up @@ -1549,9 +1549,9 @@ function say_punctuation($text, $escape_digits='', $frequency=8000)
*/
function &new_AsteriskManager()
{
$this->asm = new AGI_AsteriskManager(NULL, $this->config);
$this->asm = new AGI_AsteriskManager(NULL, $this->config['asmanager']);
$this->asm->setPagi($this);
$this->config =& $this->asm->config;
$this->config['asmanager'] =& $this->asm->config['asmanager'];
return $this->asm;
}

Expand Down Expand Up @@ -1689,16 +1689,20 @@ function conlog($str, $vbl=1)
*/
function which($cmd, $checkpath=NULL)
{
global $_ENV;
$chpath = is_null($checkpath) ? $_ENV['PATH'] : $checkpath;
if (is_null($checkpath)) {
$chpath = getenv('PATH');
if ($chpath === false) {
$chpath = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:'.
'/usr/X11R6/bin:/usr/local/apache/bin:/usr/local/mysql/bin';
}
} else {
$chpath = $checkpath;
}

foreach(explode(':', $chpath) as $path)
if(is_executable("$path/$cmd"))
return "$path/$cmd";

if(is_null($checkpath))
return $this->which($cmd, '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:'.
'/usr/X11R6/bin:/usr/local/apache/bin:/usr/local/mysql/bin');
return false;
}

Expand All @@ -1708,7 +1712,7 @@ function which($cmd, $checkpath=NULL)
* @access private
* @param string $folder
* @param integer $perms
* @return boolean
* @return boolean
*/
function make_folder($folder, $perms=0755)
{
Expand All @@ -1725,7 +1729,7 @@ function make_folder($folder, $perms=0755)
$base .= DIRECTORY_SEPARATOR;
}
return(TRUE);
}
}

}

Expand Down

0 comments on commit e609e51

Please sign in to comment.