Files
aastra-xml-php/php_classes/sample.php
2018-02-15 22:59:05 +01:00

377 lines
16 KiB
PHP

<?php
##########################################################
# Sample php applications using the Aastra XML API Classes
# Aastra SIP Phones Firmware 2.1.0 or better
# Copyright Aastra Telecom 2007
#
# @param type, type of XML object to display
# type=textmenu1 AastraIPPhoneTextMenu
# type=textmenu2 AastraIPPhoneTextMenu
# type=textmenu3 AastraIPPhoneTextMenu
# type=textscreen AastraIPPhoneTextScreen
# type=directory AastraIPPhoneDirectory
# type=inputscreen1 AastraIPPhoneInputScreen
# type=inputscreen2 AastraIPPhoneInputScreen
# type=inputscreen3 AastraIPPhoneInputScreen
# type=inputscreen4 AastraIPPhoneInputScreen
# type=status AastraIPPhoneStatus
# type=execute AastraIPPhoneExecute
# type=configuration AastraIPPhoneConfiguration
# type=imagescreen AastraIPPhoneImageScreen
# type=imagemenu AastraIPPhoneImageMenu
# type=formattedtextscreen AastraIPPhoneFormattedTextScreen
#
# If type is not set, the list of all the XML objects is displayed
#
##########################################################
##########################################################
# Aastra_decode_HTTP_header
#
# Returns an array
# 'model' Phone Type
# 'mac' Phone MAC Address
# 'firmware' Phone firmware version
# 'ip' Phone Remote IP address
# 'language' Phone Language
# 'module'[x] Expension Modules
#
function Aastra_decode_HTTP_header()
{
# User Agent
$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";
}
# Create array
$array=array('model'=>$value[0],'mac'=>$value[1],'firmware'=>$value[2]);
return($array);
}
##########################################################
# Retrieve type parameter
$type=$_GET['type'];
# Global parameters
$XML_SERVER = "http://".$_SERVER['SERVER_ADDR'].$_SERVER['SCRIPT_NAME'];
# Get UA information
$header=Aastra_decode_HTTP_header();
# Display the object
switch($type)
{
case '':
require_once('AastraIPPhoneTextMenu.class.php');
$menu = new AastraIPPhoneTextMenu();
$menu->setTitle('Sample Applications');
$menu->setDestroyOnExit();
$menu->addEntry('Configuration', $XML_SERVER.'?type=configuration');
$menu->addEntry('TextMenu1', $XML_SERVER.'?type=textmenu1');
$menu->addEntry('TextMenu2', $XML_SERVER.'?type=textmenu2');
$menu->addEntry('TextScreen', $XML_SERVER.'?type=textscreen');
$menu->addEntry('InputScreen1', $XML_SERVER.'?type=inputscreen1');
$menu->addEntry('InputScreen2', $XML_SERVER.'?type=inputscreen2');
$menu->addEntry('Status', $XML_SERVER.'?type=status');
$menu->addEntry('Execute', $XML_SERVER.'?type=execute');
if($header['model']!="Aastra53i")
{
$menu->addEntry('ImageScreen', $XML_SERVER.'?type=imagescreen');
$menu->addEntry('ImageMenu', $XML_SERVER.'?type=imagemenu');
$menu->addEntry('InputScreen3', $XML_SERVER.'?type=inputscreen3');
$menu->addEntry('InputScreen4', $XML_SERVER.'?type=inputscreen4');
$menu->addEntry('InputScreen5', $XML_SERVER.'?type=inputscreen5');
$menu->addEntry('Directory', $XML_SERVER.'?type=directory');
}
$menu->addEntry('FTextScreen1', $XML_SERVER.'?type=formattedtextscreen1');
$menu->addEntry('FTextScreen2', $XML_SERVER.'?type=formattedtextscreen2');
$menu->natsortByName();
$menu->output();
break;
case 'textmenu1':
require_once('AastraIPPhoneTextMenu.class.php');
$menu = new AastraIPPhoneTextMenu();
$menu->setTitle('Title this is a pretty long title');
$menu->setTitleWrap();
$menu->setDestroyOnExit();
$menu->setDeFaultIndex('3');
$menu->setStyle('radio');
$menu->addEntry('Choice 2', 'http://myserver.com/script.php?choice=2', 'Value=2','','12345');
$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->addEntry('Choice 4', 'http://myserver.com/script.php?choice=4', 'Value=4');
$menu->addEntry('Choice 5', 'http://myserver.com/script.php?choice=5', 'Value=5');
$menu->addEntry('Choice 6', 'http://myserver.com/script.php?choice=6', 'Value=6');
$menu->addEntry('Choice 7', 'http://myserver.com/script.php?choice=7', 'Value=7');
$menu->natsortByName();
$menu->addSoftkey('1', 'My Select', 'http://myserver.com/script.php?action=1');
$menu->addSoftkey('2', 'My Dial', 'SoftKey:Dial2');
$menu->addSoftkey('4', 'Back', $XML_SERVER);
$menu->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$menu->output();
break;
case 'textmenu2':
require_once('AastraIPPhoneTextMenu.class.php');
$menu = new AastraIPPhoneTextMenu();
$menu->setTitle('Title');
$menu->setDestroyOnExit();
$menu->setDeFaultIndex('2');
$menu->addEntry('Choice 2', 'http://myserver.com/script.php?choice=2', 'Value=2','1');
$menu->addEntry('Choice 1', 'http://myserver.com/script.php?choice=1', 'Value=1','2');
$menu->addEntry('Choice 3', 'http://myserver.com/script.php?choice=3', 'Value=3','3');
$menu->natsortByName();
$menu->addSoftkey('1', 'My Select', 'http://myserver.com/script.php?action=1');
$menu->addSoftkey('4', 'Back', $XML_SERVER);
$menu->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$menu->addIcon('1', 'Icon:PhoneOnHook');
$menu->addIcon('2', 'Icon:PhoneOffHook');
$menu->addIcon('3', 'Icon:PhoneRinging');
$menu->output();
break;
case 'textmenu3':
require_once('AastraIPPhoneTextMenu.class.php');
$menu = new AastraIPPhoneTextMenu();
$menu->setTitle('Title');
$menu->setDestroyOnExit();
$menu->addEntry('Choice 1', 'Dial:12345', 'Value=1', '', '6789');
$menu->addEntry('Choice 2', 'http://myserver.com/script.php?choice=2', 'Value=2','','12345');
$menu->addEntry('Choice 3', 'http://myserver.com/script.php?choice=3', 'Value=3');
$menu->addSoftkey('1', 'Select', 'SoftKey:Select');
$menu->addSoftkey('2', 'Dial', 'SoftKey:Dial');
$menu->addSoftkey('3', 'Dial2', 'SoftKey:Dial2');
$menu->addSoftkey('4', 'Back', $XML_SERVER);
$menu->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$menu->output();
break;
case 'textscreen':
require_once('AastraIPPhoneTextScreen.class.php');
$text = new AastraIPPhoneTextScreen();
$text->setTitle('Title');
$text->setText('The screen object can be implemented similar to the firmware info screen.');
$text->setDestroyOnExit();
$text->addSoftkey('1', 'Mail', 'http://myserver.com/script.php?action=1','1');
$text->addSoftkey('4', 'Back', $XML_SERVER);
$text->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$text->addIcon('1', 'Icon:Envelope');
$text->output();
break;
case 'inputscreen1':
require_once('AastraIPPhoneInputScreen.class.php');
$input = new AastraIPPhoneInputScreen();
$input->setTitle('Title');
$input->setPrompt('Enter date');
$input->setParameter('param');
$input->setType('string');
$input->setURL('http://myserver.com/script.php?test=1');
$input->setPassword();
$input->setDestroyOnExit();
$input->setDefault('');
$input->setCancelAction($XML_SERVER);
$input->output();
break;
case 'inputscreen2':
require_once('AastraIPPhoneInputScreen.class.php');
$input = new AastraIPPhoneInputScreen();
$input->setTitle('Title');
$input->setPrompt('Enter the date');
$input->setParameter('param');
$input->setType('dateUS');
$input->setURL('http://myserver.com/script.php');
$input->setDestroyOnExit();
$input->setCancelAction($XML_SERVER);
$input->output();
break;
case 'inputscreen3':
require_once('AastraIPPhoneInputScreen.class.php');
$input = new AastraIPPhoneInputScreen();
$input->setTitle('Title');
$input->setPrompt('Enter email address');
$input->setParameter('email');
$input->setType('string');
$input->setURL('http://myserver.com/script.php');
$input->addSoftkey('1', 'Backspace', 'SoftKey:BackSpace');
$input->addSoftkey('2', 'Symbols', 'SoftKey:SymbolList="@."');
$input->addSoftkey('5', 'Done', 'SoftKey:Submit');
$input->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$input->setDestroyOnExit();
$input->output();
break;
case 'inputscreen4':
require_once('AastraIPPhoneInputScreen.class.php');
$input = new AastraIPPhoneInputScreen();
$input->setTitle('Restricted application');
$input->setDisplayMode('condensed');
$input->setURL($XML_SERVER);
$input->setDestroyOnExit();
$input->addSoftkey('5', 'Done', 'SoftKey:Submit');
$input->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$input->addField();
$input->setFieldType('empty');
$input->addField('string');
$input->setFieldType('string');
$input->setFieldPrompt('Username:');
$input->setFieldParameter('user');
$input->addFieldSoftkey('3', 'ABC', 'SoftKey:ChangeMode');
$input->addField('number');
$input->setFieldPassword('yes');
$input->setFieldPrompt('Password:');
$input->setFieldParameter('password');
$input->output();
break;
case 'inputscreen5':
require_once('AastraIPPhoneInputScreen.class.php');
$input = new AastraIPPhoneInputScreen();
$input->setTitle('Date and Time');
$input->setURL('http://myserver.com/script.php');
$input->setDestroyOnExit();
$input->addSoftkey('5', 'Done', 'SoftKey:Submit');
$input->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$input->addField('dateUS');
$input->setFieldPrompt('Enter Date');
$input->setFieldParameter('date');
$input->addField('timeUS');
$input->setFieldPrompt('Enter Time');
$input->setFieldParameter('time');
$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('4', 'Back', $XML_SERVER);
$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->setTriggerDestroyOnExit();
$execute->addEntry('http://myserver.com/script.php?choice=2');
$execute->addEntry('Command: Reset');
$execute->addEntry('Command: FastReboot');
$execute->addEntry('Led: softkey1=on');
$execute->addEntry('Dial:7001','no');
$execute->output();
break;
case 'configuration':
require_once('AastraIPPhoneConfiguration.class.php');
$configuration = new AastraIPPhoneConfiguration();
$configuration->addEntry('softkey1 label','Test');
$configuration->addEntry('softkey1 type','xml');
$configuration->setTriggerDestroyOnExit();
$configuration->setBeep();
$configuration->output();
break;
case 'formattedtextscreen1':
require_once('AastraIPPhoneFormattedTextScreen.class.php');
$ftext = new AastraIPPhoneFormattedTextScreen();
$ftext->setDestroyOnExit();
if($header['model']!="Aastra53i") $ftext->addLine('Formatted Screen','double','center');
$ftext->setScrollStart('2');
$ftext->addLine('Scrolled text1');
$ftext->addLine('Scrolled text2');
$ftext->addLine('Scrolled text3','double');
$ftext->addLine('Scrolled text4');
$ftext->addLine('Scrolled text5');
$ftext->setScrollEnd();
$ftext->addLine('Footer',NULL,'center');
$ftext->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1','1');
$ftext->addSoftkey('4', 'Back', $XML_SERVER);
$ftext->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$ftext->addIcon('1', 'Icon:Envelope');
$ftext->output();
break;
case 'formattedtextscreen2':
require_once('AastraIPPhoneFormattedTextScreen.class.php');
$ftext = new AastraIPPhoneFormattedTextScreen();
$ftext->setDestroyOnExit();
$ftext->addLine('Line 1');
$ftext->addLine('Line 2');
$ftext->addLine('Line 3');
$ftext->addLine('Line 4');
$ftext->addLine('Line 5');
$ftext->addLine('Line 6');
$ftext->addSoftkey('1', 'Softkey 1', 'SoftKey:Exit');
$ftext->addSoftkey('2', 'Softkey 2', 'SoftKey:Exit');
$ftext->addSoftkey('3', 'Softkey 3', 'SoftKey:Exit');
$ftext->addSoftkey('4', 'Softkey 4', 'SoftKey:Exit');
$ftext->addSoftkey('5', 'Softkey 5', 'SoftKey:Exit');
$ftext->addSoftkey('6', 'Softkey 6', 'SoftKey:Exit');
$ftext->output();
break;
case 'imagescreen':
require_once('AastraIPPhoneImageScreen.class.php');
$images = new AastraIPPhoneImageScreen();
$images->setDestroyOnExit();
$images->setSize(40,144);
$images->setImage('fffffffc02fffffffee4ffffbfffc05fffe7ff7a7ffffffffeffeebd7fffffea6bcfffffe796f3feff6fa289f0a86f4866fa20df42414595dd0134f8037ed1637f0e2522b2dd003b6eb936f05fffbd4f4107bba6eb0080e93715000010b754001281271408c640252081b1b22500013c5c66201368004e04467520dc11067152b82094d418e100247205805494780105002601530020931400020ac5c91088b0f2b08c21c07d0c2006009fdfe81f80efe0107fe0fb1c3ffff8ffc3fffef8f7febffbfcf87ffbff64');
$images->addSoftkey('1', 'Mail', 'http://myserver.com/script.php?action=1','1');
$images->addSoftkey('4', 'Back', $XML_SERVER);
$images->addSoftkey('6', 'Exit', 'SoftKey:Exit',2);
$images->addIcon('1', 'Icon:Envelope');
$images->output();
break;
case 'imagemenu':
require_once('AastraIPPhoneImageMenu.class.php');
$imagem = new AastraIPPhoneImageMenu();
$imagem->setDestroyOnExit();
$imagem->setSize(40,144);
$imagem->setImage('fffffffc02fffffffee4ffffbfffc05fffe7ff7a7ffffffffeffeebd7fffffea6bcfffffe796f3feff6fa289f0a86f4866fa20df42414595dd0134f8037ed1637f0e2522b2dd003b6eb936f05fffbd4f4107bba6eb0080e93715000010b754001281271408c640252081b1b22500013c5c66201368004e04467520dc11067152b82094d418e100247205805494780105002601530020131400020a05c91088b002b08c21c0000c200000001fe800000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020041000004008300000ff08500000000c900000000710000000000000001401400000140140000014014000001401400000140140000000000000007c0ff00000c30880000081088000008108800000c30700000062000000000003f000001e02000000330200000021000000003301e000001e0330000000021000003f033000002001e0000020000000000001e000c03fc33003c013021007c02101201f00330ff03f001e000039000003e039001e00103f003300101f8021003007c03303f003c01e000000c00001e001c03f033007802002100f002002103e000001203c401702003cc0290ff039c02902101fc02b000007c03f01a003c020039018c0ff02d03c402102703c400001203ec01e000026402b0000264029000026c029000027c01a0000338000000033800000003100000000300000000030003f00003fc03000003fc02000003fc020000030001f0000300000000030001e000030002b000030002900003fc02900003fc01a00003f00000000310030000031c01e000031f003000033f81e00003f383000001e081e000008c003000003c01e00000fc03000001f000000003d001a0000390039000039002d00003f002700000f8012000007c000000001c0000000004000000000000000000000000000');
$imagem->addURI('1','http://myserver.com?choice=1');
$imagem->addURI('2','http://myserver.com?Choice=2');
$imagem->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1','1');
$imagem->addSoftkey('4', 'Back', $XML_SERVER);
$imagem->addSoftkey('6', 'Exit', 'SoftKey:Exit');
$imagem->addIcon('1', 'Icon:Envelope');
$imagem->addIcon('2', 'FFFF0000FFFF0000');
$imagem->output();
break;
}
?>