[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/files/types/ -> base.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\files\types;
  15  
  16  abstract class base implements type_interface
  17  {
  18      /** @var \phpbb\language\language */
  19      protected $language;
  20  
  21      /** @var \bantu\IniGetWrapper\IniGetWrapper */
  22      protected $php_ini;
  23  
  24      /** @var \phpbb\files\upload */
  25      protected $upload;
  26  
  27      /**
  28       * Check if upload exceeds maximum file size
  29       *
  30       * @param \phpbb\files\filespec $file Filespec object
  31       *
  32       * @return \phpbb\files\filespec Returns same filespec instance
  33       */
  34  	public function check_upload_size($file)
  35      {
  36          // PHP Upload filesize exceeded
  37          if ($file->get('filename') == 'none')
  38          {
  39              $max_filesize = $this->php_ini->getString('upload_max_filesize');
  40              $unit = 'MB';
  41  
  42              if (!empty($max_filesize))
  43              {
  44                  $unit = strtolower(substr($max_filesize, -1, 1));
  45                  $max_filesize = (int) $max_filesize;
  46  
  47                  $unit = ($unit == 'k') ? 'KB' : (($unit == 'g') ? 'GB' : 'MB');
  48              }
  49  
  50              $file->error[] = (empty($max_filesize)) ? $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_NA') : $this->language->lang($this->upload->error_prefix . 'PHP_SIZE_OVERRUN', $max_filesize, $this->language->lang($unit));
  51          }
  52  
  53          return $file;
  54      }
  55  
  56      /**
  57       * {@inheritdoc}
  58       */
  59  	public function set_upload(\phpbb\files\upload $upload)
  60      {
  61          $this->upload = $upload;
  62  
  63          return $this;
  64      }
  65  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1