<?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>Tom Reitz &#187; Tech</title>
	<atom:link href="http://www.tom-reitz.com/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tom-reitz.com</link>
	<description>Tech Talk, Catholic Commentary, and American Activism</description>
	<lastBuildDate>Tue, 07 Dec 2010 09:42:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calendar Syncing with iPhone and Mozilla Sunbird or Thunderbird/Lightning</title>
		<link>http://www.tom-reitz.com/2010/12/07/calendar-syncing-with-iphone-and-mozilla-sunbird-or-thunderbird-lightning/</link>
		<comments>http://www.tom-reitz.com/2010/12/07/calendar-syncing-with-iphone-and-mozilla-sunbird-or-thunderbird-lightning/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 09:22:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[CalDAV]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[lightning]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[sunbird]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[thunderbird]]></category>
		<category><![CDATA[WebDAV]]></category>

		<guid isPermaLink="false">http://www.tom-reitz.com/?p=180</guid>
		<description><![CDATA[After an unacceptably long vacation from blogging, I&#8217;m back. And I&#8217;ll try to post goodies here more often!
Today&#8217;s post is a rant followed by a technical solution that hopefully some will find useful. You can skip past the rant by clicking here  
The Rant: Cloud Storage and Sync
I tend to use a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>After an unacceptably long vacation from blogging, I&#8217;m back. And I&#8217;ll try to post goodies here more often!</p>
<p>Today&#8217;s post is a rant followed by a technical solution that hopefully some will find useful. You can skip past the rant by <a href="#theproblem">clicking here</a> <img src='http://www.tom-reitz.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' title="Calendar Syncing with iPhone and Mozilla Sunbird or Thunderbird/Lightning" /> </p>
<h2 style="padding: 20px 2px 10px 2px;">The Rant: Cloud Storage and Sync</h2>
<p><a href="http://www.tom-reitz.com/wp-content/uploads/2010/12/iphone.jpg"><img class="alignleft size-full wp-image-195" title="iPhone" src="http://www.tom-reitz.com/wp-content/uploads/2010/12/iphone.jpg" alt="iPhone" width="122" /></a>I tend to use a lot of open source software. It&#8217;s free, and it&#8217;s usually as well or better built than commercial software. It does sometimes require a bit of technical knowledge and troubleshooting though.</p>
<p>I also own an iPhone. In some ways, I really love it. I can check on all my websites, servers, social streams, emails, and calls from one compact gadget. From anywhere. However, the iPhone is unfortunately a very closed sort of platform. Apple controls all of the software available for the device, and chooses not to provide some seemingly basic features &#8211; like accessing files stored on the phone from your computer.</p>
<p>Now almost anybody you ask will say that you should just sync all your data to the cloud. Then you can access it from your computer easily (or from anywhere else). But I have a problem with that.</p>
<p><a href="http://www.tom-reitz.com/wp-content/uploads/2010/12/1216139826649869464rgtaylor_csc_net_wan_cloud.svg_.med_.png"><img class="size-full wp-image-194 alignright" style="margin: 8px;" title="Cloud" src="http://www.tom-reitz.com/wp-content/uploads/2010/12/1216139826649869464rgtaylor_csc_net_wan_cloud.svg_.med_.png" alt="Cloud Storage" width="300" height="158" /></a>When you sync your data to the cloud, you&#8217;re sending it to a server that&#8217;s controlled by a third party. Any of the following things can then happen:</p>
<ol>
<li style="padding-bottom: 10px;">Some nosy admin on the other end can inadvertently or purposely start looking through your data. He could get fired, but only if his boss finds out.</li>
<li style="padding-bottom: 10px;">The third party could have its servers compromised, by hackers for instance. Oops! now <em>bl4sterz.ru</em> knows your every personal detail.</li>
<li style="padding-bottom: 10px;">By storing your data, the third party in a sense &#8220;owns&#8221; it. If they decide to start embedding ads in your data, or charging a monthly fee to use their service, what can you do about it?</li>
</ol>
<p>For these sorts of reasons, I never send information to third parties on the web unless I&#8217;m basically comfortable with that information being publicly available to all. Yes, that means you, Facebook. And Twitter. Et cetera.</p>
<h2 style="padding: 20px 2px 10px 2px;" id="theproblem">The Problem: iPhone/Lightning Calendar Sync, without the Cloud</h2>
<p>OK, enough rant about cloud storage services. Here&#8217;s why this all came up:</p>
<p><a href="http://www.tom-reitz.com/wp-content/uploads/2010/12/mozilla_thunderbird.png"><img class="alignright size-medium wp-image-198" style="margin: 2px 8px;" title="Mozilla Thunderbird" src="http://www.tom-reitz.com/wp-content/uploads/2010/12/mozilla_thunderbird-282x300.png" alt="Mozilla Thunderbird" width="141" /></a>As I said before, I have an iPhone. I also use Mozilla&#8217;s Thunderbird email browser with a calendar plugin called Lightning to manage my appointments and such. I would like to have the calendar on the iPhone sync with Lightning. (Mozilla Sunbird is basically the same as Lightning for Thunderbird &#8211; it&#8217;s made by the same folks and has the same functionality. Sunbird just lacks the email client.)</p>
<p>If you Google how to do this, everyone says that you should sync both Lightning and the iPhone with Google calendar. But that&#8217;s a cloud solution: I don&#8217;t want Google to know all my appointments!</p>
<h2 style="padding: 20px 2px 10px 2px;">The Solution: Set Up Your Own CalDAV server</h2>
<p><a href="http://www.tom-reitz.com/wp-content/uploads/2010/12/1194984495549320725tabella_architetto_franc_01.svg_.thumb_.png"><img class="alignleft size-full wp-image-199" style="margin: 4px 8px;" title="CalDAV" src="http://www.tom-reitz.com/wp-content/uploads/2010/12/1194984495549320725tabella_architetto_franc_01.svg_.thumb_.png" alt="CalDAV" width="100" height="100" /></a>Faced with this problem, I&#8217;ve worked out a nice solution: install your own CalDAV server. You can do this on either your own local network (more secure), or any webserver you have access to remotely (easier to share calendars with many people).</p>
<p>CalDAV is an implementation of a web standard called WebDAV which makes it easy to store files, calendars, addressbooks, and other information in a format that is easily readable by many devices and platforms. CalDAV specifically can identify users and store events &#8211; including recurring events and alerts. You can set up shared calendars, configure read-write access for different users to different calendars. In short, CalDAV can provide enterprise-level calendaring functionality much like Microsoft&#8217;s Exchange server.</p>
<p>There are a number of CalDAV servers available, both free and commercial. After assessing several, I went with <a title="DAViCal" href="http://www.davical.org/" target="_blank">DAViCal</a>, an open source CalDAV server implementation built on top of Apache, Perl, PHP5, and PostgreSQL server. If you need to install this suite, you can grab a prepackaged distribution like the <a title="Bitnami WAPP Stack" href="http://bitnami.org/stack/wappstack" target="_blank">Bitnami stack</a>, or install each package from the Linux shell if you&#8217;re comfortable doing so.</p>
<p><a href="http://www.tom-reitz.com/wp-content/uploads/2010/12/tux-working.png"><img class="alignright size-full wp-image-200" style="margin: 4px;" title="Tux Working" src="http://www.tom-reitz.com/wp-content/uploads/2010/12/tux-working.png" alt="Tux Working" width="160" height="160" /></a>The details of how to install DAViCal depend on the operation system distribution you&#8217;re running on your server box. See the <em>Distribution Specifics</em> section of the <a title="DAViCal Installation Wiki" href="http://wiki.davical.org/w/Installation_Stuff" target="_blank">DAViCal Installation Wiki</a>. When I installed DAViCal, I ran into the following problems. I&#8217;m posting them here, as well as some tips, in hopes that they may save you some time:</p>
<ul>
<li style="padding-bottom: 10px;">If you&#8217;re installing in a shared server environment, you&#8217;ll need to change the hard-coded Postgre database name and username in <span style="font-family: Courier New,monospace;">davical/dba/create-database.sh</span>. You may also need to manually specify the location of the AWL library in this script if it&#8217;s not in <span style="font-family: Courier New,monospace;">/usr/share/awl</span>.</li>
<li style="padding-bottom: 10px;">When running davical/dba/create-database.sh, pay attention to the output. Near the end, it will say something like &#8220;created user <em>user</em> with password <em>password</em>&#8221; &#8211; save these, as you will need them to log into DAViCal&#8217;s web administration interface later.</li>
<li style="padding-bottom: 10px;">I ran into a problem where some of DAViCal&#8217;s installation Perl scripts wouldn&#8217;t run because I was missing some required Perl modules. When I tried installing them (<span style="font-family: Courier New,monospace;">yum install perl-DBD-Pg</span>), I got &#8220;package not found&#8221;&#8230; until I checked <span style="font-family: Courier New,monospace;">/etc/yum.conf</span> which had <span style="font-family: Courier New,monospace;">exclude= &#8230; perl* &#8230;</span>. Removing the <em>perl*</em> fixed this issue <img src='http://www.tom-reitz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Calendar Syncing with iPhone and Mozilla Sunbird or Thunderbird/Lightning" /> </li>
<li style="padding-bottom: 10px;">The Installation Wiki gives two methods to install DAViCal: as a directory on your server (<em>example.com/davical</em>) or as a VHost subdomain (<em>davical.example.com</em>). If you want this to work with iPhone, go the subdomain route &#8211; when I tried to tack on a directory in the iPhone CalDAV settings, it kept removing it.
<div style="clear:both">&nbsp;</div>
<p>If you&#8217;re using an automated system like cPanel to manage your server VHosts, and hence don&#8217;t want to edit httpd.conf manually, just follow the directions for installing DAViCal in a directory (creating the symlink to davical/htdocs), and then create the subdomain in cPanel, but giving the symlink for the directory.</li>
</ul>
<p>Once installed, visit <em>davical.example.com</em> in your web browser. You should see a login screen soliciting a username and password, or you may see a diagnostic screen with some details if your installation isn&#8217;t complete.</p>
<p>Log into DAViCal with the username and password the dba/create-database.sh script generated. In the menu up top, choose <em>User Functions</em> -&gt; <em>View My Details</em>. At the bottom of this page, under <em>Principal Collections</em>, click <em>Create Collection</em>. This will basically create a new calendar you can subscribe to with a CalDAV client. Fill in the <em>DAV Path</em> and <em>Display Name</em>. Click <em>Create</em>.</p>
<p>Now, to subscribe to your new CalDAV, you&#8217;ll use the URL <em>http://davical.example.com/caldav.php/username/DAVPath</em>, where <em>username</em> is the username you used to log into the administrative interface for DAViCal, and <em>DAVPath</em> is what you set when creating the collection (previous paragraph).</p>
<p><a href="http://www.tom-reitz.com/wp-content/uploads/2010/12/iphone-calendar.png"><img class="alignright size-medium wp-image-202" style="margin: 4px 8px;" title="iPhone Calendar" src="http://www.tom-reitz.com/wp-content/uploads/2010/12/iphone-calendar-200x300.png" alt="iPhone Calendar" width="200" height="300" /></a>On the iPhone, you can subscribe to this calendar by chosing <em>Settings</em> -&gt; <em>Mail, Contacts, Calendars</em> -&gt; <em>Accounts</em> -&gt; <em>Add Account</em> -&gt; <em>Other</em> -&gt; <em>Calendars</em> -&gt; <em>Add CalDAV Account</em>. <em>Server</em> is your <em>davical.example.com</em>, <em>User Name</em> and <em>Password</em> are from your administrative account, and <em>Description</em> is any descriptive name you want appearing in your iPhone Calendar list. (Maybe the <em>Display Name</em> you chose in DAViCal admin?). Click <em>Next</em>: the iPhone will try to autodetect other settings. If it works, great! your calendar has been added. If not, click the <em>Advanced Settings</em> button that appears, then copy<em> http://davical.example.com/caldav.php/username/DAVPath</em> (see previous paragraph) into the<em> Account URL</em>.</p>
<p>In Lightning or Sunbird, right-click in the calendar list and choose <em>New Calendar</em>. Then, <em>On the Network</em> and <em>Next</em>. Choose <em>CalDAV</em> for the format, and enter <em>http://davical.example.com/caldav.php/username/DAVPath</em> (see two paragraphs ago) into <em>Location</em>. Hit <em>Next</em>. Enter your <em>username</em> and <em>password</em>. Now you should be subscribed to your CalDAV calendar!</p>
<h2 style="padding: 20px 2px 10px 2px;">Summary</h2>
<p>The iPhone can sync many things very well indeed &#8211; music, email, even web browser bookmarks. But for open source calendar software, the only easy way is to use Google&#8217;s cloud service. If you&#8217;re unwilling to do that, however, rejoice: there is another way!</p>
<p>Running a CalDAV server like DAViCal is a great way to sync calendars across computers and mobile devices, and even to share calendars with friends. And if you&#8217;re still worried about the security of your data on a public server (even one that you own or control), you can run a CalDAV server on a local network. It just won&#8217;t be accessible for remote synchronization.</p>
<p>I hope this guide was useful to you. Feel free to leave your comments below.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.tom-reitz.com%2F2010%2F12%2F07%2Fcalendar-syncing-with-iphone-and-mozilla-sunbird-or-thunderbird-lightning%2F&amp;linkname=Calendar%20Syncing%20with%20iPhone%20and%20Mozilla%20Sunbird%20or%20Thunderbird%2FLightning"><img src="/wp-content/themes/organic-theme/img/share_save.gif" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.tom-reitz.com/2010/12/07/calendar-syncing-with-iphone-and-mozilla-sunbird-or-thunderbird-lightning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter from PHP</title>
		<link>http://www.tom-reitz.com/2009/06/16/twitter-from-php/</link>
		<comments>http://www.tom-reitz.com/2009/06/16/twitter-from-php/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 17:52:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[microblogging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.tom-reitz.com/?p=143</guid>
		<description><![CDATA[A few months ago I broke down and joined Twitter. Pretty much the only reason is that I wanted to learn how to integrate Twitter into PHP web applications. Here&#8217;s what I found:
Twitter has a URL http://www.twitter.com/statuses/update.xml where you can POST a twitter update. The following HTML form will update your twitter status after asking [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I broke down and joined <a title="Twitter: Tom Reitz" href="http://twitter.com/t0mreitz" target="_blank">Twitter</a>. Pretty much the only reason is that I wanted to learn how to integrate Twitter into PHP web applications. Here&#8217;s what I found:</p>
<p>Twitter has a URL <a title="Twitter status update" href="http://www.twitter.com/statuses/update.xml" target="_blank">http://www.twitter.com/statuses/update.xml</a> where you can POST a twitter update. The following HTML form will update your twitter status after asking you for your username and password:</p>
<pre style="padding-left: 30px;">&lt;form action="http://twitter.com/statuses/update.xml" method="POST"&gt;
	&lt;input type="text" name="status" /&gt;
	&lt;input type="submit" value=""Tweet!" /&gt;
&lt;/form&gt;</pre>
<p>This is cool, but it would be nice to circumvent the password protection in a web application where you probably already have a user logged in and validated? Fortunately this is possible using HTTP headers: (please make sure you read my SECURITY NOTE below)</p>
<pre style="padding-left: 30px;">&lt;form action='twitter.php' method='post'&gt;
	&lt;input type='text' name='status' /&gt;
	&lt;input type='submit' value='tweet' /&gt;
&lt;/form&gt;
&lt;?php
	if($_POST['status']!="") {

		$data = "status=".stripslashes($_POST['status']);
		$fp = fsockopen("www.twitter.com", 80);
		$user = "twitter_username";
		$pass = "twitter_password";

		fputs($fp, "POST /statuses/update.xml HTTP/1.1\r\n");
		fputs($fp, "Host: www.twitter.com\r\n");
		fputs($fp, "Referer: None\r\n");
		fputs($fp, "Authorization: Basic ".
			base64_encode($user.":".$pass)."\r\n");
		fputs($fp, "Content-type: ".
			"application/x-www-form-urlencoded\r\n");
		fputs($fp, "Content-length: ". strlen($data) ."\r\n");
		fputs($fp, "Connection: close\r\n\r\n");
		fputs($fp, $data);

		while(!feof($fp))$str .= fgets($fp, 128);
		if(!strstr(" OK ",$str))
			echo "There was a problem posting your twitter update.";
		else echo "twitter update posted successfully!";
	}
?&gt;</pre>
<h3>SECURITY NOTE:</h3>
<p>Please notice that the code above sends the username and password hash <em>unencrypted</em> over a plaintext HTTP pipe. The password hash is thus vulnerable to rainbow table attacks.</p>
<p>A better solution uses HTTPS with <a title="cURL in PHP" href="http://us.php.net/curl" target="_blank">cURL</a>. This way, the username &amp; password hash info don&#8217;t have to be sent plaintext:</p>
<pre style="padding-left: 30px;">&lt;form action='twitter.php' method='post'&gt;
	&lt;input type='text' name='status' /&gt; &lt;input type='submit' value='tweet' /&gt;
&lt;/form&gt;
&lt;?php
	if($_POST['status']!="") {
		$url = "https://twitter.com/statuses/update.xml";
		$user = "twitter_username";
		$pass = "twitter_password";

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_HEADER, true);
		curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_POSTFIELDS,
			"status=".stripslashes($_POST['status']));

		ob_start();
		curl_exec($ch);
		$str = ob_get_contents();
		ob_end_clean();
		curl_close($ch);

		if($str=="" || strstr($str,"&lt;error&gt;"))
			echo "There was a problem posting your twitter update.";
		else echo "twitter update posted successfully!";
	}
?&gt;</pre>
<p>Since I&#8217;ve started using twitter I&#8217;ve found that it&#8217;s very useful for companies and organizations that want to get messages out to lots of people quickly. You can even get twitter updates by phone using SMS!</p>
<p>Happy tweeting!</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.tom-reitz.com%2F2009%2F06%2F16%2Ftwitter-from-php%2F&amp;linkname=Twitter%20from%20PHP"><img src="/wp-content/themes/organic-theme/img/share_save.gif" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.tom-reitz.com/2009/06/16/twitter-from-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

