|
5 | 5 | * Date: 04/05/2019
|
6 | 6 | * Time: 09:04 PM
|
7 | 7 | */
|
8 |
| -defined('BASEPATH') or exit('No direct script access allowed'); |
9 | 8 |
|
10 | 9 | /**
|
| 10 | + * Inspired By |
11 | 11 | * Ratchet Websocket Library: helper file
|
12 | 12 | * @author Romain GALLIEN <romaingallien.rg@gmail.com>
|
13 | 13 | */
|
| 14 | + |
| 15 | +defined('BASEPATH') or exit('No direct script access allowed'); |
| 16 | + |
14 | 17 | if (!function_exists('valid_json')) {
|
15 | 18 |
|
16 |
| - /** |
17 |
| - * Check JSON validity |
18 |
| - * @method valid_json |
19 |
| - * @author Romain GALLIEN <romaingallien.rg@gmail.com> |
20 |
| - * @param mixed $var Variable to check |
21 |
| - * @return bool |
22 |
| - */ |
23 |
| - function valid_json($var) |
24 |
| - { |
25 |
| - return (is_string($var)) && (is_array(json_decode($var, |
26 |
| - true))) && (json_last_error() == JSON_ERROR_NONE) ? true : false; |
27 |
| - } |
| 19 | + /** |
| 20 | + * Check JSON validity |
| 21 | + * @method valid_json |
| 22 | + * @param mixed $var Variable to check |
| 23 | + * @return bool |
| 24 | + */ |
| 25 | + function valid_json($var) |
| 26 | + { |
| 27 | + return (is_string($var)) && (is_array(json_decode($var, |
| 28 | + true))) && (json_last_error() == JSON_ERROR_NONE) ? true : false; |
| 29 | + } |
28 | 30 | }
|
29 | 31 |
|
30 | 32 | if (!function_exists('valid_jwt')) {
|
31 | 33 |
|
32 |
| - /** |
33 |
| - * Check JWT validity |
34 |
| - * @method valid_jwt |
35 |
| - * @param mixed $token Variable to check |
36 |
| - * @return Object/false |
37 |
| - */ |
38 |
| - function valid_jwt($token) |
39 |
| - { |
40 |
| - return AUTHORIZATION::validateToken($token); |
41 |
| - } |
| 34 | + /** |
| 35 | + * Check JWT validity |
| 36 | + * @method valid_jwt |
| 37 | + * @param mixed $token Variable to check |
| 38 | + * @return Object/false |
| 39 | + */ |
| 40 | + function valid_jwt($token) |
| 41 | + { |
| 42 | + return AUTHORIZATION::validateToken($token); |
| 43 | + } |
42 | 44 | }
|
43 | 45 |
|
44 | 46 | /**
|
45 |
| - * Ratchet Websocket Library: helper file |
46 |
| - * @author Romain GALLIEN <romaingallien.rg@gmail.com> |
| 47 | + * Codeigniter Websocket Library: helper file |
47 | 48 | */
|
48 | 49 | if (!function_exists('output')) {
|
49 | 50 |
|
50 |
| - /** |
51 |
| - * Output valid or invalid logs |
52 |
| - * @method output |
53 |
| - * @author Romain GALLIEN <romaingallien.rg@gmail.com> |
54 |
| - * @param string $type Log type |
55 |
| - * @param string $var String |
56 |
| - * @return string |
57 |
| - */ |
58 |
| - function output($type = 'success', $output = null) |
59 |
| - { |
60 |
| - if ($type == 'success') { |
61 |
| - echo "\033[32m" . $output . "\033[0m" . PHP_EOL; |
62 |
| - } elseif ($type == 'error') { |
63 |
| - echo "\033[31m" . $output . "\033[0m" . PHP_EOL; |
64 |
| - } elseif ($type == 'fatal') { |
65 |
| - echo "\033[31m" . $output . "\033[0m" . PHP_EOL; |
66 |
| - exit(EXIT_ERROR); |
67 |
| - } else { |
68 |
| - echo $output . PHP_EOL; |
69 |
| - } |
70 |
| - } |
| 51 | + /** |
| 52 | + * Output valid or invalid logs |
| 53 | + * @method output |
| 54 | + * @param string $type Log type |
| 55 | + * @param string $var String |
| 56 | + * @return string |
| 57 | + */ |
| 58 | + function output($type = 'success', $output = null) |
| 59 | + { |
| 60 | + if ($type == 'success') { |
| 61 | + echo "\033[32m" . $output . "\033[0m" . PHP_EOL; |
| 62 | + } elseif ($type == 'error') { |
| 63 | + echo "\033[31m" . $output . "\033[0m" . PHP_EOL; |
| 64 | + } elseif ($type == 'fatal') { |
| 65 | + echo "\033[31m" . $output . "\033[0m" . PHP_EOL; |
| 66 | + exit(EXIT_ERROR); |
| 67 | + } else { |
| 68 | + echo $output . PHP_EOL; |
| 69 | + } |
| 70 | + } |
71 | 71 | }
|
0 commit comments