From 12513f099efa07873f268fdfeb3dc8919ab1f3ad Mon Sep 17 00:00:00 2001 From: Kudryavtsev Date: Tue, 11 Jun 2019 13:37:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=8D=D0=B2=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20asterisk=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8?= =?UTF-8?q?=D0=B8=2014=20=D0=B8=20=D0=B2=D1=8B=D1=88=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Поддержка эвентов для asterisk версии 14 и выше --- src/phpagi-asmanager.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/phpagi-asmanager.php b/src/phpagi-asmanager.php index 5eb69a4..a9b61c8 100644 --- a/src/phpagi-asmanager.php +++ b/src/phpagi-asmanager.php @@ -97,7 +97,7 @@ class AGI_AsteriskManager * @var boolean */ private $_logged_in = false; - + public function setPagi(&$agi) { $this->pagi = $agi; @@ -191,12 +191,30 @@ function read_one_msg($allow_timeout = false) $r = explode(': ', $msgarr[0]); $type = strtolower($r[0]); - if ($r[1] == 'Follows') { - $str = array_pop($msgarr); - $lastline = strpos($str, '--END COMMAND--'); - if (false !== $lastline) { - $parameters['data'] = substr($str, 0, $lastline-1); // cut '\n' too - } + if ($r[1] == 'Success' || $r[1] == 'Follows') { + $m = explode(': ', $msgarr[2]); + $msgarr_tmp = $msgarr; + $str = array_pop($msgarr); + $lastline = strpos($str, '--END COMMAND--'); + if (false !== $lastline) { + $parameters['data'] = substr($str, 0, $lastline-1); // cut '\n' too + } else { + if ($m[1] == 'Command output follows') { + $n = 3; + $c = count($msgarr_tmp) - 1; + $output = explode(': ', $msgarr_tmp[3]); + if ($output[1]) { + $data = $output[1]; + while ($n++<$c) { + $output = explode(': ', $msgarr_tmp[$n]); + if ($output[1]) { + $data .= "\n".$output[1]; + } + } + $parameters['data'] = $data; + } + } + } } foreach ($msgarr as $num=>$str) {