ASP vs PHP for long tasks

Yesterday, I got a good taste of what it’s like for a programming language on a web server to be handed a massive task to complete.

I was tasked with automating emails to subscribers of a vacancies alert service. The script as it stood was run manually once a day just before the end of work, and this script (written in PHP) would query the SQL server for details of subscribers and their preferences, and then compile individual emails and send them off. With hundreds of subscribers, this is quite a task. Nevertheless, the script took around 4 minutes at the most.

The preference was to move this script from the desktop to the server and automate it with a cron job. However, the database it interacts with is stored in MSSQL, and the way that the system is set up does not allow PHP access to MSSQL; only ASP.

I decided to re-write the whole script in ASP, upload it, test it, and then create a cron job to run it daily. With a few bumps and scrapes, I managed to port the script, but when I started to test it, the script timed out. OK, I thought: the automatic timeout is 90 seconds, which is not enough for this script. I increased it to four minutes (the length of time the PHP equivalent took), but it still timed out. Then I went to 6 minutes and the same happened. It was then that I realised that until timing out, the script would also bring down the whole site. This was unacceptable, and therefore we decided to revert to a desktop script, albeit automated with Scheduled Tasks in Windows.

This brings me neatly to the conclusion: ASP is much slower than PHP for running equivalent scripts, and its inefficiencies really showed up in this test and taught me a valuable lesson about using web scripts for very long tasks.

vCardMaker headaches

Yesterday, I wrote about my updates to vCardMaker. Today, I’m going to tell you about all the headaches that Internet Explorer 6 has caused me throughout this update, and about some of the problems I hadn’t spotted earlier on.

To date, I have had the following problems:

  • Opacity of objects
  • Fixed positioning
  • Positioning within a float
  • The background of fieldset legends
  • The overall size of text when using keywords for size
  • Width attributes
  • Disabled items in select boxes
  • select boxes showing through divs placed on top of them
  • Non-support of the onclick event on objects inside a select box

Phew!

Also, I hadn’t noticed that Internet Explorer 6 doesn’t support the onclick event on select boxes, so Internet Explorer users wouldn’t have been able to enter data in optional sections of the form that are hidden as default. Sorry! I’ll get that one fixed as soon as possible.

vCardMaker updates

To date, vCardMaker has been one of the most popular features on this site, as shown by my site’s statistics. However, conversely, it’s also been the least-updated tool on the site - the last time it was updated must have been close to a year ago.

The script was starting to creak behind-the-scenes and an attempt by me long ago to split off the interface and mate it with a third-party back-end proved unsuccessful. Everything got left to rot. It must have been the gradual drop in popularity that prompted me to resume work on it, coupled with the general lack of having things to do at the moment.

Up to now, I’ve done quite a bit of work on it, dedicating the best part of two days to back-end work. However, the interface hasn’t escaped lightly. Just some of the features that I suspect will be popular include collapsible sections, more meaningful field labels, large text boxes and improved support for Internet Explorer 6 (trust me, it hasn’t been easy!)

I have also AJAXified the whole interface with an overlay that displays the resulting vCard and any error messages. I debugged the PHP back-end and removed a lot of errors as well as porting the whole thing to PHP 5. Finally, I’ve added the ability to get your vCard emailed to you. I also tried (unsuccessfully) to bring back the download option - it’s been a problem ever since I introduced it - but I’m not giving up on it just yet.

There are still a few Internet Explorer quirks to sort out and the download option to fix, and then it’s onto the new vCardMaker Wizard (presents a simple interface with only the important fields) and the vCardMaker API to allow third-party scripts to access vCardMaker and make their own vCards. I’m also planning to start using cookies to allow users to store their favourite configuration of collapsed sections and options.

vCardMaker updates

Those of you who’ve been using vCardMaker may have noticed that there has been little in the way of updates for many months. This is mainly because I’m at university, and most of my time is taken up with working and partying :)

However, my Christmas holidays are fast approaching and I’m going to use the opportunity to apply lots of very significant updates to the service. Many of these updates are features that I’d like to see in the service myself, as well as requests from users and a few new things I’ve thought up.

You’ll have to wait to find out what many of them are, but don’t worry. The wait isn’t long!

Stopping the spambots

Recently, spambots have been trying to make my life difficult… Whether it’s creating new users and posting spam to forums that I manage or sending spam messages using my contact form, they’ll always find a way to annoy people. But no more!

I received quite a few spam messages last week from my contact form, and that got me thinking about how to stop them. I’ve read that the usual “type the letters you see” trick doesn’t work any more since lots of bots can now read the text inside the images. While I was thinking, I remembered an article about displaying random colours and asking the user to name them. Since spambots can’t (currently) decipher colours and name them, this is an excellent idea.

However, I couldn’t find a script that would do this job, so I went about writing my own. The result is the Random Colour Validator which chooses a random colour, displays it, and then validates the user’s response. I’m going to apply it to my contact form soon, so feel free to try it out for yourself. if you have any questions, there’s always the (now protected!) contact form.