@@ -31,7 +31,9 @@ |
||
31 | 31 | |
32 | 32 | public static function delete(string $name) { |
33 | 33 | |
34 | - if (isset($_COOKIE[$name])) unset($_COOKIE[$name]); |
|
34 | + if (isset($_COOKIE[$name])) { |
|
35 | + unset($_COOKIE[$name]); |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | } |
37 | 39 | } |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | private static function checkType(string $extension, string $type) { |
12 | 12 | |
13 | - if (false === ($mime = self::get($extension))) return false; |
|
13 | + if (false === ($mime = self::get($extension))) { |
|
14 | + return false; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | return (preg_match('/^' . $type . '\//', $mime) ? true : false); |
16 | 18 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | |
13 | 13 | if (false === ($mime = self::get($extension))) return false; |
14 | 14 | |
15 | - return (preg_match(('/^' . $type . '\//'), $mime) ? true : false); |
|
15 | + return (preg_match(('/^'.$type.'\//'), $mime) ? true : false); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | # Autoloader |
19 | 19 | |
20 | 20 | public static function __autoload() { |
21 | 21 | |
22 | - self::init(DIR_DATA . 'Mime.php'); |
|
22 | + self::init(DIR_DATA.'Mime.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | # Check if extension is image |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | private static function output($image, string $mime, callable $outputter, array $params = []) { |
10 | 10 | |
11 | - if (!is_resource($image)) return false; |
|
11 | + if (!is_resource($image)) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | Headers::nocache(); Headers::content($mime); |
14 | 16 |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | # Mime types |
4 | 4 | |
5 | -define('MIME_TYPE_HTML', 'html'); |
|
6 | -define('MIME_TYPE_XML', 'xml'); |
|
7 | -define('MIME_TYPE_JSON', 'json'); |
|
5 | +define('MIME_TYPE_HTML', 'html'); |
|
6 | +define('MIME_TYPE_XML', 'xml'); |
|
7 | +define('MIME_TYPE_JSON', 'json'); |
|
8 | 8 | |
9 | -define('MIME_TYPE_JPEG', 'jpeg'); |
|
10 | -define('MIME_TYPE_PNG', 'png'); |
|
11 | -define('MIME_TYPE_GIF', 'gif'); |
|
9 | +define('MIME_TYPE_JPEG', 'jpeg'); |
|
10 | +define('MIME_TYPE_PNG', 'png'); |
|
11 | +define('MIME_TYPE_GIF', 'gif'); |
@@ -26,7 +26,9 @@ |
||
26 | 26 | |
27 | 27 | public function __construct(string $message = '') { |
28 | 28 | |
29 | - if ('' !== $message) $this->message = $message; |
|
29 | + if ('' !== $message) { |
|
30 | + $this->message = $message; |
|
31 | + } |
|
30 | 32 | } |
31 | 33 | } |
32 | 34 |
@@ -36,28 +36,28 @@ |
||
36 | 36 | |
37 | 37 | # Class load exception |
38 | 38 | |
39 | - class ClassLoad extends Exception { |
|
39 | + class ClassLoad extends Exception { |
|
40 | 40 | |
41 | 41 | protected $message = 'Class \'$value$\' not found'; |
42 | 42 | } |
43 | 43 | |
44 | 44 | # Database connect exception |
45 | 45 | |
46 | - class DBConnect extends Exception { |
|
46 | + class DBConnect extends Exception { |
|
47 | 47 | |
48 | 48 | protected $message = 'Unable to connect to database'; |
49 | 49 | } |
50 | 50 | |
51 | 51 | # Database charset exception |
52 | 52 | |
53 | - class DBCharset extends Exception { |
|
53 | + class DBCharset extends Exception { |
|
54 | 54 | |
55 | 55 | protected $message = 'Unable to set database charset'; |
56 | 56 | } |
57 | 57 | |
58 | 58 | # Database select exception |
59 | 59 | |
60 | - class DBSelect extends Exception { |
|
60 | + class DBSelect extends Exception { |
|
61 | 61 | |
62 | 62 | protected $message = 'Unable to select database'; |
63 | 63 | } |
@@ -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 | + }); |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | |
18 | 18 | # Define constants |
19 | 19 | |
20 | -define('DIR_ENGINE', (dirname(__FILE__) . '/')); |
|
20 | +define('DIR_ENGINE', (dirname(__FILE__).'/')); |
|
21 | 21 | |
22 | -define('DIR_WWW', (DIR_ENGINE . '../')); |
|
23 | -define('DIR_UPLOADS', (DIR_ENGINE . '../uploads/')); |
|
22 | +define('DIR_WWW', (DIR_ENGINE.'../')); |
|
23 | +define('DIR_UPLOADS', (DIR_ENGINE.'../uploads/')); |
|
24 | 24 | |
25 | 25 | # Require framework main file |
26 | 26 | |
27 | -require_once(DIR_ENGINE . 'Framework/Main.php'); |
|
27 | +require_once(DIR_ENGINE.'Framework/Main.php'); |
|
28 | 28 | |
29 | 29 | # Require system main file |
30 | 30 | |
31 | -require_once(DIR_ENGINE . 'System/Main.php'); |
|
31 | +require_once(DIR_ENGINE.'System/Main.php'); |
|
32 | 32 | |
33 | 33 | # Register classes autoloader |
34 | 34 | |
35 | -spl_autoload_register(function ($class_name) { |
|
35 | +spl_autoload_register(function($class_name) { |
|
36 | 36 | |
37 | 37 | $path = explode('\\', $class_name); $last = $path[count($path) - 1]; |
38 | 38 | |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | $system_classes = ['Addons', 'Frames', 'Modules', 'Schemas', 'Utils', 'Dispatcher', 'Installer']; |
42 | 42 | |
43 | - $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES) . implode('/', $path)); |
|
43 | + $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES).implode('/', $path)); |
|
44 | 44 | |
45 | 45 | # Require class file |
46 | 46 | |
47 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
47 | + if (@file_exists($file_name = ($path.'.php')) && @is_file($file_name)) require_once $file_name; |
|
48 | 48 | |
49 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
49 | + else if (@file_exists($file_name = ($path.'/'.$last.'.php')) && @is_file($file_name)) require_once $file_name; |
|
50 | 50 | |
51 | 51 | # Check if class exists |
52 | 52 |
@@ -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 | } |