-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readme and Documentation has been updated.
- Loading branch information
Showing
3 changed files
with
483 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,67 +5,67 @@ | |
* Date: 04/05/2019 | ||
* Time: 09:04 PM | ||
*/ | ||
defined('BASEPATH') or exit('No direct script access allowed'); | ||
|
||
/** | ||
* Inspired By | ||
* Ratchet Websocket Library: helper file | ||
* @author Romain GALLIEN <[email protected]> | ||
*/ | ||
|
||
defined('BASEPATH') or exit('No direct script access allowed'); | ||
|
||
if (!function_exists('valid_json')) { | ||
|
||
/** | ||
* Check JSON validity | ||
* @method valid_json | ||
* @author Romain GALLIEN <[email protected]> | ||
* @param mixed $var Variable to check | ||
* @return bool | ||
*/ | ||
function valid_json($var) | ||
{ | ||
return (is_string($var)) && (is_array(json_decode($var, | ||
true))) && (json_last_error() == JSON_ERROR_NONE) ? true : false; | ||
} | ||
/** | ||
* Check JSON validity | ||
* @method valid_json | ||
* @param mixed $var Variable to check | ||
* @return bool | ||
*/ | ||
function valid_json($var) | ||
{ | ||
return (is_string($var)) && (is_array(json_decode($var, | ||
true))) && (json_last_error() == JSON_ERROR_NONE) ? true : false; | ||
} | ||
} | ||
|
||
if (!function_exists('valid_jwt')) { | ||
|
||
/** | ||
* Check JWT validity | ||
* @method valid_jwt | ||
* @param mixed $token Variable to check | ||
* @return Object/false | ||
*/ | ||
function valid_jwt($token) | ||
{ | ||
return AUTHORIZATION::validateToken($token); | ||
} | ||
/** | ||
* Check JWT validity | ||
* @method valid_jwt | ||
* @param mixed $token Variable to check | ||
* @return Object/false | ||
*/ | ||
function valid_jwt($token) | ||
{ | ||
return AUTHORIZATION::validateToken($token); | ||
} | ||
} | ||
|
||
/** | ||
* Ratchet Websocket Library: helper file | ||
* @author Romain GALLIEN <[email protected]> | ||
* Codeigniter Websocket Library: helper file | ||
*/ | ||
if (!function_exists('output')) { | ||
|
||
/** | ||
* Output valid or invalid logs | ||
* @method output | ||
* @author Romain GALLIEN <[email protected]> | ||
* @param string $type Log type | ||
* @param string $var String | ||
* @return string | ||
*/ | ||
function output($type = 'success', $output = null) | ||
{ | ||
if ($type == 'success') { | ||
echo "\033[32m" . $output . "\033[0m" . PHP_EOL; | ||
} elseif ($type == 'error') { | ||
echo "\033[31m" . $output . "\033[0m" . PHP_EOL; | ||
} elseif ($type == 'fatal') { | ||
echo "\033[31m" . $output . "\033[0m" . PHP_EOL; | ||
exit(EXIT_ERROR); | ||
} else { | ||
echo $output . PHP_EOL; | ||
} | ||
} | ||
/** | ||
* Output valid or invalid logs | ||
* @method output | ||
* @param string $type Log type | ||
* @param string $var String | ||
* @return string | ||
*/ | ||
function output($type = 'success', $output = null) | ||
{ | ||
if ($type == 'success') { | ||
echo "\033[32m" . $output . "\033[0m" . PHP_EOL; | ||
} elseif ($type == 'error') { | ||
echo "\033[31m" . $output . "\033[0m" . PHP_EOL; | ||
} elseif ($type == 'fatal') { | ||
echo "\033[31m" . $output . "\033[0m" . PHP_EOL; | ||
exit(EXIT_ERROR); | ||
} else { | ||
echo $output . PHP_EOL; | ||
} | ||
} | ||
} |
Oops, something went wrong.