Archive for the ‘Web Development’ Category

ga_shade – a white DIV breaking my site

I just went to our main company website, Medicology, and there was a large white semi-transparent block over the top of the entire screen. Since I use something like this for displaying AJAX content I panicked a bit and then dived into my JS and CSS files to see what was going on.

After finding nothing out of the ordinary I searched the entire set of source files for “alpha” hoping to to find a snippet of CSS that was causing my woes. Unfortunately it came back with nothing. I then decided to do the same with the source from one of the pages in Firefox and came back with a div at the bottom of the page with the ID “ga_shade”.

A quick Google led me to find that it is Google Analytics placing it there as part of the whole “content overlay” thing they do. Problem is that I wasn’t using content overlay and as such the menu bar for it wasn’t available and I couldn’t turn it off, let alone click on any links. Not happy. And suprised that Google can make slip-ups of this kind.

Sort yourselves out boys. Don’t just assume that because it works in IE6 it works in everything – try testing stuff in FF for us.

 

IE6 and PNG transparency woes. Still…

We have several sites we’ve been developing for a range of conferences we are running (Safeguarding and Q, G & E being two) and to help reduce the development time, our designer used a few PNGs so that we could use a standard layout template and then alter a CSS sheet to create a new site. This plan was working well until I finally found some time to do a bit of housekeeping and checked Google Analytics.

I was quite shocked to find that almost half of our users are still visiting us with the rediculous IE6, complete with it’s security flaws, lack of compatibility and other problems. The main problem in this instance is the lack of proper support for PNGs and in particular, alpha transparency. This was causing our nice design with the rounded corners to be displayed as big blocks of light grey all over the place.

Apart from the slight anoyance that the only reason these people are still on IE6 is because they are ignoring or not using Windows Update, and are therefore probably part of a Botnet, it means that IE’s awful legacy is still with us and is likely to be so for some years to come until these PCs finally die. We therefore STILL need to code all our new sites for IE with all the hacks and tweaks we’ve been using in the past.

In this case I found an off the shelf solution that worked quite well for us in the excellent SuperSleight that for us, allowed us to keep most our PNGs with the transparency enabled and just change a few of the core images. I never did look two hard at why all the PNGs weren’t fixed (we replaced the logo with a JPEG) but maybe your site will be fixed without a hitch.

 

“Last month” incorrect with PHP Date & strtotime functions

I use a lot of business style reporting in our companies website where displaying figures by month is important. However, at certain points in the year using the PHP date and strtotime functions to pull data from our DB works incorrectly. For example, today and tomorrow (30th & 31st March), using “last month” in the strtotime function will actually return the timestamp for 2nd & 3rd March, not the 27th & 28th February that the developer may have been expecting.

The reason for this? It’s because the Romans were superstitious of even numbers and thus we have a very disorganised calendar system that doesn’t always match up with the decimal and binary way we now work in.

If you do want to get the timestamp of a date that falls in the previous month, the below code should help:

$last = strtotime(date(‘Y-m-01′).’ -1 month’);

This will (at the moment) return the 1st February.

 

The 15% VAT Change: Software development lessons learned

With the suprise announcement that the government is going to reduce the VAT rate to 15%, there was much media coverage about how this may or may not help the economy, whether the high street will actually pass on the savings to consumers and as per usual, nothing much about how this affects the IT services that support the ever-increasing amount of small businesses that are moving online.

I’m sure I wasn’t alone in suffering a feeling of dread when I heard that the new rate is going to go into effect on the 1st December 2008, leaving us just 5 days to plan, implement & test any changes that need to be made. For the majotity of the businesses I run sites for, this was a minor thing since I tend to follow these simple rules:

  • Store the VAT charged with the payment record – don’t rely on coding to calculate it post-transaction
  • Store the VAT amount in a configuration file or database value – never hard code it

In these cases all I need to do is change the VAT amount on the morning of the 1st and everything will be fine. There is one company though that wasn’t so easy to change.

