MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mdownload.class
Ir para a documentação deste ficheiro.
1
<?php
6
class
MDownload
7
{
11
private
12
$mimeType = array(
'ai'
=>
'application/postscript'
,
'aif'
=>
'audio/x-aiff'
,
13
'aifc'
=>
'audio/x-aiff'
,
'aiff'
=>
'audio/x-aiff'
,
14
'asf'
=>
'video/x-ms-asf'
,
'asr'
=>
'video/x-ms-asf'
,
15
'asx'
=>
'video/x-ms-asf'
,
'au'
=>
'audio/basic'
,
16
'avi'
=>
'video/x-msvideo'
,
'bin'
=>
'application/octet-stream'
,
17
'bmp'
=>
'image/bmp'
,
'css'
=>
'text/css'
,
18
'doc'
=>
'application/msword'
,
'gif'
=>
'image/gif'
,
19
'gz'
=>
'application/x-gzip'
,
'hlp'
=>
' application/winhlp'
,
20
'htm'
=>
'text/html'
,
'html'
=>
'text/html'
,
21
'ico'
=>
'image/x-icon'
,
'jpe'
=>
'image/jpeg'
,
22
'jpeg'
=>
'image/jpeg'
,
'jpg'
=>
'image/jpeg'
,
23
'js'
=>
'application/x-javascript'
,
'lzh'
=>
'application/octet-stream'
,
24
'mid'
=>
'audio/mid'
,
'mov'
=>
'video/quicktime'
,
25
'mp3'
=>
'audio/mpeg'
,
'mpa'
=>
'video/mpeg'
,
26
'mpe'
=>
'video/mpeg'
,
'mpeg'
=>
'video/mpeg'
,
27
'mpg'
=>
'video/mpeg'
,
'pdf'
=>
'application/pdf'
,
28
'png'
=>
'image/png'
,
'pps'
=>
'application/vnd.ms-powerpoint'
,
29
'ppt'
=>
'application/vnd.ms-powerpoint'
,
'ps'
=>
'application/postscript'
,
30
'qt'
=>
'video/quicktime'
,
'ra'
=>
'audio/x-pn-realaudio'
,
31
'ram'
=>
'audio/x-pn-realaudio'
,
'rtf'
=>
'application/rtf'
,
32
'snd'
=>
'audio/basic'
,
'tgz'
=>
'application/x-compressed'
,
33
'tif'
=>
'image/tiff'
,
'tiff'
=>
'image/tiff'
,
34
'txt'
=>
'text/plain'
,
'wav'
=>
'audio/x-wav'
,
35
'xbm'
=>
'image/x-xbitmap'
,
'xpm'
=>
'image/x-xpixmap'
,
36
'z'
=>
'application/x-compress'
,
'zip'
=>
'application/zip'
,
37
'csv'
=>
'application/csv'
,
'odt'
=>
'application/vnd.oasis.opendocument.text'
);
38
42
var
$ContentType
;
43
47
var
$ContentLength
;
48
52
var
$ContentDisposition
;
53
57
var
$ContentTransferEncoding
;
58
62
var
$fileName
;
63
67
var
$fileNameDown
;
68
72
var
$baseName
;
73
85
function
__construct
()
86
{
87
$this->ContentType =
"application/save"
;
88
$this->ContentLength =
""
;
89
$this->ContentDisposition =
""
;
90
$this->ContentTransferEncoding =
""
;
91
$this->fileName =
""
;
92
$this->fileNameDown =
""
;
93
}
94
109
function
setContentType
($strValue)
110
{
111
$this->ContentType = $strValue;
112
}
113
126
function
_setContentLength
()
127
{
128
$this->ContentLength = filesize($this->fileName);
129
}
130
144
function
setContentDisposition
($strValue)
145
{
146
$this->ContentDisposition = $strValue;
147
}
148
162
function
setContentTransferEncoding
($strValue)
163
{
164
$this->ContentTransferEncoding = $strValue;
165
}
166
180
function
setFileName
($strValue)
181
{
185
if
(strpos($strValue,
".."
) ===
false
)
186
{
187
$this->fileName = $strValue;
188
$this->baseName = basename($this->fileName);
189
$extension = strstr($this->baseName,
'.'
);
190
191
if
($extension !=
''
)
192
{
193
$extension = substr($extension, 1, 5);
194
$this->
setContentType
($this->mimeType[$extension]);
195
}
196
}
197
else
198
{
199
die (
"Trying to access an URL with '..'"
);
200
}
201
}
202
217
function
setFileNameDown
($strValue)
218
{
219
$this->SetFileName($strValue);
220
$this->fileNameDown = $strValue;
221
}
222
234
function
send
()
235
{
236
$fileName
=
$this->fileName
;
237
$this->
_setContentLength
();
238
239
/*
240
echo $fileName;
241
echo $this->baseName;
242
echo $this->ContentType;
243
echo $this->ContentLength;
244
*/
245
246
header (
"Content-Type: "
. $this->ContentType);
247
header (
"Content-Length: "
. $this->ContentLength);
248
249
if
($this->fileNameDown ==
""
)
250
header (
"Content-Disposition: inline; filename= "
. $this->baseName);
251
else
252
header (
"Content-Disposition: attachment; filename= "
. $this->baseName);
253
254
header (
"Cache-Control: cache"
);
// HTTP/1.1
255
header (
"Content-Transfer-Encoding: binary"
);
256
257
ob_clean();
258
259
$fp = fopen(
$fileName
,
"r"
);
260
fpassthru ($fp);
261
fclose ($fp);
262
263
exit();
264
}
265
276
function
SendText
($text, $type)
277
{
278
$length = strlen($text);
279
header (
"Content-Type: "
. $type);
280
header (
"Content-Length: "
. $length);
281
header (
"Content-Disposition: inline; filename="
. $this->baseName);
282
header (
"Content-Transfer-Encoding: binary"
);
283
echo $text;
284
exit();
285
}
286
}
287
?>
MDownload
Definição
mdownload.class:7
MDownload\_setContentLength
_setContentLength()
Definição
mdownload.class:126
MDownload\__construct
__construct()
Definição
mdownload.class:85
MDownload\send
send()
Definição
mdownload.class:234
MDownload\setFileNameDown
setFileNameDown($strValue)
Definição
mdownload.class:217
MDownload\setFileName
setFileName($strValue)
Definição
mdownload.class:180
MDownload\SendText
SendText($text, $type)
Definição
mdownload.class:276
MDownload\$ContentType
$ContentType
Definição
mdownload.class:42
MDownload\$ContentLength
$ContentLength
Definição
mdownload.class:47
MDownload\$ContentTransferEncoding
$ContentTransferEncoding
Definição
mdownload.class:57
MDownload\$fileName
$fileName
Definição
mdownload.class:62
MDownload\setContentDisposition
setContentDisposition($strValue)
Definição
mdownload.class:144
MDownload\setContentTransferEncoding
setContentTransferEncoding($strValue)
Definição
mdownload.class:162
MDownload\$ContentDisposition
$ContentDisposition
Definição
mdownload.class:52
MDownload\$baseName
$baseName
Definição
mdownload.class:72
MDownload\setContentType
setContentType($strValue)
Definição
mdownload.class:109
MDownload\$fileNameDown
$fileNameDown
Definição
mdownload.class:67
classes
utils
mdownload.class
Gerado por
1.10.0