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' => '<iframe class="video"'
+ .' type="text/html"'
+ .' src="<SRC>"'
+ .' frameborder="0"'
+ .' allowfullscreen'
+ .'></iframe>',
+ ],
+ 'hooktube' => [
+ 'exp' => 'hooktube.com/watch\?v=([^&\s]+)',
+ 'html' => '<iframe class="video"'
+ .' type="text/html"'
+ .' src="//hooktube.com/embed/<SRC>?enablejsapi=1"'
+ .' frameborder="0"'
+ .' allowfullscreen'
+ .'></iframe>',
+ ],
+ 'youtube' => [
+ 'exp' => 'www.youtube.com/watch\?v=([^&\s]+)',
+ 'html' => '<iframe class="video"'
+ .' type="text/html"'
+ .' src="//www.youtube.com/embed/<SRC>?enablejsapi=1"'
+ .' frameborder="0"'
+ .' allowfullscreen'
+ .'></iframe>',
+ ],
+ ];
+
+ 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 = '<script type="text/javascript"><!-- '."\n";
+ $init .= 'var html_video = [];';
+ $init .= 'var html_video_e = document.createElement("div");';
+
+ foreach ($sites as $k => $site) {
+ $init .= ''
+ . 'html_video_e.innerHTML = "' . htmlentities($site['html']) . '";'
+ . 'html_video["'.$k.'"] = html_video_e.childNodes.length === 0 ? "" : html_video_e.childNodes[0].nodeValue;'
+ ;
+ }
+
+ $init .= "\n".' --></script>';
+
+ $already_init = true;
+
+ } else {
+ $init = '';
+
+ }
+
+ return $init
+ . '<a class="video" href="#"'
+ .' onclick="this.outerHTML=html_video[\''.$idsite.'\'].replace(\'<SRC>\',\''.$id.'\')"'
+ .'>'.$str.'</a>';
+
$id = '';
if (!preg_match(',//www.youtube.com/watch\?v=([^&\s]+),',$str,$m)) return $str;
$id = $m[1];
+
$iframe = ''
- #.'<details>'
.'<iframe'
.' class="video"'
.' type="text/html"'
.' src="//www.youtube.com/embed/<ID>?enablejsapi=1"'
.' frameborder="0"'
.'></iframe>'
- #.'<details>'
;
+
+ static $init = '';
if (empty($init)) {
$init = ''
. '<script type="text/javascript"><!-- '."\n"
- . 'var html_youtube_embed = document.createElement("div");'
- . 'html_youtube_embed.innerHTML = "' . htmlentities($iframe) . '";'
- #. 'var html_youtube_embed = "' . str_replace('"','\\"',htmlentities($iframe)) . '";'
- . 'html_youtube_embed = html_youtube_embed.childNodes.length === 0 ? "" : html_youtube_embed.childNodes[0].nodeValue;'
+ . 'var html_video = document.createElement("div");'
+ . 'html_video.innerHTML = "' . htmlentities($iframe) . '";'
+ #. 'var html_video = "' . str_replace('"','\\"',htmlentities($iframe)) . '";'
+ . 'html_video = html_video.childNodes.length === 0 ? "" : html_video.childNodes[0].nodeValue;'
. "\n".' --></script>'
;
}
+
return $init
. '<a class="video" href="#"'
- .' onclick="this.outerHTML=html_youtube_embed.replace(\'<ID>\',\''.$id.'\')"'
+ .' onclick="this.outerHTML=html_video.replace(\'<ID>\',\''.$id.'\')"'
.'>'.$str.'</a>';
+
$iframe = str_replace('<ID>',$id,$iframe);
- return $init.$iframe;
- return ''
- #.'<a target="_blank" href="//www.youtube.com/v/'.$id.'?color2=FBE9EC&version=3">'
- .'<object type="application/x-shockwave-flash" class="video" data="//www.youtube.com/v/'.$id.'?color2=FBE9EC&version=3">'
- .'<param name="movie" value="//www.youtube.com/v/'.$id.'?color2=FBE9EC&version=3" />'
- .'<param name="allowFullScreen" value="true" />'
- .'<param name="allowscriptaccess" value="always" />'
- .'</object>'
- #.'</a>'
- ;
+
}
public static function html_img_data($str) {
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);
$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,[
} 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) {
}
} # < 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) : ''),