Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Can you add PHPBB attachment support to Vanilla Porter? (I'll pay you)



  • x00x00 MVP
    edited May 2013

    say if you rename 1996_ddf13163c0ebb022a4c246ab8b11eb57

    1704231_original.jpg and point to it does that work?

    grep is your friend.

  • No, it doesn't work. Link is correctly pointing to 1996_ddf13163c0ebb022a4c246ab8b11eb57, the file is there, but is not displayed.

    It's interesting that Firefox sees it as a text file and Chrome tries to display it as an image (well, sort of), but saves it as a .txt. I have no clue what's going on.

    Here's a few screenshots to get the idea.

  • Several things.

    1 - if you create a comment and upload a new jpg file does it work correctly, when you try to download it.

    2 - when you hover over the thumbnail of the imported images what does it show


    3) can you create less blurry image of screen_chrome3.jpg?

    4) how did you transfer the images from one computer to another - did you use binary transfer? what os are you using for the server. Can you print a screenshot of the details listing sizes and filenames in the upload directory showing some of the jpg file names.

    5) Did you retry copying the files over to the uploads directory?

    6) do you you have a link to your test web site?

    7) when you run a "file command on the files in the fileupload directory does it show the correct file type.

    8) a few of the examples you have seem to be suspiciously small jpg files?

    9) are there any size restrictions for the jpgs, etc that may be causing the problems?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine you made a serious breakthrough! :D But it's not over yet...

    First, your answers:

    1) Yes, this works as it should.

    2) If the only difference between these two is file extension, then answer B - it shows without extension.

    3) Of course, I just masked unimportant or private information

    4) Here's the catch. I had "Auto" set in Filezilla, which was obviously wrong. Server is Debian. I just deleted whole FileUpload directory, because I see I have to re-upload all files anyway. I'm sending screen from the original PhpBB Files directory. It doesn't include any .jpg files, just long names of random strings without extension.

    5) I have, but apparently wrong. I'm re-uploading right now, it'll take some time.

    6) Of course, I'll send you in a message.

    7) I'm not sure what you mean. "Run a file command..."? These attachments have no extension and as far as I know no specific file type. At least Vanilla doesn't seem to know what to do with them.

    8) I chose a post with small attachments on purpose, just for faster testing. Files are ok, most of them are few hundred kb.

    9) No, that's not the issue.

    So, at least (large) part of the problem was obviously ftp transfer mode. I had Filezilla set to Auto, which never gave me a problem, so far. Because these files must look like text inside, I guess Filezilla decided to copy them ascii way. So I changed it to binary and tried a few files, and it works ... almost.

    Problem 1: while actual attachments look ok if you click on them in Chrome, but there's no thumbnails in any browser. I don't know if thumbnails are actually different files or they're made on the fly. I'll wait to see when all files are re-uploaded.

    Problem 2: Only Chrome opens them as images, FF and IE still open them as txt files.

  • peregrineperegrine MVP
    edited May 2013

    well you are making progress....

    it appears the browsers determine things differently - one read the file type and the other determines it by extension.

    if you can get command access to the file names - I think you need to put extensions on them. and things will work better.

    unix and linux boxes usually show file extension and windows depending on settings will not show settings.

    you could try this on your machine and see what file types are what and add appropriate extension suffix e.g. jpg, png whatever.

    caveat - I have never imported - just suggesting what I would do to solve problem.

    you could cut and paste this into a program called file.php and see if you can execute system commands on your server, or do it locally and add extensions accordingly basrd on results.

    echo '<pre>';
    // Outputs all the result of shellcommand "file", and returns
    // the last output line into $last_line. Stores the return value
    // of the shell command in $retval.
    $last_line = system('file *', $retval);
    // Printing additional info
    echo '
    <hr />Last line of the output: ' . $last_line . '
    <hr />Return value: ' . $retval;

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • this may also help - the thumbnails for the uploads are in

    e.g. sample


    the info is stored in media table in vanilla

    the name in media - is the name that shows in icon.
    the path points to the fullsize image
    the the thumbnail reference above points to the thumbnail of the uploaded file.

    I would think extensions in the media database in the type column that is same as file and thumbnail would give you the optimal results.

    e.g. in the table

    name - samplephoto.png
    type - png
    path - /FileUpload/39/68fac13c460faa5ce5feccef6dcc1f.png

    on the file system the names for the samplephoto.png would be

    • the thumbnail of the samplephoto.png that was created and that you see you before you click....

    • the actual samplephoto.png that was given a new name.

    probably the based I can do. But it should give you an idea.

    you could change one item in the media table to add an extension and change corresponding files (as long as you know the discussions where it is located - which you can do with webdeveloper tools) and using phpmyadmin.

    if it fixes your problem and you will then know how to proceed. - that extensions (suffixes .jpg or .png etc are the answer to your dillemma.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • x00x00 MVP
    edited May 2013

    a the old ftp'n as ascii.

    have you tried clearing cache in your browser too?

    grep is your friend.

  • tom762tom762 New
    edited May 2013

    Ahhhh, now I think I got it. :)

    You gave me some great starting points. The thing is that I know exactly which file is which type. Even better - I have all sorted really nice in the export dump file, easily exportable to csv. I'm just not sure how to rename all files. Do those ancient .bat files still work?

    I also found out how to get thumbnails! :D

    All imported attachments have "ImageWidth" and "ImageHeight" fields in the media table filled with NULL, while native Vanilla attachments have true size of their dimensions. What I found out is that if you enter some small value here (1 or 100 also works), the attachment is inserted into post in its full size, but if you enter some larger number (200 works, 1000 is safer, probably has to be larger than thumbnail height), thumbnail is created. :D

    Cool huh?

    So I'll have to semi-manually edit the final export dump file and import it with these changes and everything should be fine... hopefully.

    I can't thank you enough guys, you're 8! (pronounced awesome in my language)

  • peregrineperegrine MVP
    edited May 2013

    I'm just not sure how to rename all files. Do those ancient .bat files still work?

    I suspect batch files still work depending on version of windows.

    If you download ubuntu to a partition on your local hard drive

    you can run any number of shell scripts or awk, sed, perl, etc.

    if your host provider lets you - you could do it in perl or a combination of find, file and mv in shell script.

    just google rename file based on file type and you will see numerous variations of code that could get you on your way to a bit more automation.

    for php

    you could read filenames from a list
    test file type - determined from magic sig inside file
    and mv the file to the proper name.

    wouldn't be too hard.

    depending on window version if you have windows version you could download cygwin unix utilities and cobble together a script.

    this looked good

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I just made a test with .bat renaming and it works as in good ol' DOS days. ;)

    I already use kubuntu, but am more familiar with Win, so batch will be just fine. That and a bit of Excel and Notepad++ does the job. I think I'll have no major problems from here.

    Now that we know how it works, maybe an update to Porter or some forum transfer script would be nice. :)

    I consider this case solved. Yay...

  • meshugymeshugy Musician/Hacker ✭✭
    edited December 2013

    I had a more serious version of this same problem. I had several thousand phpbb attachments with names that were converted into a hash and no extension. I was able to import them into Vanilla by first:

    Using Trid to detect the file types of all the files without extensions and automatically add the correct extension (I had over 20 different file types to import!)

    Then I performed this query for each of the file types which added the correct extension in the database:

    UPDATE `GDN_Media` SET `Path`=CONCAT(`Path`,".jpg") WHERE `Type` = '"image/jpeg"' AND `MediaID` > 2809

    Now all the phpbb attachments work in Vanilla!

  • LincLinc Detroit Admin

    I actually have a script that renames phpBB files with proper extensions. It isn't in Porter because it's a little hacky in that you need to define the file path manually and run it separately from Porter, which is why I left it out. I'll make a little utility folder or something for the next release until I have time to make it prettier.

  • meshugymeshugy Musician/Hacker ✭✭

    @Lincoln said:
    I actually have a script that renames phpBB files with proper extensions.

    Wow, I wish I had known about that! I lost about 10 hours of my life trying to figure this out. Glad it's available as this will be a problem for anyone importing from PHPBB.

  • LincLinc Detroit Admin

    I know, I apologize. It was dumb to keep it private, I was hung up on making it prettier first. Anyway, 1.9.0 is out with a bunch of fixes and this is in the GitHub repo under 'utilities'.

Sign In or Register to comment.