[line
127]
This class is intented to perform Huffman static compression on files with a PHP script.
Such compression is essentially useful for reducing the size of texts by about 43% ; it is at its best when working with data containing strong redundancies at the character level -- that is, the opposite of a binary file in which the characters would be spread over the whole ASCII alphabet.
It is questionable whether anyone would want to do such an operation with PHP, when C implementations of much stronger and more versatile algorithms are readily avaible as PHP functions. The main drawback of this script class is slowness despite processing intensiveness (7 to 8 seconds to compress a 300Kb text, about 25 seconds to expand it back).
USE AND FUNCTION REFERENCE :
The 4 PHP files having been placed in the same directory, the only ones you have to include are compress.inc.php and/or expand.inc.php according to your needs.
----------------- -- Compression -- -----------------
Once a CPRS_Compress object has been constructed, the following functions are available :
- setFiles('path/to/source/file', 'path/to/destination/file'):
This step is mandatory, as you give the paths to the file you want to compress, and the file you want the compressed output written to. These paths will be passed to the PHP fopen() function, see its reference for details. Note that the paths, if local, should be relative to the location of _your_ script, i.e. the one that has included this compression class.
- setTimeLimit(int seconds):
This step is optional. It allows you to force a certain timeout limit for the PHP script, presumably longer than the default configuration on your server, should the job take too long. It simply calls the PHP set_time_limit() function.
This is the function that actually executes the job. It receives no parameters, and is of course obligatory.
--------------- -- Expansion -- ---------------
Once a CPRS_Expand object has been constructed, the following functions are available :
- setFiles('path/to/source/file', 'path/to/destination/file'):
This step is mandatory, as you give the paths to the file containing the compressed data, and the file you want the expanded output written to. These paths will be passed to the PHP fopen() function, see its reference for details. Note that the paths, if local, should be relative to the location of _your_ script, i.e. the one that has included this compression class.
- setTimeLimit(int seconds):
This step is optional. It allows you to force a certain timeout limit for the PHP script, presumably longer than the default configuration on your server, should the job take too long. It simply calls the PHP set_time_limit() function.
This is the function that actually executes the job. It receives no parameters, and is of course obligatory.
EXTRA NOTICE:
Please also note that some technical considerations apart from the core Huffman static algorithm have probably not been implemented after any standard in this class. That means that any other compressed file, even if you have reason to be certain that it was produced using the Huffman static algorithm, would in all probability not be usable as source file for data expansion with this class. In short, this class can very probably only restore what it itself compressed.
Anyway, thanks for using ! No feedback would be ignored. Feel free to tell me how you came in contact with this class, why you're using it (if at liberty to do so), and to suggest any enhancements, or of course to point out any serious bugs.