Jump to content

[SOLVED] Google Video BBcode


EZE

Recommended Posts

Okay, I've been trying to make a bbcode parser for google video, so that a user can input [gvid]http://video.google.com/videoplay?docid=VARIABLE ID[/gvid] and it will turn into this:

<embed style=\"width:400px;height:326px;\" id=\"VideoPlayback\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId=[b]VARIABLE ID[/b]&hl=en\" quality=\"best\" FlashVars=\"playerMode=embedded\"/>

This is my code so far:

<?
$send = $_POST['send'];
$text = $_POST['text'];
if(!$send){
echo '<form action="" method="post"><textarea name="text"/></textarea><input type="submit" name="send"/></form>';
}
elseif($send){

function gvid($gid)
{
	if(preg_match("/\[gvid\]http:\/\/video.google.com\/videoplay?docid=(.*?)\[\/gvid\]/ise", $text))
	{
	$gid = str_replace("http://video.google.com/videoplay?docid=", "", $gid);
	$gid = "<embed style=\"width:400px;height:326px;\" id=\"VideoPlayback\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId=$gid&hl=en\" quality=\"best\" FlashVars=\"playerMode=embedded\"/>";
	}
	return $gid;
}
gvid($text);
echo $text;
}
?>

But when I enter text with the [gvid] code, it comes out as plain text. What should I do?

Link to comment
https://forums.phpfreaks.com/topic/40931-solved-google-video-bbcode/
Share on other sites

Never Mind, I solved it:

<?php
$send = $_POST['send'];
$text = $_POST['text'];
if(!$send){
echo '<form action="" method="post"><textarea name="text"/></textarea><input type="submit" name="send"/></form>';
}
elseif($send){
function gvid($gid)
{
$gid = str_replace("http://video.google.com/videoplay?docid=", "", $gid);
$someit = "<embed style=\"width:400px;height:326px;\" id=\"VideoPlayback\" type=\"application/x-shockwave-flash\" src=\"http://video.google.com/googleplayer.swf?docId=$gid&hl=en\" quality=\"best\" FlashVars=\"playerMode=embedded\"/>";
return $someit;
}
while(preg_match("/\[gvid\](.*?)\[\/gvid\]/ise", $text, $matches))
{
$text = str_replace($matches[0], gvid($matches[1]), $text);
}
echo $text;
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.