Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 06-28-2011, 01:41 PM   #1
The Dawg
Confirmed User
 
The Dawg's Avatar
 
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
Help REGEX help with Vbulletin cleaner.php

I need to replace all of the mod code from an outdated youtube video embedding mod [ame] to [video].

Old code:

Code:
[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]
I want the new code to look like this:

Code:
[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]
Cleaner.php has this section to do the search and replace:

Code:
// BACK UP YOUR DATABASE
$replacer = array(
                        ""      => "",
                        ""      => "",
                        ""      => "",
);
I want to add a $text = preg_replace with regex code to replace the old code.

I got this from stackoverflow:

Quote:
$text = preg_replace('#\[ame\=".*?\=([a-zA-Z0-9]*?)"]#', '([video=youtube;$1]https://youtube.com/watch?v=$1[/video])', $text);
and

Code:
$text = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\]|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);
The code looks right, but neither affected the thread text.

Anyone know how to make this work?

The Dawg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2011, 05:01 PM   #2
The Dawg
Confirmed User
 
The Dawg's Avatar
 
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
Bump for more eyes.
The Dawg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2011, 05:52 PM   #3
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
why not just create a new custom bb code, or are you trying to replace all the current ones via the database?
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2011, 06:00 PM   #4
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
I believe it is a problem that has more to do with where you are putting the code. I added a small piece to the code to remove the other shit at the end:

Here is the code from my example.. You can drop it into a php extension file and run it on your sever to see the output and play with it yourself...

Code:
<?

$text = '[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - &#x202a;Bill O\'Reilly Interviews Rapper Lupe Fiasco - 06/20/11&#x202c;&rlm;[/ame]';

$text3 = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);


echo "$text <br><br>$text3";

$text5 = '[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]';
echo "<br><br>$text5";

?>
And the output is:

[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

Which is:

line 1 - original string
line 2 - modified string
line 3 - what you wanted.

Notice 2 and 3 match.
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2011, 06:01 PM   #5
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
Of course you could just run this on the DB as Fris suggested and be done with it.
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2011, 09:06 PM   #6
The Dawg
Confirmed User
 
The Dawg's Avatar
 
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
Quote:
Originally Posted by fris View Post
why not just create a new custom bb code, or are you trying to replace all the current ones via the database?
Yes this is to replace the current ones in the database.
Quote:
Originally Posted by V_RocKs View Post
I believe it is a problem that has more to do with where you are putting the code. I added a small piece to the code to remove the other shit at the end:

Here is the code from my example.. You can drop it into a php extension file and run it on your sever to see the output and play with it yourself...

Code:
<?

$text = '[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - &#x202a;Bill O\'Reilly Interviews Rapper Lupe Fiasco - 06/20/11&#x202c;&rlm;[/ame]';

$text3 = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);


echo "$text <br><br>$text3";

$text5 = '[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]';
echo "<br><br>$text5";

?>
And the output is:

[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

Which is:

line 1 - original string
line 2 - modified string
line 3 - what you wanted.

Notice 2 and 3 match.
Thanks. I have a test database that I am running the test configurations on before I mess with the live forum. 2.5Million posts... so I cant screw it up.
The Dawg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-28-2011, 11:50 PM   #7
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
this won't make changes to the DB... so far as I know... didn't see what you were using to do that.
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 06-29-2011, 01:41 PM   #8
The Dawg
Confirmed User
 
The Dawg's Avatar
 
Join Date: Apr 2002
Location: State Of Bliss
Posts: 2,438
Quote:
Originally Posted by V_RocKs View Post
this won't make changes to the DB... so far as I know... didn't see what you were using to do that.
Your the man!

I just plugged in the code:

Code:
$text = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);
It processed correctly! Thanks a lot!
The Dawg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.