首頁 > 後端開發 > php教程 > patch檔案 PHP檔案下載類

patch檔案 PHP檔案下載類

WBOY
發布: 2016-07-29 08:35:28
原創
1317 人瀏覽過

複製程式碼 程式碼如下:

   
//============================================= = = =======   
//   使用範例:   
// $download=new download('php,exe,html',false);   
//  if(!$download->downloadfile($filename))   
//  {   
//    echo $download->geterrormsg();   
//  }         
//======================================= == == =============   
類別下載{   
  var $debug=true;   
  var $errormsg='';   
  var $Filter=array();   
  var $filename='';   
  var $mineType='text/plain';   
  var $xlq_filetype=array();   
  函數下載($fileFilter='',$isdebug=true)   
  {   
    $this->setFilter($fileFilter);   
        $this->setdebug($isdebug);           
        $this->setfiletype();   
  }   
  函數 setFilter($fileFilter)   
  {   
    if(empty($fileFilter));   
        $this->Filter=explode(',',strtolower($fileFilter));   
  }   
  函數 setdebug($debug)   
  {   
    $1>debug=$debug;   
  }   
  函數 setfilename($filename)   
  {   
    $1>filename=$filename;   
  }   
  函數 downloadfile($filename)   
  {   
    $this->setname($filename);   
    if($this->filecheck())   
        {    
   '\', '/' ) ) );
          header(“Pragma: public”);   
      header(「過渡時間:0」)  // 過渡時間post-check=0, pre -check=0”);   
          header(「內容類型:".$this->mineType);   
   header(「內容寄件:附件;filename="$fn"」);   
      header('中傳輸編碼:二進位');   
   🎜>    回$this->errormsg;   
  }   
  function filecheck()   
  {   
    $filename=$this->filename;   
        if(file_exists($filename))   
        {    )));   
           if(in_array($filetype,$this->Filter))   
        >errormsg.=$filename.'不允許下載!   
                 if($this->debug) exit($filename.' 不允許下載!') ;   
                返回 false;   
           }其他   
           {   
            if  function_exists( "mime_content_type" ) )   
                 {   
           $this->mineType = mime_content_type( $filename );   
         }   
                    {   
                    if( isset($this-& ->xlq_filetype[$filetype];   
                 }   
                         回復 true;   
                 else   
                  $this->errormsg.='取得'.$filename.'檔案類型時發生錯誤,或預先存在的檔案類型';   
                        if($this->debug) exit('取得檔案類型錯誤);   
                        返回 false;   
                }   
           }    
        } 否則   
        {   
          $this->errormsg.=$filename.'不存在!' ;   
          if($this->debug) exit($filename.'不存在!') ;   
          返回 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-settext";   
    $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']="音訊/基本";   
    $this->xlq_filetype['snd']="音訊/基本";   
    $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";   
  }   
}   

以上就介紹了patch檔案的PHP檔案下載類,包含patch檔案方面的內容,希望對PHP教學有興趣的朋友得到幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板