Tag: PHP

Clean Auth module usage in Kohana

February 24, 2010 » Geek

I’ve been learning the Kohana framework for a project at work, and I have to say I really like it. It has a lot of the things I liked about rails, and it stays out of my way, unlike CakePHP.

I thought I’d highlight my authentication solution that uses the built in Auth module and a base controller that I call Site_Controller. Keep in mind that all of my controllers derive from this one.

So, what’s it boil down to? Essentially you set up Auth and my base controller, then in your children controllers you can set $access_control to an array of methods you want protected. It works with key == method and value == access level. For values you can have “*” which means anyone logged in can use the method, or a string providing a specific role. Take a look at the controller then I’ll show you an example usage.


Here’s an example controller. In this case anyone can access login, anyone logged in can access index and only logged in admins can access adminsonly.


I haven’t done a ton of testing and it’s not the most robust solution, but I like it and it was easy to write.

Take Me Somewhere Rework

May 26, 2009 » Geek

Over the weekend I knocked out a new code base for TakeMeSomewhere.org. It’s not much, just a new look and feel as well as some back end work so that I can get fancy later.

Check It Out


January 1, 2009 » Geek

I’ve been working on the guts of a REST API for Amarok though PHP and DCOP. Thought I’d share my JSON format because I’m proud of it. Also because I’m bound to lose the format file sooner or later.

There are two basic things you can do with Amarok: take an action and ask for information. So that’s how I broke it down, action and info blocks in every request.

Rather than codify it in any formal way I’m just going to show examples.

Action – Toggle play/pause condition


Action – Play and set the equalizer


Info – Get playing track album name


Info – Get playing track album name, artist and title.


Both – Go to next track, get that track artist.
Note: I have decided that when both action and info are present they will alternate execution starting on action (i.e. action 0 then info 0 then action 1 and so on.) Thus we will probably want to create a NOP at some point.


Making DCOP work with Apache and PHP

January 1, 2009 » Geek

I’ve been working on a design for a web technology based media frame (think digital photo frame that you can program). I have my hardware ducks in a row (ripped apart a laptop, rewired some buttons and flipped the screen around) and now I’m working on software. I put together a reasonable frame work and then decided to add some integration with Amarok. That got hairy fast.

I found a PHP5 DCOP library but no explanation on how to get it to work. Google got me to the point where I knew it was an environment variable thing (the command line dcop has to have access to an X display since DCOP uses X’s ICE protocol to do it’s thing). Unfortunately trying to set the DISPLAY in the exec call doesn’t work, never found out why. Neither did the next 100 things I tried.

Skipping past all that anger and frustration that brought me to a solution, and here it is.

BEWARE this isn’t really a safe way to run a server. If you want to do this, be sure that it is on a machine that can’t harm the rest of your network or files. If you know a better way or some tips on locking things down, please share!

This is all done assuming a Debian machine base.

Make a full-fledged but restricted user. They must have an KDE login, and X must be running with them logged in. Let’s call our user notagoodidea for this example.
Make apache2 run as your user by editing /etc/apache2/envvars

Edit your run script to launch Apache with the DISPLAY variable set, so edit /etc/init.d/apache2 which will probably break on updates and makes me cringe.

Restart everything and test it out.

It isn’t pretty but it gets the job done.

Fun Holiday Message

December 15, 2008 » Geek

I made a cool holiday message today for my new job at REBEL INTERACTIVE, it’s a fridge with magnets that you can use to make and send messages. I think it’s rad.

Check it out: http://rebel-interactive.com/fridge/

Tags: , ,