Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: fishoaus on August 31, 2021, 07:28:23 AM

Title: Re: Decrypt attachment files
Post by: fishoaus on August 31, 2021, 07:28:23 AM
how do i de decrypt images have been stuck for ages after up grade months back wonder if my forum attachments are bugged only show up as save then open image, no image as thumbnails view now, would this work help

https://www.simplemachines.org/community/index.php?topic=367382.0
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 05, 2021, 06:03:02 AM
Quote from: fishoaus on August 31, 2021, 07:28:23 AMhow do i de decrypt images have been stuck for ages after up grade months back wonder if my forum attachments are bugged only show up as save then open image, no image as thumbnails view now, would this work help

https://www.simplemachines.org/community/index.php?topic=367382.0

looks like i"ll have to wipe my forum & start again, as i can't figure it out
Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 05, 2021, 07:29:10 AM
Whoa, hold on there before you go starting over.

What, exactly, is your situation? You have some attachments - do you have the database for those attachments? Did you move the files between servers at some point?

It also might have helped if you'd made your own topic...
Title: Re: Re: Decrypt attachment files
Post by: Aleksi "Lex" Kilpinen on September 05, 2021, 09:43:50 AM
Split from https://www.simplemachines.org/community/index.php?topic=296786.0
The original topic is from over a decade ago.
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 05, 2021, 11:43:38 PM
Attachments aren't encrypted, file names are hashed.  It's not too difficult to restore original file names, but attachments won't work if you do.  That's not your problem.

Title: Re: Re: Decrypt attachment files
Post by: shawnb61 on September 06, 2021, 01:01:21 AM
I suspect you need to doublecheck your attachments configuration.  Repair_settings.php may help.

Check all attachments settings, folders, etc.  Confirm you still have the rows in your attachments table.  If the files are still there, and the rows are in the attachments table, you can likely still recover.


If OTOH you really just want to recover the files, you need some way to rename them back.  I've done this before, instructions here:
https://www.simplemachines.org/community/index.php?msg=3927825
Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 06, 2021, 02:47:54 AM
This is why I'm asking if the OP moved files... say with FileZilla :(
Title: Re: Decrypt attachment files
Post by: fishoaus on September 06, 2021, 04:49:34 AM
i had forum up graded by some one else, can see attachments but only by saving not by thumb nails, Had a few extra mods installed & can save them all by ftping back to my computer no viewing on my pc, only view from forum is by click on paper clip open with my default image software if that makes sense
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 06, 2021, 04:58:49 AM
Quote from: Arantor on September 05, 2021, 07:29:10 AMWhoa, hold on there before you go starting over.

What, exactly, is your situation? You have some attachments - do you have the database for those attachments? Did you move the files between servers at some point?

It also might have helped if you'd made your own topic...

No not moved between servers just different portal, media gallery i just had to up grade as my forum was way out dated, i just bugged it up from start i say, then had some one else try pic up the pieces, say images not moved or saved properly not sure, yes still have data base forum is still running
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 06, 2021, 08:31:17 AM
Quote from: Arantor on September 06, 2021, 02:47:54 AMThis is why I'm asking if the OP moved files... say with FileZilla :(


i did use filezilla, you have helped me before at dezinerstudio many years ago adding code to new balance, i also use to use your media gallery before i up graded
Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 06, 2021, 09:48:23 AM
That's kind of what I'm wondering about: FileZilla can and does damage file attachments in SMF if not explicitly configured not to. :(
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 06, 2021, 12:34:12 PM
If the images are viewable by any means (apparently they are), they haven't been damaged by FZ ascii d/l, which corrupts the files and makes them unuseable.
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 07, 2021, 08:07:42 AM
Quote from: shawnb61 on September 06, 2021, 01:01:21 AMI suspect you need to doublecheck your attachments configuration.  Repair_settings.php may help.

Check all attachments settings, folders, etc.  Confirm you still have the rows in your attachments table.  If the files are still there, and the rows are in the attachments table, you can likely still recover.


If OTOH you really just want to recover the files, you need some way to rename them back.  I've done this before, instructions here:
https://www.simplemachines.org/community/index.php?msg=3927825

I am not sure how to do this But images are still all there & i have downloaded them in binary can view a lot of them on pc & in forum but only shows the paper clip on forum , open with my default image viewer same on pc right click open with
Title: Re: Re: Decrypt attachment files
Post by: shadav on September 07, 2021, 09:09:34 AM
ok so attachments work, images are fine it's just they aren't being displayed in the post
sounds to me more like your theme's display.template.php or in your sources folder the display.php is messed up
what version of smf is this
what theme are you using
does this do this with the default theme
what mods do you have installed

also
in your admin under forum then under Attachments and Avatars and then attachment settings
is this box checkmarked?
Display image attachments as pictures under post
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 07, 2021, 06:12:59 PM
Do all attachments fail to load?  Can you attach pics successfully to new posts?
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 08, 2021, 07:51:54 AM
Quote from: Sir Osis of Liver on September 07, 2021, 06:12:59 PMDo all attachments fail to load?  Can you attach pics successfully to new posts?

yes can attach  but fail to display image, only paper clip to open with default image viewer
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 08, 2021, 07:58:42 AM
forum is breamalliance .com
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 08, 2021, 08:20:01 AM
Quote from: shadav on September 07, 2021, 09:09:34 AMok so attachments work, images are fine it's just they aren't being displayed in the post
sounds to me more like your theme's display.template.php or in your sources folder the display.php is messed up
what version of smf is this
what theme are you using
does this do this with the default theme
what mods do you have installed

also
in your admin under forum then under Attachments and Avatars and then attachment settings
is this box checkmarked?
Display image attachments as pictures under post

yes images attachments  box checked &  avatars, yes display  image attachments as pictures under posts checked

smf 2.0.18 theme dzinersutdio theme newbalance old as now, default theme does same no display images


mods

1.    Simple Audio Video Embedder    6.0.4    August 31, 2021, 08:59:55 PM.   
2.    TinyPortal    2.1.0    August 30, 2021, 10:06:56 PM.   
3.    Contact Page    5.0.1a    May 20, 2021, 08:40:17 PM.   
4.    Sortable Packages (and Installed Time)    1.3.5    May 19, 2021, 02:51:13 AM.   
5.    Levertine Gallery    1.1.1    April 30, 2021, 09:23:32 PM.
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 08, 2021, 12:25:47 PM
Looking at your pic test post, link to attachment is correct, download works, image file is fine.  What's not working is 'Display image attachments as pictures under post' setting.  If it actually is checked, then you probably have a mod problem.  Only one I don't recognize is Levertine Gallery, you can try uninstalling that.
Title: Re: Re: Decrypt attachment files
Post by: Aleksi "Lex" Kilpinen on September 08, 2021, 01:18:38 PM
I don't think Levertine really does anything about attachments in posts, so that one seems unlikely. Though it does add a lot of permissions handling regarding the gallery.
Title: Re: Re: Decrypt attachment files
Post by: shadav on September 08, 2021, 01:41:12 PM
can you upload your
theme's display.template.php and in your sources folder the display.php
as attachments
if your theme doesn't have the display.template.php then it uses the one in the default folder
just to compare them with default files and see if there might be something wrong there
but yeah nothing that you posted of the mods above should have messed anything up

with so few mods I'd say just download fresh files of 2.0.18 and upload them overwriting your current files and then reinstall themes and mods
however the themes you use I'm fairly sure are not found anymore and well are outdated
Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 08, 2021, 02:26:38 PM
Quote from: Aleksi "Lex" Kilpinen on September 08, 2021, 01:18:38 PMI don't think Levertine really does anything about attachments in posts, so that one seems unlikely. Though it does add a lot of permissions handling regarding the gallery.

Correct, it does nothing to this at all.
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 08, 2021, 10:01:17 PM
Haven't had any problems with DS themes in 2.0.18.  Don't have newbalance, that may have been a paid theme.  But do as shadav suggested -

https://wiki.simplemachines.org/smf/How_to_upload_a_fresh_set_of_files

Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 09, 2021, 04:29:45 AM
Yes, newBalance was a paid theme.
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 11, 2021, 06:18:30 AM
 Levertine Gallery 1.1.1, was made by a a well known smf legend, but i am not sure if there real active in doing stuff on here now,
 
Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 11, 2021, 06:48:27 AM
I'm not developing the gallery. I haven't in years.
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 11, 2021, 07:07:04 AM
Quote from: Arantor on September 09, 2021, 04:29:45 AMYes, newBalance was a paid theme.

yes i did pay for it many years ago, when dzinerstudio was active, you even helped me with the code to put ads under nav menu in newbalance may still have your code some where  so it could of change ads after a time frame some where i had a different user name on there the owner  wife desinged new post no neww post avatars for me as well
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 11, 2021, 07:21:48 AM
ok will do as others suggested
Title: Re: Decrypt attachment files
Post by: fishoaus on September 11, 2021, 07:59:52 AM
Please see attachments



Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 17, 2021, 08:24:28 AM
I still have no luck would you call this forum a ride off with attachments, images & start again?????
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 17, 2021, 12:59:00 PM
Have you tried uploading clean files?  If you can pm cpanel access I'll have a look tonight.
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on September 23, 2021, 01:31:38 AM
Quote from: Sir Osis of Liver on September 17, 2021, 12:59:00 PMHave you tried uploading clean files?  If you can pm cpanel access I'll have a look tonight.

Have PM,ed access
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 23, 2021, 06:07:10 PM
Will have a look.
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 25, 2021, 12:51:21 AM
This is a strange one.  Attachment settings are correct, pics can be d/l'd from link under post and displayed in image editor.  Database setting can be toggled on/off as per normal.  Have a clean 2.0.18 install running in subdir, imported prod database, old attachments aren't displayed, new ones display correctly.  If I d/l image from prod forum that is not displayed, it doesn't display on test forum until it's opened in image editor and saved, it then displays correctly on test forum, not prod forum.  Looks like a mod is affecting the files. 

Installed mods:
  Simple Audio Video Embedder 6.0.4
  TinyPortal 2.1.0
  Contact Page 5.0.1a
  Sortable Packages (and Installed Time) 1.3.5
  Levertine Gallery 1.1.1

AEVA was installed at one time, iirc it was problematic and removed from mod site, wondering if there may be some remnant code that's damaging uploads.  Next thing to do is clean install on prod forum, but there'a a lot of custom work on prod theme.  Main concern is if attachments are damaged, is there any way to fix 460 files in bulk. 

I'm beat, will get back to this tomorrow night.  If anyone has any ideas, would be appreciated.
Title: Re: Re: Decrypt attachment files
Post by: shadav on September 25, 2021, 01:25:12 AM
I have all of those mods installed without said issue, except for levertine gallery though I doubt that would be the cause and I never used aeva but maybe it caused issues

if opening and saving the files seems to work, maybe use an image optimizer and see if that does the trick
you can use this one for bulk uploads
kraken.io/web-interface
Title: Re: Re: Decrypt attachment files
Post by: Arantor on September 25, 2021, 05:29:34 AM
AEVA never touched the attachments system.
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 26, 2021, 01:12:06 AM
Sadly, my Logitech solar keyboard seems to have died since last night.  Can't do much with this onscreen keyboard, will have to look through my vast collection of computer stuff and see if I can find a keyboard that works with this computer.

<sigh>
Title: Re: Decrypt attachment files
Post by: Sir Osis of Liver on September 26, 2021, 01:38:02 AM
 :)  It's come back to life, just needed a little light.

