QUICK NEWS

{NEW} - More to come for this tab...

{OLD} - A new css video is up.


Video of the moment:


Internal Links

SMF Sites

Quick Info

Mysql database help please?

Started by Dave, Jan 30, 2026, 09:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dave

I'm in need of some help please by anyone with good mysql database knowledge. Can anyone tell me how I can remove the database entries for links like the one below. These are links in our 'Downloads' mod from SMFHacks, who I have consulted with him about this also

The reason for removing them is because FileFactory recently has been down more often than it's up so we've changed our hosting company

https://www.filefactory.com/file/75rhoje35jb6/WIN-Bingo-Setup.zip
I can remove all the instances of https://www.filefactory.com/file/ but the text following that remains in the database as it's a unique link to a file and all other links following that have all got different text that I'm left with in the database and download.

I've tried using 'UPDATE smf_down_file SET fileurl = REPLACE(fileurl, 'https://www.filefactory.com/file/', '')' but because of the unique text following that path '75rhoje35jb6/WIN-Bingo-Setup.zip' the unique text remains. I cannot use a wildcard with Replace apparently the other way to do it is with delete and then use the % wildcard but that removes everything following the

https://www.filefactory.com/file/

I'm at a loss of how to do what I want. I can manually remove the whole link in the database via phpMyadmin and I have done a few like that but there are a lot to do, I have tried the  SQL 'Delete' option and using a wild card but everything after the wildcard is removed also
Below is a few lines from the databse so you can see what I mean

(5209, 1, 1733992476, 'Win-Bingo', '\r\nIts Bingo - what more is there to say! With automatic Yorkshire Bingo Caller (which can be turned On or OFF)The last 3 numbers called is displayed in a panel below the main number. Main number flashes when first 5 numbers have gone to remind the bingo caller to read the first 5 numbers again.Press 'Next Number' for next new random number. Displays all bingo number nicknames during game.Display all balls that have gone in a 10 X 9 gridBut heres the best part.....ITS FREE!', 64, 13, 1745174028, 0, NULL, NULL, 'https://www.filefactory.com/file/75rhoje35jb6/WIN-Bingo-Setup.zip', 1, 2, 1, 1, 0, 0, 0, 1, 0, '', 0, 5931, 0, 0, 0, NULL, 0, 0, ''),
(2453, 1, 1686054756, 'Audiograbber', 'What is Audiograbber\r\n\r\nAudiograbber is a beautiful piece of software that grabs digital audio from cd's. Audiograbber can automatically normalize the music, delete silence from the start and/or end of tracks, and encode them to a variety of formats including MP3. Audiograbber can download and upload disc info from freedb, an Internet compact disc database. You can even record your vinyl LP's or cassette tapes with Audiograbber and make wav's or MP3's of them. There are a lot more functions in Audiograbber, but to put it simply: Audiograbber has the most features one can wish from such a program!\r\n\r\nMarch 4: Audiograbber 1.82 build 2 released.  \r\nThis build 2 supports USB drives, has support for Windows digital playback and works with more drives when it comes to CDG (karaoke) ripping. Read more about it on the forum:\r\nhttps://www.audiograbber.com-us.net/boards/ubb/Forum1/HTML/002996.html\r\n\r\nFebruary 11: Audiograbber 1.82 now released. \r\nFinally! New in this version is:\r\nBetter tracklist detection.\r\nRipping of CDG tracks (karaoke tracks).\r\nShipped with the latest official OGG Vorbis dll (and full OGG Vorbis support).\r\nOther minor but useful features.\r\n\r\nGet the latest version here \r\n\r\nhttps://www.audiograbber.org/get2/download-audiograbber-free.php', 42, 3, 1689457730, 0, '', '', 'http://www.filefactory.com/file/62l19ab7znpc/Setup_Audiograbber.rar', 2, 2, 1, 1, 0, 0, 0, 1, 0, '', 0, 2658, 0, 0, 0, '', 0, 0, ''),
(2362, 1, 1684336747, 'MusicBee 3.5 + Plugins', '\r\nThe link to download is for version \r\n\r\nMusicBee 3.5.8447\r\nReleased on February 19, 2023\r\nFor Windows 7/ 8/ 10/ 11\r\n\r\nIf you want to check if that's the latest version go here https://getmusicbee.com/downloads/\r\n\r\n[b]Simple, Powerful, and Fast[/b]\r\nPlay your music the way you want. Turn your computer into a music jukebox. Use auto-tagging to clean up your messy music library. Enjoy a great music experience with MusicBee.\r\n\r\n[b]Beautiful Skins[/b]\r\nChange the appearance of MusicBee by choosing from the included skins or download more from our Add-on section.\r\nSkins are a great way to personalize MusicBee to your liking.\r\n\r\nYou can also make your own skin and share it with others\r\n\r\n[b]Sync with Devices[/b]\r\nSync your music collection with devices you use. MusicBee supports playlist and podcast syncing, even supports audio books with 2 way syncing.\r\nConvert formats on the fly if your device does not support certain formats.\r\n\r\nYou can also sync your Android and Windows Phone (8.1+) devices.\r\n\r\n[b]Groove Music Support[/b]\r\nMusicBee has native support for Groove Music (formerly Xbox Music). You can stream directly from MusicBee or add to your existing playlist, get song recommendations from the vast Groove catalog.\r\n\r\nWant to listen to a song before buy? You can listen to preview.\r\n\r\n[b]last.fm, CD Ripping, Tagging tools.... plus more![/b]\r\nMusicBee packs a comprehensive set of features to make your music experience better.\r\n\r\nYet it is one of the most lightweight player using about 25-70 MB ram* with skins and add-ons, and packs all of these under 10 MB!\r\n\r\n\r\n*Tested with MusicBee 3 with a library of 200 albums, sized around 3GB.\r\n\r\n[b]The Best.... rated by reviewers and users[/b]\r\nMusicBee is rated one of the best music managers and players available for Windows. It packs features that will WOW you.\r\n\r\nWe have a dedicated thread for users to share their experience or check reviews from trusted sources.\r\n\r\nStart using MusicBee today. You will never go back.', 34, 2, 1690093576, 0, '', '', 'http://www.filefactory.com/file/148phdi8tncy/MusicBee%2Bplugins.rar', 0, 2, 1, 1, 0, 0, 0, 1, 0, '', 0, 2541, 0, 0, 0, '', 0, 0, ''),

Bigguy

Just about to go out but will have a look when I get back. 
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

Dave

Quote from: Bigguy on Jan 30, 2026, 12:44 PMJust about to go out but will have a look when I get back.

Thanks Geoff

Bigguy

In order to delete everything associated with that link, you would have to know all the names of every instance of it and then run it in an .sql file. If I'm not mistaken. I think it may have to be done manually. (hope that made sense)
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

Dave

Quote from: Bigguy on Jan 30, 2026, 03:42 PMIn order to delete everything associated with that link, you would have to know all the names of every instance of it and then run it in an .sql file. If I'm not mistaken. I think it may have to be done manually. (hope that made sense)


Yes I does Geoff, that's what I was hoping to avoid, thanks anyway

Bigguy

I don't know any other way to do it really. Maybe someone else will chime in and tell me I'm wrong or have a better idea. 
"It's the American dream....cause ya have to be asleep to believe it." - George Carlin

Skhilled

I haven't really messed with mysql in quite awhile but I agree with Geoff.

I know there was a query to find anything you want but I haven't used it in a long time and forgot what it was. Chen might know what it is if someone here doesn't answer first.

Neša

#7
You want to do a regular expression replace.
https://www.techgrind.io/explain/how-to-do-a-regular-expression-replace-in-mysql

I've had a go at creating a regular expression for you, I'm not the best at it maybe past some more filefactory links and test it out  :)
https://regexr.com/8jjum


