Completed
Push — xmf11sync ( 85ff3d )
by Richard
08:09
created

XoopsDownloader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 85
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A _header() 0 17 3
addFile() 0 1 ?
addBinaryFile() 0 1 ?
addFileData() 0 1 ?
addBinaryFileData() 0 1 ?
download() 0 1 ?
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * XOOPS downloader
14
 *
15
 * @copyright       XOOPS Project (http://xoops.org)
16
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17
 * @package         class
18
 * @since           2.0.0
19
 * @author          Kazumi Ono <[email protected]>
20
 * @version         $Id$
21
 */
22
23
/**
24
 * Sends non HTML files through a http socket
25
 *
26
 * @package class
27
 */
28
abstract class XoopsDownloader
29
{
30
31
    /**
32
     * @var string
33
     */
34
    protected $mimetype;
35
36
    /**
37
     * @var string
38
     */
39
    protected $ext;
40
41
    /**
42
     * @var XoopsDownloader
43
     */
44
    protected $archiver;
45
46
47
    /**
48
     * Send the HTTP header
49
     *
50
     * @param string $filename
51
     * @access protected
52
     */
53
    protected function _header($filename)
54
    {
55
        if (function_exists('mb_http_output')) {
56
            mb_http_output('pass');
57
        }
58
        header('Content-Type: ' . $this->mimetype);
59
        if (preg_match("/MSIE ([0-9]\.[0-9]{1,2})/", $_SERVER['HTTP_USER_AGENT'])) {
60
            header('Content-Disposition: attachment; filename="' . $filename . '"');
61
            header('Expires: 0');
62
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
63
            header('Pragma: public');
64
        } else {
65
            header('Content-Disposition: attachment; filename="' . $filename . '"');
66
            header('Expires: 0');
67
            header('Pragma: no-cache');
68
        }
69
    }
70
71
    /**
72
     * @abstract
73
     * @param $filepath
74
     * @param boolean|string $newfilename
75
     * @return void
76
     */
77
     abstract function addFile($filepath, $newfilename = null);
78
79
    /**
80
     * @abstract
81
     * @param $filepath
82
     * @param null $newfilename
83
     * @return void
84
     */
85
    abstract function addBinaryFile($filepath, $newfilename = null);
86
87
    /**
88
     * @abstract
89
     * @param $data
90
     * @param $filename
91
     * @param int $time
92
     * @return void
93
     */
94
    abstract function addFileData(&$data, $filename, $time = 0);
95
96
    /**
97
     * @abstract
98
     * @param $data
99
     * @param $filename
100
     * @param int $time
101
     * @return void
102
     */
103
    abstract function addBinaryFileData(&$data, $filename, $time = 0);
104
105
    /**
106
     * @abstract
107
     * @param $name
108
     * @param bool $gzip
109
     * @return void
110
     */
111
    abstract function download($name, $gzip = true);
112
}
113