Resource icon

Post Content Find / Replace 2.0.1

No permission to download
No secret.

All occurrences of macradio.net in the forum should be changed to technightowl.live

URL prefix would be the same, and there would be different directories that apply the same to both domains.
 
I ended up just doing the simple find/replace updates in phpMyAdmin in my server's Plesk panel for the affected database.

It took less than 15 to meticulously go over all the variations and replace them. Since it was just post text, and Resource Manager messages and updates, the dangers of mistakes were minimal.

I would be nice to have a find/replace tool that is as easy to use, without the need of expressions and such, but maybe another time I suppose.
 
Hello,

I'm very bad in regex and hope, someone will help me:

I like to replace

PFX

with

<span style="font-weight:bold"><span style="color:#a50220">P</span><span style="color:#036d2d">ortugal</span><span style="color:#a50220">F</span><span style="color:#036d2d">orum</span></span>

Is this possible? Works it also in signatures?

Thx

Kai
 

Any ideas as to why only the first hit gets replaced if there is a few that needs to be replaced in a singular post?

1682371952723.webp
 
I need to remove some html code that I brought with me from a forum import.
But I have the following error...
How can I do?
Thank you
 

Attachments

  • Screenshot (63).webp
    Screenshot (63).webp
    40.6 KB · Views: 23
  • Screenshot (62).webp
    Screenshot (62).webp
    17.7 KB · Views: 22
From the database I launch the following sql query

Code:
UPDATE xf_post SET message = REPLACE(message, 'TEXT-OLD', 'TEXT-NEW');
 
We found the answer to the error: no matter what you put in the Quick Search and the replacement string, YOU MUST put something in the Regular Expression field (you can't leave it blank). So put the regex version of your search string.

Once you do that, the add-on works perfectly. press proceed to check if there's an error in what you put in. If all goes well and you get a result, just click save and proceed to apply the changes. :)
 
Working on a slow server I get timeouts,
but I cant wait for a RAM-upgrade.

I try to limit, but ->limit(20) does not work:
Code:
        $postsFinder = $this->finder('XF:Post');

        /** @var \XF\Entity\Post[] $posts */
        $posts = $postsFinder
            ->where(
                'message', 'like',
                $postsFinder->escapeLike(
                    $input['quick_find'], '%?%'
                )
            )
            ->order('post_id')
            ->limit(20)
            ->fetch();


What can I do?
 
Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(message, '\\[IMG\\]http://[^\\s\\/]+\\.postimg\\.org/[^\\s\\[]+\\[/IMG\\]', 'REMOVED');

my query I've been using to remove any old obsolete urls referenced in the database that are embedding images. This example uses postimg.org. Change "REMOVED" to whatever.
 
Another for those whom had vBulletin migration errors due to some obsolete vB version bugs. In this instance, I had around a 1000 broken messages which embedded an image as the following;

Code:
image/png;base64,

1700314580402.png

To work around this, I've removed the content.

Query

Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(message, '\\[IMG\\]https://forum\\.domain\\.com/image/png[^\\[]+\\[/IMG\\]', '[IMG]https://forum.domain.com/images/404_image.png[/IMG]');

To work around the Regex limit, via MySQL set the following;

Code:
SET GLOBAL regexp_time_limit=0;

You will also need to bump up your php limits.

#Result

1700315164582.webp
 
Last edited:
signature code to remove old obsolete images/domains

Code:
UPDATE xf_user_profile
SET signature = REGEXP_REPLACE(signature, '\\[IMG\\].*photobucket\\.com.*\\[\\/IMG\\]', '');

replace photobucket with imageshack. This one nulls any found inside the img tag.
 
I had some malformed URLS via a plugin here, i fixed it via this script.
 
Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(message, 'Sent from my .+ using Tapatalk', '');

removes the old Tapatalk references in posts, although this one is English. Other languages should follow same principle.

Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(message, 'Envoyé de mon .+ en utilisant Tapatalk', '');
Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(message, 'Gesendet von meinem .+ mit Tapatalk', '');

merging query

Code:
UPDATE xf_post
SET message = REGEXP_REPLACE(message, '(Gesendet von meinem .+ mit Tapatalk|Envoyé de mon .+ en utilisant Tapatalk)', '');
 
I'm not very good with regex. Please help me if you can.

I have hundreds, maybe thousands of links posted in my forum to a 3rd party news site that got hacked, went offline, and has re-emerged, but with a new site (structure). All the old links in my forum now resolve to 404 error pages.

I would like to remove the URL bbcode (just base URL bbcode, not URL= code with special anchor text) wrapped around any links to DOMAIN.COM so that they are no longer live links. Maybe even remove the leading https:// as well. Is this possible with this mod?
 
I'm not very good with regex. Please help me if you can.

I have hundreds, maybe thousands of links posted in my forum to a 3rd party news site that got hacked, went offline, and has re-emerged, but with a new site (structure). All the old links in my forum now resolve to 404 error pages.

I would like to remove the URL bbcode (just base URL bbcode, not URL= code with special anchor text) wrapped around any links to DOMAIN.COM so that they are no longer live links. Maybe even remove the leading https:// as well. Is this possible with this mod?


Just do the replace as \1 not the bbcode variant.

Test the output first before committing to it.
 
  • Love
Reactions: cwe


Just do the replace as \1 not the bbcode variant.

Test the output first before committing to it.

Thanks James, that is really close to what I need. I added DOMAIN.COM to the Quick Find field and tested.

That REGEX is finding all the URL= formatted links with DOMAIN.COM, but the REGEX finds every link in a post - including links that are not DOMAIN.COM (when posts contain several links including one to DOMAIN.COM).

I'm guessing the REGEX would need to be modified to limit the search to just links including DOMAIN.COM and to find URL bbcode without anchor text (not the URL= format - the URL unfurl="true" format).
 
Last edited:
Back
Top Bottom