kieranbarnes Independent PHP, WordPress & CubeCart Programmer

[Snippet] Clearing forms with Javascript

Posted on March 29, 2011

When creating forms on a website it is helpful to place descriptive text with some of the form fields to help the user understand what they should type in the box. I can never remember the Javascript to do it

  1. <input value="Username" onclick="this.value=''" type="text">
Tagged as: No Comments

Messing with time and date on Linux

Posted on March 9, 2011

Some Linux distros don't come with time synchronisation utilities, even though Windows has done it since Windows 2000.

Here's how I solved the issue on a basic CentOS install.

Tagged as: , Continue reading

Installing nginx & PHP-FPM securely on CentOS

Posted on March 9, 2011

I won't go into the reasons why you should install nginx, if you're here, you've already decided.
Here's how I installed nginx and PHP-FPM on CentOS.

“sh: -t: command not found” with PHP cron/command line

Posted on March 8, 2011

Are you getting "sh: -t: command not found" when running a PHP from cron or command line? This usually occurs when your accessing PHP's mail() function with no (compatible) mail server installed on the server.

Here's my CentOS based solution.

Tagged as: Continue reading

Passing Every ~ \.php$ request to to PHP

Posted on March 8, 2011

It is common with Nginx to pass every URI ending in .php to the PHP parser, if using a default PHP build this might lead to security issues. Nginx is a reverse proxy and as such does not have a concept of file unless you specifically tell it to. So if your configuration looks like this.

Tagged as: , , Continue reading

Windows Storage Server 2008 RC Default Password

Posted on March 7, 2011

It is wSS2008!. Thats all.

Filed under: Windows 1 Comment

[Snippet] Shopp Carousels & Slideshows

Posted on March 7, 2011

Carousels & Slideshows in Shopp can be a little tricky, the documentation isn't 100%.

  1. <?php
  2. shopp('catalog', 'onsale-products', 'load=true');
  3. shopp('category','carousel', 'duration=0&fit=all&imageheight=200&imagewidth=320');
  4. shopp('catalog','category','reset=true');
  5. ?>

or

  1. <?php
  2. shopp('catalog', 'featured-products', 'load=true');
  3. shopp('category','carousel', 'duration=0&fit=all&imageheight=200&imagewidth=320');
  4. shopp('catalog','category','reset=true');
  5. ?>
Filed under: PHP, WordPress 7 Comments

[Snippet] Formatting an IMEI Number in PHP

Posted on March 4, 2011

Formatting an IMEI number in PHP is reasonably simple. The IMEI (14 decimal digits plus a check digit) or IMEISV (16 digits) includes information on the origin, model, and serial number of the device.

The format of the IMEI is AA-BBBBBB-CCCCCC-D, although it may not always be displayed this way. The IMEISV drops the Luhn check digit in favour of an additional two digits for the Software Version Number (SVN), making the format AA-BBBBBB-CCCCCC-EE

 

[Snippet] Simplified UK/US Date Conversion

Posted on March 4, 2011

One of my major annoyances in PHP & MySQL world is the different formats when working with dates.

US format: mm-dd-yy, UK format: dd-mm-yy and MySQL's date,datetime, timestamp columns yy-mm-dd. How do you cope with them all? I've been working on a rich UI recently which includes the jQuery date picker, by default thats in US format. UK users expect a date in UK format.

Tagged as: , , Continue reading
Page 9 of 34« First...7891011...2030...Last »