diff options
Diffstat (limited to 'system/core/compat')
-rw-r--r-- | system/core/compat/standard.php (renamed from system/core/compat/array.php) | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/system/core/compat/array.php b/system/core/compat/standard.php index 07dae21c2..6380fa1e8 100644 --- a/system/core/compat/array.php +++ b/system/core/compat/standard.php @@ -27,14 +27,13 @@ defined('BASEPATH') OR exit('No direct script access allowed'); /** - * PHP ext/standard/array compatibility package + * PHP ext/standard compatibility package * * @package CodeIgniter * @subpackage CodeIgniter * @category Compatibility * @author Andrey Andreev * @link http://codeigniter.com/user_guide/ - * @link http://php.net/book.array */ // ------------------------------------------------------------------------ @@ -125,6 +124,54 @@ if ( ! function_exists('array_column')) // ------------------------------------------------------------------------ +if (is_php('5.4')) +{ + return; +} + +// ------------------------------------------------------------------------ + +if ( ! function_exists('hex2bin')) +{ + /** + * hex2bin() + * + * @link http://php.net/hex2bin + * @param string $data + * @return string + */ + function hex2bin($data) + { + if (in_array($type = gettype($data), array('array', 'double', 'object'), TRUE)) + { + if ($type === 'object' && method_exists($data, '__toString')) + { + $data = (string) $data; + } + else + { + trigger_error('hex2bin() expects parameter 1 to be string, '.$type.' given', E_USER_WARNING); + return NULL; + } + } + + if (strlen($data) % 2 !== 0) + { + trigger_error('Hexadecimal input string must have an even length', E_USER_WARNING); + return FALSE; + } + elseif ( ! preg_match('/^[0-9a-f]*$/i', $data)) + { + trigger_error('Input string must be hexadecimal string', E_USER_WARNING); + return FALSE; + } + + return pack('H*', $data); + } +} + +// ------------------------------------------------------------------------ + if (is_php('5.3')) { return; |