[2.0.19] Youtube Video BBCode

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
125
64%
Very Good
23
12%
Good
21
11%
Fair
5
3%
Poor
21
11%
 
Total votes: 195

taifunbrowser
Registered User
Posts: 60
Joined: Sun Sep 10, 2006 2:09 am
Contact:

asdf

Post by taifunbrowser »

I edited the mod so that only moderators / admins can use the bbcode:

Code: Select all

############################################################## 
## MOD Title: YouTube Video BBCode 
## MOD Author: michaeltripp < iamdrscience@hotmail.com > (Mike) http://itsbeenconfirmed.com 
## MOD Description: Adds a new bbcode allowing you to easily embed videos from YouTube.com.
## MOD Version: 1.0.1 
## 
## Installation Level: (Easy) 
## Installation Time: ~5 Minutes
## Files To Edit: - includes/bbcode.php,
##                - langugage/lang_english/lang_main.php,
##                - templates/subSilver/bbcode.tpl,
##                - templates/subSilver/posting_body.tpl
## Included Files: n/a
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
############################################################## 
## For security purposes, please check: http://www.phpbb.com/mods/ 
## for the latest version of this MOD. Although MODs are checked 
## before being allowed in the MODs Database there is no guarantee 
## that there are no security problems within the MOD. No support 
## will be given for MODs not found within the MODs Database which 
## can be found at http://www.phpbb.com/mods/
############################################################## 
## Author Notes: 
##   You must have Multiple BBCode MOD installed for this to work.
##      Get it here: http://www.phpbb.com/phpBB/viewtopic.php?t=74705
##
##      example:
##  [youtube]YouTube URL[/youtube]
##
##  YouTube URL is the "Video URL (Permalink)" or the URL of the page the video 
##  is on, NOT the "Embeddable Player" code they have on their video pages.
## 
############################################################## 
## MOD History: 
##
##  2006-03-20 - Version 1.0.1
##	-Changed the names of the variables tbat are replaced in bbcode.tpl
##	from VIDEO and LINK to YOUTUBEID and YOUTUBELINK, because the names
##	were too common making it likely that they would conflict with other mods.
##
##  2006-03-17 - Version 1.0.0
##
##  2006-03-16 - Version 0.9.3
##	-Fixed a problem in the regex that allowed some invalid but benign input
##
##  2006-03-15 - Version 0.9.2
##	-Made the word "link" was a language variable
##	-Made the link open in a new window
##	-YouTube video IDs can have dashes, so I changed the regex to account for this
##	-Moved the link underneath the video instead of beside it
##
##  2006-03-07 - Version 0.9.1
##	-Added link for browsers YouTube's player doesn't like, i.e. Opera :(
##
##  2006-03-06 - Version 0.9.0
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

