Skip to content

Commit e609e51

Browse files
Merge branch 'master' into master
2 parents 2993fb3 + 006d143 commit e609e51

File tree

2 files changed

+56
-52
lines changed

2 files changed

+56
-52
lines changed

phpagi-asmanager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class AGI_AsteriskManager
7878
* @access private
7979
* @var AGI
8080
*/
81-
private $pagi;
81+
public $pagi = false;
8282

8383
/**
8484
* Event Handlers

phpagi.php

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* phpagi.php : PHP AGI Functions for Asterisk
55
* @see https://github.com/welltime/phpagi
66
* @filesource http://phpagi.sourceforge.net/
7-
*
7+
*
88
* $Id: phpagi.php,v 2.20 2010/09/30 02:21:00 masham Exp $
99
*
1010
* Copyright (c) 2003 - 2010 Matthew Asham <[email protected]>, David Eder <[email protected]> and others
@@ -15,7 +15,7 @@
1515
*
1616
* We would be happy to list your phpagi based application on the phpagi
1717
* website. Drop me an Email if you'd like us to list your program.
18-
*
18+
*
1919
*
2020
* Written for PHP 4.3.4, should work with older PHP 4.x versions.
2121
*
@@ -131,11 +131,11 @@ class AGI
131131

132132
/**
133133
* Application option delimiter
134-
*
134+
*
135135
* @access public
136136
*/
137137
public $option_delim = ",";
138-
138+
139139
/**
140140
* Constructor
141141
*
@@ -377,19 +377,19 @@ function exec($application, $options)
377377
* Asterisk looks for the file to play in /var/lib/asterisk/sounds by default.
378378
*
379379
* If the user doesn't press any keys when the message plays, there is $timeout milliseconds
380-
* of silence then the command ends.
380+
* of silence then the command ends.
381381
*
382382
* The user has the opportunity to press a key at any time during the message or the
383383
* post-message silence. If the user presses a key while the message is playing, the
384384
* message stops playing. When the first key is pressed a timer starts counting for
385385
* $timeout milliseconds. Every time the user presses another key the timer is restarted.
386386
* The command ends when the counter goes to zero or the maximum number of digits is entered,
387-
* whichever happens first.
387+
* whichever happens first.
388388
*
389389
* If you don't specify a time out then a default timeout of 2000 is used following a pressed
390-
* digit. If no digits are pressed then 6 seconds of silence follow the message.
390+
* digit. If no digits are pressed then 6 seconds of silence follow the message.
391391
*
392-
* If you don't specify $max_digits then the user can enter as many digits as they want.
392+
* If you don't specify $max_digits then the user can enter as many digits as they want.
393393
*
394394
* Pressing the # key has the same effect as the timer running out: the command ends and
395395
* any previously keyed digits are returned. A side effect of this is that there is no
@@ -440,7 +440,7 @@ function get_variable($variable,$getvalue=FALSE)
440440
* @link http://www.voip-info.org/wiki-Asterisk+variables
441441
* @param string $variable name
442442
* @param string $channel channel
443-
* @param boolean $getvalue return the value only
443+
* @param boolean $getvalue return the value only
444444
* @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
445445
*/
446446
function get_fullvariable($variable,$channel=FALSE,$getvalue=FALSE)
@@ -450,14 +450,14 @@ function get_fullvariable($variable,$channel=FALSE,$getvalue=FALSE)
450450
} else {
451451
$req = $variable.' '.$channel;
452452
}
453-
453+
454454
$res=$this->evaluate('GET FULL VARIABLE '.$req);
455-
455+
456456
if($getvalue==FALSE)
457457
return($res);
458-
458+
459459
return($res['data']);
460-
460+
461461
}
462462

