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

form.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 3.10 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\plupload\plupload;
021  use phpbb\request\request_interface;
022   
023  class form extends base
024  {
025      /** @var factory Files factory */
026      protected $factory;
027   
028      /** @var language */
029      protected $language;
030   
031      /** @var IniGetWrapper */
032      protected $php_ini;
033   
034      /** @var plupload */
035      protected $plupload;
036   
037      /** @var request_interface */
038      protected $request;
039   
040      /** @var \phpbb\files\upload */
041      protected $upload;
042   
043      /**
044       * Construct a form upload type
045       *
046       * @param factory            $factory    Files factory
047       * @param language            $language    Language class
048       * @param IniGetWrapper        $php_ini    ini_get() wrapper
049       * @param plupload            $plupload    Plupload
050       * @param request_interface    $request    Request object
051       */
052      public function __construct(factory $factory, language $language, IniGetWrapper $php_ini, plupload $plupload, request_interface $request)
053      {
054          $this->factory = $factory;
055          $this->language = $language;
056          $this->php_ini = $php_ini;
057          $this->plupload = $plupload;
058          $this->request = $request;
059      }
060   
061      /**
062       * {@inheritdoc}
063       */
064      public function upload()
065      {
066          $args = func_get_args();
067          return $this->form_upload($args[0]);
068      }
069   
070      /**
071       * Form upload method
072       * Upload file from users harddisk
073       *
074       * @param string $form_name Form name assigned to the file input field (if it is an array, the key has to be specified)
075       *
076       * @return filespec $file Object "filespec" is returned, all further operations can be done with this object
077       * @access public
078       */
079      protected function form_upload($form_name)
080      {
081          $upload = $this->request->file($form_name);
082          unset($upload['local_mode']);
083   
084          $result = $this->plupload->handle_upload($form_name);
085          if (is_array($result))
086          {
087              $upload = array_merge($upload, $result);
088          }
089   
090          /** @var filespec $file */
091          $file = $this->factory->get('filespec')
092              ->set_upload_ary($upload)
093              ->set_upload_namespace($this->upload);
094   
095          if ($file->init_error())
096          {
097              $file->error[] = '';
098              return $file;
099          }
100   
101          // Error array filled?
102          if (isset($upload['error']))
103          {
104              $error = $this->upload->assign_internal_error($upload['error']);
105   
106              if ($error !== false)
107              {
108                  $file->error[] = $error;
109                  return $file;
110              }
111          }
112   
113          // Check if empty file got uploaded (not catched by is_uploaded_file)
114          if (isset($upload['size']) && $upload['size'] == 0)
115          {
116              $file->error[] = $this->language->lang($this->upload->error_prefix . 'EMPTY_FILEUPLOAD');
117              return $file;
118          }
119   
120          // PHP Upload file size check
121          $file = $this->check_upload_size($file);
122          if (count($file->error))
123          {
124              return $file;
125          }
126   
127          // Not correctly uploaded
128          if (!$file->is_uploaded())
129          {
130              $file->error[] = $this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED');
131              return $file;
132          }
133   
134          $this->upload->common_checks($file);
135   
136          return $file;
137      }
138  }
139