From: Nicolas Boisselier Date: Thu, 30 Jun 2016 16:14:31 +0000 (+0100) Subject: str_match ignore case X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=fd938aeb6463b5bf7ff007aeda1443bd76aa8022;p=nb.git str_match ignore case --- diff --git a/etc/dbs/ui.php b/etc/dbs/ui.php index 8a6ed537..8da2799f 100644 --- a/etc/dbs/ui.php +++ b/etc/dbs/ui.php @@ -156,7 +156,7 @@ $CONF['_ui'] = array( }, ), - 'network_ips' => array('sql' => "SELECT id as idnetwork,code,network,iddc,count(*) as count FROM network n JOIN view_ip ON cidr_range(network,ip) WHERE n.network IS NOT NULL AND n.hidden=0 GROUP BY n.id" ), + 'network_ips' => array('sql' => "SELECT id as idnetwork,code,network,iddc,count(*) as count FROM network n JOIN view_ip ON cidr_range(network,ip) WHERE n.network IS NOT NULL AND n.hidden=0 AND EXISTS(SELECT 1 FROM fact WHERE value=ip AND name LIKE 'ipaddress%') GROUP BY n.id"), 'view_puppet_error' => array('sql' => "SELECT idnode ,idcompany ,iddc ,value as last_run FROM fact JOIN node ON id=idnode WHERE name='last_run' AND substr(value,1,10) <='".date('Y-m-d', strtotime('-3 days'))."'"), 'view_backup_error' => array('sql' => "SELECT idnode,idcompany,iddc,server,max(backup.date) as date FROM backup JOIN node ON id=idnode WHERE NOT EXISTS (SELECT 1 FROM node_decommission nd WHERE nd.id=node.id) GROUP BY idnode HAVING date <= '".date('Y-m-d', strtotime('-2 days'))."' ORDER BY backup.date") diff --git a/lib/php/db.php b/lib/php/db.php index 3633f80d..15d755c6 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -399,10 +399,14 @@ class Db extends nb { # Filters $name = self::p('name',''); $type = self::p('type',''); + $count = self::p('count',''); + $engine = self::p('engine',''); foreach ($this->tables() as $t) { if (!empty($name) and !$this->str_match($t->name,$name)) continue; if (!empty($type) and !$this->str_match($t->type,$type)) continue; + if (!empty($count) and !$this->str_match($t->count,$count)) continue; + if (!empty($engine) and !$this->str_match($t->engine,$engine)) continue; $rows[] = $t->infos(); } diff --git a/lib/php/nb.php b/lib/php/nb.php index 63aee7ff..7d350248 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -540,13 +540,13 @@ class NB { // Regex if (strpos($pattern,'~')===0) { $pattern = substr($pattern,1); - $match = preg_match('@'.str_replace('@','\@',$pattern).'@',$string); + $match = preg_match('@'.str_replace('@','\@',$pattern).'@i',$string); // Match } elseif(preg_match('/['.preg_quote('*?[]!').']/',$pattern)) { #if (strpos($pattern,'*') !== false or strpos($pattern,'') !== false - $match = fnmatch($pattern,$string); + $match = fnmatch($pattern,$string,FNM_CASEFOLD); #var_dump($not); // Default @@ -556,7 +556,7 @@ class NB { if (!$string) $string = 0; } #debug("$pattern = $string"); - $match = ($pattern == $string); + $match = (strtolower($pattern) == strtolower($string)); } return (bool)($not ? !$match : $match);