Dave

#8
Quote from: Neša on Jan 31, 2026, 07:56 AMYou want to do a regular expression replace.
https://www.techgrind.io/explain/how-to-do-a-regular-expression-replace-in-mysql

I've had a go at creating a regular expression for you, I'm not the best at it maybe past some more filefactory links and test it out  :)
https://regexr.com/8jjum

Thanks Nesa,

I've just done a test in Notepad++ with the database table I need to work on and it removes all instances of the links. I have just downloaded 2 copies of the table edited one and now I'll upload it to the database and see if there are any issues.


Update

It seems it's deleting all rows with that regex in it. I'm going to attempt do do the same thing in phpMyadmin directly into the database. I have a backup I can quickly restore if need be

UPDATE2.
 
I ran this query in the database and although it didn't give me any errors now rows were affected

update smf_down_file set fileurl = replace(fileurl,'(https:|http:+)//www.filefactory.com\/file\/[A-Za-z0-9]+\/(.+)\.[A-Za-z]+','Ralph');

shawnb61

#9
Are you trying to delete the records, or just substitute the text?

If you've changed hosting company, wouldn't you like the links to point to the new host?

These don't look like download mod links, download mod links have 'action=downloads' in them, e.g.:
https://www.yadayada.com/index.php?action=downloads;sa=view;down=78
So I don't think SMFHacks can help you there.

If you're looking for methods to replace existing text, I have two utilities that might help.  Both use php bbc.  Both have a 'preview' mode that help you confirm the changes are correct before proceeding.

Replace old bbc:
https://github.com/sbulen/sjrbTools/blob/master/smf_replace_old_bbc.php

The above was intended to replace old bbc via a replace regex.  But it can actually do *any* replacement via regex - nothing is specific to bbc other than the example.

Replace URLs & Paths:
https://github.com/sbulen/sjrbTools/blob/master/smf_urls_paths.php

The above is intended to be used after host moves to completely alter all references from the old host to the new host.  It operates on all settings entries, theme entries, signatures, post content, PM content.  I use this mainly when making test copies of forums.  It will get all mods working, themes, etc.  I didn't like clicking on links & finding myself back on the production site...  It must be used *after* repair_settings.txt & the site is functioning.

I've used it in production, too, for things like my https conversion & forum merges.

