Taking care of HTML comments in PHP

A little problem came up with some user submitted content on a platform I’m working with.

A form allows users to submit content with tinyMCE. If the content is pasted from MS Word, the source is then littered with HTML conditional comments that can have a detrimental effect on the the page that returns it.

After discovering what was going on, I thought that the best time to capture the offending content is when the text is submitted. Using a regular expression, I can capture the HTML conditionals as well as remove any unnecessary comments:

function clear_html_comments($html)
    return preg_replace('/&lt;!--(.|\s)*?--&gt;/', '', $html);

That’s it. Just pass in the content from tinyMCE and it should prevent any content being returned that is in HTML comments.

Fixed width, yet I’m still on the borders.

The Google sidebar happened to allow me to drop into the following blog:
Armed and Dangerous » Blog Archive » Site theme no longer completely sucks.

Gripping title, isn’t it?

The crux of it is that all designers are morons because it’s sometimes preferable to use fixed width styles.


I think there’s a time and a place for fixed width styles. In fact, I’m proud of the paper-layout style that the Centaur Systems website has.

On the flip-side, the Imhotep theme that bloggingIT is using had to be modified to make the margins smaller. Although, the values were percentages, and not fixed-width as it first appeared.

Nine-times out of ten, wasted space is pretty awful – but I personally use a 1600 x 1200 resolution, and I couldn’t bear to use my browser in full screen mode. Why call them windows if you’re just going to full the screen?

There’s one thing that Eric Raymond get wrong. That is that the user should have the right to alter anything in a design. If that’s so, why bother with design at all? Good design has all the elements that are needed for 99.9% of users – and the designer then has the right to allow / restrict as much changes as necessary. If that means fixing the width of a web page

– so be it.

Controversial Issue

I’ve downloaded the new FireFox Beta (1.5) to give a spin. The good news is that the developer toolbar and Open in IE plugins still work. As far as I’m concerned – these are the two critical plugins for me.

I decided to tackle an issue that has been nagging me for some time now. The disappearing scrollbar!

If you have a high resolution monitor, you may have noticed that this site shifts along to the left or right. The problem is that the pages are centre aligned. So is the Centaur Systems website.

Naturally, there is a fix (or at least a workaround) that works quite well. html By putting the following code into your css:

html { height: 100%; margin-bottom: 1px; }

If forces the page height to be 1 pixel greater than the window size. Even better is that Internet Explorer’s greyed-out scrollbar remains that – grey.

I wondered if this was an oversight on the Mozilla team’s part. No – apparently only IE has a constant scrollbar. That’s consistent with the Microsoft UI guidelines. The W3C guidelines are somewhat vague on the matter.

From a design viewpoint, it’s a pain in the rear, yet there are many passionate posts on the Mozilla Forums for and against.

I don’t suppose that this is an issue that will be effectively answered in the future. But hey, at least I have a centred website now.

The Joys of HTA

I’ve been developing a number of HTA tools lately.

Certainly a pretty nifty way to create script-based applications without the need for whole development suites. In fact, seeing as Notepad++ is my tool of choice – it’s a no-brainer.

A lot of custom scripts should never need to be written once I’ve finished a suite of Active Directory tools. The first one is the most useful, a tool to create users automatically on a domain. Now I’m working on a tool to enumerate all users in a domain and empower the user to either enable or disable an account, as well as reset the password and change obvious settings like requiring the user to change passwords, alter group membership and bits like that.

The only downer is that there’s no real way to compile the app once it’s complete. Well, none that I know of.