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