From 633b6f7be5a219943f353ad37cc7ac9d8be75f94 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 16 Dec 2015 15:23:44 +0000 Subject: [PATCH] sort and extras in db.yaml --- lib/php/db/table.php | 3 ++- lib/php/functions.php | 1 + lib/php/nb.php | 10 ++++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 3be38eab..d07bb0cd 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -613,8 +613,9 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. if ($this->db->type =='mysql') { $query = $this->db->conn->query('SELECT FOUND_ROWS()'); } else { - $sql_count = preg_replace('/^SELECT .*?FROM/s','SELECT count(*) FROM',$sql); + $sql_count = $sql; $sql_count = preg_replace('/ (ORDER|LIMIT) .*?$/s','',$sql_count); + $sql_count = preg_replace('/^SELECT .*FROM/s','SELECT count(*) FROM (',$sql_count).') count'; $query = $this->db->conn->query($sql_count); } diff --git a/lib/php/functions.php b/lib/php/functions.php index bae7d64b..1103b579 100644 --- a/lib/php/functions.php +++ b/lib/php/functions.php @@ -115,6 +115,7 @@ function debug($msg,$level=0) { if (preg_match('/ml/i',nb::get_header('Content-type'))) { echo '
'
       .(@$_SERVER['HTTP_HOST'] ? htmlentities($msg) : $msg)
+# NB 16.12.15       .(@$_SERVER['HTTP_HOST'] ? htmlspecialchars($msg) : $msg)
     .'
'.PHP_EOL; } else { diff --git a/lib/php/nb.php b/lib/php/nb.php index babe9863..91fb341b 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -87,12 +87,10 @@ class nb { * Return a client header */ static function get_header($name,$value=null) { - $v = array_map(create_function('$a', - #'return $a;' - 'return( preg_match("/^'.$name.':\s+(\S+)/i",$a,$m) ? $m[1] : null );' - ),headers_list()); - - return $v ? $v[0] : null; + foreach (headers_list() as $a) { + if ( preg_match("/^$name:\s+(.*)/i",$a,$m) ) return $m[1]; + } + return null; } } -- 2.47.3