XMB Forum Software
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: [Inactive] Php7 uploaded files problem
Crazy Sage
New Poster
**




Posts: 4
Registered: 6-15-2018
Member Is Offline


[*] posted on 6-15-2018 at 01:38 PM
[Inactive] Php7 uploaded files problem


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
View user's profile View All Posts By User
lottos
Administrator
********




Posts: 461
Registered: 6-3-2002
Member Is Offline

Mood: pass me a TimTam

[*] posted on 6-15-2018 at 01:41 PM


test image attached, which php 7?

sand scoop drill pattern.png - 8kB



View user's profile View All Posts By User
Crazy Sage
New Poster
**




Posts: 4
Registered: 6-15-2018
Member Is Offline


[*] posted on 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.
View user's profile View All Posts By User
Jenny Lee
Member
***




Posts: 36
Registered: 7-21-2017
Location: England, UK
Member Is Offline

Mood: Meh. :P

[*] posted on 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....


View user's profile View All Posts By User
Crazy Sage
New Poster
**




Posts: 4
Registered: 6-15-2018
Member Is Offline


[*] posted on 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.
View user's profile View All Posts By User
Jenny Lee
Member
***




Posts: 36
Registered: 7-21-2017
Location: England, UK
Member Is Offline

Mood: Meh. :P

[*] posted on 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.";


Code:
// 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:

Code:
// 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: Скачиваемый файл испорчен. Скачивание прекращено.
OR
PATH RELATED: Скачиваемый файл испорчен. Скачивание прекращено.

Tell us which one you are getting.:)


View user's profile View All Posts By User
Crazy Sage
New Poster
**




Posts: 4
Registered: 6-15-2018
Member Is Offline


[*] posted on 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.
View user's profile View All Posts By User
miqrogroove
XMB 1.9.12 Lead Developer
*********


Avatar


Posts: 460
Registered: 10-1-2002
Location: Florida
Member Is Offline

Mood: Past Three O'Clock

[*] posted on 9-17-2020 at 04:21 PM


Jenny Lee seemed to have a good answer here. If the files are all correctly stored as blobs then you need to confirm $file['subdir'] is empty and $file['size'] is exactly the right number.

If there is no more follow up then we will archive this for troubleshooting documentation.
View user's profile Visit user's homepage View All Posts By User

  Go To Top

Powered by XMB 1.9.12 (Debug Mode)
XMB Forum Software © 2001-2024 The XMB Group
[Queries: 16] [PHP: 30.4% - SQL: 69.6%]