Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

朱继来 / 后台订单管理

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Find file
Normal viewHistoryPermalink
Switch branch/tag
  • Order
  • ..
  • Shared
  • ZipStreamWrapper.php
ZipStreamWrapper.php 5.2 KB
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
1
<?php
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
2

叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
3
/**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
4
 * PHPExcel_Shared_ZipStreamWrapper
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
5
 *
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
6
 * Copyright (c) 2006 - 2015 PHPExcel
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel_Shared
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
24 25
 * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
26 27
 * @version    ##VERSION##, ##DATE##
 */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
28 29 30 31 32 33 34 35
class PHPExcel_Shared_ZipStreamWrapper
{
    /**
     * Internal ZipAcrhive
     *
     * @var ZipArchive
     */
    private $archive;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
36 37 38 39 40 41

    /**
     * Filename in ZipAcrhive
     *
     * @var string
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
42
    private $fileNameInArchive = '';
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
43 44 45 46 47 48

    /**
     * Position in file
     *
     * @var int
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
49
    private $position = 0;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
50 51 52 53 54 55

    /**
     * Data
     *
     * @var mixed
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
56
    private $data = '';
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
57 58 59 60

    /**
     * Register wrapper
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
61 62 63 64
    public static function register()
    {
        @stream_wrapper_unregister('zip');
        @stream_wrapper_register('zip', __CLASS__);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
65 66 67
    }

    /**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
68 69 70 71 72 73 74
     * Implements support for fopen().
     *
     * @param    string    $path            resource name including scheme, e.g.
     * @param    string    $mode            only "r" is supported
     * @param    int        $options        mask of STREAM_REPORT_ERRORS and STREAM_USE_PATH
     * @param    string  &$openedPath    absolute path of the opened stream (out parameter)
     * @return    bool    true on success
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
75
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
76 77
    public function stream_open($path, $mode, $options, &$opened_path)
    {
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
78 79 80 81 82
        // Check for mode
        if ($mode{0} != 'r') {
            throw new PHPExcel_Reader_Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
        }

朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
83 84 85
        $pos = strrpos($path, '#');
        $url['host'] = substr($path, 6, $pos - 6); // 6: strlen('zip://')
        $url['fragment'] = substr($path, $pos + 1);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
86 87

        // Open archive
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
88 89
        $this->archive = new ZipArchive();
        $this->archive->open($url['host']);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
90

朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
91 92 93
        $this->fileNameInArchive = $url['fragment'];
        $this->position = 0;
        $this->data = $this->archive->getFromName($this->fileNameInArchive);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
94 95 96 97 98

        return true;
    }

    /**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
99 100 101
     * Implements support for fstat().
     *
     * @return  boolean
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
102
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
103 104 105
    public function statName()
    {
        return $this->fileNameInArchive;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
106 107 108
    }

    /**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
109 110 111
     * Implements support for fstat().
     *
     * @return  boolean
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
112
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
113 114 115
    public function url_stat()
    {
        return $this->statName($this->fileNameInArchive);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
116 117 118
    }

    /**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
119 120 121
     * Implements support for fstat().
     *
     * @return  boolean
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
122
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
123 124 125
    public function stream_stat()
    {
        return $this->archive->statName($this->fileNameInArchive);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
126 127 128
    }

    /**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
129 130 131 132
     * Implements support for fread(), fgets() etc.
     *
     * @param   int        $count    maximum number of bytes to read
     * @return  string
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
133
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
134 135 136 137
    public function stream_read($count)
    {
        $ret = substr($this->data, $this->position, $count);
        $this->position += strlen($ret);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
138 139 140 141
        return $ret;
    }

    /**
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
142 143 144 145
     * Returns the position of the file pointer, i.e. its offset into the file
     * stream. Implements support for ftell().
     *
     * @return  int
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
146
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
147 148 149
    public function stream_tell()
    {
        return $this->position;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
150 151 152 153
    }

    /**
     * EOF stream
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
154 155
     *
     * @return    bool
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
156
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
157 158 159
    public function stream_eof()
    {
        return $this->position >= strlen($this->data);
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
160 161 162 163
    }

    /**
     * Seek stream
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
164 165 166 167
     *
     * @param    int        $offset    byte offset
     * @param    int        $whence    SEEK_SET, SEEK_CUR or SEEK_END
     * @return    bool
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
168
     */
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
169 170
    public function stream_seek($offset, $whence)
    {
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
171 172
        switch ($whence) {
            case SEEK_SET:
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
173 174
                if ($offset < strlen($this->data) && $offset >= 0) {
                     $this->position = $offset;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
175 176 177 178 179 180 181
                     return true;
                } else {
                     return false;
                }
                break;
            case SEEK_CUR:
                if ($offset >= 0) {
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
182
                     $this->position += $offset;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
183 184 185 186 187 188
                     return true;
                } else {
                     return false;
                }
                break;
            case SEEK_END:
朱继来's avatar
1. 调整明细编辑;
0b4e495b
 
朱继来 committed 5 years ago
189 190
                if (strlen($this->data) + $offset >= 0) {
                     $this->position = strlen($this->data) + $offset;
叶明星's avatar
账期管理
d99f4f05
 
叶明星 committed 6 years ago
191 192 193 194 195 196 197 198 199 200
                     return true;
                } else {
                     return false;
                }
                break;
            default:
                return false;
        }
    }
}