Completed
Pull Request — master (#563)
by Richard
08:33
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
rs 10
c 0
b 0
f 0
ccs 0
cts 13
cp 0
wmc 3
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A _header() 0 15 3
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);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
78
79
    /**
80
     * @abstract
81
     * @param $filepath
82
     * @param null $newfilename
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $newfilename is correct as it would always require null to be passed?
Loading history...
83
     * @return void
84
     */
85
    abstract function addBinaryFile($filepath, $newfilename = null);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
104
105
    /**
106
     * @abstract
107
     * @param $name
108
     * @param bool $gzip
109
     * @return void
110
     */
111
    abstract function download($name, $gzip = true);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
112
}
113