]> git.mxchange.org Git - friendica.git/blob - mod/oembed.php
Merge pull request #3149 from annando/1601-new-diaspora-mention
[friendica.git] / mod / oembed.php
1 <?php
2 require_once("include/oembed.php");
3
4 function oembed_content(App $a) {
5         // logger('mod_oembed ' . $a->query_string, LOGGER_ALL);
6
7         if ($a->argv[1]=='b2h'){
8                 $url = array( "", trim(hex2bin($_REQUEST['url'])));
9                 echo oembed_replacecb($url);
10                 killme();
11         }
12
13         if ($a->argv[1]=='h2b'){
14                 $text = trim(hex2bin($_REQUEST['text']));
15                 echo oembed_html2bbcode($text);
16                 killme();
17         }
18
19         if ($a->argc == 2){
20                 echo "<html><body>";
21                 $url = base64url_decode($a->argv[1]);
22                 $j = oembed_fetch_url($url);
23
24                 // workaround for media.ccc.de (and any other endpoint that return size 0)
25                 if (substr($j->html, 0, 7) == "<iframe" && strstr($j->html, 'width="0"')) {
26                         $j->html = '<style>html,body{margin:0;padding:0;} iframe{width:100%;height:100%;}</style>'. $j->html;
27                         $j->html = str_replace('width="0"', '', $j->html);
28                         $j->html = str_replace('height="0"', '', $j->html);
29                 }
30                 echo $j->html;
31 //              logger('mod-oembed ' . $j->html, LOGGER_ALL);
32                 echo "</body></html>";
33         }
34         killme();
35 }