<?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>Mass Transmit &#187; Garage Blog</title>
	<atom:link href="http://masstransmit.com/category/garage_blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://masstransmit.com</link>
	<description>A multi-channel Internet marketing agency</description>
	<lastBuildDate>Tue, 15 May 2012 11:53:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
			<item>
		<title>Integrate with Port25&#8242;s PowerMTA SMTP Server&#8217;s Monitoring Interface Via HTTP</title>
		<link>http://masstransmit.com/garage_blog/integrate-powermta-http/</link>
		<comments>http://masstransmit.com/garage_blog/integrate-powermta-http/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 12:30:46 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[MTA]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Port25]]></category>
		<category><![CDATA[PowerMTA]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=6501</guid>
		<description><![CDATA[Port25&#8242;s PowerMTA SMTP Server PowerMTA is a high performance SMTP server used by many email marketing technology companies.  Not only does the server handle high volume of outgoing email, the server also provides various means of integration for email submission, data merging, and monitoring. The server provides a monitoring interface over HTTP.  Server administrators can [...]<p><a href="http://masstransmit.com/garage_blog/integrate-powermta-http/">Integrate with Port25&#8242;s PowerMTA SMTP Server&#8217;s Monitoring Interface Via HTTP</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<h2>Port25&#8242;s PowerMTA SMTP Server</h2>
<p><a href="http://www.port25.com/" target="_blank">PowerMTA</a> is a high performance SMTP server used by many email marketing technology companies.  Not only does the server handle high volume of outgoing email, the server also provides various means of integration for email submission, data merging, and monitoring.</p>
<p>The server provides a monitoring interface over HTTP.  Server administrators can log into a web interface to see the current activity on the server.  This web interface can also send information marked up as XML.  Having integrated PowerMTA into various projects, Mass Transmit has built some PHP classes to assist with integrating with the monitoring interface.</p>
<h2>PowerMTA configuration</h2>
<p>You must enable the HTTP management interface and authorize the IPs to connect to it. Please refer to the <em>PowerMTA™ v4.0 User&#8217;s Guide.</em></p>
<h2>PowerMTA class</h2>
<p>For detailed information on the data provided by the monitoring interface, please consult the <em>PowerMTA™ v4.0 User&#8217;s Guide.</em></p>
<h3>setOption(array|string $option, int|string $value = null) : null</h3>
<p>Set a specific option prior to retrieving data.  Multiple name/value pairs can be specified by passing an associative array or repeated calling this method.  Many methods which retrieve data can be passed options as an associative array.</p>
<h3>status() : string</h3>
<p>Retrieves the status data in XML format.</p>
<h3>queues(array <strong>$options = null</strong>) : string</h3>
<p>Retrieves the queues data in XML format.  You can set the following options as an associative array of arguments or by calling the <strong>setOption()</strong> array.</p>
<ul>
<li><strong>queue</strong>: [string] wildcard search. format: domain/queue</li>
<li><strong>sort</strong>: [string] field to sort by (name|rcpt|size)</li>
<li><strong>connected</strong>: [string] connected? (yes|no|both)</li>
<li><strong>paused</strong>: [string] paused? (yes|no|both)</li>
<li><strong>mode</strong>: [string] mode (normal|backoff|both)</li>
<li><strong>maxItems</strong>: [int] maximum number of items to display</li>
<li><strong>refresh</strong>: [int] n/a</li>
</ul>
<h3>queueDetail(string $queue) : string</h3>
<p>Retrieves data for a specific queue in XML format.  $queue is specified as domain/queue.</p>
<h3>domains(array <strong>$options = null</strong>) : string</h3>
<p>Retrieves the domains data in XML format.</p>
<ul>
<li><strong>domain</strong>: [string] wildcard search for domain</li>
<li><strong>vmta</strong>: [string] widcard search for virtual MTA</li>
<li><strong>sort</strong>: [string] field to sort by (name|rcpt|size)</li>
<li><strong>connected</strong>: [string] connected? (yes|no|both)</li>
<li><strong>maxItems</strong>: [int] maximum number of items to display</li>
<li><strong>refresh</strong>: [int] n/a</li>
</ul>
<h3>domainDetail(string $domain) : string</h3>
<p>Retrieves data for a specific domain in XML format.</p>
<h3>vmtas() : string</h3>
<p>Retrieves data for the virtual MTAs in XML format.</p>
<h3>jobs() : string</h3>
<p>Retrieves data for the jobs in XML format.</p>
<h3>logs() : string</h3>
<p>Retrieves data for the log files in XML format.</p>
<h3>getFile($file) : string|boolean</h3>
<p>Retrieve the specified log file.  If $file is an accounting CSV file, it is passed to the Parse_Csv object for parsing.</p>
<h3>getCsv() : Parse_Csv</h3>
<p>Get the Parse_Csv object parsing the downloaded accounting log file.</p>
<h3>deleteFile() : null</h3>
<p>Delete the file on the localhost that was retrieved using getFile().</p>
<h2>Parse_Csv class</h2>
<p>There is an instance of the Parse_Csv object contained within the PowerMta object to parse any downloaded accounting log files.  After successfully calling PowerMta::getFile() to download an accounting, the file is passed to the Parse_Csv object for parsing.  When parsing a CSV file,the object will pass an array containing the values of the cells of any line matching the filter settings to a specified callback function.</p>
<h3>setLineCallback(array|string $callback) : void</h3>
<p>Specify a callback function (string) or an object&#8217;s  method (array) to pass the row from the CSV file matching the filter criteria.  The callback function will receive an array which is the fields of the row in order, left to right.</p>
<h3>addFilter($key, $value) : void</h3>
<p>Add a filter for the parser.  Rows matching the filters will be sent to the callback function/method as an array.  $key is either the numeric index for that columns or its ame from the header row.  $value is either an exact match or a regular expression (delimited by /../).  If $value is an array, the values will be OR&#8217;d for that key.  Multiple $key criteria will be AND&#8217;d together.  Multiple calls to addFilter() for the same will will also be AND&#8217;d together.  Specifying $key as * will apply that $value to all the fields.</p>
<h3>parse() : array</h3>
<p>Begin parsing the CSV file.</p>
<h2>Examples</h2>
<h3>Get a list of .co.uk domains the PowerMTA server is connected to</h3>
<p><code> $powermtaObj = new PowerMta();<br />
$powermtaObj-&gt;setHost('powermta.domain');<br />
$xml = $powermtaObj-&gt;domains(array('domain' =&gt; '*.co.uk', 'connected' =&gt; 'yes'));<br />
$xmlObj = new SimpleXMLElement($xml);</code></p>
<h3>Download and parse an accounting file for aol.com bounce records</h3>
<p><code> $powermtaObj = new PowerMta();<br />
$powermtaObj-&gt;setHost('powermta.domain');<br />
$powermtaObj-&gt;getFile('/var/log/pmta/acct-2012-01-01-0000.csv');<br />
$powermtaObj-&gt;getCsv()-&gt;addFilter('type', 'b');<br />
$powermtaObj-&gt;getCsv()-&gt;addFilter('rcpt', '/aol.com$/');<br />
$powermtaObj-&gt;getCsv()-&gt;setLineCallback('csvCallback');<br />
$powermtaObj-&gt;getCsv()-&gt;parse();<br />
$powermtaObj-&gt;deleteFile();<br />
function csvCallback($lineArray) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;print_r($lineArray);<br />
}</code></p>
<h2>Download</h2>
<p><button onclick="location.href = '/wp-content/uploads/2012/03/powermta-0.9.zip';">Download PowerMta PHP class files v. 0.9</button></p>
<p>&nbsp;<br />
&nbsp;</p>
<p><a href="http://masstransmit.com/garage_blog/integrate-powermta-http/">Integrate with Port25&#8242;s PowerMTA SMTP Server&#8217;s Monitoring Interface Via HTTP</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fintegrate-powermta-http%2F&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Integrate+with+Port25%27s+PowerMTA+SMTP+Server%27s+Monitoring+Interface+Via+HTTP&amp;link=http://masstransmit.com/garage_blog/integrate-powermta-http/&amp;notes=Port25%27s%20PowerMTA%20SMTP%20Server%0D%0APowerMTA%20is%20a%20high%20performance%20SMTP%20server%20used%20by%20many%20email%20marketing%20technology%20companies.%20%C2%A0Not%20only%20does%20the%20server%20handle%20high%20volume%20of%20outgoing%20email%2C%20the%20server%20also%20provides%20various%20means%20of%20integration%20for%20email%20submission%2C%20data%20merging%2C%20and%20monitoring.%0D%0A%0D%0AT&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/integrate-powermta-http/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trigger Save As&#8230; Window for PDF Download</title>
		<link>http://masstransmit.com/garage_blog/save-as-pdf/</link>
		<comments>http://masstransmit.com/garage_blog/save-as-pdf/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 06:01:20 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[content disposition]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Http]]></category>
		<category><![CDATA[Pdf]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=2661</guid>
		<description><![CDATA[Most browsers are equipped to display PDFs. This means when a user clicks on a link to a PDF on a website, the browser will download and display it. PDFs, however, are intended to be downloaded and retained by the user for offline viewing or printing. It is possible, however, for anyone to save the [...]<p><a href="http://masstransmit.com/garage_blog/save-as-pdf/">Trigger Save As&#8230; Window for PDF Download</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>Most browsers are equipped to display PDFs.  This means when a user clicks on a link to a PDF on a website, the browser will download and display it.  PDFs, however, are intended to be downloaded and retained by the user for offline viewing or printing.</p>
<p>It is possible, however, for anyone to save the PDF from the browser.  You can right-click or ctrl-click on the link to the PDF and save the file to the local computer.  If the PDF is already displayed in the browser, a Save As&#8230; menu option will allow you to save it locally as well.</p>
<p>To force the download of the PDF, or any other file, you need to send the content-disposition HTTP header.  Most server-side programmers send content-disposition and location HTTP heades from their scripts.  You can also configure Apache to send the content-disposition header for PDFs (or any other files).</p>
<p><code><br />
&lt;Files *.pdf&gt;<br />
  ForceType application/pdf<br />
  Header set Content-Disposition attachment<br />
&lt;/Files&gt;<br />
</code></p>
<p>This can be placed in your &lt;VirtualHost&gt; configuration.</p>
<p><a href="http://masstransmit.com/garage_blog/save-as-pdf/">Trigger Save As&#8230; Window for PDF Download</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fsave-as-pdf%2F&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Trigger+Save+As...+Window+for+PDF+Download&amp;link=http://masstransmit.com/garage_blog/save-as-pdf/&amp;notes=Most%20browsers%20are%20equipped%20to%20display%20PDFs.%20%20This%20means%20when%20a%20user%20clicks%20on%20a%20link%20to%20a%20PDF%20on%20a%20website%2C%20the%20browser%20will%20download%20and%20display%20it.%20%20PDFs%2C%20however%2C%20are%20intended%20to%20be%20downloaded%20and%20retained%20by%20the%20user%20for%20offline%20viewing%20or%20printing.%0D%0A%0D%0AIt%20is%20possible%2C%20however%2C%20for%20anyone%20to%20save&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/save-as-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Device Detection Plugin for WordPress</title>
		<link>http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/</link>
		<comments>http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 15:00:59 +0000</pubDate>
		<dc:creator>Christian Skelly</dc:creator>
				<category><![CDATA[Garage Blog]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WURFL]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=6030</guid>
		<description><![CDATA[Firstly set-up your Wordpress environment by creating a new directory in the
Wordpress plugins directory, for our purposes we'll name it "theme_swapper"<p><a href="http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/">Device Detection Plugin for WordPress</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>Firstly set-up your WordPress environment by creating a new directory in the<br />
Wordpress plugins directory, for our purposes we&#8217;ll name it &#8220;theme_swapper&#8221;</p>
<p>&#8220;/wp-content/plugins/theme_swapper/&#8221;</p>
<p>This newly created directory will house the plugin file and the Wurfl library.</p>
<p>Download the latest <a href="http://sourceforge.net/projects/wurfl/files/WURFL%20PHP/1.3/" target="_blank">WURFL</a> library to your &#8220;theme_swapper&#8221; directory. In &#8220;/wurfl-php-xxx/examples/demo/inc/&#8221; you&#8217;ll find the &#8220;header-config.inc&#8221; file. This file sets your Wurfl environment by including the Wurfl application files and the &#8220;Resources&#8221; directory and instantiates<br />
the Wurfl object. The other file to configure is the &#8220;wurfl-config.xml&#8221; file, located in &#8220;/wurfl-php-xxx/examples/resources/&#8221;. There is an option for cache/persistence in this xml file, this is important to set-up correctly so your queries to the library don&#8217;t tax server resources. I&#8217;ve had great results using the &#8220;file&#8221; option for persistence. There is a helpful getting started guide at the Wurfl site <a title="Wurfl PHP API" href="http://wurfl.sourceforge.net/nphp" target="_blank">here</a>.</p>
<p>header-inc.php file:</p>
<pre>session_start();
//ini_set('display_errors', 'on');
//error_reporting(E_ALL);

define("WURFL_DIR", dirname(__FILE__)."/WURFL/");
define("RESOURCES_DIR", dirname(__FILE__)."/resources/");

require_once WURFL_DIR . 'Application.php';

$wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
// Create WURFL Configuration from an XML config file
$wurflConfig = new WURFL_Configuration_XmlConfig($wurflConfigFile);
// Create a WURFL Manager Factory from the WURFL Configuration
$wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
// Create a WURFL Manager ($wurflManager is a WURFL_WURFLManager object)
$wurflManager = $wurflManagerFactory-&gt;create();
// Get information on device

$device = $wurflManager-&gt;getDeviceForHttpRequest($_SERVER);
$_SESSION['wireless'] = $device-&gt;getCapability('is_wireless_device') ;</pre>
<p>For our example I want to get the value of &#8220;is_wireless_device&#8221; from the library and pass it to the<br />
plugin filter function. For persistence I am storing the result in the $_SESSION['wireless'] variable.</p>
<p>For the plugin, inside of the &#8220;/theme_swapper/&#8221; directory create a new PHP file, give this file the same name<br />
of the directory. The complete path should be: &#8220;/wp-content/plugins/theme_swapper/theme_swapper.php&#8221;. At the<br />
top of this file will need to go the plugin specific meta-data.</p>
<p>Next, include the above mentioned &#8220;header-config.inc&#8221;.</p>
<p>Now come the actual plugin functions. In this case we are going to pass to the plugin the<br />
result of our Wurfl query stored in the $_SESSION['wireless'] variable to filter values from<br />
the WordPress wp_options table in the Database. WordPress plugin documentation can be found <a title="WordPress Plugin API" href="http://codex.wordpress.org/Plugin_API" target="_blank">here</a>.</p>
<p>&nbsp;</p>
<pre>/*** Include the WURFL library ***/
require_once 'header-config.inc';

//The three system values we want to filter
add_filter('template', array('wpThemeLoad','mobile_theme_loader'));
add_filter('option_template', array('wpThemeLoad','mobile_theme_loader'));
add_filter('option_stylesheet', array('wpThemeLoad','mobile_theme_loader'));

//Passes the value back to our filter functions
class wpThemeLoad {
	public function mobile_theme_loader() {
		$theme = getTheme::displaytheme();
			return $theme;
	}
}

/*This sets the theme we want, should be the actual name of the
* directory that houses your theme e.g. "/wp-content/themes/desktop_theme/"
*/
class getTheme {
	public static function displaytheme() {
		if($_SESSION['wireless'] == 'false') {
			return 'desktop_theme';
			} else {
			return 'mobile_theme';
		}
	}
}

?&gt;</pre>
<p>Lastly, login to your WordPress site and activte the &#8220;Theme Swapper&#8221; plugin.</p>
<p><a href="http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/">Device Detection Plugin for WordPress</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fdevice-detection-plugin-for-wordpress%2F&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Device+Detection+Plugin+for+Wordpress&amp;link=http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/&amp;notes=Firstly%20set-up%20your%20Wordpress%20environment%20by%20creating%20a%20new%20directory%20in%20the%0D%0AWordpress%20plugins%20directory%2C%20for%20our%20purposes%20we%27ll%20name%20it%20%22theme_swapper%22&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/device-detection-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Incorporate Insert On Duplicate Key Update Method in Zend_Db_Table</title>
		<link>http://masstransmit.com/garage_blog/zend-dup-key-update/</link>
		<comments>http://masstransmit.com/garage_blog/zend-dup-key-update/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 01:11:20 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=4938</guid>
		<description><![CDATA[MySQL includes a clause for INSERT statements in which an UPDATE is executed if an existing primary or unique key is encountered on the update. The generate syntax for this statement is: INSERT INTO [table] ([columns]) VALUES ([values]) ON DUPLICATE KEY UPDATE [column updates]; The Zend_Db_Table_Abstract class may be extended to incorporate a method to [...]<p><a href="http://masstransmit.com/garage_blog/zend-dup-key-update/">Incorporate Insert On Duplicate Key Update Method in Zend_Db_Table</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>MySQL includes a clause for INSERT statements in which an UPDATE is executed if an existing primary or unique key is encountered on the update.  The generate syntax for this statement is:</p>
<p><code><br />
INSERT INTO [table] ([columns]) VALUES ([values])<br />
ON DUPLICATE KEY UPDATE [column updates];<br />
</code></p>
<p>The Zend_Db_Table_Abstract class may be extended to incorporate a method to execute this statement.  The Zend_Db classes are meant to be database agnostic, so this can only work if your database is MySQL.  Since this SQL statement is a hybrid of INSERT and UPDATE, the method accepts two data arrays: one for insert and one for update.  If the INSERT data encounters a duplicate key, the update array is executed on the existing row.  The method will return whichever Zend_Db_Statement class you are using as the method utilizes the adapter&#8217;s query() method.</p>
<p><code></p>
<pre>
class MyProject_BaseTable extends Zend_Db_Table_Abstract
{
	/**
	 * Execute an INSERT ON DUPLICATE KEY statement
	 * @param array $insertData Data to use for INSERT portion
	 * @param array $updateData Data to use for UPDATE portion
	 * @return Zend_Db_Statement
	 */
	public function insertOnDuplicateKeyUpdate($insertData, $updateData) {
		// generate INSERT part statement
		$insertCols = '';
		$insertVals = '';
		foreach($insertData as $column => $value) {
			$insertCols .= $this->getAdapter()->quoteIdentifier($column) . ',';
			$insertVals .=	(get_class($value) == 'Zend_Db_Expr')
						? $value->__toString()
						: $this->getAdapter()->quoteInto('?', $value);
			$insertVals .= ',';
		}
		$insertCols = rtrim($insertCols, ',');
		$insertVals = rtrim($insertVals, ',');

		// generate UPDATE part of statement
		$updateExpr = '';
		foreach($updateData as $column => $value) {
			$updateExpr .=	$this->getAdapter()->quoteIdentifier($column) . ' = ';
			$updateExpr .=	(get_class($value) == 'Zend_Db_Expr')
						? $value->__toString()
						: $this->getAdapter()->quoteInto('?', $value);
			$updateExpr .= ',';
		}
		$updateExpr = rtrim($updateExpr, ',');

		// generate statement
		$sql = 'INSERT INTO ' . $this->_name . ' (' . $insertCols . ') VALUES (' . $insertVals . ') ';
		$sql .= 'ON DUPLICATE KEY UPDATE ' . $updateExpr . ';';

		return $this->_db->query($sql);
	}
}
</pre>
<p></code></p>
<p><a href="http://masstransmit.com/garage_blog/zend-dup-key-update/">Incorporate Insert On Duplicate Key Update Method in Zend_Db_Table</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fzend-dup-key-update%2F&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Incorporate+Insert+On+Duplicate+Key+Update+Method+in+Zend_Db_Table&amp;link=http://masstransmit.com/garage_blog/zend-dup-key-update/&amp;notes=MySQL%20includes%20a%20clause%20for%20INSERT%20statements%20in%20which%20an%20UPDATE%20is%20executed%20if%20an%20existing%20primary%20or%20unique%20key%20is%20encountered%20on%20the%20update.%20%20The%20generate%20syntax%20for%20this%20statement%20is%3A%0D%0A%0D%0A%0D%0AINSERT%20INTO%20%5Btable%5D%20%28%5Bcolumns%5D%29%20VALUES%20%28%5Bvalues%5D%29%0D%0AON%20DUPLICATE%20KEY%20UPDATE%20%5Bcolumn%20updates%5D%3B%0D%0A%0D%0A%0D%0AThe%20Zend_&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/zend-dup-key-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extend Zend_Db_Table with Replace() Method</title>
		<link>http://masstransmit.com/garage_blog/zend-db-table-replace/</link>
		<comments>http://masstransmit.com/garage_blog/zend-db-table-replace/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 03:56:52 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=4703</guid>
		<description><![CDATA[The REPLACE statement is a handy MySQL addition to the SQL language. It is useful when you want to INSERT a new row or replace any existing row with the same primary key or unique index. In the event of a replace, the existing row is deleted and a new row inserted. If the table [...]<p><a href="http://masstransmit.com/garage_blog/zend-db-table-replace/">Extend Zend_Db_Table with Replace() Method</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>The REPLACE statement is a handy MySQL addition to the SQL language.  It is useful when you want to INSERT a new row or replace any existing row with the same primary key or unique index.  In the event of a replace, the existing row is deleted and a new row inserted.  If the table has an auto-incrementing field, the new row will have the next number in the sequence.  It wil not have the number of the old row.</p>
<p>The Zend_Db classes are meant to be database agnostic, though MySQL is largely the underlying database in Zend projects.  The Zend_Db_Table class is without a replace() method as it is only supported by MySQL.  You can, however, add a replace() method to your table classes by extending Zend_Db_Table_Abstract and extending your table classes from this child class of Zend_Db_Table_Abstract.</p>
<p><code></p>
<pre>
class MyProject_BaseTable extends Zend_Db_Table_Abstract
{
	/**
	 * Replace function to execute a MySQL REPLACE.
	 * @param array $data data array just as if it was for insert()
	 * @return Zend_Db_Statement_Mysqli
	 */
	public function replace($data) {
		// get the columns for the table
		$tableInfo = $this->info();
		$tableColumns = $tableInfo['cols'];

		// columns submitted for insert
		$dataColumns = array_keys($data);

		// intersection of table and insert cols
		$valueColumns = array_intersect($tableColumns, $dataColumns);
		sort($valueColumns);

		// generate SQL statement
		$cols = '';
		$vals = '';
		foreach($valueColumns as $col) {
			$cols .= $this->getAdapter()->quoteIdentifier($col) . ',';
			$vals .=	(get_class($data[$col]) == 'Zend_Db_Expr')
						? $data[$col]->__toString()
						: $this->getAdapter()->quoteInto('?', $data[$col]);
			$vals .= ',';
		}
		$cols = rtrim($cols, ',');
		$vals = rtrim($vals, ',');
		$sql = 'REPLACE INTO ' . $this->_name . ' (' . $cols . ') VALUES (' . $vals . ');';

		return $this->_db->query($sql);

	}
}
</pre>
<p></code></p>
<p><a href="http://masstransmit.com/garage_blog/zend-db-table-replace/">Extend Zend_Db_Table with Replace() Method</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fzend-db-table-replace%2F&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Extend+Zend_Db_Table+with+Replace%28%29+Method&amp;link=http://masstransmit.com/garage_blog/zend-db-table-replace/&amp;notes=The%20REPLACE%20statement%20is%20a%20handy%20MySQL%20addition%20to%20the%20SQL%20language.%20%20It%20is%20useful%20when%20you%20want%20to%20INSERT%20a%20new%20row%20or%20replace%20any%20existing%20row%20with%20the%20same%20primary%20key%20or%20unique%20index.%20%20In%20the%20event%20of%20a%20replace%2C%20the%20existing%20row%20is%20deleted%20and%20a%20new%20row%20inserted.%20%20If%20the%20table%20has%20an%20auto-increm&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/zend-db-table-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable PHP Execution in Certain Directories</title>
		<link>http://masstransmit.com/garage_blog/disable-php-execution/</link>
		<comments>http://masstransmit.com/garage_blog/disable-php-execution/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 18:30:24 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=4570</guid>
		<description><![CDATA[In deploying a web PHP application, there may be instances where you need to disable PHP execution in certain places. This is especially helpful if your application accepts uploaded files which are placed under the document root. This way if a person happens to upload a PHP file, it will not be executed. Under Apache, [...]<p><a href="http://masstransmit.com/garage_blog/disable-php-execution/">Disable PHP Execution in Certain Directories</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>In deploying a web PHP application, there may be instances where you need to disable PHP execution in certain places.  This is especially helpful if your application accepts uploaded files which are placed under the document root.  This way if a person happens to upload a PHP file, it will not be executed.</p>
<p>Under Apache, you may turn off PHP execution on a per-directory basis.  In the VirtualHost directive, add:</p>
<p><code>&lt;Directory /full/path/to/directory&gt;<br />
    php_flag engine off<br />
&lt;/Directory&gt;</code></p>
<p>If you&#8217;re allowed to use .htaccess files, create a .htaccess file in the directory you wish to disable PHP execution:</p>
<p><code>php_flag engine off</code></p>
<p><a href="http://masstransmit.com/garage_blog/disable-php-execution/">Disable PHP Execution in Certain Directories</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fdisable-php-execution%2F&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Disable+PHP+Execution+in+Certain+Directories&amp;link=http://masstransmit.com/garage_blog/disable-php-execution/&amp;notes=In%20deploying%20a%20web%20PHP%20application%2C%20there%20may%20be%20instances%20where%20you%20need%20to%20disable%20PHP%20execution%20in%20certain%20places.%20%20This%20is%20especially%20helpful%20if%20your%20application%20accepts%20uploaded%20files%20which%20are%20placed%20under%20the%20document%20root.%20%20This%20way%20if%20a%20person%20happens%20to%20upload%20a%20PHP%20file%2C%20it%20will%20not%20be%20ex&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/disable-php-execution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Publish SPF Record to Increase Email Deliverability</title>
		<link>http://masstransmit.com/garage_blog/spf/</link>
		<comments>http://masstransmit.com/garage_blog/spf/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 22:57:43 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=4562</guid>
		<description><![CDATA[SPF (Sender Policy Framework) is means of validating email senders to help reduce spam. The process involves publish a TXT DNS record for a domain or hostname that specifies the outgoing SMTP servers which are authorized to send email on behalf of the domain/hostname. An SMTP server receiving mail or spam prevention system can perform [...]<p><a href="http://masstransmit.com/garage_blog/spf/">Publish SPF Record to Increase Email Deliverability</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>SPF (Sender Policy Framework) is means of validating email senders to help reduce spam. The process involves publish a TXT DNS record for a domain or hostname that specifies the outgoing SMTP servers which are authorized to send email on behalf of the domain/hostname.</p>
<p>An SMTP server receiving mail or spam prevention system can perform SPF checks using the FROM header of the email and the IP of the originating server. In the check, the domain or hostname part of the email in the FROM header is used for the DNS lookup. For instance, if the server receives an email from john.doe@some.domain.com, a TXT record lookup is performed on some.domain.com:</p>
<p>Using dig on Unix/Linux:<br />
<code><br />
&gt; dig -t txt some.domain.com<br />
;; ANSWER SECTION:<br />
some.domain.com.	4754	IN	TXT	"v=spf1 ip4:192.168.1.10 -all"<br />
</code></p>
<p>Using nslookup on Windows:<br />
<code><br />
&gt; nslookup<br />
&gt; set type=TXT<br />
&gt; some.domain.com<br />
Non-authoritative answer:<br />
some.domain.com        text =<br />
        "v=spf1 ip4:192.168.1.10 -all"<br />
</code></p>
<p>Now the receiving server sees that only IP 192.168.1.10 is allowed to send emails for some.domain.com.  If the sending server is not 192.168.1.10, then the SPF check has failed.  The <tt>-all</tt> is a catchall for all IPs.  The minus denotes a hard fail, hence the mail administrator for some.domain.com really does not want mail for that hostname originating from anywhere other than 192.168.1.10.  A &#8220;~&#8221; denotes a soft fail.  This directive is more lenient as it indicates some mail may originate from other IPs.  Base on this hard/soft fail, a weight to the spam score may be applied.  A hard fail will have a heavier score if not outright rejection of the email.</p>
<p>As an email marketer, publishing an SPF record for your sending domain/hostname will improve your deliverability.  The &#8220;harder&#8221; the fail, the more secure the receiving SMTP servers will regard your email infrastructure to be.</p>
<p>More information regarding SPF can be found at <a href="http://www.openspf.org" target="_blank">http://www.openspf.org</a> including SPF record syntax and links to SPF testing tools.  Clients using our <a href="http://emailtransmit.com" target="_blank">EmailTransmit</a> email marketing service should include:spf.emailtransmit.com to the SPF record of all domains/hostnames used in the FROM email for their campaigns.</p>
<p><a href="http://masstransmit.com/garage_blog/spf/">Publish SPF Record to Increase Email Deliverability</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fspf%2F&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Publish+SPF+Record+to+Increase+Email+Deliverability&amp;link=http://masstransmit.com/garage_blog/spf/&amp;notes=SPF%20%28Sender%20Policy%20Framework%29%20is%20means%20of%20validating%20email%20senders%20to%20help%20reduce%20spam.%20The%20process%20involves%20publish%20a%20TXT%20DNS%20record%20for%20a%20domain%20or%20hostname%20that%20specifies%20the%20outgoing%20SMTP%20servers%20which%20are%20authorized%20to%20send%20email%20on%20behalf%20of%20the%20domain%2Fhostname.%0D%0A%0D%0AAn%20SMTP%20server%20receiving%20mai&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/spf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exclude the Include: Zend Framework Namespaces</title>
		<link>http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/</link>
		<comments>http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 17:18:24 +0000</pubDate>
		<dc:creator>Christian Skelly</dc:creator>
				<category><![CDATA[Garage Blog]]></category>
		<category><![CDATA[Zend Framework namespace]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=4359</guid>
		<description><![CDATA[An extremely useful feature of Zend Framework is the utilization of Namespaces instead of using PHP includes to communicate with your class files. Configure this feature correctly and you have successfully done away with the need to maintain multiple &#8220;includes&#8221; throughout your app. If you look at the standard Zend Framework file hierarchy, your controllers [...]<p><a href="http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/">Exclude the Include: Zend Framework Namespaces</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>An extremely useful feature of Zend Framework is the utilization of Namespaces instead of using PHP includes to communicate with your class files. Configure this feature correctly and you have successfully done away with the need to maintain multiple &#8220;includes&#8221; throughout your app.</p>
<p>If you look at the standard Zend Framework file hierarchy, your controllers reside in &#8220;/application-&gt;controllers&#8221;, and ideally your custom class files reside in &#8220;/library-&gt;&#8221;. To enable all your controllers to communicate with your library files, simply edit your application.ini file like so:</p>
<p>1) Make sure you have your library added to your &#8220;includePaths&#8221;</p>
<pre>includePaths.library = APPLICATION_PATH "/../library"</pre>
<p>2) Add this line:</p>
<pre>autoloaderNamespaces.Example = Example_</pre>
<p>Where &#8220;Example&#8221; is the Namespace you want to specify.</p>
<p>So now you have the Namespace set-up correctly, how do you use it?</p>
<p>One level directly below your &#8220;library&#8221; create a directory that echoes your newly created Namespace. e.g. &#8220;/library/Example&#8221;.</p>
<p>Inside the &#8220;Example&#8221; directory create a new PHP file named &#8220;Service.php&#8221;. The naming of your class in &#8220;Service.php&#8221; should follow the directory structure you have created, so the class name in this case will look like:</p>
<pre>class Example_Service {</pre>
<p>When trying to create the &#8220;Example_Service&#8221; object from one of your controllers, you can now call it directly:</p>
<pre>public function indexAction()
    {
    $example = new Example_Service();
    //do something
    }</pre>
<p>There is now no need to have multiple lines of include files to maintain.</p>
<p><a href="http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/">Exclude the Include: Zend Framework Namespaces</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fexclude-the-include-zend-framework-namespaces%2F&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Exclude+the+Include%3A+Zend+Framework+Namespaces&amp;link=http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/&amp;notes=An%20extremely%20useful%20feature%20of%20Zend%20Framework%20is%20the%20utilization%20of%20Namespaces%20instead%20of%20using%20PHP%20includes%20to%20communicate%20with%20your%20class%20files.%20Configure%20this%20feature%20correctly%20and%20you%20have%20successfully%20done%20away%20with%20the%20need%20to%20maintain%20multiple%20%22includes%22%20throughout%20your%20app.%0D%0A%0D%0AIf%20you%20look%20at&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/exclude-the-include-zend-framework-namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH key authentication HOWTO</title>
		<link>http://masstransmit.com/garage_blog/ssh-key-auth/</link>
		<comments>http://masstransmit.com/garage_blog/ssh-key-auth/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 22:11:20 +0000</pubDate>
		<dc:creator>Mark Lewis</dc:creator>
				<category><![CDATA[Garage Blog]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=4245</guid>
		<description><![CDATA[Connecting to a server over SSH/SCP/SFTP via key authentication is quite handy when: frequently connecting to the same set of servers from one location Allowing a cron job to remotely execute or transfer files to another server The process to allow this is to generate a private/public key pair on the computer from which you [...]<p><a href="http://masstransmit.com/garage_blog/ssh-key-auth/">SSH key authentication HOWTO</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>Connecting to a server over SSH/SCP/SFTP via key authentication is quite handy when:</p>
<ul>
<li>frequently connecting to the same set of servers from one location</li>
<li>Allowing a cron job to remotely execute or transfer files to another server</li>
</ul>
<p>The process to allow this is to generate a private/public key pair on the computer from which you will be connecting.  You then place the public key on the remote server(s) to which you will be connecting.  Here&#8217;s how:</p>
<p><strong>Go to your SSH preferences directory on the client</strong></p>
<p>Log into the computer from which you will be connecting.  Log in as the user who will be initiating the ssh/scp/sftp client connection.  In the case of a cron job, this may be root.</p>
<p>Go to that user&#8217;s ssh preferences directory.  This is at ~/.ssh:<br />
<code>cd ~/.ssh</code></p>
<p>If that directory does not exist, create it:<br />
<code>mkdir ~/.ssh<br />
cd ~/.ssh<br />
</code></p>
<p><strong>Generate the private/public key pair</strong></p>
<p>The best results I&#8217;ve had are with a DSA key pair:</p>
<p><code>ssh-keygen -t dsa</code></p>
<p>This will begin the process of generating the keys.  Opt for no passphrase else you&#8217;ll be asked for it every time you try to connect (thus defeating the purpose of a password-less login).</p>
<p><code>Generating public/private dsa key pair.<br />
Enter file in which to save the key (/home/jdoe/.ssh/id_dsa):<br />
Enter passphrase (empty for no passphrase):<br />
Enter same passphrase again:<br />
Your identification has been saved in /home/jdoe/.ssh/id_dsa.<br />
Your public key has been saved in /home/jdoe/.ssh/id_dsa.pub.<br />
The key fingerprint is:<br />
f1:44:74:5b:65:c9:af:92:9d:74:c5:0f:8e:4d:47:01 jdoe@domain.com<br />
</code></p>
<p>You now have two keys: id_dsa and id_dsa.pub.  id_dsa is your private key and must remain on this server and kept secure.  id_dsa.pub is the public key you will place on all servers to which you wish to connect.</p>
<p>Be sure only this user has permission to the private key:</p>
<p><code>chmod 700 ~/.ssh/id_dsa</code></p>
<p><strong>Transfer the public key to the server(s) to which you want to connect</strong></p>
<p>The public key, id_dsa.pub, goes into the authorized_keys files of the user on the remote server you will be connecting as.  The easiest way this is accomplished is:</p>
<p><code>ssh remoteuser@remotedomain.com 'cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_dsa.pub</code></p>
<p>This executes the cat command on the remote server which will take the contents of ~/.ssh/id_dsa.pub on the local server and append it to ~/.ssh/authorized_keys on the remote server for user remoteuser.  You will be prompted for the password for remoteuser.</p>
<p><strong>Try connecting</strong></p>
<p>Now try connecting to the remote server:</p>
<p><code>ssh remoteuser@remotedomain.com</code></p>
<p>You should not have to enter a password.  If you are still prompted for a password, there's some trouble shooting to be done.  One thing to check is the correct name of the authorized_keys file on the remote server.  This is found in the AuthorizedKeysFile setting in /etc/ssh/sshd_config on the remote server.</p>
<p>If you want to connect to other servers from the same location, place id_dsa.pub on those servers.  There is no need to generate a new key pair.</p>
<p><a href="http://masstransmit.com/garage_blog/ssh-key-auth/">SSH key authentication HOWTO</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fssh-key-auth%2F&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=SSH+key+authentication+HOWTO&amp;link=http://masstransmit.com/garage_blog/ssh-key-auth/&amp;notes=Connecting%20to%20a%20server%20over%20SSH%2FSCP%2FSFTP%20via%20key%20authentication%20is%20quite%20handy%20when%3A%0D%0A%0D%0A%0D%0A%09frequently%20connecting%20to%20the%20same%20set%20of%20servers%20from%20one%20location%0D%0A%09Allowing%20a%20cron%20job%20to%20remotely%20execute%20or%20transfer%20files%20to%20another%20server%0D%0A%0D%0A%0D%0AThe%20process%20to%20allow%20this%20is%20to%20generate%20a%20private%2Fpublic%20k&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/ssh-key-auth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simplify Your Use of cURL</title>
		<link>http://masstransmit.com/garage_blog/simplify-your-use-of-curl/</link>
		<comments>http://masstransmit.com/garage_blog/simplify-your-use-of-curl/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 21:01:42 +0000</pubDate>
		<dc:creator>Christian Skelly</dc:creator>
				<category><![CDATA[Garage Blog]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://masstransmit.com/?p=2327</guid>
		<description><![CDATA[A common scenario: You are developing an app in PHP where you will be making numerous API calls to various 3rd party services. You will invariably need to utilize some form of HTTP client. My choice for this is the cURL PHP extension. If you are using the Zend Framework there is a built in [...]<p><a href="http://masstransmit.com/garage_blog/simplify-your-use-of-curl/">Simplify Your Use of cURL</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>
]]></description>
			<content:encoded><![CDATA[<p>A common scenario: You are developing an app in PHP where you will be making<br />
numerous API calls to various 3rd party services. You will invariably<br />
need to utilize some form of HTTP client.</p>
<p>My choice for this is the cURL PHP extension. If you are using the Zend Framework there is a built in HTTP client &#8211; I still prefer to use the native cURL php library, partly because it handles<br />
SSL requests (in Zend you need to use a cURL adapter to achieve this within their HTTP client*), but mostly because I can reuse the code for non-zend based projects with a minimum of fuss.</p>
<p><span id="more-2327"></span></p>
<p>For example you may have a class file that is calling the YouTube Data API half a dozen times and then the Google Analytics API another x number of times. By writing new cURL code for each call you are going to end up with a very<br />
bloated code file, and a time consuming one if a change comes down the pipe.</p>
<p>Some of these requests will be standard GET/POST requests sent over &#8220;http&#8221; whilst others will contain sensitive information such as an API key or token. Those particular requests will probably need to be sent over &#8220;https&#8221;, so essentially we have 4 types of cURL/API requests: &#8216;GET&#8217; or &#8216;POST&#8217; and &#8216;HTTP&#8217; or &#8216;HTTPS&#8217;</p>
<p>To save yourself a lot of time and to make your code more manageable create a<br />
cURL class containing a method for each type of request. Each time you need to make an API call simply reference the particular cURL method from the class file you created.</p>
<p><strong>Example:</strong> Secure Post Request</p>
<p>Your cURL class file:<br />
<code><br />
class curlrequest {<br />
// $post_string in the form of:<br />
// var1=xxx&amp;var2=yyy&amp;var3=zzz<br />
public function curlHttpsPost($url, $post_string) {<br />
$curl = curl_init();<br />
$options = array(CURLOPT_URL =&gt; $url,<br />
CURLOPT_RETURNTRANSFER =&gt; true,<br />
CURLOPT_POST =&gt; TRUE,<br />
CURLOPT_POSTFIELDS =&gt; $post_string,<br />
//these are the HTTPS related options<br />
CURLOPT_SSL_VERIFYHOST =&gt; 0,<br />
CURLOPT_SSL_VERIFYPEER =&gt; false,);<br />
curl_setopt_array($curl, $options);<br />
$response = curl_exec($curl);<br />
curl_close($curl);<br />
return $response ;<br />
}<br />
//Additional curl methods here<br />
}</code></p>
<p>Your PHP code that calls the method:</p>
<p><code><br />
$request = new curlrequest();<br />
$call = $request-&gt;curlHttpsPost("https://some_API_entrypoint", "var1=xxx&amp;var2=yyy");<br />
//code to deal with the result of $call<br />
</code></p>
<p>So the call is made using your curl object in 2 lines of code.</p>
<p><a href="http://masstransmit.com/garage_blog/simplify-your-use-of-curl/">Simplify Your Use of cURL</a> is a post from the <a href="http://blog.masstransmit.com">Mass Transmit Broadcast Blog</a>. Subscribe to <a href="http://feedburner.google.com/fb/a/mailverify?uri=masstransmit-broadcast&loc=en_US" target="_blank">receive blog posts via email</a>. Connect with us on <a href="http://facebook.com/masstransmit" target="_blank">Facebook</a>, <a href="http://twitter.com/masstransmit" target="_blank">Twitter</a> and <a href="https://plus.google.com/u/0/b/114005462330656553046/114005462330656553046/posts" target="_blank">Google+</a>!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-linkedin">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=88&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http%3A%2F%2Fmasstransmit.com%2Fgarage_blog%2Fsimplify-your-use-of-curl%2F&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=78&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-posterous">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=210&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Simplify+Your+Use+of+cURL&amp;link=http://masstransmit.com/garage_blog/simplify-your-use-of-curl/&amp;notes=A%20common%20scenario%3A%20You%20are%20developing%20an%20app%20in%20PHP%20where%20you%20will%20be%20making%0D%0Anumerous%20API%20calls%20to%20various%203rd%20party%20services.%20You%20will%20invariably%0D%0Aneed%20to%20utilize%20some%20form%20of%20HTTP%20client.%0D%0A%0D%0AMy%20choice%20for%20this%20is%20the%20cURL%20PHP%20extension.%20If%20you%20are%20using%20the%20Zend%20Framework%20there%20is%20a%20built%20in%20HTTP&amp;short_link=&amp;shortener=bitly&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
</ul><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://masstransmit.com/garage_blog/simplify-your-use-of-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

