@@ -2,7 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Filemanager\Handler { |
4 | 4 | |
5 | - use Modules\Filemanager, Date, Explorer, Mime, Number, Template; |
|
5 | + use Modules\Filemanager; |
|
6 | + use Date; |
|
7 | + use Explorer; |
|
8 | + use Mime; |
|
9 | + use Number; |
|
10 | + use Template; |
|
6 | 11 | |
7 | 12 | class File extends Filemanager\Utils\Handler { |
8 | 13 |
@@ -2,7 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace Utils { |
4 | 4 | |
5 | - use Modules\Informer, Utils\Messages, Explorer, Language, Request; |
|
5 | + use Modules\Informer; |
|
6 | + use Utils\Messages; |
|
7 | + use Explorer; |
|
8 | + use Language; |
|
9 | + use Request; |
|
6 | 10 | |
7 | 11 | abstract class Uploader { |
8 | 12 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | |
60 | 60 | # Check target file |
61 | 61 | |
62 | - $file_name = ($dir_name . '/' . basename($file['name'])); |
|
62 | + $file_name = ($dir_name.'/'.basename($file['name'])); |
|
63 | 63 | |
64 | 64 | if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
65 | 65 |
@@ -10,19 +10,33 @@ discard block |
||
10 | 10 | |
11 | 11 | private static function translateError(int $error) { |
12 | 12 | |
13 | - if ($error === UPLOAD_ERR_INI_SIZE) return 'UPLOADER_ERROR_INI_SIZE'; |
|
13 | + if ($error === UPLOAD_ERR_INI_SIZE) { |
|
14 | + return 'UPLOADER_ERROR_INI_SIZE'; |
|
15 | + } |
|
14 | 16 | |
15 | - if ($error === UPLOAD_ERR_FORM_SIZE) return 'UPLOADER_ERROR_FORM_SIZE'; |
|
17 | + if ($error === UPLOAD_ERR_FORM_SIZE) { |
|
18 | + return 'UPLOADER_ERROR_FORM_SIZE'; |
|
19 | + } |
|
16 | 20 | |
17 | - if ($error === UPLOAD_ERR_PARTIAL) return 'UPLOADER_ERROR_PARTIAL'; |
|
21 | + if ($error === UPLOAD_ERR_PARTIAL) { |
|
22 | + return 'UPLOADER_ERROR_PARTIAL'; |
|
23 | + } |
|
18 | 24 | |
19 | - if ($error === UPLOAD_ERR_NO_FILE) return 'UPLOADER_ERROR_NO_FILE'; |
|
25 | + if ($error === UPLOAD_ERR_NO_FILE) { |
|
26 | + return 'UPLOADER_ERROR_NO_FILE'; |
|
27 | + } |
|
20 | 28 | |
21 | - if ($error === UPLOAD_ERR_NO_TMP_DIR) return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
29 | + if ($error === UPLOAD_ERR_NO_TMP_DIR) { |
|
30 | + return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
31 | + } |
|
22 | 32 | |
23 | - if ($error === UPLOAD_ERR_CANT_WRITE) return 'UPLOADER_ERROR_CANT_WRITE'; |
|
33 | + if ($error === UPLOAD_ERR_CANT_WRITE) { |
|
34 | + return 'UPLOADER_ERROR_CANT_WRITE'; |
|
35 | + } |
|
24 | 36 | |
25 | - if ($error === UPLOAD_ERR_EXTENSION) return 'UPLOADER_ERROR_EXTENSION'; |
|
37 | + if ($error === UPLOAD_ERR_EXTENSION) { |
|
38 | + return 'UPLOADER_ERROR_EXTENSION'; |
|
39 | + } |
|
26 | 40 | |
27 | 41 | # ------------------------ |
28 | 42 | |
@@ -33,19 +47,27 @@ discard block |
||
33 | 47 | |
34 | 48 | public static function save(string $name, string $dir_name) { |
35 | 49 | |
36 | - if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) return false; |
|
50 | + if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) { |
|
51 | + return false; |
|
52 | + } |
|
37 | 53 | |
38 | 54 | # Check for demo mode |
39 | 55 | |
40 | - if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION'; |
|
56 | + if (Informer::isDemoMode()) { |
|
57 | + return 'DEMO_MODE_RESTRICTION'; |
|
58 | + } |
|
41 | 59 | |
42 | 60 | # Check for upload errors |
43 | 61 | |
44 | - if ($file['error'] !== UPLOAD_ERR_OK) return self::translateError($file['error']); |
|
62 | + if ($file['error'] !== UPLOAD_ERR_OK) { |
|
63 | + return self::translateError($file['error']); |
|
64 | + } |
|
45 | 65 | |
46 | 66 | # Check size |
47 | 67 | |
48 | - if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) return 'UPLOADER_ERROR_SIZE'; |
|
68 | + if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) { |
|
69 | + return 'UPLOADER_ERROR_SIZE'; |
|
70 | + } |
|
49 | 71 | |
50 | 72 | # Check file extension |
51 | 73 | |
@@ -53,21 +75,29 @@ discard block |
||
53 | 75 | |
54 | 76 | $extension = strtolower(Explorer::extension($file['name'], false)); |
55 | 77 | |
56 | - if (in_array($extension, $extensions, true)) return 'UPLOADER_ERROR_TYPE'; |
|
78 | + if (in_array($extension, $extensions, true)) { |
|
79 | + return 'UPLOADER_ERROR_TYPE'; |
|
80 | + } |
|
57 | 81 | |
58 | 82 | # Check target directory |
59 | 83 | |
60 | - if (!Explorer::isDir($dir_name)) return 'UPLOADER_ERROR_DIR'; |
|
84 | + if (!Explorer::isDir($dir_name)) { |
|
85 | + return 'UPLOADER_ERROR_DIR'; |
|
86 | + } |
|
61 | 87 | |
62 | 88 | # Check target file |
63 | 89 | |
64 | 90 | $file_name = ($dir_name . '/' . basename($file['name'])); |
65 | 91 | |
66 | - if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
|
92 | + if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) { |
|
93 | + return 'UPLOADER_ERROR_EXISTS'; |
|
94 | + } |
|
67 | 95 | |
68 | 96 | # Save uploaded file |
69 | 97 | |
70 | - if (!@move_uploaded_file($file['tmp_name'], $file_name)) return 'UPLOADER_ERROR_SAVE'; |
|
98 | + if (!@move_uploaded_file($file['tmp_name'], $file_name)) { |
|
99 | + return 'UPLOADER_ERROR_SAVE'; |
|
100 | + } |
|
71 | 101 | |
72 | 102 | # ------------------------ |
73 | 103 |
@@ -2,7 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | # Check PHP version |
4 | 4 | |
5 | -if (version_compare(PHP_VERSION, '7.0.0') < 0) exit('PHP version 7 or higher is required.'); |
|
5 | +if (version_compare(PHP_VERSION, '7.0.0') < 0) { |
|
6 | + exit('PHP version 7 or higher is required.'); |
|
7 | +} |
|
6 | 8 | |
7 | 9 | # Set error reporting |
8 | 10 | |
@@ -37,9 +39,11 @@ discard block |
||
37 | 39 | |
38 | 40 | # Require class file |
39 | 41 | |
40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
41 | - |
|
42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
42 | + if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) { |
|
43 | + require_once $file_name; |
|
44 | + } else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) { |
|
45 | + require_once $file_name; |
|
46 | + } |
|
43 | 47 | |
44 | 48 | # Check if class exists |
45 | 49 | |
@@ -50,5 +54,7 @@ discard block |
||
50 | 54 | |
51 | 55 | # Call autoload method |
52 | 56 | |
53 | - if (method_exists($class_name, '__autoload')) $class_name::__autoload(); |
|
54 | -}); |
|
57 | + if (method_exists($class_name, '__autoload')) { |
|
58 | + $class_name::__autoload(); |
|
59 | + } |
|
60 | + }); |
@@ -10,18 +10,18 @@ discard block |
||
10 | 10 | |
11 | 11 | # Define constants |
12 | 12 | |
13 | -define('DIR_ENGINE', (dirname(__FILE__) . '/')); |
|
13 | +define('DIR_ENGINE', (dirname(__FILE__).'/')); |
|
14 | 14 | |
15 | -define('DIR_WWW', (DIR_ENGINE . '../')); |
|
16 | -define('DIR_UPLOADS', (DIR_ENGINE . '../uploads/')); |
|
15 | +define('DIR_WWW', (DIR_ENGINE.'../')); |
|
16 | +define('DIR_UPLOADS', (DIR_ENGINE.'../uploads/')); |
|
17 | 17 | |
18 | 18 | # Require framework main file |
19 | 19 | |
20 | -require_once(DIR_ENGINE . 'Framework/Main.php'); |
|
20 | +require_once(DIR_ENGINE.'Framework/Main.php'); |
|
21 | 21 | |
22 | 22 | # Require system main file |
23 | 23 | |
24 | -require_once(DIR_ENGINE . 'System/Main.php'); |
|
24 | +require_once(DIR_ENGINE.'System/Main.php'); |
|
25 | 25 | |
26 | 26 | # Register classes autoloader |
27 | 27 | |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | |
34 | 34 | $system_classes = ['Frames', 'Handlers', 'Modules', 'Utils', 'Views', 'Dispatcher', 'Installer']; |
35 | 35 | |
36 | - $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES) . implode('/', $path)); |
|
36 | + $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES).implode('/', $path)); |
|
37 | 37 | |
38 | 38 | # Require class file |
39 | 39 | |
40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
40 | + if (@file_exists($file_name = ($path.'.php')) && @is_file($file_name)) require_once $file_name; |
|
41 | 41 | |
42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
42 | + else if (@file_exists($file_name = ($path.'/'.$last.'.php')) && @is_file($file_name)) require_once $file_name; |
|
43 | 43 | |
44 | 44 | # Check if class exists |
45 | 45 |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Form { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Form; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Form; |
|
6 | 7 | |
7 | 8 | class Widget extends Form { |
8 | 9 |
@@ -49,9 +49,13 @@ |
||
49 | 49 | |
50 | 50 | public static function url(string $value) { |
51 | 51 | |
52 | - if (false === ($value = parent::url($value))) return false; |
|
52 | + if (false === ($value = parent::url($value))) { |
|
53 | + return false; |
|
54 | + } |
|
53 | 55 | |
54 | - if (!preg_match('/^https?:\/\//', $value)) return false; |
|
56 | + if (!preg_match('/^https?:\/\//', $value)) { |
|
57 | + return false; |
|
58 | + } |
|
55 | 59 | |
56 | 60 | # ------------------------ |
57 | 61 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | $number = number_format(($number / pow(1024, $exponent)), (($exponent < 2) ? $exponent : 2)); |
48 | 48 | |
49 | - return (floatval($number) . ' ' . $text); |
|
49 | + return (floatval($number).' '.$text); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | # ------------------------ |
@@ -17,11 +17,17 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function forceInt($number, int $min = 0, int $max = 0) { |
19 | 19 | |
20 | - if (!is_numeric($number) || (($number = intval($number)) < 0)) $number = 0; |
|
20 | + if (!is_numeric($number) || (($number = intval($number)) < 0)) { |
|
21 | + $number = 0; |
|
22 | + } |
|
21 | 23 | |
22 | - if (($min > 0) && ($number < $min)) return $min; |
|
24 | + if (($min > 0) && ($number < $min)) { |
|
25 | + return $min; |
|
26 | + } |
|
23 | 27 | |
24 | - if (($max > 0) && ($number > $max)) return $max; |
|
28 | + if (($max > 0) && ($number > $max)) { |
|
29 | + return $max; |
|
30 | + } |
|
25 | 31 | |
26 | 32 | # ------------------------ |
27 | 33 | |
@@ -34,11 +40,17 @@ discard block |
||
34 | 40 | |
35 | 41 | public static function forceFloat($number, float $min = 0, float $max = 0, int $decimals = 0) { |
36 | 42 | |
37 | - if (!is_numeric($number) || (($number = floatval($number)) < 0)) $number = 0; |
|
43 | + if (!is_numeric($number) || (($number = floatval($number)) < 0)) { |
|
44 | + $number = 0; |
|
45 | + } |
|
38 | 46 | |
39 | - if (($min > 0) && ($number < $min)) $number = $min; |
|
47 | + if (($min > 0) && ($number < $min)) { |
|
48 | + $number = $min; |
|
49 | + } |
|
40 | 50 | |
41 | - if (($max > 0) && ($number > $max)) $number = $max; |
|
51 | + if (($max > 0) && ($number > $max)) { |
|
52 | + $number = $max; |
|
53 | + } |
|
42 | 54 | |
43 | 55 | $number = floatval(number_format($number, $decimals, '.', '')); |
44 | 56 | |
@@ -55,9 +67,11 @@ discard block |
||
55 | 67 | |
56 | 68 | $number = (($number >= 0) ? $number : 0); $exponents = [0 => 'Bytes', 'KB', 'MB', 'GB', 'TB']; |
57 | 69 | |
58 | - foreach ($exponents as $exponent => $text) if ($number < pow(1024, ($exponent + 1))) { |
|
70 | + foreach ($exponents as $exponent => $text) { |
|
71 | + if ($number < pow(1024, ($exponent + 1))) { |
|
59 | 72 | |
60 | 73 | $number = number_format(($number / pow(1024, $exponent)), (($exponent < 2) ? $exponent : 2)); |
74 | + } |
|
61 | 75 | |
62 | 76 | return (floatval($number) . ' ' . $text); |
63 | 77 | } |
@@ -79,13 +93,21 @@ discard block |
||
79 | 93 | |
80 | 94 | $last_1 = substr($number, ($length - 1), 1); $last_2 = substr($number, ($length - 2), 2); |
81 | 95 | |
82 | - if (($last_2 >= 11) && ($last_2 <= 20)) return $form_5; |
|
96 | + if (($last_2 >= 11) && ($last_2 <= 20)) { |
|
97 | + return $form_5; |
|
98 | + } |
|
83 | 99 | |
84 | - if ($last_1 == 1) return $form_1; |
|
100 | + if ($last_1 == 1) { |
|
101 | + return $form_1; |
|
102 | + } |
|
85 | 103 | |
86 | - if (($last_1 >= 2) && ($last_1 <= 4)) return $form_3; |
|
104 | + if (($last_1 >= 2) && ($last_1 <= 4)) { |
|
105 | + return $form_3; |
|
106 | + } |
|
87 | 107 | |
88 | - if (($last_1 >= 5) || ($last_1 == 0)) return $form_5; |
|
108 | + if (($last_1 >= 5) || ($last_1 == 0)) { |
|
109 | + return $form_5; |
|
110 | + } |
|
89 | 111 | } |
90 | 112 | } |
91 | 113 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public static function __autoload() { |
14 | 14 | |
15 | - self::init(DIR_DATA . 'Geo/Countries.php'); |
|
15 | + self::init(DIR_DATA.'Geo/Countries.php'); |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public static function __autoload() { |
14 | 14 | |
15 | - self::init(DIR_DATA . 'Geo/Timezones.php'); |
|
15 | + self::init(DIR_DATA.'Geo/Timezones.php'); |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | public static function status(string $code) { |
119 | 119 | |
120 | - if (self::isStatusCode($code)) header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
120 | + if (self::isStatusCode($code)) header(getenv('SERVER_PROTOCOL').' '.self::$status_codes[$code]); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | # Send content header |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | |
127 | 127 | if (self::isContentTypeText($type)) { |
128 | 128 | |
129 | - return header('Content-type: ' . self::$content_types_text[$type] . '; charset=UTF-8'); |
|
129 | + return header('Content-type: '.self::$content_types_text[$type].'; charset=UTF-8'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | if (self::isContentTypeMedia($type)) { |
133 | 133 | |
134 | - return header('Content-type: ' . self::$content_types_media[$type]); |
|
134 | + return header('Content-type: '.self::$content_types_media[$type]); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | |
144 | 144 | if (!in_array($limiter, [CACHE_LIMITER_PRIVATE, CACHE_LIMITER_PUBLIC], true)) return; |
145 | 145 | |
146 | - header('Expires: ' . gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)) . ' GMT'); |
|
146 | + header('Expires: '.gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)).' GMT'); |
|
147 | 147 | |
148 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', REQUEST_TIME) . ' GMT'); |
|
148 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', REQUEST_TIME).' GMT'); |
|
149 | 149 | |
150 | - header('Cache-Control: ' . $limiter . ', max-age=' . $expires . ', pre-check=' . $expires); |
|
150 | + header('Cache-Control: '.$limiter.', max-age='.$expires.', pre-check='.$expires); |
|
151 | 151 | |
152 | - header('Pragma: ' . $limiter); |
|
152 | + header('Pragma: '.$limiter); |
|
153 | 153 | |
154 | 154 | # ------------------------ |
155 | 155 | |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | |
163 | 163 | if (self::$cache_send) return; |
164 | 164 | |
165 | - header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
|
165 | + header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('-1 day')).' GMT'); |
|
166 | 166 | |
167 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
|
167 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', strtotime('-1 day')).' GMT'); |
|
168 | 168 | |
169 | 169 | header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); |
170 | 170 |
@@ -134,7 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | public static function sendStatus(int $code) { |
136 | 136 | |
137 | - if (self::isStatusCode($code)) header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
137 | + if (self::isStatusCode($code)) { |
|
138 | + header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
139 | + } |
|
138 | 140 | } |
139 | 141 | |
140 | 142 | /** |
@@ -160,7 +162,9 @@ discard block |
||
160 | 162 | |
161 | 163 | public static function sendCache(int $expires, bool $public = false) { |
162 | 164 | |
163 | - if (self::$cache_sent) return; |
|
165 | + if (self::$cache_sent) { |
|
166 | + return; |
|
167 | + } |
|
164 | 168 | |
165 | 169 | header('Expires: ' . gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)) . ' GMT'); |
166 | 170 | |
@@ -183,7 +187,9 @@ discard block |
||
183 | 187 | |
184 | 188 | public static function sendNoCache() { |
185 | 189 | |
186 | - if (self::$cache_sent) return; |
|
190 | + if (self::$cache_sent) { |
|
191 | + return; |
|
192 | + } |
|
187 | 193 | |
188 | 194 | header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
189 | 195 |