Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: klasa ZIP TAR/GZIP/ZIP ARCHIVE CLASSES
Forum PHP.pl > Forum > Gotowe rozwi±zania
ozzy88
Witam, dopad³em na necie klase do pakowania i wypakowywania plików ZIP ale niewiem jak j± obs³ugiwaæ... mo¿e kto¶ co¶ podpowiedzieæ??

  1. <?php
  2. /*--------------------------------------------------
  3.  | TAR/GZIP/ZIP ARCHIVE CLASSES
  4.  | By Devin Doucette
  5.  | Copyright (c) 2003 Devin Doucette
  6.  | Email: darksnoopy@shaw.ca
  7.  +--------------------------------------------------
  8.  | Email bugs/suggestions to darksnoopy@shaw.ca
  9.  +--------------------------------------------------
  10.  | This script has been created and released under
  11.  | the GNU GPL and is free to use and redistribute
  12.  | only if this copyright statement is not removed
  13.  +--------------------------------------------------*/
  14.  
  15. /*------------------------------------------------------------
  16.  | To create tar files:
  17.  | $example = new tarfile($cwd,$flags); // args optional
  18.  | -current working directory
  19.  | -flags (array):
  20.  | -overwrite - whether to overwrite existing files or return
  21.  | an error message
  22.  | -defaultperms - default file permissions (like chmod(),
  23.  | must include 0 in front of value [eg. 0777, 0644])
  24.  | -recursesd[1,0] - whether or not to include subdirs
  25.  | -storepath[1,0] - whether or not to store relative paths
  26.  | -replacestats[array] - values to replace those from files
  27.  |  -mode - same as the result of a fileperms() call
  28.  |  -uid/gid - user/group id
  29.  |  -time - timestamp
  30.  |  -type - file type (5=dir,1=link,0=file)
  31.  |  -link - the file that is linked to
  32.  |  -path - only supported in USTAR, not recommended
  33.  +------------------------------------------------------------*/
  34.  
  35. /*------------------------------------------------------------
  36.  | To create gzip files:
  37.  | $example = new gzfile($cwd,$flags); // args optional
  38.  | -current working directory
  39.  | -flags (array):
  40.  | -overwrite - whether to overwrite existing files or return
  41.  | an error message
  42.  | -defaultperms - default file permissions (like chmod(),
  43.  | must include 0 in front of value [eg. 0777, 0644])
  44.  +------------------------------------------------------------*/
  45.  
  46. /*------------------------------------------------------------
  47.  | To create zip files:
  48.  | $example = new zipfile($cwd,$flags); // args optional
  49.  | -current working directory
  50.  | -flags (array):
  51.  | -overwrite - whether to overwrite existing files or return
  52.  | an error message
  53.  | -defaultperms - default file permissions (like chmod(),
  54.  | must include 0 in front of value [eg. 0777, 0644])
  55.  | -time - timestamp to use to replace the mtime from files
  56.  | -recursesd[1,0] - whether or not to include subdirs
  57.  | -storepath[1,0] - whether or not to store relative paths
  58.  | -level[0-9] - compression level (0 = none, 9 = max)
  59.  | -comment - comment to add to the archive
  60.  +------------------------------------------------------------*/
  61.  
  62. /*------------------------------------------------------------
  63.  | To add files:
  64.  | $example->addfile($data,$filename,$flags);
  65.  | -data - file contents
  66.  | -filename - name of file to be put in archive
  67.  | -flags (all flags are optional)
  68.  | -flags (tar) [array]: -same flags as tarfile()
  69.  | -flags (gzip) [string]: -comment to add to archive
  70.  | -flags (zip) [array] -time - last modification time
  71.  |
  72.  | $example->addfiles($filelist); // tar and zip only
  73.  | -filelist - array of file names relative to CWD
  74.  |
  75.  | $example->adddirectories($dirlist); // tar and zip only
  76.  | -dirlist - array of directory names relative to CWD
  77.  +------------------------------------------------------------*/
  78.  
  79. /*------------------------------------------------------------
  80.  | To output files:
  81.  | $example->getdata();
  82.  | -returns file contents
  83.  |
  84.  | $example->filedownload($filename);
  85.  | -filename - the name to give the file that is being sent
  86.  |
  87.  | $example->filewrite($filename,$perms); // perms optional
  88.  | -filename - the name (including path) of the file to write
  89.  | -perms - permissions to give the file after it is written
  90.  +------------------------------------------------------------*/
  91.  
  92. /*------------------------------------------------------------
  93.  | To extract files (tar and gzip)
  94.  | $example->extract($data);
  95.  | -data - data to extract files from
  96.  | -returns an array containing file attributes and contents
  97.  |
  98.  | $example->extractfile($filename);
  99.  | -filename - the name (including path) of the file to use
  100.  | -returns an array containing file attributes and contents
  101.  |
  102.  | Both functions will return a string containing any errors
  103.  +------------------------------------------------------------*/
  104. ?>


----------
Po co tyle kodu -- forum sie rozsypuje.
Daj linka do klasy, a jeszcze lepiej przeczytaj to co jest w komentarzach tej klasy.
--
dr_bonzo
hwao
  1. <?php
  2. /*------------------------------------------------------------
  3.  | To extract files (tar and gzip)
  4.  | $example->extract($data);
  5.  | -data - data to extract files from
  6.  | -returns an array containing file attributes and contents
  7.  |
  8.  | $example->extractfile($filename);
  9.  | -filename - the name (including path) of the file to use
  10.  | -returns an array containing file attributes and contents
  11.  |
  12.  | Both functions will return a string containing any errors
  13.  +------------------------------------------------------------*/
  14. ?>


  1. <?php
  2. $example = new tarfile(); // args optional );
  3. $a = $example->extractfile( './plik.gzip' );
  4. print_r( $a );
  5. ?>
dr_bonzo
No tak, zapomnialem przeniesc... >> Gotowe skrypty
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.