News:

Wondering if this will always be free?  See why free is better.

Main Menu

Image Proxy Issue?

Started by MobileCS, January 14, 2018, 10:15:17 PM

Previous topic - Next topic

MobileCS

When an image is first posted (via tinypic, etc), why does it produce a 404 error when "image proxy" is enabled?

It shows fine on second page load, but users are thinking there is an issue with their image.

Also, in the admin settings it shows : Maximum file size of images to cache (Images above this threshold are still shown). That is not happening, anything above the threshold throws a 404 error - and stays that way ... regardless how many times you refresh the page.

Is this a bug?

I was able to reproduce my first issue in your test board.

Sir Osis of Liver

It happens here, just posted an image, had to refresh preview to see it.  The image is resized.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

MobileCS

Yes, it happening here as well. I believe this is a bug.

If I'm not mistaken - when you first post an image, the proxy.php file should cache the image and show it right away (not require an additional page load).

This code doesn't make any sense to me :

$response = $this->checkRequest();
if (!$response) {
// Throw a 404
header('HTTP/1.0 404 Not Found');
exit;
}
// Right, image not cached? Simply redirect, then.
if (!$response) {
header('Location: ' . $request, false, 301);
}


If there is no response, it will always 404 error - it will never reach the redirect.

Sir Osis of Liver

Just tried it on 2.0.15 test install (http).  Image displays normally with image proxy disabled, won't display at all with proxy enabled, refresh is no help.  It displays normally as attachment, but not in img tags.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

MobileCS

Removing the lines below in proxy.php fixed the issues for me :

if (!$response) {
// Throw a 404
header('HTTP/1.0 404 Not Found');
exit;
}


The image now shows up right away when posting. Also, I no longer see broken images (404) on first page load on older threads (they appear immediately now).

Also, any image exceeding "max size" no longer 404 errors and gets displayed.

With that said, I do not know if this is a proper fix. Use at your own risk until a developer confirms everything is ok with this method.


MobileCS

I'm already using v2.0.15 and that fix was included in it. This is something different.

Shambles

Quote
I'm already using v2.0.15 and that fix was included in it.

No it was not. Did actually check it?

The 2.0.15 download/patch includes this in proxy.php:

Code (Bugged Proxy) Select
return file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
))) === false ? 1 : null;;


What it should be (as confirmed by the developers) is:

Code (Working Code) Select
return (file_put_contents($dest, json_encode(array(
'content_type' => $headers['content-type'],
'size' => $response['size'],
'time' => time(),
'body' => base64_encode($response['body']),
)))) === false ? false : true;



QuoteThis is something different.
Your website, your choice.

MobileCS

Did you even look at my code?

I tried yours and if the image is not already cached, it will produce a perm 404 error.

If you look at my code, you will see there is a much bigger problem going on here.

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

The fix doesn't fix, image does not display in image tags.  Clean 2.0.15 install, http, loading image from same domain.

Having same problem on this forum that OP describes, image posted in tags does not display on first load, requires refresh to see it.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Aleksi "Lex" Kilpinen

Quote from: Sir Osis of Liver on January 15, 2018, 09:27:17 PM
Having same problem on this forum that OP describes, image posted in tags does not display on first load, requires refresh to see it.
Yeah, I've seen that too. I've seen it happen here as well. ;)
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

bjornforum

Quote from: MobileCS on January 14, 2018, 11:09:45 PM
Removing the lines below in proxy.php fixed the issues for me :

if (!$response) {
// Throw a 404
header('HTTP/1.0 404 Not Found');
exit;
}


The image now shows up right away when posting. Also, I no longer see broken images (404) on first page load on older threads (they appear immediately now).

Also, any image exceeding "max size" no longer 404 errors and gets displayed.

With that said, I do not know if this is a proper fix. Use at your own risk until a developer confirms everything is ok with this method.

I can confirm that images now display, but they are not secure, which is the whole purpose of proxy.php.. This will give a mixed content warning, or no lock in the address bar.

I also have the updated version of the file 2.0.15, and tried both ))) === false ? 1 : null;; and )))) === false ? false : true;.

When disabling cache, the image won't load, even after refresh. When enabling cache, they load after refresh.

Aleksi "Lex" Kilpinen

Bug Reports has a few topics on the proxy already, I'd suggest following those for now.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

butch2k

yep check my answer in the bug thread, the code i posted should fix the issue.
https://www.simplemachines.org/community/index.php?topic=558395.msg3958115#msg3958115


There are a few bugs in the current proxy.php version.

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: