Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

local.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 3.00 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\files\types;
015   
016  use bantu\IniGetWrapper\IniGetWrapper;
017  use phpbb\files\factory;
018  use phpbb\files\filespec;
019  use phpbb\language\language;
020  use phpbb\request\request_interface;
021   
022  class local extends base
023  {
024      /** @var factory Files factory */
025      protected $factory;
026   
027      /** @var language */
028      protected $language;
029   
030      /** @var IniGetWrapper */
031      protected $php_ini;
032   
033      /** @var request_interface */
034      protected $request;
035   
036      /** @var \phpbb\files\upload */
037      protected $upload;
038   
039      /**
040       * Construct a form upload type
041       *
042       * @param factory $factory Files factory
043       * @param language $language Language class
044       * @param IniGetWrapper $php_ini ini_get() wrapper
045       * @param request_interface $request Request object
046       */
047      public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, request_interface $request)
048      {
049          $this->factory = $factory;
050          $this->language = $language;
051          $this->php_ini = $php_ini;
052          $this->request = $request;
053      }
054   
055      /**
056       * {@inheritdoc}
057       */
058      public function upload()
059      {
060          $args = func_get_args();
061          return $this->local_upload($args[0], isset($args[1]) ? $args[1] : false);
062      }
063   
064      /**
065       * Move file from another location to phpBB
066       *
067       * @param string $source_file Filename of source file
068       * @param array|bool $filedata Array with filedata or false
069       *
070       * @return filespec Object "filespec" is returned, all further operations can be done with this object
071       */
072      protected function local_upload($source_file, $filedata = false)
073      {
074          $upload = $this->get_upload_ary($source_file, $filedata);
075   
076          /** @var filespec $file */
077          $file = $this->factory->get('filespec')
078              ->set_upload_ary($upload)
079              ->set_upload_namespace($this->upload);
080   
081          if ($file->init_error())
082          {
083              $file->error[] = '';
084              return $file;
085          }
086   
087          // PHP Upload file size check
088          $file = $this->check_upload_size($file);
089          if (count($file->error))
090          {
091              return $file;
092          }
093   
094          // Not correctly uploaded
095          if (!$file->is_uploaded())
096          {
097              $file->error[] = $this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED');
098              return $file;
099          }
100   
101          $this->upload->common_checks($file);
102          $this->request->overwrite('local', $upload, request_interface::FILES);
103   
104          return $file;
105      }
106   
107      /**
108       * Retrieve upload array
109       *
110       * @param string $source_file Source file name
111       * @param array $filedata File data array
112       *
113       * @return array Upload array
114       */
115      protected function get_upload_ary($source_file, $filedata)
116      {
117          $upload = array();
118   
119          $upload['local_mode'] = true;
120          $upload['tmp_name'] = $source_file;
121   
122          if ($filedata === false)
123          {
124              $upload['name'] = utf8_basename($source_file);
125              $upload['size'] = 0;
126          }
127          else
128          {
129              $upload['name'] = $filedata['realname'];
130              $upload['size'] = $filedata['size'];
131              $upload['type'] = $filedata['type'];
132          }
133   
134          return $upload;
135      }
136  }
137