Resource icon

Post Content Find / Replace 1.0.0

No permission to download
Seems that #1 and #2 don't work on links with this type of link

Code:
[video=youtube;saU-L4QcrEw]http://www.youtube.com/watch?v=saU-L4QcrEw[/video]

I presume that hypens and underscores are the issue. I found lots of these
 
It generated the list, which was great. When I select save changes either before or after creating the list, it kicks back the error code - Please enter a valid message. I tried adding a space or two, but no change.

Thanks again. If I can delete 1900 broken image links, this would make my day -- better yet, my week!
That happens because some of your posts have only that image in there...if you remove it and it is the only thing you have a blank post which you shouldn't be able to save anyways... if you place something in the replacement field like 'img-removed' it will save.





...ok being a newbie here I didn't notice the Save Changes checkbox that you can leave unchecked and just test this type of stuff. I should have figured that this would have been incorporated!!
Yeah it's like a safety thing...I mean to be honest most people shouldn't use this addon...not to say they shouldn't have it installed but most people don't really get regex and it can cause a SERIOUS problem with your post data if you do something wrong...and 99.9% of the time when dealing with regex...the problem will be user error. If you can pay someone to do replacements for you do so, otherwise be prepared to make a lot of backups.

I did find that I have some posts that have multiple links in the same post, and the addon treats these as a single video. For instance, it wants to replace

Code:
     [video=youtube;Lalx66vIAl4]http://www.youtube.com/watch?v=Lalx66vIAl4[/video] [video=youtube;JNwnwdAV8wI]http://www.youtube.com/watch?v=JNwnwdAV8wI[/video] [video=youtube;j2-FsaNufL4]http://www.youtube.com/watch?v=j2-FsaNufL4[/video] [video=youtube;UTCJBnhYbnk]http://www.youtube.com/watch?v=UTCJBnhYbnk[/video]

with

Code:
[media=youtube]Lalx66vIAl4[/media]

For me, this is a simple thing, I can just fix the individual posts where this occurs and let the addon fix the rest. But I'm just curious how one would handle this otherwise, as I'm sure there are others out there with many more posts containing multiple links in a single post...
(don't do that you are just going to make a mess and i'll explain why)
Your problem is in your regex and not the addon...the addon is a vessel you can use to basically do a preg_replace (php replacement) against your posts table...the quick find box is using mysql to find something in a given table and is used to limit what you are preg_replacing against to only posts that have the string from quick find in it...

While you are using a general .+ which will keep matching until it finds the last instance of things matching what is after the .+ which in essence could take a 10000 character post that starts and ends with a youtube video into a single media embed with no text...and it can do it to every post you have with a link using that expression.


You need to be specific with the expression and force a start and stop point for the expression and control as much as possible in between.

This will catch both example #1 and #2:

