From 8ae6ac660191eac6cfd22445697588c369b6c8ed Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 8 Jun 2018 14:13:03 +0100 Subject: [PATCH] www/dbq/dbq.php --- lib/php/mime.php | 101 ++++++++++++++++++++++++++++++-------- lib/postgres/category.sql | 6 +++ www/dbq/dbq.php | 11 +++++ 3 files changed, 98 insertions(+), 20 deletions(-) create mode 100644 lib/postgres/category.sql diff --git a/lib/php/mime.php b/lib/php/mime.php index 0633b0d7..11e0c106 100644 --- a/lib/php/mime.php +++ b/lib/php/mime.php @@ -729,46 +729,107 @@ class Mime { return $m[1]; } - public static function html_youtube_embed($str) { - static $init = ''; + public static function html_video($str) { + + $sites = [ + 'dtube' => [ + 'exp' => '(d.tube/#!/v/[^/]+/[^/\?\s]+)', + 'html' => '', + ], + 'hooktube' => [ + 'exp' => 'hooktube.com/watch\?v=([^&\s]+)', + 'html' => '', + ], + 'youtube' => [ + 'exp' => 'www.youtube.com/watch\?v=([^&\s]+)', + 'html' => '', + ], + ]; + + foreach ($sites as $k => $site) { + if (!preg_match(','.$site['exp'].',',$str,$m)) continue; + $id = $m[1]; + $idsite = $k; + break; + } + + if (empty($id)) return; + + static $already_init; + if (empty($already_init)) { + + $init = ''; + + $already_init = true; + + } else { + $init = ''; + + } + + return $init + . ''.$str.''; + $id = ''; if (!preg_match(',//www.youtube.com/watch\?v=([^&\s]+),',$str,$m)) return $str; $id = $m[1]; + $iframe = '' - #.'
' .'' - #.'
' ; + + static $init = ''; if (empty($init)) { $init = '' . '' ; } + return $init . ''.$str.''; + $iframe = str_replace('',$id,$iframe); - return $init.$iframe; - return '' - #.'' - .'' - .'' - .'' - .'' - .'' - #.'' - ; + } public static function html_img_data($str) { @@ -790,7 +851,7 @@ class Mime { if ($mime === null) $mime = self::getContent($str); if ($mime == 'text/plain') { - if (preg_match(',//www.youtube.com/watch\?v=,',$str)) return self::html_youtube_embed($str); + if ($v = self::html_video($str)) return $v; } elseif (preg_match('@^image/@',$mime)) { return self::html_img_data($str); diff --git a/lib/postgres/category.sql b/lib/postgres/category.sql new file mode 100644 index 00000000..99af02d3 --- /dev/null +++ b/lib/postgres/category.sql @@ -0,0 +1,6 @@ +-- DROP TABLE IF EXISTS category; +CREATE TABLE IF NOT EXISTS category ( + id serial PRIMARY KEY, + name varchar(60), + description varchar(2000) +); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index f1e69e9c..8ba5bfbe 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -1129,6 +1129,11 @@ EOF; $action = $this->params['db']; if (!$action and self::PARAM_DB_DEFAULT) $action = self::PARAM_DB_DEFAULT; #$this->params = [ 'action' => $action ]; + #bye($this->params); + $arg = join('/',[$this->params['table'],$this->params['action'],$this->params['args']]); + $arg = []; + foreach (['table','action','args'] as $k) { if (!empty($this->params[$k])) $arg[] = $this->params[$k]; } + $arg = join('/',$arg); if ($action == 'help') { $this->page($this->db,[ @@ -1174,6 +1179,9 @@ EOF; } elseif ($action == 'cryptkey') { $this->page($this->cryptkey()); } elseif ($action == 'status') { $this->page($this,'status'); } elseif ($action == 'conf') { $this->page($this,'conf'); + } elseif ($action == 'conf') { $this->page($this,'conf'); + #} elseif ($action == 'html_video') { $this->page($arg); + } elseif ($action == 'html_video') { $this->page(Mime::html_video($arg)); } elseif ($action == 'types') { $types = []; foreach (array_keys($this->db->out->types()) as $type) { @@ -1402,6 +1410,9 @@ EOF; } } # < Class Dbq +#die($_SERVER['REQUEST_URI']."\n"); +#die($_SERVER['QUERY_STRING']."\n"); +#phpinfo(); exit; $DBQ = new DbQ([ 'run' => true, 'base' => (($base = Dbq::client_header('Dbq-Base')) ? preg_replace(',/+$,','',$base) : ''), -- 2.47.3