@@ -12,21 +12,21 @@ |
||
| 12 | 12 | // Функция позволяет получить активные каналы. |
| 13 | 13 | // Возвращает ассоциативный массив. Ключ - Linkedid, значение - массив каналов. |
| 14 | 14 | function get_active_id_channels($EXTEN){ |
| 15 | - $ParkeeChannel = ''; |
|
| 16 | - $am = Util::get_am('off'); |
|
| 15 | + $ParkeeChannel = ''; |
|
| 16 | + $am = Util::get_am('off'); |
|
| 17 | 17 | if(!$am->logged_in()){ |
| 18 | 18 | return $ParkeeChannel; |
| 19 | 19 | } |
| 20 | - $res = $am->ParkedCalls('default'); |
|
| 21 | - if(count($res['data'])==0) return $ParkeeChannel; |
|
| 20 | + $res = $am->ParkedCalls('default'); |
|
| 21 | + if(count($res['data'])==0) return $ParkeeChannel; |
|
| 22 | 22 | |
| 23 | 23 | foreach($res['data']['ParkedCall'] as $park_row){ |
| 24 | - if($park_row['ParkingSpace'] == $EXTEN){ |
|
| 25 | - $ParkeeChannel = $park_row['ParkeeChannel']; |
|
| 26 | - } |
|
| 24 | + if($park_row['ParkingSpace'] == $EXTEN){ |
|
| 25 | + $ParkeeChannel = $park_row['ParkeeChannel']; |
|
| 26 | + } |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return $ParkeeChannel; |
|
| 29 | + return $ParkeeChannel; |
|
| 30 | 30 | } |
| 31 | 31 | $agi = new AGI(); |
| 32 | 32 | $exten = $agi->get_variable("EXTEN", true); |
@@ -11,17 +11,17 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | // Функция позволяет получить активные каналы. |
| 13 | 13 | // Возвращает ассоциативный массив. Ключ - Linkedid, значение - массив каналов. |
| 14 | -function get_active_id_channels($EXTEN){ |
|
| 14 | +function get_active_id_channels($EXTEN) { |
|
| 15 | 15 | $ParkeeChannel = ''; |
| 16 | - $am = Util::get_am('off'); |
|
| 17 | - if(!$am->logged_in()){ |
|
| 16 | + $am = Util::get_am('off'); |
|
| 17 | + if (!$am->logged_in()) { |
|
| 18 | 18 | return $ParkeeChannel; |
| 19 | 19 | } |
| 20 | - $res = $am->ParkedCalls('default'); |
|
| 21 | - if(count($res['data'])==0) return $ParkeeChannel; |
|
| 20 | + $res = $am->ParkedCalls('default'); |
|
| 21 | + if (count($res['data']) == 0) return $ParkeeChannel; |
|
| 22 | 22 | |
| 23 | - foreach($res['data']['ParkedCall'] as $park_row){ |
|
| 24 | - if($park_row['ParkingSpace'] == $EXTEN){ |
|
| 23 | + foreach ($res['data']['ParkedCall'] as $park_row) { |
|
| 24 | + if ($park_row['ParkingSpace'] == $EXTEN) { |
|
| 25 | 25 | $ParkeeChannel = $park_row['ParkeeChannel']; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | return $ParkeeChannel; |
| 30 | 30 | } |
| 31 | 31 | $agi = new AGI(); |
| 32 | -$exten = $agi->get_variable("EXTEN", true); |
|
| 32 | +$exten = $agi->get_variable("EXTEN", true); |
|
| 33 | 33 | |
| 34 | 34 | $PARK_CHAN = get_active_id_channels($exten); |
| 35 | 35 | $agi->set_variable("__pt1c_IS_PARK", "1"); |
@@ -18,7 +18,9 @@ |
||
| 18 | 18 | return $ParkeeChannel; |
| 19 | 19 | } |
| 20 | 20 | $res = $am->ParkedCalls('default'); |
| 21 | - if(count($res['data'])==0) return $ParkeeChannel; |
|
| 21 | + if(count($res['data'])==0) { |
|
| 22 | + return $ParkeeChannel; |
|
| 23 | + } |
|
| 22 | 24 | |
| 23 | 25 | foreach($res['data']['ParkedCall'] as $park_row){ |
| 24 | 26 | if($park_row['ParkingSpace'] == $EXTEN){ |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if (!class_exists('AGI_AsteriskManager')) { |
| 11 | - require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi-asmanager.php'); |
|
| 11 | + require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'phpagi-asmanager.php'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | define('AST_CONFIG_DIR', '/etc/asterisk/'); |
| 15 | 15 | define('AST_SPOOL_DIR', '/var/spool/asterisk/'); |
| 16 | -define('AST_TMP_DIR', AST_SPOOL_DIR . '/tmp/'); |
|
| 17 | -define('DEFAULT_PHPAGI_CONFIG', AST_CONFIG_DIR . '/phpagi.conf'); |
|
| 16 | +define('AST_TMP_DIR', AST_SPOOL_DIR.'/tmp/'); |
|
| 17 | +define('DEFAULT_PHPAGI_CONFIG', AST_CONFIG_DIR.'/phpagi.conf'); |
|
| 18 | 18 | |
| 19 | 19 | define('AST_DIGIT_ANY', '0123456789#*'); |
| 20 | 20 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param string $config is the name of the config file to parse |
| 123 | 123 | * @param array $optconfig is an array of configuration vars and vals, stuffed into $this->config['phpagi'] |
| 124 | 124 | */ |
| 125 | - function __construct($config = NULL, $optconfig = array()){ |
|
| 125 | + function __construct($config = NULL, $optconfig = array()) { |
|
| 126 | 126 | // load config |
| 127 | 127 | if (!is_null($config) && file_exists($config)) $this->config = parse_ini_file($config, true); elseif (file_exists(DEFAULT_PHPAGI_CONFIG)) $this->config = parse_ini_file(DEFAULT_PHPAGI_CONFIG, true); |
| 128 | 128 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | // open audio if eagi detected |
| 169 | 169 | if ($this->request['agi_enhanced'] == '1.0') { |
| 170 | - if (file_exists('/proc/' . getmypid() . '/fd/3')) $this->audio = fopen('/proc/' . getmypid() . '/fd/3', 'r'); elseif (file_exists('/dev/fd/3')) { |
|
| 170 | + if (file_exists('/proc/'.getmypid().'/fd/3')) $this->audio = fopen('/proc/'.getmypid().'/fd/3', 'r'); elseif (file_exists('/dev/fd/3')) { |
|
| 171 | 171 | // may need to mount fdescfs |
| 172 | 172 | $this->audio = fopen('/dev/fd/3', 'r'); |
| 173 | 173 | } else |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return array, see evaluate for return information. ['result'] is 0 on success, -1 on failure. |
| 198 | 198 | */ |
| 199 | - function answer(){ |
|
| 199 | + function answer() { |
|
| 200 | 200 | return $this->evaluate('ANSWER'); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @param string $channel |
| 208 | 208 | * @return array, see evaluate for return information. ['data'] contains description. |
| 209 | 209 | */ |
| 210 | - function channel_status($channel = ''){ |
|
| 210 | + function channel_status($channel = '') { |
|
| 211 | 211 | $ret = $this->evaluate("CHANNEL STATUS $channel"); |
| 212 | 212 | switch ($ret['result']) { |
| 213 | 213 | case -1: |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @param string $key |
| 259 | 259 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise. |
| 260 | 260 | */ |
| 261 | - function database_del($family, $key){ |
|
| 261 | + function database_del($family, $key) { |
|
| 262 | 262 | return $this->evaluate("DATABASE DEL \"$family\" \"$key\""); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param string $keytree |
| 271 | 271 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise. |
| 272 | 272 | */ |
| 273 | - function database_deltree($family, $keytree = ''){ |
|
| 273 | + function database_deltree($family, $keytree = '') { |
|
| 274 | 274 | $cmd = "DATABASE DELTREE \"$family\""; |
| 275 | 275 | if ($keytree != '') $cmd .= " \"$keytree\""; |
| 276 | 276 | return $this->evaluate($cmd); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param string $key |
| 285 | 285 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 failure. ['data'] holds the value |
| 286 | 286 | */ |
| 287 | - function database_get($family, $key){ |
|
| 287 | + function database_get($family, $key) { |
|
| 288 | 288 | return $this->evaluate("DATABASE GET \"$family\" \"$key\""); |
| 289 | 289 | } |
| 290 | 290 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @param string $value |
| 297 | 297 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise |
| 298 | 298 | */ |
| 299 | - function database_put($family, $key, $value){ |
|
| 299 | + function database_put($family, $key, $value) { |
|
| 300 | 300 | $value = str_replace("\n", '\n', addslashes($value)); |
| 301 | 301 | return $this->evaluate("DATABASE PUT \"$family\" \"$key\" \"$value\""); |
| 302 | 302 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param string|int|float $pValue |
| 312 | 312 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise |
| 313 | 313 | */ |
| 314 | - function set_global_var($pVariable, $pValue){ |
|
| 314 | + function set_global_var($pVariable, $pValue) { |
|
| 315 | 315 | if (is_numeric($pValue)) return $this->evaluate("Set({$pVariable}={$pValue},g);"); else |
| 316 | 316 | return $this->evaluate("Set({$pVariable}=\"{$pValue}\",g);"); |
| 317 | 317 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param string|int|float $pValue |
| 327 | 327 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise |
| 328 | 328 | */ |
| 329 | - function set_var($pVariable, $pValue){ |
|
| 329 | + function set_var($pVariable, $pValue) { |
|
| 330 | 330 | if (is_numeric($pValue)) return $this->evaluate("Set({$pVariable}={$pValue});"); else |
| 331 | 331 | return $this->evaluate("Set({$pVariable}=\"{$pValue}\");"); |
| 332 | 332 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param mixed $options |
| 342 | 342 | * @return array, see evaluate for return information. ['result'] is whatever the application returns, or -2 on failure to find application |
| 343 | 343 | */ |
| 344 | - function exec($application, $options){ |
|
| 344 | + function exec($application, $options) { |
|
| 345 | 345 | if (is_array($options)) $options = join('|', $options); |
| 346 | 346 | return $this->evaluate("EXEC $application $options"); |
| 347 | 347 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * |
| 384 | 384 | * This differs from other commands with return DTMF as numbers representing ASCII characters. |
| 385 | 385 | */ |
| 386 | - function get_data($filename, $timeout = NULL, $max_digits = NULL){ |
|
| 386 | + function get_data($filename, $timeout = NULL, $max_digits = NULL) { |
|
| 387 | 387 | return $this->evaluate(rtrim("GET DATA $filename $timeout $max_digits")); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -398,9 +398,9 @@ discard block |
||
| 398 | 398 | * @param boolean $getvalue return the value only |
| 399 | 399 | * @return array | string, 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 |
| 400 | 400 | */ |
| 401 | - function get_variable($variable, $getvalue = FALSE){ |
|
| 401 | + function get_variable($variable, $getvalue = FALSE) { |
|
| 402 | 402 | $res = $this->evaluate("GET VARIABLE $variable"); |
| 403 | - if ($getvalue == FALSE){ |
|
| 403 | + if ($getvalue == FALSE) { |
|
| 404 | 404 | return ($res); |
| 405 | 405 | } |
| 406 | 406 | return trim($res['data']); |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | * @param boolean $getvalue return the value only |
| 419 | 419 | * @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 |
| 420 | 420 | */ |
| 421 | - function get_fullvariable($variable, $channel = '', $getvalue = FALSE){ |
|
| 421 | + function get_fullvariable($variable, $channel = '', $getvalue = FALSE) { |
|
| 422 | 422 | if ($channel == '') { |
| 423 | 423 | $req = $variable; |
| 424 | 424 | } else { |
| 425 | - $req = $variable . ' ' . $channel; |
|
| 425 | + $req = $variable.' '.$channel; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - $res = $this->evaluate('GET VARIABLE FULL ' . $req); |
|
| 428 | + $res = $this->evaluate('GET VARIABLE FULL '.$req); |
|
| 429 | 429 | |
| 430 | 430 | if ($getvalue == FALSE) return ($res); |
| 431 | 431 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @param string $channel |
| 448 | 448 | * @return array, see evaluate for return information. ['result'] is 1 on success, -1 on failure. |
| 449 | 449 | */ |
| 450 | - function hangup($channel = ''){ |
|
| 450 | + function hangup($channel = '') { |
|
| 451 | 451 | return $this->evaluate("HANGUP $channel"); |
| 452 | 452 | } |
| 453 | 453 | |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @param string $string |
| 459 | 459 | * @return array, see evaluate for return information. |
| 460 | 460 | */ |
| 461 | - function noop($string = ""){ |
|
| 461 | + function noop($string = "") { |
|
| 462 | 462 | return $this->evaluate("NOOP \"$string\""); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @return array, see evaluate for return information. ['result'] is 0 on timeout or not supported, -1 on failure. Otherwise |
| 472 | 472 | * it is the decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 473 | 473 | */ |
| 474 | - function receive_char($timeout = -1){ |
|
| 474 | + function receive_char($timeout = -1) { |
|
| 475 | 475 | return $this->evaluate("RECEIVE CHAR $timeout"); |
| 476 | 476 | } |
| 477 | 477 | |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @return array, see evaluate for return information. ['result'] is -1 on error, 0 on hangup, otherwise a decimal value of the |
| 492 | 492 | * DTMF tone. Use chr() to convert to ASCII. |
| 493 | 493 | */ |
| 494 | - function record_file($file, $format, $escape_digits = '', $timeout = -1, $offset = NULL, $beep = false, $silence = NULL){ |
|
| 494 | + function record_file($file, $format, $escape_digits = '', $timeout = -1, $offset = NULL, $beep = false, $silence = NULL) { |
|
| 495 | 495 | $cmd = trim("RECORD FILE $file $format \"$escape_digits\" $timeout $offset"); |
| 496 | 496 | if ($beep) $cmd .= ' BEEP'; |
| 497 | 497 | if (!is_null($silence)) $cmd .= " s=$silence"; |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 508 | 508 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 509 | 509 | */ |
| 510 | - function say_digits($digits, $escape_digits = ''){ |
|
| 510 | + function say_digits($digits, $escape_digits = '') { |
|
| 511 | 511 | return $this->evaluate("SAY DIGITS $digits \"$escape_digits\""); |
| 512 | 512 | } |
| 513 | 513 | |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 521 | 521 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 522 | 522 | */ |
| 523 | - function say_number($number, $escape_digits = ''){ |
|
| 523 | + function say_number($number, $escape_digits = '') { |
|
| 524 | 524 | return $this->evaluate("SAY NUMBER $number \"$escape_digits\""); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 534 | 534 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 535 | 535 | */ |
| 536 | - function say_phonetic($text, $escape_digits = ''){ |
|
| 536 | + function say_phonetic($text, $escape_digits = '') { |
|
| 537 | 537 | return $this->evaluate("SAY PHONETIC $text \"$escape_digits\""); |
| 538 | 538 | } |
| 539 | 539 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 547 | 547 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 548 | 548 | */ |
| 549 | - function say_time($time = NULL, $escape_digits = ''){ |
|
| 549 | + function say_time($time = NULL, $escape_digits = '') { |
|
| 550 | 550 | if (is_null($time)) $time = time(); |
| 551 | 551 | return $this->evaluate("SAY TIME $time \"$escape_digits\""); |
| 552 | 552 | } |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the image is sent or |
| 562 | 562 | * channel does not support image transmission. |
| 563 | 563 | */ |
| 564 | - function send_image($image){ |
|
| 564 | + function send_image($image) { |
|
| 565 | 565 | return $this->evaluate("SEND IMAGE $image"); |
| 566 | 566 | } |
| 567 | 567 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if the text is sent or |
| 576 | 576 | * channel does not support text transmission. |
| 577 | 577 | */ |
| 578 | - function send_text($text){ |
|
| 578 | + function send_text($text) { |
|
| 579 | 579 | return $this->evaluate("SEND TEXT \"$text\""); |
| 580 | 580 | } |
| 581 | 581 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * @param integer $time until automatic hangup |
| 590 | 590 | * @return array, see evaluate for return information. |
| 591 | 591 | */ |
| 592 | - function set_autohangup($time = 0){ |
|
| 592 | + function set_autohangup($time = 0) { |
|
| 593 | 593 | return $this->evaluate("SET AUTOHANGUP $time"); |
| 594 | 594 | } |
| 595 | 595 | |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | * number will be considered to be part of the name. |
| 606 | 606 | * @return array, see evaluate for return information. |
| 607 | 607 | */ |
| 608 | - function set_callerid($cid){ |
|
| 608 | + function set_callerid($cid) { |
|
| 609 | 609 | return $this->evaluate("SET CALLERID $cid"); |
| 610 | 610 | } |
| 611 | 611 | |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | * @param string $context |
| 623 | 623 | * @return array, see evaluate for return information. |
| 624 | 624 | */ |
| 625 | - function set_context($context){ |
|
| 625 | + function set_context($context) { |
|
| 626 | 626 | return $this->evaluate("SET CONTEXT $context"); |
| 627 | 627 | } |
| 628 | 628 | |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | * @param string $extension |
| 640 | 640 | * @return array, see evaluate for return information. |
| 641 | 641 | */ |
| 642 | - function set_extension($extension){ |
|
| 642 | + function set_extension($extension) { |
|
| 643 | 643 | return $this->evaluate("SET EXTENSION $extension"); |
| 644 | 644 | } |
| 645 | 645 | |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | * @param string $class |
| 652 | 652 | * @return array, see evaluate for return information. |
| 653 | 653 | */ |
| 654 | - function set_music($enabled = true, $class = ''){ |
|
| 654 | + function set_music($enabled = true, $class = '') { |
|
| 655 | 655 | $enabled = ($enabled) ? 'ON' : 'OFF'; |
| 656 | 656 | return $this->evaluate("SET MUSIC $enabled $class"); |
| 657 | 657 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | * @param integer $priority |
| 667 | 667 | * @return array, see evaluate for return information. |
| 668 | 668 | */ |
| 669 | - function set_priority($priority){ |
|
| 669 | + function set_priority($priority) { |
|
| 670 | 670 | return $this->evaluate("SET PRIORITY $priority"); |
| 671 | 671 | } |
| 672 | 672 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | * @param string $value |
| 684 | 684 | * @return array, see evaluate for return information. |
| 685 | 685 | */ |
| 686 | - function set_variable($variable, $value){ |
|
| 686 | + function set_variable($variable, $value) { |
|
| 687 | 687 | $value = str_replace("\n", '\n', addslashes($value)); |
| 688 | 688 | return $this->evaluate("SET VARIABLE $variable \"$value\""); |
| 689 | 689 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 703 | 703 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 704 | 704 | */ |
| 705 | - function stream_file($filename, $escape_digits = '', $offset = 0){ |
|
| 705 | + function stream_file($filename, $escape_digits = '', $offset = 0) { |
|
| 706 | 706 | return $this->evaluate("STREAM FILE $filename \"$escape_digits\" $offset"); |
| 707 | 707 | } |
| 708 | 708 | |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | * @param string $setting can be on, off or mate |
| 714 | 714 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 if the channel is not TDD capable. |
| 715 | 715 | */ |
| 716 | - function tdd_mode($setting){ |
|
| 716 | + function tdd_mode($setting) { |
|
| 717 | 717 | return $this->evaluate("TDD MODE $setting"); |
| 718 | 718 | } |
| 719 | 719 | |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | * @param integer $level from 1 to 4 |
| 733 | 733 | * @return array, see evaluate for return information. |
| 734 | 734 | */ |
| 735 | - function verbose($message, $level = 1){ |
|
| 735 | + function verbose($message, $level = 1) { |
|
| 736 | 736 | $ret = ''; |
| 737 | 737 | foreach (explode("\n", str_replace("\r\n", "\n", print_r($message, true))) as $msg) { |
| 738 | 738 | @syslog(LOG_WARNING, $msg); |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | * @return array, see evaluate for return information. ['result'] is 0 if wait completes with no |
| 750 | 750 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 751 | 751 | */ |
| 752 | - function wait_for_digit($timeout = -1){ |
|
| 752 | + function wait_for_digit($timeout = -1) { |
|
| 753 | 753 | return $this->evaluate("WAIT FOR DIGIT $timeout"); |
| 754 | 754 | } |
| 755 | 755 | |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | * @param $seconds ,allowed, 0 disables timeout |
| 772 | 772 | * @return array, see evaluate for return information. |
| 773 | 773 | */ |
| 774 | - function exec_absolutetimeout($seconds = 0){ |
|
| 774 | + function exec_absolutetimeout($seconds = 0) { |
|
| 775 | 775 | return $this->exec('AbsoluteTimeout', $seconds); |
| 776 | 776 | } |
| 777 | 777 | |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or if application requested hangup, or 0 on non-hangup exit. |
| 783 | 783 | * @param string $args |
| 784 | 784 | */ |
| 785 | - function exec_agi($command, $args){ |
|
| 785 | + function exec_agi($command, $args) { |
|
| 786 | 786 | return $this->exec("AGI $command", $args); |
| 787 | 787 | } |
| 788 | 788 | |
@@ -792,8 +792,8 @@ discard block |
||
| 792 | 792 | * @param string $language code |
| 793 | 793 | * @return array, see evaluate for return information. |
| 794 | 794 | */ |
| 795 | - function exec_setlanguage($language = 'en'){ |
|
| 796 | - return $this->exec('Set', 'CHANNEL(language)=' . $language); |
|
| 795 | + function exec_setlanguage($language = 'en') { |
|
| 796 | + return $this->exec('Set', 'CHANNEL(language)='.$language); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | /** |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * @param $exten |
| 806 | 806 | * @return array, see evaluate for return information. |
| 807 | 807 | */ |
| 808 | - function exec_enumlookup($exten){ |
|
| 808 | + function exec_enumlookup($exten) { |
|
| 809 | 809 | return $this->exec('EnumLookup', $exten); |
| 810 | 810 | } |
| 811 | 811 | |
@@ -825,8 +825,8 @@ discard block |
||
| 825 | 825 | * @param string $url |
| 826 | 826 | * @return array, see evaluate for return information. |
| 827 | 827 | */ |
| 828 | - function exec_dial($type, $identifier, $timeout = NULL, $options = NULL, $url = NULL){ |
|
| 829 | - return $this->exec('Dial', trim("$type/$identifier" . $this->option_delim . $timeout . $this->option_delim . $options . $this->option_delim . $url, $this->option_delim)); |
|
| 828 | + function exec_dial($type, $identifier, $timeout = NULL, $options = NULL, $url = NULL) { |
|
| 829 | + return $this->exec('Dial', trim("$type/$identifier".$this->option_delim.$timeout.$this->option_delim.$options.$this->option_delim.$url, $this->option_delim)); |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | /** |
@@ -840,8 +840,8 @@ discard block |
||
| 840 | 840 | * @param string $c ; |
| 841 | 841 | * @return array, see evaluate for return information. |
| 842 | 842 | */ |
| 843 | - function exec_goto($a, $b = NULL, $c = NULL){ |
|
| 844 | - return $this->exec('Goto', trim($a . $this->option_delim . $b . $this->option_delim . $c, $this->option_delim)); |
|
| 843 | + function exec_goto($a, $b = NULL, $c = NULL) { |
|
| 844 | + return $this->exec('Goto', trim($a.$this->option_delim.$b.$this->option_delim.$c, $this->option_delim)); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | |
@@ -860,10 +860,10 @@ discard block |
||
| 860 | 860 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 861 | 861 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 862 | 862 | */ |
| 863 | - function fastpass_say_digits(&$buffer, $digits, $escape_digits = ''){ |
|
| 863 | + function fastpass_say_digits(&$buffer, $digits, $escape_digits = '') { |
|
| 864 | 864 | $proceed = false; |
| 865 | 865 | if ($escape_digits != '' && $buffer != '') { |
| 866 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 866 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 867 | 867 | } |
| 868 | 868 | if ($buffer == '' || $proceed) { |
| 869 | 869 | $res = $this->say_digits($digits, $escape_digits); |
@@ -884,10 +884,10 @@ discard block |
||
| 884 | 884 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 885 | 885 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 886 | 886 | */ |
| 887 | - function fastpass_say_number(&$buffer, $number, $escape_digits = ''){ |
|
| 887 | + function fastpass_say_number(&$buffer, $number, $escape_digits = '') { |
|
| 888 | 888 | $proceed = false; |
| 889 | 889 | if ($escape_digits != '' && $buffer != '') { |
| 890 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 890 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 891 | 891 | } |
| 892 | 892 | if ($buffer == '' || $proceed) { |
| 893 | 893 | $res = $this->say_number($number, $escape_digits); |
@@ -908,10 +908,10 @@ discard block |
||
| 908 | 908 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 909 | 909 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 910 | 910 | */ |
| 911 | - function fastpass_say_phonetic(&$buffer, $text, $escape_digits = ''){ |
|
| 911 | + function fastpass_say_phonetic(&$buffer, $text, $escape_digits = '') { |
|
| 912 | 912 | $proceed = false; |
| 913 | 913 | if ($escape_digits != '' && $buffer != '') { |
| 914 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 914 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 915 | 915 | } |
| 916 | 916 | if ($buffer == '' || $proceed) { |
| 917 | 917 | $res = $this->say_phonetic($text, $escape_digits); |
@@ -932,10 +932,10 @@ discard block |
||
| 932 | 932 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 933 | 933 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 934 | 934 | */ |
| 935 | - function fastpass_say_time(&$buffer, $time = NULL, $escape_digits = ''){ |
|
| 935 | + function fastpass_say_time(&$buffer, $time = NULL, $escape_digits = '') { |
|
| 936 | 936 | $proceed = false; |
| 937 | 937 | if ($escape_digits != '' && $buffer != '') { |
| 938 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 938 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 939 | 939 | } |
| 940 | 940 | if ($buffer == '' || $proceed) { |
| 941 | 941 | $res = $this->say_time($time, $escape_digits); |
@@ -959,10 +959,10 @@ discard block |
||
| 959 | 959 | * @return array, see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no |
| 960 | 960 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 961 | 961 | */ |
| 962 | - function fastpass_stream_file(&$buffer, $filename, $escape_digits = '', $offset = 0){ |
|
| 962 | + function fastpass_stream_file(&$buffer, $filename, $escape_digits = '', $offset = 0) { |
|
| 963 | 963 | $proceed = false; |
| 964 | 964 | if ($escape_digits != '' && $buffer != '') { |
| 965 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 965 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 966 | 966 | } |
| 967 | 967 | if ($buffer == '' || $proceed) { |
| 968 | 968 | $res = $this->stream_file($filename, $escape_digits, $offset); |
@@ -983,10 +983,10 @@ discard block |
||
| 983 | 983 | * @param integer $frequency |
| 984 | 984 | * @return array, see evaluate for return information. |
| 985 | 985 | */ |
| 986 | - function fastpass_text2wav(&$buffer, $text, $escape_digits = '', $frequency = 8000){ |
|
| 986 | + function fastpass_text2wav(&$buffer, $text, $escape_digits = '', $frequency = 8000) { |
|
| 987 | 987 | $proceed = false; |
| 988 | 988 | if ($escape_digits != '' && $buffer != '') { |
| 989 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 989 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 990 | 990 | } |
| 991 | 991 | if ($buffer == '' || $proceed) { |
| 992 | 992 | $res = $this->text2wav($text, $escape_digits, $frequency); |
@@ -1008,10 +1008,10 @@ discard block |
||
| 1008 | 1008 | * @param string $voice |
| 1009 | 1009 | * @return array, see evaluate for return information. |
| 1010 | 1010 | */ |
| 1011 | - function fastpass_swift(&$buffer, $text, $escape_digits = '', $frequency = 8000, $voice = NULL){ |
|
| 1011 | + function fastpass_swift(&$buffer, $text, $escape_digits = '', $frequency = 8000, $voice = NULL) { |
|
| 1012 | 1012 | $proceed = false; |
| 1013 | 1013 | if ($escape_digits != '' && $buffer != '') { |
| 1014 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1014 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | if ($buffer == '' || $proceed) { |
| 1017 | 1017 | $res = $this->swift($text, $escape_digits, $frequency, $voice); |
@@ -1031,10 +1031,10 @@ discard block |
||
| 1031 | 1031 | * @param integer $frequency |
| 1032 | 1032 | * @return array, see evaluate for return information. |
| 1033 | 1033 | */ |
| 1034 | - function fastpass_say_punctuation(&$buffer, $text, $escape_digits = '', $frequency = 8000){ |
|
| 1034 | + function fastpass_say_punctuation(&$buffer, $text, $escape_digits = '', $frequency = 8000) { |
|
| 1035 | 1035 | $proceed = false; |
| 1036 | 1036 | if ($escape_digits != '' && $buffer != '') { |
| 1037 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1037 | + if (!strpos(chr(255).$escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1038 | 1038 | } |
| 1039 | 1039 | if ($buffer == '' || $proceed) { |
| 1040 | 1040 | $res = $this->say_punctuation($text, $escape_digits, $frequency); |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | * |
| 1082 | 1082 | * This differs from other commands with return DTMF as numbers representing ASCII characters. |
| 1083 | 1083 | */ |
| 1084 | - function fastpass_get_data(&$buffer, $filename, $timeout = NULL, $max_digits = NULL){ |
|
| 1084 | + function fastpass_get_data(&$buffer, $filename, $timeout = NULL, $max_digits = NULL) { |
|
| 1085 | 1085 | if (is_null($max_digits) || strlen($buffer) < $max_digits) { |
| 1086 | 1086 | if ($buffer == '') { |
| 1087 | 1087 | $res = $this->get_data($filename, $timeout, $max_digits); |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @param $timeout |
| 1116 | 1116 | * @return mixed key pressed on sucess, -1 on failure |
| 1117 | 1117 | */ |
| 1118 | - function menu($choices, $timeout = 2000){ |
|
| 1118 | + function menu($choices, $timeout = 2000) { |
|
| 1119 | 1119 | $keys = join('', array_keys($choices)); |
| 1120 | 1120 | $choice = NULL; |
| 1121 | 1121 | while (is_null($choice)) { |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | |
| 1137 | 1137 | if (is_null($choice)) { |
| 1138 | 1138 | $ret = $this->get_data('beep', $timeout, 1); |
| 1139 | - if ($ret['code'] != AGIRES_OK || $ret['result'] == -1) $choice = -1; elseif ($ret['result'] != '' && strpos(' ' . $keys, $ret['result'])) $choice = $ret['result']; |
|
| 1139 | + if ($ret['code'] != AGIRES_OK || $ret['result'] == -1) $choice = -1; elseif ($ret['result'] != '' && strpos(' '.$keys, $ret['result'])) $choice = $ret['result']; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | return $choice; |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | * @param string $extension |
| 1150 | 1150 | * @param string $priority |
| 1151 | 1151 | */ |
| 1152 | - function setContext($context, $extension = 's', $priority = "1"){ |
|
| 1152 | + function setContext($context, $extension = 's', $priority = "1") { |
|
| 1153 | 1153 | $this->set_context($context); |
| 1154 | 1154 | $this->set_extension($extension); |
| 1155 | 1155 | $this->set_priority($priority); |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | * @param string $callerid |
| 1167 | 1167 | * @return array('Name'=>$name, 'Number'=>$number) |
| 1168 | 1168 | */ |
| 1169 | - function parse_callerid($callerid = NULL){ |
|
| 1169 | + function parse_callerid($callerid = NULL) { |
|
| 1170 | 1170 | if (is_null($callerid)) $callerid = $this->request['agi_callerid']; |
| 1171 | 1171 | |
| 1172 | 1172 | $ret = array('name' => '', 'protocol' => '', 'username' => '', 'host' => '', 'port' => ''); |
@@ -1209,13 +1209,13 @@ discard block |
||
| 1209 | 1209 | * @param integer $frequency |
| 1210 | 1210 | * @return array | bool, see evaluate for return information. |
| 1211 | 1211 | */ |
| 1212 | - function text2wav($text, $escape_digits = '', $frequency = 8000){ |
|
| 1212 | + function text2wav($text, $escape_digits = '', $frequency = 8000) { |
|
| 1213 | 1213 | $text = trim($text); |
| 1214 | 1214 | if ($text == '') return true; |
| 1215 | 1215 | |
| 1216 | 1216 | $hash = md5($text); |
| 1217 | - $fname = $this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR; |
|
| 1218 | - $fname .= 'text2wav_' . $hash; |
|
| 1217 | + $fname = $this->config['phpagi']['tempdir'].DIRECTORY_SEPARATOR; |
|
| 1218 | + $fname .= 'text2wav_'.$hash; |
|
| 1219 | 1219 | |
| 1220 | 1220 | // create wave file |
| 1221 | 1221 | if (!file_exists("$fname.wav")) { |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | |
| 1238 | 1238 | // clean up old files |
| 1239 | 1239 | $delete = time() - 2592000; // 1 month |
| 1240 | - foreach (glob($this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR . 'text2wav_*') as $file) if (filemtime($file) < $delete) unlink($file); |
|
| 1240 | + foreach (glob($this->config['phpagi']['tempdir'].DIRECTORY_SEPARATOR.'text2wav_*') as $file) if (filemtime($file) < $delete) unlink($file); |
|
| 1241 | 1241 | |
| 1242 | 1242 | return $ret; |
| 1243 | 1243 | } |
@@ -1252,15 +1252,15 @@ discard block |
||
| 1252 | 1252 | * @param $voice |
| 1253 | 1253 | * @return array | bool, see evaluate for return information. |
| 1254 | 1254 | */ |
| 1255 | - function swift($text, $escape_digits = '', $frequency = 8000, $voice = NULL){ |
|
| 1255 | + function swift($text, $escape_digits = '', $frequency = 8000, $voice = NULL) { |
|
| 1256 | 1256 | if (!is_null($voice)) $voice = "-n $voice"; elseif (isset($this->config['cepstral']['voice'])) $voice = "-n {$this->config['cepstral']['voice']}"; |
| 1257 | 1257 | |
| 1258 | 1258 | $text = trim($text); |
| 1259 | 1259 | if ($text == '') return true; |
| 1260 | 1260 | |
| 1261 | 1261 | $hash = md5($text); |
| 1262 | - $fname = $this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR; |
|
| 1263 | - $fname .= 'swift_' . $hash; |
|
| 1262 | + $fname = $this->config['phpagi']['tempdir'].DIRECTORY_SEPARATOR; |
|
| 1263 | + $fname .= 'swift_'.$hash; |
|
| 1264 | 1264 | |
| 1265 | 1265 | // create wave file |
| 1266 | 1266 | if (!file_exists("$fname.wav")) { |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | |
| 1280 | 1280 | // clean up old files |
| 1281 | 1281 | $delete = time() - 2592000; // 1 month |
| 1282 | - foreach (glob($this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR . 'swift_*') as $file) if (filemtime($file) < $delete) unlink($file); |
|
| 1282 | + foreach (glob($this->config['phpagi']['tempdir'].DIRECTORY_SEPARATOR.'swift_*') as $file) if (filemtime($file) < $delete) unlink($file); |
|
| 1283 | 1283 | |
| 1284 | 1284 | return $ret; |
| 1285 | 1285 | } |
@@ -1298,7 +1298,7 @@ discard block |
||
| 1298 | 1298 | * @param $mode |
| 1299 | 1299 | * @return string |
| 1300 | 1300 | */ |
| 1301 | - function text_input($mode = 'NUMERIC'){ |
|
| 1301 | + function text_input($mode = 'NUMERIC') { |
|
| 1302 | 1302 | $alpha = array('k0' => ' ', 'k00' => ',', 'k000' => '.', 'k0000' => '?', 'k00000' => '0', 'k1' => '!', 'k11' => ':', 'k111' => ';', 'k1111' => '#', 'k11111' => '1', 'k2' => 'A', 'k22' => 'B', 'k222' => 'C', 'k2222' => '2', 'k3' => 'D', 'k33' => 'E', 'k333' => 'F', 'k3333' => '3', 'k4' => 'G', 'k44' => 'H', 'k444' => 'I', 'k4444' => '4', 'k5' => 'J', 'k55' => 'K', 'k555' => 'L', 'k5555' => '5', 'k6' => 'M', 'k66' => 'N', 'k666' => 'O', 'k6666' => '6', 'k7' => 'P', 'k77' => 'Q', 'k777' => 'R', 'k7777' => 'S', 'k77777' => '7', 'k8' => 'T', 'k88' => 'U', 'k888' => 'V', 'k8888' => '8', 'k9' => 'W', 'k99' => 'X', 'k999' => 'Y', 'k9999' => 'Z', 'k99999' => '9'); |
| 1303 | 1303 | $symbol = array('k0' => '=', 'k1' => '<', 'k11' => '(', 'k111' => '[', 'k1111' => '{', 'k11111' => '1', 'k2' => '@', 'k22' => '$', 'k222' => '&', 'k2222' => '%', 'k22222' => '2', 'k3' => '>', 'k33' => ')', 'k333' => ']', 'k3333' => '}', 'k33333' => '3', 'k4' => '+', 'k44' => '-', 'k444' => '*', 'k4444' => '/', 'k44444' => '4', 'k5' => "'", 'k55' => '`', 'k555' => '5', 'k6' => '"', 'k66' => '6', 'k7' => '^', 'k77' => '7', 'k8' => "\\", 'k88' => '|', 'k888' => '8', 'k9' => '_', 'k99' => '~', 'k999' => '9'); |
| 1304 | 1304 | $text = ''; |
@@ -1333,9 +1333,9 @@ discard block |
||
| 1333 | 1333 | $command = false; |
| 1334 | 1334 | } |
| 1335 | 1335 | if ($code == '') $command = true; elseif ($mode == 'NUMERIC') $text .= $code; |
| 1336 | - elseif ($mode == 'UPPERCASE' && isset($alpha['k' . $code])) $text .= $alpha['k' . $code]; |
|
| 1337 | - elseif ($mode == 'LOWERCASE' && isset($alpha['k' . $code])) $text .= strtolower($alpha['k' . $code]); |
|
| 1338 | - elseif ($mode == 'SYMBOL' && isset($symbol['k' . $code])) $text .= $symbol['k' . $code]; |
|
| 1336 | + elseif ($mode == 'UPPERCASE' && isset($alpha['k'.$code])) $text .= $alpha['k'.$code]; |
|
| 1337 | + elseif ($mode == 'LOWERCASE' && isset($alpha['k'.$code])) $text .= strtolower($alpha['k'.$code]); |
|
| 1338 | + elseif ($mode == 'SYMBOL' && isset($symbol['k'.$code])) $text .= $symbol['k'.$code]; |
|
| 1339 | 1339 | } |
| 1340 | 1340 | $this->say_punctuation($text); |
| 1341 | 1341 | } while (substr($result['result'], -2) == '**'); |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | * @param integer $frequency |
| 1351 | 1351 | * @return array, see evaluate for return information. |
| 1352 | 1352 | */ |
| 1353 | - function say_punctuation($text, $escape_digits = '', $frequency = 8000){ |
|
| 1353 | + function say_punctuation($text, $escape_digits = '', $frequency = 8000) { |
|
| 1354 | 1354 | $ret = ""; |
| 1355 | 1355 | for ($i = 0; $i < strlen($text); $i++) { |
| 1356 | 1356 | switch ($text{$i}) { |
@@ -1454,7 +1454,7 @@ discard block |
||
| 1454 | 1454 | $ret .= 'TILDE '; |
| 1455 | 1455 | break; |
| 1456 | 1456 | default: |
| 1457 | - $ret .= $text{$i} . ' '; |
|
| 1457 | + $ret .= $text{$i}.' '; |
|
| 1458 | 1458 | break; |
| 1459 | 1459 | } |
| 1460 | 1460 | } |
@@ -1466,8 +1466,8 @@ discard block |
||
| 1466 | 1466 | */ |
| 1467 | 1467 | function &new_AsteriskManager(){ |
| 1468 | 1468 | $this->asm = new AGI_AsteriskManager(NULL, $this->config); |
| 1469 | - $this->asm->pagi =& $this; |
|
| 1470 | - $this->config =& $this->asm->config; |
|
| 1469 | + $this->asm->pagi = & $this; |
|
| 1470 | + $this->config = & $this->asm->config; |
|
| 1471 | 1471 | return $this->asm; |
| 1472 | 1472 | } |
| 1473 | 1473 | |
@@ -1484,11 +1484,11 @@ discard block |
||
| 1484 | 1484 | * @param string $command |
| 1485 | 1485 | * @return array ('code'=>$code, 'result'=>$result, 'data'=>$data) |
| 1486 | 1486 | */ |
| 1487 | - function evaluate($command){ |
|
| 1487 | + function evaluate($command) { |
|
| 1488 | 1488 | $broken = array('code' => 500, 'result' => -1, 'data' => ''); |
| 1489 | 1489 | |
| 1490 | 1490 | // write command |
| 1491 | - if (!@fwrite($this->out, trim($command) . "\n")) return $broken; |
|
| 1491 | + if (!@fwrite($this->out, trim($command)."\n")) return $broken; |
|
| 1492 | 1492 | fflush($this->out); |
| 1493 | 1493 | |
| 1494 | 1494 | // Read result. Occasionally, a command return a string followed by an extra new line. |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | if ($str{0} == '-') // we have a multiline response! |
| 1514 | 1514 | { |
| 1515 | 1515 | $count = 0; |
| 1516 | - $str = substr($str, 1) . "\n"; |
|
| 1516 | + $str = substr($str, 1)."\n"; |
|
| 1517 | 1517 | $line = fgets($this->in, 4096); |
| 1518 | 1518 | while (substr($line, 0, 3) != $ret['code'] && $count < 5) { |
| 1519 | 1519 | $str .= $line; |
@@ -1539,15 +1539,15 @@ discard block |
||
| 1539 | 1539 | foreach ($parse as $token) { |
| 1540 | 1540 | if ($in_token) // we previously hit a token starting with ')' but not ending in ')' |
| 1541 | 1541 | { |
| 1542 | - $ret['data'] .= ' ' . trim($token, '() '); |
|
| 1542 | + $ret['data'] .= ' '.trim($token, '() '); |
|
| 1543 | 1543 | if ($token{strlen($token) - 1} == ')') $in_token = false; |
| 1544 | 1544 | } elseif ($token{0} == '(') { |
| 1545 | 1545 | if ($token{strlen($token) - 1} != ')') $in_token = true; |
| 1546 | - $ret['data'] .= ' ' . trim($token, '() '); |
|
| 1546 | + $ret['data'] .= ' '.trim($token, '() '); |
|
| 1547 | 1547 | } elseif (strpos($token, '=')) { |
| 1548 | 1548 | $token = explode('=', $token); |
| 1549 | 1549 | $ret[$token[0]] = $token[1]; |
| 1550 | - } elseif ($token != '') $ret['data'] .= ' ' . $token; |
|
| 1550 | + } elseif ($token != '') $ret['data'] .= ' '.$token; |
|
| 1551 | 1551 | } |
| 1552 | 1552 | $ret['data'] = trim($ret['data']); |
| 1553 | 1553 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
| 1566 | 1566 | * @param string $str |
| 1567 | 1567 | * @param integer $vbl verbose level |
| 1568 | 1568 | */ |
| 1569 | - function conlog($str, $vbl = 1){ |
|
| 1569 | + function conlog($str, $vbl = 1) { |
|
| 1570 | 1570 | static $busy = false; |
| 1571 | 1571 | |
| 1572 | 1572 | if ($this->config['phpagi']['debug'] != false) { |
@@ -1587,13 +1587,13 @@ discard block |
||
| 1587 | 1587 | * @param string $checkpath path to check |
| 1588 | 1588 | * @return string the path to the command |
| 1589 | 1589 | */ |
| 1590 | - function which($cmd, $checkpath = NULL){ |
|
| 1590 | + function which($cmd, $checkpath = NULL) { |
|
| 1591 | 1591 | global $_ENV; |
| 1592 | 1592 | $chpath = is_null($checkpath) ? $_ENV['PATH'] : $checkpath; |
| 1593 | 1593 | |
| 1594 | 1594 | foreach (explode(':', $chpath) as $path) if (is_executable("$path/$cmd")) return "$path/$cmd"; |
| 1595 | 1595 | |
| 1596 | - 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'); |
|
| 1596 | + 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'); |
|
| 1597 | 1597 | return false; |
| 1598 | 1598 | } |
| 1599 | 1599 | |
@@ -1605,7 +1605,7 @@ discard block |
||
| 1605 | 1605 | * @param integer $perms |
| 1606 | 1606 | * @return boolean |
| 1607 | 1607 | */ |
| 1608 | - function make_folder($folder, $perms = 0755){ |
|
| 1608 | + function make_folder($folder, $perms = 0755) { |
|
| 1609 | 1609 | $f = explode(DIRECTORY_SEPARATOR, $folder); |
| 1610 | 1610 | $base = ''; |
| 1611 | 1611 | for ($i = 0; $i < count($f); $i++) { |
@@ -1632,10 +1632,10 @@ discard block |
||
| 1632 | 1632 | * @param integer $line line number of error |
| 1633 | 1633 | * @param array $context variables in the current scope |
| 1634 | 1634 | */ |
| 1635 | -function phpagi_error_handler($level, $message, $file, $line, $context){ |
|
| 1635 | +function phpagi_error_handler($level, $message, $file, $line, $context) { |
|
| 1636 | 1636 | if (ini_get('error_reporting') == 0) return; // this happens with an @ |
| 1637 | 1637 | |
| 1638 | - @syslog(LOG_WARNING, $file . '[' . $line . ']: ' . $message); |
|
| 1638 | + @syslog(LOG_WARNING, $file.'['.$line.']: '.$message); |
|
| 1639 | 1639 | |
| 1640 | 1640 | global $phpagi_error_handler_email; |
| 1641 | 1641 | if (function_exists('mail') && !is_null($phpagi_error_handler_email)) // generate email debugging information |
@@ -1672,23 +1672,23 @@ discard block |
||
| 1672 | 1672 | } |
| 1673 | 1673 | |
| 1674 | 1674 | // include variables |
| 1675 | - $message .= "\n\nContext:\n" . print_r($context, true); |
|
| 1676 | - $message .= "\n\nGLOBALS:\n" . print_r($GLOBALS, true); |
|
| 1677 | - $message .= "\n\nBacktrace:\n" . print_r(debug_backtrace(), true); |
|
| 1675 | + $message .= "\n\nContext:\n".print_r($context, true); |
|
| 1676 | + $message .= "\n\nGLOBALS:\n".print_r($GLOBALS, true); |
|
| 1677 | + $message .= "\n\nBacktrace:\n".print_r(debug_backtrace(), true); |
|
| 1678 | 1678 | |
| 1679 | 1679 | // include code fragment |
| 1680 | 1680 | if (file_exists($file)) { |
| 1681 | 1681 | $message .= "\n\n$file:\n"; |
| 1682 | 1682 | $code = @file($file); |
| 1683 | - for ($i = max(0, $line - 10); $i < min($line + 10, count($code)); $i++) $message .= ($i + 1) . "\t$code[$i]"; |
|
| 1683 | + for ($i = max(0, $line - 10); $i < min($line + 10, count($code)); $i++) $message .= ($i + 1)."\t$code[$i]"; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | // make sure message is fully readable (convert unprintable chars to hex representation) |
| 1687 | 1687 | $ret = ''; |
| 1688 | 1688 | for ($i = 0; $i < strlen($message); $i++) { |
| 1689 | 1689 | $c = ord($message{$i}); |
| 1690 | - if ($c == 10 || $c == 13 || $c == 9) $ret .= $message{$i}; elseif ($c < 16) $ret .= '\x0' . dechex($c); |
|
| 1691 | - elseif ($c < 32 || $c > 127) $ret .= '\x' . dechex($c); |
|
| 1690 | + if ($c == 10 || $c == 13 || $c == 9) $ret .= $message{$i}; elseif ($c < 16) $ret .= '\x0'.dechex($c); |
|
| 1691 | + elseif ($c < 32 || $c > 127) $ret .= '\x'.dechex($c); |
|
| 1692 | 1692 | else |
| 1693 | 1693 | $ret .= $message{$i}; |
| 1694 | 1694 | } |
@@ -124,22 +124,40 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | function __construct($config = NULL, $optconfig = array()){ |
| 126 | 126 | // load config |
| 127 | - if (!is_null($config) && file_exists($config)) $this->config = parse_ini_file($config, true); elseif (file_exists(DEFAULT_PHPAGI_CONFIG)) $this->config = parse_ini_file(DEFAULT_PHPAGI_CONFIG, true); |
|
| 127 | + if (!is_null($config) && file_exists($config)) { |
|
| 128 | + $this->config = parse_ini_file($config, true); |
|
| 129 | + } elseif (file_exists(DEFAULT_PHPAGI_CONFIG)) { |
|
| 130 | + $this->config = parse_ini_file(DEFAULT_PHPAGI_CONFIG, true); |
|
| 131 | + } |
|
| 128 | 132 | |
| 129 | 133 | // If optconfig is specified, stuff vals and vars into 'phpagi' config array. |
| 130 | - foreach ($optconfig as $var => $val) $this->config['phpagi'][$var] = $val; |
|
| 134 | + foreach ($optconfig as $var => $val) { |
|
| 135 | + $this->config['phpagi'][$var] = $val; |
|
| 136 | + } |
|
| 131 | 137 | |
| 132 | 138 | // add default values to config for uninitialized values |
| 133 | - if (!isset($this->config['phpagi']['error_handler'])) $this->config['phpagi']['error_handler'] = true; |
|
| 134 | - if (!isset($this->config['phpagi']['debug'])) $this->config['phpagi']['debug'] = false; |
|
| 135 | - if (!isset($this->config['phpagi']['admin'])) $this->config['phpagi']['admin'] = NULL; |
|
| 136 | - if (!isset($this->config['phpagi']['tempdir'])) $this->config['phpagi']['tempdir'] = AST_TMP_DIR; |
|
| 139 | + if (!isset($this->config['phpagi']['error_handler'])) { |
|
| 140 | + $this->config['phpagi']['error_handler'] = true; |
|
| 141 | + } |
|
| 142 | + if (!isset($this->config['phpagi']['debug'])) { |
|
| 143 | + $this->config['phpagi']['debug'] = false; |
|
| 144 | + } |
|
| 145 | + if (!isset($this->config['phpagi']['admin'])) { |
|
| 146 | + $this->config['phpagi']['admin'] = NULL; |
|
| 147 | + } |
|
| 148 | + if (!isset($this->config['phpagi']['tempdir'])) { |
|
| 149 | + $this->config['phpagi']['tempdir'] = AST_TMP_DIR; |
|
| 150 | + } |
|
| 137 | 151 | |
| 138 | 152 | // festival TTS config |
| 139 | - if (!isset($this->config['festival']['text2wave'])) $this->config['festival']['text2wave'] = $this->which('text2wave'); |
|
| 153 | + if (!isset($this->config['festival']['text2wave'])) { |
|
| 154 | + $this->config['festival']['text2wave'] = $this->which('text2wave'); |
|
| 155 | + } |
|
| 140 | 156 | |
| 141 | 157 | // swift TTS config |
| 142 | - if (!isset($this->config['cepstral']['swift'])) $this->config['cepstral']['swift'] = $this->which('swift'); |
|
| 158 | + if (!isset($this->config['cepstral']['swift'])) { |
|
| 159 | + $this->config['cepstral']['swift'] = $this->which('swift'); |
|
| 160 | + } |
|
| 143 | 161 | |
| 144 | 162 | ob_implicit_flush(true); |
| 145 | 163 | |
@@ -167,13 +185,18 @@ discard block |
||
| 167 | 185 | |
| 168 | 186 | // open audio if eagi detected |
| 169 | 187 | if ($this->request['agi_enhanced'] == '1.0') { |
| 170 | - if (file_exists('/proc/' . getmypid() . '/fd/3')) $this->audio = fopen('/proc/' . getmypid() . '/fd/3', 'r'); elseif (file_exists('/dev/fd/3')) { |
|
| 188 | + if (file_exists('/proc/' . getmypid() . '/fd/3')) { |
|
| 189 | + $this->audio = fopen('/proc/' . getmypid() . '/fd/3', 'r'); |
|
| 190 | + } elseif (file_exists('/dev/fd/3')) { |
|
| 171 | 191 | // may need to mount fdescfs |
| 172 | 192 | $this->audio = fopen('/dev/fd/3', 'r'); |
| 173 | - } else |
|
| 174 | - $this->conlog('Unable to open audio stream'); |
|
| 193 | + } else { |
|
| 194 | + $this->conlog('Unable to open audio stream'); |
|
| 195 | + } |
|
| 175 | 196 | |
| 176 | - if ($this->audio) stream_set_blocking($this->audio, 0); |
|
| 197 | + if ($this->audio) { |
|
| 198 | + stream_set_blocking($this->audio, 0); |
|
| 199 | + } |
|
| 177 | 200 | } |
| 178 | 201 | |
| 179 | 202 | $this->conlog('AGI Request:'); |
@@ -272,7 +295,9 @@ discard block |
||
| 272 | 295 | */ |
| 273 | 296 | function database_deltree($family, $keytree = ''){ |
| 274 | 297 | $cmd = "DATABASE DELTREE \"$family\""; |
| 275 | - if ($keytree != '') $cmd .= " \"$keytree\""; |
|
| 298 | + if ($keytree != '') { |
|
| 299 | + $cmd .= " \"$keytree\""; |
|
| 300 | + } |
|
| 276 | 301 | return $this->evaluate($cmd); |
| 277 | 302 | } |
| 278 | 303 | |
@@ -312,8 +337,11 @@ discard block |
||
| 312 | 337 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise |
| 313 | 338 | */ |
| 314 | 339 | function set_global_var($pVariable, $pValue){ |
| 315 | - if (is_numeric($pValue)) return $this->evaluate("Set({$pVariable}={$pValue},g);"); else |
|
| 316 | - return $this->evaluate("Set({$pVariable}=\"{$pValue}\",g);"); |
|
| 340 | + if (is_numeric($pValue)) { |
|
| 341 | + return $this->evaluate("Set({$pVariable}={$pValue},g);"); |
|
| 342 | + } else { |
|
| 343 | + return $this->evaluate("Set({$pVariable}=\"{$pValue}\",g);"); |
|
| 344 | + } |
|
| 317 | 345 | } |
| 318 | 346 | |
| 319 | 347 | |
@@ -327,8 +355,11 @@ discard block |
||
| 327 | 355 | * @return array, see evaluate for return information. ['result'] is 1 on sucess, 0 otherwise |
| 328 | 356 | */ |
| 329 | 357 | function set_var($pVariable, $pValue){ |
| 330 | - if (is_numeric($pValue)) return $this->evaluate("Set({$pVariable}={$pValue});"); else |
|
| 331 | - return $this->evaluate("Set({$pVariable}=\"{$pValue}\");"); |
|
| 358 | + if (is_numeric($pValue)) { |
|
| 359 | + return $this->evaluate("Set({$pVariable}={$pValue});"); |
|
| 360 | + } else { |
|
| 361 | + return $this->evaluate("Set({$pVariable}=\"{$pValue}\");"); |
|
| 362 | + } |
|
| 332 | 363 | } |
| 333 | 364 | |
| 334 | 365 | |
@@ -342,7 +373,9 @@ discard block |
||
| 342 | 373 | * @return array, see evaluate for return information. ['result'] is whatever the application returns, or -2 on failure to find application |
| 343 | 374 | */ |
| 344 | 375 | function exec($application, $options){ |
| 345 | - if (is_array($options)) $options = join('|', $options); |
|
| 376 | + if (is_array($options)) { |
|
| 377 | + $options = join('|', $options); |
|
| 378 | + } |
|
| 346 | 379 | return $this->evaluate("EXEC $application $options"); |
| 347 | 380 | } |
| 348 | 381 | |
@@ -427,7 +460,9 @@ discard block |
||
| 427 | 460 | |
| 428 | 461 | $res = $this->evaluate('GET VARIABLE FULL ' . $req); |
| 429 | 462 | |
| 430 | - if ($getvalue == FALSE) return ($res); |
|
| 463 | + if ($getvalue == FALSE) { |
|
| 464 | + return ($res); |
|
| 465 | + } |
|
| 431 | 466 | |
| 432 | 467 | return ($res['data']); |
| 433 | 468 | |
@@ -493,8 +528,12 @@ discard block |
||
| 493 | 528 | */ |
| 494 | 529 | function record_file($file, $format, $escape_digits = '', $timeout = -1, $offset = NULL, $beep = false, $silence = NULL){ |
| 495 | 530 | $cmd = trim("RECORD FILE $file $format \"$escape_digits\" $timeout $offset"); |
| 496 | - if ($beep) $cmd .= ' BEEP'; |
|
| 497 | - if (!is_null($silence)) $cmd .= " s=$silence"; |
|
| 531 | + if ($beep) { |
|
| 532 | + $cmd .= ' BEEP'; |
|
| 533 | + } |
|
| 534 | + if (!is_null($silence)) { |
|
| 535 | + $cmd .= " s=$silence"; |
|
| 536 | + } |
|
| 498 | 537 | return $this->evaluate($cmd); |
| 499 | 538 | } |
| 500 | 539 | |
@@ -547,7 +586,9 @@ discard block |
||
| 547 | 586 | * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. |
| 548 | 587 | */ |
| 549 | 588 | function say_time($time = NULL, $escape_digits = ''){ |
| 550 | - if (is_null($time)) $time = time(); |
|
| 589 | + if (is_null($time)) { |
|
| 590 | + $time = time(); |
|
| 591 | + } |
|
| 551 | 592 | return $this->evaluate("SAY TIME $time \"$escape_digits\""); |
| 552 | 593 | } |
| 553 | 594 | |
@@ -863,11 +904,15 @@ discard block |
||
| 863 | 904 | function fastpass_say_digits(&$buffer, $digits, $escape_digits = ''){ |
| 864 | 905 | $proceed = false; |
| 865 | 906 | if ($escape_digits != '' && $buffer != '') { |
| 866 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 907 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 908 | + $proceed = true; |
|
| 909 | + } |
|
| 867 | 910 | } |
| 868 | 911 | if ($buffer == '' || $proceed) { |
| 869 | 912 | $res = $this->say_digits($digits, $escape_digits); |
| 870 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 913 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 914 | + $buffer .= chr($res['result']); |
|
| 915 | + } |
|
| 871 | 916 | return $res; |
| 872 | 917 | } |
| 873 | 918 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1})); |
@@ -887,11 +932,15 @@ discard block |
||
| 887 | 932 | function fastpass_say_number(&$buffer, $number, $escape_digits = ''){ |
| 888 | 933 | $proceed = false; |
| 889 | 934 | if ($escape_digits != '' && $buffer != '') { |
| 890 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 935 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 936 | + $proceed = true; |
|
| 937 | + } |
|
| 891 | 938 | } |
| 892 | 939 | if ($buffer == '' || $proceed) { |
| 893 | 940 | $res = $this->say_number($number, $escape_digits); |
| 894 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 941 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 942 | + $buffer .= chr($res['result']); |
|
| 943 | + } |
|
| 895 | 944 | return $res; |
| 896 | 945 | } |
| 897 | 946 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1})); |
@@ -911,11 +960,15 @@ discard block |
||
| 911 | 960 | function fastpass_say_phonetic(&$buffer, $text, $escape_digits = ''){ |
| 912 | 961 | $proceed = false; |
| 913 | 962 | if ($escape_digits != '' && $buffer != '') { |
| 914 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 963 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 964 | + $proceed = true; |
|
| 965 | + } |
|
| 915 | 966 | } |
| 916 | 967 | if ($buffer == '' || $proceed) { |
| 917 | 968 | $res = $this->say_phonetic($text, $escape_digits); |
| 918 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 969 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 970 | + $buffer .= chr($res['result']); |
|
| 971 | + } |
|
| 919 | 972 | return $res; |
| 920 | 973 | } |
| 921 | 974 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1})); |
@@ -935,11 +988,15 @@ discard block |
||
| 935 | 988 | function fastpass_say_time(&$buffer, $time = NULL, $escape_digits = ''){ |
| 936 | 989 | $proceed = false; |
| 937 | 990 | if ($escape_digits != '' && $buffer != '') { |
| 938 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 991 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 992 | + $proceed = true; |
|
| 993 | + } |
|
| 939 | 994 | } |
| 940 | 995 | if ($buffer == '' || $proceed) { |
| 941 | 996 | $res = $this->say_time($time, $escape_digits); |
| 942 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 997 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 998 | + $buffer .= chr($res['result']); |
|
| 999 | + } |
|
| 943 | 1000 | return $res; |
| 944 | 1001 | } |
| 945 | 1002 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1})); |
@@ -962,11 +1019,15 @@ discard block |
||
| 962 | 1019 | function fastpass_stream_file(&$buffer, $filename, $escape_digits = '', $offset = 0){ |
| 963 | 1020 | $proceed = false; |
| 964 | 1021 | if ($escape_digits != '' && $buffer != '') { |
| 965 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1022 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 1023 | + $proceed = true; |
|
| 1024 | + } |
|
| 966 | 1025 | } |
| 967 | 1026 | if ($buffer == '' || $proceed) { |
| 968 | 1027 | $res = $this->stream_file($filename, $escape_digits, $offset); |
| 969 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 1028 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 1029 | + $buffer .= chr($res['result']); |
|
| 1030 | + } |
|
| 970 | 1031 | return $res; |
| 971 | 1032 | } |
| 972 | 1033 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1}), 'endpos' => 0); |
@@ -986,11 +1047,15 @@ discard block |
||
| 986 | 1047 | function fastpass_text2wav(&$buffer, $text, $escape_digits = '', $frequency = 8000){ |
| 987 | 1048 | $proceed = false; |
| 988 | 1049 | if ($escape_digits != '' && $buffer != '') { |
| 989 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1050 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 1051 | + $proceed = true; |
|
| 1052 | + } |
|
| 990 | 1053 | } |
| 991 | 1054 | if ($buffer == '' || $proceed) { |
| 992 | 1055 | $res = $this->text2wav($text, $escape_digits, $frequency); |
| 993 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 1056 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 1057 | + $buffer .= chr($res['result']); |
|
| 1058 | + } |
|
| 994 | 1059 | return $res; |
| 995 | 1060 | } |
| 996 | 1061 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1}), 'endpos' => 0); |
@@ -1011,11 +1076,15 @@ discard block |
||
| 1011 | 1076 | function fastpass_swift(&$buffer, $text, $escape_digits = '', $frequency = 8000, $voice = NULL){ |
| 1012 | 1077 | $proceed = false; |
| 1013 | 1078 | if ($escape_digits != '' && $buffer != '') { |
| 1014 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1079 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 1080 | + $proceed = true; |
|
| 1081 | + } |
|
| 1015 | 1082 | } |
| 1016 | 1083 | if ($buffer == '' || $proceed) { |
| 1017 | 1084 | $res = $this->swift($text, $escape_digits, $frequency, $voice); |
| 1018 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 1085 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 1086 | + $buffer .= chr($res['result']); |
|
| 1087 | + } |
|
| 1019 | 1088 | return $res; |
| 1020 | 1089 | } |
| 1021 | 1090 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1}), 'endpos' => 0); |
@@ -1034,11 +1103,15 @@ discard block |
||
| 1034 | 1103 | function fastpass_say_punctuation(&$buffer, $text, $escape_digits = '', $frequency = 8000){ |
| 1035 | 1104 | $proceed = false; |
| 1036 | 1105 | if ($escape_digits != '' && $buffer != '') { |
| 1037 | - if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) $proceed = true; |
|
| 1106 | + if (!strpos(chr(255) . $escape_digits, $buffer{strlen($buffer) - 1})) { |
|
| 1107 | + $proceed = true; |
|
| 1108 | + } |
|
| 1038 | 1109 | } |
| 1039 | 1110 | if ($buffer == '' || $proceed) { |
| 1040 | 1111 | $res = $this->say_punctuation($text, $escape_digits, $frequency); |
| 1041 | - if ($res['code'] == AGIRES_OK && $res['result'] > 0) $buffer .= chr($res['result']); |
|
| 1112 | + if ($res['code'] == AGIRES_OK && $res['result'] > 0) { |
|
| 1113 | + $buffer .= chr($res['result']); |
|
| 1114 | + } |
|
| 1042 | 1115 | return $res; |
| 1043 | 1116 | } |
| 1044 | 1117 | return array('code' => AGIRES_OK, 'result' => ord($buffer{strlen($buffer) - 1})); |
@@ -1085,13 +1158,19 @@ discard block |
||
| 1085 | 1158 | if (is_null($max_digits) || strlen($buffer) < $max_digits) { |
| 1086 | 1159 | if ($buffer == '') { |
| 1087 | 1160 | $res = $this->get_data($filename, $timeout, $max_digits); |
| 1088 | - if ($res['code'] == AGIRES_OK) $buffer .= $res['result']; |
|
| 1161 | + if ($res['code'] == AGIRES_OK) { |
|
| 1162 | + $buffer .= $res['result']; |
|
| 1163 | + } |
|
| 1089 | 1164 | return $res; |
| 1090 | 1165 | } else { |
| 1091 | 1166 | while (is_null($max_digits) || strlen($buffer) < $max_digits) { |
| 1092 | 1167 | $res = $this->wait_for_digit(); |
| 1093 | - if ($res['code'] != AGIRES_OK) return $res; |
|
| 1094 | - if ($res['result'] == ord('#')) break; |
|
| 1168 | + if ($res['code'] != AGIRES_OK) { |
|
| 1169 | + return $res; |
|
| 1170 | + } |
|
| 1171 | + if ($res['result'] == ord('#')) { |
|
| 1172 | + break; |
|
| 1173 | + } |
|
| 1095 | 1174 | $buffer .= chr($res['result']); |
| 1096 | 1175 | } |
| 1097 | 1176 | } |
@@ -1120,8 +1199,11 @@ discard block |
||
| 1120 | 1199 | $choice = NULL; |
| 1121 | 1200 | while (is_null($choice)) { |
| 1122 | 1201 | foreach ($choices as $prompt) { |
| 1123 | - if ($prompt{0} == '*') $ret = $this->text2wav(substr($prompt, 1), $keys); else |
|
| 1124 | - $ret = $this->stream_file($prompt, $keys); |
|
| 1202 | + if ($prompt{0} == '*') { |
|
| 1203 | + $ret = $this->text2wav(substr($prompt, 1), $keys); |
|
| 1204 | + } else { |
|
| 1205 | + $ret = $this->stream_file($prompt, $keys); |
|
| 1206 | + } |
|
| 1125 | 1207 | |
| 1126 | 1208 | if ($ret['code'] != AGIRES_OK || $ret['result'] == -1) { |
| 1127 | 1209 | $choice = -1; |
@@ -1136,7 +1218,11 @@ discard block |
||
| 1136 | 1218 | |
| 1137 | 1219 | if (is_null($choice)) { |
| 1138 | 1220 | $ret = $this->get_data('beep', $timeout, 1); |
| 1139 | - if ($ret['code'] != AGIRES_OK || $ret['result'] == -1) $choice = -1; elseif ($ret['result'] != '' && strpos(' ' . $keys, $ret['result'])) $choice = $ret['result']; |
|
| 1221 | + if ($ret['code'] != AGIRES_OK || $ret['result'] == -1) { |
|
| 1222 | + $choice = -1; |
|
| 1223 | + } elseif ($ret['result'] != '' && strpos(' ' . $keys, $ret['result'])) { |
|
| 1224 | + $choice = $ret['result']; |
|
| 1225 | + } |
|
| 1140 | 1226 | } |
| 1141 | 1227 | } |
| 1142 | 1228 | return $choice; |
@@ -1167,7 +1253,9 @@ discard block |
||
| 1167 | 1253 | * @return array('Name'=>$name, 'Number'=>$number) |
| 1168 | 1254 | */ |
| 1169 | 1255 | function parse_callerid($callerid = NULL){ |
| 1170 | - if (is_null($callerid)) $callerid = $this->request['agi_callerid']; |
|
| 1256 | + if (is_null($callerid)) { |
|
| 1257 | + $callerid = $this->request['agi_callerid']; |
|
| 1258 | + } |
|
| 1171 | 1259 | |
| 1172 | 1260 | $ret = array('name' => '', 'protocol' => '', 'username' => '', 'host' => '', 'port' => ''); |
| 1173 | 1261 | $callerid = trim($callerid); |
@@ -1181,14 +1269,18 @@ discard block |
||
| 1181 | 1269 | |
| 1182 | 1270 | $callerid = explode('@', trim($callerid, '<> ')); |
| 1183 | 1271 | $username = explode(':', array_shift($callerid)); |
| 1184 | - if (count($username) == 1) $ret['username'] = $username[0]; else { |
|
| 1272 | + if (count($username) == 1) { |
|
| 1273 | + $ret['username'] = $username[0]; |
|
| 1274 | + } else { |
|
| 1185 | 1275 | $ret['protocol'] = array_shift($username); |
| 1186 | 1276 | $ret['username'] = join(':', $username); |
| 1187 | 1277 | } |
| 1188 | 1278 | |
| 1189 | 1279 | $callerid = join('@', $callerid); |
| 1190 | 1280 | $host = explode(':', $callerid); |
| 1191 | - if (count($host) == 1) $ret['host'] = $host[0]; else { |
|
| 1281 | + if (count($host) == 1) { |
|
| 1282 | + $ret['host'] = $host[0]; |
|
| 1283 | + } else { |
|
| 1192 | 1284 | $ret['host'] = array_shift($host); |
| 1193 | 1285 | $ret['port'] = join(':', $host); |
| 1194 | 1286 | } |
@@ -1211,7 +1303,9 @@ discard block |
||
| 1211 | 1303 | */ |
| 1212 | 1304 | function text2wav($text, $escape_digits = '', $frequency = 8000){ |
| 1213 | 1305 | $text = trim($text); |
| 1214 | - if ($text == '') return true; |
|
| 1306 | + if ($text == '') { |
|
| 1307 | + return true; |
|
| 1308 | + } |
|
| 1215 | 1309 | |
| 1216 | 1310 | $hash = md5($text); |
| 1217 | 1311 | $fname = $this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR; |
@@ -1237,7 +1331,9 @@ discard block |
||
| 1237 | 1331 | |
| 1238 | 1332 | // clean up old files |
| 1239 | 1333 | $delete = time() - 2592000; // 1 month |
| 1240 | - foreach (glob($this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR . 'text2wav_*') as $file) if (filemtime($file) < $delete) unlink($file); |
|
| 1334 | + foreach (glob($this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR . 'text2wav_*') as $file) { |
|
| 1335 | + if (filemtime($file) < $delete) unlink($file); |
|
| 1336 | + } |
|
| 1241 | 1337 | |
| 1242 | 1338 | return $ret; |
| 1243 | 1339 | } |
@@ -1253,10 +1349,16 @@ discard block |
||
| 1253 | 1349 | * @return array | bool, see evaluate for return information. |
| 1254 | 1350 | */ |
| 1255 | 1351 | function swift($text, $escape_digits = '', $frequency = 8000, $voice = NULL){ |
| 1256 | - if (!is_null($voice)) $voice = "-n $voice"; elseif (isset($this->config['cepstral']['voice'])) $voice = "-n {$this->config['cepstral']['voice']}"; |
|
| 1352 | + if (!is_null($voice)) { |
|
| 1353 | + $voice = "-n $voice"; |
|
| 1354 | + } elseif (isset($this->config['cepstral']['voice'])) { |
|
| 1355 | + $voice = "-n {$this->config['cepstral']['voice']}"; |
|
| 1356 | + } |
|
| 1257 | 1357 | |
| 1258 | 1358 | $text = trim($text); |
| 1259 | - if ($text == '') return true; |
|
| 1359 | + if ($text == '') { |
|
| 1360 | + return true; |
|
| 1361 | + } |
|
| 1260 | 1362 | |
| 1261 | 1363 | $hash = md5($text); |
| 1262 | 1364 | $fname = $this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR; |
@@ -1279,7 +1381,9 @@ discard block |
||
| 1279 | 1381 | |
| 1280 | 1382 | // clean up old files |
| 1281 | 1383 | $delete = time() - 2592000; // 1 month |
| 1282 | - foreach (glob($this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR . 'swift_*') as $file) if (filemtime($file) < $delete) unlink($file); |
|
| 1384 | + foreach (glob($this->config['phpagi']['tempdir'] . DIRECTORY_SEPARATOR . 'swift_*') as $file) { |
|
| 1385 | + if (filemtime($file) < $delete) unlink($file); |
|
| 1386 | + } |
|
| 1283 | 1387 | |
| 1284 | 1388 | return $ret; |
| 1285 | 1389 | } |
@@ -1332,10 +1436,17 @@ discard block |
||
| 1332 | 1436 | $code = substr($code, 1); |
| 1333 | 1437 | $command = false; |
| 1334 | 1438 | } |
| 1335 | - if ($code == '') $command = true; elseif ($mode == 'NUMERIC') $text .= $code; |
|
| 1336 | - elseif ($mode == 'UPPERCASE' && isset($alpha['k' . $code])) $text .= $alpha['k' . $code]; |
|
| 1337 | - elseif ($mode == 'LOWERCASE' && isset($alpha['k' . $code])) $text .= strtolower($alpha['k' . $code]); |
|
| 1338 | - elseif ($mode == 'SYMBOL' && isset($symbol['k' . $code])) $text .= $symbol['k' . $code]; |
|
| 1439 | + if ($code == '') { |
|
| 1440 | + $command = true; |
|
| 1441 | + } elseif ($mode == 'NUMERIC') { |
|
| 1442 | + $text .= $code; |
|
| 1443 | + } elseif ($mode == 'UPPERCASE' && isset($alpha['k' . $code])) { |
|
| 1444 | + $text .= $alpha['k' . $code]; |
|
| 1445 | + } elseif ($mode == 'LOWERCASE' && isset($alpha['k' . $code])) { |
|
| 1446 | + $text .= strtolower($alpha['k' . $code]); |
|
| 1447 | + } elseif ($mode == 'SYMBOL' && isset($symbol['k' . $code])) { |
|
| 1448 | + $text .= $symbol['k' . $code]; |
|
| 1449 | + } |
|
| 1339 | 1450 | } |
| 1340 | 1451 | $this->say_punctuation($text); |
| 1341 | 1452 | } while (substr($result['result'], -2) == '**'); |
@@ -1488,7 +1599,9 @@ discard block |
||
| 1488 | 1599 | $broken = array('code' => 500, 'result' => -1, 'data' => ''); |
| 1489 | 1600 | |
| 1490 | 1601 | // write command |
| 1491 | - if (!@fwrite($this->out, trim($command) . "\n")) return $broken; |
|
| 1602 | + if (!@fwrite($this->out, trim($command) . "\n")) { |
|
| 1603 | + return $broken; |
|
| 1604 | + } |
|
| 1492 | 1605 | fflush($this->out); |
| 1493 | 1606 | |
| 1494 | 1607 | // Read result. Occasionally, a command return a string followed by an extra new line. |
@@ -1510,9 +1623,11 @@ discard block |
||
| 1510 | 1623 | $ret['code'] = substr($str, 0, 3); |
| 1511 | 1624 | $str = trim(substr($str, 3)); |
| 1512 | 1625 | |
| 1513 | - if ($str{0} == '-') // we have a multiline response! |
|
| 1626 | + if ($str{0} == '-') { |
|
| 1627 | + // we have a multiline response! |
|
| 1514 | 1628 | { |
| 1515 | 1629 | $count = 0; |
| 1630 | + } |
|
| 1516 | 1631 | $str = substr($str, 1) . "\n"; |
| 1517 | 1632 | $line = fgets($this->in, 4096); |
| 1518 | 1633 | while (substr($line, 0, 3) != $ret['code'] && $count < 5) { |
@@ -1528,32 +1643,44 @@ discard block |
||
| 1528 | 1643 | |
| 1529 | 1644 | $ret['result'] = NULL; |
| 1530 | 1645 | $ret['data'] = ''; |
| 1531 | - if ($ret['code'] != AGIRES_OK) // some sort of error |
|
| 1646 | + if ($ret['code'] != AGIRES_OK) { |
|
| 1647 | + // some sort of error |
|
| 1532 | 1648 | { |
| 1533 | 1649 | $ret['data'] = $str; |
| 1650 | + } |
|
| 1534 | 1651 | $this->conlog(print_r($ret, true)); |
| 1535 | 1652 | } else // normal AGIRES_OK response |
| 1536 | 1653 | { |
| 1537 | 1654 | $parse = explode(' ', trim($str)); |
| 1538 | 1655 | $in_token = false; |
| 1539 | 1656 | foreach ($parse as $token) { |
| 1540 | - if ($in_token) // we previously hit a token starting with ')' but not ending in ')' |
|
| 1657 | + if ($in_token) { |
|
| 1658 | + // we previously hit a token starting with ')' but not ending in ')' |
|
| 1541 | 1659 | { |
| 1542 | 1660 | $ret['data'] .= ' ' . trim($token, '() '); |
| 1543 | - if ($token{strlen($token) - 1} == ')') $in_token = false; |
|
| 1661 | + } |
|
| 1662 | + if ($token{strlen($token) - 1} == ')') { |
|
| 1663 | + $in_token = false; |
|
| 1664 | + } |
|
| 1544 | 1665 | } elseif ($token{0} == '(') { |
| 1545 | - if ($token{strlen($token) - 1} != ')') $in_token = true; |
|
| 1666 | + if ($token{strlen($token) - 1} != ')') { |
|
| 1667 | + $in_token = true; |
|
| 1668 | + } |
|
| 1546 | 1669 | $ret['data'] .= ' ' . trim($token, '() '); |
| 1547 | 1670 | } elseif (strpos($token, '=')) { |
| 1548 | 1671 | $token = explode('=', $token); |
| 1549 | 1672 | $ret[$token[0]] = $token[1]; |
| 1550 | - } elseif ($token != '') $ret['data'] .= ' ' . $token; |
|
| 1673 | + } elseif ($token != '') { |
|
| 1674 | + $ret['data'] .= ' ' . $token; |
|
| 1675 | + } |
|
| 1551 | 1676 | } |
| 1552 | 1677 | $ret['data'] = trim($ret['data']); |
| 1553 | 1678 | } |
| 1554 | 1679 | |
| 1555 | 1680 | // log some errors |
| 1556 | - if ($ret['result'] < 0) $this->conlog("$command returned {$ret['result']}"); |
|
| 1681 | + if ($ret['result'] < 0) { |
|
| 1682 | + $this->conlog("$command returned {$ret['result']}"); |
|
| 1683 | + } |
|
| 1557 | 1684 | |
| 1558 | 1685 | return $ret; |
| 1559 | 1686 | } |
@@ -1570,9 +1697,11 @@ discard block |
||
| 1570 | 1697 | static $busy = false; |
| 1571 | 1698 | |
| 1572 | 1699 | if ($this->config['phpagi']['debug'] != false) { |
| 1573 | - if (!$busy) // no conlogs inside conlog!!! |
|
| 1700 | + if (!$busy) { |
|
| 1701 | + // no conlogs inside conlog!!! |
|
| 1574 | 1702 | { |
| 1575 | 1703 | $busy = true; |
| 1704 | + } |
|
| 1576 | 1705 | $this->verbose($str, $vbl); |
| 1577 | 1706 | $busy = false; |
| 1578 | 1707 | } |
@@ -1591,9 +1720,13 @@ discard block |
||
| 1591 | 1720 | global $_ENV; |
| 1592 | 1721 | $chpath = is_null($checkpath) ? $_ENV['PATH'] : $checkpath; |
| 1593 | 1722 | |
| 1594 | - foreach (explode(':', $chpath) as $path) if (is_executable("$path/$cmd")) return "$path/$cmd"; |
|
| 1723 | + foreach (explode(':', $chpath) as $path) { |
|
| 1724 | + if (is_executable("$path/$cmd")) return "$path/$cmd"; |
|
| 1725 | + } |
|
| 1595 | 1726 | |
| 1596 | - 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'); |
|
| 1727 | + if (is_null($checkpath)) { |
|
| 1728 | + 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'); |
|
| 1729 | + } |
|
| 1597 | 1730 | return false; |
| 1598 | 1731 | } |
| 1599 | 1732 | |
@@ -1633,18 +1766,23 @@ discard block |
||
| 1633 | 1766 | * @param array $context variables in the current scope |
| 1634 | 1767 | */ |
| 1635 | 1768 | function phpagi_error_handler($level, $message, $file, $line, $context){ |
| 1636 | - if (ini_get('error_reporting') == 0) return; // this happens with an @ |
|
| 1769 | + if (ini_get('error_reporting') == 0) { |
|
| 1770 | + return; |
|
| 1771 | + } |
|
| 1772 | + // this happens with an @ |
|
| 1637 | 1773 | |
| 1638 | 1774 | @syslog(LOG_WARNING, $file . '[' . $line . ']: ' . $message); |
| 1639 | 1775 | |
| 1640 | 1776 | global $phpagi_error_handler_email; |
| 1641 | - if (function_exists('mail') && !is_null($phpagi_error_handler_email)) // generate email debugging information |
|
| 1777 | + if (function_exists('mail') && !is_null($phpagi_error_handler_email)) { |
|
| 1778 | + // generate email debugging information |
|
| 1642 | 1779 | { |
| 1643 | 1780 | // decode error level |
| 1644 | 1781 | switch ($level) { |
| 1645 | 1782 | case E_WARNING: |
| 1646 | 1783 | case E_USER_WARNING: |
| 1647 | 1784 | $level = "Warning"; |
| 1785 | + } |
|
| 1648 | 1786 | break; |
| 1649 | 1787 | case E_NOTICE: |
| 1650 | 1788 | case E_USER_NOTICE: |
@@ -1680,23 +1818,32 @@ discard block |
||
| 1680 | 1818 | if (file_exists($file)) { |
| 1681 | 1819 | $message .= "\n\n$file:\n"; |
| 1682 | 1820 | $code = @file($file); |
| 1683 | - for ($i = max(0, $line - 10); $i < min($line + 10, count($code)); $i++) $message .= ($i + 1) . "\t$code[$i]"; |
|
| 1821 | + for ($i = max(0, $line - 10); $i < min($line + 10, count($code)); $i++) { |
|
| 1822 | + $message .= ($i + 1) . "\t$code[$i]"; |
|
| 1823 | + } |
|
| 1684 | 1824 | } |
| 1685 | 1825 | |
| 1686 | 1826 | // make sure message is fully readable (convert unprintable chars to hex representation) |
| 1687 | 1827 | $ret = ''; |
| 1688 | 1828 | for ($i = 0; $i < strlen($message); $i++) { |
| 1689 | 1829 | $c = ord($message{$i}); |
| 1690 | - if ($c == 10 || $c == 13 || $c == 9) $ret .= $message{$i}; elseif ($c < 16) $ret .= '\x0' . dechex($c); |
|
| 1691 | - elseif ($c < 32 || $c > 127) $ret .= '\x' . dechex($c); |
|
| 1692 | - else |
|
| 1830 | + if ($c == 10 || $c == 13 || $c == 9) { |
|
| 1693 | 1831 | $ret .= $message{$i}; |
| 1832 | + } elseif ($c < 16) { |
|
| 1833 | + $ret .= '\x0' . dechex($c); |
|
| 1834 | + } elseif ($c < 32 || $c > 127) { |
|
| 1835 | + $ret .= '\x' . dechex($c); |
|
| 1836 | + } else { |
|
| 1837 | + $ret .= $message{$i}; |
|
| 1838 | + } |
|
| 1694 | 1839 | } |
| 1695 | 1840 | $message = $ret; |
| 1696 | 1841 | |
| 1697 | 1842 | // send the mail if less than 5 errors |
| 1698 | 1843 | static $mailcount = 0; |
| 1699 | - if ($mailcount < 5) @mail($phpagi_error_handler_email, $subject, $message); |
|
| 1844 | + if ($mailcount < 5) { |
|
| 1845 | + @mail($phpagi_error_handler_email, $subject, $message); |
|
| 1846 | + } |
|
| 1700 | 1847 | $mailcount++; |
| 1701 | 1848 | } |
| 1702 | 1849 | } |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | 20 | function Event_dial($agi, $action){ |
| 21 | - $now = Util::get_now_date(); |
|
| 21 | + $now = Util::get_now_date(); |
|
| 22 | 22 | $data = array(); |
| 23 | 23 | |
| 24 | - // Уточним канал, на случай очереди. |
|
| 24 | + // Уточним канал, на случай очереди. |
|
| 25 | 25 | $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true); |
| 26 | - $orign_chan = $agi->get_variable("orign_chan", true); |
|
| 26 | + $orign_chan = $agi->get_variable("orign_chan", true); |
|
| 27 | 27 | $id = $agi->get_variable("pt1c_UNIQUEID", true); |
| 28 | 28 | $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
| 29 | 29 | if($id == '' || !empty($QUEUE_SRC_CHAN)){ |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | // Если это новый вызов $id == ''. |
| 32 | 32 | $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
| 33 | 33 | } |
| 34 | - // Канал, AGI скрипта. |
|
| 35 | - $channel = $agi->request['agi_channel']; |
|
| 34 | + // Канал, AGI скрипта. |
|
| 35 | + $channel = $agi->request['agi_channel']; |
|
| 36 | 36 | $is_local = !(stripos($channel, 'local/') === false); |
| 37 | - if($QUEUE_SRC_CHAN != '' && $is_local){ |
|
| 38 | - // Это LOCAL, Переопределим на исходный. |
|
| 39 | - $channel = $QUEUE_SRC_CHAN; |
|
| 40 | - }else if($is_local && (stripos($orign_chan, 'local/') === false)){ |
|
| 37 | + if($QUEUE_SRC_CHAN != '' && $is_local){ |
|
| 38 | + // Это LOCAL, Переопределим на исходный. |
|
| 39 | + $channel = $QUEUE_SRC_CHAN; |
|
| 40 | + }else if($is_local && (stripos($orign_chan, 'local/') === false)){ |
|
| 41 | 41 | $channel = $orign_chan; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -68,20 +68,20 @@ discard block |
||
| 68 | 68 | $dst_num = $agi->request['agi_extension']; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $data['src_chan'] = $channel; |
|
| 72 | - $data['src_num'] = $src_num; |
|
| 73 | - $data['dst_num'] = $dst_num; |
|
| 74 | - $data['start'] = $now; |
|
| 75 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 76 | - $data['UNIQUEID'] = $id; |
|
| 77 | - $data['transfer'] = '0'; |
|
| 78 | - $data['agi_channel'] = $agi->request['agi_channel'];; |
|
| 79 | - $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 80 | - $data['from_account']= $from_account; |
|
| 81 | - $data['IS_ORGNT'] = !empty($IS_ORGNT); |
|
| 82 | - |
|
| 83 | - $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
|
| 84 | - return $data; |
|
| 71 | + $data['src_chan'] = $channel; |
|
| 72 | + $data['src_num'] = $src_num; |
|
| 73 | + $data['dst_num'] = $dst_num; |
|
| 74 | + $data['start'] = $now; |
|
| 75 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 76 | + $data['UNIQUEID'] = $id; |
|
| 77 | + $data['transfer'] = '0'; |
|
| 78 | + $data['agi_channel'] = $agi->request['agi_channel'];; |
|
| 79 | + $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 80 | + $data['from_account']= $from_account; |
|
| 81 | + $data['IS_ORGNT'] = !empty($IS_ORGNT); |
|
| 82 | + |
|
| 83 | + $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
|
| 84 | + return $data; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -92,17 +92,17 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | function Event_dial_create_chan($agi, $action){ |
| 94 | 94 | $now = Util::get_now_date(); |
| 95 | - $data = []; |
|
| 96 | - $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 97 | - $data['action'] = "$action"; |
|
| 98 | - $data['dst_chan'] = $agi->request['agi_channel']; |
|
| 99 | - $data['UNIQUEID'] = $id; |
|
| 100 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 95 | + $data = []; |
|
| 96 | + $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 97 | + $data['action'] = "$action"; |
|
| 98 | + $data['dst_chan'] = $agi->request['agi_channel']; |
|
| 99 | + $data['UNIQUEID'] = $id; |
|
| 100 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 101 | 101 | $data['event_time'] = $now; |
| 102 | 102 | |
| 103 | - if( stripos($data['dst_chan'], 'local/') === false ){ |
|
| 103 | + if( stripos($data['dst_chan'], 'local/') === false ){ |
|
| 104 | 104 | $data['to_account'] = $agi->get_variable('CUT(CUT(CHANNEL(name),,1),/,2)', true); |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
| 108 | 108 | if(!empty($IS_ORGNT)){ |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | function Event_dial_answer($agi, $action){ |
| 129 | 129 | $now = Util::get_now_date(); |
| 130 | 130 | |
| 131 | - $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 132 | - $data = []; |
|
| 133 | - $data['action'] = "$action"; |
|
| 134 | - $data['answer'] = $now; |
|
| 135 | - $data['id'] = $id; |
|
| 131 | + $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 132 | + $data = []; |
|
| 133 | + $data['action'] = "$action"; |
|
| 134 | + $data['answer'] = $now; |
|
| 135 | + $data['id'] = $id; |
|
| 136 | 136 | $data['dst_num'] = $agi->request['agi_callerid']; |
| 137 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 138 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 137 | + $data['agi_channel']= $agi->request['agi_channel']; |
|
| 138 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 139 | 139 | |
| 140 | - $data['ENDCALLONANSWER']= $agi->get_variable("ENDCALLONANSWER", true); |
|
| 140 | + $data['ENDCALLONANSWER']= $agi->get_variable("ENDCALLONANSWER", true); |
|
| 141 | 141 | $data['BRIDGEPEER'] = $agi->get_variable("FROM_CHAN", true); |
| 142 | 142 | |
| 143 | 143 | $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
| 176 | 176 | |
| 177 | - return $data; |
|
| 177 | + return $data; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | function Event_dial_hangup_DEPRECATED($agi, $action){ |
| 187 | 187 | // TODO Удалить эту функцию в будущем. |
| 188 | 188 | $now = Util::get_now_date(); |
| 189 | - $data = array(); |
|
| 190 | - $data['action'] = "$action"; |
|
| 191 | - $data['end'] = $now; |
|
| 192 | - $data['id'] = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 193 | - $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 194 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 195 | - $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 189 | + $data = array(); |
|
| 190 | + $data['action'] = "$action"; |
|
| 191 | + $data['end'] = $now; |
|
| 192 | + $data['id'] = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 193 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 194 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 195 | + $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 196 | 196 | |
| 197 | - $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 197 | + $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 198 | 198 | |
| 199 | - return $data; |
|
| 199 | + return $data; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | function Event_transfer_dial($agi, $action){ |
| 209 | 209 | $now = Util::get_now_date(); |
| 210 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 210 | + $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 211 | 211 | |
| 212 | - // Пытаемся определить канал. |
|
| 212 | + // Пытаемся определить канал. |
|
| 213 | 213 | $TRANSFERERNAME = $agi->get_variable("TRANSFERERNAME", true); |
| 214 | - $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true); |
|
| 215 | - $is_local = !(stripos($TRANSFERERNAME, 'local/') === false); |
|
| 214 | + $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true); |
|
| 215 | + $is_local = !(stripos($TRANSFERERNAME, 'local/') === false); |
|
| 216 | 216 | if( $QUEUE_SRC_CHAN != '' && $is_local ){ |
| 217 | 217 | // Это LOCAL, Переопределим на исходный. |
| 218 | 218 | $channel = $QUEUE_SRC_CHAN; |
@@ -225,21 +225,21 @@ discard block |
||
| 225 | 225 | $channel = $TRANSFERERNAME; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $data = array(); |
|
| 229 | - $data['action'] = "$action"; |
|
| 230 | - $data['agi_channel']= $channel;// $agi->request['agi_channel']; |
|
| 231 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 232 | - $data['src_chan'] = $channel; |
|
| 233 | - $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 234 | - $data['start'] = $now; |
|
| 235 | - $data['UNIQUEID'] = $id; |
|
| 236 | - $data['transfer'] = ($TRANSFERERNAME == '')?'0':'1'; |
|
| 237 | - $data['src_num'] = $agi->request['agi_callerid']; |
|
| 238 | - $data['dst_num'] = $agi->request['agi_extension']; |
|
| 228 | + $data = array(); |
|
| 229 | + $data['action'] = "$action"; |
|
| 230 | + $data['agi_channel']= $channel;// $agi->request['agi_channel']; |
|
| 231 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 232 | + $data['src_chan'] = $channel; |
|
| 233 | + $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 234 | + $data['start'] = $now; |
|
| 235 | + $data['UNIQUEID'] = $id; |
|
| 236 | + $data['transfer'] = ($TRANSFERERNAME == '')?'0':'1'; |
|
| 237 | + $data['src_num'] = $agi->request['agi_callerid']; |
|
| 238 | + $data['dst_num'] = $agi->request['agi_extension']; |
|
| 239 | 239 | |
| 240 | 240 | $agi->set_variable("__transfer_UNIQUEID", $id); |
| 241 | 241 | |
| 242 | - return $data; |
|
| 242 | + return $data; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -249,14 +249,14 @@ discard block |
||
| 249 | 249 | * @return array |
| 250 | 250 | */ |
| 251 | 251 | function Event_transfer_dial_create_chan($agi, $action){ |
| 252 | - $id = $agi->get_variable("transfer_UNIQUEID", true); |
|
| 253 | - $data = array(); |
|
| 254 | - $data['dst_chan'] = $agi->request['agi_channel']; |
|
| 255 | - $data['transfer_UNIQUEID'] = "$id"; |
|
| 256 | - $data['action'] = "$action"; |
|
| 257 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 258 | - |
|
| 259 | - return $data; |
|
| 252 | + $id = $agi->get_variable("transfer_UNIQUEID", true); |
|
| 253 | + $data = array(); |
|
| 254 | + $data['dst_chan'] = $agi->request['agi_channel']; |
|
| 255 | + $data['transfer_UNIQUEID'] = "$id"; |
|
| 256 | + $data['action'] = "$action"; |
|
| 257 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 258 | + |
|
| 259 | + return $data; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -266,16 +266,16 @@ discard block |
||
| 266 | 266 | * @return array |
| 267 | 267 | */ |
| 268 | 268 | function Event_transfer_dial_answer($agi, $action){ |
| 269 | - $data = array(); |
|
| 269 | + $data = array(); |
|
| 270 | 270 | $now = Util::get_now_date(); |
| 271 | - $id = $agi->get_variable("transfer_UNIQUEID", true); |
|
| 272 | - $data['answer'] = $now; |
|
| 273 | - $data['transfer_UNIQUEID'] = "$id"; |
|
| 274 | - $data['action'] = "$action"; |
|
| 275 | - $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 276 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 277 | - |
|
| 278 | - return $data; |
|
| 271 | + $id = $agi->get_variable("transfer_UNIQUEID", true); |
|
| 272 | + $data['answer'] = $now; |
|
| 273 | + $data['transfer_UNIQUEID'] = "$id"; |
|
| 274 | + $data['action'] = "$action"; |
|
| 275 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 276 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 277 | + |
|
| 278 | + return $data; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -286,25 +286,25 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | function Event_transfer_dial_hangup($agi, $action){ |
| 288 | 288 | $now = Util::get_now_date(); |
| 289 | - $data = array(); |
|
| 290 | - $data['end'] = $now; |
|
| 291 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 292 | - $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 293 | - $data['action'] = "$action"; |
|
| 294 | - $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 295 | - $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 296 | - |
|
| 297 | - $pos = stripos( $data['agi_channel'], 'local/'); |
|
| 298 | - if($pos === false){ |
|
| 299 | - // Если это завершение переадресации (консультативной). Создадим новую строку CDR. |
|
| 300 | - }else{ |
|
| 301 | - // Если пришел локальный канал: |
|
| 302 | - $data['TRANSFERERNAME'] = $agi->get_variable("TRANSFERERNAME", true); |
|
| 303 | - $data['ANSWEREDTIME'] = $agi->get_variable("ANSWEREDTIME", true); |
|
| 304 | - $data['dst_chan'] = $agi->get_variable("CDR(dstchannel)", true); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return $data; |
|
| 289 | + $data = array(); |
|
| 290 | + $data['end'] = $now; |
|
| 291 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 292 | + $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 293 | + $data['action'] = "$action"; |
|
| 294 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 295 | + $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 296 | + |
|
| 297 | + $pos = stripos( $data['agi_channel'], 'local/'); |
|
| 298 | + if($pos === false){ |
|
| 299 | + // Если это завершение переадресации (консультативной). Создадим новую строку CDR. |
|
| 300 | + }else{ |
|
| 301 | + // Если пришел локальный канал: |
|
| 302 | + $data['TRANSFERERNAME'] = $agi->get_variable("TRANSFERERNAME", true); |
|
| 303 | + $data['ANSWEREDTIME'] = $agi->get_variable("ANSWEREDTIME", true); |
|
| 304 | + $data['dst_chan'] = $agi->get_variable("CDR(dstchannel)", true); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + return $data; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -315,23 +315,23 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | function Event_hangup_chan($agi, $action){ |
| 317 | 317 | $now = Util::get_now_date(); |
| 318 | - $data = []; |
|
| 318 | + $data = []; |
|
| 319 | 319 | $data['action'] = "$action"; |
| 320 | 320 | $data['did'] = $agi->get_variable("FROM_DID", true);; |
| 321 | 321 | $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
| 322 | 322 | |
| 323 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 324 | - $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true); |
|
| 325 | - if('ANSWER' == $data['dialstatus']){ |
|
| 323 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 324 | + $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true); |
|
| 325 | + if('ANSWER' == $data['dialstatus']){ |
|
| 326 | 326 | $data['dialstatus'] = "ANSWERED"; |
| 327 | 327 | } |
| 328 | - $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 329 | - $data['end'] = $now; |
|
| 328 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 329 | + $data['end'] = $now; |
|
| 330 | 330 | |
| 331 | 331 | $data['OLD_LINKEDID'] = $agi->get_variable("OLD_LINKEDID", true); |
| 332 | 332 | $data['UNIQUEID'] = $agi->get_variable("pt1c_UNIQUEID", true); |
| 333 | 333 | |
| 334 | - return $data; |
|
| 334 | + return $data; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -342,64 +342,64 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | function Event_unpark_call($agi, $action){ |
| 344 | 344 | $now = Util::get_now_date(); |
| 345 | - // Обработка данных парковки. |
|
| 346 | - $exten = $agi->get_variable("EXTEN", true); |
|
| 347 | - $park_row = p_Park::get_parkslot_data($exten); |
|
| 345 | + // Обработка данных парковки. |
|
| 346 | + $exten = $agi->get_variable("EXTEN", true); |
|
| 347 | + $park_row = p_Park::get_parkslot_data($exten); |
|
| 348 | 348 | |
| 349 | - $agi->set_variable("__pt1c_IS_PARK", "1"); |
|
| 350 | - $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']); |
|
| 349 | + $agi->set_variable("__pt1c_IS_PARK", "1"); |
|
| 350 | + $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']); |
|
| 351 | 351 | |
| 352 | - // Сбор данных для генерации CDR. |
|
| 353 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 354 | - $channel= $agi->request['agi_channel']; |
|
| 355 | - $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
|
| 356 | - $data = array(); |
|
| 357 | - $data['action'] = "$action"; |
|
| 358 | - $data['UNIQUEID'] = $id; |
|
| 359 | - $data['linkedid_old']= $agi->get_variable("CDR(linkedid)", true); |
|
| 360 | - $data['agi_channel'] = $channel; |
|
| 361 | - $data['linkedid'] = $park_row['ParkeeLinkedid']; |
|
| 362 | - $data['start'] = $now; |
|
| 363 | - $data['transfer'] = '0'; |
|
| 364 | - $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 365 | - $data['answer'] = $data['start']; |
|
| 352 | + // Сбор данных для генерации CDR. |
|
| 353 | + $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 354 | + $channel= $agi->request['agi_channel']; |
|
| 355 | + $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
|
| 356 | + $data = array(); |
|
| 357 | + $data['action'] = "$action"; |
|
| 358 | + $data['UNIQUEID'] = $id; |
|
| 359 | + $data['linkedid_old']= $agi->get_variable("CDR(linkedid)", true); |
|
| 360 | + $data['agi_channel'] = $channel; |
|
| 361 | + $data['linkedid'] = $park_row['ParkeeLinkedid']; |
|
| 362 | + $data['start'] = $now; |
|
| 363 | + $data['transfer'] = '0'; |
|
| 364 | + $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 365 | + $data['answer'] = $data['start']; |
|
| 366 | 366 | |
| 367 | - if(null == $park_row){ |
|
| 368 | - $data['src_chan'] = $channel; |
|
| 369 | - $data['src_num'] = $agi->request['agi_callerid']; |
|
| 370 | - $data['dst_num'] = $agi->request['agi_extension']; |
|
| 371 | - $data['dst_chan'] = 'Park:'.$agi->request['agi_extension']; |
|
| 372 | - }else if(true == $park_row['pt1c_is_dst']){ |
|
| 373 | - $data['src_chan'] = $channel; |
|
| 374 | - $data['dst_chan'] = $park_row['ParkeeChannel']; |
|
| 375 | - $data['src_num'] = $agi->request['agi_callerid']; |
|
| 376 | - $data['dst_num'] = $park_row['ParkeeCallerIDNum']; |
|
| 377 | - }else{ |
|
| 378 | - $data['src_chan'] = $park_row['ParkeeChannel']; |
|
| 379 | - $data['dst_chan'] = $channel; |
|
| 380 | - $data['src_num'] = $park_row['ParkeeCallerIDNum']; |
|
| 381 | - $data['dst_num'] = $agi->request['agi_callerid']; |
|
| 382 | - } |
|
| 367 | + if(null == $park_row){ |
|
| 368 | + $data['src_chan'] = $channel; |
|
| 369 | + $data['src_num'] = $agi->request['agi_callerid']; |
|
| 370 | + $data['dst_num'] = $agi->request['agi_extension']; |
|
| 371 | + $data['dst_chan'] = 'Park:'.$agi->request['agi_extension']; |
|
| 372 | + }else if(true == $park_row['pt1c_is_dst']){ |
|
| 373 | + $data['src_chan'] = $channel; |
|
| 374 | + $data['dst_chan'] = $park_row['ParkeeChannel']; |
|
| 375 | + $data['src_num'] = $agi->request['agi_callerid']; |
|
| 376 | + $data['dst_num'] = $park_row['ParkeeCallerIDNum']; |
|
| 377 | + }else{ |
|
| 378 | + $data['src_chan'] = $park_row['ParkeeChannel']; |
|
| 379 | + $data['dst_chan'] = $channel; |
|
| 380 | + $data['src_num'] = $park_row['ParkeeCallerIDNum']; |
|
| 381 | + $data['dst_num'] = $agi->request['agi_callerid']; |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - if(trim($park_row['ParkingDuration'])!=''){ |
|
| 385 | - $time_start = date("Y-m-d H:i:s", time() - 1*($park_row['ParkingDuration']) ); |
|
| 386 | - $data_parking = array( |
|
| 387 | - 'UNIQUEID' => $id .'_'. Util::generateRandomString(3), |
|
| 388 | - 'src_chan' => $park_row['ParkeeChannel'], |
|
| 389 | - 'src_num' => $park_row['ParkeeCallerIDNum'], |
|
| 390 | - 'dst_num' => $park_row['ParkingSpace'], |
|
| 391 | - 'dst_chan' => 'Park:'.$park_row['ParkingSpace'], |
|
| 392 | - 'start' => $time_start, |
|
| 393 | - 'answer' => $time_start, |
|
| 394 | - 'endtime' => $now, |
|
| 395 | - 'did' => $data['did'], |
|
| 396 | - 'transfer' => '0', |
|
| 397 | - 'linkedid' => $data['linkedid'] |
|
| 398 | - ); |
|
| 399 | - $data['data_parking'] = $data_parking; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - return $data; |
|
| 384 | + if(trim($park_row['ParkingDuration'])!=''){ |
|
| 385 | + $time_start = date("Y-m-d H:i:s", time() - 1*($park_row['ParkingDuration']) ); |
|
| 386 | + $data_parking = array( |
|
| 387 | + 'UNIQUEID' => $id .'_'. Util::generateRandomString(3), |
|
| 388 | + 'src_chan' => $park_row['ParkeeChannel'], |
|
| 389 | + 'src_num' => $park_row['ParkeeCallerIDNum'], |
|
| 390 | + 'dst_num' => $park_row['ParkingSpace'], |
|
| 391 | + 'dst_chan' => 'Park:'.$park_row['ParkingSpace'], |
|
| 392 | + 'start' => $time_start, |
|
| 393 | + 'answer' => $time_start, |
|
| 394 | + 'endtime' => $now, |
|
| 395 | + 'did' => $data['did'], |
|
| 396 | + 'transfer' => '0', |
|
| 397 | + 'linkedid' => $data['linkedid'] |
|
| 398 | + ); |
|
| 399 | + $data['data_parking'] = $data_parking; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + return $data; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -410,28 +410,28 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | function Event_unpark_call_timeout($agi, $action){ |
| 412 | 412 | $now = Util::get_now_date(); |
| 413 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 414 | - // PARKER=SIP/206 |
|
| 415 | - $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true); |
|
| 416 | - $PARKING_DURATION = ($PARKING_DURATION == '')?45:$PARKING_DURATION; |
|
| 413 | + $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 414 | + // PARKER=SIP/206 |
|
| 415 | + $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true); |
|
| 416 | + $PARKING_DURATION = ($PARKING_DURATION == '')?45:$PARKING_DURATION; |
|
| 417 | 417 | |
| 418 | - $time_start = date("Y-m-d H:i:s", time() - 1*($PARKING_DURATION)); |
|
| 419 | - $PARKING_SPACE = $agi->get_variable("PARKING_SPACE", true); |
|
| 420 | - $data = array( |
|
| 421 | - 'action' => "$action", |
|
| 422 | - 'src_chan' => $agi->request['agi_channel'], // $agi->get_variable("PARKER", true), // ??? |
|
| 423 | - 'src_num' => $agi->request['agi_callerid'], |
|
| 424 | - 'dst_num' => $PARKING_SPACE, |
|
| 425 | - 'dst_chan' => 'Park:'.$PARKING_SPACE, |
|
| 426 | - 'start' => $time_start, |
|
| 427 | - 'answer' => $time_start, |
|
| 428 | - 'endtime' => $now, |
|
| 429 | - 'did' => $agi->get_variable("FROM_DID", true), |
|
| 430 | - 'UNIQUEID' => $id, |
|
| 431 | - 'transfer' => '0', |
|
| 432 | - 'linkedid' => $agi->get_variable("CDR(linkedid)", true), |
|
| 418 | + $time_start = date("Y-m-d H:i:s", time() - 1*($PARKING_DURATION)); |
|
| 419 | + $PARKING_SPACE = $agi->get_variable("PARKING_SPACE", true); |
|
| 420 | + $data = array( |
|
| 421 | + 'action' => "$action", |
|
| 422 | + 'src_chan' => $agi->request['agi_channel'], // $agi->get_variable("PARKER", true), // ??? |
|
| 423 | + 'src_num' => $agi->request['agi_callerid'], |
|
| 424 | + 'dst_num' => $PARKING_SPACE, |
|
| 425 | + 'dst_chan' => 'Park:'.$PARKING_SPACE, |
|
| 426 | + 'start' => $time_start, |
|
| 427 | + 'answer' => $time_start, |
|
| 428 | + 'endtime' => $now, |
|
| 429 | + 'did' => $agi->get_variable("FROM_DID", true), |
|
| 430 | + 'UNIQUEID' => $id, |
|
| 431 | + 'transfer' => '0', |
|
| 432 | + 'linkedid' => $agi->get_variable("CDR(linkedid)", true), |
|
| 433 | 433 | 'PARKER' => $agi->get_variable("PARKER", true), |
| 434 | - ); |
|
| 434 | + ); |
|
| 435 | 435 | |
| 436 | 436 | |
| 437 | 437 | $id2 = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
@@ -458,18 +458,18 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | $data = array( |
| 461 | - 'action' => "$action", |
|
| 462 | - // 'src_chan' => $agi->request['agi_channel'], |
|
| 463 | - // 'src_num' => $agi->request['agi_callerid'], |
|
| 464 | - 'dst_num' => $agi->request['agi_extension'], |
|
| 465 | - 'dst_chan' => 'Queue:'.$agi->request['agi_extension'], |
|
| 466 | - // 'answer' => $time_start, |
|
| 467 | - // 'end' => $now, |
|
| 468 | - 'did' => $agi->get_variable("FROM_DID", true), |
|
| 469 | - 'is_app' => '1', |
|
| 470 | - 'UNIQUEID' => $id, |
|
| 471 | - 'linkedid' => $agi->get_variable("CDR(linkedid)", true) |
|
| 472 | - ); |
|
| 461 | + 'action' => "$action", |
|
| 462 | + // 'src_chan' => $agi->request['agi_channel'], |
|
| 463 | + // 'src_num' => $agi->request['agi_callerid'], |
|
| 464 | + 'dst_num' => $agi->request['agi_extension'], |
|
| 465 | + 'dst_chan' => 'Queue:'.$agi->request['agi_extension'], |
|
| 466 | + // 'answer' => $time_start, |
|
| 467 | + // 'end' => $now, |
|
| 468 | + 'did' => $agi->get_variable("FROM_DID", true), |
|
| 469 | + 'is_app' => '1', |
|
| 470 | + 'UNIQUEID' => $id, |
|
| 471 | + 'linkedid' => $agi->get_variable("CDR(linkedid)", true) |
|
| 472 | + ); |
|
| 473 | 473 | if(!empty($time_start)){ |
| 474 | 474 | $data['src_chan'] = $agi->get_variable("QUEUE_SRC_CHAN", true); |
| 475 | 475 | $data['src_num'] = $agi->request['agi_callerid']; |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | $data['transfer'] = '0'; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - return $data; |
|
| 487 | + return $data; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -495,15 +495,15 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | function Event_queue_answer($agi, $action){ |
| 497 | 497 | $now = Util::get_now_date(); |
| 498 | - $id = $agi->get_variable("pt1c_q_UNIQUEID", true); |
|
| 499 | - $data = array(); |
|
| 500 | - $data['action'] = "$action"; |
|
| 501 | - $data['answer'] = $now; |
|
| 502 | - $data['id'] = $id; |
|
| 503 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 504 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 505 | - |
|
| 506 | - return $data; |
|
| 498 | + $id = $agi->get_variable("pt1c_q_UNIQUEID", true); |
|
| 499 | + $data = array(); |
|
| 500 | + $data['action'] = "$action"; |
|
| 501 | + $data['answer'] = $now; |
|
| 502 | + $data['id'] = $id; |
|
| 503 | + $data['agi_channel']= $agi->request['agi_channel']; |
|
| 504 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 505 | + |
|
| 506 | + return $data; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -514,16 +514,16 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | function Event_queue_end($agi, $action){ |
| 516 | 516 | $now = Util::get_now_date(); |
| 517 | - $id = $agi->get_variable("pt1c_q_UNIQUEID", true); |
|
| 518 | - $data = array(); |
|
| 519 | - $data['action'] = "$action"; |
|
| 520 | - $data['end'] = $now; |
|
| 521 | - $data['id'] = $id; |
|
| 522 | - $data['dialstatus'] = $agi->get_variable("QUEUESTATUS", true); |
|
| 523 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 524 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 525 | - |
|
| 526 | - return $data; |
|
| 517 | + $id = $agi->get_variable("pt1c_q_UNIQUEID", true); |
|
| 518 | + $data = array(); |
|
| 519 | + $data['action'] = "$action"; |
|
| 520 | + $data['end'] = $now; |
|
| 521 | + $data['id'] = $id; |
|
| 522 | + $data['dialstatus'] = $agi->get_variable("QUEUESTATUS", true); |
|
| 523 | + $data['agi_channel']= $agi->request['agi_channel']; |
|
| 524 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 525 | + |
|
| 526 | + return $data; |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | /** |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | if( function_exists($func_name) ){ |
| 673 | 673 | $agi = new AGI(); |
| 674 | 674 | // Сбор сведений по каналу. |
| 675 | - $result = $func_name($agi, $action); |
|
| 675 | + $result = $func_name($agi, $action); |
|
| 676 | 676 | // Оповещение без задержек. |
| 677 | 677 | $data = base64_encode(json_encode($result)); |
| 678 | 678 | $agi->exec("UserEvent", "CdrConnector,AgiData:".base64_encode(json_encode($result))); |
@@ -17,53 +17,53 @@ discard block |
||
| 17 | 17 | * @param string $action |
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | -function Event_dial($agi, $action){ |
|
| 20 | +function Event_dial($agi, $action) { |
|
| 21 | 21 | $now = Util::get_now_date(); |
| 22 | 22 | $data = array(); |
| 23 | 23 | |
| 24 | 24 | // Уточним канал, на случай очереди. |
| 25 | 25 | $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true); |
| 26 | - $orign_chan = $agi->get_variable("orign_chan", true); |
|
| 27 | - $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 28 | - $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
|
| 29 | - if($id == '' || !empty($QUEUE_SRC_CHAN)){ |
|
| 26 | + $orign_chan = $agi->get_variable("orign_chan", true); |
|
| 27 | + $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 28 | + $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
|
| 29 | + if ($id == '' || !empty($QUEUE_SRC_CHAN)) { |
|
| 30 | 30 | // Если это вызов на агента очереди !empty($QUEUE_SRC_CHAN). |
| 31 | 31 | // Если это новый вызов $id == ''. |
| 32 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 32 | + $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 33 | 33 | } |
| 34 | 34 | // Канал, AGI скрипта. |
| 35 | - $channel = $agi->request['agi_channel']; |
|
| 36 | - $is_local = !(stripos($channel, 'local/') === false); |
|
| 37 | - if($QUEUE_SRC_CHAN != '' && $is_local){ |
|
| 35 | + $channel = $agi->request['agi_channel']; |
|
| 36 | + $is_local = !(stripos($channel, 'local/') === false); |
|
| 37 | + if ($QUEUE_SRC_CHAN != '' && $is_local) { |
|
| 38 | 38 | // Это LOCAL, Переопределим на исходный. |
| 39 | 39 | $channel = $QUEUE_SRC_CHAN; |
| 40 | - }else if($is_local && (stripos($orign_chan, 'local/') === false)){ |
|
| 40 | + } else if ($is_local && (stripos($orign_chan, 'local/') === false)) { |
|
| 41 | 41 | $channel = $orign_chan; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Получим ID исходного канала. |
| 45 | 45 | $from_account = $agi->get_variable("FROM_PEER", true); |
| 46 | - if( $from_account == '' && stripos($agi->request['agi_channel'], 'local/') === false ){ |
|
| 47 | - $from_account = $agi->get_variable('CUT(CUT(CHANNEL(name),,1),/,2)', true); |
|
| 46 | + if ($from_account == '' && stripos($agi->request['agi_channel'], 'local/') === false) { |
|
| 47 | + $from_account = $agi->get_variable('CUT(CUT(CHANNEL(name),,1),/,2)', true); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $data['action'] = "$action"; |
|
| 51 | - if(!empty($IS_ORGNT)){ |
|
| 50 | + $data['action'] = "$action"; |
|
| 51 | + if (!empty($IS_ORGNT)) { |
|
| 52 | 52 | $dst_num = $agi->request['agi_callerid']; |
| 53 | 53 | $src_num = $agi->request['agi_extension']; |
| 54 | 54 | $data['dialstatus'] = 'ORIGINATE'; |
| 55 | - $from_account=''; |
|
| 55 | + $from_account = ''; |
|
| 56 | 56 | |
| 57 | - $p_start = strpos($agi->request['agi_channel'],'/')+1; |
|
| 58 | - $p_end = strpos($agi->request['agi_channel'],'@') - $p_start; |
|
| 57 | + $p_start = strpos($agi->request['agi_channel'], '/') + 1; |
|
| 58 | + $p_end = strpos($agi->request['agi_channel'], '@') - $p_start; |
|
| 59 | 59 | $num = substr($agi->request['agi_channel'], $p_start, $p_end); |
| 60 | 60 | |
| 61 | - $p_start = strpos($agi->request['agi_channel'],';'); |
|
| 62 | - $dst_chan= substr($agi->request['agi_channel'], 0, $p_start).';1'; |
|
| 61 | + $p_start = strpos($agi->request['agi_channel'], ';'); |
|
| 62 | + $dst_chan = substr($agi->request['agi_channel'], 0, $p_start).';1'; |
|
| 63 | 63 | |
| 64 | - $id = substr($agi->request['agi_uniqueid'],0, 16) .'_'.$num.'_'. $IS_ORGNT; |
|
| 65 | - $data['dst_chan'] = $dst_chan; |
|
| 66 | - }else{ |
|
| 64 | + $id = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$num.'_'.$IS_ORGNT; |
|
| 65 | + $data['dst_chan'] = $dst_chan; |
|
| 66 | + } else { |
|
| 67 | 67 | $src_num = $agi->request['agi_callerid']; |
| 68 | 68 | $dst_num = $agi->request['agi_extension']; |
| 69 | 69 | } |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | $data['src_chan'] = $channel; |
| 72 | 72 | $data['src_num'] = $src_num; |
| 73 | 73 | $data['dst_num'] = $dst_num; |
| 74 | - $data['start'] = $now; |
|
| 74 | + $data['start'] = $now; |
|
| 75 | 75 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 76 | 76 | $data['UNIQUEID'] = $id; |
| 77 | 77 | $data['transfer'] = '0'; |
| 78 | - $data['agi_channel'] = $agi->request['agi_channel'];; |
|
| 79 | - $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 80 | - $data['from_account']= $from_account; |
|
| 78 | + $data['agi_channel'] = $agi->request['agi_channel']; ; |
|
| 79 | + $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 80 | + $data['from_account'] = $from_account; |
|
| 81 | 81 | $data['IS_ORGNT'] = !empty($IS_ORGNT); |
| 82 | 82 | |
| 83 | 83 | $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
@@ -90,28 +90,28 @@ discard block |
||
| 90 | 90 | * @param string $action |
| 91 | 91 | * @return array |
| 92 | 92 | */ |
| 93 | -function Event_dial_create_chan($agi, $action){ |
|
| 93 | +function Event_dial_create_chan($agi, $action) { |
|
| 94 | 94 | $now = Util::get_now_date(); |
| 95 | 95 | $data = []; |
| 96 | 96 | $id = $agi->get_variable("pt1c_UNIQUEID", true); |
| 97 | 97 | $data['action'] = "$action"; |
| 98 | 98 | $data['dst_chan'] = $agi->request['agi_channel']; |
| 99 | 99 | $data['UNIQUEID'] = $id; |
| 100 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 101 | - $data['event_time'] = $now; |
|
| 100 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 101 | + $data['event_time'] = $now; |
|
| 102 | 102 | |
| 103 | - if( stripos($data['dst_chan'], 'local/') === false ){ |
|
| 104 | - $data['to_account'] = $agi->get_variable('CUT(CUT(CHANNEL(name),,1),/,2)', true); |
|
| 103 | + if (stripos($data['dst_chan'], 'local/') === false) { |
|
| 104 | + $data['to_account'] = $agi->get_variable('CUT(CUT(CHANNEL(name),,1),/,2)', true); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
|
| 108 | - if(!empty($IS_ORGNT)){ |
|
| 107 | + $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
|
| 108 | + if (!empty($IS_ORGNT)) { |
|
| 109 | 109 | // Вероятно необходимо переопределить искать по двум ID. |
| 110 | 110 | // Применимо только для Originate, когда в качестве звонящего используем два канала |
| 111 | 111 | // мобильный и внутренний номер. |
| 112 | - $peer_mobile= $agi->get_variable("peer_mobile", true); |
|
| 113 | - if( !empty($peer_mobile) && stripos($id, $peer_mobile) === false ) { |
|
| 114 | - $id = substr($agi->request['agi_uniqueid'],0, 16) .'_'.$peer_mobile.'_'. $IS_ORGNT; |
|
| 112 | + $peer_mobile = $agi->get_variable("peer_mobile", true); |
|
| 113 | + if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) { |
|
| 114 | + $id = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT; |
|
| 115 | 115 | $data['org_id'] = $id; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -125,52 +125,52 @@ discard block |
||
| 125 | 125 | * @param string $action |
| 126 | 126 | * @return array |
| 127 | 127 | */ |
| 128 | -function Event_dial_answer($agi, $action){ |
|
| 128 | +function Event_dial_answer($agi, $action) { |
|
| 129 | 129 | $now = Util::get_now_date(); |
| 130 | 130 | |
| 131 | 131 | $id = $agi->get_variable("pt1c_UNIQUEID", true); |
| 132 | 132 | $data = []; |
| 133 | 133 | $data['action'] = "$action"; |
| 134 | 134 | $data['answer'] = $now; |
| 135 | - $data['id'] = $id; |
|
| 135 | + $data['id'] = $id; |
|
| 136 | 136 | $data['dst_num'] = $agi->request['agi_callerid']; |
| 137 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 137 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 138 | 138 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 139 | 139 | |
| 140 | - $data['ENDCALLONANSWER']= $agi->get_variable("ENDCALLONANSWER", true); |
|
| 141 | - $data['BRIDGEPEER'] = $agi->get_variable("FROM_CHAN", true); |
|
| 140 | + $data['ENDCALLONANSWER'] = $agi->get_variable("ENDCALLONANSWER", true); |
|
| 141 | + $data['BRIDGEPEER'] = $agi->get_variable("FROM_CHAN", true); |
|
| 142 | 142 | |
| 143 | - $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
|
| 144 | - if(!empty($IS_ORGNT)){ |
|
| 143 | + $IS_ORGNT = $agi->get_variable("IS_ORGNT", true); |
|
| 144 | + if (!empty($IS_ORGNT)) { |
|
| 145 | 145 | // Вероятно необходимо переопределить ID. |
| 146 | 146 | // Применимо только для Originate, когда в качестве звонящего используем два канала |
| 147 | 147 | // мобильный и внутренний номер. |
| 148 | - $peer_mobile= $agi->get_variable("peer_mobile", true); |
|
| 149 | - if( !empty($peer_mobile) && stripos($id, $peer_mobile) === false ) { |
|
| 150 | - $id = substr($agi->request['agi_uniqueid'],0, 16) .'_'.$peer_mobile.'_'. $IS_ORGNT; |
|
| 148 | + $peer_mobile = $agi->get_variable("peer_mobile", true); |
|
| 149 | + if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) { |
|
| 150 | + $id = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT; |
|
| 151 | 151 | $data['org_id'] = $id; |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if(!empty($data['ENDCALLONANSWER'])){ |
|
| 155 | + if (!empty($data['ENDCALLONANSWER'])) { |
|
| 156 | 156 | $agi->set_variable("__ENDCALLONANSWER", ""); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $PICKUPEER = trim(''.$agi->get_variable("PICKUPEER", true)); |
| 160 | 160 | $data['dnid'] = $agi->request['agi_dnid']; |
| 161 | 161 | $pickupexten = Config::get_pickupexten(); |
| 162 | - if('unknown' == $data['dnid'] && $PICKUPEER != ''){ |
|
| 162 | + if ('unknown' == $data['dnid'] && $PICKUPEER != '') { |
|
| 163 | 163 | // Скорее всего ответ на вызов из 1С. |
| 164 | 164 | $data['dnid'] = $pickupexten; |
| 165 | - }elseif ($pickupexten == substr($data['dnid'], 0, 2) && $PICKUPEER != ''){ |
|
| 165 | + }elseif ($pickupexten == substr($data['dnid'], 0, 2) && $PICKUPEER != '') { |
|
| 166 | 166 | // Это перехват при наборе номера *8XXX. |
| 167 | 167 | $data['dnid'] = $pickupexten; |
| 168 | 168 | } |
| 169 | - if(trim($data['dnid']) == $pickupexten ) { |
|
| 169 | + if (trim($data['dnid']) == $pickupexten) { |
|
| 170 | 170 | // Очищаем переменную канала. Больше не требуется. |
| 171 | 171 | $agi->set_variable("PICKUPEER", ""); |
| 172 | 172 | $data['old_id'] = $id; |
| 173 | - $data['id'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 173 | + $data['id'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 174 | 174 | } |
| 175 | 175 | $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
| 176 | 176 | |
@@ -183,18 +183,18 @@ discard block |
||
| 183 | 183 | * @param string $action |
| 184 | 184 | * @return array |
| 185 | 185 | */ |
| 186 | -function Event_dial_hangup_DEPRECATED($agi, $action){ |
|
| 186 | +function Event_dial_hangup_DEPRECATED($agi, $action) { |
|
| 187 | 187 | // TODO Удалить эту функцию в будущем. |
| 188 | - $now = Util::get_now_date(); |
|
| 189 | - $data = array(); |
|
| 190 | - $data['action'] = "$action"; |
|
| 191 | - $data['end'] = $now; |
|
| 188 | + $now = Util::get_now_date(); |
|
| 189 | + $data = array(); |
|
| 190 | + $data['action'] = "$action"; |
|
| 191 | + $data['end'] = $now; |
|
| 192 | 192 | $data['id'] = $agi->get_variable("pt1c_UNIQUEID", true); |
| 193 | 193 | $data['agi_channel'] = $agi->request['agi_channel']; |
| 194 | 194 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 195 | 195 | $data['did'] = $agi->get_variable("FROM_DID", true); |
| 196 | 196 | |
| 197 | - $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 197 | + $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 198 | 198 | |
| 199 | 199 | return $data; |
| 200 | 200 | } |
@@ -205,35 +205,35 @@ discard block |
||
| 205 | 205 | * @param string $action |
| 206 | 206 | * @return array |
| 207 | 207 | */ |
| 208 | -function Event_transfer_dial($agi, $action){ |
|
| 208 | +function Event_transfer_dial($agi, $action) { |
|
| 209 | 209 | $now = Util::get_now_date(); |
| 210 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 210 | + $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 211 | 211 | |
| 212 | 212 | // Пытаемся определить канал. |
| 213 | 213 | $TRANSFERERNAME = $agi->get_variable("TRANSFERERNAME", true); |
| 214 | 214 | $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true); |
| 215 | 215 | $is_local = !(stripos($TRANSFERERNAME, 'local/') === false); |
| 216 | - if( $QUEUE_SRC_CHAN != '' && $is_local ){ |
|
| 216 | + if ($QUEUE_SRC_CHAN != '' && $is_local) { |
|
| 217 | 217 | // Это LOCAL, Переопределим на исходный. |
| 218 | 218 | $channel = $QUEUE_SRC_CHAN; |
| 219 | - }else if( $QUEUE_SRC_CHAN != '' && $TRANSFERERNAME == '' ){ |
|
| 219 | + } else if ($QUEUE_SRC_CHAN != '' && $TRANSFERERNAME == '') { |
|
| 220 | 220 | // Это редирект на очередь. |
| 221 | 221 | $channel = $QUEUE_SRC_CHAN; |
| 222 | - }else if($TRANSFERERNAME == ''){ |
|
| 222 | + } else if ($TRANSFERERNAME == '') { |
|
| 223 | 223 | $channel = $agi->request['agi_channel']; |
| 224 | - }else{ |
|
| 224 | + } else { |
|
| 225 | 225 | $channel = $TRANSFERERNAME; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $data = array(); |
|
| 229 | - $data['action'] = "$action"; |
|
| 230 | - $data['agi_channel']= $channel;// $agi->request['agi_channel']; |
|
| 228 | + $data = array(); |
|
| 229 | + $data['action'] = "$action"; |
|
| 230 | + $data['agi_channel'] = $channel; // $agi->request['agi_channel']; |
|
| 231 | 231 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 232 | - $data['src_chan'] = $channel; |
|
| 233 | - $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 234 | - $data['start'] = $now; |
|
| 232 | + $data['src_chan'] = $channel; |
|
| 233 | + $data['did'] = $agi->get_variable("FROM_DID", true); ; |
|
| 234 | + $data['start'] = $now; |
|
| 235 | 235 | $data['UNIQUEID'] = $id; |
| 236 | - $data['transfer'] = ($TRANSFERERNAME == '')?'0':'1'; |
|
| 236 | + $data['transfer'] = ($TRANSFERERNAME == '') ? '0' : '1'; |
|
| 237 | 237 | $data['src_num'] = $agi->request['agi_callerid']; |
| 238 | 238 | $data['dst_num'] = $agi->request['agi_extension']; |
| 239 | 239 | |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | * @param string $action |
| 249 | 249 | * @return array |
| 250 | 250 | */ |
| 251 | -function Event_transfer_dial_create_chan($agi, $action){ |
|
| 252 | - $id = $agi->get_variable("transfer_UNIQUEID", true); |
|
| 253 | - $data = array(); |
|
| 254 | - $data['dst_chan'] = $agi->request['agi_channel']; |
|
| 255 | - $data['transfer_UNIQUEID'] = "$id"; |
|
| 256 | - $data['action'] = "$action"; |
|
| 257 | - $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 251 | +function Event_transfer_dial_create_chan($agi, $action) { |
|
| 252 | + $id = $agi->get_variable("transfer_UNIQUEID", true); |
|
| 253 | + $data = array(); |
|
| 254 | + $data['dst_chan'] = $agi->request['agi_channel']; |
|
| 255 | + $data['transfer_UNIQUEID'] = "$id"; |
|
| 256 | + $data['action'] = "$action"; |
|
| 257 | + $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 258 | 258 | |
| 259 | 259 | return $data; |
| 260 | 260 | } |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | * @param string $action |
| 266 | 266 | * @return array |
| 267 | 267 | */ |
| 268 | -function Event_transfer_dial_answer($agi, $action){ |
|
| 268 | +function Event_transfer_dial_answer($agi, $action) { |
|
| 269 | 269 | $data = array(); |
| 270 | - $now = Util::get_now_date(); |
|
| 270 | + $now = Util::get_now_date(); |
|
| 271 | 271 | $id = $agi->get_variable("transfer_UNIQUEID", true); |
| 272 | - $data['answer'] = $now; |
|
| 273 | - $data['transfer_UNIQUEID'] = "$id"; |
|
| 274 | - $data['action'] = "$action"; |
|
| 272 | + $data['answer'] = $now; |
|
| 273 | + $data['transfer_UNIQUEID'] = "$id"; |
|
| 274 | + $data['action'] = "$action"; |
|
| 275 | 275 | $data['agi_channel'] = $agi->request['agi_channel']; |
| 276 | 276 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 277 | 277 | |
@@ -284,24 +284,24 @@ discard block |
||
| 284 | 284 | * @param string $action |
| 285 | 285 | * @return array |
| 286 | 286 | */ |
| 287 | -function Event_transfer_dial_hangup($agi, $action){ |
|
| 288 | - $now = Util::get_now_date(); |
|
| 289 | - $data = array(); |
|
| 290 | - $data['end'] = $now; |
|
| 287 | +function Event_transfer_dial_hangup($agi, $action) { |
|
| 288 | + $now = Util::get_now_date(); |
|
| 289 | + $data = array(); |
|
| 290 | + $data['end'] = $now; |
|
| 291 | 291 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 292 | - $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 293 | - $data['action'] = "$action"; |
|
| 292 | + $data['did'] = $agi->get_variable("FROM_DID", true); ; |
|
| 293 | + $data['action'] = "$action"; |
|
| 294 | 294 | $data['agi_channel'] = $agi->request['agi_channel']; |
| 295 | - $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 295 | + $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 296 | 296 | |
| 297 | - $pos = stripos( $data['agi_channel'], 'local/'); |
|
| 298 | - if($pos === false){ |
|
| 297 | + $pos = stripos($data['agi_channel'], 'local/'); |
|
| 298 | + if ($pos === false) { |
|
| 299 | 299 | // Если это завершение переадресации (консультативной). Создадим новую строку CDR. |
| 300 | - }else{ |
|
| 300 | + } else { |
|
| 301 | 301 | // Если пришел локальный канал: |
| 302 | - $data['TRANSFERERNAME'] = $agi->get_variable("TRANSFERERNAME", true); |
|
| 303 | - $data['ANSWEREDTIME'] = $agi->get_variable("ANSWEREDTIME", true); |
|
| 304 | - $data['dst_chan'] = $agi->get_variable("CDR(dstchannel)", true); |
|
| 302 | + $data['TRANSFERERNAME'] = $agi->get_variable("TRANSFERERNAME", true); |
|
| 303 | + $data['ANSWEREDTIME'] = $agi->get_variable("ANSWEREDTIME", true); |
|
| 304 | + $data['dst_chan'] = $agi->get_variable("CDR(dstchannel)", true); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | return $data; |
@@ -313,20 +313,20 @@ discard block |
||
| 313 | 313 | * @param string $action |
| 314 | 314 | * @return array |
| 315 | 315 | */ |
| 316 | -function Event_hangup_chan($agi, $action){ |
|
| 317 | - $now = Util::get_now_date(); |
|
| 318 | - $data = []; |
|
| 316 | +function Event_hangup_chan($agi, $action) { |
|
| 317 | + $now = Util::get_now_date(); |
|
| 318 | + $data = []; |
|
| 319 | 319 | $data['action'] = "$action"; |
| 320 | - $data['did'] = $agi->get_variable("FROM_DID", true);; |
|
| 321 | - $data['agi_threadid'] = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 320 | + $data['did'] = $agi->get_variable("FROM_DID", true); ; |
|
| 321 | + $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 322 | 322 | |
| 323 | 323 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 324 | 324 | $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true); |
| 325 | - if('ANSWER' == $data['dialstatus']){ |
|
| 325 | + if ('ANSWER' == $data['dialstatus']) { |
|
| 326 | 326 | $data['dialstatus'] = "ANSWERED"; |
| 327 | 327 | } |
| 328 | - $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 329 | - $data['end'] = $now; |
|
| 328 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 329 | + $data['end'] = $now; |
|
| 330 | 330 | |
| 331 | 331 | $data['OLD_LINKEDID'] = $agi->get_variable("OLD_LINKEDID", true); |
| 332 | 332 | $data['UNIQUEID'] = $agi->get_variable("pt1c_UNIQUEID", true); |
@@ -340,51 +340,51 @@ discard block |
||
| 340 | 340 | * @param string $action |
| 341 | 341 | * @return array |
| 342 | 342 | */ |
| 343 | -function Event_unpark_call($agi, $action){ |
|
| 344 | - $now = Util::get_now_date(); |
|
| 343 | +function Event_unpark_call($agi, $action) { |
|
| 344 | + $now = Util::get_now_date(); |
|
| 345 | 345 | // Обработка данных парковки. |
| 346 | - $exten = $agi->get_variable("EXTEN", true); |
|
| 346 | + $exten = $agi->get_variable("EXTEN", true); |
|
| 347 | 347 | $park_row = p_Park::get_parkslot_data($exten); |
| 348 | 348 | |
| 349 | 349 | $agi->set_variable("__pt1c_IS_PARK", "1"); |
| 350 | 350 | $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']); |
| 351 | 351 | |
| 352 | 352 | // Сбор данных для генерации CDR. |
| 353 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 354 | - $channel= $agi->request['agi_channel']; |
|
| 353 | + $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 354 | + $channel = $agi->request['agi_channel']; |
|
| 355 | 355 | $agi->set_variable("__pt1c_UNIQUEID", "$id"); |
| 356 | 356 | $data = array(); |
| 357 | - $data['action'] = "$action"; |
|
| 357 | + $data['action'] = "$action"; |
|
| 358 | 358 | $data['UNIQUEID'] = $id; |
| 359 | - $data['linkedid_old']= $agi->get_variable("CDR(linkedid)", true); |
|
| 359 | + $data['linkedid_old'] = $agi->get_variable("CDR(linkedid)", true); |
|
| 360 | 360 | $data['agi_channel'] = $channel; |
| 361 | 361 | $data['linkedid'] = $park_row['ParkeeLinkedid']; |
| 362 | - $data['start'] = $now; |
|
| 362 | + $data['start'] = $now; |
|
| 363 | 363 | $data['transfer'] = '0'; |
| 364 | - $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 365 | - $data['answer'] = $data['start']; |
|
| 364 | + $data['did'] = $agi->get_variable("FROM_DID", true); |
|
| 365 | + $data['answer'] = $data['start']; |
|
| 366 | 366 | |
| 367 | - if(null == $park_row){ |
|
| 367 | + if (null == $park_row) { |
|
| 368 | 368 | $data['src_chan'] = $channel; |
| 369 | 369 | $data['src_num'] = $agi->request['agi_callerid']; |
| 370 | 370 | $data['dst_num'] = $agi->request['agi_extension']; |
| 371 | 371 | $data['dst_chan'] = 'Park:'.$agi->request['agi_extension']; |
| 372 | - }else if(true == $park_row['pt1c_is_dst']){ |
|
| 372 | + } else if (true == $park_row['pt1c_is_dst']) { |
|
| 373 | 373 | $data['src_chan'] = $channel; |
| 374 | 374 | $data['dst_chan'] = $park_row['ParkeeChannel']; |
| 375 | 375 | $data['src_num'] = $agi->request['agi_callerid']; |
| 376 | 376 | $data['dst_num'] = $park_row['ParkeeCallerIDNum']; |
| 377 | - }else{ |
|
| 377 | + } else { |
|
| 378 | 378 | $data['src_chan'] = $park_row['ParkeeChannel']; |
| 379 | 379 | $data['dst_chan'] = $channel; |
| 380 | 380 | $data['src_num'] = $park_row['ParkeeCallerIDNum']; |
| 381 | 381 | $data['dst_num'] = $agi->request['agi_callerid']; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if(trim($park_row['ParkingDuration'])!=''){ |
|
| 385 | - $time_start = date("Y-m-d H:i:s", time() - 1*($park_row['ParkingDuration']) ); |
|
| 384 | + if (trim($park_row['ParkingDuration']) != '') { |
|
| 385 | + $time_start = date("Y-m-d H:i:s", time() - 1 * ($park_row['ParkingDuration'])); |
|
| 386 | 386 | $data_parking = array( |
| 387 | - 'UNIQUEID' => $id .'_'. Util::generateRandomString(3), |
|
| 387 | + 'UNIQUEID' => $id.'_'.Util::generateRandomString(3), |
|
| 388 | 388 | 'src_chan' => $park_row['ParkeeChannel'], |
| 389 | 389 | 'src_num' => $park_row['ParkeeCallerIDNum'], |
| 390 | 390 | 'dst_num' => $park_row['ParkingSpace'], |
@@ -408,14 +408,14 @@ discard block |
||
| 408 | 408 | * @param string $action |
| 409 | 409 | * @return array |
| 410 | 410 | */ |
| 411 | -function Event_unpark_call_timeout($agi, $action){ |
|
| 412 | - $now = Util::get_now_date(); |
|
| 413 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 411 | +function Event_unpark_call_timeout($agi, $action) { |
|
| 412 | + $now = Util::get_now_date(); |
|
| 413 | + $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 414 | 414 | // PARKER=SIP/206 |
| 415 | 415 | $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true); |
| 416 | - $PARKING_DURATION = ($PARKING_DURATION == '')?45:$PARKING_DURATION; |
|
| 416 | + $PARKING_DURATION = ($PARKING_DURATION == '') ? 45 : $PARKING_DURATION; |
|
| 417 | 417 | |
| 418 | - $time_start = date("Y-m-d H:i:s", time() - 1*($PARKING_DURATION)); |
|
| 418 | + $time_start = date("Y-m-d H:i:s", time() - 1 * ($PARKING_DURATION)); |
|
| 419 | 419 | $PARKING_SPACE = $agi->get_variable("PARKING_SPACE", true); |
| 420 | 420 | $data = array( |
| 421 | 421 | 'action' => "$action", |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | ); |
| 435 | 435 | |
| 436 | 436 | |
| 437 | - $id2 = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 437 | + $id2 = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 438 | 438 | $agi->set_variable("__pt1c_UNIQUEID", "$id2"); |
| 439 | 439 | |
| 440 | 440 | return $data; |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | * @param string $action |
| 447 | 447 | * @return array |
| 448 | 448 | */ |
| 449 | -function Event_queue_start($agi, $action){ |
|
| 450 | - $now = Util::get_now_date(); |
|
| 449 | +function Event_queue_start($agi, $action) { |
|
| 450 | + $now = Util::get_now_date(); |
|
| 451 | 451 | $time_start = null; |
| 452 | - $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 453 | - $ISTRANSFER = $agi->get_variable("ISTRANSFER", true); |
|
| 452 | + $id = $agi->get_variable("pt1c_UNIQUEID", true); |
|
| 453 | + $ISTRANSFER = $agi->get_variable("ISTRANSFER", true); |
|
| 454 | 454 | |
| 455 | - if(empty($id) || !empty($ISTRANSFER)) { |
|
| 455 | + if (empty($id) || !empty($ISTRANSFER)) { |
|
| 456 | 456 | $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
| 457 | 457 | $time_start = $now; |
| 458 | 458 | } |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | 'UNIQUEID' => $id, |
| 471 | 471 | 'linkedid' => $agi->get_variable("CDR(linkedid)", true) |
| 472 | 472 | ); |
| 473 | - if(!empty($time_start)){ |
|
| 473 | + if (!empty($time_start)) { |
|
| 474 | 474 | $data['src_chan'] = $agi->get_variable("QUEUE_SRC_CHAN", true); |
| 475 | 475 | $data['src_num'] = $agi->request['agi_callerid']; |
| 476 | 476 | $data['start'] = $time_start; |
@@ -478,9 +478,9 @@ discard block |
||
| 478 | 478 | $data['transfer'] = '0'; |
| 479 | 479 | $agi->set_variable("__pt1c_q_UNIQUEID", "$id"); |
| 480 | 480 | } |
| 481 | - if(!empty($ISTRANSFER)){ |
|
| 481 | + if (!empty($ISTRANSFER)) { |
|
| 482 | 482 | $data['transfer'] = '1'; |
| 483 | - }else{ |
|
| 483 | + } else { |
|
| 484 | 484 | $data['transfer'] = '0'; |
| 485 | 485 | } |
| 486 | 486 | |
@@ -493,14 +493,14 @@ discard block |
||
| 493 | 493 | * @param string $action |
| 494 | 494 | * @return array |
| 495 | 495 | */ |
| 496 | -function Event_queue_answer($agi, $action){ |
|
| 497 | - $now = Util::get_now_date(); |
|
| 496 | +function Event_queue_answer($agi, $action) { |
|
| 497 | + $now = Util::get_now_date(); |
|
| 498 | 498 | $id = $agi->get_variable("pt1c_q_UNIQUEID", true); |
| 499 | 499 | $data = array(); |
| 500 | 500 | $data['action'] = "$action"; |
| 501 | 501 | $data['answer'] = $now; |
| 502 | - $data['id'] = $id; |
|
| 503 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 502 | + $data['id'] = $id; |
|
| 503 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 504 | 504 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 505 | 505 | |
| 506 | 506 | return $data; |
@@ -512,15 +512,15 @@ discard block |
||
| 512 | 512 | * @param string $action |
| 513 | 513 | * @return array |
| 514 | 514 | */ |
| 515 | -function Event_queue_end($agi, $action){ |
|
| 516 | - $now = Util::get_now_date(); |
|
| 515 | +function Event_queue_end($agi, $action) { |
|
| 516 | + $now = Util::get_now_date(); |
|
| 517 | 517 | $id = $agi->get_variable("pt1c_q_UNIQUEID", true); |
| 518 | 518 | $data = array(); |
| 519 | - $data['action'] = "$action"; |
|
| 520 | - $data['end'] = $now; |
|
| 521 | - $data['id'] = $id; |
|
| 519 | + $data['action'] = "$action"; |
|
| 520 | + $data['end'] = $now; |
|
| 521 | + $data['id'] = $id; |
|
| 522 | 522 | $data['dialstatus'] = $agi->get_variable("QUEUESTATUS", true); |
| 523 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 523 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 524 | 524 | $data['linkedid'] = $agi->get_variable("CDR(linkedid)", true); |
| 525 | 525 | |
| 526 | 526 | return $data; |
@@ -532,52 +532,52 @@ discard block |
||
| 532 | 532 | * @param string $action |
| 533 | 533 | * @return array |
| 534 | 534 | */ |
| 535 | -function Event_meetme_dial($agi, $action){ |
|
| 535 | +function Event_meetme_dial($agi, $action) { |
|
| 536 | 536 | $now = Util::get_now_date(); |
| 537 | 537 | $id = ''; |
| 538 | 538 | $time_start = $now; |
| 539 | 539 | $exten = $agi->request['agi_extension']; |
| 540 | 540 | |
| 541 | - $not_local = (stripos($agi->request['agi_channel'], 'local/') === false); |
|
| 542 | - if($not_local){ |
|
| 541 | + $not_local = (stripos($agi->request['agi_channel'], 'local/') === false); |
|
| 542 | + if ($not_local) { |
|
| 543 | 543 | $am = Util::get_am(); |
| 544 | 544 | $res = $am->meetMeCollectInfo($exten, ['conf_1c']); |
| 545 | 545 | $callid = $agi->request['agi_callerid']; |
| 546 | - $users_nums = [ [$callid] ]; |
|
| 547 | - foreach ($res as $row){ |
|
| 546 | + $users_nums = [[$callid]]; |
|
| 547 | + foreach ($res as $row) { |
|
| 548 | 548 | $users_nums[] = explode('_', $row['conf_1c']); |
| 549 | 549 | } |
| 550 | 550 | $users = implode('_', array_unique(array_merge(... $users_nums))); |
| 551 | 551 | $agi->set_variable('conf_1c', $users); |
| 552 | - $agi->set_variable('CALLERID(num)','Conference_Room'); |
|
| 552 | + $agi->set_variable('CALLERID(num)', 'Conference_Room'); |
|
| 553 | 553 | $agi->set_variable('CALLERID(name)', $callid); |
| 554 | - $agi->set_variable('mikoconfcid', $exten); |
|
| 555 | - $agi->set_variable('mikoidconf', $exten); |
|
| 554 | + $agi->set_variable('mikoconfcid', $exten); |
|
| 555 | + $agi->set_variable('mikoidconf', $exten); |
|
| 556 | 556 | |
| 557 | 557 | $mikoidconf = $exten; |
| 558 | - $BLINDTRANSFER = $agi->get_variable("BLINDTRANSFER", true); |
|
| 559 | - if(empty($BLINDTRANSFER)){ |
|
| 558 | + $BLINDTRANSFER = $agi->get_variable("BLINDTRANSFER", true); |
|
| 559 | + if (empty($BLINDTRANSFER)) { |
|
| 560 | 560 | $id = $agi->get_variable('pt1c_UNIQUEID', true); |
| 561 | 561 | } |
| 562 | - $src_num= $callid; |
|
| 563 | - $dst_num= $exten; |
|
| 564 | - }else{ |
|
| 562 | + $src_num = $callid; |
|
| 563 | + $dst_num = $exten; |
|
| 564 | + } else { |
|
| 565 | 565 | $mikoidconf = $agi->get_variable('mikoidconf', true); |
| 566 | - if(empty($mikoidconf)){ |
|
| 566 | + if (empty($mikoidconf)) { |
|
| 567 | 567 | $mikoidconf = $exten; |
| 568 | 568 | } |
| 569 | - $src_num = $agi->get_variable('mikoconfcid', true); |
|
| 569 | + $src_num = $agi->get_variable('mikoconfcid', true); |
|
| 570 | 570 | // Отсечем все до "/". |
| 571 | 571 | $tmp_arr = explode('/', $mikoidconf); |
| 572 | - if(count($tmp_arr)>1){ |
|
| 572 | + if (count($tmp_arr) > 1) { |
|
| 573 | 573 | unset($tmp_arr[0]); |
| 574 | 574 | $mikoidconf = implode('/', $tmp_arr); |
| 575 | 575 | } |
| 576 | - $dst_num = substr($mikoidconf, 4); |
|
| 576 | + $dst_num = substr($mikoidconf, 4); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - if(empty($id)){ |
|
| 580 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 579 | + if (empty($id)) { |
|
| 580 | + $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | $recordingfile = Cdr::MeetMeSetRecFilename($id); |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | 'UNIQUEID' => $id, |
| 596 | 596 | 'linkedid' => $agi->get_variable('CDR(linkedid)', true) |
| 597 | 597 | ]; |
| 598 | - $agi->set_variable('MEETME_RECORDINGFILE', $recordingfile); |
|
| 599 | - $agi->set_variable('__pt1c_q_UNIQUEID', $id); |
|
| 598 | + $agi->set_variable('MEETME_RECORDINGFILE', $recordingfile); |
|
| 599 | + $agi->set_variable('__pt1c_q_UNIQUEID', $id); |
|
| 600 | 600 | |
| 601 | 601 | return $data; |
| 602 | 602 | } |
@@ -610,11 +610,11 @@ discard block |
||
| 610 | 610 | function Event_hangup_chan_meetme($agi, $action):array { |
| 611 | 611 | $now = Util::get_now_date(); |
| 612 | 612 | $data = []; |
| 613 | - $data['action'] = $action; |
|
| 613 | + $data['action'] = $action; |
|
| 614 | 614 | $data['linkedid'] = $agi->get_variable('CDR(linkedid)', true); |
| 615 | 615 | $data['src_chan'] = $agi->request['agi_channel']; |
| 616 | - $data['agi_channel']= $agi->request['agi_channel']; |
|
| 617 | - $data['end'] = $now; |
|
| 616 | + $data['agi_channel'] = $agi->request['agi_channel']; |
|
| 617 | + $data['end'] = $now; |
|
| 618 | 618 | $data['meetme_id'] = $agi->get_variable('MEETMEUNIQUEID', true); |
| 619 | 619 | $data['conference'] = $agi->get_variable('mikoidconf', true); |
| 620 | 620 | $data['UNIQUEID'] = $agi->get_variable('pt1c_q_UNIQUEID', true); |
@@ -632,10 +632,10 @@ discard block |
||
| 632 | 632 | * @param string $action |
| 633 | 633 | * @return array |
| 634 | 634 | */ |
| 635 | -function Event_dial_app($agi, $action){ |
|
| 636 | - $id = $agi->request['agi_uniqueid'] .'_'. Util::generateRandomString(); |
|
| 635 | +function Event_dial_app($agi, $action) { |
|
| 636 | + $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString(); |
|
| 637 | 637 | $extension = $agi->get_variable("APPEXTEN", true); |
| 638 | - if(empty($extension)){ |
|
| 638 | + if (empty($extension)) { |
|
| 639 | 639 | $extension = $agi->request['agi_extension']; |
| 640 | 640 | } |
| 641 | 641 | |
@@ -655,21 +655,21 @@ discard block |
||
| 655 | 655 | * @param string $action |
| 656 | 656 | * @return array |
| 657 | 657 | */ |
| 658 | -function Event_dial_outworktimes($agi, $action){ |
|
| 658 | +function Event_dial_outworktimes($agi, $action) { |
|
| 659 | 659 | $data = Event_dial($agi, $action); |
| 660 | 660 | $data['dst_chan'] = 'App:outworktimes'; |
| 661 | - $data['dst_num'] = 'outworktimes'; |
|
| 661 | + $data['dst_num'] = 'outworktimes'; |
|
| 662 | 662 | $data['is_app'] = 1; |
| 663 | 663 | return $data; |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | // Должны быть переданы параметры. |
| 667 | -if(count($argv)==1) exit; |
|
| 667 | +if (count($argv) == 1) exit; |
|
| 668 | 668 | |
| 669 | 669 | $action = trim($argv[1]); |
| 670 | 670 | $func_name = "Event_$action"; |
| 671 | 671 | |
| 672 | -if( function_exists($func_name) ){ |
|
| 672 | +if (function_exists($func_name)) { |
|
| 673 | 673 | $agi = new AGI(); |
| 674 | 674 | // Сбор сведений по каналу. |
| 675 | 675 | $result = $func_name($agi, $action); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | if($QUEUE_SRC_CHAN != '' && $is_local){ |
| 38 | 38 | // Это LOCAL, Переопределим на исходный. |
| 39 | 39 | $channel = $QUEUE_SRC_CHAN; |
| 40 | - }else if($is_local && (stripos($orign_chan, 'local/') === false)){ |
|
| 40 | + } else if($is_local && (stripos($orign_chan, 'local/') === false)){ |
|
| 41 | 41 | $channel = $orign_chan; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $id = substr($agi->request['agi_uniqueid'],0, 16) .'_'.$num.'_'. $IS_ORGNT; |
| 65 | 65 | $data['dst_chan'] = $dst_chan; |
| 66 | - }else{ |
|
| 66 | + } else{ |
|
| 67 | 67 | $src_num = $agi->request['agi_callerid']; |
| 68 | 68 | $dst_num = $agi->request['agi_extension']; |
| 69 | 69 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | if('unknown' == $data['dnid'] && $PICKUPEER != ''){ |
| 163 | 163 | // Скорее всего ответ на вызов из 1С. |
| 164 | 164 | $data['dnid'] = $pickupexten; |
| 165 | - }elseif ($pickupexten == substr($data['dnid'], 0, 2) && $PICKUPEER != ''){ |
|
| 165 | + } elseif ($pickupexten == substr($data['dnid'], 0, 2) && $PICKUPEER != ''){ |
|
| 166 | 166 | // Это перехват при наборе номера *8XXX. |
| 167 | 167 | $data['dnid'] = $pickupexten; |
| 168 | 168 | } |
@@ -216,12 +216,12 @@ discard block |
||
| 216 | 216 | if( $QUEUE_SRC_CHAN != '' && $is_local ){ |
| 217 | 217 | // Это LOCAL, Переопределим на исходный. |
| 218 | 218 | $channel = $QUEUE_SRC_CHAN; |
| 219 | - }else if( $QUEUE_SRC_CHAN != '' && $TRANSFERERNAME == '' ){ |
|
| 219 | + } else if( $QUEUE_SRC_CHAN != '' && $TRANSFERERNAME == '' ){ |
|
| 220 | 220 | // Это редирект на очередь. |
| 221 | 221 | $channel = $QUEUE_SRC_CHAN; |
| 222 | - }else if($TRANSFERERNAME == ''){ |
|
| 222 | + } else if($TRANSFERERNAME == ''){ |
|
| 223 | 223 | $channel = $agi->request['agi_channel']; |
| 224 | - }else{ |
|
| 224 | + } else{ |
|
| 225 | 225 | $channel = $TRANSFERERNAME; |
| 226 | 226 | } |
| 227 | 227 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | $pos = stripos( $data['agi_channel'], 'local/'); |
| 298 | 298 | if($pos === false){ |
| 299 | 299 | // Если это завершение переадресации (консультативной). Создадим новую строку CDR. |
| 300 | - }else{ |
|
| 300 | + } else{ |
|
| 301 | 301 | // Если пришел локальный канал: |
| 302 | 302 | $data['TRANSFERERNAME'] = $agi->get_variable("TRANSFERERNAME", true); |
| 303 | 303 | $data['ANSWEREDTIME'] = $agi->get_variable("ANSWEREDTIME", true); |
@@ -369,12 +369,12 @@ discard block |
||
| 369 | 369 | $data['src_num'] = $agi->request['agi_callerid']; |
| 370 | 370 | $data['dst_num'] = $agi->request['agi_extension']; |
| 371 | 371 | $data['dst_chan'] = 'Park:'.$agi->request['agi_extension']; |
| 372 | - }else if(true == $park_row['pt1c_is_dst']){ |
|
| 372 | + } else if(true == $park_row['pt1c_is_dst']){ |
|
| 373 | 373 | $data['src_chan'] = $channel; |
| 374 | 374 | $data['dst_chan'] = $park_row['ParkeeChannel']; |
| 375 | 375 | $data['src_num'] = $agi->request['agi_callerid']; |
| 376 | 376 | $data['dst_num'] = $park_row['ParkeeCallerIDNum']; |
| 377 | - }else{ |
|
| 377 | + } else{ |
|
| 378 | 378 | $data['src_chan'] = $park_row['ParkeeChannel']; |
| 379 | 379 | $data['dst_chan'] = $channel; |
| 380 | 380 | $data['src_num'] = $park_row['ParkeeCallerIDNum']; |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | } |
| 481 | 481 | if(!empty($ISTRANSFER)){ |
| 482 | 482 | $data['transfer'] = '1'; |
| 483 | - }else{ |
|
| 483 | + } else{ |
|
| 484 | 484 | $data['transfer'] = '0'; |
| 485 | 485 | } |
| 486 | 486 | |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | } |
| 562 | 562 | $src_num= $callid; |
| 563 | 563 | $dst_num= $exten; |
| 564 | - }else{ |
|
| 564 | + } else{ |
|
| 565 | 565 | $mikoidconf = $agi->get_variable('mikoidconf', true); |
| 566 | 566 | if(empty($mikoidconf)){ |
| 567 | 567 | $mikoidconf = $exten; |
@@ -664,7 +664,9 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | // Должны быть переданы параметры. |
| 667 | -if(count($argv)==1) exit; |
|
| 667 | +if(count($argv)==1) { |
|
| 668 | + exit; |
|
| 669 | +} |
|
| 668 | 670 | |
| 669 | 671 | $action = trim($argv[1]); |
| 670 | 672 | $func_name = "Event_$action"; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param string $config is the name of the config file to parse or a parent agi from which to read the config |
| 89 | 89 | * @param array $optconfig is an array of configuration vars and vals, stuffed into $this->config['asmanager'] |
| 90 | 90 | */ |
| 91 | - function __construct($config = NULL, $optconfig = array()){ |
|
| 91 | + function __construct($config = NULL, $optconfig = array()) { |
|
| 92 | 92 | // load config |
| 93 | 93 | if (!is_null($config) && file_exists($config)) $this->config = parse_ini_file($config, true); elseif (file_exists(DEFAULT_PHPAGI_CONFIG)) $this->config = parse_ini_file(DEFAULT_PHPAGI_CONFIG, true); |
| 94 | 94 | |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | * @param array $parameters |
| 110 | 110 | * @return array of parameters |
| 111 | 111 | */ |
| 112 | - function send_request($action, $parameters = array()){ |
|
| 112 | + function send_request($action, $parameters = array()) { |
|
| 113 | 113 | $req = "Action: $action\r\n"; |
| 114 | 114 | foreach ($parameters as $var => $val) $req .= "$var: $val\r\n"; |
| 115 | 115 | $req .= "\r\n"; |
| 116 | - if(!is_resource($this->socket)){ |
|
| 116 | + if (!is_resource($this->socket)) { |
|
| 117 | 117 | return array(); |
| 118 | 118 | } |
| 119 | 119 | @fwrite($this->socket, $req); |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | * @param array $parameters |
| 128 | 128 | * @return array of parameters |
| 129 | 129 | */ |
| 130 | - function send_request_timeout($action, $parameters = array()){ |
|
| 130 | + function send_request_timeout($action, $parameters = array()) { |
|
| 131 | 131 | $req = "Action: $action\r\n"; |
| 132 | 132 | foreach ($parameters as $var => $val) $req .= "$var: $val\r\n"; |
| 133 | 133 | $req .= "\r\n"; |
| 134 | - if(!is_resource($this->socket)){ |
|
| 134 | + if (!is_resource($this->socket)) { |
|
| 135 | 135 | return array(); |
| 136 | 136 | } |
| 137 | 137 | @fwrite($this->socket, $req); |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | * @param string $pingname |
| 144 | 144 | * @return array|bool |
| 145 | 145 | */ |
| 146 | - function ping_ami_listner($pingname = 'CdrConnector'){ |
|
| 146 | + function ping_ami_listner($pingname = 'CdrConnector') { |
|
| 147 | 147 | // Установим фильтр на события. |
| 148 | - $params = ['Operation'=>'Add', 'Filter' => 'Event: UserEvent']; |
|
| 148 | + $params = ['Operation'=>'Add', 'Filter' => 'Event: UserEvent']; |
|
| 149 | 149 | $this->send_request_timeout('Filter', $params); |
| 150 | 150 | // Отправим пинг. |
| 151 | 151 | $req = ''; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | ); |
| 156 | 156 | foreach ($parameters as $var => $val) $req .= "$var: $val\r\n"; |
| 157 | 157 | $req .= "\r\n"; |
| 158 | - if(!is_resource($this->socket)){ |
|
| 158 | + if (!is_resource($this->socket)) { |
|
| 159 | 159 | return array(); |
| 160 | 160 | } |
| 161 | 161 | @fwrite($this->socket, $req); |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | do { |
| 170 | 170 | $type = ''; |
| 171 | 171 | $parameters = []; |
| 172 | - if(!is_resource($this->socket)){ |
|
| 172 | + if (!is_resource($this->socket)) { |
|
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | $buffer = trim(@fgets($this->socket, 4096)); |
| 176 | 176 | while ($buffer != '') { |
| 177 | 177 | $a = strpos($buffer, ':'); |
| 178 | 178 | if ($a) { |
| 179 | - if (!count($parameters)){ |
|
| 179 | + if (!count($parameters)) { |
|
| 180 | 180 | $type = strtolower(substr($buffer, 0, $a)); |
| 181 | 181 | } |
| 182 | 182 | $parameters[substr($buffer, 0, $a)] = substr($buffer, $a + 2); |
@@ -184,16 +184,16 @@ discard block |
||
| 184 | 184 | $buffer = trim(fgets($this->socket, 4096)); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if($type == '' && count($this->Ping())==0){ |
|
| 187 | + if ($type == '' && count($this->Ping()) == 0) { |
|
| 188 | 188 | $timeout = true; |
| 189 | 189 | } |
| 190 | - else if('event' == $type && $parameters['Event'] == 'UserEvent' && "{$pingname}Pong" == $parameters['UserEvent']){ |
|
| 190 | + else if ('event' == $type && $parameters['Event'] == 'UserEvent' && "{$pingname}Pong" == $parameters['UserEvent']) { |
|
| 191 | 191 | // Ответ получен. |
| 192 | 192 | $result = true; |
| 193 | 193 | break; |
| 194 | 194 | } |
| 195 | 195 | $time = $this->microtime_float() - $time_start; |
| 196 | - if($time > 2){ |
|
| 196 | + if ($time > 2) { |
|
| 197 | 197 | // Таймаут ожидания. |
| 198 | 198 | break; |
| 199 | 199 | } |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | return $result; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - private function wait_response_get_sub_data(&$parameters, $end_string = '', $event_as_array=true):void { |
|
| 207 | - if(!is_array($parameters)){ |
|
| 206 | + private function wait_response_get_sub_data(&$parameters, $end_string = '', $event_as_array = true):void { |
|
| 207 | + if (!is_array($parameters)) { |
|
| 208 | 208 | $parameters = []; |
| 209 | 209 | } |
| 210 | - if(empty($end_string)){ |
|
| 210 | + if (empty($end_string)) { |
|
| 211 | 211 | return; |
| 212 | 212 | } |
| 213 | 213 | $parameters['data'] = array(); |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | $buff = fgets($this->socket, 4096); |
| 219 | 219 | $a_pos = strpos($buff, ':'); |
| 220 | 220 | if (!$a_pos) { |
| 221 | - if (count($m)>0) { |
|
| 222 | - if($event_as_array){ |
|
| 221 | + if (count($m) > 0) { |
|
| 222 | + if ($event_as_array) { |
|
| 223 | 223 | $parameters['data'][$m['Event']][] = $m; |
| 224 | - }else{ |
|
| 224 | + } else { |
|
| 225 | 225 | $parameters['data'][$m['Event']] = $m; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | do { |
| 252 | 252 | $type = NULL; |
| 253 | 253 | $parameters = array(); |
| 254 | - if(!is_resource($this->socket)){ |
|
| 254 | + if (!is_resource($this->socket)) { |
|
| 255 | 255 | return $parameters; |
| 256 | 256 | } |
| 257 | 257 | $buffer = trim(@fgets($this->socket, 4096)); |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | if ($a) { |
| 261 | 261 | $key = ''; $value = ''; |
| 262 | 262 | $event_text = substr($buffer, $a + 2); |
| 263 | - if (!count($parameters)){ |
|
| 263 | + if (!count($parameters)) { |
|
| 264 | 264 | $type = strtolower(substr($buffer, 0, $a)); |
| 265 | 265 | if ($event_text === 'Follows') { |
| 266 | 266 | // A follows response means there is a miltiline field that follows. |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | // MeetmeList |
| 309 | 309 | $this->wait_response_get_sub_data($parameters, 'MeetmeListRoomsComplete'); |
| 310 | 310 | } |
| 311 | - unset($key,$value); |
|
| 311 | + unset($key, $value); |
|
| 312 | 312 | // store parameter in $parameters |
| 313 | 313 | $parameters[substr($buffer, 0, $a)] = $event_text; |
| 314 | 314 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | case 'response': |
| 328 | 328 | break; |
| 329 | 329 | default: |
| 330 | - $this->log('Unhandled response packet from Manager: ' . print_r($parameters, true)); |
|
| 330 | + $this->log('Unhandled response packet from Manager: '.print_r($parameters, true)); |
|
| 331 | 331 | break; |
| 332 | 332 | } |
| 333 | 333 | } while ($type !== 'response' && !$timeout); |
@@ -339,30 +339,30 @@ discard block |
||
| 339 | 339 | * @param $allow_timeout bool |
| 340 | 340 | * @return array of parameters, empty on timeout |
| 341 | 341 | */ |
| 342 | - function wait_user_event($allow_timeout = false){ |
|
| 342 | + function wait_user_event($allow_timeout = false) { |
|
| 343 | 343 | $timeout = false; |
| 344 | 344 | do { |
| 345 | 345 | $type = ''; |
| 346 | 346 | $parameters = []; |
| 347 | - try{ |
|
| 347 | + try { |
|
| 348 | 348 | $buffer = trim(@fgets($this->socket, 4096)); |
| 349 | - }catch (Exception $e){ |
|
| 349 | + } catch (Exception $e) { |
|
| 350 | 350 | return false; |
| 351 | 351 | } |
| 352 | 352 | while ($buffer != '') { |
| 353 | 353 | $a = strpos($buffer, ':'); |
| 354 | 354 | if ($a) { |
| 355 | - if (!count($parameters)){ |
|
| 355 | + if (!count($parameters)) { |
|
| 356 | 356 | $type = strtolower(substr($buffer, 0, $a)); |
| 357 | 357 | } |
| 358 | 358 | $parameters[substr($buffer, 0, $a)] = substr($buffer, $a + 2); |
| 359 | 359 | } |
| 360 | 360 | $buffer = trim(fgets($this->socket, 4096)); |
| 361 | 361 | } |
| 362 | - if($type == '' && count($this->Ping())==0){ |
|
| 362 | + if ($type == '' && count($this->Ping()) == 0) { |
|
| 363 | 363 | $timeout = $allow_timeout; |
| 364 | 364 | } |
| 365 | - else if('event' == $type){ |
|
| 365 | + else if ('event' == $type) { |
|
| 366 | 366 | $this->process_event($parameters); |
| 367 | 367 | } |
| 368 | 368 | } while (!$timeout); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @param string $events |
| 381 | 381 | * @return boolean true on success |
| 382 | 382 | */ |
| 383 | - function connect($server = NULL, $username = NULL, $secret = NULL, $events = 'on'){ |
|
| 383 | + function connect($server = NULL, $username = NULL, $secret = NULL, $events = 'on') { |
|
| 384 | 384 | // use config if not specified |
| 385 | 385 | if (is_null($server)) $server = $this->config['asmanager']['server']; |
| 386 | 386 | if (is_null($username)) $username = $this->config['asmanager']['username']; |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | return true; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - public function logged_in(){ |
|
| 431 | + public function logged_in() { |
|
| 432 | 432 | return $this->_logged_in; |
| 433 | 433 | } |
| 434 | 434 | |
@@ -437,9 +437,9 @@ discard block |
||
| 437 | 437 | * |
| 438 | 438 | * @example examples/sip_show_peer.php Get information about a sip peer |
| 439 | 439 | */ |
| 440 | - function disconnect(){ |
|
| 440 | + function disconnect() { |
|
| 441 | 441 | if ($this->_logged_in == TRUE) $this->logoff(); |
| 442 | - if(is_resource($this->socket)){ |
|
| 442 | + if (is_resource($this->socket)) { |
|
| 443 | 443 | fclose($this->socket); |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @param integer $timeout Maximum duration of the call (sec) |
| 459 | 459 | * @return array |
| 460 | 460 | */ |
| 461 | - function AbsoluteTimeout($channel, $timeout){ |
|
| 461 | + function AbsoluteTimeout($channel, $timeout) { |
|
| 462 | 462 | return $this->send_request('AbsoluteTimeout', array('Channel' => $channel, 'Timeout' => $timeout)); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * @param string $file the new name of the file created in the monitor spool directory. |
| 471 | 471 | * @return array |
| 472 | 472 | */ |
| 473 | - function ChangeMonitor($channel, $file){ |
|
| 473 | + function ChangeMonitor($channel, $file) { |
|
| 474 | 474 | return $this->send_request('ChangeMontior', array('Channel' => $channel, 'File' => $file)); |
| 475 | 475 | } |
| 476 | 476 | |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @param string $actionid message matching variable |
| 485 | 485 | * @return array |
| 486 | 486 | */ |
| 487 | - function Command($command, $actionid = NULL){ |
|
| 487 | + function Command($command, $actionid = NULL) { |
|
| 488 | 488 | $parameters = array('Command' => $command); |
| 489 | 489 | if ($actionid) $parameters['ActionID'] = $actionid; |
| 490 | 490 | return $this->send_request('Command', $parameters); |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * @param string $eventmask is either 'on', 'off', or 'system,call,log' |
| 498 | 498 | * @return array |
| 499 | 499 | */ |
| 500 | - function Events($eventmask){ |
|
| 500 | + function Events($eventmask) { |
|
| 501 | 501 | return $this->send_request('Events', array('EventMask' => $eventmask)); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | * @param string $actionid message matching variable |
| 511 | 511 | * @return array |
| 512 | 512 | */ |
| 513 | - function ExtensionState($exten, $context, $actionid = NULL){ |
|
| 513 | + function ExtensionState($exten, $context, $actionid = NULL) { |
|
| 514 | 514 | $parameters = array('Exten' => $exten, 'Context' => $context); |
| 515 | 515 | if ($actionid) $parameters['ActionID'] = $actionid; |
| 516 | 516 | return $this->send_request('ExtensionState', $parameters); |
@@ -527,15 +527,15 @@ discard block |
||
| 527 | 527 | * @param boolean $ret_array |
| 528 | 528 | * @return string | array |
| 529 | 529 | */ |
| 530 | - function GetVar($channel, $variable, $actionid = NULL, $ret_array = true){ |
|
| 530 | + function GetVar($channel, $variable, $actionid = NULL, $ret_array = true) { |
|
| 531 | 531 | $parameters = array('Channel' => $channel, 'Variable' => $variable); |
| 532 | - if ($actionid){ |
|
| 532 | + if ($actionid) { |
|
| 533 | 533 | $parameters['ActionID'] = $actionid; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | $data = $this->send_request('GetVar', $parameters); |
| 537 | - if($ret_array != true){ |
|
| 538 | - $data = (isset($data['Value']) && $data['Value'] )?$data['Value']:''; |
|
| 537 | + if ($ret_array != true) { |
|
| 538 | + $data = (isset($data['Value']) && $data['Value']) ? $data['Value'] : ''; |
|
| 539 | 539 | } |
| 540 | 540 | return $data; |
| 541 | 541 | } |
@@ -545,21 +545,21 @@ discard block |
||
| 545 | 545 | * @param boolean $group |
| 546 | 546 | * @return array |
| 547 | 547 | */ |
| 548 | - public function GetChannels($group = true){ |
|
| 549 | - $res = $this->send_request_timeout('CoreShowChannels'); |
|
| 548 | + public function GetChannels($group = true) { |
|
| 549 | + $res = $this->send_request_timeout('CoreShowChannels'); |
|
| 550 | 550 | $channels = null; |
| 551 | - if(isset($res['data']['CoreShowChannel'])){ |
|
| 551 | + if (isset($res['data']['CoreShowChannel'])) { |
|
| 552 | 552 | $channels = $res['data']['CoreShowChannel']; |
| 553 | 553 | } |
| 554 | 554 | $channels_id = array(); |
| 555 | - if(null != $channels){ |
|
| 556 | - foreach($channels as $chan){ |
|
| 557 | - if($group == true){ |
|
| 558 | - if(! isset($chan['Linkedid']) ){ |
|
| 555 | + if (null != $channels) { |
|
| 556 | + foreach ($channels as $chan) { |
|
| 557 | + if ($group == true) { |
|
| 558 | + if (!isset($chan['Linkedid'])) { |
|
| 559 | 559 | continue; |
| 560 | 560 | } |
| 561 | 561 | $channels_id[$chan['Linkedid']][] = $chan['Channel']; |
| 562 | - }else{ |
|
| 562 | + } else { |
|
| 563 | 563 | $channels_id[] = $chan['Channel']; |
| 564 | 564 | } |
| 565 | 565 | } |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @param string $channel The channel name to be hungup |
| 576 | 576 | * @return array |
| 577 | 577 | */ |
| 578 | - function Hangup($channel){ |
|
| 578 | + function Hangup($channel) { |
|
| 579 | 579 | return $this->send_request('Hangup', array('Channel' => $channel)); |
| 580 | 580 | } |
| 581 | 581 | |
@@ -585,10 +585,10 @@ discard block |
||
| 585 | 585 | * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+IAXpeers |
| 586 | 586 | * @return array |
| 587 | 587 | */ |
| 588 | - function IAXpeerlist(){ |
|
| 588 | + function IAXpeerlist() { |
|
| 589 | 589 | $result = $this->send_request('IAXpeerlist'); |
| 590 | - $data = (isset($result['data']) && is_array($result['data']))?$result['data']:[]; |
|
| 591 | - $arr_peer = (isset($data['PeerEntry']) && is_array($data['PeerEntry']))?$data['PeerEntry']:[]; |
|
| 590 | + $data = (isset($result['data']) && is_array($result['data'])) ? $result['data'] : []; |
|
| 591 | + $arr_peer = (isset($data['PeerEntry']) && is_array($data['PeerEntry'])) ? $data['PeerEntry'] : []; |
|
| 592 | 592 | return $arr_peer; |
| 593 | 593 | } |
| 594 | 594 | |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | * Возвращает регистрации пиров. |
| 597 | 597 | * @return array |
| 598 | 598 | */ |
| 599 | - function IAXregistry(){ |
|
| 599 | + function IAXregistry() { |
|
| 600 | 600 | $result = $this->send_request('IAXregistry'); |
| 601 | - $data = (isset($result['data']) && is_array($result['data']))?$result['data']:[]; |
|
| 602 | - $arr_peer = (isset($data['RegistryEntry']) && is_array($data['RegistryEntry']))?$data['RegistryEntry']:[]; |
|
| 601 | + $data = (isset($result['data']) && is_array($result['data'])) ? $result['data'] : []; |
|
| 602 | + $arr_peer = (isset($data['RegistryEntry']) && is_array($data['RegistryEntry'])) ? $data['RegistryEntry'] : []; |
|
| 603 | 603 | return $arr_peer; |
| 604 | 604 | } |
| 605 | 605 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @param string $actionid message matching variable |
| 611 | 611 | * @return array |
| 612 | 612 | */ |
| 613 | - function ListCommands($actionid = NULL){ |
|
| 613 | + function ListCommands($actionid = NULL) { |
|
| 614 | 614 | if ($actionid) return $this->send_request('ListCommands', array('ActionID' => $actionid)); else |
| 615 | 615 | return $this->send_request('ListCommands'); |
| 616 | 616 | } |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @param array $headers |
| 622 | 622 | * @return array |
| 623 | 623 | */ |
| 624 | - function UserEvent($name, $headers){ |
|
| 624 | + function UserEvent($name, $headers) { |
|
| 625 | 625 | $headers['UserEvent'] = $name; |
| 626 | 626 | return $this->send_request_timeout('UserEvent', $headers); |
| 627 | 627 | } |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | * |
| 632 | 632 | * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Logoff |
| 633 | 633 | */ |
| 634 | - function Logoff(){ |
|
| 634 | + function Logoff() { |
|
| 635 | 635 | return $this->send_request_timeout('Logoff'); |
| 636 | 636 | } |
| 637 | 637 | |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | * @param string $actionid message matching variable |
| 650 | 650 | * @return array |
| 651 | 651 | */ |
| 652 | - function MailboxCount($mailbox, $actionid = NULL){ |
|
| 652 | + function MailboxCount($mailbox, $actionid = NULL) { |
|
| 653 | 653 | $parameters = array('Mailbox' => $mailbox); |
| 654 | 654 | if ($actionid) $parameters['ActionID'] = $actionid; |
| 655 | 655 | return $this->send_request('MailboxCount', $parameters); |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | * @param string $actionid message matching variable |
| 669 | 669 | * @return array |
| 670 | 670 | */ |
| 671 | - function MailboxStatus($mailbox, $actionid = NULL){ |
|
| 671 | + function MailboxStatus($mailbox, $actionid = NULL) { |
|
| 672 | 672 | $parameters = array('Mailbox' => $mailbox); |
| 673 | 673 | if ($actionid) $parameters['ActionID'] = $actionid; |
| 674 | 674 | return $this->send_request('MailboxStatus', $parameters); |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | * @param boolean $mix |
| 685 | 685 | * @return array |
| 686 | 686 | */ |
| 687 | - function Monitor($channel, $file = NULL, $format = NULL, $mix = NULL){ |
|
| 687 | + function Monitor($channel, $file = NULL, $format = NULL, $mix = NULL) { |
|
| 688 | 688 | $parameters = array('Channel' => $channel); |
| 689 | 689 | if ($file) $parameters['File'] = $file; |
| 690 | 690 | if ($format) $parameters['Format'] = $format; |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | * @param string $command |
| 703 | 703 | * @return array |
| 704 | 704 | */ |
| 705 | - function MixMonitor($channel, $file, $options, $command){ |
|
| 705 | + function MixMonitor($channel, $file, $options, $command) { |
|
| 706 | 706 | $parameters = array('Channel' => $channel); |
| 707 | 707 | $parameters['File'] = $file; |
| 708 | 708 | $parameters['options'] = $options; |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * @param string $channel |
| 718 | 718 | * @return array |
| 719 | 719 | */ |
| 720 | - function StopMixMonitor($channel){ |
|
| 720 | + function StopMixMonitor($channel) { |
|
| 721 | 721 | $parameters = array('Channel' => $channel); |
| 722 | 722 | return $this->send_request_timeout('StopMixMonitor', $parameters); |
| 723 | 723 | } |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | * @param string $Val |
| 731 | 731 | * @return array |
| 732 | 732 | */ |
| 733 | - function DBPut($Family, $Key, $Val = ''){ |
|
| 733 | + function DBPut($Family, $Key, $Val = '') { |
|
| 734 | 734 | $parameters = array('Family' => $Family, 'Key' => $Key, 'Val' => $Val); |
| 735 | 735 | $res_data = $this->send_request_timeout('DBPut', $parameters); |
| 736 | 736 | return $res_data; |
@@ -742,8 +742,8 @@ discard block |
||
| 742 | 742 | * @param $ActionID |
| 743 | 743 | * @return array |
| 744 | 744 | */ |
| 745 | - public function MeetmeList($Conference, $ActionID=''):array { |
|
| 746 | - if(empty($ActionID)){ |
|
| 745 | + public function MeetmeList($Conference, $ActionID = ''):array { |
|
| 746 | + if (empty($ActionID)) { |
|
| 747 | 747 | $ActionID = Util::generateRandomString(5); |
| 748 | 748 | } |
| 749 | 749 | $parameters = [ |
@@ -758,8 +758,8 @@ discard block |
||
| 758 | 758 | * @param $ActionID |
| 759 | 759 | * @return array |
| 760 | 760 | */ |
| 761 | - public function MeetmeListRooms($ActionID=''):array { |
|
| 762 | - if(empty($ActionID)){ |
|
| 761 | + public function MeetmeListRooms($ActionID = ''):array { |
|
| 762 | + if (empty($ActionID)) { |
|
| 763 | 763 | $ActionID = Util::generateRandomString(5); |
| 764 | 764 | } |
| 765 | 765 | $parameters = [ |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * @param string $Key |
| 776 | 776 | * @return array |
| 777 | 777 | */ |
| 778 | - function DBGet($Family, $Key){ |
|
| 778 | + function DBGet($Family, $Key) { |
|
| 779 | 779 | $parameters = array('Family' => $Family, 'Key' => $Key); |
| 780 | 780 | return $this->send_request_timeout('DBGet', $parameters); |
| 781 | 781 | } |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | * @param string $actionid message matching variable |
| 799 | 799 | * @return array |
| 800 | 800 | */ |
| 801 | - function Originate($channel, $exten = NULL, $context = NULL, $priority = NULL, $application = NULL, $data = NULL, $timeout = NULL, $callerid = NULL, $variable = NULL, $account = NULL, $async = NULL, $actionid = NULL){ |
|
| 801 | + function Originate($channel, $exten = NULL, $context = NULL, $priority = NULL, $application = NULL, $data = NULL, $timeout = NULL, $callerid = NULL, $variable = NULL, $account = NULL, $async = NULL, $actionid = NULL) { |
|
| 802 | 802 | $parameters = array('Channel' => $channel); |
| 803 | 803 | |
| 804 | 804 | if ($exten) $parameters['Exten'] = $exten; |
@@ -826,12 +826,12 @@ discard block |
||
| 826 | 826 | * @param string $parkinglot message matching variable |
| 827 | 827 | * @return array |
| 828 | 828 | */ |
| 829 | - function ParkedCalls($parkinglot = NULL, $actionid = NULL){ |
|
| 829 | + function ParkedCalls($parkinglot = NULL, $actionid = NULL) { |
|
| 830 | 830 | $parameters = []; |
| 831 | - if ($actionid){ |
|
| 831 | + if ($actionid) { |
|
| 832 | 832 | $parameters['ActionID'] = $actionid; |
| 833 | 833 | } |
| 834 | - if ($parkinglot){ |
|
| 834 | + if ($parkinglot) { |
|
| 835 | 835 | $parameters['ParkingLot'] = $parkinglot; |
| 836 | 836 | } |
| 837 | 837 | $result = $this->send_request_timeout('ParkedCalls', $parameters); |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | * |
| 845 | 845 | * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Ping |
| 846 | 846 | */ |
| 847 | - function Ping(){ |
|
| 847 | + function Ping() { |
|
| 848 | 848 | return $this->send_request_timeout('Ping'); |
| 849 | 849 | } |
| 850 | 850 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | * @param integer $penalty |
| 858 | 858 | * @return array |
| 859 | 859 | */ |
| 860 | - function QueueAdd($queue, $interface, $penalty = 0){ |
|
| 860 | + function QueueAdd($queue, $interface, $penalty = 0) { |
|
| 861 | 861 | $parameters = array('Queue' => $queue, 'Interface' => $interface); |
| 862 | 862 | if ($penalty) $parameters['Penalty'] = $penalty; |
| 863 | 863 | return $this->send_request('QueueAdd', $parameters); |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | * @param string $interface |
| 872 | 872 | * @return array |
| 873 | 873 | */ |
| 874 | - function QueueRemove($queue, $interface){ |
|
| 874 | + function QueueRemove($queue, $interface) { |
|
| 875 | 875 | return $this->send_request('QueueRemove', array('Queue' => $queue, 'Interface' => $interface)); |
| 876 | 876 | } |
| 877 | 877 | |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | * |
| 881 | 881 | * @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Queues |
| 882 | 882 | */ |
| 883 | - function Queues(){ |
|
| 883 | + function Queues() { |
|
| 884 | 884 | return $this->send_request('Queues'); |
| 885 | 885 | } |
| 886 | 886 | |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | * @param string $actionid message matching variable |
| 892 | 892 | * @return array |
| 893 | 893 | */ |
| 894 | - function QueueStatus($actionid = NULL){ |
|
| 894 | + function QueueStatus($actionid = NULL) { |
|
| 895 | 895 | if ($actionid) return $this->send_request('QueueStatus', array('ActionID' => $actionid)); else |
| 896 | 896 | return $this->send_request('QueueStatus'); |
| 897 | 897 | } |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | * @param string $priority |
| 908 | 908 | * @return array |
| 909 | 909 | */ |
| 910 | - function Redirect($channel, $extrachannel, $exten, $context, $priority){ |
|
| 910 | + function Redirect($channel, $extrachannel, $exten, $context, $priority) { |
|
| 911 | 911 | return $this->send_request('Redirect', array('Channel' => $channel, 'ExtraChannel' => $extrachannel, 'Exten' => $exten, 'Context' => $context, 'Priority' => $priority)); |
| 912 | 912 | } |
| 913 | 913 | |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | * @param string $append |
| 921 | 921 | * @return array |
| 922 | 922 | */ |
| 923 | - function SetCDRUserField($userfield, $channel, $append = NULL){ |
|
| 923 | + function SetCDRUserField($userfield, $channel, $append = NULL) { |
|
| 924 | 924 | $parameters = array('UserField' => $userfield, 'Channel' => $channel); |
| 925 | 925 | if ($append) $parameters['Append'] = $append; |
| 926 | 926 | return $this->send_request('SetCDRUserField', $parameters); |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | * @param string $value |
| 936 | 936 | * @return array |
| 937 | 937 | */ |
| 938 | - function SetVar($channel, $variable, $value){ |
|
| 938 | + function SetVar($channel, $variable, $value) { |
|
| 939 | 939 | return $this->send_request('SetVar', array('Channel' => $channel, 'Variable' => $variable, 'Value' => $value)); |
| 940 | 940 | } |
| 941 | 941 | |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | * @param string $actionid message matching variable |
| 948 | 948 | * @return array |
| 949 | 949 | */ |
| 950 | - function Status($channel, $actionid = NULL){ |
|
| 950 | + function Status($channel, $actionid = NULL) { |
|
| 951 | 951 | $parameters = array('Channel' => $channel); |
| 952 | 952 | if ($actionid) $parameters['ActionID'] = $actionid; |
| 953 | 953 | return $this->send_request('Status', $parameters); |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | * @param string $channel |
| 961 | 961 | * @return array |
| 962 | 962 | */ |
| 963 | - function StopMonitor($channel){ |
|
| 963 | + function StopMonitor($channel) { |
|
| 964 | 964 | return $this->send_request('StopMonitor', array('Channel' => $channel)); |
| 965 | 965 | } |
| 966 | 966 | |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | * Полученире текущих регистраций. |
| 973 | 973 | * @return array |
| 974 | 974 | */ |
| 975 | - public function get_sip_registry(){ |
|
| 975 | + public function get_sip_registry() { |
|
| 976 | 976 | $peers = array(); |
| 977 | 977 | $result = $this->send_request_timeout('SIPshowregistry'); |
| 978 | 978 | if ($result['data'] !== null && $result['data']['RegistryEntry'] !== null) { |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | public function get_pj_sip_registry():array { |
| 996 | 996 | $peers = []; |
| 997 | 997 | $result = $this->send_request_timeout('PJSIPShowRegistrationsOutbound'); |
| 998 | - if ( isset($result['data']['OutboundRegistrationDetail']) ) { |
|
| 998 | + if (isset($result['data']['OutboundRegistrationDetail'])) { |
|
| 999 | 999 | foreach ($result['data']['OutboundRegistrationDetail'] as $peer) { |
| 1000 | 1000 | [$sip, $host, $port] = explode(':', $peer['ServerUri']); |
| 1001 | 1001 | $peers[] = array( |
@@ -1017,9 +1017,9 @@ discard block |
||
| 1017 | 1017 | public function get_pj_sip_peers():array { |
| 1018 | 1018 | $peers = []; |
| 1019 | 1019 | $result = $this->send_request_timeout('PJSIPShowEndpoints'); |
| 1020 | - if ( isset($result['data']['EndpointList']) ) { |
|
| 1020 | + if (isset($result['data']['EndpointList'])) { |
|
| 1021 | 1021 | foreach ($result['data']['EndpointList'] as $peer) { |
| 1022 | - if($peer['ObjectName'] === 'anonymous'){ |
|
| 1022 | + if ($peer['ObjectName'] === 'anonymous') { |
|
| 1023 | 1023 | continue; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | * Получение статусов пиров. |
| 1043 | 1043 | * @return array |
| 1044 | 1044 | */ |
| 1045 | - function get_sip_peers(){ |
|
| 1045 | + function get_sip_peers() { |
|
| 1046 | 1046 | $peers = array(); |
| 1047 | 1047 | $res = $this->send_request_timeout('SIPpeers'); |
| 1048 | 1048 | if (isset($res['data']) && $res['data'] != null && $res['data']['PeerEntry'] != null) { |
@@ -1061,12 +1061,12 @@ discard block |
||
| 1061 | 1061 | * @param $peer |
| 1062 | 1062 | * @return array |
| 1063 | 1063 | */ |
| 1064 | - function get_sip_peer($peer){ |
|
| 1064 | + function get_sip_peer($peer) { |
|
| 1065 | 1065 | $parameters = ['Peer' => trim($peer)]; |
| 1066 | 1066 | $res = $this->send_request_timeout('SIPshowpeer', $parameters); |
| 1067 | 1067 | $arr_status = explode(' ', $res['Status']); |
| 1068 | 1068 | $res['state'] = strtoupper($arr_status[0]); |
| 1069 | - $res['time-response']= strtoupper(str_replace(['(', ')'],'',$arr_status[1])); |
|
| 1069 | + $res['time-response'] = strtoupper(str_replace(['(', ')'], '', $arr_status[1])); |
|
| 1070 | 1070 | return $res; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
@@ -1075,15 +1075,15 @@ discard block |
||
| 1075 | 1075 | * @param $peer |
| 1076 | 1076 | * @return array |
| 1077 | 1077 | */ |
| 1078 | - function get_pj_sip_peer($peer){ |
|
| 1078 | + function get_pj_sip_peer($peer) { |
|
| 1079 | 1079 | $result = []; |
| 1080 | 1080 | $parameters = ['Endpoint' => trim($peer)]; |
| 1081 | 1081 | $res = $this->send_request_timeout('PJSIPShowEndpoint', $parameters); |
| 1082 | 1082 | |
| 1083 | - if(isset($res['data']['ContactStatusDetail'])){ |
|
| 1083 | + if (isset($res['data']['ContactStatusDetail'])) { |
|
| 1084 | 1084 | $result = $res['data']['ContactStatusDetail']; |
| 1085 | 1085 | } |
| 1086 | - $result['state'] = isset($result['URI']) && !empty($result['URI']) ? 'OK' : 'UNKNOWN'; |
|
| 1086 | + $result['state'] = isset($result['URI']) && !empty($result['URI']) ? 'OK' : 'UNKNOWN'; |
|
| 1087 | 1087 | return $result; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
@@ -1092,17 +1092,17 @@ discard block |
||
| 1092 | 1092 | * @param array $vars |
| 1093 | 1093 | * @return array |
| 1094 | 1094 | */ |
| 1095 | - public function meetMeCollectInfo($conference, $vars=[]):array { |
|
| 1095 | + public function meetMeCollectInfo($conference, $vars = []):array { |
|
| 1096 | 1096 | $result = []; |
| 1097 | 1097 | $conf_data = $this->MeetmeList($conference); |
| 1098 | - if(!isset($conf_data['data']['MeetmeList'])){ |
|
| 1098 | + if (!isset($conf_data['data']['MeetmeList'])) { |
|
| 1099 | 1099 | return $result; |
| 1100 | 1100 | } |
| 1101 | - foreach ($conf_data['data']['MeetmeList'] as $user_data){ |
|
| 1102 | - $user_data['linkedid'] = $this->GetVar($user_data['Channel'], 'CDR(linkedid)', null, false); |
|
| 1101 | + foreach ($conf_data['data']['MeetmeList'] as $user_data) { |
|
| 1102 | + $user_data['linkedid'] = $this->GetVar($user_data['Channel'], 'CDR(linkedid)', null, false); |
|
| 1103 | 1103 | $user_data['meetme_id'] = $this->GetVar($user_data['Channel'], 'MEETMEUNIQUEID', null, false); |
| 1104 | 1104 | |
| 1105 | - foreach ($vars as $var){ |
|
| 1105 | + foreach ($vars as $var) { |
|
| 1106 | 1106 | $user_data[$var] = $this->GetVar($user_data['Channel'], $var, null, false); |
| 1107 | 1107 | } |
| 1108 | 1108 | |
@@ -1127,14 +1127,14 @@ discard block |
||
| 1127 | 1127 | * @param string $message |
| 1128 | 1128 | * @param integer $level from 1 to 4 |
| 1129 | 1129 | */ |
| 1130 | - function log($message, $level = 1){ |
|
| 1130 | + function log($message, $level = 1) { |
|
| 1131 | 1131 | if ($this->pagi != false) $this->pagi->conlog($message, $level); |
| 1132 | 1132 | |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - function microtime_float(){ |
|
| 1135 | + function microtime_float() { |
|
| 1136 | 1136 | list($usec, $sec) = explode(" ", microtime()); |
| 1137 | - return ((float)$usec + (float)$sec); |
|
| 1137 | + return ((float) $usec + (float) $sec); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | /** |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | * @param string | array $callback function |
| 1178 | 1178 | * @return boolean sucess |
| 1179 | 1179 | */ |
| 1180 | - function add_event_handler($event, $callback){ |
|
| 1180 | + function add_event_handler($event, $callback) { |
|
| 1181 | 1181 | $event = strtolower($event); |
| 1182 | 1182 | if (isset($this->event_handlers[$event])) { |
| 1183 | 1183 | $this->log("$event handler is already defined, not over-writing."); |
@@ -1194,21 +1194,21 @@ discard block |
||
| 1194 | 1194 | * @param array $parameters |
| 1195 | 1195 | * @return mixed result of event handler or false if no handler was found |
| 1196 | 1196 | */ |
| 1197 | - function process_event($parameters){ |
|
| 1197 | + function process_event($parameters) { |
|
| 1198 | 1198 | $ret = false; |
| 1199 | 1199 | $e = strtolower($parameters['Event']); |
| 1200 | 1200 | $this->log("Got event.. $e"); |
| 1201 | 1201 | |
| 1202 | 1202 | $handler = ''; |
| 1203 | - if (isset($this->event_handlers[$e])){ |
|
| 1203 | + if (isset($this->event_handlers[$e])) { |
|
| 1204 | 1204 | $handler = $this->event_handlers[$e]; |
| 1205 | 1205 | } |
| 1206 | - elseif (isset($this->event_handlers['*'])){ |
|
| 1206 | + elseif (isset($this->event_handlers['*'])) { |
|
| 1207 | 1207 | $handler = $this->event_handlers['*']; |
| 1208 | 1208 | } |
| 1209 | - if(is_array($handler)){ |
|
| 1209 | + if (is_array($handler)) { |
|
| 1210 | 1210 | call_user_func($handler, $parameters); |
| 1211 | - }else if (function_exists($handler)) { |
|
| 1211 | + } else if (function_exists($handler)) { |
|
| 1212 | 1212 | $this->log("Execute handler $handler"); |
| 1213 | 1213 | $ret = $handler($e, $parameters, $this->server, $this->port); |
| 1214 | 1214 | } else |
@@ -90,16 +90,30 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | function __construct($config = NULL, $optconfig = array()){ |
| 92 | 92 | // load config |
| 93 | - if (!is_null($config) && file_exists($config)) $this->config = parse_ini_file($config, true); elseif (file_exists(DEFAULT_PHPAGI_CONFIG)) $this->config = parse_ini_file(DEFAULT_PHPAGI_CONFIG, true); |
|
| 93 | + if (!is_null($config) && file_exists($config)) { |
|
| 94 | + $this->config = parse_ini_file($config, true); |
|
| 95 | + } elseif (file_exists(DEFAULT_PHPAGI_CONFIG)) { |
|
| 96 | + $this->config = parse_ini_file(DEFAULT_PHPAGI_CONFIG, true); |
|
| 97 | + } |
|
| 94 | 98 | |
| 95 | 99 | // If optconfig is specified, stuff vals and vars into 'asmanager' config array. |
| 96 | - foreach ($optconfig as $var => $val) $this->config['asmanager'][$var] = $val; |
|
| 100 | + foreach ($optconfig as $var => $val) { |
|
| 101 | + $this->config['asmanager'][$var] = $val; |
|
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | // add default values to config for uninitialized values |
| 99 | - if (!isset($this->config['asmanager']['server'])) $this->config['asmanager']['server'] = 'localhost'; |
|
| 100 | - if (!isset($this->config['asmanager']['port'])) $this->config['asmanager']['port'] = 5038; |
|
| 101 | - if (!isset($this->config['asmanager']['username'])) $this->config['asmanager']['username'] = 'phpagi'; |
|
| 102 | - if (!isset($this->config['asmanager']['secret'])) $this->config['asmanager']['secret'] = 'phpagi'; |
|
| 105 | + if (!isset($this->config['asmanager']['server'])) { |
|
| 106 | + $this->config['asmanager']['server'] = 'localhost'; |
|
| 107 | + } |
|
| 108 | + if (!isset($this->config['asmanager']['port'])) { |
|
| 109 | + $this->config['asmanager']['port'] = 5038; |
|
| 110 | + } |
|
| 111 | + if (!isset($this->config['asmanager']['username'])) { |
|
| 112 | + $this->config['asmanager']['username'] = 'phpagi'; |
|
| 113 | + } |
|
| 114 | + if (!isset($this->config['asmanager']['secret'])) { |
|
| 115 | + $this->config['asmanager']['secret'] = 'phpagi'; |
|
| 116 | + } |
|
| 103 | 117 | } |
| 104 | 118 | |
| 105 | 119 | /** |
@@ -111,7 +125,9 @@ discard block |
||
| 111 | 125 | */ |
| 112 | 126 | function send_request($action, $parameters = array()){ |
| 113 | 127 | $req = "Action: $action\r\n"; |
| 114 | - foreach ($parameters as $var => $val) $req .= "$var: $val\r\n"; |
|
| 128 | + foreach ($parameters as $var => $val) { |
|
| 129 | + $req .= "$var: $val\r\n"; |
|
| 130 | + } |
|
| 115 | 131 | $req .= "\r\n"; |
| 116 | 132 | if(!is_resource($this->socket)){ |
| 117 | 133 | return array(); |
@@ -129,7 +145,9 @@ discard block |
||
| 129 | 145 | */ |
| 130 | 146 | function send_request_timeout($action, $parameters = array()){ |
| 131 | 147 | $req = "Action: $action\r\n"; |
| 132 | - foreach ($parameters as $var => $val) $req .= "$var: $val\r\n"; |
|
| 148 | + foreach ($parameters as $var => $val) { |
|
| 149 | + $req .= "$var: $val\r\n"; |
|
| 150 | + } |
|
| 133 | 151 | $req .= "\r\n"; |
| 134 | 152 | if(!is_resource($this->socket)){ |
| 135 | 153 | return array(); |
@@ -153,7 +171,9 @@ discard block |
||
| 153 | 171 | 'Action' => 'UserEvent', |
| 154 | 172 | 'UserEvent' => "{$pingname}Ping" |
| 155 | 173 | ); |
| 156 | - foreach ($parameters as $var => $val) $req .= "$var: $val\r\n"; |
|
| 174 | + foreach ($parameters as $var => $val) { |
|
| 175 | + $req .= "$var: $val\r\n"; |
|
| 176 | + } |
|
| 157 | 177 | $req .= "\r\n"; |
| 158 | 178 | if(!is_resource($this->socket)){ |
| 159 | 179 | return array(); |
@@ -186,8 +206,7 @@ discard block |
||
| 186 | 206 | |
| 187 | 207 | if($type == '' && count($this->Ping())==0){ |
| 188 | 208 | $timeout = true; |
| 189 | - } |
|
| 190 | - else if('event' == $type && $parameters['Event'] == 'UserEvent' && "{$pingname}Pong" == $parameters['UserEvent']){ |
|
| 209 | + } else if('event' == $type && $parameters['Event'] == 'UserEvent' && "{$pingname}Pong" == $parameters['UserEvent']){ |
|
| 191 | 210 | // Ответ получен. |
| 192 | 211 | $result = true; |
| 193 | 212 | break; |
@@ -221,7 +240,7 @@ discard block |
||
| 221 | 240 | if (count($m)>0) { |
| 222 | 241 | if($event_as_array){ |
| 223 | 242 | $parameters['data'][$m['Event']][] = $m; |
| 224 | - }else{ |
|
| 243 | + } else{ |
|
| 225 | 244 | $parameters['data'][$m['Event']] = $m; |
| 226 | 245 | } |
| 227 | 246 | } |
@@ -346,7 +365,7 @@ discard block |
||
| 346 | 365 | $parameters = []; |
| 347 | 366 | try{ |
| 348 | 367 | $buffer = trim(@fgets($this->socket, 4096)); |
| 349 | - }catch (Exception $e){ |
|
| 368 | + } catch (Exception $e){ |
|
| 350 | 369 | return false; |
| 351 | 370 | } |
| 352 | 371 | while ($buffer != '') { |
@@ -361,8 +380,7 @@ discard block |
||
| 361 | 380 | } |
| 362 | 381 | if($type == '' && count($this->Ping())==0){ |
| 363 | 382 | $timeout = $allow_timeout; |
| 364 | - } |
|
| 365 | - else if('event' == $type){ |
|
| 383 | + } else if('event' == $type){ |
|
| 366 | 384 | $this->process_event($parameters); |
| 367 | 385 | } |
| 368 | 386 | } while (!$timeout); |
@@ -382,9 +400,15 @@ discard block |
||
| 382 | 400 | */ |
| 383 | 401 | function connect($server = NULL, $username = NULL, $secret = NULL, $events = 'on'){ |
| 384 | 402 | // use config if not specified |
| 385 | - if (is_null($server)) $server = $this->config['asmanager']['server']; |
|
| 386 | - if (is_null($username)) $username = $this->config['asmanager']['username']; |
|
| 387 | - if (is_null($secret)) $secret = $this->config['asmanager']['secret']; |
|
| 403 | + if (is_null($server)) { |
|
| 404 | + $server = $this->config['asmanager']['server']; |
|
| 405 | + } |
|
| 406 | + if (is_null($username)) { |
|
| 407 | + $username = $this->config['asmanager']['username']; |
|
| 408 | + } |
|
| 409 | + if (is_null($secret)) { |
|
| 410 | + $secret = $this->config['asmanager']['secret']; |
|
| 411 | + } |
|
| 388 | 412 | |
| 389 | 413 | // get port from server if specified |
| 390 | 414 | if (strpos($server, ':') !== false) { |
@@ -438,7 +462,9 @@ discard block |
||
| 438 | 462 | * @example examples/sip_show_peer.php Get information about a sip peer |
| 439 | 463 | */ |
| 440 | 464 | function disconnect(){ |
| 441 | - if ($this->_logged_in == TRUE) $this->logoff(); |
|
| 465 | + if ($this->_logged_in == TRUE) { |
|
| 466 | + $this->logoff(); |
|
| 467 | + } |
|
| 442 | 468 | if(is_resource($this->socket)){ |
| 443 | 469 | fclose($this->socket); |
| 444 | 470 | } |
@@ -486,7 +512,9 @@ discard block |
||
| 486 | 512 | */ |
| 487 | 513 | function Command($command, $actionid = NULL){ |
| 488 | 514 | $parameters = array('Command' => $command); |
| 489 | - if ($actionid) $parameters['ActionID'] = $actionid; |
|
| 515 | + if ($actionid) { |
|
| 516 | + $parameters['ActionID'] = $actionid; |
|
| 517 | + } |
|
| 490 | 518 | return $this->send_request('Command', $parameters); |
| 491 | 519 | } |
| 492 | 520 | |
@@ -512,7 +540,9 @@ discard block |
||
| 512 | 540 | */ |
| 513 | 541 | function ExtensionState($exten, $context, $actionid = NULL){ |
| 514 | 542 | $parameters = array('Exten' => $exten, 'Context' => $context); |
| 515 | - if ($actionid) $parameters['ActionID'] = $actionid; |
|
| 543 | + if ($actionid) { |
|
| 544 | + $parameters['ActionID'] = $actionid; |
|
| 545 | + } |
|
| 516 | 546 | return $this->send_request('ExtensionState', $parameters); |
| 517 | 547 | } |
| 518 | 548 | |
@@ -559,7 +589,7 @@ discard block |
||
| 559 | 589 | continue; |
| 560 | 590 | } |
| 561 | 591 | $channels_id[$chan['Linkedid']][] = $chan['Channel']; |
| 562 | - }else{ |
|
| 592 | + } else{ |
|
| 563 | 593 | $channels_id[] = $chan['Channel']; |
| 564 | 594 | } |
| 565 | 595 | } |
@@ -611,8 +641,11 @@ discard block |
||
| 611 | 641 | * @return array |
| 612 | 642 | */ |
| 613 | 643 | function ListCommands($actionid = NULL){ |
| 614 | - if ($actionid) return $this->send_request('ListCommands', array('ActionID' => $actionid)); else |
|
| 615 | - return $this->send_request('ListCommands'); |
|
| 644 | + if ($actionid) { |
|
| 645 | + return $this->send_request('ListCommands', array('ActionID' => $actionid)); |
|
| 646 | + } else { |
|
| 647 | + return $this->send_request('ListCommands'); |
|
| 648 | + } |
|
| 616 | 649 | } |
| 617 | 650 | |
| 618 | 651 | /** |
@@ -651,7 +684,9 @@ discard block |
||
| 651 | 684 | */ |
| 652 | 685 | function MailboxCount($mailbox, $actionid = NULL){ |
| 653 | 686 | $parameters = array('Mailbox' => $mailbox); |
| 654 | - if ($actionid) $parameters['ActionID'] = $actionid; |
|
| 687 | + if ($actionid) { |
|
| 688 | + $parameters['ActionID'] = $actionid; |
|
| 689 | + } |
|
| 655 | 690 | return $this->send_request('MailboxCount', $parameters); |
| 656 | 691 | } |
| 657 | 692 | |
@@ -670,7 +705,9 @@ discard block |
||
| 670 | 705 | */ |
| 671 | 706 | function MailboxStatus($mailbox, $actionid = NULL){ |
| 672 | 707 | $parameters = array('Mailbox' => $mailbox); |
| 673 | - if ($actionid) $parameters['ActionID'] = $actionid; |
|
| 708 | + if ($actionid) { |
|
| 709 | + $parameters['ActionID'] = $actionid; |
|
| 710 | + } |
|
| 674 | 711 | return $this->send_request('MailboxStatus', $parameters); |
| 675 | 712 | } |
| 676 | 713 | |
@@ -686,9 +723,15 @@ discard block |
||
| 686 | 723 | */ |
| 687 | 724 | function Monitor($channel, $file = NULL, $format = NULL, $mix = NULL){ |
| 688 | 725 | $parameters = array('Channel' => $channel); |
| 689 | - if ($file) $parameters['File'] = $file; |
|
| 690 | - if ($format) $parameters['Format'] = $format; |
|
| 691 | - if (!is_null($file)) $parameters['Mix'] = ($mix) ? 'true' : 'false'; |
|
| 726 | + if ($file) { |
|
| 727 | + $parameters['File'] = $file; |
|
| 728 | + } |
|
| 729 | + if ($format) { |
|
| 730 | + $parameters['Format'] = $format; |
|
| 731 | + } |
|
| 732 | + if (!is_null($file)) { |
|
| 733 | + $parameters['Mix'] = ($mix) ? 'true' : 'false'; |
|
| 734 | + } |
|
| 692 | 735 | return $this->send_request('Monitor', $parameters); |
| 693 | 736 | } |
| 694 | 737 | |
@@ -801,19 +844,41 @@ discard block |
||
| 801 | 844 | function Originate($channel, $exten = NULL, $context = NULL, $priority = NULL, $application = NULL, $data = NULL, $timeout = NULL, $callerid = NULL, $variable = NULL, $account = NULL, $async = NULL, $actionid = NULL){ |
| 802 | 845 | $parameters = array('Channel' => $channel); |
| 803 | 846 | |
| 804 | - if ($exten) $parameters['Exten'] = $exten; |
|
| 805 | - if ($context) $parameters['Context'] = $context; |
|
| 806 | - if ($priority) $parameters['Priority'] = $priority; |
|
| 847 | + if ($exten) { |
|
| 848 | + $parameters['Exten'] = $exten; |
|
| 849 | + } |
|
| 850 | + if ($context) { |
|
| 851 | + $parameters['Context'] = $context; |
|
| 852 | + } |
|
| 853 | + if ($priority) { |
|
| 854 | + $parameters['Priority'] = $priority; |
|
| 855 | + } |
|
| 807 | 856 | |
| 808 | - if ($application) $parameters['Application'] = $application; |
|
| 809 | - if ($data) $parameters['Data'] = $data; |
|
| 857 | + if ($application) { |
|
| 858 | + $parameters['Application'] = $application; |
|
| 859 | + } |
|
| 860 | + if ($data) { |
|
| 861 | + $parameters['Data'] = $data; |
|
| 862 | + } |
|
| 810 | 863 | |
| 811 | - if ($timeout) $parameters['Timeout'] = $timeout; |
|
| 812 | - if ($callerid) $parameters['CallerID'] = $callerid; |
|
| 813 | - if ($variable) $parameters['Variable'] = $variable; |
|
| 814 | - if ($account) $parameters['Account'] = $account; |
|
| 815 | - if (!is_null($async)) $parameters['Async'] = ($async) ? 'true' : 'false'; |
|
| 816 | - if ($actionid) $parameters['ActionID'] = $actionid; |
|
| 864 | + if ($timeout) { |
|
| 865 | + $parameters['Timeout'] = $timeout; |
|
| 866 | + } |
|
| 867 | + if ($callerid) { |
|
| 868 | + $parameters['CallerID'] = $callerid; |
|
| 869 | + } |
|
| 870 | + if ($variable) { |
|
| 871 | + $parameters['Variable'] = $variable; |
|
| 872 | + } |
|
| 873 | + if ($account) { |
|
| 874 | + $parameters['Account'] = $account; |
|
| 875 | + } |
|
| 876 | + if (!is_null($async)) { |
|
| 877 | + $parameters['Async'] = ($async) ? 'true' : 'false'; |
|
| 878 | + } |
|
| 879 | + if ($actionid) { |
|
| 880 | + $parameters['ActionID'] = $actionid; |
|
| 881 | + } |
|
| 817 | 882 | |
| 818 | 883 | return $this->send_request('Originate', $parameters); |
| 819 | 884 | } |
@@ -859,7 +924,9 @@ discard block |
||
| 859 | 924 | */ |
| 860 | 925 | function QueueAdd($queue, $interface, $penalty = 0){ |
| 861 | 926 | $parameters = array('Queue' => $queue, 'Interface' => $interface); |
| 862 | - if ($penalty) $parameters['Penalty'] = $penalty; |
|
| 927 | + if ($penalty) { |
|
| 928 | + $parameters['Penalty'] = $penalty; |
|
| 929 | + } |
|
| 863 | 930 | return $this->send_request('QueueAdd', $parameters); |
| 864 | 931 | } |
| 865 | 932 | |
@@ -892,8 +959,11 @@ discard block |
||
| 892 | 959 | * @return array |
| 893 | 960 | */ |
| 894 | 961 | function QueueStatus($actionid = NULL){ |
| 895 | - if ($actionid) return $this->send_request('QueueStatus', array('ActionID' => $actionid)); else |
|
| 896 | - return $this->send_request('QueueStatus'); |
|
| 962 | + if ($actionid) { |
|
| 963 | + return $this->send_request('QueueStatus', array('ActionID' => $actionid)); |
|
| 964 | + } else { |
|
| 965 | + return $this->send_request('QueueStatus'); |
|
| 966 | + } |
|
| 897 | 967 | } |
| 898 | 968 | |
| 899 | 969 | /** |
@@ -922,7 +992,9 @@ discard block |
||
| 922 | 992 | */ |
| 923 | 993 | function SetCDRUserField($userfield, $channel, $append = NULL){ |
| 924 | 994 | $parameters = array('UserField' => $userfield, 'Channel' => $channel); |
| 925 | - if ($append) $parameters['Append'] = $append; |
|
| 995 | + if ($append) { |
|
| 996 | + $parameters['Append'] = $append; |
|
| 997 | + } |
|
| 926 | 998 | return $this->send_request('SetCDRUserField', $parameters); |
| 927 | 999 | } |
| 928 | 1000 | |
@@ -949,7 +1021,9 @@ discard block |
||
| 949 | 1021 | */ |
| 950 | 1022 | function Status($channel, $actionid = NULL){ |
| 951 | 1023 | $parameters = array('Channel' => $channel); |
| 952 | - if ($actionid) $parameters['ActionID'] = $actionid; |
|
| 1024 | + if ($actionid) { |
|
| 1025 | + $parameters['ActionID'] = $actionid; |
|
| 1026 | + } |
|
| 953 | 1027 | return $this->send_request('Status', $parameters); |
| 954 | 1028 | } |
| 955 | 1029 | |
@@ -1047,7 +1121,9 @@ discard block |
||
| 1047 | 1121 | $res = $this->send_request_timeout('SIPpeers'); |
| 1048 | 1122 | if (isset($res['data']) && $res['data'] != null && $res['data']['PeerEntry'] != null) { |
| 1049 | 1123 | foreach ($res['data']['PeerEntry'] as $peer) { |
| 1050 | - if (!is_numeric($peer['ObjectName'])) continue; |
|
| 1124 | + if (!is_numeric($peer['ObjectName'])) { |
|
| 1125 | + continue; |
|
| 1126 | + } |
|
| 1051 | 1127 | // if ('Unmonitored' == $peer['Status']) continue; |
| 1052 | 1128 | $arr_status = explode(' ', $peer['Status']); |
| 1053 | 1129 | $peers[] = array('id' => $peer['ObjectName'], 'state' => strtoupper($arr_status[0]),); |
@@ -1128,7 +1204,9 @@ discard block |
||
| 1128 | 1204 | * @param integer $level from 1 to 4 |
| 1129 | 1205 | */ |
| 1130 | 1206 | function log($message, $level = 1){ |
| 1131 | - if ($this->pagi != false) $this->pagi->conlog($message, $level); |
|
| 1207 | + if ($this->pagi != false) { |
|
| 1208 | + $this->pagi->conlog($message, $level); |
|
| 1209 | + } |
|
| 1132 | 1210 | |
| 1133 | 1211 | } |
| 1134 | 1212 | |
@@ -1202,17 +1280,17 @@ discard block |
||
| 1202 | 1280 | $handler = ''; |
| 1203 | 1281 | if (isset($this->event_handlers[$e])){ |
| 1204 | 1282 | $handler = $this->event_handlers[$e]; |
| 1205 | - } |
|
| 1206 | - elseif (isset($this->event_handlers['*'])){ |
|
| 1283 | + } elseif (isset($this->event_handlers['*'])){ |
|
| 1207 | 1284 | $handler = $this->event_handlers['*']; |
| 1208 | 1285 | } |
| 1209 | 1286 | if(is_array($handler)){ |
| 1210 | 1287 | call_user_func($handler, $parameters); |
| 1211 | - }else if (function_exists($handler)) { |
|
| 1288 | + } else if (function_exists($handler)) { |
|
| 1212 | 1289 | $this->log("Execute handler $handler"); |
| 1213 | 1290 | $ret = $handler($e, $parameters, $this->server, $this->port); |
| 1214 | - } else |
|
| 1215 | - $this->log("No event handler for event '$e'"); |
|
| 1291 | + } else { |
|
| 1292 | + $this->log("No event handler for event '$e'"); |
|
| 1293 | + } |
|
| 1216 | 1294 | return $ret; |
| 1217 | 1295 | } |
| 1218 | 1296 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | $DIALSTATUS = $agi->get_variable('DIALSTATUS', true); |
| 15 | 15 | $linkedid = $agi->get_variable('CDR(linkedid)', true); |
| 16 | 16 | if($chan === '' && 'ANSWER' === $DIALSTATUS) { |
| 17 | - exit; |
|
| 17 | + exit; |
|
| 18 | 18 | } |
| 19 | 19 | // Обнуляем значение переменной. |
| 20 | 20 | $agi->set_variable('BLINDTRANSFER', ''); |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | $agi = new AGI(); |
| 14 | 14 | $DIALSTATUS = $agi->get_variable('DIALSTATUS', true); |
| 15 | 15 | $linkedid = $agi->get_variable('CDR(linkedid)', true); |
| 16 | -if($chan === '' && 'ANSWER' === $DIALSTATUS) { |
|
| 16 | +if ($chan === '' && 'ANSWER' === $DIALSTATUS) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | // Обнуляем значение переменной. |
| 20 | 20 | $agi->set_variable('BLINDTRANSFER', ''); |
| 21 | 21 | |
| 22 | -try{ |
|
| 22 | +try { |
|
| 23 | 23 | $filter = [ |
| 24 | 24 | '(dst_chan=:chan: OR src_chan=:chan:) AND linkedid=:linkedid:', |
| 25 | 25 | 'bind' => ['chan' => $chan, 'linkedid' => $linkedid], |
@@ -28,18 +28,18 @@ discard block |
||
| 28 | 28 | ]; |
| 29 | 29 | $client = new BeanstalkClient('select_cdr'); |
| 30 | 30 | $message = $client->request(json_encode($filter), 2); |
| 31 | - if($message !== false){ |
|
| 31 | + if ($message !== false) { |
|
| 32 | 32 | $res = json_decode($client->getBody(), true); |
| 33 | - if(count($res) === 1){ |
|
| 34 | - $exten = ($res[0]['src_chan'] === $chan)?$res[0]['src_num']:$res[0]['dst_num']; |
|
| 33 | + if (count($res) === 1) { |
|
| 34 | + $exten = ($res[0]['src_chan'] === $chan) ? $res[0]['src_num'] : $res[0]['dst_num']; |
|
| 35 | 35 | sleep(2); |
| 36 | 36 | $agi->set_variable('pt1c_UNIQUEID', ''); |
| 37 | 37 | $agi->exec_goto('internal', $exten, '1'); |
| 38 | 38 | } |
| 39 | - }else{ |
|
| 39 | + } else { |
|
| 40 | 40 | Util::sys_log_msg('CheckRedirect', "Error get data from queue 'select_cdr'. "); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -}catch (Exception $e){ |
|
| 43 | +} catch (Exception $e) { |
|
| 44 | 44 | Util::sys_log_msg('CheckRedirect', $e->getMessage()); |
| 45 | 45 | } |
@@ -36,10 +36,10 @@ |
||
| 36 | 36 | $agi->set_variable('pt1c_UNIQUEID', ''); |
| 37 | 37 | $agi->exec_goto('internal', $exten, '1'); |
| 38 | 38 | } |
| 39 | - }else{ |
|
| 39 | + } else{ |
|
| 40 | 40 | Util::sys_log_msg('CheckRedirect', "Error get data from queue 'select_cdr'. "); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -}catch (Exception $e){ |
|
| 43 | +} catch (Exception $e){ |
|
| 44 | 44 | Util::sys_log_msg('CheckRedirect', $e->getMessage()); |
| 45 | 45 | } |
@@ -1,79 +1,79 @@ |
||
| 1 | 1 | #!/usr/local/bin/php -q |
| 2 | 2 | <?php |
| 3 | - /** |
|
| 4 | - * phpagi-fastagi.php : PHP FastAGI bootstrap |
|
| 5 | - * Website: http://phpagi.sourceforge.net |
|
| 6 | - * |
|
| 7 | - * $Id: phpagi-fastagi.php,v 1.2 2005/05/25 18:43:48 pinhole Exp $ |
|
| 8 | - * |
|
| 9 | - * Copyright (c) 2004, 2005 Matthew Asham <[email protected]>, David Eder <[email protected]> |
|
| 10 | - * All Rights Reserved. |
|
| 11 | - * |
|
| 12 | - * This software is released under the terms of the GNU Lesser General Public License v2.1 |
|
| 13 | - * A copy of which is available from http://www.gnu.org/copyleft/lesser.html |
|
| 14 | - * |
|
| 15 | - * We would be happy to list your phpagi based application on the phpagi |
|
| 16 | - * website. Drop me an Email if you'd like us to list your program. |
|
| 17 | - * |
|
| 18 | - * @package phpAGI |
|
| 19 | - * @version 2.0 |
|
| 20 | - * @example docs/fastagi.xinetd Example xinetd config file |
|
| 21 | - */ |
|
| 3 | + /** |
|
| 4 | + * phpagi-fastagi.php : PHP FastAGI bootstrap |
|
| 5 | + * Website: http://phpagi.sourceforge.net |
|
| 6 | + * |
|
| 7 | + * $Id: phpagi-fastagi.php,v 1.2 2005/05/25 18:43:48 pinhole Exp $ |
|
| 8 | + * |
|
| 9 | + * Copyright (c) 2004, 2005 Matthew Asham <[email protected]>, David Eder <[email protected]> |
|
| 10 | + * All Rights Reserved. |
|
| 11 | + * |
|
| 12 | + * This software is released under the terms of the GNU Lesser General Public License v2.1 |
|
| 13 | + * A copy of which is available from http://www.gnu.org/copyleft/lesser.html |
|
| 14 | + * |
|
| 15 | + * We would be happy to list your phpagi based application on the phpagi |
|
| 16 | + * website. Drop me an Email if you'd like us to list your program. |
|
| 17 | + * |
|
| 18 | + * @package phpAGI |
|
| 19 | + * @version 2.0 |
|
| 20 | + * @example docs/fastagi.xinetd Example xinetd config file |
|
| 21 | + */ |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Written for PHP 4.3.4, should work with older PHP 4.x versions. |
|
| 25 | - * Please submit bug reports, patches, etc to http://sourceforge.net/projects/phpagi/ |
|
| 26 | - * Gracias. :) |
|
| 27 | - * |
|
| 28 | - */ |
|
| 23 | + /** |
|
| 24 | + * Written for PHP 4.3.4, should work with older PHP 4.x versions. |
|
| 25 | + * Please submit bug reports, patches, etc to http://sourceforge.net/projects/phpagi/ |
|
| 26 | + * Gracias. :) |
|
| 27 | + * |
|
| 28 | + */ |
|
| 29 | 29 | |
| 30 | - require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi.php'); |
|
| 30 | + require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi.php'); |
|
| 31 | 31 | |
| 32 | - $fastagi = new AGI(); |
|
| 32 | + $fastagi = new AGI(); |
|
| 33 | 33 | |
| 34 | - $fastagi->verbose(print_r($fastagi, true)); |
|
| 34 | + $fastagi->verbose(print_r($fastagi, true)); |
|
| 35 | 35 | |
| 36 | - if(!isset($fastagi->config['fastagi']['basedir'])) |
|
| 36 | + if(!isset($fastagi->config['fastagi']['basedir'])) |
|
| 37 | 37 | $fastagi->config['fastagi']['basedir'] = dirname(__FILE__); |
| 38 | 38 | |
| 39 | - // perform some security checks |
|
| 39 | + // perform some security checks |
|
| 40 | 40 | |
| 41 | - $script = $fastagi->config['fastagi']['basedir'] . DIRECTORY_SEPARATOR . $fastagi->request['agi_network_script']; |
|
| 41 | + $script = $fastagi->config['fastagi']['basedir'] . DIRECTORY_SEPARATOR . $fastagi->request['agi_network_script']; |
|
| 42 | 42 | |
| 43 | - // in the same directory (or subdirectory) |
|
| 44 | - $mydir = dirname($fastagi->config['fastagi']['basedir']) . DIRECTORY_SEPARATOR; |
|
| 45 | - $dir = dirname($script) . DIRECTORY_SEPARATOR; |
|
| 46 | - if(substr($dir, 0, strlen($mydir)) != $mydir) |
|
| 47 | - { |
|
| 43 | + // in the same directory (or subdirectory) |
|
| 44 | + $mydir = dirname($fastagi->config['fastagi']['basedir']) . DIRECTORY_SEPARATOR; |
|
| 45 | + $dir = dirname($script) . DIRECTORY_SEPARATOR; |
|
| 46 | + if(substr($dir, 0, strlen($mydir)) != $mydir) |
|
| 47 | + { |
|
| 48 | 48 | $fastagi->conlog("$script is not allowed to execute."); |
| 49 | 49 | exit; |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // make sure it exists |
|
| 53 | - if(!file_exists($script)) |
|
| 54 | - { |
|
| 52 | + // make sure it exists |
|
| 53 | + if(!file_exists($script)) |
|
| 54 | + { |
|
| 55 | 55 | $fastagi->conlog("$script does not exist."); |
| 56 | 56 | exit; |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - // drop privileges |
|
| 60 | - if(isset($fastagi->config['fastagi']['setuid']) && $fastagi->config['fastagi']['setuid']) |
|
| 61 | - { |
|
| 59 | + // drop privileges |
|
| 60 | + if(isset($fastagi->config['fastagi']['setuid']) && $fastagi->config['fastagi']['setuid']) |
|
| 61 | + { |
|
| 62 | 62 | $owner = fileowner($script); |
| 63 | 63 | $group = filegroup($script); |
| 64 | 64 | if(!posix_setgid($group) || !posix_setegid($group) || !posix_setuid($owner) || !posix_seteuid($owner)) |
| 65 | 65 | { |
| 66 | - $fastagi->conlog("failed to lower privileges."); |
|
| 67 | - exit; |
|
| 66 | + $fastagi->conlog("failed to lower privileges."); |
|
| 67 | + exit; |
|
| 68 | + } |
|
| 68 | 69 | } |
| 69 | - } |
|
| 70 | 70 | |
| 71 | - // make sure script is still readable |
|
| 72 | - if(!is_readable($script)) |
|
| 73 | - { |
|
| 71 | + // make sure script is still readable |
|
| 72 | + if(!is_readable($script)) |
|
| 73 | + { |
|
| 74 | 74 | $fastagi->conlog("$script is not readable."); |
| 75 | 75 | exit; |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - require_once($script); |
|
| 78 | + require_once($script); |
|
| 79 | 79 | ?> |
@@ -27,41 +27,41 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | - require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi.php'); |
|
| 30 | + require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'phpagi.php'); |
|
| 31 | 31 | |
| 32 | 32 | $fastagi = new AGI(); |
| 33 | 33 | |
| 34 | 34 | $fastagi->verbose(print_r($fastagi, true)); |
| 35 | 35 | |
| 36 | - if(!isset($fastagi->config['fastagi']['basedir'])) |
|
| 36 | + if (!isset($fastagi->config['fastagi']['basedir'])) |
|
| 37 | 37 | $fastagi->config['fastagi']['basedir'] = dirname(__FILE__); |
| 38 | 38 | |
| 39 | 39 | // perform some security checks |
| 40 | 40 | |
| 41 | - $script = $fastagi->config['fastagi']['basedir'] . DIRECTORY_SEPARATOR . $fastagi->request['agi_network_script']; |
|
| 41 | + $script = $fastagi->config['fastagi']['basedir'].DIRECTORY_SEPARATOR.$fastagi->request['agi_network_script']; |
|
| 42 | 42 | |
| 43 | 43 | // in the same directory (or subdirectory) |
| 44 | - $mydir = dirname($fastagi->config['fastagi']['basedir']) . DIRECTORY_SEPARATOR; |
|
| 45 | - $dir = dirname($script) . DIRECTORY_SEPARATOR; |
|
| 46 | - if(substr($dir, 0, strlen($mydir)) != $mydir) |
|
| 44 | + $mydir = dirname($fastagi->config['fastagi']['basedir']).DIRECTORY_SEPARATOR; |
|
| 45 | + $dir = dirname($script).DIRECTORY_SEPARATOR; |
|
| 46 | + if (substr($dir, 0, strlen($mydir)) != $mydir) |
|
| 47 | 47 | { |
| 48 | 48 | $fastagi->conlog("$script is not allowed to execute."); |
| 49 | 49 | exit; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // make sure it exists |
| 53 | - if(!file_exists($script)) |
|
| 53 | + if (!file_exists($script)) |
|
| 54 | 54 | { |
| 55 | 55 | $fastagi->conlog("$script does not exist."); |
| 56 | 56 | exit; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // drop privileges |
| 60 | - if(isset($fastagi->config['fastagi']['setuid']) && $fastagi->config['fastagi']['setuid']) |
|
| 60 | + if (isset($fastagi->config['fastagi']['setuid']) && $fastagi->config['fastagi']['setuid']) |
|
| 61 | 61 | { |
| 62 | 62 | $owner = fileowner($script); |
| 63 | 63 | $group = filegroup($script); |
| 64 | - if(!posix_setgid($group) || !posix_setegid($group) || !posix_setuid($owner) || !posix_seteuid($owner)) |
|
| 64 | + if (!posix_setgid($group) || !posix_setegid($group) || !posix_setuid($owner) || !posix_seteuid($owner)) |
|
| 65 | 65 | { |
| 66 | 66 | $fastagi->conlog("failed to lower privileges."); |
| 67 | 67 | exit; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // make sure script is still readable |
| 72 | - if(!is_readable($script)) |
|
| 72 | + if (!is_readable($script)) |
|
| 73 | 73 | { |
| 74 | 74 | $fastagi->conlog("$script is not readable."); |
| 75 | 75 | exit; |
@@ -33,8 +33,9 @@ |
||
| 33 | 33 | |
| 34 | 34 | $fastagi->verbose(print_r($fastagi, true)); |
| 35 | 35 | |
| 36 | - if(!isset($fastagi->config['fastagi']['basedir'])) |
|
| 37 | - $fastagi->config['fastagi']['basedir'] = dirname(__FILE__); |
|
| 36 | + if(!isset($fastagi->config['fastagi']['basedir'])) { |
|
| 37 | + $fastagi->config['fastagi']['basedir'] = dirname(__FILE__); |
|
| 38 | + } |
|
| 38 | 39 | |
| 39 | 40 | // perform some security checks |
| 40 | 41 | |
@@ -10,12 +10,12 @@ |
||
| 10 | 10 | require_once 'phpagi.php'; |
| 11 | 11 | |
| 12 | 12 | $agi = new AGI(); |
| 13 | -$channel = $agi->get_variable('MASTER_CHANNEL(M_TIMEOUT_CHANNEL)', true); |
|
| 14 | -$FROM_CHAN = $agi->get_variable('FROM_CHAN', true); |
|
| 13 | +$channel = $agi->get_variable('MASTER_CHANNEL(M_TIMEOUT_CHANNEL)', true); |
|
| 14 | +$FROM_CHAN = $agi->get_variable('FROM_CHAN', true); |
|
| 15 | 15 | |
| 16 | 16 | /** @var AGI_AsteriskManager $am */ |
| 17 | 17 | $am = Util::get_am('off'); |
| 18 | -$am->SetVar($channel, 'TIMEOUT(absolute)', '0'); |
|
| 18 | +$am->SetVar($channel, 'TIMEOUT(absolute)', '0'); |
|
| 19 | 19 | $am->SetVar($FROM_CHAN, "MASTER_CHANNEL(M_DIALSTATUS)", 'ANSWER'); |
| 20 | 20 | |
| 21 | 21 | // Перестрахова на случай с перехватом звонка через *8. |
@@ -10,83 +10,83 @@ |
||
| 10 | 10 | * Заглушка для отладки скрипта. |
| 11 | 11 | */ |
| 12 | 12 | class _AGI { |
| 13 | - public function exec($v1, $v2){ |
|
| 14 | - echo "exec($v1, $v2)\n"; |
|
| 15 | - } |
|
| 16 | - public function answer(){ |
|
| 17 | - echo "answer()\n"; |
|
| 18 | - } |
|
| 19 | - public function get_variable($_varName){ |
|
| 13 | + public function exec($v1, $v2){ |
|
| 14 | + echo "exec($v1, $v2)\n"; |
|
| 15 | + } |
|
| 16 | + public function answer(){ |
|
| 17 | + echo "answer()\n"; |
|
| 18 | + } |
|
| 19 | + public function get_variable($_varName){ |
|
| 20 | 20 | |
| 21 | - $value = array(); |
|
| 22 | - $value['result']=1; |
|
| 21 | + $value = array(); |
|
| 22 | + $value['result']=1; |
|
| 23 | 23 | |
| 24 | - if('10000666' == PT1C_SKRIPTNAME){ |
|
| 25 | - switch ($_varName) { |
|
| 26 | - case 'v1': |
|
| 27 | - $value['data']='SIP/204'; |
|
| 28 | - break; |
|
| 29 | - case 'v2': |
|
| 30 | - $value['data']='mikopbx-1558444069.34'; |
|
| 31 | - break; |
|
| 32 | - case 'v3': |
|
| 33 | - $value['data']=''; |
|
| 34 | - break; |
|
| 35 | - case 'v6': |
|
| 36 | - $value['data']='Records'; |
|
| 37 | - break; |
|
| 38 | - case 'ASTSPOOLDIR': |
|
| 39 | - $value['data']='/var/spool/asterisk'; |
|
| 40 | - break; |
|
| 41 | - default: |
|
| 42 | - $value['data']=''; |
|
| 43 | - } |
|
| 44 | - }else if('10000555' == PT1C_SKRIPTNAME){ |
|
| 45 | - switch ($_varName) { |
|
| 46 | - case 'v1': |
|
| 47 | - $value['data']='SIP/201'; |
|
| 48 | - break; |
|
| 49 | - case 'v2': |
|
| 50 | - $value['data']='2017-01-01'; |
|
| 51 | - break; |
|
| 52 | - case 'v3': |
|
| 53 | - $value['data']='2019-01-01'; |
|
| 54 | - break; |
|
| 55 | - case 'v4': |
|
| 56 | - $value['data']='201-89257184254'; |
|
| 57 | - break; |
|
| 58 | - default: |
|
| 59 | - $value['data']=''; |
|
| 60 | - } |
|
| 61 | - }else if('1C_HistoryFax.php' == PT1C_SKRIPTNAME){ |
|
| 62 | - switch ($_varName) { |
|
| 63 | - case 'v1': |
|
| 64 | - $value['data']='SIP/1000'; |
|
| 65 | - break; |
|
| 66 | - case 'v2': |
|
| 67 | - $value['data']='2017-01-01'; |
|
| 68 | - break; |
|
| 69 | - case 'v3': |
|
| 70 | - $value['data']='2019-01-01'; |
|
| 71 | - break; |
|
| 72 | - default: |
|
| 73 | - $value['data']=''; |
|
| 74 | - } |
|
| 75 | - }else if('10000777' == PT1C_SKRIPTNAME){ |
|
| 76 | - switch ($_varName) { |
|
| 77 | - case 'chan': |
|
| 78 | - $value['data']='SIP/204'; |
|
| 79 | - break; |
|
| 80 | - case 'uniqueid1c': |
|
| 81 | - $value['data']='mikopbx-1519992881.0'; |
|
| 82 | - break; |
|
| 83 | - case 'ASTSPOOLDIR': |
|
| 84 | - $value['data']='/var/spool/asterisk'; |
|
| 85 | - break; |
|
| 86 | - default: |
|
| 87 | - $value['data']=''; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - return $value['data']; |
|
| 91 | - } |
|
| 24 | + if('10000666' == PT1C_SKRIPTNAME){ |
|
| 25 | + switch ($_varName) { |
|
| 26 | + case 'v1': |
|
| 27 | + $value['data']='SIP/204'; |
|
| 28 | + break; |
|
| 29 | + case 'v2': |
|
| 30 | + $value['data']='mikopbx-1558444069.34'; |
|
| 31 | + break; |
|
| 32 | + case 'v3': |
|
| 33 | + $value['data']=''; |
|
| 34 | + break; |
|
| 35 | + case 'v6': |
|
| 36 | + $value['data']='Records'; |
|
| 37 | + break; |
|
| 38 | + case 'ASTSPOOLDIR': |
|
| 39 | + $value['data']='/var/spool/asterisk'; |
|
| 40 | + break; |
|
| 41 | + default: |
|
| 42 | + $value['data']=''; |
|
| 43 | + } |
|
| 44 | + }else if('10000555' == PT1C_SKRIPTNAME){ |
|
| 45 | + switch ($_varName) { |
|
| 46 | + case 'v1': |
|
| 47 | + $value['data']='SIP/201'; |
|
| 48 | + break; |
|
| 49 | + case 'v2': |
|
| 50 | + $value['data']='2017-01-01'; |
|
| 51 | + break; |
|
| 52 | + case 'v3': |
|
| 53 | + $value['data']='2019-01-01'; |
|
| 54 | + break; |
|
| 55 | + case 'v4': |
|
| 56 | + $value['data']='201-89257184254'; |
|
| 57 | + break; |
|
| 58 | + default: |
|
| 59 | + $value['data']=''; |
|
| 60 | + } |
|
| 61 | + }else if('1C_HistoryFax.php' == PT1C_SKRIPTNAME){ |
|
| 62 | + switch ($_varName) { |
|
| 63 | + case 'v1': |
|
| 64 | + $value['data']='SIP/1000'; |
|
| 65 | + break; |
|
| 66 | + case 'v2': |
|
| 67 | + $value['data']='2017-01-01'; |
|
| 68 | + break; |
|
| 69 | + case 'v3': |
|
| 70 | + $value['data']='2019-01-01'; |
|
| 71 | + break; |
|
| 72 | + default: |
|
| 73 | + $value['data']=''; |
|
| 74 | + } |
|
| 75 | + }else if('10000777' == PT1C_SKRIPTNAME){ |
|
| 76 | + switch ($_varName) { |
|
| 77 | + case 'chan': |
|
| 78 | + $value['data']='SIP/204'; |
|
| 79 | + break; |
|
| 80 | + case 'uniqueid1c': |
|
| 81 | + $value['data']='mikopbx-1519992881.0'; |
|
| 82 | + break; |
|
| 83 | + case 'ASTSPOOLDIR': |
|
| 84 | + $value['data']='/var/spool/asterisk'; |
|
| 85 | + break; |
|
| 86 | + default: |
|
| 87 | + $value['data']=''; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + return $value['data']; |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -10,81 +10,81 @@ |
||
| 10 | 10 | * Заглушка для отладки скрипта. |
| 11 | 11 | */ |
| 12 | 12 | class _AGI { |
| 13 | - public function exec($v1, $v2){ |
|
| 13 | + public function exec($v1, $v2) { |
|
| 14 | 14 | echo "exec($v1, $v2)\n"; |
| 15 | 15 | } |
| 16 | - public function answer(){ |
|
| 16 | + public function answer() { |
|
| 17 | 17 | echo "answer()\n"; |
| 18 | 18 | } |
| 19 | - public function get_variable($_varName){ |
|
| 19 | + public function get_variable($_varName) { |
|
| 20 | 20 | |
| 21 | 21 | $value = array(); |
| 22 | - $value['result']=1; |
|
| 22 | + $value['result'] = 1; |
|
| 23 | 23 | |
| 24 | - if('10000666' == PT1C_SKRIPTNAME){ |
|
| 24 | + if ('10000666' == PT1C_SKRIPTNAME) { |
|
| 25 | 25 | switch ($_varName) { |
| 26 | 26 | case 'v1': |
| 27 | - $value['data']='SIP/204'; |
|
| 27 | + $value['data'] = 'SIP/204'; |
|
| 28 | 28 | break; |
| 29 | 29 | case 'v2': |
| 30 | - $value['data']='mikopbx-1558444069.34'; |
|
| 30 | + $value['data'] = 'mikopbx-1558444069.34'; |
|
| 31 | 31 | break; |
| 32 | 32 | case 'v3': |
| 33 | - $value['data']=''; |
|
| 33 | + $value['data'] = ''; |
|
| 34 | 34 | break; |
| 35 | 35 | case 'v6': |
| 36 | - $value['data']='Records'; |
|
| 36 | + $value['data'] = 'Records'; |
|
| 37 | 37 | break; |
| 38 | 38 | case 'ASTSPOOLDIR': |
| 39 | - $value['data']='/var/spool/asterisk'; |
|
| 39 | + $value['data'] = '/var/spool/asterisk'; |
|
| 40 | 40 | break; |
| 41 | 41 | default: |
| 42 | - $value['data']=''; |
|
| 42 | + $value['data'] = ''; |
|
| 43 | 43 | } |
| 44 | - }else if('10000555' == PT1C_SKRIPTNAME){ |
|
| 44 | + } else if ('10000555' == PT1C_SKRIPTNAME) { |
|
| 45 | 45 | switch ($_varName) { |
| 46 | 46 | case 'v1': |
| 47 | - $value['data']='SIP/201'; |
|
| 47 | + $value['data'] = 'SIP/201'; |
|
| 48 | 48 | break; |
| 49 | 49 | case 'v2': |
| 50 | - $value['data']='2017-01-01'; |
|
| 50 | + $value['data'] = '2017-01-01'; |
|
| 51 | 51 | break; |
| 52 | 52 | case 'v3': |
| 53 | - $value['data']='2019-01-01'; |
|
| 53 | + $value['data'] = '2019-01-01'; |
|
| 54 | 54 | break; |
| 55 | 55 | case 'v4': |
| 56 | - $value['data']='201-89257184254'; |
|
| 56 | + $value['data'] = '201-89257184254'; |
|
| 57 | 57 | break; |
| 58 | 58 | default: |
| 59 | - $value['data']=''; |
|
| 59 | + $value['data'] = ''; |
|
| 60 | 60 | } |
| 61 | - }else if('1C_HistoryFax.php' == PT1C_SKRIPTNAME){ |
|
| 61 | + } else if ('1C_HistoryFax.php' == PT1C_SKRIPTNAME) { |
|
| 62 | 62 | switch ($_varName) { |
| 63 | 63 | case 'v1': |
| 64 | - $value['data']='SIP/1000'; |
|
| 64 | + $value['data'] = 'SIP/1000'; |
|
| 65 | 65 | break; |
| 66 | 66 | case 'v2': |
| 67 | - $value['data']='2017-01-01'; |
|
| 67 | + $value['data'] = '2017-01-01'; |
|
| 68 | 68 | break; |
| 69 | 69 | case 'v3': |
| 70 | - $value['data']='2019-01-01'; |
|
| 70 | + $value['data'] = '2019-01-01'; |
|
| 71 | 71 | break; |
| 72 | 72 | default: |
| 73 | - $value['data']=''; |
|
| 73 | + $value['data'] = ''; |
|
| 74 | 74 | } |
| 75 | - }else if('10000777' == PT1C_SKRIPTNAME){ |
|
| 75 | + } else if ('10000777' == PT1C_SKRIPTNAME) { |
|
| 76 | 76 | switch ($_varName) { |
| 77 | 77 | case 'chan': |
| 78 | - $value['data']='SIP/204'; |
|
| 78 | + $value['data'] = 'SIP/204'; |
|
| 79 | 79 | break; |
| 80 | 80 | case 'uniqueid1c': |
| 81 | - $value['data']='mikopbx-1519992881.0'; |
|
| 81 | + $value['data'] = 'mikopbx-1519992881.0'; |
|
| 82 | 82 | break; |
| 83 | 83 | case 'ASTSPOOLDIR': |
| 84 | - $value['data']='/var/spool/asterisk'; |
|
| 84 | + $value['data'] = '/var/spool/asterisk'; |
|
| 85 | 85 | break; |
| 86 | 86 | default: |
| 87 | - $value['data']=''; |
|
| 87 | + $value['data'] = ''; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | return $value['data']; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | default: |
| 42 | 42 | $value['data']=''; |
| 43 | 43 | } |
| 44 | - }else if('10000555' == PT1C_SKRIPTNAME){ |
|
| 44 | + } else if('10000555' == PT1C_SKRIPTNAME){ |
|
| 45 | 45 | switch ($_varName) { |
| 46 | 46 | case 'v1': |
| 47 | 47 | $value['data']='SIP/201'; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | default: |
| 59 | 59 | $value['data']=''; |
| 60 | 60 | } |
| 61 | - }else if('1C_HistoryFax.php' == PT1C_SKRIPTNAME){ |
|
| 61 | + } else if('1C_HistoryFax.php' == PT1C_SKRIPTNAME){ |
|
| 62 | 62 | switch ($_varName) { |
| 63 | 63 | case 'v1': |
| 64 | 64 | $value['data']='SIP/1000'; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | default: |
| 73 | 73 | $value['data']=''; |
| 74 | 74 | } |
| 75 | - }else if('10000777' == PT1C_SKRIPTNAME){ |
|
| 75 | + } else if('10000777' == PT1C_SKRIPTNAME){ |
|
| 76 | 76 | switch ($_varName) { |
| 77 | 77 | case 'chan': |
| 78 | 78 | $value['data']='SIP/204'; |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | |
| 9 | 9 | // autoload.php @generated by Composer |
| 10 | 10 | |
| 11 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 11 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 12 | 12 | |
| 13 | 13 | return ComposerAutoloaderInit6670dab4b71421eb4b91561314912df5::getLoader(); |