<?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"
	>

<channel>
	<title>Richard Johnson</title>
	<atom:link href="http://www.rjohnson.id.au/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rjohnson.id.au/wordpress</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Mon, 29 Nov 2010 17:13:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Converting relative URLs to absolute ones.</title>
		<link>http://www.rjohnson.id.au/wordpress/2010/11/30/converting-relative-urls-to-absolute-ones/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2010/11/30/converting-relative-urls-to-absolute-ones/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 17:12:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/?p=77</guid>
		<description><![CDATA[On a number of occasions I have found that I need to convert all URLs in a webpage from relative ones to absolute ones.  This is usually done when you are displaying a page sourced from one domain from a different domain.
Note that this doesn’t really provide full emulation or proxying of a site, you [...]]]></description>
			<content:encoded><![CDATA[<p>On a number of occasions I have found that I need to convert all URLs in a webpage from relative ones to absolute ones.  This is usually done when you are displaying a page sourced from one domain from a different domain.</p>
<p>Note that this doesn’t really provide full emulation or proxying of a site, you need to take into account cookies, etc. to do that correctly.</p>
<p>Here is how I most recently cracked it (in C# .NET).  This isn’t fool proof; however it should work with most HTML:</p>
<div><textarea name="code" class="php:nogutter:nocontrols" style="width: 98%; font-family: consolas, courier new, monospace; font-size: 11px;" rows="10">public static string RelativeToAbsoluteURLs(string input, string uriPrefix, string path)
{
	string[] attributesToPrefix = {"href", "src", "action"};

	foreach (string attributeToPrefix in attributesToPrefix) {

		string regex = "<([^>]*?)" + attributeToPrefix + "=([\"'])(.*?)([\"'])([^>]*?)>";

		Regex reg = new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
		MatchCollection matches = reg.Matches(input);
		foreach (Match match in matches)
		{
			string add = match.Groups[3].Value;
			if (add.Length > 1)
			{
				if (add.IndexOf("//") >= 0 || add.IndexOf(":") >= 0)
				{
					// we are already absolute at the protocol level, nothing to do with this match
				}
				else if (add.Substring(0, 1) == "/")
				{
					// we are starting with a /, just throw the uri prefix in there
					string src = match.Groups[0].Value;
					string dest = "<" + match.Groups[1].Value + attributeToPrefix + "=" + match.Groups[2].Value + uriPrefix + match.Groups[3].Value + match.Groups[4].Value + match.Groups[5].Value + ">";

					input = input.Replace(src, dest);
				}
				else
				{
					// normal, relative url!
					string src = match.Groups[0].Value;
					string dest = "<" + match.Groups[1].Value + attributeToPrefix + "=" + match.Groups[2].Value + uriPrefix + path + match.Groups[3].Value + match.Groups[4].Value + match.Groups[5].Value + ">";

					input = input.Replace(src, dest);
				}
			}
		}
	}
	return input;
}

</textarea></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2010/11/30/converting-relative-urls-to-absolute-ones/feed/</wfw:commentRss>
		</item>
		<item>
		<title>GAPP CMS</title>
		<link>http://www.rjohnson.id.au/wordpress/2010/06/26/gapp-cms/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2010/06/26/gapp-cms/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 09:34:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/?p=73</guid>
		<description><![CDATA[
Okay, so I’ve written a CMS.
Not a huge deal I know, but there are a couple of things about this CMS that make it a bit different.  Check it out.
The reasoning behind creating it was I had recently moved to London and was looking for work.  I thought it might be a good way to [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Okay, so I’ve written a CMS.</p>
<p>Not a huge deal I know, but there are a couple of things about this CMS that make it a bit different.  <a href="http://gappcms.appspot.com" target="_blank">Check it out</a>.</p>
<p>The reasoning behind creating it was I had recently moved to London and was looking for work.  I thought it might be a good way to up-skill a little and have something to show a little bit of Java experience when it comes to web.</p>
<p>I&#8217;ve also kinda wanted to do some work with the Google Application Engine since it was released, and I figured that this was a good opportunity.</p>
<p>Turns out I got a job doing .NET!  Come to think about it, I’ve actually got more Java here than PHP… hmmm.  Just to clarify, I have done more PHP than anything else, but I do like to have experience across a range of platforms.</p>
<p>So, I decided to finish it off and publish it.  It’s based on the Google App Engine, which gives it a number of advantages (with a couple of drawbacks).  Working with a No-SQL database was an interesting experience, but given how difficult some of the simple things can be (aggregates anyone?) I think there would need to be some strong reasoning behind the decision to use them.</p>
<p>Anyway, check out the website, have a play, give me feedback.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2010/06/26/gapp-cms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>java-libpst &#038; pst2gmail</title>
		<link>http://www.rjohnson.id.au/wordpress/2010/01/26/java-libpst-pst2gmail/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2010/01/26/java-libpst-pst2gmail/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 08:28:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/?p=64</guid>
		<description><![CDATA[I like Gmail.
I like the huge storage, the reliability (I know they’ve had the occasional issue, but it’s nothing compared to some other services), the interface with the vim-like shortcuts and I simply love the searching capabilities.
When Google finally enabled IMAP support for Gmail I decided it might be worthwhile to move my work email [...]]]></description>
			<content:encoded><![CDATA[<p>I like Gmail.</p>
<p>I like the huge storage, the reliability (I know they’ve had the occasional issue, but it’s nothing compared to some other services), the interface with the vim-like shortcuts and I simply love the searching capabilities.</p>
<p>When Google finally enabled IMAP support for Gmail I decided it might be worthwhile to move my work email over to it (people may recall my <a href="/wordpress/2006/11/26/rss-imap-server/">love for IMAP</a>).  This meant I could still use Outlook with IMAP and get all of the benefits such as being able to read calendar invitations, RTF formatted emails as well as the horrendous HTML generated by client with Outlook, but it also gave me the added features of Gmail.</p>
<p>Unfortunately I had about 4GB of email stored in my old Outlook PST.  I really wanted to migrate this over to Gmail as well to take advantage of those sweet searching features to help me navigate through the vast minefield which is my email archive.</p>
<p>So! I tried drag-dropping the emails from my PST file over to the Gmail IMAP store through Outlook, and started the migration.  My Outlook almost instantly hung while each email was uploaded to Gmail at what seemed a glacial pace.  Indeed, I left it for a weekend and managed to get a couple of gig up, but my outlook had completely crashed by the time I walked in on Monday.</p>
<p>So, I thought to myself &#8220;there has to be a better way&#8221;, and started searching for a migration tool.  Unfortunately I couldn&#8217;t find one.  No probs I thought, I&#8217;ll just write my own&#8230; only there wasn&#8217;t much in the way of libraries that could read PST files.</p>
<p>First I tried <a href="http://www.five-ten-sg.com/libpst/" target="_blank">libpst</a>, which is a cute little C library.  I hadn&#8217;t really done any development in straight C before, so I decided I&#8217;d try to make a little ncurses app to read my PST files to test out the library.  I proceeded with moderate levels of success.  Unfortunately I ran into a few issues, the first being my deep-seated and intense hatred for C as a language.  The second and slightly more fatal one was that the library didn&#8217;t work particularly well for me; it would crash when reading any emails under the Inbox and it would simply hang when trying to read my larger 4GB PST file.</p>
<p>I then came across <a href="http://sourceforge.net/projects/libpff/" target="_blank">libpff</a>.  This is another C library that was built from libpst. By this time however, I had had a gutful of programming in C.  I also suspected it may have some of the scalability issues present in the original libpst.  It was also a little difficult for me to work out how exactly to use the library as C isn&#8217;t one of my strong points and there isn&#8217;t much in the way of usage / API documentation.</p>
<p>So, I did the only reasonable thing that a self-respecting geek would do: started to write my own library in Java.  Thankfully, Joachim Metz of Hoffmann Investigations who was responsible for the vast majority of the work in libpff also studiously documented the file format as he went and it looked like there was more than enough there to make a start.</p>
<p><strong>The library (java-libpst):</strong></p>
<p>Okay, so I&#8217;ll admit that I was biting off a bit more than I could effectively chew, let alone swallow.  It turns out that PST Files are all little-endian, and Java is, of course, big endian.  Oh, did I mention that PST files are also encrypted by default using a substitution cipher? But&#8230; not completely encrypted&#8230; just enough of them to make it difficult, oh! all the RTF items are compressed as well.</p>
<p>There is also the matter of the reasonably important unknown bits of the file format which were not yet documented.  For example, there is this B-Tree in the file format that allows you to quickly locate an item within the file.  Which is great! only, there didn&#8217;t seem to be a way to find out what child items may be attached to a parent item (like a folder).  Oh! you can find out who your parent in easy enough, the id of the parent is sitting right there&#8230; but the child items&#8230; no sir!  This was a bit of a problem you see because as with most tree structured files, you start from the top and work your way down.</p>
<p>I managed to work around this by reading the entire contents of the B-Tree and creating my own inverted map of parent to child objects.  It turns out that this wasn&#8217;t really that bad of a solution and only takes a few seconds to read through them all and create the map even on huge PST files.</p>
<p>Frustratingly, soon after I had managed to get this part of the library to work, a new section of the file format was documented which describes &#8220;related&#8221; nodes, which contains, among other things, a list of all the child items.  Sigh.</p>
<p>I also had a few difficulties understanding some of the finer points of the documentation, like when data tables fall across different blocks with external lookup tables.  There was also a fun point when I started to hit &#8220;named items&#8221;, which are basically keys that change meaning from file to file.  The identifier that denotes a recipient&#8217;s email address may, for example, be a different identifier in a different PST file!  Once again, this is only in some instances (yay for consistency!).</p>
<p>After much head scratching, reading, and staring at massive amounts of Hex encoded data, I managed to get the library working well enough to navigate the PST structure and extract items including emails, attachments, contacts, calendar items, etc. relatively quickly without crashing too horribly.</p>
<p>The result is available on Google code here:  <a href="http://code.google.com/p/java-libpst/" target="_blank">http://code.google.com/p/java-libpst/</a></p>
<p>But my work was not yet done.</p>
<p><strong>The migration app (pst2gmail):</strong></p>
<p>Of course, the real goal was to create an application that could migrate all of your email from your legacy PST file to Gmail.</p>
<p>With the library working, this part was a lot more straightforward, and a mostly working alpha can be downloaded from here: <a href="http://code.google.com/p/pst2gmail/" target="_blank">http://code.google.com/p/pst2gmail/</a></p>
<p>I did have grand plans of having the system migrate your contacts and calendar items as well, which wouldn&#8217;t actually be that difficult to do, however my personal development focus has once again shifted and this functionality will probably remain disabled and unimplemented until people start to howl for it to be implemented.</p>
<p>Until then, please enjoy, the emails are uploaded through IMAP, flagged messages are passed through as starred items, folders are automatically created as tags, attachments and all that work, you can even resume your upload through the generated log files if you need to stop the process midway through!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2010/01/26/java-libpst-pst2gmail/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New PHP MSSQL Driver</title>
		<link>http://www.rjohnson.id.au/wordpress/2008/08/12/new-php-mssql-driver/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2008/08/12/new-php-mssql-driver/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 11:52:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/?p=57</guid>
		<description><![CDATA[Further to my previous post about FreeTDS for PHP on windows, I&#8217;ve just come across a new microsoft PHP 5 extension that apparently provides compatibility with the latest versions of MSSQL (including the 2008 pre-releases).
I&#8217;m yet to check it out, but it looks promising: http://www.microsoft.com/downloads/details.aspx?FamilyID=61bf87e0-d031-466b-b09a-6597c21a2e2a&#38;DisplayLang=en
]]></description>
			<content:encoded><![CDATA[<p>Further to my previous post about FreeTDS for PHP on windows, I&#8217;ve just come across a new microsoft PHP 5 extension that apparently provides compatibility with the latest versions of MSSQL (including the 2008 pre-releases).</p>
<p>I&#8217;m yet to check it out, but it looks promising: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=61bf87e0-d031-466b-b09a-6597c21a2e2a&amp;DisplayLang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=61bf87e0-d031-466b-b09a-6597c21a2e2a&amp;DisplayLang=en</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2008/08/12/new-php-mssql-driver/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hacked</title>
		<link>http://www.rjohnson.id.au/wordpress/2008/08/11/hacked/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2008/08/11/hacked/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 12:01:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/?p=60</guid>
		<description><![CDATA[Well, I guess I was one of many wordpress victims that have suffered from an unscrupulous blog spamming bot.
Unfortunately I didn’t keep backups of my posts.  It’s strange, you don’t really count these sorts of things as important and therefore it was overlooked with my normal backups.  Thankfully, I was saved by the Way Back [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I guess I was one of many wordpress victims that have suffered from an unscrupulous blog spamming bot.</p>
<p>Unfortunately I didn’t keep backups of my posts.  It’s strange, you don’t really count these sorts of things as important and therefore it was overlooked with my normal backups.  Thankfully, I was saved by the Way Back Machine, which had a copy of my Jasper post which was destroyed.</p>
<p>Google is currently in the process of removing me off their blacklist.  Apparently it can take a bit of time.</p>
<p>A few reasons for the lack of posts and generally not being around.  Firstly I went through Europe, and caught up with Nick, Haley, Havard and Alex, which was awesome.  Secondly, I have been completely swamped at work and it is a little difficult to be geeky at home when you have had a rather full-on day.</p>
<p>Hopefully this need to update my blog will prompt a bit of a resurgence in posting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2008/08/11/hacked/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bullet-Proof Jasper Reports and PHP</title>
		<link>http://www.rjohnson.id.au/wordpress/2007/10/27/bullet-proof-jasper-reports-and-php/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2007/10/27/bullet-proof-jasper-reports-and-php/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 04:41:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/2007/10/27/bullet-proof-jasper-reports-and-php/</guid>
		<description><![CDATA[Okay, so I got a fair bit of traffic about my last entry where I attempted to explain how I managed to get PHP to talk to Jasper through use of the PHP/Java Bridge instead of having to resort to running external programs through exec, which is undesirable for a number of reasons (including parameter [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I got a fair bit of traffic about my <a href="/wordpress/2007/02/04/jasper-reports-and-php/" target="_blank">last entry</a> where I attempted to explain how I managed to get PHP to talk to Jasper through use of the <a href="http://php-java-bridge.sourceforge.net/" target="_blank">PHP/Java Bridge</a> instead of having to resort to running external programs through exec, which is undesirable for a number of reasons (including parameter passing and performance).</p>
<p>I’ve done a bit more work with Jasper using PHP and I can say that a few simple steps can make life infinitely easier.</p>
<p>First of all: <strong>Setting up and using the PHP/Java Bridge</strong>.</p>
<p>You don’t need to use the extension, there is a library written in pure PHP that you can use as a fall-back.  When populating a report with Jasper, you don’t use that many Java calls so the reduced performance should not impact on your application too much.  If you are calling a fair bit of Java from PHP, I would attempt to get the extension working as the performance is increased dramatically.</p>
<p>Here is a nice little function from the PHP/Java Bridge examples that detects if the extension is loaded and falls back to the native bridge if it isn’t available:</p>
<p><textarea name="code" class="php:nogutter:nocontrols" style="width: 98%; font-family: consolas, courier new, monospace; font-size: 11px;" rows="10">/**
 * see if the java extension was loaded.
 */
function checkJavaExtension()
{
    if(!extension_loaded('java'))
    {
        $sapi_type = php_sapi_name();
        $port = (isset($_SERVER['SERVER_PORT']) && (($_SERVER['SERVER_PORT'])>1024)) ? $_SERVER['SERVER_PORT'] : '8080';
        if ($sapi_type == "cgi" || $sapi_type == "cgi-fcgi" || $sapi_type == "cli") 
        {
            if(!(PHP_SHLIB_SUFFIX=="so" && @dl('java.so'))&&!(PHP_SHLIB_SUFFIX=="dll" && @dl('php_java.dll'))&&!(@include_once("java/Java.inc"))&&!(require_once("http://127.0.0.1:$port/java/Java.inc"))) 
            {
                return "java extension not installed.";
            }
        } 
        else
        {
            if(!(@include_once("java/Java.inc")))
            {
                require_once("http://127.0.0.1:$port/java/Java.inc");
            }
        }
    }
    if(!function_exists("java_get_server_name")) 
    {
        return "The loaded java extension is not the PHP/Java Bridge";
    }

    return true;
}
</textarea></p>
<p>It assumes that you have the PHP implementation in the &#8220;java&#8221; directory.  See the guide below for downloading this.</p>
<p>Second: <strong>Classpath is still screwy</strong>.</p>
<p>There is something about the bridge that I cannot figure out.  Regardless of environment variables, they way you use java_require, settings in php.ini or any other setting this still seems to stuff up.  There is one solution that I attempted to steer away from as I did not see it as ideal, however please believe me when I say that this single step will save you hours, if not days of frustration.</p>
<p><strong>Put all the Jasper libraries into your jre lib/ext directory</strong>.  Trust me.</p>
<p>I have got things tantalisingly close to working with other methods of making the libraries available to the bridge, and even succeeded on the odd occasion.  However this is the only reproducible guaranteed way to get rid of those class woes once and for all.</p>
<p>By using the PHP implementation of the bridge and putting your jars into the lib/ext directory, you should be able to get this to work on any platform.  I have got it working on Windows and Linux, but by removing any reliance on external settings this should work on pretty much any platform.</p>
<p>Third: <strong>Use the JDT compiler</strong>.</p>
<p>This little <a href="/wordpress/2007/02/04/jasper-reports-and-php/#comment-432" target="_blank">tid-bit of gold</a> was dropped on my blog by Lucian, one of the primary contributors to Jasper’s continued development (thank you).</p>
<p>If you have the jdt-compiler jar in your lib/ext folder as well, the problem of java having a different running directory to that of PHP becomes a non-issue.  Most importantly however, this removes the need to set environment variables!</p>
<p>With my previous approach to getting jasper working, I resorted to writing a wrapper class primarily because you can not set the “jasper.reports.compile.temp” and “jasper.reports.compile.class.path” through the bridge (it doesn’t work).  Setting these gave the javac compiler the information it needed to compile the report, without them it failed horribly.  The JDT compiler does all this stuff in memory, it is hot.</p>
<p>Lastly, the easiest way to get all the libraries required for running Jasper is to <a href="http://sourceforge.net/project/showfiles.php?group_id=64348" target="_blank">download and install iReport</a> then grab them from the lib directory.  Please pay attention to the licensing!  Some of these libraries like the mysql connector are under the GPL so  distributing it with a non-GPL product will be frowned upon.</p>
<p><strong>Putting it all together.</strong></p>
<p>After this work, compiling and running a report from PHP becomes a simple exercise in translating from the Java examples to PHP:</p>
<p><textarea name="code" class="php:nogutter:nocontrols" style="width: 98%; font-family: consolas, courier new, monospace; font-size: 11px;" rows="10">$compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
$report = $compileManager->compileReport(realpath("test.jrxml"));

$fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
$params = new Java("java.util.HashMap");
$emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource");
$jasperPrint = $fillManager->fillReport($report, $params, $emptyDataSource);

$exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");

$outputPath = realpath(".")."/"."output.pdf";
$exportManager->exportReportToPdfFile($jasperPrint, $outputPath);
</textarea></p>
<p>Note that you still need to use complete class names, otherwise you will get Class Not Found problems.</p>
<p>Okay, <strong>a quick guide to running Jasper from PHP</strong>:</p>
<ol>
<li>Setup the environment as per normal with PHP and Java (I use WAMP on Windows);</li>
<li>Download the latest iReport software and install it on your workstation;</li>
<li>Grab all of the files from “C:\Program Files\JasperSoft\iReport-2.0.2\lib” (version number will change) and copy them into your java’s lib/ext directory;</li>
<li>Download the latest version of the <a href="http://sourceforge.net/project/showfiles.php?group_id=117793" target="_blank">PHP/Java Bridge</a> with source and unzip it;</li>
<li>Unzip the src.zip file (should be included in the download) and copy the contents of the “java” directory to your PHP app.</li>
<li>If you want to use the stand-alone Java Server (easiest), grab the JavaBridge.jar from the ext directory (in the download) and copy it into the “java” directory you just placed in your PHP app.For production, you will probably want to use the Java extension and configure it to come up with your web server.  There are a few configuration options here (including J2EE back-ends and the like), and the PHP/Java Bridge website explains how to get working with them.</li>
<li>Start the Java backend (java –jar JavaBridge.jar).  This will usually bring up a dialog asking what port to use, however you have command-line options as well if you are running headless.</li>
<li>Try it out!!</li>
</ol>
<p>Here is an example report: <a href="/download/jasper/test.jrxml" target="_blank">test.jrxml</a><br />
And some example PHP code to compile, run it and send it to your browser: <a href="/download/jasper/index.php.txt" target="_blank">index.php.txt</a></p>
<p>Other things to note:</p>
<ul>
<li>Please cache the compiled version of your reports; otherwise you will be waiting for the report to compile every time you run one.  I have some example code for doing this in my ReportGenerator class I used in my previous post.</li>
</ul>
<p>Hopefully people will find this approach a little more straight-forward.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2007/10/27/bullet-proof-jasper-reports-and-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reading Apple Mail Attachments</title>
		<link>http://www.rjohnson.id.au/wordpress/2007/10/24/reading-apple-mail-attachments/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2007/10/24/reading-apple-mail-attachments/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 13:11:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/2007/10/24/reading-apple-mail-attachments/</guid>
		<description><![CDATA[Okay, so Jess is finishing up her Masters of Project Management with many of the assignments having gone to and from people for review via email.
One problem however: Enter Apple Mail, exit attachments.
Instead of the nicely revised document, you get a nice, anonymous, useless attachment.  It&#8217;s frustrating to know that this &#8220;noname&#8221; attachment contains [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so Jess is finishing up her Masters of Project Management with many of the assignments having gone to and from people for review via email.</p>
<p>One problem however: Enter Apple Mail, exit attachments.</p>
<p>Instead of the nicely revised document, you get a nice, anonymous, useless attachment.  It&#8217;s frustrating to know that this &#8220;noname&#8221; attachment contains all of the precious work, just out of reach.</p>
<p>So, on opening this attachment (in vim, of course) I found that it was basically a base-64 encoded version of the document and some other stuff, with normalish MIME headers.  Sort of like an attachment in an attachment.  So by grabbing the most important (biggest) bit of encoded text, stripping out the new lines and un-encoding it, I could successfully get the document back and everyone was happy.</p>
<p>Having needed to use this script on a few occasions, I decided that it might be useful for some others, so here you go:<textarea name="code" class="php:nogutter:nocontrols" style="width: 98%; font-family: consolas, courier new, monospace; font-size: 11px;" rows="10"><?php
if (!empty($_FILES["test"]["tmp_name"]))
{
	$data = file_get_contents($_FILES["test"]["tmp_name"]);

	$bits = explode("\n\n", $data);

	// filename is the last line of the 3rd bit
	$lines = explode("\n", $bits[2]);
	$filename = trim($lines[sizeof($lines)-1]);
	$filename = str_replace("filename=", "", $filename);

	header('Content-Disposition: attachment; filename="'.$filename.'"');
	header("Content-Type: application/octet-stream");
	header("Expires: 0");

	$data = $bits[3];
	$data = str_replace("\n", "", $data);
	echo base64_decode($data);
	die();
}
?>
<html>
	<head>
		<title>Apple Mail Attachment Decoder</title>
	</head>
	<body>
		Select the document and hit submit:<br />
		<form action="" enctype="multipart/form-data" method="post">
			<input type="file" name="test" /><br />
			<input type="submit" name="submit" value="Submit" />
		</form>
	</body>
</html>
</textarea></p>
<p>Of course I can&#8217;t be held responsible for the script not working, destroying priceless documents, killing your cat or anything else.</p>
<p>I have also put the script up on the server for quick reference:  <a href="http://www.rjohnson.id.au/attachment_decoder/" title="Apple Mail Attachment Decoder" target="_blank">http://www.rjohnson.id.au/attachment_decoder/</a><br />
Hope this is useful to someone out there&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2007/10/24/reading-apple-mail-attachments/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New ABC News</title>
		<link>http://www.rjohnson.id.au/wordpress/2007/08/19/new-abc-news/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2007/08/19/new-abc-news/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 00:12:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/2007/08/19/new-abc-news/</guid>
		<description><![CDATA[I just noticed this the other day, the ABC (Australian Broadcasting Corporation to those people from the states) have re-worked the News section of their site.
The first and most important thing I noticed was that the News was actually there!   For example, I heard on the radio this morning that there was an [...]]]></description>
			<content:encoded><![CDATA[<p>I just noticed this the other day, the ABC (<em>Australian </em>Broadcasting Corporation to those people from the states) have re-worked the News section of their site.</p>
<p>The first and most important thing I noticed was that the News was actually there!   For example, I heard on the radio this morning that there was an incident involving our opposition leader and a strip club in New York while he was a little shin dig for the UN (wont someone think of the children??).   Apparently a statement had been released but there wasn&#8217;t any explanation about what the substance of that statement was, jump on to the website and there is the article, posted a whole 24min ago.</p>
<p>I also wanted to know what happened to that passenger jet from Turkey that was hijacked.   A quick click on World and then the fantastic tagging system at the top of the page and I found the article.   Once in the article I could see all of the related stories so I could back-track through each of the updates.</p>
<p>There are also a bunch of Web2.0 (if I can use that term) features that include a personal list of tags for new stories that are applicable to you, and a personal stash of Articles (like internal bookmarks).   Combine that with a lack of advertising, a smattering of new media and the tagging system for navigation and we have a winning site.  Of course this is all government funded so check it out and subscribe to the RSS feed, public interest will help ensure the future of this great service and the ABC in general.</p>
<p>News Home: <a href="http://abc.net.au/news/" target="_blank">http://abc.net.au/news/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2007/08/19/new-abc-news/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Safari For Windows</title>
		<link>http://www.rjohnson.id.au/wordpress/2007/06/13/safari-for-windows/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2007/06/13/safari-for-windows/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 12:21:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/2007/06/13/safari-for-windows/</guid>
		<description><![CDATA[Yay!! I didn&#8217;t believe it when I first heard it, but apple has released a public beta of the soon-to-be Windows version of Safari.
First impressions are really quite good, here are a few of the highlights:
Quartz font rendering.

It just looks sweet, using the same font rendering as available on OS X.  I love my [...]]]></description>
			<content:encoded><![CDATA[<p>Yay!! I didn&#8217;t believe it when I first heard it, but apple has released a public beta of the soon-to-be Windows version of Safari.</p>
<p>First impressions are really quite good, here are a few of the highlights:</p>
<p><strong>Quartz font rendering.</strong></p>
<ul></ul>
<p>It just looks sweet, using the same font rendering as available on OS X.  I love my fonts, and I love seeing them displayed without the hinting (that modifies the shape of the letters to better fit the pixels) combined with the secret sauce that manages to make things not too blury.</p>
<p><strong>Aqua widgets</strong></p>
<ul></ul>
<p>Rather than go through the rather lengthy process of porting the application to an alternate toolkit, Apple ported their toolkit to Windows, which is good &#8220;˜cause it means us Microsoft ppl can get a bit of a taste of the Mac world.</p>
<p><strong>Thin Borders</strong></p>
<ul></ul>
<p>I know it sounds lame, but one of the things I love about Macs is the way that everything is presented on the screen.  The application just sits there with no borders; you just use the resize option at the bottom-left of the window to do the needful.  Vista on the other hand looks terrible, with great chunky borders that attempt to show off how well the glass theme works.  As a result, the shadows don&#8217;t seem to make the windows float like they should, it&#8217;s a small thing I know, but it&#8217;s the small things that make a big difference.</p>
<p><strong>We can test!</strong></p>
<ul></ul>
<p>Being a fan of accessibility and cross-browser compatibility, I am really really happy that this is happening.  I can actually see how the site will look on a Mac!  That is complete with the same font rendering, DPI settings, etc.  It&#8217;s really handy.</p>
<p>The frustrating things:</p>
<p><strong>I can&#8217;t get it to work on my machine at work.</strong></p>
<ul></ul>
<p>I think I must have had some dodgy version of the &#8220;Lucida Grande&#8221; font that has caused Safari to start off without any text being displayed.  Kind of a downer.  I have attempted to replace these problematic fonts with the correct ones, but I have still had no success.  I hope Apple will be able to do something about this &#8220;˜cause I am keen to use it.</p>
<p><strong>My laptop touchpad scroll doesn&#8217;t work</strong></p>
<ul></ul>
<p>Which is rather annoying.  I assume it has something to do with the lack of integration with the underlying OS, both a good and a bad thing I guess.</p>
<p><strong>We will potentially have another browser that we need to support.</strong></p>
<ul></ul>
<p>Yeah, I know that I said it&#8217;s great to able to test on a new browser, but it will be a pain when we can no longer say &#8220;well, it&#8217;s not perfect on Safari, but that&#8217;s only 1.5% of the market so that&#8217;s acceptable&#8221;.  I do think that the browser share will increase considerably with this move to be something more significant, and that will mean another Javascript DOM to accommodate for and another set of CSS curiosities to consider.</p>
<p>Download the beta here:  <a href="http://www.apple.com/safari/" target="_blank">http://www.apple.com/safari/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2007/06/13/safari-for-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>It&#8217;s raining.</title>
		<link>http://www.rjohnson.id.au/wordpress/2007/06/06/it%e2%80%99s-raining/</link>
		<comments>http://www.rjohnson.id.au/wordpress/2007/06/06/it%e2%80%99s-raining/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 09:16:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<guid isPermaLink="false">http://www.rjohnson.id.au/wordpress/2007/06/06/it%e2%80%99s-raining/</guid>
		<description><![CDATA[This might not sound like a big deal, but Brisbane and a lot of South East Queensland is currently dry as a bone.  Actually, we are really quite screwed.
Everyone has been watching every drop that goes down the drain.  We have buckets in the shower so that we can still water our herbs [...]]]></description>
			<content:encoded><![CDATA[<p>This might not sound like a big deal, but Brisbane and a lot of South East Queensland is currently dry as a bone.  Actually, we are really quite screwed.</p>
<p>Everyone has been watching every drop that goes down the drain.  We have buckets in the shower so that we can still water our herbs and chilli plants.  The car has gone unwashed for months and months.  We are trying to run the dishwasher only once a week.  We have been encouraged to keep our water consumption down to 140L / day, sounds like a lot, but go a minute or two over the allocated 3 in the shower and it starts to become rather difficult.</p>
<p>So, water was a major election issue for Premier Beattie and it will be for the Federal government when it comes time for little Johnny to defend his position.  The Federal government has already stepped in, trying to get the Northern NSW government to setup pipes to take water from some of the better off areas to help support Brisbane.  There is also a national water grid going in that will take water from some of the other dams in the surrounding regions for Brisbane, and some desalination plants going up.</p>
<p>All sounds good eh?  Well, not really, I&#8217;m not overly convinced that it will be in here enough.  We only have about <a href="http://www.brisinst.org.au/resources/ravenscroft_peter_burdekin_line.html" target="_blank">15 months left of water</a> if we keep going at the current rate.  Our population is also increasing at about 1700 people a month, which will put further strain on our resources.</p>
<p>The rain is just divine, nothing nicer than listening to it while going to sleep and I just love it when it is cold (not really cold, Brisbane cold).  Unfortunately this particular fall is only enough to extend the 15 month deadline by 2 days.</p>
<p>Some more links about the situation:</p>
<ul>
<li><a href="http://www.seqwater.com.au/content/standard.asp?name=DamOperationsAndMaintenance">SEQ Brisbane Dam Levels</a></li>
<li><a href="http://www.brisbane.qld.gov.au/BCC:BASE::pc=PC_2095" target="_blank">Brisbane City Council drought information</a></li>
<li><a href="http://www.brisbane.qld.gov.au/BCC:BASE:1644439006:pc=PC_2162" target="_blank">Details on Level 5 restrictions</a>, Level 6 kick in as we approach September.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rjohnson.id.au/wordpress/2007/06/06/it%e2%80%99s-raining/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

