<?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>Richard Dutton &#187; PHP</title>
	<atom:link href="http://www.dutton.me.uk/category/software-development/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dutton.me.uk</link>
	<description>Software Engineering, Photography, Travel, Stuff...</description>
	<lastBuildDate>Sat, 13 Feb 2010 08:45:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Personal Route Logging with MobileMe&#8217;s Find My iPhone</title>
		<link>http://www.dutton.me.uk/2009/09/27/personal-route-logging-with-mobilemes-find-my-iphone/</link>
		<comments>http://www.dutton.me.uk/2009/09/27/personal-route-logging-with-mobilemes-find-my-iphone/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 15:16:13 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[find my iphone]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[google maps api]]></category>
		<category><![CDATA[mobileme]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=276</guid>
		<description><![CDATA[Although I&#8217;m struggling to achieve a happy co-existence between Google&#8217;s Calendars and Contacts and my MobileMe subscription (still fighting dupes and funny syncs with the wrong numbers being associated with the wrong contacts etc&#8230; but that&#8217;s for another blog post!), one part of MobileMe I was keen to do something with was their &#8220;Locate My [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com/mobileme/whats-new/"><img class="alignright" title="Find My iPhone" src="http://images.apple.com/mobileme/whats-new/images/find_iphone_map_20090909.png" alt="" width="299" height="318" /></a>Although I&#8217;m struggling to achieve a happy co-existence between Google&#8217;s Calendars and Contacts and my MobileMe subscription (still fighting dupes and funny syncs with the wrong numbers being associated with the wrong contacts etc&#8230; but that&#8217;s for another blog post!), one part of MobileMe I was keen to do something with was their &#8220;Locate My iPhone&#8221; feature. Regular apps aren&#8217;t allowed to run in the background on the iPhone, making any form of auto-updating tracking application all a bit &#8220;manual&#8221;  (e.g. Google Latitude on the iPhone), Apple have provided the ability to get the location of your iPhone automatically, but as it&#8217;s <a href="http://www.apple.com/mobileme/whats-new/" target="_blank">officially</a> being touted as a feature to use when you&#8217;ve lost your iPhone it&#8217;s tucked away within the &#8220;Account Settings&#8221; section of the MobileMe web page.</p>
<p>This was screaming out to be screen-scraped and <span id="more-276"></span>developer Tyler Hall has stepped up to the plate with <a href="http://clickontyler.com/blog/2009/06/sosumi-a-mobileme-scraper/" target="_blank">Sosumi &#8211; A MobileMe Scraper</a>. Using Sosumi is literally a case of including the class in your PHP, instantiating it with your MobileMe username and password and calling its locate method which returns an object containing the current latitude, longitude and result accuracy, it&#8217;s as simple as that!</p>
<p>At the moment I&#8217;ve got a cron job on my server hitting this every five minutes and logging to a database. If the data hasn&#8217;t changed since the last logged entry, a counter is incremented and timestamp_last is set. A very simple Google Map displays these locations as points on a map but I&#8217;ve got loads of ideas of stuff to play about with, such as:</p>
<ul>
<li>Plot the reported accuracy of each location as a circle on the map, more Google Maps fiddling.</li>
<li>Modify which points are mapped based on time and date ranges through the webpage, some PHP + AJAX experience.</li>
<li>Store locations of common places I visit, then for each point logged (taking into account the accuracy range) I can programatically work out where I am.  Could then auto-generate &#8220;Richard is at work&#8221;, &#8220;Richard is at home&#8221;, etc&#8230; reports for my blog/twitter/facebook etc&#8230; =).</li>
</ul>
<p>Bit sad I know, but it seemed too good for a total sync-monkey like myself and I&#8217;ll never pass up an opportunity, however contrived, for a PHP mash-up!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2009/09/27/personal-route-logging-with-mobilemes-find-my-iphone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating Excel .xls spreadsheets with PHP</title>
		<link>http://www.dutton.me.uk/2009/03/02/creating-excel-xls-spreadsheets-with-php/</link>
		<comments>http://www.dutton.me.uk/2009/03/02/creating-excel-xls-spreadsheets-with-php/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 12:52:25 +0000</pubDate>
		<dc:creator>richard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Microsoft Excel]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[spreadsheet]]></category>
		<category><![CDATA[spreadsheet generation]]></category>
		<category><![CDATA[xls]]></category>

		<guid isPermaLink="false">http://www.dutton.me.uk/?p=131</guid>
		<description><![CDATA[A web-based statistics system I&#8217;m developing for a client needs the facility to dynamically generate Excel spreadsheets. The system runs on a Linux platform with a typical Apache, MySQL and PHP install and is hosted on a virtual server at a commercial hosting company so access to anything Microsoft or COM-like wasn&#8217;t an option and [...]]]></description>
			<content:encoded><![CDATA[<p>A web-based statistics system I&#8217;m developing for a client needs the facility to dynamically generate Excel spreadsheets. The system runs on a Linux platform with a typical Apache, MySQL and PHP install and is hosted on a virtual server at a commercial hosting company so access to anything Microsoft or COM-like wasn&#8217;t an option and I only had a basic PHP install available. Most web searches come up with solutions that rely on PEAR (such as the Spreadsheet_Excel_Writer module) but my hosts&#8217; PHP didn&#8217;t support PEAR and they wouldn&#8217;t let me install it.</p>
<p>Finally I came across Johann Hanne&#8217;s port of the <a href="http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm" target="_blank">Perl Spreadsheet::WriteExcel module</a> on <a href="http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/" target="_blank">his website</a> and it&#8217;s working brilliantly without any additional dependencies! Although his documentation is a little thin on the ground, he does provide some example scripts to get you going and as it&#8217;s a direct port, you can still refer to the original Perl documentation. In particular the reference pages on cell number format strings <a href="http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.25/doc/number_formats1.html" target="_blank">here</a> and <a href="http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.25/doc/number_formats2.html" target="_blank">here</a> were most useful when tweaking the output.</p>
<p>Creating a simple spreadsheet in PHP is as simple as importing the writeexcel classes and setting up a new workbook and worksheet:</p>
<pre name="code" class="php">
require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";

$fname = tempnam("/tmp", "simple.xls");
$workbook = &#038;new writeexcel_workbook($fname);
$worksheet = &#038;$workbook->addworksheet();
</pre>
<p>&#8230;then use the write($row, $column, $token) function to put values into cells:</p>
<pre name="code" class="php">
# Write some text
$worksheet->write(0, 0,  "Hi Excel!");
# Write some numbers
$worksheet->write(1, 0,  3);
</pre>
<p>&#8230;and tidy up and return it, in this example through the browser, but you could always copy the file from the /tmp folder to somewhere more permanent and do what you want with it:</p>
<pre name="code" class="php">
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"example.xls\"");
header("Content-Disposition: inline; filename=\"example.xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
</pre>
<p>&#8230;and there you go, automatically generated Excel spreadsheets through PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dutton.me.uk/2009/03/02/creating-excel-xls-spreadsheets-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
