<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geoff&#039;s Blog &#187; VoIP</title>
	<atom:link href="http://blog.grimsy.net/tag/voip/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.grimsy.net</link>
	<description>tech, travels and other stuff</description>
	<lastBuildDate>Wed, 06 Apr 2011 03:41:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>New battery for ClearOne Max Conference Phone</title>
		<link>http://blog.grimsy.net/2009/08/new-battery-for-clearone-max-conference-phone/</link>
		<comments>http://blog.grimsy.net/2009/08/new-battery-for-clearone-max-conference-phone/#comments</comments>
		<pubDate>Thu, 13 Aug 2009 04:28:23 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://blog.grimsy.net/?p=100</guid>
		<description><![CDATA[We have a ClearOne Max conference phone at work that has been in need of a new battery for a while. When we do get new batteries for it, they never seem to last as long as they should and always need to be ordered in. Solution: Use an RC battery pack. The battery in [...]]]></description>
			<content:encoded><![CDATA[<p>We have a <a href="http://www.clearone.com/wireless-speakerphone.html">ClearOne Max</a> conference phone at work that has been in need of a new battery for a while. When we do get new batteries for it, they never seem to last as long as they should and always need to be ordered in.<br />
Solution: Use an RC battery pack.<br />
The battery in the conference unit is a 7.2V 1800mAh NiMH battery pack. The RC battery pack is 3000mAH so we get much longer out of it on a single charge.<br />
We&#8217;re still able to use the normal charger that came with the phone too.</p>
<div style="text-align: center;">
<img class="size-full wp-image-102" title="ClearOne Max conference phone" src="http://blog.grimsy.s223.sureserver.com/wp-content/uploads/2009/08/clearonemax.png" alt="ClearOne Max conference phone battery mod" width="400" height="305" />
</div>
<p>Sure it might be big and ugly (I&#8217;ve hot glued it to the phone) but it works amazingly well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2009/08/new-battery-for-clearone-max-conference-phone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql schema&#8230;. finally</title>
		<link>http://blog.grimsy.net/2009/04/mysql-schema-finally/</link>
		<comments>http://blog.grimsy.net/2009/04/mysql-schema-finally/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 05:20:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[SPA942]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=24</guid>
		<description><![CDATA[I know this has taken waaay to long to post. But here it is if anyone still wants it. # CREATE DATABASE voip; # USE voip; # # TABLE STRUCTURE FOR TABLE 'allocation' # # DROP TABLE IF EXISTS allocation; CREATE TABLE `allocation` &#40; `allocation_id` INT&#40;11&#41; NOT NULL AUTO_INCREMENT, `asset_id` INT&#40;11&#41; NOT NULL DEFAULT '0', [...]]]></description>
			<content:encoded><![CDATA[<p>I know this has taken waaay to long to post. But here it is if anyone still wants it.</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># <span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> voip;<br />
# <span style="color: #993333; font-weight: bold;">USE</span> voip;<br />
<br />
#<br />
# <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">STRUCTURE</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'allocation'</span><br />
#<br />
<br />
# <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> allocation;<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`allocation`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`allocation_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`asset_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`site_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`extension`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span><br />
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`allocation_id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">58</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">COLLATE</span><span style="color: #66cc66;">=</span>latin1_general_ci;<br />
<br />
#<br />
# <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">STRUCTURE</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'asset'</span><br />
#<br />
<br />
# <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> asset;<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`asset`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`asset_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`manufacturer`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`model`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`serial`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`mac`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'000000000000'</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`phone_ip`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`purchase_price`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`purchase_date`</span> <span style="color: #993333; font-weight: bold;">DATE</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0000-00-00'</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`purchase_from`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`invoice_number`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`asset_id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">46</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">COLLATE</span><span style="color: #66cc66;">=</span>latin1_general_ci;<br />
<br />
#<br />
# <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">STRUCTURE</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'phoneline'</span><br />
#<br />
<br />
# <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> phoneline;<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`phoneline`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`line_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`phone_number`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`line_id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">3</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">COLLATE</span><span style="color: #66cc66;">=</span>latin1_general_ci;<br />
<br />
#<br />
# <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">STRUCTURE</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'server'</span><br />
#<br />
<br />
# <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> server;<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`server`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`server_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`site_id`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`server_ip`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`server_hostname`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`server_id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">COLLATE</span><span style="color: #66cc66;">=</span>latin1_general_ci;<br />
<br />
#<br />
# <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">STRUCTURE</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'site'</span><br />
#<br />
<br />
# <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> site;<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`site`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`site_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`site_name`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`street_number`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`street_name`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`city`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`state`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`country`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`site_id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">COLLATE</span><span style="color: #66cc66;">=</span>latin1_general_ci;<br />
<br />
#<br />
# <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">STRUCTURE</span> <span style="color: #993333; font-weight: bold;">FOR</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">'user'</span><br />
#<br />
<br />
# <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #993333; font-weight: bold;">USER</span>;<br />
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`user`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`user_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`samaccountname`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">COLLATE</span> latin1_general_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">,</span><br />
<span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`user_id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">2</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">COLLATE</span><span style="color: #66cc66;">=</span>latin1_general_ci;</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2009/04/mysql-schema-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Follow up to SPA942 Personal Directory with LDAP</title>
		<link>http://blog.grimsy.net/2007/11/follow-up-to-spa942-personal-directory-with-ldap/</link>
		<comments>http://blog.grimsy.net/2007/11/follow-up-to-spa942-personal-directory-with-ldap/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 22:06:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[SPA942]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=19</guid>
		<description><![CDATA[I just wanted to follow up on my previous post about using LDAP and PHP to push the directories on the SPA942. I&#8217;ve included a whole lot of code below, and please note that a lot of this is me just getting the job done. The code is probably messy and poorly written, and some [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to follow up on my previous post about using LDAP and PHP to push the directories on the SPA942.<br />
I&#8217;ve included a whole lot of code below, and please note that a lot of this is me just getting the job done. The code is probably messy and poorly written, and some of it is taken from other sites/samples.<br />
Unfortunately, blogger seems to take away all my nice formatting (indents etc&#8230;), so you&#8217;ll have to bear with me. Also, long comments appear across multiple lines in here, so that could make it even harder. Copy the code into a program like <a href="http://notepad-plus.sourceforge.net/uk/site.htm">notepad++</a> and set language to php to make it easier to read.</p>
<p>Firstly, just need to include a few files etc&#8230;</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/error_reporting"><span style="color: #990000;">error_reporting</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ERROR</span> <span style="color: #339933;">|</span> <span style="color: #009900; font-weight: bold;">E_WARNING</span> <span style="color: #339933;">|</span> <span style="color: #009900; font-weight: bold;">E_PARSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">240</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;common/dbConnection.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;common/header.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;common/ldapInfo.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;voip_ext.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p><span style="font-weight:bold;">dbConnection.php</span> connects to a Mysql DB that I use basically as an asset register. It contains IPs, allocations, extensions, invoice numbers yada yada yada. Originally, I drove this script entirely from LDAP, however once users started to have multiple extensions (depending on which site they were working from), LDAP (well Active Directory actually) just couldn&#8217;t cut it. Note that this still uses LDAP for getting user details (display name) and extensions. It cross references these with Mysql.<br />
<span style="font-weight:bold;">header.php</span> is just some menu&#8217;s etc<br />
<span style="font-weight:bold;">ldapInfo.php</span> is the connection to LDAP. It returns the info as $info<br />
<span style="font-weight:bold;">voip_ext.php</span> is a list of extensions returned as $extensions. Note that the extensions have changed with firmware updates, so check your phone to see what yours are.<br />
The rest of the code follows.<br />
I&#8217;ve tried my best to include comments, and please remember this is not a complete solution (due to DB dependencies etc&#8230;) but will hopefully get you started.<br />
If anyone is interested in the DB schema, leave a comment and I can post it here.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$pDir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//MAIN</span><br />
<br />
<span style="color: #666666; font-style: italic;">//get users extensions</span><br />
<span style="color: #000088;">$UserExtensions</span> <span style="color: #339933;">=</span> getExtensions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//100 slots to use. fill from bottom, so 99 -&amp;gt; 0</span><br />
<span style="color: #000088;">$extID</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">99</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//for each extension, find the appropriate info</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$UserExtensions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ext</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$ext</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;amp;&quot;</span><span style="color: #339933;">.</span>dirEntry<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//tidy up and sort the pdir string</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pDir</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;amp;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/sort"><span style="color: #990000;">sort</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//assign an extid to each entry</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pDir</span> <span style="color: #b1b100;">as</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$entry</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$extensions</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$extID</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;=n%3D&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$entry</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$extID</span><span style="color: #339933;">--;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//more tidying of pdir</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;amp;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">.=</span> getGroups<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;%20&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//need to fill in from extID to 0 to clean vacant entries from pdir</span><br />
<span style="color: #666666; font-style: italic;">//note that this will wipe out any duplicate names (was occuring when users were leaving)</span><br />
<span style="color: #666666; font-style: italic;">//this will also wipe out any personal entries (i.e. this script is the only way that entries will appear in the directory)</span><br />
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$extID</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$pDir</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;amp;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$extensions</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$extID</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;=;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$extID</span><span style="color: #339933;">--;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$extID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br /&amp;gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pDir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br /&amp;gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//run the wget (comment this out to test sending to a single phone - use next bit instead)</span><br />
<span style="color: #000088;">$phoneIPs</span> <span style="color: #339933;">=</span> GetPhoneIPs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIPs</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$phoneIP</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
updatePhonePDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//uncomment for testing</span><br />
<span style="color: #666666; font-style: italic;">//updatePhonePDir(&quot;192.168.10.170&quot;,$pDir);</span><br />
<br />
<span style="color: #666666; font-style: italic;">//FUNCTIONS</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> getExtensions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this gets all the phone extensions that i've allocated in mysql. Note that other extensions probably exist in ldap, but they're not assigned to a phone and hence we don't want them here.</span><br />
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select allocation.extension from allocation order by allocation.extension asc&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$extensions</span> <span style="color: #339933;">.=</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;extension&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<a href="http://www.php.net/mysql_free_result"><span style="color: #990000;">mysql_free_result</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$extensions</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extensions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$extensions</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> GetPhoneIPs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this gets the ips of the phones. need this when performing the wget command</span><br />
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select distinct phone_ip from asset where phone_ip not like ''&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$phoneIPs</span> <span style="color: #339933;">.=</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;phone_ip&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<a href="http://www.php.net/mysql_free_result"><span style="color: #990000;">mysql_free_result</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$phoneIPs</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$phoneIPs</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$phoneIPs</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> dirEntry<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this is creating the sting that we eventually want to POST to the phone's pdir</span><br />
<span style="color: #000088;">$allocationDetails</span> <span style="color: #339933;">=</span> getAllocationDetails<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$phoneMAC</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$allocationDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$phoneIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$allocationDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$siteName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$allocationDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$serverIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$allocationDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$userDetails</span> <span style="color: #339933;">=</span> ldapUserDetails<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$userSamAccountName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$userDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$userDisplayName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$userDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$userComany</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$userDetails</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> getRingTone<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$userDisplayName</span>;p%3D<span style="color: #006699; font-weight: bold;">$ext</span>;r%3D<span style="color: #006699; font-weight: bold;">$ringtone</span>&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//return &quot;n%3D$userDisplayName;p%3D$ext;r%3D$ringtone&quot;;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> ldapUserDetails<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this matches the extensions with the names from ldap (we don't keep names in mysql)</span><br />
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;count&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ipphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$samaccountname</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;samaccountname&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$displayName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;displayname&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$company</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;company&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$company</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$company</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GLiNTECH&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//catch accounts with no company name specified</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$samaccountname</span><span style="color: #339933;">,</span><span style="color: #000088;">$displayName</span><span style="color: #339933;">,</span><span style="color: #000088;">$company</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> getAllocationDetails<span style="color: #009900;">&#40;</span><span style="color: #000088;">$extension</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// this gets more info about the phone (we use multiple sites and servers)</span><br />
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select asset.mac, allocation.extension, server.server_ip, asset.phone_ip, site.site_name<br />
from allocation<br />
join asset as asset on allocation.asset_id = asset.asset_id<br />
join site as site on allocation.site_id = site.site_id<br />
join server as server on site.site_id = server.site_id<br />
where allocation.extension = '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$extension</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' limit 1&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$thisPhoneMac</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;0000000000&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisPhoneIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;0.0.0.0&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisSiteName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;NULL&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisServerIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;0.0.0.0&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$thisPhoneMac</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;0000000000&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisPhoneIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;0.0.0.0&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisSiteName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;NULL&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisServerIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;0.0.0.0&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// While a row of data exists, put that row in $row as an associative array</span><br />
<span style="color: #666666; font-style: italic;">// Note: If you're expecting just one row, no need to use a loop</span><br />
<span style="color: #666666; font-style: italic;">// Note: If you put extract($row); inside the following loop, you'll</span><br />
<span style="color: #666666; font-style: italic;">// &nbsp; &nbsp; &nbsp; then create $userid, $fullname, and $userstatus</span><br />
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$thisPhoneMac</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;mac&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisPhoneIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;phone_ip&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisSiteName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;site_name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$thisServerIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;server_ip&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<a href="http://www.php.net/mysql_free_result"><span style="color: #990000;">mysql_free_result</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thisPhoneMac</span><span style="color: #339933;">,</span><span style="color: #000088;">$thisPhoneIP</span><span style="color: #339933;">,</span><span style="color: #000088;">$thisSiteName</span><span style="color: #339933;">,</span><span style="color: #000088;">$thisServerIP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> getRingTone<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this checks to see if a user as set a custom ringtone.</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xmlstr</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$phoneIP</span>/admin/spacfg.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xmlstr</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleXMLElement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$xmlstr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Default_Ring_1_<span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ringtone</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;User 1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;11&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ringtone</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;User 2&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//default ringtone for people in the directory</span><br />
<span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$ringtone</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> updatePhonePDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this generates the wget command. -t 1 means it will only try once. if it fails then it won't try again until the next day.</span><br />
<span style="color: #000088;">$command</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;wget --post-data '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$pDir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' http://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$phoneIP</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/pdir.spa -t 1&quot;</span><span style="color: #339933;">;</span><br />
runCommand<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// or die(&quot;update to $phoneIP failed&quot;);</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> runCommand<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//calls the command and writes some debugging to the screen</span><br />
<a href="http://www.php.net/system"><span style="color: #990000;">system</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #339933;">,</span><span style="color: #000088;">$returned</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$command</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br /&amp;gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$returned</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$returned</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> getGroups<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//this is used for getting groups in ldap and finding their exts etc... read up in a previous post for more on this. Note that groups are prepended with '*' to make them appear at the top of the directory</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$extID</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$extensions</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;count&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/ereg"><span style="color: #990000;">ereg</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[[6][0-9]{3}]&quot;</span><span style="color: #339933;">,</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;info&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//calling groups</span><br />
<span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&amp;amp;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$extensions</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$extID</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;=n%3D*&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/strtoupper"><span style="color: #990000;">strtoupper</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;%20&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;p%3D&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;info&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;r%3D11&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$extID</span><span style="color: #339933;">--;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$extensionstring</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2007/11/follow-up-to-spa942-personal-directory-with-ldap/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Asterisk Bootcamp</title>
		<link>http://blog.grimsy.net/2007/10/asterisk-bootcamp/</link>
		<comments>http://blog.grimsy.net/2007/10/asterisk-bootcamp/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 05:55:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[GLiNTECH]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=18</guid>
		<description><![CDATA[Just a quick post to mention that I&#8217;m heading to Melbourne next month for the Asterisk Bootcamp (care of work). Should be a good opportunity to learn a lot of info about Asterisk and VoIP in general.]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to mention that I&#8217;m heading to Melbourne next month for the <a href="http://www.digium.com/en/training/courses/">Asterisk Bootcamp</a> (care of work). Should be a good opportunity to learn a lot of info about Asterisk and VoIP in general.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2007/10/asterisk-bootcamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More SPA942 Firmware stuff</title>
		<link>http://blog.grimsy.net/2007/10/more-spa942-firmware-stuff/</link>
		<comments>http://blog.grimsy.net/2007/10/more-spa942-firmware-stuff/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 01:48:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[SPA942]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=16</guid>
		<description><![CDATA[Well I&#8217;m trailing out the 5.15a firmware for the SPA942 phones. Firstly, I have figured out the problem I was having previously with the first line being one pixel out of alignment. For our users, we display $EXT &#8211; Line # on each of the lines, so for me it appears as: &#60;br /&#62;6004 - [...]]]></description>
			<content:encoded><![CDATA[<p>Well I&#8217;m trailing out the 5.15a firmware for the SPA942 phones. Firstly, I have figured out the problem I was having previously with the first line being one pixel out of alignment. For our users, we display $EXT &#8211; Line # on each of the lines, so for me it appears as:</p>
<div class="codecolorer-container text default prettyprint" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;br /&gt;6004 - Line 1&lt;br /&gt;6004 - Line 2&lt;br /&gt;6004 - Line 3&lt;br /&gt;6004 - Line 4&lt;br /&gt;</div></div>
<p>In the previous (5.1.5) firmware, this was left aligned, where as the newer firmwares are right aligned. Because the number 1 is thinner than the numbers 2,3 and 4, the text looked out of line. Other people probably wouldn&#8217;t have this issue, because adding in the Line numbers was a custom change I made for my users (in response to too many questions about why there where 4 buttons).</p>
<p>The other issue I was having with </p>
<div class="codecolorer-container text default prettyprint" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;br /&gt;&lt;2nd_preferred_codec_1_ group=&quot;Ext_1/Audio_Configuration&quot;&gt;&lt;br /&gt;</div></div>
<p>has been changed to </p>
<div class="codecolorer-container text default prettyprint" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;br /&gt;&amp;lt;Second_Preferred_Codec_1_ group=&quot;Ext_1/Audio_Configuration&quot;&gt;&lt;br /&gt;</div></div>
<p>There&#8217;s also a new feature that allows you to set a background image that I&#8217;m hoping to play around with shortly &#8211; more info about that on <a href="http://www.voip-info.org/wiki/index.php?page=SPA-941#BackgroundImage">voip-info</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2007/10/more-spa942-firmware-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SPA942 Personal Directory with LDAP</title>
		<link>http://blog.grimsy.net/2007/06/spa942-personal-directory-with-ldap/</link>
		<comments>http://blog.grimsy.net/2007/06/spa942-personal-directory-with-ldap/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 23:03:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[GLiNTECH]]></category>
		<category><![CDATA[SPA942]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=14</guid>
		<description><![CDATA[A while ago, I posted a blog about the SPA942 Personal Directory. Well I&#8217;ve built on it a bit now and managed to get it populated from the information taken out of our LDAP server (Microsoft Active Directory). When we allocate a phone to someone, we fill in the ipphone field with their extension. We [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I posted a blog about the SPA942 Personal Directory. Well I&#8217;ve built on it a bit now and managed to get it populated from the information taken out of our LDAP server (Microsoft Active Directory).</p>
<p>When we allocate a phone to someone, we fill in the ipphone field with their extension. We then also add two other ipphone entries, the first being the MAC address of the phone, the second being the phone&#8217;s IP.</p>
<p>I&#8217;m also managing calling groups (queues) in LDAP by creating security groups and using the Notes field to enter the information that I then use to build Asterisk&#8217;s queues.conf file (I might post more on that later if people are interested). An example of one of these entries for the groups is:</p>
<div class="codecolorer-container ini default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ini codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>6000<span style="">&#93;</span></span><br />
<span style="color: #000099;">fullname</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> <span style="">&#123;</span>groupname<span style="">&#125;</span></span><br />
<span style="color: #000099;">strategy</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> ringall</span><br />
<span style="color: #000099;">timeout</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 15</span><br />
<span style="color: #000099;">wrapuptime</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 0</span><br />
<span style="color: #000099;">autofill</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><br />
<span style="color: #000099;">autopause</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> no</span><br />
<span style="color: #000099;">maxlen</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 0</span><br />
<span style="color: #000099;">joinempty</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><br />
<span style="color: #000099;">leavewhenempty</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><br />
<span style="color: #000099;">reportholdtime</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> yes</span><br />
<span style="color: #000099;">musicclass</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> default</span></div></div>
<p>From this information in LDAP, I have a PHP script that is run as a cron job each night to update the phones with the new Personal Directory.</p>
<p>I&#8217;ll post the PHP as one big chunk, and explain it a bit further below.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
&nbsp; &nbsp; <a href="http://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Include a list of all the extensions - this is page that lists the id's for the pdir. $extensions=array('25454','25390','25582', etc...</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'voip_ext.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Doing LDAP connection stuff</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$ldap_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ldapserver&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$base_dn</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DC=domain,DC=com&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$filter</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;(|(ipphone=*)(info=[*))&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$ldap_user</span> &nbsp;<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CN=Admin User,CN=Users,DC=domain,DC=com&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$ldap_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;fullysecretpassword&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$connect</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ldap_connect"><span style="color: #990000;">ldap_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ldap_host</span><span style="color: #339933;">,</span><span style="color: #000088;">$ldap_port</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; or <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&gt;&gt;Could not connect to LDAP server&lt;&lt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/ldap_set_option"><span style="color: #990000;">ldap_set_option</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #339933;">,</span> LDAP_OPT_PROTOCOL_VERSION<span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/ldap_set_option"><span style="color: #990000;">ldap_set_option</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #339933;">,</span> LDAP_OPT_REFERRALS<span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$bind</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ldap_bind"><span style="color: #990000;">ldap_bind</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ldap_user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ldap_pass</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; or <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&gt;&gt;Could not bind to <span style="color: #006699; font-weight: bold;">$ldap_host</span>&lt;&lt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$read</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ldap_search"><span style="color: #990000;">ldap_search</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #339933;">,</span> <span style="color: #000088;">$base_dn</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filter</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; or <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&gt;&gt;Unable to search ldap server&lt;&lt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ldap_get_entries"><span style="color: #990000;">ldap_get_entries</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #339933;">,</span> <span style="color: #000088;">$read</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//start doing things</span><br />
&nbsp; &nbsp; ldapPhoneIPs<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//close the ldap connection</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/ldap_close"><span style="color: #990000;">ldap_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//FUNCTIONS</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> ldapPhoneIPs<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$pDir</span> <span style="color: #339933;">=</span> ldapUsers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;count&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;otheripphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;samaccountname&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$phoneIP</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;otheripphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$phoneMAC</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;otheripphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> getRingTone<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$pDir2</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;r%3D0&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ringtone</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updatePhonePDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//This just makes sure we don't overwrite somone's customised ringtone</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> getRingTone<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$xmlstr</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://<span style="color: #006699; font-weight: bold;">$phoneIP</span>/admin/spacfg.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xmlstr</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleXMLElement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$xmlstr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Default_Ring_1_</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ringtone</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;User 1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;11&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ringtone</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;User 2&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$ringtone</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;12&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;r%3D&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ringtone</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> updatePhonePDir<span style="color: #009900;">&#40;</span><span style="color: #000088;">$phoneIP</span><span style="color: #339933;">,</span><span style="color: #000088;">$pDir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$command</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;wget --post-data '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$pDir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' http://&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$phoneIP</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/pdir.spa&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; runCommand<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// or die(&quot;update to $phoneIP failed&quot;);</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> ldapUsers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//get the list of users</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$extensions</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extID</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">99</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;count&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ipphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//individual users</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;otheripphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;&gt;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$extensions</span>[<span style="color: #006699; font-weight: bold;">$extID</span>]=n%3D&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;%20&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;displayname&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;p%3D&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ipphone&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;r%3D0&amp;amp;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extID</span><span style="color: #339933;">--;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/ereg"><span style="color: #990000;">ereg</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[[6][0-9]{3}]&quot;</span><span style="color: #339933;">,</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;info&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//calling groups</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;info&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$extensions</span>[<span style="color: #006699; font-weight: bold;">$extID</span>]=n%3D&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/strtoupper"><span style="color: #990000;">strtoupper</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;%20&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;p%3D&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;info&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;;r%3D0&amp;amp;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extID</span><span style="color: #339933;">--;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$extensionstring</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extensionstring</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extensionstring</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$extensionstring</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> runCommand<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/system"><span style="color: #990000;">system</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #339933;">,</span><span style="color: #000088;">$returned</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$command</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$returned</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Ok, so firstly we include another file. There&#8217;s nothing flash about this file, in fact all it contains is a list of all the id&#8217;s in the Personal Directory page</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$extensions</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'25454'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'25390'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'25582'</span><span style="color: #339933;">,</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Next it&#8217;s a matter of setting up the LDAP connection and filters. I&#8217;m filtering for either an entry in the ipphone field (for individual users) OR the notes(info) field (for the groups).<br />
Then we get into actually doing things.<br />
The first bit parses the info from LDAP and extracts the fields I care about. I&#8217;ve added in filtering for custom ringtones, so that if someone has set a custom ringtone for a particular entry, it doesn&#8217;t get overwritten.<br />
From there, we go through and construct the wget strings (see my previous post for an explanation on this). It puts regular users in CamelCase and groups in UPPERCASE so that users can distinguish the difference.<br />
Once all that is done, we run the wget command and push out the updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2007/06/spa942-personal-directory-with-ldap/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SPA942 Personal Directory</title>
		<link>http://blog.grimsy.net/2007/02/spa942-personal-directory/</link>
		<comments>http://blog.grimsy.net/2007/02/spa942-personal-directory/#comments</comments>
		<pubDate>Fri, 23 Feb 2007 03:52:00 +0000</pubDate>
		<dc:creator>Geoff Jacobs</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[GLiNTECH]]></category>
		<category><![CDATA[SPA942]]></category>
		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://grimsy.net/?p=12</guid>
		<description><![CDATA[I&#8217;ve been setting up Asterisk at work recently, as our old PABX has reached it&#8217;s limits. We picked up half a dozen SPA942&#8242;s for some initial testing. I have to say that while the phones are nice as an end user, however some of the administration functions seem to come up a bit short. One [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been setting up Asterisk at work recently, as our old PABX has reached it&#8217;s limits.<br />
We picked up half a dozen <a href="http://www.voip-info.org/wiki/index.php?page_id=2634">SPA942&#8242;s</a> for some initial testing.<br />
I have to say that while the phones are nice as an end user, however some of the administration functions seem to come up a bit short.<br />
One of the big issues for us was that the personal directory on the phones doesn&#8217;t actually have to option to be populated from Asterisk (or any other PBX other than SPA9000). I have to admit though, I&#8217;m not really one to accept that something can&#8217;t be done.<br />
After trying a number of things, I upgraded to the latest firmware (<a href="http://www.linksys.com/servlet/Satellite?c=L_Download_C2&amp;childpagename=US%2FLayout&amp;cid=1115417109974&amp;packedargs=sku%3D1138743806996&amp;pagename=Linksys%2FCommon%2FVisitorWrapper">5.1.5</a> at time of writing) and after some more stuffing around, I was finally able to get the following line to populate the Personal Directory:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">--post-data</span> <span style="color: #ff0000;">'24686=n%3DGeoff;p%3D6004;r%3D1&amp;amp;25390=n%3DMatt;p%3D6001;r%3D1'</span> http:<span style="color: #000000; font-weight: bold;">//</span>myphoneIP<span style="color: #000000; font-weight: bold;">/</span>pdir.spa</div></div>
<p>A few things about the command.<br />
Firstly, the command will enter in two contacts in the Directory. These will be under entry #5 (24686) and entry #2 (25390). A complete list of all the codes here can be seen in the source of the Personal Directory page in the phone&#8217;s web interface.<br />
So taking the first of the two entries (24686), what we&#8217;re posting is:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">n<span style="color: #000000; font-weight: bold;">%</span>3DGeoff;</div></div>
<p>n=Geoff; (we need to escape the &#8216;=&#8217; signs so that wget will actually pass the info on correctly)<br />
n is the Display Name that will appear in the Directory</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">p<span style="color: #000000; font-weight: bold;">%</span>3D6004;</div></div>
<p>p=6004;<br />
p is the extension number (or phone number). My extension is 6004.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">r<span style="color: #000000; font-weight: bold;">%</span>3D1</div></div>
<p>r=1<br />
r is the ring to use. 0 is no sound, just flashing. Play around with the other numbers to find the ringtone you want to use.</p>
<p>To add more than one entry at a time, simply separate the strings with &#8216;&amp;&#8217;.</p>
<p>From here I&#8217;m going to look into LDAP integration, so that I can autorun the command, pulling the users and extensions out of Active Directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.grimsy.net/2007/02/spa942-personal-directory/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

