日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

PHP文件下载过滤类

發布時間:2025/3/8 php 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP文件下载过滤类 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Java代碼??
  • <?php??
  • /**?
  • $filename?=?'index.php';?
  • $download?=?new?Download('php,exe,html',?false);?
  • if?(!$download->downloadfile($filename))?{?
  • ????echo?$download->getErrorMsgs();?
  • }?
  • */??
  • class?Download?{??
  • ????private?$debug?=?false;??
  • ????private?$errorMsg?=?'';??
  • ????private?$filter?=?array();??
  • ????private?$fileName?=?'';??
  • ????private?$mineType?=?'';??
  • ????private?$xlq_filetype?=?array();??
  • ????private?$limitTime?=?60;??
  • ??
  • ????/**?
  • ?????*?@param?string?$fileFilter?
  • ?????*?@param?boolean?$isDebug?
  • ?????*/??
  • ????function?__construct($fileFilter?=?'',?$isDebug?=?true)?{??
  • ????????$this->setFilter($fileFilter);??
  • ????????$this->setDebug($isDebug);??
  • ????????$this->setFileType();??
  • ????}??
  • ??
  • ????function?downloadfile($filename)?{??
  • ????????$this->fileName?=?$filename;??
  • ????????if?($this->filecheck())?{??
  • ????????????$fn?=?basename($this->fileName);??
  • ????????????ob_end_clean();??
  • ????????????@set_time_limit($this->limitTime);??
  • ????????????header('Cache-control:?max-age=31536000');??
  • ????????????header('Expires:?'?.?gmdate('D,?d?M?Y?H:i:s',?time()?+?31536000)?.?'?GMT');??
  • ????????????header('Content-Encoding:?none');??
  • ????????????header('Content-Length:?'?.?filesize($this->fileName));??
  • ????????????header('Content-Disposition:?attachment;?filename='?.?$fn);??
  • ????????????header('Content-Type:?'?.?$this->mineType);??
  • ????????????readfile($this->fileName);??
  • ????????????return?true;??
  • ????????}?else?{??
  • ????????????return?false;??
  • ????????}??
  • ????}??
  • ??
  • ????function?filecheck()?{??
  • ????????$fileName?=?$this->fileName;??
  • ????????if?(file_exists($fileName))?{??
  • ????????????$fileType?=?strtolower(array_pop(explode(".",?$fileName)));??
  • ????????????if?(!in_array($fileType,?$this->filter))?{??
  • ????????????????$this->errorMsg?.=?sprintf("%s?不允許下載",?$fileName);??
  • ????????????????if?($this->debug)?exit(sprintf("%s?不允許下載",?$fileName));??
  • ????????????????return?false;??
  • ????????????}?else?{??
  • ????????????????if?(function_exists("mime_content_type"))?{??
  • ????????????????????$this->mineType?=?mime_content_type($fileName);??
  • ????????????????}??
  • ??
  • ????????????????if?(empty($this->mineType))?{??
  • ????????????????????if?(isset($this->xlq_filetype[$fileType]))?{??
  • ????????????????????????$this->mineType?=?$this->xlq_filetype[$fileType];??
  • ????????????????????}??
  • ????????????????}??
  • ??
  • ????????????????if?(!empty($this->mineType))?{??
  • ????????????????????return?true;??
  • ????????????????}?else?{??
  • ????????????????????$this->errorMsg?.=?"獲取文件類型出錯";??
  • ????????????????????if?($this->debug)?exit("獲取文件類型出錯");??
  • ????????????????????return?false;??
  • ????????????????}??
  • ????????????}??
  • ????????}?else?{??
  • ????????????$this->errorMsg?.=?sprintf("%s?不存在",?$fileName);??
  • ????????????if?($this->debug)?exit(sprintf("%s?不存在",?$fileName));??
  • ????????????return?false;??
  • ????????}??
  • ????}??
  • ??
  • ????function?setFileType()?{??
  • ????????$this->xlq_filetype['chm']?=?'application/octet-stream';??
  • ????????$this->xlq_filetype['ppt']?=?'application/vnd.ms-powerpoint';??
  • ????????$this->xlq_filetype['xls']?=?'application/vnd.ms-excel';??
  • ????????$this->xlq_filetype['doc']?=?'application/msword';??
  • ????????$this->xlq_filetype['exe']?=?'application/octet-stream';??
  • ????????$this->xlq_filetype['rar']?=?'application/octet-stream';??
  • ????????$this->xlq_filetype['js']?=?"javascript/js";??
  • ????????$this->xlq_filetype['css']?=?"text/css";??
  • ????????$this->xlq_filetype['hqx']?=?"application/mac-binhex40";??
  • ????????$this->xlq_filetype['bin']?=?"application/octet-stream";??
  • ????????$this->xlq_filetype['oda']?=?"application/oda";??
  • ????????$this->xlq_filetype['pdf']?=?"application/pdf";??
  • ????????$this->xlq_filetype['ai']?=?"application/postsrcipt";??
  • ????????$this->xlq_filetype['eps']?=?"application/postsrcipt";??
  • ????????$this->xlq_filetype['es']?=?"application/postsrcipt";??
  • ????????$this->xlq_filetype['rtf']?=?"application/rtf";??
  • ????????$this->xlq_filetype['mif']?=?"application/x-mif";??
  • ????????$this->xlq_filetype['csh']?=?"application/x-csh";??
  • ????????$this->xlq_filetype['dvi']?=?"application/x-dvi";??
  • ????????$this->xlq_filetype['hdf']?=?"application/x-hdf";??
  • ????????$this->xlq_filetype['nc']?=?"application/x-netcdf";??
  • ????????$this->xlq_filetype['cdf']?=?"application/x-netcdf";??
  • ????????$this->xlq_filetype['latex']?=?"application/x-latex";??
  • ????????$this->xlq_filetype['ts']?=?"application/x-troll-ts";??
  • ????????$this->xlq_filetype['src']?=?"application/x-wais-source";??
  • ????????$this->xlq_filetype['zip']?=?"application/zip";??
  • ????????$this->xlq_filetype['bcpio']?=?"application/x-bcpio";??
  • ????????$this->xlq_filetype['cpio']?=?"application/x-cpio";??
  • ????????$this->xlq_filetype['gtar']?=?"application/x-gtar";??
  • ????????$this->xlq_filetype['shar']?=?"application/x-shar";??
  • ????????$this->xlq_filetype['sv4cpio']?=?"application/x-sv4cpio";??
  • ????????$this->xlq_filetype['sv4crc']?=?"application/x-sv4crc";??
  • ????????$this->xlq_filetype['tar']?=?"application/x-tar";??
  • ????????$this->xlq_filetype['ustar']?=?"application/x-ustar";??
  • ????????$this->xlq_filetype['man']?=?"application/x-troff-man";??
  • ????????$this->xlq_filetype['sh']?=?"application/x-sh";??
  • ????????$this->xlq_filetype['tcl']?=?"application/x-tcl";??
  • ????????$this->xlq_filetype['tex']?=?"application/x-tex";??
  • ????????$this->xlq_filetype['texi']?=?"application/x-texinfo";??
  • ????????$this->xlq_filetype['texinfo']?=?"application/x-texinfo";??
  • ????????$this->xlq_filetype['t']?=?"application/x-troff";??
  • ????????$this->xlq_filetype['tr']?=?"application/x-troff";??
  • ????????$this->xlq_filetype['roff']?=?"application/x-troff";??
  • ????????$this->xlq_filetype['shar']?=?"application/x-shar";??
  • ????????$this->xlq_filetype['me']?=?"application/x-troll-me";??
  • ????????$this->xlq_filetype['ts']?=?"application/x-troll-ts";??
  • ????????$this->xlq_filetype['gif']?=?"image/gif";??
  • ????????$this->xlq_filetype['jpeg']?=?"image/pjpeg";??
  • ????????$this->xlq_filetype['jpg']?=?"image/pjpeg";??
  • ????????$this->xlq_filetype['jpe']?=?"image/pjpeg";??
  • ????????$this->xlq_filetype['ras']?=?"image/x-cmu-raster";??
  • ????????$this->xlq_filetype['pbm']?=?"image/x-portable-bitmap";??
  • ????????$this->xlq_filetype['ppm']?=?"image/x-portable-pixmap";??
  • ????????$this->xlq_filetype['xbm']?=?"image/x-xbitmap";??
  • ????????$this->xlq_filetype['xwd']?=?"image/x-xwindowdump";??
  • ????????$this->xlq_filetype['ief']?=?"image/ief";??
  • ????????$this->xlq_filetype['tif']?=?"image/tiff";??
  • ????????$this->xlq_filetype['tiff']?=?"image/tiff";??
  • ????????$this->xlq_filetype['pnm']?=?"image/x-portable-anymap";??
  • ????????$this->xlq_filetype['pgm']?=?"image/x-portable-graymap";??
  • ????????$this->xlq_filetype['rgb']?=?"image/x-rgb";??
  • ????????$this->xlq_filetype['xpm']?=?"image/x-xpixmap";??
  • ????????$this->xlq_filetype['txt']?=?"text/plain";??
  • ????????$this->xlq_filetype['c']?=?"text/plain";??
  • ????????$this->xlq_filetype['cc']?=?"text/plain";??
  • ????????$this->xlq_filetype['h']?=?"text/plain";??
  • ????????$this->xlq_filetype['html']?=?"text/html";??
  • ????????$this->xlq_filetype['htm']?=?"text/html";??
  • ????????$this->xlq_filetype['htl']?=?"text/html";??
  • ????????$this->xlq_filetype['rtx']?=?"text/richtext";??
  • ????????$this->xlq_filetype['etx']?=?"text/x-setext";??
  • ????????$this->xlq_filetype['tsv']?=?"text/tab-separated-values";??
  • ????????$this->xlq_filetype['mpeg']?=?"video/mpeg";??
  • ????????$this->xlq_filetype['mpg']?=?"video/mpeg";??
  • ????????$this->xlq_filetype['mpe']?=?"video/mpeg";??
  • ????????$this->xlq_filetype['avi']?=?"video/x-msvideo";??
  • ????????$this->xlq_filetype['qt']?=?"video/quicktime";??
  • ????????$this->xlq_filetype['mov']?=?"video/quicktime";??
  • ????????$this->xlq_filetype['moov']?=?"video/quicktime";??
  • ????????$this->xlq_filetype['movie']?=?"video/x-sgi-movie";??
  • ????????$this->xlq_filetype['au']?=?"audio/basic";??
  • ????????$this->xlq_filetype['snd']?=?"audio/basic";??
  • ????????$this->xlq_filetype['wav']?=?"audio/x-wav";??
  • ????????$this->xlq_filetype['aif']?=?"audio/x-aiff";??
  • ????????$this->xlq_filetype['aiff']?=?"audio/x-aiff";??
  • ????????$this->xlq_filetype['aifc']?=?"audio/x-aiff";??
  • ????????$this->xlq_filetype['swf']?=?"application/x-shockwave-flash";??
  • ????}??
  • ??
  • ????function?setFilter($fileFilter)?{??
  • ????????if?(empty($fileFilter))?return;??
  • ????????$this->filter?=?explode(",",?strtolower($fileFilter));??
  • ????}??
  • ??
  • ????function?setDebug($debug)?{??
  • ????????$this->debug?=?$debug;??
  • ????}??
  • ??
  • ????function?setlimittime($limittime)?{??
  • ????????$this->limitTime?=?$limittime;??
  • ????}??
  • ??
  • ????function?getfilename($filename)?{??
  • ????????return?$this->fileName;??
  • ????}??
  • ??
  • ????function?getErrorMsgs()?{??
  • ????????return?$this->errorMsg;??
  • ????}??
  • ??
  • ????function?__destruct()?{??
  • ????????$this->errorMsg?=?'';??
  • ????}??
  • }??
  • ?> ?
  • 總結

    以上是生活随笔為你收集整理的PHP文件下载过滤类的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 国产乡下妇女做爰视频 | 日本免费专区 | 色噜av | 超碰免费人人 | 日本免费网站视频 | 中文字幕久久久 | 女性向小h片资源在线观看 日本天天操 | 水蜜桃av在线 | 在线中文字幕播放 | 亚洲最新av在线 | 日本中文字幕免费 | 在线国产黄色 | 男女av| 在线观看日韩中文字幕 | 色午夜av| 国产精品一区二区三区四区 | 免费无码又爽又黄又刺激网站 | 成人免费观看视频大全 | 九色丨蝌蚪丨成人 | 欧美少妇一级片 | 老女人性视频 | 91丝袜国产在线观看 | 97免费在线观看 | 国产精品一级黄色片 | 91新网站| 亚洲精品激情 | 国产学生美女无遮拦高潮视频 | 开心激情亚洲 | 最近免费中文字幕大全免费版视频 | 欧美综合在线观看 | av波多野吉衣| 激情 亚洲 | 我们的生活第五季在线观看免费 | 欧美三级视频在线 | 在线黄色av | 亚洲乱码日产精品bd在线观看 | 理论片亚洲 | 久久国产成人精品国产成人亚洲 | 视色影视 | 日韩黄色免费看 | 香蕉视频99 | 免费看片黄色 | 欧美日批| www国产精品 | 亚洲av无码片一区二区三区 | 久草视频免费看 | 亚洲精品视频在线免费 | 国产v在线观看 | 国产电影一区二区三区爱妃记 | 成人午夜又粗又硬又大 | 亚洲欧洲免费视频 | 女人喷潮完整视频 | 亚洲精品无码久久久久久久 | 日本成人在线一区 | free性娇小hd第一次 | 黄色www网站 | 天天舔天天操 | 亚洲免费观看视频 | 毛片大全在线观看 | 成人免费毛片色戒 | 国产精品一区二区三区线羞羞网站 | 久久久综合 | 国产又粗又猛又爽又黄的视频一 | 日本一区二区三区在线观看视频 | 国产大屁股喷水视频在线观看 | 国产欧美日韩精品区一区二污污污 | 激情视频在线免费观看 | 茄子av在线 | 国产精品高潮呻吟久久av黑人 | 国产精品美女网站 | 爱爱免费网址 | 高清日韩一区 | 多男调教一女折磨高潮高h 国内毛片毛片毛片毛片毛片 | 理伦毛片 | 都市激情 自拍偷拍 | 天天干视频 | 欧美黑人性xxx | 亚洲熟妇无码av在线播放 | 欧美1区 | 欧美特一级 | 麻豆视频在线观看 | 午夜精品毛片 | 久久精品欧美视频 | 91精品婷婷国产综合久久蝌蚪 | 天天色综网 | 国产理论视频 | 国产精品免费无码 | 国产成人精品一区二区在线观看 | 影音先锋久久 | 久久无吗视频 | 精产国品一二三区 | 奇米影视在线播放 | 天堂欧美城网站网址 | av动漫免费看 | 午夜激情网址 | 伊人成年综合网 | 灌满闺乖女h高h调教尿h | 日本中文字幕不卡 | 色噜噜狠狠一区二区三区果冻 |