r1271 + completely rewrote getIPRange() to avoid nested joins and be more MySQL-4...