PDA

View Full Version : 5000 entries in db for same file


webmaster74
08-25-2016, 12:36 PM
Checking on my vbulletin 4 forums, I came across tens of ablums with 100% broken links to their uploaded images.

Looking in the attachment table, I found about 5000 entries all referring to the same file. Looking closely, the file is named keyword1_keyword2_keyword3_keyword4_keyword5_keywo rd6_keyword7_keyword8_keyword9_keyword10_keyw_.jpg

OK I got it. A few years ago, I created some nice designs and pushed the SEO a bit too much by naming the files in the above way.

I don't have those designs as I was very short on space on my SSD. After uploading them as attachments, I deleted them from my pc. They then looked fine...

Now, the attachments are fine in their proper places as /n/n/filedataid.attach

Can I fix this by renaming the files in the DB? I am good at manipulating data in Excel and re-uploading with a replace order to the DB.

it would be a real pitty to have to delete 5000 files and re-create and re-upload.

--------------- Added 1472153849 at 1472153849 ---------------

This should not be very difficult to do as the files are not encrypted or modified except that they are renamed to filedataid.attach

I tried simply renaming one of them to filedataid.attach.jpg and I could easily open it as a jpg.

I know for a fact all of those files in question were jpg...

I was thinking I am able to write a replace / update statement such as

update attachment where filedataid=nnnnn set filename=new_short_name_filedataid.jpg

RichieBoy67
08-25-2016, 10:56 PM
Can you share a link to your site? I'm very confused. You said it's fine?

webmaster74
08-26-2016, 12:26 AM
Can you share a link to your site? I'm very confused. You said it's fine?

I said the attachments are fine in their places, that is they are indeed where you expect them to be ... in the attachments folder. However, they do not show up at all on the website....

Dave
08-26-2016, 12:58 AM
So it's incorrectly stored in the database? Can you show us an example of what it looks like in the database and what it's supposed to look like?

webmaster74
08-26-2016, 01:01 AM
So it's incorrectly stored in the database? Can you show us an example of what it looks like in the database and what it's supposed to look like?

Hi Dave.

I have about 5000 entries in the attachment table with this under filename

keyword1_keyword2_keyword3_keyword4_keyword5_keywo rd6_keyword7_keyword8_keyword9 _keyword10_keyw_.jpg

Of course originally the entries were like

keyword1_keyword2_keyword3_keyword4_keyword5_keywo rd6_keyword7_keyword8_keyword9 _keyword10_keyword11_some_serial_number.jpg


Of course I can mass modify the entries in the mysql db... but how do those tie back with the attachments ?

Dave
08-26-2016, 01:06 AM
If I recall correctly, there's no strict check against the filename column in the attachment table. What matters the most is that the attachmentid exists in the attachment table.

Browsing to /attachment.php?attachmentid=XX where XX is a valid attachmentid in your table does not download/load the attachment?

webmaster74
08-26-2016, 01:20 AM
If I recall correctly, there's no strict check against the filename column in the attachment table. What matters the most is that the attachmentid exists in the attachment table.

Browsing to /attachment.php?attachmentid=XX where XX is a valid attachmentid in your table does not download/load the attachment?

thank you for this.

On the website, the source of the images in the album is something like this:
http://domain.com/forum/attachment.php?attachmentid=20027&d=1426709651


and those do not lead to an image... they are broken links.

--------------- Added 1472182313 at 1472182313 ---------------

If I recall correctly, there's no strict check against the filename column in the attachment table. What matters the most is that the attachmentid exists in the attachment table.

Browsing to /attachment.php?attachmentid=XX where XX is a valid attachmentid in your table does not download/load the attachment?

I apologize.... I most humbly say I am sorry....

I now recalled, thanks to you, that after the migration to a new server I did NOT update the path to the vbattachments folder.

So sorry. Fixed now.

Dave
08-26-2016, 01:35 AM
But does the attachmentid 20027 exist in the attachment table?
If so, it's probably not passing a bunch of checks that are coded in /packages/vbforum/attach/album.php or /packages/vbforum/attach/post.php (look for function verify_attachment) Based on those checks, you can see what's wrong and causing the attachment to "break".

Edit: guess you figured it out. :)

webmaster74
08-26-2016, 03:20 AM
Edit: guess you figured it out. :)

You did, when you mentioned that the filename does not matter.... you logically lead me to conclude that if the files are available in their folder, then ... it is the path to them that is broken!

thank you much