XMB Forum Software

[New] Php7 uploaded files problem

Crazy Sage - 6-15-2018 at 01:38 PM

Full Board URL: http://asf.ural.ru/forum
XMB Version: 1.9.11

Hello. I have a problem: my hosting was transferred to php7 (and there are some scripts working that require it), after that display of uploaded photos have broken, they won't show in attachments and through direct link I've got message "file is corrupted". I've checked it through phpMyAdmin, binary data in db is correct, it can be downloaded and viewed as jpeg. Do someone know if there is some simple way to fix it?

xmb 1.9.11 patch 15

lottos - 6-15-2018 at 01:41 PM

test image attached, which php 7?

sand scoop drill pattern.png - 8kB

Crazy Sage - 6-19-2018 at 09:08 AM

Php 7.0.30
Files uploaded after change of php version and upgrade of forum to patch 15 still won't show.

Jenny Lee - 6-19-2018 at 09:03 PM

It's not on XMB's side. :frog: Ofc unless you use some custom version of the script that has/might have bugs.
Just tested it and it works as it supposed to. Contact your hosting provider. Don't want to speculate, but it might be wrong server configuration or a PHP installation related issue.

Inside the post:
itworks.jpg - 155kB

Direct file access:
directworkstoo.jpg - 27kB

P.S. You could try installing this XMB build (in case you use a custom/older one): https://sourceforge.net/projects/xmb-forum/files/XMB-1.9.11....

Crazy Sage - 6-20-2018 at 03:08 AM

Hosting provider say that it's not their problem and all they can do - switch back to php5 (which will break some scripts not related to forum, but forum will work, yes).
I understand that it may be php configuration problem, but I don't know how does it work inside of xmb and what may cause such problem so I don't have a slightest hint, where to look in config.

Jenny Lee - 6-20-2018 at 06:56 AM

If it's not the hosting provider and not XMB then you might have damaged some of the files or even database entries. I could not think of any other reasonable explanation until I get my hands on your forum source code which is unlikely. You said that you transferred hosting. Can you give more details? Was it the same hosting company? They just simply switched it to PHP7 or moved you to a different virtual server?

I suggest you take the copy of the database and file system and check if it works outside your hosting. You could use some tools like "wamp","xammp","mamp" or even some other free hosting provider just to test if it's actually a script problem or not. If the script on different host/localhost works fine, then something is indeed wrong with your main hosting.

If it's configuration related, you need to ask them for php.ini contents. Most of shared web hosting providers never give a direct access to php. ini:snob:

In addition, turn on debug level to max maybe it will show some additional notifications/errors etc..
If it was me, I would probably use something like http://filp.github.io/whoops/. A perfect error handler.

POST EDIT: It might be misconfiguration inside the ACP or no permissions to read the directory.

Скачиваемый файл испорчен. Скачивание прекращено.

English definition:
$lang['filecorrupt'] = "The file you are trying to download appears corrupt. File download aborted.";

// Verify file is available $path = ''; $size = 0; if ($file['subdir'] == '') { $size = strlen($file['attachment']); } else { $path = $SETTINGS['files_storage_path']; if (substr($path, -1) != '/') { $path .= '/'; } $path = $path.$file['subdir'].'/'.$file['aid']; if (!is_file($path)) { header('HTTP/1.0 500 Internal Server Error'); error($lang['filecorrupt']); } $size = intval(filesize($path)); } if ($size != $file['filesize']) { header('HTTP/1.0 500 Internal Server Error'); error($lang['filecorrupt']); }

From ACP:
Attachment Storage Path:
Optional, disk storage location for new files.

Check if $SETTINGS['files_storage_path'] is defined correctly and matches the folder of storage(if you use it in the first place because by default it's optional). If the folder actually exists and defined properly then it might not be readable. Try making it readable, writable and executable (chmod 777).

The second conditional aims for size, if size doesn't match it's also going to throw the same error. So in order to know where it occurs exactly you have add some simple debugging to the files.php:

// Verify file is available $path = ''; $size = 0; if ($file['subdir'] == '') { $size = strlen($file['attachment']); } else { $path = $SETTINGS['files_storage_path']; if (substr($path, -1) != '/') { $path .= '/'; } $path = $path.$file['subdir'].'/'.$file['aid']; if (!is_file($path)) { header('HTTP/1.0 500 Internal Server Error'); error('PATH RELATED: '.$lang['filecorrupt']); } $size = intval(filesize($path)); } if ($size != $file['filesize']) { header('HTTP/1.0 500 Internal Server Error'); error('SIZE RELATED: '.$lang['filecorrupt']); }

In your case the errors will look like that:
SIZE RELATED: Скачиваемый файл испорчен. Скачивание прекращено.
PATH RELATED: Скачиваемый файл испорчен. Скачивание прекращено.

Tell us which one you are getting.:)

Crazy Sage - 6-20-2018 at 01:26 PM

They just changed to PHP7, without moving to new server.
I don't have any attachments dir, all files are stored as blobs in database, I've downloaded couple, renamed them to jpg - they are ok.
I'll try copying database and tell results.