Like Ra's Naughty Forum

Full Version: [UPDATED] feature - Media Auto-embedding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Let me know if anything is missing in the list above and should be added.
Added instagram embedding.

See the second post in this thread for the list of supported sites.
Some sites updated their scripts, so they are breaking out from iframes (e.g. hypnotube). I'm currently tweaking the plugin to run all iframes in sandboxes with limited features.

Edit: I blocked pop-ups too. Please let me know if you notice any broken embeddings.
Youtube time codes still do not work. Can anybody spot the error?

Code:
// Youtube https://шшш.youtube.com/watch?v=e8WuGzXyO7Y&t=132s

    $message = preg_replace('%(https?://)?(www\.youtube\.com/watch\?v=)([a-zA-Z0-9_-]+)(&t=)?([0-9]+)?(s)?%', $leftdiv . '"https://www.youtube.com/embed/$3?fs=1&start=$5"' . $rightdiv . "$1$2$3$4$5$6<br />", $message);
Right now, I don't have a PHP-environment set up, so I tested this on regex101.com with PCRE2, which should be close enough. It turns out that what looks like a "w" in your test-url is in fact a cyrillic sha. If I replace "шшш" with "www" the regex and the url-part of the replacement work just fine.
(12 Mar 2023, 23:35 )Thegolor Wrote: [ -> ]It turns out that what looks like a "w" in your test-url is in fact a cyrillic sha. If I replace "шшш" with "www" the regex and the url-part of the replacement work just fine.
It's done intentionally for the post above, because otherwise it would be replaced with a video in the post. So, I just used whatever looks like "w". In any case, it's in the comment 😊

(12 Mar 2023, 23:35 )Thegolor Wrote: [ -> ]the url-part of the replacement work just fine.
The problem is - it does not in work in the forum... I wonder if it's related to "&".

See, for example, this post: https://www.likera.com/forum/mybb/Thread...3#pid65713
(13 Mar 2023, 00:34 )Like Ra Wrote: [ -> ]
(12 Mar 2023, 23:35 )Thegolor Wrote: [ -> ]It turns out that what looks like a "w" in your test-url is in fact a cyrillic sha. If I replace "шшш" with "www" the regex and the url-part of the replacement work just fine.
It's done intentionally for the post above, because otherwise it would be replaced with a video in the post. So, I just used whatever looks like "w". In any case, it's in the comment 😊
Ah. I almost thought that was a bit too easy. 😐

(13 Mar 2023, 00:34 )Like Ra Wrote: [ -> ]
(12 Mar 2023, 23:35 )Thegolor Wrote: [ -> ]the url-part of the replacement work just fine.
The problem is - it does not in work in the forum... I wonder if it's related to "&".

See, for example, this post: https://www.likera.com/forum/mybb/Thread...3#pid65713
Which version of PHP is the forum running on? Then I could try running it locally tomorrow evening.

And it probably doesn't help too much, but in any case this is my test on regex101.com: https://regex101.com/r/ceeALI/1. I had to remove the percent signs and escape the forward slahes instead. But that can't really be a problem, since it works fine for most of the url and if it were a problem it probably wouldn't work at all.
(13 Mar 2023, 01:05 )Thegolor Wrote: [ -> ]Which version of PHP is the forum running on?
7.4.33 - still can't migrate to 8.x -- some plugins are abandoned 😕

(13 Mar 2023, 01:05 )Thegolor Wrote: [ -> ]since it works fine for most of the url
Exactly... No idea why the &.* part is ignored.
So. I set up a PHP-installation on my computer and tried running your piece of code against that. The bad news? It works. Which leads me to believe that the regex itself is working as intended and something else is causing the problem. But since I'm not at all familiar with myBB and its inner workings, I can only take vague guesses. Sorry that I can't be of more help.
(13 Mar 2023, 21:27 )Thegolor Wrote: [ -> ]Sorry that I can't be of more help.
You helped a lot! Independent testing is a huge help! Thanks much!

The next step is to check what comes after my plugin (actually, it aeady uses one of the last "showthread" hooks.)
Pages: 1 2 3 4