summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/enchant/CREDITS2
-rwxr-xr-xext/enchant/config.m436
-rw-r--r--ext/enchant/config.w3213
-rw-r--r--ext/enchant/docs/examples/example1.php25
-rwxr-xr-xext/enchant/enchant.c776
-rwxr-xr-xext/enchant/package.xml148
-rw-r--r--ext/enchant/php_enchant.h81
-rw-r--r--ext/enchant/tests/broker_describe.phpt28
-rw-r--r--ext/enchant/tests/broker_free.phpt21
-rw-r--r--ext/enchant/tests/broker_init.phpt15
-rw-r--r--ext/enchant/tests/broker_request_dict.phpt31
-rw-r--r--ext/enchant/tests/hindi_correct.txt1
-rw-r--r--ext/enchant/tests/hindi_incorrect.txt1
-rw-r--r--ext/fileinfo/CREDITS2
-rw-r--r--ext/fileinfo/EXPERIMENTAL0
-rw-r--r--ext/fileinfo/config.m462
-rw-r--r--ext/fileinfo/config.w3213
-rw-r--r--ext/fileinfo/fileinfo.c437
-rw-r--r--ext/fileinfo/fileinfo.php29
-rw-r--r--ext/fileinfo/package.xml43
-rw-r--r--ext/fileinfo/php_fileinfo.h61
-rw-r--r--ext/filter/CREDITS2
-rw-r--r--ext/filter/callback_filter.c68
-rw-r--r--ext/filter/config.m495
-rw-r--r--ext/filter/config.w328
-rw-r--r--ext/filter/docs/filter.txt331
-rw-r--r--ext/filter/docs/input_get_args.php41
-rw-r--r--ext/filter/filter.c867
-rw-r--r--ext/filter/filter_private.h90
-rw-r--r--ext/filter/package.xml98
-rw-r--r--ext/filter/package2.xml127
-rw-r--r--ext/filter/php_filter.h106
-rw-r--r--ext/filter/sanitizing_filters.c340
-rw-r--r--ext/filter/tests/001.phpt8
-rw-r--r--ext/filter/tests/002.phpt11
-rw-r--r--ext/filter/tests/003.phpt22
-rw-r--r--ext/filter/tests/004.phpt24
-rw-r--r--ext/filter/tests/005.phpt21
-rw-r--r--ext/filter/tests/006.phpt10
-rw-r--r--ext/filter/tests/007.phpt68
-rw-r--r--ext/filter/tests/008.phpt88
-rw-r--r--ext/filter/tests/009.phpt30
-rw-r--r--ext/filter/tests/010.phpt60
-rw-r--r--ext/filter/tests/011.phpt49
-rw-r--r--ext/filter/tests/012.phpt16
-rw-r--r--ext/filter/tests/013.phpt72
-rw-r--r--ext/filter/tests/014.phpt41
-rw-r--r--ext/filter/tests/015.phpt72
-rw-r--r--ext/filter/tests/016.phpt32
-rw-r--r--ext/filter/tests/017.phpt24
-rw-r--r--ext/filter/tests/018.phpt50
-rw-r--r--ext/filter/tests/019.phpt20
-rw-r--r--ext/filter/tests/020.phpt18
-rw-r--r--ext/filter/tests/021.phpt44
-rw-r--r--ext/filter/tests/022.phpt20
-rw-r--r--ext/filter/tests/023.phpt20
-rw-r--r--ext/filter/tests/024.phpt18
-rw-r--r--ext/filter/tests/025.phpt24
-rw-r--r--ext/filter/tests/026.phpt30
-rw-r--r--ext/filter/tests/027.phpt30
-rw-r--r--ext/filter/tests/028.phpt35
-rw-r--r--ext/filter/tests/029.phpt103
-rw-r--r--ext/filter/tests/030.phpt35
-rw-r--r--ext/filter/tests/031.phpt54
-rw-r--r--ext/filter/tests/032.phpt55
-rw-r--r--ext/filter/tests/033.phpt25
-rw-r--r--ext/filter/tests/033_run.php23
-rw-r--r--ext/filter/tests/bug7586.phpt53
-rw-r--r--ext/filter/tests/bug7715.phpt27
-rw-r--r--ext/filter/tests/bug7733.phpt27
-rw-r--r--ext/filter/tests/filter_data.phpt71
-rw-r--r--ext/imap/imap.h103
-rw-r--r--ext/json/JSON_parser.c757
-rw-r--r--ext/json/JSON_parser.h8
-rw-r--r--ext/json/README76
-rw-r--r--ext/json/config.m488
-rw-r--r--ext/json/config.w3210
-rw-r--r--ext/json/json.c449
-rw-r--r--ext/json/json.dsp135
-rw-r--r--ext/json/package.xml152
-rw-r--r--ext/json/php_json.h60
-rw-r--r--ext/json/tests/fail001.phpt166
-rw-r--r--ext/json/tests/pass001.1.phpt895
-rw-r--r--ext/json/tests/pass001.phpt709
-rw-r--r--ext/json/tests/pass002.phpt276
-rw-r--r--ext/json/tests/pass003.phpt95
-rw-r--r--ext/json/utf8_decode.c179
-rw-r--r--ext/json/utf8_decode.h18
-rw-r--r--ext/json/utf8_to_utf16.c56
-rw-r--r--ext/json/utf8_to_utf16.h3
-rw-r--r--ext/phar/CREDITS2
-rw-r--r--ext/phar/EXPERIMENTAL7
-rw-r--r--ext/phar/LICENSE68
-rw-r--r--ext/phar/config.m412
-rw-r--r--ext/phar/config.w3211
-rw-r--r--ext/phar/package.xml88
-rw-r--r--ext/phar/phar.c1922
-rw-r--r--ext/phar/phar.php21
-rw-r--r--ext/phar/php_phar.h64
-rw-r--r--ext/phar/tests/001.phpt12
-rw-r--r--ext/phar/tests/002.phpt21
-rw-r--r--ext/phar/tests/003.phpt13
-rw-r--r--ext/phar/tests/004.phpt10
-rw-r--r--ext/phar/tests/005.phpt10
-rw-r--r--ext/phar/tests/006.phpt10
-rw-r--r--ext/phar/tests/007.phpt10
-rw-r--r--ext/phar/tests/008.phpt17
-rw-r--r--ext/phar/tests/009.phpt17
-rw-r--r--ext/phar/tests/010.phpt23
-rw-r--r--ext/phar/tests/011.phpt35
-rw-r--r--ext/phar/tests/012.phpt33
-rw-r--r--ext/phar/tests/013.phpt34
-rw-r--r--ext/phar/tests/014.phpt34
-rw-r--r--ext/phar/tests/015.phpt34
-rwxr-xr-xext/phar/tests/015b.phpt33
-rw-r--r--ext/phar/tests/016.phpt51
-rwxr-xr-xext/phar/tests/016b.phpt35
-rw-r--r--ext/phar/tests/017.phpt34
-rw-r--r--ext/phar/tests/018.phpt41
-rw-r--r--ext/phar/tests/019.phpt43
-rwxr-xr-xext/phar/tests/019b.phpt74
-rwxr-xr-xext/phar/tests/019c.phpt82
-rw-r--r--ext/phar/tests/020.phpt143
-rw-r--r--ext/phar/tests/021.phpt91
-rw-r--r--ext/phar/tests/022.phpt116
-rwxr-xr-xext/phar/tests/023.phpt40
-rwxr-xr-xext/phar/tests/024.phpt40
-rwxr-xr-xext/phar/tests/025.phpt40
-rwxr-xr-xext/phar/tests/026.phpt45
-rwxr-xr-xext/phar/tests/027.phpt73
-rwxr-xr-xext/phar/tests/028.phpt57
-rwxr-xr-xext/phar/tests/029.phpt50
-rwxr-xr-xext/phar/tests/030.phpt49
-rwxr-xr-xext/phar/tests/031.phpt29
-rwxr-xr-xext/phar/tests/phar_oo_001.phpt42
-rwxr-xr-xext/phar/tests/phar_oo_002.phpt133
-rwxr-xr-xext/phar/tests/phar_oo_003.phpt42
-rwxr-xr-xext/phar/tests/phar_oo_004.phpt123
-rwxr-xr-xext/phar/tests/phar_oo_005.phpt56
-rwxr-xr-xext/phar/tests/phar_oo_006.phpt49
-rwxr-xr-xext/phar/tests/phar_oo_007.phpt84
-rwxr-xr-xext/phar/tests/phar_oo_008.phpt94
-rwxr-xr-xext/phar/tests/phar_oo_009.phpt54
-rwxr-xr-xext/phar/tests/phar_oo_010.phpt52
-rwxr-xr-xext/phar/tests/phar_oo_test.inc61
-rw-r--r--main/php_realpath.c285
-rw-r--r--sapi/litespeed/Makefile.frag3
-rw-r--r--sapi/litespeed/README118
-rw-r--r--sapi/litespeed/config.m436
-rw-r--r--sapi/litespeed/lsapi_main.c781
-rw-r--r--sapi/litespeed/lsapidef.h181
-rw-r--r--sapi/litespeed/lsapilib.c1127
-rw-r--r--sapi/litespeed/lsapilib.h287
153 files changed, 0 insertions, 16945 deletions
diff --git a/ext/enchant/CREDITS b/ext/enchant/CREDITS
deleted file mode 100644
index 481febbfc2..0000000000
--- a/ext/enchant/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-enchant
-Pierre-Alain Joye, Ilia Alshanetsky
diff --git a/ext/enchant/config.m4 b/ext/enchant/config.m4
deleted file mode 100755
index b59cd8fb3c..0000000000
--- a/ext/enchant/config.m4
+++ /dev/null
@@ -1,36 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-PHP_ARG_WITH(enchant,for ENCHANT support,
-[ --with-enchant[=DIR] Include enchant support.
- GNU Aspell version 1.1.3 or higher required.])
-
-if test "$PHP_ENCHANT" != "no"; then
- PHP_NEW_EXTENSION(enchant, enchant.c, $ext_shared)
- if test "$PHP_ENCHANT" != "yes"; then
- ENCHANT_SEARCH_DIRS=$PHP_ENCHANT
- else
- ENCHANT_SEARCH_DIRS="/usr/local /usr"
- fi
- for i in $ENCHANT_SEARCH_DIRS; do
- if test -f $i/include/enchant/enchant.h; then
- ENCHANT_DIR=$i
- ENCHANT_INCDIR=$i/include/enchant
- elif test -f $i/include/enchant.h; then
- ENCHANT_DIR=$i
- ENCHANT_INCDIR=$i/include
- fi
- done
-
- if test -z "$ENCHANT_DIR"; then
- AC_MSG_ERROR(Cannot find enchant)
- fi
-
- ENCHANT_LIBDIR=$ENCHANT_DIR/lib
-
- AC_DEFINE(HAVE_ENCHANT,1,[ ])
- PHP_SUBST(ENCHANT_SHARED_LIBADD)
- PHP_ADD_LIBRARY_WITH_PATH(enchant, $ENCHANT_LIBDIR, ENCHANT_SHARED_LIBADD)
- PHP_ADD_INCLUDE($ENCHANT_INCDIR)
-fi
diff --git a/ext/enchant/config.w32 b/ext/enchant/config.w32
deleted file mode 100644
index f9ba6beafc..0000000000
--- a/ext/enchant/config.w32
+++ /dev/null
@@ -1,13 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_ENABLE("enchant", "Enchant Support", "no");
-
-if (PHP_ENCHANT == "yes") {
- if (CHECK_HEADER_ADD_INCLUDE("enchant.h", "CFLAGS_ENCHANT", PHP_ENCHANT)) {
- EXTENSION("enchant", "enchant.c");
- AC_DEFINE('HAVE_ENCHANT', 1, 'Have Enchant support', false);
- } else {
- WARNING('Could not find enchant.h; skipping');
- }
-}
diff --git a/ext/enchant/docs/examples/example1.php b/ext/enchant/docs/examples/example1.php
deleted file mode 100644
index 9d503f74e6..0000000000
--- a/ext/enchant/docs/examples/example1.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-$tag = 'en_US';
-$r = enchant_broker_init();
-$bprovides = enchant_broker_describe($r);
-echo "Current broker provides the following backend(s):\n";
-print_r($bprovides);
-
-
-if (enchant_broker_dict_exists($r,$tag)) {
- $d = enchant_broker_request_dict($r, $tag);
- $dprovides = enchant_dict_describe($d);
- echo "dictionary $tag provides:\n";
- $spellerrors = enchant_dict_check($d, "soong");
- print_r($dprovides);
- echo "found $spellerrors spell errors\n";
- if ($spellerrors) {
- $suggs = enchant_dict_suggest($d, "soong");
- echo "Suggestions for 'soong':";
- print_r($suggs);
- }
- enchant_broker_free_dict($d);
-} else {
-}
-enchant_broker_free($r);
-?>
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
deleted file mode 100755
index 07ae10207c..0000000000
--- a/ext/enchant/enchant.c
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Pierre-Alain Joye <paj@pearfr.org> |
- | Ilia Alshanetsky <ilia@prohost.org> |
- +----------------------------------------------------------------------+
-
- $Id$
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "enchant.h"
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "php_enchant.h"
-
-
-typedef EnchantBroker * EnchantBrokerPtr;
-typedef struct _broker_struct enchant_broker;
-typedef struct _dict_struct enchant_dict;
-
-typedef enchant_broker * enchant_brokerPtr;
-typedef enchant_dict * enchant_dictPtr;
-
-typedef struct _broker_struct {
- EnchantBroker *pbroker;
- enchant_dict **dict;
- unsigned int dictcnt;
- zval *rsrc_id;
-} _enchant_broker;
-
-typedef struct _dict_struct {
- unsigned int id;
- EnchantDict *pdict;
- enchant_broker *pbroker;
- zval *rsrc_id;
- enchant_dict *next;
- enchant_dict *prev;
-} _enchant_dict;
-
-
-/* True global resources - no need for thread safety here */
-static int le_enchant_broker;
-static int le_enchant_dict;
-
-/* If you declare any globals in php_enchant.h uncomment this:*/
-/*ZEND_DECLARE_MODULE_GLOBALS(enchant)*/
-
-/* {{{ enchant_functions[]
- *
- * Every user visible function must have an entry in enchant_functions[].
- */
-function_entry enchant_functions[] = {
- PHP_FE(enchant_broker_init, NULL)
- PHP_FE(enchant_broker_free, NULL)
- PHP_FE(enchant_broker_get_error, NULL)
- PHP_FE(enchant_broker_list_dicts, NULL)
- PHP_FE(enchant_broker_request_dict, NULL)
- PHP_FE(enchant_broker_request_pwl_dict, NULL)
- PHP_FE(enchant_broker_free_dict, NULL)
- PHP_FE(enchant_broker_dict_exists, NULL)
- PHP_FE(enchant_broker_set_ordering, NULL)
- PHP_FE(enchant_broker_describe, NULL)
- PHP_FE(enchant_dict_check, NULL)
- PHP_FE(enchant_dict_suggest, NULL)
- PHP_FE(enchant_dict_add_to_personal, NULL)
- PHP_FE(enchant_dict_add_to_session, NULL)
- PHP_FE(enchant_dict_is_in_session, NULL)
- PHP_FE(enchant_dict_store_replacement, NULL)
- PHP_FE(enchant_dict_get_error, NULL)
- PHP_FE(enchant_dict_describe, NULL)
- PHP_FE(enchant_dict_quick_check, third_arg_force_ref)
-
- {NULL, NULL, NULL} /* Must be the last line in enchant_functions[] */
-};
-/* }}} */
-
-/* {{{ enchant_module_entry
- */
-zend_module_entry enchant_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- "enchant",
- enchant_functions,
- PHP_MINIT(enchant),
- PHP_MSHUTDOWN(enchant),
- NULL, /* Replace with NULL if there's nothing to do at request start */
- NULL, /* Replace with NULL if there's nothing to do at request end */
- PHP_MINFO(enchant),
-#if ZEND_MODULE_API_NO >= 20010901
- "0.1", /* Replace with version number for your extension */
-#endif
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_ENCHANT
-ZEND_GET_MODULE(enchant)
-#endif
-
-static void
-enumerate_providers_fn (const char * const name,
- const char * const desc,
- const char * const file,
- void * ud) /* {{{ */
-{
- zval *zdesc = (zval *) ud;
- zval *tmp_array;
-
- MAKE_STD_ZVAL(tmp_array);
- array_init(tmp_array);
-
- add_assoc_string(tmp_array, "name", (char *)name, 1);
- add_assoc_string(tmp_array, "desc", (char *)desc, 1);
- add_assoc_string(tmp_array, "file", (char *)file, 1);
-
- if (Z_TYPE_P(zdesc)!=IS_ARRAY) {
- array_init(zdesc);
- }
-
- add_next_index_zval(zdesc, tmp_array);
-}
-/* }}} */
-
-static void
-describe_dict_fn (const char * const lang,
- const char * const name,
- const char * const desc,
- const char * const file,
- void * ud) /* {{{ */
-{
- zval *zdesc = (zval *) ud;
- array_init(zdesc);
- add_assoc_string(zdesc, "lang", (char *)lang, 1);
- add_assoc_string(zdesc, "name", (char *)name, 1);
- add_assoc_string(zdesc, "desc", (char *)desc, 1);
- add_assoc_string(zdesc, "file", (char *)file, 1);
-}
-/* }}} */
-
-static void php_enchant_list_dicts_fn( const char * const lang_tag,
- const char * const provider_name, const char * const provider_desc,
- const char * const provider_file, void * ud) /* {{{ */
-{
- zval *zdesc = (zval *) ud;
- zval *tmp_array;
-
- MAKE_STD_ZVAL(tmp_array);
- array_init(tmp_array);
- add_assoc_string(tmp_array, "lang_tag", (char *)lang_tag, 1);
- add_assoc_string(tmp_array, "provider_name", (char *)provider_name, 1);
- add_assoc_string(tmp_array, "provider_desc", (char *)provider_desc, 1);
- add_assoc_string(tmp_array, "provider_file", (char *)provider_file, 1);
-
- if (Z_TYPE_P(zdesc) != IS_ARRAY) {
- array_init(zdesc);
- }
- add_next_index_zval(zdesc, tmp_array);
-
-}
-/* }}} */
-
-static void php_enchant_broker_free(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
-{
- if (rsrc->ptr) {
- enchant_broker *broker = (enchant_broker *)rsrc->ptr;
- if (broker) {
- if (broker->pbroker) {
- if (broker->dictcnt && broker->dict) {
- if (broker->dict) {
- int total, tofree;
- tofree = total = broker->dictcnt-1;
- do {
- zend_list_delete(Z_RESVAL_P(broker->dict[total]->rsrc_id));
- efree(broker->dict[total]);
- total--;
- } while (total>=0);
- }
- efree(broker->dict);
- broker->dict = NULL;
- }
- enchant_broker_free(broker->pbroker);
- }
- efree(broker);
- }
- }
-}
-/* }}} */
-
-static void php_enchant_dict_free(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
-
-{
- if (rsrc->ptr) {
- enchant_dict *pdict = (enchant_dict *)rsrc->ptr;
- if (pdict) {
- if (pdict->pdict && pdict->pbroker) {
- enchant_broker_free_dict(pdict->pbroker->pbroker, pdict->pdict);
- }
- if (pdict->id) {
- pdict->pbroker->dict[pdict->id-1]->next = NULL;
- }
- }
- }
-}
-/* }}} */
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(enchant)
-{
- le_enchant_broker = zend_register_list_destructors_ex(php_enchant_broker_free, NULL, "enchant broker", module_number);
- le_enchant_dict = zend_register_list_destructors_ex(php_enchant_dict_free, NULL, "enchant dict", module_number);
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MSHUTDOWN_FUNCTION
- */
-PHP_MSHUTDOWN_FUNCTION(enchant)
-{
- return SUCCESS;
-}
-/* }}} */
-
-static void __enumerate_providers_fn (const char * const name,
- const char * const desc,
- const char * const file,
- void * ud) /* {{{ */
-{
- php_info_print_table_row(3, name, desc, file);
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(enchant)
-{
- EnchantBroker *pbroker;
-
- pbroker = enchant_broker_init();
- php_info_print_table_start();
- php_info_print_table_header(2, "enchant support", "enabled");
- php_info_print_table_row(2, "Version", "@package_version@");
- php_info_print_table_row(2, "Revision", "$Revision$");
- php_info_print_table_end();
-
- php_info_print_table_start();
- enchant_broker_describe(pbroker, __enumerate_providers_fn, NULL);
- php_info_print_table_end();
- enchant_broker_free(pbroker);
-}
-/* }}} */
-
-#define PHP_ENCHANT_GET_BROKER \
- ZEND_FETCH_RESOURCE(pbroker, enchant_broker *, &broker, -1, "enchant_broker", le_enchant_broker); \
- if (!pbroker || !pbroker->pbroker) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "Resource broker invalid"); \
- RETURN_FALSE; \
- }
-
-#define PHP_ENCHANT_GET_DICT \
- ZEND_FETCH_RESOURCE(pdict, enchant_dict *, &dict, -1, "enchant dict", le_enchant_dict); \
- if (!pdict || !pdict->pdict) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", "Invalid dictionary resource."); \
- RETURN_FALSE; \
- }
-
-/* {{{ proto resource enchant_broker_init()
- create a new broker object capable of requesting */
-PHP_FUNCTION(enchant_broker_init)
-{
- enchant_broker *broker;
- EnchantBroker *pbroker;
-
- if (ZEND_NUM_ARGS()) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- pbroker = enchant_broker_init();
-
- if (pbroker) {
- broker = (enchant_broker *) emalloc(sizeof(enchant_broker));
- broker->pbroker = pbroker;
- broker->dict = NULL;
- broker->dictcnt = 0;
- ZEND_REGISTER_RESOURCE(return_value, broker, le_enchant_broker);
- broker->rsrc_id = return_value;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto boolean enchant_broker_free(resource broker)
- Destroys the broker object and its dictionnaries */
-PHP_FUNCTION(enchant_broker_free)
-{
- zval *broker;
- enchant_broker *pbroker;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
- RETURN_FALSE;
- }
- PHP_ENCHANT_GET_BROKER;
-
- zend_list_delete(Z_RESVAL_P(broker));
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string enchant_broker_get_error(resource broker)
- Returns the last error of the broker */
-PHP_FUNCTION(enchant_broker_get_error)
-{
- zval *broker;
- enchant_broker *pbroker;
- char *msg;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- msg = enchant_broker_get_error(pbroker->pbroker);
- if (msg) {
- RETURN_STRING((char *)msg, 1);
- }
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string enchant_broker_list_dicts(resource broker)
- Returns the last error of the broker */
-PHP_FUNCTION(enchant_broker_list_dicts)
-{
- zval *broker;
- enchant_broker *pbroker;
- EnchantDictDescribeFn describetozval = php_enchant_list_dicts_fn;
-
- char *msg;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- enchant_broker_list_dicts(pbroker->pbroker, php_enchant_list_dicts_fn, (void *)return_value);
-}
-/* }}} */
-
-/* {{{ proto resource enchant_broker_request_dict(resource broker, string tag)
- create a new dictionary using tag, the non-empty language tag you wish to request
- a dictionary for ("en_US", "de_DE", ...) */
-PHP_FUNCTION(enchant_broker_request_dict)
-{
- zval *broker;
- enchant_broker *pbroker;
- enchant_dict *dict;
- EnchantDict *d;
- char *tag;
- int taglen;
- int pos;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
- if (d) {
- if (pbroker->dictcnt) {
- pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
- pos = pbroker->dictcnt++;
- } else {
- pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
- pos = 0;
- pbroker->dictcnt++;
- }
-
- dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
- dict->id = pos;
- dict->pbroker = pbroker;
- dict->pdict = d;
- dict->rsrc_id = return_value;
- dict->prev = pos ? pbroker->dict[pos-1] : NULL;
- dict->next = NULL;
- pbroker->dict[pos] = dict;
-
- if (pos) {
- pbroker->dict[pos-1]->next = dict;
- }
-
- ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto resource enchant_broker_request_pwl_dict(resource dict, string filename)
- creates a dictionary using a PWL file. A PWL file is personal word file one word per line.
- It must exist before the call.*/
-PHP_FUNCTION(enchant_broker_request_pwl_dict)
-{
- zval *broker;
- enchant_broker *pbroker;
- enchant_dict *dict;
- EnchantDict *d;
- char *pwl;
- int pwllen;
- int pos;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &pwl, &pwllen) == FAILURE) {
- RETURN_FALSE;
- }
-
- if ((PG(safe_mode) && (!php_checkuid(pwl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pwl TSRMLS_CC)) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- d = enchant_broker_request_pwl_dict(pbroker->pbroker, (const char *)pwl);
- if (d) {
- if (pbroker->dictcnt) {
- pos = pbroker->dictcnt++;
- pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
- } else {
- pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
- pos = 0;
- pbroker->dictcnt++;
- }
- dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
- dict->id = pos;
- dict->pbroker = pbroker;
- dict->pdict = d;
- dict->rsrc_id = return_value;
- dict->prev = pos?pbroker->dict[pos-1]:NULL;
- dict->next = NULL;
- pbroker->dict[pos] = dict;
- if (pos) {
- pbroker->dict[pos-1]->next = dict;
- }
- ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto resource enchant_broker_free_dict(resource dict)
- Free the dictionary resource */
-PHP_FUNCTION(enchant_broker_free_dict)
-{
- zval *dict;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- zend_list_delete(Z_RESVAL_P(dict));
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool enchant_broker_dict_exists(resource broker, string tag)
- Wether a dictionary exists or not. Using non-empty tag */
-PHP_FUNCTION(enchant_broker_dict_exists)
-{
- zval *broker;
- char *tag;
- int taglen;
- enchant_broker * pbroker;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- RETURN_BOOL(enchant_broker_dict_exists(pbroker->pbroker, tag));
-}
-/* }}} */
-
-/* {{{ proto bool enchant_broker_set_ordering(resource broker, string tag, string ordering)
- Declares a preference of dictionaries to use for the language
- described/referred to by 'tag'. The ordering is a comma delimited
- list of provider names. As a special exception, the "*" tag can
- be used as a language tag to declare a default ordering for any
- language that does not explictly declare an ordering. */
-
-PHP_FUNCTION(enchant_broker_set_ordering)
-{
- zval *broker;
- char *pordering;
- int porderinglen;
- char *ptag;
- int ptaglen;
- enchant_broker * pbroker;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &broker, &ptag, &ptaglen, &pordering, &porderinglen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- enchant_broker_set_ordering(pbroker->pbroker, ptag, pordering);
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto array enchant_broker_describe(resource broker)
- Enumerates the Enchant providers and tells
- you some rudimentary information about them. The same info is provided through phpinfo() */
-PHP_FUNCTION(enchant_broker_describe)
-{
- EnchantBrokerDescribeFn describetozval = enumerate_providers_fn;
- zval *broker;
- enchant_broker * pbroker;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_BROKER;
-
- enchant_broker_describe(pbroker->pbroker, describetozval, (void *)return_value);
-}
-/* }}} */
-
-/* {{{ proto bool enchant_dict_quick_check(resource dict, string word [, array &suggestions])
- If the word is correctly spelled return true, otherwise return false, if suggestions variable
- is provided, fill it with spelling alternatives. */
-PHP_FUNCTION(enchant_dict_quick_check)
-{
- zval *dict, *sugg = NULL;
- char *word;
- int wordlen;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|z/", &dict, &word, &wordlen, &sugg) == FAILURE) {
- RETURN_FALSE;
- }
-
- if (sugg) {
- zval_dtor(sugg);
- }
-
- PHP_ENCHANT_GET_DICT;
-
- if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) {
- if (!sugg && ZEND_NUM_ARGS() == 2) {
- RETURN_FALSE;
- }
-
- int n_sugg;
- char **suggs;
-
- array_init(sugg);
-
- suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, (size_t *) &n_sugg);
- if (suggs && n_sugg) {
- int i;
- for (i = 0; i < n_sugg; i++) {
- add_next_index_string(sugg, suggs[i], 1);
- }
- enchant_dict_free_suggestions(pdict->pdict, suggs);
- }
-
-
- RETURN_FALSE;
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool enchant_dict_check(resource dict, string word)
- If the word is correctly spelled return true, otherwise return false */
-PHP_FUNCTION(enchant_dict_check)
-{
- zval *dict;
- char *word;
- int wordlen;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- RETURN_BOOL(!enchant_dict_check(pdict->pdict, word, wordlen));
-}
-/* }}} */
-
-/* {{{ proto array enchant_dict_suggest(resource dict, string word)
- Will return a list of values if any of those pre-conditions are not met.*/
-PHP_FUNCTION(enchant_dict_suggest)
-{
- zval *dict;
- char *word;
- int wordlen;
- char **suggs;
- enchant_dict *pdict;
- int n_sugg;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, (size_t *)&n_sugg);
- if (suggs && n_sugg) {
- int i;
-
- array_init(return_value);
- for (i = 0; i < n_sugg; i++) {
- add_next_index_string(return_value, suggs[i], 1);
- }
-
- enchant_dict_free_suggestions(pdict->pdict, suggs);
- }
-}
-/* }}} */
-
-/* {{{ proto void enchant_dict_add_to_personal(resource dict, string word)
- add 'word' to personal word list */
-PHP_FUNCTION(enchant_dict_add_to_personal)
-{
- zval *dict;
- char *word;
- int wordlen;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- enchant_dict_add_to_personal(pdict->pdict, word, wordlen);
-}
-/* }}} */
-
-/* {{{ proto void enchant_dict_add_to_session(resource dict, string word)
- add 'word' to this spell-checking session */
-PHP_FUNCTION(enchant_dict_add_to_session)
-{
- zval *dict;
- char *word;
- int wordlen;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- enchant_dict_add_to_session(pdict->pdict, word, wordlen);
-}
-/* }}} */
-
-/* {{{ proto bool enchant_dict_is_in_session(resource dict, string word)
- whether or not 'word' exists in this spelling-session */
-PHP_FUNCTION(enchant_dict_is_in_session)
-{
- zval *dict;
- char *word;
- int wordlen;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- RETURN_BOOL(enchant_dict_is_in_session(pdict->pdict, word, wordlen));
-}
-/* }}} */
-
-/* {{{ proto void enchant_dict_store_replacement(resource dict, string mis, string cor)
- add a correction for 'mis' using 'cor'.
- Notes that you replaced @mis with @cor, so it's possibly more likely
- that future occurrences of @mis will be replaced with @cor. So it might
- bump @cor up in the suggestion list.*/
-PHP_FUNCTION(enchant_dict_store_replacement)
-{
- zval *dict;
- char *mis, *cor;
- int mislen, corlen;
-
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &dict, &mis, &mislen, &cor, &corlen) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- enchant_dict_store_replacement(pdict->pdict, mis, mislen, cor, corlen);
-}
-/* }}} */
-
-/* {{{ proto string enchant_dict_get_error(resource dict)
- Returns the last error of the current spelling-session */
-PHP_FUNCTION(enchant_dict_get_error)
-{
- zval *dict;
- enchant_dict *pdict;
- char *msg;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- msg = enchant_dict_get_error(pdict->pdict);
- if (msg) {
- RETURN_STRING((char *)msg, 1);
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array enchant_dict_describe(resource dict)
- Describes an individual dictionary 'dict' */
-PHP_FUNCTION(enchant_dict_describe)
-{
- zval *dict;
- enchant_dict *pdict;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
- RETURN_FALSE;
- }
-
- PHP_ENCHANT_GET_DICT;
-
- enchant_dict_describe(pdict->pdict, describe_dict_fn, (void *)return_value);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/enchant/package.xml b/ext/enchant/package.xml
deleted file mode 100755
index 01826fbbcf..0000000000
--- a/ext/enchant/package.xml
+++ /dev/null
@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.8" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
- <name>enchant</name>
- <channel>pecl.php.net</channel>
- <summary>libenchant binder, support near all spelling tools</summary>
- <description>Enchant is a binder for libenchant. Libenchant provides a common
-API for many spell libraries:
-- aspell/pspell (intended to replace ispell)
-- hspell (hebrew)
-- ispell
-- myspell/hunspell (OpenOffice project, mozilla)
-- uspell (primarily Yiddish, Hebrew, and Eastern European languages)
-A plugin system allows to add custom spell support.
-see www.abisource.com/enchant/
- </description>
- <lead>
- <name>Pierre-Alain Joye</name>
- <user>pajoye</user>
- <email>paj@pearfr.org</email>
- <active>yes</active>
- </lead>
- <lead>
- <name>Ilia Alshanetsky</name>
- <user>iliaa</user>
- <email>ilia@php.net</email>
- <active>yes</active>
- </lead>
- <date>2006-03-21</date>
- <version>
- <release>1.0.1</release>
- <api>1.1.0</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>- add enchant_broker_list_dicts to get a list of available dictionaries
-- fix compilation warnings
-- add examples
-- add tests</notes>
- <contents>
- <dir name="/">
- <dir name="docs">
- <dir name="examples">
- <file name="example1.php" role="doc"/>
- </dir>
-<!-- //docs/examples -->
- </dir>
-<!-- //docs -->
- <file name="config.m4" role="src"/>
- <file name="config.w32" role="src"/>
- <file name="CREDITS" role="doc"/>
- <file name="enchant.c" role="src">
- <tasks:replace from="@package_version@" to="version" type="package-info"/>
- </file>
- <file name="php_enchant.h" role="src"/>
- <dir name="tests">
- <file name="broker_describe.phpt" role="test"/>
- <file name="broker_free.phpt" role="test"/>
- <file name="broker_init.phpt" role="test"/>
- <file name="broker_request_dict.phpt" role="test"/>
- <file name="hindi_correct.txt" role="test"/>
- <file name="hindi_incorrect.txt" role="test"/>
- </dir>
- </dir>
-<!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>5</min>
- </php>
- <pearinstaller>
- <min>1.4.0b1</min>
- </pearinstaller>
- </required>
- </dependencies>
- <providesextension>enchant</providesextension>
- <extsrcrelease>
- <configureoption default="shared" name="with-enchant" prompt="libenchant prefix?"/>
- </extsrcrelease>
- <changelog>
- <release>
- <date>2004-08-11</date>
- <version>
- <release>1.0</release>
- <api>1.0</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>- Fixed leak inside MINFO function.
-- Fixed crash inside enchant_dict_suggest() when there are no suggestions.
-- Added missing safe_mode/open_basedir check inside enchant_broker_request_pwl_dict().
-- Fixed various function prototypes.
-- Fixed possible leak in suggestions result.
- </notes>
- </release>
- <release>
- <version>
- <release>0.2.1</release>
- <api>0.2.1</api>
- </version>
- <stability>
- <release>beta</release>
- <api>beta</api>
- </stability>
- <date>2004-03-11</date>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>- Fix possible leak in suggestions result
-- Move to beta status
- </notes>
- </release>
- <release>
- <version>
- <release>0.2.0</release>
- <api>0.2.0</api>
- </version>
- <stability>
- <release>alpha</release>
- <api>alpha</api>
- </stability>
- <date>2006-03-21</date>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>- Add Ilia Alshanetsky as maintainer
-- Cleanup sources codes (ilia)
-- Add enchant_dict_quick_check (ilia)
- </notes>
- </release>
- <release>
- <version>
- <release>0.1</release>
- <api>0.1</api>
- </version>
- <stability>
- <release>alpha</release>
- <api>alpha</api>
- </stability>
- <date>2003-03-08</date>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>Initial release
- </notes>
- </release>
- </changelog>
-</package>
diff --git a/ext/enchant/php_enchant.h b/ext/enchant/php_enchant.h
deleted file mode 100644
index 33f2441519..0000000000
--- a/ext/enchant/php_enchant.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Pierre-Alain Joye <paj@pearfr.org> |
- +----------------------------------------------------------------------+
-
- $Id$
-*/
-
-#ifndef PHP_ENCHANT_H
-#define PHP_ENCHANT_H
-
-extern zend_module_entry enchant_module_entry;
-#define phpext_enchant_ptr &enchant_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_ENCHANT_API __declspec(dllexport)
-#else
-#define PHP_ENCHANT_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-static void php_enchant_broker_free(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-static void php_enchant_dict_free(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-
-PHP_MINIT_FUNCTION(enchant);
-PHP_MSHUTDOWN_FUNCTION(enchant);
-PHP_MINFO_FUNCTION(enchant);
-
-PHP_FUNCTION(enchant_broker_init);
-PHP_FUNCTION(enchant_broker_free);
-PHP_FUNCTION(enchant_broker_get_error);
-PHP_FUNCTION(enchant_broker_list_dicts);
-PHP_FUNCTION(enchant_broker_request_dict);
-PHP_FUNCTION(enchant_broker_request_pwl_dict);
-PHP_FUNCTION(enchant_broker_free_dict);
-PHP_FUNCTION(enchant_broker_dict_exists);
-PHP_FUNCTION(enchant_broker_set_ordering);
-PHP_FUNCTION(enchant_broker_describe);
-
-PHP_FUNCTION(enchant_dict_check);
-PHP_FUNCTION(enchant_dict_suggest);
-PHP_FUNCTION(enchant_dict_add_to_personal);
-PHP_FUNCTION(enchant_dict_add_to_session);
-PHP_FUNCTION(enchant_dict_is_in_session);
-PHP_FUNCTION(enchant_dict_store_replacement);
-PHP_FUNCTION(enchant_dict_get_error);
-PHP_FUNCTION(enchant_dict_describe);
-PHP_FUNCTION(enchant_dict_quick_check);
-
-#ifdef ZTS
-#define ENCHANT_G(v) TSRMG(enchant_globals_id, zend_enchant_globals *, v)
-#else
-#define ENCHANT_G(v) (enchant_globals.v)
-#endif
-
-#endif /* PHP_ENCHANT_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- */
-
diff --git a/ext/enchant/tests/broker_describe.phpt b/ext/enchant/tests/broker_describe.phpt
deleted file mode 100644
index 4c03f6f4dd..0000000000
--- a/ext/enchant/tests/broker_describe.phpt
+++ /dev/null
@@ -1,28 +0,0 @@
---TEST--
-enchant_broker_describe() function
---SKIPIF--
-<?php
-if(!extension_loaded('enchant')) die('skip, enchant not loader');
-
- ?>
---FILE--
-<?php
-$broker = enchant_broker_init();
-
-if(!$broker) exit("failed, broker_init failure\n");
-
-$provides = enchant_broker_describe($broker);
-
-if (is_array($provides)) {
- foreach ($provides as $backend) {
- if (!(isset($backend['name']) && isset($backend['desc']) && isset($backend['file']))) {
- exit("failed\n");
- }
- }
- exit("OK\n");
-} else {
- echo "failed";
-}
-?>
---EXPECTF--
-OK
diff --git a/ext/enchant/tests/broker_free.phpt b/ext/enchant/tests/broker_free.phpt
deleted file mode 100644
index d00c22a974..0000000000
--- a/ext/enchant/tests/broker_free.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-enchant_broker_free() function
---SKIPIF--
-<?php
-if(!extension_loaded('enchant')) die('skip, enchant not loader');
-
- ?>
---FILE--
-<?php
-$broker = enchant_broker_init();
-if (is_resource($broker)) {
- echo "OK\n";
- enchant_broker_free($broker);
-} else {
- exit("init failed\n");
-}
-echo "OK\n";
-?>
---EXPECT--
-OK
-OK
diff --git a/ext/enchant/tests/broker_init.phpt b/ext/enchant/tests/broker_init.phpt
deleted file mode 100644
index 359a653359..0000000000
--- a/ext/enchant/tests/broker_init.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-enchant_broker_init() function
---SKIPIF--
-<?php
-if(!extension_loaded('enchant')) die('skip, enchant not loader');
-
- ?>
---FILE--
-<?php
-$broker = enchant_broker_init();
-echo is_resource($broker) ? "OK" : "Failure";
-echo "\n";
-?>
---EXPECT--
-OK
diff --git a/ext/enchant/tests/broker_request_dict.phpt b/ext/enchant/tests/broker_request_dict.phpt
deleted file mode 100644
index 5744da6747..0000000000
--- a/ext/enchant/tests/broker_request_dict.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-enchant_broker_request_dict() function
---SKIPIF--
-<?php
-if(!extension_loaded('enchant')) die('skip, enchant not loader');
-?>
---FILE--
-<?php
-$broker = enchant_broker_init();
-if (!is_resource($broker)) {
- exit("init failed\n");
-}
-
-$dicts = enchant_broker_list_dicts($broker);
-if (is_array($dicts)) {
- if (count($dicts)) {
- $dict = enchant_broker_request_dict($broker, $dicts[0]['lang_tag']);
- if (is_resource($dict)) {
- echo "OK\n";
- } else {
- echo "fail to request " . $dicts[0]['lang_tag'];
- }
- }
-} else {
- exit("list dicts failed\n");
-}
-echo "OK\n";
-?>
---EXPECT--
-OK
-OK
diff --git a/ext/enchant/tests/hindi_correct.txt b/ext/enchant/tests/hindi_correct.txt
deleted file mode 100644
index cced6b86fa..0000000000
--- a/ext/enchant/tests/hindi_correct.txt
+++ /dev/null
@@ -1 +0,0 @@
-इस पृष्ठ में एक लिंक बनाने के लिये इस प्रतीक को खीचें व छोड़ें
diff --git a/ext/enchant/tests/hindi_incorrect.txt b/ext/enchant/tests/hindi_incorrect.txt
deleted file mode 100644
index 1f7353c958..0000000000
--- a/ext/enchant/tests/hindi_incorrect.txt
+++ /dev/null
@@ -1 +0,0 @@
-इस पृष्ठ में एक लिंक बनाने के लिये इस प्रतीक को खच व छड
diff --git a/ext/fileinfo/CREDITS b/ext/fileinfo/CREDITS
deleted file mode 100644
index 6251d1b110..0000000000
--- a/ext/fileinfo/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-fileinfo
-Ilia Alshanetsky
diff --git a/ext/fileinfo/EXPERIMENTAL b/ext/fileinfo/EXPERIMENTAL
deleted file mode 100644
index e69de29bb2..0000000000
--- a/ext/fileinfo/EXPERIMENTAL
+++ /dev/null
diff --git a/ext/fileinfo/config.m4 b/ext/fileinfo/config.m4
deleted file mode 100644
index f1c15c006b..0000000000
--- a/ext/fileinfo/config.m4
+++ /dev/null
@@ -1,62 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension fileinfo
-
-PHP_ARG_WITH(fileinfo, for fileinfo support,
-[ --with-fileinfo=DIR Include fileinfo support])
-
-if test "$PHP_FILEINFO" != "no"; then
- SEARCH_PATH="/usr/local /usr /usr/share/file"
- if test -r $PHP_FILEINFO/include/magic.h || test -r $PHP_FILEINFO/magic.h; then
- FILEINFO_DIR=$PHP_FILEINFO
- else
- AC_MSG_CHECKING([for magic files in default path])
- for i in $SEARCH_PATH ; do
- if test -r $i/include/magic.h || test -r $i/magic.h; then
- FILEINFO_DIR=$i
- AC_MSG_RESULT(found in $i)
- break
- fi
- done
- fi
-
- if test -z "$FILEINFO_DIR"; then
- AC_MSG_RESULT([not found])
- AC_MSG_ERROR([Please reinstall the libmagic distribution])
- fi
-
- if test -r "$FILEINFO_DIR/include/magic.h"; then
- PHP_ADD_INCLUDE($FILEINFO_DIR/include)
- else
- PHP_ADD_INCLUDE($FILEINFO_DIR)
- fi
-
- LIBNAME=magic
- LIBSYMBOL=magic_open
-
- PHP_CHECK_FUNC(dl, dlopen)
- PHP_CHECK_FUNC(gzgets, z)
- PHP_CHECK_FUNC(round, m)
-
- PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
- [
- PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $FILEINFO_DIR/lib, FILEINFO_SHARED_LIBADD)
- AC_DEFINE(HAVE_FILEINFOLIB,1,[ ])
- ],[
- AC_MSG_ERROR([wrong magic lib version or lib not found])
- ],[
- -L$FILEINFO_DIR/lib
- ])
-
- MAGIC_MIME_LOCATIONS="/usr/local/share/file/magic /usr/share/file/magic /usr/share/misc/file/magic /etc/magic /usr/share/misc"
- for i in $MAGIC_MIME_LOCATIONS; do
- if test -f $i; then
- PHP_DEFAULT_MAGIC_FILE=$i
- break
- fi
- done
- AC_DEFINE_UNQUOTED(PHP_DEFAULT_MAGIC_FILE,"$PHP_DEFAULT_MAGIC_FILE",[magic file path])
-
- PHP_SUBST(FILEINFO_SHARED_LIBADD)
-
- PHP_NEW_EXTENSION(fileinfo, fileinfo.c, $ext_shared)
-fi
diff --git a/ext/fileinfo/config.w32 b/ext/fileinfo/config.w32
deleted file mode 100644
index 08d09e61f5..0000000000
--- a/ext/fileinfo/config.w32
+++ /dev/null
@@ -1,13 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("fileinfo", "fileinfo support", "no");
-
-if (PHP_FILEINFO != 'no' &&
- CHECK_HEADER_ADD_INCLUDE('magic.h', 'CFLAGS_FILEINFO') &&
- CHECK_LIB(PHP_DEBUG != 'no'?'libmagic-staticd.lib':'libmagic-static.lib',
- 'fileinfo', PHP_FILEINFO)) {
- EXTENSION('fileinfo', 'fileinfo.c');
- AC_DEFINE('USE_MAGIC_STATIC', '', '');
-}
-
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
deleted file mode 100644
index 4f3d0cb1e6..0000000000
--- a/ext/fileinfo/fileinfo.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Ilia Alshanetsky <ilia@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "php.h"
-
-#include <magic.h>
-/*
- * HOWMANY specifies the maximum offset libmagic will look at
- * this is currently hardcoded in the libmagic source but not exported
- */
-#ifndef HOWMANY
-#define HOWMANY 65536
-#endif
-
-
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "ext/standard/file.h" /* needed for context stuff */
-#include "php_fileinfo.h"
-#include "fopen_wrappers.h" /* needed for is_url */
-
-struct php_fileinfo {
- long options;
- struct magic_set *magic;
-};
-
-#ifndef PHP_DEFAULT_MAGIC_FILE
-#define PHP_DEFAULT_MAGIC_FILE NULL
-#endif
-
-#ifdef ZEND_ENGINE_2
-
-static zend_object_handlers finfo_object_handlers;
-zend_class_entry *finfo_class_entry;
-
-struct finfo_object {
- zend_object zo;
- struct php_fileinfo *ptr;
-};
-
-#define FILEINFO_DECLARE_INIT_OBJECT(object) \
- zval *object = getThis();
-
-#define FILEINFO_REGISTER_OBJECT(_object, _ptr) \
-{ \
- struct finfo_object *obj; \
- obj = (struct finfo_object*)zend_object_store_get_object(_object TSRMLS_CC); \
- obj->ptr = _ptr; \
-}
-
-#define FILEINFO_FROM_OBJECT(finfo, object) \
-{ \
- struct finfo_object *obj = zend_object_store_get_object(object TSRMLS_CC); \
- finfo = obj->ptr; \
- if (!finfo) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The invalid fileinfo object."); \
- RETURN_FALSE; \
- } \
-}
-
-/* {{{ finfo_objects_dtor
- */
-static void finfo_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC)
-{
- struct finfo_object *intern = (struct finfo_object *) object;
-
- if (intern->ptr) {
- magic_close(intern->ptr->magic);
- efree(intern->ptr);
- }
-
- efree(intern);
-}
-/* }}} */
-
-/* {{{ finfo_objects_new
- */
-PHP_FILEINFO_API zend_object_value finfo_objects_new(zend_class_entry *class_type TSRMLS_DC)
-{
- zend_object_value retval;
- struct finfo_object *intern;
-
- intern = ecalloc(1, sizeof(struct finfo_object));
- intern->zo.ce = class_type;
- intern->zo.properties = NULL;
-#if ZEND_MODULE_API_NO >= 20050922
- intern->zo.guards = NULL;
-#else
- intern->zo.in_get = 0;
- intern->zo.in_set = 0;
-#endif
- intern->ptr = NULL;
-
- retval.handle = zend_objects_store_put(intern, finfo_objects_dtor, NULL, NULL TSRMLS_CC);
- retval.handlers = (zend_object_handlers *) &finfo_object_handlers;
-
- return retval;
-}
-/* }}} */
-
-/* {{{ finfo_class_functions
- */
-function_entry finfo_class_functions[] = {
- ZEND_ME_MAPPING(finfo, finfo_open, NULL)
- ZEND_ME_MAPPING(set_flags, finfo_set_flags,NULL)
- ZEND_ME_MAPPING(file, finfo_file, NULL)
- ZEND_ME_MAPPING(buffer, finfo_buffer, NULL)
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-#else
-
-#define FILEINFO_REGISTER_OBJECT(_object, _ptr) {}
-#define FILEINFO_FROM_OBJECT(socket_id, object) {}
-
-#define FILEINFO_DECLARE_INIT_OBJECT(object)
-#define object 0
-
-#endif
-
-#define FINFO_SET_OPTION(magic, options) \
- if (magic_setflags(magic, options) == -1) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to set option '%ld' %d:%s", \
- options, magic_errno(magic), magic_error(magic)); \
- RETURN_FALSE; \
- }
-
-/* True global resources - no need for thread safety here */
-static int le_fileinfo;
-
-void finfo_resource_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- if (rsrc->ptr) {
- struct php_fileinfo *finfo = (struct php_fileinfo *) rsrc->ptr;
- magic_close(finfo->magic);
- efree(rsrc->ptr);
- rsrc->ptr = NULL;
- }
-}
-
-/* {{{ fileinfo_functions[]
- */
-function_entry fileinfo_functions[] = {
- PHP_FE(finfo_open, NULL)
- PHP_FE(finfo_close, NULL)
- PHP_FE(finfo_set_flags, NULL)
- PHP_FE(finfo_file, NULL)
- PHP_FE(finfo_buffer, NULL)
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(finfo)
-{
-#ifdef ZEND_ENGINE_2
- zend_class_entry _finfo_class_entry;
- INIT_CLASS_ENTRY(_finfo_class_entry, "finfo", finfo_class_functions);
- _finfo_class_entry.create_object = finfo_objects_new;
- finfo_class_entry = zend_register_internal_class(&_finfo_class_entry TSRMLS_CC);
-
- /* copy the standard object handlers to you handler table */
- memcpy(&finfo_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-#endif /* ZEND_ENGINE_2 */
-
- le_fileinfo = zend_register_list_destructors_ex(finfo_resource_destructor, NULL, "file_info", module_number);
-
- REGISTER_LONG_CONSTANT("FILEINFO_NONE", MAGIC_NONE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_SYMLINK", MAGIC_SYMLINK, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_MIME", MAGIC_MIME, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_COMPRESS", MAGIC_COMPRESS, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_DEVICES", MAGIC_DEVICES, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_CONTINUE", MAGIC_CONTINUE, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_PRESERVE_ATIME", MAGIC_PRESERVE_ATIME, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILEINFO_RAW", MAGIC_RAW, CONST_CS|CONST_PERSISTENT);
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ fileinfo_module_entry
- */
-zend_module_entry fileinfo_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- "fileinfo",
- fileinfo_functions,
- PHP_MINIT(finfo),
- NULL,
- NULL,
- NULL,
- PHP_MINFO(fileinfo),
-#if ZEND_MODULE_API_NO >= 20010901
- "0.1", /* Replace with version number for your extension */
-#endif
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_FILEINFO
-ZEND_GET_MODULE(fileinfo)
-#endif
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(fileinfo)
-{
- php_info_print_table_start();
- php_info_print_table_header(2, "fileinfo support", "enabled");
- php_info_print_table_end();
-}
-/* }}} */
-
-/* {{{ proto resource finfo_open([int options [, string arg]])
- Create a new fileinfo resource. */
-PHP_FUNCTION(finfo_open)
-{
- long options = MAGIC_NONE;
- char *file = PHP_DEFAULT_MAGIC_FILE;
- int file_len = 0;
- struct php_fileinfo *finfo;
- FILEINFO_DECLARE_INIT_OBJECT(object)
- char resolved_path[MAXPATHLEN];
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ls", &options, &file, &file_len) == FAILURE) {
- RETURN_FALSE;
- }
-
- if (file_len) { /* user specified filed, perform open_basedir checks */
- if (!VCWD_REALPATH(file, resolved_path)) {
- RETURN_FALSE;
- }
- file = resolved_path;
-
- if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
- RETURN_FALSE;
- }
- }
-
- finfo = emalloc(sizeof(struct php_fileinfo));
-
- finfo->options = options;
- finfo->magic = magic_open(options);
-
- if (finfo->magic == NULL) {
- efree(finfo);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid mode '%ld'.", options);
- RETURN_FALSE;
- }
-
- if (magic_load(finfo->magic, file) == -1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to load magic database at '%s'.", file);
- magic_close(finfo->magic);
- efree(finfo);
- RETURN_FALSE;
- }
-
- if (object) {
- FILEINFO_REGISTER_OBJECT(object, finfo);
- } else {
- ZEND_REGISTER_RESOURCE(return_value, finfo, le_fileinfo);
- }
-}
-/* }}} */
-
-/* {{{ proto resource finfo_close(resource finfo)
- Close fileinfo resource. */
-PHP_FUNCTION(finfo_close)
-{
- struct php_fileinfo *finfo;
- zval *zfinfo;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zfinfo) == FAILURE) {
- RETURN_FALSE;
- }
- ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, "file_info", le_fileinfo);
-
- zend_list_delete(Z_RESVAL_P(zfinfo));
-
- RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool finfo_set_flags(resource finfo, int options)
- Set libmagic configuration options. */
-PHP_FUNCTION(finfo_set_flags)
-{
- long options;
- struct php_fileinfo *finfo;
- zval *zfinfo;
- FILEINFO_DECLARE_INIT_OBJECT(object)
-
- if (object) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &options) == FAILURE) {
- RETURN_FALSE;
- }
- FILEINFO_FROM_OBJECT(finfo, object);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &zfinfo, &options) == FAILURE) {
- RETURN_FALSE;
- }
- ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, "file_info", le_fileinfo);
- }
-
- FINFO_SET_OPTION(finfo->magic, options)
- finfo->options = options;
-
- RETURN_TRUE;
-}
-/* }}} */
-
-static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode)
-{
- long options = 0;
- char *buffer, *tmp, *ret_val;
- int buffer_len;
- struct php_fileinfo *finfo;
- zval *zfinfo, *zcontext = NULL;
- FILEINFO_DECLARE_INIT_OBJECT(object)
-
- if (object) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lbz", &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
- RETURN_FALSE;
- }
- FILEINFO_FROM_OBJECT(finfo, object);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|lbz", &zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) {
- RETURN_FALSE;
- }
- ZEND_FETCH_RESOURCE(finfo, struct php_fileinfo *, &zfinfo, -1, "file_info", le_fileinfo);
- }
-
- /* Set options for the current file/buffer. */
- if (options) {
- FINFO_SET_OPTION(finfo->magic, options)
- }
-
- if (mode) { /* file */
- /* determine if the file is a local file or remote URL */
- char *tmp2;
- php_stream_wrapper *wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_CC);
- if (wrap && wrap->is_url) {
-#ifdef ZEND_ENGINE_2
- php_stream_context *context = php_stream_context_from_zval(zcontext, 0);
-#else
- php_stream_context *context = NULL;
-#endif
- php_stream *stream = php_stream_open_wrapper_ex(buffer, "rb",
- ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
- if (!stream) {
- RETURN_FALSE;
- }
- buffer_len = php_stream_copy_to_mem(stream, &tmp, HOWMANY, 0);
- php_stream_close(stream);
-
- if (buffer_len == 0) {
- RETURN_FALSE;
- }
- } else { /* local file */
- char resolved_path[MAXPATHLEN];
- if (!VCWD_REALPATH(buffer, resolved_path)) {
- RETURN_FALSE;
- }
-
- ret_val = (char *) magic_file(finfo->magic, buffer);
- goto common;
- }
- } else { /* buffer */
- tmp = buffer;
- }
-
- ret_val = (char *) magic_buffer(finfo->magic, tmp, buffer_len);
- if (mode) {
- efree(tmp);
- }
-common:
- /* Restore options */
- if (options) {
- FINFO_SET_OPTION(finfo->magic, finfo->options)
- }
-
- if (!ret_val) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed identify data %d:%s",
- magic_errno(finfo->magic), magic_error(finfo->magic));
- RETURN_FALSE;
- } else {
- RETURN_STRING(ret_val, 1);
- }
-}
-
-/* {{{ proto string finfo_file(resource finfo, char *file_name [, int options [, resource context]])
- Return information about a file. */
-PHP_FUNCTION(finfo_file)
-{
- _php_finfo_get_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto string finfo_buffer(resource finfo, char *string [, int options])
- Return infromation about a string buffer. */
-PHP_FUNCTION(finfo_buffer)
-{
- _php_finfo_get_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/fileinfo/fileinfo.php b/ext/fileinfo/fileinfo.php
deleted file mode 100644
index 1ee9efbeb8..0000000000
--- a/ext/fileinfo/fileinfo.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-if(!extension_loaded('fileinfo')) {
- dl('fileinfo.' . PHP_SHLIB_SUFFIX);
-}
-if(!extension_loaded('fileinfo')) {
- die("fileinfo extension is not avaliable, please compile it.\n");
-}
-
-// normal operation
-$res = finfo_open(FILEINFO_MIME); /* return mime type ala mimetype extension */
-$files = glob("*");
-foreach ($files as $file) {
- echo finfo_file($res, $file) . "\n";
-}
-finfo_close($res);
-
-// OO mode
-/*
- * FILEINFO_PRESERVE_ATIME - if possible preserve the original access time
- * FILEINFO_SYMLINK - follow symlinks
- * FILEINFO_DEVICES - look at the contents of blocks or character special devices
- * FILEINFO_COMPRESS - decompress compressed files
- */
-$fi = new finfo(FILEINFO_PRESERVE_ATIME|FILEINFO_SYMLINK|FILEINFO_DEVICES|FILEINFO_COMPRESS);
-$files = glob("*");
-foreach ($files as $file) {
- echo $fi->buffer(file_get_contents($file)) . "\n";
-}
-?>
diff --git a/ext/fileinfo/package.xml b/ext/fileinfo/package.xml
deleted file mode 100644
index fd3fdab384..0000000000
--- a/ext/fileinfo/package.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package>
- <name>Fileinfo</name>
- <summary>libmagic bindings</summary>
- <maintainers>
- <maintainer>
- <user>iliaa</user>
- <name>Ilia Alshanetsky</name>
- <email>ilia@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <description>
-This extension allows retrieval of information regarding vast majority of file.
-This information may include dimensions, quality, length etc...
-
-Additionally it can also be used to retrieve the mime type for a particular
-file and for text files proper language encoding.
- </description>
- <license>PHP</license>
- <release>
- <state>stable</state>
- <version>1.0.2</version>
- <date>2005-12-05</date>
- <notes>
- 1) Allow build against 5.1 and 5.0 versions of PHP
- </notes>
- <filelist>
- <file role="src" name="config.m4"/>
- <file role="src" name="fileinfo.c"/>
- <file role="src" name="php_fileinfo.h"/>
- <file role="doc" name="CREDITS"/>
- <file role="doc" name="EXPERIMENTAL"/>
- <file role="doc" name="fileinfo.php"/>
- </filelist>
- <deps>
- </deps>
- </release>
-</package>
-<!--
-vim:et:ts=1:sw=1
--->
diff --git a/ext/fileinfo/php_fileinfo.h b/ext/fileinfo/php_fileinfo.h
deleted file mode 100644
index 66c562172d..0000000000
--- a/ext/fileinfo/php_fileinfo.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Ilia Alshanetsky <ilia@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_FILEINFO_H
-#define PHP_FILEINFO_H
-
-extern zend_module_entry fileinfo_module_entry;
-#define phpext_fileinfo_ptr &fileinfo_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_FILEINFO_API __declspec(dllexport)
-#else
-#define PHP_FILEINFO_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-PHP_MINFO_FUNCTION(fileinfo);
-
-PHP_FUNCTION(finfo_open);
-PHP_FUNCTION(finfo_close);
-PHP_FUNCTION(finfo_set_flags);
-PHP_FUNCTION(finfo_file);
-PHP_FUNCTION(finfo_buffer);
-
-#ifdef ZTS
-#define FILEINFO_G(v) TSRMG(fileinfo_globals_id, zend_fileinfo_globals *, v)
-#else
-#define FILEINFO_G(v) (fileinfo_globals.v)
-#endif
-
-#endif /* PHP_FILEINFO_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/filter/CREDITS b/ext/filter/CREDITS
deleted file mode 100644
index fade411d07..0000000000
--- a/ext/filter/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Input Filter
-Rasmus Lerdorf, Derick Rethans
diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c
deleted file mode 100644
index 5ce17fe23f..0000000000
--- a/ext/filter/callback_filter.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php_filter.h"
-
-void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
-{
- char *name = NULL;
- zval *retval_ptr;
- zval ***args;
- int status;
-
- if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, &name)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback");
- if (name) {
- efree(name);
- }
- zval_dtor(value);
- Z_TYPE_P(value) = IS_NULL;
- return;
- }
- efree(name);
-
- args = safe_emalloc(sizeof(zval **), 1, 0);
- args[0] = &value;
-
- status = call_user_function_ex(EG(function_table), NULL, option_array, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
-
- if (status == SUCCESS && retval_ptr != NULL) {
- zval_dtor(value);
- *value = *retval_ptr;
- zval_copy_ctor(value);
- } else {
- zval_dtor(value);
- Z_TYPE_P(value) = IS_NULL;
- }
-
- if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
- }
- efree(args);
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/filter/config.m4 b/ext/filter/config.m4
deleted file mode 100644
index 0db0375e26..0000000000
--- a/ext/filter/config.m4
+++ /dev/null
@@ -1,95 +0,0 @@
-dnl $Id$
-dnl config.m4 for input filtering extension
-
-PHP_ARG_ENABLE(filter, whether to enable input filter support,
-[ --disable-filter Disable input filter support], yes)
-
-PHP_ARG_WITH(pcre-dir, pcre install prefix,
-[ --with-pcre-dir FILTER: pcre install prefix], no, no)
-
-if test "$PHP_FILTER" != "no"; then
-
- dnl Check if configure is the PHP core configure
- if test -n "$PHP_VERSION"; then
- dnl This extension can not be build as shared when in PHP core
- ext_shared=no
- else
- dnl This is PECL build, check if bundled PCRE library is used
- old_CPPFLAGS=$CPPFLAGS
- CPPFLAGS=$INCLUDES
- AC_EGREP_CPP(yes,[
-#include <main/php_config.h>
-#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
-yes
-#endif
- ],[
- PHP_PCRE_REGEX=yes
- ],[
- AC_EGREP_CPP(yes,[
-#include <main/php_config.h>
-#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
-yes
-#endif
- ],[
- PHP_PCRE_REGEX=pecl
- ],[
- PHP_PCRE_REGEX=no
- ])
- ])
- CPPFLAGS=$old_CPPFLAGS
- fi
-
- if test "$PHP_PCRE_REGEX" != "yes"; then
- dnl
- dnl If PCRE extension is enabled we can use the already found paths,
- dnl otherwise we have to detect them here:
- dnl
- if test "$PHP_PCRE_REGEX" = "no" || test "$PHP_PCRE_REGEX" = "pecl"; then
- dnl Set the PCRE search dirs correctly
- case "$PHP_PCRE_DIR" in
- yes|no)
- PCRE_SEARCH_DIR="/usr/local /usr"
- ;;
- *)
- PCRE_SEARCH_DIR="$PHP_PCRE_DIR"
- ;;
- esac
-
- for i in $PCRE_SEARCH_DIR; do
- if test -f $i/include/pcre/pcre.h; then
- PCRE_INCDIR=$i/include/pcre
- break
- elif test -f $i/include/pcre.h; then
- PCRE_INCDIR=$i/include
- break
- elif test -f $i/pcre.h; then
- PCRE_INCDIR=$i
- break
- fi
- done
-
- if test -z "$PCRE_INCDIR"; then
- AC_MSG_ERROR([Could not find pcre.h anywhere under $PCRE_SEARCH_DIR])
- fi
-
- for j in $PCRE_SEARCH_DIR/$PHP_LIBDIR $PCRE_SEARCH_DIR; do
- if test -f $j/libpcre.a || test -f $j/libpcre.$SHLIB_SUFFIX_NAME; then
- PCRE_LIBDIR=$j
- break
- fi
- done
-
- if test -z "$PCRE_LIBDIR" ; then
- AC_MSG_ERROR([Could not find libpcre.(a|$SHLIB_SUFFIX_NAME) anywhere under $PCRE_SEARCH_DIR])
- fi
- fi
-
- PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, FILTER_SHARED_LIBADD)
- PHP_ADD_INCLUDE($PCRE_INCDIR)
- fi
-
- PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared)
- PHP_SUBST(FILTER_SHARED_LIBADD)
-
- PHP_INSTALL_HEADERS([$ext_srcdir/php_filter.h])
-fi
diff --git a/ext/filter/config.w32 b/ext/filter/config.w32
deleted file mode 100644
index 083555a4c7..0000000000
--- a/ext/filter/config.w32
+++ /dev/null
@@ -1,8 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_ENABLE("filter", "Filter Support", "yes");
-
-if (PHP_FILTER == "yes") {
- EXTENSION("filter", "filter.c sanitizing_filters.c logical_filters.c callback_filter.c");
-}
diff --git a/ext/filter/docs/filter.txt b/ext/filter/docs/filter.txt
deleted file mode 100644
index 48aae0c8d5..0000000000
--- a/ext/filter/docs/filter.txt
+++ /dev/null
@@ -1,331 +0,0 @@
-Input Filter Extension
-~~~~~~~~~~~~~~~~~~~~~~
-
-Introduction
-============
-We all know that you should always check input variables, but PHP does not
-offer really good functionality for doing this in a safe way. The Input Filter
-extension is meant to address this issue by implementing a set of filters and
-mechanisms that users can use to safely access their input data.
-
-
-Change Log
-==========
-2005-10-27
- * Updated filter_data prototype
- * Added filter constants
- * Fixed minor problems
- * Changes by David Tulloh
-
-2005-10-05
- * Changed "input_filter.paranoid_admin_default_filter" to
- "filter.default".
- * Updated API prototypes to reflect implementation.
- * Added 'on' and 'off' to the boolean filter.
- * Removed min_range and max_range flags from the float filter.
- * Added validate_url, validate_email and validate_ip filters.
- * Updated allows flags for all filters.
-
-2005-08-15
- * Unmade *source* a bitmask, it doesn't make sense to do.
- * Changed return value of filters which got invalid data from 'false' to
- 'null.
- * Failed filters do not throw an E_NOTICE any longer.
- * Added a magic_quotes sanitizing filter.
-
-
-General Considerations
-======================
-* If the filter's expected input data mask does not match the provided data
- for logical filters the filter function returns "false". If the data was
- not found, "null" is returned.
-* Character filters always return a string.
-* With the input filter extension enabled, and the
- input_filter.paranoid_admin_default_filter is set to something != 'raw',
- then all entries in the affected super globals will be passed through the
- configured filter. The 'callback' filter can not be used here, as that
- requieres a PHP script to be running already.
-* As the input filter acts on input data before the magic quotes function
- mangles data, all access through the filter() function will not have any
- quotes or slashes added - it will be the pure data as send by the browser.
-* All flags mentioned here should be prepended with `FILTER_FLAG_` when used
- with PHP.
-
-
-API
-===
-mixed *input_get* (int *source*, string *name*, [, int *filter* [, mixed *filter_options*, [ string *characterset* ] ]);
- Returns the filtered variable *$name* from source *$source*. It uses the
- filter as specified in *$filter* with a constant, and additional options
- to the filter through *$filter_options*.
-
-mixed *input_get_args* (array *definitions*, int *source*, [, array *data*]);
- Returns an array with all filtered variables defined in 'definition'.
- The keys are used as the name of the argument. The value can be either
- an integer (flags) or an array of options. This array can contain
- the 'filter' type, the 'flags', the 'otptions' or the 'charset'
-
-bool *input_has_variable (int *source*, string *name*);
- Returns *true* if the variable with the name *name* exists in *source*, or
- *false* otherwise.
-
-array *input_filters_list* ();
- Returns a list with all supported filter names.
-
-mixed *filter_data* (mixed *variable*, int *filter* [, mixed *filter_options*, [ string *characterset* ] ]);
- Filters the user supplied variable *$variable* in the same manner as
- *input_get*.
-
-*$source*:
-
-* INPUT_POST 0
-* INPUT_GET 1
-* INPUT_COOKIE 2
-* INPUT_ENV 4
-* INPUT_SERVER 5 (not implemented yet)
-* INPUT_SESSION 6 (not implemented yet)
-
-
-General flags
-=============
-
-* FILTER_FLAG_SCALAR
-* FILTER_FLAG_ARRAY
-
-These two constants define whether to allow arrays in the source values. The
-default value is SCALAR for input_get_args and ARRAY for the other functions
-(< 0.9.5). These constants also insure that the function returns the correct
-type, if you ask for an array, you will get an array even if the source is
-only one value. However, if you ask for a scalar and the source is an array,
-the result will be FALSE (invalid).
-
-
-Logical Filters
-===============
-
-These filters check whether passed data was valid, and do never mangle input
-variables, but ofcourse they can deny the whole input variable getting to the
-application by returning false.
-
-The constants should be prepended by `FILTER_VALIDATE_` when used with php.
-
-================ ========== =========== ==================================================
-Name Constant Return Type Description
-================ ========== =========== ==================================================
-int INT integer Returns the input variable as an integer
-
- $filter_options - an array with the optional
- elements:
-
- * min_range: Minimal number that is allowed
- (inclusive)
- * max_range: Maximum number that is allowed
- (inclusive)
- * flags: A bitmask supporting the following flags:
-
- - ALLOW_OCTAL: allow octal numbers with the format
- 0nn as input too.
- - ALLOW_HEX: allow hexadecimal numbers with the
- format 0xnn or 0Xnn too.
-
-boolean BOOLEAN boolean Returns *true* for '1', 'on' and 'true' and *false*
- for '0', 'off' and 'false'
-
-float FLOAT float Returns the input variable as a floating point value
-
-validate_regexp REGEXP string Matches the input value as a string against the
- regular expression. If there is a match then the
- string is returned, otherwise the filter returns
- *null*.
- Remarks: Only available if pcre has been compiled
- into PHP.
-
-validate_url URL string Validates an URL's format.
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * SCHEME_REQUIRED: The 'schema' part of the URL
- needs to in the passed URL.
- * HOST_REQUIRED: The 'host' part of the URL
- needs to in the passed URL.
- * PATH_REQUIRED: The 'path' part of the URL
- needs to in the passed URL.
- * QUERY_REQUIRED: The 'query' part of the URL
- needs to in the passed URL.
-
-validate_email EMAIL string Validates the passed string against a reasonably
- good regular expression for validating an email
- address.
-
-validate_ip IP string Validates a string representing an IP address.
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * IPV4: Allows IPv4 addresses.
- * IPV6: Allows IPv6 addresses.
- * NO_RES_RANGE: Disallows addresses in reversed
- ranges (IPv4 only)
- * NO_PRIV_RANGE: Disallows addresses in private
- ranges (IPv4 only)
-================ ========== =========== ==================================================
-
-
-Sanitizing Filters
-==================
-
-These filters remove data, or change data depending on the filter, and the
-set rules for this specific filter. Instead of taking an *options* array, they
-use this parameter for flags for the specific filter.
-
-The constants should be prepended by `FILTER_SANITIZE_` when used with php.
-
-============= ================ =========== =====================================================
-Name Constant Return Type Description
-============= ================ =========== =====================================================
-string STRING string Returns the input variable as a string after it has
- been stripped of XML/HTML tags and other evil things
- that can cause XSS problems.
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * NO_ENCODE_QUOTES: Prevents single and double
- quotes from being encoded as numerical HTML
- entities.
- * STRIP_LOW: excludes all characters < 0x20 from the
- allowed character list
- * STRIP_HIGH: excludes all characters >= 0x80 from
- the allowed character list
- * ENCODE_LOW: allows characters < 0x20 but encodes
- them as numerical HTML entities
- * ENCODE_HIGH: allows characters >= 0x80 but encodes
- them as numerical HTML entities
- * ENCODE_AMP: encodes & as &amp;
-
- The flags STRIP_LOW and ENCODE_LOW are mutual
- exclusive, and so are STRIP_HIGH and ENCODE_HIGH. In
- the case they clash, the characters will be
- stripped.
-
-stripped STRIPPED string Alias for 'string'.
-
-encoded ENCODED string Encodes all characters outside the range
- "a-zA-Z0-9-._" as URL encoded values.
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * STRIP_LOW: excludes all characters < 0x20 from the
- allowed character list
- * STRIP_HIGH: excludes all characters >= 0x80 from
- the allowed character list
- * ENCODE_LOW: allows characters < 0x20 but encodes
- them as numerical HTML entities
- * ENCODE_HIGH: allows characters >= 0x80 but encodes
- them as numerical HTML entities
-
-special_chars SPECIAL_CHARS string Encodes the 'special' characters ' " < > &, \0 and
- everything below 0x20 as numerical HTML entities.
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * STRIP_LOW: excludes all characters < 0x20 from the
- allowed character list. If this is not set, then
- those characters are encoded as numerical HTML
- entities
- * STRIP_HIGH: excludes all characters >= 0x80 from
- the allowed character list
- * ENCODE_HIGH: allows characters >= 0x80 but encodes
- them as numerical HTML entities
-
-unsafe_raw UNSAFE_RAW string Returns the input variable as a string without
- XML/HTML being stripped from the input value.
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * STRIP_LOW: excludes all characters < 0x20 from the
- allowed character list
- * STRIP_HIGH: excludes all characters >= 0x80 from
- the allowed character list
- * ENCODE_LOW: allows characters < 0x20 but encodes
- them as numerical HTML entities
- * ENCODE_HIGH: allows characters >= 0x80 but encodes
- them as numerical HTML entities
- * ENCODE_AMP: encodes & as &amp;
-
- The flags STRIP_LOW and ENCODE_LOW are mutual
- exclusive, and so are STRIP_HIGH and ENCODE_HIGH. In
- the case they clash, the characters will be
- stripped.
-
-email EMAIL string Removes all characters that can not be part of a
- correctly formed e-mail address (exception are
- comments in the email address) (a-z A-Z 0-9 " ! # $
- % & ' * + - / = ? ^ _ ` { | } ~ @ . [ ]). This
- filter does `not` validate if the e-mail address has
- the correct format, use the validate_email filter
- for that.
-
-url URL string Removes all characters that can not be part of a
- correctly formed URI. (a-z A-Z 0-9 $ - _ . + ! * ' (
- ) , { } | \ ^ ~ [ ] ` < > # % " ; / ? : @ & =) This
- filter does `not` validate if a URI has the correct
- format, use the validate_url filter for that.
-
-number_int NUMBER_INT int Removes all characters that are [^0-9+-].
-
-number_float NUMBER_FLOAT float Removes all characters that are [^0-9+-].
-
- $filter_options - an bitmask that supports the
- following flags:
-
- * ALLOW_FRACTION: adds "." to the characters that
- are not stripped.
- * ALLOW_THOUSAND: adds "," to the characters that
- are not stripped.
- * ALLOW_SCIENTIFIC: adds "eE" to the characters that
- are not stripped.
-
-magic_quotes MAGIC_QUOTES string BC filter for people who like magic quotes.
-============= ================ =========== =====================================================
-
-
-Callback Filter
-===============
-
-This filter will callback to the specified callback function as specified with
-the *filter_options* parameter. All variants of callback functions are
-supported:
-
-* function with *'functionname'*
-* static method with *array('classname', 'methodname')*
-* dynamic method with *array(&$this, 'methodname')*
-
-The constants should be prepended by `FILTER_` when used with php.
-
-============= =========== =========== =====================================================
-Name Constant Return Type Description
-============= =========== =========== =====================================================
-callback CALLBACK mixed Calls the callback function/method with the input
- variable's value by reference which can do filtering
- and modifying of the input value. If the callback
- function returns "false" then the input value is
- supposed to be incorrect and the returned value will
- be 'false' (and an E_NOTICE will be raised).
-============= =========== =========== =====================================================
-
-The callback function's prototype is:
-
-boolean callback(&$value, $characterset);
- With *$value* being a reference to the input variable and *$characterset*
- containing the same value as this parameter's value in the call to
- *input_get()* or *input_get_array()*. If the *$characterset* parameter was
- not passed, it defaults to *'null'*.
-
-Version: $Id$
-.. vim: et syn=rst tw=78
-
diff --git a/ext/filter/docs/input_get_args.php b/ext/filter/docs/input_get_args.php
deleted file mode 100644
index b580524489..0000000000
--- a/ext/filter/docs/input_get_args.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-error_reporting(E_ALL|E_STRICT);
-$data = array(
- 'product_id' => 'product id<script>',
- 'component' => '10',
- 'versions' => '1.2.33',
- 'testscalar' => array('2','23','10','12'),
- 'testarray' => '2',
-);
-
-$args = array(
- 'product_id' => FILTER_SANITIZE_ENCODED,
- 'component' => array('filter' => FILTER_VALIDATE_INT,
- 'flags' => FILTER_FLAG_ARRAY,
- 'options' => array("min_range"=>1, "max_range"=>10)
- ),
-
- /* equivalent of => FILTER_SANITIZE_ENCODED as SCALAR is
- * the default mode
- */
- 'versions' => array(
- 'filter' => FILTER_SANITIZE_ENCODED,
- 'flags' => FILTER_FLAG_SCALAR,
- ),
- 'doesnotexist' => FILTER_VALIDATE_INT,
- 'testscalar' => FILTER_VALIDATE_INT,
- 'testarray' => array(
- 'filter' => FILTER_VALIDATE_INT,
- 'flags' => FILTER_FLAG_ARRAY,
- )
-
-);
-
-/*
-The other INPUT_* can be used as well.
-$myinputs = input_get_args($args, INPUT_POST);
-*/
-$myinputs = input_get_args($args, INPUT_DATA, $data);
-
-var_dump($myinputs);
-
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
deleted file mode 100644
index 96a5a2d666..0000000000
--- a/ext/filter/filter.c
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | Derick Rethans <derick@php.net> |
- | Pierre-A. Joye <pierre@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php_filter.h"
-
-ZEND_DECLARE_MODULE_GLOBALS(filter)
-
-#include "filter_private.h"
-
-typedef struct filter_list_entry {
- char *name;
- int id;
- void (*function)(PHP_INPUT_FILTER_PARAM_DECL);
-} filter_list_entry;
-
-/* {{{ filter_list */
-filter_list_entry filter_list[] = {
- { "int", FILTER_VALIDATE_INT, php_filter_int },
- { "boolean", FILTER_VALIDATE_BOOLEAN, php_filter_boolean },
- { "float", FILTER_VALIDATE_FLOAT, php_filter_float },
-
- { "validate_regexp", FILTER_VALIDATE_REGEXP, php_filter_validate_regexp },
- { "validate_url", FILTER_VALIDATE_URL, php_filter_validate_url },
- { "validate_email", FILTER_VALIDATE_EMAIL, php_filter_validate_email },
- { "validate_ip", FILTER_VALIDATE_IP, php_filter_validate_ip },
-
- { "string", FILTER_SANITIZE_STRING, php_filter_string },
- { "stripped", FILTER_SANITIZE_STRING, php_filter_string },
- { "encoded", FILTER_SANITIZE_ENCODED, php_filter_encoded },
- { "special_chars", FILTER_SANITIZE_SPECIAL_CHARS, php_filter_special_chars },
- { "unsafe_raw", FILTER_UNSAFE_RAW, php_filter_unsafe_raw },
- { "email", FILTER_SANITIZE_EMAIL, php_filter_email },
- { "url", FILTER_SANITIZE_URL, php_filter_url },
- { "number_int", FILTER_SANITIZE_NUMBER_INT, php_filter_number_int },
- { "number_float", FILTER_SANITIZE_NUMBER_FLOAT, php_filter_number_float },
- { "magic_quotes", FILTER_SANITIZE_MAGIC_QUOTES, php_filter_magic_quotes },
-
- { "callback", FILTER_CALLBACK, php_filter_callback },
-};
-/* }}} */
-
-#ifndef PARSE_ENV
-#define PARSE_ENV 4
-#endif
-
-#ifndef PARSE_SERVER
-#define PARSE_SERVER 5
-#endif
-
-#ifndef PARSE_SESSION
-#define PARSE_SESSION 6
-#endif
-
-#ifndef PARSE_DATA
-#define PARSE_DATA 7
-#endif
-
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
-
-/* {{{ filter_functions[]
- */
-zend_function_entry filter_functions[] = {
- PHP_FE(input_get, NULL)
- PHP_FE(input_get_args, NULL)
- PHP_FE(input_filters_list, NULL)
- PHP_FE(input_has_variable, NULL)
- PHP_FE(input_name_to_filter, NULL)
- PHP_FE(filter_data, NULL)
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ filter_module_entry
- */
-zend_module_entry filter_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- "filter",
- filter_functions,
- PHP_MINIT(filter),
- PHP_MSHUTDOWN(filter),
- NULL,
- PHP_RSHUTDOWN(filter),
- PHP_MINFO(filter),
- "0.9.5-dev",
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_FILTER
-ZEND_GET_MODULE(filter)
-#endif
-
-static PHP_INI_MH(UpdateDefaultFilter) /* {{{ */
-{
- int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
-
- for (i = 0; i < size; ++i) {
- if ((strcasecmp(new_value, filter_list[i].name) == 0)) {
- IF_G(default_filter) = filter_list[i].id;
- return SUCCESS;
- }
- }
- /* Fallback to "string" filter */
- IF_G(default_filter) = FILTER_DEFAULT;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_INI
- */
-static PHP_INI_MH(OnUpdateFlags)
-{
- if (!new_value) {
- IF_G(default_filter_flags) = FILTER_FLAG_NO_ENCODE_QUOTES;
- } else {
- IF_G(default_filter_flags) = atoi(new_value);
- }
- return SUCCESS;
-}
-
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("filter.default", "unsafe_raw", PHP_INI_SYSTEM|PHP_INI_PERDIR, UpdateDefaultFilter, default_filter, zend_filter_globals, filter_globals)
- PHP_INI_ENTRY("filter.default_flags", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateFlags)
-PHP_INI_END()
-/* }}} */
-
-static void php_filter_init_globals(zend_filter_globals *filter_globals) /* {{{ */
-{
- filter_globals->post_array = NULL;
- filter_globals->get_array = NULL;
- filter_globals->cookie_array = NULL;
- filter_globals->env_array = NULL;
- filter_globals->server_array = NULL;
- filter_globals->session_array = NULL;
- filter_globals->default_filter = FILTER_DEFAULT;
-}
-/* }}} */
-
-#define PARSE_REQUEST 99
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(filter)
-{
- ZEND_INIT_MODULE_GLOBALS(filter, php_filter_init_globals, NULL);
-
- REGISTER_INI_ENTRIES();
-
- REGISTER_LONG_CONSTANT("INPUT_POST", PARSE_POST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_GET", PARSE_GET, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_COOKIE", PARSE_COOKIE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_ENV", PARSE_ENV, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_SERVER", PARSE_SERVER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_SESSION", PARSE_SESSION, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_DATA", PARSE_DATA, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NONE", FILTER_FLAG_NONE, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_SCALAR", FILTER_FLAG_SCALAR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ARRAY", FILTER_FLAG_ARRAY, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_INT", FILTER_VALIDATE_INT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_BOOLEAN", FILTER_VALIDATE_BOOLEAN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_FLOAT", FILTER_VALIDATE_FLOAT, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_REGEXP", FILTER_VALIDATE_REGEXP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_URL", FILTER_VALIDATE_URL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_EMAIL", FILTER_VALIDATE_EMAIL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_VALIDATE_IP", FILTER_VALIDATE_IP, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_DEFAULT", FILTER_DEFAULT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_UNSAFE_RAW", FILTER_UNSAFE_RAW, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRING", FILTER_SANITIZE_STRING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRIPPED", FILTER_SANITIZE_STRING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_ENCODED", FILTER_SANITIZE_ENCODED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_SPECIAL_CHARS", FILTER_SANITIZE_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_EMAIL", FILTER_SANITIZE_EMAIL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_URL", FILTER_SANITIZE_URL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_NUMBER_INT", FILTER_SANITIZE_NUMBER_INT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_NUMBER_FLOAT", FILTER_SANITIZE_NUMBER_FLOAT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_SANITIZE_MAGIC_QUOTES", FILTER_SANITIZE_MAGIC_QUOTES, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_CALLBACK", FILTER_CALLBACK, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_OCTAL", FILTER_FLAG_ALLOW_OCTAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_HEX", FILTER_FLAG_ALLOW_HEX, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_LOW", FILTER_FLAG_STRIP_LOW, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_HIGH", FILTER_FLAG_STRIP_HIGH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_LOW", FILTER_FLAG_ENCODE_LOW, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_HIGH", FILTER_FLAG_ENCODE_HIGH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_AMP", FILTER_FLAG_ENCODE_AMP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_ENCODE_QUOTES", FILTER_FLAG_NO_ENCODE_QUOTES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_EMPTY_STRING_NULL", FILTER_FLAG_EMPTY_STRING_NULL, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_FRACTION", FILTER_FLAG_ALLOW_FRACTION, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_THOUSAND", FILTER_FLAG_ALLOW_THOUSAND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_SCIENTIFIC", FILTER_FLAG_ALLOW_SCIENTIFIC, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_SCHEME_REQUIRED", FILTER_FLAG_SCHEME_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_HOST_REQUIRED", FILTER_FLAG_HOST_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_PATH_REQUIRED", FILTER_FLAG_PATH_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_QUERY_REQUIRED", FILTER_FLAG_QUERY_REQUIRED, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_IPV4", FILTER_FLAG_IPV4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_IPV6", FILTER_FLAG_IPV6, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT);
-
- sapi_register_input_filter(php_sapi_filter);
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MSHUTDOWN_FUNCTION
- */
-PHP_MSHUTDOWN_FUNCTION(filter)
-{
- UNREGISTER_INI_ENTRIES();
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_RSHUTDOWN_FUNCTION
- */
-#define VAR_ARRAY_COPY_DTOR(a) \
- if (IF_G(a)) { \
- zval_ptr_dtor(&IF_G(a)); \
- IF_G(a) = NULL; \
- }
-PHP_RSHUTDOWN_FUNCTION(filter)
-{
- VAR_ARRAY_COPY_DTOR(get_array)
- VAR_ARRAY_COPY_DTOR(post_array)
- VAR_ARRAY_COPY_DTOR(cookie_array)
- VAR_ARRAY_COPY_DTOR(server_array)
- VAR_ARRAY_COPY_DTOR(env_array)
- VAR_ARRAY_COPY_DTOR(session_array)
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(filter)
-{
- php_info_print_table_start();
- php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" );
- php_info_print_table_row( 2, "Revision", "$Revision$");
- php_info_print_table_end();
-
- DISPLAY_INI_ENTRIES();
-}
-/* }}} */
-
-static filter_list_entry php_find_filter(long id) /* {{{ */
-{
- int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
-
- for (i = 0; i < size; ++i) {
- if (filter_list[i].id == id) {
- return filter_list[i];
- }
- }
- /* Fallback to "string" filter */
- for (i = 0; i < size; ++i) {
- if (filter_list[i].id == FILTER_DEFAULT) {
- return filter_list[i];
- }
- }
- /* To shut up GCC */
- return filter_list[0];
-}
-/* }}} */
-
-static void php_zval_filter(zval *value, long filter, long flags, zval *options, char* charset TSRMLS_DC) /* {{{ */
-{
- filter_list_entry filter_func;
-
- filter_func = php_find_filter(filter);
-
- if (!filter_func.id) {
- /* Find default filter */
- filter_func = php_find_filter(FILTER_DEFAULT);
- }
-
- /* Here be strings */
- convert_to_string(value);
-
- filter_func.function(value, flags, options, charset TSRMLS_CC);
-}
-/* }}} */
-
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) /* {{{ */
-{
- zval new_var, raw_var;
- zval *array_ptr = NULL, *orig_array_ptr = NULL;
- char *orig_var;
- int retval = 0;
-
- assert(*val != NULL);
-
-#define PARSE_CASE(s,a,t) \
- case s: \
- if (!IF_G(a)) { \
- ALLOC_ZVAL(array_ptr); \
- array_init(array_ptr); \
- INIT_PZVAL(array_ptr); \
- IF_G(a) = array_ptr; \
- } else { \
- array_ptr = IF_G(a); \
- } \
- orig_array_ptr = PG(http_globals)[t]; \
- break;
-
- switch (arg) {
- PARSE_CASE(PARSE_POST, post_array, TRACK_VARS_POST)
- PARSE_CASE(PARSE_GET, get_array, TRACK_VARS_GET)
- PARSE_CASE(PARSE_COOKIE, cookie_array, TRACK_VARS_COOKIE)
- PARSE_CASE(PARSE_SERVER, server_array, TRACK_VARS_SERVER)
- PARSE_CASE(PARSE_ENV, env_array, TRACK_VARS_ENV)
-
- case PARSE_STRING: /* PARSE_STRING is used by parse_str() function */
- retval = 1;
- break;
- }
-
- if (array_ptr) {
- /* Make a copy of the variable name, as php_register_variable_ex seems to
- * modify it */
- orig_var = estrdup(var);
-
- /* Store the RAW variable internally */
- /* FIXME: Should not use php_register_variable_ex as that also registers
- * globals when register_globals is turned on */
- Z_STRLEN(raw_var) = val_len;
- Z_STRVAL(raw_var) = estrndup(*val, val_len + 1);
- Z_TYPE(raw_var) = IS_STRING;
-
- php_register_variable_ex(var, &raw_var, array_ptr TSRMLS_CC);
- }
-
- /* Register mangled variable */
- /* FIXME: Should not use php_register_variable_ex as that also registers
- * globals when register_globals is turned on */
- Z_STRLEN(new_var) = val_len;
- Z_STRVAL(new_var) = estrndup(*val, val_len + 1);
- Z_TYPE(new_var) = IS_STRING;
-
- if (val_len) {
- if (! (IF_G(default_filter) == FILTER_UNSAFE_RAW)) {
- php_zval_filter(&new_var, IF_G(default_filter), IF_G(default_filter_flags), NULL, NULL/*charset*/ TSRMLS_CC);
- }
- }
-
- if (orig_array_ptr) {
- php_register_variable_ex(orig_var, &new_var, orig_array_ptr TSRMLS_CC);
- }
- if (array_ptr) {
- efree(orig_var);
- }
-
- if (retval) {
- if (new_val_len) {
- *new_val_len = Z_STRLEN(new_var);
- }
- efree(*val);
- if (Z_STRLEN(new_var)) {
- *val = estrndup(Z_STRVAL(new_var), Z_STRLEN(new_var) + 1);
- zval_dtor(&new_var);
- } else {
- *val = estrdup("");
- }
- }
-
- return retval;
-}
-/* }}} */
-
-static void php_zval_filter_recursive(zval *value, long filter, long flags, zval *options, char *charset TSRMLS_DC) /* {{{ */
-{
- zval **element;
- HashPosition pos;
-
- if (Z_TYPE_P(value) == IS_ARRAY) {
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(value), &pos);
- zend_hash_get_current_data_ex(Z_ARRVAL_P(value), (void **) &element, &pos) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_P(value), &pos)) {
- php_zval_filter_recursive(*element, filter, flags, options, charset TSRMLS_CC);
- }
- } else {
- php_zval_filter(value, filter, flags, options, charset TSRMLS_CC);
- }
-}
-/* }}} */
-
-static zval * php_filter_get_storage(long arg TSRMLS_DC) /* {{{ */
-{
- zval * array_ptr = NULL;
- zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays));
- switch (arg) {
- case PARSE_GET:
- array_ptr = IF_G(get_array);
- break;
- case PARSE_POST:
- array_ptr = IF_G(post_array);
- break;
- case PARSE_COOKIE:
- array_ptr = IF_G(cookie_array);
- break;
- case PARSE_SERVER:
- if(jit_initialization) zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
- array_ptr = IF_G(server_array);
- break;
- case PARSE_ENV:
- if(jit_initialization) zend_is_auto_global("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
- array_ptr = IF_G(env_array);
- break;
- }
-
- return array_ptr;
-}
-/* }}} */
-
-/* {{{ proto mixed input_has_variable(constant type, string variable_name)
- * Returns true if the variable with the name 'name' exists in source.
- */
-PHP_FUNCTION(input_has_variable)
-{
- long arg;
- char *var;
- int var_len;
- zval **tmp;
- zval *array_ptr = NULL;
- HashTable *hash_ptr;
- int found = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) {
- return;
- }
-
- array_ptr = php_filter_get_storage(arg TSRMLS_CC);
-
- if (!array_ptr) {
- RETURN_FALSE;
- }
-
- if (!found) {
- hash_ptr = HASH_OF(array_ptr);
-
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto mixed input_get(constant type, string variable_name [, int filter [, mixed flags [, string charset]]])
- * Returns the filtered variable 'name'* from source `type`.
- */
-PHP_FUNCTION(input_get)
-{
- long arg, filter = FILTER_DEFAULT;
- char *var, *charset = NULL;
- int var_len, charset_len;
- zval *flags = NULL;
- zval **tmp;
- zval *array_ptr = NULL, *array_ptr2 = NULL, *array_ptr3 = NULL;
- HashTable *hash_ptr;
- int found = 0;
- long filter_flags = 0;
- zval *options = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|lzs", &arg, &var, &var_len, &filter, &flags, &charset, &charset_len) == FAILURE) {
- return;
- }
-
- if (flags) {
- switch (Z_TYPE_P(flags)) {
- case IS_ARRAY:
- options = flags;
- break;
-
- case IS_STRING:
- case IS_BOOL:
- case IS_LONG:
- convert_to_long(flags);
- filter_flags = Z_LVAL_P(flags);
- options = NULL;
- break;
- }
- }
-
- switch(arg) {
- case PARSE_GET:
- case PARSE_POST:
- case PARSE_COOKIE:
- case PARSE_SERVER:
- case PARSE_ENV:
- array_ptr = php_filter_get_storage(arg TSRMLS_CC);
- break;
-
- case PARSE_SESSION:
- /* FIXME: Implement session source */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "INPUT_SESSION not implemented");
- break;
-
- case PARSE_REQUEST:
- /* FIXME: Implement request source */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "INPUT_REQUEST not implemented");
- return;
- if (PG(variables_order)) {
- zval **a_ptr = &array_ptr;
- char *p, *variables_order = PG(variables_order);
-
- for (p = variables_order; p && *p; p++) {
- switch (*p) {
- case 'p':
- case 'P':
- if (IF_G(default_filter) != FILTER_UNSAFE_RAW) {
- *a_ptr = IF_G(post_array);
- } else {
- *a_ptr = PG(http_globals)[TRACK_VARS_POST];
- }
- break;
- case 'g':
- case 'G':
- if (IF_G(default_filter) != FILTER_UNSAFE_RAW) {
- *a_ptr = IF_G(get_array);
- } else {
- *a_ptr = PG(http_globals)[TRACK_VARS_GET];
- }
- break;
- case 'c':
- case 'C':
- if (IF_G(default_filter) != FILTER_UNSAFE_RAW) {
- *a_ptr = IF_G(cookie_array);
- } else {
- *a_ptr = PG(http_globals)[TRACK_VARS_COOKIE];
- }
- break;
- }
- if (array_ptr && !array_ptr2) {
- a_ptr = &array_ptr2;
- continue;
- }
- if (array_ptr2 && !array_ptr3) {
- a_ptr = &array_ptr3;
- }
- }
- } else {
- array_ptr = php_filter_get_storage(PARSE_GET TSRMLS_CC);
- }
- }
-
- if (!array_ptr) {
- RETURN_FALSE;
- }
-
- if (array_ptr3) {
- hash_ptr = HASH_OF(array_ptr3);
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- *return_value = **tmp;
- found = 1;
- }
- }
-
- if (array_ptr2 && !found) {
- hash_ptr = HASH_OF(array_ptr2);
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- *return_value = **tmp;
- found = 1;
- }
- }
-
- if (!found) {
- hash_ptr = HASH_OF(array_ptr);
-
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- *return_value = **tmp;
- found = 1;
- }
- }
-
- if (found) {
- zval_copy_ctor(return_value); /* Watch out for empty strings */
- php_zval_filter_recursive(return_value, filter, filter_flags, options, charset TSRMLS_CC);
- } else {
- RETURN_NULL();
- }
-}
-/* }}} */
-
-/* {{{ proto mixed input_get_args(array definition, constant type [, array data])
- * Returns an array with all arguments defined in 'definition'.
- */
-PHP_FUNCTION(input_get_args)
-{
- long filter = FILTER_DEFAULT;
- char *charset = NULL;
- zval **tmp, ** option;
- int filter_flags = FILTER_FLAG_SCALAR;
- zval *options = NULL, *temparray = NULL;
-
- zval *args_array, *values;
- HashTable *args_hash;
- HashPosition pos;
-
- HashTable * g_hash;
-
- long args_from = 0;
- long elm_count;
- char *key;
- unsigned int key_len;
- unsigned long index;
-
- /* pointers to the zval array GET, POST,... */
- zval *array_ptr = NULL;
- zval **element;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|a", &args_array, &args_from, &values) == FAILURE) {
- RETURN_FALSE;
- }
-
- args_hash = HASH_OF(args_array);
- elm_count = zend_hash_num_elements(args_hash);
-
- if (elm_count < 1) {
- RETURN_NULL();
- }
-
- switch (args_from) {
- case PARSE_GET:
- case PARSE_POST:
- case PARSE_COOKIE:
- case PARSE_SERVER:
- case PARSE_ENV:
- array_ptr = php_filter_get_storage(args_from TSRMLS_CC);
- break;
-
- case PARSE_DATA:
- array_ptr = values;
- break;
-
- case PARSE_SESSION:
- /* FIXME: Implement session source */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "INPUT_SESSION not implemented");
- break;
- }
-
- if (!array_ptr) {
- RETURN_FALSE;
- } else {
- g_hash = HASH_OF(array_ptr);
- zend_hash_internal_pointer_reset_ex(g_hash, &pos);
- array_init(return_value);
- }
-
- for (zend_hash_internal_pointer_reset_ex(args_hash, &pos);
- zend_hash_get_current_data_ex(args_hash, (void **) &element, &pos) == SUCCESS;
- zend_hash_move_forward_ex(args_hash, &pos)) {
-
- if (zend_hash_get_current_key_ex(args_hash, &key, &key_len, &index, 0, &pos) != HASH_KEY_IS_STRING) {
- zval_dtor(return_value);
- RETURN_FALSE;
- }
-
- if (g_hash && zend_hash_find(g_hash, key, key_len, (void **)&tmp) == SUCCESS) {
- if (Z_TYPE_PP(element) != IS_ARRAY) {
- convert_to_long(*element);
- filter = Z_LVAL_PP(element);
- filter_flags = FILTER_FLAG_SCALAR;
-
- if ((filter_flags & FILTER_FLAG_SCALAR) && Z_TYPE_PP(tmp) == IS_ARRAY) {
- /* asked for scalar and found an array do not test further */
- add_assoc_bool(return_value, key, 0);
- continue;
- }
-
- } else {
- if (zend_hash_find(HASH_OF(*element), "filter", sizeof("filter"), (void **)&option) == SUCCESS) {
- convert_to_long(*option);
- filter = Z_LVAL_PP(option);
- }
-
- if (zend_hash_find(HASH_OF(*element), "options", sizeof("options"), (void **)&option) == SUCCESS) {
- if (Z_TYPE_PP(option) == IS_ARRAY) {
- options = *option;
- }
- } else {
- options = NULL;
- }
-
- if (zend_hash_find(HASH_OF(*element), "flags", sizeof("flags"), (void **)&option) == SUCCESS) {
-
- switch (Z_TYPE_PP(option)) {
- case IS_ARRAY:
- break;
- default:
- convert_to_long(*option);
- filter_flags = Z_LVAL_PP(option);
- break;
- }
- } else {
- filter_flags = FILTER_FLAG_SCALAR;
- }
-
- if ((filter_flags & FILTER_FLAG_SCALAR) && Z_TYPE_PP(tmp) == IS_ARRAY) {
- /* asked for scalar and found an array do not test further */
- add_assoc_bool(return_value, key, 0);
- continue;
- }
-
- if (zend_hash_find(HASH_OF(*element), "charset", sizeof("charset"), (void **)&option) == SUCCESS) {
- convert_to_string(*option);
- charset = Z_STRVAL_PP(option);
- }
- }
-
- if (filter_flags & FILTER_FLAG_ARRAY) {
- php_zval_filter_recursive(*tmp, filter, filter_flags, options, charset TSRMLS_CC);
-
- /* ARRAY always returns an array */
- if (Z_TYPE_PP(tmp) != IS_ARRAY) {
- ALLOC_INIT_ZVAL(temparray);
- array_init(temparray);
- add_next_index_zval(temparray, *tmp);
- *tmp = temparray;
- }
- } else {
- php_zval_filter(*tmp, filter, filter_flags, options, charset TSRMLS_CC);
- }
-
- add_assoc_zval(return_value, key, *tmp);
- } else {
- add_assoc_null(return_value, key);
- }
- filter = FILTER_DEFAULT;
- filter_flags = FILTER_FLAG_SCALAR;
- }
-}
-/* }}} */
-
-/* {{{ proto input_filters_list()
- * Returns a list of all supported filters */
-PHP_FUNCTION(input_filters_list)
-{
- int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
-
- array_init(return_value);
- for (i = 0; i < size; ++i) {
- add_next_index_string(return_value, filter_list[i].name, 1);
- }
-}
-/* }}} */
-
-/* {{{ proto input_name_to_filter(string filtername)
- * Returns the filter ID belonging to a named filter */
-PHP_FUNCTION(input_name_to_filter)
-{
- int i, filter_len;
- int size = sizeof(filter_list) / sizeof(filter_list_entry);
- char *filter;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filter, &filter_len) == FAILURE) {
- return;
- }
-
- for (i = 0; i < size; ++i) {
- if (strcmp(filter_list[i].name, filter) == 0) {
- RETURN_LONG(filter_list[i].id);
- }
- }
- RETURN_NULL();
-}
-/* }}} */
-
-/* {{{ proto filter_data(mixed variable, int filter [, mixed filter_options [, string charset ]])
- * Returns the filterd variable (scalar or array can be used).
- */
-PHP_FUNCTION(filter_data)
-{
- long filter = FILTER_DEFAULT;
- char *charset = NULL;
- int charset_len;
- zval *var, *flags = NULL;
- int filter_flags = 0;
- zval *options = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/l|zs", &var, &filter, &flags, &charset, &charset_len) == FAILURE) {
- return;
- }
-
- if (filter != FILTER_CALLBACK) {
- if (flags) {
- switch (Z_TYPE_P(flags)) {
- case IS_ARRAY:
- options = flags;
- break;
-
- case IS_STRING:
- case IS_BOOL:
- case IS_LONG:
- convert_to_long(flags);
- filter_flags = Z_LVAL_P(flags);
- options = NULL;
- break;
- }
- }
- } else {
- if (flags) {
- switch (Z_TYPE_P(flags)) {
- case IS_ARRAY:
- case IS_STRING:
- options = flags;
- break;
-
- default:
- convert_to_string(flags);
- options = flags;
- break;
- }
- }
- }
- php_zval_filter_recursive(var, filter, filter_flags, options, charset TSRMLS_CC);
- RETURN_ZVAL(var, 1, 0);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h
deleted file mode 100644
index ea44775032..0000000000
--- a/ext/filter/filter_private.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef FILTER_PRIVATE_H
-#define FILTER_PRIVATE_H
-
-#define FILTER_FLAG_NONE 0x0000
-
-#define FILTER_FLAG_ARRAY 0x1000000
-#define FILTER_FLAG_SCALAR 0x2000000
-
-#define FILTER_FLAG_ALLOW_OCTAL 0x0001
-#define FILTER_FLAG_ALLOW_HEX 0x0002
-
-#define FILTER_FLAG_STRIP_LOW 0x0004
-#define FILTER_FLAG_STRIP_HIGH 0x0008
-#define FILTER_FLAG_ENCODE_LOW 0x0010
-#define FILTER_FLAG_ENCODE_HIGH 0x0020
-#define FILTER_FLAG_ENCODE_AMP 0x0040
-#define FILTER_FLAG_NO_ENCODE_QUOTES 0x0080
-#define FILTER_FLAG_EMPTY_STRING_NULL 0x0100
-
-#define FILTER_FLAG_ALLOW_FRACTION 0x1000
-#define FILTER_FLAG_ALLOW_THOUSAND 0x2000
-#define FILTER_FLAG_ALLOW_SCIENTIFIC 0x4000
-
-#define FILTER_FLAG_SCHEME_REQUIRED 0x010000
-#define FILTER_FLAG_HOST_REQUIRED 0x020000
-#define FILTER_FLAG_PATH_REQUIRED 0x040000
-#define FILTER_FLAG_QUERY_REQUIRED 0x080000
-
-#define FILTER_FLAG_IPV4 0x100000
-#define FILTER_FLAG_IPV6 0x200000
-#define FILTER_FLAG_NO_RES_RANGE 0x400000
-#define FILTER_FLAG_NO_PRIV_RANGE 0x800000
-
-#define FILTER_VALIDATE_INT 0x0101
-#define FILTER_VALIDATE_BOOLEAN 0x0102
-#define FILTER_VALIDATE_FLOAT 0x0103
-
-#define FILTER_VALIDATE_REGEXP 0x0110
-#define FILTER_VALIDATE_URL 0x0111
-#define FILTER_VALIDATE_EMAIL 0x0112
-#define FILTER_VALIDATE_IP 0x0113
-
-#define FILTER_VALIDATE_ALL 0x0100
-
-#define FILTER_DEFAULT 0x0204
-#define FILTER_UNSAFE_RAW 0x0204
-
-#define FILTER_SANITIZE_STRING 0x0201
-#define FILTER_SANITIZE_ENCODED 0x0202
-#define FILTER_SANITIZE_SPECIAL_CHARS 0x0203
-#define FILTER_SANITIZE_EMAIL 0x0205
-#define FILTER_SANITIZE_URL 0x0206
-#define FILTER_SANITIZE_NUMBER_INT 0x0207
-#define FILTER_SANITIZE_NUMBER_FLOAT 0x0208
-#define FILTER_SANITIZE_MAGIC_QUOTES 0x0209
-
-#define FILTER_SANITIZE_ALL 0x0200
-
-#define FILTER_CALLBACK 0x0400
-
-#endif /* FILTER_PRIVATE_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/filter/package.xml b/ext/filter/package.xml
deleted file mode 100644
index cca5fd6a8c..0000000000
--- a/ext/filter/package.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package>
- <name>filter</name>
- <summary>Extension for safely dealing with input parameters</summary>
- <maintainers>
- <maintainer>
- <user>derick</user>
- <name>Derick Rethans</name>
- <email>derick@php.net</email>
- <role>lead</role>
- </maintainer>
- <maintainer>
- <user>rasmus</user>
- <name>Rasmus Lerdorf</name>
- <email>rasmus@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <description>
-The Input Filter extension is meant to address this issue by implementing a set
-of filters and mechanisms that users can use to safely access their input data.
- </description>
- <license>PHP</license>
- <release>
- <state>beta</state>
- <version>0.10.0</version>
- <date>2006-05-14</date>
- <notes>- Fixed PECL bug #6136, ini_set should not be able to change the filter.default (Pierre)
-- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported
-- Fixed PECL bug #7733, Float exponential weird result (Pierre)
-- Fixed PECL bug #7715, Input_get float error (Pierre)
-- Implemented PECL req #6641: negative values for hexadecimal and octal numbers are not supported.
-- Added support for php pcre expressions (Pierre)
-- Fixed Possible leak in internal sapi_filter (Pierre)
-- Added input_get_args, fetches all input in one call (Pierre)
-- Added FILTER_FLAG_SCALAR and FILTER_FLAG_ARRAY , allows or not array values (Pierre)
-- Basic IPv6 (no option yet, only the syntax is verified) (Pierre)
-- Add support for custom decimal separator (Pierre)
-- INT and Float filters trim the values before the validations (spaces only) (Pierre)
-- input_get and input_get_args returns now FALSE when the validation failed
- and NULL when the variable has not been found (Pierre)
-- Added JIT support
- </notes>
- <filelist>
- <file role="src" name="config.m4"/>
- <file role="src" name="config.w32"/>
- <file role="src" name="filter.c"/>
- <file role="src" name="filter_private.h"/>
- <file role="src" name="callback_filter.c"/>
- <file role="src" name="logical_filters.c"/>
- <file role="src" name="sanitizing_filters.c"/>
- <file role="src" name="php_filter.h"/>
- <file role="doc" name="CREDITS"/>
- <dir name="tests">
- <file role="test" name="001.phpt"/>
- <file role="test" name="002.phpt"/>
- <file role="test" name="003.phpt"/>
- <file role="test" name="004.phpt"/>
- <file role="test" name="005.phpt"/>
- <file role="test" name="006.phpt"/>
- <file role="test" name="007.phpt"/>
- <file role="test" name="008.phpt"/>
- <file role="test" name="009.phpt"/>
- <file role="test" name="010.phpt"/>
- <file role="test" name="011.phpt"/>
- <file role="test" name="012.phpt"/>
- <file role="test" name="013.phpt"/>
- <file role="test" name="014.phpt"/>
- <file role="test" name="015.phpt"/>
- <file role="test" name="016.phpt"/>
- <file role="test" name="017.phpt"/>
- <file role="test" name="018.phpt"/>
- <file role="test" name="019.phpt"/>
- <file role="test" name="020.phpt"/>
- <file role="test" name="021.phpt"/>
- <file role="test" name="022.phpt"/>
- <file role="test" name="023.phpt"/>
- <file role="test" name="024.phpt"/>
- <file role="test" name="025.phpt"/>
- <file role="test" name="026.phpt"/>
- <file role="test" name="027.phpt"/>
- <file role="test" name="028.phpt"/>
- <file role="test" name="029.phpt"/>
- <file role="test" name="030.phpt"/>
- <file role="test" name="031.phpt"/>
- <file role="test" name="032.phpt"/>
- <file role="test" name="bug7586.phpt"/>
- </dir>
- </filelist>
- <deps>
- <dep type="php" rel="ge" version="5.0.0"/>
- </deps>
- </release>
-</package>
-<!--
-vim:et:ts=1:sw=1
--->
diff --git a/ext/filter/package2.xml b/ext/filter/package2.xml
deleted file mode 100644
index ffe3d7db44..0000000000
--- a/ext/filter/package2.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.6" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
- <name>filter</name>
- <channel>pecl.php.net</channel>
- <summary>Extension for safely dealing with input parameters</summary>
- <description>The Input Filter extension is meant to address this issue by implementing a set
-of filters and mechanisms that users can use to safely access their input data.
-
- </description>
- <lead>
- <name>Derick Rethans</name>
- <user>derick</user>
- <email>derick@php.net</email>
- <active>yes</active>
- </lead>
- <lead>
- <name>Rasmus Lerdorf</name>
- <user>rasmus</user>
- <email>rasmus@php.net</email>
- <active>yes</active>
- </lead>
- <date>2006-05-14</date>
- <time>10:04:15</time>
- <version>
- <release>0.10.0</release>
- <api>0.10.0</api>
- </version>
- <stability>
- <release>beta</release>
- <api>beta</api>
- </stability>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>- Fixed PECL bug #6136, ini_set should not be able to change the filter.default (Pierre)
-- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported
-- Fixed PECL bug #7733, Float exponential weird result (Pierre)
-- Fixed PECL bug #7715, Input_get float error (Pierre)
-- Implemented PECL req #6641: negative values for hexadecimal and octal numbers are not supported.
-- Added support for php pcre expressions (Pierre)
-- Fixed Possible leak in internal sapi_filter (Pierre)
-- Added input_get_args, fetches all input in one call (Pierre)
-- Added FILTER_FLAG_SCALAR and FILTER_FLAG_ARRAY , allows or not array values (Pierre)
-- Basic IPv6 (no option yet, only the syntax is verified) (Pierre)
-- Add support for custom decimal separator (Pierre)
-- INT and Float filters trim the values before the validations (spaces only) (Pierre)
-- input_get and input_get_args returns now FALSE when the validation failed
- and NULL when the variable has not been found (Pierre)
-- Added JIT support
- </notes>
- <contents>
- <dir name="/">
- <file name="callback_filter.c" role="src"/>
- <file name="config.m4" role="src"/>
- <file name="config.w32" role="src"/>
- <file name="CREDITS" role="doc"/>
- <file name="filter.c" role="src"/>
- <file name="filter_private.h" role="src"/>
- <file name="logical_filters.c" role="src"/>
- <file name="php_filter.h" role="src"/>
- <file name="sanitizing_filters.c" role="src"/>
- <dir name="tests">
- <file role="test" name="001.phpt"/>
- <file role="test" name="002.phpt"/>
- <file role="test" name="003.phpt"/>
- <file role="test" name="004.phpt"/>
- <file role="test" name="005.phpt"/>
- <file role="test" name="006.phpt"/>
- <file role="test" name="007.phpt"/>
- <file role="test" name="008.phpt"/>
- <file role="test" name="009.phpt"/>
- <file role="test" name="010.phpt"/>
- <file role="test" name="011.phpt"/>
- <file role="test" name="012.phpt"/>
- <file role="test" name="013.phpt"/>
- <file role="test" name="014.phpt"/>
- <file role="test" name="015.phpt"/>
- <file role="test" name="016.phpt"/>
- <file role="test" name="017.phpt"/>
- <file role="test" name="018.phpt"/>
- <file role="test" name="019.phpt"/>
- <file role="test" name="020.phpt"/>
- <file role="test" name="021.phpt"/>
- <file role="test" name="022.phpt"/>
- <file role="test" name="023.phpt"/>
- <file role="test" name="024.phpt"/>
- <file role="test" name="025.phpt"/>
- <file role="test" name="026.phpt"/>
- <file role="test" name="027.phpt"/>
- <file role="test" name="028.phpt"/>
- <file role="test" name="029.phpt"/>
- <file role="test" name="030.phpt"/>
- <file role="test" name="031.phpt"/>
- <file role="test" name="032.phpt"/>
- <file role="test" name="bug7586.phpt"/>
- </dir>
- </dir>
-<!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>5.0.0</min>
- </php>
- <pearinstaller>
- <min>1.4.0b1</min>
- </pearinstaller>
- </required>
- </dependencies>
- <providesextension>filter</providesextension>
- <extsrcrelease/>
- <changelog>
- <release>
- <date>2006-01-23</date>
- <time>10:04:15</time>
- <version>
- <release>0.9.4</release>
- <api>0.9.4</api>
- </version>
- <stability>
- <release>beta</release>
- <api>beta</api>
- </stability>
- <notes>- Reimplement php_filter_callback() as exception-safe and without memleaks
-- Renamed all constants.
-- Fixed PECL bug #6124: Crash on HTML tags when using FS_STRING</notes>
- </release>
- </changelog>
-</package>
diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h
deleted file mode 100644
index 4c2b9381bb..0000000000
--- a/ext/filter/php_filter.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_FILTER_H
-#define PHP_FILTER_H
-
-#include "SAPI.h"
-#include "zend_API.h"
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "ext/standard/php_string.h"
-#include "php_variables.h"
-
-extern zend_module_entry filter_module_entry;
-#define phpext_filter_ptr &filter_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_FILTER_API __declspec(dllexport)
-#else
-#define PHP_FILTER_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-PHP_MINIT_FUNCTION(filter);
-PHP_MSHUTDOWN_FUNCTION(filter);
-PHP_RINIT_FUNCTION(filter);
-PHP_RSHUTDOWN_FUNCTION(filter);
-PHP_MINFO_FUNCTION(filter);
-
-PHP_FUNCTION(input_get);
-PHP_FUNCTION(input_get_args);
-PHP_FUNCTION(input_filters_list);
-PHP_FUNCTION(input_has_variable);
-PHP_FUNCTION(input_name_to_filter);
-PHP_FUNCTION(filter_data);
-
-ZEND_BEGIN_MODULE_GLOBALS(filter)
- zval *post_array;
- zval *get_array;
- zval *cookie_array;
- zval *env_array;
- zval *server_array;
- zval *session_array;
- long default_filter;
- long default_filter_flags;
-ZEND_END_MODULE_GLOBALS(filter)
-
-#ifdef ZTS
-#define IF_G(v) TSRMG(filter_globals_id, zend_filter_globals *, v)
-#else
-#define IF_G(v) (filter_globals.v)
-#endif
-
-
-#define PHP_INPUT_FILTER_PARAM_DECL zval *value, long flags, zval *option_array, char *charset TSRMLS_DC
-void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL);
-
-void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL);
-
-void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL);
-
-#endif /* FILTER_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- */
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
deleted file mode 100644
index 50d17eb65c..0000000000
--- a/ext/filter/sanitizing_filters.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php_filter.h"
-#include "filter_private.h"
-#include "ext/standard/php_smart_str.h"
-
-/* {{{ STRUCTS */
-typedef unsigned long filter_map[256];
-/* }}} */
-
-/* {{{ HELPER FUNCTIONS */
-static void php_filter_encode_html(zval *value, char* chars, int encode_nul)
-{
- register int x, y;
- smart_str str = {0};
- int len = Z_STRLEN_P(value);
- char *s = Z_STRVAL_P(value);
-
- if (Z_STRLEN_P(value) == 0) {
- return;
- }
-
- for (x = 0, y = 0; len--; x++, y++) {
- if (strchr(chars, s[x]) || (encode_nul && s[x] == 0)) {
- smart_str_appendl(&str, "&#", 2);
- smart_str_append_long(&str, s[x]);
- smart_str_appendc(&str, ';');
- } else {
- smart_str_appendc(&str, s[x]);
- }
- }
- smart_str_0(&str);
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = str.c;
- Z_STRLEN_P(value) = str.len;
-}
-
-static void php_filter_encode_html_high_low(zval *value, long flags)
-{
- register int x, y;
- smart_str str = {0};
- int len = Z_STRLEN_P(value);
- unsigned char *s = Z_STRVAL_P(value);
-
- if (Z_STRLEN_P(value) == 0) {
- return;
- }
-
- for (x = 0, y = 0; len--; x++, y++) {
- if (((flags & FILTER_FLAG_ENCODE_LOW) && (s[x] < 32)) || ((flags & FILTER_FLAG_ENCODE_HIGH) && (s[x] > 127))) {
- smart_str_appendl(&str, "&#", 2);
- smart_str_append_long(&str, s[x]);
- smart_str_appendc(&str, ';');
- } else {
- smart_str_appendc(&str, s[x]);
- }
- }
- smart_str_0(&str);
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = str.c;
- Z_STRLEN_P(value) = str.len;
-}
-
-static unsigned char hexchars[] = "0123456789ABCDEF";
-
-#define LOWALPHA "abcdefghijklmnopqrstuvwxyz"
-#define HIALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define DIGIT "0123456789"
-
-#define DEFAULT_URL_ENCODE LOWALPHA HIALPHA DIGIT "-._"
-
-static void php_filter_encode_url(zval *value, char* chars, int high, int low, int encode_nul)
-{
- register int x, y;
- unsigned char *str;
- int len = Z_STRLEN_P(value);
- char *s = Z_STRVAL_P(value);
-
- str = (unsigned char *) safe_emalloc(3, len, 1);
- for (x = 0, y = 0; len--; x++, y++) {
- str[y] = (unsigned char) s[x];
-
- if ((strlen(chars) && !strchr(chars, str[y])) || (high && str[y] > 127) || (low && str[y] < 32) || (encode_nul && str[y] == 0)) {
- str[y++] = '%';
- str[y++] = hexchars[(unsigned char) s[x] >> 4];
- str[y] = hexchars[(unsigned char) s[x] & 15];
- }
- }
- str[y] = '\0';
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = str;
- Z_STRLEN_P(value) = y;
-}
-
-static void php_filter_strip(zval *value, long flags)
-{
- unsigned char *buf, *str;
- int i, c;
-
- /* Optimization for if no strip flags are set */
- if (! ((flags & FILTER_FLAG_STRIP_LOW) || (flags & FILTER_FLAG_STRIP_HIGH)) ) {
- return;
- }
-
- str = Z_STRVAL_P(value);
- buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
- c = 0;
- for (i = 0; i < Z_STRLEN_P(value); i++) {
- if ((str[i] > 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
- } else if ((str[i] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) {
- } else {
- buf[c] = str[i];
- ++c;
- }
- }
- /* update zval string data */
- buf[c] = '\0';
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = c;
-}
-/* }}} */
-
-/* {{{ FILTER MAP HELPERS */
-static void filter_map_init(filter_map *map)
-{
- memset(map, 0, sizeof(filter_map));
-}
-
-static void filter_map_update(filter_map *map, int flag, unsigned char *allowed_list)
-{
- int l, i;
-
- l = strlen(allowed_list);
- for (i = 0; i < l; ++i) {
- (*map)[allowed_list[i]] = flag;
- }
-}
-
-static void filter_map_apply(zval *value, filter_map *map)
-{
- unsigned char *buf, *str;
- int i, c;
-
- str = Z_STRVAL_P(value);
- buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
- c = 0;
- for (i = 0; i < Z_STRLEN_P(value); i++) {
- if ((*map)[str[i]]) {
- buf[c] = str[i];
- ++c;
- }
- }
- /* update zval string data */
- buf[c] = '\0';
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = c;
-}
-/* }}} */
-
-
-/* {{{ php_filter_string */
-void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL)
-{
- size_t new_len;
-
- /* strip tags, implicitly also removes \0 chars */
- new_len = php_strip_tags(Z_STRVAL_P(value), Z_STRLEN_P(value), NULL, NULL, 0);
- Z_STRLEN_P(value) = new_len;
-
- if (new_len == 0) {
- zval_dtor(value);
- ZVAL_EMPTY_STRING(value);
- return;
- }
-
- if (! (flags & FILTER_FLAG_NO_ENCODE_QUOTES)) {
- /* encode ' and " to numerical entity */
- php_filter_encode_html(value, "'\"", 0);
- }
- /* strip high/strip low ( see flags )*/
- php_filter_strip(value, flags);
-
- /* encode low/encode high flags */
- php_filter_encode_html_high_low(value, flags);
-
- /* also all the flags - & encode as %xx */
- if (flags & FILTER_FLAG_ENCODE_AMP) {
- php_filter_encode_html(value, "&", 0);
- }
-}
-/* }}} */
-
-/* {{{ php_filter_encoded */
-void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* apply strip_high and strip_low filters */
- php_filter_strip(value, flags);
- /* urlencode */
- php_filter_encode_url(value, DEFAULT_URL_ENCODE, flags & FILTER_FLAG_ENCODE_HIGH, flags & FILTER_FLAG_ENCODE_LOW, 1);
-}
-/* }}} */
-
-/* {{{ php_filter_special_chars */
-void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* encodes ' " < > & \0 to numerical entities */
- php_filter_encode_html(value, "'\"<>&", 1);
- /* if strip low is not set, then we encode them as &#xx; */
- php_filter_strip(value, flags);
- php_filter_encode_html_high_low(value, FILTER_FLAG_ENCODE_LOW | flags);
-}
-/* }}} */
-
-/* {{{ php_filter_unsafe_raw */
-void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* Only if no flags are set (optimization) */
- if (flags != 0 && Z_STRLEN_P(value) > 0) {
- php_filter_strip(value, flags);
- if (flags & FILTER_FLAG_ENCODE_AMP) {
- php_filter_encode_html(value, "&", 0);
- }
- php_filter_encode_html_high_low(value, flags);
- }
-}
-/* }}} */
-
-/* {{{ php_filter_email */
-#define SAFE "$-_.+"
-#define EXTRA "!*'(),"
-#define NATIONAL "{}|\\^~[]`"
-#define PUNCTUATION "<>#%\""
-#define RESERVED ";/?:@&="
-
-void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* Check section 6 of rfc 822 http://www.faqs.org/rfcs/rfc822.html */
- unsigned char *allowed_list = LOWALPHA HIALPHA DIGIT "!#$%&'*+-/=?^_`{|}~@.[]";
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_url */
-void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* Strip all chars not part of section 5 of
- * http://www.faqs.org/rfcs/rfc1738.html */
- unsigned char *allowed_list = LOWALPHA HIALPHA DIGIT SAFE EXTRA NATIONAL PUNCTUATION RESERVED;
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_number_int */
-void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* strip everything [^0-9+-] */
- unsigned char *allowed_list = "+-" DIGIT;
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_number_float */
-void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* strip everything [^0-9+-] */
- unsigned char *allowed_list = "+-" DIGIT;
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
-
- /* depending on flags, strip '.', 'e', ",", "'" */
- if (flags & FILTER_FLAG_ALLOW_FRACTION) {
- filter_map_update(&map, 2, ".");
- }
- if (flags & FILTER_FLAG_ALLOW_THOUSAND) {
- filter_map_update(&map, 3, ",");
- }
- if (flags & FILTER_FLAG_ALLOW_SCIENTIFIC) {
- filter_map_update(&map, 4, "eE");
- }
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_magic_quotes */
-void php_filter_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL)
-{
- char *buf;
- int len;
-
- /* just call php_addslashes quotes */
- buf = php_addslashes(Z_STRVAL_P(value), Z_STRLEN_P(value), &len, 0 TSRMLS_CC);
-
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = len;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/filter/tests/001.phpt b/ext/filter/tests/001.phpt
deleted file mode 100644
index 2755a57363..0000000000
--- a/ext/filter/tests/001.phpt
+++ /dev/null
@@ -1,8 +0,0 @@
---TEST--
-Simple GET test
---GET--
-a=1
---FILE--
-<?php echo $_GET['a']; ?>
---EXPECT--
-1
diff --git a/ext/filter/tests/002.phpt b/ext/filter/tests/002.phpt
deleted file mode 100644
index 7136b251a6..0000000000
--- a/ext/filter/tests/002.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-GET test with 2 values and an empty one
---GET--
-a=1&b=&c=3
---FILE--
-<?php echo $_GET['a'];
-echo $_GET['b'];
-echo $_GET['c'];
-?>
---EXPECT--
-13
diff --git a/ext/filter/tests/003.phpt b/ext/filter/tests/003.phpt
deleted file mode 100644
index 43e6cd9b03..0000000000
--- a/ext/filter/tests/003.phpt
+++ /dev/null
@@ -1,22 +0,0 @@
---TEST--
-GET/POST/REQUEST Test
---POST--
-d=4&e=5
---GET--
-a=1&b=&c=3
---FILE--
-<?php echo $_GET['a'];
-echo $_GET['b'];
-echo $_GET['c'];
-echo $_POST['d'];
-echo $_POST['e'];
-echo "\n";
-echo $_REQUEST['a'];
-echo $_REQUEST['b'];
-echo $_REQUEST['c'];
-echo $_REQUEST['d'];
-echo $_REQUEST['e'];
-?>
---EXPECT--
-1345
-1345
diff --git a/ext/filter/tests/004.phpt b/ext/filter/tests/004.phpt
deleted file mode 100644
index 05ea952145..0000000000
--- a/ext/filter/tests/004.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-GET/POST/REQUEST Test with filtered data
---INI--
-filter.default=special_chars
---POST--
-d="quotes"&e=\slash
---GET--
-a=O'Henry&b=&c=<b>Bold</b>
---FILE--
-<?php echo $_GET['a'];
-echo $_GET['b'];
-echo $_GET['c'];
-echo $_POST['d'];
-echo $_POST['e'];
-echo "\n";
-echo $_REQUEST['a'];
-echo $_REQUEST['b'];
-echo $_REQUEST['c'];
-echo $_REQUEST['d'];
-echo $_REQUEST['e'];
-?>
---EXPECT--
-O&#39;HenryBold&quot;quotes&quot;\slash
-O&#39;HenryBold&quot;quotes&quot;\slash
diff --git a/ext/filter/tests/005.phpt b/ext/filter/tests/005.phpt
deleted file mode 100644
index f44379153e..0000000000
--- a/ext/filter/tests/005.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-GET/REQUEST Test with fifa example data
---INI--
-filter.default=stripped
---GET--
-id=f03_photos&pgurl=http%3A//fifaworldcup.yahoo.com/03/en/photozone/index.html
---FILE--
-<?php
-echo $_GET['id'];
-echo "\n";
-echo $_GET['pgurl'];
-echo "\n";
-echo $_REQUEST['id'];
-echo "\n";
-echo $_REQUEST['pgurl'];
-?>
---EXPECT--
-f03_photos
-http://fifaworldcup.yahoo.com/03/en/photozone/index.html
-f03_photos
-http://fifaworldcup.yahoo.com/03/en/photozone/index.html
diff --git a/ext/filter/tests/006.phpt b/ext/filter/tests/006.phpt
deleted file mode 100644
index 189579acf1..0000000000
--- a/ext/filter/tests/006.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-filter() test
---POST--
-foo=<b>abc</b>
---FILE--
-<?php
-echo input_get(INPUT_POST, 'foo', FILTER_SANITIZE_STRIPPED);
-?>
---EXPECT--
-abc
diff --git a/ext/filter/tests/007.phpt b/ext/filter/tests/007.phpt
deleted file mode 100644
index ffc727801d..0000000000
--- a/ext/filter/tests/007.phpt
+++ /dev/null
@@ -1,68 +0,0 @@
---TEST--
-input_has_variable()
---GET--
-a=qwe&abc=<a>href</a>
---POST--
-b=qwe&bbc=<a>href</a>
---FILE--
-<?php
-
-var_dump(input_has_variable(INPUT_GET, "a"));
-var_dump(input_has_variable(INPUT_GET, "abc"));
-var_dump(input_has_variable(INPUT_GET, "nonex"));
-var_dump(input_has_variable(INPUT_GET, " "));
-var_dump(input_has_variable(INPUT_GET, ""));
-var_dump(input_has_variable(INPUT_GET, array()));
-
-var_dump(input_has_variable(INPUT_POST, "b"));
-var_dump(input_has_variable(INPUT_POST, "bbc"));
-var_dump(input_has_variable(INPUT_POST, "nonex"));
-var_dump(input_has_variable(INPUT_POST, " "));
-var_dump(input_has_variable(INPUT_POST, ""));
-var_dump(input_has_variable(INPUT_POST, array()));
-
-var_dump(input_has_variable(-1, ""));
-var_dump(input_has_variable("", ""));
-var_dump(input_has_variable(array(), array()));
-var_dump(input_has_variable(array(), ""));
-var_dump(input_has_variable("", array()));
-
-echo "Done\n";
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(false)
-bool(false)
-bool(false)
-PHP Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-NULL
-bool(true)
-bool(true)
-bool(false)
-bool(false)
-bool(false)
-PHP Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-NULL
-bool(false)
-PHP Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-NULL
-PHP Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-NULL
-PHP Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-NULL
-PHP Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-NULL
-Done
diff --git a/ext/filter/tests/008.phpt b/ext/filter/tests/008.phpt
deleted file mode 100644
index eb6963c099..0000000000
--- a/ext/filter/tests/008.phpt
+++ /dev/null
@@ -1,88 +0,0 @@
---TEST--
-input_filters_list()
---FILE--
-<?php
-
-var_dump(input_filters_list());
-var_dump(input_filters_list(array()));
-
-echo "Done\n";
-?>
---EXPECTF--
-array(18) {
- [0]=>
- string(3) "int"
- [1]=>
- string(7) "boolean"
- [2]=>
- string(5) "float"
- [3]=>
- string(15) "validate_regexp"
- [4]=>
- string(12) "validate_url"
- [5]=>
- string(14) "validate_email"
- [6]=>
- string(11) "validate_ip"
- [7]=>
- string(6) "string"
- [8]=>
- string(8) "stripped"
- [9]=>
- string(7) "encoded"
- [10]=>
- string(13) "special_chars"
- [11]=>
- string(10) "unsafe_raw"
- [12]=>
- string(5) "email"
- [13]=>
- string(3) "url"
- [14]=>
- string(10) "number_int"
- [15]=>
- string(12) "number_float"
- [16]=>
- string(12) "magic_quotes"
- [17]=>
- string(8) "callback"
-}
-array(18) {
- [0]=>
- string(3) "int"
- [1]=>
- string(7) "boolean"
- [2]=>
- string(5) "float"
- [3]=>
- string(15) "validate_regexp"
- [4]=>
- string(12) "validate_url"
- [5]=>
- string(14) "validate_email"
- [6]=>
- string(11) "validate_ip"
- [7]=>
- string(6) "string"
- [8]=>
- string(8) "stripped"
- [9]=>
- string(7) "encoded"
- [10]=>
- string(13) "special_chars"
- [11]=>
- string(10) "unsafe_raw"
- [12]=>
- string(5) "email"
- [13]=>
- string(3) "url"
- [14]=>
- string(10) "number_int"
- [15]=>
- string(12) "number_float"
- [16]=>
- string(12) "magic_quotes"
- [17]=>
- string(8) "callback"
-}
-Done
diff --git a/ext/filter/tests/009.phpt b/ext/filter/tests/009.phpt
deleted file mode 100644
index c33fe8ae36..0000000000
--- a/ext/filter/tests/009.phpt
+++ /dev/null
@@ -1,30 +0,0 @@
---TEST--
-input_name_to_filter()
---FILE--
-<?php
-
-var_dump(input_name_to_filter("stripped"));
-var_dump(input_name_to_filter("string"));
-var_dump(input_name_to_filter("url"));
-var_dump(input_name_to_filter("int"));
-var_dump(input_name_to_filter("none"));
-var_dump(input_name_to_filter(array()));
-var_dump(input_name_to_filter(-1));
-var_dump(input_name_to_filter(0,0,0));
-
-echo "Done\n";
-?>
---EXPECTF--
-int(513)
-int(513)
-int(518)
-int(257)
-NULL
-
-Warning: input_name_to_filter() expects parameter 1 to be string, array given in %s on line %d
-NULL
-NULL
-
-Warning: input_name_to_filter() expects exactly 1 parameter, 3 given in %s on line %d
-NULL
-Done
diff --git a/ext/filter/tests/010.phpt b/ext/filter/tests/010.phpt
deleted file mode 100644
index eaded25b65..0000000000
--- a/ext/filter/tests/010.phpt
+++ /dev/null
@@ -1,60 +0,0 @@
---TEST--
-filter_data()
---FILE--
-<?php
-
-var_dump(filter_data(array(1,"1","", "-23234", "text", "asdf234asdfgs", array()), FILTER_VALIDATE_INT));
-var_dump(filter_data(array(1.2,"1.7","", "-23234.123", "text", "asdf234.2asdfgs", array()), FILTER_VALIDATE_FLOAT));
-var_dump(filter_data(1, array()));
-var_dump(filter_data(1, FILTER_SANITIZE_STRING, 1));
-var_dump(filter_data(1, FILTER_SANITIZE_STRING, 0));
-var_dump(filter_data(1, FILTER_SANITIZE_STRING, array()));
-var_dump(filter_data(1, -1, array(123)));
-var_dump(filter_data(1, 0, array()));
-
-echo "Done\n";
-?>
---EXPECTF--
-array(7) {
- [0]=>
- int(1)
- [1]=>
- int(1)
- [2]=>
- int(0)
- [3]=>
- int(-23234)
- [4]=>
- bool(false)
- [5]=>
- bool(false)
- [6]=>
- array(0) {
- }
-}
-array(7) {
- [0]=>
- float(1.2)
- [1]=>
- float(1.7)
- [2]=>
- float(0)
- [3]=>
- float(-23234.123)
- [4]=>
- bool(false)
- [5]=>
- bool(false)
- [6]=>
- array(0) {
- }
-}
-
-Warning: filter_data() expects parameter 2 to be long, array given in %s on line %d
-NULL
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-Done
diff --git a/ext/filter/tests/011.phpt b/ext/filter/tests/011.phpt
deleted file mode 100644
index 0d3fa42745..0000000000
--- a/ext/filter/tests/011.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-input_get()
---GET--
-a=<b>test</b>&b=http://example.com
---POST--
-c=<p>string</p>&d=12345.7
---FILE--
-<?php
-
-var_dump(input_get(INPUT_GET, "a", FILTER_SANITIZE_STRIPPED));
-var_dump(input_get(INPUT_GET, "b", FILTER_SANITIZE_URL));
-var_dump(input_get(INPUT_GET, "a", FILTER_SANITIZE_SPECIAL_CHARS, array(1,2,3,4,5)));
-var_dump(input_get(INPUT_GET, "b", FILTER_VALIDATE_FLOAT, new stdClass));
-var_dump(input_get(INPUT_POST, "c", FILTER_SANITIZE_STRIPPED, array(5,6,7,8)));
-var_dump(input_get(INPUT_POST, "d", FILTER_VALIDATE_FLOAT));
-var_dump(input_get(INPUT_POST, "c", FILTER_SANITIZE_SPECIAL_CHARS));
-var_dump(input_get(INPUT_POST, "d", FILTER_VALIDATE_INT));
-
-var_dump(input_get(new stdClass, "d"));
-
-var_dump(input_get(INPUT_POST, "c", "", ""));
-var_dump(input_get("", "", "", "", ""));
-var_dump(input_get(0, 0, 0, 0, 0));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(4) "test"
-string(18) "http://example.com"
-string(27) "&#60;b&#62;test&#60;/b&#62;"
-NULL
-string(6) "string"
-float(12345.7)
-string(29) "&#60;p&#62;string&#60;/p&#62;"
-NULL
-PHP Warning: input_get() expects parameter 1 to be long, object given in %s on line %d
-
-Warning: input_get() expects parameter 1 to be long, object given in %s on line %d
-NULL
-PHP Warning: input_get() expects parameter 3 to be long, string given in %s on line %d
-
-Warning: input_get() expects parameter 3 to be long, string given in %s on line %d
-NULL
-PHP Warning: input_get() expects parameter 1 to be long, string given in %s on line %d
-
-Warning: input_get() expects parameter 1 to be long, string given in %s on line %d
-NULL
-bool(false)
-Done
diff --git a/ext/filter/tests/012.phpt b/ext/filter/tests/012.phpt
deleted file mode 100644
index 77c1880137..0000000000
--- a/ext/filter/tests/012.phpt
+++ /dev/null
@@ -1,16 +0,0 @@
---TEST--
-input_get()
---FILE--
-<?php
-
-var_dump(input_get(INPUT_GET, "test"));
-var_dump(input_get(INPUT_POST, "test"));
-var_dump(input_get(INPUT_COOKIE, ""));
-
-echo "Done\n";
-?>
---EXPECT--
-bool(false)
-bool(false)
-bool(false)
-Done
diff --git a/ext/filter/tests/013.phpt b/ext/filter/tests/013.phpt
deleted file mode 100644
index 728a29c321..0000000000
--- a/ext/filter/tests/013.phpt
+++ /dev/null
@@ -1,72 +0,0 @@
---TEST--
-filter_data() and flags
---FILE--
-<?php
-var_dump(filter_data(" 234", FILTER_VALIDATE_INT));
-var_dump(filter_data("234 ", FILTER_VALIDATE_INT));
-var_dump(filter_data(" 234 ", FILTER_VALIDATE_INT));
-var_dump(filter_data("0xff", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("0Xff", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("0xFF", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("0XFF", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("07", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-var_dump(filter_data("0xff0000", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("0666", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-var_dump(filter_data("08", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-var_dump(filter_data("00", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-var_dump(filter_data("000", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-
-var_dump(filter_data("-0xff", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("-0Xff", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("-0xFF", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("-0XFF", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("-07", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-var_dump(filter_data("-0xff0000", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("-0666", FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-
-var_dump(filter_data("6", FILTER_VALIDATE_INT, array("min_range"=>1, "max_range"=>7)));
-var_dump(filter_data("6", FILTER_VALIDATE_INT, array("min_range"=>0, "max_range"=>5)));
-var_dump(filter_data(-1, FILTER_VALIDATE_INT, array("min_range"=>1, "max_range"=>7)));
-var_dump(filter_data(-1, FILTER_VALIDATE_INT, array("min_range"=>-4, "max_range"=>7)));
-
-var_dump(filter_data("", FILTER_VALIDATE_INT, array("min_range"=>-4, "max_range"=>7)));
-var_dump(filter_data("", FILTER_VALIDATE_INT, array("min_range"=>2, "max_range"=>7)));
-var_dump(filter_data("", FILTER_VALIDATE_INT, array("min_range"=>-5, "max_range"=>-3)));
-var_dump(filter_data(345, FILTER_VALIDATE_INT, array("min_range"=>500, "max_range"=>100)));
-var_dump(filter_data("0ff", FILTER_VALIDATE_INT));
-var_dump(filter_data("010", FILTER_VALIDATE_INT));
-
-echo "Done\n";
-?>
---EXPECT--
-int(234)
-int(234)
-int(234)
-int(255)
-int(255)
-int(255)
-int(255)
-int(7)
-int(16711680)
-int(438)
-bool(false)
-int(0)
-int(0)
-int(-255)
-int(-255)
-int(-255)
-int(-255)
-int(-7)
-int(-16711680)
-int(-438)
-int(6)
-bool(false)
-bool(false)
-int(-1)
-int(0)
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-Done
diff --git a/ext/filter/tests/014.phpt b/ext/filter/tests/014.phpt
deleted file mode 100644
index f31fe6e9f4..0000000000
--- a/ext/filter/tests/014.phpt
+++ /dev/null
@@ -1,41 +0,0 @@
---TEST--
-filter_data() and FILTER_VALIDATE_BOOLEAN
---FILE--
-<?php
-
-var_dump(filter_data("no", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data(new stdClass, FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("yes", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("true", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("false", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("off", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("on", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("0", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("1", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("NONE", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data(-1, FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("000000", FILTER_VALIDATE_BOOLEAN));
-var_dump(filter_data("111111", FILTER_VALIDATE_BOOLEAN));
-
-
-echo "Done\n";
-?>
---EXPECTF--
-bool(false)
-
-Notice: Object of class stdClass to string conversion in %s on line %d
-NULL
-bool(true)
-bool(true)
-bool(false)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-NULL
-bool(false)
-NULL
-NULL
-NULL
-Done
diff --git a/ext/filter/tests/015.phpt b/ext/filter/tests/015.phpt
deleted file mode 100644
index c46b7d1fb7..0000000000
--- a/ext/filter/tests/015.phpt
+++ /dev/null
@@ -1,72 +0,0 @@
---TEST--
-filter_data() and FILTER_VALIDATE_URL
---FILE--
-<?php
-
-$values = Array(
-'http://example.com/index.html',
-'http://www.example.com/index.php',
-'http://www.example/img/test.png',
-'http://www.example/img/dir/',
-'http://www.example/img/dir',
-'http//www.example/wrong/url/',
-'http:/www.example',
-'file:///tmp/test.c',
-'ftp://ftp.example.com/tmp/',
-'/tmp/test.c',
-'/',
-'http://',
-'http:/',
-'http:',
-'http',
-'',
--1,
-array(),
-);
-foreach ($values as $value) {
- var_dump(filter_data($value, FILTER_VALIDATE_URL));
-}
-
-
-var_dump(filter_data("qwe", FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
-var_dump(filter_data("http://qwe", FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
-var_dump(filter_data("http://", FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED));
-var_dump(filter_data("/tmp/test", FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED));
-var_dump(filter_data("http://www.example.com", FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED));
-var_dump(filter_data("http://www.example.com", FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));
-var_dump(filter_data("http://www.example.com/path/at/the/server/", FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));
-var_dump(filter_data("http://www.example.com/index.html", FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED));
-var_dump(filter_data("http://www.example.com/index.php?a=b&c=d", FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(29) "http://example.com/index.html"
-string(32) "http://www.example.com/index.php"
-string(31) "http://www.example/img/test.png"
-string(27) "http://www.example/img/dir/"
-string(26) "http://www.example/img/dir"
-string(28) "http//www.example/wrong/url/"
-string(17) "http:/www.example"
-string(18) "file:///tmp/test.c"
-string(26) "ftp://ftp.example.com/tmp/"
-string(11) "/tmp/test.c"
-string(1) "/"
-bool(false)
-string(6) "http:/"
-string(5) "http:"
-string(4) "http"
-string(0) ""
-string(2) "-1"
-array(0) {
-}
-bool(false)
-string(10) "http://qwe"
-bool(false)
-bool(false)
-string(22) "http://www.example.com"
-bool(false)
-string(42) "http://www.example.com/path/at/the/server/"
-bool(false)
-string(40) "http://www.example.com/index.php?a=b&c=d"
-Done
diff --git a/ext/filter/tests/016.phpt b/ext/filter/tests/016.phpt
deleted file mode 100644
index 5043567e8d..0000000000
--- a/ext/filter/tests/016.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-filter_data() and FILTER_VALIDATE_EMAIL
---FILE--
-<?php
-$values = Array(
-'a@b.c',
-'abuse@example.com',
-'test!.!@#$%^&*@example.com',
-'test@@#$%^&*())).com',
-'test@.com',
-'test@com',
-'@',
-'[]()/@example.com',
-'QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET',
-);
-foreach ($values as $value) {
- var_dump(filter_data($value, FILTER_VALIDATE_EMAIL));
-}
-
-echo "Done\n";
-?>
---EXPECT--
-string(5) "a@b.c"
-string(17) "abuse@example.com"
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-string(57) "QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET"
-Done
diff --git a/ext/filter/tests/017.phpt b/ext/filter/tests/017.phpt
deleted file mode 100644
index 18c323510c..0000000000
--- a/ext/filter/tests/017.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-filter_data() and FILTER_VALIDATE_REGEXP
---FILE--
-<?php
-
-var_dump(filter_data("data", FILTER_VALIDATE_REGEXP, array("regexp"=>'/.*/')));
-var_dump(filter_data("data", FILTER_VALIDATE_REGEXP, array("regexp"=>'/^b(.*)/')));
-var_dump(filter_data("data", FILTER_VALIDATE_REGEXP, array("regexp"=>'/^d(.*)/')));
-var_dump(filter_data("data", FILTER_VALIDATE_REGEXP, array("regexp"=>'/blah/')));
-var_dump(filter_data("data", FILTER_VALIDATE_REGEXP, array("regexp"=>'/\[/')));
-var_dump(filter_data("data", FILTER_VALIDATE_REGEXP));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(4) "data"
-bool(false)
-string(4) "data"
-bool(false)
-bool(false)
-
-Warning: filter_data(): 'regexp' option missing in %s on line %d
-bool(false)
-Done
diff --git a/ext/filter/tests/018.phpt b/ext/filter/tests/018.phpt
deleted file mode 100644
index 0f5c1a46ed..0000000000
--- a/ext/filter/tests/018.phpt
+++ /dev/null
@@ -1,50 +0,0 @@
---TEST--
-filter_data() and FILTER_VALIDATE_IP
---FILE--
-<?php
-var_dump(filter_data("192.168.0.1", FILTER_VALIDATE_IP));
-var_dump(filter_data("192.168.0.1.1", FILTER_VALIDATE_IP));
-var_dump(filter_data("::1", FILTER_VALIDATE_IP));
-var_dump(filter_data("fe00::0", FILTER_VALIDATE_IP));
-var_dump(filter_data("::123456", FILTER_VALIDATE_IP));
-var_dump(filter_data("::1::b", FILTER_VALIDATE_IP));
-var_dump(filter_data("127.0.0.1", FILTER_VALIDATE_IP));
-var_dump(filter_data("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
-var_dump(filter_data("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
-var_dump(filter_data("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
-var_dump(filter_data("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
-var_dump(filter_data("192.0.34.166", FILTER_VALIDATE_IP));
-var_dump(filter_data("256.1237.123.1", FILTER_VALIDATE_IP));
-var_dump(filter_data("255.255.255.255", FILTER_VALIDATE_IP));
-var_dump(filter_data("255.255.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
-var_dump(filter_data("", FILTER_VALIDATE_IP));
-var_dump(filter_data(-1, FILTER_VALIDATE_IP));
-var_dump(filter_data("::1", FILTER_VALIDATE_IP, FILTER_FLAG_IPV4));
-var_dump(filter_data("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_IPV6));
-var_dump(filter_data("::1", FILTER_VALIDATE_IP, FILTER_FLAG_IPV6));
-var_dump(filter_data("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_IPV4));
-echo "Done\n";
-?>
---EXPECT--
-string(11) "192.168.0.1"
-bool(false)
-string(3) "::1"
-string(7) "fe00::0"
-bool(false)
-bool(false)
-string(9) "127.0.0.1"
-bool(false)
-string(12) "192.0.34.166"
-string(9) "127.0.0.1"
-string(9) "192.0.0.1"
-string(12) "192.0.34.166"
-bool(false)
-string(15) "255.255.255.255"
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-string(3) "::1"
-string(9) "127.0.0.1"
-Done
diff --git a/ext/filter/tests/019.phpt b/ext/filter/tests/019.phpt
deleted file mode 100644
index 7c22e104cc..0000000000
--- a/ext/filter/tests/019.phpt
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-filter_data() & FILTER_VALIDATE_IP and weird data
---FILE--
-<?php
-
-var_dump(filter_data("....", FILTER_VALIDATE_IP));
-var_dump(filter_data("...", FILTER_VALIDATE_IP));
-var_dump(filter_data("..", FILTER_VALIDATE_IP));
-var_dump(filter_data(".", FILTER_VALIDATE_IP));
-var_dump(filter_data("1.1.1.1", FILTER_VALIDATE_IP));
-
-echo "Done\n";
-?>
---EXPECTF--
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-string(7) "1.1.1.1"
-Done
diff --git a/ext/filter/tests/020.phpt b/ext/filter/tests/020.phpt
deleted file mode 100644
index 914c199afb..0000000000
--- a/ext/filter/tests/020.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_MAGIC_QUOTES
---FILE--
-<?php
-
-var_dump(filter_data("test'asd'asd'' asd\'\"asdfasdf", FILTER_SANITIZE_MAGIC_QUOTES));
-var_dump(filter_data("'", FILTER_SANITIZE_MAGIC_QUOTES));
-var_dump(filter_data("", FILTER_SANITIZE_MAGIC_QUOTES));
-var_dump(filter_data(-1, FILTER_SANITIZE_MAGIC_QUOTES));
-
-echo "Done\n";
-?>
---EXPECT--
-string(36) "test\'asd\'asd\'\' asd\\\'\"asdfasdf"
-string(2) "\'"
-string(0) ""
-string(2) "-1"
-Done
diff --git a/ext/filter/tests/021.phpt b/ext/filter/tests/021.phpt
deleted file mode 100644
index 697fdd69d4..0000000000
--- a/ext/filter/tests/021.phpt
+++ /dev/null
@@ -1,44 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_NUMBER_*
---FILE--
-<?php
-
-var_dump(filter_data("qwertyu123456dfghj", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("asd123123.asd123.23", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("123,23", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("0", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("asd123.2asd", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("qwertyuiop", FILTER_SANITIZE_NUMBER_INT));
-var_dump(filter_data("123.4", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("123,4", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("123.4", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_THOUSAND));
-var_dump(filter_data("123,4", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_THOUSAND));
-var_dump(filter_data("123.4e", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_SCIENTIFIC));
-var_dump(filter_data("123,4E", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_SCIENTIFIC));
-var_dump(filter_data("qwe123,4qwe", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("werty65456.34", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("234.56fsfd", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("", FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-
-echo "Done\n";
-?>
---EXPECT--
-string(6) "123456"
-string(11) "12312312323"
-string(5) "12323"
-string(0) ""
-string(1) "0"
-string(4) "1232"
-string(0) ""
-string(5) "123.4"
-string(4) "1234"
-string(4) "1234"
-string(5) "123,4"
-string(5) "1234e"
-string(5) "1234E"
-string(4) "1234"
-string(8) "65456.34"
-string(6) "234.56"
-string(0) ""
-Done
diff --git a/ext/filter/tests/022.phpt b/ext/filter/tests/022.phpt
deleted file mode 100644
index 28ad64e723..0000000000
--- a/ext/filter/tests/022.phpt
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_EMAIL
---FILE--
-<?php
-
-var_dump(filter_data("a@b.c", FILTER_SANITIZE_EMAIL));
-var_dump(filter_data("a[!@#$%^&*()@a@#$%^&*(.com@#$%^&*(", FILTER_SANITIZE_EMAIL));
-var_dump(filter_data("white space here \ \ \" som more", FILTER_SANITIZE_EMAIL));
-var_dump(filter_data("", FILTER_SANITIZE_EMAIL));
-var_dump(filter_data("123456789000000", FILTER_SANITIZE_EMAIL));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(5) "a@b.c"
-string(30) "a[!@#$%^&*@a@#$%^&*.com@#$%^&*"
-string(21) "whitespaceheresommore"
-string(0) ""
-string(15) "123456789000000"
-Done
diff --git a/ext/filter/tests/023.phpt b/ext/filter/tests/023.phpt
deleted file mode 100644
index 21fdc49a9b..0000000000
--- a/ext/filter/tests/023.phpt
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-filter_data() and FILTER_UNSAFE_RAW
---FILE--
-<?php
-
-var_dump(filter_data("}\"<p>test para</p>", FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("a[!@#<b>$%^&*()@a@#$%^&*(.<br>com@#$%^&*(", FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("white space here \ \ \" some more", FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("", FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data(" 123456789000000 <qwertyuiop> ", FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-
-echo "Done\n";
-?>
---EXPECT--
-string(18) "}"<p>test para</p>"
-string(53) "a[!@#<b>$%^&#38;*()@a@#$%^&#38;*(.<br>com@#$%^&#38;*("
-string(32) "white space here \ \ " some more"
-string(0) ""
-string(48) " 123456789000000 <qwertyuiop> "
-Done
diff --git a/ext/filter/tests/024.phpt b/ext/filter/tests/024.phpt
deleted file mode 100644
index d405af3f08..0000000000
--- a/ext/filter/tests/024.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_ENCODED
---FILE--
-<?php
-
-var_dump(filter_data("\"<br>blah</ph>", FILTER_SANITIZE_ENCODED));
-var_dump(filter_data("", FILTER_SANITIZE_ENCODED));
-var_dump(filter_data(" text here ", FILTER_SANITIZE_ENCODED));
-var_dump(filter_data("!@#$%^&*()QWERTYUIOP{ASDFGHJKL:\"ZXCVBNM<>?", FILTER_SANITIZE_ENCODED));
-
-echo "Done\n";
-?>
---EXPECT--
-string(26) "%22%3Cbr%3Eblah%3C%2Fph%3E"
-string(0) ""
-string(23) "%20%20text%20here%20%20"
-string(74) "%21%40%23%24%25%5E%26%2A%28%29QWERTYUIOP%7BASDFGHJKL%3A%22ZXCVBNM%3C%3E%3F"
-Done
diff --git a/ext/filter/tests/025.phpt b/ext/filter/tests/025.phpt
deleted file mode 100644
index c770fb80f7..0000000000
--- a/ext/filter/tests/025.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_STRING
---FILE--
-<?php
-
-var_dump(filter_data("", FILTER_SANITIZE_STRING));
-var_dump(filter_data("<>", FILTER_SANITIZE_STRING));
-var_dump(filter_data("<>!@#$%^&*()'\"", FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES));
-var_dump(filter_data("<>!@#$%^&*()'\"", FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("<>`1234567890", FILTER_SANITIZE_STRING));
-var_dump(filter_data("`123`", FILTER_SANITIZE_STRING));
-var_dump(filter_data(".", FILTER_SANITIZE_STRING));
-
-echo "Done\n";
-?>
---EXPECT--
-string(0) ""
-string(0) ""
-string(12) "!@#$%^&*()'""
-string(32) "!@#$%^&#38;*()&#38;#39;&#38;#34;"
-string(11) "`1234567890"
-string(5) "`123`"
-string(1) "."
-Done
diff --git a/ext/filter/tests/026.phpt b/ext/filter/tests/026.phpt
deleted file mode 100644
index b53dcb1989..0000000000
--- a/ext/filter/tests/026.phpt
+++ /dev/null
@@ -1,30 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_STRIPPED
---FILE--
-<?php
-
-var_dump(filter_data("<p>Let me <font color=\"#000000\">see</font> you <br /><b>Stripped</b> down to the bone</p>", FILTER_SANITIZE_STRIPPED));
-var_dump(filter_data("!@#$%^&*()><<>+_\"'<br><p /><li />", FILTER_SANITIZE_STRIPPED));
-var_dump(filter_data("", FILTER_SANITIZE_STRIPPED));
-
-var_dump(filter_data("<p>Let me <font color=\"#000000\">see</font> you <br /><b>Stripped</b> down to the bone</p>", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_LOW));
-var_dump(filter_data("!@#$%^&*()><<>+_\"'<br><p /><li />", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_LOW));
-var_dump(filter_data("", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_LOW));
-
-var_dump(filter_data("<p>Let me <font color=\"#000000\">see</font> you <br /><b>Stripped</b> down to the bone</p>", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_HIGH));
-var_dump(filter_data("!@#$%^&*()><<>+_\"'<br><p /><li />", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_HIGH));
-var_dump(filter_data("", FILTER_SANITIZE_STRIPPED, FILTER_FLAG_STRIP_HIGH));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(40) "Let me see you Stripped down to the bone"
-string(11) "!@#$%^&*()>"
-string(0) ""
-string(40) "Let me see you Stripped down to the bone"
-string(11) "!@#$%^&*()>"
-string(0) ""
-string(40) "Let me see you Stripped down to the bone"
-string(11) "!@#$%^&*()>"
-string(0) ""
-Done
diff --git a/ext/filter/tests/027.phpt b/ext/filter/tests/027.phpt
deleted file mode 100644
index 048dc362ef..0000000000
--- a/ext/filter/tests/027.phpt
+++ /dev/null
@@ -1,30 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_ENCODED
---FILE--
-<?php
-
-var_dump(filter_data("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_ENCODED));
-var_dump(filter_data("<data&sons>", FILTER_SANITIZE_ENCODED));
-var_dump(filter_data("", FILTER_SANITIZE_ENCODED));
-
-var_dump(filter_data("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW));
-var_dump(filter_data("<data&sons>", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW));
-var_dump(filter_data("", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW));
-
-var_dump(filter_data("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH));
-var_dump(filter_data("<data&sons>", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH));
-var_dump(filter_data("", FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH));
-
-echo "Done\n";
-?>
---EXPECT--
-string(75) "%3F%3E%3C%21%40%23%24%25%5E%26%2A%28%29%7D%7B%7EQwertyuilfdsasdfgmnbvcxcvbn"
-string(17) "%3Cdata%26sons%3E"
-string(0) ""
-string(75) "%3F%3E%3C%21%40%23%24%25%5E%26%2A%28%29%7D%7B%7EQwertyuilfdsasdfgmnbvcxcvbn"
-string(17) "%3Cdata%26sons%3E"
-string(0) ""
-string(75) "%3F%3E%3C%21%40%23%24%25%5E%26%2A%28%29%7D%7B%7EQwertyuilfdsasdfgmnbvcxcvbn"
-string(17) "%3Cdata%26sons%3E"
-string(0) ""
-Done
diff --git a/ext/filter/tests/028.phpt b/ext/filter/tests/028.phpt
deleted file mode 100644
index 1d0d2e2071..0000000000
--- a/ext/filter/tests/028.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-filter_data() and FILTER_SANITIZE_SPECIAL_CHARS
---FILE--
-<?php
-
-var_dump(filter_data("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_SPECIAL_CHARS));
-var_dump(filter_data("<data&sons>", FILTER_SANITIZE_SPECIAL_CHARS));
-var_dump(filter_data("", FILTER_SANITIZE_SPECIAL_CHARS));
-
-var_dump(filter_data("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_LOW));
-var_dump(filter_data("<data&sons>", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_LOW));
-var_dump(filter_data("", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_LOW));
-
-var_dump(filter_data("?><!@#$%^&*()}{~Qwertyuilfdsasdfgmnbvcxcvbn", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH));
-var_dump(filter_data("<data&sons>", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH));
-var_dump(filter_data("", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH));
-
-var_dump(filter_data("кириллица", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH));
-var_dump(filter_data("кириллица", FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_LOW));
-
-echo "Done\n";
-?>
---EXPECT--
-string(55) "?&#62;&#60;!@#$%^&#38;*()}{~Qwertyuilfdsasdfgmnbvcxcvbn"
-string(23) "&#60;data&#38;sons&#62;"
-string(0) ""
-string(55) "?&#62;&#60;!@#$%^&#38;*()}{~Qwertyuilfdsasdfgmnbvcxcvbn"
-string(23) "&#60;data&#38;sons&#62;"
-string(0) ""
-string(55) "?&#62;&#60;!@#$%^&#38;*()}{~Qwertyuilfdsasdfgmnbvcxcvbn"
-string(23) "&#60;data&#38;sons&#62;"
-string(0) ""
-string(108) "&#208;&#186;&#208;&#184;&#209;&#128;&#208;&#184;&#208;&#187;&#208;&#187;&#208;&#184;&#209;&#134;&#208;&#176;"
-string(18) "кириллица"
-Done
diff --git a/ext/filter/tests/029.phpt b/ext/filter/tests/029.phpt
deleted file mode 100644
index f60c42ef3c..0000000000
--- a/ext/filter/tests/029.phpt
+++ /dev/null
@@ -1,103 +0,0 @@
---TEST--
-filter_data() and FILTER_CALLBACK
---FILE--
-<?php
-
-/* Simple callback function */
-function test($var) {
- return strtoupper($var);
-}
-
-var_dump(filter_data("data", FILTER_CALLBACK, "test"));
-var_dump(filter_data("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, "test"));
-var_dump(filter_data("", FILTER_CALLBACK, "test"));
-var_dump(filter_data("qwe", FILTER_CALLBACK, "no such func"));
-var_dump(filter_data("qwe", FILTER_CALLBACK, ""));
-var_dump(filter_data("qwe", FILTER_CALLBACK));
-
-/* Simple class method callback */
-class test_class {
- static function test ($var) {
- return strtolower($var);
- }
-}
-
-var_dump(filter_data("dAtA", FILTER_CALLBACK, array("test_class", "test")));
-var_dump(filter_data("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, array("test_class","test")));
-var_dump(filter_data("", FILTER_CALLBACK, array("test_class","test")));
-
-/* empty function without return value */
-function test1($var) {
-}
-
-var_dump(filter_data("data", FILTER_CALLBACK, "test1"));
-var_dump(filter_data("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, "test1"));
-var_dump(filter_data("", FILTER_CALLBACK, "test1"));
-
-/* attempting to change data by reference */
-function test2(&$var) {
- $var = 1;
-}
-
-var_dump(filter_data("data", FILTER_CALLBACK, "test2"));
-var_dump(filter_data("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, "test2"));
-var_dump(filter_data("", FILTER_CALLBACK, "test2"));
-
-/* unsetting data */
-function test3(&$var) {
- unset($var);
-}
-
-var_dump(filter_data("data", FILTER_CALLBACK, "test3"));
-var_dump(filter_data("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, "test3"));
-var_dump(filter_data("", FILTER_CALLBACK, "test3"));
-
-/* unset data and return value */
-function test4(&$var) {
- unset($var);
- return 1;
-}
-
-var_dump(filter_data("data", FILTER_CALLBACK, "test4"));
-
-/* thrown exception in the callback */
-function test5(&$var) {
- throw new Exception("test");
-}
-
-try {
- var_dump(filter_data("data", FILTER_CALLBACK, "test5"));
-} catch (Exception $e) {
- var_dump($e->getMessage());
-}
-
-echo "Done\n";
-?>
---EXPECTF--
-string(4) "DATA"
-string(46) "~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?"}{:"
-string(0) ""
-
-Warning: filter_data(): First argument is expected to be a valid callback in %s on line %d
-NULL
-
-Warning: filter_data(): First argument is expected to be a valid callback in %s on line %d
-NULL
-
-Warning: filter_data(): First argument is expected to be a valid callback in %s on line %d
-NULL
-string(4) "data"
-string(46) "~!@#$%^&*()_qwertyuiopasdfghjklzxcvbnm<>>?"}{:"
-string(0) ""
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-int(1)
-string(4) "test"
-Done
diff --git a/ext/filter/tests/030.phpt b/ext/filter/tests/030.phpt
deleted file mode 100644
index ff4ea3930b..0000000000
--- a/ext/filter/tests/030.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-filter_data() and IPv6
---FILE--
-<?php
-$ipv6_test = array(
- "::127.0.0.1" => true,
- "FF01::101:127.0.1" => false,
- "FF01:0:0:0:101:127.0.1.1" => false,
- "FF01:0:0:0:237:101:127.0.1.1" => true,
- "FF01::101" => true,
- "A1080::8:800:200C:417A" => false,
- "1080::8:Z00:200C:417A" => false,
- "FF01::101::1" => false,
- "1080::8:800:200C:417A" => true,
- "1080:0:0:0:8:800:200C:417A" => true,
- "2001:ec8:1:1:1:1:1:1" => true,
- "ffff::FFFF:129.144.52.38" => true,
- "::ffff:1.2.3.4" => true,
- "0:0:0:0:0:FFFF:129.144.52.38" => true,
- "0:0:0:0:0:0:13.1.68.3" => true,
- "::13.1.68.3" => true,
- "::FFFF:129.144.52.38" => true
-);
-foreach ($ipv6_test as $ip => $exp) {
- $out = filter_data($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
- $out = (int) ($out === false ? 0 : 1);
- if ($exp != $out) {
- echo "$ip failed\n";
- }
-}
-
-echo "Ok\n";
-?>
---EXPECT--
-Ok
diff --git a/ext/filter/tests/031.phpt b/ext/filter/tests/031.phpt
deleted file mode 100644
index a743291612..0000000000
--- a/ext/filter/tests/031.phpt
+++ /dev/null
@@ -1,54 +0,0 @@
---TEST--
-filter_data() and FLOAT
---FILE--
-<?php
-
-$floats = array(
-'1.234 ',
-' 1.234',
-'1.234' ,
-'1.2e3',
-'7E3',
-'7E3 ',
-' 7E3 ',
-' 7E-3 '
-);
-
-foreach ($floats as $float) {
- $out = filter_data($float, FILTER_VALIDATE_FLOAT);
- var_dump($out);
-}
-
-$floats = array(
-'1.234 ' => ',',
-'1,234' => ',',
-' 1.234' => '.',
-'1.234' => '..',
-'1.2e3' => ','
-);
-
-echo "\ncustom decimal:\n";
-foreach ($floats as $float => $dec) {
- $out = filter_data($float, FILTER_VALIDATE_FLOAT, array('decimal' => $dec));
- var_dump($out);
-}
-
-?>
---EXPECTF--
-float(1.234)
-float(1.234)
-float(1.234)
-float(1200)
-float(7000)
-float(7000)
-float(7000)
-float(0.007)
-
-custom decimal:
-bool(false)
-float(1.234)
-float(1.234)
-
-Warning: filter_data(): decimal separator must be one char in %s on line %d
-bool(false)
-bool(false)
diff --git a/ext/filter/tests/032.phpt b/ext/filter/tests/032.phpt
deleted file mode 100644
index a7f8a7c6cb..0000000000
--- a/ext/filter/tests/032.phpt
+++ /dev/null
@@ -1,55 +0,0 @@
---TEST--
-input_get_args()
---FILE--
-<?php
-$data = array(
- 'product_id' => 'libgd<script>',
- 'component' => '10dhsajkkdhk <do>',
- 'versions' => '2.0.33',
- 'testscalar' => array('2','23','10','12'),
- 'testarray' => '2',
-);
-
-$args = array(
- 'product_id' => FILTER_SANITIZE_ENCODED,
- 'component' => array(//'filter' => FILTER_VALIDATE_INT,
- 'flags' => FILTER_FLAG_ARRAY,
- 'options' => array("min_range"=>1, "max_range"=>10)
- ),
- 'versions' => array(
- 'filter' => FILTER_SANITIZE_ENCODED,
- 'flags' => FILTER_FLAG_SCALAR,
- ),
- 'doesnotexist' => FILTER_VALIDATE_INT,
- 'testscalar' => FILTER_VALIDATE_INT,
- 'testarray' => array(
- 'filter' => FILTER_VALIDATE_INT,
- 'flags' => FILTER_FLAG_ARRAY,
- )
-
-);
-
-$myinputs = input_get_args($args, INPUT_DATA, $data);
-var_dump($myinputs);
-?>
---EXPECT--
-array(6) {
- ["product_id"]=>
- string(17) "libgd%3Cscript%3E"
- ["component"]=>
- array(1) {
- [0]=>
- string(17) "10dhsajkkdhk <do>"
- }
- ["versions"]=>
- string(6) "2.0.33"
- ["doesnotexist"]=>
- NULL
- ["testscalar"]=>
- bool(false)
- ["testarray"]=>
- array(1) {
- [0]=>
- int(2)
- }
-}
diff --git a/ext/filter/tests/033.phpt b/ext/filter/tests/033.phpt
deleted file mode 100644
index c6ec13323e..0000000000
--- a/ext/filter/tests/033.phpt
+++ /dev/null
@@ -1,25 +0,0 @@
---TEST--
-Test all filters returned by input_filters_list()
---FILE--
-<?php
-include dirname(__FILE__) . '/033_run.php';
-?>
---EXPECT--
-int 1 123
-boolean 1
-float 1
-validate_regexp O'Henry
-validate_url http://a.b.c
-validate_email foo@bar.com
-validate_ip 1.2.3.4
-string PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() O&#39;Henry 하퍼
-stripped PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc() OHenry 하퍼
-encoded PHP 1 foo%40bar.com http%3A%2F%2Fa.b.c 1.2.3.4 123 123abc%3C%3E%28%29 O%27Henry %ED%95%98%ED%8D%BC
-special_chars PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc&#60;&#62;() O&#39;Henry 하퍼
-unsafe_raw PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry 하퍼
-email PHP 1 foo@bar.com http//a.b.c 1.2.3.4 123 123abc O'Henry
-url PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O'Henry
-number_int 1 1234 123 123
-number_float 1 1.2.3.4 123 123
-magic_quotes PHP 1 foo@bar.com http://a.b.c 1.2.3.4 123 123abc<>() O\'Henry 하퍼
-callback PHP 1 FOO@BAR.COM HTTP://A.B.C 1.2.3.4 123 123ABC<>() O'HENRY 하퍼
diff --git a/ext/filter/tests/033_run.php b/ext/filter/tests/033_run.php
deleted file mode 100644
index 229e7ba259..0000000000
--- a/ext/filter/tests/033_run.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-function test($data) {
- return strtoupper($data);
-}
-$data = array("PHP","1","foo@bar.com","http://a.b.c","1.2.3.4","123","123abc<>()","O'Henry", "하퍼");
-foreach(input_filters_list() as $filter) {
- if($filter=="validate_regexp") {
- foreach($data as $k=>$d) $result[$k] = filter_data($d,input_name_to_filter($filter),array("regexp"=>'/^O.*/'));
- } else {
- foreach($data as $k=>$d) $result[$k] = filter_data($d,input_name_to_filter($filter),"test");
- }
- printf("%-20s",$filter);
- printf("%-5s",$result[0]);
- printf("%-3s",$result[1]);
- printf("%-15s",$result[2]);
- printf("%-20s",$result[3]);
- printf("%-10s",$result[4]);
- printf("%-5s",$result[5]);
- printf("%-20s",$result[6]);
- printf("%-15s",$result[7]);
- printf("%-10s\n",$result[8]);
-}
-?>
diff --git a/ext/filter/tests/bug7586.phpt b/ext/filter/tests/bug7586.phpt
deleted file mode 100644
index af4be33f78..0000000000
--- a/ext/filter/tests/bug7586.phpt
+++ /dev/null
@@ -1,53 +0,0 @@
---TEST--
-input_get_args() filter not reseted between elements
---FILE--
-<?php
-$data = array(
- 'product_id' => 'libgd<script>',
- 'component' => '10dhsajkkdhk <do>',
- 'versions' => '2.0.33',
- 'testscalar' => array('2','23','10','12'),
- 'testarray' => '2',
-);
-
-$args = array(
- 'product_id' => FILTER_SANITIZE_ENCODED,
- 'component' => array('flags' => FILTER_FLAG_ARRAY,
- 'options' => array("min_range"=>1, "max_range"=>10)
- ),
- 'versions' => array(
- 'filter' => FILTER_SANITIZE_ENCODED,
- 'flags' => FILTER_FLAG_SCALAR,
- ),
- 'doesnotexist' => FILTER_VALIDATE_INT,
- 'testscalar' => FILTER_VALIDATE_INT,
- 'testarray' => array(
- 'filter' => FILTER_VALIDATE_INT,
- 'flags' => FILTER_FLAG_ARRAY,
- )
-
-);
-$out = input_get_args($args, INPUT_DATA, $data);
-var_dump($out);
-?>
---EXPECTF--
-array(6) {
- ["product_id"]=>
- string(17) "libgd%3Cscript%3E"
- ["component"]=>
- array(1) {
- [0]=>
- string(17) "%s"
- }
- ["versions"]=>
- string(6) "2.0.33"
- ["doesnotexist"]=>
- NULL
- ["testscalar"]=>
- bool(false)
- ["testarray"]=>
- array(1) {
- [0]=>
- int(2)
- }
-}
diff --git a/ext/filter/tests/bug7715.phpt b/ext/filter/tests/bug7715.phpt
deleted file mode 100644
index 9e1206f6a5..0000000000
--- a/ext/filter/tests/bug7715.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-bug 7715, floats value with integer or incomplete input
---FILE--
-<?php
-$data = array(
- '.23',
- '-42',
- '+42',
- '.4',
- '-.4',
- '1000000000000',
- '-1000000000000'
-);
-foreach ($data as $val) {
- $res = filter_data($val, FILTER_VALIDATE_FLOAT);
- var_dump($res);
-}
-echo "\n";
-?>
---EXPECTF--
-float(0.23)
-float(-42)
-float(42)
-float(0.4)
-float(-0.4)
-float(1.0E+12)
-float(-1.0E+12)
diff --git a/ext/filter/tests/bug7733.phpt b/ext/filter/tests/bug7733.phpt
deleted file mode 100644
index f8497122a5..0000000000
--- a/ext/filter/tests/bug7733.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-input_get_args() filter not reseted between elements
---FILE--
-<?php
-$data = array(
- 'E2',
- '10E',
- '2E-',
- 'E-2',
- '+E2'
- );
-$out = filter_data($data, FILTER_VALIDATE_FLOAT);
-var_dump($out);
-?>
---EXPECTF--
-array(5) {
- [0]=>
- float(0)
- [1]=>
- float(10)
- [2]=>
- float(2)
- [3]=>
- float(0)
- [4]=>
- float(0)
-}
diff --git a/ext/filter/tests/filter_data.phpt b/ext/filter/tests/filter_data.phpt
deleted file mode 100644
index e907d02093..0000000000
--- a/ext/filter/tests/filter_data.phpt
+++ /dev/null
@@ -1,71 +0,0 @@
---TEST--
-Simple filter_data() tests
---FILE--
-<?php
-
-/* Integer */
-$data = "-123"; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-$data = "0"; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-$data = "123"; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-$data = -123; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-$data = 0; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-$data = 123; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-$data = ""; var_dump(filter_data($data, FILTER_VALIDATE_INT));
-echo "\n";
-
-/* Float */
-$data = "-0.123"; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-$data = "0.00"; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-$data = "1.23"; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-$data = -1.23; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-$data = 0.0; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-$data = 1.23; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-$data = ""; var_dump(filter_data($data, FILTER_VALIDATE_FLOAT));
-echo "\n";
-
-/* Boolean */
-$data = "on"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "off"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "yes"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "no"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "true"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "false"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "1"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = "0"; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = 1; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = 0; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = true; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = false; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-$data = ""; var_dump(filter_data($data, FILTER_VALIDATE_BOOLEAN));
-
-?>
---EXPECT--
-int(-123)
-int(0)
-int(123)
-int(-123)
-int(0)
-int(123)
-int(0)
-
-float(-0.123)
-float(0)
-float(1.23)
-float(-1.23)
-float(0)
-float(1.23)
-float(0)
-
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(false)
diff --git a/ext/imap/imap.h b/ext/imap/imap.h
deleted file mode 100644
index 914d128316..0000000000
--- a/ext/imap/imap.h
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef _INCLUDED_IMAP_H
-#define _INCLUDED_IMAP_H
-
-#if COMPILE_DL
-#undef HAVE_IMAP
-#define HAVE_IMAP 1
-#endif
-
-#if HAVE_IMAP
-
-#ifndef PHP_WIN32
-#include "build-defs.h"
-#endif
-
-/* Functions accessable to PHP */
-extern zend_module_entry imap_module_entry;
-#define imap_module_ptr &imap_module_entry
-
-extern PHP_MINIT_FUNCTION(imap);
-extern PHP_RINIT_FUNCTION(imap);
-extern PHP_RSHUTDOWN_FUNCTION(imap);
-PHP_MINFO_FUNCTION(imap);
-PHP_FUNCTION(imap_open);
-PHP_FUNCTION(imap_popen);
-PHP_FUNCTION(imap_reopen);
-PHP_FUNCTION(imap_num_msg);
-PHP_FUNCTION(imap_num_recent);
-PHP_FUNCTION(imap_headers);
-PHP_FUNCTION(imap_headerinfo);
-PHP_FUNCTION(imap_rfc822_parse_headers);
-PHP_FUNCTION(imap_body);
-PHP_FUNCTION(imap_fetchstructure);
-PHP_FUNCTION(imap_fetchbody);
-PHP_FUNCTION(imap_expunge);
-PHP_FUNCTION(imap_delete);
-PHP_FUNCTION(imap_undelete);
-PHP_FUNCTION(imap_check);
-PHP_FUNCTION(imap_close);
-PHP_FUNCTION(imap_mail_copy);
-PHP_FUNCTION(imap_mail_move);
-PHP_FUNCTION(imap_createmailbox);
-PHP_FUNCTION(imap_renamemailbox);
-PHP_FUNCTION(imap_deletemailbox);
-PHP_FUNCTION(imap_listmailbox);
-PHP_FUNCTION(imap_scanmailbox);
-PHP_FUNCTION(imap_subscribe);
-PHP_FUNCTION(imap_unsubscribe);
-PHP_FUNCTION(imap_append);
-PHP_FUNCTION(imap_ping);
-PHP_FUNCTION(imap_base64);
-PHP_FUNCTION(imap_qprint);
-PHP_FUNCTION(imap_8bit);
-PHP_FUNCTION(imap_binary);
-PHP_FUNCTION(imap_mailboxmsginfo);
-PHP_FUNCTION(imap_rfc822_write_address);
-PHP_FUNCTION(imap_rfc822_parse_adrlist);
-PHP_FUNCTION(imap_setflag_full);
-PHP_FUNCTION(imap_clearflag_full);
-PHP_FUNCTION(imap_sort);
-PHP_FUNCTION(imap_fetchheader);
-PHP_FUNCTION(imap_fetchtext);
-PHP_FUNCTION(imap_uid);
-PHP_FUNCTION(imap_msgno);
-PHP_FUNCTION(imap_list);
-PHP_FUNCTION(imap_list_full);
-PHP_FUNCTION(imap_listscan);
-PHP_FUNCTION(imap_lsub);
-PHP_FUNCTION(imap_lsub_full);
-PHP_FUNCTION(imap_create);
-PHP_FUNCTION(imap_rename);
-PHP_FUNCTION(imap_status);
-PHP_FUNCTION(imap_bodystruct);
-PHP_FUNCTION(imap_fetch_overview);
-PHP_FUNCTION(imap_mail_compose);
-PHP_FUNCTION(imap_alerts);
-PHP_FUNCTION(imap_errors);
-PHP_FUNCTION(imap_last_error);
-PHP_FUNCTION(imap_mail);
-PHP_FUNCTION(imap_search);
-PHP_FUNCTION(imap_utf8);
-PHP_FUNCTION(imap_utf7_decode);
-PHP_FUNCTION(imap_utf7_encode);
-PHP_FUNCTION(imap_mime_header_decode);
-#else
-#define imap_module_ptr NULL
-#endif /* HAVE_IMAP */
-
-#endif
-
-
-
-
-
-
-#define phpext_imap_ptr imap_module_ptr
-
-
-
-
-
-
-
-
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c
deleted file mode 100644
index adb974346e..0000000000
--- a/ext/json/JSON_parser.c
+++ /dev/null
@@ -1,757 +0,0 @@
-/* JSON_parser.c */
-
-/* 2005-12-30 */
-
-/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-
-#include "JSON_parser.h"
-#include <stdio.h>
-
-#define true 1
-#define false 0
-
-/*
- Characters are mapped into these 32 symbol classes. This allows for
- significant reductions in the size of the state transition table.
-*/
-
-/* error */
-#define S_ERR -1
-
-/* space */
-#define S_SPA 0
-
-/* other whitespace */
-#define S_WSP 1
-
-/* { */
-#define S_LBE 2
-
-/* } */
-#define S_RBE 3
-
-/* [ */
-#define S_LBT 4
-
-/* ] */
-#define S_RBT 5
-
-/* : */
-#define S_COL 6
-
-/* , */
-#define S_COM 7
-
-/* " */
-#define S_QUO 8
-
-/* \ */
-#define S_BAC 9
-
-/* / */
-#define S_SLA 10
-
-/* + */
-#define S_PLU 11
-
-/* - */
-#define S_MIN 12
-
-/* . */
-#define S_DOT 13
-
-/* 0 */
-#define S_ZER 14
-
-/* 123456789 */
-#define S_DIG 15
-
-/* a */
-#define S__A_ 16
-
-/* b */
-#define S__B_ 17
-
-/* c */
-#define S__C_ 18
-
-/* d */
-#define S__D_ 19
-
-/* e */
-#define S__E_ 20
-
-/* f */
-#define S__F_ 21
-
-/* l */
-#define S__L_ 22
-
-/* n */
-#define S__N_ 23
-
-/* r */
-#define S__R_ 24
-
-/* s */
-#define S__S_ 25
-
-/* t */
-#define S__T_ 26
-
-/* u */
-#define S__U_ 27
-
-/* ABCDF */
-#define S_A_F 28
-
-/* E */
-#define S_E 29
-
-/* everything else */
-#define S_ETC 30
-
-
-/*
- This table maps the 128 ASCII characters into the 32 character classes.
- The remaining Unicode characters should be mapped to S_ETC.
-*/
-static int ascii_class[128] = {
- S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
- S_ERR, S_WSP, S_WSP, S_ERR, S_ERR, S_WSP, S_ERR, S_ERR,
- S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
- S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
-
- S_SPA, S_ETC, S_QUO, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC,
- S_ETC, S_ETC, S_ETC, S_PLU, S_COM, S_MIN, S_DOT, S_SLA,
- S_ZER, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG,
- S_DIG, S_DIG, S_COL, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC,
-
- S_ETC, S_A_F, S_A_F, S_A_F, S_A_F, S_E , S_A_F, S_ETC,
- S_ETC, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC,
- S_ETC, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC, S_ETC,
- S_ETC, S_ETC, S_ETC, S_LBT, S_BAC, S_RBT, S_ETC, S_ETC,
-
- S_ETC, S__A_, S__B_, S__C_, S__D_, S__E_, S__F_, S_ETC,
- S_ETC, S_ETC, S_ETC, S_ETC, S__L_, S_ETC, S__N_, S_ETC,
- S_ETC, S_ETC, S__R_, S__S_, S__T_, S__U_, S_ETC, S_ETC,
- S_ETC, S_ETC, S_ETC, S_LBE, S_ETC, S_RBE, S_ETC, S_ETC
-};
-
-
-/*
- The state transition table takes the current state and the current symbol,
- and returns either a new state or an action. A new state is a number between
- 0 and 29. An action is a negative number between -1 and -9. A JSON text is
- accepted if the end of the text is in state 9 and mode is MODE_DONE.
-*/
-static int state_transition_table[30][31] = {
-/* 0*/ { 0, 0,-8,-1,-6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/* 1*/ { 1, 1,-1,-9,-1,-1,-1,-1, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/* 2*/ { 2, 2,-8,-1,-6,-5,-1,-1, 3,-1,-1,-1,20,-1,21,22,-1,-1,-1,-1,-1,13,-1,17,-1,-1,10,-1,-1,-1,-1},
-/* 3*/ { 3,-1, 3, 3, 3, 3, 3, 3,-4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
-/* 4*/ {-1,-1,-1,-1,-1,-1,-1,-1, 3, 3, 3,-1,-1,-1,-1,-1,-1, 3,-1,-1,-1, 3,-1, 3, 3,-1, 3, 5,-1,-1,-1},
-/* 5*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 6, 6, 6, 6, 6, 6, 6, 6,-1,-1,-1,-1,-1,-1, 6, 6,-1},
-/* 6*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 7, 7, 7, 7, 7, 7, 7, 7,-1,-1,-1,-1,-1,-1, 7, 7,-1},
-/* 7*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 8, 8, 8, 8, 8, 8, 8, 8,-1,-1,-1,-1,-1,-1, 8, 8,-1},
-/* 8*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 3, 3, 3, 3, 3, 3, 3, 3,-1,-1,-1,-1,-1,-1, 3, 3,-1},
-/* 9*/ { 9, 9,-1,-7,-1,-5,-1,-3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*10*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,-1,-1,-1,-1,-1,-1},
-/*11*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,12,-1,-1,-1},
-/*12*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*13*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*14*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,15,-1,-1,-1,-1,-1,-1,-1,-1},
-/*15*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,16,-1,-1,-1,-1,-1},
-/*16*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*17*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,18,-1,-1,-1},
-/*18*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,-1,-1,-1,-1,-1,-1,-1,-1},
-/*19*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 9,-1,-1,-1,-1,-1,-1,-1,-1},
-/*20*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,21,22,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*21*/ { 9, 9,-1,-7,-1,-5,-1,-3,-1,-1,-1,-1,-1,23,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*22*/ { 9, 9,-1,-7,-1,-5,-1,-3,-1,-1,-1,-1,-1,23,22,22,-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,24,-1},
-/*23*/ { 9, 9,-1,-7,-1,-5,-1,-3,-1,-1,-1,-1,-1,-1,23,23,-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,24,-1},
-/*24*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,25,25,-1,26,26,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*25*/ {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,26,26,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*26*/ { 9, 9,-1,-7,-1,-5,-1,-3,-1,-1,-1,-1,-1,-1,26,26,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*27*/ {27,27,-1,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
-/*28*/ {28,28,-8,-1,-6,-1,-1,-1, 3,-1,-1,-1,20,-1,21,22,-1,-1,-1,-1,-1,13,-1,17,-1,-1,10,-1,-1,-1,-1},
-/*29*/ {29,29,-1,-1,-1,-1,-1,-1, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
-};
-
-#define JSON_PARSER_MAX_DEPTH 20
-
-
-/*
- A stack maintains the states of nested structures.
-*/
-
-typedef struct json_parser
-{
- int the_stack[JSON_PARSER_MAX_DEPTH];
- zval *the_zstack[JSON_PARSER_MAX_DEPTH];
- int the_top;
-} json_parser;
-
-
-/*
- These modes can be pushed on the PDA stack.
-*/
-#define MODE_DONE 1
-#define MODE_KEY 2
-#define MODE_OBJECT 3
-#define MODE_ARRAY 4
-
-/*
- Push a mode onto the stack. Return false if there is overflow.
-*/
-static int
-push(json_parser *json, zval *z, int mode)
-{
- json->the_top += 1;
- if (json->the_top >= JSON_PARSER_MAX_DEPTH) {
- return false;
- }
-
- json->the_stack[json->the_top] = mode;
- return true;
-}
-
-
-/*
- Pop the stack, assuring that the current mode matches the expectation.
- Return false if there is underflow or if the modes mismatch.
-*/
-static int
-pop(json_parser *json, zval *z, int mode)
-{
- if (json->the_top < 0 || json->the_stack[json->the_top] != mode) {
- return false;
- }
- json->the_stack[json->the_top] = 0;
- json->the_top -= 1;
-
- return true;
-}
-
-
-static int dehexchar(char c)
-{
- if (c >= '0' && c <= '9')
- {
- return c - '0';
- }
- else if (c >= 'A' && c <= 'F')
- {
- return c - ('A' - 10);
- }
- else if (c >= 'a' && c <= 'f')
- {
- return c - ('a' - 10);
- }
- else
- {
- return -1;
- }
-}
-
-
-static void json_create_zval(zval **z, smart_str *buf, int type)
-{
- ALLOC_INIT_ZVAL(*z);
-
- if (type == IS_LONG)
- {
- ZVAL_LONG(*z, atol(buf->c));
- }
- else if (type == IS_DOUBLE)
- {
- ZVAL_DOUBLE(*z, atof(buf->c));
- }
- else if (type == IS_STRING)
- {
- ZVAL_STRINGL(*z, buf->c, buf->len, 1);
- }
- else if (type == IS_BOOL)
- {
- ZVAL_BOOL(*z, (*(buf->c) == 't'));
- }
- else /* type == IS_NULL) || type unknown */
- {
- ZVAL_NULL(*z);
- }
-}
-
-
-static void utf16_to_utf8(smart_str *buf, unsigned short utf16)
-{
- if (utf16 < 0x80)
- {
- smart_str_appendc(buf, (unsigned char) utf16);
- }
- else if (utf16 < 0x800)
- {
- smart_str_appendc(buf, 0xc0 | (utf16 >> 6));
- smart_str_appendc(buf, 0x80 | (utf16 & 0x3f));
- }
- else
- {
- smart_str_appendc(buf, 0xe0 | (utf16 >> 12));
- smart_str_appendc(buf, 0x80 | ((utf16 >> 6) & 0x3f));
- smart_str_appendc(buf, 0x80 | (utf16 & 0x3f));
- }
-}
-
-static void attach_zval(json_parser *json, int up, int cur, smart_str *key, int assoc TSRMLS_DC)
-{
- zval *root = json->the_zstack[up];
- zval *child = json->the_zstack[cur];
- int up_mode = json->the_stack[up];
-
- if (up_mode == MODE_ARRAY)
- {
- add_next_index_zval(root, child);
- }
- else if (up_mode == MODE_OBJECT)
- {
- if (!assoc)
- {
- add_property_zval(root, key->c, child);
-#if PHP_MAJOR_VERSION >= 5
- ZVAL_DELREF(child);
-#endif
- }
- else
- {
- add_assoc_zval(root, key->c, child);
- }
- key->len = 0;
- }
-}
-
-
-#define FREE_BUFFERS() do { smart_str_free(&buf); smart_str_free(&key); } while (0);
-#define SWAP_BUFFERS(from, to) do { \
- char *t1 = from.c; \
- int t2 = from.a; \
- from.c = to.c; \
- from.a = to.a; \
- to.c = t1; \
- to.a = t2; \
- to.len = from.len; \
- from.len = 0; \
- } while(0);
-#define JSON_RESET_TYPE() do { type = -1; } while(0);
-#define JSON(x) the_json.x
-
-
-/*
- The JSON_parser takes a UTF-16 encoded string and determines if it is a
- syntactically correct JSON text. Along the way, it creates a PHP variable.
-
- It is implemented as a Pushdown Automaton; that means it is a finite state
- machine with a stack.
-*/
-int
-JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC)
-{
- int b; /* the next character */
- int c; /* the next character class */
- int s; /* the next state */
- json_parser the_json; /* the parser state */
- int the_state = 0;
- int the_index;
-
- smart_str buf = {0};
- smart_str key = {0};
-
- int type = -1;
- unsigned short utf16;
-
- JSON(the_top) = -1;
- push(&the_json, z, MODE_DONE);
-
- for (the_index = 0; the_index < length; the_index += 1) {
- b = p[the_index];
- if ((b & 127) == b) {
- c = ascii_class[b];
- if (c <= S_ERR) {
- FREE_BUFFERS();
- return false;
- }
- } else {
- c = S_ETC;
- }
-/*
- Get the next state from the transition table.
-*/
- s = state_transition_table[the_state][c];
- if (s < 0) {
-/*
- Perform one of the predefined actions.
-*/
- switch (s) {
-/*
- empty }
-*/
- case -9:
- if (!pop(&the_json, z, MODE_KEY)) {
- FREE_BUFFERS();
- return false;
- }
- the_state = 9;
- break;
-/*
- {
-*/
- case -8:
- if (!push(&the_json, z, MODE_KEY)) {
- FREE_BUFFERS();
- return false;
- }
-
- the_state = 1;
- if (JSON(the_top) > 0)
- {
- zval *obj;
-
- if (JSON(the_top) == 1)
- {
- obj = z;
- }
- else
- {
- ALLOC_INIT_ZVAL(obj);
- }
-
- if (!assoc)
- {
- object_init(obj);
- }
- else
- {
- array_init(obj);
- }
-
- JSON(the_zstack)[JSON(the_top)] = obj;
-
- if (JSON(the_top) > 1)
- {
- attach_zval(&the_json, JSON(the_top-1), JSON(the_top), &key, assoc TSRMLS_CC);
- }
-
- JSON_RESET_TYPE();
- }
-
- break;
-/*
- }
-*/
- case -7:
- if (type != -1 &&
- (JSON(the_stack)[JSON(the_top)] == MODE_OBJECT ||
- JSON(the_stack)[JSON(the_top)] == MODE_ARRAY))
- {
- zval *mval;
- smart_str_0(&buf);
-
- json_create_zval(&mval, &buf, type);
-
- if (!assoc)
- {
- add_property_zval(JSON(the_zstack)[JSON(the_top)], key.c, mval);
-#if PHP_MAJOR_VERSION >= 5
- ZVAL_DELREF(mval);
-#endif
- }
- else
- {
- add_assoc_zval(JSON(the_zstack)[JSON(the_top)], key.c, mval);
- }
- key.len = 0;
- buf.len = 0;
- JSON_RESET_TYPE();
- }
-
-
- if (!pop(&the_json, z, MODE_OBJECT)) {
- FREE_BUFFERS();
- return false;
- }
- the_state = 9;
- break;
-/*
- [
-*/
- case -6:
- if (!push(&the_json, z, MODE_ARRAY)) {
- FREE_BUFFERS();
- return false;
- }
- the_state = 2;
-
- if (JSON(the_top) > 0)
- {
- zval *arr;
-
- if (JSON(the_top) == 1)
- {
- arr = z;
- }
- else
- {
- ALLOC_INIT_ZVAL(arr);
- }
-
- array_init(arr);
- JSON(the_zstack)[JSON(the_top)] = arr;
-
- if (JSON(the_top) > 1)
- {
- attach_zval(&the_json, JSON(the_top-1), JSON(the_top), &key, assoc TSRMLS_CC);
- }
-
- JSON_RESET_TYPE();
- }
-
- break;
-/*
- ]
-*/
- case -5:
- {
- if (type != -1 &&
- (JSON(the_stack)[JSON(the_top)] == MODE_OBJECT ||
- JSON(the_stack)[JSON(the_top)] == MODE_ARRAY))
- {
- zval *mval;
- smart_str_0(&buf);
-
- json_create_zval(&mval, &buf, type);
- add_next_index_zval(JSON(the_zstack)[JSON(the_top)], mval);
- buf.len = 0;
- JSON_RESET_TYPE();
- }
-
- if (!pop(&the_json, z, MODE_ARRAY)) {
- FREE_BUFFERS();
- return false;
- }
- the_state = 9;
- }
- break;
-/*
- "
-*/
- case -4:
- switch (JSON(the_stack)[JSON(the_top)]) {
- case MODE_KEY:
- the_state = 27;
- smart_str_0(&buf);
- SWAP_BUFFERS(buf, key);
- JSON_RESET_TYPE();
- break;
- case MODE_ARRAY:
- case MODE_OBJECT:
- the_state = 9;
- break;
- default:
- FREE_BUFFERS();
- return false;
- }
- break;
-/*
- ,
-*/
- case -3:
- {
- zval *mval;
-
- if (type != -1 &&
- (JSON(the_stack)[JSON(the_top)] == MODE_OBJECT ||
- JSON(the_stack[JSON(the_top)]) == MODE_ARRAY))
- {
- smart_str_0(&buf);
- json_create_zval(&mval, &buf, type);
- }
-
- switch (JSON(the_stack)[JSON(the_top)]) {
- case MODE_OBJECT:
- if (pop(&the_json, z, MODE_OBJECT) && push(&the_json, z, MODE_KEY)) {
- if (type != -1)
- {
- if (!assoc)
- {
- add_property_zval(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : "_empty_"), mval);
-#if PHP_MAJOR_VERSION >= 5
- ZVAL_DELREF(mval);
-#endif
- }
- else
- {
- add_assoc_zval(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : "_empty_"), mval);
- }
- key.len = 0;
- }
- the_state = 29;
- }
- break;
- case MODE_ARRAY:
- if (type != -1)
- {
- add_next_index_zval(JSON(the_zstack)[JSON(the_top)], mval);
- }
- the_state = 28;
- break;
- default:
- FREE_BUFFERS();
- return false;
- }
- buf.len = 0;
- JSON_RESET_TYPE();
- }
- break;
-/*
- :
-*/
- case -2:
- if (pop(&the_json, z, MODE_KEY) && push(&the_json, z, MODE_OBJECT)) {
- the_state = 28;
- break;
- }
-/*
- syntax error
-*/
- case -1:
- {
- FREE_BUFFERS();
- return false;
- }
- }
- } else {
-/*
- Change the state and iterate.
-*/
- if (type == IS_STRING)
- {
- if (s == 3 && the_state != 8)
- {
- if (the_state != 4)
- {
- utf16_to_utf8(&buf, b);
- }
- else
- {
- switch (b)
- {
- case 'b':
- smart_str_appendc(&buf, '\b');
- break;
- case 't':
- smart_str_appendc(&buf, '\t');
- break;
- case 'n':
- smart_str_appendc(&buf, '\n');
- break;
- case 'f':
- smart_str_appendc(&buf, '\f');
- break;
- case 'r':
- smart_str_appendc(&buf, '\r');
- break;
- default:
- utf16_to_utf8(&buf, b);
- break;
- }
- }
- }
- else if (s == 6)
- {
- utf16 = dehexchar(b) << 12;
- }
- else if (s == 7)
- {
- utf16 += dehexchar(b) << 8;
- }
- else if (s == 8)
- {
- utf16 += dehexchar(b) << 4;
- }
- else if (s == 3 && the_state == 8)
- {
- utf16 += dehexchar(b);
- utf16_to_utf8(&buf, utf16);
- }
- }
- else if (type < IS_LONG && (c == S_DIG || c == S_ZER))
- {
- type = IS_LONG;
- smart_str_appendc(&buf, b);
- }
- else if (type == IS_LONG && s == 24)
- {
- type = IS_DOUBLE;
- smart_str_appendc(&buf, b);
- }
- else if (type < IS_DOUBLE && c == S_DOT)
- {
- type = IS_DOUBLE;
- smart_str_appendc(&buf, b);
- }
- else if (type < IS_STRING && c == S_QUO)
- {
- type = IS_STRING;
- }
- else if (type < IS_BOOL && ((the_state == 12 && s == 9) || (the_state == 16 && s == 9)))
- {
- type = IS_BOOL;
- }
- else if (type < IS_NULL && the_state == 19 && s == 9)
- {
- type = IS_NULL;
- }
- else if (type != IS_STRING && c > S_WSP)
- {
- utf16_to_utf8(&buf, b);
- }
-
- the_state = s;
- }
- }
-
- FREE_BUFFERS();
-
- return the_state == 9 && pop(&the_json, z, MODE_DONE);
-}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/json/JSON_parser.h b/ext/json/JSON_parser.h
deleted file mode 100644
index 085e776982..0000000000
--- a/ext/json/JSON_parser.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* JSON_checker.h */
-
-#include "php.h"
-#include "ext/standard/php_smart_str.h"
-
-static char digits[] = "0123456789abcdef";
-
-extern int JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC);
diff --git a/ext/json/README b/ext/json/README
deleted file mode 100644
index d680b0c592..0000000000
--- a/ext/json/README
+++ /dev/null
@@ -1,76 +0,0 @@
-json 1.2.0
-==========
-
-This extension implements the JavaScript Object Notation (JSON)
-data-interchange format as specified in [0].
-
-Two functions are implemented: encoding and decoding. The decoding
-is handled by a parser based on JSON_checker[1] by Douglas Crockford.
-
-
-Function overview
------------------
-
- string json_encode ( mixed value )
-
-json_encode returns a string containing the JSON representation of value.
-value can be any type except a resource.
-
- mixed json_decode ( string json, [bool assoc] )
-
-json_decode takes a JSON string and converts it into a PHP variable.
-When assoc is given, and evaluates to TRUE, json_decode() will return
-any objects as associative arrays.
-
-
-Example usage
--------------
-
-$arr = array("a"=>1,"b"=>2,"c"=>3,"d"=>4,"e"=>5);
-echo json_encode($arr);
-
----> {"a":1,"b":2,"c":3,"d":4,"e":5}
-
-$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
-var_dump(json_decode($json));
-
----> object(stdClass)#1 (5) {
- ["a"]=>
- int(1)
- ["b"]=>
- int(2)
- ["c"]=>
- int(3)
- ["d"]=>
- int(4)
- ["e"]=>
- int(5)
- }
-
-$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
-var_dump(json_decode($json, true));
-
----> array(5) {
- ["a"]=>
- int(1)
- ["b"]=>
- int(2)
- ["c"]=>
- int(3)
- ["d"]=>
- int(4)
- ["e"]=>
- int(5)
- }
-
-
-Authors
--------
-
-Omar Kilani <omar@php.net>
-
-
----
-
-[0] http://www.crockford.com/JSON/draft-jsonorg-json-00.txt
-[1] http://www.crockford.com/JSON/JSON_checker/
diff --git a/ext/json/config.m4 b/ext/json/config.m4
deleted file mode 100644
index a937b1f91b..0000000000
--- a/ext/json/config.m4
+++ /dev/null
@@ -1,88 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-AC_DEFUN([PHP_JSON_ADD_SOURCES], [
- PHP_JSON_SOURCES="$PHP_JSON_SOURCES $1"
-])
-
-AC_DEFUN([PHP_JSON_ADD_BASE_SOURCES], [
- PHP_JSON_BASE_SOURCES="$PHP_JSON_BASE_SOURCES $1"
-])
-
-AC_DEFUN([PHP_JSON_ADD_BUILD_DIR], [
- PHP_JSON_EXTRA_BUILD_DIRS="$PHP_JSON_EXTRA_BUILD_DIRS $1"
-])
-
-AC_DEFUN([PHP_JSON_ADD_INCLUDE], [
- PHP_JSON_EXTRA_INCLUDES="$PHP_JSON_EXTRA_INCLUDES $1"
-])
-
-AC_DEFUN([PHP_JSON_ADD_CONFIG_HEADER], [
- PHP_JSON_EXTRA_CONFIG_HEADERS="$PHP_JSON_EXTRA_CONFIG_HEADERS $1"
-])
-
-AC_DEFUN([PHP_JSON_ADD_CFLAG], [
- PHP_JSON_CFLAGS="$PHP_JSON_CFLAGS $1"
-])
-
-AC_DEFUN([PHP_JSON_EXTENSION], [
- PHP_NEW_EXTENSION(json, $PHP_JSON_SOURCES, $ext_shared,, $PHP_JSON_CFLAGS)
- PHP_SUBST(JSON_SHARED_LIBADD)
-
- for dir in $PHP_JSON_EXTRA_BUILD_DIRS; do
- PHP_ADD_BUILD_DIR([$ext_builddir/$dir], 1)
- done
-
- for dir in $PHP_JSON_EXTRA_INCLUDES; do
- PHP_ADD_INCLUDE([$ext_srcdir/$dir])
- PHP_ADD_INCLUDE([$ext_builddir/$dir])
- done
-
- if test "$ext_shared" = "no"; then
- PHP_ADD_SOURCES(PHP_EXT_DIR(json), $PHP_JSON_BASE_SOURCES,$PHP_JSON_CFLAGS)
- out="php_config.h"
- else
- PHP_ADD_SOURCES_X(PHP_EXT_DIR(json),$PHP_JSON_BASE_SOURCES,$PHP_JSON_CFLAGS,shared_objects_json,yes)
- if test -f "$ext_builddir/config.h.in"; then
- out="$abs_builddir/config.h"
- else
- out="php_config.h"
- fi
- fi
-
- for cfg in $PHP_JSON_EXTRA_CONFIG_HEADERS; do
- cat > $ext_builddir/$cfg <<EOF
-#include "$out"
-EOF
- done
-])
-
-AC_DEFUN([PHP_JSON_SETUP_JSON_CHECKER], [
- PHP_JSON_ADD_SOURCES([
- utf8_to_utf16.c
- utf8_decode.c
- JSON_parser.c
- ])
-])
-
-dnl
-dnl Main config
-dnl
-
-PHP_ARG_WITH(json, whether to enable JavaScript Object Serialization support,
-[ --with-json Enable JavaScript Object Serialization support])
-
-if test "$PHP_JSON" != "no"; then
- AC_DEFINE([HAVE_JSON],1,[whether to have JavaScript Object Serialization support])
- AC_HEADER_STDC
-
- PHP_JSON_ADD_BASE_SOURCES([json.c])
-
- dnl json_c is required
- PHP_JSON_SETUP_JSON_CHECKER
- PHP_JSON_EXTENSION
- dnl PHP_INSTALL_HEADERS([ext/json], [json_c])
-fi
-
-# vim600: sts=2 sw=2 et
diff --git a/ext/json/config.w32 b/ext/json/config.w32
deleted file mode 100644
index fa001d308c..0000000000
--- a/ext/json/config.w32
+++ /dev/null
@@ -1,10 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("json", "JavaScript Object Serialization support", "no");
-
-if (PHP_JSON != "no") {
- EXTENSION('json', 'json.c', PHP_JSON_SHARED, "");
- ADD_SOURCES(configure_module_dirname, "JSON_parser.c utf8_decode.c utf8_to_utf16.c", "json");
-}
-
diff --git a/ext/json/json.c b/ext/json/json.c
deleted file mode 100644
index d19eb2e9b5..0000000000
--- a/ext/json/json.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Omar Kilani <omar@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "ext/standard/php_smart_str.h"
-#include "utf8_to_utf16.h"
-#include "JSON_parser.h"
-#include "php_json.h"
-
-/* If you declare any globals in php_json.h uncomment this:
-ZEND_DECLARE_MODULE_GLOBALS(json)
-*/
-
-/* True global resources - no need for thread safety here */
-static int le_json;
-
-/* {{{ json_functions[]
- *
- * Every user visible function must have an entry in json_functions[].
- */
-function_entry json_functions[] = {
- PHP_FE(json_encode, NULL)
- PHP_FE(json_decode, NULL)
- {NULL, NULL, NULL} /* Must be the last line in json_functions[] */
-};
-/* }}} */
-
-/* {{{ json_module_entry
- */
-zend_module_entry json_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- "json",
- json_functions,
- NULL,
- NULL,
- NULL,
- NULL,
- PHP_MINFO(json),
-#if ZEND_MODULE_API_NO >= 20010901
- PHP_JSON_VERSION,
-#endif
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_JSON
-ZEND_GET_MODULE(json)
-#endif
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(json)
-{
- php_info_print_table_start();
- php_info_print_table_row(2, "json support", "enabled");
- php_info_print_table_row(2, "json version", PHP_JSON_VERSION);
- php_info_print_table_end();
-}
-/* }}} */
-
-static void json_encode_r(smart_str *buf, zval *val TSRMLS_DC);
-static void json_escape_string(smart_str *buf, char *s, int len TSRMLS_DC);
-
-static int json_determine_array_type(zval **val TSRMLS_DC) {
- int i;
- HashTable *myht;
-
- if (Z_TYPE_PP(val) == IS_ARRAY) {
- myht = HASH_OF(*val);
- } else {
- myht = Z_OBJPROP_PP(val);
- return 1;
- }
-
- i = myht ? zend_hash_num_elements(myht) : 0;
- if (i > 0) {
- char *key;
- ulong index, idx;
- uint key_len;
- HashPosition pos;
-
- zend_hash_internal_pointer_reset_ex(myht, &pos);
- idx = 0;
- for (;; zend_hash_move_forward_ex(myht, &pos)) {
- i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos);
- if (i == HASH_KEY_NON_EXISTANT)
- break;
-
- if (i == HASH_KEY_IS_STRING) {
- return 1;
- } else {
- if (index != idx) {
- return 1;
- }
- }
- idx++;
- }
- }
-
- return 0;
-}
-
-static void json_encode_array(smart_str *buf, zval **val TSRMLS_DC) {
- int i, r;
- HashTable *myht;
-
- if (Z_TYPE_PP(val) == IS_ARRAY) {
- myht = HASH_OF(*val);
- r = json_determine_array_type(val TSRMLS_CC);
- } else {
- myht = Z_OBJPROP_PP(val);
- r = 1;
- }
-
- if (r == 0)
- {
- smart_str_appendc(buf, '[');
- }
- else
- {
- smart_str_appendc(buf, '{');
- }
-
- i = myht ? zend_hash_num_elements(myht) : 0;
- if (i > 0) {
- char *key;
- zval **data;
- ulong index;
- uint key_len;
- HashPosition pos;
- int need_comma = 0;
-
- zend_hash_internal_pointer_reset_ex(myht, &pos);
- for (;; zend_hash_move_forward_ex(myht, &pos)) {
- i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos);
- if (i == HASH_KEY_NON_EXISTANT)
- break;
-
- if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) == SUCCESS) {
- if (r == 0) {
- if (need_comma) {
- smart_str_appendc(buf, ',');
- } else {
- need_comma = 1;
- }
-
- json_encode_r(buf, *data TSRMLS_CC);
- } else if (r == 1) {
- if (i == HASH_KEY_IS_STRING) {
- if (key[0] == '\0') {
- /* Skip protected and private members. */
- continue;
- }
-
- if (need_comma) {
- smart_str_appendc(buf, ',');
- } else {
- need_comma = 1;
- }
-
- json_escape_string(buf, key, key_len - 1 TSRMLS_CC);
- smart_str_appendc(buf, ':');
-
- json_encode_r(buf, *data TSRMLS_CC);
- } else {
- if (need_comma) {
- smart_str_appendc(buf, ',');
- } else {
- need_comma = 1;
- }
-
- smart_str_appendc(buf, '"');
- smart_str_append_long(buf, (long) index);
- smart_str_appendc(buf, '"');
- smart_str_appendc(buf, ':');
-
- json_encode_r(buf, *data TSRMLS_CC);
- }
- }
- }
- }
- }
-
- if (r == 0)
- {
- smart_str_appendc(buf, ']');
- }
- else
- {
- smart_str_appendc(buf, '}');
- }
-}
-
-#define REVERSE16(us) (((us & 0xf) << 12) | (((us >> 4) & 0xf) << 8) | (((us >> 8) & 0xf) << 4) | ((us >> 12) & 0xf))
-
-static void json_escape_string(smart_str *buf, char *s, int len TSRMLS_DC)
-{
- int pos = 0;
- unsigned short us;
- unsigned short *utf16;
-
- if (len == 0)
- {
- smart_str_appendl(buf, "\"\"", 2);
- return;
- }
-
- utf16 = (unsigned short *) emalloc(len * sizeof(unsigned short));
-
- len = utf8_to_utf16(utf16, s, len);
- if (len <= 0)
- {
- if (utf16)
- {
- efree(utf16);
- }
-
- smart_str_appendl(buf, "\"\"", 2);
- return;
- }
-
- smart_str_appendc(buf, '"');
-
- while(pos < len)
- {
- us = utf16[pos++];
-
- switch (us)
- {
- case '"':
- {
- smart_str_appendl(buf, "\\\"", 2);
- }
- break;
- case '\\':
- {
- smart_str_appendl(buf, "\\\\", 2);
- }
- break;
- case '/':
- {
- smart_str_appendl(buf, "\\/", 2);
- }
- break;
- case '\b':
- {
- smart_str_appendl(buf, "\\b", 2);
- }
- break;
- case '\f':
- {
- smart_str_appendl(buf, "\\f", 2);
- }
- break;
- case '\n':
- {
- smart_str_appendl(buf, "\\n", 2);
- }
- break;
- case '\r':
- {
- smart_str_appendl(buf, "\\r", 2);
- }
- break;
- case '\t':
- {
- smart_str_appendl(buf, "\\t", 2);
- }
- break;
- default:
- {
- if (us < ' ' || (us & 127) == us)
- {
- smart_str_appendc(buf, (unsigned char) us);
- }
- else
- {
- smart_str_appendl(buf, "\\u", 2);
- us = REVERSE16(us);
-
- smart_str_appendc(buf, digits[us & ((1 << 4) - 1)]);
- us >>= 4;
- smart_str_appendc(buf, digits[us & ((1 << 4) - 1)]);
- us >>= 4;
- smart_str_appendc(buf, digits[us & ((1 << 4) - 1)]);
- us >>= 4;
- smart_str_appendc(buf, digits[us & ((1 << 4) - 1)]);
- }
- }
- break;
- }
- }
-
- smart_str_appendc(buf, '"');
- efree(utf16);
-}
-
-static void json_encode_r(smart_str *buf, zval *val TSRMLS_DC) {
- switch (Z_TYPE_P(val)) {
- case IS_NULL:
- smart_str_appendl(buf, "null", 4);
- break;
- case IS_BOOL:
- if (Z_BVAL_P(val))
- {
- smart_str_appendl(buf, "true", 4);
- }
- else
- {
- smart_str_appendl(buf, "false", 5);
- }
- break;
- case IS_LONG:
- smart_str_append_long(buf, Z_LVAL_P(val));
- break;
- case IS_DOUBLE:
- {
- char *d = NULL;
- int len;
- double dbl = Z_DVAL_P(val);
-
- if (!zend_isinf(dbl) && !zend_isnan(dbl))
- {
- len = spprintf(&d, 0, "%.9g", dbl);
- if (d)
- {
- smart_str_appendl(buf, d, len);
- efree(d);
- }
- }
- else
- {
- zend_error(E_WARNING, "[json] (json_encode_r) double %.9g does not conform to the JSON spec, encoded as 0.", dbl);
- smart_str_appendc(buf, '0');
- }
- }
- break;
- case IS_STRING:
- json_escape_string(buf, Z_STRVAL_P(val), Z_STRLEN_P(val) TSRMLS_CC);
- break;
- case IS_ARRAY:
- case IS_OBJECT:
- json_encode_array(buf, &val TSRMLS_CC);
- break;
- default:
- zend_error(E_WARNING, "[json] (json_encode_r) type is unsupported, encoded as null.");
- smart_str_appendl(buf, "null", 4);
- break;
- }
-
- return;
-}
-
-PHP_FUNCTION(json_encode)
-{
- zval *parameter;
- smart_str buf = {0};
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &parameter) == FAILURE) {
- return;
- }
-
- json_encode_r(&buf, parameter TSRMLS_CC);
-
- ZVAL_STRINGL(return_value, buf.c, buf.len, 1);
-
- smart_str_free(&buf);
-}
-
-PHP_FUNCTION(json_decode)
-{
- char *parameter;
- int parameter_len, utf16_len;
- zend_bool assoc = 0; /* return JS objects as PHP objects by default */
- zval *z;
- unsigned short *utf16;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &parameter, &parameter_len, &assoc) == FAILURE) {
- return;
- }
-
- if (!parameter_len)
- {
- RETURN_NULL();
- }
-
- utf16 = (unsigned short *) emalloc((parameter_len+1) * sizeof(unsigned short));
-
- utf16_len = utf8_to_utf16(utf16, parameter, parameter_len);
- if (utf16_len <= 0)
- {
- if (utf16)
- {
- efree(utf16);
- }
-
- RETURN_NULL();
- }
-
- ALLOC_INIT_ZVAL(z);
- if (JSON_parser(z, utf16, utf16_len, assoc TSRMLS_CC))
- {
- *return_value = *z;
-
- FREE_ZVAL(z);
- efree(utf16);
- }
- else
- {
- zval_dtor(z);
- FREE_ZVAL(z);
- efree(utf16);
- RETURN_NULL();
- }
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/json/json.dsp b/ext/json/json.dsp
deleted file mode 100644
index e5bb3767bf..0000000000
--- a/ext/json/json.dsp
+++ /dev/null
@@ -1,135 +0,0 @@
-# Microsoft Developer Studio Project File - Name="json" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=json - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "json.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "json.mak" CFG="json - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "json - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "json - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "json - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JSON_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "json_c" /D HAVE_JSON=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D ZEND_DEBUG=1 /D ZTS=1 /D COMPILE_DL_JSON=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JSON_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x1009 /d "_DEBUG"
-# ADD RSC /l 0x1009 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 iconv.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_json.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
-
-!ELSEIF "$(CFG)" == "json - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JSON_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "json_c" /D HAVE_JSON=1 /D "ZEND_WIN32" /D ZEND_DEBUG=0 /D "PHP_WIN32" /D ZTS=1 /D COMPILE_DL_JSON=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JSON_EXPORTS" /D "HAVE_FCNTL_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x1009 /d "NDEBUG"
-# ADD RSC /l 0x1009 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 iconv.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_json.dll" /libpath:"..\..\Release_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "json - Win32 Debug_TS"
-# Name "json - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=".\json.c"
-# End Source File
-# Begin Source File
-
-SOURCE=.\JSON_parser.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\JSON_parser.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\utf8_decode.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\utf8_decode.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\utf8_to_utf16.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\utf8_to_utf16.h
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_json.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/ext/json/package.xml b/ext/json/package.xml
deleted file mode 100644
index 0651de736f..0000000000
--- a/ext/json/package.xml
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package>
- <dep type="php" rel="ge" version="4.3.0" optional="no"/>
- <name>json</name>
- <summary>JavaScript Object Notation</summary>
- <maintainers>
- <maintainer>
- <user>omar</user>
- <name>Omar Kilani</name>
- <email>omar@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <description>
- Support for JSON (JavaScript Object Notation) serialization.
- </description>
- <license>PHP 3.01</license>
- <release>
- <state>stable</state>
- <version>1.2.1</version>
- <date>2006-03-18</date>
- <notes>
- Fix PECL bug #7147 - rework handling of comma insertion while encoding.
- Add tests to package.xml
- </notes>
- </release>
- <configureoptions>
- </configureoptions>
- <filelist>
- <file role="doc" name="README" />
- <file role="src" name="config.m4" />
- <file role="src" name="config.w32" />
- <file role="src" name="json.dsp" />
- <file role="src" name="json.c" />
- <file role="src" name="JSON_parser.c" />
- <file role="src" name="JSON_parser.h" />
- <file role="src" name="php_json.h" />
- <file role="src" name="utf8_decode.c" />
- <file role="src" name="utf8_decode.h" />
- <file role="src" name="utf8_to_utf16.c" />
- <file role="src" name="utf8_to_utf16.h" />
- <dir role="test" name="tests">
- <file role="test" name="fail001.phpt" />
- <file role="test" name="pass001.phpt" />
- <file role="test" name="pass001.1.phpt" />
- <file role="test" name="pass002.phpt" />
- <file role="test" name="pass003.phpt" />
- </dir>
- </filelist>
- <changelog>
- <release>
- <state>stable</state>
- <version>1.0.0</version>
- <date>2005-04-01</date>
- <notes>
- Initial release.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.1</version>
- <date>2005-06-10</date>
- <notes>
- Fixed non-linear and mixed type array index issues, fixed issues with escaping \\, forked json-c and added Unicode support.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.2</version>
- <date>2005-06-11</date>
- <notes>
- Fixed issues with object reference counts under PHP4.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.3</version>
- <date>2005-06-15</date>
- <notes>
- Fixed json-c string corruption issues under Mac OS X and FreeBSD.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.4</version>
- <date>2005-06-15</date>
- <notes>
- Changes in 1.0.4 released with 1.0.5.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.5</version>
- <date>2005-06-16</date>
- <notes>
- Changed spacing in json-c encoding, added optional assoc (boolean) parameter to json_decode to decode as associative array instead of object, fixed issues with escaping /.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.6</version>
- <date>2005-08-05</date>
- <notes>
- Fixed issues with exporting private and protected class members.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.7</version>
- <date>2005-09-07</date>
- <notes>
- Fixed issues with negative array keys, modified json-c to return an error on unquoted object key names instead of going into an infinite loop.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.0.8</version>
- <date>2005-12-01</date>
- <notes>
- Changed license to LGPL, modified build system to allow static compilation into PHP, added strndup check for json-c.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.1.0</version>
- <date>2005-12-04</date>
- <notes>
- Port to Win32.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.1.1</version>
- <date>2006-01-12</date>
- <notes>
- Cleanup and TSRM performance fixes by rasmus.
- </notes>
- </release>
- <release>
- <state>stable</state>
- <version>1.2.0</version>
- <date>2006-03-15</date>
- <notes>
- Complete rewrite using JSON_checker as the base for the parser. Implements the JSON specification. 3-8x faster on encodes and 1.2x-4x faster on decodes.
- </notes>
- </release>
- </changelog>
-</package>
-<!--
-vim:et:ts=1:sw=1
--->
diff --git a/ext/json/php_json.h b/ext/json/php_json.h
deleted file mode 100644
index 48555ee31f..0000000000
--- a/ext/json/php_json.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Omar Kilani <omar@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_JSON_H
-#define PHP_JSON_H
-
-#define PHP_JSON_VERSION "1.2.1"
-
-extern zend_module_entry json_module_entry;
-#define phpext_json_ptr &json_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_JSON_API __declspec(dllexport)
-#else
-#define PHP_JSON_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-PHP_MINFO_FUNCTION(json);
-
-PHP_FUNCTION(json_encode);
-PHP_FUNCTION(json_decode);
-
-#ifdef ZTS
-#define JSON_G(v) TSRMG(json_globals_id, zend_json_globals *, v)
-#else
-#define JSON_G(v) (json_globals.v)
-#endif
-
-#endif /* PHP_JSON_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/json/tests/fail001.phpt b/ext/json/tests/fail001.phpt
deleted file mode 100644
index 4ee3780cf3..0000000000
--- a/ext/json/tests/fail001.phpt
+++ /dev/null
@@ -1,166 +0,0 @@
---TEST--
-JSON Test Pattern fail1 -> fail24
-http://www.crockford.com/JSON/JSON_checker/test/fail*.json
---SKIPIF--
-<?php
- if (!extension_loaded('json')) die('skip: json extension not available');
-?>
---FILE--
-<?php
-
-$tests = array('"A JSON payload should be an object or array, not a string."',
- '["Unclosed array"',
- '{unquoted_key: "keys must be quoted}',
- '["extra comma",]',
- '["double extra comma",,]',
- '[ , "<-- missing value"]',
- '["Comma after the close"],',
- '["Extra close"]]',
- '{"Extra comma": true,}',
- '{"Extra value after close": true} "misplaced quoted value"',
- '{"Illegal expression": 1 + 2}',
- '{"Illegal invocation": alert()}',
- '{"Numbers cannot have leading zeroes": 013}',
- '{"Numbers cannot be hex": 0x14}',
- '["Illegal backslash escape: \\x15"]',
- '["Illegal backslash escape: \\\'"]',
- '["Illegal backslash escape: \\017"]',
- '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]',
- '{"Missing colon" null}',
- '{"Double colon":: null}',
- '{"Comma instead of colon", null}',
- '["Colon instead of comma": false]',
- '["Bad value", truth]',
- "['single quote']");
-
-foreach ($tests as $test)
-{
- echo 'Testing: ' . $test . "\n";
- echo "AS OBJECT\n";
- var_dump(json_decode($test));
- echo "AS ARRAY\n";
- var_dump(json_decode($test, true));
-}
-
-?>
---EXPECT--
-Testing: "A JSON payload should be an object or array, not a string."
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Unclosed array"
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {unquoted_key: "keys must be quoted}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["extra comma",]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["double extra comma",,]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: [ , "<-- missing value"]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Comma after the close"],
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Extra close"]]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Extra comma": true,}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Extra value after close": true} "misplaced quoted value"
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Illegal expression": 1 + 2}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Illegal invocation": alert()}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Numbers cannot have leading zeroes": 013}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Numbers cannot be hex": 0x14}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Illegal backslash escape: \x15"]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Illegal backslash escape: \'"]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Illegal backslash escape: \017"]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: [[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Missing colon" null}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Double colon":: null}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: {"Comma instead of colon", null}
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Colon instead of comma": false]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ["Bad value", truth]
-AS OBJECT
-NULL
-AS ARRAY
-NULL
-Testing: ['single quote']
-AS OBJECT
-NULL
-AS ARRAY
-NULL
diff --git a/ext/json/tests/pass001.1.phpt b/ext/json/tests/pass001.1.phpt
deleted file mode 100644
index 0cb05308da..0000000000
--- a/ext/json/tests/pass001.1.phpt
+++ /dev/null
@@ -1,895 +0,0 @@
---TEST--
-JSON Test Pattern pass1.1
-Modified to test unescaped UNICODE as keys and values.
-Modified to test numbers with exponents without a decimal point.
-Modified to test empty string values.
-Modified to test a mix of integers and strings as keys.
-http://www.crockford.com/JSON/JSON_checker/test/pass1.json
---SKIPIF--
-<?php
- if (!extension_loaded('json')) die('skip: json extension not available');
-?>
---FILE--
-<?php
-// Expect warnings about INF.
-ini_set("error_reporting", E_ALL & ~E_WARNING);
-
-$test = "
-[
- \"JSON Test Pattern pass1\",
- {\"object with 1 member\":[\"array with 1 element\"]},
- {},
- [],
- -42,
- true,
- false,
- null,
- {
- \"integer\": 1234567890,
- \"real\": -9876.543210,
- \"e\": 0.123456789e-12,
- \"E\": 1.234567890E+34,
- \"\": 23456789012E666,
- \"E no .\": 4E12,
- \"zero\": 0,
- \"one\": 1,
- \"space\": \" \",
- \"quote\": \"\\\"\",
- \"backslash\": \"\\\\\",
- \"controls\": \"\\b\\f\\n\\r\\t\",
- \"slash\": \"/ & \\/\",
- \"alpha\": \"abcdefghijklmnopqrstuvwyz\",
- \"ALPHA\": \"ABCDEFGHIJKLMNOPQRSTUVWYZ\",
- \"digit\": \"0123456789\",
- \"special\": \"`1~!@#$%^&*()_+-={':[,]}|;.</>?\",
- \"hex\": \"\\u0123\\u4567\\u89AB\\uCDEF\\uabcd\\uef4A\",
- \"unicode\": \"\\u30d7\\u30ec\\u30b9\\u30ad\\u30c3\\u30c8\",
- \"プレスキット\": \"プレスキット\",
- \"empty_string\": \"\",
- \"true\": true,
- \"false\": false,
- \"null\": null,
- \"array\":[ ],
- \"object\":{ },
- \"123\":{\"456\":{\"abc\":{\"789\":\"def\",\"012\":[1,2,\"5\",500],\"ghi\":[1,2,\"five\",50,\"sixty\"]}}},
- \"address\": \"50 St. James Street\",
- \"url\": \"http://www.JSON.org/\",
- \"comment\": \"// /* <!-- --\",
- \"# -- --> */\": \" \",
- \" s p a c e d \" :[1,2 , 3
-
-,
-
-4 , 5 , 6 ,7 ],
- \"compact\": [1,2,3,4,5,6,7],
- \"jsontext\": \"{\\\"object with 1 member\\\":[\\\"array with 1 element\\\"]}\",
- \"quotes\": \"&#34; \\u0022 %22 0x22 034 &#x22;\",
- \"\\/\\\\\\\"\\uCAFE\\uBABE\\uAB98\\uFCDE\\ubcda\\uef4A\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?\"
-: \"A key can be any string\"
- },
- 0.5 ,98.6
-,
-99.44
-,
-
-1066
-
-
-,\"rosebud\"]
-";
-
-echo 'Testing: ' . $test . "\n";
-echo "DECODE: AS OBJECT\n";
-$obj = json_decode($test);
-var_dump($obj);
-echo "DECODE: AS ARRAY\n";
-$arr = json_decode($test, true);
-var_dump($arr);
-
-echo "ENCODE: FROM OBJECT\n";
-$obj_enc = json_encode($obj);
-echo $obj_enc . "\n";
-echo "ENCODE: FROM ARRAY\n";
-$arr_enc = json_encode($arr);
-echo $arr_enc . "\n";
-
-echo "DECODE AGAIN: AS OBJECT\n";
-$obj = json_decode($obj_enc);
-var_dump($obj);
-echo "DECODE AGAIN: AS ARRAY\n";
-$arr = json_decode($arr_enc, true);
-var_dump($arr);
-
-?>
---EXPECT--
-Testing:
-[
- "JSON Test Pattern pass1",
- {"object with 1 member":["array with 1 element"]},
- {},
- [],
- -42,
- true,
- false,
- null,
- {
- "integer": 1234567890,
- "real": -9876.543210,
- "e": 0.123456789e-12,
- "E": 1.234567890E+34,
- "": 23456789012E666,
- "E no .": 4E12,
- "zero": 0,
- "one": 1,
- "space": " ",
- "quote": "\"",
- "backslash": "\\",
- "controls": "\b\f\n\r\t",
- "slash": "/ & \/",
- "alpha": "abcdefghijklmnopqrstuvwyz",
- "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
- "digit": "0123456789",
- "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
- "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
- "unicode": "\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8",
- "プレスキット": "プレスキット",
- "empty_string": "",
- "true": true,
- "false": false,
- "null": null,
- "array":[ ],
- "object":{ },
- "123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},
- "address": "50 St. James Street",
- "url": "http://www.JSON.org/",
- "comment": "// /* <!-- --",
- "# -- --> */": " ",
- " s p a c e d " :[1,2 , 3
-
-,
-
-4 , 5 , 6 ,7 ],
- "compact": [1,2,3,4,5,6,7],
- "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
- "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
- "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
-: "A key can be any string"
- },
- 0.5 ,98.6
-,
-99.44
-,
-
-1066
-
-
-,"rosebud"]
-
-DECODE: AS OBJECT
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- object(stdClass)#1 (1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- object(stdClass)#2 (0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- object(stdClass)#3 (36) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- float(INF)
- ["E no ."]=>
- float(4.0E+12)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["unicode"]=>
- string(18) "プレスキット"
- ["プレスキット"]=>
- string(18) "プレスキット"
- ["empty_string"]=>
- string(0) ""
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- object(stdClass)#4 (0) {
- }
- ["123"]=>
- object(stdClass)#5 (1) {
- ["456"]=>
- object(stdClass)#6 (1) {
- ["abc"]=>
- object(stdClass)#7 (3) {
- ["789"]=>
- string(3) "def"
- ["012"]=>
- array(4) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(1) "5"
- [3]=>
- int(500)
- }
- ["ghi"]=>
- array(5) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(4) "five"
- [3]=>
- int(50)
- [4]=>
- string(5) "sixty"
- }
- }
- }
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
-DECODE: AS ARRAY
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- array(1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- array(0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- array(36) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- float(INF)
- ["E no ."]=>
- float(4.0E+12)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["unicode"]=>
- string(18) "プレスキット"
- ["プレスキット"]=>
- string(18) "プレスキット"
- ["empty_string"]=>
- string(0) ""
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- array(0) {
- }
- [123]=>
- array(1) {
- [456]=>
- array(1) {
- ["abc"]=>
- array(3) {
- [789]=>
- string(3) "def"
- ["012"]=>
- array(4) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(1) "5"
- [3]=>
- int(500)
- }
- ["ghi"]=>
- array(5) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(4) "five"
- [3]=>
- int(50)
- [4]=>
- string(5) "sixty"
- }
- }
- }
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
-ENCODE: FROM OBJECT
-["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"E no .":4.0e+12,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":{},"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
-ENCODE: FROM ARRAY
-["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"E no .":4.0e+12,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":[],"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
-DECODE AGAIN: AS OBJECT
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- object(stdClass)#8 (1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- object(stdClass)#9 (0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- object(stdClass)#10 (36) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- int(0)
- ["E no ."]=>
- float(4.0E+12)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["unicode"]=>
- string(18) "プレスキット"
- ["プレスキット"]=>
- string(18) "プレスキット"
- ["empty_string"]=>
- string(0) ""
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- object(stdClass)#11 (0) {
- }
- ["123"]=>
- object(stdClass)#12 (1) {
- ["456"]=>
- object(stdClass)#13 (1) {
- ["abc"]=>
- object(stdClass)#14 (3) {
- ["789"]=>
- string(3) "def"
- ["012"]=>
- array(4) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(1) "5"
- [3]=>
- int(500)
- }
- ["ghi"]=>
- array(5) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(4) "five"
- [3]=>
- int(50)
- [4]=>
- string(5) "sixty"
- }
- }
- }
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
-DECODE AGAIN: AS ARRAY
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- array(1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- array(0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- array(36) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- int(0)
- ["E no ."]=>
- float(4.0E+12)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["unicode"]=>
- string(18) "プレスキット"
- ["プレスキット"]=>
- string(18) "プレスキット"
- ["empty_string"]=>
- string(0) ""
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- array(0) {
- }
- [123]=>
- array(1) {
- [456]=>
- array(1) {
- ["abc"]=>
- array(3) {
- [789]=>
- string(3) "def"
- ["012"]=>
- array(4) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(1) "5"
- [3]=>
- int(500)
- }
- ["ghi"]=>
- array(5) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- string(4) "five"
- [3]=>
- int(50)
- [4]=>
- string(5) "sixty"
- }
- }
- }
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
diff --git a/ext/json/tests/pass001.phpt b/ext/json/tests/pass001.phpt
deleted file mode 100644
index aff970b107..0000000000
--- a/ext/json/tests/pass001.phpt
+++ /dev/null
@@ -1,709 +0,0 @@
---TEST--
-JSON Test Pattern pass1
-http://www.crockford.com/JSON/JSON_checker/test/pass1.json
---SKIPIF--
-<?php
- if (!extension_loaded('json')) die('skip: json extension not available');
-?>
---FILE--
-<?php
-// Expect warnings about INF.
-ini_set("error_reporting", E_ALL & ~E_WARNING);
-
-$test = "
-[
- \"JSON Test Pattern pass1\",
- {\"object with 1 member\":[\"array with 1 element\"]},
- {},
- [],
- -42,
- true,
- false,
- null,
- {
- \"integer\": 1234567890,
- \"real\": -9876.543210,
- \"e\": 0.123456789e-12,
- \"E\": 1.234567890E+34,
- \"\": 23456789012E666,
- \"zero\": 0,
- \"one\": 1,
- \"space\": \" \",
- \"quote\": \"\\\"\",
- \"backslash\": \"\\\\\",
- \"controls\": \"\\b\\f\\n\\r\\t\",
- \"slash\": \"/ & \\/\",
- \"alpha\": \"abcdefghijklmnopqrstuvwyz\",
- \"ALPHA\": \"ABCDEFGHIJKLMNOPQRSTUVWYZ\",
- \"digit\": \"0123456789\",
- \"special\": \"`1~!@#$%^&*()_+-={':[,]}|;.</>?\",
- \"hex\": \"\\u0123\\u4567\\u89AB\\uCDEF\\uabcd\\uef4A\",
- \"true\": true,
- \"false\": false,
- \"null\": null,
- \"array\":[ ],
- \"object\":{ },
- \"address\": \"50 St. James Street\",
- \"url\": \"http://www.JSON.org/\",
- \"comment\": \"// /* <!-- --\",
- \"# -- --> */\": \" \",
- \" s p a c e d \" :[1,2 , 3
-
-,
-
-4 , 5 , 6 ,7 ],
- \"compact\": [1,2,3,4,5,6,7],
- \"jsontext\": \"{\\\"object with 1 member\\\":[\\\"array with 1 element\\\"]}\",
- \"quotes\": \"&#34; \\u0022 %22 0x22 034 &#x22;\",
- \"\\/\\\\\\\"\\uCAFE\\uBABE\\uAB98\\uFCDE\\ubcda\\uef4A\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?\"
-: \"A key can be any string\"
- },
- 0.5 ,98.6
-,
-99.44
-,
-
-1066
-
-
-,\"rosebud\"]
-";
-
-echo 'Testing: ' . $test . "\n";
-echo "DECODE: AS OBJECT\n";
-$obj = json_decode($test);
-var_dump($obj);
-echo "DECODE: AS ARRAY\n";
-$arr = json_decode($test, true);
-var_dump($arr);
-
-echo "ENCODE: FROM OBJECT\n";
-$obj_enc = json_encode($obj);
-echo $obj_enc . "\n";
-echo "ENCODE: FROM ARRAY\n";
-$arr_enc = json_encode($arr);
-echo $arr_enc . "\n";
-
-echo "DECODE AGAIN: AS OBJECT\n";
-$obj = json_decode($obj_enc);
-var_dump($obj);
-echo "DECODE AGAIN: AS ARRAY\n";
-$arr = json_decode($arr_enc, true);
-var_dump($arr);
-
-?>
---EXPECT--
-Testing:
-[
- "JSON Test Pattern pass1",
- {"object with 1 member":["array with 1 element"]},
- {},
- [],
- -42,
- true,
- false,
- null,
- {
- "integer": 1234567890,
- "real": -9876.543210,
- "e": 0.123456789e-12,
- "E": 1.234567890E+34,
- "": 23456789012E666,
- "zero": 0,
- "one": 1,
- "space": " ",
- "quote": "\"",
- "backslash": "\\",
- "controls": "\b\f\n\r\t",
- "slash": "/ & \/",
- "alpha": "abcdefghijklmnopqrstuvwyz",
- "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
- "digit": "0123456789",
- "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
- "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
- "true": true,
- "false": false,
- "null": null,
- "array":[ ],
- "object":{ },
- "address": "50 St. James Street",
- "url": "http://www.JSON.org/",
- "comment": "// /* <!-- --",
- "# -- --> */": " ",
- " s p a c e d " :[1,2 , 3
-
-,
-
-4 , 5 , 6 ,7 ],
- "compact": [1,2,3,4,5,6,7],
- "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
- "quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
- "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
-: "A key can be any string"
- },
- 0.5 ,98.6
-,
-99.44
-,
-
-1066
-
-
-,"rosebud"]
-
-DECODE: AS OBJECT
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- object(stdClass)#1 (1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- object(stdClass)#2 (0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- object(stdClass)#3 (31) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- float(INF)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- object(stdClass)#4 (0) {
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
-DECODE: AS ARRAY
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- array(1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- array(0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- array(31) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- float(INF)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- array(0) {
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
-ENCODE: FROM OBJECT
-["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":{},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
-ENCODE: FROM ARRAY
-["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":[],"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
-DECODE AGAIN: AS OBJECT
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- object(stdClass)#5 (1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- object(stdClass)#6 (0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- object(stdClass)#7 (31) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- int(0)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- object(stdClass)#8 (0) {
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
-DECODE AGAIN: AS ARRAY
-array(14) {
- [0]=>
- string(23) "JSON Test Pattern pass1"
- [1]=>
- array(1) {
- ["object with 1 member"]=>
- array(1) {
- [0]=>
- string(20) "array with 1 element"
- }
- }
- [2]=>
- array(0) {
- }
- [3]=>
- array(0) {
- }
- [4]=>
- int(-42)
- [5]=>
- bool(true)
- [6]=>
- bool(false)
- [7]=>
- NULL
- [8]=>
- array(31) {
- ["integer"]=>
- int(1234567890)
- ["real"]=>
- float(-9876.54321)
- ["e"]=>
- float(1.23456789E-13)
- ["E"]=>
- float(1.23456789E+34)
- ["_empty_"]=>
- int(0)
- ["zero"]=>
- int(0)
- ["one"]=>
- int(1)
- ["space"]=>
- string(1) " "
- ["quote"]=>
- string(1) """
- ["backslash"]=>
- string(1) "\"
- ["controls"]=>
- string(5) "
-
- "
- ["slash"]=>
- string(5) "/ & /"
- ["alpha"]=>
- string(25) "abcdefghijklmnopqrstuvwyz"
- ["ALPHA"]=>
- string(25) "ABCDEFGHIJKLMNOPQRSTUVWYZ"
- ["digit"]=>
- string(10) "0123456789"
- ["special"]=>
- string(31) "`1~!@#$%^&*()_+-={':[,]}|;.</>?"
- ["hex"]=>
- string(17) "ģ䕧覫췯ꯍ"
- ["true"]=>
- bool(true)
- ["false"]=>
- bool(false)
- ["null"]=>
- NULL
- ["array"]=>
- array(0) {
- }
- ["object"]=>
- array(0) {
- }
- ["address"]=>
- string(19) "50 St. James Street"
- ["url"]=>
- string(20) "http://www.JSON.org/"
- ["comment"]=>
- string(13) "// /* <!-- --"
- ["# -- --> */"]=>
- string(1) " "
- [" s p a c e d "]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["compact"]=>
- array(7) {
- [0]=>
- int(1)
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- [4]=>
- int(5)
- [5]=>
- int(6)
- [6]=>
- int(7)
- }
- ["jsontext"]=>
- string(49) "{"object with 1 member":["array with 1 element"]}"
- ["quotes"]=>
- string(27) "&#34; " %22 0x22 034 &#x22;"
- ["/\"쫾몾ꮘﳞ볚
-
- `1~!@#$%^&*()_+-=[]{}|;:',./<>?"]=>
- string(23) "A key can be any string"
- }
- [9]=>
- float(0.5)
- [10]=>
- float(98.6)
- [11]=>
- float(99.44)
- [12]=>
- int(1066)
- [13]=>
- string(7) "rosebud"
-}
diff --git a/ext/json/tests/pass002.phpt b/ext/json/tests/pass002.phpt
deleted file mode 100644
index a0e527ac4f..0000000000
--- a/ext/json/tests/pass002.phpt
+++ /dev/null
@@ -1,276 +0,0 @@
---TEST--
-JSON Test Pattern pass2
-http://www.crockford.com/JSON/JSON_checker/test/pass2.json
---SKIPIF--
-<?php
- if (!extension_loaded('json')) die('skip: json extension not available');
-?>
---FILE--
-<?php
-
-$test = '[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]';
-echo 'Testing: ' . $test . "\n";
-echo "DECODE: AS OBJECT\n";
-$obj = json_decode($test);
-var_dump($obj);
-echo "DECODE: AS ARRAY\n";
-$arr = json_decode($test, true);
-var_dump($arr);
-
-echo "ENCODE: FROM OBJECT\n";
-$obj_enc = json_encode($obj);
-echo $obj_enc . "\n";
-echo "ENCODE: FROM ARRAY\n";
-$arr_enc = json_encode($arr);
-echo $arr_enc . "\n";
-
-echo "DECODE AGAIN: AS OBJECT\n";
-$obj = json_decode($obj_enc);
-var_dump($obj);
-echo "DECODE AGAIN: AS ARRAY\n";
-$arr = json_decode($arr_enc, true);
-var_dump($arr);
-
-?>
---EXPECT--
-Testing: [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
-DECODE: AS OBJECT
-array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- string(12) "Not too deep"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-DECODE: AS ARRAY
-array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- string(12) "Not too deep"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-ENCODE: FROM OBJECT
-[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
-ENCODE: FROM ARRAY
-[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
-DECODE AGAIN: AS OBJECT
-array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- string(12) "Not too deep"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-DECODE AGAIN: AS ARRAY
-array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- array(1) {
- [0]=>
- string(12) "Not too deep"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
diff --git a/ext/json/tests/pass003.phpt b/ext/json/tests/pass003.phpt
deleted file mode 100644
index 506ff05b3e..0000000000
--- a/ext/json/tests/pass003.phpt
+++ /dev/null
@@ -1,95 +0,0 @@
---TEST--
-JSON Test Pattern pass3
-http://www.crockford.com/JSON/JSON_checker/test/pass3.json
---SKIPIF--
-<?php
- if (!extension_loaded('json')) die('skip: json extension not available');
-?>
---FILE--
-<?php
-
-$test = '
-{
- "JSON Test Pattern pass3": {
- "The outermost value": "must be an object or array.",
- "In this test": "It is an object."
- }
-}
-';
-
-echo 'Testing: ' . $test . "\n";
-echo "DECODE: AS OBJECT\n";
-$obj = json_decode($test);
-var_dump($obj);
-echo "DECODE: AS ARRAY\n";
-$arr = json_decode($test, true);
-var_dump($arr);
-
-echo "ENCODE: FROM OBJECT\n";
-$obj_enc = json_encode($obj);
-echo $obj_enc . "\n";
-echo "ENCODE: FROM ARRAY\n";
-$arr_enc = json_encode($arr);
-echo $arr_enc . "\n";
-
-echo "DECODE AGAIN: AS OBJECT\n";
-$obj = json_decode($obj_enc);
-var_dump($obj);
-echo "DECODE AGAIN: AS ARRAY\n";
-$arr = json_decode($arr_enc, true);
-var_dump($arr);
-
-?>
---EXPECT--
-Testing:
-{
- "JSON Test Pattern pass3": {
- "The outermost value": "must be an object or array.",
- "In this test": "It is an object."
- }
-}
-
-DECODE: AS OBJECT
-object(stdClass)#1 (1) {
- ["JSON Test Pattern pass3"]=>
- object(stdClass)#2 (2) {
- ["The outermost value"]=>
- string(27) "must be an object or array."
- ["In this test"]=>
- string(16) "It is an object."
- }
-}
-DECODE: AS ARRAY
-array(1) {
- ["JSON Test Pattern pass3"]=>
- array(2) {
- ["The outermost value"]=>
- string(27) "must be an object or array."
- ["In this test"]=>
- string(16) "It is an object."
- }
-}
-ENCODE: FROM OBJECT
-{"JSON Test Pattern pass3":{"The outermost value":"must be an object or array.","In this test":"It is an object."}}
-ENCODE: FROM ARRAY
-{"JSON Test Pattern pass3":{"The outermost value":"must be an object or array.","In this test":"It is an object."}}
-DECODE AGAIN: AS OBJECT
-object(stdClass)#3 (1) {
- ["JSON Test Pattern pass3"]=>
- object(stdClass)#4 (2) {
- ["The outermost value"]=>
- string(27) "must be an object or array."
- ["In this test"]=>
- string(16) "It is an object."
- }
-}
-DECODE AGAIN: AS ARRAY
-array(1) {
- ["JSON Test Pattern pass3"]=>
- array(2) {
- ["The outermost value"]=>
- string(27) "must be an object or array."
- ["In this test"]=>
- string(16) "It is an object."
- }
-}
diff --git a/ext/json/utf8_decode.c b/ext/json/utf8_decode.c
deleted file mode 100644
index cea1f8cec8..0000000000
--- a/ext/json/utf8_decode.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* utf8_decode.c */
-
-/* 2005-12-25 */
-
-/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-#include "utf8_decode.h"
-
-/*
- Very Strict UTF-8 Decoder
-
- UTF-8 is a multibyte character encoding of Unicode. A character can be
- represented by 1-4 bytes. The bit pattern of the first byte indicates the
- number of continuation bytes.
-
- Most UTF-8 decoders tend to be lenient, attempting to recover as much
- information as possible, even from badly encoded input. This UTF-8
- decoder is not lenient. It will reject input which does not include
- proper continuation bytes. It will reject aliases (or suboptimal
- codings). It will reject surrogates. (Surrogate encoding should only be
- used with UTF-16.)
-
- Code Contination Minimum Maximum
- 0xxxxxxx 0 0 127
- 10xxxxxx error
- 110xxxxx 1 128 2047
- 1110xxxx 2 2048 65535 excluding 55296 - 57343
- 11110xxx 3 65536 1114111
- 11111xxx error
-*/
-
-
-/*
- Get the next byte. It returns UTF8_END if there are no more bytes.
-*/
-static int
-get(json_utf8_decode *utf8)
-{
- int c;
- if (utf8->the_index >= utf8->the_length) {
- return UTF8_END;
- }
- c = utf8->the_input[utf8->the_index] & 0xFF;
- utf8->the_index += 1;
- return c;
-}
-
-
-/*
- Get the 6-bit payload of the next continuation byte.
- Return UTF8_ERROR if it is not a contination byte.
-*/
-static int
-cont(json_utf8_decode *utf8)
-{
- int c = get(utf8);
- return ((c & 0xC0) == 0x80) ? (c & 0x3F) : UTF8_ERROR;
-}
-
-
-/*
- Initialize the UTF-8 decoder. The decoder is not reentrant,
-*/
-void
-utf8_decode_init(json_utf8_decode *utf8, char p[], int length)
-{
- utf8->the_index = 0;
- utf8->the_input = p;
- utf8->the_length = length;
- utf8->the_char = 0;
- utf8->the_byte = 0;
-}
-
-
-/*
- Get the current byte offset. This is generally used in error reporting.
-*/
-int
-utf8_decode_at_byte(json_utf8_decode *utf8)
-{
- return utf8->the_byte;
-}
-
-
-/*
- Get the current character offset. This is generally used in error reporting.
- The character offset matches the byte offset if the text is strictly ASCII.
-*/
-int
-utf8_decode_at_character(json_utf8_decode *utf8)
-{
- return utf8->the_char > 0 ? utf8->the_char - 1 : 0;
-}
-
-
-/*
- Extract the next character.
- Returns: the character (between 0 and 1114111)
- or UTF8_END (the end)
- or UTF8_ERROR (error)
-*/
-int
-utf8_decode_next(json_utf8_decode *utf8)
-{
- int c; /* the first byte of the character */
- int r; /* the result */
-
- if (utf8->the_index >= utf8->the_length) {
- return utf8->the_index == utf8->the_length ? UTF8_END : UTF8_ERROR;
- }
- utf8->the_byte = utf8->the_index;
- utf8->the_char += 1;
- c = get(utf8);
-/*
- Zero continuation (0 to 127)
-*/
- if ((c & 0x80) == 0) {
- return c;
- }
-/*
- One contination (128 to 2047)
-*/
- if ((c & 0xE0) == 0xC0) {
- int c1 = cont(utf8);
- if (c1 < 0) {
- return UTF8_ERROR;
- }
- r = ((c & 0x1F) << 6) | c1;
- return r >= 128 ? r : UTF8_ERROR;
- }
-/*
- Two continuation (2048 to 55295 and 57344 to 65535)
-*/
- if ((c & 0xF0) == 0xE0) {
- int c1 = cont(utf8);
- int c2 = cont(utf8);
- if (c1 < 0 || c2 < 0) {
- return UTF8_ERROR;
- }
- r = ((c & 0x0F) << 12) | (c1 << 6) | c2;
- return r >= 2048 && (r < 55296 || r > 57343) ? r : UTF8_ERROR;
- }
-/*
- Three continuation (65536 to 1114111)
-*/
- if ((c & 0xF1) == 0xF0) {
- int c1 = cont(utf8);
- int c2 = cont(utf8);
- int c3 = cont(utf8);
- if (c1 < 0 || c2 < 0 || c3 < 0) {
- return UTF8_ERROR;
- }
- r = ((c & 0x0F) << 18) | (c1 << 12) | (c2 << 6) | c3;
- return r >= 65536 && r <= 1114111 ? r : UTF8_ERROR;
- }
- return UTF8_ERROR;
-}
diff --git a/ext/json/utf8_decode.h b/ext/json/utf8_decode.h
deleted file mode 100644
index cc0fc79f6c..0000000000
--- a/ext/json/utf8_decode.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* utf8_decode.h */
-
-#define UTF8_END -1
-#define UTF8_ERROR -2
-
-typedef struct json_utf8_decode
-{
- int the_index;
- char *the_input;
- int the_length;
- int the_char;
- int the_byte;
-} json_utf8_decode;
-
-extern int utf8_decode_at_byte(json_utf8_decode *utf8);
-extern int utf8_decode_at_character(json_utf8_decode *utf8);
-extern void utf8_decode_init(json_utf8_decode *utf8, char p[], int length);
-extern int utf8_decode_next(json_utf8_decode *utf8);
diff --git a/ext/json/utf8_to_utf16.c b/ext/json/utf8_to_utf16.c
deleted file mode 100644
index bc2d6f36d6..0000000000
--- a/ext/json/utf8_to_utf16.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* utf8_to_utf16.c */
-
-/* 2005-12-25 */
-
-/*
-Copyright (c) 2005 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-#include "utf8_to_utf16.h"
-#include "utf8_decode.h"
-
-int
-utf8_to_utf16(unsigned short w[], char p[], int length)
-{
- int c;
- int the_index = 0;
- json_utf8_decode utf8;
-
- utf8_decode_init(&utf8, p, length);
- for (;;) {
- c = utf8_decode_next(&utf8);
- if (c < 0) {
- return UTF8_END ? the_index : UTF8_ERROR;
- }
- if (c < 0x10000) {
- w[the_index] = (unsigned short)c;
- the_index += 1;
- } else {
- c &= 0xFFFF;
- w[the_index] = (unsigned short)(0xD800 | (c >> 10));
- the_index += 1;
- w[the_index] = (unsigned short)(0xDC00 | (c & 0x3FF));
- the_index += 1;
- }
- }
-}
diff --git a/ext/json/utf8_to_utf16.h b/ext/json/utf8_to_utf16.h
deleted file mode 100644
index 5aff0268bf..0000000000
--- a/ext/json/utf8_to_utf16.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* utf8_to_utf16.h */
-
-extern int utf8_to_utf16(unsigned short w[], char p[], int length);
diff --git a/ext/phar/CREDITS b/ext/phar/CREDITS
deleted file mode 100644
index d5936bee7d..0000000000
--- a/ext/phar/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-phar
-Gregory Beaver, Marcus Boerger
diff --git a/ext/phar/EXPERIMENTAL b/ext/phar/EXPERIMENTAL
deleted file mode 100644
index 3bab0b126c..0000000000
--- a/ext/phar/EXPERIMENTAL
+++ /dev/null
@@ -1,7 +0,0 @@
-TODO:
-
-bugs:
-no known bugs
-
-features:
-- stream context option for cleaning crap paths like phar://blah.phar/file//to\\here.php
diff --git a/ext/phar/LICENSE b/ext/phar/LICENSE
deleted file mode 100644
index 3e48203d54..0000000000
--- a/ext/phar/LICENSE
+++ /dev/null
@@ -1,68 +0,0 @@
---------------------------------------------------------------------
- The PHP License, version 3.01
-Copyright (c) 1999 - 2005 The PHP Group. All rights reserved.
---------------------------------------------------------------------
-
-Redistribution and use in source and binary forms, with or without
-modification, is permitted provided that the following conditions
-are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- 3. The name "PHP" must not be used to endorse or promote products
- derived from this software without prior written permission. For
- written permission, please contact group@php.net.
-
- 4. Products derived from this software may not be called "PHP", nor
- may "PHP" appear in their name, without prior written permission
- from group@php.net. You may indicate that your software works in
- conjunction with PHP by saying "Foo for PHP" instead of calling
- it "PHP Foo" or "phpfoo"
-
- 5. The PHP Group may publish revised and/or new versions of the
- license from time to time. Each version will be given a
- distinguishing version number.
- Once covered code has been published under a particular version
- of the license, you may always continue to use it under the terms
- of that version. You may also choose to use such covered code
- under the terms of any subsequent version of the license
- published by the PHP Group. No one other than the PHP Group has
- the right to modify the terms applicable to covered code created
- under this License.
-
- 6. Redistributions of any form whatsoever must retain the following
- acknowledgment:
- "This product includes PHP software, freely available from
- <http://www.php.net/software/>".
-
-THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
-ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
-DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-
---------------------------------------------------------------------
-
-This software consists of voluntary contributions made by many
-individuals on behalf of the PHP Group.
-
-The PHP Group can be contacted via Email at group@php.net.
-
-For more information on the PHP Group and the PHP project,
-please see <http://www.php.net>.
-
-PHP includes the Zend Engine, freely available at
-<http://www.zend.com>.
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
deleted file mode 100644
index b1c9985c2e..0000000000
--- a/ext/phar/config.m4
+++ /dev/null
@@ -1,12 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension phar
-
-PHP_ARG_ENABLE(phar, for phar support/phar zlib support,
-[ --enable-phar Enable phar support, use --with-zlib-dir if zlib detection fails])
-
-if test "$PHP_PHAR" != "no"; then
- PHP_NEW_EXTENSION(phar, phar.c, $ext_shared)
- PHP_ADD_EXTENSION_DEP(phar, zlib, true)
- PHP_ADD_EXTENSION_DEP(phar, bz2, true)
- PHP_ADD_EXTENSION_DEP(phar, spl, false)
-fi
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
deleted file mode 100644
index 694de2e7f4..0000000000
--- a/ext/phar/config.w32
+++ /dev/null
@@ -1,11 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_ENABLE("phar", "enable phar support", "no");
-
-if (PHP_PHAR != "no") {
- EXTENSION("phar", "phar.c");
- ADD_EXTENSION_DEP('phar', 'zlib', true);
- ADD_EXTENSION_DEP('phar', 'bz2', true);
- ADD_EXTENSION_DEP('phar', 'spl', false);
-}
diff --git a/ext/phar/package.xml b/ext/phar/package.xml
deleted file mode 100644
index b31d319fd0..0000000000
--- a/ext/phar/package.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
- <name>phar</name>
- <channel>pecl.php.net</channel>
- <summary>allows running of complete applications out of .phar files (like Java .jar files)</summary>
- <description>
-This is the extension version of PEAR's PHP_Archive package. Support for zlib and crc32 is achieved without any dependency other than the external libz. The zlib extension need not be enabled to take advantage of compressed .phar files.
-
-.phar files should be created using pear.php.net/PHP_Archive
- </description>
- <lead>
- <name>Greg Beaver</name>
- <user>cellog</user>
- <email>cellog@php.net</email>
- <active>yes</active>
- </lead>
- <lead>
- <name>Marcus Boerger</name>
- <user>helly</user>
- <email>helly@php.net</email>
- <active>yes</active>
- </lead>
- <date>2006-01-01</date>
- <version>
- <release>0.1.0</release>
- <api>0.7.1</api>
- </version>
- <stability>
- <release>alpha</release>
- <api>alpha</api>
- </stability>
- <license uri="http://www.php.net/license">PHP License</license>
- <notes>
- Initial release. This release is fully regression-tested
-
- This extension is only compatible with phar archives compliant with PHP_Archive
- 0.8.0 (api Version 0.7.1)
- </notes>
- <contents>
- <dir name="/">
- <dir name="tests">
- <file name="001.phpt" role="test"/>
- <file name="002.phpt" role="test"/>
- <file name="003.phpt" role="test"/>
- <file name="004.phpt" role="test"/>
- <file name="005.phpt" role="test"/>
- <file name="006.phpt" role="test"/>
- <file name="007.phpt" role="test"/>
- <file name="008.phpt" role="test"/>
- <file name="009.phpt" role="test"/>
- <file name="010.phpt" role="test"/>
- <file name="011.phpt" role="test"/>
- <file name="012.phpt" role="test"/>
- <file name="013.phpt" role="test"/>
- <file name="014.phpt" role="test"/>
- <file name="015.phpt" role="test"/>
- <file name="016.phpt" role="test"/>
- <file name="017.phpt" role="test"/>
- <file name="018.phpt" role="test"/>
- <file name="019.phpt" role="test"/>
- <file name="020.phpt" role="test"/>
- <file name="021.phpt" role="test"/>
- <file name="022.phpt" role="test"/>
- </dir> <!-- /tests -->
- <file name="config.m4" role="src"/>
- <file name="config.w32" role="src"/>
- <file name="CREDITS" role="doc"/>
- <file name="EXPERIMENTAL" role="src"/>
- <file name="phar.c" role="src"/>
- <file name="php_phar.h" role="src"/>
- </dir> <!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>5.1.2</min>
- </php>
- <pearinstaller>
- <min>1.4.3</min>
- </pearinstaller>
- </required>
- </dependencies>
- <providesextension>phar</providesextension>
- <extsrcrelease/>
-</package> \ No newline at end of file
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
deleted file mode 100644
index 3f63e139e4..0000000000
--- a/ext/phar/phar.c
+++ /dev/null
@@ -1,1922 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2005-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Gregory Beaver <cellog@php.net> |
- | Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <time.h>
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "ext/standard/url.h"
-#include "ext/standard/crc32.h"
-#include "ext/spl/spl_array.h"
-#include "ext/spl/spl_directory.h"
-#include "ext/spl/spl_engine.h"
-#include "ext/spl/spl_exceptions.h"
-#include "zend_constants.h"
-#include "zend_execute.h"
-#include "zend_exceptions.h"
-#include "zend_hash.h"
-#include "zend_interfaces.h"
-#include "zend_operators.h"
-#include "zend_qsort.h"
-#include "php_phar.h"
-#include "main/php_streams.h"
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
-#ifndef TRUE
- # define TRUE 1
- # define FALSE 0
-#endif
-
-#ifndef E_RECOVERABLE_ERROR
-#define E_RECOVERABLE_ERROR E_ERROR
-#endif
-
-#define PHAR_VERSION_STR "0.8.0"
-/* x.y.z maps to 0xyz0 */
-#define PHAR_API_VERSION 0x0800
-#define PHAR_API_MAJORVERSION 0x0000
-#define PHAR_API_MAJORVER_MASK 0xF000
-#define PHAR_API_VER_MASK 0xFFF0
-
-#define PHAR_HDR_ANY_COMPRESSED 0x0001
-#define PHAR_HDR_SIGNATURE 0x0008
-
-/* flags byte for each file adheres to these bitmasks.
- All unused values are reserved */
-#define PHAR_ENT_COMPRESSION_MASK 0x0F
-#define PHAR_ENT_COMPRESSED_NONE 0x00
-#define PHAR_ENT_COMPRESSED_GZ 0x01
-#define PHAR_ENT_COMPRESSED_BZ2 0x02
-
-
-ZEND_BEGIN_MODULE_GLOBALS(phar)
- HashTable phar_fname_map;
- HashTable phar_alias_map;
-ZEND_END_MODULE_GLOBALS(phar)
-
-ZEND_DECLARE_MODULE_GLOBALS(phar)
-
-#ifndef php_uint16
-# if SIZEOF_SHORT == 2
-# define php_uint16 unsigned short
-# else
-# define php_uint16 uint16_t
-# endif
-#endif
-
-typedef union _phar_archive_object phar_archive_object;
-typedef union _phar_entry_object phar_entry_object;
-
-/* entry for one file in a phar file */
-typedef struct _phar_manifest_entry {
- php_uint32 filename_len;
- char *filename;
- php_uint32 uncompressed_filesize;
- php_uint32 timestamp;
- long offset_within_phar;
- php_uint32 compressed_filesize;
- php_uint32 crc32;
- char flags;
- zend_bool crc_checked;
- php_stream *fp;
-} phar_entry_info;
-
-/* information about a phar file (the archive itself) */
-typedef struct _phar_archive_data {
- char *fname;
- int fname_len;
- char *alias;
- int alias_len;
- char version[12];
- size_t internal_file_start;
- zend_bool has_compressed_files;
- HashTable manifest;
- php_uint32 min_timestamp;
- php_uint32 max_timestamp;
- php_stream *fp;
- int refcount;
-} phar_archive_data;
-
-/* stream access data for one file entry in a phar file */
-typedef struct _phar_entry_data {
- phar_archive_data *phar;
- php_stream *fp;
- phar_entry_info *internal_file;
-} phar_entry_data;
-
-/* archive php object */
-union _phar_archive_object {
- zend_object std;
- spl_filesystem_object spl;
- struct {
- zend_object std;
- phar_archive_data *archive;
- } arc;
-};
-
-/* entry php object */
-union _phar_entry_object {
- zend_object std;
- spl_filesystem_object spl;
- struct {
- zend_object std;
- phar_entry_info *entry;
- } ent;
-};
-
-/* {{{ forward declarations */
-static php_stream *php_stream_phar_url_wrapper(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-static int phar_close(php_stream *stream, int close_handle TSRMLS_DC);
-static int phar_closedir(php_stream *stream, int close_handle TSRMLS_DC);
-static int phar_seekdir(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
-static size_t phar_read(php_stream *stream, char *buf, size_t count TSRMLS_DC);
-static size_t phar_readdir(php_stream *stream, char *buf, size_t count TSRMLS_DC);
-static int phar_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
-
-static size_t phar_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
-static int phar_flush(php_stream *stream TSRMLS_DC);
-static int phar_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
-
-static int phar_stream_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);
-static php_stream *phar_opendir(php_stream_wrapper *wrapper, char *filename, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-/* }}} */
-
-static zend_class_entry *phar_ce_archive;
-static zend_class_entry *phar_ce_entry;
-
-static void phar_destroy_phar_data(phar_archive_data *data TSRMLS_DC) /* {{{ */
-{
- if (data->alias && data->alias != data->fname) {
- efree(data->alias);
- data->alias = NULL;
- }
- efree(data->fname);
- zend_hash_destroy(&data->manifest);
- if (data->fp) {
- php_stream_close(data->fp);
- }
- data->fp = 0;
- efree(data);
-}
-/* }}}*/
-
-static void destroy_phar_data(void *pDest) /* {{{ */
-{
- phar_archive_data *phar_data = *(phar_archive_data **) pDest;
- TSRMLS_FETCH();
-
- if (--phar_data->refcount < 0) {
- phar_destroy_phar_data(phar_data TSRMLS_CC);
- }
-}
-/* }}}*/
-
-static void phar_spl_foreign_dtor(spl_filesystem_object *object TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *phar_data = (phar_archive_data *) object->oth;
-
- if (--phar_data->refcount < 0) {
- phar_destroy_phar_data(phar_data TSRMLS_CC);
- }
-}
-/* }}} */
-
-static void phar_spl_foreign_clone(spl_filesystem_object *src, spl_filesystem_object *dst TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *phar_data = (phar_archive_data *) dst->oth;
-
- phar_data->refcount++;
-}
-/* }}} */
-
-static spl_other_handler phar_spl_foreign_handler = {
- phar_spl_foreign_dtor,
- phar_spl_foreign_clone
-};
-
-static void destroy_phar_manifest(void *pDest) /* {{{ */
-{
- phar_entry_info *entry = (phar_entry_info *)pDest;
-
- if (entry->fp) {
- TSRMLS_FETCH();
-
- php_stream_close(entry->fp);
- }
- entry->fp = 0;
- efree(entry->filename);
-}
-/* }}} */
-
-static phar_archive_data * phar_get_archive(char *fname, int fname_len, char *alias, int alias_len TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *fd, **fd_ptr;
-
- if (alias && alias_len) {
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void**)&fd_ptr)) {
- if (fname && (fname_len != (*fd_ptr)->fname_len || strncmp(fname, (*fd_ptr)->fname, fname_len))) {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
- return NULL;
- }
- return *fd_ptr;
- }
- }
- if (fname && fname_len) {
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void**)&fd_ptr)) {
- fd = *fd_ptr;
- if (alias && alias_len) {
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&fd, sizeof(phar_archive_data*), NULL);
- }
- return fd;
- }
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), fname, fname_len, (void**)&fd_ptr)) {
- return *fd_ptr;
- }
- }
- return NULL;
-}
-/* }}} */
-
-static phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len TSRMLS_DC) /* {{{ */
-{
- phar_entry_info *entry;
-
- if (path && *path == '/') {
- path++;
- path_len--;
- }
- if (SUCCESS == zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) {
- return entry;
- }
- return NULL;
-}
-/* }}} */
-
-static phar_entry_data *phar_get_entry_data(char *fname, int fname_len, char *path, int path_len TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *phar;
- phar_entry_info *entry;
- phar_entry_data *ret;
-
- ret = NULL;
- if ((phar = phar_get_archive(fname, fname_len, NULL, 0 TSRMLS_CC)) != NULL) {
- if ((entry = phar_get_entry_info(phar, path, path_len TSRMLS_CC)) != NULL) {
- ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
- ret->phar = phar;
- ret->internal_file = entry;
- if (entry->fp) {
- /* transfer ownership */
- ret->fp = entry->fp;
- php_stream_seek(ret->fp, 0, SEEK_SET);
- entry->fp = 0;
- } else {
- ret->fp = 0;
- }
- }
- }
- return ret;
-}
-/* }}} */
-
-/* {{{ proto string apiVersion()
- * Returns the api version */
-PHP_METHOD(Phar, apiVersion)
-{
- RETURN_STRINGL(PHAR_VERSION_STR, sizeof(PHAR_VERSION_STR)-1, 1);
-}
-/* }}}*/
-
-/* {{{ proto bool canCompress()
- * Returns whether phar extension supports compression using zlib */
-PHP_METHOD(Phar, canCompress)
-{
-#if HAVE_ZLIB || HAVE_BZ2
- RETURN_TRUE;
-#else
- RETURN_FALSE;
-#endif
-}
-/* }}} */
-
-#define MAPPHAR_ALLOC_FAIL(msg) \
- php_stream_close(fp);\
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, msg, fname);\
- return FAILURE;
-
-#define MAPPHAR_FAIL(msg) \
- efree(savebuf);\
- MAPPHAR_ALLOC_FAIL(msg)
-
-#ifdef WORDS_BIGENDIAN
-# define PHAR_GET_32(buffer, var) \
- var = ((unsigned char)buffer[3]) << 24 \
- + ((unsigned char)buffer[2]) << 16 \
- + ((unsigned char)buffer[1]) << 8 \
- + ((unsigned char)buffer[0]); \
- buffer += 4
-#else
-# define PHAR_GET_32(buffer, var) \
- var = *(php_uint32*)(buffer); \
- buffer += 4
-#endif
-
-static int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar TSRMLS_DC) /* {{{ */
-{
- char b32[4], *buffer, *endbuffer, *savebuf;
- phar_archive_data *mydata;
- phar_entry_info entry;
- php_uint32 manifest_len, manifest_count, manifest_index, tmp_len;
- php_uint16 manifest_tag;
- long offset;
- int compressed = 0;
- int register_alias;
-
- if (pphar) {
- *pphar = NULL;
- }
-
- if ((mydata = phar_get_archive(fname, fname_len, alias, alias_len TSRMLS_CC)) != NULL) {
- /* Overloading or reloading an archive would only be possible if we */
- /* refcount everything to be sure no stream for any file in the */
- /* archive is open. */
- if (fname_len != mydata->fname_len || strncmp(fname, mydata->fname, fname_len)) {
- php_stream_close(fp);
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, mydata->fname, fname);
- return FAILURE;
- } else {
- if (pphar) {
- *pphar = mydata;
- }
- php_stream_close(fp);
- return SUCCESS;
- }
- }
-
- /* check for ?>\n and increment accordingly */
- if (-1 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
- MAPPHAR_ALLOC_FAIL("cannot seek to __HALT_COMPILER(); location in phar \"%s\"")
- }
-
- buffer = b32;
- if (3 != php_stream_read(fp, buffer, 3)) {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest)")
- }
- if (*buffer == ' ' && *(buffer + 1) == '?' && *(buffer + 2) == '>') {
- int nextchar;
- halt_offset += 3;
- if (EOF == (nextchar = php_stream_getc(fp))) {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest)")
- }
- if ((char) nextchar == '\r') {
- if (EOF == (nextchar = php_stream_getc(fp))) {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest)")
- }
- halt_offset++;
- }
- if ((char) nextchar == '\n') {
- halt_offset++;
- }
- }
- /* make sure we are at the right location to read the manifest */
- if (-1 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
- MAPPHAR_ALLOC_FAIL("cannot seek to __HALT_COMPILER(); location in phar \"%s\"")
- }
-
- /* read in manifest */
- buffer = b32;
- if (4 != php_stream_read(fp, buffer, 4)) {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest)")
- }
- PHAR_GET_32(buffer, manifest_len);
- if (manifest_len > 1048576) {
- /* prevent serious memory issues by limiting manifest to at most 1 MB in length */
- MAPPHAR_ALLOC_FAIL("manifest cannot be larger than 1 MB in phar \"%s\"")
- }
- buffer = (char *)emalloc(manifest_len);
- savebuf = buffer;
- endbuffer = buffer + manifest_len;
- if (manifest_len != php_stream_read(fp, buffer, manifest_len)) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest)")
- }
- if (manifest_len < 10) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest header)")
- }
-
- /* extract the number of entries */
- PHAR_GET_32(buffer, manifest_count);
- if (manifest_count == 0) {
- MAPPHAR_FAIL("in phar \"%s\", manifest claims to have zero entries. Phars must have at least 1 entry");
- }
-
- /* extract API version and global compressed flag */
- manifest_tag = (((unsigned char)buffer[0]) << 8)
- + ((unsigned char)buffer[1]);
- buffer += 2;
- if ((manifest_tag & PHAR_API_VER_MASK) < PHAR_API_VERSION ||
- (manifest_tag & PHAR_API_MAJORVER_MASK) != PHAR_API_MAJORVERSION)
- {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "phar \"%s\" is API version %1.u.%1.u.%1.u, and cannot be processed", fname, manifest_tag >> 12, (manifest_tag >> 8) & 0xF, (manifest_tag >> 4) & 0x0F);
- efree(savebuf);
- return FAILURE;
- }
- /* The lowest nibble contains the phar wide flags. The any compressed can */
- /* be ignored on reading because it is being generated anyways. */
-
- /* extract alias */
- PHAR_GET_32(buffer, tmp_len);
- if (buffer + tmp_len > endbuffer) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (buffer overrun)");
- }
- if (manifest_len < 10 + tmp_len) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest header)")
- }
- /* tmp_len = 0 says alias length is 0, which means the alias is not stored in the phar */
- if (tmp_len) {
- /* if the alias is stored we enforce it (implicit overrides explicit) */
- if (alias && alias_len && (alias_len != tmp_len || strncmp(alias, buffer, tmp_len)))
- {
- buffer[tmp_len] = '\0';
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "cannot load phar \"%s\" with implicit alias \"%s\" under different alias \"%s\"", fname, buffer, alias);
- efree(savebuf);
- return FAILURE;
- }
- alias_len = tmp_len;
- alias = buffer;
- buffer += tmp_len;
- register_alias = 1;
- } else if (!alias_len || !alias) {
- /* if we neither have an explicit nor an implicit alias, we use the filename */
- alias = NULL;
- alias_len = 0;
- register_alias = 0;
- } else {
- register_alias = 1;
- }
-
- /* we have 5 32-bit items plus 1 byte at least */
- if (manifest_count > ((manifest_len - 10 - tmp_len) / (5 * 4 + 1))) {
- /* prevent serious memory issues */
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (too many manifest entries for size of manifest)")
- }
-
- /* set up our manifest */
- mydata = emalloc(sizeof(phar_archive_data));
- zend_hash_init(&mydata->manifest, sizeof(phar_entry_info),
- zend_get_hash_value, destroy_phar_manifest, 0);
- offset = 0;
- mydata->min_timestamp = 0;
- mydata->max_timestamp = 0;
- for (manifest_index = 0; manifest_index < manifest_count; manifest_index++) {
- if (buffer + 4 > endbuffer) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)")
- }
- PHAR_GET_32(buffer, entry.filename_len);
- if (entry.filename_len == 0) {
- MAPPHAR_FAIL("zero-length filename encountered in phar \"%s\"");
- }
- if (buffer + entry.filename_len + 16 + 1 > endbuffer) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)");
- }
- entry.filename = estrndup(buffer, entry.filename_len);
- buffer += entry.filename_len;
- PHAR_GET_32(buffer, entry.uncompressed_filesize);
- PHAR_GET_32(buffer, entry.timestamp);
- if (offset == 0) {
- mydata->min_timestamp = entry.timestamp;
- mydata->max_timestamp = entry.timestamp;
- } else {
- if (mydata->min_timestamp > entry.timestamp) {
- mydata->min_timestamp = entry.timestamp;
- } else if (mydata->max_timestamp < entry.timestamp) {
- mydata->max_timestamp = entry.timestamp;
- }
- }
- PHAR_GET_32(buffer, entry.compressed_filesize);
- PHAR_GET_32(buffer, entry.crc32);
- entry.offset_within_phar = offset;
- offset += entry.compressed_filesize;
- entry.flags = *buffer++;
- switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
- case PHAR_ENT_COMPRESSED_GZ:
-#if !HAVE_ZLIB
- MAPPHAR_FAIL("zlib extension is required for gz compressed .phar file \"%s\"");
-#endif
- compressed = 1;
- break;
- case PHAR_ENT_COMPRESSED_BZ2:
-#if !HAVE_BZ2
- MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
-#endif
- compressed = 1;
- break;
- default:
- if (entry.uncompressed_filesize != entry.compressed_filesize) {
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (compressed and uncompressed size does not match for uncompressed entry)");
- }
- break;
- }
- entry.crc_checked = 0;
- entry.fp = NULL;
- zend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
- }
-
- mydata->fname = estrndup(fname, fname_len);
- mydata->fname_len = fname_len;
- mydata->alias = alias ? estrndup(alias, alias_len) : mydata->fname;
- mydata->alias_len = alias ? alias_len : fname_len;
- snprintf(mydata->version, sizeof(mydata->version), "%u.%u.%u", manifest_tag >> 12, (manifest_tag >> 8) & 0xF, (manifest_tag >> 4) & 0xF);
- mydata->internal_file_start = halt_offset + manifest_len + 4;
- mydata->has_compressed_files = compressed;
- mydata->fp = fp;
- mydata->refcount = 0;
- zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void*)&mydata, sizeof(phar_archive_data), NULL);
- if (register_alias) {
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
- }
- efree(savebuf);
-
- if (pphar) {
- *pphar = mydata;
- }
-
- return SUCCESS;
-}
-/* }}} */
-
-static int phar_open_filename(char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar TSRMLS_DC) /* {{{ */
-{
- const char token[] = "__HALT_COMPILER();";
- char *pos, buffer[1024 + sizeof(token)];
- const long readsize = sizeof(buffer) - sizeof(token);
- const long tokenlen = sizeof(token) - 1;
- long halt_offset;
- php_stream *fp;
- phar_archive_data *phar;
-
- if ((phar = phar_get_archive(fname, fname_len, alias, alias_len TSRMLS_CC)) != NULL) {
- if (fname_len != phar->fname_len || strncmp(fname, phar->fname, fname_len)) {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, phar->fname, fname);
- return FAILURE;
- } else {
- if (pphar) {
- *pphar = phar;
- }
- return SUCCESS;
- }
- }
-
-#if PHP_MAJOR_VERSION < 6
- if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- return FAILURE;
- }
-#endif
-
- if (php_check_open_basedir(fname TSRMLS_CC)) {
- return FAILURE;
- }
-
- fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
-
- if (!fp) {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "unable to open phar for reading \"%s\"", fname);
- return FAILURE;
- }
-
- /* Maybe it's better to compile the file instead of just searching, */
- /* but we only want the offset. So we want a .re scanner to find it. */
-
- if (-1 == php_stream_seek(fp, 0, SEEK_SET)) {
- MAPPHAR_ALLOC_FAIL("cannot rewind phar \"%s\"")
- }
-
- buffer[sizeof(buffer)-1] = '\0';
- memset(buffer, 32, sizeof(token));
- halt_offset = 0;
- while(!php_stream_eof(fp)) {
- if (php_stream_read(fp, buffer+tokenlen, readsize) < 0) {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest)")
- }
- if ((pos = strstr(buffer, token)) != NULL) {
- halt_offset += (pos - buffer); /* no -tokenlen+tokenlen here */
- return phar_open_file(fp, fname, fname_len, alias, alias_len, halt_offset, pphar TSRMLS_CC);
- }
-
- halt_offset += readsize;
- memmove(buffer, buffer + tokenlen, readsize + 1);
- }
-
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (__HALT_COMPILER(); not found)")
- php_stream_close(fp);
- return FAILURE;
-}
-/* }}} */
-
-static int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len TSRMLS_DC) /* {{{ */
-{
- char *pos_p, *pos_z, *ext_str;
- int ext_len;
-
- if (!strncasecmp(filename, "phar://", 7)) {
- filename += 7;
- filename_len -= 7;
- }
-
- pos_p = strstr(filename, ".phar.php");
- pos_z = strstr(filename, ".phar.gz");
- if (pos_p) {
- if (pos_z) {
- return FAILURE;
- }
- ext_str = pos_p;
- ext_len = 9;
- } else if (pos_z) {
- ext_str = pos_z;
- ext_len = 8;
- } else if ((pos_p = strstr(filename, ".phar")) != NULL) {
- ext_str = pos_p;
- ext_len = 5;
- } else {
- return FAILURE;
- }
- *arch_len = ext_str - filename + ext_len;
- *arch = estrndup(filename, *arch_len);
- if (ext_str[ext_len]) {
- *entry_len = filename_len - *arch_len;
- *entry = estrndup(ext_str+ext_len, *entry_len);
- } else {
- *entry_len = 1;
- *entry = estrndup("/", 1);
- }
- return SUCCESS;
-}
-/* }}} */
-
-static php_url* phar_open_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */
-{
- php_url *resource;
- char *arch, *entry;
- int arch_len, entry_len;
-
- if (!strncasecmp(filename, "phar://", 7)) {
-
- if (phar_split_fname(filename, strlen(filename), &arch, &arch_len, &entry, &entry_len TSRMLS_CC) == FAILURE) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\" (cannot contain .phar.php and .phar.gz)", filename);
- return NULL;
- }
- resource = ecalloc(1, sizeof(php_url));
- resource->scheme = estrndup("phar", 4);
- resource->host = arch;
- resource->path = entry;
-#if MBO_0
- if (resource) {
- fprintf(stderr, "Alias: %s\n", alias);
- fprintf(stderr, "Scheme: %s\n", resource->scheme);
-/* fprintf(stderr, "User: %s\n", resource->user);*/
-/* fprintf(stderr, "Pass: %s\n", resource->pass ? "***" : NULL);*/
- fprintf(stderr, "Host: %s\n", resource->host);
-/* fprintf(stderr, "Port: %d\n", resource->port);*/
- fprintf(stderr, "Path: %s\n", resource->path);
-/* fprintf(stderr, "Query: %s\n", resource->query);*/
-/* fprintf(stderr, "Fragment: %s\n", resource->fragment);*/
- }
-#endif
- if (phar_open_filename(resource->host, arch_len, NULL, 0, NULL TSRMLS_CC) == FAILURE)
- {
- php_url_free(resource);
- return NULL;
- }
-
- return resource;
- }
-
- return NULL;
-}
-/* }}} */
-
-static int phar_open_compiled_file(char *alias, int alias_len TSRMLS_DC) /* {{{ */
-{
- char *fname;
- long halt_offset;
- zval *halt_constant;
- php_stream *fp;
-
- fname = zend_get_executed_filename(TSRMLS_C);
-
- if (!strcmp(fname, "[no active file]")) {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "cannot initialize a phar outside of PHP execution");
- return FAILURE;
- }
-
- MAKE_STD_ZVAL(halt_constant);
- if (0 == zend_get_constant("__COMPILER_HALT_OFFSET__", 24, halt_constant TSRMLS_CC)) {
- FREE_ZVAL(halt_constant);
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "__HALT_COMPILER(); must be declared in a phar");
- return FAILURE;
- }
- halt_offset = Z_LVAL(*halt_constant);
- zval_ptr_dtor(&halt_constant);
-
- fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
-
- if (!fp) {
- php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "unable to open phar for reading \"%s\"", fname);
- return FAILURE;
- }
-
- return phar_open_file(fp, fname, strlen(fname), alias, alias_len, halt_offset, NULL TSRMLS_CC);
-}
-/* }}} */
-
-/* {{{ proto mixed Phar::mapPhar([string alias])
- * Reads the currently executed file (a phar) and registers its manifest */
-PHP_METHOD(Phar, mapPhar)
-{
- char * alias = NULL;
- int alias_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &alias, &alias_len) == FAILURE) {
- return;
- }
-
- RETURN_BOOL(phar_open_compiled_file(alias, alias_len TSRMLS_CC) == SUCCESS);
-} /* }}} */
-
-/* {{{ proto mixed Phar::loadPhar(string url [, string alias])
- * Loads a phar archive with an alias */
-PHP_METHOD(Phar, loadPhar)
-{
- char *fname, *alias = NULL;
- int fname_len, alias_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &fname, &fname_len, &alias, &alias_len) == FAILURE) {
- return;
- }
- RETURN_BOOL(phar_open_filename(fname, fname_len, alias, alias_len, NULL TSRMLS_CC) == SUCCESS);
-} /* }}} */
-
-static php_stream_ops phar_ops = {
- phar_write, /* write (does nothing) */
- phar_read, /* read */
- phar_close, /* close */
- phar_flush, /* flush (does nothing) */
- "phar stream",
- phar_seek, /* seek */
- NULL, /* cast */
- phar_stat, /* stat */
- NULL, /* set option */
-};
-
-static php_stream_ops phar_dir_ops = {
- phar_write, /* write (does nothing) */
- phar_readdir, /* read */
- phar_closedir, /* close */
- phar_flush, /* flush (does nothing) */
- "phar stream",
- phar_seekdir, /* seek */
- NULL, /* cast */
- phar_stat, /* stat */
- NULL, /* set option */
-};
-
-static php_stream_wrapper_ops phar_stream_wops = {
- php_stream_phar_url_wrapper,
- NULL, /* stream_close */
- NULL, /* php_stream_phar_stat, */
- phar_stream_stat, /* stat_url */
- phar_opendir, /* opendir */
- "phar",
- NULL, /* unlink */
- NULL, /* rename */
- NULL, /* create directory */
- NULL /* remove directory */
-};
-
-php_stream_wrapper php_stream_phar_wrapper = {
- &phar_stream_wops,
- NULL,
- 0 /* is_url */
-};
-
-static int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_data *idata, php_uint32 crc32 TSRMLS_DC) /* {{{ */
-{
- unsigned int crc = ~0;
- int len = idata->internal_file->uncompressed_filesize;
- char c;
-
- php_stream_seek(idata->fp, 0, SEEK_SET);
-
- while (len--) {
- php_stream_read(idata->fp, &c, 1);
- CRC32(crc, c);
- }
- php_stream_seek(idata->fp, 0, SEEK_SET);
- if (~crc == crc32) {
- return SUCCESS;
- } else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", idata->phar->fname, idata->internal_file->filename);
- return FAILURE;
- }
-}
-/* }}} */
-
-static char * phar_decompress_filter(phar_entry_info * entry, int return_unknow) /* {{{ */
-{
- switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) {
- case PHAR_ENT_COMPRESSED_GZ:
- return "zlib.inflate";
- case PHAR_ENT_COMPRESSED_BZ2:
- return "bzip2.decompress";
- default:
- return return_unknow ? "unknown" : NULL;
- }
-}
-/* }}} */
-
-static php_stream * php_stream_phar_url_wrapper(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *idata;
- char *internal_file;
- char *buffer;
- char *filter_name;
- char tmpbuf[8];
- php_url *resource = NULL;
- php_stream *fp, *fpf;
- php_stream_filter *filter, *consumed;
- php_uint32 offset;
-
- resource = php_url_parse(path);
-
- if (!resource && (resource = phar_open_url(wrapper, path, mode, options TSRMLS_CC)) == NULL) {
- return NULL;
- }
-
- /* we must have at the very least phar://alias.phar/internalfile.php */
- if (!resource->scheme || !resource->host || !resource->path) {
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", path);
- return NULL;
- }
-
- if (strcasecmp("phar", resource->scheme)) {
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", path);
- return NULL;
- }
-
- /* strip leading "/" */
- internal_file = estrdup(resource->path + 1);
- if (NULL == (idata = phar_get_entry_data(resource->host, strlen(resource->host), internal_file, strlen(internal_file) TSRMLS_CC))) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" is not a file in phar \"%s\"", internal_file, resource->host);
- efree(internal_file);
- php_url_free(resource);
- return NULL;
- }
- php_url_free(resource);
-
-#if MBO_0
- fprintf(stderr, "Pharname: %s\n", idata->phar->filename);
- fprintf(stderr, "Filename: %s\n", internal_file);
- fprintf(stderr, "Entry: %s\n", idata->internal_file->filename);
- fprintf(stderr, "Size: %u\n", idata->internal_file->uncompressed_filesize);
- fprintf(stderr, "Compressed: %u\n", idata->internal_file->flags);
- fprintf(stderr, "Offset: %u\n", idata->internal_file->offset_within_phar);
- fprintf(stderr, "Cached: %s\n", idata->internal_file->filedata ? "yes" : "no");
-#endif
-
- /* do we have the data already? */
- if (idata->fp) {
- fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
- idata->phar->refcount++;
- efree(internal_file);
- return fpf;
- }
-
-#if PHP_MAJOR_VERSION < 6
- if (PG(safe_mode) && (!php_checkuid(idata->phar->fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- efree(idata);
- efree(internal_file);
- return NULL;
- }
-#endif
-
- if (php_check_open_basedir(idata->phar->fname TSRMLS_CC)) {
- efree(idata);
- efree(internal_file);
- return NULL;
- }
-
- fp = idata->phar->fp;
-
- if (!fp) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot open phar \"%s\"", idata->phar->fname);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
-
- /* seek to start of internal file and read it */
- offset = idata->phar->internal_file_start + idata->internal_file->offset_within_phar;
- if (-1 == php_stream_seek(fp, offset, SEEK_SET)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (cannot seek to start of file \"%s\" at offset \"%d\")",
- idata->phar->fname, internal_file, offset);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
-
- if ((idata->internal_file->flags & PHAR_ENT_COMPRESSION_MASK) != 0) {
- ;
- if ((filter_name = phar_decompress_filter(idata->internal_file, 0)) != NULL) {
- filter = php_stream_filter_create(phar_decompress_filter(idata->internal_file, 0), NULL, php_stream_is_persistent(fp) TSRMLS_CC);
- } else {
- filter = NULL;
- }
- if (!filter) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: unable to read phar \"%s\" (cannot create %s filter while decompressing file \"%s\")", idata->phar->fname, phar_decompress_filter(idata->internal_file, 1), internal_file);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
- /* Unfortunatley we cannot check the read position of fp after getting */
- /* uncompressed data because the new stream posiition is being changed */
- /* by the number of bytes read throughthe filter not by the raw number */
- /* bytes being consumed on the stream. Therefor use a consumed filter. */
- consumed = php_stream_filter_create("consumed", NULL, php_stream_is_persistent(fp) TSRMLS_CC);
- php_stream_filter_append(&fp->readfilters, consumed);
- php_stream_filter_append(&fp->readfilters, filter);
-
- idata->fp = php_stream_temp_new();
- if (php_stream_copy_to_stream(fp, idata->fp, idata->internal_file->uncompressed_filesize) != idata->internal_file->uncompressed_filesize) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", idata->phar->fname, internal_file);
- php_stream_close(idata->fp);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
- php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- php_stream_filter_flush(consumed, 1);
- php_stream_filter_remove(consumed, 1 TSRMLS_CC);
- if (offset + idata->internal_file->compressed_filesize != php_stream_tell(fp)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", idata->phar->fname, internal_file);
- php_stream_close(idata->fp);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
- php_stream_seek(fp, offset + idata->internal_file->compressed_filesize, SEEK_SET);
- } else { /* from here is for non-compressed */
- buffer = &tmpbuf[0];
- /* bypass to temp stream */
- idata->fp = php_stream_temp_new();
- if (php_stream_copy_to_stream(fp, idata->fp, idata->internal_file->uncompressed_filesize) != idata->internal_file->uncompressed_filesize) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", idata->phar->fname, internal_file);
- php_stream_close(idata->fp);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
- }
-
- /* check length, crc32 */
- if (phar_postprocess_file(wrapper, options, idata, idata->internal_file->crc32 TSRMLS_CC) != SUCCESS) {
- php_stream_close(idata->fp);
- efree(idata);
- efree(internal_file);
- return NULL;
- }
- idata->internal_file->crc_checked = 1;
-
- fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
- idata->phar->refcount++;
- efree(internal_file);
- return fpf;
-}
-/* }}} */
-
-static int phar_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *)stream->abstract;
-
- /* data->fp is the temporary memory stream containing this file's data */
- if (data->fp) {
- /* only close if we have a cached temp memory stream */
- if (data->internal_file->fp) {
- php_stream_close(data->fp);
- } else {
- data->internal_file->fp = data->fp;
- }
- }
- if (--data->phar->refcount < 0) {
- phar_destroy_phar_data(data->phar TSRMLS_CC);
- }
-
- efree(data);
- return 0;
-}
-/* }}} */
-
-static int phar_closedir(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
-{
- HashTable *data = (HashTable *)stream->abstract;
-
- if (data)
- {
- zend_hash_destroy(data);
- FREE_HASHTABLE(data);
- stream->abstract = NULL;
- }
- return 0;
-}
-/* }}} */
-
-static int phar_seekdir(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
-{
- HashTable *data = (HashTable *)stream->abstract;
-
- if (data)
- {
- if (whence == SEEK_END) {
- whence = SEEK_SET;
- offset = zend_hash_num_elements(data) + offset;
- }
- if (whence == SEEK_SET) {
- zend_hash_internal_pointer_reset(data);
- }
-
- if (offset < 0) {
- php_stream_wrapper_log_error(stream->wrapper, stream->flags TSRMLS_CC, "phar error: cannot seek because the resulting seek is negative");
- return -1;
- } else {
- *newoffset = 0;
- while (*newoffset < offset && zend_hash_move_forward(data) == SUCCESS) {
- (*newoffset)++;
- }
- return 0;
- }
- }
- return -1;
-}
-/* }}} */
-
-static size_t phar_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *)stream->abstract;
-
- size_t got = php_stream_read(data->fp, buf, count);
-
- if (data->fp->eof) {
- stream->eof = 1;
- }
-
- return got;
-}
-/* }}} */
-
-static size_t phar_readdir(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
-{
- size_t to_read;
- HashTable *data = (HashTable *)stream->abstract;
- char *key;
- uint keylen;
- ulong unused;
-
- if (FAILURE == zend_hash_has_more_elements(data)) {
- return 0;
- }
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) {
- return 0;
- }
- zend_hash_move_forward(data);
- to_read = MIN(keylen, count);
- if (to_read == 0 || count < keylen) {
- return 0;
- }
- memset(buf, 0, sizeof(php_stream_dirent));
- memcpy(((php_stream_dirent *) buf)->d_name, key, to_read);
- ((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
-
- return sizeof(php_stream_dirent);
-}
-/* }}} */
-
-static int phar_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *)stream->abstract;
-
- int res = php_stream_seek(data->fp, offset, whence);
- *newoffset = php_stream_tell(data->fp);
- return res;
-}
-/* }}} */
-
-static size_t phar_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
-{
- return 0;
-}
-/* }}} */
-
-static int phar_flush(php_stream *stream TSRMLS_DC) /* {{{ */
-{
- return EOF;
-}
-/* }}} */
-
- /* {{{ phar_dostat */
-static void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_statbuf *ssb,
- zend_bool is_dir, char *alias, int alias_len TSRMLS_DC)
-{
- char *tmp;
- int tmp_len;
- memset(ssb, 0, sizeof(php_stream_statbuf));
- /* read-only across the board */
- ssb->sb.st_mode = 0444;
-
- if (!is_dir) {
- ssb->sb.st_size = data->uncompressed_filesize;
- ssb->sb.st_mode |= S_IFREG; /* regular file */
- /* timestamp is just the timestamp when this was added to the phar */
-#ifdef NETWARE
- ssb->sb.st_mtime.tv_sec = data->timestamp;
- ssb->sb.st_atime.tv_sec = data->timestamp;
- ssb->sb.st_ctime.tv_sec = data->timestamp;
-#else
- ssb->sb.st_mtime = data->timestamp;
- ssb->sb.st_atime = data->timestamp;
- ssb->sb.st_ctime = data->timestamp;
-#endif
- } else {
- ssb->sb.st_size = 0;
- ssb->sb.st_mode |= S_IFDIR; /* regular directory */
-#ifdef NETWARE
- ssb->sb.st_mtime.tv_sec = phar->max_timestamp;
- ssb->sb.st_atime.tv_sec = phar->max_timestamp;
- ssb->sb.st_ctime.tv_sec = phar->max_timestamp;
-#else
- ssb->sb.st_mtime = phar->max_timestamp;
- ssb->sb.st_atime = phar->max_timestamp;
- ssb->sb.st_ctime = phar->max_timestamp;
-#endif
- }
-
- ssb->sb.st_nlink = 1;
- ssb->sb.st_rdev = -1;
- if (data) {
- tmp_len = data->filename_len + alias_len;
- } else {
- tmp_len = alias_len + 1;
- }
- tmp = (char *) emalloc(tmp_len);
- memcpy(tmp, alias, alias_len);
- if (data) {
- memcpy(tmp + alias_len, data->filename, data->filename_len);
- } else {
- *(tmp+alias_len) = '/';
- }
- /* this is only for APC, so use /dev/null device - no chance of conflict there! */
- ssb->sb.st_dev = 0xc;
- /* generate unique inode number for alias/filename, so no phars will conflict */
- ssb->sb.st_ino = zend_get_hash_value(tmp, tmp_len);
- efree(tmp);
-#ifndef PHP_WIN32
- ssb->sb.st_blksize = -1;
- ssb->sb.st_blocks = -1;
-#endif
-}
-/* }}}*/
-
-static int phar_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data;
- /* If ssb is NULL then someone is misbehaving */
- if (!ssb) return -1;
-
- data = (phar_entry_data *)stream->abstract;
- phar_dostat(data->phar, data->internal_file, ssb, 0, data->phar->alias, data->phar->alias_len TSRMLS_CC);
- return 0;
-}
-/* }}} */
-
-static int phar_stream_stat(php_stream_wrapper *wrapper, char *url, int flags,
- php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) /* {{{ */
-{
- php_url *resource = NULL;
- char *internal_file, *key;
- uint keylen;
- ulong unused;
- phar_archive_data *phar;
- phar_entry_info *entry;
-
- resource = php_url_parse(url);
-
- if (!resource && (resource = phar_open_url(wrapper, url, "r", 0 TSRMLS_CC)) == NULL) {
- return -1;
- }
-
- /* we must have at the very least phar://alias.phar/internalfile.php */
- if (!resource->scheme || !resource->host || !resource->path) {
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, flags TSRMLS_CC, "phar error: invalid url \"%s\"", url);
- return -1;
- }
-
- if (strcasecmp("phar", resource->scheme)) {
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, flags TSRMLS_CC, "phar error: not a phar url \"%s\"", url);
- return -1;
- }
-
- internal_file = resource->path + 1; /* strip leading "/" */
- /* find the phar in our trusty global hash indexed by alias (host of phar://blah.phar/file.whatever) */
- if ((phar = phar_get_archive(resource->host, strlen(resource->host), NULL, 0 TSRMLS_CC)) != NULL) {
- if (*internal_file == '\0') {
- /* root directory requested */
- phar_dostat(phar, NULL, ssb, 1, phar->alias, phar->alias_len TSRMLS_CC);
- php_url_free(resource);
- return 0;
- }
- /* search through the manifest of files, and if we have an exact match, it's a file */
- if (SUCCESS == zend_hash_find(&phar->manifest, internal_file, strlen(internal_file), (void**)&entry)) {
- phar_dostat(phar, entry, ssb, 0, phar->alias, phar->alias_len TSRMLS_CC);
- } else {
- /* search for directory (partial match of a file) */
- zend_hash_internal_pointer_reset(&phar->manifest);
- while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
- if (HASH_KEY_NON_EXISTANT !=
- zend_hash_get_current_key_ex(
- &phar->manifest, &key, &keylen, &unused, 0, NULL)) {
- if (0 == memcmp(internal_file, key, strlen(internal_file))) {
- /* directory found, all dirs have the same stat */
- if (key[strlen(internal_file)] == '/') {
- phar_dostat(phar, NULL, ssb, 1, phar->alias, phar->alias_len TSRMLS_CC);
- break;
- }
- }
- }
- if (SUCCESS != zend_hash_move_forward(&phar->manifest)) {
- break;
- }
- }
- }
- }
-
- php_url_free(resource);
- return 0;
-}
-/* }}} */
-
-/* add an empty element with a char * key to a hash table, avoiding duplicates */
-static int phar_add_empty(HashTable *ht, char *arKey, uint nKeyLength) /* {{{ */
-{
- void *dummy = (void *) 1;
-
- return zend_hash_update(ht, arKey, nKeyLength, &dummy, sizeof(void *), NULL);
-}
-/* }}} */
-
-static int compare_dir_name(const void *a, const void *b TSRMLS_DC) /* {{{ */
-{
- Bucket *f;
- Bucket *s;
- int result;
-
- f = *((Bucket **) a);
- s = *((Bucket **) b);
-
-#if (PHP_MAJOR_VERSION < 6)
- result = zend_binary_strcmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
-#else
- result = zend_binary_strcmp(f->key.arKey.s, f->nKeyLength, s->key.arKey.s, s->nKeyLength);
-#endif
-
- if (result < 0) {
- return -1;
- } else if (result > 0) {
- return 1;
- } else {
- return 0;
- }
-}
-/* }}} */
-
-static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) /* {{{ */
-{
- HashTable *data;
- int dirlen = strlen(dir);
- char *save, *found, *key;
- uint keylen;
- ulong unused;
- char *entry;
- ALLOC_HASHTABLE(data);
- zend_hash_init(data, 64, zend_get_hash_value, NULL, 0);
-
- zend_hash_internal_pointer_reset(manifest);
- while (FAILURE != zend_hash_has_more_elements(manifest)) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
- break;
- }
- if (*dir == '/') {
- /* root directory */
- if (NULL != (found = (char *) memchr(key, '/', keylen))) {
- /* the entry has a path separator and is a subdirectory */
- entry = (char *) emalloc (found - key + 1);
- memcpy(entry, key, found - key);
- keylen = found - key;
- entry[keylen] = '\0';
- } else {
- entry = (char *) emalloc (keylen + 1);
- memcpy(entry, key, keylen);
- entry[keylen] = '\0';
- }
- goto PHAR_ADD_ENTRY;
- } else {
- if (0 != memcmp(key, dir, dirlen)) {
- /* entry in directory not found */
- if (SUCCESS != zend_hash_move_forward(manifest)) {
- break;
- }
- continue;
- } else {
- if (key[dirlen] != '/') {
- if (SUCCESS != zend_hash_move_forward(manifest)) {
- break;
- }
- continue;
- }
- }
- }
- save = key;
- save += dirlen + 1; /* seek to just past the path separator */
- if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) {
- /* is subdirectory */
- save -= dirlen + 1;
- entry = (char *) emalloc (found - save + dirlen + 1);
- memcpy(entry, save + dirlen + 1, found - save - dirlen - 1);
- keylen = found - save - dirlen - 1;
- entry[keylen] = '\0';
- } else {
- /* is file */
- save -= dirlen + 1;
- entry = (char *) emalloc (keylen - dirlen + 1);
- memcpy(entry, save + dirlen + 1, keylen - dirlen - 1);
- entry[keylen - dirlen - 1] = '\0';
- keylen = keylen - dirlen - 1;
- }
-PHAR_ADD_ENTRY:
- phar_add_empty(data, entry, keylen);
- efree(entry);
- if (SUCCESS != zend_hash_move_forward(manifest)) {
- break;
- }
- }
- if (FAILURE != zend_hash_has_more_elements(data)) {
- efree(dir);
- if (zend_hash_sort(data, zend_qsort, compare_dir_name, 0 TSRMLS_CC) == FAILURE) {
- FREE_HASHTABLE(data);
- return NULL;
- }
- return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
- } else {
- efree(dir);
- FREE_HASHTABLE(data);
- return NULL;
- }
-}
-/* }}}*/
-
-static php_stream *phar_opendir(php_stream_wrapper *wrapper, char *filename, char *mode,
- int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC) /* {{{ */
-{
- php_url *resource = NULL;
- php_stream *ret;
- char *internal_file, *key;
- uint keylen;
- ulong unused;
- phar_archive_data *phar;
- phar_entry_info *entry;
-
- resource = php_url_parse(filename);
-
- if (!resource && (resource = phar_open_url(wrapper, filename, mode, options TSRMLS_CC)) == NULL) {
- return NULL;
- }
-
- /* we must have at the very least phar://alias.phar/ */
- if (!resource->scheme || !resource->host || !resource->path) {
- if (resource->host && !resource->path) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory", filename, resource->host);
- php_url_free(resource);
- return NULL;
- }
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\", must have at least phar://%s/", filename, filename);
- return NULL;
- }
-
- if (strcasecmp("phar", resource->scheme)) {
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar url \"%s\"", filename);
- return NULL;
- }
-
- internal_file = resource->path + 1; /* strip leading "/" */
- if ((phar = phar_get_archive(resource->host, strlen(resource->host), NULL, 0 TSRMLS_CC)) != NULL) {
- if (*internal_file == '\0') {
- /* root directory requested */
- internal_file = estrndup(internal_file - 1, 1);
- ret = phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
- php_url_free(resource);
- return ret;
- }
- if (SUCCESS == zend_hash_find(&phar->manifest, internal_file, strlen(internal_file), (void**)&entry)) {
- php_url_free(resource);
- return NULL;
- } else {
- /* search for directory */
- zend_hash_internal_pointer_reset(&phar->manifest);
- while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
- if (HASH_KEY_NON_EXISTANT !=
- zend_hash_get_current_key_ex(
- &phar->manifest, &key, &keylen, &unused, 0, NULL)) {
- if (0 == memcmp(key, internal_file, strlen(internal_file))) {
- /* directory found */
- internal_file = estrndup(internal_file,
- strlen(internal_file));
- php_url_free(resource);
- return phar_make_dirstream(internal_file, &phar->manifest TSRMLS_CC);
- }
- }
- if (SUCCESS != zend_hash_move_forward(&phar->manifest)) {
- break;
- }
- }
- }
- }
-
- php_url_free(resource);
- return NULL;
-}
-/* }}} */
-
-/* {{{ proto void Phar::__construct(string fname [, int flags [, string alias]])
- * Construct a Phar archive object
- */
-PHP_METHOD(Phar, __construct)
-{
- char *fname, *alias = NULL;
- int fname_len, alias_len = 0;
- long flags = 0;
- phar_archive_object *phar_obj;
- phar_archive_data *phar_data;
- zval *zobj = getThis(), arg1, arg2;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
- return;
- }
-
- phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- if (phar_obj->arc.archive) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot call constructor twice");
- return;
- }
-
- if (phar_open_filename(fname, fname_len, alias, alias_len, &phar_data TSRMLS_CC) == FAILURE) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot open phar file '%s' with alias '%s'", fname, alias);
- return;
- }
-
- phar_data->refcount++;
- phar_obj->arc.archive = phar_data;
- phar_obj->spl.oth_handler = &phar_spl_foreign_handler;
-
- fname_len = spprintf(&fname, 0, "phar://%s", fname);
-
- INIT_PZVAL(&arg1);
- ZVAL_STRINGL(&arg1, fname, fname_len, 0);
-
- if (ZEND_NUM_ARGS() > 1) {
- INIT_PZVAL(&arg2);
- ZVAL_LONG(&arg2, flags);
- zend_call_method_with_2_params(&zobj, Z_OBJCE_P(zobj),
- &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1, &arg2);
- } else {
- zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj),
- &spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg1);
- }
-
- phar_obj->spl.info_class = phar_ce_entry;
-
- efree(fname);
-}
-/* }}} */
-
-#define PHAR_ARCHIVE_OBJECT() \
- phar_archive_object *phar_obj = (phar_archive_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
- if (!phar_obj->arc.archive) { \
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
- "Cannot call method on an uninitialzed Phar object"); \
- return; \
- }
-
-/* {{{ proto int Phar::count()
- * Returns the number of entries in the Phar archive
- */
-PHP_METHOD(Phar, count)
-{
- PHAR_ARCHIVE_OBJECT();
-
- RETURN_LONG(zend_hash_num_elements(&phar_obj->arc.archive->manifest));
-}
-/* }}} */
-
-/* {{{ proto string Phar::getVersion()
- * Return version info of Phar archive
- */
-PHP_METHOD(Phar, getVersion)
-{
- PHAR_ARCHIVE_OBJECT();
-
- RETURN_STRING(phar_obj->arc.archive->version, 1);
-}
-/* }}} */
-
-/* {{{ proto int Phar::offsetExists(string offset)
- * determines whether a file exists in the phar
- */
-PHP_METHOD(Phar, offsetExists)
-{
- char *fname;
- int fname_len;
- PHAR_ARCHIVE_OBJECT();
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
- return;
- }
-
- if (zend_hash_exists(&phar_obj->arc.archive->manifest, fname, (uint) fname_len)) {
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int Phar::offsetGet(string offset)
- * get a PharFileInfo object for a specific file
- */
-PHP_METHOD(Phar, offsetGet)
-{
- char *fname;
- int fname_len;
- zval *zfname;
- PHAR_ARCHIVE_OBJECT();
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
- return;
- }
-
- if (!phar_get_entry_info(phar_obj->arc.archive, fname, fname_len TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist", fname);
- } else {
- fname_len = spprintf(&fname, 0, "phar://%s/%s", phar_obj->arc.archive->fname, fname);
- MAKE_STD_ZVAL(zfname);
- ZVAL_STRINGL(zfname, fname, fname_len, 0);
- spl_instantiate_arg_ex1(phar_obj->spl.file_class, &return_value, 0, zfname TSRMLS_CC);
- zval_ptr_dtor(&zfname);
- }
-
-}
-/* }}} */
-
-/* {{{ proto int Phar::offsetSet(string offset, string value)
- * set the contents of an internal file to those of an external file
- */
-PHP_METHOD(Phar, offsetSet)
-{
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Operation currently not supported");
-}
-/* }}} */
-
-/* {{{ proto int Phar::offsetUnset()
- * remove a file from a phar
- */
-PHP_METHOD(Phar, offsetUnset)
-{
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Operation currently not supported");
-}
-/* }}} */
-
-/* {{{ proto void PharFileInfo::__construct(string entry)
- * Construct a Phar entry object
- */
-PHP_METHOD(PharFileInfo, __construct)
-{
- char *fname, *arch, *entry;
- int fname_len, arch_len, entry_len;
- phar_entry_object *entry_obj;
- phar_entry_info *entry_info;
- phar_archive_data *phar_data;
- zval *zobj = getThis(), arg1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
- return;
- }
-
- entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- if (entry_obj->ent.entry) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot call constructor twice");
- return;
- }
-
- if (phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len TSRMLS_CC) == FAILURE) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot access phar file entry '%s'", fname);
- return;
- }
-
- if (phar_open_filename(arch, arch_len, NULL, 0, &phar_data TSRMLS_CC) == FAILURE) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot open phar file '%s'", fname);
- return;
- }
-
- if ((entry_info = phar_get_entry_info(phar_data, entry, entry_len TSRMLS_CC)) == NULL) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot access phar file entry '%s' in archive '%s'", entry, arch);
- return;
- }
-
- entry_obj->ent.entry = entry_info;
-
- INIT_PZVAL(&arg1);
- ZVAL_STRINGL(&arg1, fname, fname_len, 0);
-
- zend_call_method_with_1_params(&zobj, Z_OBJCE_P(zobj),
- &spl_ce_SplFileInfo->constructor, "__construct", NULL, &arg1);
-}
-/* }}} */
-
-#define PHAR_ENTRY_OBJECT() \
- phar_entry_object *entry_obj = (phar_entry_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
- if (!entry_obj->ent.entry) { \
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
- "Cannot call method on an uninitialzed PharFileInfo object"); \
- return; \
- }
-
-/* {{{ proto int PharFileInfo::getCompressedSize()
- * Returns the compressed size
- */
-PHP_METHOD(PharFileInfo, getCompressedSize)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_LONG(entry_obj->ent.entry->compressed_filesize);
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::getCRC32()
- * Returns CRC32 code or throws an exception if not CRC checked
- */
-PHP_METHOD(PharFileInfo, getCRC32)
-{
- PHAR_ENTRY_OBJECT();
-
- if (entry_obj->ent.entry->crc_checked) {
- RETURN_LONG(entry_obj->ent.entry->crc32);
- } else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
- "Phar entry was not CRC checked"); \
- }
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::getPharFlags()
- * Returns the Phar file entry flags
- */
-PHP_METHOD(PharFileInfo, getPharFlags)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_LONG(entry_obj->ent.entry->flags);
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::isCRCChecked()
- * Returns whether file entry is CRC checked
- */
-PHP_METHOD(PharFileInfo, isCRCChecked)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_BOOL(entry_obj->ent.entry->crc_checked);
-}
-/* }}} */
-
-#ifdef COMPILE_DL_PHAR
-ZEND_GET_MODULE(phar)
-#endif
-
-/* {{{ phar_functions[]
- *
- * Every user visible function must have an entry in phar_functions[].
- */
-function_entry phar_functions[] = {
- {NULL, NULL, NULL} /* Must be the last line in phar_functions[] */
-};
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
- ZEND_ARG_INFO(0, fname)
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_INFO(0, alias)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_mapPhar, 0, 0, 0)
- ZEND_ARG_INFO(0, alias)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_loadPhar, 0, 0, 1)
- ZEND_ARG_INFO(0, fname)
- ZEND_ARG_INFO(0, alias)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetExists, 0, 0, 1)
- ZEND_ARG_INFO(0, entry)
-ZEND_END_ARG_INFO();
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_offsetSet, 0, 0, 2)
- ZEND_ARG_INFO(0, entry)
- ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO();
-
-zend_function_entry php_archive_methods[] = {
- PHP_ME(Phar, __construct, arginfo_phar___construct, 0)
- PHP_ME(Phar, count, NULL, 0)
- PHP_ME(Phar, getVersion, NULL, 0)
- PHP_ME(Phar, offsetGet, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, offsetSet, arginfo_phar_offsetSet, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, offsetUnset, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
- /* static member functions */
- PHP_ME(Phar, apiVersion, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, canCompress, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- {NULL, NULL, NULL}
-};
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
- ZEND_ARG_INFO(0, fname)
- ZEND_ARG_INFO(0, flags)
-ZEND_END_ARG_INFO();
-
-zend_function_entry php_entry_methods[] = {
- PHP_ME(PharFileInfo, __construct, arginfo_entry___construct, 0)
- PHP_ME(PharFileInfo, getCompressedSize, NULL, 0)
- PHP_ME(PharFileInfo, getCRC32, NULL, 0)
- PHP_ME(PharFileInfo, getPharFlags, NULL, 0)
- PHP_ME(PharFileInfo, isCRCChecked, NULL, 0)
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ php_phar_init_globals
- */
-static void php_phar_init_globals_module(zend_phar_globals *phar_globals)
-{
- memset(phar_globals, 0, sizeof(zend_phar_globals));
-}
-/* }}} */
-
-PHP_MINIT_FUNCTION(phar) /* {{{ */
-{
- zend_class_entry ce;
-
- ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL);
-
- INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
- phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator, NULL TSRMLS_CC);
-
- zend_class_implements(phar_ce_archive TSRMLS_CC, 2, spl_ce_Countable, zend_ce_arrayaccess);
-
- INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
- phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo, NULL TSRMLS_CC);
-
- return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper TSRMLS_CC);
-}
-/* }}} */
-
-PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
-{
- return php_unregister_url_stream_wrapper("phar" TSRMLS_CC);
-}
-/* }}} */
-
-PHP_RINIT_FUNCTION(phar) /* {{{ */
-{
- zend_hash_init(&(PHAR_GLOBALS->phar_fname_map), sizeof(phar_archive_data), zend_get_hash_value, destroy_phar_data, 0);
- zend_hash_init(&(PHAR_GLOBALS->phar_alias_map), sizeof(phar_archive_data*), zend_get_hash_value, NULL, 0);
- return SUCCESS;
-}
-/* }}} */
-
-PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */
-{
- zend_hash_destroy(&(PHAR_GLOBALS->phar_alias_map));
- zend_hash_destroy(&(PHAR_GLOBALS->phar_fname_map));
- return SUCCESS;
-}
-/* }}} */
-
-PHP_MINFO_FUNCTION(phar) /* {{{ */
-{
- php_info_print_table_start();
- php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
- php_info_print_table_row(2, "Phar API version", PHAR_VERSION_STR);
- php_info_print_table_row(2, "CVS revision", "$Revision$");
- php_info_print_table_row(2, "gzip compression",
-#if HAVE_ZLIB
- "enabled");
-#else
- "disabled");
-#endif
- php_info_print_table_row(2, "bzip2 compression",
-#if HAVE_BZ2
- "enabled");
-#else
- "disabled");
-#endif
- php_info_print_table_row(1, "Phar based on pear/PHP_Archive, original concept by Davey Shafik and fully realized by Gregory Beaver");
- php_info_print_table_end();
-}
-/* }}} */
-
-/* {{{ phar_module_entry
- */
-static zend_module_dep phar_deps[] = {
-#if HAVE_ZLIB
- ZEND_MOD_REQUIRED("zlib")
-#endif
-#if HAVE_BZ2
- ZEND_MOD_REQUIRED("bz2")
-#endif
- ZEND_MOD_REQUIRED("spl")
- {NULL, NULL, NULL}
-};
-
-zend_module_entry phar_module_entry = {
- STANDARD_MODULE_HEADER_EX, NULL,
- phar_deps,
- "Phar",
- phar_functions,
- PHP_MINIT(phar),
- PHP_MSHUTDOWN(phar),
- PHP_RINIT(phar),
- PHP_RSHUTDOWN(phar),
- PHP_MINFO(phar),
- PHAR_VERSION_STR,
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/phar/phar.php b/ext/phar/phar.php
deleted file mode 100644
index 146566ae7b..0000000000
--- a/ext/phar/phar.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-$br = (php_sapi_name() == "cli")? "":"<br>";
-
-if(!extension_loaded('phar')) {
- dl('phar.' . PHP_SHLIB_SUFFIX);
-}
-$module = 'phar';
-$functions = get_extension_funcs($module);
-echo "Functions available in the test extension:$br\n";
-foreach($functions as $func) {
- echo $func."$br\n";
-}
-echo "$br\n";
-$function = 'confirm_' . $module . '_compiled';
-if (extension_loaded($module)) {
- $str = $function($module);
-} else {
- $str = "Module $module is not compiled into PHP";
-}
-echo "$str\n";
-?>
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
deleted file mode 100644
index b4b94f9bee..0000000000
--- a/ext/phar/php_phar.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2005 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Gregory Beaver <cellog@php.net> |
- | Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_PHAR_H
-#define PHP_PHAR_H
-
-#include "ext/standard/basic_functions.h"
-extern zend_module_entry phar_module_entry;
-#define phpext_phar_ptr &phar_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_PHAR_API __declspec(dllexport)
-#else
-#define PHP_PHAR_API
-#endif
-
-/* In every utility function you add that needs to use variables
- in php_phar_globals, call TSRMLS_FETCH(); after declaring other
- variables used by that function, or better yet, pass in TSRMLS_CC
- after the last function argument and declare your utility function
- with TSRMLS_DC after the last declared argument. Always refer to
- the globals in your function as PHAR_G(variable). You are
- encouraged to rename these macros something shorter, see
- examples in any other php module directory.
-*/
-
-#ifdef ZTS
-# include "TSRM.h"
-# define PHAR_G(v) TSRMG(phar_globals_id, zend_phar_globals *, v)
-# define PHAR_GLOBALS ((zend_phar_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phar_globals_id)])
-#else
-# define PHAR_G(v) (phar_globals.v)
-# define PHAR_GLOBALS (&phar_globals)
-#endif
-
-#endif /* PHP_PHAR_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/phar/tests/001.phpt b/ext/phar/tests/001.phpt
deleted file mode 100644
index 5d1629edbf..0000000000
--- a/ext/phar/tests/001.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-Phar::apiVersion
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-var_dump(Phar::apiVersion());
-?>
-===DONE===
---EXPECT--
-string(5) "0.8.0"
-===DONE===
diff --git a/ext/phar/tests/002.phpt b/ext/phar/tests/002.phpt
deleted file mode 100644
index a070314a5d..0000000000
--- a/ext/phar/tests/002.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest/improper params
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-Phar::mapPhar(5, 5);
-Phar::mapPhar(5, 'hio');
-Phar::mapPhar(5, 'hio', 'hi');
-
-Phar::mapPhar();
-Phar::mapPhar(5);
-__HALT_COMPILER(); ?>
---EXPECTF--
-Warning: Phar::mapPhar() expects at most 1 parameter, 2 given in %s002.php on line %d
-
-Warning: Phar::mapPhar() expects at most 1 parameter, 2 given in %s002.php on line %d
-
-Warning: Phar::mapPhar() expects at most 1 parameter, 3 given in %s002.php on line %d
-
-%satal error: Phar::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
diff --git a/ext/phar/tests/003.phpt b/ext/phar/tests/003.phpt
deleted file mode 100644
index 693bfdccd7..0000000000
--- a/ext/phar/tests/003.phpt
+++ /dev/null
@@ -1,13 +0,0 @@
---TEST--
-Phar::canCompress
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-/* check this works and actually returns the boolean value */
-var_dump(Phar::canCompress() == (
- extension_loaded("zlib") || extension_loaded("bz2")
- ));
-?>
---EXPECT--
-bool(true)
diff --git a/ext/phar/tests/004.phpt b/ext/phar/tests/004.phpt
deleted file mode 100644
index b7e02de1ab..0000000000
--- a/ext/phar/tests/004.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Phar::mapPhar no __HALT_COMPILER();
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-Phar::mapPhar('hio');
-?>
---EXPECTF--
-%satal error: Phar::mapPhar(): __HALT_COMPILER(); must be declared in a phar in %s on line %d
diff --git a/ext/phar/tests/005.phpt b/ext/phar/tests/005.phpt
deleted file mode 100644
index 460df3baec..0000000000
--- a/ext/phar/tests/005.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest (none)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>()
---EXPECTF--
-%satal error: Phar::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
diff --git a/ext/phar/tests/006.phpt b/ext/phar/tests/006.phpt
deleted file mode 100644
index 89535f7045..0000000000
--- a/ext/phar/tests/006.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest (manifest length truncated)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>
---EXPECTF--
-%satal error: Phar::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
diff --git a/ext/phar/tests/007.phpt b/ext/phar/tests/007.phpt
deleted file mode 100644
index 1da7a85de5..0000000000
--- a/ext/phar/tests/007.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Phar::mapPhar manifest too big
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>~~~~
---EXPECTF--
-%satal error: Phar::mapPhar(): manifest cannot be larger than 1 MB in phar "%s" in %s on line %d
diff --git a/ext/phar/tests/008.phpt b/ext/phar/tests/008.phpt
deleted file mode 100644
index ae1837a83d..0000000000
--- a/ext/phar/tests/008.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest (not enough for manifest length)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-$file .= pack('V', 500) . 'notenough';
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-%satal error: Phar::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
diff --git a/ext/phar/tests/009.phpt b/ext/phar/tests/009.phpt
deleted file mode 100644
index 7e3acabf0e..0000000000
--- a/ext/phar/tests/009.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-Phar::mapPhar too many manifest entries
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-$file .= pack('VVnV', 500, 500, 0x0800, 0) . str_repeat('A', 500);
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-%satal error: Phar::mapPhar(): internal corruption of phar "%s009.phar.php" (too many manifest entries for size of manifest) in %s on line %d
diff --git a/ext/phar/tests/010.phpt b/ext/phar/tests/010.phpt
deleted file mode 100644
index f22d364c7f..0000000000
--- a/ext/phar/tests/010.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Phar::mapPhar buffer overrun
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-// this fails because the manifest length does not include the other 10 byte manifest data
-
-$manifest = pack('V', 1) . 'a' . pack('VVVVC', 0, time(), 0, crc32(''), 0);
-$file .= pack('VVnV', strlen($manifest), 1, 0x0800, 3) . 'hio' . $manifest;
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-%satal error: Phar::mapPhar(): internal corruption of phar "%s" (too many manifest entries for size of manifest) in %s on line %d
diff --git a/ext/phar/tests/011.phpt b/ext/phar/tests/011.phpt
deleted file mode 100644
index c88d918708..0000000000
--- a/ext/phar/tests/011.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Phar::mapPhar filesize too small in manifest
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-// compressed file length does not match incompressed lentgh for an uncompressed file
-
-$files = array();
-$files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len+1, crc32($cont), 0);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-%satal error: Phar::mapPhar(): internal corruption of phar "%s" (compressed and uncompressed size does not match for uncompressed entry) in %s on line %d
diff --git a/ext/phar/tests/012.phpt b/ext/phar/tests/012.phpt
deleted file mode 100644
index 83135586dd..0000000000
--- a/ext/phar/tests/012.phpt
+++ /dev/null
@@ -1,33 +0,0 @@
---TEST--
-Phar::mapPhar valid file
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-a \ No newline at end of file
diff --git a/ext/phar/tests/013.phpt b/ext/phar/tests/013.phpt
deleted file mode 100644
index ef966e5b2e..0000000000
--- a/ext/phar/tests/013.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar::mapPhar filesize mismatch
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-// filesize should be 1, and is 2
-
-$files = array();
-$files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont)+1;
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
diff --git a/ext/phar/tests/014.phpt b/ext/phar/tests/014.phpt
deleted file mode 100644
index 51b753106e..0000000000
--- a/ext/phar/tests/014.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar::mapPhar filesize mismatch
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-// wrong crc32
-
-$files = array();
-$files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont.'X'), 0);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line %d \ No newline at end of file
diff --git a/ext/phar/tests/015.phpt b/ext/phar/tests/015.phpt
deleted file mode 100644
index 3e6c673691..0000000000
--- a/ext/phar/tests/015.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar::mapPhar valid file (gzipped)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";
-if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), 3, crc32($cont), 0x01);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= chr(75) . chr(4) . chr(0); // 'a' gzdeflated
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-a \ No newline at end of file
diff --git a/ext/phar/tests/015b.phpt b/ext/phar/tests/015b.phpt
deleted file mode 100755
index 06c0d3065a..0000000000
--- a/ext/phar/tests/015b.phpt
+++ /dev/null
@@ -1,33 +0,0 @@
---TEST--
-Phar::mapPhar valid file (bzip2)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";
-if (!extension_loaded("bz2")) print "skip bz2 not present"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('Hello World', pack('H*', '425a6839314159265359d872012f00000157800010400000400080060490002000220686d420c988c769e8281f8bb9229c28486c39009780'));
-$manifest = '';
-foreach($files as $name => $cont) {
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', strlen($cont[0]), time(), strlen($cont[1]), crc32($cont[0]), 0x02);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont[1];
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-var_dump(file_get_contents('phar://hio/a'));
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(11) "Hello World"
diff --git a/ext/phar/tests/016.phpt b/ext/phar/tests/016.phpt
deleted file mode 100644
index 61d784474f..0000000000
--- a/ext/phar/tests/016.phpt
+++ /dev/null
@@ -1,51 +0,0 @@
---TEST--
-Phar::mapPhar invalid file (gzipped file length is too short)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";
-if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-// file length is too short
-
-$files = array();
-$files['a'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x01);
-$files['b'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x01);
-$files['c'] = array('*', '*', 0x00);
-$files['d'] = array('a', chr(75)/*. chr(4) . chr(0): 'a' gzdeflated */, 0x01);
-$manifest = '';
-foreach($files as $name => $cont) {
- $ulen = strlen($cont[0]);
- $clen = strlen($cont[1]);
- $manifest .= pack('V', strlen($name)) . $name
- . pack('VVVVC', $ulen, time(), $clen, crc32($cont[0]), $cont[2]);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont[1];
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-var_dump(file_get_contents('phar://hio/a'));
-var_dump(file_get_contents('phar://hio/b'));
-var_dump(file_get_contents('phar://hio/c'));
-var_dump(file_get_contents('phar://hio/d'));
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
-bool(false)
-
-Warning: file_get_contents(phar://hio/b): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "b") in %s on line %d
-bool(false)
-string(1) "*"
-
-Warning: file_get_contents(phar://hio/d): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "d") in %s on line %d
-bool(false)
diff --git a/ext/phar/tests/016b.phpt b/ext/phar/tests/016b.phpt
deleted file mode 100755
index da6d10800a..0000000000
--- a/ext/phar/tests/016b.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Phar::mapPhar invalid file (gzipped file length is too short)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";
-if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-// file length is too short
-
-$files = array();
-$files['a'] = 'a';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), 1, crc32($cont), 0x01);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= chr(0) . chr(4) . chr(0); // 'a' gzdeflated
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d \ No newline at end of file
diff --git a/ext/phar/tests/017.phpt b/ext/phar/tests/017.phpt
deleted file mode 100644
index 3f67df4885..0000000000
--- a/ext/phar/tests/017.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar: opendir test - no dir specified at all
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-// file length is too short
-
-$files = array();
-$files['a'] = 'abc';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x01);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$dir = opendir('phar://hio');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory in %s on line %d \ No newline at end of file
diff --git a/ext/phar/tests/018.phpt b/ext/phar/tests/018.phpt
deleted file mode 100644
index 83c733437a..0000000000
--- a/ext/phar/tests/018.phpt
+++ /dev/null
@@ -1,41 +0,0 @@
---TEST--
-Phar: opendir test, root directory
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= chr(0) . chr(4) . chr(0); // 'a' gzdeflated
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$dir = opendir('phar://hio/');
-while (false !== ($a = readdir($dir))) {
- var_dump($a);
- var_dump(is_dir('phar://hio/' . $a));
-}
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(true) \ No newline at end of file
diff --git a/ext/phar/tests/019.phpt b/ext/phar/tests/019.phpt
deleted file mode 100644
index 0e608a2ce8..0000000000
--- a/ext/phar/tests/019.phpt
+++ /dev/null
@@ -1,43 +0,0 @@
---TEST--
-Phar: opendir test, subdirectory
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$files['b/c/d'] = 'c';
-$files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$dir = opendir('phar://hio/b');
-while (false !== ($a = readdir($dir))) {
- var_dump($a);
- var_dump(is_dir('phar://hio/b/' . $a));
-}
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-bool(false)
-string(1) "c"
-bool(true) \ No newline at end of file
diff --git a/ext/phar/tests/019b.phpt b/ext/phar/tests/019b.phpt
deleted file mode 100755
index f7b605f52c..0000000000
--- a/ext/phar/tests/019b.phpt
+++ /dev/null
@@ -1,74 +0,0 @@
---TEST--
-Phar: opendir test, recurse into
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$files['b/c/d'] = 'c';
-$files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-
-function dump($phar, $base)
-{
- var_dump($phar . $base);
- $dir = opendir($phar . $base);
- if ($base == '/')
- {
- $base = '';
- }
- while (false !== ($entry = readdir($dir))) {
- $entry = $base . '/' . $entry;
- var_dump($entry);
- var_dump(is_dir($phar . $entry));
- if (is_dir($phar . $entry))
- {
- dump($phar, $entry);
- }
- }
-}
-
-dump('phar://hio', '/');
-
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(11) "phar://hio/"
-string(2) "/a"
-bool(false)
-string(2) "/b"
-bool(true)
-string(12) "phar://hio/b"
-string(4) "/b/a"
-bool(false)
-string(4) "/b/c"
-bool(true)
-string(14) "phar://hio/b/c"
-string(6) "/b/c/d"
-bool(false)
-string(4) "/bad"
-bool(true)
-string(14) "phar://hio/bad"
-string(6) "/bad/c"
-bool(false)
diff --git a/ext/phar/tests/019c.phpt b/ext/phar/tests/019c.phpt
deleted file mode 100755
index c9f98efdf8..0000000000
--- a/ext/phar/tests/019c.phpt
+++ /dev/null
@@ -1,82 +0,0 @@
---TEST--
-Phar: opendir test, recurse into
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$files['b/c/d'] = 'c';
-$files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-
-function dump($phar, $base)
-{
- var_dump($phar . $base);
- $dir = opendir($phar . $base);
- if ($base == '/')
- {
- $base = '';
- }
- while (false !== ($entry = readdir($dir))) {
- $entry = $base . '/' . $entry;
- var_dump($entry);
- var_dump(is_dir($phar . $entry));
- if (is_dir($phar . $entry))
- {
- dump($phar, $entry);
- }
- else
- {
- var_dump(file_get_contents($phar . $entry));
- }
- }
-}
-
-dump('phar://hio', '/');
-
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(11) "phar://hio/"
-string(2) "/a"
-bool(false)
-string(1) "a"
-string(2) "/b"
-bool(true)
-string(12) "phar://hio/b"
-string(4) "/b/a"
-bool(false)
-string(1) "b"
-string(4) "/b/c"
-bool(true)
-string(14) "phar://hio/b/c"
-string(6) "/b/c/d"
-bool(false)
-string(1) "c"
-string(4) "/bad"
-bool(true)
-string(14) "phar://hio/bad"
-string(6) "/bad/c"
-bool(false)
-string(1) "d"
diff --git a/ext/phar/tests/020.phpt b/ext/phar/tests/020.phpt
deleted file mode 100644
index a9cbbca7b2..0000000000
--- a/ext/phar/tests/020.phpt
+++ /dev/null
@@ -1,143 +0,0 @@
---TEST--
-Phar: url stat
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$files['b/c/d'] = 'c';
-$files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-var_dump(stat('phar://hio/a'), stat('phar://hio/b'));
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-array(26) {
- [0]=>
- int(12)
- [1]=>
- int(2090329158)
- [2]=>
- int(33060)
- [3]=>
- int(1)
- [4]=>
- int(0)
- [5]=>
- int(0)
- [6]=>
- int(-1)
- [7]=>
- int(1)
- [8]=>
- int(%d)
- [9]=>
- int(%d)
- [10]=>
- int(%d)
- [11]=>
- int(-1)
- [12]=>
- int(-1)
- ["dev"]=>
- int(12)
- ["ino"]=>
- int(2090329158)
- ["mode"]=>
- int(33060)
- ["nlink"]=>
- int(1)
- ["uid"]=>
- int(0)
- ["gid"]=>
- int(0)
- ["rdev"]=>
- int(-1)
- ["size"]=>
- int(1)
- ["atime"]=>
- int(%d)
- ["mtime"]=>
- int(%d)
- ["ctime"]=>
- int(%d)
- ["blksize"]=>
- int(-1)
- ["blocks"]=>
- int(-1)
-}
-array(26) {
- [0]=>
- int(12)
- [1]=>
- int(2090329108)
- [2]=>
- int(16676)
- [3]=>
- int(1)
- [4]=>
- int(0)
- [5]=>
- int(0)
- [6]=>
- int(-1)
- [7]=>
- int(0)
- [8]=>
- int(%d)
- [9]=>
- int(%d)
- [10]=>
- int(%d)
- [11]=>
- int(-1)
- [12]=>
- int(-1)
- ["dev"]=>
- int(12)
- ["ino"]=>
- int(2090329108)
- ["mode"]=>
- int(16676)
- ["nlink"]=>
- int(1)
- ["uid"]=>
- int(0)
- ["gid"]=>
- int(0)
- ["rdev"]=>
- int(-1)
- ["size"]=>
- int(0)
- ["atime"]=>
- int(%d)
- ["mtime"]=>
- int(%d)
- ["ctime"]=>
- int(%d)
- ["blksize"]=>
- int(-1)
- ["blocks"]=>
- int(-1)
-} \ No newline at end of file
diff --git a/ext/phar/tests/021.phpt b/ext/phar/tests/021.phpt
deleted file mode 100644
index 810a45a877..0000000000
--- a/ext/phar/tests/021.phpt
+++ /dev/null
@@ -1,91 +0,0 @@
---TEST--
-Phar: stream stat
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$files['b/c/d'] = 'c';
-$files['bad/c'] = 'd';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$fp = fopen('phar://hio/a', 'r');
-var_dump(fstat($fp));
-fclose($fp);
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-array(26) {
- [0]=>
- int(12)
- [1]=>
- int(2090329158)
- [2]=>
- int(33060)
- [3]=>
- int(1)
- [4]=>
- int(0)
- [5]=>
- int(0)
- [6]=>
- int(-1)
- [7]=>
- int(1)
- [8]=>
- int(%d)
- [9]=>
- int(%d)
- [10]=>
- int(%d)
- [11]=>
- int(-1)
- [12]=>
- int(-1)
- ["dev"]=>
- int(12)
- ["ino"]=>
- int(2090329158)
- ["mode"]=>
- int(33060)
- ["nlink"]=>
- int(1)
- ["uid"]=>
- int(0)
- ["gid"]=>
- int(0)
- ["rdev"]=>
- int(-1)
- ["size"]=>
- int(1)
- ["atime"]=>
- int(%d)
- ["mtime"]=>
- int(%d)
- ["ctime"]=>
- int(%d)
- ["blksize"]=>
- int(-1)
- ["blocks"]=>
- int(-1)
-} \ No newline at end of file
diff --git a/ext/phar/tests/022.phpt b/ext/phar/tests/022.phpt
deleted file mode 100644
index 5835640fa3..0000000000
--- a/ext/phar/tests/022.phpt
+++ /dev/null
@@ -1,116 +0,0 @@
---TEST--
-Phar: stream stat
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'abcdefg';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$fp = fopen('phar://hio/a', 'r');
-var_dump(ftell($fp));
-echo 'fseek($fp, 1)';var_dump(fseek($fp, 1));
-var_dump(ftell($fp));
-echo 'fseek($fp, 1, SEEK_CUR)';var_dump(fseek($fp, 1, SEEK_CUR));
-var_dump(ftell($fp));
-echo 'fseek($fp, -1, SEEK_CUR)';var_dump(fseek($fp, -1, SEEK_CUR));
-var_dump(ftell($fp));
-echo 'fseek($fp, -1, SEEK_END)';var_dump(fseek($fp, -1, SEEK_END));
-var_dump(ftell($fp));
-echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
-var_dump(ftell($fp));
-echo 'fseek($fp, -7, SEEK_END)';var_dump(fseek($fp, -7, SEEK_END));
-var_dump(ftell($fp));
-echo 'fseek($fp, 0, SEEK_END)';var_dump(fseek($fp, 0, SEEK_END));
-var_dump(ftell($fp));
-echo 'fseek($fp, 1, SEEK_END)';var_dump(fseek($fp, 1, SEEK_END));
-var_dump(ftell($fp));
-echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
-var_dump(ftell($fp));
-echo 'fseek($fp, 6)';var_dump(fseek($fp, 6));
-var_dump(ftell($fp));
-echo 'fseek($fp, 8)';var_dump(fseek($fp, 8));
-var_dump(ftell($fp));
-echo 'fseek($fp, -1)';var_dump(fseek($fp, -1));
-var_dump(ftell($fp));
-echo "next\n";
-fseek($fp, 4);
-var_dump(ftell($fp));
-echo 'fseek($fp, -5, SEEK_CUR)';var_dump(fseek($fp, -5, SEEK_CUR));
-var_dump(ftell($fp));
-fseek($fp, 4);
-var_dump(ftell($fp));
-echo 'fseek($fp, 5, SEEK_CUR)';var_dump(fseek($fp, 5, SEEK_CUR));
-var_dump(ftell($fp));
-fseek($fp, 4);
-var_dump(ftell($fp));
-echo 'fseek($fp, -4, SEEK_CUR)';var_dump(fseek($fp, -4, SEEK_CUR));
-var_dump(ftell($fp));
-fseek($fp, 4);
-var_dump(ftell($fp));
-echo 'fseek($fp, 3, SEEK_CUR)';var_dump(fseek($fp, 3, SEEK_CUR));
-var_dump(ftell($fp));
-fclose($fp);
-?>
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-exit(0);
- ?>
---EXPECT--
-int(0)
-fseek($fp, 1)int(0)
-int(1)
-fseek($fp, 1, SEEK_CUR)int(0)
-int(2)
-fseek($fp, -1, SEEK_CUR)int(0)
-int(1)
-fseek($fp, -1, SEEK_END)int(0)
-int(6)
-fseek($fp, -8, SEEK_END)int(-1)
-bool(false)
-fseek($fp, -7, SEEK_END)int(0)
-int(0)
-fseek($fp, 0, SEEK_END)int(0)
-int(7)
-fseek($fp, 1, SEEK_END)int(-1)
-bool(false)
-fseek($fp, -8, SEEK_END)int(-1)
-bool(false)
-fseek($fp, 6)int(0)
-int(6)
-fseek($fp, 8)int(-1)
-bool(false)
-fseek($fp, -1)int(-1)
-bool(false)
-next
-int(4)
-fseek($fp, -5, SEEK_CUR)int(-1)
-bool(false)
-int(4)
-fseek($fp, 5, SEEK_CUR)int(-1)
-bool(false)
-int(4)
-fseek($fp, -4, SEEK_CUR)int(0)
-int(0)
-int(4)
-fseek($fp, 3, SEEK_CUR)int(0)
-int(7)
diff --git a/ext/phar/tests/023.phpt b/ext/phar/tests/023.phpt
deleted file mode 100755
index 6104c8719d..0000000000
--- a/ext/phar/tests/023.phpt
+++ /dev/null
@@ -1,40 +0,0 @@
---TEST--
-Phar: phar:// file_get_contents
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php'));
-var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php'));
-var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php'));
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(28) "<?php echo "This is a\n"; ?>"
-string(28) "<?php echo "This is b\n"; ?>"
-string(30) "<?php echo "This is b/c\n"; ?>"
-===DONE===
diff --git a/ext/phar/tests/024.phpt b/ext/phar/tests/024.phpt
deleted file mode 100755
index 243e70c6c8..0000000000
--- a/ext/phar/tests/024.phpt
+++ /dev/null
@@ -1,40 +0,0 @@
---TEST--
-Phar: phar:// include
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-This is a
-This is b
-This is b/c
-===DONE===
diff --git a/ext/phar/tests/025.phpt b/ext/phar/tests/025.phpt
deleted file mode 100755
index bf66256bdc..0000000000
--- a/ext/phar/tests/025.phpt
+++ /dev/null
@@ -1,40 +0,0 @@
---TEST--
-Phar: phar:// include (repeated names)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = '<?php echo "This is a\n"; ?>';
-$files['b'] = '<?php echo "This is b\n"; ?>';
-$files['b/b'] = '<?php echo "This is b/b\n"; ?>';
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/b';
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-This is a
-This is b
-This is b/b
-===DONE===
diff --git a/ext/phar/tests/026.phpt b/ext/phar/tests/026.phpt
deleted file mode 100755
index 9737c5f1fd..0000000000
--- a/ext/phar/tests/026.phpt
+++ /dev/null
@@ -1,45 +0,0 @@
---TEST--
-Phar: phar:// require from within
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; require "'.$pname.'/b.php"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; require "'.$pname.'/b/c.php"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; require "'.$pname.'/b/d.php"; ?>';
-$files['b/d.php'] = '<?php echo "This is b/d\n"; require "'.$pname.'/e.php"; ?>';
-$files['e.php'] = '<?php echo "This is e\n"; ?>';
-
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents($fname, $file);
-
-require $pname . '/a.php';
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-This is a
-This is b
-This is b/c
-This is b/d
-This is e
-===DONE===
diff --git a/ext/phar/tests/027.phpt b/ext/phar/tests/027.phpt
deleted file mode 100755
index 4322630b42..0000000000
--- a/ext/phar/tests/027.phpt
+++ /dev/null
@@ -1,73 +0,0 @@
---TEST--
-Phar: phar:// opendir
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; require "'.$pname.'/b.php"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; require "'.$pname.'/b/c.php"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; require "'.$pname.'/b/d.php"; ?>';
-$files['b/d.php'] = '<?php echo "This is b/d\n"; require "'.$pname.'/e.php"; ?>';
-$files['e.php'] = '<?php echo "This is e\n"; ?>';
-
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'hio';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents($fname, $file);
-
-function dump($phar, $base)
-{
- var_dump(str_replace(dirname(__FILE__), '*', $phar) . $base);
- $dir = opendir($phar . $base);
- if ($base == '/')
- {
- $base = '';
- }
- while (false !== ($entry = readdir($dir))) {
- $entry = $base . '/' . $entry;
- var_dump($entry);
- var_dump(is_dir($phar . $entry));
- if (is_dir($phar . $entry))
- {
- dump($phar, $entry);
- }
- }
-}
-
-dump($pname, '/');
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-string(%d) "phar://*/027.phar.php/"
-string(6) "/a.php"
-bool(false)
-string(2) "/b"
-bool(true)
-string(%d) "phar://*/027.phar.php/b"
-string(8) "/b/c.php"
-bool(false)
-string(8) "/b/d.php"
-bool(false)
-string(6) "/b.php"
-bool(false)
-string(6) "/e.php"
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/028.phpt b/ext/phar/tests/028.phpt
deleted file mode 100755
index 331ad4a240..0000000000
--- a/ext/phar/tests/028.phpt
+++ /dev/null
@@ -1,57 +0,0 @@
---TEST--
-Phar::loadPhar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://test';
-$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; include "'.$pname.'/b/c.php"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?>';
-$files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';
-$files['e.php'] = '<?php echo "This is e\n"; ?>';
-
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents($fname, $file);
-
-Phar::loadPhar($fname, 'test');
-
-include $fname;
-
-echo "======\n";
-
-include $pname . '/a.php';
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-This is a
-This is b
-This is b/c
-This is b/d
-This is e
-======
-This is a
-This is b
-This is b/c
-This is b/d
-This is e
-===DONE===
diff --git a/ext/phar/tests/029.phpt b/ext/phar/tests/029.phpt
deleted file mode 100755
index 1bc9dcda35..0000000000
--- a/ext/phar/tests/029.phpt
+++ /dev/null
@@ -1,50 +0,0 @@
---TEST--
-Phar::loadPhar overloading alias names
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$fname1 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
-$pname = 'phar://test';
-$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; include "'.$pname.'/b/c.php"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?>';
-$files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';
-$files['e.php'] = '<?php echo "This is e\n"; ?>';
-
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = '';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents($fname1, $file);
-file_put_contents($fname2, $file);
-
-var_dump(Phar::loadPhar($fname1, 'test'));
-var_dump(Phar::loadPhar($fname1, 'copy'));
-var_dump(Phar::loadPhar($fname2, 'copy'));
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar.php');
-?>
---EXPECTF--
-bool(true)
-bool(true)
-
-%satal error: Phar::loadPhar(): alias "copy" is already used for archive "%s029.1.phar.php" cannot be overloaded with "%s029.2.phar.php" in %s029.php on line %d
diff --git a/ext/phar/tests/030.phpt b/ext/phar/tests/030.phpt
deleted file mode 100755
index 0ad1209193..0000000000
--- a/ext/phar/tests/030.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-Phar::loadPhar ignoring alias
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; include "'.$pname.'/b/c.php"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; include "'.$pname.'/b/d.php"; ?>';
-$files['b/d.php'] = '<?php echo "This is b/d\n"; include "'.$pname.'/e.php"; ?>';
-$files['e.php'] = '<?php echo "This is e\n"; ?>';
-
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
-}
-$alias = 'alias';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents($fname, $file);
-
-Phar::loadPhar($fname);
-
-require $pname . '/a.php';
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-This is a
-This is b
-This is b/c
-This is b/d
-This is e
-===DONE===
diff --git a/ext/phar/tests/031.phpt b/ext/phar/tests/031.phpt
deleted file mode 100755
index 8f14563125..0000000000
--- a/ext/phar/tests/031.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Phar include and parser error
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-$pharconfig = 3;
-
-require_once 'phar_oo_test.inc';
-
-Phar::loadPhar($fname);
-
-$pname = 'phar://' . $fname . '/a.php';
-
-var_dump(file_get_contents($pname));
-require $pname;
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-string(25) "<?php echo new new class;"
-
-Parse error: syntax error, unexpected T_NEW, expecting T_STRING or T_VARIABLE or '$' in phar://%sphar_oo_test.phar.php/a.php on line %d
diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt
deleted file mode 100755
index 8240969a2b..0000000000
--- a/ext/phar/tests/phar_oo_001.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Phar object: basics
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-var_dump($phar->getVersion());
-var_dump(count($phar));
-
-class MyPhar extends Phar
-{
- function __construct()
- {
- }
-}
-
-try
-{
- $phar = new MyPhar();
- var_dump($phar->getVersion());
-}
-catch (BadMethodCallException $e)
-{
- var_dump($e->getMessage());
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-string(5) "0.8.0"
-int(5)
-string(49) "Cannot call method on an uninitialzed Phar object"
-===DONE===
diff --git a/ext/phar/tests/phar_oo_002.phpt b/ext/phar/tests/phar_oo_002.phpt
deleted file mode 100755
index f937f4b9e2..0000000000
--- a/ext/phar/tests/phar_oo_002.phpt
+++ /dev/null
@@ -1,133 +0,0 @@
---TEST--
-Phar object: iterator & entries
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass('SplFileInfo');
-foreach($phar as $name => $ent)
-{
- var_dump(str_replace(dirname(__FILE__), '*', $name));
- var_dump($ent->getFilename());
- var_dump($ent->getSize());
- var_dump($ent->getType());
- var_dump($ent->isWritable());
- var_dump($ent->isReadable());
- var_dump($ent->isExecutable());
- var_dump($ent->isFile());
- var_dump($ent->isDir());
- var_dump($ent->isLink());
- var_dump($ent->getCTime());
- var_dump($ent->getMTime());
- var_dump($ent->getATime());
-}
-
-echo "==RECURSIVE==\n";
-
-$phar = new Phar($fname);
-foreach(new RecursiveIteratorIterator($phar) as $name => $ent)
-{
- var_dump(str_replace(dirname(__FILE__), '*', $name));
- var_dump($ent->getFilename());
- var_dump($ent->getCompressedSize());
- var_dump($ent->isCRCChecked());
- var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL);
- var_dump($ent->getPharFlags());
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-string(36) "phar://*/phar_oo_test.phar.php/a.php"
-string(5) "a.php"
-int(32)
-string(4) "file"
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(false)
-int(1141214400)
-int(1141214400)
-int(1141214400)
-string(32) "phar://*/phar_oo_test.phar.php/b"
-string(1) "b"
-int(0)
-string(3) "dir"
-bool(false)
-bool(true)
-bool(false)
-bool(false)
-bool(true)
-bool(false)
-int(1141214400)
-int(1141214400)
-int(1141214400)
-string(36) "phar://*/phar_oo_test.phar.php/b.php"
-string(5) "b.php"
-int(32)
-string(4) "file"
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(false)
-int(1141214400)
-int(1141214400)
-int(1141214400)
-string(36) "phar://*/phar_oo_test.phar.php/e.php"
-string(5) "e.php"
-int(32)
-string(4) "file"
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(false)
-int(1141214400)
-int(1141214400)
-int(1141214400)
-==RECURSIVE==
-string(36) "phar://*/phar_oo_test.phar.php/a.php"
-string(5) "a.php"
-int(32)
-bool(false)
-NULL
-int(0)
-string(38) "phar://*/phar_oo_test.phar.php/b/c.php"
-string(5) "c.php"
-int(34)
-bool(false)
-NULL
-int(0)
-string(38) "phar://*/phar_oo_test.phar.php/b/d.php"
-string(5) "d.php"
-int(34)
-bool(false)
-NULL
-int(0)
-string(36) "phar://*/phar_oo_test.phar.php/b.php"
-string(5) "b.php"
-int(32)
-bool(false)
-NULL
-int(0)
-string(36) "phar://*/phar_oo_test.phar.php/e.php"
-string(5) "e.php"
-int(32)
-bool(false)
-NULL
-int(0)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_003.phpt b/ext/phar/tests/phar_oo_003.phpt
deleted file mode 100755
index 838d599a0f..0000000000
--- a/ext/phar/tests/phar_oo_003.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Phar object: entry & openFile()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass();
-foreach($phar as $name => $ent)
-{
- var_dump($ent->getFilename());
- if ($ent->isDir()) {
- var_dump('DIR');
- } else {
- var_dump($ent->openFile()->fgets());
- include $ent->getPathName();
- }
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-string(5) "a.php"
-string(32) "<?php echo "This is a.php\n"; ?>"
-This is a.php
-string(1) "b"
-string(3) "DIR"
-string(5) "b.php"
-string(32) "<?php echo "This is b.php\n"; ?>"
-This is b.php
-string(5) "e.php"
-string(32) "<?php echo "This is e.php\n"; ?>"
-This is e.php
-===DONE===
diff --git a/ext/phar/tests/phar_oo_004.phpt b/ext/phar/tests/phar_oo_004.phpt
deleted file mode 100755
index 561ff5f093..0000000000
--- a/ext/phar/tests/phar_oo_004.phpt
+++ /dev/null
@@ -1,123 +0,0 @@
---TEST--
-Phar and DirectoryIteraotr
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-$it = new DirectoryIterator('phar://'.$fname);
-
-foreach($it as $name => $ent)
-{
- var_dump($name);
- var_dump($ent->getFilename());
- var_dump($ent->isDir());
- var_dump($ent->isDot());
-}
-
-?>
-===MANUAL===
-<?php
-
-class MyDirectoryIterator extends DirectoryIterator
-{
- function __construct($dir)
- {
- echo __METHOD__ . "\n";
- parent::__construct($dir);
- }
-
- function rewind()
- {
- echo __METHOD__ . "\n";
- parent::rewind();
- }
-
- function valid()
- {
- echo __METHOD__ . "\n";
- return parent::valid();
- }
-
- function key()
- {
- echo __METHOD__ . "\n";
- return parent::key();
- }
-
- function current()
- {
- echo __METHOD__ . "\n";
- return parent::current();
- }
-
- function next()
- {
- echo __METHOD__ . "\n";
- parent::next();
- }
-}
-
-$it = new MyDirectoryIterator('phar://'.$fname);
-
-foreach($it as $name => $ent)
-{
- var_dump($name);
- var_dump($ent->getFilename());
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-int(0)
-string(5) "a.php"
-bool(false)
-bool(false)
-int(1)
-string(1) "b"
-bool(true)
-bool(false)
-int(2)
-string(5) "b.php"
-bool(false)
-bool(false)
-int(3)
-string(5) "e.php"
-bool(false)
-bool(false)
-===MANUAL===
-MyDirectoryIterator::__construct
-MyDirectoryIterator::rewind
-MyDirectoryIterator::valid
-MyDirectoryIterator::current
-MyDirectoryIterator::key
-int(0)
-string(5) "a.php"
-MyDirectoryIterator::next
-MyDirectoryIterator::valid
-MyDirectoryIterator::current
-MyDirectoryIterator::key
-int(1)
-string(1) "b"
-MyDirectoryIterator::next
-MyDirectoryIterator::valid
-MyDirectoryIterator::current
-MyDirectoryIterator::key
-int(2)
-string(5) "b.php"
-MyDirectoryIterator::next
-MyDirectoryIterator::valid
-MyDirectoryIterator::current
-MyDirectoryIterator::key
-int(3)
-string(5) "e.php"
-MyDirectoryIterator::next
-MyDirectoryIterator::valid
-===DONE===
diff --git a/ext/phar/tests/phar_oo_005.phpt b/ext/phar/tests/phar_oo_005.phpt
deleted file mode 100755
index 167bee73ad..0000000000
--- a/ext/phar/tests/phar_oo_005.phpt
+++ /dev/null
@@ -1,56 +0,0 @@
---TEST--
-Phar and RecursiveDirectoryIterator
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-$it = new RecursiveDirectoryIterator('phar://'.$fname);
-$it = new RecursiveIteratorIterator($it);
-
-foreach($it as $name => $ent)
-{
- var_dump(str_replace($fname, '*', $name));
- var_dump(str_replace($fname, '*', $ent->getPathname()));
- var_dump($it->getSubPath());
- var_dump($it->getSubPathName());
- $sub = $it->getPathInfo();
- var_dump($sub->getFilename());
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-string(14) "phar://*/a.php"
-string(14) "phar://*/a.php"
-string(0) ""
-string(5) "a.php"
-string(21) "phar_oo_test.phar.php"
-string(16) "phar://*/b/c.php"
-string(16) "phar://*/b/c.php"
-string(1) "b"
-string(7) "b/c.php"
-string(1) "b"
-string(16) "phar://*/b/d.php"
-string(16) "phar://*/b/d.php"
-string(1) "b"
-string(7) "b/d.php"
-string(1) "b"
-string(14) "phar://*/b.php"
-string(14) "phar://*/b.php"
-string(0) ""
-string(5) "b.php"
-string(21) "phar_oo_test.phar.php"
-string(14) "phar://*/e.php"
-string(14) "phar://*/e.php"
-string(0) ""
-string(5) "e.php"
-string(21) "phar_oo_test.phar.php"
-===DONE===
diff --git a/ext/phar/tests/phar_oo_006.phpt b/ext/phar/tests/phar_oo_006.phpt
deleted file mode 100755
index 6940c3baa6..0000000000
--- a/ext/phar/tests/phar_oo_006.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-Phar object: array access
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-class MyFile extends SplFileObject
-{
- function __construct($what)
- {
- echo __METHOD__ . "($what)\n";
- parent::__construct($what);
- }
-}
-
-$phar = new Phar($fname);
-try
-{
- $phar->setFileClass('SplFileInfo');
-}
-catch (UnexpectedValueException $e)
-{
- echo $e->getMessage() . "\n";
-}
-$phar->setFileClass('MyFile');
-
-echo $phar['a.php']->getFilename() . "\n";
-echo $phar['b/c.php']->getFilename() . "\n";
-echo $phar['b.php']->getFilename() . "\n";
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-SplFileInfo::setFileClass() expects parameter 1 to be a class name derived from SplFileObject, 'SplFileInfo' given
-MyFile::__construct(phar://%s/a.php)
-phar://%s/a.php
-MyFile::__construct(phar://%s/b/c.php)
-phar://%s/b/c.php
-MyFile::__construct(phar://%s/b.php)
-phar://%s/b.php
-===DONE===
diff --git a/ext/phar/tests/phar_oo_007.phpt b/ext/phar/tests/phar_oo_007.phpt
deleted file mode 100755
index 6a2565220a..0000000000
--- a/ext/phar/tests/phar_oo_007.phpt
+++ /dev/null
@@ -1,84 +0,0 @@
---TEST--
-Phar object: access through SplFileObject
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-require_once 'phar_oo_test.inc';
-
-class MyFile extends SplFileObject
-{
- function __construct($name)
- {
- echo __METHOD__ . "(" . str_replace(dirname(__FILE__), '*', $name) . ")\n";
- parent::__construct($name);
- }
-}
-
-$phar = new Phar($fname);
-$phar->setFileClass('MyFile');
-
-$f = $phar['a.php'];
-
-$s = $f->fstat();
-
-var_dump($s['atime']);
-var_dump($s['ctime']);
-var_dump($s['mtime']);
-
-var_dump($f->ftell());
-var_dump($f->eof());
-var_dump($f->fgets());
-var_dump($f->eof());
-var_dump($f->fseek(20));
-var_dump($f->ftell());
-var_dump($f->fgets());
-var_dump($f->rewind());
-var_dump($f->ftell());
-var_dump($f->fgets());
-var_dump($f->ftell());
-
-?>
-===AGAIN===
-<?php
-
-$f = $phar['a.php'];
-
-var_dump($f->ftell());
-var_dump($f->eof());
-var_dump($f->fgets());
-var_dump($f->eof());
-
-//unset($f); without unset we check for working refcounting
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-MyFile::__construct(phar://*/phar_oo_test.phar.php/a.php)
-int(1141214400)
-int(1141214400)
-int(1141214400)
-int(0)
-bool(false)
-string(32) "<?php echo "This is a.php\n"; ?>"
-bool(true)
-int(0)
-int(20)
-string(12) "a.php\n"; ?>"
-NULL
-int(0)
-string(32) "<?php echo "This is a.php\n"; ?>"
-int(32)
-===AGAIN===
-MyFile::__construct(phar://*/phar_oo_test.phar.php/a.php)
-int(0)
-bool(false)
-string(32) "<?php echo "This is a.php\n"; ?>"
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_008.phpt b/ext/phar/tests/phar_oo_008.phpt
deleted file mode 100755
index 8746912e91..0000000000
--- a/ext/phar/tests/phar_oo_008.phpt
+++ /dev/null
@@ -1,94 +0,0 @@
---TEST--
-Phar object: iterating via SplFileObject
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-
-$pharconfig = 1;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setFileClass('SplFileObject');
-
-$f = $phar['a.csv'];
-foreach($f as $k => $v)
-{
- echo "$k=>$v\n";
-}
-
-$f->setFlags(SplFileObject::DROP_NEW_LINE);
-
-foreach($f as $k => $v)
-{
- echo "$k=>$v\n";
-}
-
-class MyCSVFile extends SplFileObject
-{
- function current()
- {
- return parent::fgetcsv(',', '"');
- }
-}
-
-$phar->setFileClass('MyCSVFile');
-$v = $phar['a.csv'];
-
-while(!$v->eof())
-{
- echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n";
-}
-
-foreach($v as $k => $d)
-{
- echo "$k=>" . join('|',$d) . "\n";
-}
-
-class MyCSVFile2 extends SplFileObject
-{
- function getCurrentLine()
- {
- echo __METHOD__ . "\n";
- return parent::fgetcsv(',', '"');
- }
-}
-
-$phar->setFileClass('MyCSVFile2');
-$v = $phar['a.csv'];
-
-foreach($v as $k => $d)
-{
- echo "$k=>" . join('|',$d) . "\n";
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-0=>1,2,3
-
-1=>2,a,b
-
-2=>3,"c","'e'"
-0=>1,2,3
-1=>2,a,b
-2=>3,"c","'e'"
-0=>1|2|3
-1=>2|a|b
-2=>3|c|'e'
-1=>1|2|3
-3=>2|a|b
-5=>3|c|'e'
-MyCSVFile2::getCurrentLine
-1=>1|2|3
-MyCSVFile2::getCurrentLine
-3=>2|a|b
-MyCSVFile2::getCurrentLine
-5=>3|c|'e'
-===DONE===
diff --git a/ext/phar/tests/phar_oo_009.phpt b/ext/phar/tests/phar_oo_009.phpt
deleted file mode 100755
index 75ab947a33..0000000000
--- a/ext/phar/tests/phar_oo_009.phpt
+++ /dev/null
@@ -1,54 +0,0 @@
---TEST--
-Phar object: iterating via SplFileObject and reading csv
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!defined('SplFileObject::READ_CSV') || !defined('SplFileObject::SKIP_EMPTY')) die('skip newer SPL version is required'); ?>
---FILE--
-<?php
-
-$pharconfig = 2;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setFileClass('SplFileObject');
-
-$f = $phar['a.csv'];
-$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
-foreach($f as $k => $v)
-{
- echo "$k=>$v\n";
-}
-
-?>
-===CSV===
-<?php
-
-$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV);
-foreach($f as $k => $v)
-{
- echo "$k=>" . join('|', $v) . "\n";
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-0=>1,2,3
-1=>2,a,b
-2=>3,"c","'e'"
-3=>4
-4=>5,5
-5=>7,777
-===CSV===
-0=>1|2|3
-1=>2|a|b
-2=>3|c|'e'
-3=>4
-4=>5|5
-5=>7|777
-===DONE===
diff --git a/ext/phar/tests/phar_oo_010.phpt b/ext/phar/tests/phar_oo_010.phpt
deleted file mode 100755
index f1ace6a365..0000000000
--- a/ext/phar/tests/phar_oo_010.phpt
+++ /dev/null
@@ -1,52 +0,0 @@
---TEST--
-Phar object: ArrayAccess and isset
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
---FILE--
-<?php
-
-$pharconfig = 0;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(isset($phar['a.php']));
-var_dump(isset($phar['b.php']));
-var_dump(isset($phar['b/c.php']));
-var_dump(isset($phar['b/d.php']));
-var_dump(isset($phar['e.php']));
-
-?>
-===DIR===
-<?php
-var_dump(isset($phar['b']));
-?>
-===NA===
-<?php
-var_dump(isset($phar['a']));
-var_dump(isset($phar['b/c']));
-var_dump(isset($phar[12]));
-var_dump(isset($phar['b']));
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-===DIR===
-bool(false)
-===NA===
-bool(false)
-bool(false)
-bool(false)
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_test.inc b/ext/phar/tests/phar_oo_test.inc
deleted file mode 100755
index 164264f556..0000000000
--- a/ext/phar/tests/phar_oo_test.inc
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-ini_set('date.timezone', 'GMT');
-
-$fname = dirname(__FILE__) . '/phar_oo_test.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
-
-$files = array();
-
-if (!isset($pharconfig)) $pharconfig = 0;
-
-switch($pharconfig)
-{
- default:
- case 0:
- $files['a.php'] = '<?php echo "This is a.php\n"; ?>';
- $files['b.php'] = '<?php echo "This is b.php\n"; ?>';
- $files['b/c.php'] = '<?php echo "This is b/c.php\n"; ?>';
- $files['b/d.php'] = '<?php echo "This is b/d.php\n"; ?>';
- $files['e.php'] = '<?php echo "This is e.php\n"; ?>';
- break;
- case 1:
- $files['a.csv'] =<<<EOF
-1,2,3
-2,a,b
-3,"c","'e'"
-EOF;
- break;
- case 2:
- $files['a.csv'] =<<<EOF
-1,2,3
-2,a,b
-3,"c","'e'"
-4
-5,5
-
-7,777
-EOF;
- break;
- case 3:
- $files['a.php'] = '<?php echo new new class;';
- break;
-}
-
-$manifest = '';
-foreach($files as $name => $cont) {
- $len = strlen($cont);
- $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, mktime (12, 0, 0, 3, 1, 2006), $len, crc32($cont), 0x00);
-}
-$alias = 'alias';
-$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
-$file .= pack('V', strlen($manifest)) . $manifest;
-foreach($files as $cont)
-{
- $file .= $cont;
-}
-
-file_put_contents($fname, $file);
-
-?> \ No newline at end of file
diff --git a/main/php_realpath.c b/main/php_realpath.c
deleted file mode 100644
index 0607e91cc4..0000000000
--- a/main/php_realpath.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sander Steffann (sander@steffann.nl) |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h"
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-
-#ifndef MAXSYMLINKS
-#define MAXSYMLINKS 32
-#endif
-
-#ifndef S_ISDIR
-#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
-#endif
-
-char *php_realpath(char *path, char resolved_path[]);
-
-#ifdef PHP_WIN32
-#define IS_SLASH(p) ((p) == '/' || (p) == '\\')
-#else
-#define IS_SLASH(p) ((p) == '/')
-#endif
-
-char *php_realpath(char *path, char resolved_path []) {
- char path_construction[MAXPATHLEN]; /* We build the result in here */
- char *writepos; /* Position to write next char */
-
- char path_copy[MAXPATHLEN]; /* A work-copy of the path */
- char *workpos; /* working position in *path */
-
-#if !defined(PHP_WIN32)
- char buf[MAXPATHLEN]; /* Buffer for readlink */
- int linklength; /* The result from readlink */
-#endif
- int linkcount = 0; /* Count symlinks to avoid loops */
-
- struct stat filestat; /* result from stat */
-
-#ifdef PHP_WIN32
- char *temppos; /* position while counting '.' */
- int dotcount; /* number of '.' */
- int t; /* counter */
-#endif
-
- /* Set the work-position to the beginning of the given path */
- strcpy(path_copy, path);
- workpos = path_copy;
-
-#ifdef PHP_WIN32
- /* Find out where we start - Windows version */
- if (IS_SLASH(*workpos)) {
- /* We start at the root of the current drive */
- /* Get the current directory */
- if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
- /* Unable to get cwd */
- resolved_path[0] = 0;
- return NULL;
- }
- /* We only need the first three chars (for example "C:\") */
- path_construction[3] = 0;
- workpos++;
- } else if (workpos[1] == ':') {
- /* A drive-letter is specified, copy it */
- strncpy(path_construction, path, 2);
- strcat(path_construction, "\\");
- workpos++;
- workpos++;
- } else {
- /* Use the current directory */
- if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
- /* Unable to get cwd */
- resolved_path[0] = 0;
- return NULL;
- }
- strcat(path_construction, "\\");
- }
-#else
- /* Find out where we start - Unix version */
- if (*workpos == '/') {
- /* We start at the root */
- strcpy(path_construction, "/");
- workpos++;
- } else {
- /* Use the current directory */
- if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) {
- /* Unable to get cwd */
- resolved_path[0] = 0;
- return NULL;
- }
- strcat(path_construction, "/");
- }
-#endif
-
- /* Set the next-char-position */
- writepos = &path_construction[strlen(path_construction)];
-
- /* Go to the end, then stop */
- while(*workpos != 0) {
- /* Strip (back)slashes */
- while(IS_SLASH(*workpos)) workpos++;
-
-#ifdef PHP_WIN32
- /* reset dotcount */
- dotcount = 0;
-
- /* Look for .. */
- if ((workpos[0] == '.') && (workpos[1] != 0)) {
- /* Windows accepts \...\ as \..\..\, \....\ as \..\..\..\, etc */
- /* At least Win98 does */
-
- temppos = workpos;
- while(*temppos++ == '.') {
- dotcount++;
- if (!IS_SLASH(*temppos) && (*temppos != 0) && (*temppos != '.')) {
- /* This is not a /../ component, but a filename that starts with '.' */
- dotcount = 0;
- }
- }
-
- /* Go back dotcount-1 times */
- for (t=0 ; t<(dotcount-1) ; t++) {
- workpos++; /* move to next '.' */
-
- /* Can we still go back? */
- if ((writepos-3) <= path_construction) return NULL;
-
- /* Go back */
- writepos--; /* move to '\' */
- writepos--;
- while(!IS_SLASH(*writepos)) writepos--; /* skip until previous '\\' */
- }
- workpos++;
- }
-
- /* No special case */
- if (dotcount == 0) {
- /* Append */
- while(!IS_SLASH(*workpos) && (*workpos != 0)) {
- *writepos++ = *workpos++;
- }
- }
-
- /* Just one '.', go to next element */
- if (dotcount == 1) {
- while(!IS_SLASH(*workpos) && (*workpos != 0)) {
- *workpos++;
- }
-
- /* Avoid double \ in the result */
- writepos--;
- }
-
- /* If it was a directory, append a slash */
- if (IS_SLASH(*workpos)) {
- *writepos++ = *workpos++;
- }
- *writepos = 0;
-#else /* defined(PHP_WIN32) */
- /* Look for .. */
- if ((workpos[0] == '.') && (workpos[1] != 0)) {
- if ((workpos[1] == '.') && ((workpos[2] == '/') || (workpos[2] == 0))) {
- /* One directory back */
- /* Set pointers to right position */
- workpos++; /* move to second '.' */
- workpos++; /* move to '/' */
-
- /* Only apply .. if not in root */
- if ((writepos-1) > path_construction) {
- writepos--; /* move to '/' */
- while(*--writepos != '/') ; /* skip until previous '/' */
- }
- } else {
- if (workpos[1] == '/') {
- /* Found a /./ skip it */
- workpos++; /* move to '/' */
-
- /* Avoid double / in the result */
- writepos--;
- } else {
- /* No special case, the name just started with a . */
- /* Append */
- while((*workpos != '/') && (*workpos != 0)) {
- *writepos++ = *workpos++;
- }
- }
- }
- } else {
- /* No special case */
- /* Append */
- while((*workpos != '/') && (*workpos != 0)) {
- *writepos++ = *workpos++;
- }
- }
-
-#if HAVE_SYMLINK
- /* We are going to use path_construction, so close it */
- *writepos = 0;
-
- /* Check the current location to see if it is a symlink */
- if((linklength = readlink(path_construction, buf, MAXPATHLEN)) != -1) {
- /* Check linkcount */
- if (linkcount > MAXSYMLINKS) return NULL;
-
- /* Count this symlink */
- linkcount++;
-
- /* Set end of buf */
- buf[linklength] = 0;
-
- /* Check for overflow */
- if ((strlen(workpos) + strlen(buf) + 1) >= MAXPATHLEN) return NULL;
-
- /* Remove the symlink-component wrom path_construction */
- writepos--; /* move to '/' */
- while(*--writepos != '/') ; /* skip until previous '/' */
- *++writepos = 0; /* end of string after '/' */
-
- /* If the symlink starts with a '/', empty path_construction */
- if (*buf == '/') {
- *path_construction = 0;
- writepos = path_construction;
- }
-
- /* Insert symlink into path_copy */
- strcat(buf, workpos);
- strcpy(path_copy, buf);
- workpos = path_copy;
- }
-#endif /* HAVE_SYMLINK */
-
- /* If it was a directory, append a slash */
- if (*workpos == '/') {
- *writepos++ = *workpos++;
- }
- *writepos = 0;
-#endif /* defined(PHP_WIN32) */
- }
-
- /* Check if the resolved path is a directory */
- if (V_STAT(path_construction, &filestat) != 0) {
- if (errno != ENOENT) return NULL;
- } else {
- if (S_ISDIR(filestat.st_mode)) {
- /* It's a directory, append a / if needed */
- if (*(writepos-1) != '/') {
- /* Check for overflow */
- if ((strlen(workpos) + 2) >= MAXPATHLEN) {
- return NULL;
- }
- *writepos++ = '/';
- *writepos = 0;
- }
- }
- }
-
- strcpy(resolved_path, path_construction);
- return resolved_path;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/sapi/litespeed/Makefile.frag b/sapi/litespeed/Makefile.frag
deleted file mode 100644
index e1af2b90ca..0000000000
--- a/sapi/litespeed/Makefile.frag
+++ /dev/null
@@ -1,3 +0,0 @@
-$(SAPI_LITESPEED_PATH): $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
- $(BUILD_LITESPEED)
-
diff --git a/sapi/litespeed/README b/sapi/litespeed/README
deleted file mode 100644
index bd57f1f315..0000000000
--- a/sapi/litespeed/README
+++ /dev/null
@@ -1,118 +0,0 @@
-Introduction
-============
-
-LiteSpeed SAPI module is a dedicated interface for PHP integration with
-LiteSpeed Web Server. LiteSpeed SAPI has similar architecture to the
-FastCGI SAPI with two major enhancements: better performance and
-support for dynamic PHP configuration changes through web server
-configuration and .htaccess files.
-
-Our simple benchmark test ("hello world") shows that PHP with
-LiteSpeed SAPI has 30% better performance over PHP with FastCGI SAPI,
-which is nearly twice the performance that Apache mod_php can deliver.
-
-A major drawback of FastCGI PHP comparing to mod_php is that "php.ini"
-is the only way to set PHP configuration, and cannot be changed at
-runtime via configuration files like .htaccess files or web server's
-virtual host configuration. As FastCGI PHP is usually shared at server
-level by all virtual hosts, it is big security concern to use it in a
-shared hosting environment. LiteSpeed SAPI is carefully designed to
-address this issue. It accepts same flexible configuration overridden
-methods as those supported in mod_php. LiteSpeed SAPI also uses the
-same configuration directives as Apache mod_php.
-
-Therefore, with above enhancements, LiteSpeed SAPI is highly
-recommended over FastCGI SAPI for using PHP with LiteSpeed web
-server.
-
-
-Building PHP with LiteSpeed SAPI
-================================
-
-You need to add "--with-litespeed" to the configure command to build
-PHP with LiteSpeed SAPI, all other SAPI related configure options
-should be removed.
-
-For example:
- ./configure --with-litespeed
- make
-
-You should find an executable called 'php' under sapi/litespeed/
-directory after the compilation succeeds. Copy it to
-'lsws/fcgi-bin/lsphp' or wherever you prefer, if LiteSpeed web server
-has been configured to run PHP with LiteSpeed SAPI already, you just
-need to overwrite the old executable with this one and you are all
-set.
-
-
-Using LiteSpeed PHP with LiteSpeed Web Server
-=============================================
-
-Detailed information about how to configure LiteSpeed web server with
-PHP support is available from our website, at:
-
-http://www.litespeedtech.com/docs/HowTo_QA.html
-
-Usually, PHP support has been configured out of box, you don't need to
-change it unless you want to change PHP interface from FastCGI to
-LiteSpeed SAPI or vice versa.
-
-Brief instructions are as follow:
-
-1) Login to web admin interface, go to 'Server'->'Ext App' tab, add an
- external application of type "LSAPI app", "Command" should be set
- to a shell command that executes the PHP binary you just
- built. "Instances" should be set to match the value of "Max
- Connections".
-
-2) Go to 'Server'->'Script Handler' tab, add a script handler
- configuration: set 'suffix' to 'php', 'Handler Type' to 'LiteSpeed
- API', 'Handler Name' should be the name of external application
- just defined.
-
-
-3) Click 'Apply Changes' link on the top left of the page, then click
- 'graceful restart'. Now PHP is running with LiteSpeed SAPI.
-
-Tuning
-------
-
-There are two environment variables that can be tweaked to control the
-behavior of LiteSpeed PHP.
-
-PHP_LSAPI_CHILDREN (no default)
-
-In order to handle multiple requests concurrently, LiteSpeed web
-server can either spawn multiple PHP processes; or spawn one process,
-and this process will create a number of child processes to handle
-multiple requests simultaneously.
-
-The web server will create PHP processes specified by "Instance" in
-LSAPI application configuration. For one PHP process launched by the
-server, if PHP_LSAPI_CHILDREN is not set, it will not create any child
-process; if PHP_LSAPI_CHILDREN is set, it will spawn a number of child
-processes specified by PHP_LSAPI_CHILDREN. Usually, it should match
-"Max Connections" configured for the LSAPI application, and both
-values should not be set over 100 in most cases.
-
-PHP_LSAPI_MAX_REQUESTS (default value: 500)
-
-This controls how many requests each child process will handle before
-exit. When one process exits, another will be created. This tuning is
-necessary because several PHP functions have been identified having
-memory leaks. If the PHP processes were left around forever, they
-could become very inefficient.
-
-
-Contact
-=======
-
-For support questions, please post to our free support forum, at:
-
-http://www.litespeedtech.com/forum/
-
-For bug report, please send bug report to bug [at] litespeedtech.com.
-
-
-
-
diff --git a/sapi/litespeed/config.m4 b/sapi/litespeed/config.m4
deleted file mode 100644
index e34d4dcdb5..0000000000
--- a/sapi/litespeed/config.m4
+++ /dev/null
@@ -1,36 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-AC_MSG_CHECKING(for LiteSpeed support)
-
-AC_ARG_WITH(litespeed,
-[ --with-litespeed Build PHP as litespeed module],
-[
- PHP_SAPI_LITESPEED=$withval
-],[
- PHP_SAPI_LITESPEED=no
-])
-
-if test "$PHP_SAPI_LITESPEED" != "no"; then
- PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/litespeed/Makefile.frag,$abs_srcdir/sapi/litespeed,sapi/litespeed)
- SAPI_LITESPEED_PATH=sapi/litespeed/php
- PHP_SUBST(SAPI_LITESPEED_PATH)
- PHP_SELECT_SAPI(litespeed, program, lsapi_main.c lsapilib.c, "", '$(SAPI_LITESPEED_PATH)')
- case $host_alias in
- *darwin*)
- BUILD_LITESPEED="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_SAPI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
- ;;
- *cygwin*)
- SAPI_LITESPEED_PATH=sapi/litespeed/php.exe
- BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
- ;;
- *)
- BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
- ;;
- esac
-
- PHP_SUBST(BUILD_LITESPEED)
-fi
-
-AC_MSG_RESULT($PHP_SAPI_LITESPEED)
diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c
deleted file mode 100644
index c8c84201c5..0000000000
--- a/sapi/litespeed/lsapi_main.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: George Wang <gwang@litespeedtech.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "php.h"
-#include "SAPI.h"
-#include "php_main.h"
-#include "php_ini.h"
-#include "php_variables.h"
-#include "zend_highlight.h"
-
-#include "lsapilib.h"
-
-#include <stdio.h>
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef PHP_WIN32
-#include <io.h>
-#include <fcntl.h>
-#include "win32/php_registry.h"
-#else
-#include <sys/wait.h>
-#endif
-#include <sys/stat.h>
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-
-#define SAPI_LSAPI_MAX_HEADER_LENGTH 2048
-static char s_headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH];
-
-static int lsapi_mode = 1;
-static char *php_self = "";
-static char *script_filename = "";
-
-#ifdef ZTS
-zend_compiler_globals *compiler_globals;
-zend_executor_globals *executor_globals;
-php_core_globals *core_globals;
-sapi_globals_struct *sapi_globals;
-void ***tsrm_ls;
-#endif
-
-
-/* {{{ php_lsapi_startup
- */
-static int php_lsapi_startup(sapi_module_struct *sapi_module)
-{
- if (php_module_startup(sapi_module, NULL, 0)==FAILURE) {
- return FAILURE;
- }
- return SUCCESS;
-}
-/* }}} */
-
-
-
-/* {{{ sapi_lsapi_ub_write
- */
-static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC)
-{
- int ret;
- int remain;
- if ( lsapi_mode )
- {
- ret = LSAPI_Write( str, str_length );
- if ( ret < str_length )
- {
- php_handle_aborted_connection();
- return str_length - ret;
- }
- }
- else
- {
- remain = str_length;
- while( remain > 0 )
- {
- ret = write( 1, str, remain );
- if ( ret <= 0 )
- {
- php_handle_aborted_connection();
- return str_length - remain;
- }
- str += ret;
- remain -= ret;
- }
- }
- return str_length;
-}
-/* }}} */
-
-
-/* {{{ sapi_lsapi_flush
- */
-static void sapi_lsapi_flush( void * server_context )
-{
- if ( lsapi_mode )
- {
- if ( LSAPI_Flush() == -1)
- php_handle_aborted_connection();
- }
-}
-/* }}} */
-
-
-/* {{{ sapi_lsapi_deactivate
- */
-static int sapi_lsapi_deactivate(TSRMLS_D)
-{
- LSAPI_Finish();
- return SUCCESS;
-}
-/* }}} */
-
-
-
-
-/* {{{ sapi_lsapi_getenv
- */
-static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC )
-{
- if ( lsapi_mode )
- return LSAPI_GetEnv( name );
- else
- return getenv( name );
-}
-/* }}} */
-
-
-
-static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen,
- void * arg )
-{
- php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC);
- return 1;
-}
-
-
-
-/* {{{ sapi_lsapi_register_variables
- */
-static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC)
-{
-
- if ( lsapi_mode )
- {
- LSAPI_ForeachHeader( add_variable, track_vars_array );
- LSAPI_ForeachEnv( add_variable, track_vars_array );
- php_import_environment_variables(track_vars_array TSRMLS_CC);
-
- php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC);
- }
- else
- {
- php_import_environment_variables(track_vars_array TSRMLS_CC);
-
- php_register_variable("PHP_SELF", php_self, track_vars_array TSRMLS_CC);
- php_register_variable("SCRIPT_NAME", php_self, track_vars_array TSRMLS_CC);
- php_register_variable("SCRIPT_FILENAME", script_filename, track_vars_array TSRMLS_CC);
- php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array TSRMLS_CC);
- php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC);
-
- }
-}
-/* }}} */
-
-
-/* {{{ sapi_lsapi_read_post
- */
-static int sapi_lsapi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
-{
- if ( lsapi_mode )
- {
- return LSAPI_ReadReqBody( buffer, count_bytes );
- }
- else
- return 0;
-}
-/* }}} */
-
-
-
-
-/* {{{ sapi_lsapi_read_cookies
- */
-static char *sapi_lsapi_read_cookies(TSRMLS_D)
-{
- if ( lsapi_mode )
- return LSAPI_GetHeader( H_COOKIE );
- else
- return NULL;
-}
-/* }}} */
-
-
-/* {{{ sapi_lsapi_send_headers
- */
-static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
-{
- sapi_header_struct *h;
- zend_llist_position pos;
- if ( lsapi_mode )
- {
- LSAPI_SetRespStatus( SG(sapi_headers).http_response_code );
-
- h = zend_llist_get_first_ex(&sapi_headers->headers, &pos);
- while (h) {
- LSAPI_AppendRespHeader(h->header, h->header_len);
- h = zend_llist_get_next_ex(&sapi_headers->headers, &pos);
- }
- if (SG(sapi_headers).send_default_content_type)
- {
- char *hd;
- int len;
-
- hd = sapi_get_default_content_type(TSRMLS_C);
- len = snprintf( s_headerBuf, SAPI_LSAPI_MAX_HEADER_LENGTH - 1,
- "Content-type: %s", hd );
- efree(hd);
-
- LSAPI_AppendRespHeader( s_headerBuf, len );
- }
- }
- LSAPI_FinalizeRespHeaders();
- return SAPI_HEADER_SENT_SUCCESSFULLY;
-
-
-}
-/* }}} */
-
-
-/* {{{ sapi_lsapi_send_headers
- */
-static void sapi_lsapi_log_message(char *message)
-{
- int len = strlen( message );
- LSAPI_Write_Stderr( message, len);
-}
-/* }}} */
-
-
-/* {{{ sapi_module_struct cgi_sapi_module
- */
-static sapi_module_struct lsapi_sapi_module =
-{
- "litespeed",
- "LiteSpeed",
-
- php_lsapi_startup, /* startup */
- php_module_shutdown_wrapper, /* shutdown */
-
- NULL, /* activate */
- sapi_lsapi_deactivate, /* deactivate */
-
- sapi_lsapi_ub_write, /* unbuffered write */
- sapi_lsapi_flush, /* flush */
- NULL, /* get uid */
- sapi_lsapi_getenv, /* getenv */
-
- php_error, /* error handler */
-
- NULL, /* header handler */
- sapi_lsapi_send_headers, /* send headers handler */
- NULL, /* send header handler */
-
- sapi_lsapi_read_post, /* read POST data */
- sapi_lsapi_read_cookies, /* read Cookies */
-
- sapi_lsapi_register_variables, /* register server variables */
- sapi_lsapi_log_message, /* Log message */
-
- NULL, /* php.ini path override */
- NULL, /* block interruptions */
- NULL, /* unblock interruptions */
- NULL, /* default post reader */
- NULL, /* treat data */
- NULL, /* executable location */
-
- 0, /* php.ini ignore */
-
- STANDARD_SAPI_MODULE_PROPERTIES
-
-};
-/* }}} */
-
-static int init_request_info( TSRMLS_D )
-{
- char * pContentType = LSAPI_GetHeader( H_CONTENT_TYPE );
- char * pAuth;
-
- SG(request_info).content_type = pContentType ? pContentType : "";
- SG(request_info).request_method = LSAPI_GetRequestMethod();
- SG(request_info).query_string = LSAPI_GetQueryString();
- SG(request_info).request_uri = LSAPI_GetScriptName();
- SG(request_info).content_length = LSAPI_GetReqBodyLen();
- SG(request_info).path_translated = LSAPI_GetScriptFileName();
- SG(sapi_headers).http_response_code = 0; //It is not reset by zend engine, set it to 0.
-
- pAuth = LSAPI_GetHeader( H_AUTHORIZATION );
- php_handle_auth_data(pAuth TSRMLS_CC);
-}
-
-static int lsapi_module_main(int show_source TSRMLS_DC)
-{
- zend_file_handle file_handle = {0};
-
- if (php_request_startup(TSRMLS_C) == FAILURE )
- return -1;
- if (show_source)
- {
- zend_syntax_highlighter_ini syntax_highlighter_ini;
-
- php_get_highlight_struct(&syntax_highlighter_ini);
- highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC);
- }
- else
- {
- file_handle.type = ZEND_HANDLE_FILENAME;
- file_handle.handle.fd = 0;
- file_handle.filename = SG(request_info).path_translated;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_execute_script(&file_handle TSRMLS_CC);
- }
- zend_try
- {
- php_request_shutdown(NULL);
- } zend_end_try();
- return 0;
-}
-
-
-static int alter_ini( const char * pKey, int keyLen, const char * pValue, int valLen,
- void * arg )
-{
- int type = ZEND_INI_PERDIR;
- if ( '\001' == *pKey )
- {
- ++pKey;
- if ( *pKey == 4 )
- type = ZEND_INI_SYSTEM;
- ++pKey;
- --keyLen;
- zend_alter_ini_entry((char *)pKey, keyLen,
- (char *)pValue, valLen,
- type, PHP_INI_STAGE_ACTIVATE);
- }
- return 1;
-}
-
-
-static void override_ini()
-{
-
- LSAPI_ForeachSpecialEnv( alter_ini, NULL );
-
-}
-
-static int processReq( TSRMLS_D )
-{
- int ret = 0;
- zend_first_try
- {
- /* avoid server_context==NULL checks */
- SG(server_context) = (void *) 1;
-
- init_request_info( TSRMLS_C );
-
- override_ini();
-
- if ( lsapi_module_main( 0 TSRMLS_CC ) == -1 )
- ret = -1;
-
- } zend_end_try();
- return ret;
-}
-
-static void cli_usage( TSRMLS_D )
-{
- static const char * usage =
- "Usage: php\n"
- " php -[h|i|q|v|?] [<file>] [args...]\n"
- " Run in LSAPI mode when no parameter or only '-c' is specified\n"
- " Run in Command Line Interpreter mode when parameters are specified"
- "\n"
- " -c <path>|<file> Look for php.ini file in this directory\n"
- " -h This help\n"
- " -i PHP information\n"
- " -q Quiet-mode. Suppress HTTP Header output.\n"
- " -v Version number\n"
- " -? This help\n"
- "\n"
- " args... Arguments passed to script.\n";
- php_output_startup();
- php_output_activate(TSRMLS_C);
-// SG(headers_sent) = 1;
- php_printf( usage );
- php_end_ob_buffers(1 TSRMLS_CC);
-}
-
-static int parse_opt( int argc, char * argv[], int *climode,
- char **php_ini_path )
-{
- char ** p = &argv[1];
- char ** argend= &argv[argc];
- int c;
- while (( p < argend )&&(**p == '-' ))
- {
- c = *((*p)+1);
- ++p;
- switch( c )
- {
- case 'c':
- if ( p >= argend )
- {
- fprintf( stderr, "<path> or <file> must be specified following '-c' option.\n");
-
- return -1;
- }
- *php_ini_path = *p++;
- break;
- case 'h':
- case 'i':
- case 'q':
- case 'v':
- case '?':
- default:
- *climode = 1;
- break;
- }
- }
- if ( p - argv < argc )
- *climode = 1;
- return 0;
-}
-
-static int cli_main( int argc, char * argv[] )
-{
-
- static const char * ini_defaults[] =
- {
- "report_zend_debug", "0",
- "display_errors", "1",
- "register_argc_argv", "1",
- "html_errors", "0",
- "implicit_flush", "1",
- "output_buffering", "0",
- "max_execution_time", "0",
- NULL
- };
-
- const char ** ini;
- char ** p = &argv[1];
- char ** argend= &argv[argc];
- int ret = 0;
- int c;
- lsapi_mode = 0; /* enter CLI mode */
-
-#ifdef PHP_WIN32
- _fmode = _O_BINARY; /*sets default for file streams to binary */
- setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
-#endif
-
- zend_first_try
- {
- SG(server_context) = (void *) 1;
-
- zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
- CG(in_compilation) = 0; /* not initialized but needed for several options */
- EG(uninitialized_zval_ptr) = NULL;
-
- for( ini = ini_defaults; *ini; ini+=2 )
- {
- zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1,
- (char *)*(ini+1), strlen( *(ini+1) ),
- PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
- }
-
- while (( p < argend )&&(**p == '-' ))
- {
- c = *((*p)+1);
- ++p;
- switch( c )
- {
- case 'q':
-// SG(headers_sent) = 1;
-// SG(request_info).no_headers = 1;
- break;
- case 'i':
- if (php_request_startup(TSRMLS_C) != FAILURE)
- {
-// SG(headers_sent) = 1;
-// SG(request_info).no_headers = 1;
- php_print_info(0xFFFFFFFF TSRMLS_CC);
- php_end_ob_buffers(1 TSRMLS_CC);
- php_request_shutdown( NULL );
- }
- ret = 1;
- break;
- case 'v':
- if (php_request_startup(TSRMLS_C) != FAILURE)
- {
-// SG(headers_sent) = 1;
-// SG(request_info).no_headers = 1;
-#if ZEND_DEBUG
- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
-#else
- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
-#endif
- php_end_ob_buffers(1 TSRMLS_CC);
- php_request_shutdown( NULL );
- }
- ret = 1;
- break;
- case 'c':
- ++p;
- break;
- case 'h':
- case '?':
- default:
- cli_usage(TSRMLS_C);
- ret = 1;
- break;
-
- }
- }
- if ( !ret )
- {
- if ( *p )
- {
- zend_file_handle file_handle = {0};
-
- file_handle.type = ZEND_HANDLE_FP;
- file_handle.handle.fp = VCWD_FOPEN(*p, "rb");
-
- if ( file_handle.handle.fp )
- {
- script_filename = *p;
- php_self = *p;
-
- SG(request_info).path_translated = *p;
- SG(request_info).argc = argc - (p - argv);
- SG(request_info).argv = p;
-
- if (php_request_startup(TSRMLS_C) == FAILURE )
- {
- fclose( file_handle.handle.fp );
- ret = 2;
- }
- else
- {
-
- file_handle.filename = *p;
- file_handle.free_filename = 0;
- file_handle.opened_path = NULL;
-
- php_execute_script(&file_handle TSRMLS_CC);
- php_request_shutdown( NULL );
- }
- }
- else
- {
- php_printf("Could not open input file: %s.\n", *p);
- }
- }
- else
- {
- cli_usage(TSRMLS_C);
- }
- }
-
- }zend_end_try();
-
- php_module_shutdown(TSRMLS_C);
-
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- return ret;
-}
-
-static int s_stop;
-void litespeed_cleanup(int signal)
-{
- s_stop = signal;
-}
-
-
-void start_children( int children )
-{
- struct sigaction act, old_term, old_quit, old_int, old_usr1;
- int running = 0;
- int status;
- pid_t pid;
-
- /* Create a process group */
- setsid();
-
- /* Set up handler to kill children upon exit */
- act.sa_flags = 0;
- act.sa_handler = litespeed_cleanup;
- if( sigaction( SIGTERM, &act, &old_term ) ||
- sigaction( SIGINT, &act, &old_int ) ||
- sigaction( SIGUSR1, &act, &old_usr1 ) ||
- sigaction( SIGQUIT, &act, &old_quit ))
- {
- perror( "Can't set signals" );
- exit( 1 );
- }
- s_stop = 0;
- while( 1 )
- {
- while((!s_stop )&&( running < children ))
- {
- pid = fork();
- switch( pid ) {
- case 0: /* children process */
-
- /* don't catch our signals */
- sigaction( SIGTERM, &old_term, 0 );
- sigaction( SIGQUIT, &old_quit, 0 );
- sigaction( SIGINT, &old_int, 0 );
- sigaction( SIGUSR1, &old_usr1, 0 );
- return ;
- case -1:
- perror( "php (pre-forking)" );
- exit( 1 );
- break;
- default: /* parent process */
- running++;
- break;
- }
- }
- if ( s_stop )
- break;
- pid = wait( &status );
- running--;
- }
- kill( -getpgrp(), s_stop );
- exit( 0 );
-}
-
-
-
-#include <fcntl.h>
-int main( int argc, char * argv[] )
-{
- int ret;
- int max_requests = 500;
- int requests = 0;
-
- char * php_ini_path = NULL;
- int climode = 0;
-
-#ifdef HAVE_SIGNAL_H
-#if defined(SIGPIPE) && defined(SIG_IGN)
- signal(SIGPIPE, SIG_IGN);
-#endif
-#endif
-
-#ifdef ZTS
- tsrm_startup(1, 1, 0, NULL);
-#endif
-
- if (argc > 1 )
- {
- if ( parse_opt( argc, argv, &climode, &php_ini_path ) == -1 )
- return 1;
- }
- if ( climode )
- lsapi_sapi_module.phpinfo_as_text = 1;
- sapi_startup(&lsapi_sapi_module);
-
-#ifdef ZTS
- compiler_globals = ts_resource(compiler_globals_id);
- executor_globals = ts_resource(executor_globals_id);
- core_globals = ts_resource(core_globals_id);
- sapi_globals = ts_resource(sapi_globals_id);
- tsrm_ls = ts_resource(0);
-
- SG(request_info).path_translated = NULL;
-#endif
-
- lsapi_sapi_module.executable_location = argv[0];
-
- if ( php_ini_path )
- lsapi_sapi_module.php_ini_path_override = php_ini_path;
-
- if (php_module_startup(&lsapi_sapi_module, NULL, 0) == FAILURE) {
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- return FAILURE;
- }
-
- if ( climode )
- {
- return cli_main(argc, argv);
- }
-
- if( getenv( "PHP_LSAPI_MAX_REQUESTS" ))
- {
- max_requests = atoi( getenv( "PHP_LSAPI_MAX_REQUESTS" ));
- if( !max_requests )
- {
- fprintf( stderr,
- "PHP_LSAPI_MAX_REQUESTS is not valid\n" );
- exit( 1 );
- }
- }
-
- LSAPI_Init();
-
- if (( getenv( "PHP_LSAPI_CHILDREN" ) )&& LSAPI_Is_Listen() )
- {
- int children = atoi( getenv( "PHP_LSAPI_CHILDREN" ));
- if ( children > 0 )
- start_children( children );
- }
-
- while( LSAPI_Accept() >= 0 )
- {
- ret = processReq(TSRMLS_C);
- LSAPI_Finish();
- if ( ret )
- break;
- requests++;
- if( max_requests && ( requests == max_requests ))
- {
- break;
- }
- }
- php_module_shutdown(TSRMLS_C);
-
-#ifdef ZTS
- tsrm_shutdown();
-#endif
- return ret;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
-
-
diff --git a/sapi/litespeed/lsapidef.h b/sapi/litespeed/lsapidef.h
deleted file mode 100644
index 420f3ed3b4..0000000000
--- a/sapi/litespeed/lsapidef.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
-Copyright (c) 2005, Lite Speed Technologies Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of the Lite Speed Technologies Inc nor the
- names of its contributors may be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/***************************************************************************
- $Id$
- -------------------
- begin : Thu Feb 10 2005
- author : George Wang
- email : gwang@litespeedtech.com
- ***************************************************************************/
-
-#ifndef _LSAPIDEF_H_
-#define _LSAPIDEF_H_
-
-#include <inttypes.h>
-
-#if defined (c_plusplus) || defined (__cplusplus)
-extern "C" {
-#endif
-
-enum
-{
- H_ACCEPT = 0,
- H_ACC_CHARSET,
- H_ACC_ENCODING,
- H_ACC_LANG,
- H_AUTHORIZATION,
- H_CONNECTION,
- H_CONTENT_TYPE,
- H_CONTENT_LENGTH,
- H_COOKIE,
- H_COOKIE2,
- H_HOST,
- H_PRAGMA,
- H_REFERER,
- H_USERAGENT,
- H_CACHE_CTRL,
- H_IF_MODIFIED_SINCE,
- H_IF_MATCH,
- H_IF_NO_MATCH,
- H_IF_RANGE,
- H_IF_UNMOD_SINCE,
- H_KEEP_ALIVE,
- H_RANGE,
- H_X_FORWARDED_FOR,
- H_VIA,
- H_TRANSFER_ENCODING
-
-};
-#define LSAPI_SOCK_FILENO 0
-
-#define LSAPI_VERSION_B0 'L'
-#define LSAPI_VERSION_B1 'S'
-
-//Values for m_flag in lsapi_packet_header
-#define LSAPI_ENDIAN_LITTLE 0
-#define LSAPI_ENDIAN_BIG 1
-#define LSAPI_ENDIAN_BIT 1
-
-#if defined(__i386__)||defined( __x86_64 )||defined( __x86_64__ )
-#define LSAPI_ENDIAN LSAPI_ENDIAN_LITTLE
-#else
-#define LSAPI_ENDIAN LSAPI_ENDIAN_BIG
-#endif
-
-//Values for m_type in lsapi_packet_header
-#define LSAPI_BEGIN_REQUEST 1
-#define LSAPI_ABORT_REQUEST 2
-#define LSAPI_RESP_HEADER 3
-#define LSAPI_RESP_STREAM 4
-#define LSAPI_RESP_END 5
-#define LSAPI_STDERR_STREAM 6
-#define LSAPI_REQ_RECEIVED 7
-
-
-#define LSAPI_MAX_HEADER_LEN 65535
-#define LSAPI_MAX_DATA_PACKET_LEN 16384
-
-#define LSAPI_RESP_HTTP_HEADER_MAX 4096
-#define LSAPI_PACKET_HEADER_LEN 8
-
-
-struct lsapi_packet_header
-{
- char m_versionB0; //LSAPI protocol version
- char m_versionB1;
- char m_type;
- char m_flag;
- union
- {
- int32_t m_iLen; //include this header
- char m_bytes[4];
- }m_packetLen;
-};
-
-// LSAPI request header packet
-//
-// 1. struct lsapi_req_header
-// 2. struct lsapi_http_header_index
-// 3. lsapi_header_offset * unknownHeaders
-// 4. org http request header
-// 5. request body if available
-
-struct lsapi_req_header
-{
- struct lsapi_packet_header m_pktHeader;
-
- int32_t m_httpHeaderLen;
- int32_t m_reqBodyLen;
- int32_t m_scriptFileOff; //path to the script file.
- int32_t m_scriptNameOff; //decrypted URI, without pathinfo,
- int32_t m_queryStringOff; //Query string inside env
- int32_t m_requestMethodOff;
- int32_t m_cntUnknownHeaders;
- int32_t m_cntEnv;
- int32_t m_cntSpecialEnv;
-} ;
-
-
-struct lsapi_http_header_index
-{
- int16_t m_headerLen[H_TRANSFER_ENCODING+1];
- int32_t m_headerOff[H_TRANSFER_ENCODING+1];
-} ;
-
-struct lsapi_header_offset
-{
- int32_t nameOff;
- int32_t nameLen;
- int32_t valueOff;
- int32_t valueLen;
-} ;
-
-struct lsapi_resp_info
-{
- int32_t m_cntHeaders;
- int32_t m_status;
-};
-
-struct lsapi_resp_header
-{
- struct lsapi_packet_header m_pktHeader;
- struct lsapi_resp_info m_respInfo;
-};
-
-#if defined (c_plusplus) || defined (__cplusplus)
-}
-#endif
-
-
-#endif
-
diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
deleted file mode 100644
index 53232694e7..0000000000
--- a/sapi/litespeed/lsapilib.c
+++ /dev/null
@@ -1,1127 +0,0 @@
-/*
-Copyright (c) 2005, Lite Speed Technologies Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of the Lite Speed Technologies Inc nor the
- names of its contributors may be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/***************************************************************************
- lsapilib.c - description
- -------------------
- begin : Mon Feb 21 2005
- copyright : (C) 2005 by George Wang
- email : gwang@litespeedtech.com
- ***************************************************************************/
-
-
-#include <lsapilib.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-
-//#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#define LSAPI_ST_REQ_HEADER 1
-#define LSAPI_ST_REQ_BODY 2
-#define LSAPI_ST_RESP_HEADER 4
-#define LSAPI_ST_RESP_BODY 8
-
-#define LSAPI_RESP_BUF_SIZE 8192
-#define LSAPI_INIT_RESP_HEADER_LEN 4096
-
-
-static int g_inited = 0;
-static int g_running = 1;
-LSAPI_Request g_req;
-
-void Flush_RespBuf_r( LSAPI_Request * pReq );
-
-static const char *CGI_HEADERS[H_TRANSFER_ENCODING+1] =
-{
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET",
- "HTTP_ACCEPT_ENCODING",
- "HTTP_ACCEPT_LANG", "HTTP_AUTHORIZATION",
- "HTTP_CONNECTION", "CONTENT_TYPE",
- "CONTENT_LENGTH", "HTTP_COOKIE", "HTTP_COOKIE2",
- "HTTP_HOST", "HTTP_PRAGMA",
- "HTTP_REFERER", "HTTP_USER_AGENT",
- "HTTP_CACHE_CTRL",
- "HTTP_IF_MODIFIED_SINCE", "HTTP_IF_MATCH",
- "HTTP_IF_NONE_MATCH",
- "HTTP_IF_RANGE",
- "HTTP_IF_UNMODIFIED_SINCE",
- "HTTP_KEEPALIVE",
- "HTTP_RANGE",
- "HTTP_X_FORWARDED_FOR",
- "HTTP_VIA",
- "HTTP_TRANSFER_ENCODING"
-};
-
-static int CGI_HEADER_LEN[H_TRANSFER_ENCODING+1] =
-{ 11, 19, 20, 16, 18, 15, 12, 14, 11, 12, 9, 11, 12, 15, 15,
- 22, 13, 18, 13, 24, 14, 10, 20, 8, 22 };
-
-static void lsapi_sigpipe( int sig )
-{
-}
-static void lsapi_siguser1( int sig )
-{
- g_running = 0;
-}
-
-#ifndef sighandler_t
-typedef void (*sighandler_t)(int);
-#endif
-
-static void lsapi_signal(int signo, sighandler_t handler)
-{
- struct sigaction sa;
-
- sigaction(signo, NULL, &sa);
-
- if (sa.sa_handler == SIG_DFL)
- {
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = handler;
- sigaction(signo, &sa, NULL);
- }
-}
-
-
-static inline void lsapi_buildPacketHeader( struct lsapi_packet_header * pHeader,
- char type, int len )
-{
- pHeader->m_versionB0 = LSAPI_VERSION_B0; //LSAPI protocol version
- pHeader->m_versionB1 = LSAPI_VERSION_B1;
- pHeader->m_type = type;
- pHeader->m_flag = LSAPI_ENDIAN;
- pHeader->m_packetLen.m_iLen = len;
-}
-
-static int lsapi_close( int fd )
-{
- int ret;
- while( 1 )
- {
- ret = close( fd );
- if (( ret == -1 )&&( errno == EINTR )&&(g_running))
- continue;
- return ret;
- }
-}
-
-static inline int lsapi_read( int fd, void * pBuf, int len )
-{
- int ret;
- while( 1 )
- {
- ret = read( fd, (char *)pBuf, len );
- if (( ret == -1 )&&( errno == EINTR )&&(g_running))
- continue;
- return ret;
- }
-}
-
-//static int lsapi_write( int fd, const void * pBuf, int len )
-//{
-// int ret;
-// const char * pCur;
-// const char * pEnd;
-// if ( len == 0 )
-// return 0;
-// pCur = (const char *)pBuf;
-// pEnd = pCur + len;
-// while( g_running && (pCur < pEnd) )
-// {
-// ret = write( fd, pCur, pEnd - pCur );
-// if ( ret >= 0)
-// pCur += ret;
-// else if (( ret == -1 )&&( errno != EINTR ))
-// return ret;
-// }
-// return pCur - (const char *)pBuf;
-//}
-
-static int lsapi_writev( int fd, struct iovec ** pVec, int count, int totalLen )
-{
- int ret;
- int left = totalLen;
- int n = count;
- while(( left > 0 )&&g_running )
- {
- ret = writev( fd, *pVec, n );
- if ( ret > 0 )
- {
- left -= ret;
- if (( left <= 0)||( !g_running ))
- return totalLen - left;
- while( ret > 0 )
- {
- if ( (*pVec)->iov_len <= ret )
- {
- ret -= (*pVec)->iov_len;
- ++(*pVec);
- }
- else
- {
- (*pVec)->iov_base = (char *)(*pVec)->iov_base + ret;
- (*pVec)->iov_len -= ret;
- break;
- }
- }
- }
- else if (( ret == -1 )&&( errno != EINTR ))
- return ret;
- }
- return totalLen - left;
-}
-
-//static int getTotalLen( struct iovec * pVec, int count )
-//{
-// struct iovec * pEnd = pVec + count;
-// int total = 0;
-// while( pVec < pEnd )
-// {
-// total += pVec->iov_len;
-// ++pVec;
-// }
-// return total;
-//}
-
-
-static inline int allocateBuf( LSAPI_Request * pReq, int size )
-{
- char * pBuf = (char *)realloc( pReq->m_pReqBuf, size );
- if ( pBuf )
- {
- pReq->m_pReqBuf = pBuf;
- pReq->m_reqBufSize = size;
- pReq->m_pHeader = (struct lsapi_req_header *)pReq->m_pReqBuf;
- return 0;
- }
- return -1;
-}
-
-
-static int allocateIovec( LSAPI_Request * pReq, int n )
-{
- struct iovec * p = (struct iovec *)realloc(
- pReq->m_pIovec, sizeof(struct iovec) * n );
- if ( !p )
- return -1;
- pReq->m_pIovecToWrite = p + ( pReq->m_pIovecToWrite - pReq->m_pIovec );
- pReq->m_pIovecCur = p + ( pReq->m_pIovecCur - pReq->m_pIovec );
- pReq->m_pIovec = p;
- pReq->m_pIovecEnd = p + n;
- return 0;
-}
-
-static int allocateRespHeaderBuf( LSAPI_Request * pReq, int size )
-{
- char * p = (char *)realloc( pReq->m_pRespHeaderBuf, size );
- if ( !p )
- return -1;
- pReq->m_pRespHeaderBufPos = p + ( pReq->m_pRespHeaderBufPos - pReq->m_pRespHeaderBuf );
- pReq->m_pRespHeaderBuf = p;
- pReq->m_pRespHeaderBufEnd = p + size;
- return 0;
-}
-
-
-static inline int verifyHeader( struct lsapi_packet_header * pHeader, char pktType )
-{
- if (( LSAPI_VERSION_B0 != pHeader->m_versionB0 )||
- ( LSAPI_VERSION_B1 != pHeader->m_versionB1 )||
- ( pktType != pHeader->m_type ))
- return -1;
- if ( LSAPI_ENDIAN != (pHeader->m_flag & LSAPI_ENDIAN_BIT ))
- {
- register char b;
- b = pHeader->m_packetLen.m_bytes[0];
- pHeader->m_packetLen.m_bytes[0] = pHeader->m_packetLen.m_bytes[3];
- pHeader->m_packetLen.m_bytes[3] = b;
- b = pHeader->m_packetLen.m_bytes[1];
- pHeader->m_packetLen.m_bytes[1] = pHeader->m_packetLen.m_bytes[2];
- pHeader->m_packetLen.m_bytes[2] = b;
- }
- return pHeader->m_packetLen.m_iLen;
-}
-
-static int allocateEnvList( struct LSAPI_key_value_pair ** pEnvList,
- int *curSize, int newSize )
-{
- struct LSAPI_key_value_pair * pBuf;
- if ( *curSize >= newSize )
- return 0;
- if ( newSize > 8192 )
- return -1;
- pBuf = (struct LSAPI_key_value_pair *)realloc( *pEnvList, newSize *
- sizeof(struct LSAPI_key_value_pair) );
- if ( pBuf )
- {
- *pEnvList = pBuf;
- *curSize = newSize;
- return 0;
- }
- else
- return -1;
-
-}
-
-static inline int isPipe( int fd )
-{
- char achPeer[128];
- int len = 128;
- if (( getpeername( fd, (struct sockaddr *)achPeer, &len ) != 0 )&&
- ( errno == ENOTCONN ))
- return 0;
- else
- return 1;
-}
-
-static int parseEnv( struct LSAPI_key_value_pair * pEnvList, int count,
- char **pBegin, char * pEnd )
-{
- struct LSAPI_key_value_pair * pEnvEnd;
- int keyLen = 0, valLen = 0;
- if ( count > 8192 )
- return -1;
- pEnvEnd = pEnvList + count;
- while( pEnvList != pEnvEnd )
- {
- if ( pEnd - *pBegin < 4 )
- return -1;
- keyLen = *((unsigned char *)((*pBegin)++));
- keyLen = (keyLen << 8) + *((unsigned char *)((*pBegin)++));
- valLen = *((unsigned char *)((*pBegin)++));
- valLen = (valLen << 8) + *((unsigned char *)((*pBegin)++));
- if ( *pBegin + keyLen + valLen > pEnd )
- return -1;
- if (( !keyLen )||( !valLen ))
- return -1;
-
- pEnvList->pKey = *pBegin;
- *pBegin += keyLen;
- pEnvList->pValue = *pBegin;
- *pBegin += valLen;
-
- pEnvList->keyLen = keyLen - 1;
- pEnvList->valLen = valLen - 1;
- ++pEnvList;
- }
- if ( memcmp( *pBegin, "\0\0\0\0", 4 ) != 0 )
- return -1;
- *pBegin += 4;
- return 0;
-}
-
-static inline void swapIntEndian( int * pInteger )
-{
- char * p = (char *)pInteger;
- register char b;
- b = p[0];
- p[0] = p[3];
- p[3] = b;
- b = p[1];
- p[1] = p[2];
- p[2] = b;
-
-}
-
-static inline void fixEndian( LSAPI_Request * pReq )
-{
- struct lsapi_req_header *p= pReq->m_pHeader;
- swapIntEndian( &p->m_httpHeaderLen );
- swapIntEndian( &p->m_reqBodyLen );
- swapIntEndian( &p->m_scriptFileOff );
- swapIntEndian( &p->m_scriptNameOff );
- swapIntEndian( &p->m_queryStringOff );
- swapIntEndian( &p->m_requestMethodOff );
- swapIntEndian( &p->m_cntUnknownHeaders );
- swapIntEndian( &p->m_cntEnv );
- swapIntEndian( &p->m_cntSpecialEnv );
-}
-
-static void fixHeaderIndexEndian( LSAPI_Request * pReq )
-{
- int i;
- for( i = 0; i < H_TRANSFER_ENCODING; ++i )
- {
- if ( pReq->m_pHeaderIndex->m_headerOff[i] )
- {
- register char b;
- char * p = (char *)(&pReq->m_pHeaderIndex->m_headerLen[i]);
- b = p[0];
- p[0] = p[1];
- p[1] = b;
- swapIntEndian( &pReq->m_pHeaderIndex->m_headerOff[i] );
- }
- }
- if ( pReq->m_pHeader->m_cntUnknownHeaders > 0 )
- {
- struct lsapi_header_offset * pCur, *pEnd;
- pCur = pReq->m_pUnknownHeader;
- pEnd = pCur + pReq->m_pHeader->m_cntUnknownHeaders;
- while( pCur < pEnd )
- {
- swapIntEndian( &pCur->nameOff );
- swapIntEndian( &pCur->nameLen );
- swapIntEndian( &pCur->valueOff );
- swapIntEndian( &pCur->valueLen );
- ++pCur;
- }
- }
-}
-
-static int parseRequest( LSAPI_Request * pReq, int totalLen )
-{
- int shouldFixEndian;
- char * pBegin = pReq->m_pReqBuf + sizeof( struct lsapi_req_header );
- char * pEnd = pReq->m_pReqBuf + totalLen;
- shouldFixEndian = ( LSAPI_ENDIAN != (
- pReq->m_pHeader->m_pktHeader.m_flag & LSAPI_ENDIAN_BIT ) );
- if ( shouldFixEndian )
- {
- fixEndian( pReq );
- }
- if ( (pReq->m_specialEnvListSize < pReq->m_pHeader->m_cntSpecialEnv )&&
- allocateEnvList( &pReq->m_pSpecialEnvList,
- &pReq->m_specialEnvListSize,
- pReq->m_pHeader->m_cntSpecialEnv ) == -1 )
- return -1;
- if ( (pReq->m_envListSize < pReq->m_pHeader->m_cntEnv )&&
- allocateEnvList( &pReq->m_pEnvList, &pReq->m_envListSize,
- pReq->m_pHeader->m_cntEnv ) == -1 )
- return -1;
-
- if ( parseEnv( pReq->m_pSpecialEnvList,
- pReq->m_pHeader->m_cntSpecialEnv,
- &pBegin, pEnd ) == -1 )
- return -1;
- if ( parseEnv( pReq->m_pEnvList, pReq->m_pHeader->m_cntEnv,
- &pBegin, pEnd ) == -1 )
- return -1;
-
- pReq->m_pScriptFile = pReq->m_pReqBuf + pReq->m_pHeader->m_scriptFileOff;
- pReq->m_pScriptName = pReq->m_pReqBuf + pReq->m_pHeader->m_scriptNameOff;
- pReq->m_pQueryString = pReq->m_pReqBuf + pReq->m_pHeader->m_queryStringOff;
- pReq->m_pRequestMethod = pReq->m_pReqBuf + pReq->m_pHeader->m_requestMethodOff;
-
- pBegin = pReq->m_pReqBuf + (( pBegin - pReq->m_pReqBuf + 7 ) & (~0x7));
- pReq->m_pHeaderIndex = ( struct lsapi_http_header_index * )pBegin;
- pBegin += sizeof( struct lsapi_http_header_index );
-
- pReq->m_pUnknownHeader = (struct lsapi_header_offset *)pBegin;
- pBegin += sizeof( struct lsapi_header_offset) *
- pReq->m_pHeader->m_cntUnknownHeaders;
-
- pReq->m_pHttpHeader = pBegin;
- pBegin += pReq->m_pHeader->m_httpHeaderLen;
- if ( pBegin != pEnd )
- return -1;
-
- if ( shouldFixEndian )
- {
- fixHeaderIndexEndian( pReq );
- }
-
- return 0;
-}
-
-static struct lsapi_packet_header ack = {'L', 'S',
- LSAPI_REQ_RECEIVED, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} };
-static inline int notify_req_received( LSAPI_Request * pReq )
-{
- if ( write( pReq->m_fd, &ack, LSAPI_PACKET_HEADER_LEN )
- < LSAPI_PACKET_HEADER_LEN )
- return -1;
- return 0;
-}
-
-
-static int readReq( LSAPI_Request * pReq )
-{
- int len;
- int packetLen;
- if ( !pReq )
- return -1;
- if ( pReq->m_reqBufSize < 8192 )
- {
- if ( allocateBuf( pReq, 8192 ) == -1 )
- return -1;
- }
-
- while ( pReq->m_bufRead < LSAPI_PACKET_HEADER_LEN )
- {
- len = lsapi_read( pReq->m_fd, pReq->m_pReqBuf, pReq->m_reqBufSize );
- if ( len <= 0 )
- return -1;
- pReq->m_bufRead += len;
- }
- pReq->m_reqState = LSAPI_ST_REQ_HEADER;
-
- packetLen = verifyHeader( &pReq->m_pHeader->m_pktHeader, LSAPI_BEGIN_REQUEST );
- if ( packetLen < 0 )
- return -1;
- if ( packetLen > LSAPI_MAX_HEADER_LEN )
- return -1;
-
- if ( packetLen > pReq->m_reqBufSize )
- {
- if ( allocateBuf( pReq, packetLen ) == -1 )
- return -1;
- }
- while( packetLen > pReq->m_bufRead )
- {
- len = lsapi_read( pReq->m_fd, pReq->m_pReqBuf + pReq->m_bufRead, packetLen - pReq->m_bufRead );
- if ( len <= 0 )
- return -1;
- pReq->m_bufRead += len;
- }
- if ( parseRequest( pReq, packetLen ) < 0 )
- return -1;
- pReq->m_bufProcessed = packetLen;
- pReq->m_reqState = LSAPI_ST_REQ_BODY | LSAPI_ST_RESP_HEADER;
-
- return notify_req_received( pReq );
-}
-
-
-
-int LSAPI_Init(void)
-{
- if ( !g_inited )
- {
- lsapi_signal(SIGPIPE, lsapi_sigpipe);
- lsapi_signal(SIGUSR1, lsapi_siguser1);
-
- if ( LSAPI_InitRequest( &g_req, LSAPI_SOCK_FILENO ) == -1 )
- return -1;
- g_inited = 1;
- }
- return 0;
-}
-
-void LSAPI_stop(void)
-{
- g_running = 0;
-}
-
-int LSAPI_InitRequest( LSAPI_Request * pReq, int fd )
-{
- if ( !pReq )
- return -1;
- memset( pReq, 0, sizeof( LSAPI_Request ) );
- if ( allocateIovec( pReq, 16 ) == -1 )
- return -1;
- pReq->m_pRespBuf = pReq->m_pRespBufPos = (char *)malloc( LSAPI_RESP_BUF_SIZE );
- if ( !pReq->m_pRespBuf )
- return -1;
- pReq->m_pRespBufEnd = pReq->m_pRespBuf + LSAPI_RESP_BUF_SIZE;
- pReq->m_pIovecCur = pReq->m_pIovecToWrite = pReq->m_pIovec + 1;
- pReq->m_respPktHeaderEnd = &pReq->m_respPktHeader[5];
- if ( allocateRespHeaderBuf( pReq, LSAPI_INIT_RESP_HEADER_LEN ) == -1 )
- return -1;
-
- if ( isPipe( fd ) )
- {
- pReq->m_fdListen = -1;
- pReq->m_fd = fd;
- }
- else
- {
- pReq->m_fdListen = fd;
- pReq->m_fd = -1;
- }
- return 0;
-}
-
-int LSAPI_Is_Listen( void )
-{
- return LSAPI_Is_Listen_r( &g_req );
-}
-
-int LSAPI_Is_Listen_r( LSAPI_Request * pReq)
-{
- return pReq->m_fdListen != -1;
-}
-
-
-
-int LSAPI_Accept_r( LSAPI_Request * pReq )
-{
- char achPeer[128];
- int len;
- int nodelay = 1;
- if ( !pReq )
- return -1;
- if ( LSAPI_Finish_r( pReq ) == -1 )
- return -1;
- while( g_running )
- {
- if ( pReq->m_fd == -1 )
- {
- if ( pReq->m_fdListen != -1)
- {
- len = sizeof( achPeer );
- pReq->m_fd = accept( pReq->m_fdListen,
- (struct sockaddr *)&achPeer, &len );
- if (( pReq->m_fd == -1 )&&( errno == EINTR ))
- continue;
- if (( pReq->m_fd != -1 )&&
- (((struct sockaddr *)&achPeer)->sa_family == AF_INET ))
- {
- setsockopt(pReq->m_fd, IPPROTO_TCP, TCP_NODELAY,
- (char *)&nodelay, sizeof(nodelay));
- }
- }
- else
- return -1;
- }
- if ( !readReq( pReq ) )
- break;
- lsapi_close( pReq->m_fd );
- pReq->m_fd = -1;
- LSAPI_Reset_r( pReq );
- }
- return 0;
-}
-
-static struct lsapi_packet_header finish = {'L', 'S',
- LSAPI_RESP_END, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} };
-
-int LSAPI_Finish_r( LSAPI_Request * pReq )
-{
- //finish req body
- if ( !pReq )
- return -1;
- if (pReq->m_reqState)
- {
- if ( pReq->m_fd != -1 )
- {
- if ( pReq->m_reqState & LSAPI_ST_RESP_HEADER )
- {
- LSAPI_FinalizeRespHeaders_r( pReq );
- }
- if ( pReq->m_pRespBufPos != pReq->m_pRespBuf )
- {
- Flush_RespBuf_r( pReq );
- }
-
- pReq->m_pIovecCur->iov_base = (void *)&finish;
- pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
- pReq->m_totalLen += LSAPI_PACKET_HEADER_LEN;
- ++pReq->m_pIovecCur;
- LSAPI_Flush_r( pReq );
- }
- LSAPI_Reset_r( pReq );
- }
- return 0;
-}
-
-
-void LSAPI_Reset_r( LSAPI_Request * pReq )
-{
- pReq->m_pRespBufPos = pReq->m_pRespBuf;
- pReq->m_pIovecCur = pReq->m_pIovecToWrite = pReq->m_pIovec + 1;
- pReq->m_pRespHeaderBufPos = pReq->m_pRespHeaderBuf;
-
- memset( &pReq->m_pHeaderIndex, 0,
- (char *)(pReq->m_respHeaderLen) - (char *)&pReq->m_pHeaderIndex );
-}
-
-
-int LSAPI_Release_r( LSAPI_Request * pReq )
-{
- if ( pReq->m_pReqBuf )
- free( pReq->m_pReqBuf );
- if ( pReq->m_pSpecialEnvList )
- free( pReq->m_pSpecialEnvList );
- if ( pReq->m_pEnvList )
- free( pReq->m_pEnvList );
- if ( pReq->m_pRespHeaderBuf )
- free( pReq->m_pRespHeaderBuf );
- return 0;
-}
-
-
-char * LSAPI_GetHeader_r( LSAPI_Request * pReq, int headerIndex )
-{
- int off;
- if ( !pReq || ((unsigned int)headerIndex > H_TRANSFER_ENCODING) )
- return NULL;
- off = pReq->m_pHeaderIndex->m_headerOff[ headerIndex ];
- if ( !off )
- return NULL;
- if ( *(pReq->m_pHttpHeader + off +
- pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) )
- *( pReq->m_pHttpHeader + off +
- pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) = 0;
- return pReq->m_pHttpHeader + off;
-}
-
-
-
-int LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, int bufLen )
-{
- int len;
- int total;
- //char *pOldBuf = pBuf;
- if (!pReq || ( !pBuf )||(bufLen < 0 ))
- return -1;
-
- total = pReq->m_pHeader->m_reqBodyLen - pReq->m_reqBodyRead;
-
- if ( total <= 0 )
- return 0;
- if ( total < bufLen )
- bufLen = total;
-
- total = 0;
- len = pReq->m_bufRead - pReq->m_bufProcessed;
- if ( len > 0 )
- {
- if ( len > bufLen )
- len = bufLen;
- memmove( pBuf, pReq->m_pReqBuf + pReq->m_bufProcessed, len );
- pReq->m_bufProcessed += len;
- total += len;
- pBuf += len;
- bufLen -= len;
- }
- while( bufLen > 0 )
- {
- len = lsapi_read( pReq->m_fd, pBuf, bufLen );
- if ( len > 0 )
- {
- total += len;
- pBuf += len;
- bufLen -= len;
- }
- else if ( len < 0 )
- return -1;
- }
- pReq->m_reqBodyRead += total;
- return total;
-
-}
-
-
-//int LSAPI_Write( const char * pBuf, int len )
-//{
-// return LSAPI_Write_r( &g_req, pBuf, len );
-//}
-
-int LSAPI_Write_r( LSAPI_Request * pReq, const char * pBuf, int len )
-{
- struct lsapi_packet_header * pHeader;
- const char * pEnd;
- const char * p;
- int bufLen;
- int toWrite;
- int packetLen;
-
- if ( !pReq || !pBuf )
- return -1;
- if ( len < pReq->m_pRespBufEnd - pReq->m_pRespBufPos )
- {
- memmove( pReq->m_pRespBufPos, pBuf, len );
- pReq->m_pRespBufPos += len;
- return len;
- }
-
- if ( pReq->m_reqState & LSAPI_ST_RESP_HEADER )
- {
- LSAPI_FinalizeRespHeaders_r( pReq );
- }
- pReq->m_reqState |= LSAPI_ST_RESP_BODY;
-
- pHeader = pReq->m_respPktHeader;
- p = pBuf;
- pEnd = pBuf + len;
- bufLen = pReq->m_pRespBufPos - pReq->m_pRespBuf;
-
- while( ( toWrite = pEnd - p ) > 0 )
- {
- packetLen = toWrite + bufLen;
- if ( LSAPI_MAX_DATA_PACKET_LEN < packetLen)
- {
- packetLen = LSAPI_MAX_DATA_PACKET_LEN;
- toWrite = packetLen - bufLen;
- }
-
- lsapi_buildPacketHeader( pHeader, LSAPI_RESP_STREAM,
- packetLen + LSAPI_PACKET_HEADER_LEN );
- pReq->m_totalLen += packetLen + LSAPI_PACKET_HEADER_LEN;
-
- pReq->m_pIovecCur->iov_base = (void *)pHeader;
- pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
- ++pReq->m_pIovecCur;
- ++pHeader;
- if ( bufLen > 0 )
- {
- pReq->m_pIovecCur->iov_base = (void *)pReq->m_pRespBuf;
- pReq->m_pIovecCur->iov_len = bufLen;
- pReq->m_pRespBufPos = pReq->m_pRespBuf;
- ++pReq->m_pIovecCur;
- bufLen = 0;
- }
-
- pReq->m_pIovecCur->iov_base = (void *)p;
- pReq->m_pIovecCur->iov_len = toWrite;
- ++pReq->m_pIovecCur;
- p += toWrite;
-
- if ( pHeader >= pReq->m_respPktHeaderEnd - 1)
- {
- if ( LSAPI_Flush_r( pReq ) == -1 )
- return -1;
- pHeader = pReq->m_respPktHeader;
- }
- }
- if ( pHeader != pReq->m_respPktHeader )
- if ( LSAPI_Flush_r( pReq ) == -1 )
- return -1;
- return p - pBuf;
-}
-
-void Flush_RespBuf_r( LSAPI_Request * pReq )
-{
- struct lsapi_packet_header * pHeader = pReq->m_respPktHeader;
- int bufLen = pReq->m_pRespBufPos - pReq->m_pRespBuf;
- pReq->m_reqState |= LSAPI_ST_RESP_BODY;
- lsapi_buildPacketHeader( pHeader, LSAPI_RESP_STREAM,
- bufLen + LSAPI_PACKET_HEADER_LEN );
- pReq->m_totalLen += bufLen + LSAPI_PACKET_HEADER_LEN;
-
- pReq->m_pIovecCur->iov_base = (void *)pHeader;
- pReq->m_pIovecCur->iov_len = LSAPI_PACKET_HEADER_LEN;
- ++pReq->m_pIovecCur;
- ++pHeader;
- if ( bufLen > 0 )
- {
- pReq->m_pIovecCur->iov_base = (void *)pReq->m_pRespBuf;
- pReq->m_pIovecCur->iov_len = bufLen;
- pReq->m_pRespBufPos = pReq->m_pRespBuf;
- ++pReq->m_pIovecCur;
- bufLen = 0;
- }
-}
-
-
-
-
-int LSAPI_Flush_r( LSAPI_Request * pReq )
-{
- int ret = 0;
- int n;
- if ( !pReq )
- return -1;
- if ( pReq->m_reqState & LSAPI_ST_RESP_HEADER )
- {
- LSAPI_FinalizeRespHeaders_r( pReq );
- }
- if ( pReq->m_pRespBufPos != pReq->m_pRespBuf )
- {
- Flush_RespBuf_r( pReq );
- }
- n = pReq->m_pIovecCur - pReq->m_pIovecToWrite;
- if ( n > 0 )
- {
-
- ret = lsapi_writev( pReq->m_fd, &pReq->m_pIovecToWrite,
- n, pReq->m_totalLen );
- if ( ret < pReq->m_totalLen )
- {
- lsapi_close( pReq->m_fd );
- pReq->m_fd = -1;
- ret = -1;
- }
- pReq->m_totalLen = 0;
- pReq->m_pIovecCur = pReq->m_pIovecToWrite = pReq->m_pIovec;
- }
- return ret;
-}
-
-
-int LSAPI_Write_Stderr_r( LSAPI_Request * pReq, const char * pBuf, int len )
-{
- struct lsapi_packet_header header;
- const char * pEnd;
- const char * p;
- int packetLen;
- int totalLen;
- int ret;
- struct iovec iov[2];
- struct iovec *pIov;
-
- if ( pReq->m_pRespBufPos != pReq->m_pRespBuf )
- {
- LSAPI_Flush_r( pReq );
- }
-
- p = pBuf;
- pEnd = pBuf + len;
-
- while( ( packetLen = pEnd - p ) > 0 )
- {
- if ( LSAPI_MAX_DATA_PACKET_LEN < packetLen)
- {
- packetLen = LSAPI_MAX_DATA_PACKET_LEN;
- }
-
- lsapi_buildPacketHeader( &header, LSAPI_STDERR_STREAM,
- packetLen + LSAPI_PACKET_HEADER_LEN );
- totalLen = packetLen + LSAPI_PACKET_HEADER_LEN;
-
- iov[0].iov_base = (void *)&header;
- iov[0].iov_len = LSAPI_PACKET_HEADER_LEN;
-
- iov[1].iov_base = (void *)p;
- iov[1].iov_len = packetLen;
- p += packetLen;
- pIov = iov;
- ret = lsapi_writev( pReq->m_fd, &pIov,
- 2, totalLen );
- if ( ret < totalLen )
- {
- lsapi_close( pReq->m_fd );
- pReq->m_fd = -1;
- ret = -1;
- }
- }
- return p - pBuf;
-}
-
-
-char * LSAPI_GetEnv_r( LSAPI_Request * pReq, const char * name )
-{
- struct LSAPI_key_value_pair * pBegin = pReq->m_pEnvList;
- struct LSAPI_key_value_pair * pEnd = pBegin + pReq->m_pHeader->m_cntEnv;
- if ( !pReq || !name )
- return NULL;
- while( pBegin < pEnd )
- {
- if ( strcmp( name, pBegin->pKey ) == 0 )
- return pBegin->pValue;
- ++pBegin;
- }
- return NULL;
-}
-
-
-int LSAPI_ForeachHeader_r( LSAPI_Request * pReq,
- LSAPI_CB_EnvHandler fn, void * arg )
-{
- int i;
- int len = 0;
- char * pValue;
- int ret;
- int count = 0;
- if ( !pReq || !fn )
- return -1;
- for( i = 0; i < H_TRANSFER_ENCODING; ++i )
- {
- if ( pReq->m_pHeaderIndex->m_headerOff[i] )
- {
- len = pReq->m_pHeaderIndex->m_headerLen[i];
- pValue = pReq->m_pHttpHeader + pReq->m_pHeaderIndex->m_headerOff[i];
- *(pValue + len ) = 0;
- ret = (*fn)( CGI_HEADERS[i], CGI_HEADER_LEN[i],
- pValue, len, arg );
- ++count;
- if ( ret <= 0 )
- return ret;
- }
- }
- if ( pReq->m_pHeader->m_cntUnknownHeaders > 0 )
- {
- char achHeaderName[256];
- char *p;
- char *pKey;
- char *pKeyEnd ;
- int keyLen;
- struct lsapi_header_offset * pCur, *pEnd;
- pCur = pReq->m_pUnknownHeader;
- pEnd = pCur + pReq->m_pHeader->m_cntUnknownHeaders;
- while( pCur < pEnd )
- {
- pKey = pReq->m_pHttpHeader + pCur->nameOff;
- keyLen = pCur->nameLen;
- pKeyEnd = pKey + keyLen;
- memcpy( achHeaderName, "HTTP_", 5 );
- p = &achHeaderName[5];
- if ( keyLen > 250 )
- keyLen = 250;
-
- while( pKey < pKeyEnd )
- {
- char ch = *pKey++;
- if ( ch == '-' )
- *p++ = '_';
- else
- *p++ = toupper( ch );
- }
- *p = 0;
- keyLen += 5;
-
- pValue = pReq->m_pHttpHeader + pCur->valueOff;
- *(pValue + pCur->valueLen ) = 0;
- ret = (*fn)( achHeaderName, pCur->valueLen,
- pValue, len, arg );
- if ( ret <= 0 )
- return ret;
- ++pCur;
- }
- }
- return count + pReq->m_pHeader->m_cntUnknownHeaders;
-
-}
-
-static int EnvForeach( struct LSAPI_key_value_pair * pEnv,
- int n, LSAPI_CB_EnvHandler fn, void * arg )
-{
- struct LSAPI_key_value_pair * pEnd = pEnv + n;
- int ret;
- if ( !pEnv || !fn )
- return -1;
- while( pEnv < pEnd )
- {
- ret = (*fn)( pEnv->pKey, pEnv->keyLen,
- pEnv->pValue, pEnv->valLen, arg );
- if ( ret <= 0 )
- return ret;
- ++pEnv;
- }
- return n;
-}
-
-
-
-int LSAPI_ForeachEnv_r( LSAPI_Request * pReq,
- LSAPI_CB_EnvHandler fn, void * arg )
-{
- if ( !pReq || !fn )
- return -1;
- if ( pReq->m_pHeader->m_cntEnv > 0 )
- {
- return EnvForeach( pReq->m_pEnvList, pReq->m_pHeader->m_cntEnv,
- fn, arg );
- }
- return 0;
-}
-
-
-
-int LSAPI_ForeachSpecialEnv_r( LSAPI_Request * pReq,
- LSAPI_CB_EnvHandler fn, void * arg )
-{
- if ( !pReq || !fn )
- return -1;
- if ( pReq->m_pHeader->m_cntSpecialEnv > 0 )
- {
- return EnvForeach( pReq->m_pSpecialEnvList,
- pReq->m_pHeader->m_cntSpecialEnv,
- fn, arg );
- }
- return 0;
-
-}
-
-
-
-int LSAPI_FinalizeRespHeaders_r( LSAPI_Request * pReq )
-{
- if ( !pReq || !pReq->m_pIovec )
- return -1;
- if ( !( pReq->m_reqState & LSAPI_ST_RESP_HEADER ) )
- return 0;
- pReq->m_reqState &= ~LSAPI_ST_RESP_HEADER;
- if ( pReq->m_pRespHeaderBufPos > pReq->m_pRespHeaderBuf )
- {
- pReq->m_pIovecCur->iov_base = (void *)pReq->m_pRespHeaderBuf;
- pReq->m_pIovecCur->iov_len = pReq->m_pRespHeaderBufPos - pReq->m_pRespHeaderBuf;
- pReq->m_totalLen += pReq->m_pIovecCur->iov_len;
- ++pReq->m_pIovecCur;
- }
-
- pReq->m_pIovec->iov_len = sizeof( struct lsapi_resp_header)
- + pReq->m_respHeader.m_respInfo.m_cntHeaders * sizeof( short );
- pReq->m_totalLen += pReq->m_pIovec->iov_len;
-
- lsapi_buildPacketHeader( &pReq->m_respHeader.m_pktHeader,
- LSAPI_RESP_HEADER, pReq->m_totalLen );
- pReq->m_pIovec->iov_base = (void *)&pReq->m_respHeader;
- pReq->m_pIovecToWrite = pReq->m_pIovec;
- return 0;
-}
-
-
-
-
-int LSAPI_AppendRespHeader_r( LSAPI_Request * pReq, char * pBuf, int len )
-{
- if ( !pReq || !pBuf || len <= 0 || len > LSAPI_RESP_HTTP_HEADER_MAX )
- return -1;
- if ( pReq->m_reqState & LSAPI_ST_RESP_BODY )
- return -1;
- if ( pReq->m_respHeader.m_respInfo.m_cntHeaders >= LSAPI_MAX_RESP_HEADERS )
- return -1;
- if ( pReq->m_pRespHeaderBufPos + len + 1 > pReq->m_pRespHeaderBufEnd )
- {
- int newlen = pReq->m_pRespHeaderBufPos + len + 4096 - pReq->m_pRespHeaderBuf;
- newlen -= newlen % 4096;
- if ( allocateRespHeaderBuf( pReq, newlen ) == -1 )
- return -1;
- }
- memmove( pReq->m_pRespHeaderBufPos, pBuf, len );
- pReq->m_pRespHeaderBufPos += len;
- *pReq->m_pRespHeaderBufPos++ = 0;
- ++len; //add one byte padding for \0
- pReq->m_respHeaderLen[pReq->m_respHeader.m_respInfo.m_cntHeaders] = len;
- ++pReq->m_respHeader.m_respInfo.m_cntHeaders;
- return 0;
-}
-
-
-
-
-
-
diff --git a/sapi/litespeed/lsapilib.h b/sapi/litespeed/lsapilib.h
deleted file mode 100644
index e1c156fa51..0000000000
--- a/sapi/litespeed/lsapilib.h
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
-Copyright (c) 2005, Lite Speed Technologies Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
- * Neither the name of the Lite Speed Technologies Inc nor the
- names of its contributors may be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/***************************************************************************
- lsapilib.h - description
- -------------------
- begin : Mon Feb 21 2005
- copyright : (C) 2005 by George Wang
- email : gwang@litespeedtech.com
- ***************************************************************************/
-
-
-#ifndef _LSAPILIB_H_
-#define _LSAPILIB_H_
-
-#if defined (c_plusplus) || defined (__cplusplus)
-extern "C" {
-#endif
-
-#include <stddef.h>
-#include <lsapidef.h>
-
-struct LSAPI_key_value_pair
-{
- char * pKey;
- char * pValue;
- int keyLen;
- int valLen;
-};
-
-
-#define LSAPI_MAX_RESP_HEADERS 100
-
-typedef struct lsapi_request
-{
- int m_fdListen;
- int m_fd;
-
- char * m_pReqBuf;
- int m_reqBufSize;
-
- char * m_pRespBuf;
- char * m_pRespBufEnd;
- char * m_pRespBufPos;
-
- char * m_pRespHeaderBuf;
- char * m_pRespHeaderBufEnd;
- char * m_pRespHeaderBufPos;
-
-
- struct iovec * m_pIovec;
- struct iovec * m_pIovecEnd;
- struct iovec * m_pIovecCur;
- struct iovec * m_pIovecToWrite;
-
- struct lsapi_packet_header * m_respPktHeaderEnd;
-
- struct lsapi_req_header * m_pHeader;
- struct LSAPI_key_value_pair * m_pEnvList;
- struct LSAPI_key_value_pair * m_pSpecialEnvList;
- int m_envListSize;
- int m_specialEnvListSize;
-
- struct lsapi_http_header_index * m_pHeaderIndex;
- struct lsapi_header_offset * m_pUnknownHeader;
-
- char * m_pScriptFile;
- char * m_pScriptName;
- char * m_pQueryString;
- char * m_pHttpHeader;
- char * m_pRequestMethod;
- int m_totalLen;
- int m_reqState;
- int m_reqBodyRead;
- int m_bufProcessed;
- int m_bufRead;
-
- struct lsapi_packet_header m_respPktHeader[5];
-
- struct lsapi_resp_header m_respHeader;
- short m_respHeaderLen[LSAPI_MAX_RESP_HEADERS];
-
-}LSAPI_Request;
-
-extern LSAPI_Request g_req;
-
-
-//return: >0 continue, ==0 stop, -1 failed
-typedef int (*LSAPI_CB_EnvHandler )( const char * pKey, int keyLen,
- const char * pValue, int valLen, void * arg );
-
-
-int LSAPI_Init(void);
-
-void LSAPI_stop(void);
-
-int LSAPI_Is_Listen_r( LSAPI_Request * pReq);
-
-int LSAPI_InitRequest( LSAPI_Request * pReq, int fd );
-
-int LSAPI_Accept_r( LSAPI_Request * pReq );
-
-void LSAPI_Reset_r( LSAPI_Request * pReq );
-
-int LSAPI_Finish_r( LSAPI_Request * pReq );
-
-int LSAPI_Release_r( LSAPI_Request * pReq );
-
-char * LSAPI_GetHeader_r( LSAPI_Request * pReq, int headerIndex );
-
-int LSAPI_ForeachHeader_r( LSAPI_Request * pReq,
- LSAPI_CB_EnvHandler fn, void * arg );
-
-int LSAPI_ForeachEnv_r( LSAPI_Request * pReq,
- LSAPI_CB_EnvHandler fn, void * arg );
-
-int LSAPI_ForeachSpecialEnv_r( LSAPI_Request * pReq,
- LSAPI_CB_EnvHandler fn, void * arg );
-
-char * LSAPI_GetEnv_r( LSAPI_Request * pReq, const char * name );
-
-
-int LSAPI_GetContentLen_r( LSAPI_Request * pReq );
-
-int LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, int len );
-
-int LSAPI_FinalizeRespHeaders_r( LSAPI_Request * pReq );
-
-int LSAPI_Write_r( LSAPI_Request * pReq, const char * pBuf, int len );
-
-int LSAPI_Write_Stderr_r( LSAPI_Request * pReq, const char * pBuf, int len );
-
-int LSAPI_Flush_r( LSAPI_Request * pReq );
-
-int LSAPI_AppendRespHeader_r( LSAPI_Request * pHeader, char * pBuf, int len );
-
-static inline int LSAPI_SetRespStatus_r( LSAPI_Request * pReq, int code )
-{
- if ( !pReq )
- return -1;
- pReq->m_respHeader.m_respInfo.m_status = code;
- return 0;
-}
-
-static inline char * LSAPI_GetQueryString_r( LSAPI_Request * pReq )
-{
- if ( pReq )
- return pReq->m_pQueryString;
- return NULL;
-}
-
-
-static inline char * LSAPI_GetScriptFileName_r( LSAPI_Request * pReq )
-{
- if ( pReq )
- return pReq->m_pScriptFile;
- return NULL;
-}
-
-
-static inline char * LSAPI_GetScriptName_r( LSAPI_Request * pReq )
-{
- if ( pReq )
- return pReq->m_pScriptName;
- return NULL;
-}
-
-
-static inline char * LSAPI_GetRequestMethod_r( LSAPI_Request * pReq)
-{
- if ( pReq )
- return pReq->m_pRequestMethod;
- return NULL;
-}
-
-
-
-static inline int LSAPI_GetReqBodyLen_r( LSAPI_Request * pReq )
-{
- if ( pReq )
- return pReq->m_pHeader->m_reqBodyLen;
- return -1;
-}
-
-
-int LSAPI_Is_Listen(void);
-
-static inline int LSAPI_Accept( void )
-{ return LSAPI_Accept_r( &g_req ); }
-
-static inline int LSAPI_Finish(void)
-{ return LSAPI_Finish_r( &g_req ); }
-
-static inline char * LSAPI_GetHeader( int headerIndex )
-{ return LSAPI_GetHeader_r( &g_req, headerIndex ); }
-
-static inline int LSAPI_ForeachHeader( LSAPI_CB_EnvHandler fn, void * arg )
-{ return LSAPI_ForeachHeader_r( &g_req, fn, arg ); }
-
-static inline int LSAPI_ForeachEnv( LSAPI_CB_EnvHandler fn, void * arg )
-{ return LSAPI_ForeachEnv_r( &g_req, fn, arg ); }
-
-static inline int LSAPI_ForeachSpecialEnv( LSAPI_CB_EnvHandler fn, void * arg )
-{ return LSAPI_ForeachSpecialEnv_r( &g_req, fn, arg ); }
-
-static inline char * LSAPI_GetEnv( const char * name )
-{ return LSAPI_GetEnv_r( &g_req, name ); }
-
-static inline char * LSAPI_GetQueryString()
-{ return LSAPI_GetQueryString_r( &g_req ); }
-
-static inline char * LSAPI_GetScriptFileName()
-{ return LSAPI_GetScriptFileName_r( &g_req ); }
-
-static inline char * LSAPI_GetScriptName()
-{ return LSAPI_GetScriptName_r( &g_req ); }
-
-static inline char * LSAPI_GetRequestMethod()
-{ return LSAPI_GetRequestMethod_r( &g_req ); }
-
-static inline int LSAPI_GetReqBodyLen()
-{ return LSAPI_GetReqBodyLen_r( &g_req ); }
-
-static inline int LSAPI_ReadReqBody( char * pBuf, int len )
-{ return LSAPI_ReadReqBody_r( &g_req, pBuf, len ); }
-
-static inline int LSAPI_FinalizeRespHeaders(void)
-{ return LSAPI_FinalizeRespHeaders_r( &g_req ); }
-
-static inline int LSAPI_Write( const char * pBuf, int len )
-{ return LSAPI_Write_r( &g_req, pBuf, len ); }
-
-static inline int LSAPI_Write_Stderr( const char * pBuf, int len )
-{ return LSAPI_Write_Stderr_r( &g_req, pBuf, len ); }
-
-static inline int LSAPI_Flush()
-{ return LSAPI_Flush_r( &g_req ); }
-
-static inline int LSAPI_AppendRespHeader( char * pBuf, int len )
-{ return LSAPI_AppendRespHeader_r( &g_req, pBuf, len ); }
-
-static inline int LSAPI_SetRespStatus( int code )
-{ return LSAPI_SetRespStatus_r( &g_req, code ); }
-
-
-#if defined (c_plusplus) || defined (__cplusplus)
-}
-#endif
-
-
-#endif
-
-
-
-
-
-
-