Resource icon

Post Content Find / Replace 1.0.0

No permission to download

MYstIC G

Active member
Trying to kill some old smiley faces but no matter what I try I can't get this to work:
Code:
Quick Find: ph34r
Regular Expression: /(:ph34r:)/
Replacement String: fear
Any pointers appreciated chaps as I'm getting nowhere fast and I've been using RegExr to build the expressions and the searches all come up with results they just don't seem to commit :(
 

whyweprotest

Well-known member
Ok, we have a fix for ya. There was a slight bug in kiers code that had it looking in the wrong field, causing it to never load the old post when it came time to save.

PHP:
# diff orig-PostReplace/ControllerAdmin/PostReplace.php PostReplace-fixed.php
29c29
<                               $post['replaced'] = preg_replace($input['regex'], $input['replace'], $post['found']);
---
>                 $post['replaced'] = preg_replace($input['regex'], $input['replace'], $post['found']);
31c31
<                               $post['message'] = preg_replace($input['regex'], $input['replace'], $post['message']);
---
>                 $newmsg = preg_replace($input['regex'], $input['replace'], $post['message']);
34c34
<                               {
---
>                 {
38c38
<                                       $dw->setExistingData($post, true);
---
>                     $dw->setExistingData($post, true);
40c40,41
<                                       $dw->set('message', $post['message']);
---
>                     //$dw->set('message', $post['message']);
>                     $dw->set('message', $newmsg);
42,43c43,46
<                                       $dw->save();
<                               }
---
>                     $dw->save();
>                 }
>
>                 $post['message'] = $newmsg;
66c69
< }
\ No newline at end of file
---
> }

Note, the fixed php controller is attached, just wanted to show you the diff so you had an idea of what to expect.

edit: well, i tried to attach it at least ;) maybe it needs to be approved...
 

CyberAP

Well-known member
Ok, we have a fix for ya. There was a slight bug in kiers code that had it looking in the wrong field, causing it to never load the old post when it came time to save.

PHP:
# diff orig-PostReplace/ControllerAdmin/PostReplace.php PostReplace-fixed.php
29c29
<                               $post['replaced'] = preg_replace($input['regex'], $input['replace'], $post['found']);
---
>                 $post['replaced'] = preg_replace($input['regex'], $input['replace'], $post['found']);
31c31
<                               $post['message'] = preg_replace($input['regex'], $input['replace'], $post['message']);
---
>                 $newmsg = preg_replace($input['regex'], $input['replace'], $post['message']);
34c34
<                               {
---
>                 {
38c38
<                                       $dw->setExistingData($post, true);
---
>                     $dw->setExistingData($post, true);
40c40,41
<                                       $dw->set('message', $post['message']);
---
>                     //$dw->set('message', $post['message']);
>                     $dw->set('message', $newmsg);
42,43c43,46
<                                       $dw->save();
<                               }
---
>                     $dw->save();
>                 }
>
>                 $post['message'] = $newmsg;
66c69
< }
\ No newline at end of file
---
> }

Note, the fixed php controller is attached, just wanted to show you the diff so you had an idea of what to expect.

edit: well, i tried to attach it at least ;) maybe it needs to be approved...
Please, can you upload the fixed php file?
 

whyweprotest

Well-known member
I'll try again, but it didn't like it as a .php or a .zip... yah, same thing. Uploader goes to 100% and then when I hit post, nothing.

edit: removed file link to avoid confusion since kier has updated the OP.
 

Paul

Well-known member
Could i ask something about this, since it seems extrememly powerful, and i'm really not sure if what i want to do is possible!!

Some of my content includes quotes from previous postings a la newsgroup style. the only way to destinguish this is that the line starts with a ">" symbol. This may carry on over several lines.

is there any way in which this could be used to replace the multiple line ">" started content and put this lump into a "quote" box??

Thx[/quote]
 

Don

Member
This is just what I need, but I can't get it to run. Uploaded folders and contents to corresponding folders in /Xenforo/Library. Installed .xml file as usual. Here's what I get when I click on Replace in Posts. Anybody know what I'm doing wrong?

error.png
 

gldtn

Well-known member
how can I use this to replace embed code like this:
Code:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/DWD5Jr4hS9I&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/DWD5Jr4hS9I&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>
 

gldtn

Well-known member
Do the files in the zip go under library/xenforo corresponding folders? Or do I just upload the entire postreplace folder into xenforo/library?
 

Kier

XenForo developer
Staff member
Do your posts contain actual HTML, like the string you posted?
HTML:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/DWD5Jr4hS9I&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/DWD5Jr4hS9I&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>
If so, you could try this search expression:

Find:
Code:
#<object[^>]+>(<param[^>]+></param>)+<embed src="http://www.youtube.com/v/(\w+)[^"]+"[^>]+></embed></object>#siU
Replace:
Code:
[media=youtube]\2[/media]
I haven't tested that, but it should work.
 
Top