From cec4ba7d594c2739af425e77ca973b4f15c923c2 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 8 Aug 2016 16:42:24 +0200 Subject: [PATCH] out no_escape --- lib/php/db/types/mysql.php | 2 +- lib/php/out.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/php/db/types/mysql.php b/lib/php/db/types/mysql.php index d440adad..60f64996 100644 --- a/lib/php/db/types/mysql.php +++ b/lib/php/db/types/mysql.php @@ -22,7 +22,7 @@ $DB_TYPES['mysql'] = array ( 'extra_where' => 'having', 'localFile' => array (getenv('HOME').'/.my.cnf','^(?:user(?:name)?=(?P\\S+)|password=(?P\\S+))'), -'databases' => "SELECT SCHEMA_NAME as `name`,DEFAULT_CHARACTER_SET_NAME as `encoding`,DEFAULT_COLLATION_NAME as `collate` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('performance_schema','information_schema')", +'databases' => "SELECT SCHEMA_NAME as `name`,DEFAULT_CHARACTER_SET_NAME as `encoding`,DEFAULT_COLLATION_NAME as `collate` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('performance_schema','information_schema','mysql')", 'table.sql' => 'SHOW CREATE TABLE ``', 'table.sql.index' => "SELECT ".(Db::p('db.type') ? "CONCAT(s.TABLE_NAME,'_',s.INDEX_NAME,'_idx')" : 's.INDEX_NAME')." as name,(CASE NON_UNIQUE WHEN 1 THEN 0 ELSE 1 END) as uniqe,GROUP_CONCAT(COLUMN_NAME) as field FROM INFORMATION_SCHEMA.STATISTICS s LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON t.TABLE_SCHEMA=s.TABLE_SCHEMA AND t.TABLE_NAME=s.TABLE_NAME AND s.INDEX_NAME=t.CONSTRAINT_NAME WHERE 0=0 AND t.CONSTRAINT_NAME IS NULL AND s.TABLE_SCHEMA = '' AND s.TABLE_NAME='' GROUP BY name ORDER BY SEQ_IN_INDEX", diff --git a/lib/php/out.php b/lib/php/out.php index da8f6e4e..82838444 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -229,13 +229,13 @@ Class Out extends Nb { return ob_get_flush(); } - public static function rows($type,&$data,$head=array()) { + public static function rows($type,&$data,$head=[],$conf=[]) { # Ex: for action=tables when header=0 if (is_scalar($data)) $data = array(array($data)); if (!isset(self::$types[$type])) self::bye("Unknow type: `$type`"); - $conf = self::$types[$type]; + $conf = self::$types[$type] + $conf; #echo $conf['function']($data); return true; if (empty($conf['enclose'])) $conf['enclose'] = array('',''); @@ -290,13 +290,13 @@ Class Out extends Nb { return; } - public static function format($v,$type=null) { + public static function format($v,$type=null,$conf=[]) { if ($type === null) $type = self::$type; $is_scalar = is_scalar($v); $v = self::scalar($v); if ($v==='') $is_scalar = true; - $v = self::escape($v); + if (empty($conf['no_escape'])) $v = self::escape($v); if (!$is_scalar and strpos($type,'html') !== false) $v = '
'.NB_EOL.$v.NB_EOL.'
'; return $v; @@ -400,7 +400,7 @@ function out_tag(&$row,&$o) { foreach ($row as $k => $v) { - $v = out::format($v); + $v = out::format($v,null,$o); # Inside tag, ex: label if (isset($o['tag_key'])) { -- 2.47.3