Maison > php教程 > php手册 > le corps du texte

php文件在线压缩程序类(1/2)

WBOY
Libérer: 2016-06-13 11:24:51
original
1038 Les gens l'ont consulté

php文件在线压缩程序类 提供一款超完美的php文件在线压缩程序,原理很简单就是把文件以二进制形式保存了,以前用过利用rar的内核程序,这是php自带的压缩功能。

php教程文件在线压缩程序类
 提供一款超完美的php文件在线压缩程序,原理很简单就是把文件以二进制形式保存了,以前用过利用rar的内核程序,这是php自带的压缩功能。
*/

set_time_limit(0);
class phpzip{

    var $file_count = 0 ;
    var $datastr_len   = 0;
    var $dirstr_len = 0;
    var $filedata = ''; //该变量只被类外部程序访问
    var $gzfilename;
    var $fp;
    var $dirstr='';

    /*
    返回文件的修改时间格式.
    只为本类内部函数调用.
    */
    function unix2dostime($unixtime = 0) {
        $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);

        if ($timearray['year']         $timearray['year']    = 1980;
        $timearray['mon']     = 1;
        $timearray['mday']    = 1;
        $timearray['hours']   = 0;
        $timearray['minutes'] = 0;
        $timearray['seconds'] = 0;
        }

        return (($timearray['year'] - 1980)                ($timearray['hours'] > 1);
    }
    /*
    初始化文件,建立文件目录,
    并返回文件的写入权限.
    */
    function startfile($path = 'faisun.zip'){
       $this->gzfilename=$path;
       $mypathdir=array();
       do{
        $mypathdir[] = $path = dirname($path);
       }while($path != '.');
       @end($mypathdir);
       do{
        $path = @current($mypathdir);
        @mkdir($path);
       }while(@prev($mypathdir));

       if($this->fp=@fopen($this->gzfilename,"w")){
        return true;
       }
       return false;
    }
    /*
    添加一个文件到 zip 压缩包中.
    */
   

1 2

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!