~ubuntu-branches/ubuntu/lucid/phpmyadmin/lucid

« back to all changes in this revision

Viewing changes to libraries/zip_extension.lib.php

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-03-08 15:25:00 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100308152500-6e8hmuqc5co39de5
Tags: 4:3.3.0-1
* New upstream version.
* Rediff debian/patches.
* Fix permissions on mediawiki export extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
/**
5
5
 * Interface for the zip extension
6
6
 * @package    phpMyAdmin
7
 
 * @version    $Id: zip_extension.lib.php 11984 2008-11-24 10:35:27Z nijel $
 
7
 * @version    $Id: zip_extension.lib.php 12824 2009-08-19 17:58:42Z drummingds1 $
8
8
 */
9
9
 
10
10
/**
26
26
        if (false === $first_zip_entry) {
27
27
            $error_message = $GLOBALS['strNoFilesFoundInZip'];
28
28
        } else {
29
 
            zip_entry_open($zip_handle, $first_zip_entry, 'r');
30
 
            $file_data = zip_entry_read($first_zip_entry, zip_entry_filesize($first_zip_entry));
31
 
            zip_entry_close($first_zip_entry);
 
29
            /* Is the the zip really an ODS file? */
 
30
            $read = zip_entry_read($first_zip_entry);
 
31
            $ods_mime = 'application/vnd.oasis.opendocument.spreadsheet';
 
32
            if (!strcmp($ods_mime, $read)) {
 
33
                /* Return the correct contents, not just the first entry */
 
34
                for ( ; ; ) {
 
35
                    $entry = zip_read($zip_handle);
 
36
                    if (is_resource($entry)) {
 
37
                        if (!strcmp('content.xml', zip_entry_name($entry))) {
 
38
                            zip_entry_open($zip_handle, $entry, 'r');
 
39
                            $file_data = zip_entry_read($entry, zip_entry_filesize($entry));
 
40
                            zip_entry_close($entry);
 
41
                            break;
 
42
                        }
 
43
                    } else {
 
44
                        /**
 
45
                         * Either we have reached the end of the zip and still
 
46
                         * haven't found 'content.xml' or there was a parsing
 
47
                         * error that we must display
 
48
                         */
 
49
                        if ($entry === FALSE) {
 
50
                            $error_message = $GLOBALS['strErrorInZipFile'] . ' Could not find "content.xml"';
 
51
                        } else {
 
52
                            $error_message = $GLOBALS['strErrorInZipFile'] . ' ' . PMA_getZipError($zip_handle);
 
53
                        }
 
54
                        
 
55
                        break;
 
56
                    }
 
57
                }
 
58
            } else {
 
59
                zip_entry_open($zip_handle, $first_zip_entry, 'r');
 
60
                /* File pointer has already been moved, so include what was read above */
 
61
                $file_data = $read;
 
62
                $file_data .= zip_entry_read($first_zip_entry, zip_entry_filesize($first_zip_entry));
 
63
                zip_entry_close($first_zip_entry);
 
64
            }
32
65
        }
33
66
    } else {
34
67
        $error_message = $GLOBALS['strErrorInZipFile'] . ' ' . PMA_getZipError($zip_handle);
37
70
    return (array('error' => $error_message, 'data' => $file_data));
38
71
}
39
72
 
40
 
 
41
73
/**
42
74
  * Gets zip error message
43
75
  *