The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
|
#1
|
|||
|
|||
Manually Moving Images/Attachments in VB 4.0.6
I'm stuck at the moment and maybe someone can point me in the right direction. I have a large number of users to migrate from another system to vB. Only problem is that we used a different image gallery for attachments. Everything is 100% images so no docs or other files types.
So, here's what I did as a test run. I set up an album using the vB. I uploaded a few photos. Everything works fine. I have my settings to store on the filesystem so I can go in and look at the images. Then I went into filedata and created an entry for the attach and thumb images I was going to move over. I used that to create entries in the attachment and attachementcategoryuser tables. For most of the stuff I just used the same settings that were in all of my other uploads. Obviously filename, sizes, hashes, etc. I made specific to the imported test files. Lastly, I updated the album table to reflect the added pic in "visible". Then I moved the two files into the /attachements/1 and changed them to 45.attach and 45.thumb (these correspond to the attachmentid in attachment). When I go to my album I see a broken image. I experimented around a bit with renaming some of the filenames and when I rename an image that was working to 45.attach and 45.thumb they don't work. But I can take the files that I imported manually and rename them 37.attach and 37.thumb and the manually uploaded files show up. I've checked all the permissions and such and can't find a reason why they're not showing up. Anything I'm missing here? Is there another table that needs modified? Or even if anybody knows which exact file has the call to create these database fields when a new file is uploaded. I can't seem to find any of the inserts. Edit: I should say in the filedata set, I didn't create two records. But it asks for information about both the original and the thumb in that table so I described it that way to make it clearer that I filled in all of the information. Funny how trying to be more clear you make yourself less clear :-) --------------- Added [DATE]1285050715[/DATE] at [TIME]1285050715[/TIME] --------------- I didn't get a response :-( so I ended up figuring it out on my own and thought I would share in case anybody else has to do something like this. How to import external images as attachments into vB 4.0.x First, get the basic information about the file. Get the height, width, file size of both the thumbnail and the original pic. You will also need the md5 hash value of the original. In PHP that's rather easy: PHP Code:
PHP Code:
Once you have that data about your file you're going to need to update the filedata table to tell vB about the new file. The fields in filedata are: filedataid = auto incremented so you can leave blank userid = the userid of the album owner dateline = unix timestamp thumbnail_dateline = you can either use the same value as dateline or get the actual unix timestamp value for the file. I don't think it matters since I don't believe there is any check against last modified timestamp. filedata = BLOB data type. I believe this is where the actual image data is stored IF the files are stored in the db. If you're storing to the filesystem of your computer this will have no value. filesize = file size of your main file. you can get this by doing "ls -la" (Linux/Unix) on the file. filehash = the file hash value you got with the md5 routine above thumbnail = I believe this is just like the filedata field. if you were storing this in the database this is where they would store the thumbnail. again, just leave it empty. thumbnail_filesize = file size of the thumbnail. see filesize above. extension = this is the original format of your file. since vB will be storing your file like 45.attach rather than 45.attach.jpg you have to tell vB what format headers to send back to the browser so it can be rendered properly. Fortunately for me, all of mine are jpg refcount = not sure what it is but set it to 1 (that's what all my other attachments are set to) width = the width of your main image height = the height of your main image thumbnail_width = self explanatory thumbnail_height = self explanatory Once you've updated the table you need the filedataid which was auto incremented when you created the entry in the database. Let's say for example it's 49. You will use that in other references in the database and this will be the filename you assign your files. For example: 49.attach 49.thumb Next you go to the table attachmentcategoryuser and create a record there filedataid = the filedata id we just got from the previous table insert userid = the userid of the album/picture owner categoryid = not sure what this is but everything in my database, including the images that came preloaded as sample data is set to 0 so that seems to be a pretty safe value to put there. filename = I'm not sure if this is important because you lose the filename when you rename the files anyway. But I just use the original name of the image that I'm importing to be on the safe side. dateline = unix timestamp. I just use the same unix timestamp across all of the dateline entries assuming that if this were a program executing that it could make three table inserts in under 1 second. Next you need to update attachment attachmentid = this is an auto incremented value. The mistake I made and was asking about in my OP was that I thought this was the value I needed to change my image to. It's not. contenttypeid = not totally sure what this value is but everything in my albums is set to 8. So I set it to 8 contentid = this seems to to be the album ID. whatever album you're inserting into this should be the album id of that album. userid = user id of the owner of the pic dateline = self explanatory filedataid = this is your filedataid that you got from inserting the record into filedata state = set to visible if you want the image to appear in the album. counter = set to 0 posthash = none of my profile pics has a value so I just leave this blank. filename = same as the insert into attachmentcategoryuser caption = you can set the caption for the photo here. i usually leave blank because there was no caption capability in the system I was importing from. reportthreadid = not sure what this is but everything in my db is set to 0 so 0 seems like a safe value settings = again, not sure what it is but everything in my db is set to NULL so setting it to NULL seems like a safe way to go. displayorder = yet again, not sure what this does but everything in my db is set to 0 . . . Now, go and rename your files to the filedataid. 49.attach and 49.thumb and they should appear in the album for that user. WARNING!!! As I've indicated in my comments above, I don't 100% understand how vB does the attachments. Through trial and error, checking out various parts of the vB code, etc I found a solution that allowed me to do what I wanted. It would be nice if this was somehow documented somewhere but it's not. I'm simply sharing what worked for me since I spent several hours banging my head against a wall trying to find a solution. That being said, I take no responsibility and am not supporting this in any way. I have 65,000 users to import into vB and several hundred thousand pictures from my legacy site. If I notice that any of my above information is incorrect I will update it. But I'm probably about a month or two away from my final import so . . . use at your own risk. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|