当前位置:编程学习 > php >>

PHP操作Zip

<?php   
 
     class PHPZip   
 
    {   
 
         private $ctrl_dir     = array();   
 
         private $datasec      = array();   
 
    
   
 
         /**********************************************************  
 
       * ѹ������  
 
        **********************************************************/  
 
        // ------------------------------------------------------ //   
 
         // #����ָ���ļ���   
 
        //   
 
        // $archive  = new PHPZip();   
 
        // $filelist = $archive->visitFile(�ļ���·��);   
 
        // print "��ǰ�ļ��е��ļ�:<p>\r\n";   
 
       // foreach($filelist as $file)   
 
        //     printf("%s<br>\r\n", $file);   
 
        // ------------------------------------------------------ //   
 
       var $fileList = array();   
 
        public function visitFile($path)   
 
        {   
 
             global $fileList;   
 
           $path = str_replace("\\", "/", $path);   
 
          $fdir = dir($path);   
 
            
           while(($file = $fdir->read()) !== false)   
          {   
 
              if($file == '.' || $file == '..'){ continue; }   
 
            
 
                $pathSub    = preg_replace("*/{2,}*", "/", $path."/".$file);  // �滻�����б��   
 
                $fileList[] = is_dir($pathSub) ? $pathSub."/" : $pathSub;   
 
            if(is_dir($pathSub)){ $this->visitFile($pathSub); }   
          }   
           $fdir->close();   
 
           return $fileList;   
 
       }   
 
            
 
 
        private function unix2DosTime($unixtime = 0)   
 
        {   
            $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);   
 
       
 
           if($timearray['year'] < 1980)   
           {   
 
              $timearray['year']    = 1980;   
                $timearray['mon']     = 1;   
                $timearray['mday']    = 1;   
                $timearray['hours']   = 0;   
                $timearray['minutes'] = 0;   
               $timearray['seconds'] = 0;   
            }   
        
            return (  ($timearray['year'] - 1980) << 25)   
 
                   | ($timearray['mon'] << 21)   
 
                 | ($timearray['mday'] << 16)   
                   | ($timearray['hours'] << 11)   
 
                   | ($timearray['minutes'] << 5)   
 
                  | ($timearray['seconds'] >> 1);   
 
        }   
 
            
 
            
 
        var $old_offset = 0;   
 
        private function addFile($data, $filename, $time = 0)   
    &nbs

补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,