diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-19 18:36:12 -0400 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-07-19 18:36:12 -0400 |
| commit | 30dc89278674b8bc83b4e44db920a1c7654c7cdd (patch) | |
| tree | 487947167afd971979a75d9a07eba4d81f22dab7 /inc | |
| parent | 0ba40a8fc2b7e798bf1b93e4f9c2972d3ba3f4cc (diff) | |
Only store video URLs in database, instead of the generated player HTML.
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/display.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/inc/display.php b/inc/display.php index 2021dc8f..a7e4826e 100644 --- a/inc/display.php +++ b/inc/display.php @@ -241,6 +241,29 @@ function secure_link($href) { return $href . '/' . make_secure_link_token($href); } +function embed_html($link) { + global $config; + + foreach ($config['embedding'] as $embed) { + if ($html = preg_replace($embed[0], $embed[1], $link)) { + if ($html == $link) + continue; // Nope + + $html = str_replace('%%tb_width%%', $config['embed_width'], $html); + $html = str_replace('%%tb_height%%', $config['embed_height'], $html); + + return $html; + } + } + + if ($link[0] == '<') { + // Prior to v0.9.6-dev-8, HTML code for embedding was stored in the database instead of the link. + return $link; + } + + return 'Embedding error.'; +} + class Post { public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) { global $config; @@ -269,6 +292,9 @@ class Post { $this->root = $root; $this->mod = $mod; + if ($this->embed) + $this->embed = embed_html($this->embed); + if ($this->mod) // Fix internal links // Very complicated regex @@ -365,6 +391,9 @@ class Thread { $this->mod = $mod; $this->hr = $hr; + if ($this->embed) + $this->embed = embed_html($this->embed); + if ($this->mod) // Fix internal links // Very complicated regex |
