仰望星辰工作室

better-staridc-MNBT

better-staridc-MNBT/ user/amftp/Class/download.php 4.9 KB · 129 行 原始文件
Z zfhsh first commit 2 个月前
1<?php
2/************************************************
3 * Amysql FTP - AMFTP 3.0
4 * amh.sh
5 * Update:2021-01-15
6 *
7 */
8
9class download
10{
11 public $file_type = array();
12
13 function download()
14 {
15 $this->file_type['chm']='application/octet-stream';
16 $this->file_type['ppt']='application/vnd.ms-powerpoint';
17 $this->file_type['xls']='application/vnd.ms-excel';
18 $this->file_type['doc']='application/msword';
19 $this->file_type['exe']='application/octet-stream';
20 $this->file_type['rar']='application/octet-stream';
21 $this->file_type['js']="javascrīpt/js";
22 $this->file_type['css']="text/css";
23 $this->file_type['hqx']="application/mac-binhex40";
24 $this->file_type['bin']="application/octet-stream";
25 $this->file_type['oda']="application/oda";
26 $this->file_type['pdf']="application/pdf";
27 $this->file_type['ai']="application/postsrcipt";
28 $this->file_type['eps']="application/postsrcipt";
29 $this->file_type['es']="application/postsrcipt";
30 $this->file_type['rtf']="application/rtf";
31 $this->file_type['mif']="application/x-mif";
32 $this->file_type['csh']="application/x-csh";
33 $this->file_type['dvi']="application/x-dvi";
34 $this->file_type['hdf']="application/x-hdf";
35 $this->file_type['nc']="application/x-netcdf";
36 $this->file_type['cdf']="application/x-netcdf";
37 $this->file_type['latex']="application/x-latex";
38 $this->file_type['ts']="application/x-troll-ts";
39 $this->file_type['src']="application/x-wais-source";
40 $this->file_type['zip']="application/zip";
41 $this->file_type['bcpio']="application/x-bcpio";
42 $this->file_type['cpio']="application/x-cpio";
43 $this->file_type['gtar']="application/x-gtar";
44 $this->file_type['shar']="application/x-shar";
45 $this->file_type['sv4cpio']="application/x-sv4cpio";
46 $this->file_type['sv4crc']="application/x-sv4crc";
47 $this->file_type['tar']="application/x-tar";
48 $this->file_type['ustar']="application/x-ustar";
49 $this->file_type['man']="application/x-troff-man";
50 $this->file_type['sh']="application/x-sh";
51 $this->file_type['tcl']="application/x-tcl";
52 $this->file_type['tex']="application/x-tex";
53 $this->file_type['texi']="application/x-texinfo";
54 $this->file_type['texinfo']="application/x-texinfo";
55 $this->file_type['t']="application/x-troff";
56 $this->file_type['tr']="application/x-troff";
57 $this->file_type['roff']="application/x-troff";
58 $this->file_type['shar']="application/x-shar";
59 $this->file_type['me']="application/x-troll-me";
60 $this->file_type['ts']="application/x-troll-ts";
61 $this->file_type['gif']="image/gif";
62 $this->file_type['jpeg']="image/pjpeg";
63 $this->file_type['jpg']="image/pjpeg";
64 $this->file_type['jpe']="image/pjpeg";
65 $this->file_type['ras']="image/x-cmu-raster";
66 $this->file_type['pbm']="image/x-portable-bitmap";
67 $this->file_type['ppm']="image/x-portable-pixmap";
68 $this->file_type['xbm']="image/x-xbitmap";
69 $this->file_type['xwd']="image/x-xwindowdump";
70 $this->file_type['ief']="image/ief";
71 $this->file_type['tif']="image/tiff";
72 $this->file_type['tiff']="image/tiff";
73 $this->file_type['pnm']="image/x-portable-anymap";
74 $this->file_type['pgm']="image/x-portable-graymap";
75 $this->file_type['rgb']="image/x-rgb";
76 $this->file_type['xpm']="image/x-xpixmap";
77 $this->file_type['txt']="text/plain";
78 $this->file_type['c']="text/plain";
79 $this->file_type['cc']="text/plain";
80 $this->file_type['h']="text/plain";
81 $this->file_type['html']="text/html";
82 $this->file_type['htm']="text/html";
83 $this->file_type['htl']="text/html";
84 $this->file_type['rtx']="text/richtext";
85 $this->file_type['etx']="text/x-setext";
86 $this->file_type['tsv']="text/tab-separated-values";
87 $this->file_type['mpeg']="video/mpeg";
88 $this->file_type['mpg']="video/mpeg";
89 $this->file_type['mpe']="video/mpeg";
90 $this->file_type['avi']="video/x-msvideo";
91 $this->file_type['qt']="video/quicktime";
92 $this->file_type['mov']="video/quicktime";
93 $this->file_type['moov']="video/quicktime";
94 $this->file_type['movie']="video/x-sgi-movie";
95 $this->file_type['au']="audio/basic";
96 $this->file_type['snd']="audio/basic";
97 $this->file_type['wav']="audio/x-wav";
98 $this->file_type['aif']="audio/x-aiff";
99 $this->file_type['aiff']="audio/x-aiff";
100 $this->file_type['aifc']="audio/x-aiff";
101 $this->file_type['swf']="application/x-shockwave-flash";
102 }
103
104
105 function download_file($fileName, $baseName = null)
106 {
107 if (!is_file($fileName))
108 Return false;
109
110 $filetype = strtolower(array_pop(explode(".", $fileName)));
111 $filetype = $this -> file_type[$filetype];
112 // if(function_exists("mime_content_type"))
113 // $filetype = mime_content_type($fileName);
114 $baseName = basename($baseName);
115
116 ob_end_clean();
117 header('Cache-control: max-age=31536000');
118 header('Expires: '.gmdate('D, d M Y H:i:s',time()+31536000).' GMT');
119 header('Content-Encoding: none');
120 header('Content-Length: '.filesize($fileName));
121 header('Content-Disposition: attachment; filename='.$baseName);
122 header('Content-Type: '.$filetype);
123 readfile($fileName);
124 }
125
126
127}
128
129?>