mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12124)
This commit is contained in:
@@ -64,13 +64,13 @@ class AlertDB
|
||||
//Pretty-print rule to dissect easier
|
||||
$pretty = ['&&' => ' && ', '||' => ' || '];
|
||||
$rule = str_replace(array_keys($pretty), $pretty, $rule);
|
||||
$tmp = explode(" ", $rule);
|
||||
$tmp = explode(' ', $rule);
|
||||
$tables = [];
|
||||
foreach ($tmp as $opt) {
|
||||
if (strstr($opt, '%') && strstr($opt, '.')) {
|
||||
$tmpp = explode(".", $opt, 2);
|
||||
$tmpp[0] = str_replace("%", "", $tmpp[0]);
|
||||
$tables[] = mres(str_replace("(", "", $tmpp[0]));
|
||||
$tmpp = explode('.', $opt, 2);
|
||||
$tmpp[0] = str_replace('%', '', $tmpp[0]);
|
||||
$tables[] = mres(str_replace('(', '', $tmpp[0]));
|
||||
$rule = str_replace($opt, $tmpp[0] . '.' . $tmpp[1], $rule);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class AlertDB
|
||||
}
|
||||
$x = sizeof($tables) - 1;
|
||||
$i = 0;
|
||||
$join = "";
|
||||
$join = '';
|
||||
while ($i < $x) {
|
||||
if (isset($tables[$i + 1])) {
|
||||
$gtmp = ResolveGlues([$tables[$i + 1]], 'device_id');
|
||||
@@ -89,8 +89,8 @@ class AlertDB
|
||||
//Cannot resolve glue-chain. Rule is invalid.
|
||||
return false;
|
||||
}
|
||||
$last = "";
|
||||
$qry = "";
|
||||
$last = '';
|
||||
$qry = '';
|
||||
foreach ($gtmp as $glue) {
|
||||
if (empty($last)) {
|
||||
[$tmp,$last] = explode('.', $glue);
|
||||
@@ -104,11 +104,11 @@ class AlertDB
|
||||
$tables[] = $tmp;
|
||||
}
|
||||
}
|
||||
$join .= "( " . $qry . $tables[0] . ".device_id ) && ";
|
||||
$join .= '( ' . $qry . $tables[0] . '.device_id ) && ';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql = "SELECT * FROM " . implode(",", $tables) . " WHERE (" . $join . "" . str_replace("(", "", $tables[0]) . ".device_id = ?) && (" . str_replace(["%", "@", "!~", "~"], ["", ".*", "NOT REGEXP", "REGEXP"], $rule) . ")";
|
||||
$sql = 'SELECT * FROM ' . implode(',', $tables) . ' WHERE (' . $join . '' . str_replace('(', '', $tables[0]) . '.device_id = ?) && (' . str_replace(['%', '@', '!~', '~'], ['', '.*', 'NOT REGEXP', 'REGEXP'], $rule) . ')';
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
Reference in New Issue
Block a user