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 8de01a6184
commit a02e440048

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 >= ?";