@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | # Define constants |
4 | 4 | |
5 | -define('DIR_FRAMEWORK', (dirname(__FILE__) . '/')); |
|
5 | +define('DIR_FRAMEWORK', (dirname(__FILE__) . '/')); |
|
6 | 6 | |
7 | -define('DIR_CLASSES', (DIR_FRAMEWORK . 'Classes/')); |
|
8 | -define('DIR_DATA', (DIR_FRAMEWORK . 'Data/')); |
|
9 | -define('DIR_INCLUDES', (DIR_FRAMEWORK . 'Includes/')); |
|
10 | -define('DIR_TEMPLATES', (DIR_FRAMEWORK . 'Templates/')); |
|
7 | +define('DIR_CLASSES', (DIR_FRAMEWORK . 'Classes/')); |
|
8 | +define('DIR_DATA', (DIR_FRAMEWORK . 'Data/')); |
|
9 | +define('DIR_INCLUDES', (DIR_FRAMEWORK . 'Includes/')); |
|
10 | +define('DIR_TEMPLATES', (DIR_FRAMEWORK . 'Templates/')); |
|
11 | 11 | |
12 | 12 | # Require classes |
13 | 13 |
@@ -23,7 +23,9 @@ |
||
23 | 23 | |
24 | 24 | # Set defaults |
25 | 25 | |
26 | -if (function_exists('mb_internal_encoding')) mb_internal_encoding('UTF-8'); |
|
26 | +if (function_exists('mb_internal_encoding')) { |
|
27 | + mb_internal_encoding('UTF-8'); |
|
28 | +} |
|
27 | 29 | |
28 | 30 | date_default_timezone_set('UTC'); |
29 | 31 |
@@ -10,16 +10,22 @@ |
||
10 | 10 | |
11 | 11 | private static function addPhrase(string $name, string $value) { |
12 | 12 | |
13 | - if (preg_match(REGEX_LANGUAGE_PHRASE_NAME, $name)) self::$phrases[$name] = $value; |
|
13 | + if (preg_match(REGEX_LANGUAGE_PHRASE_NAME, $name)) { |
|
14 | + self::$phrases[$name] = $value; |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | # Load phrases file |
17 | 19 | |
18 | 20 | public static function load(string $file_name) { |
19 | 21 | |
20 | - if (!is_array($phrases = Explorer::php($file_name))) return false; |
|
22 | + if (!is_array($phrases = Explorer::php($file_name))) { |
|
23 | + return false; |
|
24 | + } |
|
21 | 25 | |
22 | - foreach ($phrases as $name => $value) self::addPhrase($name, $value); |
|
26 | + foreach ($phrases as $name => $value) { |
|
27 | + self::addPhrase($name, $value); |
|
28 | + } |
|
23 | 29 | |
24 | 30 | # ------------------------ |
25 | 31 |
@@ -10,18 +10,24 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct(string $url = '') { |
12 | 12 | |
13 | - if (false === ($url = parse_url($url))) return; |
|
13 | + if (false === ($url = parse_url($url))) { |
|
14 | + return; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | # Parse path |
16 | 18 | |
17 | - if (isset($url['path'])) foreach (explode('/', $url['path']) as $part) { |
|
19 | + if (isset($url['path'])) { |
|
20 | + foreach (explode('/', $url['path']) as $part) { |
|
18 | 21 | |
19 | 22 | if ('' !== $part) $this->path[] = urldecode($part); |
20 | 23 | } |
24 | + } |
|
21 | 25 | |
22 | 26 | # Parse query |
23 | 27 | |
24 | - if (isset($url['query'])) parse_str($url['query'], $this->query); |
|
28 | + if (isset($url['query'])) { |
|
29 | + parse_str($url['query'], $this->query); |
|
30 | + } |
|
25 | 31 | } |
26 | 32 | |
27 | 33 | # Return path |
@@ -53,7 +59,9 @@ discard block |
||
53 | 59 | |
54 | 60 | $path = []; |
55 | 61 | |
56 | - foreach ($this->path as $value) $path[] = urlencode($value); |
|
62 | + foreach ($this->path as $value) { |
|
63 | + $path[] = urlencode($value); |
|
64 | + } |
|
57 | 65 | |
58 | 66 | $path = implode('/', $path); $query = http_build_query($this->query); |
59 | 67 |
@@ -12,9 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | while (false !== ($name = readdir($handler))) { |
14 | 14 | |
15 | - if (($name === '.') || ($name === '..')) continue; |
|
15 | + if (($name === '.') || ($name === '..')) { |
|
16 | + continue; |
|
17 | + } |
|
16 | 18 | |
17 | - if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) yield $name; |
|
19 | + if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) { |
|
20 | + yield $name; |
|
21 | + } |
|
18 | 22 | } |
19 | 23 | |
20 | 24 | closedir($handler); |
@@ -25,7 +29,9 @@ discard block |
||
25 | 29 | |
26 | 30 | private static function getInfo(string $file_name, int $param, bool $check_exists = true) { |
27 | 31 | |
28 | - if ($check_exists && !self::isFile($file_name)) return false; |
|
32 | + if ($check_exists && !self::isFile($file_name)) { |
|
33 | + return false; |
|
34 | + } |
|
29 | 35 | |
30 | 36 | return pathinfo($file_name, $param); |
31 | 37 | } |
@@ -68,9 +74,11 @@ discard block |
||
68 | 74 | |
69 | 75 | $name = ($dir_name . '/' . $name); |
70 | 76 | |
71 | - if (@is_file($name)) self::removeFile($name); |
|
72 | - |
|
73 | - else if (@is_dir($name)) self::removeDir($name, true); |
|
77 | + if (@is_file($name)) { |
|
78 | + self::removeFile($name); |
|
79 | + } else if (@is_dir($name)) { |
|
80 | + self::removeDir($name, true); |
|
81 | + } |
|
74 | 82 | } |
75 | 83 | } |
76 | 84 | |
@@ -146,7 +154,9 @@ discard block |
||
146 | 154 | |
147 | 155 | public static function php(string $file_name) { |
148 | 156 | |
149 | - if ((strtolower(self::extension($file_name)) !== 'php')) return false; |
|
157 | + if ((strtolower(self::extension($file_name)) !== 'php')) { |
|
158 | + return false; |
|
159 | + } |
|
150 | 160 | |
151 | 161 | return include $file_name; |
152 | 162 | } |
@@ -155,7 +165,9 @@ discard block |
||
155 | 165 | |
156 | 166 | public static function xml(string $file_name) { |
157 | 167 | |
158 | - if ((strtolower(self::extension($file_name)) !== 'xml')) return false; |
|
168 | + if ((strtolower(self::extension($file_name)) !== 'xml')) { |
|
169 | + return false; |
|
170 | + } |
|
159 | 171 | |
160 | 172 | return @simplexml_load_file($file_name); |
161 | 173 | } |
@@ -164,7 +176,9 @@ discard block |
||
164 | 176 | |
165 | 177 | public static function json(string $file_name) { |
166 | 178 | |
167 | - if ((strtolower(self::extension($file_name)) !== 'json')) return false; |
|
179 | + if ((strtolower(self::extension($file_name)) !== 'json')) { |
|
180 | + return false; |
|
181 | + } |
|
168 | 182 | |
169 | 183 | return json_decode(@file_get_contents($file_name), true); |
170 | 184 | } |
@@ -173,7 +187,11 @@ discard block |
||
173 | 187 | |
174 | 188 | public static function save(string $file_name, string $contents, bool $force = false) { |
175 | 189 | |
176 | - if (self::isFile($file_name)) if (!$force) return false; else if (!@unlink($file_name)) return false; |
|
190 | + if (self::isFile($file_name)) { |
|
191 | + if (!$force) return false; |
|
192 | + } else if (!@unlink($file_name)) { |
|
193 | + return false; |
|
194 | + } |
|
177 | 195 | |
178 | 196 | return @file_put_contents($file_name, $contents); |
179 | 197 | } |
@@ -12,19 +12,29 @@ discard block |
||
12 | 12 | |
13 | 13 | # Establish connection |
14 | 14 | |
15 | - if (false === ($link = @mysqli_connect($server, $user, $password))) throw new Exception\DBConnect(); |
|
15 | + if (false === ($link = @mysqli_connect($server, $user, $password))) { |
|
16 | + throw new Exception\DBConnect(); |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # Select database |
18 | 20 | |
19 | - if (!@mysqli_select_db($link, $name)) throw new Exception\DBSelect(); |
|
21 | + if (!@mysqli_select_db($link, $name)) { |
|
22 | + throw new Exception\DBSelect(); |
|
23 | + } |
|
20 | 24 | |
21 | 25 | # Set encoding |
22 | 26 | |
23 | - if (!@mysqli_query($link, "SET character_set_client = 'utf8'")) throw new Exception\DBCharset(); |
|
27 | + if (!@mysqli_query($link, "SET character_set_client = 'utf8'")) { |
|
28 | + throw new Exception\DBCharset(); |
|
29 | + } |
|
24 | 30 | |
25 | - if (!@mysqli_query($link, "SET character_set_results = 'utf8'")) throw new Exception\DBCharset(); |
|
31 | + if (!@mysqli_query($link, "SET character_set_results = 'utf8'")) { |
|
32 | + throw new Exception\DBCharset(); |
|
33 | + } |
|
26 | 34 | |
27 | - if (!@mysqli_query($link, "SET collation_connection = 'utf8_general_ci'")) throw new Exception\DBCharset(); |
|
35 | + if (!@mysqli_query($link, "SET collation_connection = 'utf8_general_ci'")) { |
|
36 | + throw new Exception\DBCharset(); |
|
37 | + } |
|
28 | 38 | |
29 | 39 | # ------------------------ |
30 | 40 | |
@@ -35,7 +45,9 @@ discard block |
||
35 | 45 | |
36 | 46 | public static function send(string $query) { |
37 | 47 | |
38 | - if (null === self::$link) return (self::$last = false); |
|
48 | + if (null === self::$link) { |
|
49 | + return (self::$last = false); |
|
50 | + } |
|
39 | 51 | |
40 | 52 | $time = microtime(true); $result = mysqli_query(self::$link, $query); $time = (microtime(true) - $time); |
41 | 53 |
@@ -22,9 +22,9 @@ |
||
22 | 22 | |
23 | 23 | # Build query |
24 | 24 | |
25 | - $this->query = ('SELECT ' . $selection . ' FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '') . |
|
25 | + $this->query = ('SELECT ' . $selection . ' FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '') . |
|
26 | 26 | |
27 | - ($order ? (' ORDER BY ' . $order) : '') . ($limit ? (' LIMIT ' . $limit) : '')); |
|
27 | + ($order ? (' ORDER BY ' . $order) : '') . ($limit ? (' LIMIT ' . $limit) : '')); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | } |
@@ -20,9 +20,11 @@ |
||
20 | 20 | |
21 | 21 | $names = ''; $values = []; |
22 | 22 | |
23 | - foreach ($dataset as $key => $row) if (is_array($row)) { |
|
23 | + foreach ($dataset as $key => $row) { |
|
24 | + if (is_array($row)) { |
|
24 | 25 | |
25 | 26 | if (0 === $key) $names = $this->getString(array_keys($row), '$name', ', '); |
27 | + } |
|
26 | 28 | |
27 | 29 | $values[] = ('(' . $this->getString(array_values($row), '$value', ', ') . ')'); |
28 | 30 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | # Build query |
22 | 22 | |
23 | - $this->query = ('UPDATE ' . $table . ' SET ' . $dataset . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
23 | + $this->query = ('UPDATE ' . $table . ' SET ' . $dataset . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | # Build query |
20 | 20 | |
21 | - $this->query = ('DELETE FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
21 | + $this->query = ('DELETE FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | } |