login | register
Sat 17 of May, 2008 [18:33 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Juan Ortega, Thu 15 of May, 2008 [10:33 UTC]: Hi everybody, I'm Juan, an ITCom student, and I need to know what basic elements I need to create a VoIP network. Can anybody helpme, please?,Thank you very much
  • gineta, Wed 14 of May, 2008 [03:58 UTC]: any here not fine the configuration of firewall juniper -screem for VOIP asterisk????
  • Anoop Prabhakaran, Tue 13 of May, 2008 [12:16 UTC]: I am developing Asterisk IVR, Whenever i make a internation call to the IVR system, the DTMF is not getting detected properly, this happens only for the first time, second call onwards system works fine. why this is happening
  • joe, Mon 12 of May, 2008 [04:27 UTC]: Is there an opensource browser based softphone, or a system like Busta where everything is not manages through their website?
  • Nick Barnes, Fri 09 of May, 2008 [11:36 UTC]: Christopher - yesterday I tried an Asterisk install on a CentOS 5.1 box with stock GUI and it all worked fine. Sorry I can't help.
  • aero, Fri 09 of May, 2008 [08:20 UTC]: can someone help me out on this, i tried to play some sound files on my asterisk box and this is the error message i got. WARNING[4429]: format_wav.c:169 check_header: Unexpected freqency 22050 May 8 11:17:39 WARNING[4433]: codec_gsm.c:194 gsmtolin_fra
  • Christopher Faust, Thu 08 of May, 2008 [14:15 UTC]: I beleive that I may have to change something in the xserver configuration. Please advise
  • Christopher Faust, Thu 08 of May, 2008 [14:14 UTC]: Everything was perfect. In the bios I have increased the memory allocated Still receive input not supported on my display.
  • Christopher Faust, Thu 08 of May, 2008 [14:13 UTC]: This would not be my main box. I am doing some testing to see if I can install zaptel and asterisk 1.4 on a full centos 5.1 box with development software Its bizzare, because before I went through the asterisk and zaptel installation everything was perfe
  • Nick Barnes, Thu 08 of May, 2008 [13:44 UTC]: Christopher - I can't see any way in which an Asterisk installation would muck your GUI, but remember that it is advised not to use a GUI on an Asterisk box anyway.
Server Stats
  • Execution time: 0.28s
  • Memory usage: 2.31MB
  • Database queries: 29
  • GZIP: Disabled
  • Server load: 0.57

Asterisk Cisco 79XX XML Services

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=8

Working 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)


Berbee XML Services:

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.


Open 79XX XML Directory:

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.


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



AM-Web
Asterisk Manager interface for the Services button
just says 'face' on 18/01/2006 06:36 GMT






http://www.albany.edu/~rs2814/
allows basic administration of asterisk



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/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";
}
?>



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






Created by rjlawr, Last modification by melifaro on Thu 10 of Apr, 2008 [14:52 UTC]

Comments Filter

Re: PHP Image to CIP Converter

by Danny on Friday 12 of October, 2007 [13:33:58 UTC]
Hi Drew. I've tried running the script on my server and it doesn't return anything just a blank page. Could there something on my php configuration file that i migh tto adjust for the script to run properly.
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

by Danny on Friday 12 of October, 2007 [13:31:38 UTC]
Hi Drew. I've tried running the script on my server and it doesn't return anything just a blank page. Could there something on my php configuration file that i migh tto adjust for the script to run properly.
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

by Michael Waldron on Monday 24 of September, 2007 [17:56:20 UTC]
I couldn't find any really good Cisco XML parsers that properly strip HTML and make the RSS feeds viewable. I created the following in ASP (also runs on IIS 5.1 if you're using XP like we are for your services server). You may have to customize for your needs/feeds/environment, but here it is. I'm not an ASP programmer, so if you can improve this - PLEASE DO!

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 & "" &"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  '           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, "&nbsp;", "")                  
                 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 & "" &"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  '           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 & "&nbsp;"
                 cks.Str = tmpNode.text
                 cks.StripHtml
                 response.write "" & cks.Str & "" & vbCrLf

         end if


  '           if tmpNode.nodeName = "pubDate" then
  '              marqueeString= marqueeString & "" & tmpNode.text & "" &"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  '           response.write "" & tmpNode.text & ""
  '           end if

          next
      end if


   next

next

response.write "</Text>"
response.write "</CiscoIPPhoneText>"

%>


PHP Image to CIP Converter

by Drew Davies on Friday 31 of August, 2007 [16:09:56 UTC]
After getting a batch of new Cisco 7941G units, I started searching for how to display images on the LCD for phone services. Surprisingly, the documentation from Cisco on the subject was piss poor; the best resource happened to be this page from voip-info.

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

by syburgh on Monday 15 of January, 2007 [19:34:54 UTC]
Found this project on SourceForge. It's a bit old and needs PHP+MySQL, but works fine with 79x0 and 79x1. Enables Web based set up of "Containers", "Contact Holders", and Contacts with several phone numbers (and SIP URIs). Useful for situations where there is no local LDAP 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

by tex on Wednesday 02 of August, 2006 [13:42:33 UTC]
if I serve these php / xml files with apache2 on my debian sarge server the phone just displays the files as text

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.

by Steve Kirk on Thursday 08 of December, 2005 [18:06:51 UTC]
Since I'm a new to this stuff (and I'll add this is my first XML-output script EVER) I struggled a bit with the "http refresh header" thing; My company directory is over 100 entries, so doing "page navigation" stumped me - well, for about 10 mins. So to help out other newbs, here's the script I wrote (and works on my 7960/SIP v7.4) --> dir.php.

Correction in XML php mysql script

by Mark Rounds on Wednesday 19 of October, 2005 [01:38:40 UTC]
I noticed that there was a small problem with the php mysql directory script. I was getting extra characters before and after the number on my 7940 phone. I have posted an updated script that works a little better. The 9 infront of the telephone number is my dialout number. You can ignore if you like, I won't loose sleep over it.

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>

Edit

wrong url ?

by Anonymous on Thursday 13 of January, 2005 [09:55:26 UTC]
http://cvs.largeone.net/index.cgi/*checkout*/asterisk/scripts/status.cgi doesn't not work, unable to reach the webmaster by mail (:sad:)
Edit

Correction on XML Directory script from sip.conf

by Anonymous on Wednesday 05 of January, 2005 [03:08:19 UTC]
After trying to apply an Asterisk Directory PHP script on my system, php didn't like the following expression on line 13.
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";
?>

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver