Monthly Archives: April 2006

Restricting comments by IP

Is there a way in WordPress of being able to reject comments based on the IP address they came from? I had a brief look at the available plugins on the WordPress site but there doesn’t appear to be anything that does what I want.

Basically for about the last week or so I have been getting numerous bogus comments that I keep having to delete; all of the IP addresses are in the range 64.62.228.x. Using Arin’s WHOIS service it appears that all of the comments are originating within a range of IP addresses owned by an ISP called Hurricane Electric.

If there was some way of telling WordPress to automatically reject comments that fall within a certain IP range, I wouldn’t have a problem. I remember the discussion forums in the old ACS had such a feature. If you have any suggestions, let me know.

Fun with SQL

So I was minding my own business trying to manually insert an entry in the user table for the XMPP server that I am using when I got an error when I tried to set the creation date. Turns out that the creation date column in the user table is a 15 character string, 0 padded, that represents the number of milliseconds since January 1st, 1970. Why it is not a standard date type is beyond me but I digress.

Well if you ever need to do such a thing, and who doesn’t, here is the SQL query to do it:


select lpad(round(extract(epoch from now())*1000),15,0) as result from dual;

result
-------------------------
001144246603582

Note that this query is specific to Postgres. You may have to alter a few things to get it to work with whatever database you are using.

It is also worth noting that extracting the epoch from the date only returns the number of seconds since January 1, 1970. To get milliseconds we need to multiply by 1000.

Yet more randomness

I’m suffering from writers block so in the meantime here is a summary of some of the things I have come across in the last half an hour.

I have just discovered The Dilbert Blog by Scott Adams. Judging by the number of comments on some of the posts it’s rather popular. I already get my daily Dilbert cartoon via my Dashboard, now I can read the blog too. Maybe I should spend more time working and less time reading comics.

Philip Greenspun shares his thoughts on the real reason why Bill Gates is so interested in HIV and Malaria.

There’s a new competition in town, the Blooker Prize, for bloggers who have turned their online journal into books. Seems there’s a market for it. Blogs to books. Rags to riches. Who knows! The BBC has more about it here.