Skip to content


Silverstripe 2.4 Image Gallery Tutorial

I have had a few issues installing image gallery modules on Silverstripe 2.4. I’m new to using silverstripe so this is a beginners tutorial, the aim is to install a basic image gallery which fits the following criteria:

  • Allow CMS users to upload photos
  • Add custom fields to be associated with each image (such as title, caption etc.)
  • Display the images using a javascript image gallery of my choice

Another goal of this exercise was to better understand silverstripe – so the solution is simple, but effective and suitable for our needs.

What you will need:

Continued…

Posted in SilverStripe.

vnStat hack to measure data usage in a given billing cycle

I’m using vnStat to measure internet usage on my Ubuntu 10.04 laptop, coupled with the vnStat PHP frontend it works nicely. Only problem was the summaries of disk usage started at the beginning of the month (sensibly) and we get billed on the 23rd, which is when our month ticks over and we get a new data cap.

Not wanting to waste any data – to get a summary of the data use starting and ending on some random day of the month here is some simple code to go in index.php->write_summary():

Continued…

Posted in Tips of the Week.

Silverstripe Captcha

Starting out on some silverstripe projects there will likely be a few bits and pieces finding their way to the blog. SilverStripe is a product I have always wanted to work with, besides being a great example of open source success in New Zealand I’m attracted to the MVC architecture.

I’ve had a few teething issues, due to deployment issues and module compatability. I have successfully installed one module so far, recaptcha – which relies on the Spam Protection module. Here are the steps:

Continued…

Posted in PHP.

Rolling out an API for your cakePHP app Part 3: Handling Errors

The last posts in this series covered the a basic architecture of an API in cakePHP, the limitations of that basic architecture and a possible solution using an API component and some external API classes. The last part is the handling of API specific errors. The goals for the error handling system:

  • Return specific error codes for API errors
  • Control over header response codes sent
  • Ability to version the responses
  • Return an error in the format of the initial request

Continued…

Posted in PHP.

Rolling out an API for your cakePHP app Part ++1: The Solution

In the previous post I covered creating a basic API using cakePHP and what limitations are imposed if you want to extend the API over the course of several versions. This post is going to cover the architecture of a possible solution, I don’t claim its the best solution out there and feedback is welcomed.

A quick rundown of the goals for this solution:

  • Contain a single version of the API to one file/class to improve maintenance
  • Orderly folder structure for API view files
  • Simple and minimal routing rules
  • A more DRY solution minimising code (and file) replication
  • Easy deployment of new API versions
  • A system to return API specific errors
  • A place for non object specific API methods

Continued…

Posted in PHP.

Rolling out an API for your cakePHP app Part 1: The Problems

Recently I’ve put a lot of work into an API solution for a cakePHP app which addresses some of the architectural issues of creating an API in a cakePHP project. To start with I threw together a nice simple API as a proof of concept and to showcase the ease at which an API can be created quickly using the RequestHandler component. While that solution was fine and incredibly quick to whip up, there are some issues when it comes time to extend the API, the biggest of which is versioning.

This API solution is still a work in progress, there are several ideas I want to poach from other APIs, including a better authentication method possibly using oAuth. The API solution presented here is basically an architectural blueprint to avoid versioning problems, its not a complete API solution, but the skeleton for one. I’m just writing it up now while its fresh in my mind.
Continued…

Posted in PHP.

CakePHP session expire bug

UPDATE: This bug has been fixed.

This auth component / request handler component “bug” drops the 403 header code from an AJAX response when the session has timed out.

Note: this is based on cakePHP version 1.2.4.8284 and may have been fixed already I haven’t checked.
Continued…

Posted in PHP.

5 XSS Exploits You Should Know About

Following on from my HTTP Splitting post, this post rounds up 5 common cross site scripting (xss) attacks and how to prevent them.

Continued…

Posted in Web Development.

HTTP Cache Poisoning

I have started working through the WebGoat tutorials from OWASP (Open Web Application Security Project). The first tute covering HTTP splitting and cache poisoning was difficult enough for me to start with, and in fact I could write a whole post on installing WebGoat and WebScarab which was an achievement in itself.

Half the reason I found this first test challenging was the solution which I found to be confusingly worded. So I have gone through the process and here is the solution as I see it.

Continued…

Posted in Web Development.

Install Eclipse 3.3 On Ubuntu 8.04

This is just a quick post. I’ve had numerous problems with eclipse 3.2 PDT and Aptana on my Hardy Heron install; updates have broken functionality in the past and many problems with memory allocation. After installing the PyDev plugin the other night to try out Django my PDT and Aptana installs were destroyed and so I had to look at my Eclipse install again.

Continued…

Posted in Linux.