PDA

View Full Version : vBulletin4 how to 1) add youtube BB code tag 2) search and replace in all posts MySQL



Fli
03-11-2023, 11:01 AM
How to achieve two things:

1) how to add into vBulletin 4 the Youtube BB code tag/button to embed Youtube or any other video:

Go to AdminCP, Custom BB Codes, BB Code manager, Add new

title and tag name: youtube
replacement:
<iframe width="420" height="315"
src="https://www.youtube.com/embed/{param}">
</iframe>

Example: 6Bd-ESafWjc
Description: Please enter ONLY video code without any parameters and without full address.
Use {option}: No
Button Image (Optional): upload 16x16 YT image (https://www.ecosia.org/search?q=youtube+image+16x16) to your site directories and link to it in full address or just ./images/youtube16x16.png

Remaining radio buttons on Add new BB code set to: Yes

2) how to search and replace inside all vBulletin 4 posts

People used wrong format in their vBulletin 4 posts: http://www.youtube.com/watch?v=....
And i needed to convert it to above setup BB code format: 6Bd-ESafWjc (because maybe allowing people to post whole URL not just video identifier can result in malicious URL being included on page instead)

1. Backup MySQL posts table: Went into MySQL manager PHPMyAdmin (inside webhosting control panel), clicked posts table. Clicked to export. Selected Gzip compression and saved the backup. Ideally verify beginning and end of the extracted .sql file that it look complete forum posts table - it can be huge.
2. Inside PHPMyAdmin click Query tab and paste following:

UPDATE post SET pagetext = REPLACE(pagetext,'[YOUTUBE]http://www.youtube.com/watch?v=','[YOUTUBE]');
UPDATE post SET pagetext = REPLACE(pagetext,'[youtube]http://www.youtube.com/watch?v=','[YOUTUBE]');
Verified result on the forum. It worked for me. If not worked for you, you may try to adjust queries or at worst, emptying the posts table and restoring your previously made working backup - do this only if you are sure you know how to do it.