diff options
author | James Bottomley <JBottomley@Parallels.com> | 2013-04-26 17:26:20 -0700 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-04-26 17:39:33 -0700 |
commit | e6e67f707e2e6f571931043b39546eefbd5d1da2 (patch) | |
tree | 08db4bd2e8c871b09134bc60be4d0ef89c8f9c22 | |
parent | f31c2af09cc825693c65295d859e14d06447f6d9 (diff) | |
download | asterisk-aastra-e6e67f707e2e6f571931043b39546eefbd5d1da2.tar.gz |
AastraAsterisk: add some core functionality
The authentication model for all the classes (see BaseAastra.class) is that
the phone using the XML code must be registered, so we check the sip
registrations for the incoming IP address
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | include/AastraAsterisk.class.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/AastraAsterisk.class.php b/include/AastraAsterisk.class.php index 7ba33ad..dc930bb 100644 --- a/include/AastraAsterisk.class.php +++ b/include/AastraAsterisk.class.php @@ -309,6 +309,33 @@ class AGI_AsteriskManager return $this->send_request('Command', $parameters); } + function CommandArray($command, $actionid=NULL) { + $ret = $this->Command($command, $actionid); + $arr = preg_split("\n", $ret['data']); + # remove the header line + unset($arr[0]); + $retval = array(); + + for ($i = 0; $i < count($arr); $i++) { + $retval[$i] = preg_split("/\s+/", $arr[$i+1]); + } + + return $retval; + } + + function get_user() { + $ret = $this->Command('sip show peers'); + $ret = split("\n", $ret['data']); + for ($i = 1; $i < count($ret) - 1; $i++) { + $a = preg_split("/\s+/", $ret[$i]); + if (strcmp($a[1], $_SERVER['REMOTE_ADDR']) == 0) { + $n = explode("/", $a[0]); + return $n[0]; + } + } + throw new Exception('Not Authorized'); + } + function Logoff() { return $this->send_request('Logoff'); |