follow me on Twitter

    Latest Gallery Images

    Gothic Fairy (Again)
    El Médano from the top of Montaña Roja
    Joyce in The Subway Sara prepares for application!
    PHP Women
    LinuxChix
    Blogs By Women
    Creative Commons Licence

    Archive for the ‘PHP’ Category

    Boarduino vivarium temperature monitor

    Thursday, October 29th, 2009

    I like snakes. This weekend I will be collecting my new snake, he’s a baby Royal Python. I have been worried about the temperature in the vivarium I will be housing him so I built an ethernet enabled monitoring device to do a science!

    Vivarium Temperature Monitor

    (more…)

    PHP NW and the Decorator Pattern

    Wednesday, September 9th, 2009

    The first Tuesday of the month is the PHP NW meeting in Manchester. This month I was the warm act for PHP celebrity Derick Rethans. Due to traffic issues Lornajane and Derick were late so I gave my talk first. It was one in a series of talks on Design Patterns being given by various members of the group. Mine was on the Decorator Pattern. The slides from the talk are available for download.

    Derick’s very interesting talk was on Test Driven Development in a PHP environment. Derick is the author of XDebug and an expert in PHP QA. It covered the concepts behind Test Driven Development and why it both improves code quality and makes code development more efficient over the long term. It covered the use of PHPUnit, XDebug and CruiseControl. As a fan of quality reusable code this is a great way to develop.

    Next month is the PHP NW 2009 Conference held in Manchester. The you can see Derick and some of other great European PHP conference speakers doing their thing. Its fantastic value for money and you get a year’s subscription to PHP Architect Magazine too. Bargain!

    Talk: Introduction to WordPress Plugins

    Wednesday, August 5th, 2009

    Last night I gave my first pukka pecha kucha talk at the monthly PHPNW. The talk is a lightning talk with 20 slides with 20 seconds a slide. I.e. 6 minutes 40 seconds in total. Since I hadn’t even decided I was going to talk until last Friday and I had no talk prepared I was still preparing the slides on the train to Manchester where the meetings are held.

    I didn’t have a VGA adapter for my MacBook and had to borrow one to connect it to the project. I think I need to buy one. I bought a DVI adapter when I bought the machine but not the VGA one as I thought who needs them with modern monitors. But of course most projectors have VGA only connections so such adapters are a necessary component of the presenter’s toolkit.

    The talk seemed to go well and was appreciated by the audience and plugins seemed to be my topic of conversation for the rest of the evening. There was some interest in my WordPress Coppermine Widget plugin and techniques I had used in the Javascript for it. I think this will become the subject of another blog post.

    I went a little awry with my mental arithmetic and ran over by about a minute. When Lornajane gave her talk she had the slides change automatically after 20 seconds so you know when the talking time for a slide is up. I will steal this idea!

    My slides are available as a PDF download.

    WordPress Automatic Update Bug – Follow Up

    Thursday, July 16th, 2009

    The bug I raised on WordPress yesterday as documented in this blog post has been closed as a ‘duplicate’.

    Looking through the bugs about a month ago someone else raised a very similar bug report and proposed a very similar solution. That bug report was closed with ‘wontfix’. The basic comment is that (a) they know about it; (b) they think changing the behaviour will break shared hosting; (c) group write support is not supported in WordPress anyway.

    The comments in the bug do confirm something I spotted yesterday when looking at the latest release revision of wp-admin/includes/file.php which is that you can completely over-ride the write checking mechanism in WordPress 2.8 and above if you define the constant FS_METHOD to be ‘direct’. A bit hacky but useful. It means I can use decent permissions and still use auto-update. Time to upgrade to 2.8.1 I think.

    WordPress Automatic Update Bug

    Wednesday, July 15th, 2009

    LornaJane wrote an article on her blog about WordPress automatic update asking for FTP. As I’ve been having problems with the automatic update too and since I also don’t want to install FTP I changed permissions as she suggested. Unfortunately, even with ‘other’ (world) write permissions, I was still being asked for FTP details. After some discussion on IRC it turns out that not only do you need the right permissions but you need the files with the right owner i.e. the Apache process. This didn’t seem right. Why an earth do you need the right ownership if you can write anyway. Also if you have to have the files owned by the Apache process any scripting running on the server can access and change the files. Its a security risk. So I decided to dig deeper.

    Grepping the WordPress source for the text line ‘There was an error connecting to the server, Please verify the settings are correct.’ showed me the relevant code is in wp-admin/includes/file.php. The function that requests the FTP details is request_filesystem_credentials(). This function is called if get_filesystem_method() returns a method other than ‘direct’. It seemed that get_filesystem_method() was at fault. The relevant code snippet is below.

            $method = false;
            if( function_exists('getmyuid') && function_exists('fileowner') ){
                    $temp_file = wp_tempnam();
                    if ( getmyuid() == fileowner($temp_file) )
                            $method = 'direct';
                    unlink($temp_file);
            }

    Examining the function it seems that it tries to creates temporary file (typically in wp-content) and if successful compares the ownership of that file with the process. If equivalent it decides that it can use ‘direct’ mode. The problem is it uses getmyuid() which according to the documentation returns the owner of the file that called the function and not the owner of the process running the code. I.e. the owner of wp-admin/includes/file.php. It doesn’t matter who the owner of the apache process is. There is another function
    posix_getuid() which returns the process owner. So I have modified the get_filesystem_method() function as follows:

            $method = false;
            if( function_exists('posix_getuid') && function_exists('fileowner') ){
                    $temp_file = wp_tempnam();
                    if ( posix_getuid() == fileowner($temp_file) )
                            $method = 'direct';
                    unlink($temp_file);
            } else if( function_exists('getmyuid') && function_exists('fileowner') ){
                    $temp_file = wp_tempnam();
                    if ( getmyuid() == fileowner($temp_file) )
                            $method = 'direct';
                    unlink($temp_file);
            }

    I.e it checks to see if posix_getuid() is supported and if it is it uses that instead. This allows me to have my WordPress files owned by a different owner than the apache process. I have set the wp-content to a member of a group containing the apache process owner and made them group writeable. As long as apache can write the temp file WordPress can use automatic update. This is still some what insecure but better than having all the WordPress files either owner by the apache process or world writeable.

    Note that I am currently running WordPress 2.7.1. Looking at WordPress 2.8.1 the get_filesystem_method() function has changed but not significantly. I am raising a bug.

    Using PHP sessions from Objective C and Cocoa

    Saturday, June 6th, 2009

    A little while ago I wrote a post “Using PHP sessions from Java”. This is a companion post looking at the same issue but using Objective C and Apple’s Cocoa Framework which are used both in OS X and in iPhone OS.

    (more…)

    Coppermine WordPress Widget

    Sunday, March 29th, 2009

    I’ve not been well this weekend. Its the remnants of a fluey cold exacerbated by getting too cold in the wind and rain when using public transportation on Thursday and Friday. However every cloud has a silver lining and sitting in bed, in between snoozes, has given me the chance to get on and develop a WordPress plugin and widget that integrates with, and displays images from a Coppermine gallery.

    This is the first plugin and widget for WordPress I have developed and its been a bit of a learning exercise. Its no way completed but the basics are there and you can download the plug-in here. (Edit: The plug-in is now supported officially on the WordPress site. You can get the latest one from here). Currently the only known bug is that you add the widget to a sidebar before you have configured the default Coppermine database settings.

    Currently the widget just displays a fixed number of random images from the whole gallery. You can see it in action in the left side bar. Clicking an image takes you to that image’s album in the gallery. Imminent additions I will make are a configurable number of images and columns; selectable queries e.g. the latest additions to the gallery, random from an album or albums, and so on; and pop-ups on mouse-over showing a larger version of the image together with image title and description.

    Using PHP sessions from Java

    Thursday, March 19th, 2009

    This blog post is the first in a number of what I hope are useful coding related posts. I’ve been coding for many years in many languages on many platforms. I tend to solve issues using a combination of technologies so many of my posts will be based around combining technologies. Others will be basically describing gotchas that I have found during development and how I solved or worked around them. This post is about using PHP’s session handling from a Java client, i.e. not a browser.

    (more…)

    Popping my conference cherry (Part #2)

    Thursday, March 12th, 2009

    (cont…)

    Lunch really wasn’t bad at all. There was some carefully rationing on the part of the servers but I suppose it would be better to have too much at the end than to run out.

    Living with Frameworks

    I had wanted to see this talk on frameworks because of my common code background and love of frameworks in any development environment. Alas it seems that nearly everyone else wanted to see it too and because it was in the smaller of the two rooms it was over subscribed. So I took time out and nattered with other conference attendees and visited some of the exhibitors. I had a long play with the interactive table the Microsoft guys brought and perused the books on the O’Reily stand. I’ll catch the talk online.

    Dave comforts Ellie after the PHP Women's ElePHPant goes missingIt was also around now that we discovered that someone had stolen the PHP Women’s ElePHPant from the stand. The little blue ‘pants are rare anyway but this one was wearing a hand crocheted PHP Women’s top. We are all supposedly like minded individuals. It upsets me that someone would even consider the theft. Despite all announcements and appeals over twitter she never turned up.

    Flex and AIR for PHP programmers

    This talk by Adobe’s Mihai Corlan should have been interesting. Instead it was both controversial and boring. The idea of writing platform agnostic clients that would run both in a browser and stand-a-lone appealed so I wanted to see this talk. At first it was interesting covering FLEX, AIR and the open source tools you can use to develop apps. But then he decided to show what the technologies were capable of with a demonstration of "Desktop Keeley" (Who ever she is), an application developed for the Sun Newspaper’s web site.

    To say the Sun is not the most politically correct publication is an understatement. The application seemed to comprise of a scantily clad young woman in heels who comes on and presents a pop-up displaying some tit-bit of news from the Sun’s website. I feel this is entirely inappropriate for a professional conference. At best its immature and schoolboy-ish and at worst its misogynistic. I wasn’t the only one who felt this. A straw poll found that many, regardless of gender, were uncomfortable with it. Mihai Corlan’s comment in reply to this post by Jaime Hemmett suggests he just doesn’t get it. Surely he could have found an example which wasn’t degrading. It doesn’t matter why he used the application, he shouldn’t have used it.

    So now I was annoyed. Then his talk finished with some ‘extreme programming’. Watching someone typing is not the most exciting content for a talk. If I wanted to do that I could watch the guy who sits opposite me in the office. Anyway I was tired now and just wanted the talk to finish so I snoozed.

    Security-Centered Design – exploring the impact of human behavior

    Chris Shiflett gave a great talk to finish off the conference. He spoke about how, in order to be more secure, we need to understand how people think. Informative and amusing it appealed very much to the amateur psychologist in me. He covered change blindness and ambient signifiers. I loved the Derren Brown videos. It made me think a lot and was useful not just for web developers but developers in general.

    Then the conference was wrapped up and we all headed back to the Brook Green Hotel for more socialising, a buffet, and finally goodbyes. Kat and I returned to the Hilton Euston for another night as on the Saturday we were off to Bristol and Techadventure but that’s another post.

    Conclusion

    Would I go again? Yes! It was enjoyable and informative and great getting together with like minded people. Can’t wait for the next one.

    Popping my conference cherry (Part #1)

    Friday, March 6th, 2009

    Friday 27 February was PHP UK Conference 2009. I’m doing more and more PHP and other web oriented coding as a change from my day to day work which is debugging low level linux code. A conference seemed the best way to find out more about the language and technologies so, with some encouragement from friends, I decided to go. I used some Hilton Honors points to get a couple of nights at the Hilton Euston in London and drove down there on the Thursday.

    Usually I catch the train to London but as I was heading to Bristol from London on the Saturday I drove. Also normally when I drive I leave the car in outer London and catch the tube but a combination of lack of time and Barnet Council making all street parking short term meters or residents only I found it was easier to drive all the way in and leave the car in some free over night parking by the hotel. This worked well the first night because I entered the area after the end of congestion charging.

    The Social

    The PHP WomenThursday night was the social at The Brook Green Hotel on Shepherd’s Bush Road near to Olympia, which is where the conference was held. After a quick check in I changed and caught the tube to the Hotel. At the hotel I met up with my roomie for the two days, Kat, Lornajane, Derick and Sara. I also met a load of new people and put faces to the PHP Women I knew from online. I also drank rather a lot of vodka!

    Sara poses for the cameraThe social was organised by PHP London as a special one of their usual nights held at the hotel. There were two talks made during the evening. Derick made the first one on using DBUS with PHP. It was interesting . By the time of Sara’s talk I was both tired and quite drunk so I’m afraid I wasn’t paying attention. Although I did get an awesome photo of her.

    A round midnight Kat and I started to wend our way back to the hotel. Once we got there Kat had a few transfers to apply to t-shirts for the “Booth Babes”. Then we set the alarm for 6.30 am and went to sleep.

    The Conference

    The morning started far too early with the alarm going off at 6.30 am but after waking up I was quite excited as this was my first ever conference of this kind. I’ve attended shows and expos before and even given talks in front of lots of people but never attended a ‘proper’ conference. Since I had to find parking for the car it seemed easiest to drive across town and leave it in the horendously expensive Olympia car park. Like Thursday night I was driving against the traffic and so it was a pain free trip.

    Chatting between talksKat and I arrived at the Conference Centre around 8.30 am. We registered, grabbed tea and coffee and helped set up the PHP Women’s stand. The key note was due to start at 9.30 but due to registration issues it didn’t start until 9.45. This meant we could natter longer between ourselves.

    The future’s so bright, I gotta wear shades

    Aral Balkan gave the key note speech and what a speech to be introduced to conferences with. Aral is a flash developer. Quite trendy he is a sociable guy and we talked both at the social and at the after conference party. His talk was not just relevant to PHP developers or even Web 2.0 developers but all developers of any software that has an end user. And he’s absolutely right. What is the point of having the most perfectly architected piece of software which follows more computer science patterns that you can shake a stick at if you completely miss the boat, which in most cases is the market. Sometimes you do just have to code and refactor later. He talked about commodity hardware and commodity software, great new tools and technologies, and was totally inspiring. An excellent way to start the day.

    What’s new in PHP 5.3

    The talk on the new features of the PHP language by Scott MacVicar was, in some respects, the complete opposite of Aral’s talk. It was totally technically and just described each of the new features in PHP 5.3, just as it said on the tin. For someone still learning this was extremely useful.

    Of lambda functions, closures and traits

    The final talk of the morning I attended was another technical one which explained some of the upcoming facilities in PHP 5.4. It described how to define lambda functions and closured (quick throw away functions useful as callbacks and so on). And the upcoming traits mechanism that introduces a level of multiple inheritance to PHP classes whilst avoiding the diamond pattern issue and duplicating Java’s interface mechanism.

    Then it was lunch.

    (cont)