Nov 24

Compressor 不指定

felix021 @ 2007-11-24 10:47 [IT » 网络] 评论(0) , 引用(0) , 阅读(3819) | Via 本站原创 | |
I don't want to provide download link here.
If you need it, contact me in private.
You are not permitted to distribute it without my confirmation!


Class compressor (Version 2.1)   Written By Felix021 2007-11-24

Compress and uncompress files and folders, so you don't need to
upload/download a lot of bits and pieces using FTP.

http://www.19880711.com   All rights reserverd.
No safety guarantee. Use it at your own risk.

How to use it?
Examples:

1. Test whether your server have good support to compression

[codes=php]  require("compressor.php");
  $a = new compressor();
  $a->test();
?>[/codes]
Notice:
It doesn't matter if your server don't support compression.
You still can merge files into a single one, and split them as well.

2. Compress a folder:

[codes=php]  require("compressor.php");
  $a = new compressor;
  $a->SetSourceDir("blog");
  $a->SetFilelistName("blog.lst");
  $a->SetArchieveName("blog.fm");
  $a->compress(); // you'll see infomation while processing
  //show links to created files so you can download them
  $a->ListFiles();
  //the folder blog will be compressed to blog.fm
?>[/codes]
Notice:
The function will generate two files: one is blog.fm, the nother being
blog.lst (it is filelist.txt by default. Don't neglect filelist.txt, or
you will NOT be able to split the files!!!!
The folder blog itself WILL be included in the archieve.
If you set sourcedir =
  "blog" , folder blog will NOT be included.
  "./blog" ,  folder blog WILL be included.


3. Uncompress the file compressed above:

[codes=php]  require("compressor.php");
  $a = new compressor;
  $a->SetTargetDir(".");
  $a->SetFilelistName("blog.lst");
  $a->SetArchieveNmae("blog.fm");
  $a->uncompress(true); //you won't see any output.
  $a->DeleteFiles(); //Delete files you uploaded for uncompression.
  //the file blog.fm will be uncompressed to folder blog
?>[/codes]
Notice:
The function need two files: blog.fm and blog.lst.


Something important:

Use "." and ".." only at the begining of the path.



Function List:

1. compressor([$sourcedir = "source", [$targetdir = "target", [$filelist = "filelist.txt", [$archieve = "files.fm"]]]])
Called when an object of this class is created.
If parameters are not specified, they will be set to default value.

2. SetDefault()
Set all settings to default value.

3. test()
Test your server's support to compression.
It doesn't matter if your server don't support compression
(  function gzcompress() and  function gzuncompress()  ) .
You can upload the uncompressed file to your webspace.

4. SetSourceDir([$sourcedir = "source"])
If $sourcedir is not specified, it will be set to default value.
It's NOT RECOMMENDED you use  "."  or  ".." .

5. SetTargetDir([$targetdir = "target"])
If $targetdir is not specified, it will be set to default value.
Please notice that you can use  "."  or  "..",  but ".." is NOT RECOMMENDED.

6. SetFilelistName([$filelistname = "filelist.txt"])
If $filelistname is not specified, it will be set to default value.

7. SetArchieveName([$archievename = "files.fm"])
If $archievename is not specified, it will be set to default value.
And notice that if your server supports gzcompress(), $archievename.gz will be created.

8. compress([$silent = false])
Compress files and folders in $SourceDir.
If you call compress(true), output will not be generated, but be returned as a string.

9. uncompress([$silent = false])
Uncompress files and folders in $Archive or $Archieve.gz.
If you call compress(true), output will not be generated, but be returned as a string.
Please notice that, if your server support gzuncompress(), it will try $Archieve.gz at first;
If $Archieve.gz does not exist, then it will try $Archieve.

10. DeleteFiles([$mode = 7])
Delete files : $Filelist  $Archieve  $Archieve.gz
$mode: you can treat it as consisted of 3 bits which I call C,B,A
if neglected or be set greater than 7, it will be set to default value 7.
C, the highest bit, indicating $Archieve.gz.  C=1 means to delete it.
B, the middle bit, indicating $Archieve.  B=1 means to delete it.
A, the lowest bit, indicating $Filelist.gz.  A=1 means to delete it.
Notice that this function returns a value indicating which file is deleted
using the method described above.

11. ListFiles([$mode = 7])
List files specified by $mode.
It will list created files and show links to them so that you can download them conveniently.

12. Other functions (you are not supposed to call these functions)
filecontent($filename)  merge($dirname)  makedir($route)  IsCompressFile($filename)


Powered by Felix021. 2007-11-24



欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]