From ea63f3312fc69df6c9e9b55568933a65adafee77 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 4 Aug 2015 20:07:55 -0700 Subject: personal oembed black/white list --- include/bbcode.php | 1 + include/oembed.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/bbcode.php b/include/bbcode.php index 66b63d395..66bf6b5ec 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -12,6 +12,7 @@ require_once('include/hubloc.php'); function tryoembed($match) { $url = ((count($match) == 2) ? $match[1] : $match[2]); + $o = oembed_fetch_url($url); if ($o->type == 'error') diff --git a/include/oembed.php b/include/oembed.php index a11a64eec..e50d34c7d 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -2,6 +2,35 @@ function oembed_replacecb($matches){ $embedurl=$matches[1]; + + // implements a personal embed white/black list for logged in members + if(local_channel()) { + if(($x = get_pconfig(local_channel(),'system','embed_deny'))) { + $l = explode("\n",$x); + if($l) { + foreach($l as $ll) { + if(trim($ll) && strpos($embedurl,trim($ll)) !== false) + return '' . $embedurl . ''; + } + } + } + if(($x = get_pconfig(local_channel(),'system','embed_allow'))) { + $found = false; + $l = explode("\n",$x); + if($l) { + foreach($l as $ll) { + if(trim($ll) && strpos($embedurl,trim($ll)) !== false) { + $found = true; + break; + } + } + } + if(! $found) { + return '' . $embedurl . ''; + } + } + } + $j = oembed_fetch_url($embedurl); $s = oembed_format_object($j); return $s; -- cgit v1.2.3