Well, first of all: don't use Flash when HTML5 is available and supported by practically every browser of note
Secondly, here is the solution I've got for one of my boards. It probably can do with some tweaking and a general overhaul, but for the moment it's "working" and it has been working for the past 2+ years or so.
File: yt_embed.php
Code: Select all
<?php
//Simple code for returning an "embed" link, for youtube.
//works mostly with the iframe method.
if(isset($_GET['url'])) {
$url = $_GET['url'];
if (filter_var($url, FILTER_VALIDATE_URL)) {
//Strip out the url itself,
$url = str_replace('http://', "", $url);
$url = str_replace('https://', "", $url);
$url = str_replace('www.', "", $url);
//
$url = str_replace('youtube.com/watch?v=', "", $url);
$url = str_replace('youtube.com/v/', "", $url);
$url = str_replace('youtu.be/', "", $url);
//probably in effecient, but i'm too lazy to look up a better way.. so...
$params = explode('&', $url);
$embed = $params[0];
$params = explode('?', $embed);
$embed = $params[0];
//Basically, it'll split the remnants by the "&"s found in the string. We only need the first instance, as the rest
//are just arguements for the video, that aren't compatible in this form.
header('Location: https://www.youtube.com/embed/'.$embed );
//and viola!
}
else
{
echo "URL is invalid.";
}
};
?>
Paste: https://p.k0nsl.org/?d5b320612d6ad0fa#/ ... b047Pw3wY=
Usage:
HTML replacement:
Code: Select all
<iframe width="420" height="315" src="/yt_embed.php?url={TEXT}" frameborder="0" border="0" cellspacing="0" style="border-style: none"></iframe>
This method can be taxing on resources. If anyone can improve on it, go ahead. The author is somewhere on this board, I forgot who it was!
Best wishes,
-k0nsl