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