VAT & Services
Our primary client, Medicology, provides services in the form of training courses. People decide to book onto one of their courses, usually well in advance and they receive a 28 day invoice which is then paid. In this companies case, the tax point (the point at which the VAT is calculated and paid) is the point at which the course is run. This has major implications for them:

  • If a customer had booked onto a course in September, they would have been invoiced at 17.5%
  • However, if the course they are attending runs in January, they should have been invoiced at 15%
  • This would therefore require the original invoice to be credit noted at n17.5% and then a new invoice generated at 15%

This was potentially devastating for the company as they may have hundreds of invoices, some paid, some unpaid which need credit noting, re-invoicing and in some cases, refunds issued and new payments taken.

Luckily, due to the short notice, the HMRC has said they will waive this process and let the existing invoices stand. This will save the company hundreds of man-hours and thus thousands of pounds. From a customer point of view, they are not loosing out by paying the extra VAT since the majority of courses are paid for by the NHS Trusts who can claim back the VAT, whatever the amount.

I will be keeping a close eye on the press for what will happen in 13 months time when the rate will increase and my guess is, the government won’t be so kind about letting people off paying additional VAT. In this case, their courses running in 2010 may have to be re-issued so as soon as the new VAT rate is announced, I will be making changes ot the system to calculate the VAT amount based on the tax point as opposed to the current amount.

I just hope they decide the amount sooner rather than later

 

IE7 File Uploads don’t work – nothing happens

So, Microsoft have a released a new Internet Explorer and as per usual, we’re going to have to re-code all our sites for it. So, what’s this versions problem: file uploads.

I have a site that uploads a file in the usual HTML form way and then the PHP on the server checks if it’s a JPEG and uses copy() to move it to a desired folder. I tested it in FireFox and everything was working fine and since it’s so simple a script I left it at that. Then a client with IE7 called me because he was trying to upload a jpeg and nothing was happening. I fired up IE and gave it a go and when I clicked on the Submit button it just sat there, doing sod all.

A bit of digging and I found that the problem was because I’d included the following in the code for the Submit Button:

onClick=”this.disabled = true;”

This was being executed by IE and then it appears it just sits there and forgots you clicked Submit. You can give IE a good kicking and get it working again by changing it to:

onClick=”this.disabled = true; document.form.submit();”

I hate IE and M$

 

1and1 Dedicated server and PEAR

I’ve recently had to do a complete reinstall on our 1and1 Root Linux server which is easy enough in itself as it’s just a case of going into the Control Panel and hitting Server Re-Image alogn with your choice of operating system. I went for Fedora Core 6 and within an hour everything was up and running. Within another hour I had my files uploaded (4Gb including images), MySQL databases loaded and my custom httpd.conf loaded. After that I thought the only hard bit would be the extras I had installed but with a quick “yum install ImageMagick” and “yum install webmin” then using Webmin to set up the firewall properly, everything was good to go.

With the sites back up I just needed to do a few quick checks to see if various bits of the website were working. Everything was fine except for PHP sending out emails. I knew that newer versions of Fedora were supposed to use QMail and not Sendmail so I headed off into the system to see if I could track down the problem. After a bit of messing around it seemed the mail server was fine (even with the MTA set as QMail) but nothing would be sent out using PHP. By saving the MTA to Sendmail I could get emails out using the mail() function but not using PEAR’s Mail package. Enabling ErrorReporting on one of my scripts threw up the errors:

Warning: main(Mail.php): failed to open stream: No such file or directory in
/var/www/html/email.php on line 15

Fatal error: main(): Failed opening required ‘Mail.php’
(include_path=’.:/usr/local/share/php/pear’) in
/var/www/html/email.php on line 15

I then loaded up a phpinfo() script and noticed the following line:

–without-pear

For some reason they’ve decided to be overly cautious and install PHP without PEAR support so even though PEAR was showing as being installed and commands such as “pear install Mime” were working, something with PHP was a bit pear shaped (get it, arf arf!). It turns out that the solution is simply to open up /etc/php.ini and add the following line:

