diff options
| author | modela bitweaver <spiderr@bitweaver.org> | 2017-02-13 12:22:47 -0500 |
|---|---|---|
| committer | modela bitweaver <spiderr@bitweaver.org> | 2017-02-13 12:22:47 -0500 |
| commit | 75b7b46b9dafdee7f703d34f549941c88a9e9e15 (patch) | |
| tree | e10cef2465e3bc6dacfbabab7ba757c8d910c138 | |
| parent | c4c3dddb63d25c9b311c5cf892d7f9bafd55e9e7 (diff) | |
| download | util-75b7b46b9dafdee7f703d34f549941c88a9e9e15.tar.gz util-75b7b46b9dafdee7f703d34f549941c88a9e9e15.tar.bz2 util-75b7b46b9dafdee7f703d34f549941c88a9e9e15.zip | |
remove-PHP_Compat
38 files changed, 0 insertions, 3350 deletions
diff --git a/PHP_Compat/Compat.php b/PHP_Compat/Compat.php deleted file mode 100644 index 2495284..0000000 --- a/PHP_Compat/Compat.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Provides missing functionality in the form of constants and functions - * for older versions of PHP - * - * Optionally, you may simply include the file. - * e.g. require_once 'PHP/Compat/Function/scandir.php'; - * - * @category PHP - * @package PHP_Compat - * @version 1.1.0 - * @author Aidan Lister <aidan@php.net> - * @static - */ -class PHP_Compat -{ - - /** - * Load a function, or array of functions - * - * @param string|array $function The function or functions to load. - * @return bool|array true if loaded, false if not - */ - function loadFunction ($function) - { - if (is_array($function)) { - $res = array (); - foreach ($function as $singlefunc) { - $res[] = PHP_Compat::loadFunction($singlefunc); - } - return $res; - } - - else { - if (!function_exists($function)) { - $file = sprintf('PHP/Compat/Function/%s.php', $function); - - if ((@include_once $file) !== false) { - return true; - } - } - - return false; - } - } - - - /** - * Load a constant, or array of constants - * - * @param string|array $constant The constant or constants to load. - * @return bool|array true if loaded, false if not - */ - function loadConstant ($constant) - { - if (is_array($constant)) { - $res = array (); - foreach ($constant as $singleconst) { - $res[] = PHP_Compat::loadConstant($singleconst); - } - return $res; - } - - else { - if (!defined($constant)) { - $file = sprintf('PHP/Compat/Constant/%s.php', $constant); - - if ((@include_once $file) !== false) { - return true; - } - } - - return false; - } - } - -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/E_STRICT.php b/PHP_Compat/Compat/Constant/E_STRICT.php deleted file mode 100644 index 5941701..0000000 --- a/PHP_Compat/Compat/Constant/E_STRICT.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace constant E_STRICT - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.errorfunc - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - */ -if (!defined('E_STRICT')) { - define('E_STRICT', 2048); -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/FILE.php b/PHP_Compat/Compat/Constant/FILE.php deleted file mode 100644 index 4fb1f20..0000000 --- a/PHP_Compat/Compat/Constant/FILE.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace filesystem constants - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.filesystem - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - */ -if (!defined('FILE_USE_INCLUDE_PATH')) { - define('FILE_USE_INCLUDE_PATH', 1); -} - -if (!defined('FILE_IGNORE_NEW_LINES')) { - define('FILE_IGNORE_NEW_LINES', 2); -} - -if (!defined('FILE_SKIP_EMPTY_LINES')) { - define('FILE_SKIP_EMPTY_LINES', 4); -} - -if (!defined('FILE_APPEND')) { - define('FILE_APPEND', 8); -} - -if (!defined('FILE_NO_DEFAULT_CONTEXT')) { - define('FILE_NO_DEFAULT_CONTEXT', 16); -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php b/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php deleted file mode 100644 index e77dd76..0000000 --- a/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace constant PATH_SEPARATOR - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ref.dir - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.3.0-RC2 - */ -if (!defined('PATH_SEPARATOR')) { define('PATH_SEPARATOR', - strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? - ';' : - ':'); -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/STD.php b/PHP_Compat/Compat/Constant/STD.php deleted file mode 100644 index 8d4184b..0000000 --- a/PHP_Compat/Compat/Constant/STD.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace commandline constants - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/features.commandline - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.3.0 - */ -if (!defined('STDIN')) { - define('STDIN', fopen('php://stdin', 'r')); -} - -if (!defined('STDOUT')) { - define('STDOUT', fopen('php://stdout', 'w')); -} - -if (!defined('STDERR')) { - define('STDERR', fopen('php://stderr', 'w')); -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_change_key_case.php b/PHP_Compat/Compat/Function/array_change_key_case.php deleted file mode 100644 index e2df422..0000000 --- a/PHP_Compat/Compat/Function/array_change_key_case.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stephan Schmidt <schst@php.net> | -// | Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -if (!defined('CASE_LOWER')) { - define('CASE_LOWER', 0); -} - -if (!defined('CASE_UPPER')) { - define('CASE_UPPER', 1); -} - - -/** - * Replace array_change_key_case() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_change_key_case - * @author Stephan Schmidt <schst@php.net> - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.2.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_change_key_case')) -{ - function array_change_key_case ($input, $case = CASE_LOWER) - { - if (!is_array($input)) { - trigger_error('array_change_key_case(): The argument should be an array', E_USER_WARNING); - return false; - } - - $output = array (); - $keys = array_keys($input); - $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; - - foreach ($keys as $key) { - $output[$casefunc($key)] = $input[$key]; - } - - return $output; - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_chunk.php b/PHP_Compat/Compat/Function/array_chunk.php deleted file mode 100644 index 2c0b6f1..0000000 --- a/PHP_Compat/Compat/Function/array_chunk.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_combine() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_chunk - * @author Aidan Lister <aidan@php.net> - * @author Thiemo Mättig (http://maettig.com) - * @version $Revision$ - * @since PHP 4.2.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_chunk')) -{ - function array_chunk ($input, $size, $preserve_keys = false) - { - if (!is_array($input)) { - trigger_error('array_chunk() expects parameter 1 to be array, ' . gettype($input) . ' given', E_USER_WARNING); - return null; - } - - if (!is_numeric($size)) { - trigger_error('array_chunk() expects parameter 2 to be long, ' . gettype($size) . ' given', E_USER_WARNING); - return null; - } - - $size = (int)$size; - if ($size <= 0) - { - trigger_error('array_chunk() Size parameter expected to be greater than 0', E_USER_WARNING); - return null; - } - - $chunks = array(); - $i = 0; - - if ($preserve_keys !== false) - { - foreach ($input as $key => $value) { - $chunks[(int)($i++ / $size)][$key] = $value; - } - } - else - { - foreach ($input as $value) { - $chunks[(int)($i++ / $size)][] = $value; - } - } - - return $chunks; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_combine.php b/PHP_Compat/Compat/Function/array_combine.php deleted file mode 100644 index 93d1b07..0000000 --- a/PHP_Compat/Compat/Function/array_combine.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_combine() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_combine - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_combine')) -{ - function array_combine ($keys, $values) - { - if (!is_array($keys)) { - trigger_error('array_combine() expects parameter 1 to be array, ' . gettype($keys) . ' given', E_USER_WARNING); - return null; - } - - if (!is_array($values)) { - trigger_error('array_combine() expects parameter 2 to be array, ' . gettype($values) . ' given', E_USER_WARNING); - return null; - } - - if (count($keys) !== count($values)) { - trigger_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING); - return false; - } - - if (count($keys) === 0 || count($values) === 0) { - trigger_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING); - return false; - } - - $keys = array_values($keys); - $values = array_values($values); - - $combined = array (); - - for ($i = 0, $cnt = count($values); $i < $cnt; $i++) { - $combined[$keys[$i]] = $values[$i]; - } - - return $combined; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_diff_assoc.php b/PHP_Compat/Compat/Function/array_diff_assoc.php deleted file mode 100644 index d96d7c1..0000000 --- a/PHP_Compat/Compat/Function/array_diff_assoc.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_diff_assoc() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_diff_assoc - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.3.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_diff_assoc')) -{ - function array_diff_assoc () - { - // Check we have enough arguments - $args = func_get_args(); - $count = count($args); - if (count($args) < 2) { - trigger_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING); - return null; - } - - // Check arrays - for ($i = 0; $i < $count; $i++) - { - if (!is_array($args[$i])) { - trigger_error('array_diff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); - return null; - } - } - - // Get the comparison array - $array_comp = array_shift($args); - --$count; - - // Traverse values of the first array - foreach ($array_comp as $key => $value) - { - // Loop through the other arrays - for ($i = 0; $i < $count; $i++) - { - // Loop through this arrays key/value pairs and compare - foreach ($args[$i] as $comp_key => $comp_value) - { - if ((string)$key === (string)$comp_key && - (string)$value === (string)$comp_value) { - - unset($array_comp[$key]); - } - } - } - } - - return $array_comp; - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_key_exists.php b/PHP_Compat/Compat/Function/array_key_exists.php deleted file mode 100644 index 94ed5f2..0000000 --- a/PHP_Compat/Compat/Function/array_key_exists.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_key_exists() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/array_key_exists - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.1.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_key_exists')) -{ - function array_key_exists ($key, $search) - { - if (!is_scalar($key)) { - trigger_error('array_key_exists() The first argument should be either a string or an integer', E_USER_WARNING); - return false; - } - - if (is_object($search)) { - $search = get_object_vars($search); - } - - if (!is_array($search)) { - trigger_error('array_key_exists() The second argument should be either an array or an object', E_USER_WARNING); - return false; - } - - return in_array($key, array_keys($search)); - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_search.php b/PHP_Compat/Compat/Function/array_search.php deleted file mode 100644 index d794b48..0000000 --- a/PHP_Compat/Compat/Function/array_search.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_search() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/array_search - * @author Aidan Lister <aidan@php.net> - * @author Thiemo Mättig (http://maettig.com/) - * @version $Revision$ - * @since PHP 4.0.5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_search')) -{ - function array_search ($needle, $haystack, $strict = false) - { - if (!is_array($haystack)) { - trigger_error("array_search() Wrong datatype for second argument", E_USER_WARNING); - return false; - } - - foreach ($haystack as $key => $value) { - if ($strict ? $value === $needle : $value == $needle) { - return $key; - } - } - - return false; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_udiff.php b/PHP_Compat/Compat/Function/array_udiff.php deleted file mode 100644 index 40321ae..0000000 --- a/PHP_Compat/Compat/Function/array_udiff.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stephan Schmidt <schst@php.net> | -// | Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_udiff() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.array_udiff - * @author Stephan Schmidt <schst@php.net> - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_udiff')) -{ - function array_udiff () - { - $args = func_get_args(); - - if (count($args) < 3) { - trigger_error('Wrong parameter count for array_udiff()', E_USER_WARNING); - return null; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) { - if (is_array($compare_func)) { - $compare_func = $compare_func[0] . '::' . $compare_func[1]; - } - trigger_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING); - return null; - } - - // Check arrays - $cnt = count($args); - for ($i = 0; $i < $cnt; $i++) { - if (!is_array($args[$i])) { - trigger_error('array_udiff() Argument #' . ($i + 1). ' is not an array', E_USER_WARNING); - return null; - } - } - - $diff = array (); - // Traverse values of the first array - foreach ($args[0] as $key => $value) { - // Check all arrays - for ($i = 1; $i < $cnt; $i++) { - foreach ($args[$i] as $cmp_value) { - $result = call_user_func($compare_func, $value, $cmp_value); - if ($result === 0) { - continue 3; - } - } - } - $diff[$key] = $value; - } - return $diff; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_udiff_assoc.php b/PHP_Compat/Compat/Function/array_udiff_assoc.php deleted file mode 100644 index cc29d28..0000000 --- a/PHP_Compat/Compat/Function/array_udiff_assoc.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stephan Schmidt <schst@php.net> | -// | Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace array_udiff_assoc() - * - * @category PHP - * @package PHP_Compat - * @author Stephan Schmidt <schst@php.net> - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @link http://php.net/function.array-udiff-assoc - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('array_udiff_assoc')) -{ - function array_udiff_assoc () - { - $args = func_get_args(); - if (count($args) < 3) { - trigger_error('Wrong parameter count for array_udiff()', E_USER_WARNING); - return null; - } - - // Get compare function - $compare_func = array_pop($args); - if (!is_callable($compare_func)) - { - if (is_array($compare_func)) { - $compare_func = $compare_func[0].'::'.$compare_func[1]; - } - trigger_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING); - return null; - } - - // Check arrays - $count = count($args); - for ($i = 0; $i < $count; $i++) - { - if (!is_array($args[$i])) { - trigger_error('array_udiff() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); - return null; - } - } - - $diff = array (); - // Traverse values of the first array - foreach ($args[0] as $key => $value) - { - // Check all arrays - for ($i = 1; $i < $count; $i++) - { - if (!isset($args[$i][$key])) { - continue; - } - $result = call_user_func($compare_func, $value, $args[$i][$key]); - if ($result === 0) { - continue 2; - } - } - - $diff[$key] = $value; - } - - return $diff; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/call_user_func_array.php b/PHP_Compat/Compat/Function/call_user_func_array.php deleted file mode 100644 index 822b9c7..0000000 --- a/PHP_Compat/Compat/Function/call_user_func_array.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace call_user_func_array() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/call_user_func_array - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.0.4 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('call_user_func_array')) -{ - function call_user_func_array ($function, $param_arr) - { - $param_arr = (array) $param_arr; - - // Sanity check - if (!is_callable($function)) - { - if (is_array($function) && count($function) > 2) { - $function = $function[0] . '::' . $function[1]; - } - $error = sprintf('call_user_func_array() First argument is expected to be a valid callback, \'%s\' was given', $function); - trigger_error($error, E_USER_WARNING); - return null; - } - - // Build argument string - $arg_string = ''; - $comma = ''; - for ($i = 0, $x = count($param_arr); $i < $x; $i++) { - $arg_string .= $comma . "\$param_arr[$i]"; - $comma = ', '; - } - - // Determine method of calling function - if (is_array($function)) - { - $object =& $function[0]; - $method = $function[1]; - - // Static vs method call - if (is_string($function[0])) { - eval("\$retval = $object::\$method($arg_string);"); - } else { - eval("\$retval = \$object->\$method($arg_string);"); - } - } - else { - eval("\$retval = \$function($arg_string);"); - } - - return $retval; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/constant.php b/PHP_Compat/Compat/Function/constant.php deleted file mode 100644 index bb47ac7..0000000 --- a/PHP_Compat/Compat/Function/constant.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace constant() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/constant - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.0.4 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('constant')) -{ - function constant ($constant) - { - if (!defined($constant)) { - $error = sprintf('constant() Couldn\'t find constant %s', $constant); - trigger_error($error, E_USER_WARNING); - return false; - } - - eval("\$value=$constant;"); - - return $value; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/file_get_contents.php b/PHP_Compat/Compat/Function/file_get_contents.php deleted file mode 100644 index 6ed5e7f..0000000 --- a/PHP_Compat/Compat/Function/file_get_contents.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace file_get_contents() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.file_get_contents - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @internal resource_context is not supported - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('file_get_contents')) -{ - function file_get_contents ($filename, $incpath = false, $resource_context = null) - { - if (false === $fh = fopen($filename, 'rb', $incpath)) { - trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING); - return false; - } - - clearstatcache(); - if ($fsize = filesize($filename)) { - $data = fread($fh, $fsize); - } - - else { - while (!feof($fh)) { - $data .= fread($fh, 8192); - } - } - - fclose($fh); - - return $data; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/file_put_contents.php b/PHP_Compat/Compat/Function/file_put_contents.php deleted file mode 100644 index c5745df..0000000 --- a/PHP_Compat/Compat/Function/file_put_contents.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -if (!defined('FILE_USE_INCLUDE_PATH')) { - define('FILE_USE_INCLUDE_PATH', 1); -} - -if (!defined('FILE_APPEND')) { - define('FILE_APPEND', 8); -} - - -/** - * Replace file_put_contents() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.file_put_contents - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @internal $resource_context is not supported - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('file_put_contents')) -{ - function file_put_contents ($filename, $content, $flags = null, $resource_context = null) - { - // If $content is an array, convert it to a string - if (is_array($content)) { - $content = implode('', $content); - } - - // If we don't have a string, throw an error - if (!is_string($content)) { - trigger_error('file_put_contents() The 2nd parameter should be either a string or an array', E_USER_WARNING); - return false; - } - - // Get the length of date to write - $length = strlen($content); - - // Check what mode we are using - $mode = ($flags & FILE_APPEND) ? - $mode = 'a' : - $mode = 'w'; - - // Check if we're using the include path - $use_inc_path = ($flags & FILE_USE_INCLUDE_PATH) ? - true : - false; - - // Open the file for writing - if (($fh = @fopen($filename, $mode, $use_inc_path)) === false) { - trigger_error('file_put_contents() failed to open stream: Permission denied', E_USER_WARNING); - return false; - } - - // Write to the file - $bytes = 0; - if (($bytes = @fwrite($fh, $content)) === false) { - $errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s', - $length, - $filename); - trigger_error($errormsg, E_USER_WARNING); - return false; - } - - // Close the handle - @fclose($fh); - - // Check all the data was written - if ($bytes != $length) { - $errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.', - $bytes, - $length); - trigger_error($errormsg, E_USER_WARNING); - return false; - } - - // Return length - return $bytes; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/fprintf.php b/PHP_Compat/Compat/Function/fprintf.php deleted file mode 100644 index 52faced..0000000 --- a/PHP_Compat/Compat/Function/fprintf.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace fprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.fprintf - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('fprintf')) -{ - function fprintf () { - $args = func_get_args(); - - if (count($args) < 2) { - trigger_error ('Wrong parameter count for fprintf()', E_USER_WARNING); - return null; - } - - $resource_handle = array_shift($args); - $format = array_shift($args); - - if (!is_resource($resource_handle)) { - trigger_error ('fprintf(): supplied argument is not a valid stream resource', E_USER_WARNING); - return false; - } - - return fwrite($resource_handle, vsprintf($format, $args)); - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/get_include_path.php b/PHP_Compat/Compat/Function/get_include_path.php deleted file mode 100644 index 3c673a8..0000000 --- a/PHP_Compat/Compat/Function/get_include_path.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php -if(!function_exists("get_include_path")) { - function get_include_path() { - return ini_get('include_path'); - } -} -?> diff --git a/PHP_Compat/Compat/Function/html_entity_decode.php b/PHP_Compat/Compat/Function/html_entity_decode.php deleted file mode 100644 index 18d469b..0000000 --- a/PHP_Compat/Compat/Function/html_entity_decode.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: David Irvine <dave@codexweb.co.za> | -// | Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -if (!defined('ENT_NOQUOTES')) { - define('ENT_NOQUOTES', 0); -} - -if (!defined('ENT_COMPAT')) { - define('ENT_COMPAT', 2); -} - -if (!defined('ENT_QUOTES')) { - define('ENT_QUOTES', 3); -} - - -/** - * Replace html_entity_decode() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.html_entity_decode - * @author David Irvine <dave@codexweb.co.za> - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.3.0 - * @internal Setting the charset will not do anything - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('html_entity_decode')) -{ - function html_entity_decode ($string, $quote_style = ENT_COMPAT, $charset = null) - { - if (!is_int($quote_style)) { - trigger_error('html_entity_decode() expects parameter 2 to be long, ' . gettype($quote_style) . ' given', E_USER_WARNING); - return null; - } - - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - $trans_tbl = array_flip($trans_tbl); - - // Add single quote to translation table; - $trans_tbl['''] = '\''; - - // Not translating double quotes - if ($quote_style & ENT_NOQUOTES) { - // Remove double quote from translation table - unset($trans_tbl['"']); - } - - return strtr($string, $trans_tbl); - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/http_build_query.php b/PHP_Compat/Compat/Function/http_build_query.php deleted file mode 100644 index 33b95da..0000000 --- a/PHP_Compat/Compat/Function/http_build_query.php +++ /dev/null @@ -1,101 +0,0 @@ -<?PHP -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stephan Schmidt <schst@php.net> | -// | Aidan Lister <aidan@php.net> -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace function http_build_query() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.http-build-query - * @author Stephan Schmidt <schst@php.net> - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('http_build_query')) -{ - function http_build_query ($formdata, $numeric_prefix = null) - { - // If $formdata is an object, convert it to an array - if (is_object($formdata)) { - $formdata = get_object_vars($formdata); - } - - // Check we have an array to work with - if (!is_array($formdata)) { - trigger_error('http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given.', E_USER_WARNING); - return false; - } - - // If the array is empty, return null - if (empty($formdata)) { - return null; - } - - // Start building the query - $tmp = array (); - foreach ($formdata as $key => $val) - { - if (is_integer($key) && $numeric_prefix != null) { - $key = $numeric_prefix . $key; - } - - if (is_scalar($val)) { - array_push($tmp, urlencode($key).'='.urlencode($val)); - continue; - } - - // If the value is an array, recursively parse it - if (is_array($val)) { - array_push($tmp, __http_build_query($val, urlencode($key))); - continue; - } - } - - return implode('&', $tmp); - } - - // Helper function - function __http_build_query ($array, $name) - { - $tmp = array (); - foreach ($array as $key => $value) - { - if (is_array($value)) { - array_push($tmp, __http_build_query($value, sprintf('%s[%s]', $name, $key))); - } - - elseif (is_scalar($value)) { - array_push($tmp, sprintf('%s[%s]=%s', $name, urlencode($key), urlencode($value))); - } - - elseif (is_object($value)) { - array_push($tmp, __http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key))); - } - } - - return implode('&', $tmp); - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/image_type_to_mime_type.php b/PHP_Compat/Compat/Function/image_type_to_mime_type.php deleted file mode 100644 index 69a1144..0000000 --- a/PHP_Compat/Compat/Function/image_type_to_mime_type.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -if (!defined('IMAGETYPE_GIF')) { - define('IMAGETYPE_GIF', 0); -} - -if (!defined('IMAGETYPE_JPEG')) { - define('IMAGETYPE_JPEG', 1); -} - -if (!defined('IMAGETYPE_PNG')) { - define('IMAGETYPE_PNG', 2); -} - -if (!defined('IMAGETYPE_SWF')) { - define('IMAGETYPE_SWF', 3); -} - -if (!defined('IMAGETYPE_PSD')) { - define('IMAGETYPE_PSD', 4); -} - -if (!defined('IMAGETYPE_BMP')) { - define('IMAGETYPE_BMP', 5); -} - -if (!defined('IMAGETYPE_TIFF_II')) { - define('IMAGETYPE_TIFF_II', 6); -} - -if (!defined('IMAGETYPE_TIFF_MM')) { - define('IMAGETYPE_TIFF_MM', 7); -} - -if (!defined('IMAGETYPE_JPC')) { - define('IMAGETYPE_JPC', 8); -} - -if (!defined('IMAGETYPE_JP2')) { - define('IMAGETYPE_JP2', 9); -} - -if (!defined('IMAGETYPE_JPX')) { - define('IMAGETYPE_JPX', 10); -} - -if (!defined('IMAGETYPE_JB2')) { - define('IMAGETYPE_JB2', 11); -} - -if (!defined('IMAGETYPE_SWC')) { - define('IMAGETYPE_SWC', 12); -} - -if (!defined('IMAGETYPE_IFF')) { - define('IMAGETYPE_IFF', 13); -} - -if (!defined('IMAGETYPE_WBMP')) { - define('IMAGETYPE_WBMP', 14); -} - -if (!defined('IMAGETYPE_XBM')) { - define('IMAGETYPE_XBM', 15); -} - - -/** - * Replace image_type_to_mime_type() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.image_type_to_mime_type - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.3.0 - * @require PHP 3 - */ -if (!function_exists('image_type_to_mime_type')) -{ - function image_type_to_mime_type ($imagetype) - { - static $image_type_to_mime_type = array ( - IMAGETYPE_GIF => 'image/gif', - IMAGETYPE_JPEG => 'image/jpeg', - IMAGETYPE_PNG => 'image/png', - IMAGETYPE_SWF => 'application/x-shockwave-flash', - IMAGETYPE_PSD => 'image/psd', - IMAGETYPE_BMP => 'image/bmp', - IMAGETYPE_TIFF_II => 'image/tiff', - IMAGETYPE_TIFF_MM => 'image/tiff', - IMAGETYPE_JPC => 'application/octet-stream', - IMAGETYPE_JP2 => 'image/jp2', - IMAGETYPE_JPX => 'application/octet-stream', - IMAGETYPE_JB2 => 'application/octet-stream', - IMAGETYPE_SWC => 'application/x-shockwave-flash', - IMAGETYPE_IFF => 'image/iff', - IMAGETYPE_WBMP => 'image/vnd.wap.wbmp', - IMAGETYPE_XBM => 'image/xbm', - ); - - return (isset($image_type_to_mime_type[$imagetype]) ? - $image_type_to_mime_type[$imagetype] : - $image_type_to_mime_type[IMAGETYPE_JPC]); - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/is_a.php b/PHP_Compat/Compat/Function/is_a.php deleted file mode 100644 index bffc408..0000000 --- a/PHP_Compat/Compat/Function/is_a.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace function is_a() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.is_a - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.2.0 - * @require PHP 4.0.0 (is_subclass_of) - */ -if (!function_exists('is_a')) -{ - function is_a ($object, $class) - { - if (get_class($object) == strtolower($class)) { - return true; - } - - else { - return is_subclass_of($object, $class); - } - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/json_funcs.php b/PHP_Compat/Compat/Function/json_funcs.php deleted file mode 100644 index fcd48fb..0000000 --- a/PHP_Compat/Compat/Function/json_funcs.php +++ /dev/null @@ -1,821 +0,0 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Converts to and from JSON format.
- *
- * JSON (JavaScript Object Notation) is a lightweight data-interchange
- * format. It is easy for humans to read and write. It is easy for machines
- * to parse and generate. It is based on a subset of the JavaScript
- * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
- * This feature can also be found in Python. JSON is a text format that is
- * completely language independent but uses conventions that are familiar
- * to programmers of the C-family of languages, including C, C++, C#, Java,
- * JavaScript, Perl, TCL, and many others. These properties make JSON an
- * ideal data-interchange language.
- *
- * This package provides a simple encoder and decoder for JSON notation. It
- * is intended for use with client-side Javascript applications that make
- * use of HTTPRequest to perform server communication functions - data can
- * be encoded into JSON notation for use in a client-side javascript, or
- * decoded from incoming Javascript requests. JSON format is native to
- * Javascript, and can be directly eval()'ed with no further parsing
- * overhead
- *
- * All strings should be in ASCII or UTF-8 format!
- *
- * LICENSE: Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met: Redistributions of source code must retain the
- * above copyright notice, this list of conditions and the following
- * disclaimer. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * @category
- * @package Services_JSON
- * @author Michal Migurski <mike-json@teczno.com>
- * @author Matt Knapp <mdknapp[at]gmail[dot]com>
- * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
- * @copyright 2005 Michal Migurski
- * @version CVS: $Id$
- * @license http://www.opensource.org/licenses/bsd-license.php
- * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
- */
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_SLICE', 1);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_STR', 2);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_ARR', 3);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_OBJ', 4);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_CMT', 5);
-
-/**
- * Behavior switch for Services_JSON::decode()
- */
-define('SERVICES_JSON_LOOSE_TYPE', 16);
-
-/**
- * Behavior switch for Services_JSON::decode()
- */
-define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
-
-/**
- * Converts to and from JSON format.
- *
- * Brief example of use:
- *
- * <code>
- * // create a new instance of Services_JSON
- * $json = new Services_JSON();
- *
- * // convert a complexe value to JSON notation, and send it to the browser
- * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
- * $output = $json->encode($value);
- *
- * print($output);
- * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
- *
- * // accept incoming POST data, assumed to be in JSON notation
- * $input = file_get_contents('php://input', 1000000);
- * $value = $json->decode($input);
- * </code>
- */
-class Services_JSON
-{
- /**
- * constructs a new JSON instance
- *
- * @param int $use object behavior flags; combine with boolean-OR
- *
- * possible values:
- * - SERVICES_JSON_LOOSE_TYPE: loose typing.
- * "{...}" syntax creates associative arrays
- * instead of objects in decode().
- * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
- * Values which can't be encoded (e.g. resources)
- * appear as NULL instead of throwing errors.
- * By default, a deeply-nested resource will
- * bubble up with an error, so all return values
- * from encode() should be checked with isError()
- */
- function Services_JSON($use = 0)
- {
- $this->use = $use;
- }
-
- /**
- * convert a string from one UTF-16 char to one UTF-8 char
- *
- * Normally should be handled by mb_convert_encoding, but
- * provides a slower PHP-only method for installations
- * that lack the multibye string extension.
- *
- * @param string $utf16 UTF-16 character
- * @return string UTF-8 character
- * @access private
- */
- function utf162utf8($utf16)
- {
- // oh please oh please oh please oh please oh please
- if(function_exists('mb_convert_encoding')) {
- return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
- }
-
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
-
- switch(true) {
- case ((0x7F & $bytes) == $bytes):
- // this case should never be reached, because we are in ASCII range
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x7F & $bytes);
-
- case (0x07FF & $bytes) == $bytes:
- // return a 2-byte UTF-8 character
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0xC0 | (($bytes >> 6) & 0x1F))
- . chr(0x80 | ($bytes & 0x3F));
-
- case (0xFFFF & $bytes) == $bytes:
- // return a 3-byte UTF-8 character
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0xE0 | (($bytes >> 12) & 0x0F))
- . chr(0x80 | (($bytes >> 6) & 0x3F))
- . chr(0x80 | ($bytes & 0x3F));
- }
-
- // ignoring UTF-32 for now, sorry
- return '';
- }
-
- /**
- * convert a string from one UTF-8 char to one UTF-16 char
- *
- * Normally should be handled by mb_convert_encoding, but
- * provides a slower PHP-only method for installations
- * that lack the multibye string extension.
- *
- * @param string $utf8 UTF-8 character
- * @return string UTF-16 character
- * @access private
- */
- function utf82utf16($utf8)
- {
- // oh please oh please oh please oh please oh please
- if(function_exists('mb_convert_encoding')) {
- return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
- }
-
- switch(strlen($utf8)) {
- case 1:
- // this case should never be reached, because we are in ASCII range
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return $utf8;
-
- case 2:
- // return a UTF-16 character from a 2-byte UTF-8 char
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
-
- case 3:
- // return a UTF-16 character from a 3-byte UTF-8 char
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
- }
-
- // ignoring UTF-32 for now, sorry
- return '';
- }
-
- /**
- * encodes an arbitrary variable into JSON format
- *
- * @param mixed $var any number, boolean, string, array, or object to be encoded.
- * see argument 1 to Services_JSON() above for array-parsing behavior.
- * if var is a strng, note that encode() always expects it
- * to be in ASCII or UTF-8 format!
- *
- * @return mixed JSON string representation of input var or an error if a problem occurs
- * @access public
- */
- function encode($var)
- {
- switch (gettype($var)) {
- case 'boolean':
- return $var ? 'true' : 'false';
-
- case 'NULL':
- return 'null';
-
- case 'integer':
- return (int) $var;
-
- case 'double':
- case 'float':
- return (float) $var;
-
- case 'string':
- // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
- $ascii = '';
- $strlen_var = strlen($var);
-
- /*
- * Iterate over every character in the string,
- * escaping with a slash or encoding to UTF-8 where necessary
- */
- for ($c = 0; $c < $strlen_var; ++$c) {
-
- $ord_var_c = ord($var{$c});
-
- switch (true) {
- case $ord_var_c == 0x08:
- $ascii .= '\b';
- break;
- case $ord_var_c == 0x09:
- $ascii .= '\t';
- break;
- case $ord_var_c == 0x0A:
- $ascii .= '\n';
- break;
- case $ord_var_c == 0x0C:
- $ascii .= '\f';
- break;
- case $ord_var_c == 0x0D:
- $ascii .= '\r';
- break;
-
- case $ord_var_c == 0x22:
- case $ord_var_c == 0x2F:
- case $ord_var_c == 0x5C:
- // double quote, slash, slosh
- $ascii .= '\\'.$var{$c};
- break;
-
- case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
- // characters U-00000000 - U-0000007F (same as ASCII)
- $ascii .= $var{$c};
- break;
-
- case (($ord_var_c & 0xE0) == 0xC0):
- // characters U-00000080 - U-000007FF, mask 110XXXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
- $c += 1;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xF0) == 0xE0):
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}));
- $c += 2;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xF8) == 0xF0):
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}));
- $c += 3;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xFC) == 0xF8):
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}));
- $c += 4;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xFE) == 0xFC):
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}),
- ord($var{$c + 5}));
- $c += 5;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
- }
- }
-
- return '"'.$ascii.'"';
-
- case 'array':
- /*
- * As per JSON spec if any array key is not an integer
- * we must treat the the whole array as an object. We
- * also try to catch a sparsely populated associative
- * array with numeric keys here because some JS engines
- * will create an array with empty indexes up to
- * max_index which can cause memory issues and because
- * the keys, which may be relevant, will be remapped
- * otherwise.
- *
- * As per the ECMA and JSON specification an object may
- * have any string as a property. Unfortunately due to
- * a hole in the ECMA specification if the key is a
- * ECMA reserved word or starts with a digit the
- * parameter is only accessible using ECMAScript's
- * bracket notation.
- */
-
- // treat as a JSON object
- if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
- $properties = array_map(array($this, 'name_value'),
- array_keys($var),
- array_values($var));
-
- foreach($properties as $property) {
- if(Services_JSON::isError($property)) {
- return $property;
- }
- }
-
- return '{' . join(',', $properties) . '}';
- }
-
- // treat it like a regular array
- $elements = array_map(array($this, 'encode'), $var);
-
- foreach($elements as $element) {
- if(Services_JSON::isError($element)) {
- return $element;
- }
- }
-
- return '[' . join(',', $elements) . ']';
-
- case 'object':
- $vars = get_object_vars($var);
-
- $properties = array_map(array($this, 'name_value'),
- array_keys($vars),
- array_values($vars));
-
- foreach($properties as $property) {
- if(Services_JSON::isError($property)) {
- return $property;
- }
- }
-
- return '{' . join(',', $properties) . '}';
-
- default:
- return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
- ? 'null'
- : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
- }
- }
-
- /**
- * array-walking function for use in generating JSON-formatted name-value pairs
- *
- * @param string $name name of key to use
- * @param mixed $value reference to an array element to be encoded
- *
- * @return string JSON-formatted name-value pair, like '"name":value'
- * @access private
- */
- function name_value($name, $value)
- {
- $encoded_value = $this->encode($value);
-
- if(Services_JSON::isError($encoded_value)) {
- return $encoded_value;
- }
-
- return $this->encode(strval($name)) . ':' . $encoded_value;
- }
-
- /**
- * reduce a string by removing leading and trailing comments and whitespace
- *
- * @param $str string string value to strip of comments and whitespace
- *
- * @return string string value stripped of comments and whitespace
- * @access private
- */
- function reduce_string($str)
- {
- $str = preg_replace(array(
-
- // eliminate single line comments in '// ...' form
- '#^\s*//(.+)$#m',
-
- // eliminate multi-line comments in '/* ... */' form, at start of string
- '#^\s*/\*(.+)\*/#Us',
-
- // eliminate multi-line comments in '/* ... */' form, at end of string
- '#/\*(.+)\*/\s*$#Us'
-
- ), '', $str);
-
- // eliminate extraneous space
- return trim($str);
- }
-
- /**
- * decodes a JSON string into appropriate variable
- *
- * @param string $str JSON-formatted string
- *
- * @return mixed number, boolean, string, array, or object
- * corresponding to given JSON input string.
- * See argument 1 to Services_JSON() above for object-output behavior.
- * Note that decode() always returns strings
- * in ASCII or UTF-8 format!
- * @access public
- */
- function decode($str)
- {
- $str = $this->reduce_string($str);
-
- switch (strtolower($str)) {
- case 'true':
- return true;
-
- case 'false':
- return false;
-
- case 'null':
- return null;
-
- default:
- $m = array();
-
- if (is_numeric($str)) {
- // Lookie-loo, it's a number
-
- // This would work on its own, but I'm trying to be
- // good about returning integers where appropriate:
- // return (float)$str;
-
- // Return float or int, as appropriate
- return ((float)$str == (integer)$str)
- ? (integer)$str
- : (float)$str;
-
- } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
- // STRINGS RETURNED IN UTF-8 FORMAT
- $delim = substr($str, 0, 1);
- $chrs = substr($str, 1, -1);
- $utf8 = '';
- $strlen_chrs = strlen($chrs);
-
- for ($c = 0; $c < $strlen_chrs; ++$c) {
-
- $substr_chrs_c_2 = substr($chrs, $c, 2);
- $ord_chrs_c = ord($chrs{$c});
-
- switch (true) {
- case $substr_chrs_c_2 == '\b':
- $utf8 .= chr(0x08);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\t':
- $utf8 .= chr(0x09);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\n':
- $utf8 .= chr(0x0A);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\f':
- $utf8 .= chr(0x0C);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\r':
- $utf8 .= chr(0x0D);
- ++$c;
- break;
-
- case $substr_chrs_c_2 == '\\"':
- case $substr_chrs_c_2 == '\\\'':
- case $substr_chrs_c_2 == '\\\\':
- case $substr_chrs_c_2 == '\\/':
- if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
- ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
- $utf8 .= $chrs{++$c};
- }
- break;
-
- case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
- // single, escaped unicode character
- $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
- . chr(hexdec(substr($chrs, ($c + 4), 2)));
- $utf8 .= $this->utf162utf8($utf16);
- $c += 5;
- break;
-
- case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
- $utf8 .= $chrs{$c};
- break;
-
- case ($ord_chrs_c & 0xE0) == 0xC0:
- // characters U-00000080 - U-000007FF, mask 110XXXXX
- //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 2);
- ++$c;
- break;
-
- case ($ord_chrs_c & 0xF0) == 0xE0:
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 3);
- $c += 2;
- break;
-
- case ($ord_chrs_c & 0xF8) == 0xF0:
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 4);
- $c += 3;
- break;
-
- case ($ord_chrs_c & 0xFC) == 0xF8:
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 5);
- $c += 4;
- break;
-
- case ($ord_chrs_c & 0xFE) == 0xFC:
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 6);
- $c += 5;
- break;
-
- }
-
- }
-
- return $utf8;
-
- } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
- // array, or object notation
-
- if ($str{0} == '[') {
- $stk = array(SERVICES_JSON_IN_ARR);
- $arr = array();
- } else {
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
- $stk = array(SERVICES_JSON_IN_OBJ);
- $obj = array();
- } else {
- $stk = array(SERVICES_JSON_IN_OBJ);
- $obj = new stdClass();
- }
- }
-
- array_push($stk, array('what' => SERVICES_JSON_SLICE,
- 'where' => 0,
- 'delim' => false));
-
- $chrs = substr($str, 1, -1);
- $chrs = $this->reduce_string($chrs);
-
- if ($chrs == '') {
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
- return $arr;
-
- } else {
- return $obj;
-
- }
- }
-
- //print("\nparsing {$chrs}\n");
-
- $strlen_chrs = strlen($chrs);
-
- for ($c = 0; $c <= $strlen_chrs; ++$c) {
-
- $top = end($stk);
- $substr_chrs_c_2 = substr($chrs, $c, 2);
-
- if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
- // found a comma that is not inside a string, array, etc.,
- // OR we've reached the end of the character list
- $slice = substr($chrs, $top['where'], ($c - $top['where']));
- array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
- //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
- // we are in an array, so just push an element onto the stack
- array_push($arr, $this->decode($slice));
-
- } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
- // we are in an object, so figure
- // out the property name and set an
- // element in an associative array,
- // for now
- $parts = array();
-
- if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
- // "name":value pair
- $key = $this->decode($parts[1]);
- $val = $this->decode($parts[2]);
-
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
- $obj[$key] = $val;
- } else {
- $obj->$key = $val;
- }
- } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
- // name:value pair, where name is unquoted
- $key = $parts[1];
- $val = $this->decode($parts[2]);
-
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
- $obj[$key] = $val;
- } else {
- $obj->$key = $val;
- }
- }
-
- }
-
- } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
- // found a quote, and we are not inside a string
- array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
- //print("Found start of string at {$c}\n");
-
- } elseif (($chrs{$c} == $top['delim']) &&
- ($top['what'] == SERVICES_JSON_IN_STR) &&
- ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
- // found a quote, we're in a string, and it's not escaped
- // we know that it's not escaped becase there is _not_ an
- // odd number of backslashes at the end of the string so far
- array_pop($stk);
- //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
-
- } elseif (($chrs{$c} == '[') &&
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
- // found a left-bracket, and we are in an array, object, or slice
- array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
- //print("Found start of array at {$c}\n");
-
- } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
- // found a right-bracket, and we're in an array
- array_pop($stk);
- //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- } elseif (($chrs{$c} == '{') &&
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
- // found a left-brace, and we are in an array, object, or slice
- array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
- //print("Found start of object at {$c}\n");
-
- } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
- // found a right-brace, and we're in an object
- array_pop($stk);
- //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- } elseif (($substr_chrs_c_2 == '/*') &&
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
- // found a comment start, and we are in an array, object, or slice
- array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
- $c++;
- //print("Found start of comment at {$c}\n");
-
- } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
- // found a comment end, and we're in one now
- array_pop($stk);
- $c++;
-
- for ($i = $top['where']; $i <= $c; ++$i)
- $chrs = substr_replace($chrs, ' ', $i, 1);
-
- //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- }
-
- }
-
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
- return $arr;
-
- } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
- return $obj;
-
- }
-
- }
- }
- }
-
- /**
- * @todo Ultimately, this should just call PEAR::isError()
- */
- function isError($data, $code = null)
- {
- if (class_exists('pear')) {
- return PEAR::isError($data, $code);
- } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
- is_subclass_of($data, 'services_json_error'))) {
- return true;
- }
-
- return false;
- }
-}
-
-if (class_exists('PEAR_Error')) {
-
- class Services_JSON_Error extends PEAR_Error
- {
- function Services_JSON_Error($message = 'unknown error', $code = null,
- $mode = null, $options = null, $userinfo = null)
- {
- parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
- }
- }
-
-} else {
-
- /**
- * @todo Ultimately, this class shall be descended from PEAR_Error
- */
- class Services_JSON_Error
- {
- function Services_JSON_Error($message = 'unknown error', $code = null,
- $mode = null, $options = null, $userinfo = null)
- {
-
- }
- }
-
-}
-
-// Future-friendly json_encode
-if( !function_exists('json_encode') ) {
- function json_encode($data) {
- $json = new Services_JSON();
- return( $json->encode($data) );
- }
-}
-
-// Future-friendly json_decode
-if( !function_exists('json_decode') ) {
- function json_decode($data) {
- $json = new Services_JSON();
- return( $json->decode($data) );
- }
-}
-?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_clean.php b/PHP_Compat/Compat/Function/ob_clean.php deleted file mode 100644 index 565713b..0000000 --- a/PHP_Compat/Compat/Function/ob_clean.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace ob_clean() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ob_clean - * @author Aidan Lister <aidan@php.net> - * @author Thiemo Mättig (http://maettig.com/) - * @version $Revision$ - * @since PHP 4.2.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('ob_clean')) -{ - function ob_clean () - { - if (@ob_end_clean()) { - return ob_start(); - } - - trigger_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE); - - return false; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_flush.php b/PHP_Compat/Compat/Function/ob_flush.php deleted file mode 100644 index c57a1f5..0000000 --- a/PHP_Compat/Compat/Function/ob_flush.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace ob_flush() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ob_flush - * @author Aidan Lister <aidan@php.net> - * @author Thiemo Mättig (http://maettig.com/) - * @version $Revision$ - * @since PHP 4.2.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('ob_flush')) -{ - function ob_flush () - { - if (@ob_end_flush()) { - return ob_start(); - } - - trigger_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE); - - return false; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_get_clean.php b/PHP_Compat/Compat/Function/ob_get_clean.php deleted file mode 100644 index 9c2686c..0000000 --- a/PHP_Compat/Compat/Function/ob_get_clean.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace ob_get_clean() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ob_get_clean - * @author Aidan Lister <aidan@php.net> - * @author Thiemo Mättig (http://maettig.com/) - * @version $Revision$ - * @since PHP 4.3.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('ob_get_clean')) -{ - function ob_get_clean () - { - $contents = ob_get_contents(); - - if ($contents !== false) { - ob_end_clean(); - } - - return $contents; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_get_flush.php b/PHP_Compat/Compat/Function/ob_get_flush.php deleted file mode 100644 index 2c5cec9..0000000 --- a/PHP_Compat/Compat/Function/ob_get_flush.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace ob_get_flush() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/ob_get_flush - * @author Aidan Lister <aidan@php.net> - * @author Thiemo Mättig (http://maettig.com/) - * @version $Revision$ - * @since PHP 4.3.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('ob_get_flush')) -{ - function ob_get_flush () - { - $contents = ob_get_contents(); - - if ($contents !== false) { - ob_end_flush(); - } - - return $contents; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/scandir.php b/PHP_Compat/Compat/Function/scandir.php deleted file mode 100644 index 5766c35..0000000 --- a/PHP_Compat/Compat/Function/scandir.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace scandir() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.scandir - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('scandir')) -{ - function scandir ($directory, $sorting_order = 0) - { - if (!is_string($directory)) { - trigger_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING); - return null; - } - - if (!is_int($sorting_order)) { - trigger_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING); - return null; - } - - if (!is_dir($directory) || (false === $fh = @opendir($directory))) { - trigger_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING); - return false; - } - - $files = array (); - while (false !== ($filename = readdir($fh))) { - $files[] = $filename; - } - - closedir($fh); - - if ($sorting_order == 1) { - rsort($files); - } else { - sort($files); - } - - return $files; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/set_include_path.php b/PHP_Compat/Compat/Function/set_include_path.php deleted file mode 100644 index d6f2006..0000000 --- a/PHP_Compat/Compat/Function/set_include_path.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php -if(!function_exists("set_include_path")) { - function set_include_path($path) { - return ini_set('include_path', $path); - } -} -?> diff --git a/PHP_Compat/Compat/Function/str_ireplace.php b/PHP_Compat/Compat/Function/str_ireplace.php deleted file mode 100644 index 221c9eb..0000000 --- a/PHP_Compat/Compat/Function/str_ireplace.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace str_ireplace() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_ireplace - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @internal count not by returned by reference - not possible in php4 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('str_ireplace')) -{ - function str_ireplace ($search, $replace, $subject, $count = null) - { - if (is_string($search) && is_array($replace)) { - trigger_error('Array to string conversion', E_USER_NOTICE); - $replace = (string) $replace; - } - - // If search isn't an array, make it one - if (!is_array($search)) { - $search = array ($search); - } - - // If replace isn't an array, make it one, and pad it to the length of search - if (!is_array($replace)) - { - $replace_string = $replace; - - $replace = array (); - for ($i = 0, $c = count($search); $i < $c; $i++) - { - $replace[$i] = $replace_string; - } - } - - // Check the replace array is padded to the correct length - $length_replace = count($replace); - $length_search = count($search); - if ($length_replace < $length_search) - { - for ($i = $length_replace; $i < $length_search; $i++) - { - $replace[$i] = ''; - } - } - - // If subject is not an array, make it one - $was_array = false; - if (!is_array($subject)) { - $was_array = true; - $subject = array ($subject); - } - - // Loop through each subject - $count = 0; - foreach ($subject as $subject_key => $subject_value) - { - // Loop through each search - foreach ($search as $search_key => $search_value) - { - // Split the array into segments, in between each part is our search - $segments = explode(strtolower($search_value), strtolower($subject_value)); - - // The number of replacements done is the number of segments minus the first - $count += count($segments) - 1; - $pos = 0; - - // Loop through each segment - foreach ($segments as $segment_key => $segment_value) - { - // Replace the lowercase segments with the upper case versions - $segments[$segment_key] = substr($subject_value, $pos, strlen($segment_value)); - // Increase the position relative to the initial string - $pos += strlen($segment_value) + strlen($search_value); - } - - // Put our original string back together - $subject_value = implode($replace[$search_key], $segments); - } - - $result[$subject_key] = $subject_value; - } - - // Check if subject was initially a string and return it as a string - if ($was_array === true) { - return $result[0]; - } - - // Otherwise, just return the array - return $result; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/str_split.php b/PHP_Compat/Compat/Function/str_split.php deleted file mode 100644 index b46e4f7..0000000 --- a/PHP_Compat/Compat/Function/str_split.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace str_split() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.str_split - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('str_split')) -{ - function str_split ($string, $split_length = 1) - { - if (!is_numeric($split_length)) { - trigger_error('str_split() expects parameter 2 to be long, ' . gettype($split_length) . ' given', E_USER_WARNING); - return false; - } - - if ($split_length < 1) { - trigger_error('str_split() The the length of each segment must be greater then zero', E_USER_WARNING); - return false; - } - - preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches); - return $matches[0]; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/stripos.php b/PHP_Compat/Compat/Function/stripos.php deleted file mode 100644 index 0ea96f8..0000000 --- a/PHP_Compat/Compat/Function/stripos.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace stripos() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.stripos - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('stripos')) -{ - function stripos ($haystack, $needle, $offset = null) - { - if (!is_scalar($haystack)) { - trigger_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($needle)) { - trigger_error('stripos() needle is not a string or an integer.', E_USER_WARNING); - return false; - } - - if (!is_null($offset) && !is_numeric($offset)) { - trigger_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); - return false; - } - - // Manipulate the string if there is an offset - $fix = 0; - if (!is_null($offset)) - { - if ($offset > 0) - { - $haystack = substr($haystack, $offset, strlen($haystack) - $offset); - $fix = $offset; - } - } - - $segments = explode (strtolower($needle), strtolower($haystack), 2); - // Check there was a match - if (count($segments) === 1) { - return false; - } - $position = strlen($segments[0]) + $fix; - - return $position; - } -} -?> diff --git a/PHP_Compat/Compat/Function/strripos.php b/PHP_Compat/Compat/Function/strripos.php deleted file mode 100644 index bb8b59d..0000000 --- a/PHP_Compat/Compat/Function/strripos.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// | Stephan Schmidt <schst@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace strripos() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.strripos - * @author Aidan Lister <aidan@php.net> - * @author Stephan Schmidt <schst@php.net> - * @version $Revision$ - * @since PHP 5 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('strripos')) -{ - function strripos ($haystack, $needle, $offset = null) - { - if (!is_scalar($haystack)) { - trigger_error('strripos() expects parameter 1 to be scalar, ' . gettype($haystack) . ' given', E_USER_WARNING); - return false; - } - - if (!is_scalar($needle)) { - trigger_error('strripos() expects parameter 2 to be scalar, ' . gettype($needle) . ' given', E_USER_WARNING); - return false; - } - - if (!is_null($offset) && !is_numeric($offset)) { - trigger_error('strripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); - return false; - } - - // Manipulate the string if there is an offset - $fix = 0; - if (!is_null($offset)) - { - // If the offset is larger than the haystack, return - if (abs($offset) >= strlen($haystack)) { - return false; - } - - // Check whether offset is negative or positive - if ($offset > 0) { - $haystack = substr($haystack, $offset, strlen($haystack) - $offset); - // We need to add this to the position of the needle - $fix = $offset; - } - else { - $haystack = substr($haystack, 0, strlen($haystack) + $offset); - } - } - - $segments = explode(strtolower($needle), strtolower($haystack)); - - $last_seg = count($segments) - 1; - $position = strlen($haystack) + $fix - strlen($segments[$last_seg]) - strlen($needle); - - return $position; - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/var_export.php b/PHP_Compat/Compat/Function/var_export.php deleted file mode 100644 index b5d8719..0000000 --- a/PHP_Compat/Compat/Function/var_export.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace var_export() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.var_export - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.2.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('var_export')) -{ - function var_export ($array, $return = false) - { - // Common output variables - $indent = ' '; - $doublearrow = ' => '; - $lineend = ",\n"; - $stringdelim = '\''; - $newline = "\n"; - - // Check the export isn't a simple string / int - if (is_string($array)) { - $out = $stringdelim . $array . $stringdelim; - } - elseif (is_int($array)) { - $out = (string)$array; - } - - // Begin the array export - else - { - // Start the string - $out = "array (\n"; - - // Loop through each value in array - foreach ($array as $key => $value) - { - // If the key is a string, delimit it - if (is_string($key)) { - $key = $stringdelim . addslashes($key) . $stringdelim; - } - - // If the value is a string, delimit it - if (is_string($value)) { - $value = $stringdelim . addslashes($value) . $stringdelim; - } - - // We have an array, so do some recursion - elseif (is_array($value)) - { - // Do some basic recursion while increasing the indent - $recur_array = explode($newline, var_export($value, true)); - $recur_newarr = array (); - foreach ($recur_array as $recur_line) { - $recur_newarr[] = $indent . $recur_line; - } - $recur_array = implode($newline, $recur_newarr); - $value = $newline . $recur_array; - } - - // Piece together the line - $out .= $indent . $key . $doublearrow . $value . $lineend; - } - - // End our string - $out .= ")"; - } - - - // Decide method of output - if ($return === true) { - return $out; - } else { - echo $out; - return null; - } - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/version_compare.php b/PHP_Compat/Compat/Function/version_compare.php deleted file mode 100644 index 0542ff9..0000000 --- a/PHP_Compat/Compat/Function/version_compare.php +++ /dev/null @@ -1,170 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Philippe Jausions <Philippe.Jausions@11abacus.com> | -// | Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace version_compare() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/version_compare - * @author Philippe Jausions <Philippe.Jausions@11abacus.com> - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.1.0 - * @require PHP 4.0.1 (trigger_error) - */ -if (!function_exists('version_compare')) { - - function version_compare ($version1, $version2, $operator = '<') - { - // Check input - if (!is_scalar($version1)) { - trigger_error('version_compare() expects parameter 1 to be string, ' . gettype($version1) . ' given', E_USER_WARNING); - return null; - } - - if (!is_scalar($version2)) { - trigger_error('version_compare() expects parameter 2 to be string, ' . gettype($version2) . ' given', E_USER_WARNING); - return null; - } - - if (!is_scalar($operator)) { - trigger_error('version_compare() expects parameter 3 to be string, ' . gettype($operator) . ' given', E_USER_WARNING); - return null; - } - - // Standardise versions - $v1 = explode('.', - str_replace('..', '.', - preg_replace('/([^0-9\.]+)/', '.$1.', - str_replace(array('-', '_', '+'), '.', - trim($version1))))); - - $v2 = explode('.', - str_replace('..', '.', - preg_replace('/([^0-9\.]+)/', '.$1.', - str_replace(array('-', '_', '+'), '.', - trim($version2))))); - - // Replace empty entries at the start of the array - while (empty($v1[0]) && array_shift($v1)) {} - while (empty($v2[0]) && array_shift($v2)) {} - - // Describe our release states - $versions = array( - 'dev' => 0, - 'alpha' => 1, - 'a' => 1, - 'beta' => 2, - 'b' => 2, - 'RC' => 3, - 'pl' => 4); - - // Loop through each segment in the version string - $compare = 0; - for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++) - { - if ($v1[$i] == $v2[$i]) { - continue; - } - if (is_numeric($v1[$i]) && is_numeric($v2[$i])) { - $compare = ($v1[$i] < $v2[$i]) ? -1 : 1; - } - elseif (is_numeric($v1[$i])) { - $compare = 1; - } - elseif (is_numeric($v2[$i])) { - $compare = -1; - } - elseif (isset($versions[$v1[$i]]) && isset($versions[$v2[$i]])) { - $compare = ($versions[$v1[$i]] < $versions[$v2[$i]]) ? -1 : 1; - } - else { - $compare = strcmp($v2[$i], $v1[$i]); - } - - break; - } - - // If previous loop didn't find anything, compare the "extra" segments - if ($compare == 0) { - if (count($v2) > count($v1)) - { - if (isset($versions[$v2[$i]])) { - $compare = ($versions[$v2[$i]] < 4) ? 1 : -1; - } else { - $compare = -1; - } - } - elseif (count($v2) < count($v1)) - { - if (isset($versions[$v1[$i]])) { - $compare = ($versions[$v1[$i]] < 4) ? -1 : 1; - } else { - $compare = 1; - } - } - } - - // Compare the versions - if (func_num_args() > 2) - { - switch ($operator) - { - case '>': - case 'gt': - return (bool) ($compare > 0); - break; - case '>=': - case 'ge': - return (bool) ($compare >= 0); - break; - case '<=': - case 'le': - return (bool) ($compare <= 0); - break; - case '==': - case '=': - case 'eq': - return (bool) ($compare == 0); - break; - case '<>': - case '!=': - case 'ne': - return (bool) ($compare != 0); - break; - case '': - case '<': - case 'lt': - return (bool) ($compare < 0); - break; - default: - return null; - } - } - - return $compare; - } -} - -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/vprintf.php b/PHP_Compat/Compat/Function/vprintf.php deleted file mode 100644 index 2a4e62e..0000000 --- a/PHP_Compat/Compat/Function/vprintf.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace vprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.vprintf - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.1.0 - * @require PHP 4.0.4 (call_user_func_array) - */ -if (!function_exists('vprintf')) -{ - function vprintf ($format, $args) - { - if (count($args) < 2) { - trigger_error('vprintf() Too few arguments', E_USER_WARNING); - return null; - } - - array_unshift($args, $format); - return call_user_func_array('printf', $args); - } -} -?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/vsprintf.php b/PHP_Compat/Compat/Function/vsprintf.php deleted file mode 100644 index ce6d35d..0000000 --- a/PHP_Compat/Compat/Function/vsprintf.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - - -/** - * Replace vsprintf() - * - * @category PHP - * @package PHP_Compat - * @link http://php.net/function.vsprintf - * @author Aidan Lister <aidan@php.net> - * @version $Revision$ - * @since PHP 4.1.0 - * @require PHP 4.0.4 (call_user_func_array) - */ -if (!function_exists('vsprintf')) -{ - function vsprintf ($format, $args) - { - if (count($args) < 2) { - trigger_error('vsprintf() Too few arguments', E_USER_WARNING); - return null; - } - - array_unshift($args, $format); - return call_user_func_array('sprintf', $args); - } -} -?>
\ No newline at end of file |