Use with caution.  Pretty big shotguns.  Don't aim at your own feet.

The harder part is finding a good regex.  It's easier if you know all extensions, e.g., .zip, .tar, etc.

I use this site to test drive (php) regex, it's very helpful:
https://regex101.com/

Skhilled

Quote from: shawnb61 on Feb 01, 2026, 12:35 PMUse with caution.  Pretty big shotguns.  Don't aim at your own feet.
:rflmao :rflmao  :rflmao

Quote from: shawnb61 on Feb 01, 2026, 12:35 PMI use this site to test drive (php) regex, it's very helpful:
https://regex101.com/

Nice site! Thanks!

shawnb61

#11
If you know all the links in question are archives, and end in .zip or .gz or .tar, you can use the replace old bbc utility with something like the following.

Regex:
~http(?:s|):\/\/(?:www\.|)?filefactory\.com\/\S+(\.zip|\.tar|\.gz)~i
Replacement:
[i]Link Removed[/i]
If the links aren't all archives, it gets a bit more challenging - hard to tell text strings in the posts from URLs. Doable, but the regex is a bit more convoluted.

Dave

Hi Shawn

I'm not sure how much you know about SMFHacks mod but there is an option where linked files can be added, the following is a grab of the settings

Allow remotely linked files/pages. With this feature we are unable to determine the filesize of the file since it can be a page that links to a file as well
Quote from: shawnb61 on Feb 01, 2026, 12:35 PMAre you trying to delete the records, or just substitute the text?

I want to remove the whole url for the file host FileFactory (FF) links e.g
https://www.filefactory.com/file/othertext.zip from the database.

Quote from: shawnb61 on Feb 01, 2026, 12:35 PMIf you've changed hosting company, wouldn't you like the links to point to the new host?

The file host hosts the remotely linked files for SMFPacks Downloads mod. In my first post you'll see a sample of the database entries with the FF links in it

Quote from: shawnb61 on Feb 01, 2026, 12:35 PMThese don't look like download mod links, download mod links have 'action=downloads' in them, e.g.:
https://www.yadayada.com/index.php?action=downloads;sa=view;down=78

You are correct Shawn those are indeed similar to the links but those links lead to links in the database as above.

Quote from: shawnb61 on Feb 01, 2026, 12:35 PMIf you're looking for methods to replace existing text, I have two utilities that might help.  Both use php bbc.  Both have a 'preview' mode that help you confirm the changes are correct before proceeding.


Thank you I'll have a look at that

Replace old bbc:
https://github.com/sbulen/sjrbTools/blob/master/smf_replace_old_bbc.php

The above was intended to replace old bbc via a replace regex.  But it can actually do *any* replacement via regex - nothing is specific to bbc other than the example.

Replace URLs & Paths:
https://github.com/sbulen/sjrbTools/blob/master/smf_urls_paths.php

The above is intended to be used after host moves to completely alter all references from the old host to the new host.  It operates on all settings entries, theme entries, signatures, post content, PM content.  I use this mainly when making test copies of forums.  It will get all mods working, themes, etc.  I didn't like clicking on links & finding myself back on the production site...  It must be used *after* repair_settings.txt & the site is functioning.

Thank you I'll investigate those

I've used it in production, too, for things like my https conversion & forum merges.

Quote from: shawnb61 on Feb 01, 2026, 12:35 PMUse with caution.  Pretty big shotguns.  Don't aim at your own feet.

The harder part is finding a good regex.  It's easier if you know all extensions, e.g., .zip, .tar, etc.

I use this site to test drive (php) regex, it's very helpful:
https://regex101.com/

Thanks for the info, I always create backup before doing anything so I have that covered. The regex that Nesa posted works on the test site and I'm pretty sure it worked in Notepad++ too, but I don't know if it works with SQL query REPLACE as I couldn't get it to run without syntax errors.

Dave

Quote from: shawnb61 on Feb 01, 2026, 01:17 PMIf you know all the links in question are archives, and end in .zip or .gz or .tar, you can use the replace old bbc utility with something like the following.

Regex:
~http(?:s|):\/\/(?:www\.|)?filefactory\.com\/\S+(\.zip|\.tar|\.gz)~i
Replacement:
[i]Link Removed[/i]
If the links aren't all archives, it gets a bit more challenging - hard to tell text strings in the posts from URLs. Doable, but the regex is a bit more convoluted.


Thanks again Shawn, I will investigate that also. I will have another go tomorrow and update everyone the outcome

Neša

Quote from: Dave on Jan 31, 2026, 09:34 AMUPDATE2.
 
I ran this query in the database and although it didn't give me any errors now rows were affected

update smf_down_file set fileurl = replace(fileurl,'(https:|http:+)//www.filefactory.com\/file\/[A-Za-z0-9]+\/(.+)\.[A-Za-z]+','Ralph');
You need to use the function regexp_replace() not replace()
https://www.techgrind.io/explain/how-to-do-a-regular-expression-replace-in-mysql has an example with set column, replace will just replace that string.
It didn't find any string that is the same as the regex  :) so it returned nothing