Kitz Forum

Announcements => Site & Forum Discussion => Topic started by: kitz on August 02, 2015, 07:24:08 PM

Title: Embedded Youtube links & errors
Post by: kitz on August 02, 2015, 07:24:08 PM
Ive been using the mod YouTube BBCode (http://custom.simplemachines.org/mods/?mod=936) for many years which allows users to embed youtube videos into forum posts.   Unfortunately the mod has been deprecated and received no further updates or support since 2010. 

Because at the time there wasn't anything else other than AEVA* I continued to use the old one as it wasn't causing any problems.  Until that is I did a PHP/security update (http://forum.kitz.co.uk/index.php/topic,15509.0.html) a few weeks ago.  Although the mod continues to work on the surface it is generating 1000's of php errors in the log file, so Im about to remove it and see if I can get something else to work.   In the meantime Im not quite sure how it will impact older links.    I will update this thread as I go along.


*Without going into specifics but there appears to be some sort of fall out between the mod creator & SMF.  AEVA media is a $pay for mod, and numerous reports of problems with the free version meant I kept with youtube bbcode for as long as I could.
Title: Re: Embedded Youtube links & errors
Post by: kitz on August 02, 2015, 07:25:36 PM
I'm documenting things here because I've done lots of searching this afternoon trying to find out whats going on and others may also have the same issue wondering why they are getting the following error and it may help someone else who googles it.

SMF LOG ERROR
8: Array to string conversion
File: /home/server/public_html/forum/Sources/Subs.php
Line: 2382

the problem is with this part of the code inserted by youtube bbcode

Code: [Select]

// Don't parse the content, just skip it.
elseif ($tag['type'] == 'unparsed_content')
{
$pos2 = stripos($message, '[/' . substr($message, $pos + 1, strlen($tag['tag'])) . ']', $pos1);
if ($pos2 === false)
continue;

$data = substr($message, $pos1, $pos2 - $pos1);         
if (!empty($tag['block_level']) && substr($data, 0, 6) == '<br />')
$data = substr($data, 6);

if (isset($tag['validate']))
$tag['validate']($tag, $data, $disabled);

$code = strtr($tag['content'], array('$1' => $data)); // <-------------------------  HERE!!!!!!!!!!

$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + strlen($tag['tag']));

$pos += strlen($code) - 1 + 2;
$last_pos = $pos + 1;

[code]
Title: Re: Embedded Youtube links & errors
Post by: Weaver on August 02, 2015, 07:39:03 PM
my PHP is too rusty, I don't know what the argument of array() is meant to mean.
Title: Re: Embedded Youtube links & errors
Post by: kitz on August 02, 2015, 08:00:54 PM
Okay now Ive found out exactly what is going on the solution really is very very simple.   
The hardest part was finding out what was throwing the error and then finding a suitable replacement that will be able to correctly handle any posts with the old style code.

Solution

Uninstall:- Youtube BBCode   - Errors immediately stop
Install:- Ohara YouTube Embed (http://custom.simplemachines.org/mods/index.php?mod=3268)

The author has just added support (http://www.simplemachines.org/community/index.php?topic=462968.msg3821097#msg3821097) for conversion of YouTube urls in the format used by the older mod and handles the conversion very nicely.


Notification for forum members

The new mod allows insertion of Vimeo and YouTube videos.  Simply click one of the buttons  (https://forum.kitz.co.uk/Themes/KitzBlue/images/bbc/youtube.gif)  (https://forum.kitz.co.uk/Themes/KitzBlue/images/bbc/vimeo.gif)
Links can be the full urls or the short format
Title: Re: Embedded Youtube links & errors
Post by: GigabitEthernet on August 02, 2015, 08:01:24 PM
Is HTML5 supported?
Title: Re: Embedded Youtube links & errors
Post by: kitz on August 02, 2015, 08:17:13 PM
Yep - works fine on the ipad using html5 :)


----
ETA

I've been reliably informed it also works fine in html5 mode on Linux too