include_path=”.;/usr/share/pear”

Everything seems to be working now, a bit more testing might be in order though

 

PHP Translation: English to French

I’m just about to get started on a new project for a client and it’s going to be my first multi-lingual site. The site is Visit Pyrenees and it’s a holiday home and hotel advertising site based around three villages in the Eastern Pyrenees. As far as a brand new project goes, it shouldn’t be too complicated and the only technically difficult bit will be the French and English versions.

As the site is aimed at UK tourists wanting to visit the area, the default language will be English, but I also want a French version for a number of reasons:

  • It adds to the USP of the site by attracting visitors speaking both languages
  • There will be a slight SEO benefit from the dual language site
  • Some of the advertisers will only speak French and will be editing their advert which will then need translating

There are basically two section to the site: the adverts for the various places of accommodation and the static information pages. Since I don’t speak much French, I’d like the static areas of the site to be editable by a none technical but French speaking person (such as the site owner). It therefore makes sense that the easiest way of implementing the site using a wysiwyg editor that lets the user select their language and then enter the text and any other HTML entities into the editor before saving it. The PHP script will then take the text and then create a version in the other language.

When I find something suitable that works, I’ll post a link or a zip file for download if I have to modify it.

 

PHPlist: Advantages & disadvantages

Our main company, Medicology, derives the majority of its business from mailings to NHS staff. We currently use PHPlist to manage the sending of our emails, with the contacts being broken down into one of several lists based on the source of the contact and which day they are contacted on.

This works fine at the moment but we want to be able to have greater control over the mailings and who receives what, when. There are a few things that we’d like to do, some of which are easily done and some of which can’t be done.

Possible with PHPlist

  • Add extra contact information such as location, job title and hospital
  • Automatically schedule emails for later sending
  • Send emails through an external SMTP server requiring authentication
  • Rich Text Editor (RTE) built in for creation of good quality emails

These are all essential features for us and handled very well in PHPlist. There are some features that either don’t perform the way we want or are missing and which are also essential for us.

Missing from PHPlist

  • Skip sending to contacts if they’ve received an email within a certain time frame
  • Dynamically create lists based on selectable criteria (slighty supported in PHPlist but not to the extent we need)
  • Modify the content of the emails based on contact preferences or other database stored information

Although I’d like to continue using PHPlist, the business benefits of the missing features are too great to ignore so I think I’m going to have to make a decision and either start modifying our PHPlist installation or create my own mailing programme.

I’m going to have a look through the code for PHPlist, make a decision and then I’ll post back later.

 

Simply Add AdSense to your Wordpress blog

Here’s a quick guide to Google AdSense to your Wordpress blog. I’ve tried to keep it as simple as possible for the novice user but I’ve made a few assumptions:

  • You have a Wordpress blog and know how to upload files to your webspace
  • You’ve already signed up for a Google AdSense account (if not, click on the banner on the right)
  • You won’t moan at me if you accidentally break something!

Ok, First go to your AdSense account and log in. Click on “AdSense Setup” and then “AdSense for Content”. Follow the guide to create your AdSense code (if you need help at any point, look at Google’s support pages). I’m going to show you how to add the adverts in the “Sidebar” (the strip on the right) so I recommend choosing either a Skyscraper or Vertical Banner.

Once you have you code leave it open in your browser and go to where you’re keeping your wordpress files on you PC. You’ll need to browse through the folders to:

wp-content\themes\default\

Open the file you’ll find in there called sidebar.php in a text editor (such as Notepad). All you have to do is paste your code in there. I recommend putting it at the bottom (just before the </div>) to put the ads below your other links.

Now just save the file and upload it to your webspace. Go have a look at your site and you should now have your ads on there!

If you can’t get it working, leave a comment and I’ll try and help when I get the chance.

 

AJAX Online Document Store

Here is the code for the simple AJAX online collaboration document store I wrote a while back.

You should just be able to upload it to the document root, edit the header.php and footer.php files to your design and everything should work. If not, try editing it to get it working on your server.