dbXapp
2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Toggle main menu visibility
Loading...
Searching...
No Matches
dbxDownload.class.php
Go to the documentation of this file.
1
<?php
2
3
class
dbxDownload
{
4
5
function
run
(
$dir
,$file,$mobile=1) {
6
$content=
'Hallo'
;
7
$dir_file =
$dir
.$file;
8
$href_dir_file=
dbx
()->get_base_url().$dir_file;
9
10
$ar_ext = explode(
'.'
, $file);
11
$ext = strtolower(end($ar_ext));
12
$extensions = array(
13
'bmp'
=>
'image/bmp'
,
14
'csv'
=>
'text/csv'
,
15
'doc'
=>
'application/msword'
,
16
'docx'
=>
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
17
'exe'
=>
'application/octet-stream'
,
18
'gif'
=>
'image/gif'
,
19
'htm'
=>
'text/html'
,
20
'html'
=>
'text/html'
,
21
'txt'
=>
'text/html'
,
22
'ldt'
=>
'text/html'
,
23
'ldtx'
=>
'application/ldtx'
,
24
'ico'
=>
'image/vnd.microsoft.icon'
,
25
'jpeg'
=>
'image/jpg'
,
26
'jpe'
=>
'image/jpg'
,
27
'jpg'
=>
'image/jpg'
,
28
'pdf'
=>
'application/pdf'
,
29
'png'
=>
'image/png'
,
30
'ppt'
=>
'application/vnd.ms-powerpoint'
,
31
'psd'
=>
'image/psd'
,
32
'swf'
=>
'application/x-shockwave-flash'
,
33
'tif'
=>
'image/tiff'
,
34
'tiff'
=>
'image/tiff'
,
35
'xhtml'
=>
'application/xhtml+xml'
,
36
'xml'
=>
'application/xml'
,
37
'xls'
=>
'application/vnd.ms-excel'
,
38
'xlsx'
=>
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
39
'zip'
=>
'application/zip'
40
);
41
42
$ctype = isset($extensions[$ext]) ? $extensions[$ext] :
'application/force-download'
;
43
if
($mobile) $ctype=
'application/force-download'
;
44
45
if
(file_exists($dir_file) && is_readable($dir_file)) {
46
if
(!$mobile) {
47
// required for IE, otherwise Content-disposition is ignored
48
if
(ini_get(
'zlib.output_compression'
)) ini_set(
'zlib.output_compression'
,
'Off'
);
49
50
header(
'Pragma: public'
);
// required
51
header(
'Expires: 0'
);
52
header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0'
);
53
header(
'Cache-Control: private'
,
false
);
// required for certain browsers
54
header(
'Content-Type: '
. $ctype);
55
header(
'Content-Disposition: attachment; filename="'
. $file .
'"'
);
56
header(
'Content-Transfer-Encoding: binary'
);
57
header(
'Content-Length: '
. filesize($dir_file));
58
readfile($dir_file);
59
$content=
"Desktop: <a href='$href_dir_file'>$file</a>"
;
60
}
61
if
($mobile) {
62
header(
'Pragma: public'
);
63
header(
'Expires: 0'
);
64
header(
"Cache-Control: must-revalidate, post-check=0, pre-check=0"
);
65
header(
"Cache-Control: private"
,
false
);
66
header(
'Content-Type: '
. $ctype);
67
header(
'Content-Type: application/octet-stream'
);
68
header(
"Content-Disposition: attachment; filename=\"{$file}\";"
);
69
header(
'Content-Transfer-Encoding: binary'
);
70
header(
'Content-Length: '
. filesize(
$dir
.$file));
71
//@ob_clean();
72
readfile($dir_file);
73
$content=
"Mobile: <a href='$href_dir_file'>$file</a>"
;
74
}
75
76
}
77
else
{
78
$content.=
"<h1>File Not Found:</h1><br>($dir_file)<br> href=($href_dir_file)"
;
79
}
80
return
$content;
81
}
82
83
}
84
dbxDownload
Definition
dbxDownload.class.php:3
dbxDownload\run
run($dir, $file, $mobile=1)
Definition
dbxDownload.class.php:5
dbx
DBX schema administration.
$dir
$dir
Definition
seed_admin_help_tpl.php:2
dbx
include
dbxDownload.class.php
Generated by
1.17.0