#
#-----[ OPEN ]---------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]---------------------------------
#
$EMBB_widths = array(''

#
#-----[ IN-LINE FIND ]---------------------------------
#
 array(''

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'60'

#
#-----[ FIND ]---------------------------------
#
$EMBB_values = array(''

#
#-----[ IN-LINE FIND ]---------------------------------
#
$EMBB_values = array(''

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'YouTube'

#
#-----[ FIND ]------------------------------------------
#
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
#
#-----[ AFTER, ADD ]------------------------------------------
#

global $userdata;
if ($userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD){
	$bbcode_tpl['youtube'] = str_replace('{YOUTUBEID}', '\\1', $bbcode_tpl['youtube']);
        $bbcode_tpl['youtube'] = str_replace('{YOUTUBELINK}', $lang['youtube_link'], $bbcode_tpl['youtube']);
}

#
#-----[ FIND ]------------------------------------------
#
$replacements[] = $bbcode_tpl['email'];
#
#-----[ AFTER, ADD ]------------------------------------------
#

// [youtube]YouTube URL[/youtube] code..
global $userdata;
if ($userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD){
   $patterns[] = "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is";
   $replacements[] = $bbcode_tpl['youtube'];
}

#
#-----[ OPEN ]---------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]---------------------------------
#
# NOTE: the full line to look for is:
#$lang['bbcode_f_help'] = "Font size: [size=x-small]small text[/size]";
#
$lang['bbcode_f_help'] =

#
#-----[ AFTER, ADD ]---------------------------------
#

$lang['bbcode_help']['youtube'] = 'YouTube: [youtube]YouTube URL[/youtube]';

$lang['youtube_link'] = 'Link';
#
#-----[ OPEN ]------------------------------------------ 
#
templates/subSilver/bbcode.tpl
    
#
#-----[ FIND ]------------------------------------------ 
#
<!-- BEGIN email --><a href="mailto:{EMAIL}">{EMAIL}</a><!-- END email -->
#
#-----[ AFTER, ADD ]------------------------------------------ 
#

<!-- BEGIN youtube -->
<object width="425" height="350">
	<param name="movie" value="http://www.youtube.com/v/{YOUTUBEID}"></param>
	<embed src="http://www.youtube.com/v/{YOUTUBEID}" type="application/x-shockwave-flash" width="425" height="350"></embed>
</object><br />
<a href="http://youtube.com/watch?v={YOUTUBEID}" target="_blank">{YOUTUBELINK}</a><br />
<!-- END youtube -->
#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------
#
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags
#
bbtags = new Array(

#
#-----[ IN-LINE FIND ]---------------------------------
#
'[url]','[/url]'

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'[youtube]','[/youtube]'

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
#
# EoM

User avatar
versache
Registered User
Posts: 14
Joined: Fri Nov 17, 2006 4:43 am

Post by versache »

nm

taifunbrowser
Registered User
Posts: 60
Joined: Sun Sep 10, 2006 2:09 am
Contact:

asdf

Post by taifunbrowser »

lol, what the heck?
"not much"


That totally doesnt fit this situation ,_<

k2xl
Registered User
Posts: 29
Joined: Sat Nov 18, 2006 3:50 am
Location: Georgia, USA
Contact:

Post by k2xl »

For anyone wanting to have a javascript popup when the user clicks the YouTube Button on their forums, use this code that I made.

Make sure that the youtube button is a bbcode id of 18.

Example can be found on my forum: http://www.k2xl.com/phpBB2

Code: Select all


function bbstyle(bbnumber) {

	var txtarea = document.post.message;

	txtarea.focus();
	donotinsert = false;
	theSelection = false;
	bblast = 0;

	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[0]) {
			butnumber = arraypop(bbcode) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post.addbbcode' + butnumber + '.value');
			eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}

	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		return;
	}
	
	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode.length; i++) {
		if (bbcode[i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[bblast]) {
				butnumber = arraypop(bbcode) - 1;
				txtarea.value += bbtags[butnumber + 1];
				buttext = eval('document.post.addbbcode' + butnumber + '.value');
				eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
				imageTag = false;
			}
			txtarea.focus();
			return;
	} else { // Open tags
	
		if (imageTag && (bbnumber != 14)) {		// Close image tag before adding another
			txtarea.value += bbtags[15];
			lastValue = arraypop(bbcode) - 1;	// Remove the close image tag from the list
			document.post.addbbcode14.value = "Img";	// Return button back to normal state
			imageTag = false;
		}
		
		// Open tag
		if (bbnumber != 18) // if not a youtube video
		{
			txtarea.value += bbtags[bbnumber];
			if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
			arraypush(bbcode,bbnumber+1);

			eval('document.post.addbbcode'+bbnumber+'.value += "*"');
		}
		else
		{
			var youtubeURL = prompt("Enter the YouTube VALUE.\nhttp://www.youtube.com/watch?v=VALUE\nExample: UxqNsUbWlHc","");
			txtarea.value += bbtags[bbnumber]+youtubeURL+bbtags[bbnumber+1];
		}
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}
The javascript will prompt the user for a "YouTube Value".
Enjoy!

-Danny
http://www.k2xl.com/ - My flash games.

Stormyweather
Registered User
Posts: 7
Joined: Sat Nov 18, 2006 1:34 pm

Post by Stormyweather »

I have the the "YouTube" button but when I use it the [youtube] tags do not show up. All I get is "undefined" in my post.
Anyone some idea?

Something different but the same issue:
I noticed that without any mod I can get the same result of embedding Youtube movies when I allow HTML and restrict it to: "object" "param" and "embed". (using the embedded link ofcourse)
Is such a thing a big risk?

k2xl
Registered User
Posts: 29
Joined: Sat Nov 18, 2006 3:50 am
Location: Georgia, USA
Contact:

Post by k2xl »

Post the code your using for the button.

-Danny
http://www.k2xl.com/ - My flash games.

htaccesselite
Registered User
Posts: 14
Joined: Thu Nov 09, 2006 2:49 am
Contact:

Fix for warning: page contains secure and nonsecure items

Post by htaccesselite »

I run a secure phpBB forum that ONLY operates on port 443, SSL is required or the connection is denied. My users started requesting the ability to post youtube and google videos within the post.

I installed the [2.0.19] Youtube Video BBCode and the [2.0.21] Google Video and everthing worked perfectly, until I tested the feature in my browser and got the following warning message:
This page contains both secure and nonsecure items.

Do you want to display the nonsecure items?


AHH! How annoying. So I went about looking for a workaround for this and finally came up with my own solution, that is very easy.

Open includes\bbcode.php

Find

Code: Select all

	// [email]user@domain.tld[/email] code..
	$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
	$replacements[] = $bbcode_tpl['email'];
After Add

Code: Select all

    // [youtube]YouTube URL[/youtube] code..
    $patterns[] = "#\[youtube\]http://(?:www\.)?youtube.com/watch\?v=([0-9A-Za-z-_]{11})[^[]*\[/youtube\]#is";
$replacements[] = $bbcode_tpl['youtube'];

// [GVideo]GVideo URL[/GVideo] code..
    $patterns[] = "#\[GVideo\]http://video.google.com/googleplayer\.swf\?docid=([0-9A-Za-z-_]*)[^[]*\[/GVideo\]#is";
    $replacements[] = $bbcode_tpl['GVideo'];

    // [GVideo]GVideo URL[/GVideo] code..
    $patterns[] = "#\[GVideo\]http://video.google.com/videoplay\?docid=([0-9A-Za-z-_]*)[^[]*\[/GVideo\]#is";
    $replacements[] = $bbcode_tpl['GVideo'];
Find

Code: Select all

	$text = preg_replace($patterns, $replacements, $text);
After Add

Code: Select all

	$text = str_replace("http://www.youtube.com/", "https://example.com/lounge/youtube/", $text);

	$text = str_replace("http://video.google.com/videoplay", "https://example.com/lounge/googleplayer.swf", $text);
	$text = str_replace("http://video.google.com/", "https://example.com/lounge/", $text);
Now heres the cool part, in your sites root web-accessible folder http://www.example.com/ add an .htaccess file with the following:

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^lounge/googleplayer\.swf(.*)$ http://video.google.com/googleplayer.swf$1 [L]
RewriteRule ^lounge/youtube/(.*)$ http://www.youtube.com/$1 [L]
and it worked!

But one caveat, this wouldn’t turn the warning messages off in IE < version 7, so I added some simple HTML to the head of all my pages that only shows up for people using IE < version 7.

Code: Select all

<!--[if lt IE 7]>
<span id="ie7">Please Upgrade:
<a href="http://www.microsoft.com/windows/ie/downloads/default.mspx?mg_id=10013">IE 7!</a>
<a href="http://www.mozilla.com/en-US/">FF!</a></span>
<![endif]–>

Cool huh! Can anyone help me clean up the code that I am including in bbcode.php? As you can see I don't really understand how to do the replacing in the most efficient way..

Original Solution: Fix for secure and nonsecure items warning message also at AskApache.com blog
Last edited by htaccesselite on Tue Apr 03, 2007 6:27 pm, edited 1 time in total.

angeljhouse
Registered User
Posts: 86
Joined: Wed Jul 26, 2006 5:59 am

Post by angeljhouse »

For the original mod, when user click on the youtube screen in the post, it will redirect user to the original youtube website for that video (by opening a new window)... i want to remove this function as I don't want user know that video is uploaded by whom....that mean when they click on the youtube screen, nothing will be happen. can i??thanks

Spydie88
Registered User
Posts: 6
Joined: Sun Nov 19, 2006 11:02 pm

Post by Spydie88 »


Steelers
Registered User
Posts: 109
Joined: Fri Mar 25, 2005 6:13 am
Contact:

Post by Steelers »

Stormyweather wrote: I have the the "YouTube" button but when I use it the [youtube] tags do not show up. All I get is "undefined" in my post.
Anyone some idea?


I'm having the same problem. but when i put in [youtube][/youtube] manually, it works. hmm
go steelers

angeljhouse
Registered User
Posts: 86
Joined: Wed Jul 26, 2006 5:59 am

Post by angeljhouse »

angeljhouse wrote: For the original mod, when user click on the youtube screen in the post, it will redirect user to the original youtube website for that video (by opening a new window)... i want to remove this function as I don't want user know that video is uploaded by whom....that mean when they click on the youtube screen, nothing will be happen. can i??thanks


no one can help me??

areax
Registered User
Posts: 3
Joined: Thu Nov 23, 2006 12:58 am

Re: [2.0.19] Youtube Video BBCode

Post by areax »

MOD Database Manager wrote: Classification: 53 BBCode

MOD Name: Youtube Video BBCode
Author: michaeltripp
MOD Description: Adds a new bbcode allowing you to easily embed videos from YouTube.com.


MOD Version: 1.0.1 (Updated 03/21/06)
Installation Level: Easy
Installation Time: ~ 5 Minutes

Download File: youtube-1.0.1.mod
File Size: 5790 Bytes

Security Score: 0

Support for this MOD needs to be asked within this topic. The phpBB Teams are not responsible or required to give anyone support for this MOD. By installing this MOD, the phpBB Support Team or phpBB MODifications Team may not be able to provide support.

This MOD has only been tested by the phpBB MOD Team with the phpBB version in the topic title. It may not work in any other versions of phpBB.


Hello all, I am new to administering a board. Once I have downloaded the MOD where do I place the information?

Stormyweather
Registered User
Posts: 7
Joined: Sat Nov 18, 2006 1:34 pm

Post by Stormyweather »

@ Steelers, about that undefined thing:

I would check next part of the code. Doin` something wrong there resulted in the undefined thing.

Code: Select all

#
#-----[ OPEN ]---------------------------------
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]---------------------------------
#
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags
#
bbtags = new Array(

#
#-----[ IN-LINE FIND ]---------------------------------
#
'[url]','[/url]'

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'[youtube]','[/youtube]' 

Vortex_ICS
Registered User
Posts: 2
Joined: Thu Jul 01, 2004 1:06 am

Post by Vortex_ICS »

I have installed multi-bbc-1-4-0.mod and the youtube-1.0.1.mod to my installation.

Now, whenever I am posting or editing I get two 'preview' and 'submit' buttons, which only the ones above work :

Image

I can see that there is a "> in there that probably needs to get fixed, but I just don't know what file I should edit and how.

Thanks !

User avatar
nepukjon
Registered User
Posts: 116
Joined: Sat Jul 23, 2005 8:07 pm
Location: Cardiff. S. Wales
Contact:

Post by nepukjon »

I cant for the life of me find the commands for the first couple of edits in the includes/bbcode file....

Peeing me off as this would be a good addition to my forum. Any help would be great!!
knowledge is knowing a tomato is a fruit, wisdom is not putting it in a fruit salad

Post Reply

Return to “[2.0.x] MOD Database Releases”