@@ -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 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | |
| 60 | 60 | # ------------------------ |
| 61 | 61 | |
| 62 | - return ('/' . $path . ($query ? ('?' . $query) : '')); |
|
| 62 | + return ('/'.$path.($query ? ('?'.$query) : '')); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -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 | |
@@ -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 | } |
@@ -24,12 +24,12 @@ |
||
| 24 | 24 | |
| 25 | 25 | if (0 === $key) $names = $this->getString(array_keys($row), '$name', ', '); |
| 26 | 26 | |
| 27 | - $values[] = ('(' . $this->getString(array_values($row), '$value', ', ') . ')'); |
|
| 27 | + $values[] = ('('.$this->getString(array_values($row), '$value', ', ').')'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | # Build query |
| 31 | 31 | |
| 32 | - $this->query = ('INSERT INTO ' . $table . ' (' . $names . ') VALUES ' . implode(', ', $values)); |
|
| 32 | + $this->query = ('INSERT INTO '.$table.' ('.$names.') VALUES '.implode(', ', $values)); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -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 | |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | protected function getString($source = null, string $pattern = '', string $separator = '') { |
| 33 | 33 | |
| 34 | - if (!is_array($source)) return (is_scalar($source) ? strval($source) : ''); |
|
| 34 | + if (!is_array($source)) { |
|
| 35 | + return (is_scalar($source) ? strval($source) : ''); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $regexs = ['key' => '/\^([a-z]+)/', 'value' => '/\$([a-z]+)/']; $matches = ['key' => [], 'value' => []]; |
| 37 | 39 | |
@@ -39,18 +41,25 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | # Parse pattern |
| 41 | 43 | |
| 42 | - foreach ($regexs as $name => $regex) preg_match($regex, $pattern, $matches[$name]); |
|
| 44 | + foreach ($regexs as $name => $regex) { |
|
| 45 | + preg_match($regex, $pattern, $matches[$name]); |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | # Process replacements |
| 45 | 49 | |
| 46 | - foreach ($source as $key => $value) if (is_scalar($value)) { |
|
| 50 | + foreach ($source as $key => $value) { |
|
| 51 | + if (is_scalar($value)) { |
|
| 47 | 52 | |
| 48 | - $output[$count] = $pattern; $item = &$output[$count++]; |
|
| 53 | + $output[$count] = $pattern; |
|
| 54 | + } |
|
| 55 | + $item = &$output[$count++]; |
|
| 49 | 56 | |
| 50 | - foreach ($matches as $name => $match) if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
| 57 | + foreach ($matches as $name => $match) { |
|
| 58 | + if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
| 51 | 59 | |
| 52 | 60 | $item = str_replace($match[0], [$this, $parsers[$match[1]]]($$name), $item); |
| 53 | 61 | } |
| 62 | + } |
|
| 54 | 63 | }; |
| 55 | 64 | |
| 56 | 65 | # ------------------------ |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | protected function getValue(string $value) { |
| 19 | 19 | |
| 20 | - return ('\'' . addslashes($value) . '\''); |
|
| 20 | + return ('\''.addslashes($value).'\''); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | # Get field sort |
@@ -117,7 +117,9 @@ 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)) { |
|
| 121 | + header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
| 122 | + } |
|
| 121 | 123 | } |
| 122 | 124 | |
| 123 | 125 | # Send content header |
@@ -139,9 +141,13 @@ discard block |
||
| 139 | 141 | |
| 140 | 142 | public static function cache(string $limiter, int $expires) { |
| 141 | 143 | |
| 142 | - if (self::$cache_send) return; |
|
| 144 | + if (self::$cache_send) { |
|
| 145 | + return; |
|
| 146 | + } |
|
| 143 | 147 | |
| 144 | - if (!in_array($limiter, [CACHE_LIMITER_PRIVATE, CACHE_LIMITER_PUBLIC], true)) return; |
|
| 148 | + if (!in_array($limiter, [CACHE_LIMITER_PRIVATE, CACHE_LIMITER_PUBLIC], true)) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | header('Expires: ' . gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)) . ' GMT'); |
| 147 | 153 | |
@@ -160,7 +166,9 @@ discard block |
||
| 160 | 166 | |
| 161 | 167 | public static function nocache() { |
| 162 | 168 | |
| 163 | - if (self::$cache_send) return; |
|
| 169 | + if (self::$cache_send) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 164 | 172 | |
| 165 | 173 | header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
| 166 | 174 | |
@@ -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 | |
@@ -19,7 +19,9 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function error(string $value = null) { |
| 21 | 21 | |
| 22 | - if (null !== $value) $this->set('error', $value); |
|
| 22 | + if (null !== $value) { |
|
| 23 | + $this->set('error', $value); |
|
| 24 | + } |
|
| 23 | 25 | |
| 24 | 26 | $this->status = false; |
| 25 | 27 | |
@@ -10,14 +10,18 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | foreach (($string = explode("\n", $string)) as $key => $line) { |
| 12 | 12 | |
| 13 | - if ($multiline && $codestyle) $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
| 14 | - |
|
| 15 | - else $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
| 13 | + if ($multiline && $codestyle) { |
|
| 14 | + $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
| 15 | + } else { |
|
| 16 | + $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
| 17 | + } |
|
| 16 | 18 | } |
| 17 | 19 | |
| 18 | - if (!$multiline) $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
| 19 | - |
|
| 20 | - else $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
| 20 | + if (!$multiline) { |
|
| 21 | + $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
| 22 | + } else { |
|
| 23 | + $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
| 24 | + } |
|
| 21 | 25 | |
| 22 | 26 | # ------------------------ |
| 23 | 27 | |
@@ -136,7 +140,9 @@ discard block |
||
| 136 | 140 | |
| 137 | 141 | public static function cut(string $string, int $maxlength, bool $ellipsis = false) { |
| 138 | 142 | |
| 139 | - if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
|
| 143 | + if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) { |
|
| 144 | + return $string; |
|
| 145 | + } |
|
| 140 | 146 | |
| 141 | 147 | $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
| 142 | 148 | |
@@ -149,9 +155,13 @@ discard block |
||
| 149 | 155 | |
| 150 | 156 | public static function random(int $length, string $pool = STR_POOL_DEFAULT) { |
| 151 | 157 | |
| 152 | - if (($length < 1) || (0 === ($pool_length = self::length($pool)))) return ''; |
|
| 158 | + if (($length < 1) || (0 === ($pool_length = self::length($pool)))) { |
|
| 159 | + return ''; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | - $string = ''; for ($i = 0; $i < $length; $i++) $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
| 162 | + $string = ''; for ($i = 0; $i < $length; $i++) { |
|
| 163 | + $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
| 164 | + } |
|
| 155 | 165 | |
| 156 | 166 | # ------------------------ |
| 157 | 167 | |
@@ -53,25 +53,25 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $pattern = [ |
| 55 | 55 | |
| 56 | - 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
| 57 | - 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
| 58 | - 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
| 59 | - 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
| 60 | - 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
| 61 | - 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
| 62 | - 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
| 63 | - 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
| 64 | - 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
| 65 | - |
|
| 66 | - 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
| 67 | - 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
| 68 | - 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
| 69 | - 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
| 70 | - 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
| 71 | - 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
| 72 | - 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
| 73 | - 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
| 74 | - 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
| 56 | + 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
| 57 | + 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
| 58 | + 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
| 59 | + 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
| 60 | + 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
| 61 | + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
| 62 | + 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
| 63 | + 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
| 64 | + 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
| 65 | + |
|
| 66 | + 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
| 67 | + 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
| 68 | + 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
| 69 | + 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
| 70 | + 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
| 71 | + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
| 72 | + 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
| 73 | + 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
| 74 | + 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | 77 | # ------------------------ |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
| 140 | 140 | |
| 141 | - $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
|
| 141 | + $string = (rtrim(self::substr($string, 0, $maxlength)).($ellipsis ? '...' : '')); |
|
| 142 | 142 | |
| 143 | 143 | # ------------------------ |
| 144 | 144 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | public static function encode(string $key, string $string) { |
| 164 | 164 | |
| 165 | - return sha1($key . substr(sha1($string), 8, 32)); |
|
| 165 | + return sha1($key.substr(sha1($string), 8, 32)); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -10,9 +10,13 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | private static function search(array &$list) { |
| 12 | 12 | |
| 13 | - if (empty($agent = getenv('HTTP_USER_AGENT'))) return false; |
|
| 13 | + if (empty($agent = getenv('HTTP_USER_AGENT'))) { |
|
| 14 | + return false; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | - foreach ($list as $item) if (false !== stripos($agent, $item)) return true; |
|
| 17 | + foreach ($list as $item) { |
|
| 18 | + if (false !== stripos($agent, $item)) return true; |
|
| 19 | + } |
|
| 16 | 20 | |
| 17 | 21 | # ------------------------ |
| 18 | 22 | |
@@ -27,9 +31,13 @@ discard block |
||
| 27 | 31 | |
| 28 | 32 | $file_robots = (DIR_DATA . 'Agent/Robots.php'); |
| 29 | 33 | |
| 30 | - if (is_array($mobiles = Explorer::php($file_mobiles))) self::$mobiles = $mobiles; |
|
| 34 | + if (is_array($mobiles = Explorer::php($file_mobiles))) { |
|
| 35 | + self::$mobiles = $mobiles; |
|
| 36 | + } |
|
| 31 | 37 | |
| 32 | - if (is_array($robots = Explorer::php($file_robots))) self::$robots = $robots; |
|
| 38 | + if (is_array($robots = Explorer::php($file_robots))) { |
|
| 39 | + self::$robots = $robots; |
|
| 40 | + } |
|
| 33 | 41 | } |
| 34 | 42 | |
| 35 | 43 | # Check if user agent is mobile |
@@ -23,9 +23,9 @@ |
||
| 23 | 23 | |
| 24 | 24 | public static function __autoload() { |
| 25 | 25 | |
| 26 | - $file_mobiles = (DIR_DATA . 'Agent/Mobiles.php'); |
|
| 26 | + $file_mobiles = (DIR_DATA.'Agent/Mobiles.php'); |
|
| 27 | 27 | |
| 28 | - $file_robots = (DIR_DATA . 'Agent/Robots.php'); |
|
| 28 | + $file_robots = (DIR_DATA.'Agent/Robots.php'); |
|
| 29 | 29 | |
| 30 | 30 | if (is_array($mobiles = Explorer::php($file_mobiles))) self::$mobiles = $mobiles; |
| 31 | 31 | |