Tuesday, November 17, 2009

phpBB3 with youtube

To allow users to embed youtube videos in your pbpBB3 forum, do the following:

1. Go to the Administration Control Panel (ACP)

2. Click on the "Posting" tab, click "Add new BBCode".

3. In BBCode usage, enter the following:
[youtube]http://www.youtube.com/watch?v={SIMPLETEXT}{TEXT}[/youtube]

4. In HTML replace, enter the following:
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/{SIMPLETEXT}"><param name="wmode" value="transparent"><embed src="http://www.youtube.com/v/{SIMPLETEXT}" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

5. In Helpline, put anything you want, I use : Embed youtube links

6. Check "Display on posting page".

7. Submit.

With this, you can embed youtube links like this:
On some sites, the solution requires you to enter only the video id e.g. [youtube]ZGx2Mu2Yaig[/youtube], which is crazy. Which user will carefully select the id and paste it? Users will just copy everything in the address bar and paste it into the forum.

You may have tried other similar solution, and wondered why those do not work. The trick is in the bbcode, we have {SIMPLETEXT}{TEXT}. Often, a user will copy a youtube link with additional parameters (e.g. feature=channel ), which these parameters are handled by the {TEXT} and we throw these parameters away when we display the youtube object on screen. We only want the video id, which is supplied by the "v" parameter.

Friday, November 6, 2009

PHP - killing long running exec process

Was writing a php script to run in commandline to process some files. Part of it is to run a 'whois' command from within PHP, but it hang (ip is 74.220.96.0). I don't know why.

Anyway, I searched and found this:
<?
exec("command & sleep 3 ; kill $!");
?>