News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

how to remove "member" bbcode left from old mentions mod

Started by fms-er2020, January 15, 2021, 11:14:22 AM

Previous topic - Next topic

fms-er2020

i replaced my mentions mod with a new one

anyone?

help please

Aleksi "Lex" Kilpinen

What format is the bbcode exactly? The cleanest way to go would probably be to clean them from the database side, but with some tags that could be tricky.
Other option would be to add support for the tags, so that SMF still parses them and does something or nothing except hiding them.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kindred

you'd have to do a direct database edit... with a replace


UPDATE smf_messages
SET
    body = REPLACE(body,
        string_to_find,
        string_to_replace)
WHERE
    conditions;
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GigaWatt

You could also use this script ;).

https://github.com/sbulen/sjrbTools/blob/master/SMF_URLs_Paths.php

It's meant for changing URLs on forums, but I use it in these sorts of cases as well ;). I needed to remove the youtube tag from Yet Another YouTube BBCode Tag mod from my forum ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Aleksi "Lex" Kilpinen

That's actually a pretty handy tool. If used with care.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

GigaWatt

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

fms-er2020

thanks y'all

but i have no idea how to make use of that script

the bbcode looks like this:

[member=1234]SomeUsername[/member]

if you be so kind to give some steps to follow

:(

shawnb61

That script would not work for this.  It works on fixed strings only.

You need something that operates on a pattern match.  It looks like the user id is part of what needs to be removed.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Aleksi "Lex" Kilpinen

That would be in the category of "tricky", because REPLACE() does not have any support for wildcards, patterns, regular expressions, etc. REPLACE() only replaces one constant string for another constant string.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF


Aleksi "Lex" Kilpinen

I'm sure there is - Sadly, I'm not really able to come up with it. This would probably need a separate purpose built script to find and handle all of those tags.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

shawnb61

I'm thinking...

Mysql honors a REGEXP_REPLACE, but in mysql 8.0.

It honors a REGEXP in earlier versions, but as a SELECT only, not for updates.  Maybe a subquery...  Still thinking...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Aleksi "Lex" Kilpinen

Of course, if you shut down the forum for a moment - you could do it offline. Backup, export the table, do the replace with a suitable editor or command line tool to your liking, and then import the edited version?
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

shawnb61

Yes, as long as your editor had some kind of regexp replacement. 

I know Notepad++ does.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

fms-er2020


fms-er2020

i think my php version as per checking cpanel is PHP 7.2 (ea-php72)

GigaWatt

The script I posted earlier can be modified ;). The "[/member]" part's easy, no need to modify anything. The "[member=" part would go like this: if you hit "[member=" see if it has a digit after that; if it does, continue reading the data until you hit "]"; if no "]" is encountered after (let's say) 50 digits, drop everything move on; if "]" is hit before 50 digits, delete the value from the DB.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

#17
Here is a simplified, modified version here:
https://github.com/sbulen/sjrbTools/blob/master/smf_remove_old_bbc.php

If you have a test environment, run it there first & review the changes.
If you do not have a test environment, back everything up first.  Have your host back the db up, too.  Seriously.  If something bad happens & you can't restore, that's on you.

It will run in an inquiry mode.  When you like the output, change the "doit" flag to "Yes" & rerun.

It's written in a way to be able to be used for other bbc-like substitutions.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

GigaWatt

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

fms-er2020

Quote from: shawnb61 on January 15, 2021, 06:12:55 PM
Here is a simplified, modified version here:
https://github.com/sbulen/sjrbTools/blob/master/smf_remove_old_bbc.php [nofollow]

If you have a test environment, run it there first & review the changes.
If you do not have a test environment, back everything up first.  Have your host back the db up, too.  Seriously.  If something bad happens & you can't restore, that's on you.

It will run in an inquiry mode.  When you like the output, change the "doit" flag to "Yes" & rerun.

It's written in a way to be able to be used for other bbc-like substitutions.

thanks

how safe is it to run this with $doit = "no" ?

Advertisement: