News:

Join the Facebook Fan Page.

Main Menu

Autosearch and replace

Started by efk, January 11, 2018, 06:37:46 PM

Previous topic - Next topic

efk

Hey guys, I'm thinking to remove some old links (ex domains) from 2 different forums. Example, for subtitles for movies for text files (like srt, txt, notepad) there is an option to replace characters or words (Edit/Replace/Find What/Replace With) , so I'm wondering if there is something like that on smf? Or if I enter in word censoring exact word or domain, will it remove existing word/domain and without causing some mess? Replacing with something else will be awesome.

Aleksi "Lex" Kilpinen

You can use the word censoring, I've done that sometimes as a temporary measure. A real search and replace would have to be done through the database though.
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

efk

Quote from: Aleksi "Lex" Kilpinen on January 12, 2018, 11:42:32 AM
You can use the word censoring, I've done that sometimes as a temporary measure. A real search and replace would have to be done through the database though.
Is that simple to do, or very complex thing?

Illori


efk

Quote from: Illori on January 12, 2018, 11:57:59 AM
which part?
This?
QuoteA real search and replace would have to be done through the database though.

aegersz

If you have access to the DB unload, this is how I do a DB search and replace (in Linux but you may adapt it)  - this example builds my clone DB and imports it:

# Unload the current database
mysqldump -u root -passwd smf209 > /SQL/database_smf209_`date '+%d-%m-%Y'`.sql

# Convert the table prefix to the clone
sed 's/`smf209_/`smfclone1_/g' /SQL/database_smf209_`date '+%d-%m-%Y'`.sql > /SQL/smfclone1.sql

# Drop and Recreate the clone database
mysql -u root -passwd < /root/data/mysql.batch

# Reload the clone database
mysql -u root -passwd smfclone1 < /SQL/smfclone1.sql (drop database smfclone1; create database smfclone1;)
   
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Kindred

Ummm.... what?   That has nothing to do with what the op is asking.

Efk...    something like

UPDATE smf_messages SET body REPLACE(body,'original string','new string');
Сл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."

aegersz

 :-[  :-[

i just glanced at the previous post about seraching and replacing data in the DB.

please delete my posts.

long night ... whoops.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

shawnb61

I have a utility that I use to setup test environments after restoring the DB from prod.  I got sick of clicking on a link in test & finding myself on my prod site. 

It does ***ALL*** paths ***AND*** URLs in the settings table, the themes table, the messages table, the PMs table & even member signatures (some folks on my forum actually promote their own "tips & tricks" threads in their signatures). 

It has a "do it" flag, which if set to "no" can be used to preview the changes. 

It is extremely helpful.  OTOH, it is extremely dangerous & should be used with extreme caution.  Uh... backup your DB first.   Then back it up again...   

I have it up on Github.  Link here:
https://github.com/sbulen/sjrbTools/blob/master/SMF_URLs_Paths.php
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Kindred

Shawn,   It think that the op was looking to replace URLs in messages not the system URLs and paths
Сл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."

shawnb61

Yes, it does messages too.  It can be pared back.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

a10

Been doing this by exporting the single message table, then notepad++ and using the excellent find \ replace functions then reuploading the table.

As always, the start of of any table or db editing process is a backup :O)
2.0.19, php 8.0.23, MariaDB 10.5.15. Mods: Contact Page, Like Posts, Responsive Curve, Search Focus Dropdown, Add Join Date to Post.

Kindred

#12
A10,doing it Inline, in phpmyadmin is 1000 Times simpler and faster
Сл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."

efk


Aleksi "Lex" Kilpinen

As always, any time you do anything directly to your database - Backup, backup and backup again. :)
Did you get all the answers you needed, or is there something we can still help you with?
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

efk

I guess this is all. In about 2-4 weeks my colleague will read this topic and will work on it.  :)

Aleksi "Lex" Kilpinen

I'll mark this solved for now then, but you are free to mark this not solved again if you want to continue from here later. :)
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

Advertisement: