Closed jibsaramnim closed 1 year ago
I realized after submitting these three PRs that as even though I separately submitted them, the later PRs also include all changes made in the former PRs. That's less ideal, I had hoped things would've stayed as separately merge-able PRs.
So this PR includes what's separately listed out in #19 and #20, and I've closed those PRs in favor of just having one PR to review for you all.
Apologies again for creating a bit of a confusing set of PRs here, I should've double checked before creating all these PRs what was going to happen. I hope the clean-up I did after made things clear enough!
This PR adds a mimetype check (using a
HEAD
request before the actualfile_get_contents
is called). If the mimetype the server responds with is in the$compatible_content_types
array, theread.php
code will continue as it always did.If the mimetype returned isn't in this allowed array, or if the server does not return any mimetype at all,
read.php
will instead try to proxy the linked file directly through to the end-user, so long as it's reported filesize isn't larger than what is specified in$proxy_download_max_filesize
(Currently set to about 8Mb).It will try to use the original filename as discovered in the URL, but if that fails it should simply be called
download
, without a file extension. TheContent-Disposition
is also set toattachment
to encourage the browser to download the file, rather than show it in-line, but it's been a long time since I last looked in detail into what the older browsers might think of this, so if this is causing any issues we might want to change that bit.There's a few assumptions put in place here that might need tweaking, like the allowed filesize limit and which content-types are considered OK for the usual article parsing to proceed. Right now the code switches over to "download mode" if the server does not return a known content type, but it might make sense in that case to still try to do the usual article processing method.
Happy to take any and all feedback you may have for this PR. You can also directly edit whatever you want if you're a maintainer of this project already. It's been quite a few years since I last wrote PHP, so I apologize in advance if I made any oopsies.
In addition, this includes some minor cleanup to make it a bit easier for future contributors to know which bits they can focus on. Most of these are related to removing of bits and pieces that presumably were left-over after things were initially copied/forked from the 86k.news project.
image_compressed.php
.php/
directory as its contents aren't used by FrogFindchoose_edition.php
file$loc
variables as it is not used by FrogFind.DS_Store
to.gitignore
(superseding #15)