KevinTheJedi Ohh sorry, i understood that you found the exact think which is causing the issue, I want to help as much as possible
Images Suddenly Stopped Displaying
Okay, so my issue was the result of a separate issue someone reported late last week which I do have a temporary patch for. So, in my case I had the ACL enabled for Clients (Users) and we have a bug where if you have ACL enabled for Clients it restricts the ability for Staff to see and download attachments/images as they weren't in the ACL. The below patch skips the Client ACL check if current session is an Staff:
diff --git a/include/class.validator.php b/include/class.validator.php
index 30163b8b..b46ead0e 100644
--- a/include/class.validator.php
+++ b/include/class.validator.php
@@ -367,7 +367,8 @@ class Validator {
$aclbk = $cfg->getACLBackend();
switch($backend) {
case 'client':
- if (in_array($aclbk, array(0,3)))
+ if (in_array($aclbk, array(0,3))
+ || ($aclbk == 2 && StaffAuthenticationBackend::getUser()))
return true;
break;
case 'staff':
After doing this (or disabling the ACL) it all started working flawlessly again.
Cheers.
KevinTheJedi
Interesting but we don't use ACL :/
So if i understand correctly there is maybe different issue on our site. but nice that you at least was able to fount something. As i wrote on GH i done a lot of debugging if issue was same on my site i would not be able to to get base 64 content of file in dump of class.file.php. but iam able to get content of file if i remove headers part
Then yea I simply cannot replicate your issue. I would need either some relevant debug content, some relevant logs, or some way to replicate it to further assist.
“… remove headers part” what do you mean by that?
Cheers.
KevinTheJedi in class.file.php there is function download which is used to serv the file loaded from provider, internally calls headers() (to set appropriate headers mime type, content length etc.) getContetn() function which gets content of file. if i just dump contents of file i get content of file if headers are added content is present to browser as image which is invalid for some reason. so either problem lies in headers => no error logs on server site || on site of browser unsupported mime type when used in inline image or something.
- Edited
This is where the majority of the file download headers actually get set:
Each GET for /file.php should have those headers present to tell the browser how to handle the attachment.
Cheers.
- Edited
KevinTheJedi Yes i now, this was my debug how to test if there are maybe some issues with permissions or paths, i would not get any content if they would be there Right ?
But i get the content then problem must be related with browser or headers, but don't know how to try to get more detail problem why headers/browser is not correctly read.
is there any possible path how to get Absolut path to attachment file ? (inside file below)
if yes i can try to use my different image serv function i am using in different app based on PHP which is running in same environment correctly. similar to code below
$imageFolder = realpath($imageFolder);
$imageFile = $imageFolder . $vin . '-' . $i . '.jpg';
header('Content-Type: ' . mime_content_type($imageFile));
header('Content-Length: ' . filesize($imageFile));
readfile($imageFile);
exit;
- Edited
No, you send the key and other needed information to the file.php where it looks up the file, gets the content, etc. and serves it back to the browser. Only other way would be to get the file yourself from db or from the file system.
Edit:
I think you meant from the file system. If that’s the case then of course. The files are all there by key.
Cheers.
KevinTheJedi shi*** then we are totally scrued , i don't know hat to text next or how to verify that content which is returned to browser is actually an image. If i can get you any more information's let me know i would be sad if we would need to switch off from OST it served us well for many years so far :/ and we were supper happy with it
Read my edit above. Files on filesystem are accesible directly on the server by key.
Cheers.
- Edited
KevinTheJedi they are in some random subfolders :/ how can i guess name of subfolder ?
gamerclassn7 first letter of key
KevinTheJedi i maybe found our issue, if i parse key as you specified files are not there, if i find them manually by date of creation and time they are there under different key. at least 4 which I tried to found
I'm sorry but that doesn't really make much sense. The file keys and file names on filesystem do not change after they are created. Let's say for example have a link like /file.php?key=fzadgagadsfadfads&expires=...
. The file key in this case would be fzadgagadsfadfads
which means on the filesystem there will be a file named fzadgagadsfadfads
in the f/
directory in your attachment folder. Keep in mind that IIS is case sensitive with the folder names and file names.
Cheers.
- Edited
KevinTheJedi yes that is precisely what i mean, for example i have key
but the image is stored
can be found inside directory with name 'c' which is in diffrent path for IIS right ?
I don’t understand what you are asking. What is shown in your screenshot should be the full path to the file. It’s essentially the full path to the attachment folder + the folder name (first character of key) + file key. You can find the path to the attachment folder from within the plugin settings.
Cheers.
KevinTheJedi sorry, i will try to make it clear attachment is not in same path which is resolved from database instead of big C in folder name there is small c on filesystem could this be the problem ?
It all depends on what the key from the db is and the IIS setup. Not all setups are the same so yours could very well not be case sensitive. I just know the majority of IIS setups that I’ve dealt with are. Anyways, the key from the db is always the correct casing. So whatever the first character of the key in the db is should be the folder it’s stored in.
Cheers.
KevinTheJedi Hi, I was able to get it working again by starting from scratch (even WM) initializing new server not just DB an reinstalling server how ever after 12 days same error appeared again.
Any idea what can be tried next ?