Fix bug in validate_ip function

Fix bug in validate_ip function: it wouldn't work for more than one subnets because `$ip = ip2long($ip);` line was executed on each iteration giving you `false` on the second one
Fix CodeGenerator to rely on more random source than `microtime()` - 40 chars limitation added as a BC because sha1 is limited to 40 chars