Quick Find:
Code:
[video=


Regular expression:
Code:
#(\[video=(youtube)[^]]+])http(?:s)?://(?:www\.)?(?:[a-z0-9-]+\.)?youtu(?:be\.com/(?:[a-z]+(?:/api/videos/)?)|\.be)(?:\?v=|/)?([a-z0-9_-]{11})(?:[^\s[]+)?(\[/video])#siu


Replacement String:
Code:
[media=\2]\3[/media]
 
Last edited:
Yeah dude, that was the bomb! It found everything!

I agree that it appears that this tool could be seriously dangerous in the wrong hands. Thus the reason why the preview option is so handy. You can not only see the code section that will be affected, you can also go right to the post and look at how it looks before anything is changed.

I ran the #1 preview and then just manually edited the posts with multiple links, ran the preview again, and everything looked good so I checked the box and ran it.

I ran yours and it found about 21 more bad links the previous one had not caught, including the ones with hyphens and underscores, and the youtube_share links too (which #2 did not catch, at all, because of the hyphens and underscores)

Thanks a ton man!

now, what about #3 in my first post, the URL links? These are a result of people copying & pasting links directly under the vB engine, which just get turned into hyperlinks. vB wasn't smart enough to recognize these and automatically turn them into embedded video. yet another reason why vB sucks and XF rocks. So I can manually find these and just edit the post and save it, but I was hoping the addon could at least find these instances for me.
 
#3
Code:
[URL]http://youtu.be/p-h4VVRMj5A[/URL]

Fix for #3?

This one gets cleanly fixed when I simply Edit and Save the post. The others do not as they leave a hanging video=youtube text preceeding the video. But I don't want to have to go find and edit every post with a URL youtube link.
Thanks ahead of time
Don't do that, it makes more work for whoever has to come up with the fixes, individually editing and saving posts is a last ditch effort always unless you are talking about a situation where you know something is only coming up ten times and you know the location and it isnt worth the time to come up with an expression to catch it.


untested (don't have time right now to test it) so test this first with save unchecked and I should remind you that you should always backup after you finish your import so that you can do this part without worrying on a test bed with your import data (which is what everyone should always be doing when following advice from someone they don't know that when followed can effect their entire site)

Quick Find:
Code:
[url


Regular expression:
Code:
#(\[url(?:]|[^]]+]))http(?:s)?://(?:www\.)?(?:[a-z0-9-]+\.)?youtu(?:be\.com/(?:[a-z]+(?:/api/videos/)?)|\.be)(?:\?v=|/)?([a-z0-9_-]{11})(?:[^\s[]+)?(\[/url])#siu


Replacement String:
Code:
[media=youtube]\2[/media]
 
That worked perfect. Thanks

Also your point is good about the manual issue, because on a big board that would be tedious. I only had 3-5 instances that wouldn't get fixed right, and a sum total of maybe 100-130 embedded video links all together.
 
Hi! I found several old megaupload links at my forum that now are broken. I'd like to remove them.
Is there an easy way using this addon?
The urls are something like:
Code:
[URL]http://www.megaupload.com/?d=X1TERMZD[/URL]
Thanks!
 
Hi! I found several old megaupload links at my forum that now are broken. I'd like to remove them.
Is there an easy way using this addon?
The urls are something like:
Code:
[URL]http://www.megaupload.com/?d=X1TERMZD[/URL]
Thanks!
As long as you have a regular expression that matches the signature you are going for, this addon makes things really easy.


Quick Find:
Code:
megaupload


Regular expression:
Code:
#\[url(?:]|=')(http://(?:www\.)?megaupload\.com/\?d[^\[']+)(?:(?:'])?[^]]+])#siu


Replacement String: (you can use a string like LINK REMOVED or leave this blank, if you have posts that contain only a MU link then you will need to supply something in this field otherwise after replacing it will be trying to save blank posts which is a no go.)
Code:
 
Can I use this to replace quoted names after a username change. Eg as below...

Find
[quote="Old Name, post:

Replace
[quote="New Name, post:


I'd also like to use it to replace tags like this...

Find
Code:
[USER=435]Old Name[/USER]

Replace
Code:
[USER=435]New Name[/USER]
 
Can I use this to replace quoted names after a username change. Eg as below...

Find
[quote="Old Name, post:

Replace
[quote="New Name, post:


I'd also like to use it to replace tags like this...

Find
Code:
[USER=435]Old Name[/USER]

Replace
Code:
[USER=435]New Name[/USER]

@EQnoble

I see you're online buddy. Any advice on how to do this?
 
Gimme a lil bit ...

I'm balls deep in a hailmary series of nested foreach loops containing for loops and going through them all and trying to track down why a variable in a variable variable is not rotating with the cycle and I may be on the verge of finding the error or going insane and i need to flip the coin and try to finish this before doing anything else.

I'll update this post if no one posts in between now and when I get back.
 
Gimme a lil bit ...

I'm balls deep in a hailmary series of nested foreach loops containing for loops and going through them all and trying to track down why a variable in a variable variable is not rotating with the cycle and I may be on the verge of finding the error or going insane and i need to flip the coin and try to finish this before doing anything else.

I'll update this post if no one posts in between now and when I get back.

No rush EQ. I managed to do it with a SQL query with help from @xfrocks so it's already done.
 
I too converted from phpBB and had to run hundreds of regex and SQL queries to fix all the broken BB Code, due to the random hex strings you've mentioned above.

Try this for YouTube.

Take a backup first though!

Quick Find
Code:
[youtube

Regular Expression
Code:
#\[(youtube):([a-z0-9_]+)\](.*)\[/\1:\2]#siU

Replacement String
Code:
[\1]\3[/\1]

Don't forget that you will also need to convert the tags from youtube to media=youtube.
You can do that with standard queries.
Code:
UPDATE xf_post SET message = REPLACE(message, '[youtube]', '[media=youtube]');
UPDATE xf_post SET message = REPLACE(message, '[/youtube]', '[/media]');

Any idea how I can do the first part after running the UPDATE query in the second part? I thought I would be able to handle everything through queries in phpMyAdmin, however, there are several youtube codes that include the full URL or some additional code as well that simply don't show up now. Unfortunately the Post Content/Replace does not work for me. I guess my server doesn't have enough juice to run that for the number of threads I have and it consistently returns an error.
 
Any idea how I can do the first part after running the UPDATE query in the second part? I thought I would be able to handle everything through queries in phpMyAdmin, however, there are several youtube codes that include the full URL or some additional code as well that simply don't show up now.

I have never used phpBB but if you give me an example of the full bbcodes (click edit on a post with bbcode in question and then click the button for 'Use BBcode Editor') you need changed I will see what I can do for you.

Unfortunately the Post Content/Replace does not work for me. I guess my server doesn't have enough juice to run that for the number of threads I have and it consistently returns an error.
If it is a memory thing follow this guide that Jake Bunce put together, it will allow you to limit how many results get processed per submit.


http://xenforo.com/community/threads/import-from-ipb-3-2-posts-not-parsed-at-all.39577/#post-435226
 
Last edited:
I am not converting from phpBB... I imported from vB 3.8 and I want to use the phpMyAdmin query system to convert the youtube strings that are still hanging around - essentially i need to remove the "http://youtube.com...." that is in front of some links on my site.
 
I am not converting from phpBB... I imported from vB 3.8 and I want to use the phpMyAdmin query system to convert the youtube strings that are still hanging around - essentially i need to remove the "http://youtube.com...." that is in front of some links on my site.


Generally speaking I only post up regex relevant to this addon in this thread, if I am using a mysql query it is because I need to do more that just a simple regex replacement and even then I only use mysql to grab the data from the db, and put it back after all the processing done in straight php because mysql and the scope of it's regex abilities are just awful without creating custom user defined functions. This addon bridges the divide, it allows one to use regex in a very easy way against their posts table.

Like I said, I need to see an example or two in order to help you.

Go to your forum and click edit on any post with one of the bbcode/youtube links in question, and in the editor toolbar...all the way to the right...click the icon that looks like a wrench over a piece of paper....the bbcode tags with content in between is what I need to be able to tell you the expression to run. Just paste that example in between some [code][/code] tags
 
This addon has 4 folders, all of which are located under library/Xenforo/

One of the folders in the addon is Model, which contains a file post.php, however replacing that file will obviously be very bad.

What am I doing wrong?
 
This addon has 4 folders, all of which are located under library/Xenforo/

One of the folders in the addon is Model, which contains a file post.php, however replacing that file will obviously be very bad.

What am I doing wrong?
You need the four folders from the zip to be in /library/PostReplace/ so you literally just upload the PostReplace directory from the zip to the library folder.
 
I'm using the Link Check addon and found more links like previous megaupload links.
I find these kind of links several times, is there anyway to remove all those links?
I'm trying this:
Code:
Example:
[URL='http://etowalk.com/template/detail/displaydetail.html?itemId=228885']pantalla resistiva[/URL]

Quick Find:
[URL='http://

Regular expression:
#(\[url='http://)(etowalk\.com(?:[^\[]+)?\'])#siu

Replacement String:
http://www.movilesdualsim.com

The same with www.
Code:
Example:
[URL='http://www.etowalk.com/template/detail/displaydetail.html?itemId=228885']pantalla resistiva[/URL]

Quick Find:
[URL='http://

Regular expression:
#(\[url='http://)(?:www\.)(etowalk\.com(?:[^\[]+)?\'])#siu

Replacement String:
http://www.movilesdualsim.com

The replacement string is just optional.
I tried, but it doesn't work.
Any idea??
 
Top Bottom