Introduction
The Cisco 79XX Phones include a mini-browser that allows the phone to interact with specially designed web services. These services can be developed as a CGI script on an HTTP server which outputs content using the XML syntax presented in this document.
A phone operator presses the "Services" button to access a menu of available services. Using the numeric key pad or the up/down button, a service is selected. The phone will then contact Apache to download an XML document which can contain the description of an object. These objects can be one of six different types.
This document will show you how to use PHP and Apache, all open source tools, to provide these services to your phones.
NB Currently, this document covers version 3.0 of CMXML. Current SIP firmware (6.1) for Cisco Phones will only work with the syntax below. CMXML 3.1 to 4.0 is supported only by SCCP phones.
XML Push is only supported with the SCCP image.
To achieve a dynamic page with the SIP image you can use the http header refresh directive.
XML applications written for Cisco 79XX IP Phones can be delivered to other types of IP Phones and IP Endpoints using a middleware technology from Millenigence called DashPhone CXP.
Cisco Documentation
Perhaps a good place to start is the Cisco documentation -
Cisco IP Phone Services Application Development Notes (Cisco IP Phone XML Objects)
This is a callmanager document which also pertains to SIP.
For SIP image limitations see -
Cisco SIP IP Phone Administrator Guide, Versions 6.x and 7.x - Managing Cisco SIP IP Phones - XML Cards
XML Objects Types
When service applications send XML displays to the Cisco phone, they must ensure that Apache outputs the content with a MIME text/xml type, which can be accomplished with the PHP header() function.
The code sample below will send the necessary headers using PHP.
<?
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
?>
CiscoIPPhoneDirectory
This object is the same as the one used by the phone when you press the "Directory" button. Using this object will allow you to present a dialing directory of up to 32 entries.Syntax
<CiscoIPPhoneDirectory>
<Title>Name Of Directory</Title>
<Prompt>Prompt text.</Prompt>
<DirectoryEntry>
<Name>Name of Person or Company</Name>
<Telephone>TelephoneNumber</Telephone>
</DirectoryEntry>
<DirectoryEntry>
<Name>Name of Person or Company</Name>
<Telephone>TelephoneNumber</Telephone>
</DirectoryEntry>
</CiscoIPPhoneDirectory>
Example PHP Source Code
<?
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
$mysql_conn = mysql_connect("localhost", "asteriskuser", "");
mysql_select_db("directory", $mysql_conn);
$result = mysql_query("SELECT name,tel FROM lunchdir", $mysql_conn);
print("<CiscoIPPhoneDirectory>\n");
print("\t<Title>Lunch Time Essentials</Title>\n");
print("\t<Prompt>Who will deliver food today?</Prompt>\n");
while($row = mysql_fetch_row($result))
{
print("\t<DirectoryEntry>\n");
print("\t\t<Name>");
print($row[0]);
print("</Name>\n");
print("\t\t<Telephone>");
print($row[1]);
print("</Telephone>\n");
print("\t</DirectoryEntry>\n");
}
print("</CiscoIPPhoneDirectory>\n");
?>
vCard to Cisco IP Phone CMXML Directory Script for PHP
Other open-source integration scripts are available to retrieve directory content from relational databases or LDAP servers. These are great methods, but some of us don't want the hassle of running yet another directory server or database since all the contacts we want are stored in our local address book and not in a web-connected database or LDAP server.This script from VOSTROM gives you the ability to search your vCard file by name or browse through your vCard file name-by-name using your 79XX IP Phone's External Directory feature. You can simply tap Dial to call any entry. But unlike many other scripts, this this supports paging (Next page, ...) to get around the phone's silly limitation on number of entries per page (32), reformats phone numbers automatically to work with the IP Phone, and even labels entries with Work, Mobile, Home, or Main for contacts with multiple phone numbers. Easy to integrate (no database or LDAP server required), and also easy to use as a basis for adding your own SQL queries or LDAP queries if you have names stored there--See the addEntry() function. View the PHP source code here. There is some documentation here including a 3-step, 5-minute setup process.
CiscoIPPhoneGraphicMenu
Syntax
<CiscoIPPhoneGraphicMenu>
<Title>Title of Graphic Menu</Title>
<LocationX>Position - X Coordinate</LocationX>
<LocationY>Position - Y Coordinate</LocationY>
<Width>Width of Image</Width>
<Height>Height of image</Height>
<Depth>Pixel Depth of image</Depth>
<Data>Image Data (Hex)</Data>
<Prompt>Prompt text.</Prompt>
<MenuItem>
<Name>Name of Menu Item.</Name>
<URL>http://url.of.site.com/services/command.php</URL>
</MenuItem>
<MenuItem>
<Name>Name of Menu Item.</Name>
<URL>http://url.of.site.com/services/command.php</URL>
</MenuItem>
</CiscoIPPhoneGraphicMenu>
CiscoIPPhoneImage
Syntax
<CiscoIPPhoneImage>
<Title>Title of Image</Title>
<LocationX>Position - X Coordinate</LocationX>
<LocationY>Position - Y Coordinate</LocationY>
<Width>Width of Image</Width>
<Height>Height of image</Height>
<Depth>Pixel Depth of image</Depth>
<Data>Image Data (Hex)</Data>
<Prompt>Prompt text.</Prompt>
</CiscoIPPhoneImage>
CiscoIPPhoneInput
Syntax
<CiscoIPPhoneInput>
<Title>Title</Title>
<Prompt>Prompt text.</Prompt>
<URL>http://url.of.site.com/services/command.php</URL>
<InputItem>
<DisplayName>Name of field.</DisplayName>
<QueryStringParam>TelephoneNumber</QueryStringParam>
<InputFlags></InputFlags>
<DefaultValue>Value</DefaultValue>
</InputItem>
</CiscoIPPhoneInput>
CiscoIPPhoneMenu
Syntax
<CiscoIPPhoneMenu>
<Title>Title of Menu</Title>
<Prompt>Prompt text.</Prompt>
<MenuItem>
<Name>Name of Menu Item.</Name>
<URL>http://url.of.site.com/services/command.php</URL>
</MenuItem>
<MenuItem>
<Name>Name of Menu Item.</Name>
<URL>http://url.of.site.com/services/command.php</URL>
</MenuItem>
</CiscoIPPhoneMenu>
CiscoIPPhoneText
Syntax
<CiscoIPPhoneText>
<Title>Title Here.</Title>
<Text>Text message to display.</Text>
<Prompt>Prompt text.</Prompt>
</CiscoIPPhoneText>
CiscoIPPhone PHP Classes
http://www.kludgebox.com/index.php?p=8Working Examples
A working example of some XML Services can be found at the following addresses:
BT Exact IP Phone Services:
http://193.113.58.136/xml/ - NOTE: Doesn't work on current SIP firmware
http://193.113.58.136/bt/ - Non-Graphical version of above which DOES work.
These pages are generated with ASP
(times out on 18/01/2006 06:36 GMT)
http://193.113.58.136/xml/ - NOTE: Doesn't work on current SIP firmware
http://193.113.58.136/bt/ - Non-Graphical version of above which DOES work.
These pages are generated with ASP
(times out on 18/01/2006 06:36 GMT)
Berbee XML Services:
http://phone-xml.berbee.com/menu.xml - Nice working Graphical menu with useful stuff
These pages are generated with Perl
http://phone-xml.berbee.com/menu.xml - Nice working Graphical menu with useful stuff
These pages are generated with Perl
McFadden XML RSS News Service:
http://xmlsvc.csma.biz/ - (Live) PHP Script for displaying news headlines from RSS feeds. Can be used via this site or downloaded for local installation.
http://xmlsvc.csma.biz/ - (Live) PHP Script for displaying news headlines from RSS feeds. Can be used via this site or downloaded for local installation.
Open 79XX XML Directory:
Open79XXDir - Open PHP/MySQL XML Services content management system for Cisco 79XX XML Phones.
Open79XXDir - Open PHP/MySQL XML Services content management system for Cisco 79XX XML Phones.
cxs:
http://www.btinternet.com/~andrewjk/cxs - Flexible and extensible directory service for Cisco 7900 series IP phones
Written in C# and utilising the Microsoft .NET Framework cxs allows access to a number of directories through a standard provider interface allowing other further directory services to be added with ease. Currently supported directories are LDAP, Microsoft Outlook Business Contact Manager and OLE DB compatible databases.
http://www.btinternet.com/~andrewjk/cxs - Flexible and extensible directory service for Cisco 7900 series IP phones
Written in C# and utilising the Microsoft .NET Framework cxs allows access to a number of directories through a standard provider interface allowing other further directory services to be added with ease. Currently supported directories are LDAP, Microsoft Outlook Business Contact Manager and OLE DB compatible databases.
Phil's XML Portal:
http://flame.tiefighter.org/fwd/xml/ 404s on 18/01/2006 06:36 GMT
My own portal which links to the above two sites, and also has a work in progress of the above PHP code, using a mysql db to serve up a phone directory
http://flame.tiefighter.org/fwd/xml/ 404s on 18/01/2006 06:36 GMT
My own portal which links to the above two sites, and also has a work in progress of the above PHP code, using a mysql db to serve up a phone directory
http://www.dontpokebadgers.com/RSS2Cisco/
This script will take RSS feeds and convert them to be displayed on Cisco's IP based phones such as the 7940 and 7960.
http://cvs.largeone.net/index.cgi/*checkout*/asterisk/scripts/search.cgi
Directory script to csv file
http://cvs.largeone.net/index.cgi/*checkout*/asterisk/scripts/status.cgi
Directory for internal numbers that uses the asterisk manager interface to show whether someone is on the phone
http://llg.cubic.org/tools/cisco.html
Links to 5 XML services (some german). The site also provides an enhanced version of the rss2cisco script from dontpokebadgers.
http://www.tjir.za.net/rss.html
An updated version of the rss2cisco.pl script from above that supports the XML browser on CISCO 796x, 794x and 797x IP Phones running SIP images and provides some debug/phone information.
MPD (Music Player Daemon) basic client (*unsecure*, you have to use .htaccess)
main.xml :
<CiscoIPPhoneMenu>
<Title>MPD</Title>
<Prompt>Play Music NOW !</Prompt>
<MenuItem>
<Name>Status</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=</URL>
</MenuItem>
<MenuItem>
<Name>Play - Pause</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=toggle</URL>
</MenuItem>
<MenuItem>
<Name>Stop</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=stop</URL>
</MenuItem>
<MenuItem>
<Name>Next</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=next</URL>
</MenuItem>
<MenuItem>
<Name>Previous</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=prev</URL>
</MenuItem>
</CiscoIPPhoneMenu>
cmd.php :
<?php
$cmd = $_GET"cmd";
exec("mpc $cmd", $ret);
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
if ($cmd != "status")
header("Location: http://host.tld/cisco/mpd/cmd.php?cmd=status");
else
header("Refresh: 2");
if ($cmd == "status")
{
echo "<CiscoIPPhoneText>\n";
echo "<Title>MPD</Title>\n";
echo "<Text>";
foreach ($ret as $r)
echo "$r\n";
echo "</Text>\n";
echo "</CiscoIPPhoneText>\n";
}
?>
main.xml :
<CiscoIPPhoneMenu>
<Title>MPD</Title>
<Prompt>Play Music NOW !</Prompt>
<MenuItem>
<Name>Status</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=</URL>
</MenuItem>
<MenuItem>
<Name>Play - Pause</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=toggle</URL>
</MenuItem>
<MenuItem>
<Name>Stop</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=stop</URL>
</MenuItem>
<MenuItem>
<Name>Next</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=next</URL>
</MenuItem>
<MenuItem>
<Name>Previous</Name>
<URL>http://host.tld/cisco/mpd/cmd.php?cmd=prev</URL>
</MenuItem>
</CiscoIPPhoneMenu>
cmd.php :
<?php
$cmd = $_GET"cmd";
exec("mpc $cmd", $ret);
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
if ($cmd != "status")
header("Location: http://host.tld/cisco/mpd/cmd.php?cmd=status");
else
header("Refresh: 2");
if ($cmd == "status")
{
echo "<CiscoIPPhoneText>\n";
echo "<Title>MPD</Title>\n";
echo "<Text>";
foreach ($ret as $r)
echo "$r\n";
echo "</Text>\n";
echo "</CiscoIPPhoneText>\n";
}
?>
Asterisk Directory
Use this PHP script to generate an Asterisk sip.conf, skinny.conf, and iax.conf based directory.
NOTE: Only entries which use the 'name' key are considered. Previously used 'callerid', but ran into problems parsing callerid if the extension was included. For each user you want added to the directory add 'name=User' to their respective profile. Change the
$location and $dirname variables depending on your configuration.
Verified to work with P0S3-07-5-00
Verified to work with P0S3-08-2-00 3-9-06 --ctwohig
http://users.marshall.edu/~twohig5/directory.php.txt
P0S3-08-2-00 is listed on Cisco's site but not with the rest of the SIP images,
on the voice downloads page follow the link for Cisco IP Phone FW 7900 Series.
It is listed as a download for CCM v5.0
http://www.cisco.com/cgi-bin/tablebuild.pl/ip-7900ser
tc0nn: P0S3-08-2-00 zip file (instead of the "cop" file) is listed on this page:
http://www.cisco.com/cgi-bin/tablebuild.pl/sip-ip-phone7960
- http://www-106.ibm.com/developerworks/wireless/library/wi-voip/
- Cisco 79XX XML Push
- cisco 79xx
- Asterisk phone cisco 79xx
Page Changes
Re: PHP Image to CIP Converter
And one more thing. I need to convert a text/srting to CIP and don't have a clue where to start. can you please help with that also.
Cheers Danny(RSA)
Re: PHP Image to CIP Converter
And one more thing. I need to convert a text/srting to CIP and don't have a clue where to start. can you please help with that also.
Cheers Danny(RSA)
ASP RSS to Cisco XML Parser/Parsing
This script requires the HTML strip component downloadable here: http://www.example-code.com/asp/asp_strip_html.asp
Script 1 - This one loads REUTERS news:
<%
response.write "<CiscoIPPhoneText>"
' Simply change the lines below to reflect your feed.
const inputRSSFile = "http://feeds.reuters.com/reuters/topNews"
response.write "<Title>" & "Reuters Headlines" & "</Title>"
' That's it!
Set xmlhttp = Server.CreateObject("msxml2.serverxmlhttp")
set cks = Server.CreateObject("CkString.CkString")
xmlhttp.Open "GET", inputRSSFile, false
xmlhttp.Send
set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.async = false
objXMLDoc.loadxml(xmlhttp.ResponseText)
counter = 1
response.write "<Text>"
for each ParentNode in objXMLDoc.documentElement.childNodes
for each ChildN in ParentNode.ChildNodes
if childN.nodeName= "item" then
counter = counter + 1
for each tmpNode in childN.ChildNodes
if tmpNode.nodeName = "title" then
marqueeString= marqueeString & tmpNode.text & ""
response.write "" & tmpNode.text & vbCrLf
response.write "---------------------------------"
end if
if tmpNode.nodeName = "description" then
marqueeString= marqueeString & tmpNode.text & ""
cks.Str = tmpNode.text
cks.StripHtml
response.write "" & cks.Str & "" & vbCrLf
response.write "---------------------------------"
end if
' if tmpNode.nodeName = "pubDate" then
' marqueeString= marqueeString & "" & tmpNode.text & "" &" "
' response.write "" & tmpNode.text & ""
' end if
next
if counter > 10 then exit for
end if
next
next
response.write "</Text>"
response.write "</CiscoIPPhoneText>"
%>
This one requests a stock quote from NASDAQ from a Cisco INPUT form and parses it for phone display (quite a hack):
<%
response.write "<CiscoIPPhoneText>"
' Simply change the lines below to reflect your feed.
inputRSSFile = "http://www.nasdaq.com/aspxcontent/NasdaqRSS.aspx?data=quotes&symbol=" & Request.Querystring("symbol")
response.write "<Title>" & "Stock Quote" & "</Title>"
' That's it!
Set xmlhttp = Server.CreateObject("msxml2.serverxmlhttp")
set cks = Server.CreateObject("CkString.CkString")
xmlhttp.Open "GET", inputRSSFile, false
xmlhttp.Send
set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.async = false
objXMLDoc.loadxml(xmlhttp.ResponseText)
response.write "<Text>Quote for Symbol:"
for each ParentNode in objXMLDoc.documentElement.childNodes
for each ChildN in ParentNode.ChildNodes
if childN.nodeName= "item" then
for each tmpNode in childN.ChildNodes
if tmpNode.nodeName = "description" then
marqueeString= marqueeString & tmpNode.text & ""
cks.Str = tmpNode.text
cks.StripHtml
cks.Str = replace(cks.Str, vbCrLf, "")
cks.Str = replace(cks.Str, " ", "")
cks.Str = replace(cks.Str, " ", " ")
cks.Str = replace(cks.Str, "View: Summary Quote | News", "")
cks.Str = replace(cks.Str, " ", "")
cks.Str = replace(cks.Str, " ", "")
cks.Str = replace(cks.Str, " ", "")
cks.Str = replace(cks.Str, vbLf, "")
cks.Str = replace(cks.Str, "Last", vbCrLf & "Last")
cks.Str = replace(cks.Str, "Change", vbCrLf & "Change")
cks.Str = replace(cks.Str, "% Change", vbCrLf & "% Change")
cks.Str = replace(cks.Str, "Volume", vbCrLf & "Volume")
cks.Str = replace(cks.Str, "As of", vbCrLf & "Quote as of")
response.write "" & cks.Str & vbCrLf
end if
' if tmpNode.nodeName = "pubDate" then
' marqueeString= marqueeString & "" & tmpNode.text & "" &" "
' response.write "" & tmpNode.text & ""
' end if
next
end if
next
next
response.write "</Text>"
response.write "</CiscoIPPhoneText>"
%>
This one collects input and displays the weather based on INPUT from the user:
<%
response.write "<CiscoIPPhoneText>"
' Simply change the lines below to reflect your feed.
inputRSSFile = "http://weather.yahooapis.com/forecastrss?p=" & Request.Querystring("zip")
response.write "<Title>" & "Current Weather" & "</Title>"
' That's it!
Set xmlhttp = Server.CreateObject("msxml2.serverxmlhttp")
set cks = Server.CreateObject("CkString.CkString")
xmlhttp.Open "GET", inputRSSFile, false
xmlhttp.Send
set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.async = false
objXMLDoc.loadxml(xmlhttp.ResponseText)
response.write "<Text>"
for each ParentNode in objXMLDoc.documentElement.childNodes
for each ChildN in ParentNode.ChildNodes
if childN.nodeName= "item" then
for each tmpNode in childN.ChildNodes
if tmpNode.nodeName = "title" then
response.write "---------------------------------"
marqueeString= marqueeString & tmpNode.text & ""
response.write "" & tmpNode.text & vbCrLf
response.write "---------------------------------"
end if
if tmpNode.nodeName = "description" then
marqueeString= marqueeString & tmpNode.text & " "
cks.Str = tmpNode.text
cks.StripHtml
response.write "" & cks.Str & "" & vbCrLf
end if
' if tmpNode.nodeName = "pubDate" then
' marqueeString= marqueeString & "" & tmpNode.text & "" &" "
' response.write "" & tmpNode.text & ""
' end if
next
end if
next
next
response.write "</Text>"
response.write "</CiscoIPPhoneText>"
%>
PHP Image to CIP Converter
I also found a gif2cip executable solution developed by Mark Palmer (http://search.cpan.org/~mrpalmer/Cisco-IPPhone-0.05) which was helpful, but I wanted to be able to dynamically create images on the fly rather than having to run them through the gif2cip converter first. Thus I created this PHP script which allows for GIF/JPG/PNG conversion to packed HEX which the Cisco phones read.
One minor issue occurs with transparent GIF/PNG images, as the imagecreatetruecolor PHP function midway through the script renders the pixels as black rather than the desired white. This can be solved, with a slight trade off in quality by replacing the imagecreatetruecolor function in the script with imagecreate.
Copy the following code and save as a .php file on a webserver which is accessible from your Cisco 79xx phone. Then, from either CallManager or by manually modifying the SEPMACADDRESS.cnf.xml file, have your <servicesURL> tag point at the .php file you created.
<?
//Image filename
$IMAGESOURCE = "http://ca.php.net/images/php.gif";
//Sets the max width and height for the image
$MAXWIDTH = 133;
$MAXHEIGHT = 65;
//Sets the display location on the phone
$LOCATIONX = -1;
$LOCATIONY = -1;
//Sets the decimal RGB ranges for binary conversion
$LOW = 100;
$MEDIUM = 150;
$HIGH = 200;
/*************** PROBABLY NO NEED TO EDIT BELOW HERE ***************/
//Checks to see if the image exists
if (strtolower(substr($IMAGESOURCE,0,7)) == "http://") {
$IMAGEHEADER = @get_headers($IMAGESOURCE);
if (!preg_match("|200|", $IMAGEHEADER0)) {
echo "ERROR:\n\nRemote Image Does Not Exist\n\n"; exit; }}
elseif (!file_exists($IMAGESOURCE)) {
echo "ERROR:\n\nImage Does Not Exist\n\n"; exit; }
//Creates a cached copy of the image based on the extension
if (strtolower(substr($IMAGESOURCE,-3,3)) == "gif") {
$IMAGECACHE = @imagecreatefromgif($IMAGESOURCE); }
elseif (strtolower(substr($IMAGESOURCE,-3,3)) == "jpg") {
$IMAGECACHE = @imagecreatefromjpeg($IMAGESOURCE); }
elseif (strtolower(substr($IMAGESOURCE,-3,3)) == "png") {
$IMAGECACHE = @imagecreatefrompng($IMAGESOURCE); }
else { echo "ERROR:\n\nImage Format Not Recognized\n\n"; exit; }
//Gets the width and height of the image
list($IMAGEWIDTH, $IMAGEHEIGHT) = getimagesize($IMAGESOURCE);
//Gets the width to height ratio of the image
$SOURCERATIO = $IMAGEWIDTH/$IMAGEHEIGHT;
//Checks to see if the image needs resizing
if ($IMAGEWIDTH <= $MAXWIDTH && $IMAGEHEIGHT <= $MAXHEIGHT) {
$RESIZEDWIDTH = $IMAGEWIDTH;
$RESIZEDHEIGHT = $IMAGEHEIGHT; }
elseif ($IMAGEWIDTH <= $MAXWIDTH && $IMAGEHEIGHT > $MAXHEIGHT) {
$RESIZEDHEIGHT = $MAXHEIGHT;
$RESIZEDWIDTH = ceil($MAXHEIGHT*$SOURCERATIO); }
elseif ($IMAGEWIDTH > $MAXWIDTH && $IMAGEHEIGHT <= $MAXHEIGHT) {
$RESIZEDWIDTH = $MAXWIDTH;
$RESIZEDHEIGHT = ceil($MAXWIDTH/$SOURCERATIO); }
elseif ($IMAGEWIDTH > $MAXWIDTH && $IMAGEHEIGHT > $MAXHEIGHT) {
$WIDTHDIFF = $IMAGEWIDTH-$MAXWIDTH;
$HEIGHTDIFF = $IMAGEHEIGHT-$MAXHEIGHT;
if ($WIDTHDIFF < $HEIGHTDIFF) {
$RESIZEDHEIGHT = $MAXHEIGHT;
$RESIZEDWITH = ceil($MAXHEIGHT*$SOURCERATIO); }
elseif ($WIDTHDIFF > $HEIGHTDIFF) {
$RESIZEDWIDTH = $MAXWIDTH;
$RESIZEDHEIGHT = ceil($MAXWIDTH/$SOURCERATIO); }
elseif ($WIDTHDIFF == $HEIGHTDIFF) {
$RESIZEDWIDTH = $MAXWIDTH;
$RESIZEDHEIGHT = $MAXHEIGHT; }}
//Create new resized image
$RESIZEDIMAGE = imagecreatetruecolor($RESIZEDWIDTH, $RESIZEDHEIGHT);
imagecopyresampled($RESIZEDIMAGE, $IMAGECACHE, 0, 0, 0, 0, $RESIZEDWIDTH, $RESIZEDHEIGHT, $IMAGEWIDTH, $IMAGEHEIGHT);
//Sets an empty variable for future use
$BINARYFULL = "";
//Sets header information to XML with no caching
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
//Outputs the initial Cisco XML tags
echo "<CiscoIPPhoneImage>";
echo "<LocationX>$LOCATIONX</LocationX>";
echo "<LocationY>$LOCATIONY</LocationY>";
echo "<Width>$RESIZEDWIDTH</Width>";
echo "<Height>$RESIZEDHEIGHT</Height>";
echo "<Depth>2</Depth>";
echo "<Data>";
//Gets the red RGB value for each pixel in the image
for ($Y=0;$Y<$RESIZEDHEIGHT;$Y++) {
for ($X=0;$X<$RESIZEDWIDTH;$X++) {
$COLORINDEX = imagecolorat($RESIZEDIMAGE,$X,$Y);
$RGBDEC = imagecolorsforindex($RESIZEDIMAGE,$COLORINDEX);
$RED = $RGBDECred>'red';
//Converts each pixel from red RGB value to 2-bit binary
if ($RED < $LOW) { $TWOBIT = "11"; }
elseif ($RED >= $LOW && $RED < $MEDIUM) { $TWOBIT = "10"; }
elseif ($RED >= $MEDIUM && $RED < $HIGH) { $TWOBIT = "01"; }
elseif ($RED >= $HIGH) { $TWOBIT = "00"; }
//Sets the 2-bit binary string for each pixel
$BINARYFULL .= $TWOBIT; }}
//Parses the string and reorders the binary pairs
$i = 0;
while ($i <= strlen($BINARYFULL)) {
$EIGHTBIT = substr($BINARYFULL,$i,8);
$TWOBIT1 = substr($EIGHTBIT,6,2);
$TWOBIT2 = substr($EIGHTBIT,4,2);
$TWOBIT3 = substr($EIGHTBIT,2,2);
$TWOBIT4 = substr($EIGHTBIT,0,2);
$EIGHTBITFLIP = $TWOBIT1 . $TWOBIT2 . $TWOBIT3 . $TWOBIT4;
//Converts the reordered binary byte to decimal and then to hexidecmal
$OUTPUT = dechex(bindec($EIGHTBITFLIP));
//Pads single value binary bits and outputs the result
if (strlen($OUTPUT)==1) { echo "0" . $OUTPUT; }
else { echo $OUTPUT; }
$i = $i+8; }
//Outputs the closing Cisco XML tags
echo "</Data>";
echo "<Title>Test</Title>";
echo "<Prompt>Test</Prompt>";
echo "</CiscoIPPhoneImage>";
//Frees any memory associated with cached images
imagedestroy($IMAGECACHE);
imagedestroy($RESIZEDIMAGE);
?>
Open 79XX XML Directory
The graphical menus are "bitmapped" (literally, using text) and don't display well on 79x1. I only use the directory features (ignoring the memo and RSS), so I set the directoryURL to http://servername/PhoneUI/menuItems.php rather than http://servername/PhoneUI/index.php.
Project is: http://web.csma.biz/apps/xml_xmldir.php
cisco 7960 cm_7-2-3 php-header
I had to insert an additional header line
header("Cache-Control: private");
Now it works
I am not sure why ... hope it will help
Working script with > 32 entries.
Correction in XML php mysql script
And Remember, printf is your friend!!
<?
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
echo "<" . "?xml version=\"1.0\" ?".">\n";
?>
<CiscoIPPhoneDirectory>
<Title>IP Telephony Directory</Title>
<Prompt>1340Media Phone List</Prompt>
<?
$database = 'contacts';
$db_server = 'my server';
$db_user = 'my user';
$db_pass = 'my password';
$link = mysql_connect($db_server, $db_user, $db_pass);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($database, $link);
if (!$db_selected) {
die('Can\'t use database $database : ' . mysql_error());
}
$result = mysql_db_query ($database, "select * from phonelists ORDER BY `name`");
while ($row = mysql_fetch_array ($result)) {
printf("\t\t<DirectoryEntry>\n");
printf("\t\t\t<Name>%s</Name>\n",$row"name");
printf("\t\t\t<Telephone>9%s</Telephone>\n",$row"phone");
printf("\t\t</DirectoryEntry>\n");
}
mysql_free_result ($result);
mysql_close($link);
?>
</CiscoIPPhoneDirectory>
wrong url ?
Correction on XML Directory script from sip.conf
if (isset($vcallerid>'callerid'))
After a bit of research, I figured out that wiki eats up a square bracket (sorry, I am a newbie here). I am offering below a modified version, which I have just verified to work on my Cisco 79X0's with SIP 7.3 firmware.
Enjoy. Serge Vecher
kb_directory.php
/* PHP Script for Creating XML Directory
for Cisco 79X0 Phones at KB Studio
implemented by SAV, last update 1/5/04
based on howto at
www.voip-info.org/wiki-Asterisk+Cisco+79XX+XML+Services
- /
header("Content-type: text/xml");header("Connection: close");
header("Expires: -1");
// location of asterisk config files
$location = "/etc/asterisk/";
$dirname = "KB Studio Directory";
// parse sip.conf
$sip_array = parse_ini_file($location."sip.conf", true);
while ($v = current($sip_array))
{ if (isset($v['callerid']]))
{ $directory[] = "\n".$v['callerid']]."\n". "".key($sip_array)."\n\n"; }
next($sip_array);
}
echo "\n";
echo "".$dirname."\n";
foreach ($directory as $v)
{ print_r($v); }
echo "select entry\n";
echo "\n";
?>