@@ -29,13 +29,19 @@ discard block |
||
29 | 29 | |
30 | 30 | # Validate name |
31 | 31 | |
32 | - if (false === ($name = Validate::templateComponentName($name))) return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
|
32 | + if (false === ($name = Validate::templateComponentName($name))) { |
|
33 | + return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Check name exists |
35 | 37 | |
36 | - if (false === ($check_name = $this->widget->check($name, 'name'))) return 'WIDGET_ERROR_MODIFY'; |
|
38 | + if (false === ($check_name = $this->widget->check($name, 'name'))) { |
|
39 | + return 'WIDGET_ERROR_MODIFY'; |
|
40 | + } |
|
37 | 41 | |
38 | - if ($check_name === 1) return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
42 | + if ($check_name === 1) { |
|
43 | + return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
44 | + } |
|
39 | 45 | |
40 | 46 | # Modify widget |
41 | 47 | |
@@ -48,7 +54,9 @@ discard block |
||
48 | 54 | |
49 | 55 | $modifier = ((0 === $this->widget->id) ? 'create' : 'edit'); |
50 | 56 | |
51 | - if (!$this->widget->$modifier($data)) return 'WIDGET_ERROR_MODIFY'; |
|
57 | + if (!$this->widget->$modifier($data)) { |
|
58 | + return 'WIDGET_ERROR_MODIFY'; |
|
59 | + } |
|
52 | 60 | |
53 | 61 | # ------------------------ |
54 | 62 |
@@ -31,4 +31,6 @@ |
||
31 | 31 | |
32 | 32 | # Set error reporting |
33 | 33 | |
34 | -if (DEBUG_MODE) error_reporting(E_ALL); |
|
34 | +if (DEBUG_MODE) { |
|
35 | + error_reporting(E_ALL); |
|
36 | +} |
@@ -9,32 +9,32 @@ |
||
9 | 9 | |
10 | 10 | # Define directories |
11 | 11 | |
12 | -define('DIR_SYSTEM', (dirname(__FILE__) . '/')); |
|
12 | +define('DIR_SYSTEM', (dirname(__FILE__).'/')); |
|
13 | 13 | |
14 | -define('DIR_SYSTEM_CLASSES', (DIR_SYSTEM . 'Classes/')); |
|
15 | -define('DIR_SYSTEM_DATA', (DIR_SYSTEM . 'Data/')); |
|
16 | -define('DIR_SYSTEM_INCLUDES', (DIR_SYSTEM . 'Includes/')); |
|
17 | -define('DIR_SYSTEM_LANGUAGES', (DIR_SYSTEM . 'Languages/')); |
|
18 | -define('DIR_SYSTEM_TEMPLATES', (DIR_SYSTEM . 'Templates/')); |
|
14 | +define('DIR_SYSTEM_CLASSES', (DIR_SYSTEM.'Classes/')); |
|
15 | +define('DIR_SYSTEM_DATA', (DIR_SYSTEM.'Data/')); |
|
16 | +define('DIR_SYSTEM_INCLUDES', (DIR_SYSTEM.'Includes/')); |
|
17 | +define('DIR_SYSTEM_LANGUAGES', (DIR_SYSTEM.'Languages/')); |
|
18 | +define('DIR_SYSTEM_TEMPLATES', (DIR_SYSTEM.'Templates/')); |
|
19 | 19 | |
20 | 20 | # Require classes |
21 | 21 | |
22 | -require_once (DIR_SYSTEM . 'Exception.php'); |
|
22 | +require_once (DIR_SYSTEM.'Exception.php'); |
|
23 | 23 | |
24 | 24 | # Require configuration |
25 | 25 | |
26 | -require_once (DIR_SYSTEM_INCLUDES . 'Constants.php'); |
|
27 | -require_once (DIR_SYSTEM_INCLUDES . 'Config.php'); |
|
28 | -require_once (DIR_SYSTEM_INCLUDES . 'Regex.php'); |
|
29 | -require_once (DIR_SYSTEM_INCLUDES . 'Tables.php'); |
|
26 | +require_once (DIR_SYSTEM_INCLUDES.'Constants.php'); |
|
27 | +require_once (DIR_SYSTEM_INCLUDES.'Config.php'); |
|
28 | +require_once (DIR_SYSTEM_INCLUDES.'Regex.php'); |
|
29 | +require_once (DIR_SYSTEM_INCLUDES.'Tables.php'); |
|
30 | 30 | |
31 | 31 | # Set environment constants |
32 | 32 | |
33 | -define('HTTP_MOD_REWRITE', ($_SERVER['HTTP_MOD_REWRITE'] === 'on')); |
|
33 | +define('HTTP_MOD_REWRITE', ($_SERVER['HTTP_MOD_REWRITE'] === 'on')); |
|
34 | 34 | |
35 | -define('INSTALL_PATH', rtrim($_SERVER['INSTALL_PATH'], '/')); |
|
35 | +define('INSTALL_PATH', rtrim($_SERVER['INSTALL_PATH'], '/')); |
|
36 | 36 | |
37 | -define('DEBUG_MODE', @file_exists(DIR_SYSTEM_DATA . '.debug')); |
|
37 | +define('DEBUG_MODE', @file_exists(DIR_SYSTEM_DATA.'.debug')); |
|
38 | 38 | |
39 | 39 | # Set error reporting |
40 | 40 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | if ('' === static::$file_name) return null; |
77 | 77 | |
78 | - $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
|
78 | + $file_name = (DIR_SYSTEM_DATA.static::$file_name); |
|
79 | 79 | |
80 | 80 | if (null === ($data = JSON::load($file_name))) return null; |
81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | if ('' === static::$file_name) return false; |
94 | 94 | |
95 | - $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
|
95 | + $file_name = (DIR_SYSTEM_DATA.static::$file_name); |
|
96 | 96 | |
97 | 97 | if (null === ($data = $this->validate($data))) return false; |
98 | 98 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | if ('' === static::$file_name) return false; |
111 | 111 | |
112 | - $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
|
112 | + $file_name = (DIR_SYSTEM_DATA.static::$file_name); |
|
113 | 113 | |
114 | 114 | return (!Explorer::isFile($file_name) || Explorer::removeFile($file_name)); |
115 | 115 | } |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | protected function addArray(string $name) { |
29 | 29 | |
30 | - if ('' !== $name) return $this->properties[$name] = new _Array; |
|
30 | + if ('' !== $name) { |
|
31 | + return $this->properties[$name] = new _Array; |
|
32 | + } |
|
31 | 33 | } |
32 | 34 | |
33 | 35 | /** |
@@ -36,7 +38,9 @@ discard block |
||
36 | 38 | |
37 | 39 | protected function addBoolean(string $name) { |
38 | 40 | |
39 | - if ('' !== $name) return $this->properties[$name] = new _Boolean; |
|
41 | + if ('' !== $name) { |
|
42 | + return $this->properties[$name] = new _Boolean; |
|
43 | + } |
|
40 | 44 | } |
41 | 45 | |
42 | 46 | /** |
@@ -45,7 +49,9 @@ discard block |
||
45 | 49 | |
46 | 50 | protected function addInteger(string $name) { |
47 | 51 | |
48 | - if ('' !== $name) return $this->properties[$name] = new _Integer; |
|
52 | + if ('' !== $name) { |
|
53 | + return $this->properties[$name] = new _Integer; |
|
54 | + } |
|
49 | 55 | } |
50 | 56 | |
51 | 57 | /** |
@@ -54,7 +60,9 @@ discard block |
||
54 | 60 | |
55 | 61 | protected function addObject(string $name) { |
56 | 62 | |
57 | - if ('' !== $name) return $this->properties[$name] = new _Object; |
|
63 | + if ('' !== $name) { |
|
64 | + return $this->properties[$name] = new _Object; |
|
65 | + } |
|
58 | 66 | } |
59 | 67 | |
60 | 68 | /** |
@@ -63,7 +71,9 @@ discard block |
||
63 | 71 | |
64 | 72 | protected function addString(string $name) { |
65 | 73 | |
66 | - if ('' !== $name) return $this->properties[$name] = new _String; |
|
74 | + if ('' !== $name) { |
|
75 | + return $this->properties[$name] = new _String; |
|
76 | + } |
|
67 | 77 | } |
68 | 78 | |
69 | 79 | /** |
@@ -74,13 +84,17 @@ discard block |
||
74 | 84 | |
75 | 85 | public function validate($data) { |
76 | 86 | |
77 | - if (!is_array($data)) return null; |
|
87 | + if (!is_array($data)) { |
|
88 | + return null; |
|
89 | + } |
|
78 | 90 | |
79 | 91 | $result = []; |
80 | 92 | |
81 | 93 | foreach ($this->properties as $name => $property) { |
82 | 94 | |
83 | - if (!isset($data[$name]) || (null === ($value = $property->validate($data[$name])))) return null; |
|
95 | + if (!isset($data[$name]) || (null === ($value = $property->validate($data[$name])))) { |
|
96 | + return null; |
|
97 | + } |
|
84 | 98 | |
85 | 99 | $result[$name] = $value; |
86 | 100 | } |
@@ -98,13 +112,19 @@ discard block |
||
98 | 112 | |
99 | 113 | public function load() { |
100 | 114 | |
101 | - if ('' === static::$file_name) return null; |
|
115 | + if ('' === static::$file_name) { |
|
116 | + return null; |
|
117 | + } |
|
102 | 118 | |
103 | 119 | $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
104 | 120 | |
105 | - if (null === ($data = JSON::load($file_name))) return null; |
|
121 | + if (null === ($data = JSON::load($file_name))) { |
|
122 | + return null; |
|
123 | + } |
|
106 | 124 | |
107 | - if (null === ($data = $this->validate($data))) return null; |
|
125 | + if (null === ($data = $this->validate($data))) { |
|
126 | + return null; |
|
127 | + } |
|
108 | 128 | |
109 | 129 | # ------------------------ |
110 | 130 | |
@@ -119,13 +139,19 @@ discard block |
||
119 | 139 | |
120 | 140 | public function save(array $data) : bool { |
121 | 141 | |
122 | - if ('' === static::$file_name) return false; |
|
142 | + if ('' === static::$file_name) { |
|
143 | + return false; |
|
144 | + } |
|
123 | 145 | |
124 | 146 | $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
125 | 147 | |
126 | - if (null === ($data = $this->validate($data))) return false; |
|
148 | + if (null === ($data = $this->validate($data))) { |
|
149 | + return false; |
|
150 | + } |
|
127 | 151 | |
128 | - if (false === JSON::save($file_name, $data)) return false; |
|
152 | + if (false === JSON::save($file_name, $data)) { |
|
153 | + return false; |
|
154 | + } |
|
129 | 155 | |
130 | 156 | # ------------------------ |
131 | 157 | |
@@ -140,7 +166,9 @@ discard block |
||
140 | 166 | |
141 | 167 | public function remove() : bool { |
142 | 168 | |
143 | - if ('' === static::$file_name) return false; |
|
169 | + if ('' === static::$file_name) { |
|
170 | + return false; |
|
171 | + } |
|
144 | 172 | |
145 | 173 | $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
146 | 174 |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | public static function sendStatus(int $code) { |
136 | 136 | |
137 | - if (self::isStatusCode($code)) header($_SERVER['SERVER_PROTOCOL'] . ' ' . self::$status_codes[$code]); |
|
137 | + if (self::isStatusCode($code)) header($_SERVER['SERVER_PROTOCOL'].' '.self::$status_codes[$code]); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | |
146 | 146 | if (self::isTextContentType($type)) { |
147 | 147 | |
148 | - return header('Content-type: ' . self::$content_types_text[$type] . '; charset=UTF-8'); |
|
148 | + return header('Content-type: '.self::$content_types_text[$type].'; charset=UTF-8'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | if (self::isMediaContentType($type)) { |
152 | 152 | |
153 | - return header('Content-type: ' . self::$content_types_media[$type]); |
|
153 | + return header('Content-type: '.self::$content_types_media[$type]); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | |
163 | 163 | if (self::$cache_sent) return; |
164 | 164 | |
165 | - header('Expires: ' . gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)) . ' GMT'); |
|
165 | + header('Expires: '.gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)).' GMT'); |
|
166 | 166 | |
167 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', REQUEST_TIME) . ' GMT'); |
|
167 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', REQUEST_TIME).' GMT'); |
|
168 | 168 | |
169 | 169 | $limiter = ($public ? 'public' : 'private'); |
170 | 170 | |
171 | - header('Cache-Control: ' . $limiter . ', max-age=' . $expires . ', pre-check=' . $expires); |
|
171 | + header('Cache-Control: '.$limiter.', max-age='.$expires.', pre-check='.$expires); |
|
172 | 172 | |
173 | - header('Pragma: ' . $limiter); |
|
173 | + header('Pragma: '.$limiter); |
|
174 | 174 | |
175 | 175 | # ------------------------ |
176 | 176 | |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | |
186 | 186 | if (self::$cache_sent) return; |
187 | 187 | |
188 | - header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
|
188 | + header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('-1 day')).' GMT'); |
|
189 | 189 | |
190 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
|
190 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', strtotime('-1 day')).' GMT'); |
|
191 | 191 | |
192 | 192 | header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); |
193 | 193 |
@@ -134,7 +134,9 @@ discard block |
||
134 | 134 | |
135 | 135 | public static function sendStatus(int $code) { |
136 | 136 | |
137 | - if (self::isStatusCode($code)) header($_SERVER['SERVER_PROTOCOL'] . ' ' . self::$status_codes[$code]); |
|
137 | + if (self::isStatusCode($code)) { |
|
138 | + header($_SERVER['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 |
@@ -21,9 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | private static function search(array &$list) : bool { |
23 | 23 | |
24 | - if (empty($_SERVER['HTTP_USER_AGENT'])) return false; |
|
24 | + if (empty($_SERVER['HTTP_USER_AGENT'])) { |
|
25 | + return false; |
|
26 | + } |
|
25 | 27 | |
26 | - foreach ($list as $item) if (false !== stripos($_SERVER['HTTP_USER_AGENT'], $item)) return true; |
|
28 | + foreach ($list as $item) { |
|
29 | + if (false !== stripos($_SERVER['HTTP_USER_AGENT'], $item)) return true; |
|
30 | + } |
|
27 | 31 | |
28 | 32 | # ------------------------ |
29 | 33 | |
@@ -40,9 +44,13 @@ discard block |
||
40 | 44 | |
41 | 45 | $file_robots = (DIR_DATA . 'Agent/Robots.php'); |
42 | 46 | |
43 | - if (is_array($mobiles = Explorer::include($file_mobiles))) self::$mobiles = $mobiles; |
|
47 | + if (is_array($mobiles = Explorer::include($file_mobiles))) { |
|
48 | + self::$mobiles = $mobiles; |
|
49 | + } |
|
44 | 50 | |
45 | - if (is_array($robots = Explorer::include($file_robots))) self::$robots = $robots; |
|
51 | + if (is_array($robots = Explorer::include($file_robots))) { |
|
52 | + self::$robots = $robots; |
|
53 | + } |
|
46 | 54 | } |
47 | 55 | |
48 | 56 | /** |
@@ -36,9 +36,9 @@ |
||
36 | 36 | |
37 | 37 | public static function __autoload() { |
38 | 38 | |
39 | - $file_mobiles = (DIR_DATA . 'Agent/Mobiles.php'); |
|
39 | + $file_mobiles = (DIR_DATA.'Agent/Mobiles.php'); |
|
40 | 40 | |
41 | - $file_robots = (DIR_DATA . 'Agent/Robots.php'); |
|
41 | + $file_robots = (DIR_DATA.'Agent/Robots.php'); |
|
42 | 42 | |
43 | 43 | if (is_array($mobiles = Explorer::include($file_mobiles))) self::$mobiles = $mobiles; |
44 | 44 |
@@ -23,15 +23,23 @@ discard block |
||
23 | 23 | |
24 | 24 | // Ignore error to avoid warning when trying to connect to unavailable host |
25 | 25 | |
26 | - if (false === ($link = @mysqli_connect($server, $user, $password))) throw new Exception\DBConnect; |
|
26 | + if (false === ($link = @mysqli_connect($server, $user, $password))) { |
|
27 | + throw new Exception\DBConnect; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | # Set encoding |
29 | 31 | |
30 | - if (!mysqli_query($link, "SET character_set_client = 'utf8'")) throw new Exception\DBCharset; |
|
32 | + if (!mysqli_query($link, "SET character_set_client = 'utf8'")) { |
|
33 | + throw new Exception\DBCharset; |
|
34 | + } |
|
31 | 35 | |
32 | - if (!mysqli_query($link, "SET character_set_results = 'utf8'")) throw new Exception\DBCharset; |
|
36 | + if (!mysqli_query($link, "SET character_set_results = 'utf8'")) { |
|
37 | + throw new Exception\DBCharset; |
|
38 | + } |
|
33 | 39 | |
34 | - if (!mysqli_query($link, "SET collation_connection = 'utf8_general_ci'")) throw new Exception\DBCharset; |
|
40 | + if (!mysqli_query($link, "SET collation_connection = 'utf8_general_ci'")) { |
|
41 | + throw new Exception\DBCharset; |
|
42 | + } |
|
35 | 43 | |
36 | 44 | # ------------------------ |
37 | 45 | |
@@ -44,7 +52,9 @@ discard block |
||
44 | 52 | |
45 | 53 | public static function name(string $name) { |
46 | 54 | |
47 | - if (!mysqli_select_db(self::$link, $name)) throw new Exception\DBSelect; |
|
55 | + if (!mysqli_select_db(self::$link, $name)) { |
|
56 | + throw new Exception\DBSelect; |
|
57 | + } |
|
48 | 58 | } |
49 | 59 | |
50 | 60 | /** |
@@ -55,7 +65,9 @@ discard block |
||
55 | 65 | |
56 | 66 | public static function send(string $query) { |
57 | 67 | |
58 | - if (null === self::$link) return (self::$last = false); |
|
68 | + if (null === self::$link) { |
|
69 | + return (self::$last = false); |
|
70 | + } |
|
59 | 71 | |
60 | 72 | $time = microtime(true); $result = mysqli_query(self::$link, $query); $time = (microtime(true) - $time); |
61 | 73 |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | # Check target file |
65 | 65 | |
66 | - $base_name = basename($file['name']); $file_name = ($dir_name . '/' . $base_name); |
|
66 | + $base_name = basename($file['name']); $file_name = ($dir_name.'/'.$base_name); |
|
67 | 67 | |
68 | 68 | if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
69 | 69 |
@@ -60,7 +60,7 @@ |
||
60 | 60 | /** |
61 | 61 | * Save an uploaded file |
62 | 62 | * |
63 | - * @return true|string|false : true on success, an error code on failure, or false if there are no uploaded files |
|
63 | + * @return string|boolean : true on success, an error code on failure, or false if there are no uploaded files |
|
64 | 64 | */ |
65 | 65 | |
66 | 66 | public static function save(string $name, string $dir_name) { |
@@ -21,19 +21,33 @@ discard block |
||
21 | 21 | |
22 | 22 | private static function getErrorCode(int $error) : string { |
23 | 23 | |
24 | - if ($error === UPLOAD_ERR_INI_SIZE) return 'UPLOADER_ERROR_INI_SIZE'; |
|
24 | + if ($error === UPLOAD_ERR_INI_SIZE) { |
|
25 | + return 'UPLOADER_ERROR_INI_SIZE'; |
|
26 | + } |
|
25 | 27 | |
26 | - if ($error === UPLOAD_ERR_FORM_SIZE) return 'UPLOADER_ERROR_FORM_SIZE'; |
|
28 | + if ($error === UPLOAD_ERR_FORM_SIZE) { |
|
29 | + return 'UPLOADER_ERROR_FORM_SIZE'; |
|
30 | + } |
|
27 | 31 | |
28 | - if ($error === UPLOAD_ERR_PARTIAL) return 'UPLOADER_ERROR_PARTIAL'; |
|
32 | + if ($error === UPLOAD_ERR_PARTIAL) { |
|
33 | + return 'UPLOADER_ERROR_PARTIAL'; |
|
34 | + } |
|
29 | 35 | |
30 | - if ($error === UPLOAD_ERR_NO_FILE) return 'UPLOADER_ERROR_NO_FILE'; |
|
36 | + if ($error === UPLOAD_ERR_NO_FILE) { |
|
37 | + return 'UPLOADER_ERROR_NO_FILE'; |
|
38 | + } |
|
31 | 39 | |
32 | - if ($error === UPLOAD_ERR_NO_TMP_DIR) return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
40 | + if ($error === UPLOAD_ERR_NO_TMP_DIR) { |
|
41 | + return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
42 | + } |
|
33 | 43 | |
34 | - if ($error === UPLOAD_ERR_CANT_WRITE) return 'UPLOADER_ERROR_CANT_WRITE'; |
|
44 | + if ($error === UPLOAD_ERR_CANT_WRITE) { |
|
45 | + return 'UPLOADER_ERROR_CANT_WRITE'; |
|
46 | + } |
|
35 | 47 | |
36 | - if ($error === UPLOAD_ERR_EXTENSION) return 'UPLOADER_ERROR_EXTENSION'; |
|
48 | + if ($error === UPLOAD_ERR_EXTENSION) { |
|
49 | + return 'UPLOADER_ERROR_EXTENSION'; |
|
50 | + } |
|
37 | 51 | |
38 | 52 | # ------------------------ |
39 | 53 | |
@@ -50,7 +64,11 @@ discard block |
||
50 | 64 | |
51 | 65 | $text = Language::get($phrase); |
52 | 66 | |
53 | - if (!$popup) Messages::set('error', $text); else Popup::set('negative', $text); |
|
67 | + if (!$popup) { |
|
68 | + Messages::set('error', $text); |
|
69 | + } else { |
|
70 | + Popup::set('negative', $text); |
|
71 | + } |
|
54 | 72 | |
55 | 73 | # ------------------------ |
56 | 74 | |
@@ -65,19 +83,27 @@ discard block |
||
65 | 83 | |
66 | 84 | public static function save(string $name, string $dir_name) { |
67 | 85 | |
68 | - if (false === ($file = Request::file($name))) return false; |
|
86 | + if (false === ($file = Request::file($name))) { |
|
87 | + return false; |
|
88 | + } |
|
69 | 89 | |
70 | 90 | # Check for upload errors |
71 | 91 | |
72 | - if ($file['error'] !== UPLOAD_ERR_OK) return self::getErrorCode($file['error']); |
|
92 | + if ($file['error'] !== UPLOAD_ERR_OK) { |
|
93 | + return self::getErrorCode($file['error']); |
|
94 | + } |
|
73 | 95 | |
74 | 96 | # Check for secure upload |
75 | 97 | |
76 | - if (!is_uploaded_file($file['tmp_name'])) return 'UPLOADER_ERROR_SECURITY'; |
|
98 | + if (!is_uploaded_file($file['tmp_name'])) { |
|
99 | + return 'UPLOADER_ERROR_SECURITY'; |
|
100 | + } |
|
77 | 101 | |
78 | 102 | # Check size |
79 | 103 | |
80 | - if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) return 'UPLOADER_ERROR_SIZE'; |
|
104 | + if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) { |
|
105 | + return 'UPLOADER_ERROR_SIZE'; |
|
106 | + } |
|
81 | 107 | |
82 | 108 | # Check file extension |
83 | 109 | |
@@ -85,21 +111,29 @@ discard block |
||
85 | 111 | |
86 | 112 | $extension = strtolower(Explorer::getExtension($file['name'], false)); |
87 | 113 | |
88 | - if (in_array($extension, $extensions, true)) return 'UPLOADER_ERROR_TYPE'; |
|
114 | + if (in_array($extension, $extensions, true)) { |
|
115 | + return 'UPLOADER_ERROR_TYPE'; |
|
116 | + } |
|
89 | 117 | |
90 | 118 | # Check target directory |
91 | 119 | |
92 | - if (!Explorer::isDir($dir_name) && !Explorer::createDir($dir_name)) return 'UPLOADER_ERROR_DIR'; |
|
120 | + if (!Explorer::isDir($dir_name) && !Explorer::createDir($dir_name)) { |
|
121 | + return 'UPLOADER_ERROR_DIR'; |
|
122 | + } |
|
93 | 123 | |
94 | 124 | # Check target file |
95 | 125 | |
96 | 126 | $base_name = basename($file['name']); $file_name = ($dir_name . '/' . $base_name); |
97 | 127 | |
98 | - if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
|
128 | + if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) { |
|
129 | + return 'UPLOADER_ERROR_EXISTS'; |
|
130 | + } |
|
99 | 131 | |
100 | 132 | # Save uploaded file |
101 | 133 | |
102 | - if (!@move_uploaded_file($file['tmp_name'], $file_name)) return 'UPLOADER_ERROR_SAVE'; |
|
134 | + if (!@move_uploaded_file($file['tmp_name'], $file_name)) { |
|
135 | + return 'UPLOADER_ERROR_SAVE'; |
|
136 | + } |
|
103 | 137 | |
104 | 138 | # Set upload data |
105 | 139 | |
@@ -122,7 +156,9 @@ discard block |
||
122 | 156 | |
123 | 157 | $result = self::save($name, $dir_name); |
124 | 158 | |
125 | - if (is_string($result)) return self::displayError($result, $popup); |
|
159 | + if (is_string($result)) { |
|
160 | + return self::displayError($result, $popup); |
|
161 | + } |
|
126 | 162 | |
127 | 163 | # ------------------------ |
128 | 164 |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | public function set(string $name, $value) : Response { |
32 | 32 | |
33 | - if (!in_array($name, ['error', 'status'], true)) $this->data[$name] = $value; |
|
33 | + if (!in_array($name, ['error', 'status'], true)) { |
|
34 | + $this->data[$name] = $value; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | return $this; |
36 | 38 | } |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | |
44 | 46 | public function setArray(array $data) : Response { |
45 | 47 | |
46 | - foreach ($data as $name => $value) $this->set($name, $value); |
|
48 | + foreach ($data as $name => $value) { |
|
49 | + $this->set($name, $value); |
|
50 | + } |
|
47 | 51 | |
48 | 52 | return $this; |
49 | 53 | } |
@@ -104,7 +108,9 @@ discard block |
||
104 | 108 | |
105 | 109 | $data = ['status' => $this->status]; |
106 | 110 | |
107 | - if (null !== $this->error) $data['error'] = $this->error; |
|
111 | + if (null !== $this->error) { |
|
112 | + $data['error'] = $this->error; |
|
113 | + } |
|
108 | 114 | |
109 | 115 | # ------------------------ |
110 | 116 |
@@ -19,32 +19,32 @@ |
||
19 | 19 | |
20 | 20 | # Check basic types |
21 | 21 | |
22 | - if (is_string ($default)) return function (string $value) { return $value; }; |
|
22 | + if (is_string($default)) return function(string $value) { return $value; }; |
|
23 | 23 | |
24 | - if (is_bool ($default)) return function (bool $value) { return $value; }; |
|
24 | + if (is_bool($default)) return function(bool $value) { return $value; }; |
|
25 | 25 | |
26 | - if (is_int ($default)) return function (int $value) { return $value; }; |
|
26 | + if (is_int($default)) return function(int $value) { return $value; }; |
|
27 | 27 | |
28 | - if (is_float ($default)) return function (float $value) { return $value; }; |
|
28 | + if (is_float($default)) return function(float $value) { return $value; }; |
|
29 | 29 | |
30 | - if (is_array ($default)) return function (array $value) { return $value; }; |
|
30 | + if (is_array($default)) return function(array $value) { return $value; }; |
|
31 | 31 | |
32 | - if (is_callable ($default)) return function (callable $value) { return $value; }; |
|
32 | + if (is_callable($default)) return function(callable $value) { return $value; }; |
|
33 | 33 | |
34 | 34 | # Check object type |
35 | 35 | |
36 | - if (is_object($default)) return function ($value) use ($default) { |
|
36 | + if (is_object($default)) return function($value) use ($default) { |
|
37 | 37 | |
38 | 38 | return (is_a($value, get_class($default)) ? $value : null); |
39 | 39 | }; |
40 | 40 | |
41 | 41 | # Check resource type |
42 | 42 | |
43 | - if (is_resource($default)) return function ($value) { return (is_resource($value) ? $value : null); }; |
|
43 | + if (is_resource($default)) return function($value) { return (is_resource($value) ? $value : null); }; |
|
44 | 44 | |
45 | 45 | # ------------------------ |
46 | 46 | |
47 | - return function () { return null; }; |
|
47 | + return function() { return null; }; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -19,28 +19,51 @@ |
||
19 | 19 | |
20 | 20 | # Check basic types |
21 | 21 | |
22 | - if (is_string ($default)) return function (string $value) { return $value; }; |
|
22 | + if (is_string ($default)) { |
|
23 | + return function (string $value) { return $value; |
|
24 | + } |
|
25 | + }; |
|
23 | 26 | |
24 | - if (is_bool ($default)) return function (bool $value) { return $value; }; |
|
27 | + if (is_bool ($default)) { |
|
28 | + return function (bool $value) { return $value; |
|
29 | + } |
|
30 | + }; |
|
25 | 31 | |
26 | - if (is_int ($default)) return function (int $value) { return $value; }; |
|
32 | + if (is_int ($default)) { |
|
33 | + return function (int $value) { return $value; |
|
34 | + } |
|
35 | + }; |
|
27 | 36 | |
28 | - if (is_float ($default)) return function (float $value) { return $value; }; |
|
37 | + if (is_float ($default)) { |
|
38 | + return function (float $value) { return $value; |
|
39 | + } |
|
40 | + }; |
|
29 | 41 | |
30 | - if (is_array ($default)) return function (array $value) { return $value; }; |
|
42 | + if (is_array ($default)) { |
|
43 | + return function (array $value) { return $value; |
|
44 | + } |
|
45 | + }; |
|
31 | 46 | |
32 | - if (is_callable ($default)) return function (callable $value) { return $value; }; |
|
47 | + if (is_callable ($default)) { |
|
48 | + return function (callable $value) { return $value; |
|
49 | + } |
|
50 | + }; |
|
33 | 51 | |
34 | 52 | # Check object type |
35 | 53 | |
36 | - if (is_object($default)) return function ($value) use ($default) { |
|
54 | + if (is_object($default)) { |
|
55 | + return function ($value) use ($default) { |
|
37 | 56 | |
38 | 57 | return (is_a($value, get_class($default)) ? $value : null); |
58 | + } |
|
39 | 59 | }; |
40 | 60 | |
41 | 61 | # Check resource type |
42 | 62 | |
43 | - if (is_resource($default)) return function ($value) { return (is_resource($value) ? $value : null); }; |
|
63 | + if (is_resource($default)) { |
|
64 | + return function ($value) { return (is_resource($value) ? $value : null); |
|
65 | + } |
|
66 | + }; |
|
44 | 67 | |
45 | 68 | # ------------------------ |
46 | 69 |