Both directories are subdirectories of the webserver root directory.
owner, group and access rights are the same. There is no special .htaccess file for these folders.
I now turned on all PHP error messages. For the not working directory I get following message:
[FONT=“Courier New”]Strict Standards: getimagesize() [function.getimagesize]: It is not safe to rely on the system’s timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Europe/Berlin’ for ‘CET/1.0/no DST’ instead in /srv/www/vhosts/domain.tld/httpdocs/_test/zip.php on line 42
Warning: getimagesize(bild.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /srv/www/vhosts/domain.tld/httpdocs/_test/zip.php on line 42
[/FONT]
Line 42 is ‘list($width, $height) = getimagesize($filename);’
And this is the complete code:
<?php
$dbfilename = "/srv/www/vhosts/domain.tld/httpdocs/1-tests/bild.zip";
if (preg_match('/\\.zip\\b/i', $dbfilename)) {
$zip = new ZipArchive();
if (true !== $zip->open($dbfilename))
{
throw new Exception('ZIP archive, '.$dbfilename.', konnte nicht geoeffnet werden!');
}
// Search for the image file.
for($i = 0; $i < $zip->numFiles; $i++)
{
$entry = $zip->statIndex($i);
$ext = substr($entry['name'], -3);
if (in_array($ext, array('jpg', 'jpeg', 'png', 'psd', 'tif', 'tiff', 'pdf', 'gif', 'pct')) && (!preg_match('/\\/\\./i', $entry['name'])))
{
$filename = $entry['name'];
}
}
if (isset($filename) && ($image = $zip->getFromName($filename)))
{
list($width, $height) = getimagesize($filename);
echo "w $width - h $height<br />";
}
else
{
throw new Exception('No image found');
}
}
else {
}
?>
I really don’t understand what is happening on this server…
If I recognize the code correctly, it is mine from a few weeks ago! I assumed extension is only 3 chars because the original code was looking for “images” which I thought meant .jpg, .png, .gif.
Floezen, you can’t just copy-paste other people’s code without understanding it. To improve in any language, you need to try doing things yourself.
How do you know, that I don’t understand it, just because, there are some minor errors? The code is not final and not what I will use in the end.
Nevertheless you all are missing the discussion.
The question is, why does this test code work from one directory, but not another???
User rights, owners, groups are identical.
PHP file and ZIP file are both copied (working) originals.
There is no .htaccess file for these directories, which could change behavior
I can change the name of the working directory and the code will still work (when I change the zip file path accordingly).
“Trying myself” did not bring me further with this issue. So maybe I really do not understand some part of the code , but please tell me, what part of this code could be influenced by the location. (except $dbfilename )
start echoing variables onto the page to find out which directory bild thinks it is in, is it in the right directory? Prove it, echo some useful variables onto the page.
Does it recognise the images in that directory? Prove it, echo them onto the page.
Take it from there, ask questions and prove things in a structured logical fashion until you understand more about the script you are dealing with. Its called debugging and welcome to the club.
Lets hope the zip file is well written, eh?
My previous comment might have explained why some kind of hiccup would occur if the first image that the computer picked up was a .jpeg image.
I played around for some time and found out following:
Part of the problem must be the zip file, the other problem is probably the location. The strange thing is, that the original ZIP file works fine. Only any copy of it is problematic.
The interesting thing is, that the working file gives some owner and permission output for the image file (not the others): Files: bild.jpg
Owner: 10001
Permission: 33188
while the non working ZIP file shows warnings for all:
[FONT=“Courier New”]Files: bild.jpg
Warning: fileowner() [function.fileowner]: stat failed for bild.jpg in /srv/www/vhosts/domain.local/httpdocs/_test/zip.php on line 26
Owner:
Warning: fileperms() [function.fileperms]: stat failed for bild.jpg in /srv/www/vhosts/domain.local/httpdocs/_test/zip.php on line 27
Permission:
[/FONT]
The next point is, that it looks like the file has to be in the same directory of the php script, otherwise again owner and permission errors occur.
Does anyone have a suggestion, how to solve this second problem?