Advertisement:

Author Topic: Autosearch and replace  (Read 698 times)

Offline efk

  • Jr. Member
  • **
  • Posts: 105
  • Gender: Male
Autosearch and replace
« on: January 11, 2018, 06:37:46 PM »
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.

Offline Aleksi "Lex" Kilpinen

  • Support Specialist
  • SMF Super Hero
  • *
  • Posts: 16,542
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • aleksi-kilpinen on LinkedIn
Re: Autosearch and replace
« Reply #1 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.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

"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

Offline efk

  • Jr. Member
  • **
  • Posts: 105
  • Gender: Male
Re: Autosearch and replace
« Reply #2 on: January 12, 2018, 11:57:01 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?

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 48,968
Re: Autosearch and replace
« Reply #3 on: January 12, 2018, 11:57:59 AM »
which part?

Offline efk

  • Jr. Member
  • **
  • Posts: 105
  • Gender: Male
Re: Autosearch and replace
« Reply #4 on: January 12, 2018, 04:14:14 PM »
which part?
This?
Quote
A real search and replace would have to be done through the database though.

Offline aegersz

  • Sophist Member
  • *****
  • Posts: 1,313
  • Gender: Male
  • "mods" junkie
    • dopetalk
Re: Autosearch and replace
« Reply #5 on: January 13, 2018, 08:46:30 PM »
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;)
   
Linux CentOS VPS running SMF 2.0 with 140+ mods installed (the full h/w and s/w can be seen at http://forum.drugs-and-users.org/index.php/topic,3301)

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,885
  • Gender: Male
    • Kindred-999 on GitHub
Re: Autosearch and replace
« Reply #6 on: January 13, 2018, 08:53:36 PM »
Ummm.... what?   That has nothing to do with what the op is asking.

Efk...    something like
Code: [Select]
UPDATE smf_messages SET body REPLACE(body,’original string’,’new string’);
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline aegersz

  • Sophist Member
  • *****
  • Posts: 1,313
  • Gender: Male
  • "mods" junkie
    • dopetalk
Re: Autosearch and replace
« Reply #7 on: January 13, 2018, 09:07:34 PM »
 :-[  :-[

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

please delete my posts.

long night ... whoops.
Linux CentOS VPS running SMF 2.0 with 140+ mods installed (the full h/w and s/w can be seen at http://forum.drugs-and-users.org/index.php/topic,3301)

Online shawnb61

  • Support Specialist
  • Full Member
  • *
  • Posts: 674
    • sbulen on GitHub
Re: Autosearch and replace
« Reply #8 on: January 13, 2018, 09:35:23 PM »
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

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,885
  • Gender: Male
    • Kindred-999 on GitHub
Re: Autosearch and replace
« Reply #9 on: January 13, 2018, 09:50:25 PM »
Shawn,   It think that the op was looking to replace URLs in messages not the system URLs and paths
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Online shawnb61

  • Support Specialist
  • Full Member
  • *
  • Posts: 674
    • sbulen on GitHub
Re: Autosearch and replace
« Reply #10 on: January 13, 2018, 10:08:52 PM »
Yes, it does messages too.  It can be pared back.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline a10

  • Charter Member
  • Sr. Member
  • *
  • Posts: 758
Re: Autosearch and replace
« Reply #11 on: January 14, 2018, 05:57:25 AM »
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.15, php 7.0.24, ssl. Mods: Contact Page, Like Posts, Responsive Curve, Search Focus Dropdown.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,885
  • Gender: Male
    • Kindred-999 on GitHub
Re: Autosearch and replace
« Reply #12 on: January 14, 2018, 09:30:14 PM »
A10,doing it Inline, in phpmyadmin is 1000 Times simpler and faster
« Last Edit: January 17, 2018, 01:00:38 AM by Kindred »
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline efk

  • Jr. Member
  • **
  • Posts: 105
  • Gender: Male
Re: Autosearch and replace
« Reply #13 on: January 15, 2018, 08:10:34 PM »
Thank you guys. :)

Offline Aleksi "Lex" Kilpinen

  • Support Specialist
  • SMF Super Hero
  • *
  • Posts: 16,542
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • aleksi-kilpinen on LinkedIn
Re: Autosearch and replace
« Reply #14 on: January 17, 2018, 12:25:21 AM »
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?
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

"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

Offline efk

  • Jr. Member
  • **
  • Posts: 105
  • Gender: Male
Re: Autosearch and replace
« Reply #15 on: January 17, 2018, 06:48:51 PM »
I guess this is all. In about 2-4 weeks my colleague will read this topic and will work on it.  :)

Offline Aleksi "Lex" Kilpinen

  • Support Specialist
  • SMF Super Hero
  • *
  • Posts: 16,542
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • aleksi-kilpinen on LinkedIn
Re: Autosearch and replace
« Reply #16 on: January 18, 2018, 12:57:05 AM »
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. :)
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

"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