JfoxEdge
03-30-2013, 05:13 PM
vBulletin 4.1.12. Avatars are stored in the database.
Some avatars display, others do not. It appears that file format doesn't matter, I have some JPG and some PNG with the problem, while others display fine.
The data is being output to the browser by image.php. I modified image.php and inserted the following line:
file_put_contents($imageinfo['filename'],$imageinfo['filedata']);
Before the following section:
($hook = vBulletinHook::fetch_hook('image_exists')) ? eval($hook) : false;
header('Pragma:'); // VBIV-8269
header('Cache-control: max-age=31536000');
header('Expires: ' . gmdate('D, d M Y H:i:s', (TIMENOW + 31536000)) . ' GMT');
header('Content-disposition: inline; filename=' . $imageinfo['filename']);
header('Content-transfer-encoding: binary');
header('Content-Length: ' . strlen($imageinfo['filedata']));
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $imageinfo['dateline']) . ' GMT');
header('ETag: "' . $imageinfo['dateline'] . '-' . $vbulletin->GPC['userid'] . '"');
This causes image.php to save the database data to a file.
On a given avatar, the saved file is 6474 bytes, called "header.png", and is a valid PNG file that can be viewed successfully, either by accessing through a browser (at "/forums/header.png") or by downloading the file with FTP and then viewing.
When trying to open the image at /forums/image.php?u=14548&dateline=1362221067, you get a file size of 6480 bytes, and the browser says the file contains errors. When saving the image from the browser, you get a 6480 byte file that is not a valid PNG. The saved file contains many different looking characters.
So I've got two files, the one that image.php saved on the server with file_put_contents and the one downloaded from the browser. You see the difference in the very beginning of the file.
When opened in notepad, the good file that was saved on the server looks like this:
?PNG
The file being output by image.php to the browser looks like this:
�PNG
In addition, the one output by image.php is full of those characters with a ? inside a diamond.
So what could be wrong? This seems to have just happened all-of-a-sudden a few days ago, with no changes that I'm aware of at all. And even more confusing is that it's not all avatar images, just some of them.
Any suggestions would be appreciated.
Thanks.
Some avatars display, others do not. It appears that file format doesn't matter, I have some JPG and some PNG with the problem, while others display fine.
The data is being output to the browser by image.php. I modified image.php and inserted the following line:
file_put_contents($imageinfo['filename'],$imageinfo['filedata']);
Before the following section:
($hook = vBulletinHook::fetch_hook('image_exists')) ? eval($hook) : false;
header('Pragma:'); // VBIV-8269
header('Cache-control: max-age=31536000');
header('Expires: ' . gmdate('D, d M Y H:i:s', (TIMENOW + 31536000)) . ' GMT');
header('Content-disposition: inline; filename=' . $imageinfo['filename']);
header('Content-transfer-encoding: binary');
header('Content-Length: ' . strlen($imageinfo['filedata']));
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $imageinfo['dateline']) . ' GMT');
header('ETag: "' . $imageinfo['dateline'] . '-' . $vbulletin->GPC['userid'] . '"');
This causes image.php to save the database data to a file.
On a given avatar, the saved file is 6474 bytes, called "header.png", and is a valid PNG file that can be viewed successfully, either by accessing through a browser (at "/forums/header.png") or by downloading the file with FTP and then viewing.
When trying to open the image at /forums/image.php?u=14548&dateline=1362221067, you get a file size of 6480 bytes, and the browser says the file contains errors. When saving the image from the browser, you get a 6480 byte file that is not a valid PNG. The saved file contains many different looking characters.
So I've got two files, the one that image.php saved on the server with file_put_contents and the one downloaded from the browser. You see the difference in the very beginning of the file.
When opened in notepad, the good file that was saved on the server looks like this:
?PNG
The file being output by image.php to the browser looks like this:
�PNG
In addition, the one output by image.php is full of those characters with a ? inside a diamond.
So what could be wrong? This seems to have just happened all-of-a-sudden a few days ago, with no changes that I'm aware of at all. And even more confusing is that it's not all avatar images, just some of them.
Any suggestions would be appreciated.
Thanks.