@@ -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,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 | } |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | |
41 | 41 | public function row() { |
42 | 42 | |
43 | - if (!is_object($this->result)) return null; |
|
43 | + if (!is_object($this->result)) { |
|
44 | + return null; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return mysqli_fetch_assoc($this->result); |
46 | 48 | } |
@@ -49,9 +51,13 @@ discard block |
||
49 | 51 | |
50 | 52 | public function rows() { |
51 | 53 | |
52 | - if (!is_object($this->result)) return []; |
|
54 | + if (!is_object($this->result)) { |
|
55 | + return []; |
|
56 | + } |
|
53 | 57 | |
54 | - $rows = []; while (null !== ($row = $this->row())) $rows[] = $row; |
|
58 | + $rows = []; while (null !== ($row = $this->row())) { |
|
59 | + $rows[] = $row; |
|
60 | + } |
|
55 | 61 | |
56 | 62 | # ------------------------ |
57 | 63 |