Minor fix for rare occurrence: zipping files with dates <1981 generates the following errors:
PHP Notice: Uninitialized string offset: 6 in /home/carcich/phpmyadmin/libraries/zip.lib.php on line 100
PHP Notice: Uninitialized string offset: 7 in /home/carcich/phpmyadmin/libraries/zip.lib.php on line 100
This does occasionally happen.
Test with this code (send stdout to x.zip):
<?php
$fn='zip.lib.php';
require_once $fn';
$zf = new zipfile;
$zf -> addFile( file_get_contents( $fn), $fn, 315640920); // 315640920 is 1980-01-02 01:02
echo $zf -> file();
?>
N.B. Also submitted with patch 3271853; separated out here to isolate bug and feature request
Merged, though I don't think this does affect our case (the dates should not be that in our past).
Michal, Thanks!
FYI:
I agree that this bug is unlikely to affect phpMyAdmin. I can't even find where zip.lib.php is used.
However, this routine has been picked up and used by others.
The only reason I noticed this bug was that I have used zip.lib.php for a project of my own, and I had a problem wrt the memory_limit in php.ini (see Feature request 3271770), and I used a fixed old timestamp for testing i.e. so that I could confirm identical results of ZIP archive files produced by different methods.
I can see three uses of zip.lib.php quite easily:
$ git grep /zip.lib.php
export.php:require_once './libraries/zip.lib.php';
libraries/opendocument.lib.php:require_once './libraries/zip.lib.php';
webapp.php:require './libraries/zip.lib.php';
Ah yes, there they are; I don't know how I missed them. Thanks.
Also: I could have used str_pad( dechex(...), 8, '0', STR_PAD_LEFT) instead of substr( '00000000' . dechex(...), -8)