kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Yahoo GeoLocation API

Posted on July 13, 2007

Posted by Kieran

The Yahoo Maps API is the best API I've found for using on in internal site. Google won't let me access theirs from a non-public site.

imagegrabwindow() and imagegrabscreen()

Posted on July 13, 2007

Posted by Kieran

I stumbled over these two new functions in the PHP CVS today. They are only available in Windows as they use COM, but interesting non the least.

Nicer Pagination with ADOdb

Posted on July 7, 2007

Posted by Kieran

Or should that be Nicr? To follow in an annoying theme.

Olavo Alexandrino wrote a nice well rounded class for record set pagination in ADOdb. If you've ever used ADOdb's version, you will know it is not very good, to say the least.

Although Olavo did a fantastic job on the logic, the presentation left a little to be desired from my perspective.
I am providing my modifed version for download below, it provides a few logic updates and better presentation.

Idiot Proof Lightbox

Posted on July 7, 2007

Posted by Kieran

I've just made some modifications to my Gallery code which is part of i9000's small site CMS software.
It adds some client side logic to make sure the images Lightbox 2 creates fit the users screen perfectly. Previous to this some customers were complaining that the images they uploaded were too big for their visitor's screen.

This allows us to present the largest possible image to the user without scrolling around the page.

Tagged as: Continue reading

Poor mans currency conversion

Posted on July 3, 2007

Posted by Kieran

I recently completed a project that required currency conversion. I was limited what I could get out through the corporate firewall, so I came up with this.
It connects to Yahoo! with curl and reads a CSV string into memory.

Tagged as: Continue reading

Read a file into an array

Posted on July 3, 2007

Posted by Kieran

Here's something that puddled me for a while...

$filename = 'file.txt';
$file_handle = fopen($filename, 'r');
$data = '';
while(!feof($file_handle)){
$data .= fgets($file_handle, 1024);
}

Filed under: PHP No Comments

Converting XLS to CSV. Simple, eh? Well, sorta.

Posted on July 3, 2007

Posted by Kieran

I hate problems that can be solved really easily. (With a totally different set of tools). I needed to open Excel (XLS) files in PHP. Simple enough you think, IF you are using Windows.

IF I was using Windows, I would have a bunch of options open to me, I could use PHP's COM & .NET functions. Or PHP's ODBC functions. Or a selection of classess from PHP Classes.

file_exists(), is_file() & is_dir() with spaces?

Posted on June 26, 2007

Posted by Kieran

Why won't file_exists(), is_file(), is_dir() return true if the file or directory has a space in it?

I spent a few hours trying all kinds of ways to make this work. I finally settled on using $file->setName("safe"); from PEAR's HTTP_Upload class which makes the uploaded file "safe".

What's safe?

Filed under: PHP 1 Comment

Yellow text?

Posted on June 25, 2007

Posted by Kieran

I stumbled over a strange bug on two systems the other day where the imagettftext() function was always writing the text in yellow. No matter how I set the colour, imagecolorallocate($image, 0, 0, 0);, I would always get yellow. Why yellow?

Both systems are Ubuntu, I don't know if it is a mix up on the libraries from the package, or indeed PHP.

I had to recompile PHP ignoring the --with-ttf option which most docs suggest, and just use the --with-freetype-dir instead. Problem solved.

Tagged as: No Comments

“Mail option not available!”

Posted on June 25, 2007

Posted by Kieran

I spotted a strange PHP "feature" in the error_log() feature.

PHP checks for sendmail functionality once during ./configure for the mail() and error_log() functions.

Now, you can quite happily pass the sendmail path with the 'additional_parameters' flag to the mail() function, if you added mail support later but error_log() won't take that flag, so it fails with "Mail option not available!"

Rule: Install postfix/qmail/whatever BEFORE installing PHP if you want to use mail as an error_log() option.

Page 10 of 11« First...7891011