postgres barfs if you try to compare a string to an inet_addr

This commit is contained in:
Shish 2010-02-03 14:29:55 +00:00
parent 5e4f387983
commit 8b93b0644c

View File

@ -55,9 +55,22 @@ class LogDatabase extends SimpleExtension {
$args[] = $_GET["module"];
}
if(!empty($_GET["user"])) {
$wheres[] = "(username = ? OR address = ?)";
$args[] = $_GET["user"];
$args[] = $_GET["user"];
if($database->engine->name == "pgsql") {
if(preg_match("#\d+\.\d+\.\d+\.\d+(/\d+)?#", $_GET["user"])) {
$wheres[] = "(username = ? OR address << ?)";
$args[] = $_GET["user"];
$args[] = $_GET["user"];
}
else {
$wheres[] = "lower(username) = lower(?)";
$args[] = $_GET["user"];
}
}
else {
$wheres[] = "(username = ? OR address = ?)";
$args[] = $_GET["user"];
$args[] = $_GET["user"];
}
}
if(!empty($_GET["priority"])) {
$wheres[] = "priority >= ?";