Initial commit
This commit is contained in:
150
AastraXMLSchema.xsd
Normal file
150
AastraXMLSchema.xsd
Normal file
@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<xs:element name="AastraIPPhoneTextScreen">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Title" type="xs:string" />
|
||||
<xs:element name="Text">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:minLength value="1" />
|
||||
<xs:maxLength value="1000" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="SoftKey" type="softKeyType" minOccurs="0" maxOccurs="6"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="destroyOnExit" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="Beep" type="textAttributeType" default="no" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="AastraIPPhoneTextMenu">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Title" type="xs:string" />
|
||||
<xs:element name="MenuItem" minOccurs="1" maxOccurs="15">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Prompt" type="xs:string" />
|
||||
<xs:element name="URI" type="xs:string" />
|
||||
<xs:element name="Selection" type="xs:string" minOccurs="0" maxOccurs="1" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="base" type="xs:string" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="SoftKey" type="softKeyType" minOccurs="0" maxOccurs="6"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="destroyOnExit" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="Beep" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="defaultIndex" type="integerAttributeType" default="1" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="AastraIPPhoneInputScreen">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Title" />
|
||||
<xs:element name="Prompt" />
|
||||
<xs:element name="URL" />
|
||||
<xs:element name="Parameter" />
|
||||
<xs:element name="Default" />
|
||||
<xs:element name="SoftKey" type="softKeyType" minOccurs="0" maxOccurs="6"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="type" use="required">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="IP|string|number" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="password" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="destroyOnExit" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="editable" type="textAttributeType" default="yes" />
|
||||
<xs:attribute name="Beep" type="textAttributeType" default="no" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="AastraIPPhoneDirectory">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Title" type="xs:string" />
|
||||
<xs:element name="MenuItem" minOccurs="1" maxOccurs="15">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Prompt" type="xs:string" />
|
||||
<xs:element name="URI" type="xs:string" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="SoftKey" type="softKeyType" minOccurs="0" maxOccurs="6"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="destroyOnExit" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="Beep" type="textAttributeType" default="no" />
|
||||
<xs:attribute name="next" type="xs:string" />
|
||||
<xs:attribute name="previous" type="xs:string" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="AastraIPPhoneExecute">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ExecuteItem" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="URI" type="xs:string" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="Beep" type="textAttributeType" default="no" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="AastraIPPhoneStatus">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Session" type="xs:string" minOccurs="0" />
|
||||
<xs:element name="Message">
|
||||
<xs:complexType mixed="true">
|
||||
<xs:attribute name="index" type="integerAttributeType" use="required" />
|
||||
<xs:attribute name="type">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="alert" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="Timeout" type="integerAttributeType" default="3" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="Beep" type="textAttributeType" default="no" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:simpleType name="textAttributeType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="yes|no" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="integerAttributeType">
|
||||
<xs:restriction base="xs:integer" />
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:complexType name="softKeyType">
|
||||
<xs:sequence>
|
||||
<xs:element name="Label" type="xs:string" />
|
||||
<xs:element name="URI" type="xs:string" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="index" use="required">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:integer">
|
||||
<xs:minInclusive value="1" />
|
||||
<xs:maxInclusive value="6" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
BIN
PA-001004-00-02-XML-API.pdf
Normal file
BIN
PA-001004-00-02-XML-API.pdf
Normal file
Binary file not shown.
19
README.txt
Normal file
19
README.txt
Normal file
@ -0,0 +1,19 @@
|
||||
AASTRA TELECOM INC.
|
||||
|
||||
November 2006
|
||||
|
||||
|
||||
-PA-001004-00-02-XML-API.pdf - Aastra IP Phone XML API document. For use with IP Phone SIP Release 1.4.1.
|
||||
|
||||
-AastraXMLSchema 1.4.1.xsd - XML Schema which can be used to validate XML development.
|
||||
For use with IP Phone SIP Release 1.3.1.
|
||||
|
||||
-php_classes 1.4.1.zip - contains the directory php classes with all the XML classes.
|
||||
The files are commented.
|
||||
|
||||
-asterisk sample source 1.4.1.zip - contains the source code of XML Asterisk integration described in the XML API document
|
||||
The files are commented.
|
||||
|
||||
|
||||
For XML documents related to IP Phone SIP Release 1.3.0, see file PA-001004-00-00.zip
|
||||
For XML documents related to IP Phone SIP Release 1.3.1, see file PA-001004-00-01.zip
|
4714
XML-API.txt
Normal file
4714
XML-API.txt
Normal file
File diff suppressed because it is too large
Load Diff
24
asterisk sample source/License.txt
Normal file
24
asterisk sample source/License.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
216
asterisk sample source/cfwd.php
Normal file
216
asterisk sample source/cfwd.php
Normal file
@ -0,0 +1,216 @@
|
||||
<?
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Asterisk Call Forward for Aastra SIP Phones R1.4.1 or better
|
||||
#
|
||||
# php source code
|
||||
###################################################################################################
|
||||
|
||||
include (dirname(__FILE__)."/phpagi/misc.php");
|
||||
include (dirname(__FILE__)."/phpagi/phpagi-asmanager.php");
|
||||
|
||||
###################################################################################################
|
||||
# Aastra_decode_HTTP_header
|
||||
#
|
||||
# Returns an array
|
||||
# 0 Phone Type
|
||||
# 1 Phone MAC Address
|
||||
# 2 Phone firmware version
|
||||
###################################################################################################
|
||||
|
||||
function Aastra_decode_HTTP_header()
|
||||
{
|
||||
$user_agent=$_SERVER["HTTP_USER_AGENT"];
|
||||
if(stristr($user_agent,"Aastra"))
|
||||
{
|
||||
$value=preg_split("/ MAC:/",$user_agent);
|
||||
$fin=preg_split("/ /",$value[1]);
|
||||
$value[1]=preg_replace("/\-/","",$fin[0]);
|
||||
$value[2]=preg_replace("/V:/","",$fin[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value[0]="MSIE";
|
||||
$value[1]="NA";
|
||||
$value[2]="NA";
|
||||
}
|
||||
|
||||
return($value);
|
||||
}
|
||||
|
||||
###################################################################################################
|
||||
# Global parameters
|
||||
$Server = "http://$SERVER_ADDR".$_SERVER['SCRIPT_NAME'];
|
||||
$cf="";
|
||||
|
||||
# Retrieve parameters
|
||||
$user=$_GET['user'];
|
||||
$action=$_GET['action'];
|
||||
$value=$_GET['value'];
|
||||
|
||||
# Get header info
|
||||
$header=Aastra_decode_HTTP_header();
|
||||
|
||||
# Connect to AGI
|
||||
$as = new AGI_AsteriskManager();
|
||||
$res = $as->connect();
|
||||
|
||||
#GET CFWD
|
||||
$res = $as->Command('database get CF '.$user);
|
||||
$line=split("\n", $res['data']);
|
||||
$data=split(" ", $line[0]);
|
||||
if($data[0]=="Value:") $cf=$data[1];
|
||||
if($cf=="")
|
||||
{
|
||||
$data=split(" ", $line[1]);
|
||||
if($data[0]=="Value:") $cf=$data[1];
|
||||
}
|
||||
|
||||
# change CF status
|
||||
if(isset($action))
|
||||
{
|
||||
if($action=="cancel")
|
||||
{
|
||||
$res = $as->Command('database del CF '.$user);
|
||||
$output = "<AastraIPPhoneExecute>\n";
|
||||
$output .= "<ExecuteItem URI=\"".$Server."?action=msg&user=".$user."\"/>\n";
|
||||
switch($header[0])
|
||||
{
|
||||
case "Aastra9112i":
|
||||
case "Aastra9133i":
|
||||
break;
|
||||
|
||||
default:
|
||||
$output .= "<ExecuteItem URI=\"".$Server."?user=".$user."\"/>\n";
|
||||
break;
|
||||
}
|
||||
$output .= "</AastraIPPhoneExecute>\n";
|
||||
}
|
||||
|
||||
if($action=="set")
|
||||
{
|
||||
$res = $as->Command('database put CF '.$user.' '.$value);
|
||||
$output = "<AastraIPPhoneExecute>\n";
|
||||
$output .= "<ExecuteItem URI=\"".$Server."?action=msg&user=".$user."\"/>\n";
|
||||
switch($header[0])
|
||||
{
|
||||
case "Aastra9112i":
|
||||
case "Aastra9133i":
|
||||
break;
|
||||
|
||||
default:
|
||||
$output .= "<ExecuteItem URI=\"".$Server."?user=".$user."\"/>\n";
|
||||
break;
|
||||
}
|
||||
$output .= "</AastraIPPhoneExecute>\n";
|
||||
}
|
||||
|
||||
if($action=="change")
|
||||
{
|
||||
$output = "<AastraIPPhoneInputScreen type=\"number\" destroyOnExit=\"yes\">\n";
|
||||
$output .= "<Title>Call Forward</Title>\n";
|
||||
$output .= "<Prompt>Enter destination</Prompt>\n";
|
||||
$output .= "<URL>".$Server."?user=$user&action=set</URL>\n";
|
||||
$output .= "<Parameter>value</Parameter>\n";
|
||||
$output .= "<Default></Default>\n";
|
||||
$output .= "</AastraIPPhoneInputScreen>\n";
|
||||
}
|
||||
|
||||
if($action=="msg")
|
||||
{
|
||||
$output = "<AastraIPPhoneStatus Beep=\"yes\">\n";
|
||||
$output .= "<Session>CFDND</Session>\n";
|
||||
if ($cf=="") $output .= "<Message index=\"1\"></Message>\n";
|
||||
else $output .= "<Message index=\"1\">CFWD activated</Message>\n";
|
||||
$output .= "</AastraIPPhoneStatus>\n";
|
||||
}
|
||||
|
||||
# Disconnect properly
|
||||
$as->disconnect();
|
||||
|
||||
header("Content-Type: text/xml");
|
||||
header("Content-Length: ".strlen($output));
|
||||
echo $output;
|
||||
exit;
|
||||
}
|
||||
|
||||
# Disconnect properly
|
||||
$as->disconnect();
|
||||
|
||||
# Setup header type
|
||||
header("Content-Type: text/xml");
|
||||
|
||||
switch($header[0])
|
||||
{
|
||||
case "Aastra9112i":
|
||||
case "Aastra9133i":
|
||||
$output = "<AastraIPPhoneTextMenu destroyOnExit=\"yes\">\n";
|
||||
if($cf=="") $output .= "<Title>CFWD deactivated</Title>\n";
|
||||
else $output .= "<Title>CFWD set (".$cf.")</Title>\n";
|
||||
if($cf!="")
|
||||
{
|
||||
$output .= "<MenuItem>\n";
|
||||
$output .= "<Prompt>Cancel</Prompt>\n";
|
||||
$output .= "<URI>$Server/cfwd.php?action=cancel&user=$user</URI>\n";
|
||||
$output .= "</MenuItem>\n";
|
||||
}
|
||||
$output .= "<MenuItem>\n";
|
||||
$output .= "<Prompt>Change</Prompt>\n";
|
||||
$output .= "<URI>$Server/cfwd.php?action=change&user=$user</URI>\n";
|
||||
$output .= "</MenuItem>\n";
|
||||
$output .= "</AastraIPPhoneTextMenu>\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
$output = "<AastraIPPhoneTextScreen destroyOnExit=\"yes\">\n";
|
||||
$output .= "<Title>Call Forward for $user</Title>\n";
|
||||
if ($cf=="") $output .= "<Text>Call Forward is currently deactivated.</Text>\n";
|
||||
else $output .= "<Text>Call Forward is currently set to $cf.</Text>\n";
|
||||
$output .= "<SoftKey index=\"1\">\n";
|
||||
$output .= "<Label>Change</Label>\n";
|
||||
$output .= "<URI>$Server/cfwd.php?action=change&user=$user</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
if($cf!="")
|
||||
{
|
||||
$output .= "<SoftKey index=\"2\">\n";
|
||||
$output .= "<Label>Cancel</Label>\n";
|
||||
$output .= "<URI>$Server/cfwd.php?action=cancel&user=$user</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
}
|
||||
$output .= "<SoftKey index=\"6\">\n";
|
||||
$output .= "<Label>Done</Label>\n";
|
||||
$output .= "<URI>SoftKey:Exit</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
$output .= "</AastraIPPhoneTextScreen>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
header("Content-Length: ".strlen($output));
|
||||
echo $output;
|
||||
?>
|
144
asterisk sample source/directory.php
Normal file
144
asterisk sample source/directory.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Asterisk Directory for Aastra SIP Phones R1.4.1 or better
|
||||
#
|
||||
# php source code
|
||||
#
|
||||
# Parses
|
||||
# - SIP users
|
||||
# - IAX users
|
||||
#
|
||||
# Warning
|
||||
# Location of Asterisk config files is set to "/etc/asterisk"
|
||||
###################################################################################################
|
||||
|
||||
# Location of asterisk config files
|
||||
$location = "/etc/asterisk/";
|
||||
|
||||
# Global Variables
|
||||
$Server = "http://$SERVER_ADDR".$_SERVER['SCRIPT_NAME'];
|
||||
|
||||
# Init number of records
|
||||
$index=0;
|
||||
|
||||
# Parse sip.conf
|
||||
$sip_array=parse_ini_file($location."sip_additional.conf", true);
|
||||
while ($v=current($sip_array))
|
||||
{
|
||||
if((isset($v['callerid'])) and (key($sip_array)!="register"))
|
||||
{
|
||||
$temp=$v['callerid'];
|
||||
$len=strlen($temp);
|
||||
$callerid=substr($temp,0,$len-(strlen(strrchr($temp, '<')))-1);
|
||||
$directory[] = "<Prompt>". $callerid."</Prompt>\n"."<URI>".key($sip_array)."</URI>\n"."<Selection>". key($sip_array)."&name=".$callerid."</Selection>\n";
|
||||
$index++;
|
||||
}
|
||||
next($sip_array);
|
||||
}
|
||||
|
||||
# Parse iax.conf
|
||||
$iax_array=parse_ini_file($location."iax.conf", true);
|
||||
while($v=current($iax_array))
|
||||
{
|
||||
if(isset($v['name']))
|
||||
{
|
||||
$directory[]="<Prompt>".$v['name']."</Prompt>\n"."<URI>".key($iax_array)."</URI>\n";
|
||||
$index++;
|
||||
}
|
||||
next($iax_array);
|
||||
}
|
||||
|
||||
# Sort Directory
|
||||
sort($directory);
|
||||
|
||||
# Retrieve last page
|
||||
$last=intval($index/15);
|
||||
if(($index-$last*15) != 0) $last++;
|
||||
|
||||
# Retrieve current page
|
||||
$page=$_GET['page'];
|
||||
if (empty($page)) $page=1;
|
||||
|
||||
# Display Page
|
||||
$output ="<AastraIPPhoneTextMenu destroyOnExit=\"yes\">";
|
||||
$output .= "<Title>Directory ($page/$last)</Title>\n";
|
||||
$index=1;
|
||||
foreach ($directory as $v)
|
||||
{
|
||||
if(($index>=(($page-1)*15+1)) and ($index<=$page*15))
|
||||
{
|
||||
$output .= "<MenuItem>\n";
|
||||
$output .= $v;
|
||||
$output .= "</MenuItem>\n";
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
|
||||
# Dial button
|
||||
$output .= "<SoftKey index=\"1\">\n";
|
||||
$output .= "<Label>Dial</Label>\n";
|
||||
$output .= "<URI>SoftKey:Dial</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
|
||||
# Next button
|
||||
if($page!=$last)
|
||||
{
|
||||
$next=$page+1;
|
||||
$output .= "<SoftKey index=\"5\">\n";
|
||||
$output .= "<Label>Next</Label>\n";
|
||||
$output .= "<URI>$Server?page=$next</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
}
|
||||
|
||||
# Previous button
|
||||
if($page!=1)
|
||||
{
|
||||
$previous=$page-1;
|
||||
$output .= "<SoftKey index=\"2\">\n";
|
||||
$output .= "<Label>Previous</Label>\n";
|
||||
$output .= "<URI>$Server?page=$previous</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
}
|
||||
|
||||
# Exit Button
|
||||
$output .= "<SoftKey index=\"6\">\n";
|
||||
$output .= "<Label>Exit</Label>\n";
|
||||
$output .= "<URI>SoftKey:Exit</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
|
||||
# End of the object
|
||||
$output .= "</AastraIPPhoneTextMenu>\n";
|
||||
|
||||
# HTTP header and output
|
||||
header("Content-Type: text/xml");
|
||||
header("Content-Length: ".strlen($output));
|
||||
echo $output;
|
||||
?>
|
||||
|
173
asterisk sample source/dnd.php
Normal file
173
asterisk sample source/dnd.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Asterisk DND for Aastra SIP Phones R1.4.1 or better
|
||||
#
|
||||
# php source code
|
||||
#####################################################################
|
||||
|
||||
include (dirname(__FILE__)."/phpagi/misc.php");
|
||||
include (dirname(__FILE__)."/phpagi/phpagi-asmanager.php");
|
||||
|
||||
#####################################################################
|
||||
# Aastra_decode_HTTP_header
|
||||
#
|
||||
# Returns an array
|
||||
# 0 Phone Type
|
||||
# 1 Phone MAC Address
|
||||
# 2 Phone firmware version
|
||||
#####################################################################
|
||||
|
||||
function Aastra_decode_HTTP_header()
|
||||
{
|
||||
$user_agent=$_SERVER["HTTP_USER_AGENT"];
|
||||
if(stristr($user_agent,"Aastra"))
|
||||
{
|
||||
$value=preg_split("/ MAC:/",$user_agent);
|
||||
$fin=preg_split("/ /",$value[1]);
|
||||
$value[1]=preg_replace("/\-/","",$fin[0]);
|
||||
$value[2]=preg_replace("/V:/","",$fin[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value[0]="MSIE";
|
||||
$value[1]="NA";
|
||||
$value[2]="NA";
|
||||
}
|
||||
|
||||
return($value);
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# Global parameters
|
||||
#####################################################################
|
||||
$Server = "http://$SERVER_ADDR".$_SERVER['SCRIPT_NAME'];
|
||||
$dnd=0;
|
||||
|
||||
# Retrieve parameters
|
||||
$user=$_GET['user'];
|
||||
$action=$_GET['action'];
|
||||
$status=$_GET['status'];
|
||||
|
||||
# Force default action
|
||||
if($action=="") $action="change";
|
||||
|
||||
# Get header info
|
||||
$header=Aastra_decode_HTTP_header();
|
||||
|
||||
# Get current value only if action is change or update
|
||||
if(($action=="change") || ($action=="update"))
|
||||
{
|
||||
# Connect to AGI
|
||||
$as = new AGI_AsteriskManager();
|
||||
$res = $as->connect();
|
||||
|
||||
#DND GET
|
||||
$res = $as->Command('database get DND '.$user);
|
||||
$line=split("\n", $res['data']);
|
||||
$value=split(" ", $line[0]);
|
||||
if($value[1]=="YES") $dnd=1;
|
||||
if($dnd==0)
|
||||
{
|
||||
$value=split(" ", $line[1]);
|
||||
if($value[1]=="YES") $dnd=1;
|
||||
}
|
||||
|
||||
# CHANGE CURRENT VALUE
|
||||
if($action=="change")
|
||||
{
|
||||
# change DND status
|
||||
if($dnd==0)
|
||||
{
|
||||
$res = $as->Command('database put DND '.$user.' YES');
|
||||
$dnd=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$res = $as->Command('database del DND '.$user);
|
||||
$dnd=0;
|
||||
}
|
||||
}
|
||||
|
||||
# Disconnect properly
|
||||
$as->disconnect();
|
||||
}
|
||||
|
||||
# Setup header type
|
||||
header("Content-Type: text/xml");
|
||||
|
||||
# Update action
|
||||
if($action=="update")
|
||||
{
|
||||
$output = "<AastraIPPhoneExecute>\n";
|
||||
$output .= "<ExecuteItem URI=\"".$Server."?action=msg&status=".$status."\"/>\n";
|
||||
$output .= "</AastraIPPhoneExecute>\n";
|
||||
}
|
||||
|
||||
# Update message
|
||||
if($action=="msg")
|
||||
{
|
||||
$output = "<AastraIPPhoneStatus Beep=\"yes\">\n";
|
||||
$output .= "<Session>CFDND12345</Session>\n";
|
||||
if ($status==1) $output .= "<Message index=\"0\">DND activated</Message>\n";
|
||||
else $output .= "<Message index=\"0\"></Message>\n";
|
||||
$output .= "</AastraIPPhoneStatus>\n";
|
||||
}
|
||||
|
||||
# Action=change
|
||||
if($action=="change")
|
||||
{
|
||||
switch($header[0])
|
||||
{
|
||||
case "Aastra9112i":
|
||||
case "Aastra9133i":
|
||||
$output = "<AastraIPPhoneStatus Beep=\"yes\">\n";
|
||||
$output .= "<Session>CFDND12345</Session>\n";
|
||||
if ($dnd==1) $output .= "<Message index=\"0\">DND activated</Message>\n";
|
||||
else $output .= "<Message index=\"0\"></Message>\n";
|
||||
$output .= "</AastraIPPhoneStatus>\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
$output = "<AastraIPPhoneTextScreen destroyOnExit=\"yes\">\n";
|
||||
$output .= "<Title></Title>\n";
|
||||
if ($dnd==0) $output .= "<Text>DND deactivated.</Text>\n";
|
||||
else $output .= "<Text>DND activated.</Text>\n";
|
||||
$output .= "<SoftKey index=\"6\">\n";
|
||||
$output .= "<Label>Done</Label>\n";
|
||||
$output .= "<URI>".$Server."?action=update&status=".$dnd."</URI>\n";
|
||||
$output .= "</SoftKey>\n";
|
||||
$output .= "</AastraIPPhoneTextScreen>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-Length: ".strlen($output));
|
||||
echo $output;
|
||||
?>
|
218
asterisk sample source/phpagi/README.phpagi-asmanager
Normal file
218
asterisk sample source/phpagi/README.phpagi-asmanager
Normal file
@ -0,0 +1,218 @@
|
||||
phpagi-asmanager: an Asterisk Manager class written in PHP
|
||||
|
||||
Matthew Asham <matthewa@bcwireless.net>
|
||||
http://phpagi.sourceforge.net
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SECURITY
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Validation:
|
||||
|
||||
******If asterisk is running as root, the manager interface may allow the
|
||||
execution of arbitrary shell commands as root. If the user can update any
|
||||
configuration file that can execute arbitrary command (like the dialplan),
|
||||
the system may be compromised.
|
||||
|
||||
Also, look out for command injection. Consider the following example:
|
||||
|
||||
$as->Events($_POST['events_status']);
|
||||
|
||||
We expect either 'on' or 'off', but the attacker uses:
|
||||
|
||||
"\r\n\r\nAction: Command\r\nCommand: database put forward 54321 19005551212";
|
||||
|
||||
|
||||
Validation is a *must* for all user data.
|
||||
|
||||
|
||||
Username and Secret:
|
||||
|
||||
Storing the username and secret in the config file will isolate them from your
|
||||
code.
|
||||
|
||||
Isolation of username and secret in the config file does not mean that the
|
||||
script cannot simple read the config file. The config file must be readable
|
||||
by the script.
|
||||
|
||||
|
||||
CREATING A NEW INSTANCE OF THE CLASS
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
The class can be created standalone of phpagi.php, or through phpagi.
|
||||
|
||||
STANDALONE:
|
||||
|
||||
require "phpagi-asmanager.php";
|
||||
|
||||
$as = new AGI_AsteriskManager();
|
||||
|
||||
FROM PHPAGI:
|
||||
|
||||
require "phpagi.php";
|
||||
|
||||
$agi = new AGI();
|
||||
$as = $agi->new_AsteriskManager();
|
||||
|
||||
Notes:
|
||||
|
||||
* If the class is created using $agi->new_AsteriskManager(),
|
||||
AGI_AsteriskManager will use the parent phpagi for logging to the Asterisk
|
||||
console.
|
||||
|
||||
* phpagi.php will include phpagi-asmanager.php by itself.
|
||||
* If phpagi-asmanager.php is included _before_ phpagi.php, phpagi.php will
|
||||
not attempt to re-include it.
|
||||
* If phpagi.php tries to include phpagi-asmanager.php but is unable to do
|
||||
so, an error will be echoed to the asterisk console and the script will
|
||||
continue running normally. in this case the return value of
|
||||
new_AsteriskManager() will be FALSE.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
CONFIGURATION
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
phpagi-asmanager uses the same configuration file as phpagi.conf (usually
|
||||
/etc/asterisk/phpagi.conf). All configuration information specific to
|
||||
phpagi-asmanager is contained in the [asmanager] section of the .conf file.
|
||||
|
||||
supported directives:
|
||||
|
||||
[asmanager]
|
||||
# server to connect to
|
||||
server=localhost
|
||||
|
||||
# default manager port
|
||||
port=5038
|
||||
|
||||
#username for login
|
||||
username=me_and_only_me
|
||||
|
||||
#password for login
|
||||
secret=i_am_not_telling
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
CONNECTING
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
$res = $as->connect("localhost", "username", "password");
|
||||
if($res == FALSE) {
|
||||
echo "Connection failed.\n";
|
||||
}
|
||||
elseif($res == TRUE){
|
||||
echo "Connection established.\n";
|
||||
}
|
||||
|
||||
A port can also be specified for the hostname. eg:
|
||||
|
||||
$res = $as->connect("my.asterisk.server:1234", "username", "port");
|
||||
|
||||
If the no parameters are specified, the defaults from the config will be used.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
DISCONNECTING
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
$as->disconnect();
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
SENDING REQUESTS
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
$as->send_request($eventname, $arrayofparameterstopass);
|
||||
|
||||
send_request() calls wait_request and returns an array of returned data from
|
||||
the manager. If something went wrong, it returns false.
|
||||
|
||||
wait_request() shouldn't need to be called from a script directly unless you
|
||||
are implementing merely an event listener.
|
||||
|
||||
wait_request() will also detect events and dispatch any registered event
|
||||
handlers for the event.
|
||||
|
||||
examples:
|
||||
|
||||
$res = $as->send_request('EventName',
|
||||
array('Channel'=>'Zap/1/16045551212',
|
||||
'SomeParameter'=>'data'));
|
||||
echo "Dump of returned data:\n";
|
||||
foreach($res as $var=>$val)
|
||||
echo "$var = $val\n";
|
||||
|
||||
|
||||
$res['Response'] will generally be 'Success' on success and 'Error' on
|
||||
failure. But this is not always true. If $res['Response'] == 'Follows', a
|
||||
multi-line response will be stored in $res['data'].
|
||||
|
||||
Several manager commands have been aliased for convenience. See below.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
EVENTS
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
TODO: non-blocking socket i/o.
|
||||
|
||||
The class uses event callbacks to process events received from the manager.
|
||||
|
||||
The event callback prototype looks like:
|
||||
|
||||
function dump_event($ecode, $data, $server, $port)
|
||||
{
|
||||
echo "received event '$ecode' from $server:$port\n";
|
||||
print_r($data);
|
||||
}
|
||||
|
||||
To register an event call back:
|
||||
|
||||
$as->add_event_handler('eventname', 'eventfunction');
|
||||
|
||||
eg:
|
||||
|
||||
$as->add_event_handler('registry', 'dump_event');
|
||||
|
||||
|
||||
The special eventname "*" can also be registered. any eventname not
|
||||
specifically registered will be handled by the "*" handler. If no "*" handler
|
||||
is defined, the event will be silently ignored.
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
PRECANNED FUNCTIONS
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
The following Manager functions have been aliased for convenience:
|
||||
|
||||
AbsoluteTimeout
|
||||
ChangeMonitor
|
||||
Command
|
||||
Events
|
||||
ExtensionState
|
||||
GetVar
|
||||
Hangup
|
||||
IAXPeers
|
||||
ListCommands
|
||||
Logoff
|
||||
MailboxCount
|
||||
MailboxStatus
|
||||
Monitor
|
||||
Originate
|
||||
ParkedCalls
|
||||
Ping
|
||||
Queues
|
||||
QueueStatus
|
||||
Redirect
|
||||
SetCDRUserField
|
||||
SetVar
|
||||
SIPpeers
|
||||
Status
|
||||
StopMontor
|
||||
ZapDialOffhook
|
||||
ZapDNDoff
|
||||
ZapDNDon
|
||||
ZapHangup
|
||||
ZapTransfer
|
||||
|
42
asterisk sample source/phpagi/meetme-user-room.php
Normal file
42
asterisk sample source/phpagi/meetme-user-room.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require "phpagi-asmanager.php";
|
||||
|
||||
$as = new AGI_AsteriskManager();
|
||||
// && CONNECTING
|
||||
$res = $as->connect();
|
||||
|
||||
$room = 1234;
|
||||
$res = $as->Command('meetme list '.$room);
|
||||
|
||||
//echo $res['data'].'</br>';
|
||||
|
||||
|
||||
$line= split("\n", $res['data']);
|
||||
|
||||
//print_r ($line);
|
||||
echo $line[0];
|
||||
|
||||
$element= split(' ', $line[0]);
|
||||
|
||||
print_r ($element);
|
||||
|
||||
/*
|
||||
|
||||
</br>Array
|
||||
(
|
||||
[0] => User #: 1 Channel: IAX2/areskiax@areskiax-2 (Admn Muted) (unmonitored)
|
||||
[1] => User #: 2 Channel: SIP/kphone-b15c (unmonitored)
|
||||
[2] => 2 users in that conference.
|
||||
[3] =>
|
||||
)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
flush();
|
||||
ob_flush();
|
||||
|
||||
// && DISCONNECTING
|
||||
$as->disconnect();
|
||||
|
||||
?>
|
22
asterisk sample source/phpagi/misc.php
Normal file
22
asterisk sample source/phpagi/misc.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
function getpost_ifset($test_vars)
|
||||
{
|
||||
if (!is_array($test_vars)) {
|
||||
$test_vars = array($test_vars);
|
||||
}
|
||||
foreach($test_vars as $test_var) {
|
||||
if (isset($_POST[$test_var])) {
|
||||
global $$test_var;
|
||||
$$test_var = $_POST[$test_var];
|
||||
} elseif (isset($_GET[$test_var])) {
|
||||
global $$test_var;
|
||||
$$test_var = $_GET[$test_var];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
699
asterisk sample source/phpagi/phpagi-asmanager.php
Normal file
699
asterisk sample source/phpagi/phpagi-asmanager.php
Normal file
@ -0,0 +1,699 @@
|
||||
<?php
|
||||
/**
|
||||
* phpagi-asmanager.php : PHP Asterisk Manager functions
|
||||
* Website: http://phpagi.sourceforge.net
|
||||
*
|
||||
* $Id: phpagi-asmanager.php,v 1.6 2005/02/16 23:31:50 pinhole Exp $
|
||||
*
|
||||
* Copyright (c) 2004 Matthew Asham <matthewa@bcwireless.net>
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software is released under the terms of the GNU Public License v2
|
||||
* A copy of which is available from http://www.fsf.org/licenses/gpl.txt
|
||||
*
|
||||
*
|
||||
* You are requested to drop me an Email letting me know that you're
|
||||
* using it. This is more of a courtesy than anything else, but I am
|
||||
* interested to know how it is being used.
|
||||
*
|
||||
* @package phpAGI
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Written for PHP 4.3.4, should work with older PHP 4.x versions.
|
||||
* Please submit bug reports, patches, etc to http://sourceforge.net/projects/phpagi/
|
||||
* Gracias. :)
|
||||
*
|
||||
*/
|
||||
|
||||
if(!class_exists('AGI'))
|
||||
{
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asterisk Manager class
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+config+manager.conf
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+manager+API
|
||||
* @example examples/sip_show_peer.php Get information about a sip peer
|
||||
* @package phpAGI
|
||||
*/
|
||||
class AGI_AsteriskManager
|
||||
{
|
||||
/**
|
||||
* Config variables
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $config;
|
||||
|
||||
/**
|
||||
* Socket
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
var $socket = NULL;
|
||||
|
||||
/**
|
||||
* Server we are connected to
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
var $server;
|
||||
|
||||
/**
|
||||
* Port on the server we are connected to
|
||||
*
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
var $port;
|
||||
|
||||
/**
|
||||
* Parent AGI
|
||||
*
|
||||
* @access private
|
||||
* @var AGI
|
||||
*/
|
||||
var $pagi;
|
||||
|
||||
/**
|
||||
* Event Handlers
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
var $event_handlers;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $config is the name of the config file to parse or a parent agi from which to read the config
|
||||
* @param array $optconfig is an array of configuration vars and vals, stuffed into $this->config['asmanager']
|
||||
*/
|
||||
function AGI_AsteriskManager($config=NULL, $optconfig=array())
|
||||
{
|
||||
// load config
|
||||
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);
|
||||
|
||||
// If optconfig is specified, stuff vals and vars into 'asmanager' config array.
|
||||
foreach($optconfig as $var=>$val)
|
||||
$this->config['asmanager'][$var] = $val;
|
||||
|
||||
// add default values to config for uninitialized values
|
||||
if(!isset($this->config['asmanager']['server'])) $this->config['asmanager']['server'] = 'localhost';
|
||||
if(!isset($this->config['asmanager']['port'])) $this->config['asmanager']['port'] = 5038;
|
||||
if(!isset($this->config['asmanager']['username'])) $this->config['asmanager']['username'] = 'phpagi';
|
||||
if(!isset($this->config['asmanager']['secret'])) $this->config['asmanager']['secret'] = 'phpagi';
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request
|
||||
*
|
||||
* @param string $action
|
||||
* @param array $parameters
|
||||
* @return array of parameters
|
||||
*/
|
||||
function send_request($action, $parameters=array())
|
||||
{
|
||||
$req = "Action: $action\r\n";
|
||||
foreach($parameters as $var=>$val)
|
||||
$req .= "$var: $val\r\n";
|
||||
$req .= "\r\n";
|
||||
fwrite($this->socket, $req);
|
||||
return $this->wait_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a response
|
||||
*
|
||||
* If a request was just sent, this will return the response.
|
||||
* Otherwise, it will loop forever, handling events.
|
||||
*
|
||||
* @param boolean $allow_timeout if the socket times out, return an empty array
|
||||
* @return array of parameters, empty on timeout
|
||||
*/
|
||||
function wait_response($allow_timeout=false)
|
||||
{
|
||||
$timeout = false;
|
||||
do
|
||||
{
|
||||
$type = NULL;
|
||||
$parameters = array();
|
||||
|
||||
$buffer = trim(fgets($this->socket, 4096));
|
||||
while($buffer != '')
|
||||
{
|
||||
$a = strpos($buffer, ':');
|
||||
if($a)
|
||||
{
|
||||
if(!count($parameters)) // first line in a response?
|
||||
{
|
||||
$type = strtolower(substr($buffer, 0, $a));
|
||||
if(substr($buffer, $a + 2) == 'Follows')
|
||||
{
|
||||
// A follows response means there is a miltiline field that follows.
|
||||
$parameters['data'] = '';
|
||||
$buff = fgets($this->socket, 4096);
|
||||
while(substr($buff, 0, 6) != '--END ')
|
||||
{
|
||||
$parameters['data'] .= $buff;
|
||||
$buff = fgets($this->socket, 4096);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// store parameter in $parameters
|
||||
$parameters[substr($buffer, 0, $a)] = substr($buffer, $a + 2);
|
||||
}
|
||||
$buffer = trim(fgets($this->socket, 4096));
|
||||
}
|
||||
|
||||
// process response
|
||||
switch($type)
|
||||
{
|
||||
case '': // timeout occured
|
||||
$timeout = $allow_timeout;
|
||||
break;
|
||||
case 'event':
|
||||
$this->process_event($parameters);
|
||||
break;
|
||||
case 'response':
|
||||
break;
|
||||
default:
|
||||
$this->log('Unhandled response packet from Manager: ' . print_r($parameters, true));
|
||||
break;
|
||||
}
|
||||
} while($type != 'response' && !$timeout);
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to Asterisk
|
||||
*
|
||||
* @example examples/sip_show_peer.php Get information about a sip peer
|
||||
*
|
||||
* @param string $server
|
||||
* @param string $username
|
||||
* @param string $secret
|
||||
* @return boolean true on success
|
||||
*/
|
||||
function connect($server=NULL, $username=NULL, $secret=NULL)
|
||||
{
|
||||
// use config if not specified
|
||||
if(is_null($server)) $server = $this->config['asmanager']['server'];
|
||||
if(is_null($username)) $username = $this->config['asmanager']['username'];
|
||||
if(is_null($secret)) $secret = $this->config['asmanager']['secret'];
|
||||
|
||||
// get port from server if specified
|
||||
if(strpos($server, ':') !== false)
|
||||
{
|
||||
$c = explode(':', $server);
|
||||
$this->server = $c[0];
|
||||
$this->port = $c[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->port = $this->config['asmanager']['port'];
|
||||
}
|
||||
|
||||
// connect the socket
|
||||
$errno = $errstr = NULL;
|
||||
$this->socket = @fsockopen($this->server, $this->port, $errno, $errstr);
|
||||
if($this->socket == false)
|
||||
{
|
||||
$this->log("Unable to connect to manager {$this->server}:{$this->port} ($errno): $errstr");
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the header
|
||||
$str = fgets($this->socket);
|
||||
if($str == false)
|
||||
{
|
||||
// a problem.
|
||||
$this->log("Asterisk Manager header not received.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// note: don't $this->log($str) until someone looks to see why it mangles the logging
|
||||
}
|
||||
|
||||
// login
|
||||
$res = $this->send_request('login', array('Username'=>$username, 'Secret'=>$secret));
|
||||
if($res['Response'] != 'Success')
|
||||
{
|
||||
$this->log("Failed to login.");
|
||||
$this->disconnect();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect
|
||||
*
|
||||
* @example examples/sip_show_peer.php Get information about a sip peer
|
||||
*/
|
||||
function disconnect()
|
||||
{
|
||||
$this->logoff();
|
||||
fclose($this->socket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Absolute Timeout
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+AbsoluteTimeout
|
||||
* @param string $channel
|
||||
* @param integer $timeout
|
||||
*/
|
||||
function AbsoluteTimeout($channel, $timeout)
|
||||
{
|
||||
return $this->send_request('AbsoluteTimeout', array('Channel'=>$channel, 'Timeout'=>$timeout));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change monitoring filename of a channel
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+ChangeMonitor
|
||||
* @param string $channel
|
||||
* @param string $file
|
||||
*/
|
||||
function ChangeMonitor($channel, $file)
|
||||
{
|
||||
return $this->send_request('ChangeMontior', array('Channel'=>$channel, 'File'=>$file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute Command
|
||||
*
|
||||
* @example examples/sip_show_peer.php Get information about a sip peer
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Command
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+CLI
|
||||
* @param string $commadn
|
||||
*/
|
||||
function Command($command)
|
||||
{
|
||||
return $this->send_request('Command', array('Command'=>$command));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable sending of events to this manager
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Events
|
||||
* @param string $eventmask is either 'on', 'off', or 'system,call,log'
|
||||
*/
|
||||
function Events($eventmask)
|
||||
{
|
||||
return $this->send_request('Events', array('EventMask'=>$eventmask));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Extension Status
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+ExtensionState
|
||||
* @param string $exten
|
||||
* @param string $context
|
||||
* @param string $actionid
|
||||
*/
|
||||
function ExtensionState($exten, $context, $actionid)
|
||||
{
|
||||
return $this->send_request('ExtensionState', array('Exten'=>$exten, 'Context'=>$context, 'ActionID'=>$actionid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a Channel Variable
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+GetVar
|
||||
* @param string $channel
|
||||
* @param string $variable
|
||||
*/
|
||||
function GetVar($channel, $variable)
|
||||
{
|
||||
return $this->send_request('GetVar', array('Channel'=>$channel, 'Variable'=>$variable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hangup Channel
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Hangup
|
||||
* @param string $channel
|
||||
*/
|
||||
function Hangup($channel)
|
||||
{
|
||||
return $this->send_request('Hangup', array('Channel'=>$channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* List IAX Peers
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+IAXpeers
|
||||
*/
|
||||
function IAXPeers()
|
||||
{
|
||||
return $this->send_request('IAXPeers');
|
||||
}
|
||||
|
||||
/**
|
||||
* List available manager commands
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+ListCommands
|
||||
*/
|
||||
function ListCommands()
|
||||
{
|
||||
return $this->send_request('ListCommands');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logoff Manager
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Logoff
|
||||
*/
|
||||
function Logoff()
|
||||
{
|
||||
return $this->send_request('Logoff');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Mailbox Message Count
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+MailboxCount
|
||||
* @param string $mailbox
|
||||
*/
|
||||
function MailboxCount($mailbox)
|
||||
{
|
||||
return $this->send_request('MailboxCount', array('Mailbox'=>$mailbox));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Mailbox
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+MailboxStatus
|
||||
* @param string $mailbox
|
||||
*/
|
||||
function MailboxStatus($mailbox)
|
||||
{
|
||||
return $this->send_request('MailboxStatus', array('Mailbox'=>$mailbox));
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor a channel
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Monitor
|
||||
* @param string $channel
|
||||
* @param string $file
|
||||
*/
|
||||
function Monitor($channel, $file)
|
||||
{
|
||||
return $this->send_request('Monitor', array('Channel'=>$channel, 'File'=>$file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Originate Call
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Originate
|
||||
* @param string $channel
|
||||
* @param string $exten
|
||||
* @param string $context
|
||||
* @param string $priority
|
||||
* @param integer $timeout
|
||||
* @param string $callerid
|
||||
* @param string $variable
|
||||
* @param string $account
|
||||
* @param string $application
|
||||
* @param string $data
|
||||
*/
|
||||
function Originate($channel, $exten, $context, $priority, $timeout, $callerid, $variable, $account, $application, $data)
|
||||
{
|
||||
$parameters = array();
|
||||
if($channel) $parameters['Channel'] = $channel;
|
||||
if($exten) $parameters['Exten'] = $exten;
|
||||
if($context) $parameters['Context'] = $context;
|
||||
if($priority) $parameters['Priority'] = $priority;
|
||||
if($timeout) $parameters['Timeout'] = $timeout;
|
||||
if($callerid) $parameters['CallerID'] = $callerid;
|
||||
if($variable) $parameters['Variable'] = $variable;
|
||||
if($account) $parameters['Account'] = $account;
|
||||
if($application) $parameters['Application'] = $application;
|
||||
if($data) $parameters['Data'] = $data;
|
||||
return $this->send_request('Originate', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* List parked calls
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+ParkedCalls
|
||||
*/
|
||||
function ParkedCalls()
|
||||
{
|
||||
return $this->send_request('ParkedCalls');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Ping
|
||||
*/
|
||||
function Ping()
|
||||
{
|
||||
return $this->send_request('Ping');
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Queues
|
||||
*/
|
||||
function Queues()
|
||||
{
|
||||
return $this->send_request('Queues');
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue Status
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+QueueStatus
|
||||
*/
|
||||
function QueueStatus()
|
||||
{
|
||||
return $this->send_request('QueueStatus');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Redirect
|
||||
* @param string $channel
|
||||
* @param string $extrachannel
|
||||
* @param string $exten
|
||||
* @param string $context
|
||||
* @param string $priority
|
||||
*/
|
||||
function Redirect($channel, $extrachannel, $exten, $context, $priority)
|
||||
{
|
||||
return $this->send_request('Redirect', array('Channel'=>$channel, 'ExtraChannel'=>$extrachannel, 'Exten'=>$exten,
|
||||
'Context'=>$context, 'Priority'=>$priority));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CDR UserField
|
||||
*/
|
||||
function SetCDRUserField()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('SetCDRUserField');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Channel Variable
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+SetVar
|
||||
* @param string $channel
|
||||
* @param string $variable
|
||||
* @param string $value
|
||||
*/
|
||||
function SetVar($channel, $variable, $value)
|
||||
{
|
||||
return $this->send_request('SetVar', array('Channel'=>$channel, 'Variable'=>$variable, 'Value'=>$value));
|
||||
}
|
||||
|
||||
/**
|
||||
* List SIP Peers
|
||||
*/
|
||||
function SIPpeers()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('SIPpeers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel Status
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+Status
|
||||
* @param string $channel
|
||||
*/
|
||||
function Status($channel)
|
||||
{
|
||||
return $this->send_request('Status', array('Channel'=>$channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop monitoring a channel
|
||||
*
|
||||
* @link http://www.voip-info.org/wiki-Asterisk+Manager+API+Action+StopMonitor
|
||||
* @param string $channel
|
||||
*/
|
||||
function StopMontor($channel)
|
||||
{
|
||||
return $this->send_request('StopMonitor', array('Channel'=>$channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dial over Zap channel while offhook
|
||||
*/
|
||||
function ZapDialOffhook()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('ZapDialOffhook');
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Zap channel Do Not Disturb status OFF
|
||||
*/
|
||||
function ZapDNDoff()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('ZapDNDoff');
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Zap channel Do Not Disturb status ON
|
||||
*/
|
||||
function ZapDNDon()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('ZapDNDon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hangup Zap Channel
|
||||
*/
|
||||
function ZapHangup()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('ZapHangup');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer Zap Channel
|
||||
*/
|
||||
function ZapTransfer()
|
||||
{
|
||||
// XXX need to look at source to find this function...
|
||||
return $this->send_request('ZapTransfer');
|
||||
}
|
||||
|
||||
/*
|
||||
* Log a message
|
||||
*
|
||||
* @param string $message
|
||||
* @param integer $level from 1 to 4
|
||||
*/
|
||||
function log($message, $level=1)
|
||||
{
|
||||
if($this->pagi != false)
|
||||
$this->pagi->conlog($message, $level);
|
||||
else
|
||||
error_log(date('r') . ' - ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add event handler
|
||||
*
|
||||
* Known Events include ( http://www.voip-info.org/wiki-asterisk+manager+events )
|
||||
* Link - Fired when two voice channels are linked together and voice data exchange commences.
|
||||
* Unlink - Fired when a link between two voice channels is discontinued, for example, just before call completion.
|
||||
* Newexten -
|
||||
* Hangup -
|
||||
* Newchannel -
|
||||
* Newstate -
|
||||
* Reload - Fired when the "RELOAD" console command is executed.
|
||||
* Shutdown -
|
||||
* ExtensionStatus -
|
||||
* Rename -
|
||||
* Newcallerid -
|
||||
* Alarm -
|
||||
* AlarmClear -
|
||||
* Agentcallbacklogoff -
|
||||
* Agentcallbacklogin -
|
||||
* Agentlogoff -
|
||||
* MeetmeJoin -
|
||||
* MessageWaiting -
|
||||
* join -
|
||||
* leave -
|
||||
* AgentCalled -
|
||||
* ParkedCall -
|
||||
* Cdr -
|
||||
* ParkedCallsComplete -
|
||||
* QueueParams -
|
||||
* QueueMember -
|
||||
* QueueStatusEnd -
|
||||
* Status -
|
||||
* StatusComplete -
|
||||
* ZapShowChannels -
|
||||
* ZapShowChannelsComplete -
|
||||
*
|
||||
* @param string $event type or * for default handler
|
||||
* @param string $callback function
|
||||
* @return boolean sucess
|
||||
*/
|
||||
function add_event_handler($event, $callback)
|
||||
{
|
||||
$event = strtolower($event);
|
||||
if(isset($this->event_handlers[$event]))
|
||||
{
|
||||
$this->log("$event handler is already defined, not over-writing.");
|
||||
return false;
|
||||
}
|
||||
$this->event_handlers[$event] = $callback;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process event
|
||||
*
|
||||
* @access private
|
||||
* @param array $parameters
|
||||
* @return mixed result of event handler or false if no handler was found
|
||||
*/
|
||||
function process_event($parameters)
|
||||
{
|
||||
$ret = false;
|
||||
$e = strtolower($parameters['Event']);
|
||||
$this->log("Got event.. $e");
|
||||
|
||||
$handler = '';
|
||||
if(isset($this->event_handlers[$e])) $handler = $this->event_handlers[$e];
|
||||
elseif(isset($this->event_handlers['*'])) $handler = $this->event_handlers['*'];
|
||||
|
||||
if(function_exists($handler))
|
||||
{
|
||||
$this->logg("Execute handler $handler");
|
||||
$ret = $handler($e, $parameters, $this->server, $this->port);
|
||||
}
|
||||
else
|
||||
$this->log("No event handler for event '$e'");
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
?>
|
42
asterisk sample source/phpagi/phpagi.example.conf
Normal file
42
asterisk sample source/phpagi/phpagi.example.conf
Normal file
@ -0,0 +1,42 @@
|
||||
// example phpagi.conf
|
||||
|
||||
[phpagi]
|
||||
|
||||
#enable debuging
|
||||
debug=true
|
||||
|
||||
#use internal error handler
|
||||
error_handler=true
|
||||
|
||||
#mail errors to
|
||||
admin=errors@intertech.net
|
||||
|
||||
#host name of this server
|
||||
hostname=sip.mydomain.com
|
||||
|
||||
# temporary directory for storing temporary output
|
||||
tempdir=/var/spool/asterisk/tmp/
|
||||
|
||||
|
||||
[festival]
|
||||
#path to text2wave binary
|
||||
text2wave=/usr/bin/text2wave
|
||||
|
||||
|
||||
[asmanager]
|
||||
# server to connect to
|
||||
server=localhost
|
||||
|
||||
# default manager port
|
||||
port=5038
|
||||
|
||||
#username for login
|
||||
username=me_and_only_me
|
||||
|
||||
#password for login
|
||||
secret=i_am_not_telling
|
||||
|
||||
[cepstral]
|
||||
#alternate text to speech engine
|
||||
swift=/opt/swift/bin/swift
|
||||
voice=David
|
1275
asterisk sample source/phpagi/phpagi.php
Normal file
1275
asterisk sample source/phpagi/phpagi.php
Normal file
File diff suppressed because it is too large
Load Diff
106
php_classes/AastraIPPhone.class.php
Normal file
106
php_classes/AastraIPPhone.class.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhone
|
||||
#
|
||||
# AastraIPPhone is the root class for all the Aastra XML objects.
|
||||
#
|
||||
# Public methods
|
||||
# setTitle(Title) to setup the title of an object
|
||||
# setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
||||
# addSoftkey(index,label,uri) to add custom soktkeys to the object (optional)
|
||||
# output() to display the object
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
require_once('AastraIPPhoneSoftkeyEntry.class.php');
|
||||
|
||||
class AastraIPPhone {
|
||||
var $_entries;
|
||||
var $_softkeys;
|
||||
var $_title;
|
||||
var $_destroyOnExit='';
|
||||
var $_refreshTimeout=0;
|
||||
var $_refreshURL='';
|
||||
var $_beep='';
|
||||
|
||||
function AastraIPPhone()
|
||||
{
|
||||
$this->_entries = array();
|
||||
$this->_softkeys = array();
|
||||
$this->_title = '';
|
||||
}
|
||||
|
||||
function setTitle($title)
|
||||
{
|
||||
$this->_title = $title;
|
||||
}
|
||||
|
||||
function setRefresh($timeout,$URL)
|
||||
{
|
||||
$this->_refreshTimeout = $timeout;
|
||||
$this->_refreshURL = $URL;
|
||||
}
|
||||
|
||||
function setBeep()
|
||||
{
|
||||
$this->_beep='yes';
|
||||
}
|
||||
|
||||
function setDestroyOnExit()
|
||||
{
|
||||
$this->_destroyOnExit='yes';
|
||||
}
|
||||
|
||||
function output()
|
||||
{
|
||||
header("Content-type: text/xml");
|
||||
if (($this->_refreshTimeout!=0) and ($this->_refreshURL!='')) header("Refresh: ".$this->_refreshTimeout."; url=".$this->_refreshURL);
|
||||
$output=$this->render();
|
||||
header("Content-Length: ".strlen($output));
|
||||
echo($output);
|
||||
}
|
||||
|
||||
function addSoftkey($index, $label, $uri)
|
||||
{
|
||||
$this->_softkeys[] = new AastraIPPhoneSoftkeyEntry($index, $label, $uri);
|
||||
}
|
||||
|
||||
function escape($string)
|
||||
{
|
||||
return(str_replace(
|
||||
array('<', '>', '&'),
|
||||
array('<', '>', '&'),
|
||||
$string
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
124
php_classes/AastraIPPhoneDirectory.class.php
Normal file
124
php_classes/AastraIPPhoneDirectory.class.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?
|
||||
|
||||
##################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneDirectory
|
||||
#
|
||||
# AastraIPPhoneDirectory object.
|
||||
#
|
||||
# Public methods
|
||||
#
|
||||
# Inherited from AastraIPPhone
|
||||
# setTitle(Title) to setup the title of an object
|
||||
# setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
# addSoftkey(index,label,uri) to add custom softkeys to the object (optional)
|
||||
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
||||
# output() to display the object
|
||||
#
|
||||
# Specific to the object
|
||||
# setNext(next) to set URI of the next page, optional
|
||||
# setPrevious(previous) to set URI of the previous page, optional
|
||||
# addEntry(name,phone) to add an element in the list to be displayed, at least one is needed.
|
||||
# natsortbyname() to order the list
|
||||
#
|
||||
# Example
|
||||
# require_once('AastraIPPhoneDirectory.class.php');
|
||||
# $directory = new AastraIPPhoneDirectory();
|
||||
# $directory->setTitle('Title');
|
||||
# $directory->setNext('http://myserver.com/script.php?page=2');
|
||||
# $directory->setPrevious('http://myserver.com/script.php?page=0');
|
||||
# $directory->setDestroyOnExit();
|
||||
# $directory->addEntry('John Doe', '200');
|
||||
# $directory->addEntry('Jane Doe', '201');
|
||||
# $directory->natsortByName();
|
||||
# $directory->addSoftkey('1','Label 1','http://myserver.com/script.php?action=1');
|
||||
# $directory->addSoftkey('6','Exit','SoftKey:Exit');
|
||||
# $directory->output();
|
||||
#
|
||||
########################################################################################################
|
||||
|
||||
require_once('AastraIPPhone.class.php');
|
||||
require_once('AastraIPPhoneDirectoryEntry.class.php');
|
||||
|
||||
class AastraIPPhoneDirectory extends AastraIPPhone {
|
||||
var $_next="";
|
||||
var $_previous="";
|
||||
|
||||
function setNext($next)
|
||||
{
|
||||
$this->_next = $next;
|
||||
}
|
||||
|
||||
function setPrevious($previous)
|
||||
{
|
||||
$this->_previous = $previous;
|
||||
}
|
||||
|
||||
function addEntry($name, $telephone)
|
||||
{
|
||||
$this->_entries[] = new AastraIPPhoneDirectoryEntry($name, $telephone);
|
||||
}
|
||||
|
||||
function natsortByName()
|
||||
{
|
||||
$tmpary = array();
|
||||
foreach ($this->_entries as $id => $entry) {
|
||||
$tmpary[$id] = $entry->getName();
|
||||
}
|
||||
natsort($tmpary);
|
||||
foreach ($tmpary as $id => $name) {
|
||||
$newele[] = $this->_entries[$id];
|
||||
}
|
||||
$this->_entries = $newele;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$title = $this->escape($this->_title);
|
||||
$next = $this->escape($this->_next);
|
||||
$previous = $this->escape($this->_previous);
|
||||
$out = '';
|
||||
$out .= "<AastraIPPhoneDirectory";
|
||||
if($previous!="") $out .= " previous=\"$previous\"";
|
||||
if($next!="") $out .= " next=\"$next\"";
|
||||
if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
|
||||
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
||||
$out .= ">\n";
|
||||
$out .= "<Title>{$title}</Title>\n";
|
||||
$index=0;
|
||||
foreach ($this->_entries as $entry) {
|
||||
if($index<15) $out .= $entry->render();
|
||||
$index++;
|
||||
}
|
||||
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
|
||||
$out .= "</AastraIPPhoneDirectory>\n";
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
58
php_classes/AastraIPPhoneDirectoryEntry.class.php
Normal file
58
php_classes/AastraIPPhoneDirectoryEntry.class.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneDirectoryEntry
|
||||
#
|
||||
# Internal class for AastraIPPhoneDirectory object.
|
||||
########################################################################################################
|
||||
|
||||
class AastraIPPhoneDirectoryEntry extends AastraIPPhone {
|
||||
var $_name;
|
||||
var $_telephone;
|
||||
|
||||
function AastraIPPhoneDirectoryEntry($name, $telephone)
|
||||
{
|
||||
$this->_name=$name;
|
||||
$this->_telephone=$telephone;
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return($this->_name);
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$name = $this->escape($this->_name);
|
||||
$telephone = $this->escape($this->_telephone);
|
||||
return("<MenuItem>\n<Prompt>{$name}</Prompt>\n<URI>{$telephone}</URI>\n</MenuItem>\n");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
73
php_classes/AastraIPPhoneExecute.class.php
Normal file
73
php_classes/AastraIPPhoneExecute.class.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
########################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneExecute
|
||||
#
|
||||
# AastraIPPhoneTextMenu object.
|
||||
#
|
||||
# Public methods
|
||||
#
|
||||
# Inherited from AastraIPPhone
|
||||
# output() to display the object
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
#
|
||||
# Specific to the object
|
||||
# addEntry(url) to add an action to be executed.
|
||||
#
|
||||
# Example
|
||||
# require_once('AastraIPPhoneExecute.class.php');
|
||||
# $execute = new AastraIPPhoneExecute();
|
||||
# $execute->addEntry('http://myserver.com/script.php?choice=2');
|
||||
# $execute->addEntry('Command: Reset');
|
||||
# $execute->output();
|
||||
#
|
||||
########################################################################################################
|
||||
|
||||
require_once('AastraIPPhone.class.php');
|
||||
require_once('AastraIPPhoneExecuteEntry.class.php');
|
||||
|
||||
class AastraIPPhoneExecute extends AastraIPPhone {
|
||||
|
||||
function addEntry($url)
|
||||
{
|
||||
$this->_entries[] = new AastraIPPhoneExecuteEntry($url);
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$title = $this->escape($this->_title);
|
||||
$out = "<AastraIPPhoneExecute";
|
||||
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
||||
$out .= ">\n";
|
||||
foreach ($this->_entries as $entry) $out .= $entry->render();
|
||||
$out .= "</AastraIPPhoneExecute>\n";
|
||||
return($out);
|
||||
}
|
||||
}
|
||||
?>
|
51
php_classes/AastraIPPhoneExecuteEntry.class.php
Normal file
51
php_classes/AastraIPPhoneExecuteEntry.class.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneExecuteEntry
|
||||
# Aastra 480i Firmware 1.4.1 or better
|
||||
#
|
||||
# Internal class for AastraIPPhoneExecute object.
|
||||
################################################################################
|
||||
|
||||
class AastraIPPhoneExecuteEntry extends AastraIPPhone {
|
||||
var $_url;
|
||||
|
||||
function AastraIPPhoneExecuteEntry($url)
|
||||
{
|
||||
$this->_url=$url;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$url = $this->escape($this->_url);
|
||||
$xml = "<ExecuteItem URI=\"".$url."\"/>\n";
|
||||
return($xml);
|
||||
}
|
||||
}
|
||||
?>
|
143
php_classes/AastraIPPhoneInputScreen.class.php
Normal file
143
php_classes/AastraIPPhoneInputScreen.class.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneInputScreen
|
||||
#
|
||||
# AastraIPPhoneInputScreen object.
|
||||
#
|
||||
# Public methods
|
||||
#
|
||||
# Inherited from AastraIPPhone
|
||||
# setTitle(Title) to setup the title of an object
|
||||
# setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
# addSoftkey(index,label,uri) to add custom softkeys to the object (optional)
|
||||
# output() to display the object
|
||||
#
|
||||
# Specific to the object
|
||||
# setURL() to set the URL to called after the input
|
||||
# setType(type) to set type of input ('IP', 'string'or 'number'), 'string'by default
|
||||
# setDefault(default) to set default value for the input (optional)
|
||||
# setParameter(param) to set the parameter name to be parsed after the input
|
||||
# setPassword() to set the Password parameter to 'yes', 'no' by default (optional)
|
||||
# setNotEditable() to set the editable parameter to 'no', 'yes' by default (optional)
|
||||
# setEditable() is now replaced by setNotEditable but kept for compatibility reasons (optional)
|
||||
# setPrompt(prompt) to set the prompt to be displayed for the input.
|
||||
#
|
||||
# Example
|
||||
# require_once('AastraIPPhoneInputScreen.class.php');
|
||||
# $input = new AastraIPPhoneInputScreen();
|
||||
# $input->setTitle('Title');
|
||||
# $input->setPrompt('Enter your password');
|
||||
# $input->setParameter('param');
|
||||
# $input->setType('string');
|
||||
# $input->setURL('http://myserver.com/script.php');
|
||||
# $input->setPassword();
|
||||
# $input->setDefault('');
|
||||
# $input->setDestroyOnExit();
|
||||
# $input->setNotEditable();
|
||||
# $input->addSoftkey('1','Label 1','http://myserver.com/script.php?action=1');
|
||||
# $input->addSoftkey('6','Exit','SoftKey:Exit');
|
||||
# $input->output();
|
||||
#
|
||||
########################################################################################################
|
||||
|
||||
require_once('AastraIPPhone.class.php');
|
||||
|
||||
class AastraIPPhoneInputScreen extends AastraIPPhone {
|
||||
var $_url;
|
||||
var $_type='string';
|
||||
var $_parameter;
|
||||
var $_prompt;
|
||||
var $_editable='';
|
||||
var $_default='';
|
||||
var $_password='';
|
||||
|
||||
function setURL($url)
|
||||
{
|
||||
$this->_url=$url;
|
||||
}
|
||||
function setType($type)
|
||||
{
|
||||
$this->_type=$type;
|
||||
}
|
||||
|
||||
function setEditable()
|
||||
{
|
||||
$this->_editable='no';
|
||||
}
|
||||
|
||||
function setNotEditable()
|
||||
{
|
||||
$this->_editable='no';
|
||||
}
|
||||
|
||||
function setDefault($default)
|
||||
{
|
||||
$this->_default=$default;
|
||||
}
|
||||
|
||||
function setParameter($parameter)
|
||||
{
|
||||
$this->_parameter=$parameter;
|
||||
}
|
||||
|
||||
function setPassword()
|
||||
{
|
||||
$this->_password='yes';
|
||||
}
|
||||
|
||||
function setPrompt($prompt)
|
||||
{
|
||||
$this->_prompt=$prompt;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$title = $this->escape($this->_title);
|
||||
$prompt = $this->escape($this->_prompt);
|
||||
$url = $this->escape($this->_url);
|
||||
$out = '';
|
||||
$out .= "<AastraIPPhoneInputScreen type=\"$this->_type\"";
|
||||
if($this->_password == 'yes') $out .= " password=\"yes\"";
|
||||
if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
|
||||
if($this->_editable == 'no') $out .= " editable=\"no\"";
|
||||
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
||||
$out .= ">\n";
|
||||
$out .= "<Title>{$title}</Title>\n";
|
||||
$out .= "<Prompt>{$prompt}</Prompt>\n";
|
||||
$out .= "<URL>{$url}</URL>\n";
|
||||
$out .= "<Parameter>{$this->_parameter}</Parameter>\n";
|
||||
$out .= "<Default>{$this->_default}</Default>\n";
|
||||
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
|
||||
$out .= "</AastraIPPhoneInputScreen>\n";
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
57
php_classes/AastraIPPhoneSoftkeyEntry.class.php
Normal file
57
php_classes/AastraIPPhoneSoftkeyEntry.class.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPSoftkeyEntry
|
||||
# Aastra 480i Firmware 1.4.1 or better
|
||||
#
|
||||
# Internal class for AastraIPPhone object.
|
||||
################################################################################
|
||||
|
||||
class AastraIPPhoneSoftkeyEntry extends AastraIPPhone {
|
||||
var $_index;
|
||||
var $_label;
|
||||
var $_uri;
|
||||
|
||||
function AastraIPPhoneSoftkeyEntry($index, $label, $uri)
|
||||
{
|
||||
$this->_index=$index;
|
||||
$this->_label=$label;
|
||||
$this->_uri=$uri;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$index = $this->_index;
|
||||
$uri = $this->escape($this->_uri);
|
||||
$label = $this->escape($this->_label);
|
||||
$xml = "<SoftKey index=\"$index\">\n<Label>{$label}</Label>\n<URI>{$uri}</URI>\n</SoftKey>\n";
|
||||
return($xml);
|
||||
}
|
||||
}
|
||||
?>
|
83
php_classes/AastraIPPhoneStatus.class.php
Normal file
83
php_classes/AastraIPPhoneStatus.class.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneStatus
|
||||
#
|
||||
# AastraIPPhoneStatus object.
|
||||
#
|
||||
# Public methods
|
||||
#
|
||||
# Inherited from AastraIPPhone
|
||||
# output() to display the object
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
#
|
||||
# Specific to the object
|
||||
# setSession(session) to setup the session ID
|
||||
# addEntry(index,message,type,timeout) to add a message to be displayed on the idle screen.
|
||||
#
|
||||
# Example
|
||||
# require_once('AastraIPPhoneStatus.class.php');
|
||||
# $status = new AastraIPPhoneStatus();
|
||||
# $status->setSession('Session');
|
||||
# $status->setBeep();
|
||||
# $status->addEntry('1','Message 1','',0);
|
||||
# $status->addEntry('2','Message 2','alert',5);
|
||||
# $status->output();
|
||||
#
|
||||
########################################################################################################
|
||||
|
||||
require_once('AastraIPPhone.class.php');
|
||||
require_once('AastraIPPhoneStatusEntry.class.php');
|
||||
|
||||
class AastraIPPhoneStatus extends AastraIPPhone {
|
||||
var $_session;
|
||||
|
||||
function setSession($session)
|
||||
{
|
||||
$this->_session=$session;
|
||||
}
|
||||
|
||||
function addEntry($index, $message, $type='', $timeout=NULL)
|
||||
{
|
||||
$this->_entries[] = new AastraIPPhoneStatusEntry($index, $message, $type, $timeout);
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$session = $this->escape($this->_session);
|
||||
$out = "<AastraIPPhoneStatus";
|
||||
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
||||
$out .= ">\n";
|
||||
$out .= "<Session>".$session."</Session>\n";
|
||||
foreach ($this->_entries as $entry) $out .= $entry->render();
|
||||
$out .= "</AastraIPPhoneStatus>\n";
|
||||
return($out);
|
||||
}
|
||||
}
|
||||
?>
|
66
php_classes/AastraIPPhoneStatusEntry.class.php
Normal file
66
php_classes/AastraIPPhoneStatusEntry.class.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
##################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
##################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneStatusEntry
|
||||
# Aastra 480i Firmware 1.4.1 or better
|
||||
#
|
||||
# Internal class for AastraIPPhoneStatus object.
|
||||
##################################################################################################
|
||||
|
||||
class AastraIPPhoneStatusEntry extends AastraIPPhone {
|
||||
var $_index;
|
||||
var $_message;
|
||||
var $_type='';
|
||||
var $_timeout=NULL;
|
||||
|
||||
function AastraIPPhoneStatusEntry($index, $message, $type, $timeout)
|
||||
{
|
||||
$this->_index=$index;
|
||||
$this->_message=$message;
|
||||
$this->_type=$type;
|
||||
$this->_timeout=$timeout;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$index = $this->escape($this->_index);
|
||||
$message = $this->escape($this->_message);
|
||||
$type = $this->_type;
|
||||
$timeout = $this->_timeout;
|
||||
$xml = "<Message index=\"{$index}\"";
|
||||
if ($type!='')
|
||||
{
|
||||
$xml .= " type=\"{$type}\"";
|
||||
if ($timeout!=NULL) $xml .= " Timeout=\"{$timeout}\"";
|
||||
}
|
||||
$xml .= ">{$message}</Message>\n";
|
||||
return($xml);
|
||||
}
|
||||
}
|
||||
?>
|
114
php_classes/AastraIPPhoneTextMenu.class.php
Normal file
114
php_classes/AastraIPPhoneTextMenu.class.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneTextMenu
|
||||
#
|
||||
# AastraIPPhoneTextMenu object.
|
||||
#
|
||||
# Public methods
|
||||
#
|
||||
# Inherited from AastraIPPhone
|
||||
# setTitle(Title) to setup the title of an object
|
||||
# setDestroyOnExit() to set DestroyOnExit parameter to "yes" (optional)
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
# addSoftkey(index,label,uri) to add custom softkeys to the object (optional)
|
||||
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
||||
# output() to display the object
|
||||
#
|
||||
# Specific to the object
|
||||
# setDestroyOnExit() to set DestroyOnExit parameter to "yes", optional
|
||||
# addEntry(name,url,selection) to add an element in the list to be displayed, at
|
||||
# least one is needed.
|
||||
# natsortbyname() to order the list
|
||||
#
|
||||
# Example
|
||||
# require_once('AastraIPPhoneTextMenu.class.php');
|
||||
# $menu = new AastraIPPhoneTextMenu();
|
||||
# $menu->setTitle('Title');
|
||||
# $menu->setDestroyOnExit();
|
||||
# $menu->setDefaultIndex();
|
||||
# $menu->addEntry('Choice 2', 'http://myserver.com/script.php?choice=2','');
|
||||
# $menu->addEntry('Choice 1', 'http://myserver.com/script.php?choice=1','');
|
||||
# $menu->addEntry('Choice 3', 'http://myserver.com/script.php?choice=3','');
|
||||
# $menu->natsortByName();
|
||||
# $menu->addSoftkey('1','Label 1','http://myserver.com/script.php?action=1');
|
||||
# $menu->addSoftkey('6','Exit','SoftKey:Exit');
|
||||
# $menu->output();
|
||||
#
|
||||
####################################################################################################
|
||||
|
||||
require_once('AastraIPPhone.class.php');
|
||||
require_once('AastraIPPhoneTextMenuEntry.class.php');
|
||||
|
||||
class AastraIPPhoneTextMenu extends AastraIPPhone {
|
||||
var $_defaultIndex="";
|
||||
|
||||
function setDefaultIndex($defaultIndex)
|
||||
{
|
||||
$this->_defaultIndex = $defaultIndex;
|
||||
}
|
||||
|
||||
function addEntry($name, $url, $selection=NULL)
|
||||
{
|
||||
$this->_entries[] = new AastraIPPhoneTextMenuEntry($name, $url, $selection);
|
||||
}
|
||||
|
||||
function natsortByName()
|
||||
{
|
||||
$tmpary = array();
|
||||
foreach ($this->_entries as $id => $entry) {
|
||||
$tmpary[$id] = $entry->getName();
|
||||
}
|
||||
natsort($tmpary);
|
||||
foreach ($tmpary as $id => $name) {
|
||||
$newele[] = $this->_entries[$id];
|
||||
}
|
||||
$this->_entries = $newele;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$title = $this->escape($this->_title);
|
||||
$out = "<AastraIPPhoneTextMenu ";
|
||||
if ($this->_destroyOnExit=='yes') $out .= "destroyOnExit=\"yes\" ";
|
||||
if ($this->_defaultIndex!="") $out .= "defaultIndex=\"{$this->_defaultIndex}\"";
|
||||
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
||||
$out .= ">\n";
|
||||
$out .= "<Title>".$title."</Title>\n";
|
||||
$index=0;
|
||||
foreach ($this->_entries as $entry) {
|
||||
if($index<15) $out .= $entry->render();
|
||||
$index++;
|
||||
}
|
||||
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
|
||||
$out .= "</AastraIPPhoneTextMenu>\n";
|
||||
return($out);
|
||||
}
|
||||
}
|
||||
?>
|
64
php_classes/AastraIPPhoneTextMenuEntry.class.php
Normal file
64
php_classes/AastraIPPhoneTextMenuEntry.class.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPTextMenuEntry
|
||||
# Aastra 480i Firmware 1.4.1 or better
|
||||
#
|
||||
# Internal class for AastraIPPhoneTextMenu object.
|
||||
###################################################################################################
|
||||
|
||||
class AastraIPPhoneTextMenuEntry extends AastraIPPhone {
|
||||
var $_name;
|
||||
var $_url;
|
||||
var $_selection;
|
||||
|
||||
function AastraIPPhoneTextMenuEntry($name, $url, $selection)
|
||||
{
|
||||
$this->_name=$name;
|
||||
$this->_url=$url;
|
||||
$this->_selection=$selection;
|
||||
}
|
||||
|
||||
function getName()
|
||||
{
|
||||
return($this->_name);
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$name = $this->escape($this->_name);
|
||||
$url = $this->escape($this->_url);
|
||||
$selection = $this->escape($this->_selection);
|
||||
$xml = "<MenuItem>\n<Prompt>{$name}</Prompt>\n<URI>{$url}</URI>\n";
|
||||
if($selection!=NULL) $xml .= "<Selection>{$selection}</Selection>\n";
|
||||
$xml .= "</MenuItem>\n";
|
||||
return($xml);
|
||||
}
|
||||
}
|
||||
?>
|
85
php_classes/AastraIPPhoneTextScreen.class.php
Normal file
85
php_classes/AastraIPPhoneTextScreen.class.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Aastra XML API Classes - AastraIPPhoneTextScreen
|
||||
#
|
||||
# AastraIPPhoneTextScreen object.
|
||||
#
|
||||
# Public methods
|
||||
#
|
||||
# Inherited from AastraIPPhone
|
||||
# setTitle(Title) to setup the title of an object
|
||||
# setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
||||
# setBeep() to enable a notification beep with the object (optional)
|
||||
# addSoftkey(index, label, uri) to add custom softkeys to the object (optional)
|
||||
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
||||
# output() to display the object
|
||||
#
|
||||
# Specific to the object
|
||||
# setText(text) to set the text to be displayed.
|
||||
#
|
||||
# Example
|
||||
# require_once('AastraIPPhoneTextScreen.class.php');
|
||||
# $text = new AastraIPPhoneTextScreen();
|
||||
# $text->setTitle('Title');
|
||||
# $text->setText('Text to be displayed.');
|
||||
# $text->setDestroyOnExit();
|
||||
# $text->addSoftkey('1','Label 1','http://myserver.com/script.php?action=1');
|
||||
# $text->addSoftkey('6','Exit','SoftKey:Exit');
|
||||
# $text->output();
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
require_once('AastraIPPhone.class.php');
|
||||
|
||||
class AastraIPPhoneTextScreen extends AastraIPPhone {
|
||||
var $_text;
|
||||
|
||||
function setText($text)
|
||||
{
|
||||
$this->_text = $text;
|
||||
}
|
||||
|
||||
function render()
|
||||
{
|
||||
$title = $this->escape($this->_title);
|
||||
$text = $this->escape($this->_text);
|
||||
$out = '';
|
||||
$out .= "<AastraIPPhoneTextScreen";
|
||||
if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
|
||||
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
||||
$out .= ">\n";
|
||||
$out .= "<Title>{$title}</Title>\n";
|
||||
$out .= "<Text>{$text}</Text>\n";
|
||||
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
|
||||
$out .= "</AastraIPPhoneTextScreen>\n";
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
24
php_classes/License.txt
Normal file
24
php_classes/License.txt
Normal file
@ -0,0 +1,24 @@
|
||||
Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
148
php_classes/sample.php
Normal file
148
php_classes/sample.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
###################################################################################################
|
||||
# Copyright (c) 2006 Aastra Telecom US, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of Aastra Telecom US, Inc. may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AASTRA TELECOM US, INC. ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL AASTRA TELECOM US, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
###################################################################################################
|
||||
# Sample php applications using the Aastra XML API Classes
|
||||
# Aastra SIP Phones Firmware 1.4.1 or better
|
||||
#
|
||||
# @param type, type of XML object to display
|
||||
# type=textmenu AastraIPPhoneTextMenu
|
||||
# type=textscreen AastraIPPhoneTextScreen
|
||||
# type=directory AastraIPPhoneDirectory
|
||||
# type=input AastraIPPhoneInputScreen
|
||||
# type=status AastraIPPhoneStatus
|
||||
# type=execute AastraIPPhoneExecute
|
||||
#
|
||||
##########################################################
|
||||
|
||||
##########################################################
|
||||
# Retrieve type parameter
|
||||
$type=$_GET['type'];
|
||||
$type='inputscreen';
|
||||
|
||||
# Display the object
|
||||
switch($type)
|
||||
{
|
||||
case 'textmenu':
|
||||
require_once('AastraIPPhoneTextMenu.class.php');
|
||||
$menu = new AastraIPPhoneTextMenu();
|
||||
$menu->setTitle('Title');
|
||||
# $menu->setDestroyOnExit();
|
||||
$menu->setDeFaultIndex('3');
|
||||
$menu->addEntry('Choice 2', 'http://65.205.71.13/php_classes/php_classes_1.4.1/sample.php', 'Value=2');
|
||||
$menu->addEntry('Choice 1', 'http://65.205.71.13/php_classes/php_classes_1.4.1/sample.php', 'Value=1');
|
||||
$menu->addEntry('Choice 3', 'http://65.205.71.13/php_classes/php_classes_1.4.1/sample.php', 'Value=3');
|
||||
$menu->output();
|
||||
|
||||
|
||||
# $menu = new AastraIPPhoneTextMenu();
|
||||
# $menu->setTitle('Title');
|
||||
# $menu->setDestroyOnExit();
|
||||
# $menu->setDeFaultIndex('3');
|
||||
# $menu->addEntry('Choice 2', 'http://myserver.com/script.php?choice=2', 'Value=2');
|
||||
# $menu->addEntry('Choice 1', 'http://myserver.com/script.php?choice=1', 'Value=1');
|
||||
# $menu->addEntry('Choice 3', 'http://myserver.com/script.php?choice=3', 'Value=3');
|
||||
# $menu->natsortByName();
|
||||
# $menu->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1');
|
||||
# $menu->addSoftkey('6', 'Exit', 'SoftKey:Exit');
|
||||
# $menu->output();
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 'textscreen':
|
||||
require_once('AastraIPPhoneTextScreen.class.php');
|
||||
$text = new AastraIPPhoneTextScreen();
|
||||
$text->setTitle('Title');
|
||||
$text->setText('Text to be displayed.');
|
||||
$text->setDestroyOnExit();
|
||||
$text->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1');
|
||||
$text->addSoftkey('6', 'Exit', 'SoftKey:Exit');
|
||||
$text->output();
|
||||
break;
|
||||
|
||||
case 'inputscreen':
|
||||
require_once('AastraIPPhoneInputScreen.class.php');
|
||||
$input = new AastraIPPhoneInputScreen();
|
||||
$input->setTitle('Test Input');
|
||||
$input->setPrompt('Pin code');
|
||||
$input->setParameter('password');
|
||||
$input->setType('number');
|
||||
$input->setURL('http://192.168.0.49/VoIPer/Default.aspx?type=T001&user=TEST&number=');
|
||||
$input->setPassword();
|
||||
$input->setDestroyOnExit();
|
||||
$input->output();
|
||||
|
||||
# $input = new AastraIPPhoneInputScreen();
|
||||
# $input->setTitle('Title');
|
||||
# $input->setPrompt('Enter your password');
|
||||
# $input->setParameter('param');
|
||||
# $input->setType('string');
|
||||
# $input->setURL('http://myserver.com/script.php');
|
||||
# $input->setPassword();
|
||||
# $input->setDestroyOnExit();
|
||||
# $input->setDefault('Default');
|
||||
# $input->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1');
|
||||
# $input->addSoftkey('6', 'Exit', 'SoftKey:Exit');
|
||||
# $input->output();
|
||||
break;
|
||||
|
||||
case 'directory':
|
||||
require_once('AastraIPPhoneDirectory.class.php');
|
||||
$directory = new AastraIPPhoneDirectory();
|
||||
$directory->setTitle('Title');
|
||||
$directory->setNext('http://myserver.com/script.php?page=2');
|
||||
$directory->setPrevious('http://myserver.com/script.php?page=0');
|
||||
$directory->setDestroyOnExit();
|
||||
$directory->addEntry('John Doe', '200');
|
||||
$directory->addEntry('Jane Doe', '201');
|
||||
$directory->natsortByName();
|
||||
$directory->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1');
|
||||
$directory->addSoftkey('6', 'Exit', 'SoftKey:Exit');
|
||||
$directory->output();
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
require_once('AastraIPPhoneStatus.class.php');
|
||||
$status = new AastraIPPhoneStatus();
|
||||
$status->setSession('Session');
|
||||
$status->setBeep();
|
||||
$status->addEntry('1','Message 1',"alert",5);
|
||||
$status->addEntry('2','Message 2');
|
||||
$status->output();
|
||||
break;
|
||||
|
||||
case 'execute':
|
||||
require_once('AastraIPPhoneExecute.class.php');
|
||||
$execute = new AastraIPPhoneExecute();
|
||||
$execute->addEntry('http://myserver.com/script.php?choice=2');
|
||||
$execute->addEntry('Command: Reset');
|
||||
$execute->output();
|
||||
break;
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user