Hi,
I'm currently exploring zenphoto for a family intranet with arround 20.000 photos. Performance and look&feel is great, but I noticed some problems with filenames:
If a file or a folder contains a german "umlaut" like ä,ö,ü I cannot view the original file (option unsecure is set in image settings). If I set it to download the photo, this works.
I've seen this error in the httpd logs when viewing such a file:
[Mon May 21 21:26:24 2012] [error] PHP Warning: htmlspecialchars() [
function.htmlspecialchars]: Invalid multibyte sequence in argument in /usr/local/www/zenphoto/zp-core/functions-basic.php on line 241, referer:
http://www.intranet.local/fotoalbum/test/And for videos with preview image (video.mp4 and video.jpg in a folder) the display of the preview image does not work if it contains umlauts. Instead the default image is shown.
I have tested this with Zenphoto 1.4.2.4 and the default theme on FreeBSD/Apache 2.2/PHP 5.3.
Can someone help debugging this?
thx
Comments
Your problem is that the character set of the file name is not what Zenphoto has been told to expect. If you did to the test file and paid attention to setup warnings these things should be properly discovered.
I've just done a test with a new installation of Zenphoto 1.4.2.4, created "zp-data/charset-tést" and the setup recognized it. The setup (german) message was "Der Zenphoto-Dateisystem-Zeichensatz ist als ISO?8859?1 definiert [bestätigt]".
Hm, I'm a bit clueless about what to test next.
Since Zenphoto is able to create thumbnails from photos, it can actually read them. Only some functions have problems.
> in UTF-8. There is an option for that as well.
Tried that, but then nothing works
I just switched to protected images and those links work. So this is ok.
But this still doesn't:
> And for videos with preview image (video.mp4 and video.jpg in a
> folder) the display of the preview image does not work if it contains
> umlauts. Instead the default image is shown.
I've seen that some URLs are generated from the template-functions.php, so I'll try changing those first...
You should of course never modify core files.
>with umlauts. We have no hand in those as they are third party.
I use the flowplayer plugin, never had problems so far.
>You should of course never modify core files.
Why not? If I can merge my changes with new releases?
Well, you are free to do that but it will make our support hard and might also have unexpected side effects.
Sooo, back to the preview image of videos.
I've searched my way from zp-core/zp-extensions/class-video.php, to zp-core/functions.php to zp-core/functions-basic.php and found safe_glob() where I changed line 1445 from
return $glob;
to
return utf8_encode($glob);
which fixed the problem for videothumbnails with umlauts.
I've tested this with 4 files in an album:
"video mit ö.jpg"
"video mit ö.mp4"
"video.jpg"
"video.mp4"
Before changing the multimedia file "video mit ö.mp4" was shown with the standard thumbnail mp4Default.png, after changig I got the correct thumbnail "video mit ö.jpg".
Bad news: the change breaks various things in the admin backend (plugin listings, plugin options, ...)
Suggestion: maybe image files need another globbing treatment like backend files which also takes care of the character-set that was configured via setup.php?
If you know the calling sequence leading up to this function then perhaps we can tell where something is missing.
zp-core/zp-extensions/class-video.php, line 82:
$this->objectsThumb = checkObjectsThumb($album->localpath, $filename);
checkObjectsThumb is in zp-core/functions.php and is called with the multimedia filenames.
There the file with umlaut is passed, just add
echo $image;
after line 199 to see it.
On line 202 safe_glob is called with the filenames, which is in zp-core/functions-basic.php.
Add an "echo $file;" in functions-basic.php after line 1434 and you see that "readdir" gets the filenames with a different charset not UTF8. My browser cannot display them and shows a "?".
Use "echo utf8_encode($file);" to show the filenames correctly.
So the problem is that safe_glob does not return the filenames with umlauts in it. They are not returned to checkObjectsThumb. So for those files class-video.php asumes the default image.
I hope this is what you meant with "calling sequence"
There is a correction for this in the nightly build of Zenphoto 1.4.3 Beta. If you can we would appreciate your testing the fix.
I've checked that the thumb images are generated for all testfiles in the cache folder, but the preview of the thumbs works exactly one time, after clearing the cache. Refreshing the browser shows only photos without umlauts. Strange...
In addition, there is a httpd referrer error, when trying to view any full sized image in protected mode:
[Wed May 30 10:09:21 2012] [error] [client 192.168.97.2] script '/usr/local/www/apache22/data/zenphoto-test\\index.php' not found or unable to stat, referer: http://localhost:8080/zenphoto-test/test/icon.png.php
Not at all sure what might be the issue with that second error message. certainlyh index.php must normally be findable or nothing would work.
http://www.zenphoto.org/trac/ticket/2179