Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

compression_file_updater.php

Zuletzt modifiziert: 09.10.2024, 12:55 - Dateigröße: 2.67 KiB


 001  <?php
 002  /**
 003   *
 004   * This file is part of the phpBB Forum Software package.
 005   *
 006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007   * @license GNU General Public License, version 2 (GPL-2.0)
 008   *
 009   * For full copyright and license information, please see
 010   * the docs/CREDITS.txt file.
 011   *
 012   */
 013   
 014  namespace phpbb\install\helper\file_updater;
 015   
 016  use phpbb\install\helper\update_helper;
 017   
 018  /**
 019   * File updater for generating archive with updated files
 020   */
 021  class compression_file_updater implements file_updater_interface
 022  {
 023      /**
 024       * @var \compress
 025       */
 026      protected $compress;
 027   
 028      /**
 029       * @var update_helper
 030       */
 031      protected $update_helper;
 032   
 033      /**
 034       * @var string
 035       */
 036      protected $phpbb_root_path;
 037   
 038      /**
 039       * @var string
 040       */
 041      protected $php_ext;
 042   
 043      /**
 044       * Constructor
 045       *
 046       * @param update_helper    $update_helper
 047       * @param string        $phpbb_root_path
 048       * @param string        $php_ext
 049       */
 050      public function __construct(update_helper $update_helper, $phpbb_root_path, $php_ext)
 051      {
 052          $this->compress            = null;
 053          $this->update_helper    = $update_helper;
 054          $this->phpbb_root_path    = $phpbb_root_path;
 055          $this->php_ext            = $php_ext;
 056      }
 057   
 058      /**
 059       * Set the compression method
 060       *
 061       * @param string    $method    Compression method's file extension
 062       *
 063       * @return string    Archive's filename
 064       */
 065      public function init($method)
 066      {
 067          $this->update_helper->include_file('includes/functions_compress.' . $this->php_ext);
 068   
 069          $archive_filename = 'update_archive_' . time() . '_' . uniqid();
 070          $path = $this->phpbb_root_path . 'store/' . $archive_filename . '' . $method;
 071   
 072          if ($method === '.zip')
 073          {
 074              $this->compress = new \compress_zip('w', $path);
 075          }
 076          else
 077          {
 078              $this->compress = new \compress_tar('w', $path, $method);
 079          }
 080   
 081          return $path;
 082      }
 083   
 084      /**
 085       * Close archive writing process
 086       */
 087      public function close()
 088      {
 089          $this->compress->close();
 090      }
 091   
 092      /**
 093       * {@inheritdoc}
 094       */
 095      public function delete_file($path_to_file)
 096      {
 097          // We do absolutely nothing here, as this function is called when a file should be
 098          // removed from the filesystem, but since this is an archive generator, it clearly
 099          // cannot do that.
 100      }
 101   
 102      /**
 103       * {@inheritdoc}
 104       */
 105      public function create_new_file($path_to_file_to_create, $source, $create_from_content = false)
 106      {
 107          if ($create_from_content)
 108          {
 109              $this->compress->add_data($source, $path_to_file_to_create);
 110          }
 111          else
 112          {
 113              $this->compress->add_custom_file($source, $path_to_file_to_create);
 114          }
 115      }
 116   
 117      /**
 118       * {@inheritdoc}
 119       */
 120      public function update_file($path_to_file_to_update, $source, $create_from_content = false)
 121      {
 122          // Both functions are identical here
 123          $this->create_new_file($path_to_file_to_update, $source, $create_from_content);
 124      }
 125   
 126      /**
 127       * {@inheritdoc}
 128       */
 129      public function get_method_name()
 130      {
 131          return 'compression';
 132      }
 133  }
 134