463463
/**
@@ -496,7 +496,7 @@ function noop($string="")
496496
*
497497
* @link http://www.voip-info.org/wiki-receive+char
498498
* @param integer $timeout milliseconds
499-
* @return array, see evaluate for return information. ['result'] is 0 on timeout or not supported, -1 on failure. Otherwise
499+
* @return array, see evaluate for return information. ['result'] is 0 on timeout or not supported, -1 on failure. Otherwise
500500
* it is the decimal value of the DTMF tone. Use chr() to convert to ASCII.
501501
*/
502502
function receive_char($timeout=-1)
@@ -515,9 +515,9 @@ function receive_char($timeout=-1)
515515
* @param integer $timeout is the maximum record time in milliseconds, or -1 for no timeout.
516516
* @param integer $offset to seek to without exceeding the end of the file.
517517
* @param boolean $beep
518-
* @param integer $silence number of seconds of silence allowed before the function returns despite the
518+
* @param integer $silence number of seconds of silence allowed before the function returns despite the
519519
* lack of dtmf digits or reaching timeout.
520-
* @return array, see evaluate for return information. ['result'] is -1 on error, 0 on hangup, otherwise a decimal value of the
520+
* @return array, see evaluate for return information. ['result'] is -1 on error, 0 on hangup, otherwise a decimal value of the
521521
* DTMF tone. Use chr() to convert to ASCII.
522522
*/
523523
function record_file($file, $format, $escape_digits='', $timeout=-1, $offset=NULL, $beep=false, $silence=NULL)
@@ -534,7 +534,7 @@ function record_file($file, $format, $escape_digits='', $timeout=-1, $offset=NUL
534534
* @link http://www.voip-info.org/wiki-say+digits
535535
* @param integer $digits
536536
* @param string $escape_digits
537-
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
537+
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
538538
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
539539
*/
540540
function say_digits($digits, $escape_digits='')
@@ -548,7 +548,7 @@ function say_digits($digits, $escape_digits='')
548548
* @link http://www.voip-info.org/wiki-say+number
549549
* @param integer $number
550550
* @param string $escape_digits
551-
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
551+
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
552552
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
553553
*/
554554
function say_number($number, $escape_digits='')
@@ -562,7 +562,7 @@ function say_number($number, $escape_digits='')
562562
* @link http://www.voip-info.org/wiki-say+phonetic
563563
* @param string $text
564564
* @param string $escape_digits
565-
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
565+
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
566566
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
567567
*/
568568
function say_phonetic($text, $escape_digits='')
@@ -576,7 +576,7 @@ function say_phonetic($text, $escape_digits='')
576576
* @link http://www.voip-info.org/wiki-say+time
577577
* @param integer $time number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
578578
* @param string $escape_digits
579-
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
579+
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no
580580
* digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII.
581581
*/
582582
function say_time($time=NULL, $escape_digits='')
@@ -592,7 +592,7 @@ function say_time($time=NULL, $escape_digits='')
592592
*
593593
* @link http://www.voip-info.org/wiki-send+image
594594
* @param string $image without extension, often in /var/lib/asterisk/images
595-
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the image is sent or
595+
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the image is sent or
596596
* channel does not support image transmission.
597597
*/
598598
function send_image($image)
@@ -607,7 +607,7 @@ function send_image($image)
607607
*
608608
* @link http://www.voip-info.org/wiki-send+text
609609
* @param $text
610-
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the text is sent or
610+
* @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the text is sent or
611611
* channel does not support text transmission.
612612
*/
613613
function send_text($text)
@@ -635,7 +635,7 @@ function set_autohangup($time=0)
635635
*
636636
* @link http://www.voip-info.org/wiki-set+callerid
637637
* @param string $cid example: "John Smith"<1234567>
638-
* This command will let you take liberties with the <caller ID specification> but the format shown in the example above works
638+
* This command will let you take liberties with the <caller ID specification> but the format shown in the example above works
639639
* well: the name enclosed in double quotes followed immediately by the number inside angle brackets. If there is no name then
640640
* you can omit it. If the name contains no spaces you can omit the double quotes around it. The number must follow the name
641641
* immediately; don't put a space between them. The angle brackets around the number are necessary; if you omit them the
@@ -650,14 +650,14 @@ function set_callerid($cid)
650650
/**
651651
* Sets the context for continuation upon exiting the application.
652652
*
653-
* Setting the context does NOT automatically reset the extension and the priority; if you want to start at the top of the new
654-
* context you should set extension and priority yourself.
653+
* Setting the context does NOT automatically reset the extension and the priority; if you want to start at the top of the new
654+
* context you should set extension and priority yourself.
655655
*
656-
* If you specify a non-existent context you receive no error indication (['result'] is still 0) but you do get a
656+
* If you specify a non-existent context you receive no error indication (['result'] is still 0) but you do get a
657657
* warning message on the Asterisk console.
658658
*
659659
* @link http://www.voip-info.org/wiki-set+context
660-
* @param string $context
660+
* @param string $context
661661
* @return array, see evaluate for return information.
662662
*/
663663
function set_context($context)
@@ -668,10 +668,10 @@ function set_context($context)
668668
/**
669669
* Set the extension to be used for continuation upon exiting the application.
670670
*
671-
* Setting the extension does NOT automatically reset the priority. If you want to start with the first priority of the
672-
* extension you should set the priority yourself.
671+
* Setting the extension does NOT automatically reset the priority. If you want to start with the first priority of the
672+
* extension you should set the priority yourself.
673673
*
674-
* If you specify a non-existent extension you receive no error indication (['result'] is still 0) but you do
674+
* If you specify a non-existent extension you receive no error indication (['result'] is still 0) but you do
675675
* get a warning message on the Asterisk console.
676676
*
677677
* @link http://www.voip-info.org/wiki-set+extension
@@ -716,8 +716,8 @@ function set_priority($priority)
716716
* Sets a variable to the specified value. The variables so created can later be used by later using ${<variablename>}
717717
* in the dialplan.
718718
*
719-
* These variables live in the channel Asterisk creates when you pickup a phone and as such they are both local and temporary.
720-
* Variables created in one channel can not be accessed by another channel. When you hang up the phone, the channel is deleted
719+
* These variables live in the channel Asterisk creates when you pickup a phone and as such they are both local and temporary.
720+
* Variables created in one channel can not be accessed by another channel. When you hang up the phone, the channel is deleted
721721
* and any variables in that channel are deleted as well.
722722
*
723723
* @link http://www.voip-info.org/wiki-set+variable
@@ -732,8 +732,8 @@ function set_variable($variable, $value)
732732
}
733733

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

@@ -1689,16 +1689,20 @@ function conlog($str, $vbl=1)
16891689
*/
16901690
function which($cmd, $checkpath=NULL)
16911691
{
1692-
global $_ENV;
1693-
$chpath = is_null($checkpath) ? $_ENV['PATH'] : $checkpath;
1692+
if (is_null($checkpath)) {
1693+
$chpath = getenv('PATH');
1694+
if ($chpath === false) {
1695+
$chpath = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:'.
1696+
'/usr/X11R6/bin:/usr/local/apache/bin:/usr/local/mysql/bin';
1697+
}
1698+
} else {
1699+
$chpath = $checkpath;
1700+
}
16941701

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

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

@@ -1708,7 +1712,7 @@ function which($cmd, $checkpath=NULL)
17081712
* @access private
17091713
* @param string $folder
17101714
* @param integer $perms
1711-
* @return boolean
1715+
* @return boolean
17121716
*/
17131717
function make_folder($folder, $perms=0755)
17141718
{
@@ -1725,7 +1729,7 @@ function make_folder($folder, $perms=0755)
17251729
$base .= DIRECTORY_SEPARATOR;
17261730
}
17271731
return(TRUE);
1728-
}
1732+
}
17291733

17301734
}
17311735

0 commit comments

Comments
 (0)