Documentation is available at unzip.php
- <?php
- /**
- * Unzip script.
- *
- * This script provides a quick and easy way to unzip the compressed containing various
- * Midwich data feeds.
- *
- * {@internal
- * The unzip function relies on you using a unix based system with the associated
- * compression libraries installed
- * }
- *
- * @version 1.00
- * @copyright Midwich Ltd. 2005
- * @author Midwich Ltd <Datafeed.Administration@Midwich.com>
- */
- /**
- * Compressed data file location.
- * This is the location where the file gets transfered to by either ftp push/pull.
- * @access public
- * @var string
- * @example /home/httpd/vhosts/yourdomain.com/data/
- */
- var $MIDWICH_DATA_ZIP_LOCATION='/home/httpd/vhosts/yourdomain.com/data/';
- /**
- * Filename of the compressed data file.
- * This is the name of the file that gets transfered to by either ftp push/pull.
- * @access public
- * @var string
- * @example data.zip
- */
- var $MIDWICH_DATA_ZIP_NAME='data.zip';
- /**
- * Extracted data files location.
- * This is the location where the uncompressed data feed files get extracted to.
- * @access public
- * @var string
- * @example /home/httpd/vhosts/yourdomain.com/data/unzipped/
- */
- var $MIDWICH_DATA_FILES_DESTINATION='/home/httpd/vhosts/yourdomain.com/data/unzipped/';
- /**
- * Unzip method.
- * This method copies the saource file into the same directory as where the data
- * is to be extracted to, then it removes the original source file. It then
- * changes to the extract directory and un-compresses the data files. Finally it
- * removes the compressed data file in the extraction directory.
- * @access public
- * @param string [$zip_file] name of the compressed data file.
- * @param string [$src_dir] location of the directory where the compressed data
- * file is located.
- * @param string [$extract_dir] location of the directory where the compressed
- * data file is to be extracted to.
- */
- function unzip($zip_file, $src_dir, $extract_dir)
- {
- copy($src_dir . $zip_file, $extract_dir . $zip_file);
- exec("rm -f " . $src_dir . $zip_file);
- chdir($extract_dir);
- shell_exec('unzip -uoq ' . $zip_file);
- exec("rm -f " . $extract_dir . $zip_file);
- }
- unzip($MIDWICH_DATA_ZIP_NAME,$MIDWICH_DATA_ZIP_LOCATION,$MIDWICH_DATA_FILES_DESTINATION);
- ?>