Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Kompresja zip wypakowuje wszystkie pliki do folderu root, nie tworzy subfolderów...
Johnas
post
Post #1





Grupa: Zarejestrowani
Postów: 650
Pomógł: 16
Dołączył: 5.07.2010
Skąd: Ściśle Tajne

Ostrzeżenie: (0%)
-----


witam, mam taki kod do kompresowania plików pod ZIP...

  1. $rootPath = realpath('./');
  2. $zip = new ZipArchive;
  3. $zip->open('update-'.$version.'.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
  4. $files = new RecursiveIteratorIterator(
  5. new RecursiveDirectoryIterator($rootPath),
  6. RecursiveIteratorIterator::LEAVES_ONLY
  7. );
  8.  
  9. foreach ($files as $name => $file)
  10. {
  11. // Skip directories (they would be added automatically)
  12. if (!$file->isDir())
  13. {
  14. // Get real and relative path for current file
  15. $filePath = $file->getRealPath();
  16. $relativePath = substr($filePath, strlen($rootPath) + 1);
  17.  
  18. // Add current file to archive
  19. if (strpos($relativePath, "nstall\\") or strpos($relativePath, "ake-update.php") or strpos($relativePath, "old\\") or strpos($relativePath, "zepsuty") or strpos($relativePath, "lobal\config.php") or strpos($relativePath, "vs\\") or strpos($relativePath, "git\\") or strpos($relativePath, "idea\\") or strpos($relativePath, "pload\\") or strpos($relativePath, "cache\\") or strpos($relativePath, 'ploads\\') or strpos($relativePath, "emplates_c")) {
  20. echo "Ignoruje ".$relativePath."</br>";
  21. } else {
  22. echo "Dodano plik: ".$relativePath."</br>";
  23. $zip->addFile($filePath, $filePath);
  24. }
  25. }
  26. }
  27.  
  28. // Zip archive will be created only after closing object
  29. $zip->close();


i kiedy wypakowuje to wszystkie pliki wyrzuca mi do folderu... nie tworzy mi subfolderów i nie wypakowuje plików z subfolderów do nich

Wytłumaczy mi ktoś dlaczego ten z**any PHP tak wypakowuje pliki ?

(IMG:https://oxi-jon.pl/gowno.jpg)

(IMG:https://oxi-jon.pl/gowno2.jpg)




Dziękuję za tak wyczerpujące odpowiedzi.... Jesteście fantastyczni,,,

Czy naprawdę PHP jest tak zje**ane że nie można kompresować plików za pomocą niego ? Może wprowadzą to w wersji 50.0.49 ?

a propos wypakowywania:

  1. define('_PATH', dirname(__FILE__));
  2.  
  3. // Zip file name
  4. $filename = 'update-0.0.1-alpha.zip';
  5. $zip = new ZipArchive;
  6. $res = $zip->open($filename);
  7. if ($res === TRUE) {
  8.  
  9. // Unzip path
  10. $path = _PATH."/";
  11.  
  12. // Extract file
  13. $zip->extractTo($path);
  14. $zip->close();
  15.  
  16. echo 'Aktualizacja zakończona pomyślnie!';
  17. } else {
  18. echo 'Błąd aktualizacji! Skontaktuj się z firmą <a href="mailto:kontakt@oxi-jon.pl">Bomb of Creative</a>!';
  19. }


robię to w ten piękny sposób... nie wiem czy może można jeszcze inaczej coś tu napisać bo to jest tak ****cie obszerny kod że pisałem go przez 4 lata świetlne

Ten post edytował Johnas 20.08.2022, 21:42:45
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 10:18