Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zoho editor - save not work properly depend of php version #2564

Closed
jacceko opened this issue Jun 30, 2018 · 6 comments
Closed

zoho editor - save not work properly depend of php version #2564

jacceko opened this issue Jun 30, 2018 · 6 comments

Comments

@jacceko
Copy link
Contributor

jacceko commented Jun 30, 2018

Zoho editor work in php 5.4 ok with all file formats .doc, docx, .xls, .xlsx,
but with php 5.6, 7.0, 7.1, 7.2 when I save .docx or .xlsx - it make some big file which is not properly saved office files, (but old word file .doc is saved OK)

@nao-pon
Copy link
Member

nao-pon commented Jun 30, 2018

@jacceko The Zoho editor plugin receives uploads from the Zoho server, assigns the data to variables, and processes them. It is probably due to differences in upload limit or memory limit, not due to server version differences.

Please check those settings on your server.

@jacceko
Copy link
Contributor Author

jacceko commented Jun 30, 2018

Memory limit and upload limit - is the same, it is the same server with few instalation of php and same user.ini with custom memory limit and upload limit, but I investigate a little more and find out that is not problem with saving file but with reading.

Just after saving from in php 5.4 (ok) I change to php 7.0 and then I see that the same file is not possible to read. The same file is possible to read or not depend of php version. Maybe you know that it can be, because after change to 7.0 icon of the file is different - file is still .docx but icon from typical .docx is changed to .bin ?? (and icon only changed with file saved by zoho, copy of the same file not re-saved with zoho has normal icon). User rights on server for both files are the same.

Look at screen shot - first re-saved by zoho, second original file without re-save by zoho:
plik
after change back to the php 5.4 both files is OK again -with docx icon.

@nao-pon
Copy link
Member

nao-pon commented Jul 1, 2018

@jacceko It seems that there is a problem with detection of MIME-Type. In PHP 7, when you hover over the file type of the file information dialog of the bin icon, the MIME-Type is displayed on the tooltip. What is that MIME-Type?

180701-124831

@jacceko
Copy link
Contributor Author

jacceko commented Jul 1, 2018

In php 5.6 or higher - file type is displayed: Application
but on second file with the same extension is displayed: Microsoft Word Document (this not resaved by Zoho)

How it recognize mime type if not base of extension ?
(or it save mime type when upload is made?)

Edit 1: I check php "mime_content_type":

In php 5.6 and higher:
docx from word: application/vnd.openxmlformats-officedocument.wordprocessingml.document
resaved in zoho: application/octet-scream (NOT WORK) - bin icon

in php 5.4 work OK both version:
docx from word: application/vnd.openxmlformats-officedocument.wordprocessingml.document
resaved in zoho: application/zip (BUT IT WORK) - word icon ok

Edit 2:
I find on internet that many person have such problem in another frameworks.

Then I edit my elFinderVolumeDriverClass.php and after this:
'docx:application/zip' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx:application/zip' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx',
pptx:application/zip' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
add this:
'docx:application/octet-stream' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx:application/octet-stream'=> 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx',
'pptx:application/octet-stream' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation'

I found another solution maybe good for future of ElFinder to be sure that in all version of php always every extension work the same. It not base of php magic.mime files , but based of apache mime type definition file which is easy to download and parse.

For example (in example mime.type downloaded file, but it can be local file distributed with ElFinder, and update with update sometimes with ElFinder update)

function generateUpToDateMimeArray($url){
$return = array();
$mimes = file_get_contents('http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
preg_match_all('#^([^\s]{2,}?)\s+(.+?)$#ism', $mimes, $matches, PREG_SET_ORDER);
foreach ($matches as $match){
$exts = split(" ", $match[2]);
foreach ($exts as $ext){
$return[$ext]=$match[1];
}
}
return $return;
}

// usage:
$typeMime = generateUpToDateMimeArray();
echo $typeMime['gif'];

Edit 3:
Or similar class with composer download:
https://github.com/ralouphie/mimey

@nao-pon
Copy link
Member

nao-pon commented Jul 1, 2018

@jacceko When the MIME type is "application/octet-stream", it is logic to detect from the file extension, but there seems to be a bug in it. I will fix it.

@nao-pon nao-pon self-assigned this Jul 1, 2018
@nao-pon nao-pon closed this as completed in ba75c97 Jul 2, 2018
@nao-pon
Copy link
Member

nao-pon commented Jul 2, 2018

@jacceko I think that this problem was fixed.

Note: elFinder detects MIME-Type by file contents as much as possible for security reasons. If you want to detect MIME-Type with only the file extension, set "mimeDetect" of the connector roots option to "internal".

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants