Archive for the 'PHP' Category

PHP Hackery

Wednesday, March 30th, 2005

I just found this article called Five Things You Didn’t Know You Could Do with PHP. An interesting read for any PHP hackers out there.

The only one I didn’t know about was #1- apparently this is legal:

< ?php
switch (TRUE) {
        case ($age < 16):
                echo 'You cannot drive.';
                break;
        case ($age < 18):
                echo 'You cannot vote.';
                break;
        case ($age < 21):
                echo 'You cannot drink.';
                break;
        case ($age > 65):
                echo 'You should be retired.';
                break;
        default:
                echo 'Work, work, work...';
                break;
?}
?>

Saves a bit of space/typing versus if/elseif/else, but other than that I’m not sure how useful it is.

Web server log analysis

Tuesday, March 15th, 2005

p>I’ve recently become quite annoyed by the current offerings I’ve found available in web sever log analysis:

  • Urchin, which [my webhost] uses, generally sucks- mostly because it does a really poor job of interpreting user agent strings.
  • AwStats is really difficult to install, at least if you don’t have root on a machine (as is my situation using a shared host).
  • Analog seems to suck, too- there’s a Mac port, but its quite ugly and not particularly easy to use.
  • I’m unaware of any other good options.

For what its worth, I actually kinda like AWStats, meaning that it pretty much worked, unlike my experience with Urchin. So, after playing around with all of these, here’s what I’ve decided I want in a web server logfile analysis package:

  • The ability to categorize requests based on specific criteria. I’m thinking about the user agent string, but I’m sure I’ll think of other things later that I want to be able to classify.
  • The ability to run ad-hoc queries against the data.
  • The ability to create graphs of ad-hoc queries.

Are there any open-source projects out there that qualify?

As it is, I’m working on my own implementation, which takes logfiles, parses them out and sticks them in a mysql db. In the process, the user agent string is analyzed to classify the agent into different categories. What do I mean by ‘categories’? Well what I really want is the ability to create a hierarcy like this:

  • Browser
    • MSIE
      • 5.5
      • 6.0
    • Webkit
      • Safari
    • Gecko
      • Firebird
        • 1.0
      • Camino
  • Aggregators
    • NetNewsWire
    • Shrook
  • Robots
    • Search Engines
      • Googlebot
    • Blog bots
      • Technibot

I offer these just to give you an idea of what kind of data I want to have. My first thought was to create a taxonomy like this. However, after thinking about this more, it may be more flexible to have a flat taxonomy (like tags), which can then be bundled into groups (del.icio.us bundles are definitely my inspiration on this one). For example, I could mark something with these tags

MSIE60, WinXP

or these

MSIE55, Win2k

Then I could create bundles like this:

IE->{MSIE60, MSIE55}
Windows->{Win2k, WinXP}

Ideally this system would have a rule-based system for classifying user agents, which would mean that adding a new agent would be as simple as adding a new rule for it (rather than writing or re-writing code for it). The goal of all of this is to have an extensible system for converting useragent strings into a format which is more easily processable with SQL statements.

I’m putting this out there, because I want some feedback on this. Any thoughts?

PHP Conference

Tuesday, March 8th, 2005

Zend has announced the first ever PHP Conference and Expo October 18-21, 2005.

Its already on my calendar.

Upgrade Party

Wednesday, February 16th, 2005

I just got back from the WordPress upgrade party at the Matt’s apartment. I had a great time with a bunch of other geeks (I think the geek-o-meter would have gone through the roof). Some notable people:

Technorati tag:

[Update]: Flickr pics.

Advanced PHP Programming

Sunday, February 13th, 2005

I just bought this book two days ago, here are my initial, non-judgemental thoughts….

I spent some time glancing through the book and was surprised by how un-Advanced it was. Then again, this shouldn’t surprise me, because PHP really has a rather low barrier to entry. That means there are quite a few people using PHP who have no formal training in CS or SE.

So, its not until page 475 that the book gets to the stuff I want to learn (PHP internals and writing PHP modules). Everything before that seems to be stuff I’m familar with from the Internet (that doesn’t mean it isn’t handy to have it all in book form).