]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 25 Jul 2018 02:10:32 +0000 (03:10 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 25 Jul 2018 02:10:32 +0000 (03:10 +0100)
lib/php/mime.php
lib/php/out.php
www/dbq/dbq.php

index 4b0af9644d4e9644705e7bbbdafb647fc83b8191..3f724045f4229de6408af929d5b529c1a4909338 100644 (file)
@@ -732,8 +732,17 @@ class Mime {
        public static function html_video($str) {
 
                $sites = [
+                       'viveo' => [
+                                       'exp'  => '//player.vimeo.com/video/([^/&\s]+)',
+                                       'html' => '<iframe class="video"'
+                                               .' type="text/html"'
+                                               .' src="//player.vimeo.com/video/<SRC>"'
+                                               .' frameborder="0"'
+                                               .' allowfullscreen'
+                                       .'></iframe>',
+                       ],
                        'dtube' => [
-                                       'exp'  => '(d.tube/#!/v/[^/]+/[^/\?\s]+)',
+                                       'exp'  => '(d\.tube/#!/v/[^/]+/[^/\?\s]+)',
                                        'html' => '<iframe class="video"'
                                                .' type="text/html"'
                                                .' src="<SRC>"'
@@ -742,7 +751,7 @@ class Mime {
                                        .'></iframe>',
                        ],
                        'hooktube' => [
-                                       'exp'  => 'hooktube.com/watch\?v=([^/&\s]+)',
+                                       'exp'  => 'hooktube\.com/watch\?v=([^/&\s]+)',
                                        'html' => '<iframe class="video"'
                                                .' type="text/html"'
                                                .' src="//hooktube.com/embed/<SRC>?enablejsapi=1&autoplay=0"'
@@ -753,9 +762,10 @@ class Mime {
                        ],
                        'youtube' => [
                                        #'exp'  => 'www.youtube.com/watch\?v=([^/&\s]+)',
-                                       'exp'  => '(?:/watch\?v=|/video/)([^/&\s]+)',
+                                       'exp'  => '(?:/watch\?v=|/video/|//youtu.be/)([^/&\s]+)',
                                        'html' => '<a href="'.$str.'"><iframe class="video"'
                                                .' type="text/html"'
+                                               #.' src="//youtu.be/embed/<SRC>?enablejsapi=1"'
                                                .' src="//www.youtube.com/embed/<SRC>?enablejsapi=1"'
 # NB 10.06.18                                          .' src="//hooktube.com/embed/<SRC>?enablejsapi=1"'
                                                .' frameborder="0"'
index 296cf2510b0968f3375afda4d9f41cec679c811d..6e8eb0f7b136847f14809cd751a06755da3a2c0b 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 require_once(dirname(__FILE__).'/nb.php');
+require_once(NB_ROOT.'/lib/php/mime.php');
 
 Class Out extends Nb {
 
@@ -8,6 +9,7 @@ Class Out extends Nb {
   protected static $type = 'txt';
   protected static $types;
   protected static $header = true;
+  protected static $mime;
 
   public static function init() {
 
@@ -19,6 +21,7 @@ Class Out extends Nb {
 
     #self::$types['html'] = self::$types['table'];
     self::type(self::client_type());
+               #self::$mime = new Mime();
   }
 
   public function __construct($opt=[],&$data=[],$head=[]) {
@@ -317,6 +320,7 @@ Class Out extends Nb {
     if (empty($o['no_format'])) foreach ($row as $k => $v) {
       $row[$k] = self::format($v,null,$o);
     }
+
     if (isset($o['row_parse_post'])) {
       $o['row_parse_post']($row);
     }
@@ -334,6 +338,9 @@ Class Out extends Nb {
 
     if (!empty($o['escape'])) $v = self::escape($v);
 
+               # Html user friendly
+# NB 25.07.18 if (!empty($o['is_html']) and $is_scalar) $v = Mime::html($v);
+
     return $v;
   }
 
index de158b03e585be04eba11eae92eb0899c945dae1..e880f08b5af2764771571b3750dc5c8414c57b2a 100644 (file)
@@ -709,6 +709,7 @@ class DbQ extends nb {
                $raw = null;
 
        #debug([self::client_header('Accept'),$content_type]);
+               #global $_POST;
                foreach (['json','yaml'] as $type) {
 
                        if (!strpos($content_type,'/'.$type)) continue;
@@ -720,7 +721,9 @@ class DbQ extends nb {
 # NB 20.07.18                  unset($post[$type]);
 
                        $fct = $type . '_decode';
-                       $_POST = $this->$fct(file_get_contents("php://input"));
+                       $_POST = (array)$this->$fct(file_get_contents("php://input"));
+                       #foreach ($_POST as $k=>$v) { $_POST[$k] = $v; }
+                       #bye($_POST);
 # NB 20.07.18                  $_POST = array_merge((array)$this->$fct($_POST[$type]),$post);
 
                        break;
@@ -1190,10 +1193,7 @@ EOF;
                } 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 == '_post') { $this->page($_POST);
-               } elseif ($action == '_get') { $this->page($_GET);
+               } elseif ($action == 'html') { $this->page(Mime::html($arg));
 
                } elseif ($action == 'types') {
                        $types = [];
@@ -1215,6 +1215,8 @@ EOF;
                        #$this->page($this,'phpinfo_rows');
                        #$this->phpinfo_rows();
 
+               } elseif ($action == '_POST') { $this->page($_POST);
+               } elseif ($action == '_GET') { $this->page($_GET);
                } elseif (0
                        or $action == '_SERVER'
                        or $action == '_REQUEST'