YouTube forum code - نوشته شده در (22949 Views)
Starting Member
lucapan
مطلب: 9
9
I wrote a little mod to use a brand new youtube forum code, like:

[youtube]http://www.youtube.com/watch?v=gJmX1z1NY2c[/youtube]
Here is the code:
http://www.lucapanella.com/downloads/SnitzYouTubeForumCodeMod.zip
<
http://www.gpfun.net GP Races with Grand Prix Legends
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Advanced Member
JJenson
مطلب: 2121
2121
That would be great but your text file isn't showing me the whole code? bigsmile
But I like the idea.<
نوشته شده در
Support Moderator
Podge
مطلب: 3776
3776
Marcel did a mod for this ages ago.

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=60387

This is the updated function I'm using for the new YouTube code. It actually works for all three types of YouTube code.
Code:
function EmbedTubeVideoT(YTPermalink, width, height, autostart) {   
if(YTPermalink == null || YTPermalink == "illegal"){
//Nope, we can't. document.writeln(" error: illegal use of video tag! ");
}else{
//Add the code to the document. genCode = YTPermalink.replace(new RegExp(/http\:\/\/www\.youtube\.com\/\?v\=/g), "");
genCode = genCode.replace(new RegExp(/http\:\/\/www\.youtube\.com\/watch\?v\=/g), "");
genCode = genCode.replace(new RegExp(/http\:\/\/www\.youtube\.com\/v\//g), "");
//document.writeln("gencode-"+genCode);
document.writeln('<object width="' + width + '" height="' + height + '"><param name="movie" value="http://www.youtube.com/v/' + genCode + '"><param name="wmode" value="transparent" /></param>');
document.writeln('<embed src="http://www.youtube.com/v/' + genCode + '" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed></object>');
document.writeln('<br><center>Hosted by <a href ="' + YTPermalink + '" target="_blank">YouTube</a></center>');
}
}
<
نوشته شده در
Starting Member
lucapan
مطلب: 9
9
Originally posted by Podge
Marcel did a mod for this ages ago.

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=60387

Marcel's mod is powerfull! [^]
My mod is simpler, it is for youtube videos only and doesn't involve javascripts. I did't want to embed other type of videos, so i made my own.
I thought to post my mod to contribute in this great community. If you like it, use it. Otherwise use Marcel's one. wink <
http://www.gpfun.net GP Races with Grand Prix Legends
نوشته شده در
Starting Member
lucapan
مطلب: 9
9
Originally posted by JJenson
That would be great but your text file isn't showing me the whole code? bigsmile

It shows only the piece of code to modify... is it not enough? smile Maybe i missed something?? blackeye<
http://www.gpfun.net GP Races with Grand Prix Legends
نوشته شده در
Advanced Member
JJenson
مطلب: 2121
2121
this is all I see.
I wrote this mod for Snitz Forum to use a simple forum code like: [youtube]gJmX1z1NY2c[/youtube] to embed a youtube video in the forum. Modify "inc_func_common.asp" adding the following function at the end of the file, before the<
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
JJenson, do a "View Source" or Right-click on the link and "Save Target As..." - his web server is processing the page instead of displaying it as a .txt file. Doing a "View Source" showed this:

Code:
I wrote this mod for Snitz Forum to use a simple forum code like:

[youtube]gJmX1z1NY2c[/youtube]
to embed a youtube video in the forum.
Modify "inc_func_common.asp" adding the following function at the end of the file, before the <script> section:

____________________________________

<%
Function ReplaceYouTubeTags(fString)
Dim oTag, cTag
Dim roTag1, rcTag1, roTag2, rcTag2
Dim oTagPos, cTagPos
Dim nTagPos
Dim counter1, counter2
Dim strCodeText
Dim Tagcount
Dim strTempString, strResultString
TagCount = 1
Dim CodeTags(1,2,3)
Dim strArray, strArray2

CodeTags(1,1,1) = "[youtube]"
CodeTags(1,2,1) = "[/youtube]"
CodeTags(1,1,2) = "<object width=""425"" height=""353""><param name=""movie"" value=""http://www.youtube.com/v/"
CodeTags(1,2,2) = """></param><param name=""wmode"" value=""transparent""></param>"
CodeTags(1,1,3) = "<embed src=""http://www.youtube.com/v/"
CodeTags(1,2,3) = """ type=""application/x-shockwave-flash"" wmode=""transparent"" width=""425"" height=""353""></embed></object>"

strResultString = ""
strTempString = fString

for counter1 = 1 to TagCount

oTag = CodeTags(counter1,1,1)
roTag1 = CodeTags(counter1,1,2)
roTag2 = CodeTags(counter1,1,3)
cTag = CodeTags(counter1,2,1)
rcTag1 = CodeTags(counter1,2,2)
rcTag2 = CodeTags(counter1,2,3)
oTagPos = InStr(1, strTempString, oTag, 1)
cTagPos = InStr(1, strTempString, cTag, 1)

if (oTagpos > 0) and (cTagPos > 0) then
strArray = Split(strTempString, oTag, -1, 1)
for counter2 = 0 to Ubound(strArray)
if (Instr(1, strArray(counter2), cTag) > 0) then
strArray2 = split(strArray(counter2), cTag, -1, 1)
strCodeText = trim(strArray2(0))
strCodeText = replace(strCodeText, """", " ") ' ## filter out "
'## Added to exclude Javascript and other potentially hazardous characters
strCodeText = replace(strCodeText, "&", " ", 1, -1, 1) ' ## filter out &
strCodeText = replace(strCodeText, "#", " ", 1, -1, 1) ' ## filter out #
strCodeText = replace(strCodeText, ";", " ", 1, -1, 1) ' ## filter out ;
strCodeText = replace(strCodeText, "+", " ", 1, -1, 1) ' ## filter out +
strCodeText = replace(strCodeText, "(", " ", 1, -1, 1) ' ## filter out (
strCodeText = replace(strCodeText, ")", " ", 1, -1, 1) ' ## filter out )
strCodeText = replace(strCodeText, "[", " ", 1, -1, 1) ' ## filter out [
strCodeText = replace(strCodeText, "]", " ", 1, -1, 1) ' ## filter out ] strCodeText = replace(strCodeText, "=", " ", 1, -1, 1) ' ## filter out =
strCodeText = replace(strCodeText, "*", " ", 1, -1, 1) ' ## filter out *
strCodeText = replace(strCodeText, "'", " ", 1, -1, 1) ' ## filter out '
strCodeText = replace(strCodeText, vbTab, " ", 1, -1, 1) ' ## filter out Tabs
strCodeText = replace(strCodeText, "view-source", " ", 1, -1, 1) ' ## filter out view-source
strCodeText = replace(strCodeText, "javascript", " ", 1, -1, 1) ' ## filter out javascript
strCodeText = replace(strCodeText, "jscript", " ", 1, -1, 1) ' ## filter out jscript
strCodeText = replace(strCodeText, "vbscript", " ", 1, -1, 1) ' ## filter out vbscript
strCodeText = replace(strCodeText, "mailto", " ", 1, -1, 1) ' ## filter out mailto
'## End Added
strCodeText = replace(strCodeText, "<", " ") ' ## filter out <
strCodeText = replace(strCodeText, ">", " ") ' ## filter out >
strCodeText = replace(strCodeText, "<br />", vbNewLine)
strResultString = strResultString & roTag1 & strCodeText & rcTag1 & roTag2 & strCodeText & rcTag2 & strArray2(1)
else
strResultString = strResultString & strArray(counter2)
end if
next

strTempString = strResultString
strResultString = ""
end if
next

ReplaceYouTubeTags = strTempString
end function
%>
____________________________________

At line 239 change:

____________________________________

if strAllowForumCode = "1" then
fString = extratags(fString)
end if
____________________________________

to
____________________________________

if strAllowForumCode = "1" then
fString = extratags(fString)
fString = ReplaceYouTubeTags(fString)
end if
____________________________________

Now you can use the brand new forum code!
If you want, you can modify "pop_forum_code.asp",
adding the following code before if (strIMGInPosts = "1"), at line 158.
____________________________________

Response.Write "<p><b>YouTube:</b> Enclose the video hash code with [youtube] and [/youtube] .  <i>Example:</i> Here is a video: <b>[youtube]</b>gJmX1z1NY2c<b>[/youtube]</b></p>" & vbNewLine
____________________________________

Ciao! Luca Panella

29-Aug-2007
<
نوشته شده در
Advanced Member
JJenson
مطلب: 2121
2121
Ahh didn't even think about the view source. At work and paying attention to my jobs here sort of I just want to stop working today. tongue I am having one of those weeks.<
نوشته شده در
Support Moderator
Podge
مطلب: 3776
3776
Its because of the <script> tag.<
نوشته شده در
Senior Member
leatherlips
مطلب: 1838
1838
I just tried this on my forum and it works great! It would be nice to have a YouTube button to automatically add the YouTube tags...<
نوشته شده در
Starting Member
lucapan
مطلب: 9
9
Originally posted by Podge
Its because of the <script> tag.

Right. I put the text file in a zip archive, so there is no problem about that.<
http://www.gpfun.net GP Races with Grand Prix Legends
شما باید یک متن وارد کنید