Ok, here's what's happening tonight.  Attach a clean image to a post (bushwick.jpg), it displays the link, no image.  When I click on the link I can d/l the image, it displays normally in image editor (bushwick2.jpg).  Attach it to post in test forum, no go.  Save it in editor as bushwick3.jpg, it attaches and displays normally in test forum, not prod forum.  Let's see what it does here.

As you can see, the image that was uploaded/downloaded to/from prod forum (bushwick2.jpg) does not display here, either.  It works after it's been d/l'd and saved in image editor (bushwick3.jpg).  bushwick2.jpg loads normally in editor, but forum can't display it.

Title: Re: Decrypt attachment files
Post by: fishoaus on October 06, 2021, 11:24:20 PM
i"ll down a few images open in editor then re save then up load  to my forum for a test from me
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on October 07, 2021, 06:12:39 PM
FYI anyone following this topic, attachment glitch was caused by code in index.template.php that OP used to add his own copyright to footer -


function template_body_below()
{
    global $context, $settings, $options, $scripturl, $txt, $modSettings;

            echo '
                </div>
            </div>';

        // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
        echo '
            <div id="footer">
                <ul class="reset">
                    </li>              
                    <li>', theme_copyright(), '</li>
                                                                                <li class="copyright "><strong><style scoped>
.blackText {color:black;}
</style>
<p class="blackText">© 2021 BREAMALLIANCE.COM</p>
</div>
</p>
<a> </ul>
                </ul>';

                // Show the load time?
                if ($context['show_load_time'])
                echo '
                    <p>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>';
        echo '
            </div>
        </div>
    </div>
</div>';
}


