streams/Code/Module/Oembed.php

36 lines
956 B
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
2021-12-03 03:01:39 +00:00
2022-02-16 04:08:28 +00:00
namespace Code\Module;
2021-12-03 03:01:39 +00:00
2022-01-25 03:34:10 +00:00
use App;
2022-02-16 04:08:28 +00:00
use Code\Web\Controller;
use Code\Lib as Zlib;
2016-04-19 03:38:38 +00:00
2021-12-02 23:02:31 +00:00
class Oembed extends Controller
{
public function init()
{
2022-01-25 03:34:10 +00:00
// logger('mod_oembed ' . App::$query_string, LOGGER_ALL);
2021-12-02 23:02:31 +00:00
if (argc() > 1) {
if (argv(1) == 'b2h') {
$url = array("", trim(hex2bin($_REQUEST['url'])));
2022-01-25 03:34:10 +00:00
echo Zlib\Oembed::replacecb($url);
2021-12-02 23:02:31 +00:00
killme();
} elseif (argv(1) == 'h2b') {
$text = trim(hex2bin($_REQUEST['text']));
2022-01-25 03:34:10 +00:00
echo Zlib\Oembed::html2bbcode($text);
2021-12-02 23:02:31 +00:00
killme();
} else {
echo "<html><head><base target=\"_blank\" rel=\"nofollow noopener\" /></head><body>";
$src = base64url_decode(argv(1));
2022-01-25 03:34:10 +00:00
$j = Zlib\Oembed::fetch_url($src);
2021-12-02 23:02:31 +00:00
echo $j['html'];
echo "</body></html>";
}
}
killme();
}
2016-04-19 03:38:38 +00:00
}