package.xml100644 1750 1750 114012 100644 6314 PHP_Compat pear.php.net Provides components to achieve PHP version independence PHP_Compat provides drop-in functions and constants for compatibility with newer versions of PHP, environment emulation, and an API to allow for version independent authoring. Aidan Lister aidan aidan@php.net yes Arpad Ray arpad arpad@php.net yes 2010-10-06 1.6.0a3 1.6.0 alpha stable PHP License QA Release Bug #7402 Missing unit tests hm2k Bug #15409 Broken unit tests arpad Bug #15531 getmxrr() support for windows hm2k Bug #15532 ini_set('register_globals', 'off'); not required hm2k Bug #15537 IIS REQUEST_URI compatibility hm2k Bug #15539 PHP_EOL link is incorrect. hm2k Bug #15540 htmlspecialchars has incorrect "since" arpad Bug #15684 Add str_getcsv support for 5.1.0 + arpad Bug #15688 PATHINFO_FILENAME hm2k Bug #15698 Typo in str_ireplace.php hm2k Bug #15707 file_get_contents has incomplete support arpad Bug #16157 Missing argument 5 for setrawcookie() hm2k Bug #16158 Win Seven Fatal error: Cannot call __clone() method on objects arpad Bug #16191 fprintf parameters lost arpad Bug #16462 add json_decode-function that behaves like in PHP5.2 hm2k Bug #16921 PHP_Compat includes functions that no version of PHP does hm2k Bug #16922 bad minimum reqirements - getopt hm2k Bug #16945 Spelling error in long desc saltybeagle 4.0.0 1.4.0b1 1.5.0RC1 2005-12-06 PHP License beta Added more components: * is_scalar * property_exists * inet_pton * inet_ntop * bcinvert * bcpowmod * mime_content_type * time_sleep_until * array_product * idate Bug fixes: * Fixed #4783 (PATH_SEPARATOR) * Fixed #4788 (version_compare) * Fixed #4851 (var_export) * Fixed #5049 (strripos) * Fixed #5078 (str_shuffle) * Fixed #5691 (fputcsv) * Fixed #5469 (md5_file) * Fixed #6082 (file_put_contents) 0.2 2004-05-27 PHP License beta Still in beta until any last bugs are found and removed. Added more components: * str_split * STDIN * STDOUT * STDERR Bug fixes: * file_get_contents * file_put_contents * array_combine Other changes: * Added replica PHP error messages. 1.5.0 1.5.0 stable stable 2005-12-15 PHP License Added more components: * is_scalar * property_exists * inet_pton * inet_ntop * bcinvert * bcpowmod * mime_content_type * time_sleep_until * array_product * idate Bug fixes: * Fixed #4783 (PATH_SEPARATOR) * Fixed #4788 (version_compare) * Fixed #4851 (var_export) * Fixed #5049 (strripos) * Fixed #5078 (str_shuffle) * Fixed #5691 (fputcsv) * Fixed #5469 (md5_file) * Fixed #6082 (file_put_contents) RC bug fixes: * Fixed #6184 (idate) 1.6.0a1 1.5.0 alpha stable 2007-05-08 PHP License Added more components: * array_fill * Hyperbolic and inverse hyperbolic math functions * glob * is_callable Added more components with changed parameters: * array_splice * microtime * mkdir * range * setcookie * setrawcookie Added new Environment module * register_globals * magic_quotes_gpc * magic_quotes_sybase * register_argc_argv * register_long_arrays Changed the way PHP_Compat stores functions. * Function declaration is prefixed with php_compat_ * Dummy declaration calls php_compat_ function This allows for redefinition of functions with changed parameters. Added support for packages which modify the function tables at runtime * PHP_Compat::loadFunction now tries to rename the old function on load This further supports redefinition of functions with changed parameters. * Fix Bug #1956: stripos - not returning false [aidan] * Fix Bug #3190: [PATCH] md5_file() depends on possibly nonexistent file_get_contents() [aidan] * Fix Bug #3572: Use of addslashes() adds too much backslashes [aidan] * Fix Bug #3586: bug in str_word_count.php code [aidan] * Fix Bug #4605: debug_print_backtrace - Object to string conversion [aidan] * Fix Bug #4851: var_export severely broken! (new implementation attached) [aidan] * Fix Bug #6293: array_intersect_key produces incorrect results with more than 2 arguments [arpad] * Fix Bug #6560: missing 'Function/property_exists.php' when installed with pear [aidan] * Fix Bug #6687: array_intersect_key() fails due to func_get_args() [arpad] * Fix Bug #6758: notice errors with debug_print_backtrace and call_user_func_array usage [arpad] * Fix Bug #6922: Space after php close markup in Function/mime_content_type.php [arpad] * Fix Bug #7520: cyclic reference cloning causes timeout [aidan] * Fix Bug #8338: convert_uudecode removes spaces from line ends, causing corruption [aidan] * Fix Bug #8864: magic quotes gpc emulation missing server vars [arpad] * Fix Bug #9042: Various uninitialized variables [aidan] * Fix Bug #9043: Various issues in str_shuffle [aidan] * Fix Bug #9687: array_*_key function(s) slow [aidan] * Fix Bug #9983: Function [array_udiff_uassoc()] is incorrectly implemented [arpad] * Implement Feature #4372: addition of glob() function for php < 4.3.0 [arpad] * Implement Feature #7139: PHP 5.1.1 Datetime Constants [arpad] * Implement Feature #7403: str_ireplace too slow [arpad] * Implement Feature #7414: making var_export() generating correct PHP code with nested objects [arpad] * Implement Feature #8208: is_callable missing in php 4.0.4, 4.0.5 [arpad] * Implement Feature #9187: Adding httponly to setcookie/setrawcookie (new in php 5.2) [aidan] * Implement Feature #9659: The userdata parameter isn't correctly send to the recursive call [arpad] * Implement Feature #10177: add most recent UPLOAD ERR constants [arpad] 1.6.0a3 1.6.0 alpha stable 2010-10-06 PHP License QA Release Bug #7402 Missing unit tests hm2k Bug #15409 Broken unit tests arpad Bug #15531 getmxrr() support for windows hm2k Bug #15532 ini_set('register_globals', 'off'); not required hm2k Bug #15537 IIS REQUEST_URI compatibility hm2k Bug #15539 PHP_EOL link is incorrect. hm2k Bug #15540 htmlspecialchars has incorrect "since" arpad Bug #15684 Add str_getcsv support for 5.1.0 + arpad Bug #15688 PATHINFO_FILENAME hm2k Bug #15698 Typo in str_ireplace.php hm2k Bug #15707 file_get_contents has incomplete support arpad Bug #16157 Missing argument 5 for setrawcookie() hm2k Bug #16158 Win Seven Fatal error: Cannot call __clone() method on objects arpad Bug #16191 fprintf parameters lost arpad Bug #16462 add json_decode-function that behaves like in PHP5.2 hm2k Bug #16921 PHP_Compat includes functions that no version of PHP does hm2k Bug #16922 bad minimum reqirements - getopt hm2k Bug #16945 Spelling error in long desc saltybeagle PHP_Compat-1.6.0a3/Compat/Components.php100777 1750 1750 15556 100777 13111 , Arpad Ray */ // $Id: Components.php 301611 2010-07-27 14:09:50Z hm2k $ // Functions $components['function']['acosh'] = '5.0.0'; $components['function']['array_change_key_case'] = '4.2.0'; $components['function']['array_chunk'] = '4.2.0'; $components['function']['array_combine'] = '5.0.0'; $components['function']['array_diff_assoc'] = '4.3.0'; $components['function']['array_diff_key'] = '5.0.2'; $components['function']['array_diff_uassoc'] = '5.0.0'; $components['function']['array_diff_ukey'] = '5.0.2'; $components['function']['array_fill'] = '4.2.0'; $components['function']['array_intersect_assoc'] = '5.0.0'; $components['function']['array_intersect_key'] = '5.0.2'; $components['function']['array_intersect_uassoc'] = '5.0.0'; $components['function']['array_intersect_ukey'] = '5.0.2'; $components['function']['array_key_exists'] = '4.1.0'; $components['function']['array_product'] = '5.1.0'; $components['function']['array_search'] = '4.0.5'; $components['function']['array_slice'] = '4.0.0'; $components['function']['array_udiff'] = '5.0.0'; $components['function']['array_udiff_assoc'] = '5.0.0'; $components['function']['array_udiff_uassoc'] = '5.0.0'; $components['function']['array_uintersect'] = '5.0.0'; $components['function']['array_uintersect_assoc'] = '5.0.0'; $components['function']['array_uintersect_uassoc'] = '5.0.0'; $components['function']['array_walk_recursive'] = '5.0.0'; $components['function']['asinh'] = '5.0.0'; $components['function']['atanh'] = '5.0.0'; $components['function']['bcpowmod'] = '5.0.0'; $components['function']['call_user_func_array'] = '4.0.4'; $components['function']['clone'] = '5.0.0'; $components['function']['constant'] = '4.0.4'; $components['function']['convert_uudecode'] = '5.0.0'; $components['function']['convert_uuencode'] = '5.0.0'; $components['function']['cosh'] = '5.0.0'; $components['function']['debug_print_backtrace'] = '5.0.0'; $components['function']['file_get_contents'] = '4.3.0'; $components['function']['file_put_contents'] = '5.0.0'; $components['function']['floatval'] = '4.2.0'; $components['function']['fprintf'] = '5.0.0'; $components['function']['fputcsv'] = '5.0.0'; $components['function']['get_headers'] = '5.0.0'; $components['function']['get_include_path'] = '4.3.0'; $components['function']['getopt'] = '4.3.0'; $components['function']['glob'] = '4.3.0'; $components['function']['html_entity_decode'] = '4.3.0'; $components['function']['htmlspecialchars'] = '5.2.3'; $components['function']['htmlspecialchars_decode'] = '5.1.0'; $components['function']['http_build_query'] = '5.0.0'; $components['function']['ibase_timefmt'] = '5.0.0'; $components['function']['idate'] = '5.1.0'; $components['function']['image_type_to_mime_type'] = '4.3.0'; $components['function']['inet_ntop'] = '5.1.0'; $components['function']['inet_pton'] = '5.1.0'; $components['function']['ini_get_all'] = '4.2.0'; $components['function']['is_a'] = '4.2.0'; $components['function']['is_callable'] = '4.0.6'; $components['function']['is_scalar'] = '4.0.5'; $components['function']['md5_file'] = '4.2.0'; $components['function']['mkdir'] = '5.0.0'; $components['function']['mhash'] = '4.0.0'; $components['function']['microtime'] = '4.3.0'; $components['function']['mime_content_type'] = '4.3.0'; $components['function']['ob_clean'] = '4.2.0'; $components['function']['ob_flush'] = '4.2.0'; $components['function']['ob_get_clean'] = '4.3.0'; $components['function']['ob_get_flush'] = '4.3.0'; $components['function']['php_strip_whitespace'] = '5.0.0'; $components['function']['php_ini_loaded_file'] = '5.2.4'; $components['function']['property_exists'] = '5.1.0'; $components['function']['pg_affected_rows'] = '4.2.0'; $components['function']['pg_escape_bytea'] = '4.2.0'; $components['function']['pg_unescape_bytea'] = '4.2.0'; $components['function']['range'] = '4.0.0'; $components['function']['restore_include_path'] = '4.3.0'; $components['function']['scandir'] = '5.0.0'; $components['function']['setcookie'] = '5.2.0'; $components['function']['set_include_path'] = '4.3.0'; $components['function']['setrawcookie'] = '5.2.0'; $components['function']['sinh'] = '5.0.0'; $components['function']['stripos'] = '5.0.0'; $components['function']['str_ireplace'] = '5.0.0'; $components['function']['strpbrk'] = '5.0.0'; $components['function']['strripos'] = '5.0.0'; $components['function']['str_rot13'] = '4.2.0'; $components['function']['str_shuffle'] = '4.3.0'; $components['function']['str_split'] = '5.0.0'; $components['function']['str_word_count'] = '4.3.0'; $components['function']['substr_compare'] = '5.0.0'; $components['function']['sys_get_temp_dir'] = '5.2.1'; $components['function']['tanh'] = '5.0.0'; $components['function']['time_sleep_until'] = '5.1.0'; $components['function']['var_export'] = '4.2.0'; $components['function']['version_compare'] = '4.1.0'; $components['function']['vprintf'] = '4.1.0'; $components['function']['vsprintf'] = '4.1.0'; // Constants $components['constant']['DATE'] = '5.1.1'; $components['constant']['DIRECTORY_SEPARATOR'] = '4.0.6'; $components['constant']['E_STRICT'] = '5.0.0'; $components['constant']['FILE'] = '4.3.0'; $components['constant']['PATH_SEPARATOR'] = '4.3.0'; $components['constant']['PHP_EOL'] = '5.0.1'; $components['constant']['STD'] = '4.3.0'; $components['constant']['T'] = '5.0.0'; $components['constant']['UPLOAD_ERR'] = '4.3.0'; PHP_Compat-1.6.0a3/Compat/Constant/DATE.php100777 1750 1750 2261 100777 13237 , Arpad Ray * @link http://php.net/manual/en/ref.datetime.php * @author Rhett Waldock * @version $Revision: 274507 $ * @since PHP 5.1.1 */ if (!defined('DATE_ATOM')) { define('DATE_ATOM', 'Y-m-d\TH:i:sP'); } if (!defined('DATE_COOKIE')) { define('DATE_COOKIE', 'D, d M Y H:i:s T'); } if (!defined('DATE_ISO8601')) { define('DATE_ISO8601', 'Y-m-d\TH:i:sO'); } if (!defined('DATE_RFC822')) { define('DATE_RFC822', 'D, d M Y H:i:s T'); } if (!defined('DATE_RFC850')) { define('DATE_RFC850', 'l, d-M-y H:i:s T'); } if (!defined('DATE_RFC1036')) { define('DATE_RFC1036', 'l, d-M-y H:i:s T'); } if (!defined('DATE_RFC1123')) { define('DATE_RFC1123', 'D, d M Y H:i:s T'); } if (!defined('DATE_RFC2822')) { define('DATE_RFC2822', 'D, d M Y H:i:s O'); } if (!defined('DATE_RSS')) { define('DATE_RSS', 'D, d M Y H:i:s T'); } if (!defined('DATE_W3C')) { define('DATE_W3C', 'Y-m-d\TH:i:sO'); }PHP_Compat-1.6.0a3/Compat/Constant/DIRECTORY_SEPARATOR.php100777 1750 1750 1051 100777 15502 , Arpad Ray * @link http://php.net/reserved.constants.standard * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.0.6 */ if (!defined('DIRECTORY_SEPARATOR')) { define('DIRECTORY_SEPARATOR', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/'); } PHP_Compat-1.6.0a3/Compat/Constant/E_STRICT.php100777 1750 1750 674 100777 13764 , Arpad Ray * @link http://php.net/ref.errorfunc * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 */ if (!defined('E_STRICT')) { define('E_STRICT', 2048); } PHP_Compat-1.6.0a3/Compat/Constant/FILE.php100777 1750 1750 1430 100777 13236 , Arpad Ray * @link http://php.net/ref.filesystem * @author Aidan Lister * @version $Revision: 269597 $ * @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); } PHP_Compat-1.6.0a3/Compat/Constant/PATH_SEPARATOR.php100777 1750 1750 1005 100777 14671 , Arpad Ray * @link http://php.net/ref.dir * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 */ if (!defined('PATH_SEPARATOR')) { define('PATH_SEPARATOR', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? ';' : ':'); } PHP_Compat-1.6.0a3/Compat/Constant/PHP_EOL.php100777 1750 1750 1337 100777 13653 , Arpad Ray * @link http://php.net/reserved.constants * @author Aidan Lister * @version $Revision: 273961 $ * @since PHP 5.0.2 */ if (!defined('PHP_EOL')) { switch (strtoupper(substr(PHP_OS, 0, 3))) { // Windows case 'WIN': define('PHP_EOL', "\r\n"); break; // Mac case 'DAR': define('PHP_EOL', "\r"); break; // Unix default: define('PHP_EOL', "\n"); } } PHP_Compat-1.6.0a3/Compat/Constant/STD.php100777 1750 1750 1170 100777 13152 , Arpad Ray * @link http://php.net/features.commandline * @author Aidan Lister * @version $Revision: 269597 $ * @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')); } PHP_Compat-1.6.0a3/Compat/Constant/T.php100777 1750 1750 2246 100777 12730 , Arpad Ray * @link http://php.net/ref.tokenizer * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 */ if (!defined('T_ML_COMMENT')) { define('T_ML_COMMENT', T_COMMENT); } if (!defined('T_DOC_COMMENT')) { define('T_DOC_COMMENT', T_ML_COMMENT); } if (!defined('T_OLD_FUNCTION')) { define('T_OLD_FUNCTION', -1); } if (!defined('T_ABSTRACT')) { define('T_ABSTRACT', -1); } if (!defined('T_CATCH')) { define('T_CATCH', -1); } if (!defined('T_FINAL')) { define('T_FINAL', -1); } if (!defined('T_INSTANCEOF')) { define('T_INSTANCEOF', -1); } if (!defined('T_PRIVATE')) { define('T_PRIVATE', -1); } if (!defined('T_PROTECTED')) { define('T_PROTECTED', -1); } if (!defined('T_PUBLIC')) { define('T_PUBLIC', -1); } if (!defined('T_THROW')) { define('T_THROW', -1); } if (!defined('T_TRY')) { define('T_TRY', -1); } if (!defined('T_CLONE')) { define('T_CLONE', -1); } PHP_Compat-1.6.0a3/Compat/Constant/UPLOAD_ERR.php100777 1750 1750 2022 100777 14211 , Arpad Ray * @link http://php.net/features.file-upload.errors * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 */ if (!defined('UPLOAD_ERR_OK')) { define('UPLOAD_ERR_OK', 0); } if (!defined('UPLOAD_ERR_INI_SIZE')) { define('UPLOAD_ERR_INI_SIZE', 1); } if (!defined('UPLOAD_ERR_FORM_SIZE')) { define('UPLOAD_ERR_FORM_SIZE', 2); } if (!defined('UPLOAD_ERR_PARTIAL')) { define('UPLOAD_ERR_PARTIAL', 3); } if (!defined('UPLOAD_ERR_NO_FILE')) { define('UPLOAD_ERR_NO_FILE', 4); } if (!defined('UPLOAD_ERR_NO_TMP_DIR')) { define('UPLOAD_ERR_NO_TMP_DIR', 6); } if (!defined('UPLOAD_ERR_CANT_WRITE')) { define('UPLOAD_ERR_CANT_WRITE', 7); } if (!defined('UPLOAD_ERR_EXTENSION')) { define('UPLOAD_ERR_EXTENSION', 8); } PHP_Compat-1.6.0a3/Compat/Constant/__DIR__.php100777 1750 1750 756 100777 13723 , Arpad Ray * @link http://php.net/language.constants.predefined * @author James Wade * @version $Revision: 1.0 $ * @since PHP 5 */ if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); } PHP_Compat-1.6.0a3/Compat/Environment/magic_quotes_gpc_off.php100777 1750 1750 3677 100777 17414 , Arpad Ray * @link http://php.net/magic_quotes * @author Arpad Ray * @author Aidan Lister * @version $Revision: 274851 $ */ // wrap everything in a function to keep global scope clean function php_compat_magic_quotes_gpc_off() { $stripping = true; // Require Inputs - Assumes file is in the same directory require_once '_magic_quotes_inputs.php'; if ($magicOn && !$sybaseOn || !$phpLt50 && $phpLt51) { $inputCount = count($inputs); while (list($k, $v) = each($inputs)) { $order1 = $k < $inputCount; foreach ($v as $var => $value) { $isArray = is_array($value); $stripKeys = $magicOn ? ($isArray ? $allWorks || !$order1 : ($order1 ? !$phpLt50 : !$phpLt434)) : !$phpLt50 && $phpLt51 && !$isArray; if ($stripKeys || $compatMagicOn) { $tvar = stripslashes($var); if ($var != $tvar) { $tvalue = $inputs[$k][$var]; $inputs[$k][$tvar] = $tvalue; unset($inputs[$k][$var]); $var = $tvar; } } if (is_array($value)) { $inputs[] = &$inputs[$k][$var]; } else { $inputs[$k][$var] = $magicOn ? stripslashes($value) : $value; } } } } } php_compat_magic_quotes_gpc_off(); // Register the change //ini_set('magic_quotes_gpc', 0); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['magic_quotes_gpc'] = false; PHP_Compat-1.6.0a3/Compat/Environment/magic_quotes_gpc_on.php100777 1750 1750 3537 100777 17251 , Arpad Ray * @link http://php.net/magic_quotes * @author Arpad Ray * @version $Revision: 274851 $ */ // wrap everything in a function to keep global scope clean function php_compat_magic_quotes_gpc_on() { $stripping = false; // Require Inputs - Assumes file is in the same directory require_once '_magic_quotes_inputs.php'; if (!$magicOn || !$allWorks && !$sybaseOn) { $inputCount = count($inputs); while (list($k, $v) = each($inputs)) { foreach ($v as $var => $value) { $isArray = is_array($value); $order1 = $k < $inputCount; $escapeKeys = $magicOn ? ($isArray ? $order1 : $phpLt434 || $order1 && $phpLt50) : $phpLt50 || !$phpLt51 || $isArray; if ($escapeKeys) { $tvar = addslashes($var); if ($var != $tvar) { $tvalue = $inputs[$k][$var]; $inputs[$k][$tvar] = $tvalue; unset($inputs[$k][$var]); $var = $tvar; } } if ($isArray) { $inputs[] = &$inputs[$k][$var]; } else { $inputs[$k][$var] = $magicOn ? $value : addslashes($value); } } } } } php_compat_magic_quotes_gpc_on(); // Register the change //ini_set('magic_quotes_gpc', 1); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['magic_quotes_gpc'] = true; PHP_Compat-1.6.0a3/Compat/Environment/magic_quotes_sybase_off.php100777 1750 1750 3754 100777 20125 , Arpad Ray * @link http://php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase * @author Arpad Ray * @version $Revision: 274851 $ */ // wrap everything in a function to keep global scope clean function php_compat_magic_quotes_sybase_off() { $stripping = true; // Require Inputs - Assumes file is in the same directory require_once '_magic_quotes_inputs.php'; if (!$allWorks || $magicOn) { $inputCount = count($inputs); while (list($k, $v) = each($inputs)) { foreach ($v as $var => $value) { $isArray = is_array($value); $order1 = $k < $inputCount; $stripKeys = $magicOn ? ($isArray ? $allWorks || !$order1 : $order1 && !$phpLt50 || !$phpLt434) : !$phpLt50 && $phpLt51 && !$isArray; if ($stripKeys) { $tvar = str_replace('\'\'', '\'', $var); if ($var != $tvar) { $tvalue = $inputs[$k][$var]; $inputs[$k][$tvar] = $tvalue; unset($inputs[$k][$var]); $var = $tvar; } } if ($isArray) { $inputs[] = &$inputs[$k][$var]; } else { $inputs[$k][$var] = $sybaseOn ? str_replace('\'\'', '\'', $value) : $value; } } } } } php_compat_magic_quotes_sybase_off(); // Register the change //ini_set('magic_quotes_sybase', 0); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['magic_quotes_sybase'] = false; PHP_Compat-1.6.0a3/Compat/Environment/magic_quotes_sybase_on.php100777 1750 1750 3760 100777 17764 , Arpad Ray * @link http://php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase * @author Arpad Ray * @version $Revision: 274851 $ */ // wrap everything in a function to keep global scope clean function php_compat_magic_quotes_sybase_on() { $stripping = false; // Require Inputs - Assumes file is in the same directory require_once '_magic_quotes_inputs.php'; if (!$sybaseOn || !$allWorks && $magicOn) { if ($magicOn) { // Require Inputs - Assumes file is in the same directory require_once 'magic_quotes_gpc_off.php'; } $inputCount = count($inputs); while (list($k, $v) = each($inputs)) { foreach ($v as $var => $value) { $isArray = is_array($value); $order1 = $k < $inputCount; $escapeKeys = $phpLt50 || !$phpLt51 || $isArray; if ($escapeKeys || $compatMagicOn) { $tvar = str_replace('\'', '\'\'', $var); if ($var != $tvar) { $tvalue = $inputs[$k][$var]; $inputs[$k][$tvar] = $tvalue; unset($inputs[$k][$var]); $var = $tvar; } } if ($isArray) { $inputs[] = &$inputs[$k][$var]; } else { $inputs[$k][$var] = $sybaseOn ? $value : str_replace('\'', '\'\'', $value); } } } } } php_compat_magic_quotes_sybase_on(); // Register the change //ini_set('magic_quotes_sybase', 1); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['magic_quotes_sybase'] = true; PHP_Compat-1.6.0a3/Compat/Environment/register_argc_argv_off.php100777 1750 1750 1330 100777 17722 , Arpad Ray * @link http://php.net/manual/en/ini.core.php#ini.register-argc-argv * @author Aidan Lister * @version $Revision: 274851 $ */ if (isset($_GLOBALS['argc']) || isset($_SERVER['argc'])) { unset($GLOBALS['argc'], $GLOBALS['argv'], $_SERVER['argc'], $_SERVER['argv']); // Register the change //ini_set('register_argc_argv', 'off'); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['register_argc_argv'] = false; } PHP_Compat-1.6.0a3/Compat/Environment/register_globals_off.php100777 1750 1750 1760 100777 17421 , Arpad Ray * @link http://php.net/register_globals * @author Aidan Lister * @version $Revision: 274851 $ */ if (ini_get('register_globals')) { $ignore = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES'); $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); foreach ($input as $k => $v) { if (!in_array($k, $ignore) && isset($GLOBALS[$k])) { unset($GLOBALS[$k]); } } // Register the change //ini_set('register_globals', 'off'); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['register_globals'] = false; } PHP_Compat-1.6.0a3/Compat/Environment/register_globals_on.php100777 1750 1750 5626 100777 17270 , Arpad Ray * @link http://php.net/register_globals * @author Aidan Lister * @author Arpad Ray * @version $Revision: 274851 $ */ // wrap everything in a function to keep global scope clean function php_compat_register_globals_on() { //register_globals is already on? Do nothing if (ini_get('register_globals')) { return; } $superglobals = array(); $phpLt410 = PHP_VERSION < 4.1; // determine on which arrays to operate and in what order if ($phpLt410 || ini_get('register_long_arrays')) { global $HTTP_SERVER_VARS, $HTTP_ENV_VARS, $HTTP_COOKIE_VARS, $HTTP_SESSION_VARS, $HTTP_POST_VARS, $HTTP_POST_FILES, $HTTP_GET_VARS; $superglobals['S'][] = 'HTTP_SERVER_VARS'; $superglobals['E'][] = 'HTTP_ENV_VARS'; $superglobals['C'][] = 'HTTP_COOKIE_VARS'; $superglobals['C'][] = 'HTTP_SESSION_VARS'; $superglobals['G'][] = 'HTTP_GET_VARS'; $superglobals['P'][] = 'HTTP_POST_VARS'; $superglobals['P'][] = 'HTTP_POST_FILES'; } if (!$phpLt410) { $superglobals['S'][] = '_SERVER'; $superglobals['E'][] = '_ENV'; $superglobals['C'][] = '_COOKIE'; $superglobals['C'][] = '_SESSION'; $superglobals['G'][] = '_GET'; $superglobals['P'][] = '_POST'; $superglobals['P'][] = '_FILES'; } $order = ini_get('variables_order'); $order_length = strlen($order); $inputs = array(); for ($i = 0; $i < $order_length; $i++) { $key = strtoupper($order[$i]); if (!isset($superglobals[$key])) { continue; } foreach ($superglobals[$key] as $var) { if (isset($GLOBALS[$var])) { $inputs[] = $GLOBALS[$var]; } } } // build lookup array of predefined vars $allGlobals = array( 'GLOBALS' => 1, 'HTTP_RAW_POST_DATA' => 1, 'php_errormsg' => 1, 'http_response_header' => 1 ); foreach ($superglobals as $index => $vars) { foreach ($vars as $var) { $allGlobals[$var] = 1; } } // extract the specified arrays, reverse order since we're not overwriting for ($i = count($inputs); $i--;) { foreach ($inputs[$i] as $var => $value) { // ensure users can't set predefined vars or existing globals if (!isset($allGlobals[$var]) && !isset($GLOBALS[$var])) { $GLOBALS[$var] = $value; } } } } php_compat_register_globals_on(); // Register the change //ini_set('register_globals', 'on'); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['register_globals'] = true; PHP_Compat-1.6.0a3/Compat/Environment/register_long_arrays_off.php100777 1750 1750 1422 100777 20311 , Arpad Ray * @link http://php.net/manual/en/ini.core.php#ini.register-long-arrays * @author Aidan Lister * @version $Revision: 274851 $ */ unset( $GLOBALS['HTTP_GET_VARS'], $GLOBALS['HTTP_POST_VARS'], $GLOBALS['HTTP_COOKIE_VARS'], $GLOBALS['HTTP_SERVER_VARS'], $GLOBALS['HTTP_ENV_VARS'], $GLOBALS['HTTP_FILES_VARS'] ); // Register the change //ini_set('register_long_arrays', 'off'); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['register_long_arrays'] = false; PHP_Compat-1.6.0a3/Compat/Environment/register_long_arrays_on.php100777 1750 1750 1466 100777 20163 , Arpad Ray * @link http://php.net/manual/en/ini.core.php#ini.register-long-arrays * @author Aidan Lister * @version $Revision: 274851 $ */ $GLOBALS['HTTP_GET_VARS'] = &$_GET; $GLOBALS['HTTP_POST_VARS'] = &$_POST; $GLOBALS['HTTP_COOKIE_VARS'] = &$_COOKIE; $GLOBALS['HTTP_SERVER_VARS'] = &$_SERVER; $GLOBALS['HTTP_ENV_VARS'] = &$_ENV; $GLOBALS['HTTP_FILES_VARS'] = &$_FILES; // Register the change //ini_set('register_long_arrays', 'on'); // Cannot be set at runtime (bug 15532) $GLOBALS['__PHP_Compat_ini']['register_long_arrays'] = true; PHP_Compat-1.6.0a3/Compat/Environment/request_uri.php100777 1750 1750 2524 100777 15606 , Arpad Ray , James Wade * @link http://php.net/reserved.variables.server * @author James Wade * @version $Revision: 1.0 $ */ // wrap everything in a function to keep global scope clean function php_compat_request_uri(&$server) { if (!isset($server['REQUEST_URI']) && isset($server)) { //ISAPI_Rewrite 3.x if (isset($server['HTTP_X_REWRITE_URL'])) { $server['REQUEST_URI'] = $server['HTTP_X_REWRITE_URL']; } //ISAPI_Rewrite 2.x w/ HTTPD.INI configuration elseif (isset($server['HTTP_REQUEST_URI'])){ $server['REQUEST_URI'] = $server['HTTP_REQUEST_URI']; } //ISAPI_Rewrite isn't installed or not configured else { $server['HTTP_REQUEST_URI'] = isset($server['SCRIPT_NAME'])?$server['SCRIPT_NAME']:$server['PHP_SELF']; if (isset($server['QUERY_STRING'])) { $server['HTTP_REQUEST_URI'] .= '?'.$server['QUERY_STRING']; } $server['REQUEST_URI'] = $server['HTTP_REQUEST_URI']; } } } php_compat_request_uri($HTTP_SERVER_VARS); php_compat_request_uri($_SERVER); PHP_Compat-1.6.0a3/Compat/Environment/_magic_quotes_inputs.php100777 1750 1750 5050 100777 17455 = PHP < 5.1.0 keys are escaped even when magic quotes is off * - PHP < 5.0.0 keys of order 1 scalar values are not escaped * - PHP < 4.3.4 keys of all scalar values are not escaped * * @category PHP * @package PHP_Compat * @license LGPL - http://www.gnu.org/licenses/lgpl.html * @copyright 2004-2007 Aidan Lister , Arpad Ray * @link http://php.net/magic_quotes * @author Arpad Ray * @version $Revision: 274851 $ */ // version tests $phpLt522 = version_compare(PHP_VERSION, '5.2.2', '<'); $phpLt51 = version_compare(PHP_VERSION, '5.1.0', '<'); $phpLt50 = version_compare(PHP_VERSION, '5.0.0', '<'); $phpLt434 = version_compare(PHP_VERSION, '4.3.4', '<'); $phpLt41 = version_compare(PHP_VERSION, '4.1.0', '<'); // so far, so good $allWorks = !$phpLt522; // build the array of variables to process if ($phpLt41) { $inputs = array(); } else { // superglobals were added in PHP 4.1.0 $inputs = array(&$_POST, &$_GET, &$_COOKIE, &$_REQUEST); } if ($phpLt50 || ini_get('register_long_arrays')) { // the old style globals are toggled by register_long_arrays since PHP 5.0.0 // note the need for $GLOBALS here, since this file is included inside functions $inputs[] = &$GLOBALS['HTTP_GET_VARS']; $inputs[] = &$GLOBALS['HTTP_POST_VARS']; $inputs[] = &$GLOBALS['HTTP_COOKIE_VARS']; $inputs[] = &$GLOBALS['HTTP_SERVER_VARS']; $inputs[] = &$GLOBALS['HTTP_ENV_VARS']; if ($phpLt50 // these superglobals haven't been escaped since PHP 5.0.0 && !$phpLt41 // and didn't exist before PHP 4.1.0 && $stripping) // so we only want them if we're stripping the inputs { $inputs[] = &$_SERVER; $inputs[] = &$_ENV; } } $compatMagicOn = !empty($GLOBALS['__PHP_Compat_ini']['magic_quotes_gpc']); $compatMagicOff = isset($GLOBALS['__PHP_Compat_ini']['magic_quotes_gpc']) && !$GLOBALS['__PHP_Compat_ini']['magic_quotes_gpc']; $magicOn = get_magic_quotes_gpc() || $compatMagicOn; $allWorks = $allWorks || $compatMagicOn; $compatSybaseOn = !empty($GLOBALS['__PHP_Compat_ini']['magic_quotes_sybase']); $sybaseOn = ini_get('magic_quotes_sybase') || $compatSybaseOn; PHP_Compat-1.6.0a3/Compat/Function/acosh.php100777 1750 1750 1107 100777 13611 , Arpad Ray * @link http://php.net/function.acosh * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 3.0.0 */ function php_compat_acosh($n) { return log($n + sqrt($n + 1) * sqrt($n - 1)); } if (!function_exists('acosh')) { function acosh($n) { return php_compat_acosh($n); } } PHP_Compat-1.6.0a3/Compat/Function/array_change_key_case.php100777 1750 1750 2427 100777 17010 , Arpad Ray * @link http://php.net/function.array_change_key_case * @author Stephan Schmidt * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_array_change_key_case($input, $case = CASE_LOWER) { if (!is_array($input)) { user_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; } // Define if (!function_exists('array_change_key_case')) { function array_change_key_case($input, $case = CASE_LOWER) { return php_compat_array_change_key_case($input, $case); } } PHP_Compat-1.6.0a3/Compat/Function/array_chunk.php100777 1750 1750 3123 100777 15022 , Arpad Ray * @link http://php.net/function.array_chunk * @author Aidan Lister * @author Thiemo Mättig (http://maettig.com) * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_array_chunk($input, $size, $preserve_keys = false) { if (!is_array($input)) { user_error('array_chunk() expects parameter 1 to be array, ' . gettype($input) . ' given', E_USER_WARNING); return; } if (!is_numeric($size)) { user_error('array_chunk() expects parameter 2 to be long, ' . gettype($size) . ' given', E_USER_WARNING); return; } $size = (int)$size; if ($size <= 0) { user_error('array_chunk() Size parameter expected to be greater than 0', E_USER_WARNING); return; } $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; } // Define if (!function_exists('array_chunk')) { function array_chunk($input, $size, $preserve_keys = false) { return php_compat_array_chunk($input, $size, $preserve_keys); } } PHP_Compat-1.6.0a3/Compat/Function/array_combine.php100777 1750 1750 3200 100777 15322 , Arpad Ray * @link http://php.net/function.array_combine * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_array_combine($keys, $values) { if (!is_array($keys)) { user_error('array_combine() expects parameter 1 to be array, ' . gettype($keys) . ' given', E_USER_WARNING); return; } if (!is_array($values)) { user_error('array_combine() expects parameter 2 to be array, ' . gettype($values) . ' given', E_USER_WARNING); return; } $key_count = count($keys); $value_count = count($values); if ($key_count !== $value_count) { user_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING); return false; } if ($key_count === 0 || $value_count === 0) { user_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; $i < $key_count; $i++) { $combined[$keys[$i]] = $values[$i]; } return $combined; } // Define if (!function_exists('array_combine')) { function array_combine($keys, $values) { return php_compat_array_combine($keys, $values); } } PHP_Compat-1.6.0a3/Compat/Function/array_diff_assoc.php100777 1750 1750 3433 100777 16016 , Arpad Ray * @link http://php.net/function.array_diff_assoc * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_array_diff_assoc() { // Check we have enough arguments $args = func_get_args(); $count = count($args); if (count($args) < 2) { user_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING); return; } // Check arrays for ($i = 0; $i < $count; $i++) { if (!is_array($args[$i])) { user_error('array_diff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // 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; } // Define if (!function_exists('array_diff_assoc')) { function array_diff_assoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_diff_assoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_diff_key.php100777 1750 1750 3574 100777 15504 , Arpad Ray * @link http://php.net/function.array_diff_key * @author Tom Buskens * @version $Revision: 269597 $ * @since PHP 5.0.2 * @require PHP 4.0.0 (user_error) */ function php_compat_array_diff_key() { $args = func_get_args(); if (count($args) < 2) { user_error('Wrong parameter count for array_diff_key()', E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_diff_key() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } $result = $args[0]; if (function_exists('array_key_exists')) { // Optimize for >= PHP 4.1.0 foreach ($args[0] as $key => $value) { for ($i = 1; $i !== $array_count; $i++) { if (array_key_exists($key,$args[$i])) { unset($result[$key]); break; } } } } else { foreach ($args[0] as $key1 => $value1) { for ($i = 1; $i !== $array_count; $i++) { foreach ($args[$i] as $key2 => $value2) { if ((string) $key1 === (string) $key2) { unset($result[$key2]); break 2; } } } } } return $result; } // Define if (!function_exists('array_diff_key')) { function array_diff_key() { $args = func_get_args(); return call_user_func_array('php_compat_array_diff_key', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_diff_uassoc.php100777 1750 1750 3702 100777 16202 , Arpad Ray * @link http://php.net/function.array_diff_uassoc * @version $Revision: 269597 $ * @since PHP 5.0.0 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_diff_uassoc() { // Sanity check $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_diff_uassoc()', E_USER_WARNING); return; } // 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]; } user_error('array_diff_uassoc() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_diff_uassoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $result = array(); foreach ($args[0] as $k => $v) { for ($i = 1; $i < $array_count; $i++) { foreach ($args[$i] as $kk => $vv) { if ($v == $vv) { $compare = call_user_func_array($compare_func, array($k, $kk)); if ($compare == 0) { continue 3; } } } } $result[$k] = $v; } return $result; } // Define if (!function_exists('array_diff_uassoc')) { function array_diff_uassoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_diff_uassoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_diff_ukey.php100777 1750 1750 3606 100777 15665 , Arpad Ray * @link http://php.net/function.array_diff_ukey * @author Tom Buskens * @version $Revision: 269597 $ * @since PHP 5.0.2 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_diff_ukey() { $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_diff_ukey()', E_USER_WARNING); return; } // 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]; } user_error('array_diff_ukey() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_diff_ukey() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $result = $args[0]; foreach ($args[0] as $key1 => $value1) { for ($i = 1; $i !== $array_count; $i++) { foreach ($args[$i] as $key2 => $value2) { if (!(call_user_func($compare_func, (string) $key1, (string) $key2))) { unset($result[$key1]); break 2; } } } } return $result; } // Define if (!function_exists('array_diff_ukey')) { function array_diff_ukey() { $args = func_get_args(); return call_user_func_array('php_compat_array_diff_ukey', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_fill.php100777 1750 1750 2113 100777 14636 , Arpad Ray * @link http://php.net/function.array_fill * @author Jim Wigginton * @version $Revision: 269597 $ * @since PHP 4.2.0 */ function php_compat_array_fill($start_index, $num, $value) { if ($num <= 0) { user_error('array_fill(): Number of elements must be positive', E_USER_WARNING); return false; } $temp = array(); if ($start_index < 0) { $temp[$start_index] = $value; $start_index = 0; $end_index = $num - 1; } else { $end_index = $start_index + $num; } for ($i = (int) $start_index; $i < $end_index; $i++) { $temp[$i] = $value; } return $temp; } // Define if (!function_exists('array_fill')) { function array_fill($start_index, $num, $value) { return php_compat_array_fill($start_index, $num, $value); } } PHP_Compat-1.6.0a3/Compat/Function/array_intersect_assoc.php100777 1750 1750 3050 100777 17101 , Arpad Ray * @link http://php.net/function.array_intersect_assoc * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_array_intersect_assoc() { // Sanity check $args = func_get_args(); if (count($args) < 2) { user_error('wrong parameter count for array_intersect_assoc()', E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_intersect_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $intersect = array(); foreach ($args[0] as $key => $value) { $intersect[$key] = $value; for ($i = 1; $i < $array_count; $i++) { if (!isset($args[$i][$key]) || $args[$i][$key] != $value) { unset($intersect[$key]); break; } } } return $intersect; } // Define if (!function_exists('array_intersect_assoc')) { function array_intersect_assoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_intersect_assoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_intersect_key.php100777 1750 1750 2671 100777 16571 , Arpad Ray * @link http://php.net/function.array_intersect_key * @author Tom Buskens * @version $Revision: 269597 $ * @since PHP 5.0.2 * @require PHP 4.0.0 (user_error) */ function php_compat_array_intersect_key() { $args = func_get_args(); $array_count = count($args); if ($array_count < 2) { user_error('Wrong parameter count for array_intersect_key()', E_USER_WARNING); return; } // Check arrays for ($i = $array_count; $i--;) { if (!is_array($args[$i])) { user_error('array_intersect_key() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Intersect keys $arg_keys = array_map('array_keys', $args); $result_keys = call_user_func_array('array_intersect', $arg_keys); // Build return array $result = array(); foreach($result_keys as $key) { $result[$key] = $args[0][$key]; } return $result; } // Define if (!function_exists('array_intersect_key')) { function array_intersect_key() { $args = func_get_args(); return call_user_func_array('php_compat_array_intersect_key', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_intersect_uassoc.php100777 1750 1750 4232 100777 17271 , Arpad Ray * @link http://php.net/function.array_intersect_uassoc * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_intersect_uassoc() { // Sanity check $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_intersect_ukey()', E_USER_WARNING); return; } // 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]; } user_error('array_intersect_uassoc() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_intersect_uassoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $result = array(); foreach ($args[0] as $k => $v) { for ($i = 0; $i < $array_count; $i++) { $match = false; foreach ($args[$i] as $kk => $vv) { $compare = call_user_func_array($compare_func, array($k, $kk)); if ($compare === 0 && $v == $vv) { $match = true; continue 2; } } if ($match === false) { continue 2; } } if ($match === true) { $result[$k] = $v; } } return $result; } // Define if (!function_exists('array_intersect_uassoc')) { function array_intersect_uassoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_intersect_uassoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_intersect_ukey.php100777 1750 1750 3656 100777 16762 , Arpad Ray * @link http://php.net/function.array_intersect_ukey * @author Tom Buskens * @version $Revision: 269597 $ * @since PHP 5.0.2 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_intersect_ukey() { $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_intersect_ukey()', E_USER_WARNING); return; } // 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]; } user_error('array_diff_ukey() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_intersect_ukey() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $result = array(); foreach ($args[0] as $key1 => $value1) { for ($i = 1; $i !== $array_count; $i++) { foreach ($args[$i] as $key2 => $value2) { if (!(call_user_func($compare_func, (string) $key1, (string) $key2))) { $result[$key1] = $value1; break 2; } } } } return $result; } // Define if (!function_exists('array_intersect_ukey')) { function array_intersect_ukey() { $args = func_get_args(); return call_user_func_array('php_compat_array_intersect_ukey', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_key_exists.php100777 1750 1750 2225 100777 16103 , Arpad Ray * @link http://php.net/function.array_key_exists * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.1.0 * @require PHP 4.0.0 (user_error) */ function php_compat_array_key_exists($key, $search) { if (!is_scalar($key)) { user_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)) { user_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)); } // Define if (!function_exists('array_key_exists')) { function array_key_exists($key, $search) { return php_compat_array_key_exists($key, $search); } } PHP_Compat-1.6.0a3/Compat/Function/array_product.php100777 1750 1750 1562 100777 15377 , Arpad Ray * @link http://php.net/time_sleep_until * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.1 (trigger_error) */ function php_compat_array_product($array) { if (!is_array($array)) { trigger_error('The argument should be an array', E_USER_WARNING); return; } if (empty($array)) { return 0; } $r = 1; foreach ($array as $v) { $r *= $v; } return $r; } // Define if (!function_exists('array_product')) { function array_product($array) { return php_compat_array_product($array); } } PHP_Compat-1.6.0a3/Compat/Function/array_search.php100777 1750 1750 2062 100777 15160 , Arpad Ray * @link http://php.net/function.array_search * @author Aidan Lister * @author Thiemo Mättig (http://maettig.com/) * @version $Revision: 269597 $ * @since PHP 4.0.5 * @require PHP 4.0.0 (user_error) */ function php_compat_array_search($needle, $haystack, $strict = false) { if (!is_array($haystack)) { user_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; } // Define if (!function_exists('array_search')) { function array_search($needle, $haystack, $strict = false) { return php_compat_array_search($needle, $haystack, $strict); } } PHP_Compat-1.6.0a3/Compat/Function/array_slice.php100777 1750 1750 2311 100777 15007 , Arpad Ray * @link http://php.net/function.array_slice * @author Arpad Ray * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5.0.2 (Added optional preserve keys parameter) * @require PHP 4.0.0 (user_error) */ function php_compat_array_slice($array, $offset, $length = null, $preserve_keys = false) { if (!$preserve_keys) { return array_slice($array, $offset, $length); } if (!is_array($array)) { user_error('The first argument should be an array', E_USER_WARNING); return; } $keys = array_slice(array_keys($array), $offset, $length); $ret = array(); foreach ($keys as $key) { $ret[$key] = $array[$key]; } return $ret; } // Define if (!function_exists('array_slice')) { function array_slice($array, $offset, $length = null, $preserve_keys = false) { return php_compat_array_slice($array, $offset, $length, $preserve_keys); } } ?>PHP_Compat-1.6.0a3/Compat/Function/array_udiff.php100777 1750 1750 3651 100777 15015 , Arpad Ray * @link http://php.net/function.array_udiff * @author Stephan Schmidt * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_udiff() { $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_udiff()', E_USER_WARNING); return; } // 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]; } user_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } // Check arrays $cnt = count($args); for ($i = 0; $i < $cnt; $i++) { if (!is_array($args[$i])) { user_error('array_udiff() Argument #' . ($i + 1). ' is not an array', E_USER_WARNING); return; } } $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; } // Define if (!function_exists('array_udiff')) { function array_udiff() { $args = func_get_args(); return call_user_func_array('php_compat_array_udiff', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_udiff_assoc.php100777 1750 1750 3774 100777 16213 , Arpad Ray * @author Stephan Schmidt * @author Aidan Lister * @version $Revision: 269597 $ * @link http://php.net/function.array-udiff-assoc * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_udiff_assoc() { $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_udiff_assoc()', E_USER_WARNING); return; } // 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]; } user_error('array_udiff_assoc() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } // Check arrays $count = count($args); for ($i = 0; $i < $count; $i++) { if (!is_array($args[$i])) { user_error('array_udiff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } $diff = array (); // Traverse values of the first array foreach ($args[0] as $key => $value) { // Check all arrays for ($i = 1; $i < $count; $i++) { if (!array_key_exists($key, $args[$i])) { continue; } $result = call_user_func($compare_func, $value, $args[$i][$key]); if ($result === 0) { continue 2; } } $diff[$key] = $value; } return $diff; } // Define if (!function_exists('array_udiff_assoc')) { function array_udiff_assoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_udiff_assoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_udiff_uassoc.php100777 1750 1750 4731 100777 16372 , Arpad Ray * @link http://php.net/function.array_udiff_uassoc * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_udiff_uassoc() { $args = func_get_args(); if (count($args) < 4) { user_error('Wrong parameter count for array_udiff_uassoc()', E_USER_WARNING); return; } // Get key compare function $key_compare_func = array_pop($args); if (!is_callable($key_compare_func)) { if (is_array($key_compare_func)) { $key_compare_func = $key_compare_func[0] . '::' . $key_compare_func[1]; } user_error('array_udiff_uassoc() Not a valid callback ' . $key_compare_func, E_USER_WARNING); return; } // Get data compare function $data_compare_func = array_pop($args); if (!is_callable($data_compare_func)) { if (is_array($data_compare_func)) { $data_compare_func = $data_compare_func[0] . '::' . $data_compare_func[1]; } user_error('array_udiff_uassoc() Not a valid callback ' . $data_compare_func, E_USER_WARNING); return; } // Check arrays $count = count($args); for ($i = 0; $i < $count; $i++) { if (!is_array($args[$i])) { user_error('array_udiff_uassoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Traverse values of the first array $diff = array (); foreach ($args[0] as $key => $value) { // Check all arrays for ($i = 1; $i < $count; $i++) { foreach ($args[$i] as $args_key => $args_data) { $key_result = call_user_func($key_compare_func, $key, $args_key); $data_result = call_user_func($data_compare_func, $value, $args_data); if ($key_result === 0 && $data_result === 0) { continue 3; } } } $diff[$key] = $value; } return $diff; } // Define if (!function_exists('array_udiff_uassoc')) { function array_udiff_uassoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_udiff_uassoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_uintersect.php100777 1750 1750 3636 100777 16110 , Arpad Ray * @link http://php.net/function.array_uintersect * @author Tom Buskens * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_uintersect() { $args = func_get_args(); if (count($args) < 3) { user_error('wrong parameter count for array_uintersect()', E_USER_WARNING); return; } // Get compare function $user_func = array_pop($args); if (!is_callable($user_func)) { if (is_array($user_func)) { $user_func = $user_func[0] . '::' . $user_func[1]; } user_error('array_uintersect() Not a valid callback ' . $user_func, E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i < $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_uintersect() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $output = array(); foreach ($args[0] as $key => $item) { for ($i = 1; $i !== $array_count; $i++) { $array = $args[$i]; foreach($array as $key0 => $item0) { if (!call_user_func($user_func, $item, $item0)) { $output[$key] = $item; } } } } return $output; } // Define if (!function_exists('array_uintersect')) { function array_uintersect() { $args = func_get_args(); return call_user_func_array('php_compat_array_uintersect', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_uintersect_assoc.php100777 1750 1750 3733 100777 17276 , Arpad Ray * @link http://php.net/function.array_uintersect_assoc * @author Tom Buskens * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_uintersect_assoc() { $args = func_get_args(); if (count($args) < 3) { user_error('wrong parameter count for array_uintersect_assoc()', E_USER_WARNING); return; } // Get compare function $user_func = array_pop($args); if (!is_callable($user_func)) { if (is_array($user_func)) { $user_func = $user_func[0] . '::' . $user_func[1]; } user_error('array_uintersect_assoc() Not a valid callback ' . $user_func, E_USER_WARNING); return; } // Check arrays $array_count = count($args); for ($i = 0; $i < $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_uintersect_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Compare entries $output = array(); foreach ($args[0] as $key => $item) { for ($i = 1; $i !== $array_count; $i++) { if (array_key_exists($key, $args[$i])) { $compare = call_user_func($user_func, $item, $args[$i][$key]); if ($compare === 0) { $output[$key] = $item; } } } } return $output; } // Define if (!function_exists('array_uintersect_assoc')) { function array_uintersect_assoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_uintersect_assoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_uintersect_uassoc.php100777 1750 1750 5145 100777 17462 , Arpad Ray * @link http://php.net/function.array_uintersect_uassoc * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_uintersect_uassoc() { $args = func_get_args(); if (count($args) < 4) { user_error('Wrong parameter count for array_uintersect_uassoc()', E_USER_WARNING); return; } // Get key_compare_func $key_compare_func = array_pop($args); if (!is_callable($key_compare_func)) { if (is_array($key_compare_func)) { $key_compare_func = $key_compare_func[0] . '::' . $key_compare_func[1]; } user_error('array_uintersect_uassoc() Not a valid callback ' . $key_compare_func, E_USER_WARNING); return; } // Get data_compare_func $data_compare_func = array_pop($args); if (!is_callable($data_compare_func)) { if (is_array($data_compare_func)) { $data_compare_func = $data_compare_func[0] . '::' . $data_compare_func[1]; } user_error('array_uintersect_uassoc() Not a valid callback ' . $data_compare_func, E_USER_WARNING); return; } // Check arrays $count = count($args); for ($i = 0; $i !== $count; $i++) { if (!is_array($args[$i])) { user_error('array_uintersect_uassoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } // Traverse values of the first array $intersect = array (); foreach ($args[0] as $key => $value) { // Check against each array for ($i = 1; $i < $count; $i++) { // Traverse each element in current array foreach ($args[$i] as $ckey => $cvalue) { // Compare key and value if (call_user_func($key_compare_func, $key, $ckey) === 0 && call_user_func($data_compare_func, $value, $cvalue) === 0) { $intersect[$key] = $value; continue; } } } } return $intersect; } // Define if (!function_exists('array_uintersect_uassoc')) { function array_uintersect_uassoc() { $args = func_get_args(); return call_user_func_array('php_compat_array_uintersect_uassoc', $args); } } PHP_Compat-1.6.0a3/Compat/Function/array_walk_recursive.php100777 1750 1750 3077 100777 16747 , Arpad Ray * @link http://php.net/function.array_walk_recursive * @author Tom Buskens * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.6 (is_callable) */ function php_compat_array_walk_recursive(&$input, $funcname) { if (!is_callable($funcname)) { if (is_array($funcname)) { $funcname = $funcname[0] . '::' . $funcname[1]; } user_error('array_walk_recursive() Not a valid callback ' . $funcname, E_USER_WARNING); return; } if (!is_array($input)) { user_error('array_walk_recursive() The argument should be an array', E_USER_WARNING); return; } $args = func_get_args(); foreach ($input as $key => $item) { $callArgs = $args; if (is_array($item)) { $thisCall = 'php_compat_array_walk_recursive'; $callArgs[1] = $funcname; } else { $thisCall = $funcname; $callArgs[1] = $key; } $callArgs[0] = &$input[$key]; call_user_func_array($thisCall, $callArgs); } } // Define if (!function_exists('array_walk_recursive')) { function array_walk_recursive(&$input, $funcname) { return php_compat_array_walk_recursive($input, $funcname); } } PHP_Compat-1.6.0a3/Compat/Function/asinh.php100777 1750 1750 1100 100777 13607 , Arpad Ray * @link http://php.net/function.asinh * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 3.0.0 */ function php_compat_asinh($n) { return log($n + sqrt(1 + pow($n, 2))); } if (!function_exists('asinh')) { function asinh($n) { return php_compat_asinh($n); } } PHP_Compat-1.6.0a3/Compat/Function/atanh.php100777 1750 1750 1103 100777 13603 , Arpad Ray * @link http://php.net/function.atanh * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 3.0.0 */ function php_compat_atanh($n) { return 0.5 * (log(1 + $n) - log(1 - $n)); } if (!function_exists('atanh')) { function atanh($n) { return php_compat_atanh($n); } } PHP_Compat-1.6.0a3/Compat/Function/bcpowmod.php100777 1750 1750 3236 100777 14333 , Arpad Ray * @link http://php.net/function.bcpowmod * @author Sara Golemon * @version $Revision: 269597 $ * @since PHP 5.0.0 * @require PHP 4.0.0 (user_error) */ function php_compat_bcpowmod($x, $y, $modulus, $scale = 0) { // Sanity check if (!is_scalar($x)) { user_error('bcpowmod() expects parameter 1 to be string, ' . gettype($x) . ' given', E_USER_WARNING); return false; } if (!is_scalar($y)) { user_error('bcpowmod() expects parameter 2 to be string, ' . gettype($y) . ' given', E_USER_WARNING); return false; } if (!is_scalar($modulus)) { user_error('bcpowmod() expects parameter 3 to be string, ' . gettype($modulus) . ' given', E_USER_WARNING); return false; } if (!is_scalar($scale)) { user_error('bcpowmod() expects parameter 4 to be integer, ' . gettype($scale) . ' given', E_USER_WARNING); return false; } $t = '1'; while (bccomp($y, '0')) { if (bccomp(bcmod($y, '2'), '0')) { $t = bcmod(bcmul($t, $x), $modulus); $y = bcsub($y, '1'); } $x = bcmod(bcmul($x, $x), $modulus); $y = bcdiv($y, '2'); } return $t; } // Define if (!function_exists('bcpowmod')) { function bcpowmod($x, $y, $modulus, $scale = 0) { return php_compat_bcpowmod($x, $y, $modulus, $scale); } } PHP_Compat-1.6.0a3/Compat/Function/call_user_func_array.php100777 1750 1750 3502 100777 16677 , Arpad Ray * @link http://php.net/function.call_user_func_array * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.0.4 * @require PHP 4.0.0 (user_error) */ function php_compat_call_user_func_array($function, $param_arr) { $param_arr = array_values((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); user_error($error, E_USER_WARNING); return; } // 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 $retval = null; 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; } // Define if (!function_exists('call_user_func_array')) { function call_user_func_array($function, $param_arr) { return php_compat_call_user_func_array($function, $param_arr); } } PHP_Compat-1.6.0a3/Compat/Function/clone.php100777 1750 1750 2226 100777 13617 , Arpad Ray * @link http://php.net/language.oop5.cloning * @author Aidan Lister * @version $Revision: 280040 $ * @since PHP 5.0.0 * @require PHP 4.0.0 (user_error) */ function php_compat_clone($object) { // Sanity check if (!is_object($object)) { user_error('clone() __clone method called on non-object', E_USER_WARNING); return; } // Use serialize/unserialize trick to deep copy the object $object = unserialize(serialize($object)); // If there is a __clone method call it on the "new" class if (method_exists($object, '__clone')) { $func = '__clone'; $object->$func(); } return $object; } // Define if (version_compare(PHP_VERSION, '5.0') === -1) { // Needs to be wrapped in eval as clone is a keyword in PHP5 eval(' function clone($object) { return php_compat_clone($object); } '); } PHP_Compat-1.6.0a3/Compat/Function/constant.php100777 1750 1750 1547 100777 14355 , Arpad Ray * @link http://php.net/function.constant * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.0.4 * @require PHP 4.0.0 (user_error) */ function php_compat_constant($constant) { if (!defined($constant)) { $error = sprintf('constant() Couldn\'t find constant %s', $constant); user_error($error, E_USER_WARNING); return false; } $value = null; eval("\$value=$constant;"); return $value; } // Define if (!function_exists('constant')) { function constant($constant) { return php_compat_constant($constant); } } PHP_Compat-1.6.0a3/Compat/Function/convert_uudecode.php100777 1750 1750 3474 100777 16062 , Arpad Ray * @link http://php.net/function.convert_uudecode * @author Michael Wallner * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_convert_uudecode($string) { // Sanity check if (!is_scalar($string)) { user_error('convert_uuencode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING); return false; } if (strlen($string) < 8) { user_error('convert_uuencode() The given parameter is not a valid uuencoded string', E_USER_WARNING); return false; } $decoded = ''; foreach (explode("\n", $string) as $line) { $c = count($bytes = unpack('c*', substr(trim($line,"\r\n\t"), 1))); while ($c % 4) { $bytes[++$c] = 0; } foreach (array_chunk($bytes, 4) as $b) { $b0 = $b[0] == 0x60 ? 0 : $b[0] - 0x20; $b1 = $b[1] == 0x60 ? 0 : $b[1] - 0x20; $b2 = $b[2] == 0x60 ? 0 : $b[2] - 0x20; $b3 = $b[3] == 0x60 ? 0 : $b[3] - 0x20; $b0 <<= 2; $b0 |= ($b1 >> 4) & 0x03; $b1 <<= 4; $b1 |= ($b2 >> 2) & 0x0F; $b2 <<= 6; $b2 |= $b3 & 0x3F; $decoded .= pack('c*', $b0, $b1, $b2); } } return rtrim($decoded, "\0"); } // Define if (!function_exists('convert_uudecode')) { function convert_uudecode($string) { return php_compat_convert_uudecode($string); } } PHP_Compat-1.6.0a3/Compat/Function/convert_uuencode.php100777 1750 1750 3370 100777 16067 , Arpad Ray * @link http://php.net/function.convert_uuencode * @author Michael Wallner * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_convert_uuencode($string) { // Sanity check if (!is_scalar($string)) { user_error('convert_uuencode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING); return false; } $u = 0; $encoded = ''; while ($c = count($bytes = unpack('c*', substr($string, $u, 45)))) { $u += 45; $encoded .= pack('c', $c + 0x20); while ($c % 3) { $bytes[++$c] = 0; } foreach (array_chunk($bytes, 3) as $b) { $b0 = ($b[0] & 0xFC) >> 2; $b1 = (($b[0] & 0x03) << 4) + (($b[1] & 0xF0) >> 4); $b2 = (($b[1] & 0x0F) << 2) + (($b[2] & 0xC0) >> 6); $b3 = $b[2] & 0x3F; $b0 = $b0 ? $b0 + 0x20 : 0x60; $b1 = $b1 ? $b1 + 0x20 : 0x60; $b2 = $b2 ? $b2 + 0x20 : 0x60; $b3 = $b3 ? $b3 + 0x20 : 0x60; $encoded .= pack('c*', $b0, $b1, $b2, $b3); } $encoded .= "\n"; } // Add termination characters $encoded .= "\x60\n"; return $encoded; } // Define if (!function_exists('convert_uuencode')) { function convert_uuencode($string) { return php_compat_convert_uuencode($string); } } PHP_Compat-1.6.0a3/Compat/Function/cosh.php100777 1750 1750 1066 100777 13454 , Arpad Ray * @link http://php.net/function.cosh * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 3.0.0 */ function php_compat_cosh($n) { return 0.5 * (exp($n) + exp(-$n)); } if (!function_exists('cosh')) { function cosh($n) { return php_compat_cosh($n); } } PHP_Compat-1.6.0a3/Compat/Function/debug_print_backtrace.php100777 1750 1750 4017 100777 17020 , Arpad Ray * @link http://php.net/function.debug_print_backtrace * @author Laurent Laville * @author Aidan Lister * @version $Revision: 274507 $ * @since PHP 5 * @require PHP 4.3.0 (debug_backtrace) */ function php_compat_debug_print_backtrace() { // Get backtrace $backtrace = debug_backtrace(); // Unset call to debug_print_backtrace array_shift($backtrace); if (empty($backtrace)) { return ''; } // Iterate backtrace $calls = array(); foreach ($backtrace as $i => $call) { if (!isset($call['file'])) { $call['file'] = '(null)'; } if (!isset($call['line'])) { $call['line'] = '0'; } $location = $call['file'] . ':' . $call['line']; $function = (isset($call['class'])) ? $call['class'] . (isset($call['type']) ? $call['type'] : '.') . $call['function'] : $call['function']; $params = ''; if (isset($call['args'])) { $args = array(); foreach ($call['args'] as $arg) { if (is_array($arg) || is_object($arg)) { $desc = print_r($arg, true); $desc = preg_replace('/\s+/', ' ', $desc); $args[] = $desc; } else { $args[] = $arg; } } $params = implode(', ', $args); } $calls[] = sprintf('#%d %s(%s) called at [%s]', $i, $function, $params, $location); } echo implode("\n", $calls), "\n"; } // Define if (!function_exists('debug_print_backtrace')) { function debug_print_backtrace() { return php_compat_debug_print_backtrace(); } } PHP_Compat-1.6.0a3/Compat/Function/file_get_contents.php100777 1750 1750 12526 100777 16236 , Arpad Ray * @link http://php.net/function.file_get_contents * @author Aidan Lister * @author Arpad Ray * @version $Revision: 280045 $ * @internal resource_context is only supported for PHP 4.3.0+ (stream_context_get_options) * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_file_get_contents($filename, $incpath = false, $resource_context = null, $offset = -1, $maxlen = -1) { if (is_resource($resource_context) && function_exists('stream_context_get_options')) { $opts = stream_context_get_options($resource_context); } $colon_pos = strpos($filename, '://'); $wrapper = $colon_pos === false ? 'file' : substr($filename, 0, $colon_pos); $opts = (empty($opts) || empty($opts[$wrapper])) ? array() : $opts[$wrapper]; $data = false; switch ($wrapper) { case 'http': $max_redirects = (isset($opts[$wrapper]['max_redirects']) ? $opts[$proto]['max_redirects'] : PHP_COMPAT_FILE_GET_CONTENTS_MAX_REDIRECTS); for ($i = 0; $i < $max_redirects; $i++) { $data = php_compat_http_get_contents_helper($filename, $opts); if (is_array($contents)) { // redirected $filename = rtrim($contents[1]); $data = ''; continue; } break 2; } user_error('redirect limit exceeded', E_USER_WARNING); return; case 'ftp': case 'https': case 'ftps': case 'socket': // tbc } if (false === $data) { if (is_resource($resource_context) && version_compare(PHP_VERSION, '4.3.0', 'ge')) { $fh = fopen($filename, 'rb', $incpath, $resource_context); } else { $fh = fopen($filename, 'rb', $incpath); } if (false === $fh) { user_error('failed to open stream: No such file or directory', E_USER_WARNING); return false; } clearstatcache(); if ($fsize = @filesize($filename)) { $data = fread($fh, $fsize); } else { $data = ''; while (!feof($fh)) { $data .= fread($fh, 8192); } } fclose($fh); } if ($offset != -1) { $data = substr($data, $offset); } if ($maxlen != -1) { $data = substr($data, 0, $maxlen); } return $data; } /** * Performs HTTP requests * * @param string $filename * the full path to request * @param array $opts * an array of stream context options * @return mixed * either the contents of the requested path (as a string), * or an array where $array[1] is the path redirected to. */ function php_compat_http_get_contents_helper($filename, $opts) { $path = parse_url($filename); if (!isset($path['host'])) { return ''; } $port = isset($path['port']) ? $path['port'] : 80; $fp = fsockopen($path['host'], $port, $errno, $errstr, 4); if (!$fp) { return ''; } if (!isset($path['path'])) { $path['path'] = '/'; } $headers = array( 'Host' => $path['host'], 'Conection' => 'close' ); // enforce some options (proxy isn't supported) $opts_defaults = array( 'method' => 'GET', 'header' => null, 'user_agent' => ini_get('user_agent'), 'content' => null, 'request_fulluri' => false ); foreach ($opts_defaults as $key => $value) { if (!isset($opts[$key])) { $opts[$key] = $value; } } $opts['path'] = $opts['request_fulluri'] ? $filename : $path['path']; // build request $request = $opts['method'] . ' ' . $opts['path'] . " HTTP/1.0\r\n"; // build headers if (isset($opts['header'])) { $optheaders = explode("\r\n", $opts['header']); for ($i = count($optheaders); $i--;) { $sep_pos = strpos($optheaders[$i], ': '); $headers[substr($optheaders[$i], 0, $sep_pos)] = substr($optheaders[$i], $sep_pos + 2); } } foreach ($headers as $key => $value) { $request .= "$key: $value\r\n"; } $request .= "\r\n" . $opts['content']; // make request fputs($fp, $request); $response = ''; while (!feof($fp)) { $response .= fgets($fp, 8192); } fclose($fp); $content_pos = strpos($response, "\r\n\r\n"); $headers = substr($response, 0, $content_pos); $content = substr($response, $content_pos + 4); $GLOBALS['http_response_header'] = explode("\r\n", $headers); // recurse for redirects if (preg_match('/^Location: (.*)$/mi', $headers, $matches)) { return $matches; } return $content; } // Define if (!function_exists('file_get_contents')) { function file_get_contents($filename, $incpath = false, $resource_context = null, $offset = -1, $maxlen = -1) { return php_compat_file_get_contents($filename, $incpath, $resource_context); } } ?>PHP_Compat-1.6.0a3/Compat/Function/file_put_contents.php100777 1750 1750 5566 100777 16255 , Arpad Ray * @link http://php.net/function.file_put_contents * @author Aidan Lister * @version $Revision: 269597 $ * @internal resource_context is not supported * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_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_scalar($content)) { user_error('file_put_contents() The 2nd parameter should be either a string or an array', E_USER_WARNING); return false; } // Get the length of data to write $length = strlen($content); // Check what mode we are using $mode = ($flags & FILE_APPEND) ? 'a' : 'wb'; // 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) { user_error('file_put_contents() failed to open stream: Permission denied', E_USER_WARNING); return false; } // Attempt to get an exclusive lock $use_lock = ($flags & LOCK_EX) ? true : false ; if ($use_lock === true) { if (!flock($fh, LOCK_EX)) { 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); user_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); user_error($errormsg, E_USER_WARNING); return false; } // Return length return $bytes; } // Define if (!function_exists('file_put_contents')) { function file_put_contents($filename, $content, $flags = null, $resource_context = null) { return php_compat_file_put_contents($filename, $content, $flags, $resource_context); } } PHP_Compat-1.6.0a3/Compat/Function/floatval.php100777 1750 1750 1173 100777 14327 , Arpad Ray * @link http://php.net/function.floatval * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) (Type Casting) */ function php_compat_floatval($var) { return (float) $var; } // Define if (!function_exists('floatval')) { function floatval($var) { return php_compat_floatval($var); } } PHP_Compat-1.6.0a3/Compat/Function/fprintf.php100777 1750 1750 2216 100777 14166 , Arpad Ray * @link http://php.net/function.fprintf * @author Aidan Lister * @version $Revision: 280039 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_fprintf() { $args = func_get_args(); if (count($args) < 2) { user_error('Wrong parameter count for fprintf()', E_USER_WARNING); return; } $resource_handle = array_shift($args); $format = array_shift($args); if (!is_resource($resource_handle)) { user_error('fprintf() supplied argument is not a valid stream resource', E_USER_WARNING); return false; } array_unshift($args, $format); return fwrite($resource_handle, call_user_func_array('sprintf', $args)); } // Define if (!function_exists('fprintf')) { function fprintf() { $args = func_get_args(); return call_user_func_array('php_compat_fprintf', $args); } } PHP_Compat-1.6.0a3/Compat/Function/fputcsv.php100777 1750 1750 2702 100777 14210 , Arpad Ray * @link http://php.net/function.fprintf * @author Twebb * @author Aidan Lister * @version $Revision: 301763 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"') { // Sanity Check if (!is_resource($handle)) { user_error('fputcsv() expects parameter 1 to be resource, ' . gettype($handle) . ' given', E_USER_WARNING); return false; } $str = ''; foreach ($fields as $cell) { $cell = str_replace($enclosure, $enclosure . $enclosure, $cell); if (strchr($cell, $delimiter) !== false || strchr($cell, $enclosure) !== false || strchr($cell, "\n") !== false) { $str .= $enclosure . $cell . $enclosure . $delimiter; } else { $str .= $cell . $delimiter; } } fputs($handle, substr($str, 0, -1) . "\n"); return strlen($str); } // Define if (!function_exists('fputcsv')) { function fputcsv($handle, $fields, $delimiter = ',', $enclosure = '"') { return php_compat_fputcsv($handle, $fields, $delimiter, $enclosure); } } PHP_Compat-1.6.0a3/Compat/Function/getmxrr.php100777 1750 1750 4003 100777 14202 , Arpad Ray , James Wade * @link http://php.net/function.vsprintf * @author James Wade * @version $Revision: 1.0 $ * @since PHP 4.0 * @require PHP 4.0.3 (escapeshellarg) */ function php_compat_getmxrr($hostname, &$mxhosts, &$mxweight=false) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { return win_getmxrr($hostname, $mxhosts, $mxweight); } else { user_error('getmxrr() is not supported on your operating system.', E_USER_WARNING); return; } } function getmxrr_win($hostname, &$mxhosts, &$mxweight=false) { if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { user_error('getmxrr() is not supported on your operating system', E_USER_WARNING); return; } if (empty($hostname)) { user_error('getmxrr() expects parameter 1 to be string, ' . gettype($hostname) . ' given', E_USER_WARNING); return false; } if (!is_array ($mxhosts)) { user_error('getmxrr() expects parameter 2 to be array, ' . gettype($mxhosts) . ' given', E_USER_WARNING); return false; } $exec='nslookup -type=MX '.escapeshellarg($hostname); @exec($exec, $output); if (empty($output)) return; $i=-1; foreach ($output as $line) { $i++; if (preg_match("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.+)$/i", $line, $parts)) { $mxweight[$i] = trim($parts[1]); $mxhosts[$i] = trim($parts[2]); } if (preg_match('/responsible mail addr = (.+)$/i', $line, $parts)) { $mxweight[$i] = $i; $mxhosts[$i] = trim($parts[1]); } } return ($i!=-1); } // Define if (!function_exists('getmxrr')) { function getmxrr($hostname, &$mxhosts, &$mxweight=false) { return php_compat_getmxrr($hostname, $mxhosts, $mxweight); } } PHP_Compat-1.6.0a3/Compat/Function/getopt.php100777 1750 1750 10232 100777 14035 , Arpad Ray * @link http://php.net/function.getopt * @author Jim Wigginton * @version $Revision: 301612 $ * @since PHP 4.3.0 */ function php_compat_getopt($options, $longopts = NULL) { global $argv, $argc; $output = array(); $opt = ''; if (is_array($options)) { user_error('getopt() expects parameter 1 to be string, array given', E_USER_WARNING); return false; } for ($i = 1; $i < $argc; $i++) { switch (true) { case is_array($longopts) && substr($argv[$i], 0, 2) == '--': $pos = strpos($argv[$i], '='); $opt = is_int($pos) ? substr($argv[$i], 2, $pos - 2) : substr($argv[$i], 2); list($match) = array_values(preg_grep('#^' . preg_quote($opt, '#') . ':{0,2}$#', $longopts)); if (is_null($match)) { break; } $value = $pos === false ? null : substr($argv[$i], $pos + 1); $type = strlen(substr($match, strlen($opt))); php_compat_getopt_helper($opt, $value, $type, $output); break; case $argv[$i][0] == '-' && preg_match('#' . preg_quote($argv[$i][1], '#') . '(:{0,2})#', $options, $matches): $opt = $argv[$i][1]; $type = strlen($matches[1]); $value = substr($argv[$i], 2); if ($type == 0) { if ($value) { $argv[$i] = '-' . $value; --$i; } $value = null; } php_compat_getopt_helper($opt, $value, $type, $output); break; case !empty($opt): if (isset($output[$opt]) && is_array($output[$opt])) { $output[$opt][count($output[$opt]) - 1] = $argv[$i]; } else { $output[$opt] = $argv[$i]; } $opt = ''; } if (!empty($value) || $type == PHP_COMPAT_GETOPT_NO_VALUE) { $opt = ''; } } return $output; } function php_compat_getopt_helper($opt, $value, $type, &$output) { switch ($type) { case PHP_COMPAT_GETOPT_NO_VALUE: switch (true) { case !isset($output[$opt]): $output[$opt] = false; break; case is_array($output[$opt]): $output[$opt][] = false; break; default: $output[$opt] = array($output[$opt], false); } break; case PHP_COMPAT_GETOPT_VALUE_REQUIRED: if (!empty($value)) { switch (true) { case !isset($output[$opt]): $output[$opt] = $value; break; case is_array($output[$opt]): $output[$opt][] = $value; break; default: $output[$opt] = array($output[$opt], $value); } } break; case PHP_COMPAT_GETOPT_VALUE_OPTIONAL: $value = !empty($value) ? $value : false; switch (true) { case !isset($output[$opt]): $output[$opt] = $value; break; case is_array($output[$opt]): $output[$opt][] = $value; break; default: $output[$opt] = array($output[$opt], $value); } } } // Define if (!function_exists('getopt')) { function getopt($options, $longopts = NULL) { return php_compat_getopt($options, $longopts); } } ?>PHP_Compat-1.6.0a3/Compat/Function/get_headers.php100777 1750 1750 5420 100777 14770 , Arpad Ray * @link http://php.net/function.get_headers * @author Aeontech * @author Cpurruc * @author Aidan Lister * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.0.0 * @require PHP 4.0.0 (user_error) */ function php_compat_get_headers($url, $format = 0) { $result = array(); for ($i = 0; $i < PHP_COMPAT_GET_HEADERS_MAX_REDIRECTS; $i++) { $headers = php_compat_get_headers_helper($url, $format); if ($headers === false) { return false; } $result = array_merge($result, $headers); if ($format == 1 && isset($headers['Location'])) { $url = $headers['Location']; continue; } if ($format == 0) { for ($j = count($headers); $j--;) { if (preg_match('/^Location: (.*)$/i', $headers[$j], $matches)) { $url = $matches[1]; continue 2; } } } return $result; } return empty($result) ? false : $result; } function php_compat_get_headers_helper($url, $format) { // Init $urlinfo = parse_url($url); $port = isset($urlinfo['port']) ? $urlinfo['port'] : 80; // Connect $fp = fsockopen($urlinfo['host'], $port, $errno, $errstr, 30); if ($fp === false) { return false; } // Send request $head = 'HEAD ' . (isset($urlinfo['path']) ? $urlinfo['path'] : '/') . (isset($urlinfo['query']) ? '?' . $urlinfo['query'] : '') . ' HTTP/1.0' . "\r\n" . 'Host: ' . $urlinfo['host'] . "\r\n\r\n"; fputs($fp, $head); // Read $headers = array(); while (!feof($fp)) { if ($header = trim(fgets($fp, 1024))) { list($key) = explode(':', $header); if ($format === 1) { // First element is the HTTP header type, such as HTTP 200 OK // It doesn't have a separate name, so check for it if ($key == $header) { $headers[] = $header; } else { $headers[$key] = substr($header, strlen($key)+2); } } else { $headers[] = $header; } } } fclose($fp); return $headers; } // Define if (!function_exists('get_headers')) { function get_headers($url, $format = 0) { return php_compat_get_headers($url, $format); } } PHP_Compat-1.6.0a3/Compat/Function/get_include_path.php100777 1750 1750 1221 100777 16007 , Arpad Ray * @link http://php.net/function.get_include_path * @author Stephan Schmidt * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 */ function php_compat_get_include_path() { return ini_get('include_path'); } // Define if (!function_exists('get_include_path')) { function get_include_path() { return php_compat_get_include_path(); } } PHP_Compat-1.6.0a3/Compat/Function/glob.php100777 1750 1750 24304 100777 13463 , Arpad Ray * @link http://php.net/glob * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 3.0.9 (preg_replace) */ function php_compat_glob($pattern, $flags = 0) { $return_failure = ($flags & GLOB_NOCHECK) ? array($pattern) : false; // build path to scan files $path = '.'; $wildcards_open = '*?['; $wildcards_close = ']'; if ($flags & GLOB_BRACE) { $wildcards_open .= '{'; $wildcards_close .= '}'; } $prefix_length = strcspn($pattern, $wildcards_open); if ($prefix_length) { if (DIRECTORY_SEPARATOR == '\\') { $sep = ($flags & GLOB_NOESCAPE) ? '[\\\\/]' : '(?:/|\\\\(?![' . $wildcards_open . $wildcards_close . ']))'; } else { $sep = '/'; } if (preg_match('#^(.*)' . $sep . '#', substr($pattern, 0, $prefix_length), $matches)) { $path = $matches[1]; } } $recurse = (strpos($pattern, DIRECTORY_SEPARATOR, $prefix_length) !== false); // scan files $files = php_compat_glob_scan_helper($path, $flags, $recurse); if ($files === false) { return $return_failure; } // build preg pattern $pattern = php_compat_glob_convert_helper($pattern, $flags); $convert_patterns = array('/\{([^{}]*)\}/e', '/\[([^\]]*)\]/e'); $convert_replacements = array( 'php_compat_glob_brace_helper(\'$1\', $flags)', 'php_compat_glob_charclass_helper(\'$1\', $flags)' ); while ($flags & GLOB_BRACE) { $new_pattern = preg_replace($convert_patterns, $convert_replacements, $pattern); if ($new_pattern == $pattern) { break; } $pattern = $new_pattern; } $pattern = '#^' . $pattern . '\z#'; // process files $results = array(); foreach ($files as $file => $dir) { if (!preg_match($pattern, $file, $matches)) { continue; } if (($flags & GLOB_ONLYDIR) && !$dir) { continue; } $file = (($flags & GLOB_MARK) && $dir) ? $file . DIRECTORY_SEPARATOR : $file; if ($flags & GLOB_BRACE) { // find last matching subpattern $rank = 0; for ($i = 1, $matchc = count($matches); $i < $matchc; $i++) { if (strlen($matches[$i])) { $rank = $i; } } $file = array($file, $rank); } $results[] = $file; } if ($flags & GLOB_BRACE) { usort($results, ($flags & GLOB_NOSORT) ? 'php_compat_glob_brace_nosort_helper' : 'php_compat_glob_brace_sort_helper'); } else if ($flags & GLOB_NOSORT) { usort($results, 'php_compat_glob_nosort_helper'); } else { sort($results); } // array_values() for php 4 + $reindex = array(); foreach ($results as $result) { $reindex[] = ($flags & GLOB_BRACE) ? $result[0] : $result; } if (($flags & GLOB_NOCHECK) && !count($reindex)) { return $return_failure; } return $reindex; } /** * Scans a path * * @param string $path * the path to scan * @param int $flags * the flags passed to glob() * @param bool $recurse * true to scan recursively * @return mixed * an array of files in the given path where the key is the path, * and the value is 1 if the file is a directory, 0 if it isn't. * Returns false on unrecoverable errors, or all errors when * GLOB_ERR is on. */ function php_compat_glob_scan_helper($path, $flags, $recurse = false) { if (!is_readable($path)) { return false; } $results = array(); if (is_dir($path)) { $fp = opendir($path); if (!$fp) { return ($flags & GLOB_ERR) ? false : array($path); } if ($path != '.') { $results[$path] = 1; } while (($file = readdir($fp)) !== false) { if ($file[0] == '.' || $file == '..') { continue; } $filepath = ($path == '.') ? $file : $path . DIRECTORY_SEPARATOR . $file; if (is_dir($filepath)) { $results[$filepath] = 1; if (!$recurse) { continue; } $files = php_compat_glob_scan_helper($filepath, $flags); if ($files === false) { if ($flags & GLOB_ERR) { return false; } continue; } // array_merge for php 4 + foreach ($files as $rfile => $rdir) { $results[$rfile] = $rdir; } continue; } $results[$filepath] = 0; } closedir($fp); } else { $results[$path] = 0; } return $results; } /** * Converts a section of a glob pattern to a PCRE pattern * * @param string $input * the pattern to convert * @param int $flags * the flags passed to glob() * @return string * the escaped input */ function php_compat_glob_convert_helper($input, $flags) { $opens = array( '{' => array('}', 0), '[' => array(']', 0), '(' => array(')', 0) ); $ret = ''; for ($i = 0, $len = strlen($input); $i < $len; $i++) { $skip = false; $c = $input[$i]; $escaped = ($i && $input[$i - 1] == '\\' && ($flags & GLOB_NOCHECK == false)); // skips characters classes and subpatterns, they are escaped in their respective helpers foreach ($opens as $k => $v) { if ($v[1]) { if ($c == $v[0] && !$escaped) { --$opens[$k][1]; $ret .= $c; continue 2; } $skip = true; } } if (isset($opens[$c])) { if (!$escaped) { ++$opens[$c][1]; } $ret .= $c; continue; } if ($skip) { $ret .= $c; continue; } // converts wildcards switch ($c) { case '*': $ret .= $escaped ? '*' : '.*'; continue 2; case '?': if ($escaped) { continue; } $ret .= '.'; continue 2; } $ret .= preg_quote($c, '#'); } return $ret; } /** * Converts glob braces * * @param string $brace * the contents of the braces to convert * @param int $flags * the flags passed to glob() * @return string * a PCRE subpattern of alternatives */ function php_compat_glob_brace_helper($brace, $flags) { $alternatives = explode(',', $brace); for ($i = count($alternatives); $i--;) { $alternatives[$i] = php_compat_glob_convert_helper($alternatives[$i], $flags); } return '(?:(' . implode(')|(', $alternatives) . '))'; } /** * Converts glob character classes * * @param string $class * the contents of the class to convert * @param int $flags * the flags passed to glob() * @return string * a PCRE character class */ function php_compat_glob_charclass_helper($class, $flags) { if (strpos($class, '-') !== false) { $class = strtr($class, array('-' => '')) . '-'; } if (strpos($class, ']') !== false) { $class = ']' . strtr($class, array(']' => '')); } if (strpos($class, '^') !== false) { $class = '\^' . strtr($class, array('^' => '')); } return '[' . strtr($class, array('#' => '\#')) . ']'; } /** * Callback sort function for GLOB_NOSORT * * Sorts first by the base name, then in reverse by the extension */ function php_compat_glob_nosort_helper($a, $b) { $operands = array(array('full' => $a), array('full' => $b)); foreach ($operands as $k => $v) { $v['pos'] = strrpos($v['full'], '.'); if ($v['pos'] === false) { $v['pos'] = strlen($v['full']) - 1; } $v['slash'] = strrpos($v['full'], DIRECTORY_SEPARATOR); if ($v['slash'] === false) { $v['slash'] = strlen($v['full']) - 1; } $operands[$k]['dir'] = substr($v['full'], 0, $v['slash']); $operands[$k]['base'] = substr($v['full'], $v['slash'], $v['pos'] - $v['slash']); $operands[$k]['ext'] = substr($v['full'], $v['pos'] + 1); } $dir_cmp = strcmp($operands[0]['dir'], $operands[1]['dir']); if ($dir_cmp == 0) { $base_cmp = strcmp($operands[0]['base'], $operands[1]['base']); if ($base_cmp == 0) { $ext_cmp = strcmp($operands[0]['ext'], $operands[1]['ext']); return -$ext_cmp; } return $base_cmp; } return -$dir_cmp; } /** * Callback sort function for GLOB_BRACE * * Each argument should be an array where the first element is the * file path, and the second is its rank. The rank is the number of * alternatives between this match and the beginning of the brace. */ function php_compat_glob_brace_sort_helper($a, $b) { if ($a[1] == $b[1]) { return strcmp($a[0], $b[0]); } return ($a[1] < $b[1]) ? -1 : 1; } /** * Callback sort function for (GLOB_BRACE | GLOB_NOSORT) * * Receives the same arguments php_compat_glob_brace_sort_helper() */ function php_compat_glob_brace_nosort_helper($a, $b) { if ($a[1] == $b[1]) { $len_a = strlen($a[0]); $len_b = strlen($b[0]); if ($len_a == $len_b) { return -strcmp($a[0], $b[0]); } return ($len_a < $len_b) ? -1 : 1; } return ($a[1] < $b[1]) ? -1 : 1; } if (!function_exists('glob')) { function glob($pattern, $flags = 0) { return php_compat_glob($pattern, $flags); } } ?>PHP_Compat-1.6.0a3/Compat/Function/htmlspecialchars.php100777 1750 1750 11155 100777 16066 , Arpad Ray * @link http://php.net/function.htmlspecialchars * @author Aidan Lister * @version $Revision: 274499 $ * @since PHP 4.0.0 * @require PHP 4.0.0 (user_error) */ function php_compat_htmlspecialchars($string, $quote_style = ENT_COMPAT, $charset = 'ISO-8859-1', $double_encode = true) { if (version_compare(PHP_VERSION, '5.2.3', 'ge')) { return htmlspecialchars($string, $quote_style, $charset, $double_encode); } // Sanity check if (!is_scalar($string)) { user_error('htmlspecialchars() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING); return; } if (!is_int($quote_style) && $quote_style !== null) { user_error('htmlspecialchars() expects parameter 2 to be integer, ' . gettype($quote_style) . ' given', E_USER_WARNING); return; } if (!is_scalar($charset)) { user_error('htmlspecialchars() expects parameter 3 to be string, ' . gettype($charset) . ' given', E_USER_WARNING); return; } if (!is_bool($double_encode)) { user_error('htmlspecialchars() expects parameter 4 to be bool, ' . gettype($double_encode) . ' given', E_USER_WARNING); return; } // mb support if ($charset != 'ISO-8859-1') { if (!function_exists('mb_substr')) { user_error('php_compat_htmlspecialchars requires PHP >= 4.0.6 and ' . 'the mbstring extension to support the $charset argument.', E_USER_WARNING); return; } $len = mb_strlen($string, $charset); $ret = ''; for ($i = 0; $i < $len; $i++) { $char = mb_substr($string, $i, 1, $charset); switch ($char) { case '&': if (!$double_encode && $i < $len - 2) { // look ahead to see if we have an existing entity $foundEntity = false; $type = mb_substr($string, $i + 1, 1, $charset); if ($type == '#') { // numeric entities $type2 = mb_substr($string, $i + 2, 1, $charset); if ($type2 == 'x') { $validator = 'ctype_xdigit'; } else if (ctype_digit($type2)) { $validator = 'ctype_digit'; $foundEntity = true; } else { // invalid entity $ret .= '&'; break; } } else if (ctype_alnum($type)) { $validator = 'ctype_alnum'; $foundEntity = true; } else { $ret .= '&'; break; } for ($j = $i + ($type == '#' ? 3 : 2); $j < $len; $j++) { $tempChar = mb_substr($string, $j, 1, $charset); if ($foundEntity && $tempChar == ';') { $ret .= mb_substr($string, $i, $j - $i + 1, $charset); $i = $j; break 2; } if ($validator($tempChar)) { $foundEntity = true; } else { // invalid entity $ret .= '&'; break; } } } $ret .= '&'; break; case '"': $ret .= $quote_style & ENT_NOQUOTES ? '"' : '"'; break; case "'": $ret .= $quote_style & ENT_COMPAT || $quote_style & ENT_NOQUOTES ? "'" : '''; break; case '<': $ret .= '<'; break; case '>': $ret .= '>'; break; default: $ret .= $char; break; } } return $ret; } if (!$double_encode) { return preg_replace('/[^&]|&(?!(?:#(?:x[a-f\d]+|\d+)|\w+);)/e', 'htmlspecialchars("$0", $quote_style)', $string); } return htmlspecialchars($string, $quote_style); } PHP_Compat-1.6.0a3/Compat/Function/htmlspecialchars_decode.php100777 1750 1750 3154 100777 17351 , Arpad Ray * @link http://php.net/function.htmlspecialchars_decode * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.0 (user_error) */ function php_compat_htmlspecialchars_decode($string, $quote_style = null) { // Sanity check if (!is_scalar($string)) { user_error('htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING); return; } if (!is_int($quote_style) && $quote_style !== null) { user_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' . gettype($quote_style) . ' given', E_USER_WARNING); return; } // The function does not behave as documented // This matches the actual behaviour of the function if ($quote_style & ENT_COMPAT || $quote_style & ENT_QUOTES) { $from = array('"', ''', '<', '>', '&'); $to = array('"', "'", '<', '>', '&'); } else { $from = array('<', '>', '&'); $to = array('<', '>', '&'); } return str_replace($from, $to, $string); } // Define if (!function_exists('htmlspecialchars_decode')) { function htmlspecialchars_decode($string, $quote_style = null) { return php_compat_htmlspecialchars_decode($string, $quote_style); } } PHP_Compat-1.6.0a3/Compat/Function/html_entity_decode.php100777 1750 1750 3265 100777 16366 , Arpad Ray * @link http://php.net/function.html_entity_decode * @author David Irvine * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 * @internal Setting the charset will not do anything * @require PHP 4.0.0 (user_error) */ function php_compat_html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null) { if (!is_int($quote_style)) { user_error('html_entity_decode() expects parameter 2 to be long, ' . gettype($quote_style) . ' given', E_USER_WARNING); return; } $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); // Add single quote to translation table; if ($quote_style === ENT_QUOTES) { $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); } // Define if (!function_exists('html_entity_decode')) { function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null) { return php_compat_html_entity_decode($string, $quote_style, $charset); } } PHP_Compat-1.6.0a3/Compat/Function/http_build_query.php100777 1750 1750 5540 100777 16104 , Arpad Ray * @link http://php.net/function.http-build-query * @author Stephan Schmidt * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_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)) { user_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; } // Argument seperator $separator = ini_get('arg_separator.output'); if (strlen($separator) == 0) { $separator = '&'; } // Start building the query $tmp = array (); foreach ($formdata as $key => $val) { if (is_null($val)) { continue; } 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) || is_object($val)) { array_push($tmp, php_compat_http_build_query_helper($val, urlencode($key))); continue; } // The value is a resource return null; } return implode($separator, $tmp); } // Helper function function php_compat_http_build_query_helper($array, $name) { $tmp = array (); foreach ($array as $key => $value) { if (is_array($value)) { array_push($tmp, php_compat_http_build_query_helper($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, php_compat_http_build_query_helper(get_object_vars($value), sprintf('%s[%s]', $name, $key))); } } // Argument seperator $separator = ini_get('arg_separator.output'); if (strlen($separator) == 0) { $separator = '&'; } return implode($separator, $tmp); } // Define if (!function_exists('http_build_query')) { function http_build_query($formdata, $numeric_prefix = null) { return php_compat_http_build_query($formdata, $numeric_prefix); } } PHP_Compat-1.6.0a3/Compat/Function/ibase_timefmt.php100777 1750 1750 2116 100777 15325 , Arpad Ray * @link http://php.net/function.ibase_timefmt * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5.0.0 * @require PHP 4.0.0 (user_error) */ function php_compat_ibase_timefmt($format, $columntype = IBASE_TIMESTAMP) { switch ($columntype) { case IBASE_TIMESTAMP: ini_set('ibase.dateformat', $format); break; case IBASE_DATE: ini_set('ibase.dateformat', $format); break; case IBASE_TIME: ini_set('ibase.timeformat', $format); break; default: return false; } return true; } // Define if (!function_exists('ibase_timefmt')) { function ibase_timefmt($format, $columntype = IBASE_TIMESTAMP) { return php_compat_ibase_timefmt($format, $columntype); } } PHP_Compat-1.6.0a3/Compat/Function/idate.php100777 1750 1750 1665 100777 13613 , Arpad Ray * @link http://php.net/idate * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.0.0 * @require PHP 4.0.0 (user_error) */ function php_compat_idate($format, $timestamp = false) { if (strlen($format) !== 1) { user_error('idate format is one char', E_USER_WARNING); return false; } if (strpos('BdhHiILmstUwWyYzZ', $format) === false) { return 0; } if ($timestamp === false) { $timestamp = time(); } return intval(date($format, $timestamp)); } // Define if (!function_exists('idate')) { function idate($format, $timestamp = false) { return php_compat_idate($format, $timestamp); } } PHP_Compat-1.6.0a3/Compat/Function/image_type_to_mime_type.php100777 1750 1750 5661 100777 17422 , Arpad Ray * @link http://php.net/function.image_type_to_mime_type * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_image_type_to_mime_type($imagetype) { switch ($imagetype): case IMAGETYPE_GIF: return 'image/gif'; break; case IMAGETYPE_JPEG: return 'image/jpeg'; break; case IMAGETYPE_PNG: return 'image/png'; break; case IMAGETYPE_SWF: case IMAGETYPE_SWC: return 'application/x-shockwave-flash'; break; case IMAGETYPE_PSD: return 'image/psd'; break; case IMAGETYPE_BMP: return 'image/bmp'; break; case IMAGETYPE_TIFF_MM: case IMAGETYPE_TIFF_II: return 'image/tiff'; break; case IMAGETYPE_JP2: return 'image/jp2'; break; case IMAGETYPE_IFF: return 'image/iff'; break; case IMAGETYPE_WBMP: return 'image/vnd.wap.wbmp'; break; case IMAGETYPE_XBM: return 'image/xbm'; break; case IMAGETYPE_JPX: case IMAGETYPE_JB2: case IMAGETYPE_JPC: default: return 'application/octet-stream'; break; endswitch; } // Define if (!function_exists('image_type_to_mime_type')) { function image_type_to_mime_type($imagetype) { return php_compat_image_type_to_mime_type($imagetype); } } PHP_Compat-1.6.0a3/Compat/Function/inet_ntop.php100777 1750 1750 2010 100777 14505 , Arpad Ray * @link http://php.net/inet_ntop * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.0 (long2ip) */ function php_compat_inet_ntop($in_addr) { switch (strlen($in_addr)) { case 4: list(,$r) = unpack('N', $in_addr); return long2ip($r); case 16: $r = substr(chunk_split(bin2hex($in_addr), 4, ':'), 0, -1); $r = preg_replace( array('/(?::?\b0+\b:?){2,}/', '/\b0+([^0])/e'), array('::', '(int)"$1"?"$1":"0$1"'), $r); return $r; } return false; } // Define if (!function_exists('inet_ntop')) { function inet_ntop($in_addr) { return php_compat_inet_ntop($in_addr); } } PHP_Compat-1.6.0a3/Compat/Function/inet_pton.php100777 1750 1750 2276 100777 14523 , Arpad Ray * @link http://php.net/inet_pton * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.2.0 (array_fill) */ function php_compat_inet_pton($address) { $r = ip2long($address); if ($r !== false && $r != -1) { return pack('N', $r); } $delim_count = substr_count($address, ':'); if ($delim_count < 1 || $delim_count > 7) { return false; } $r = explode(':', $address); $rcount = count($r); if (($doub = array_search('', $r, 1)) !== false) { $length = (!$doub || $doub == $rcount - 1 ? 2 : 1); array_splice($r, $doub, $length, array_fill(0, 8 + $length - $rcount, 0)); } $r = array_map('hexdec', $r); array_unshift($r, 'n*'); $r = call_user_func_array('pack', $r); return $r; } // Define if (!function_exists('inet_pton')) { function inet_pton($address) { return php_compat_inet_pton($address); } } PHP_Compat-1.6.0a3/Compat/Function/ini_get_all.php100777 1750 1750 5314 100777 14766 , Arpad Ray * @link http://php.net/function.ini_get_all * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_ini_get_all($extension = null) { // Sanity check if ($extension !== null && !is_scalar($extension)) { user_error('ini_get_all() expects parameter 1 to be string, ' . gettype($extension) . ' given', E_USER_WARNING); return false; } // Get the location of php.ini ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_clean(); $info = explode("\n", $info); $line = array_values(preg_grep('#php\.ini#', $info)); // Plain vs HTML output if (substr($line[0], 0, 4) === '') { list (, $value) = explode('', $line[0], 2); $inifile = trim(strip_tags($value)); } else { list (, $value) = explode(' => ', $line[0], 2); $inifile = trim($value); } // Check the file actually exists if (!file_exists($inifile)) { user_error('ini_get_all() Unable to find php.ini', E_USER_WARNING); return false; } // Check the file is readable if (!is_readable($inifile)) { user_error('ini_get_all() Unable to open php.ini', E_USER_WARNING); return false; } // Parse the ini if ($extension !== null) { $ini_all = parse_ini_file($inifile, true); // Lowercase extension keys foreach ($ini_all as $key => $value) { $ini_arr[strtolower($key)] = $value; } // Check the extension exists if (isset($ini_arr[$extension])) { $ini = $ini_arr[$extension]; } else { user_error("ini_get_all() Unable to find extension '$extension'", E_USER_WARNING); return false; } } else { $ini = parse_ini_file($inifile); } // Order $ini_lc = array_map('strtolower', array_keys($ini)); array_multisort($ini_lc, SORT_ASC, SORT_STRING, $ini); // Format $info = array(); foreach ($ini as $key => $value) { $info[$key] = array( 'global_value' => $value, 'local_value' => ini_get($key), // No way to know this 'access' => -1 ); } return $info; } // Define if (!function_exists('ini_get_all')) { function ini_get_all($extension = null) { return php_compat_ini_get_all($extension); } } PHP_Compat-1.6.0a3/Compat/Function/is_a.php100777 1750 1750 1512 100777 13427 , Arpad Ray * @link http://php.net/function.is_a * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) (is_subclass_of) */ function php_compat_is_a($object, $class) { if (!is_object($object)) { return false; } if (strtolower(get_class($object)) == strtolower($class)) { return true; } else { return is_subclass_of($object, $class); } } // Define if (!function_exists('is_a')) { function is_a($object, $class) { return php_compat_is_a($object, $class); } } PHP_Compat-1.6.0a3/Compat/Function/is_callable.php100777 1750 1750 3343 100777 14752 , Arpad Ray * @link http://php.net/function.is_callable * @author Gaetano Giunta * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 4.0.6 * @require PHP 4.0.0 (true, false, etc...) * @todo add the 3rd parameter syntax... */ function php_compat_is_callable($var, $syntax_only = false) { if (!is_string($var) && !(is_array($var) && count($var) == 2 && isset($var[0], $var[1]) && is_string($var[1]) && (is_string($var[0]) || is_object($var[0]) ) ) ) { return false; } if ($syntax_only) { return true; } if (is_string($var)) { return function_exists($var); } else if (is_array($var)) { if (is_string($var[0])) { $methods = get_class_methods($var[0]); $method = strtolower($var[1]); if ($methods) { foreach ($methods as $classMethod) { if (strtolower($classMethod) == $method) { return true; } } } } else { return method_exists($var[0], $var[1]); } } return false; } // Define if (!function_exists('is_callable')) { function is_callable($var, $syntax_only) { return php_compat_is_callable($var, $syntax_only); } } PHP_Compat-1.6.0a3/Compat/Function/is_scalar.php100777 1750 1750 1251 100777 14454 , Arpad Ray * @link http://php.net/function.is_scalar * @author Gaetano Giunta * @version $Revision: 269597 $ * @since PHP 4.0.5 * @require PHP 4 (is_bool) */ function php_compat_is_scalar($val) { // Check input return (is_bool($val) || is_int($val) || is_float($val) || is_string($val)); } // Define if (!function_exists('is_scalar')) { function is_scalar($val) { return php_compat_is_scalar($val); } } PHP_Compat-1.6.0a3/Compat/Function/json_decode.php100777 1750 1750 1322 100777 14767 , Arpad Ray , James Wade * @link http://php.net/function.json_decode * @author James Wade * @version $Revision: 1.0 $ * @since 5.3.0 */ //pear install Services_JSON-1.0.1 require_once 'Services/JSON.php'; if (!function_exists('json_decode')){ function json_decode($content, $assoc=false) { $json = $assoc?new Services_JSON(SERVICES_JSON_LOOSE_TYPE):new Services_JSON; return $json->decode($content); } }PHP_Compat-1.6.0a3/Compat/Function/json_encode.php100777 1750 1750 1220 100777 14776 , Arpad Ray , James Wade * @link http://php.net/function.json_encode * @author James Wade * @version $Revision: 1.0 $ * @since 5.3.0 */ //pear install Services_JSON-1.0.1 require_once 'Services/JSON.php'; if (!function_exists('json_encode')){ function json_encode($content){ $json = new Services_JSON; return $json->encode($content); } }PHP_Compat-1.6.0a3/Compat/Function/md5_file.php100777 1750 1750 3342 100777 14203 , Arpad Ray * @link http://php.net/md5_file * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_md5_file($filename, $raw_output = false) { // Sanity check if (!is_scalar($filename)) { user_error('md5_file() expects parameter 1 to be string, ' . gettype($filename) . ' given', E_USER_WARNING); return; } if (!is_scalar($raw_output)) { user_error('md5_file() expects parameter 2 to be bool, ' . gettype($raw_output) . ' given', E_USER_WARNING); return; } if (!file_exists($filename)) { user_error('md5_file() Unable to open file', E_USER_WARNING); return false; } // Read the file if (false === $fh = fopen($filename, 'rb')) { user_error('md5_file() failed to open stream: No such file or directory', E_USER_WARNING); return false; } clearstatcache(); if ($fsize = @filesize($filename)) { $data = fread($fh, $fsize); } else { $data = ''; while (!feof($fh)) { $data .= fread($fh, 8192); } } fclose($fh); // Return $data = md5($data); if ($raw_output === true) { $data = pack('H*', $data); } return $data; } // Define if (!function_exists('md5_file')) { function md5_file($filename, $raw_output = false) { return php_compat_md5_file($filename, $raw_output); } } PHP_Compat-1.6.0a3/Compat/Function/mhash.php100777 1750 1750 4120 100777 13612 , Arpad Ray * @link http://php.net/function.mhash * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.1.0 * @require PHP 4.0.0 (user_error) */ function php_compat_mhash($hashtype, $data, $key = '') { switch ($hashtype) { case MHASH_MD5: $key = str_pad((strlen($key) > 64 ? pack("H*", md5($key)) : $key), 64, chr(0x00)); $k_opad = $key ^ (str_pad('', 64, chr(0x5c))); $k_ipad = $key ^ (str_pad('', 64, chr(0x36))); return pack("H*", md5($k_opad . pack("H*", md5($k_ipad . $data)))); default: return false; break; } } // Define if (!function_exists('mhash')) { function mhash($hashtype, $data, $key = '') { return php_compat_mhash($hashtype, $data, $key = ''); } } PHP_Compat-1.6.0a3/Compat/Function/microtime.php100777 1750 1750 2047 100777 14510 , Arpad Ray * @link http://php.net/function.microtime * @author Aidan Lister * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.0.0 (Added optional get_as_float parameter) * @require PHP 4.0.0 (user_error) */ function php_compat_microtime($get_as_float = false) { if (!function_exists('gettimeofday')) { $time = time(); return $get_as_float ? ($time * 1000000.0) : '0.00000000 ' . $time; } $gtod = gettimeofday(); $usec = $gtod['usec'] / 1000000.0; return $get_as_float ? (float) ($gtod['sec'] + $usec) : (sprintf('%.8f ', $usec) . $gtod['sec']); } // Define if (!function_exists('microtime')) { function microtime($get_as_float = false) { return php_compat_microtime($get_as_float); } } PHP_Compat-1.6.0a3/Compat/Function/mime_content_type.php100777 1750 1750 2460 100777 16241 , Arpad Ray * @link http://php.net/function.mime_content_type * @version $Revision: 269597 $ * @author Ian Eure * @since PHP 4.3.0 * @require PHP 4.0.3 (escapeshellarg) */ function php_compat_mime_content_type($filename) { // Sanity check if (!file_exists($filename)) { return false; } $filename = escapeshellarg($filename); $out = `file -iL $filename 2>/dev/null`; if (empty($out)) { return 'application/octet-stream'; } // Strip off filename $t = substr($out, strpos($out, ':') + 2); if (strpos($t, ';') !== false) { // Strip MIME parameters $t = substr($t, 0, strpos($t, ';')); } // Strip any remaining whitespace return trim($t); } // Define if (!function_exists('mime_content_type')) { function mime_content_type($filename) { return php_compat_mime_content_type($filename); } } PHP_Compat-1.6.0a3/Compat/Function/mkdir.php100777 1750 1750 3245 100777 13627 , Arpad Ray * @link http://php.net/function.mkdir * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.0.0 (Added optional recursive and context parameters) * @require PHP 4.0.0 (user_error) */ function php_compat_mkdir($pathname, $mode = 0777, $recursive = true, $context = null) { if (version_compare(PHP_VERSION, '5.0.0', 'gte')) { // revert to native function return (func_num_args() > 3) ? mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive); } if (!strlen($pathname)) { user_error('No such file or directory', E_USER_WARNING); return false; } if (is_dir($pathname)) { if (func_num_args() == 5) { // recursive call return true; } user_error('File exists', E_USER_WARNING); return false; } $parent_is_dir = php_compat_mkdir(dirname($pathname), $mode, $recursive, null, 0); if ($parent_is_dir) { return mkdir($pathname, $mode); } user_error('No such file or directory', E_USER_WARNING); return false; } // Define if (!function_exists('mkdir')) { function mkdir($pathname, $mode, $recursive = false, $context = null) { return php_compat_mkdir($pathname, $mode, $recursive, $context); } } ?>PHP_Compat-1.6.0a3/Compat/Function/ob_clean.php100777 1750 1750 1447 100777 14265 , Arpad Ray * @link http://php.net/function.ob_clean * @author Aidan Lister * @author Thiemo Mättig (http://maettig.com/) * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_ob_clean() { if (@ob_end_clean()) { return ob_start(); } user_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE); return false; } // Define if (!function_exists('ob_clean')) { function ob_clean() { return php_compat_ob_clean(); } } PHP_Compat-1.6.0a3/Compat/Function/ob_flush.php100777 1750 1750 1444 100777 14321 , Arpad Ray * @link http://php.net/function.ob_flush * @author Aidan Lister * @author Thiemo Mättig (http://maettig.com/) * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_ob_flush() { if (@ob_end_flush()) { return ob_start(); } user_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE); return false; } // Define if (!function_exists('ob_flush')) { function ob_flush() { return php_compat_ob_flush(); } } PHP_Compat-1.6.0a3/Compat/Function/ob_get_clean.php100777 1750 1750 1413 100777 15115 , Arpad Ray * @link http://php.net/function.ob_get_clean * @author Aidan Lister * @author Thiemo Mättig (http://maettig.com/) * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_ob_get_clean() { $contents = ob_get_contents(); if ($contents !== false) { ob_end_clean(); } return $contents; } // Define if (!function_exists('ob_get_clean')) { function ob_get_clean() { return php_compat_ob_get_clean(); } } PHP_Compat-1.6.0a3/Compat/Function/ob_get_flush.php100777 1750 1750 1413 100777 15154 , Arpad Ray * @link http://php.net/function.ob_get_flush * @author Aidan Lister * @author Thiemo Mättig (http://maettig.com/) * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_ob_get_flush() { $contents = ob_get_contents(); if ($contents !== false) { ob_end_flush(); } return $contents; } // Define if (!function_exists('ob_get_flush')) { function ob_get_flush() { return php_compat_ob_get_flush(); } } PHP_Compat-1.6.0a3/Compat/Function/pathinfo.php100777 1750 1750 2641 100777 14330 * @copyright 2009 James Wade * @license LGPL - http://www.gnu.org/licenses/lgpl.html * @version $CVS: 1.0 $ * @link http://php.net/function.pathinfo * @since PHP 5.2.0 * @require PHP 4.0.0 (user_error) */ if (!defined('PATHINFO_FILENAME')) { define('PATHINFO_FILENAME', 8); } /** * Returns information about a file path * * @param string $path The path being checked. * @param int $options See @link * * @return array */ function php_compat_pathinfo($path = false, $options = false) { // Sanity check if (!is_scalar($path)) { user_error('pathinfo() expects parameter 1 to be string, ' . gettype($path) . ' given', E_USER_WARNING); return; } if (version_compare(PHP_VERSION, '5.2.0', 'ge')) { return pathinfo($path, $options); } if ($options & PATHINFO_FILENAME) { //bug #15688 if (strpos($path, '.') !== false) { $filename = substr($path, 0, strrpos($path, '.')); } if ($options === PATHINFO_FILENAME) { return $filename; } $pathinfo = pathinfo($path, $options); $pathinfo['filename'] = $filename; return $pathinfo; } return pathinfo($path, $options); } PHP_Compat-1.6.0a3/Compat/Function/pg_affected_rows.php100777 1750 1750 1233 100777 16015 , Arpad Ray * @link http://php.net/function.pg_affectd_rows * @author Ian Eure * @version $Revision@ * @since PHP 4.2.0 * @require PHP 4.0.0 */ function php_compat_pg_affected_rows($resource) { return pg_cmdtuples($resource); } // Define if (!function_exists('pg_affected_rows')) { function pg_affected_rows($resource) { return php_compat_pg_affected_rows($resource); } } PHP_Compat-1.6.0a3/Compat/Function/pg_escape_bytea.php100777 1750 1750 1347 100777 15634 , Arpad Ray * @link http://php.net/function.pg_escape_bytea * @author Ian Eure * @version $Revision@ * @since PHP 4.2.0 * @require PHP 4.0.0 */ function php_compat_pg_escape_bytea($data) { return str_replace( array(chr(92), chr(0), chr(39)), array('\\\134', '\\\000', '\\\047'), $data); } // Define if (!function_exists('pg_escape_bytea')) { function pg_escape_bytea($data) { return php_compat_pg_escape_bytea($data); } } PHP_Compat-1.6.0a3/Compat/Function/pg_unescape_bytea.php100777 1750 1750 1324 100777 16172 , Arpad Ray * @link http://php.net/function.pg_unescape_bytea * @author Ian Eure * @version $Revision@ * @since PHP 4.2.0 * @require PHP 4.0.0 */ function php_compat_pg_unescape_bytea(&$data) { return str_replace( array('$', '"'), array('\\$', '\\"'), $data); } // Define if (!function_exists('pg_unescape_bytea')) { function pg_unescape_bytea(&$data) { return php_compat_pg_unescape_bytea($data); } } PHP_Compat-1.6.0a3/Compat/Function/php_ini_loaded_file.php100777 1750 1750 2340 100777 16451 , Arpad Ray * @link http://php.net/php_ini_loaded_file * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.0 (ob_start) */ function php_compat_php_ini_loaded_file() { // Get the location of php.ini ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_clean(); $info = explode("\n", $info); $line = array_values(preg_grep('#php\.ini#', $info)); // Plain vs HTML output if (substr($line[0], 0, 4) === '') { list (, $value) = explode('', $line[0], 2); $inifile = trim(strip_tags($value)); } else { list (, $value) = explode(' => ', $line[0], 2); $inifile = trim($value); } // Check the file actually exists if (!file_exists($inifile)) { return false; } } // Define if (!function_exists('php_ini_loaded_file')) { function php_ini_loaded_file() { return php_compat_php_ini_loaded_file(); } } PHP_Compat-1.6.0a3/Compat/Function/php_strip_whitespace.php100777 1750 1750 4132 100777 16741 , Arpad Ray * @link http://php.net/function.php_strip_whitespace * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) + Tokenizer extension */ function php_compat_php_strip_whitespace($file) { // Sanity check if (!is_scalar($file)) { user_error('php_strip_whitespace() expects parameter 1 to be string, ' . gettype($file) . ' given', E_USER_WARNING); return; } // Load file / tokens $source = implode('', file($file)); $tokens = token_get_all($source); // Init $source = ''; $was_ws = false; // Process foreach ($tokens as $token) { if (is_string($token)) { // Single character tokens $source .= $token; } else { list($id, $text) = $token; switch ($id) { // Skip all comments case T_COMMENT: case T_ML_COMMENT: case T_DOC_COMMENT: break; // Remove whitespace case T_WHITESPACE: // We don't want more than one whitespace in a row replaced if ($was_ws !== true) { $source .= ' '; } $was_ws = true; break; default: $was_ws = false; $source .= $text; break; } } } return $source; } // Define if (!function_exists('php_strip_whitespace')) { function php_strip_whitespace($file) { return php_compat_php_strip_whitespace($file); } } PHP_Compat-1.6.0a3/Compat/Function/property_exists.php100777 1750 1750 3402 100777 15777 , Arpad Ray * @link http://php.net/property_exists * @author Christian Stadler * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.0 (user_error) */ function php_compat_property_exists($class, $property) { if (!is_string($property)) { user_error('property_exists() expects parameter 2 to be a string, ' . gettype($property) . ' given', E_USER_WARNING); return false; } if (is_object($class) || is_string($class)) { if (is_string($class)) { if (!class_exists($class)) { return false; } $vars = get_class_vars($class); } else { $vars = get_object_vars($class); } // Bail out early if get_class_vars or get_object_vars didnt work // or returned an empty array if (!is_array($vars) || count($vars) <= 0) { return false; } $property = strtolower($property); foreach (array_keys($vars) AS $varname) { if (strtolower($varname) == $property) { return true; } } return false; } user_error('property_exists() expects parameter 1 to be a string or ' . 'an object, ' . gettype($class) . ' given', E_USER_WARNING); return false; } // Define if (!function_exists('property_exists')) { function property_exists($class, $property) { return php_compat_property_exists($class, $property); } } PHP_Compat-1.6.0a3/Compat/Function/range.php100777 1750 1750 2542 100777 13614 , Arpad Ray * @link http://php.net/function.range * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5.0.0 (The optional step parameter was added in 5.0.0) * @require PHP 4.0.0 (user_error) */ function php_compat_range($low, $high, $step = 1) { $arr = array(); $step = (abs($step) > 0) ? abs($step) : 1; $sign = ($low <= $high) ? 1 : -1; // Numeric sequence if (is_numeric($low) && is_numeric($high)) { for ($i = (float)$low; $i*$sign <= $high*$sign; $i += $step*$sign) $arr[] = $i; // Character sequence } else { if (is_numeric($low)) { return $this->range($low, 0, $step); } if (is_numeric($high)) { return $this->range(0, $high, $step); } $low = ord($low); $high = ord($high); for ($i = $low; $i * $sign <= $high * $sign; $i += $step * $sign) { $arr[] = chr($i); } } return $arr; } // Define if (!function_exists('range')) { function range($low, $high, $step = 1) { return php_compat_range($low, $high, $step); } } PHP_Compat-1.6.0a3/Compat/Function/restore_include_path.php100777 1750 1750 1223 100777 16715 , Arpad Ray * @link http://php.net/function.restore_include_path * @author Stephan Schmidt * @version $Revision: 269597 $ * @since PHP 4.3.0 */ function php_compat_restore_include_path() { return ini_restore('include_path'); } // Define if (!function_exists('restore_include_path')) { function restore_include_path() { return php_compat_restore_include_path(); } } PHP_Compat-1.6.0a3/Compat/Function/scandir.php100777 1750 1750 2735 100777 14147 , Arpad Ray * @link http://php.net/function.scandir * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_scandir($directory, $sorting_order = 0) { if (!is_string($directory)) { user_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING); return; } if (!is_int($sorting_order) && !is_bool($sorting_order)) { user_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING); return; } if (!is_dir($directory) || (false === $fh = @opendir($directory))) { user_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; } // Define if (!function_exists('scandir')) { function scandir($directory, $sorting_order = 0) { return php_compat_scandir($directory, $sorting_order = 0); } } PHP_Compat-1.6.0a3/Compat/Function/setcookie.php100777 1750 1750 2053 100777 14502 , Arpad Ray * @link http://php.net/function.setcookie * @author Stefan Neufeind * @version $Revision: 269597 $ * @since PHP 5.2 (Added optional httponly parameter) * @require PHP 3 (setcookie) */ function php_compat_setcookie($name, $value, $expire, $path, $domain, $secure, $httponly) { // Following the idea on Matt Mecham's blog // http://blog.mattmecham.com/archives/2006/09/http_only_cookies_without_php.html $domain === ($httponly === true) ? $domain . '; HttpOnly' : $domain; setcookie($name, $value, $expire, $path, $domain, $secure); } // Define if (!function_exists('setcookie')) { function setcookie($name, $value, $expire, $path, $domain, $secure, $httponly) { return php_compat_setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); } }PHP_Compat-1.6.0a3/Compat/Function/setrawcookie.php100777 1750 1750 2322 100777 15213 , Arpad Ray * @link http://php.net/function.setrawcookie * @author Stephan Schmidt * @version $Revision: 279662 $ * @since PHP 5.2.0 (Added optional httponly parameter) * @require PHP 3 (setcookie) */ function php_compat_setrawcookie($name, $value, $expire=0, $path=false, $domain=false, $secure=false, $httponly=false) { // Following the idea on Matt Mecham's blog // http://blog.mattmecham.com/archives/2006/09/http_only_cookies_without_php.html $domain = ($httponly === true) ? $domain . '; HttpOnly' : $domain; // This should probably set a cookie using header() manually so we can avoid escaping setcookie($name, $value, $expire, $path, $domain, $secure); } // Define if (!function_exists('setrawcookie')) { function setrawcookie($name, $value, $expire=0, $path=false, $domain=false, $secure=false, $httponly=false) { return php_compat_setrawcookie($name, $value, $expire, $path, $domain, $secure, $httponly); } } PHP_Compat-1.6.0a3/Compat/Function/set_include_path.php100777 1750 1750 1275 100777 16034 , Arpad Ray * @link http://php.net/function.set_include_path * @author Stephan Schmidt * @version $Revision: 269597 $ * @since PHP 4.3.0 */ function php_compat_set_include_path($new_include_path) { return ini_set('include_path', $new_include_path); } // Define if (!function_exists('set_include_path')) { function set_include_path($new_include_path) { return php_compat_set_include_path($new_include_path); } } PHP_Compat-1.6.0a3/Compat/Function/sinh.php100777 1750 1750 1066 100777 13461 , Arpad Ray * @link http://php.net/function.sinh * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 3.0.0 */ function php_compat_sinh($n) { return 0.5 * (exp($n) - exp(-$n)); } if (!function_exists('sinh')) { function sinh($n) { return php_compat_sinh($n); } } PHP_Compat-1.6.0a3/Compat/Function/stripos.php100777 1750 1750 3255 100777 14225 , Arpad Ray * @link http://php.net/function.stripos * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_stripos($haystack, $needle, $offset = null) { if (!is_scalar($haystack)) { user_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING); return false; } if (!is_scalar($needle)) { user_error('stripos() needle is not a string or an integer.', E_USER_WARNING); return false; } if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) { user_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; } // Define if (!function_exists('stripos')) { function stripos($haystack, $needle, $offset = null) { return php_compat_stripos($haystack, $needle, $offset); } } PHP_Compat-1.6.0a3/Compat/Function/strpbrk.php100777 1750 1750 2507 100777 14210 , Arpad Ray * @link http://php.net/function.strpbrk * @author Stephan Schmidt * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_strpbrk($haystack, $char_list) { if (!is_scalar($haystack)) { user_error('strpbrk() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING); return false; } if (!is_scalar($char_list)) { user_error('strpbrk() expects parameter 2 to be string, ' . gettype($char_list) . ' given', E_USER_WARNING); return false; } $haystack = (string) $haystack; $char_list = (string) $char_list; $len = strlen($haystack); for ($i = 0; $i < $len; $i++) { $char = substr($haystack, $i, 1); if (strpos($char_list, $char) === false) { continue; } return substr($haystack, $i); } return false; } // Define if (!function_exists('strpbrk')) { function strpbrk($haystack, $char_list) { return php_compat_strpbrk($haystack, $char_list); } } PHP_Compat-1.6.0a3/Compat/Function/strripos.php100777 1750 1750 3701 100777 14403 , Arpad Ray * @link http://php.net/function.strripos * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_strripos($haystack, $needle, $offset = null) { // Sanity check if (!is_scalar($haystack)) { user_error('strripos() expects parameter 1 to be scalar, ' . gettype($haystack) . ' given', E_USER_WARNING); return false; } if (!is_scalar($needle)) { user_error('strripos() expects parameter 2 to be scalar, ' . gettype($needle) . ' given', E_USER_WARNING); return false; } if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) { user_error('strripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); return false; } // Initialise variables $needle = strtolower($needle); $haystack = strtolower($haystack); $needle_fc = $needle{0}; $needle_len = strlen($needle); $haystack_len = strlen($haystack); $offset = (int) $offset; $leftlimit = ($offset >= 0) ? $offset : 0; $p = ($offset >= 0) ? $haystack_len : $haystack_len + $offset + 1; // Reverse iterate haystack while (--$p >= $leftlimit) { if ($needle_fc === $haystack{$p} && substr($haystack, $p, $needle_len) === $needle) { return $p; } } return false; } // Define if (!function_exists('strripos')) { function strripos($haystack, $needle, $offset = null) { return php_compat_strripos($haystack, $needle, $offset); } } PHP_Compat-1.6.0a3/Compat/Function/strstr.php100777 1750 1750 1244 100777 14057 , Arpad Ray , James Wade * @link http://php.net/function.strstr * @author James Wade * @version $Revision: 1.0 $ * @since PHP 5.3.0 * @require PHP 4.0.0 (strrev) */ function php_compat_strstr($haystack, $needle, $before_needle = false) { if ($before_needle) { return strrev(array_pop(explode($n,strrev($h)))); } else { return strstr($haystack, $needle); } } PHP_Compat-1.6.0a3/Compat/Function/str_getcsv.php100777 1750 1750 3235 100777 14703 , Arpad Ray * @link http://php.net/function.str_getcsv * @author HM2K * @version $CVS: 1.0 $ * @since 5.3.0 * @require PHP 4.0.0 (fgetcsv) */ function php_compat_str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\') { $fh = tmpfile(); fwrite($fh, $input); $data = array(); while (($row = php_compat_fgetcsv_wrap($fh, 1000, $delimiter, $enclosure, $escape)) !== FALSE) { $data[] = $row; } fclose($fh); return empty($data) ? false : $data; } /** * Wraps fgetcsv() for the correct PHP version * * @link http://php.net/function.fgetcsv */ function php_compat_fgetcsv_wrap($fh, $length, $delimiter = ',', $enclosure = '"', $escape = '\\') { // The escape parameter was added if (version_compare(PHP_VERSION, '5.3.0', '>=')) { return fgetcsv($fh, $length, $delimiter, $enclosure, $escape); } // The enclosure parameter was added elseif (version_compare(PHP_VERSION, '4.3.0', '>=')) { return fgetcsv($fh, $length, $delimiter, $enclosure); } else { return fgetcsv($fh, $length, $delimiter); } } if (!function_exists('str_getcsv')) { /** * Backwards compatbility for str_getcsv() * * @link http://php.net/function.fgetcsv */ function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\') { return php_compat_str_getcsv($input, $delimiter, $enclosure, $escape); } } PHP_Compat-1.6.0a3/Compat/Function/str_ireplace.php100777 1750 1750 3624 100777 15176 , Arpad Ray * @link http://php.net/function.str_ireplace * @author Aidan Lister * @author Arpad Ray * @version $Revision: 274076 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_str_ireplace($search, $replace, $subject) { // Sanity check if (is_string($search) && is_array($replace)) { user_error('Array to string conversion', E_USER_NOTICE); $replace = (string) $replace; } // If search isn't an array, make it one $search = (array) $search; $length_search = count($search); // build the replace array $replace = is_array($replace) ? array_pad($replace, $length_search, '') : array_pad(array(), $length_search, $replace); // If subject is not an array, make it one $was_string = false; if (is_string($subject)) { $was_string = true; $subject = array ($subject); } // Prepare the search array foreach ($search as $search_key => $search_value) { $search[$search_key] = '/' . preg_quote($search_value, '/') . '/i'; } // Prepare the replace array (escape backreferences) $replace = str_replace(array('\\', '$'), array('\\\\', '\$'), $replace); $result = preg_replace($search, $replace, $subject); return $was_string ? $result[0] : $result; } // Define if (!function_exists('str_ireplace')) { function str_ireplace($search, $replace, $subject) { return php_compat_str_ireplace($search, $replace, $subject); } } PHP_Compat-1.6.0a3/Compat/Function/str_rot13.php100777 1750 1750 1413 100777 14354 , Arpad Ray * @link http://php.net/function.str_rot13 * @author Alan Morey * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.0.0 */ function php_compat_str_rot13($str) { $from = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $to = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'; return strtr($str, $from, $to); } // Define if (!function_exists('str_rot13')) { function str_rot13($str) { return php_compat_str_rot13($str); } } PHP_Compat-1.6.0a3/Compat/Function/str_shuffle.php100777 1750 1750 1607 100777 15045 , Arpad Ray * @link http://php.net/function.str_shuffle * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_str_shuffle($str) { // Cast $str = (string) $str; // Swap random character from [0..$i] to position [$i]. for ($i = strlen($str) - 1; $i >= 0; $i--) { $j = mt_rand(0, $i); $tmp = $str[$i]; $str[$i] = $str[$j]; $str[$j] = $tmp; } return $str; } // Define if (!function_exists('str_shuffle')) { function str_shuffle($str) { return php_compat_str_shuffle($str); } } PHP_Compat-1.6.0a3/Compat/Function/str_split.php100777 1750 1750 3206 100777 14541 , Arpad Ray * @link http://php.net/function.str_split * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_str_split($string, $split_length = 1) { if (!is_scalar($split_length)) { user_error('str_split() expects parameter 2 to be long, ' . gettype($split_length) . ' given', E_USER_WARNING); return false; } $split_length = (int) $split_length; if ($split_length < 1) { user_error('str_split() The length of each segment must be greater than zero', E_USER_WARNING); return false; } // Select split method if ($split_length < 65536) { // Faster, but only works for less than 2^16 preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches); return $matches[0]; } else { // Required due to preg limitations $arr = array(); $idx = 0; $pos = 0; $len = strlen($string); while ($len > 0) { $blk = ($len < $split_length) ? $len : $split_length; $arr[$idx++] = substr($string, $pos, $blk); $pos += $blk; $len -= $blk; } return $arr; } } // Define if (!function_exists('str_split')) { function str_split($string, $split_length = 1) { return php_compat_str_split($string, $split_length); } } PHP_Compat-1.6.0a3/Compat/Function/str_word_count.php100777 1750 1750 3051 100777 15567 , Arpad Ray * @link http://php.net/function.str_word_count * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.3.0 * @require PHP 4.0.0 (user_error) */ function php_compat_str_word_count($string, $format = null) { if ($format !== 1 && $format !== 2 && $format !== null) { user_error('str_word_count() The specified format parameter, "' . $format . '" is invalid', E_USER_WARNING); return false; } $word_string = preg_replace('/[0-9]+/', '', $string); $word_array = preg_split('/[^A-Za-z0-9_\']+/', $word_string, -1, PREG_SPLIT_NO_EMPTY); switch ($format) { case null: $result = count($word_array); break; case 1: $result = $word_array; break; case 2: $lastmatch = 0; $word_assoc = array(); foreach ($word_array as $word) { $word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word; $lastmatch += strlen($word); } $result = $word_assoc; break; } return $result; } // Define if (!function_exists('str_word_count')) { function str_word_count($string, $format = null) { return php_compat_str_word_count($string, $format); } } PHP_Compat-1.6.0a3/Compat/Function/substr_compare.php100777 1750 1750 3604 100777 15550 , Arpad Ray * @link http://php.net/function.substr_compare * @author Tom Buskens * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (user_error) */ function php_compat_substr_compare($main_str, $str, $offset, $length = null, $case_insensitive = false) { if (!is_string($main_str)) { user_error('substr_compare() expects parameter 1 to be string, ' . gettype($main_str) . ' given', E_USER_WARNING); return; } if (!is_string($str)) { user_error('substr_compare() expects parameter 2 to be string, ' . gettype($str) . ' given', E_USER_WARNING); return; } if (!is_int($offset)) { user_error('substr_compare() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); return; } if (is_null($length)) { $length = strlen($main_str) - $offset; } elseif ($offset >= strlen($main_str)) { user_error('substr_compare() The start position cannot exceed initial string length', E_USER_WARNING); return false; } $main_str = substr($main_str, $offset, $length); $str = substr($str, 0, strlen($main_str)); if ($case_insensitive === false) { return strcmp($main_str, $str); } else { return strcasecmp($main_str, $str); } } // Define if (!function_exists('substr_compare')) { function substr_compare($main_str, $str, $offset, $length = null, $case_insensitive = false) { return php_compat_substr_compare($main_str, $str, $offset, $length, $case_insensitive); } } PHP_Compat-1.6.0a3/Compat/Function/sys_get_temp_dir.php100777 1750 1750 1714 100777 16060 , Arpad Ray * @link http://php.net/function.sys_get_temp_dir * @author James Wade * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 4.0.0 (realpath) */ function php_compat_sys_get_temp_dir() { if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } $tempfile = tempnam(uniqid(rand(),TRUE),''); if (file_exists($tempfile)) { unlink($tempfile); return realpath(dirname($tempfile)); } } // Define if (!function_exists('sys_get_temp_dir')) { function sys_get_temp_dir() { return php_compat_sys_get_temp_dir(); } } PHP_Compat-1.6.0a3/Compat/Function/tanh.php100777 1750 1750 1101 100777 13440 , Arpad Ray * @link http://php.net/function.tanh * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5 * @require PHP 3.0.0 */ function php_compat_tanh($n) { return (exp(2 * $n) - 1) / (exp(2 * $n) + 1); } if (!function_exists('tanh')) { function tanh($n) { return php_compat_tanh($n); } } PHP_Compat-1.6.0a3/Compat/Function/time_sleep_until.php100777 1750 1750 1653 100777 16063 , Arpad Ray * @link http://php.net/time_sleep_until * @author Arpad Ray * @version $Revision: 269597 $ * @since PHP 5.1.0 * @require PHP 4.0.1 (trigger_error) */ function php_compat_time_sleep_until($timestamp) { list($usec, $sec) = explode(' ', microtime()); $now = $sec + $usec; if ($timestamp <= $now) { user_error('Specified timestamp is in the past', E_USER_WARNING); return false; } $diff = $timestamp - $now; usleep($diff * 1000000); return true; } // Define if (!function_exists('time_sleep_until')) { function time_sleep_until($timestamp) { return php_compat_time_sleep_until($timestamp); } } PHP_Compat-1.6.0a3/Compat/Function/var_export.php100777 1750 1750 7074 100777 14716 , Arpad Ray * @link http://php.net/function.var_export * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ function php_compat_var_export($var, $return = false, $level = 0, $inObject = false) { // Init $indent = ' '; $doublearrow = ' => '; $lineend = ",\n"; $stringdelim = '\''; $newline = "\n"; $find = array(null, '\\', '\''); $replace = array('NULL', '\\\\', '\\\''); $out = ''; // Indent $level++; for ($i = 1, $previndent = ''; $i < $level; $i++) { $previndent .= $indent; } $varType = gettype($var); // Handle object indentation oddity if ($inObject && $varType != 'object') { $previndent = substr($previndent, 0, -1); } // Handle each type switch ($varType) { // Array case 'array': if ($inObject) { $out .= $newline . $previndent; } $out .= 'array (' . $newline; foreach ($var as $key => $value) { // Key if (is_string($key)) { // Make key safe $key = str_replace($find, $replace, $key); $key = $stringdelim . $key . $stringdelim; } // Value if (is_array($value)) { $export = php_compat_var_export($value, true, $level); $value = $newline . $previndent . $indent . $export; } else { $value = php_compat_var_export($value, true, $level); } // Piece line together $out .= $previndent . $indent . $key . $doublearrow . $value . $lineend; } // End string $out .= $previndent . ')'; break; // String case 'string': // Make the string safe for ($i = 0, $c = count($find); $i < $c; $i++) { $var = str_replace($find[$i], $replace[$i], $var); } $out = $stringdelim . $var . $stringdelim; break; // Number case 'integer': case 'double': $out = (string) $var; break; // Boolean case 'boolean': $out = $var ? 'true' : 'false'; break; // NULLs case 'NULL': case 'resource': $out = 'NULL'; break; // Objects case 'object': // Start the object export $out = $newline . $previndent; $out .= get_class($var) . '::__set_state(array(' . $newline; // Export the object vars foreach(get_object_vars($var) as $key => $value) { $out .= $previndent . $indent . ' ' . $stringdelim . $key . $stringdelim . $doublearrow; $out .= php_compat_var_export($value, true, $level, true) . $lineend; } $out .= $previndent . '))'; break; } // Method of output if ($return === true) { return $out; } else { echo $out; } } // Define if (!function_exists('var_export')) { function var_export($var, $return = false) { return php_compat_var_export($var, $return); } } PHP_Compat-1.6.0a3/Compat/Function/version_compare.php100777 1750 1750 11322 100777 15727 , Arpad Ray * @link http://php.net/function.version_compare * @author Philippe Jausions * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.1.0 * @require PHP 4.0.5 (user_error) */ function php_compat_version_compare($version1, $version2, $operator = '<') { // Check input if (!is_scalar($version1)) { user_error('version_compare() expects parameter 1 to be string, ' . gettype($version1) . ' given', E_USER_WARNING); return; } if (!is_scalar($version2)) { user_error('version_compare() expects parameter 2 to be string, ' . gettype($version2) . ' given', E_USER_WARNING); return; } if (!is_scalar($operator)) { user_error('version_compare() expects parameter 3 to be string, ' . gettype($operator) . ' given', E_USER_WARNING); return; } // 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)) {} // Release state order // '#' stands for any number $versions = array( 'dev' => 0, 'alpha' => 1, 'a' => 1, 'beta' => 2, 'b' => 2, 'RC' => 3, '#' => 4, 'p' => 5, 'pl' => 5); // 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; } $i1 = $v1[$i]; $i2 = $v2[$i]; if (is_numeric($i1) && is_numeric($i2)) { $compare = ($i1 < $i2) ? -1 : 1; break; } // We use the position of '#' in the versions list // for numbers... (so take care of # in original string) if ($i1 == '#') { $i1 = ''; } elseif (is_numeric($i1)) { $i1 = '#'; } if ($i2 == '#') { $i2 = ''; } elseif (is_numeric($i2)) { $i2 = '#'; } if (isset($versions[$i1]) && isset($versions[$i2])) { $compare = ($versions[$i1] < $versions[$i2]) ? -1 : 1; } elseif (isset($versions[$i1])) { $compare = 1; } elseif (isset($versions[$i2])) { $compare = -1; } else { $compare = 0; } 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; } } return $compare; } // Define if (!function_exists('version_compare')) { function version_compare($version1, $version2, $operator = '<') { return php_compat_version_compare($version1, $version2, $operator); } } PHP_Compat-1.6.0a3/Compat/Function/vprintf.php100777 1750 1750 1500 100777 14201 , Arpad Ray * @link http://php.net/function.vprintf * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.1.0 * @require PHP 4.0.4 (call_user_func_array) */ function php_compat_vprintf($format, $args) { if (count($args) < 2) { user_error('vprintf() Too few arguments', E_USER_WARNING); return; } array_unshift($args, $format); return call_user_func_array('printf', $args); } // Define if (!function_exists('vprintf')) { function vprintf($format, $args) { return php_compat_vprintf($format, $args); } } PHP_Compat-1.6.0a3/Compat/Function/vsprintf.php100777 1750 1750 1511 100777 14366 , Arpad Ray * @link http://php.net/function.vsprintf * @author Aidan Lister * @version $Revision: 269597 $ * @since PHP 4.1.0 * @require PHP 4.0.4 (call_user_func_array) */ function php_compat_vsprintf($format, $args) { if (count($args) < 2) { user_error('vsprintf() Too few arguments', E_USER_WARNING); return; } array_unshift($args, $format); return call_user_func_array('sprintf', $args); } // Define if (!function_exists('vsprintf')) { function vsprintf($format, $args) { return php_compat_vsprintf($format, $args); } } PHP_Compat-1.6.0a3/tests/loadconstant.phpt100777 1750 1750 1016 100777 13522 --TEST-- Method -- PHP_Compat::loadConstant --FILE-- $result) { echo $comp . ': '; echo ($result === false) ? 'false' : 'true', "\n"; } ?> --EXPECT-- false an-invalid: false also-invalid: false more-invalid: false E_STRICT: truePHP_Compat-1.6.0a3/tests/loadfunction.phpt100777 1750 1750 763 100777 13506 --TEST-- Method -- PHP_Compat::loadFunction --FILE-- $result) { echo $comp . ': '; echo ($result === false) ? 'false' : 'true', "\n"; } ?> --EXPECT-- false an-invalid: false also-invalid: false more-invalid: falsePHP_Compat-1.6.0a3/tests/loadversion.phpt100777 1750 1750 547 100777 13346 --TEST-- Method -- PHP_Compat::loadVersion --FILE-- --EXPECT-- bool(true) bool(true) bool(true)PHP_Compat-1.6.0a3/tests/constant/date.phpt100777 1750 1750 1756 100777 13612 --TEST-- Constant -- DATE --FILE-- --EXPECT-- pass pass pass pass pass pass pass pass pass passPHP_Compat-1.6.0a3/tests/constant/directory_separator.phpt100777 1750 1750 513 100777 16727 --TEST-- Constant -- DIRECTORY_SEPARATOR --SKIPIF-- --FILE-- --EXPECT-- truePHP_Compat-1.6.0a3/tests/constant/e_strict.phpt100777 1750 1750 324 100777 14457 --TEST-- Constant -- E_STRICT --SKIPIF-- --FILE-- --EXPECT-- 2048PHP_Compat-1.6.0a3/tests/constant/file.phpt100777 1750 1750 574 100777 13571 --TEST-- Constant -- File System Constants --SKIPIF-- --FILE-- --EXPECT-- 1 2 4 8 16PHP_Compat-1.6.0a3/tests/constant/path_separator.phpt100777 1750 1750 461 100777 15661 --TEST-- Constant -- PATH_SEPARATOR --SKIPIF-- --FILE-- --EXPECT-- truePHP_Compat-1.6.0a3/tests/constant/php_eol.phpt100777 1750 1750 457 100777 14300 --TEST-- Constant -- PHP_EOL --SKIPIF-- --FILE-- --EXPECT-- truePHP_Compat-1.6.0a3/tests/constant/std.phpt100777 1750 1750 544 100777 13441 --TEST-- Constant -- CLI Constants --SKIPIF-- --FILE-- --EXPECT-- true true truePHP_Compat-1.6.0a3/tests/constant/t.phpt100777 1750 1750 1152 100777 13126 --TEST-- Constant -- Tokenizer constants --FILE-- --EXPECT-- true true true true true true true true true true true true true truePHP_Compat-1.6.0a3/tests/constant/upload_err.phpt100777 1750 1750 460 100777 15000 --TEST-- Constant -- Upload error constants --FILE-- --EXPECT-- 0 1 2 3 4PHP_Compat-1.6.0a3/tests/environment/magic_quotes_gpc_off.phpt100777 1750 1750 651 100777 17524 --TEST-- Environment - magic_quotes_gpc off --INI-- magic_quotes_gpc=On --POST-- a'b=a'b&aa'b[a'b]=a'b&&aa'b[a'bb][a'b]=a'b --FILE-- --EXPECT-- Array ( [a'b] => a'b [aa'b] => Array ( [a'b] => a'b [a'bb] => Array ( [a'b] => a'b ) ) ) PHP_Compat-1.6.0a3/tests/environment/magic_quotes_gpc_on.phpt100777 1750 1750 657 100777 17374 --TEST-- Environment - magic_quotes_gpc on --INI-- magic_quotes_gpc=Off --POST-- a'b=a'b&aa'b[a'b]=a'b&&aa'b[a'bb][a'b]=a'b --FILE-- --EXPECT-- Array ( [a\'b] => a\'b [aa\'b] => Array ( [a\'b] => a\'b [a\'bb] => Array ( [a\'b] => a\'b ) ) )PHP_Compat-1.6.0a3/tests/environment/magic_quotes_sybase_off.phpt100777 1750 1750 661 100777 20242 --TEST-- Environment - magic_quotes_sybase off --INI-- magic_quotes_sybase=On --POST-- a'b=a'b&aa'b[a'b]=a'b&&aa'b[a'bb][a'b]=a'b --FILE-- --EXPECT-- Array ( [a'b] => a'b [aa'b] => Array ( [a'b] => a'b [a'bb] => Array ( [a'b] => a'b ) ) )PHP_Compat-1.6.0a3/tests/environment/magic_quotes_sybase_on.phpt100777 1750 1750 670 100777 20104 --TEST-- Environment - magic_quotes_sybase on --INI-- magic_quotes_sybase=Off --POST-- a'b=a'b&aa'b[a'b]=a'b&&aa'b[a'bb][a'b]=a'b --FILE-- --EXPECT-- Array ( [a''b] => a''b [aa''b] => Array ( [a''b] => a''b [a''bb] => Array ( [a''b] => a''b ) ) )PHP_Compat-1.6.0a3/tests/environment/register_argc_argv_off.phpt100777 1750 1750 354 100777 20052 --TEST-- Environment - register_argc_argv off --INI-- register_argc_argv=On --FILE-- --EXPECT-- bool(false) PHP_Compat-1.6.0a3/tests/environment/register_globals_off.phpt100777 1750 1750 376 100777 17546 --TEST-- Environment - register_globals off --INI-- register_globals=On --POST-- foo=bar --FILE-- --EXPECT-- bool(false) PHP_Compat-1.6.0a3/tests/environment/register_globals_on.phpt100777 1750 1750 400 100777 17374 --TEST-- Environment - register_globals on --INI-- register_globals=Off --POST-- foo=bar --FILE-- --EXPECT-- string(3) "bar"PHP_Compat-1.6.0a3/tests/environment/register_long_arrays_off.phpt100777 1750 1750 533 100777 20436 --TEST-- Environment - register_long_arrays off --INI-- register_long_arrays=On --FILE-- --EXPECT-- bool(false)PHP_Compat-1.6.0a3/tests/environment/register_long_arrays_on.phpt100777 1750 1750 476 100777 20306 --TEST-- Environment - register_long_arrays on --INI-- register_long_arrays=Off --FILE-- --EXPECT-- bool(true)PHP_Compat-1.6.0a3/tests/function/acosh.phpt100777 1750 1750 407 100777 13736 --TEST-- Function -- acosh --FILE-- --EXPECT-- 0.0000 1.3170 1.8115 4.0941 5.1929 5.8861PHP_Compat-1.6.0a3/tests/function/array_change_key_case.phpt100777 1750 1750 3241 100777 17146 --TEST-- Function -- array_change_key_case --FILE-- 1, 'SecOnd' => 4); print_r(php_compat_array_change_key_case($in)); print_r(php_compat_array_change_key_case($in, CASE_LOWER)); print_r(php_compat_array_change_key_case($in, CASE_UPPER)); $in = array('FIRST' => 1, 'SECOND' => 4); print_r(php_compat_array_change_key_case($in)); print_r(php_compat_array_change_key_case($in, CASE_LOWER)); print_r(php_compat_array_change_key_case($in, CASE_UPPER)); $in = array('first' => 1, 'second' => 4); print_r(php_compat_array_change_key_case($in)); print_r(php_compat_array_change_key_case($in, CASE_LOWER)); print_r(php_compat_array_change_key_case($in, CASE_UPPER)); $in = array('foo', 'bar'); print_r(php_compat_array_change_key_case($in)); print_r(php_compat_array_change_key_case($in, CASE_LOWER)); print_r(php_compat_array_change_key_case($in, CASE_UPPER)); $in = array(); print_r(php_compat_array_change_key_case($in)); print_r(php_compat_array_change_key_case($in, CASE_LOWER)); print_r(php_compat_array_change_key_case($in, CASE_UPPER)); ?> --EXPECT-- Array ( [first] => 1 [second] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [FIRST] => 1 [SECOND] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [FIRST] => 1 [SECOND] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [first] => 1 [second] => 4 ) Array ( [FIRST] => 1 [SECOND] => 4 ) Array ( [0] => foo [1] => bar ) Array ( [0] => foo [1] => bar ) Array ( [0] => foo [1] => bar ) Array ( ) Array ( ) Array ( )PHP_Compat-1.6.0a3/tests/function/array_chunk.phpt100777 1750 1750 4766 100777 15203 --TEST-- Function -- array_chunk --FILE-- 'a', 3 => 'b', 4 => 'c', 5 => 'd', 6 => 'e'); print_r(php_compat_array_chunk($input_array, 2)); print_r(php_compat_array_chunk($input_array, 2, true)); print_r(php_compat_array_chunk($input_array, 3)); print_r(php_compat_array_chunk($input_array, 3, true)); print_r(php_compat_array_chunk($input_array, 4)); print_r(php_compat_array_chunk($input_array, 4, true)); print_r(php_compat_array_chunk($input_array, 5)); print_r(php_compat_array_chunk($input_array, 5, true)); print_r(php_compat_array_chunk($input_array, 6)); print_r(php_compat_array_chunk($input_array, 6, true)); ?> --EXPECT-- Array ( [0] => Array ( [0] => a [1] => b ) [1] => Array ( [0] => c [1] => d ) [2] => Array ( [0] => e ) ) Array ( [0] => Array ( [2] => a [3] => b ) [1] => Array ( [4] => c [5] => d ) [2] => Array ( [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c ) [1] => Array ( [0] => d [1] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c ) [1] => Array ( [5] => d [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d ) [1] => Array ( [0] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d ) [1] => Array ( [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d [6] => e ) ) Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d [4] => e ) ) Array ( [0] => Array ( [2] => a [3] => b [4] => c [5] => d [6] => e ) )PHP_Compat-1.6.0a3/tests/function/array_combine.phpt100777 1750 1750 506 100777 15453 --TEST-- Function -- array_combine --FILE-- --EXPECT-- Array ( [green] => avocado [red] => apple [yellow] => banana )PHP_Compat-1.6.0a3/tests/function/array_diff_assoc.phpt100777 1750 1750 572 100777 16142 --TEST-- Function -- array_diff_assoc --FILE-- "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = php_compat_array_diff_assoc($array1, $array2); print_r($result); ?> --EXPECT-- Array ( [b] => brown [c] => blue [0] => red )PHP_Compat-1.6.0a3/tests/function/array_diff_key.phpt100777 1750 1750 557 100777 15625 --TEST-- Function -- array_diff_key --FILE-- 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); print_r(php_compat_array_diff_key($array1, $array2)); ?> --EXPECT-- Array ( [red] => 2 [purple] => 4 )PHP_Compat-1.6.0a3/tests/function/array_diff_uassoc.phpt100777 1750 1750 1006 100777 16340 --TEST-- Function -- array_diff_uassoc --FILE-- $b) ? 1 : -1; } $array1 = array('a' => 'green', 'b' => 'brown', 'c' => 'blue', 'red'); $array2 = array('a' => 'green', 'yellow', 'red'); $result = php_compat_array_diff_uassoc($array1, $array2, 'key_compare_func'); print_r($result); ?> --EXPECT-- Array ( [b] => brown [c] => blue [0] => red )PHP_Compat-1.6.0a3/tests/function/array_diff_ukey.phpt100777 1750 1750 1066 100777 16026 --TEST-- Function -- array_diff_ukey --FILE-- $key2) { return 1; } else { return -1; } } $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); print_r(php_compat_array_diff_ukey($array1, $array2, 'key_compare_func')); ?> --EXPECT-- Array ( [red] => 2 [purple] => 4 )PHP_Compat-1.6.0a3/tests/function/array_fill.phpt100777 1750 1750 401 100777 14757 --TEST-- Function -- array_fill --FILE-- $v) { echo "$k: $v\n"; } ?> --EXPECT-- 5: banana 6: banana 7: banana 8: banana 9: banana 10: bananaPHP_Compat-1.6.0a3/tests/function/array_intersect_assoc.phpt100777 1750 1750 553 100777 17231 --TEST-- Function -- array_intersect_assoc --FILE-- "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = php_compat_array_intersect_assoc($array1, $array2); print_r($result); ?> --EXPECT-- Array ( [a] => green )PHP_Compat-1.6.0a3/tests/function/array_intersect_key.phpt100777 1750 1750 1026 100777 16725 --TEST-- Function -- array_intersect_key --FILE-- 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); print_r(php_compat_array_intersect_key($array1, $array2)); print_r(array_intersect_key( array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>4), array('a'=>0, 'c'=>0), array('a'=>0, 'd'=>4) )); ?> --EXPECT-- Array ( [blue] => 1 [green] => 3 ) Array ( [a] => 1 )PHP_Compat-1.6.0a3/tests/function/array_intersect_uassoc.phpt100777 1750 1750 572 100777 17417 --TEST-- Function -- array_intersect_uassoc --FILE-- "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "GREEN", "B" => "brown", "yellow", "red"); print_r(php_compat_array_intersect_uassoc($array1, $array2, "strcasecmp")); ?> --EXPECT-- Array ( [b] => brown )PHP_Compat-1.6.0a3/tests/function/array_intersect_ukey.phpt100777 1750 1750 1105 100777 17110 --TEST-- Function -- array_intersect_ukey --FILE-- $key2) { return 1; } else { return -1; } } $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); print_r(php_compat_array_intersect_ukey($array1, $array2, 'key_compare_func')); ?> --EXPECT-- Array ( [blue] => 1 [green] => 3 )PHP_Compat-1.6.0a3/tests/function/array_key_exists.phpt100777 1750 1750 500 100777 16220 --TEST-- Function -- array_key_exists --FILE-- 1, "second" => 4); if (php_compat_array_key_exists("first", $search_array)) { echo "The 'first' element is in the array"; } ?> --EXPECT-- The 'first' element is in the arrayPHP_Compat-1.6.0a3/tests/function/array_product.phpt100777 1750 1750 1346 100777 15542 --TEST-- Function -- array_product --FILE-- --EXPECT-- testing: (foo) result: (Warning) NULL testing: () result: int(0) testing: (0) result: int(0) testing: (3) result: int(3) testing: (3 * 3) result: int(9) testing: (0.5 * 2 * 3) result: float(3)PHP_Compat-1.6.0a3/tests/function/array_search.phpt100777 1750 1750 454 100777 15306 --TEST-- Function -- array_search --FILE-- 'blue', 1 => 'red', 2 => 'green', 3 => 'red'); var_dump(php_compat_array_search('green', $array)); var_dump(php_compat_array_search('red', $array)); ?> --EXPECT-- int(2) int(1)PHP_Compat-1.6.0a3/tests/function/array_slice.phpt100777 1750 1750 1420 100777 15152 --TEST-- Function -- array_slice --FILE-- --EXPECT-- array(2) { [0]=> string(1) "c" [1]=> string(1) "d" } array(2) { [2]=> string(1) "c" [3]=> string(1) "d" } array(5) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "e" } array(2) { [0]=> string(1) "d" [1]=> string(1) "e" } array(1) { [0]=> string(1) "d" } array(1) { [3]=> string(1) "d" } PHP_Compat-1.6.0a3/tests/function/array_udiff.phpt100777 1750 1750 1416 100777 15155 --TEST-- Function -- array_udiff --FILE-- priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = php_compat_array_udiff($a, $b, array("cr", "comp_func_cr")); echo serialize($result); ?> --EXPECT-- a:2:{s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}}PHP_Compat-1.6.0a3/tests/function/array_udiff_assoc.phpt100777 1750 1750 1516 100777 16346 --TEST-- Function -- array_udiff_assoc --FILE-- priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = php_compat_array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); echo serialize($result); ?> --EXPECT-- a:3:{s:3:"0.1";O:2:"cr":1:{s:11:"priv_member";i:9;}s:3:"0.5";O:2:"cr":1:{s:11:"priv_member";i:12;}i:0;O:2:"cr":1:{s:11:"priv_member";i:23;}}PHP_Compat-1.6.0a3/tests/function/array_udiff_uassoc.phpt100777 1750 1750 1771 100777 16536 --TEST-- Function -- array_udiff_uassoc --FILE-- val = $val; } function comp_func_cr($a, $b) { if ($a->val === $b->val) return 0; return ($a->val > $b->val) ? 1 : -1; } function comp_func_key($a, $b) { if ($a === $b) return 0; return ($a > $b) ? 1 : -1; } } $a = array('0.1' => new cr(9), '0.5' => new cr(12), 0 => new cr(23), 1 => new cr(4), 2 => new cr(-15)); $b = array('0.2' => new cr(9), '0.5' => new cr(22), 0 => new cr(3), 1 => new cr(4), 2 => new cr(-15)); $result = php_compat_array_udiff_uassoc($a, $b, array('cr', 'comp_func_cr'), array('cr', 'comp_func_key')); print_r($result); ?> --EXPECT-- Array ( [0.1] => cr Object ( [val] => 9 ) [0.5] => cr Object ( [val] => 12 ) [0] => cr Object ( [val] => 23 ) )PHP_Compat-1.6.0a3/tests/function/array_uintersect.phpt100777 1750 1750 607 100777 16226 --TEST-- Function -- array_uintersect --FILE-- 'green', 'b' => 'brown', 'c' => 'blue', 'red'); $array2 = array('a' => 'GREEN', 'B' => 'brown', 'yellow', 'red'); print_r(php_compat_array_uintersect($array1, $array2, 'strcasecmp')); ?> --EXPECT-- Array ( [a] => green [b] => brown [0] => red )PHP_Compat-1.6.0a3/tests/function/array_uintersect_assoc.phpt100777 1750 1750 571 100777 17416 --TEST-- Function -- array_uintersect_assoc --FILE-- 'green', 'b' => 'brown', 'c' => 'blue', 'red'); $array2 = array('a' => 'GREEN', 'B' => 'brown', 'yellow', 'red'); print_r(php_compat_array_uintersect_assoc($array1, $array2, 'strcasecmp')); ?> --EXPECT-- Array ( [a] => green )PHP_Compat-1.6.0a3/tests/function/array_uintersect_uassoc.phpt100777 1750 1750 633 100777 17602 --TEST-- Function -- array_uintersect_uassoc --FILE-- 'green', 'b' => 'brown', 'c' => 'blue', 'red'); $array2 = array('a' => 'GREEN', 'B' => 'brown', 'yellow', 'red'); print_r(php_compat_array_uintersect_uassoc($array1, $array2, 'strcasecmp', 'strcasecmp')); ?> --EXPECT-- Array ( [a] => green [b] => brown )PHP_Compat-1.6.0a3/tests/function/array_walk_recursive.phpt100777 1750 1750 1141 100777 17100 --TEST-- Function -- array_walk_recursive --FILE-- 'apple', 'b' => 'banana'); $fruits = array('sweet' => $sweet, 'sour' => 'lemon'); function test_print($item, $key, $userdata) { echo "$key holds $item $userdata\n"; } php_compat_array_walk_recursive($fruits, 'test_print', 'hi'); function test_reference(&$item, $key) { $item = 'hi'; } php_compat_array_walk_recursive($fruits, 'test_reference'); echo $fruits['sweet']['a'], "\n"; // hi ?> --EXPECT-- a holds apple hi b holds banana hi sour holds lemon hi hiPHP_Compat-1.6.0a3/tests/function/asinh.phpt100777 1750 1750 407 100777 13743 --TEST-- Function -- asinh --FILE-- --EXPECT-- 0.8814 1.4436 1.8623 4.0946 5.1930 5.8861PHP_Compat-1.6.0a3/tests/function/atanh.phpt100777 1750 1750 416 100777 13734 --TEST-- Function -- atanh --FILE-- --EXPECT-- 1.4722 0.2027 0.8673 0.8035 -0.1003 0.0000PHP_Compat-1.6.0a3/tests/function/bcpowmod.phpt100777 1750 1750 1761 100777 14477 --TEST-- Function -- bcpowmod --SKIPIF-- --FILE-- --EXPECT-- php_compat_bcpowmod(1, 5, 2): 1, bcmod(bcpow(1, 5), 2): 1 php_compat_bcpowmod(3, 2, 3): 0, bcmod(bcpow(3, 2), 3): 0 php_compat_bcpowmod(32323487987324234234324, 42, 17): 4, bcmod(bcpow(32323487987324234234324, 42), 17): 4 php_compat_bcpowmod(11987987387233223423435, 42, 1276576289873): 666662814820, bcmod(bcpow(11987987387233223423435, 42), 1276576289873): 666662814820PHP_Compat-1.6.0a3/tests/function/call_user_func_array.phpt100777 1750 1750 513 100777 17021 --TEST-- Function -- call_user_func_array --FILE-- --EXPECT-- foo bar metaPHP_Compat-1.6.0a3/tests/function/clone.phpt100777 1750 1750 4150 100777 13760 --TEST-- Function -- clone --SKIPIF-- --FILE-- foo = 'bar'; } } class testclass3 { var $bar; } class testclass4 { var $foo; function __clone() { $this->foo = php_compat_clone($this->foo); } } class testclass5 { var $child; var $foo; function __clone() { $this->child = php_compat_clone($this->child); $this->child->parent = null; $this->child->parent = &$this; } } class testclass5child extends testclass5 { var $parent; function testclass5child() { $this->child = new stdClass; } } // Test 1: Initial value $aa = new testclass; echo $aa->foo, "\n"; // foo // Test 2: Not referenced $bb = php_compat_clone($aa); $bb->foo = 'baz'; echo $aa->foo, "\n"; // foo // Test 3: __clone method $cc = new testclass2; echo $cc->foo, "\n"; // foo $dd = php_compat_clone($cc); echo $dd->foo, "\n"; // bar // Test 4: Bug #3649 $a = new testclass3; $a->foo =& new testclass4; $a->foo->bar = 'hello'; $aclone = php_compat_clone($a); $aclone->b->bar = 'goodbye'; echo $a->foo->bar, "\n"; // Test 5: Bug #7519 - clone does not return reference $a = new testclass5; $a->foo = 'original parent'; $a->child = new testclass5child; $a->child->parent = &$a; $a->child->foo = 'original child'; $b = php_compat_clone($a); $b->foo = 'new parent'; $b->child->foo = 'new child'; echo $b->child->parent->foo, "\n"; // new parent echo $b->foo, "\n"; // new parent echo $a->child->parent->foo, "\n"; // original parent echo $a->foo, "\n"; // original parent echo $b->child->foo, "\n"; // new child echo $b->child->parent->child->foo, "\n"; // new child echo $a->child->foo, "\n"; // original child echo $a->child->parent->child->foo, "\n"; // original child ?> --EXPECT-- foo foo foo bar hello new parent new parent original parent original parent new child new child original child original child PHP_Compat-1.6.0a3/tests/function/constant.phpt100777 1750 1750 302 100777 14464 --TEST-- Function -- constant --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/convert_uudecode.phpt100777 1750 1750 406 100777 16175 --TEST-- Function -- convert_uudecode --FILE-- --EXPECT-- This is a simple testPHP_Compat-1.6.0a3/tests/function/convert_uuencode.phpt100777 1750 1750 661 100777 16212 --TEST-- Function -- convert_uuencode --FILE-- $i; $i++) { $string .= str_repeat(chr($i), 10); } echo md5(php_compat_convert_uuencode($string)); ?> --EXPECT-- d7974131c8970783f70851c83fe17767 19acf7157a8345307ea5e5ea6878abb4PHP_Compat-1.6.0a3/tests/function/cosh.phpt100777 1750 1750 373 100777 13577 --TEST-- Function -- cosh --FILE-- --EXPECT-- 1.0000 1.0050 1.1276 1.5431 11.5920PHP_Compat-1.6.0a3/tests/function/debug_print_backtrace.phpt100777 1750 1750 3475 100777 17172 --TEST-- Function -- debug_print_backtrace --FILE-- bar(); } } class InnerClass { function bar() { $this->baz(); } function baz() { php_compat_debug_print_backtrace(); } } function outerFunction() { OuterClass::Foo(); } class myClass { function myClass() { } } function debug($var, $val) { echo "Variable: $var\nValue: "; if (is_array($val) || is_object($val) || is_resource($val)) { print_r($val); } else { echo "\n$val\n"; } php_compat_debug_print_backtrace(); echo "***\n"; } ob_start(); // tests outerFunction(); echo "\n"; $host = 'host'; call_user_func_array('debug', array("host", $host)); $myClass = new myClass(); call_user_func_array('debug', array("myClass", $myClass)); $fp = fopen('php://stderr', 'wb'); call_user_func_array('debug', array("fp", $fp)); fclose($fp); $output = ob_get_contents(); ob_end_clean(); $output = preg_replace('#\[[^\]]+\.php#', '', $output); echo $output; ?> --EXPECT-- #0 InnerClass->baz() called at :12] #1 InnerClass->bar() called at :7] #2 OuterClass::foo() called at :19] #3 outerFunction() called at :42] Variable: host Value: host #0 debug(host, host) called at [(null):0] #1 call_user_func_array(debug, Array ( [0] => host [1] => host ) ) called at :45] *** Variable: myClass Value: myClass Object ( ) #0 debug(myClass, myClass Object ( ) ) called at [(null):0] #1 call_user_func_array(debug, Array ( [0] => myClass [1] => myClass Object ( ) ) ) called at :47] *** Variable: fp Value: Resource id #6#0 debug(fp, Resource id #6) called at [(null):0] #1 call_user_func_array(debug, Array ( [0] => fp [1] => Resource id #6 ) ) called at :49] ***PHP_Compat-1.6.0a3/tests/function/file_get_contents.phpt100777 1750 1750 477 100777 16343 --TEST-- Function -- file_get_contents --FILE-- --EXPECT-- test testPHP_Compat-1.6.0a3/tests/function/file_put_contents.phpt100777 1750 1750 1625 100777 16410 --TEST-- Function -- file_put_contents --FILE-- --EXPECT-- 4 abcd 6 foobar 6 8 foobartesttest 8 testtestPHP_Compat-1.6.0a3/tests/function/floatval.phpt100777 1750 1750 266 100777 14454 --TEST-- Function -- floatval --FILE-- --EXPECT-- float(12312.123)PHP_Compat-1.6.0a3/tests/function/fprintf.phpt100777 1750 1750 576 100777 14320 --TEST-- Function -- fprintf --FILE-- --EXPECT-- The dog went to the park for 2 daysPHP_Compat-1.6.0a3/tests/function/fputcsv.phpt100777 1750 1750 211 100777 14324 --TEST-- [INCOMPLETE] Function -- fputcsv --FILE-- --EXPECT-- testPHP_Compat-1.6.0a3/tests/function/getopt.phpt100777 1750 1750 2465 100777 14171 --TEST-- Function -- getopt --FILE-- --EXPECT-- array(6) { ["f"]=> string(11) "value for f" ["v"]=> bool(false) ["a"]=> bool(false) ["required"]=> string(5) "value" ["optional"]=> string(14) "optional value" ["option"]=> bool(false) } array(2) { ["f"]=> string(5) "value" ["h"]=> bool(false) } array(2) { ["a"]=> array(3) { [0]=> bool(false) [1]=> bool(false) [2]=> bool(false) } ["c"]=> bool(false) }PHP_Compat-1.6.0a3/tests/function/get_headers.phpt100777 1750 1750 221 100777 15105 --TEST-- [INCOMPLETE] Function -- get_headers --FILE-- --EXPECT-- testPHP_Compat-1.6.0a3/tests/function/get_include_path.phpt100777 1750 1750 324 100777 16135 --TEST-- Function -- get_include_path --FILE-- --EXPECT-- truePHP_Compat-1.6.0a3/tests/function/glob.phpt100777 1750 1750 22531 100777 13626 --TEST-- Function -- glob --SKIPIF-- --FILE-- * @version 1.0.3 * @link http://aidanlister.com/repos/v/function.rmdirr.php * @param string $dirname Directory to delete * @return bool Returns TRUE on success, FALSE on failure */ function rmdirr($dirname) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname) || is_link($dirname)) { return unlink($dirname); } // Loop through the folder $dir = dir($dirname); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Recurse rmdirr($dirname . DIRECTORY_SEPARATOR . $entry); } // Clean up $dir->close(); return rmdir($dirname); } // create test directory $base_dir = 'php_compat_test_glob_' . md5(uniqid(rand(), true)); mkdir($base_dir, 0777); chdir($base_dir); // create test contents touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abe.jpg'); touch('aba.jpg'); touch('abd.jpg'); touch('abcd.jpg'); touch('abcc.jpg'); touch('abce.jpg'); touch('abc.png'); touch('abcd.png'); touch('abc.exe'); touch('abcd.exe'); touch('foo\\?bar'); mkdir('foo', 0777); chdir('foo'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); touch('abc.png'); touch('abcd.png'); touch('abc.exe'); touch('abcd.exe'); mkdir('bar', 0777); chdir('bar'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); touch('abc.png'); touch('abcd.png'); touch('abc.exe'); touch('abcd.exe'); chdir('..'); mkdir('baz', 0777); chdir('baz'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); chdir('../..'); mkdir('baz', 0777); chdir('baz'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); mkdir('bar', 0777); chdir('bar'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); chdir('../..'); mkdir('cat', 0777); chdir('cat'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); mkdir('bar', 0777); chdir('bar'); touch('abc.php'); touch('abcd.php'); touch('abc.jpg'); touch('abcd.jpg'); chdir('../..'); // test patterns $tests = array( 0 => array( 'none', 'foo', 'ab[cd].jpg', 'foo*', '???/*', '*foo*', '*/abc.*', 'foo/*/abc.*', 'foo/*/*' ), GLOB_BRACE => array( 'GLOB_BRACE', 'a*.{php,jpg}', 'foo/a*.{php,jpg}', 'foo/a*.{p{hp,ng},jpg}' ), (GLOB_BRACE | GLOB_NOSORT) => array( 'GLOB_BRACE | GLOB_NOSORT', 'a*.{php,jpg}', 'foo/a*.{php,jpg}', 'foo/a*.{p{hp,ng},jpg}' ), GLOB_NOSORT => array( 'GLOB_NOSORT', '*/*' ), GLOB_ONLYDIR => array( 'GLOB_ONLYDIR', '*', 'foo/*' ), GLOB_MARK => array( 'GLOB_MARK', 'foo/*' ), GLOB_NOESCAPE => array( 'GLOB_NOESCAPE', 'foo\\?bar' ), GLOB_NOCHECK => array( 'GLOB_NOCHECK', 'foo/khsgkhgjhgla' ) ); foreach ($tests as $flags => $patterns) { $ftext = array_shift($patterns); foreach ($patterns as $pattern) { $compat = php_compat_glob($pattern, $flags); if ($flags & GLOB_NOSORT) { natsort($compat); $compat = array_values($compat); } echo "Flags: $ftext\nPattern: '$pattern'\n"; var_dump($compat); echo "\n"; } } rmdirr($base_dir); ?> --EXPECT-- Flags: none Pattern: 'foo' array(1) { [0]=> string(3) "foo" } Flags: none Pattern: 'ab[cd].jpg' array(2) { [0]=> string(7) "abc.jpg" [1]=> string(7) "abd.jpg" } Flags: none Pattern: 'foo*' array(2) { [0]=> string(3) "foo" [1]=> string(8) "foo\?bar" } Flags: none Pattern: '???/*' array(20) { [0]=> string(11) "baz/abc.jpg" [1]=> string(11) "baz/abc.php" [2]=> string(12) "baz/abcd.jpg" [3]=> string(12) "baz/abcd.php" [4]=> string(7) "baz/bar" [5]=> string(11) "cat/abc.jpg" [6]=> string(11) "cat/abc.php" [7]=> string(12) "cat/abcd.jpg" [8]=> string(12) "cat/abcd.php" [9]=> string(7) "cat/bar" [10]=> string(11) "foo/abc.exe" [11]=> string(11) "foo/abc.jpg" [12]=> string(11) "foo/abc.php" [13]=> string(11) "foo/abc.png" [14]=> string(12) "foo/abcd.exe" [15]=> string(12) "foo/abcd.jpg" [16]=> string(12) "foo/abcd.php" [17]=> string(12) "foo/abcd.png" [18]=> string(7) "foo/bar" [19]=> string(7) "foo/baz" } Flags: none Pattern: '*foo*' array(2) { [0]=> string(3) "foo" [1]=> string(8) "foo\?bar" } Flags: none Pattern: '*/abc.*' array(8) { [0]=> string(11) "baz/abc.jpg" [1]=> string(11) "baz/abc.php" [2]=> string(11) "cat/abc.jpg" [3]=> string(11) "cat/abc.php" [4]=> string(11) "foo/abc.exe" [5]=> string(11) "foo/abc.jpg" [6]=> string(11) "foo/abc.php" [7]=> string(11) "foo/abc.png" } Flags: none Pattern: 'foo/*/abc.*' array(6) { [0]=> string(15) "foo/bar/abc.exe" [1]=> string(15) "foo/bar/abc.jpg" [2]=> string(15) "foo/bar/abc.php" [3]=> string(15) "foo/bar/abc.png" [4]=> string(15) "foo/baz/abc.jpg" [5]=> string(15) "foo/baz/abc.php" } Flags: none Pattern: 'foo/*/*' array(12) { [0]=> string(15) "foo/bar/abc.exe" [1]=> string(15) "foo/bar/abc.jpg" [2]=> string(15) "foo/bar/abc.php" [3]=> string(15) "foo/bar/abc.png" [4]=> string(16) "foo/bar/abcd.exe" [5]=> string(16) "foo/bar/abcd.jpg" [6]=> string(16) "foo/bar/abcd.php" [7]=> string(16) "foo/bar/abcd.png" [8]=> string(15) "foo/baz/abc.jpg" [9]=> string(15) "foo/baz/abc.php" [10]=> string(16) "foo/baz/abcd.jpg" [11]=> string(16) "foo/baz/abcd.php" } Flags: GLOB_BRACE Pattern: 'a*.{php,jpg}' array(9) { [0]=> string(7) "abc.php" [1]=> string(8) "abcd.php" [2]=> string(7) "aba.jpg" [3]=> string(7) "abc.jpg" [4]=> string(8) "abcc.jpg" [5]=> string(8) "abcd.jpg" [6]=> string(8) "abce.jpg" [7]=> string(7) "abd.jpg" [8]=> string(7) "abe.jpg" } Flags: GLOB_BRACE Pattern: 'foo/a*.{php,jpg}' array(4) { [0]=> string(11) "foo/abc.php" [1]=> string(12) "foo/abcd.php" [2]=> string(11) "foo/abc.jpg" [3]=> string(12) "foo/abcd.jpg" } Flags: GLOB_BRACE Pattern: 'foo/a*.{p{hp,ng},jpg}' array(6) { [0]=> string(11) "foo/abc.php" [1]=> string(12) "foo/abcd.php" [2]=> string(11) "foo/abc.png" [3]=> string(12) "foo/abcd.png" [4]=> string(11) "foo/abc.jpg" [5]=> string(12) "foo/abcd.jpg" } Flags: GLOB_BRACE | GLOB_NOSORT Pattern: 'a*.{php,jpg}' array(9) { [0]=> string(7) "aba.jpg" [1]=> string(7) "abc.jpg" [2]=> string(7) "abc.php" [3]=> string(8) "abcc.jpg" [4]=> string(8) "abcd.jpg" [5]=> string(8) "abcd.php" [6]=> string(8) "abce.jpg" [7]=> string(7) "abd.jpg" [8]=> string(7) "abe.jpg" } Flags: GLOB_BRACE | GLOB_NOSORT Pattern: 'foo/a*.{php,jpg}' array(4) { [0]=> string(11) "foo/abc.jpg" [1]=> string(11) "foo/abc.php" [2]=> string(12) "foo/abcd.jpg" [3]=> string(12) "foo/abcd.php" } Flags: GLOB_BRACE | GLOB_NOSORT Pattern: 'foo/a*.{p{hp,ng},jpg}' array(6) { [0]=> string(11) "foo/abc.jpg" [1]=> string(11) "foo/abc.php" [2]=> string(11) "foo/abc.png" [3]=> string(12) "foo/abcd.jpg" [4]=> string(12) "foo/abcd.php" [5]=> string(12) "foo/abcd.png" } Flags: GLOB_NOSORT Pattern: '*/*' array(20) { [0]=> string(11) "baz/abc.jpg" [1]=> string(11) "baz/abc.php" [2]=> string(12) "baz/abcd.jpg" [3]=> string(12) "baz/abcd.php" [4]=> string(7) "baz/bar" [5]=> string(11) "cat/abc.jpg" [6]=> string(11) "cat/abc.php" [7]=> string(12) "cat/abcd.jpg" [8]=> string(12) "cat/abcd.php" [9]=> string(7) "cat/bar" [10]=> string(11) "foo/abc.exe" [11]=> string(11) "foo/abc.jpg" [12]=> string(11) "foo/abc.php" [13]=> string(11) "foo/abc.png" [14]=> string(12) "foo/abcd.exe" [15]=> string(12) "foo/abcd.jpg" [16]=> string(12) "foo/abcd.php" [17]=> string(12) "foo/abcd.png" [18]=> string(7) "foo/bar" [19]=> string(7) "foo/baz" } Flags: GLOB_ONLYDIR Pattern: '*' array(3) { [0]=> string(3) "baz" [1]=> string(3) "cat" [2]=> string(3) "foo" } Flags: GLOB_ONLYDIR Pattern: 'foo/*' array(2) { [0]=> string(7) "foo/bar" [1]=> string(7) "foo/baz" } Flags: GLOB_MARK Pattern: 'foo/*' array(10) { [0]=> string(11) "foo/abc.exe" [1]=> string(11) "foo/abc.jpg" [2]=> string(11) "foo/abc.php" [3]=> string(11) "foo/abc.png" [4]=> string(12) "foo/abcd.exe" [5]=> string(12) "foo/abcd.jpg" [6]=> string(12) "foo/abcd.php" [7]=> string(12) "foo/abcd.png" [8]=> string(8) "foo/bar/" [9]=> string(8) "foo/baz/" } Flags: GLOB_NOESCAPE Pattern: 'foo\?bar' array(1) { [0]=> string(8) "foo\?bar" } Flags: GLOB_NOCHECK Pattern: 'foo/khsgkhgjhgla' array(1) { [0]=> string(16) "foo/khsgkhgjhgla" } PHP_Compat-1.6.0a3/tests/function/htmlspecialchars.phpt100777 1750 1750 3203 100777 16204 --TEST-- Function -- htmlspecialchars --FILE-- '), "\n"; echo php_compat_htmlspecialchars('foobar& '), "\n"; echo php_compat_htmlspecialchars('foobar& '), "\n"; echo php_compat_htmlspecialchars('foobar ', ENT_NOQUOTES), "\n"; echo php_compat_htmlspecialchars('foobar ', ENT_QUOTES), "\n"; echo php_compat_htmlspecialchars('foobar '), "\n"; echo php_compat_htmlspecialchars('foobar & Š &#dodgy;', ENT_QUOTES, 'ISO-8859-1', false), "\n"; echo php_compat_htmlspecialchars('foobar& '), "\n"; echo php_compat_htmlspecialchars('foobar ', ENT_COMPAT, 'UTF-8'), "\n"; echo php_compat_htmlspecialchars('foobar & Š &#dodgy;', ENT_QUOTES, 'UTF-8', false), "\n"; echo php_compat_htmlspecialchars('foobar& ', ENT_COMPAT, 'UTF-8'), "\n"; ?> --EXPECT-- foobar foo<bar> foobar& <bar baz="foo"> foobar&amp; <bar baz="foo"> foobar <bar baz="foo" baz='foo'> foobar <bar baz="foo" baz='foo'> foobar <bar baz="foo" baz='foo'> foobar & Š &#dodgy;<bar baz="foo"> foobar& <bar baz="foo"> foobar <bar baz="foo" baz='foo'> foobar & Š &#dodgy;<bar baz="foo"> foobar& <bar baz="foo">PHP_Compat-1.6.0a3/tests/function/htmlspecialchars_decode.phpt100777 1750 1750 1302 100777 17505 --TEST-- Function -- htmlspecialchars_decode --FILE-- --EXPECT-- Text & " ' < > End Text Text & " ' < > End Text Text & " ' < > End Text Text & " ' < > End Text Text & " ' < > End Text >PHP_Compat-1.6.0a3/tests/function/html_entity_decode.phpt100777 1750 1750 1116 100777 16522 --TEST-- Function -- html_entity_decode --FILE-- --EXPECT-- I'll "walk" the dog now I'll "walk" the dog now I'll "walk" the dog now I'll "walk" the dog nowPHP_Compat-1.6.0a3/tests/function/http_build_query.phpt100777 1750 1750 6024 100777 16245 --TEST-- Function -- http_build_query --FILE-- 'milk', 'php' =>'hypertext processor'); echo php_compat_http_build_query($data, 'flags_'), "\n"; // Ini ini_set('arg_separator.output', '*'); // Simple $data = array('foo'=>'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo php_compat_http_build_query($data), "\n"; // With an object class myClass { var $foo; var $baz; function myClass() { $this->foo = 'bar'; $this->baz = 'boom'; } } $data = new myClass(); echo php_compat_http_build_query($data), "\n"; // With numerically indexed elements $data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor'); echo php_compat_http_build_query($data), "\n"; echo php_compat_http_build_query($data, 'myvar_'), "\n"; // With a complex array $data = array('user' => array( 'name' => 'Bob Smith', 'age' => 47, 'sex' => 'M', 'dob' => '5/12/1956'), 'pastimes' => array( 'golf', 'opera', 'poker', 'rap'), 'children' => array( 'bobby' => array( 'age' => 12, 'sex' => 'M'), 'sally' => array( 'age' => 8, 'sex'=>'F')), 'CEO'); echo php_compat_http_build_query($data, 'flags_'), "\n"; // With a nested object $data = array('foo' => new myClass()); echo php_compat_http_build_query($data, 'flags_'), "\n"; // With a key which evaluates to false $data = array('' => array('hello world'), 'foo' => 'bar'); echo php_compat_http_build_query($data, 'flags_'), "\n"; // With a separator which evaluates to false ini_set('arg_separator.output', '0'); echo php_compat_http_build_query($data, 'flags_'), "\n"; // With a resource $data = array('foo' => null, 'bar' => fopen('php://input', 'r')); var_dump(php_compat_http_build_query($data, 'flags_')); // With a null value $data = array('foo' => null, 'bar' => 1); echo php_compat_http_build_query($data, 'flags_'); ?> --EXPECT-- flags_0=foo&flags_1=bar&flags_2=baz&flags_3=boom&cow=milk&php=hypertext+processor foo=bar*baz=boom*cow=milk*php=hypertext+processor foo=bar*baz=boom 0=foo*1=bar*2=baz*3=boom*cow=milk*php=hypertext+processor myvar_0=foo*myvar_1=bar*myvar_2=baz*myvar_3=boom*cow=milk*php=hypertext+processor user[name]=Bob+Smith*user[age]=47*user[sex]=M*user[dob]=5%2F12%2F1956*pastimes[0]=golf*pastimes[1]=opera*pastimes[2]=poker*pastimes[3]=rap*children[bobby][age]=12*children[bobby][sex]=M*children[sally][age]=8*children[sally][sex]=F*flags_0=CEO foo[foo]=bar*foo[baz]=boom [0]=hello+world*foo=bar [0]=hello+world0foo=bar NULL bar=1PHP_Compat-1.6.0a3/tests/function/ibase_timefmt.phpt100777 1750 1750 1775 100777 15502 --TEST-- Function -- ibase_timefmt --SKIPIF-- --FILE-- --EXPECT-- true %D true %D true %D true %T false %D false %TPHP_Compat-1.6.0a3/tests/function/idate.phpt100777 1750 1750 3613 100777 13751 --TEST-- Function -- idate --FILE-- 0\n"; } echo "\n"; } restore_error_handler(); ?> --EXPECT-- testing: string(1) "B" result: > 0 testing: string(1) "d" result: > 0 testing: string(1) "h" result: > 0 testing: string(1) "H" result: > 0 testing: string(1) "i" result: > 0 testing: string(1) "I" result: int(0) testing: string(1) "L" result: int(0) testing: string(1) "m" result: > 0 testing: string(1) "s" result: > 0 testing: string(1) "t" result: > 0 testing: string(1) "U" result: > 0 testing: string(1) "w" result: > 0 testing: string(1) "W" result: > 0 testing: string(1) "y" result: > 0 testing: string(1) "Y" result: > 0 testing: string(1) "z" result: > 0 testing: string(1) "Z" result: int(0) testing: string(3) "foo" result: idate(): idate format is one char bool(false) testing: string(0) "" result: idate(): idate format is one char bool(false) testing: string(1) "!" result: idate(): Unrecognized date format token. bool(false) testing: string(1) "\" result: idate(): Unrecognized date format token. bool(false) PHP_Compat-1.6.0a3/tests/function/image_type_to_mime_type.phpt100777 1750 1750 1376 100777 17564 --TEST-- Function -- image_type_to_mime_type --FILE-- --EXPECT-- image/gif image/jpeg image/png application/x-shockwave-flash image/psd image/bmp image/tiff image/tiff application/octet-stream image/jp2 application/octet-stream application/octet-stream application/x-shockwave-flash image/iff image/vnd.wap.wbmp image/xbmPHP_Compat-1.6.0a3/tests/function/inet_ntop.phpt100777 1750 1750 1501 100777 14654 --TEST-- Function -- inet_ntop --FILE-- '7f000001', '192.232.131.222' => 'c0e883de', '::1' => '00000000000000000000000000000001', '2001:260:0:10::1' => '20010260000000100000000000000001', 'fe80::200:4cff:fe43:172f' => 'fe8000000000000002004cfffe43172f' ); foreach ($adds as $k => $v) { echo "\ntesting: $k\n "; var_dump(php_compat_inet_ntop(pack('H*', $v))); } ?> --EXPECT-- testing: 127.0.0.1 string(9) "127.0.0.1" testing: 192.232.131.222 string(15) "192.232.131.222" testing: ::1 string(3) "::1" testing: 2001:260:0:10::1 string(16) "2001:260:0:10::1" testing: fe80::200:4cff:fe43:172f string(24) "fe80::200:4cff:fe43:172f"PHP_Compat-1.6.0a3/tests/function/inet_pton.phpt100777 1750 1750 1455 100777 14664 --TEST-- Function -- inet_pton --FILE-- '7f000001', '192.232.131.222' => 'c0e883de', '::1' => '00000000000000000000000000000001', '2001:260:0:10::1' => '20010260000000100000000000000001', 'fe80::200:4cff:fe43:172f' => 'fe8000000000000002004cfffe43172f' ); foreach ($adds as $k => $v) { echo "\ntesting: $k\n "; echo bin2hex(php_compat_inet_pton($k)), "\n"; } ?> --EXPECT-- testing: 127.0.0.1 7f000001 testing: 192.232.131.222 c0e883de testing: ::1 00000000000000000000000000000001 testing: 2001:260:0:10::1 20010260000000100000000000000001 testing: fe80::200:4cff:fe43:172f fe8000000000000002004cfffe43172fPHP_Compat-1.6.0a3/tests/function/ini_get_all.phpt100777 1750 1750 405 100777 15105 --TEST-- Function -- ini_get_all --FILE-- --EXPECT-- true truePHP_Compat-1.6.0a3/tests/function/is_a.phpt100777 1750 1750 365 100777 13557 --TEST-- Function -- is_a --FILE-- --EXPECT-- truePHP_Compat-1.6.0a3/tests/function/is_callable.phpt100777 1750 1750 1530 100777 15111 --TEST-- Function -- is_callable --FILE-- --EXPECT-- bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) PHP_Compat-1.6.0a3/tests/function/is_scalar.phpt100777 1750 1750 1247 100777 14624 --TEST-- Function -- is_scalar --FILE-- --EXPECT-- Testing: (0) 13 bool(true) Testing: (1) 13.37 bool(true) Testing: (2) foo bool(true) Testing: (3) 13 bool(true) Testing: (4) bool(true) Testing: (5) bool(false) Testing: (6) 1 bool(true) Testing: (7) Array ( ) bool(false) Testing: (8) stdClass Object ( ) bool(false) PHP_Compat-1.6.0a3/tests/function/md5_file.phpt100777 1750 1750 261 100777 14323 --TEST-- Function -- md5_file --FILE-- --EXPECT-- 86c9d7992c16f3648612ec648848fc56PHP_Compat-1.6.0a3/tests/function/mhash.phpt100777 1750 1750 3065 100777 13764 --TEST-- Function -- mhash --FILE-- str_repeat(chr(0x0b), 16), 'data' => 'Hi There' ), array( 'key' => 'Jefe', 'data' => 'what do ya want for nothing?' ), array( 'key' => str_repeat(chr(0xAA), 16), 'data' => str_repeat(chr(0xDD), 50) ), array( 'key' => pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'), 'data' => str_repeat(chr(0xCD), 50) ), array( 'key' => str_repeat(chr(0x0C), 16), 'data' => 'Test With Truncation' ), array( 'key' => str_repeat(chr(0xAA), 80), 'data' => 'Test Using Larger Than Block-Size Key - Hash Key First' ), array( 'key' => str_repeat(chr(0xAA), 80), 'data' => 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data' ), ); $types = array( 'MD5' => MHASH_MD5, // 'SHA1' => MHASH_SHA1, ); foreach ($types as $name => $type) { foreach ($tests as $number => $test) { $result = php_compat_mhash($type, $test['data'], $test['key']); echo $name, ' ', ($number + 1), ': ', bin2hex($result), "\n"; } } ?> --EXPECT-- MD5 1: 9294727a3638bb1c13f48ef8158bfc9d MD5 2: 750c783e6ab0b503eaa86e310a5db738 MD5 3: 56be34521d144c88dbb8c733f0e8b3f6 MD5 4: 697eaf0aca3a3aea3a75164746ffaa79 MD5 5: 56461ef2342edc00f9bab995690efd4c MD5 6: 6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd MD5 7: 6f630fad67cda0ee1fb1f562db3aa53ePHP_Compat-1.6.0a3/tests/function/microtime.phpt100777 1750 1750 1314 100777 14647 --TEST-- Function -- microtime --FILE-- --EXPECT-- microtime(): difference to time() < 1: 1 pattern matches: 1 microtime(true): difference to time() < 1: 1 is_float: 1PHP_Compat-1.6.0a3/tests/function/mime_content_type.phpt100777 1750 1750 235 100777 16362 --TEST-- [INCOMPLETE] Function -- mime_content_type --FILE-- --EXPECT-- testPHP_Compat-1.6.0a3/tests/function/mkdir.phpt100777 1750 1750 3352 100777 13771 --TEST-- Function -- mkdir --FILE-- * @version 1.0.3 * @link http://aidanlister.com/repos/v/function.rmdirr.php * @param string $dirname Directory to delete * @return bool Returns TRUE on success, FALSE on failure */ function rmdirr($dirname) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname) || is_link($dirname)) { return unlink($dirname); } // Loop through the folder $dir = dir($dirname); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Recurse rmdirr($dirname . DIRECTORY_SEPARATOR . $entry); } // Clean up $dir->close(); return rmdir($dirname); } $base = realpath('.'); $tests = array( array('foo'), array('foo2', 'bar'), array('foo3', 'bar', 'baz') ); echo "\nabsolute paths:\n"; foreach ($tests as $v) { array_unshift($v, $base); $dir = implode(DIRECTORY_SEPARATOR, $v); var_dump(php_compat_mkdir($dir, 0777, true), is_dir($dir)); } // clean up foreach ($tests as $v) { rmdirr($v[0]); } echo "\nrelative paths:\n"; foreach ($tests as $v) { $dir = implode(DIRECTORY_SEPARATOR, $v); var_dump(php_compat_mkdir($dir, 0777, true), is_dir($dir)); } // clean up foreach ($tests as $v) { rmdirr($v[0]); } ?> --EXPECT-- absolute paths: bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) relative paths: bool(true) bool(true) bool(true) bool(true) bool(true) bool(true)PHP_Compat-1.6.0a3/tests/function/ob_clean.phpt100777 1750 1750 273 100777 14404 --TEST-- Function -- ob_clean --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/ob_flush.phpt100777 1750 1750 257 100777 14445 --TEST-- Function -- ob_flush --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/ob_get_clean.phpt100777 1750 1750 303 100777 15235 --TEST-- Function -- ob_get_clean --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/ob_get_flush.phpt100777 1750 1750 306 100777 15277 --TEST-- Function -- ob_get_flush --FILE-- --EXPECT-- foofooPHP_Compat-1.6.0a3/tests/function/pg_affected_rows.phpt100777 1750 1750 233 100777 16137 --TEST-- [INCOMPLETE] Function -- pg_affected_rows --FILE-- --EXPECT-- testPHP_Compat-1.6.0a3/tests/function/pg_escape_bytea.phpt100777 1750 1750 231 100777 15746 --TEST-- [INCOMPLETE] Function -- pg_escape_bytea --FILE-- --EXPECT-- testPHP_Compat-1.6.0a3/tests/function/pg_unescape_bytea.phpt100777 1750 1750 235 100777 16315 --TEST-- [INCOMPLETE] Function -- pg_unescape_bytea --FILE-- --EXPECT-- testPHP_Compat-1.6.0a3/tests/function/php_ini_loaded_file.phpt100777 1750 1750 245 100777 16576 --TEST-- [INCOMPLETE] Function -- php_ini_loaded_file --FILE-- --EXPECT-- loadedPHP_Compat-1.6.0a3/tests/function/php_strip_whitespace.phpt100777 1750 1750 1234 100777 17104 --TEST-- Function -- php_strip_whitespace --SKIPIF-- --FILE-- '; // Create a temp file $tmpfname = tempnam('/tmp', 'phpcompat'); $fh = fopen($tmpfname, 'w'); fwrite($fh, $string); // Test echo php_compat_php_strip_whitespace($tmpfname); // Close fclose($fh); ?> --EXPECT-- PHP_Compat-1.6.0a3/tests/function/property_exists.phpt100777 1750 1750 564 100777 16130 --TEST-- Function -- property_exists --FILE-- --EXPECT-- bool(true) bool(true) bool(false) PHP_Compat-1.6.0a3/tests/function/range.phpt100777 1750 1750 16565 100777 14011 --TEST-- Function -- range --FILE-- --EXPECT-- (1.5, 10.5, 1): 1.5_3.5_5.5_7.5_9.5 (10, 1, 1): 10_8_6_4_2 (-5, 5, 1): -5_-3_-1_1_3_5 (a, d, 1): a_c (d, a, 1): d_b (A, z, 1): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, 1): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, 1): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, 1): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, 1): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, 1): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, 2): 1.5_3.5_5.5_7.5_9.5 (10, 1, 2): 10_8_6_4_2 (-5, 5, 2): -5_-3_-1_1_3_5 (a, d, 2): a_c (d, a, 2): d_b (A, z, 2): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, 2): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, 2): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, 2): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, 2): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, 2): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, 3): 1.5_3.5_5.5_7.5_9.5 (10, 1, 3): 10_8_6_4_2 (-5, 5, 3): -5_-3_-1_1_3_5 (a, d, 3): a_c (d, a, 3): d_b (A, z, 3): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, 3): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, 3): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, 3): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, 3): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, 3): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, 3.5): 1.5_3.5_5.5_7.5_9.5 (10, 1, 3.5): 10_8_6_4_2 (-5, 5, 3.5): -5_-3_-1_1_3_5 (a, d, 3.5): a_c (d, a, 3.5): d_b (A, z, 3.5): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, 3.5): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, 3.5): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, 3.5): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, 3.5): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, 3.5): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, 10): 1.5_3.5_5.5_7.5_9.5 (10, 1, 10): 10_8_6_4_2 (-5, 5, 10): -5_-3_-1_1_3_5 (a, d, 10): a_c (d, a, 10): d_b (A, z, 10): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, 10): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, 10): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, 10): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, 10): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, 10): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, -1): 1.5_3.5_5.5_7.5_9.5 (10, 1, -1): 10_8_6_4_2 (-5, 5, -1): -5_-3_-1_1_3_5 (a, d, -1): a_c (d, a, -1): d_b (A, z, -1): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, -1): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, -1): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, -1): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, -1): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, -1): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, -1.5): 1.5_3.5_5.5_7.5_9.5 (10, 1, -1.5): 10_8_6_4_2 (-5, 5, -1.5): -5_-3_-1_1_3_5 (a, d, -1.5): a_c (d, a, -1.5): d_b (A, z, -1.5): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, -1.5): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, -1.5): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, -1.5): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, -1.5): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, -1.5): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, foo): 1.5_3.5_5.5_7.5_9.5 (10, 1, foo): 10_8_6_4_2 (-5, 5, foo): -5_-3_-1_1_3_5 (a, d, foo): a_c (d, a, foo): d_b (A, z, foo): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, foo): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, foo): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, foo): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, foo): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, foo): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, Array): 1.5_3.5_5.5_7.5_9.5 (10, 1, Array): 10_8_6_4_2 (-5, 5, Array): -5_-3_-1_1_3_5 (a, d, Array): a_c (d, a, Array): d_b (A, z, Array): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, Array): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, Array): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, Array): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, Array): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, Array): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ (1.5, 10.5, ): 1.5_3.5_5.5_7.5_9.5 (10, 1, ): 10_8_6_4_2 (-5, 5, ): -5_-3_-1_1_3_5 (a, d, ): a_c (d, a, ): d_b (A, z, ): A_C_E_G_I_K_M_O_Q_S_U_W_Y_[_]___a_c_e_g_i_k_m_o_q_s_u_w_y (aa, zz, ): a_c_e_g_i_k_m_o_q_s_u_w_y (aaa, zzz, ): a_c_e_g_i_k_m_o_q_s_u_w_y (00, 99, ): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98 (000, 100, ): 0_2_4_6_8_10_12_14_16_18_20_22_24_26_28_30_32_34_36_38_40_42_44_46_48_50_52_54_56_58_60_62_64_66_68_70_72_74_76_78_80_82_84_86_88_90_92_94_96_98_100 (!, [, ): !_#_%_'_)_+_-_/_1_3_5_7_9_;_=_?_A_C_E_G_I_K_M_O_Q_S_U_W_Y_[ PHP_Compat-1.6.0a3/tests/function/restore_include_path.phpt100777 1750 1750 537 100777 17047 --TEST-- Function -- restore_include_path --FILE-- --EXPECT-- foo truePHP_Compat-1.6.0a3/tests/function/scandir.phpt100777 1750 1750 1134 100777 14302 --TEST-- Function -- scandir --FILE-- --EXPECT-- Array ( [0] => . [1] => .. [2] => test1 [3] => test2 ) Array ( [0] => test2 [1] => test1 [2] => .. [3] => . )PHP_Compat-1.6.0a3/tests/function/setcookie.phpt100777 1750 1750 213 100777 14621 --TEST-- [INCOMPLETE] Function -- setcookie --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/setrawcookie.phpt100777 1750 1750 221 100777 15332 --TEST-- [INCOMPLETE] Function -- setrawcookie --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/set_include_path.phpt100777 1750 1750 302 100777 16145 --TEST-- Function -- set_include_path --FILE-- --EXPECT-- fooPHP_Compat-1.6.0a3/tests/function/sinh.phpt100777 1750 1750 373 100777 13604 --TEST-- Function -- sinh --FILE-- --EXPECT-- 0.0000 0.1002 0.5211 1.1752 11.5487PHP_Compat-1.6.0a3/tests/function/stripos.phpt100777 1750 1750 1015 100777 14360 --TEST-- Function -- stripos --FILE-- --EXPECT-- int(11) int(11) int(11) int(41) bool(false)PHP_Compat-1.6.0a3/tests/function/strpbrk.phpt100777 1750 1750 356 100777 14333 --TEST-- Function -- strpbrk --FILE-- --EXPECT-- string(9) "not to be"PHP_Compat-1.6.0a3/tests/function/strripos.phpt100777 1750 1750 2036 100777 14546 --TEST-- Function -- strripos --FILE-- --EXPECT-- int(41) int(41) int(41) bool(false) int(41) int(11) int(11) bool(false) bool(false) int(1) int(3) int(0)PHP_Compat-1.6.0a3/tests/function/str_ireplace.phpt100777 1750 1750 7272 100777 15344 --TEST-- Function -- str_ireplace --FILE-- --EXPECT-- The dog jumped over the fence Array ( [0] => A Lady [1] => The Lady [2] => My Lady ) Array ( [0] => The dog jumped over the {object} ) The dog jumped over the Array The frog jumped over the frog and the frog... The frog jumped over the gate The frog jumped over the gate and the ... The frog jumped over the gate and the {thing}... Array ( [0] => A frog [1] => The gate [2] => My beer ) The cost is 0.99 The cost is $0.99 The cost is \$0.99 \$1 \$11 The cost is \\$0.99 The cost is \$0\.\\9\\9 PHP_Compat-1.6.0a3/tests/function/str_rot13.phpt100777 1750 1750 365 100777 14504 --TEST-- Function -- str_rot13 --FILE-- --EXPECT-- Gur dhvpx oebja sbk whzcrq bire gur ynml qbt.PHP_Compat-1.6.0a3/tests/function/str_shuffle.phpt100777 1750 1750 417 100777 15166 --TEST-- Function -- str_shuffle --FILE-- --EXPECT-- truePHP_Compat-1.6.0a3/tests/function/str_split.phpt100777 1750 1750 1445 100777 14707 --TEST-- Function -- str_split --FILE-- --EXPECT-- Array ( [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => F [7] => r [8] => i [9] => e [10] => n [11] => d ) Array ( [0] => Hel [1] => lo [2] => Fri [3] => end ) Array ( [0] => Hello Friend ) Array ( [0] => Hello Frien [1] => d )PHP_Compat-1.6.0a3/tests/function/str_word_count.phpt100777 1750 1750 1670 100777 15737 --TEST-- Function -- str_word_count --FILE-- --EXPECT-- int(12) Array ( [0] => Hello [1] => friend [2] => you're [3] => sdf [4] => looking [5] => good [6] => to [7] => day [8] => yes [9] => sir [10] => you [11] => am ) Array ( [0] => Hello [6] => friend [14] => you're [23] => sdf [27] => looking [48] => good [53] => to [56] => day [61] => yes [66] => sir [71] => you [75] => am ) Array ( [0] => hello [6] => I [8] => am [11] => repeated [20] => repeated )PHP_Compat-1.6.0a3/tests/function/substr_compare.phpt100777 1750 1750 654 100777 15675 --TEST-- Function -- substr_compare --FILE-- --EXPECT-- 0 0 0 1 -1PHP_Compat-1.6.0a3/tests/function/sys_get_temp_dir.phpt100777 1750 1750 236 100777 16201 --TEST-- [INCOMPLETE] Function -- sys_get_temp_dir --FILE-- --EXPECT-- loadedPHP_Compat-1.6.0a3/tests/function/tanh.phpt100777 1750 1750 405 100777 13571 --TEST-- Function -- tanh --FILE-- --EXPECT-- 0.0000 0.0997 0.4621 0.7616 0.9963 1.0000PHP_Compat-1.6.0a3/tests/function/time_sleep_until.phpt100777 1750 1750 1002 100777 16212 --TEST-- Function -- time_sleep_until --SKIPIF-- --FILE-- --EXPECT-- 3:3 (Warning) -1:0PHP_Compat-1.6.0a3/tests/function/var_export.phpt100777 1750 1750 3463 100777 15057 --TEST-- Function -- var_export --FILE-- null, 'O\'neil', 'He said "bar" ...' => 'He said "bar" ...', 'Yes \ No' =>'Yes \ No O\'neil', 'foo' => null, ); php_compat_var_export($a); echo "\n\n"; // Classes $var = new stdClass; $var->foo = 'foo'; $var->bar = 'bar'; $inner = new stdClass; $inner->bar = 'foo'; $var->baz = $inner; $var = array(array($var)); php_compat_var_export($var); ?> --EXPECT-- true false NULL NULL array ( 0 => 1, 1 => array ( 0 => 2, 1 => array ( 0 => 3, 1 => 4, ), 2 => array ( 0 => 5, 1 => array ( 0 => 6, 1 => array ( 0 => 7, ), ), ), ), ) array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) array ( '' => NULL, 0 => 'O\'neil', 'He said "bar" ...' => 'He said "bar" ...', 'Yes \\ No' => 'Yes \\ No O\'neil', 'foo' => NULL, ) array ( 0 => array ( 0 => stdClass::__set_state(array( 'foo' => 'foo', 'bar' => 'bar', 'baz' => stdClass::__set_state(array( 'bar' => 'foo', )), )), ), ) PHP_Compat-1.6.0a3/tests/function/version_compare.phpt100777 1750 1750 35627 100777 16110 --TEST-- Function -- version_compare --FILE-- ", "ge", ">=", "eq", "=", "==", "ne", "<>", "!=" ); foreach ($special_forms as $f1) { foreach ($special_forms as $f2) { test("1.0$f1", "1.0$f2"); } } // Operators print "testing operators\n"; foreach ($special_forms as $f1) { foreach ($special_forms as $f2) { foreach ($operators as $op) { $v1 = "1.0$f1"; $v2 = "1.0$f2"; $test = php_compat_version_compare($v1, $v2, $op) ? "true" : "false"; printf("%7s %2s %-7s : %s\n", $v1, $op, $v2, $test); } } } function test($v1, $v2) { $compare = php_compat_version_compare($v1, $v2); switch ($compare) { case -1: print "$v1 < $v2\n"; break; case 1: print "$v1 > $v2\n"; break; case 0: default: print "$v1 = $v2\n"; break; } } ?> --EXPECT-- testing basic 1 < 2 10 > 2 1.0 < 1.1 1.2 > 1.0.1 1.2.p3 > 1.2.4 1.2.y = 1.2.z testing compare 1.0-dev = 1.0-dev 1.0-dev < 1.0a1 1.0-dev < 1.0b1 1.0-dev < 1.0RC1 1.0-dev < 1.0 1.0-dev < 1.0pl1 1.0a1 > 1.0-dev 1.0a1 = 1.0a1 1.0a1 < 1.0b1 1.0a1 < 1.0RC1 1.0a1 < 1.0 1.0a1 < 1.0pl1 1.0b1 > 1.0-dev 1.0b1 > 1.0a1 1.0b1 = 1.0b1 1.0b1 < 1.0RC1 1.0b1 < 1.0 1.0b1 < 1.0pl1 1.0RC1 > 1.0-dev 1.0RC1 > 1.0a1 1.0RC1 > 1.0b1 1.0RC1 = 1.0RC1 1.0RC1 < 1.0 1.0RC1 < 1.0pl1 1.0 > 1.0-dev 1.0 > 1.0a1 1.0 > 1.0b1 1.0 > 1.0RC1 1.0 = 1.0 1.0 < 1.0pl1 1.0pl1 > 1.0-dev 1.0pl1 > 1.0a1 1.0pl1 > 1.0b1 1.0pl1 > 1.0RC1 1.0pl1 > 1.0 1.0pl1 = 1.0pl1 testing operators 1.0-dev lt 1.0-dev : false 1.0-dev < 1.0-dev : false 1.0-dev le 1.0-dev : true 1.0-dev <= 1.0-dev : true 1.0-dev gt 1.0-dev : false 1.0-dev > 1.0-dev : false 1.0-dev ge 1.0-dev : true 1.0-dev >= 1.0-dev : true 1.0-dev eq 1.0-dev : true 1.0-dev = 1.0-dev : true 1.0-dev == 1.0-dev : true 1.0-dev ne 1.0-dev : false 1.0-dev <> 1.0-dev : false 1.0-dev != 1.0-dev : false 1.0-dev lt 1.0a1 : true 1.0-dev < 1.0a1 : true 1.0-dev le 1.0a1 : true 1.0-dev <= 1.0a1 : true 1.0-dev gt 1.0a1 : false 1.0-dev > 1.0a1 : false 1.0-dev ge 1.0a1 : false 1.0-dev >= 1.0a1 : false 1.0-dev eq 1.0a1 : false 1.0-dev = 1.0a1 : false 1.0-dev == 1.0a1 : false 1.0-dev ne 1.0a1 : true 1.0-dev <> 1.0a1 : true 1.0-dev != 1.0a1 : true 1.0-dev lt 1.0b1 : true 1.0-dev < 1.0b1 : true 1.0-dev le 1.0b1 : true 1.0-dev <= 1.0b1 : true 1.0-dev gt 1.0b1 : false 1.0-dev > 1.0b1 : false 1.0-dev ge 1.0b1 : false 1.0-dev >= 1.0b1 : false 1.0-dev eq 1.0b1 : false 1.0-dev = 1.0b1 : false 1.0-dev == 1.0b1 : false 1.0-dev ne 1.0b1 : true 1.0-dev <> 1.0b1 : true 1.0-dev != 1.0b1 : true 1.0-dev lt 1.0RC1 : true 1.0-dev < 1.0RC1 : true 1.0-dev le 1.0RC1 : true 1.0-dev <= 1.0RC1 : true 1.0-dev gt 1.0RC1 : false 1.0-dev > 1.0RC1 : false 1.0-dev ge 1.0RC1 : false 1.0-dev >= 1.0RC1 : false 1.0-dev eq 1.0RC1 : false 1.0-dev = 1.0RC1 : false 1.0-dev == 1.0RC1 : false 1.0-dev ne 1.0RC1 : true 1.0-dev <> 1.0RC1 : true 1.0-dev != 1.0RC1 : true 1.0-dev lt 1.0 : true 1.0-dev < 1.0 : true 1.0-dev le 1.0 : true 1.0-dev <= 1.0 : true 1.0-dev gt 1.0 : false 1.0-dev > 1.0 : false 1.0-dev ge 1.0 : false 1.0-dev >= 1.0 : false 1.0-dev eq 1.0 : false 1.0-dev = 1.0 : false 1.0-dev == 1.0 : false 1.0-dev ne 1.0 : true 1.0-dev <> 1.0 : true 1.0-dev != 1.0 : true 1.0-dev lt 1.0pl1 : true 1.0-dev < 1.0pl1 : true 1.0-dev le 1.0pl1 : true 1.0-dev <= 1.0pl1 : true 1.0-dev gt 1.0pl1 : false 1.0-dev > 1.0pl1 : false 1.0-dev ge 1.0pl1 : false 1.0-dev >= 1.0pl1 : false 1.0-dev eq 1.0pl1 : false 1.0-dev = 1.0pl1 : false 1.0-dev == 1.0pl1 : false 1.0-dev ne 1.0pl1 : true 1.0-dev <> 1.0pl1 : true 1.0-dev != 1.0pl1 : true 1.0a1 lt 1.0-dev : false 1.0a1 < 1.0-dev : false 1.0a1 le 1.0-dev : false 1.0a1 <= 1.0-dev : false 1.0a1 gt 1.0-dev : true 1.0a1 > 1.0-dev : true 1.0a1 ge 1.0-dev : true 1.0a1 >= 1.0-dev : true 1.0a1 eq 1.0-dev : false 1.0a1 = 1.0-dev : false 1.0a1 == 1.0-dev : false 1.0a1 ne 1.0-dev : true 1.0a1 <> 1.0-dev : true 1.0a1 != 1.0-dev : true 1.0a1 lt 1.0a1 : false 1.0a1 < 1.0a1 : false 1.0a1 le 1.0a1 : true 1.0a1 <= 1.0a1 : true 1.0a1 gt 1.0a1 : false 1.0a1 > 1.0a1 : false 1.0a1 ge 1.0a1 : true 1.0a1 >= 1.0a1 : true 1.0a1 eq 1.0a1 : true 1.0a1 = 1.0a1 : true 1.0a1 == 1.0a1 : true 1.0a1 ne 1.0a1 : false 1.0a1 <> 1.0a1 : false 1.0a1 != 1.0a1 : false 1.0a1 lt 1.0b1 : true 1.0a1 < 1.0b1 : true 1.0a1 le 1.0b1 : true 1.0a1 <= 1.0b1 : true 1.0a1 gt 1.0b1 : false 1.0a1 > 1.0b1 : false 1.0a1 ge 1.0b1 : false 1.0a1 >= 1.0b1 : false 1.0a1 eq 1.0b1 : false 1.0a1 = 1.0b1 : false 1.0a1 == 1.0b1 : false 1.0a1 ne 1.0b1 : true 1.0a1 <> 1.0b1 : true 1.0a1 != 1.0b1 : true 1.0a1 lt 1.0RC1 : true 1.0a1 < 1.0RC1 : true 1.0a1 le 1.0RC1 : true 1.0a1 <= 1.0RC1 : true 1.0a1 gt 1.0RC1 : false 1.0a1 > 1.0RC1 : false 1.0a1 ge 1.0RC1 : false 1.0a1 >= 1.0RC1 : false 1.0a1 eq 1.0RC1 : false 1.0a1 = 1.0RC1 : false 1.0a1 == 1.0RC1 : false 1.0a1 ne 1.0RC1 : true 1.0a1 <> 1.0RC1 : true 1.0a1 != 1.0RC1 : true 1.0a1 lt 1.0 : true 1.0a1 < 1.0 : true 1.0a1 le 1.0 : true 1.0a1 <= 1.0 : true 1.0a1 gt 1.0 : false 1.0a1 > 1.0 : false 1.0a1 ge 1.0 : false 1.0a1 >= 1.0 : false 1.0a1 eq 1.0 : false 1.0a1 = 1.0 : false 1.0a1 == 1.0 : false 1.0a1 ne 1.0 : true 1.0a1 <> 1.0 : true 1.0a1 != 1.0 : true 1.0a1 lt 1.0pl1 : true 1.0a1 < 1.0pl1 : true 1.0a1 le 1.0pl1 : true 1.0a1 <= 1.0pl1 : true 1.0a1 gt 1.0pl1 : false 1.0a1 > 1.0pl1 : false 1.0a1 ge 1.0pl1 : false 1.0a1 >= 1.0pl1 : false 1.0a1 eq 1.0pl1 : false 1.0a1 = 1.0pl1 : false 1.0a1 == 1.0pl1 : false 1.0a1 ne 1.0pl1 : true 1.0a1 <> 1.0pl1 : true 1.0a1 != 1.0pl1 : true 1.0b1 lt 1.0-dev : false 1.0b1 < 1.0-dev : false 1.0b1 le 1.0-dev : false 1.0b1 <= 1.0-dev : false 1.0b1 gt 1.0-dev : true 1.0b1 > 1.0-dev : true 1.0b1 ge 1.0-dev : true 1.0b1 >= 1.0-dev : true 1.0b1 eq 1.0-dev : false 1.0b1 = 1.0-dev : false 1.0b1 == 1.0-dev : false 1.0b1 ne 1.0-dev : true 1.0b1 <> 1.0-dev : true 1.0b1 != 1.0-dev : true 1.0b1 lt 1.0a1 : false 1.0b1 < 1.0a1 : false 1.0b1 le 1.0a1 : false 1.0b1 <= 1.0a1 : false 1.0b1 gt 1.0a1 : true 1.0b1 > 1.0a1 : true 1.0b1 ge 1.0a1 : true 1.0b1 >= 1.0a1 : true 1.0b1 eq 1.0a1 : false 1.0b1 = 1.0a1 : false 1.0b1 == 1.0a1 : false 1.0b1 ne 1.0a1 : true 1.0b1 <> 1.0a1 : true 1.0b1 != 1.0a1 : true 1.0b1 lt 1.0b1 : false 1.0b1 < 1.0b1 : false 1.0b1 le 1.0b1 : true 1.0b1 <= 1.0b1 : true 1.0b1 gt 1.0b1 : false 1.0b1 > 1.0b1 : false 1.0b1 ge 1.0b1 : true 1.0b1 >= 1.0b1 : true 1.0b1 eq 1.0b1 : true 1.0b1 = 1.0b1 : true 1.0b1 == 1.0b1 : true 1.0b1 ne 1.0b1 : false 1.0b1 <> 1.0b1 : false 1.0b1 != 1.0b1 : false 1.0b1 lt 1.0RC1 : true 1.0b1 < 1.0RC1 : true 1.0b1 le 1.0RC1 : true 1.0b1 <= 1.0RC1 : true 1.0b1 gt 1.0RC1 : false 1.0b1 > 1.0RC1 : false 1.0b1 ge 1.0RC1 : false 1.0b1 >= 1.0RC1 : false 1.0b1 eq 1.0RC1 : false 1.0b1 = 1.0RC1 : false 1.0b1 == 1.0RC1 : false 1.0b1 ne 1.0RC1 : true 1.0b1 <> 1.0RC1 : true 1.0b1 != 1.0RC1 : true 1.0b1 lt 1.0 : true 1.0b1 < 1.0 : true 1.0b1 le 1.0 : true 1.0b1 <= 1.0 : true 1.0b1 gt 1.0 : false 1.0b1 > 1.0 : false 1.0b1 ge 1.0 : false 1.0b1 >= 1.0 : false 1.0b1 eq 1.0 : false 1.0b1 = 1.0 : false 1.0b1 == 1.0 : false 1.0b1 ne 1.0 : true 1.0b1 <> 1.0 : true 1.0b1 != 1.0 : true 1.0b1 lt 1.0pl1 : true 1.0b1 < 1.0pl1 : true 1.0b1 le 1.0pl1 : true 1.0b1 <= 1.0pl1 : true 1.0b1 gt 1.0pl1 : false 1.0b1 > 1.0pl1 : false 1.0b1 ge 1.0pl1 : false 1.0b1 >= 1.0pl1 : false 1.0b1 eq 1.0pl1 : false 1.0b1 = 1.0pl1 : false 1.0b1 == 1.0pl1 : false 1.0b1 ne 1.0pl1 : true 1.0b1 <> 1.0pl1 : true 1.0b1 != 1.0pl1 : true 1.0RC1 lt 1.0-dev : false 1.0RC1 < 1.0-dev : false 1.0RC1 le 1.0-dev : false 1.0RC1 <= 1.0-dev : false 1.0RC1 gt 1.0-dev : true 1.0RC1 > 1.0-dev : true 1.0RC1 ge 1.0-dev : true 1.0RC1 >= 1.0-dev : true 1.0RC1 eq 1.0-dev : false 1.0RC1 = 1.0-dev : false 1.0RC1 == 1.0-dev : false 1.0RC1 ne 1.0-dev : true 1.0RC1 <> 1.0-dev : true 1.0RC1 != 1.0-dev : true 1.0RC1 lt 1.0a1 : false 1.0RC1 < 1.0a1 : false 1.0RC1 le 1.0a1 : false 1.0RC1 <= 1.0a1 : false 1.0RC1 gt 1.0a1 : true 1.0RC1 > 1.0a1 : true 1.0RC1 ge 1.0a1 : true 1.0RC1 >= 1.0a1 : true 1.0RC1 eq 1.0a1 : false 1.0RC1 = 1.0a1 : false 1.0RC1 == 1.0a1 : false 1.0RC1 ne 1.0a1 : true 1.0RC1 <> 1.0a1 : true 1.0RC1 != 1.0a1 : true 1.0RC1 lt 1.0b1 : false 1.0RC1 < 1.0b1 : false 1.0RC1 le 1.0b1 : false 1.0RC1 <= 1.0b1 : false 1.0RC1 gt 1.0b1 : true 1.0RC1 > 1.0b1 : true 1.0RC1 ge 1.0b1 : true 1.0RC1 >= 1.0b1 : true 1.0RC1 eq 1.0b1 : false 1.0RC1 = 1.0b1 : false 1.0RC1 == 1.0b1 : false 1.0RC1 ne 1.0b1 : true 1.0RC1 <> 1.0b1 : true 1.0RC1 != 1.0b1 : true 1.0RC1 lt 1.0RC1 : false 1.0RC1 < 1.0RC1 : false 1.0RC1 le 1.0RC1 : true 1.0RC1 <= 1.0RC1 : true 1.0RC1 gt 1.0RC1 : false 1.0RC1 > 1.0RC1 : false 1.0RC1 ge 1.0RC1 : true 1.0RC1 >= 1.0RC1 : true 1.0RC1 eq 1.0RC1 : true 1.0RC1 = 1.0RC1 : true 1.0RC1 == 1.0RC1 : true 1.0RC1 ne 1.0RC1 : false 1.0RC1 <> 1.0RC1 : false 1.0RC1 != 1.0RC1 : false 1.0RC1 lt 1.0 : true 1.0RC1 < 1.0 : true 1.0RC1 le 1.0 : true 1.0RC1 <= 1.0 : true 1.0RC1 gt 1.0 : false 1.0RC1 > 1.0 : false 1.0RC1 ge 1.0 : false 1.0RC1 >= 1.0 : false 1.0RC1 eq 1.0 : false 1.0RC1 = 1.0 : false 1.0RC1 == 1.0 : false 1.0RC1 ne 1.0 : true 1.0RC1 <> 1.0 : true 1.0RC1 != 1.0 : true 1.0RC1 lt 1.0pl1 : true 1.0RC1 < 1.0pl1 : true 1.0RC1 le 1.0pl1 : true 1.0RC1 <= 1.0pl1 : true 1.0RC1 gt 1.0pl1 : false 1.0RC1 > 1.0pl1 : false 1.0RC1 ge 1.0pl1 : false 1.0RC1 >= 1.0pl1 : false 1.0RC1 eq 1.0pl1 : false 1.0RC1 = 1.0pl1 : false 1.0RC1 == 1.0pl1 : false 1.0RC1 ne 1.0pl1 : true 1.0RC1 <> 1.0pl1 : true 1.0RC1 != 1.0pl1 : true 1.0 lt 1.0-dev : false 1.0 < 1.0-dev : false 1.0 le 1.0-dev : false 1.0 <= 1.0-dev : false 1.0 gt 1.0-dev : true 1.0 > 1.0-dev : true 1.0 ge 1.0-dev : true 1.0 >= 1.0-dev : true 1.0 eq 1.0-dev : false 1.0 = 1.0-dev : false 1.0 == 1.0-dev : false 1.0 ne 1.0-dev : true 1.0 <> 1.0-dev : true 1.0 != 1.0-dev : true 1.0 lt 1.0a1 : false 1.0 < 1.0a1 : false 1.0 le 1.0a1 : false 1.0 <= 1.0a1 : false 1.0 gt 1.0a1 : true 1.0 > 1.0a1 : true 1.0 ge 1.0a1 : true 1.0 >= 1.0a1 : true 1.0 eq 1.0a1 : false 1.0 = 1.0a1 : false 1.0 == 1.0a1 : false 1.0 ne 1.0a1 : true 1.0 <> 1.0a1 : true 1.0 != 1.0a1 : true 1.0 lt 1.0b1 : false 1.0 < 1.0b1 : false 1.0 le 1.0b1 : false 1.0 <= 1.0b1 : false 1.0 gt 1.0b1 : true 1.0 > 1.0b1 : true 1.0 ge 1.0b1 : true 1.0 >= 1.0b1 : true 1.0 eq 1.0b1 : false 1.0 = 1.0b1 : false 1.0 == 1.0b1 : false 1.0 ne 1.0b1 : true 1.0 <> 1.0b1 : true 1.0 != 1.0b1 : true 1.0 lt 1.0RC1 : false 1.0 < 1.0RC1 : false 1.0 le 1.0RC1 : false 1.0 <= 1.0RC1 : false 1.0 gt 1.0RC1 : true 1.0 > 1.0RC1 : true 1.0 ge 1.0RC1 : true 1.0 >= 1.0RC1 : true 1.0 eq 1.0RC1 : false 1.0 = 1.0RC1 : false 1.0 == 1.0RC1 : false 1.0 ne 1.0RC1 : true 1.0 <> 1.0RC1 : true 1.0 != 1.0RC1 : true 1.0 lt 1.0 : false 1.0 < 1.0 : false 1.0 le 1.0 : true 1.0 <= 1.0 : true 1.0 gt 1.0 : false 1.0 > 1.0 : false 1.0 ge 1.0 : true 1.0 >= 1.0 : true 1.0 eq 1.0 : true 1.0 = 1.0 : true 1.0 == 1.0 : true 1.0 ne 1.0 : false 1.0 <> 1.0 : false 1.0 != 1.0 : false 1.0 lt 1.0pl1 : true 1.0 < 1.0pl1 : true 1.0 le 1.0pl1 : true 1.0 <= 1.0pl1 : true 1.0 gt 1.0pl1 : false 1.0 > 1.0pl1 : false 1.0 ge 1.0pl1 : false 1.0 >= 1.0pl1 : false 1.0 eq 1.0pl1 : false 1.0 = 1.0pl1 : false 1.0 == 1.0pl1 : false 1.0 ne 1.0pl1 : true 1.0 <> 1.0pl1 : true 1.0 != 1.0pl1 : true 1.0pl1 lt 1.0-dev : false 1.0pl1 < 1.0-dev : false 1.0pl1 le 1.0-dev : false 1.0pl1 <= 1.0-dev : false 1.0pl1 gt 1.0-dev : true 1.0pl1 > 1.0-dev : true 1.0pl1 ge 1.0-dev : true 1.0pl1 >= 1.0-dev : true 1.0pl1 eq 1.0-dev : false 1.0pl1 = 1.0-dev : false 1.0pl1 == 1.0-dev : false 1.0pl1 ne 1.0-dev : true 1.0pl1 <> 1.0-dev : true 1.0pl1 != 1.0-dev : true 1.0pl1 lt 1.0a1 : false 1.0pl1 < 1.0a1 : false 1.0pl1 le 1.0a1 : false 1.0pl1 <= 1.0a1 : false 1.0pl1 gt 1.0a1 : true 1.0pl1 > 1.0a1 : true 1.0pl1 ge 1.0a1 : true 1.0pl1 >= 1.0a1 : true 1.0pl1 eq 1.0a1 : false 1.0pl1 = 1.0a1 : false 1.0pl1 == 1.0a1 : false 1.0pl1 ne 1.0a1 : true 1.0pl1 <> 1.0a1 : true 1.0pl1 != 1.0a1 : true 1.0pl1 lt 1.0b1 : false 1.0pl1 < 1.0b1 : false 1.0pl1 le 1.0b1 : false 1.0pl1 <= 1.0b1 : false 1.0pl1 gt 1.0b1 : true 1.0pl1 > 1.0b1 : true 1.0pl1 ge 1.0b1 : true 1.0pl1 >= 1.0b1 : true 1.0pl1 eq 1.0b1 : false 1.0pl1 = 1.0b1 : false 1.0pl1 == 1.0b1 : false 1.0pl1 ne 1.0b1 : true 1.0pl1 <> 1.0b1 : true 1.0pl1 != 1.0b1 : true 1.0pl1 lt 1.0RC1 : false 1.0pl1 < 1.0RC1 : false 1.0pl1 le 1.0RC1 : false 1.0pl1 <= 1.0RC1 : false 1.0pl1 gt 1.0RC1 : true 1.0pl1 > 1.0RC1 : true 1.0pl1 ge 1.0RC1 : true 1.0pl1 >= 1.0RC1 : true 1.0pl1 eq 1.0RC1 : false 1.0pl1 = 1.0RC1 : false 1.0pl1 == 1.0RC1 : false 1.0pl1 ne 1.0RC1 : true 1.0pl1 <> 1.0RC1 : true 1.0pl1 != 1.0RC1 : true 1.0pl1 lt 1.0 : false 1.0pl1 < 1.0 : false 1.0pl1 le 1.0 : false 1.0pl1 <= 1.0 : false 1.0pl1 gt 1.0 : true 1.0pl1 > 1.0 : true 1.0pl1 ge 1.0 : true 1.0pl1 >= 1.0 : true 1.0pl1 eq 1.0 : false 1.0pl1 = 1.0 : false 1.0pl1 == 1.0 : false 1.0pl1 ne 1.0 : true 1.0pl1 <> 1.0 : true 1.0pl1 != 1.0 : true 1.0pl1 lt 1.0pl1 : false 1.0pl1 < 1.0pl1 : false 1.0pl1 le 1.0pl1 : true 1.0pl1 <= 1.0pl1 : true 1.0pl1 gt 1.0pl1 : false 1.0pl1 > 1.0pl1 : false 1.0pl1 ge 1.0pl1 : true 1.0pl1 >= 1.0pl1 : true 1.0pl1 eq 1.0pl1 : true 1.0pl1 = 1.0pl1 : true 1.0pl1 == 1.0pl1 : true 1.0pl1 ne 1.0pl1 : false 1.0pl1 <> 1.0pl1 : false 1.0pl1 != 1.0pl1 : falsePHP_Compat-1.6.0a3/tests/function/vprintf.phpt100777 1750 1750 370 100777 14330 --TEST-- Function -- vprintf --FILE-- --EXPECT-- There are 2 monkeys in the carPHP_Compat-1.6.0a3/tests/function/vsprintf.phpt100777 1750 1750 400 100777 14505 --TEST-- Function -- vsprintf --FILE-- --EXPECT-- There are 2 monkeys in the carPHP_Compat-1.6.0a3/package-test.php100777 1750 1750 6173 100777 12064 registerXPathNamespace('pear', 'http://pear.php.net/dtd/package-2.0'); $xpath = '/pear:package/pear:contents/pear:dir[@name="/"]/pear:dir[@name="Compat"]/pear:dir[@name="Function"]/pear:file'; $filexml = array(); foreach ($xml->xpath($xpath) as $file) { $filexml[] = (string) $file['name']; } sort($filexml); // Get a list of tests from the package2.xml $xpath = '/pear:package/pear:contents/pear:dir[@name="/"]/pear:dir[@name="tests"]/pear:dir[@name="function"]/pear:file'; $testxml = array(); foreach ($xml->xpath($xpath) as $file) { $testxml[] = (string) $file['name']; } sort($testxml); // Get list of files from Components.php require 'Compat/Components.php'; $filecomps = array_keys($components['function']); foreach ($filecomps as $k => $comp) { $filecomps[$k] = $comp . '.php'; } sort($filecomps); // Diff them $error = false; $res = array_diff($filesystem, $filexml); if (!empty($res)) { echo "Exists in filesystem but not in XML:\n"; echo '- ' . implode($res, ', ') . "\n"; $error = true; } $res = $incompleteTests; if (!empty($res)) { echo "Incomplete test:\n"; echo '- ' . implode($res, ', ') . "\n"; $error = true; } $res = array_diff($tests_org, $testxml); if (!empty($res)) { echo "Exists in filesystem but not in tests XML:\n"; echo '- ' . implode($res, ', ') . "\n"; $error = true; } $res = array_diff($filesystem, $filecomps); if (!empty($res)) { echo "Exists in filesystem but not in Components:\n"; echo '- ' . implode($res, ', ') . "\n"; $error = true; } $res = array_diff($filexml, $filesystem); if (!empty($res)) { echo "Exists in XML but not in Filesytem:\n"; echo '- ' . implode($res, ', ') . "\n"; $error = true; } $res = array_diff($filesystem, $tests); if (!empty($res)) { echo "Tests not found for the following files:\n"; echo '- ' . implode($res, ', ') . "\n"; $error = true; } if ($error === false) { echo "No errors found\n"; } ?>