Replaced it with this, solved the problem -


function template_body_below()
{
    global $context, $settings, $options, $scripturl, $txt, $modSettings;

            echo '
                </div>
            </div>';

        // Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
        echo '
            <div id="footer">
                <ul class="reset">
                    <li>', theme_copyright(), '</li>
                    <li style="color: black; font-weight: bold;">&copy; 2021 BREAMALLIANCE.COM</li>
                </ul>';

                // Show the load time?
                if ($context['show_load_time'])
                echo '
                    <p>', $txt['page_created'], $context['load_time'], $txt['seconds_with'], $context['load_queries'], $txt['queries'], '</p>';

        echo '
            </div>
        </div>
    </div>
</div>';
}


Don't have remotest clue why original code was damaging attachments. (https://www.thekrashsite.com/pics/idk.gif)
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on October 08, 2021, 04:48:00 AM
Sir Osis of Liver, thank you for fixing my forum, I would of never worked out such a small edit would do that, if you lived close I would shout you a beer or 3, thank you again for that!
Title: Re: Re: Decrypt attachment files
Post by: Shambles on October 08, 2021, 05:27:02 AM
Quote from: fishoaus... I would shout you a beer or 3 ...

Many people do, hence the name "Sir Osis of Liver"  8)
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on October 08, 2021, 12:45:37 PM
Did someone mention beer? (https://www.thekrashsite.com/pics/eek.gif)

             (http://www.thekrashsite.com/pics/beerfund.png) (http://www.thekrashsite.com/donate.htm)
Title: Re: Re: Decrypt attachment files
Post by: shawnb61 on October 08, 2021, 02:51:33 PM
Quote from: Sir Osis of Liver on October 07, 2021, 06:12:39 PMDon't have remotest clue why original code was damaging attachments. (https://www.thekrashsite.com/pics/idk.gif)

This sounds very similar to some earlier issues, in which stray whitespace characters were getting added to the bottom of attachments, corrupting them...  This was in turn caused by stray whitespace in the source code that had been added inadvertently.

One old example:
https://www.simplemachines.org/community/index.php?msg=3938086
Title: Re: Re: Decrypt attachment files
Post by: Sir Osis of Liver on October 08, 2021, 10:23:14 PM
But why would anything in index template affect file uploads, it's strictly presentation?  Did a hex dump on bad file, completely different from original file, but no whitespace up top.  And it loads normally in image editor.  If you look at attachments to my previous post, all the same image but second one was attached to post on OP's forum and d/led from attachment link.  It's normal in editor but won't display on his forum or here.
Title: Re: Re: Decrypt attachment files
Post by: fishoaus on October 14, 2021, 09:04:06 AM
if you can get a australian beer & like a dry beer if you can get it?, lol try tooheys extra dry top drop ;-)