Aug
20
2009
0

A new round of (book related) webservice wrappers

As I continue to try and catalog my book collection I keep hitting some walls. One of these is that ISBNdb.org catalogs mostly English editions of books and their corresponding ISBN’s. Seeing that my library is only 60-70% in english this leaves me with a lot of (dutch) editions that I cannot process using ISBNdb.org.

Luckily for me ISBNdb.org isn’t the only dealer on the block. WorldCat has their xISBN service that performs roughly the same as ISBNdb.org and they have a larger collection of ‘foreign’ editions in their database. If that doesn’t work I can use the ‘ThingISBN’ service from LibraryThing to retrieve a list of other editions for my selected book, get an english edition and then search using that ISBN. To use these in PHP i’ve created wrappers for both Services. I also migrated the documentation for ISBNDBService. Information for all of these services can be found at: http://webservices.linde002.nl/

Written by Robert van der Linde in: code | Tags: , ,
Jun
07
2009
4

Isbndb.com PHP wrapper

I was working on indexing my bookcollection this weekend and while looking at the stacks of books I had lying around I decided I wasn’t, under any circumstance, going to enter all the data from those books (ISBN/ISBN13, Author, Title, Summary, Publisher, etc) by hand.

So after googling around a bit I found ISBNDB.com which is, in essence, google for books. They crawl the internet searching for bookrelated data and then indexing it themselves. They really do store alot of information about books and cross index that so you can technically search for the categories an author fits in and then search other authors that fit in those same categories.

The best part is though, that they publish all this information through a free webservice. So I wrote a wrapper for this webservice that exposes all the methods and results used that can be used in PHP. If you are interested you can download it here. Documentation here.

Code after the jump:
(more…)

Written by Robert van der Linde in: code | Tags: , , ,
Jun
03
2009
0

Trees and tribulations

I was working on a small webapp a couple of months ago that would help my girlfriend manage her research data on horses. Amongst her wishes was that she would be able to view the selected horse’s family tree.

Now this is a specific wish that contains two generic problems.

  • Retrieving hierarchical data from flat dataset
  • Representing hierarchial / genealogical data in a browser

More info after the jump:
(more…)

Written by Robert van der Linde in: code, random thoughts | Tags: , , ,
May
25
2009
2

PHP and the IMAP idiosyncrasy

So recently i’ve started working as a senior software engineer on a PHP project that, amongst a load of other things, shows the content of an IMAP mailbox. As this is a generally easy technology to work with, you’d think it would be coded sooner than you can spell idiosyncrasy (which is still a long time, if you’re me).

Problems arose on the horizon when I started noticing that PHP’s imap functions would dump any E_NOTICE’s they stumbled upon directly to STDOUT, in this case, the table that I use to display the email messages. Another fun fact is that searching and sorting using nested and/or criteria doesn’t work in one go. My colleague created a workaround by searching for each nested criteria, storing the resulting msg_id’s and then performing some filtering magic on the results.This, however, is not wat you want on a high-traphic website, each query to a database, or an imap mailbox, is one too many.

So a solution must be found.

I was made painfully aware after a day of searching that alternative IMAP libraries/components/widgets/whatchamacallits are very rare and rarely of sufficient quality, this problem is increased because of the number libraries that are (PHP4-styled) OO wrappers around the existing imap_ functions.

The solution we arrived on was using PEAR’s Net_Imap module, it is a very usable module based on Net_Socket that uses PHP’s socket functions to access the imap server. It gives you a lot of control of the communications you do with the server while keeping it high-level enough so you don’t have to type each command yourself. Sorting and searching is made pretty easy and using UID instead of Message ID is supported as well.

It does however have a couple of downsides:

  • Under the hood, it uses the PEAR::isError mechanism to check for errors and handle appropriatly, we needed it to throw Exceptions to make sure it fit within the existing architecture.
  • It’s for PHP4
  • It doesn’t support ‘Peeking’, which makes highlighting messages as unread a distinct displeasure
  • It’s for PHP4
  • The response parser that handles the raw response from the server has a bug that adds [int][int]} to the start of the body content, we noticed this when we wanted to display attachments and the base64_decode kept failing
  • It’s for PHP4
  • UID instead of MID isn’t supported in all functions
  • It’s for PHP4

After a nice couple of days of rewriting I got it to work without E_STRICT or E_NOTICES but it really needs a good update. I’m working on it in my free time but it would be nice if a developer or two with some more spare time would look at it.

And for frak sakes… Port it to PHP5 already, it’s been a while sinds they released it. Oh and if you’re at it anyways, go poke the PHP dev’s to give their old C libaries and update as well, functions just outputting notices is quite a bad practice.

Written by Robert van der Linde in: code | Tags: ,
Dec
04
2008
0

PHP does what now?

So another session I visited yesterday was given by a hydrodynamical engineer (if I recall correctly) that used PHP to help him generate floodmodels. At first this didn’t sound like a task you would consider PHP to be good for but then he explained how he used it.

He has written a library that ‘glues’ all the seperate FORTRAN / C programs together using PHP so he can input raw data at the beginning and at the end it comes out the way he wants to without the need for him to input-output-input-outpunt-etc all the data into every seperate program. In between he uses MySQL and flat text files to save the intermediate data.

After all the processing is finished he then takes PHP with the GD extension and creates charts, animations and even small animated flooding movies from the data he has stored in the database.

The actual work, even though impressive, wasn’t that interesting to me, the interesting thing is that this engineer took PHP to do a job that it was good at, glueing components together. Utilising it strengths and acknowledging it’s weaknesses allowed the engineer to make his life easier. This should be a good lessen for all of you.

Written by Robert van der Linde in: random thoughts | Tags: ,
Nov
02
2008
0

Logging intrusions with PHP-IDS

If you’ve been tinkering with PHP-IDS and like to log your intrusions you’ve probably been looking at PHP-IDS logging features. I will show you today how you can log your intrusions to mysql using PHP-IDS’s built-in logging features.
(more…)

Written by Robert van der Linde in: code | Tags: , ,
Oct
30
2008
0

PHP 5, MySQL, Windows & Stored procedures

For people like me who develop on and for windows (at times) and who like to use MySQL’s stored procedures here’s a quick tip.
Some PHP versions give the following warning when you call stored procedures in PDO.

(more…)

Written by admin in: code | Tags: , , ,

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes