Source for file unzip.php

Documentation is available at unzip.php

  1. <?php
  2. /**
  3. * Unzip script.
  4. *
  5. * This script provides a quick and easy way to unzip the compressed containing various
  6. * Midwich data feeds.
  7. *
  8. * {@internal
  9. * The unzip function relies on you using a unix based system with the associated
  10. * compression libraries installed
  11. * }
  12. *
  13. * @version 1.00
  14. * @copyright Midwich Ltd. 2005
  15. * @author Midwich Ltd <Datafeed.Administration@Midwich.com>
  16. */
  17.  
  18. /**
  19. * Compressed data file location.
  20. * This is the location where the file gets transfered to by either ftp push/pull.
  21. * @access public
  22. * @var string
  23. * @example /home/httpd/vhosts/yourdomain.com/data/
  24. */
  25. var $MIDWICH_DATA_ZIP_LOCATION='/home/httpd/vhosts/yourdomain.com/data/';
  26. /**
  27. * Filename of the compressed data file.
  28. * This is the name of the file that gets transfered to by either ftp push/pull.
  29. * @access public
  30. * @var string
  31. * @example data.zip
  32. */
  33. var $MIDWICH_DATA_ZIP_NAME='data.zip';
  34. /**
  35. * Extracted data files location.
  36. * This is the location where the uncompressed data feed files get extracted to.
  37. * @access public
  38. * @var string
  39. * @example /home/httpd/vhosts/yourdomain.com/data/unzipped/
  40. */
  41. var $MIDWICH_DATA_FILES_DESTINATION='/home/httpd/vhosts/yourdomain.com/data/unzipped/';
  42.  
  43. /**
  44. * Unzip method.
  45. * This method copies the saource file into the same directory as where the data
  46. * is to be extracted to, then it removes the original source file. It then
  47. * changes to the extract directory and un-compresses the data files. Finally it
  48. * removes the compressed data file in the extraction directory.
  49. * @access public
  50. * @param string [$zip_file] name of the compressed data file.
  51. * @param string [$src_dir] location of the directory where the compressed data
  52. * file is located.
  53. * @param string [$extract_dir] location of the directory where the compressed
  54. * data file is to be extracted to.
  55. */
  56. function unzip($zip_file, $src_dir, $extract_dir)
  57. {
  58. copy($src_dir . $zip_file, $extract_dir . $zip_file);
  59. exec("rm -f " . $src_dir . $zip_file);
  60. chdir($extract_dir);
  61. shell_exec('unzip -uoq ' . $zip_file);
  62. exec("rm -f " . $extract_dir . $zip_file);
  63. }
  64.  
  65. unzip($MIDWICH_DATA_ZIP_NAME,$MIDWICH_DATA_ZIP_LOCATION,$MIDWICH_DATA_FILES_DESTINATION);
  66. ?>

Documentation generated on Thu, 15 Sep 2005 10:13:35 +0100 by phpDocumentor 1.3.0RC3