TobyInkster.co.uk

Blog for July 2007

29/07/2007: demiblog 0.2.2 Released

I don’t normally announce point-releases of demiblog, but I felt that demiblog 0.2.2 was worth an announcement because:

It’s available in the subversion repository.

24/07/2007: Cryptography Challenge

Here’s a challenge. Decrypt…

aWt6eWZlaWEKfWJjeWFvcwppa3p5ZmVpYQpvaWJlCmZjZ2sKZmNnawp5
emtpbwpub2Z+awpleWlreApkZXxvZ2hveApvaWJlCmhrZG0KeXpraW8Ka
Wt6eWZlaWEKemt6awppa3p5ZmVpYQpmY2drCm9pYmUKa2Z6YmsKeW
NveHhrCm9pYmUKeXpraW8KZmNnawpvaWJlCmtmemJrCnxjaX5leApvaW
JlCnl6a2lvCmtmemJrCnl6a2lvCmlia3hmY28KZXlpa3gKZ2NhbwpnY2FvCm9
pYmUKZGV8b2dob3gKfmtkbWUKeXpraW8KZXlpa3gKZGV8b2dob3gKeX
praW8KfmtkbWUKZXlpa3gKaHhrfGUKc2tkYW9vCmNkbmNtZQpkZXxvZ2h
veAphY2ZlCnljb3h4awp+a2RtZQpvaWJlCnhlZ29lCnl+ZXoKaWJreGZjbwpl
eWlreAp5fmV6Cn9kY2xleGcKYWNmZQp5emtpbwppYmt4ZmNvCmZjZ2sK
a2Z6YmsKY2RuY21lCmdjYW8KY2RuY21lCmRlfG9naG94Cm1lZmwKeXpra
W8KaWJreGZjbwp4ZWdvZQpvaWJlCm5vZn5rCmNkbmNtZQp+a2RtZQp5f
mV6

Filed under: , .

20/07/2007: Parsing an HTML Table with PEAR’s XML_HTMLSax3

Here’s an example of how to parse an HTML table into an array using the PEAR module XML_HTMLSax3. It supports the <tr>, <td> and <th> elements and the rowspan and colspan attributes…

Filed under: , , , , , , .

19/07/2007: PHP Domain Class

On Usenet an often-asked question is how to programmatically determine the “domain” of a particular hostname. That is, excluding the components traditionally thought of as subdomains. As an example, groups.google.com and www.google.com both have a domain of google.com.

Invariably, one answer comes back stating that you just need to chop off everything from the front, leaving only the last two components. But then someone will chime in pointing out that groups.google.co.uk would be left as just co.uk that way, when what is really wanted is google.co.uk. And the eventual resolution of the argument will be “it just can’t be done”.

The problem is that there’s technically no difference between a domain and a subdomain: it’s simply a matter of convention. Fortunately, this issue is actually quite important to browser programmers, as it’s a key issue in cookie security: browsers must allow subdomains within a domain to share cookie data, but not allow cookies…

Filed under: , , , .

18/07/2007: PHP Linkifier

Here’s a nifty bit of code I wrote a while back (utilising a function from PHP SmartyPants) that takes a bunch of HTML, searches it for some word or phrase that you specify, and turns all occurances of it into a link, unless it’s already a link!…

Filed under: , .

17/07/2007: PHP vs Perl

Here’s a simple program which calculates, to eight decimal places, the value of the Golden Ratio φ implemented in both PHP and Perl, to demonstrate their similarities…

Filed under: , , , .

17/07/2007: Pretty Printing for PHP

Here’s a PHP function for reformatting the whitespace in PHP code…

Filed under: , .