summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2007-07-24 14:25:08 +0000
committerSVN Migration <svn@php.net>2007-07-24 14:25:08 +0000
commit8f377452f1ec5fcccdfdeb83791baf0033c7f48a (patch)
tree4ff14700c6134066946fb4e063e30b43c8f771e1
parent9343c54040883483b20824ad50252e64b348a1cd (diff)
downloadphp-git-BEFORE_REAL_IMPORT_OF_MYSQLND.tar.gz
This commit was manufactured by cvs2svn to create tagBEFORE_REAL_IMPORT_OF_MYSQLND
'BEFORE_REAL_IMPORT_OF_MYSQLND'.
-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.m467
-rw-r--r--ext/fileinfo/config.w3213
-rw-r--r--ext/fileinfo/fileinfo.c448
-rw-r--r--ext/fileinfo/fileinfo.php29
-rw-r--r--ext/fileinfo/package.xml44
-rw-r--r--ext/fileinfo/php_fileinfo.h61
-rw-r--r--ext/imap/imap.h103
-rw-r--r--ext/phar/CREDITS2
-rw-r--r--ext/phar/LICENSE68
-rwxr-xr-xext/phar/Makefile.frag13
-rw-r--r--ext/phar/TODO77
-rwxr-xr-xext/phar/build_precommand.php60
-rw-r--r--ext/phar/config.m413
-rw-r--r--ext/phar/config.w3211
-rw-r--r--ext/phar/package.php75
-rw-r--r--ext/phar/package.xml283
-rw-r--r--ext/phar/phar.c3561
-rwxr-xr-xext/phar/phar.phar1227
-rwxr-xr-xext/phar/phar/clicommand.inc377
-rwxr-xr-xext/phar/phar/directorygraphiterator.inc34
-rwxr-xr-xext/phar/phar/directorytreeiterator.inc54
-rwxr-xr-xext/phar/phar/invertedregexiterator.inc27
-rwxr-xr-xext/phar/phar/phar.inc80
-rwxr-xr-xext/phar/phar/phar.php57
-rwxr-xr-xext/phar/phar/pharcommand.inc1406
-rwxr-xr-xext/phar/phar_internal.h297
-rwxr-xr-xext/phar/phar_object.c1519
-rwxr-xr-xext/phar/phar_path_check.c196
-rwxr-xr-xext/phar/phar_path_check.re101
-rw-r--r--ext/phar/php_phar.h45
-rw-r--r--ext/phar/tests/001.phpt12
-rw-r--r--ext/phar/tests/002.phpt17
-rw-r--r--ext/phar/tests/003.phpt13
-rwxr-xr-xext/phar/tests/003a.phpt14
-rw-r--r--ext/phar/tests/004.phpt14
-rw-r--r--ext/phar/tests/005.phpt14
-rw-r--r--ext/phar/tests/006.phpt14
-rw-r--r--ext/phar/tests/007.phpt14
-rw-r--r--ext/phar/tests/008.phpt21
-rw-r--r--ext/phar/tests/009.phpt23
-rw-r--r--ext/phar/tests/010.phpt29
-rw-r--r--ext/phar/tests/011.phpt30
-rw-r--r--ext/phar/tests/012.phpt25
-rw-r--r--ext/phar/tests/013.phpt23
-rw-r--r--ext/phar/tests/014.phpt23
-rw-r--r--ext/phar/tests/015.phpt23
-rwxr-xr-xext/phar/tests/015b.phpt23
-rw-r--r--ext/phar/tests/016.phpt39
-rwxr-xr-xext/phar/tests/016b.phpt24
-rw-r--r--ext/phar/tests/017.phpt25
-rw-r--r--ext/phar/tests/018.phpt33
-rw-r--r--ext/phar/tests/019.phpt34
-rwxr-xr-xext/phar/tests/019b.phpt65
-rwxr-xr-xext/phar/tests/019c.phpt73
-rw-r--r--ext/phar/tests/020.phpt136
-rw-r--r--ext/phar/tests/021.phpt85
-rw-r--r--ext/phar/tests/022.phpt110
-rwxr-xr-xext/phar/tests/023.phpt32
-rwxr-xr-xext/phar/tests/024.phpt32
-rwxr-xr-xext/phar/tests/025.phpt32
-rwxr-xr-xext/phar/tests/026.phpt34
-rwxr-xr-xext/phar/tests/027.phpt62
-rwxr-xr-xext/phar/tests/028.phpt46
-rwxr-xr-xext/phar/tests/029.phpt48
-rwxr-xr-xext/phar/tests/030.phpt38
-rwxr-xr-xext/phar/tests/031.phpt31
-rwxr-xr-xext/phar/tests/032.phpt29
-rw-r--r--ext/phar/tests/033.phpt33
-rw-r--r--ext/phar/tests/033a.phpt36
-rwxr-xr-xext/phar/tests/create_new_and_modify.phpt48
-rw-r--r--ext/phar/tests/create_new_phar.phpt21
-rwxr-xr-xext/phar/tests/create_new_phar_b.phpt29
-rwxr-xr-xext/phar/tests/create_new_phar_c.phpt29
-rwxr-xr-xext/phar/tests/create_path_error.phpt64
-rw-r--r--ext/phar/tests/delete_in_phar.phpt48
-rwxr-xr-xext/phar/tests/delete_in_phar_b.phpt46
-rw-r--r--ext/phar/tests/delete_in_phar_confirm.phpt51
-rwxr-xr-xext/phar/tests/extracted.inc1
-rwxr-xr-xext/phar/tests/extracted_001.phpt35
-rw-r--r--ext/phar/tests/ini_set.phpt28
-rw-r--r--ext/phar/tests/ini_set_off.phpt85
-rw-r--r--ext/phar/tests/metadata_read.phpt61
-rwxr-xr-xext/phar/tests/metadata_write.phpt61
-rwxr-xr-xext/phar/tests/metadata_write_commit.phpt79
-rw-r--r--ext/phar/tests/open_for_write_existing.phpt31
-rwxr-xr-xext/phar/tests/open_for_write_existing_b.phpt42
-rwxr-xr-xext/phar/tests/open_for_write_existing_c.phpt36
-rw-r--r--ext/phar/tests/open_for_write_newfile.phpt33
-rwxr-xr-xext/phar/tests/open_for_write_newfile_b.phpt49
-rwxr-xr-xext/phar/tests/open_for_write_newfile_c.phpt43
-rwxr-xr-xext/phar/tests/phar_begin_setstub_commit.phpt50
-rw-r--r--ext/phar/tests/phar_commitwrite.phpt42
-rw-r--r--ext/phar/tests/phar_create_in_cwd.phpt37
-rw-r--r--ext/phar/tests/phar_ctx_001.phpt100
-rwxr-xr-xext/phar/tests/phar_get_suppoted_signatures_001.phpt22
-rwxr-xr-xext/phar/tests/phar_get_suppoted_signatures_002.phpt26
-rw-r--r--ext/phar/tests/phar_metadata_read.phpt64
-rw-r--r--ext/phar/tests/phar_metadata_write.phpt69
-rwxr-xr-xext/phar/tests/phar_offset_get_error.phpt37
-rwxr-xr-xext/phar/tests/phar_oo_001.phpt45
-rwxr-xr-xext/phar/tests/phar_oo_002.phpt137
-rwxr-xr-xext/phar/tests/phar_oo_003.phpt45
-rwxr-xr-xext/phar/tests/phar_oo_004.phpt126
-rwxr-xr-xext/phar/tests/phar_oo_005.phpt59
-rwxr-xr-xext/phar/tests/phar_oo_006.phpt52
-rwxr-xr-xext/phar/tests/phar_oo_007.phpt87
-rwxr-xr-xext/phar/tests/phar_oo_008.phpt119
-rwxr-xr-xext/phar/tests/phar_oo_009.phpt56
-rwxr-xr-xext/phar/tests/phar_oo_010.phpt55
-rw-r--r--ext/phar/tests/phar_oo_011.phpt34
-rwxr-xr-xext/phar/tests/phar_oo_011b.phpt39
-rw-r--r--ext/phar/tests/phar_oo_012.phpt37
-rw-r--r--ext/phar/tests/phar_oo_012_confirm.phpt40
-rwxr-xr-xext/phar/tests/phar_oo_012b.phpt42
-rw-r--r--ext/phar/tests/phar_oo_compressallbz2.phpt65
-rw-r--r--ext/phar/tests/phar_oo_compressallgz.phpt65
-rw-r--r--ext/phar/tests/phar_oo_compressed_001.phpt68
-rwxr-xr-xext/phar/tests/phar_oo_compressed_001b.phpt68
-rwxr-xr-xext/phar/tests/phar_oo_compressed_002.phpt73
-rwxr-xr-xext/phar/tests/phar_oo_compressed_002b.phpt73
-rwxr-xr-xext/phar/tests/phar_oo_test.inc49
-rw-r--r--ext/phar/tests/phar_oo_uncompressall.phpt79
-rw-r--r--ext/phar/tests/phar_setsignaturealgo1.phpt69
-rw-r--r--ext/phar/tests/phar_setsignaturealgo2.phpt79
-rw-r--r--ext/phar/tests/phar_stub.phpt81
-rwxr-xr-xext/phar/tests/phar_stub_error.phpt56
-rwxr-xr-xext/phar/tests/phar_stub_write.phpt64
-rwxr-xr-xext/phar/tests/phar_stub_write_file.phpt64
-rwxr-xr-xext/phar/tests/phar_test.inc64
-rw-r--r--ext/phar/tests/refcount1.phpt53
-rw-r--r--ext/phar/tests/rename.phpt32
-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
154 files changed, 0 insertions, 19197 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 686f6e2780..0000000000
--- a/ext/fileinfo/config.m4
+++ /dev/null
@@ -1,67 +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_DIRS="/usr/local/share/file /usr/share/file /usr/share/misc/file /etc /usr/share/misc"
- MAGIC_MIME_FILENAMES="magic magic.mime"
-
- for i in $MAGIC_MIME_DIRS; do
- for j in $MAGIC_MIME_FILENAMES; do
- if test -f "$i/$j"; then
- PHP_DEFAULT_MAGIC_FILE="$i/$j"
- break
- fi
- done
- 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 975b9c5349..0000000000
--- a/ext/fileinfo/fileinfo.c
+++ /dev/null
@@ -1,448 +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[] = {
-#if PHP_VERSION_ID >= 50200
- ZEND_ME_MAPPING(finfo, finfo_open, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME_MAPPING(set_flags, finfo_set_flags,NULL, ZEND_ACC_PUBLIC)
- ZEND_ME_MAPPING(file, finfo_file, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME_MAPPING(buffer, finfo_buffer, NULL, ZEND_ACC_PUBLIC)
-#else
- 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)
-#endif
- {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);
-#ifdef MAGIC_PRESERVE_ATIME
- REGISTER_LONG_CONSTANT("FILEINFO_PRESERVE_ATIME", MAGIC_PRESERVE_ATIME, CONST_CS|CONST_PERSISTENT);
-#endif
-#ifdef MAGIC_RAW
- REGISTER_LONG_CONSTANT("FILEINFO_RAW", MAGIC_RAW, CONST_CS|CONST_PERSISTENT);
-#endif
-
- 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 a274e47161..0000000000
--- a/ext/fileinfo/package.xml
+++ /dev/null
@@ -1,44 +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.4</version>
- <date>2006-11-07</date>
- <notes>
- 1) Fixed detection of magic files
- 2) Fixed build problems with older version of libmagic
- </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/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/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/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/Makefile.frag b/ext/phar/Makefile.frag
deleted file mode 100755
index 5396dd31dc..0000000000
--- a/ext/phar/Makefile.frag
+++ /dev/null
@@ -1,13 +0,0 @@
-
-$(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
- $(RE2C) -b -o $(srcdir)/phar_path_check.c $(srcdir)/phar_path_check.re)
-
-pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
-
-$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php
- php $(srcdir)/build_precommand.php > $(builddir)/phar.php
-
-$(builddir)/phar.phar: $(builddir)/phar.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php
- php -d phar.readonly=0 $(srcdir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x CVS -p 0 -s $(srcdir)/phar/phar.php -h sha1 $(srcdir)/phar/
- @chmod +x $(builddir)/phar.phar
-
diff --git a/ext/phar/TODO b/ext/phar/TODO
deleted file mode 100644
index cde6eadc93..0000000000
--- a/ext/phar/TODO
+++ /dev/null
@@ -1,77 +0,0 @@
-Version 1.0.0
-
- X make permissions in the lowest bits of flags to simplify using them [Greg]
- X implement ini handler for phar.readonly and phar.require_hash that allows
- enabling it on PHP_INI_ALL if it is disabled in the system, but does not
- allow disabling it if it is enabled in the system [Greg]
- X implement reading in metadata in manifest as <len32><metadata...> [Marcus]
- X implement writing out of metadata to new manifest [Marcus]
- X if SPL is disabled, enable only static methods of class Phar and disable
- class PharFileInfo completely [Marcus]
- X implement in-phar locking, so that a file that is opened for reading can't
- have a handle opened for writing [Marcus/Greg]
- X docs on file format/manifest description [Greg]
- X docs on uses [Greg]
- X stream context for specifying compression of a file [Marcus]
- X stream context for specifying meta-data [Greg]
- X Phar->begin()/Phar->commit() for specifying a new stub to the phar,
- and deferring flush until all modifications are complete [Greg]
- X Phar->getStub() for retrieving the stub of the phar [Marcus]
- X add setUncompressed(), setCompressedGZ() and setCompressedBZ2() to
- PharFileInfo class [Greg]
- X add uncompressAllFiles(), compressAllFilesGZ() and compressAllFilesBZ2()
- to Phar class [Greg]
- X add PharFileInfo::setMetaData($metadata) [Marcus]
- X add PharFileInfo::getMetaData() [Marcus]
- X always throw exceptions from the Phar object, and E_RECOVERABLE_ERROR from
- streams interface [Greg]
- X Phar archive metadata Phar::setMetaData($metadata) Phar::getMetaData() [Greg]
- X support rename() in stream wrapper [Greg]
- X update docs to reflect changes in error handling [Greg]
- X fix 011.phpt, 029.phpt for uncaught exceptions causing bad cleanup [Marcus/Greg]
-
-Version 1.1.0
-
- X Ability connect a phar file 'phar://whatever' to a directory. That way all
- access to that phar archive are directed to the extracted directory. This
- allows to have the installed files and the archieve keep the same includes.
- [Marcus]
- X add SHA-2 (256, 512) support [Marcus]
- X setSignatureAlgorithm() and Phar::MD5 Phar::SHA1 Phar::SHA256 Phar::SHA512 Phar::PGP to
- choose the kind of signature to use (PGP falls back to SHA1) [Greg]
-
-
-Version 1.2.0
-
- X add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
- X add Phar::hasMetadata(), Phar::delMetadata() [Marcus]
- X fix Phar::CanWrite() [Marcus]
- X add preliminary phar command (phar.php) [Marcus]
- X add phar command (phar.phar) [Marcus]
- X list all available compression methods using Phar::getSupportedCompression() [Marcus]
- X Remove RINIT [Marcus]
-
-Version 1.2.1
-
- X Add Phar::getAlias() [Marcus]
- * Add Phar::setAlias()
- X Make -a optional in pack subcommand of phar.phar [Marcus]
- X Make Phar::loadPhar() and Phar::mapPhar() ignore extracted archives
-
-Version 1.3.0
-
- * Provide an additional header that allows better compatibility with PHP 4
- __HALT_COMPILER();function __HALT_COMPILER(){}$a=<<<PHARDATABEGIN\n
- * ability to have Phar object return file class as offsetGet() result
- * ability to store empty directories
- * [optional] Phar->rollback() to abort a write transaction
- * implement PPG signing
- * ability to match files containing a metadata key opendir('phar://a.phar/?mime-type=image/jpeg')
- or foreach ($p->match('mime-type', 'image/jpeg') as $file)
- * Phar::copy($from, $to);
- * Phar::delete($what)
- * Phar::buildFromIterator($filename, Iterator $it, array $addinfo = null);
- $addinfo = array('alias','flags','metadata','stub'...)
- * Layout: Option to compress all content rather than single files.
- That excludes stub and manifest haeder.
- * stream context option for cleaning crap paths like phar://blah.phar/file//to\\here.php
diff --git a/ext/phar/build_precommand.php b/ext/phar/build_precommand.php
deleted file mode 100755
index 8904afdf05..0000000000
--- a/ext/phar/build_precommand.php
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/php
-<?php echo '<'.'?php';?>
-
-/** @file phar.php
- * @ingroup Phar
- * @brief class Phar Pre Command
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Phar Command
- */
-foreach(array("SPL", "Reflection", "Phar") as $ext)
-{
- if (!extension_loaded($ext))
- {
- echo "$argv[0] requires PHP extension $ext.\n";
- exit(1);
- }
-}
-
-<?php
-
-$classes = array(
- 'DirectoryTreeIterator',
- 'DirectoryGraphIterator',
- 'InvertedRegexIterator',
- 'CLICommand',
- 'PharCommand',
- );
-
-foreach($classes as $name)
-{
- echo "if (!class_exists('$name', 0))\n{\n";
- $f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc');
- unset($f[0]);
- $c = count($f);
- while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n"))
- {
- unset($f[$c--]);
- }
- if (substr($f[$c], -2) == "\r\n") {
- $f[$c] = substr($f[$c], 0, -2);
- }
- if (substr($f[$c], -1) == "\n") {
- $f[$c] = substr($f[$c], 0, -1);
- }
- if (substr($f[$c], -2) == '?>') {
- $f[$c] = substr($f[$c], 0,-2);
- }
- while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n"))
- {
- unset($f[$c--]);
- }
- echo join('', $f);
- echo "\n}\n\n";
-}
-
-echo 'new PharCommand($argc, $argv);'."\n";
-
-?>
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
deleted file mode 100644
index 4e31e7126b..0000000000
--- a/ext/phar/config.m4
+++ /dev/null
@@ -1,13 +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 phar_object.c phar_path_check.c, $ext_shared)
- PHP_ADD_EXTENSION_DEP(phar, zlib, true)
- PHP_ADD_EXTENSION_DEP(phar, bz2, true)
- PHP_ADD_EXTENSION_DEP(phar, spl, false)
- PHP_ADD_MAKEFILE_FRAGMENT
-fi
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
deleted file mode 100644
index d2392aa483..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 phar_object.c phar_path_check.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.php b/ext/phar/package.php
deleted file mode 100644
index c9b96e17e7..0000000000
--- a/ext/phar/package.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-
-$notes = '
- * add Phar::getAlias() [Marcus]
- * Made -a optional in pack subcommand of phar.phar [Marcus]
- * Fix issue with apache module and extracted archives [Marcus]
- * Send all error messages to stderr in phar.phar [Marcus]
- * Added new subcommands add and delete to phar.phar [Marcus]
- * Made Phar::loadPhar() and Phar::mapPhar() ignore extracted archives [Marcus]
- * Fix issue with compressed entries and uncompressing entries [Marcus]
- * Verify stubs before writing [Marcus]
- * Always use longest stub end to avoid issues with length field [Marcus]
-';
-
-if (!class_exists("Phar") && !extension_loaded("Phar")) {
- die("Extension phar not present");
-}
-
-require_once 'PEAR/PackageFileManager2.php';
-
-PEAR::setErrorHandling(PEAR_ERROR_DIE);
-
-$options = array(
- 'filelistgenerator' => 'CVS',
- 'changelogoldtonew' => false,
- 'simpleoutput' => true,
- 'baseinstalldir' => '/',
- 'packagedirectory' => dirname(__FILE__),
- 'packagefile' => 'package.xml',
- 'clearcontents' => true,
- 'ignore' => array('package*.php', 'package*.xml'),
- 'dir_roles' => array(
- 'docs' => 'doc',
- 'examples' => 'doc',
- 'tests' => 'test',
- 'phar' => 'src',
- ),
- 'exceptions' => array(
- 'CREDITS' => 'doc',
- 'EXPERIMENTAL' => 'doc',
- 'LICENSE' => 'doc',
- 'Makefile.frag' => 'src',
- 'phar_path_check.re' => 'src',
- 'TODO' => 'doc',
- ),
-);
-
-$package = PEAR_PackageFileManager2::importOptions(dirname(__FILE__) . '/package.xml', $options);
-
-$package->clearDeps();
-$package->setPhpDep('5.2.0');
-$package->setPearInstallerDep('1.4.3');
-$package->addPackageDepWithChannel('optional', 'bz2', 'pecl.php.net', false, false, false, false, 'bz2');
-// all this false business sets the <providesextension> tag that allows us to have hash built
-// in statically
-$package->addPackageDepWithChannel('optional', 'hash', 'pecl.php.net', false, false, false, false, 'hash');
-$package->addExtensionDep('optional', 'spl');
-$package->addExtensionDep('optional', 'zlib');
-$package->setPackageType('extsrc');
-$package->addRelease();
-$package->setReleaseVersion(phpversion('phar'));
-$package->setAPIVersion(Phar::apiVersion());
-$package->setReleaseStability('stable');
-$package->setAPIStability('stable');
-$package->setNotes("\n$notes\n");
-//$package->addGlobalReplacement('package-info', '@package_version@', 'version');
-$package->generateContents();
-
-if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) {
- $package->writePackageFile();
-} else {
- $package->debugPackageFile();
-}
-
-?>
diff --git a/ext/phar/package.xml b/ext/phar/package.xml
deleted file mode 100644
index 86d5a22366..0000000000
--- a/ext/phar/package.xml
+++ /dev/null
@@ -1,283 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.5.4" 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&apos;s PHP_Archive package. Support for
-zlib, bz2 and crc32 is achieved without any dependency other than the external
-zlib or bz2 extension.
-
-.phar files can be read using the phar stream, or with the Phar class. If the SPL extension
-is available, a Phar object can be used as an array to iterate over a phar&apos;s contents
-or to read files directly from the phar.
-
-Phar archives can be created using the streams API or with the Phar class, if
-the phar.readonly ini variable is set to false.
-
-Full support for MD5 and SHA1 signatures is possible. Signatures can be required
-if the ini variable phar.require_hash is set to true. When PECL extension hash is
-avaiable then SHA-256 and SHA-512 signatures are supported as well.</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>2007-05-18</date>
- <time>06:32:38</time>
- <version>
- <release>1.2.0</release>
- <api>1.1.0</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <license uri="http://www.php.net/license">PHP License</license>
- <notes>
-
- * add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
- * add Phar::hasMetadata(), Phar::delMetadata() [Marcus]
- * fix Phar::CanWrite() [Marcus]
- * add preliminary phar command (phar.php) [Marcus]
- * add phar command (phar.phar) [Marcus]
- * list all available compression methods using Phar::getSupportedCompression() [Marcus]
- * remove RINIT [Marcus]
-
- </notes>
- <contents>
- <dir baseinstalldir="/" name="/">
- <dir name="phar">
- <file name="clicommand.inc" role="src" />
- <file name="directorygraphiterator.inc" role="src" />
- <file name="directorytreeiterator.inc" role="src" />
- <file name="invertedregexiterator.inc" role="src" />
- <file name="phar.php" role="src" />
- <file name="pharcommand.inc" role="src" />
- </dir> <!-- /phar -->
- <dir name="tests">
- <file name="001.phpt" role="test" />
- <file name="002.phpt" role="test" />
- <file name="003.phpt" role="test" />
- <file name="003a.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="015b.phpt" role="test" />
- <file name="016.phpt" role="test" />
- <file name="016b.phpt" role="test" />
- <file name="017.phpt" role="test" />
- <file name="018.phpt" role="test" />
- <file name="019.phpt" role="test" />
- <file name="019b.phpt" role="test" />
- <file name="019c.phpt" role="test" />
- <file name="020.phpt" role="test" />
- <file name="021.phpt" role="test" />
- <file name="022.phpt" role="test" />
- <file name="023.phpt" role="test" />
- <file name="024.phpt" role="test" />
- <file name="025.phpt" role="test" />
- <file name="026.phpt" role="test" />
- <file name="027.phpt" role="test" />
- <file name="028.phpt" role="test" />
- <file name="029.phpt" role="test" />
- <file name="030.phpt" role="test" />
- <file name="031.phpt" role="test" />
- <file name="032.phpt" role="test" />
- <file name="033.phpt" role="test" />
- <file name="033a.phpt" role="test" />
- <file name="create_new_and_modify.phpt" role="test" />
- <file name="create_new_phar.phpt" role="test" />
- <file name="create_new_phar_b.phpt" role="test" />
- <file name="create_new_phar_c.phpt" role="test" />
- <file name="create_path_error.phpt" role="test" />
- <file name="delete_in_phar.phpt" role="test" />
- <file name="delete_in_phar_b.phpt" role="test" />
- <file name="delete_in_phar_confirm.phpt" role="test" />
- <file name="extracted.inc" role="test" />
- <file name="extracted_001.phpt" role="test" />
- <file name="ini_set.phpt" role="test" />
- <file name="ini_set_off.phpt" role="test" />
- <file name="metadata_read.phpt" role="test" />
- <file name="metadata_write.phpt" role="test" />
- <file name="metadata_write_commit.phpt" role="test" />
- <file name="open_for_write_existing.phpt" role="test" />
- <file name="open_for_write_existing_b.phpt" role="test" />
- <file name="open_for_write_existing_c.phpt" role="test" />
- <file name="open_for_write_newfile.phpt" role="test" />
- <file name="open_for_write_newfile_b.phpt" role="test" />
- <file name="open_for_write_newfile_c.phpt" role="test" />
- <file name="phar_begin_setstub_commit.phpt" role="test" />
- <file name="phar_commitwrite.phpt" role="test" />
- <file name="phar_create_in_cwd.phpt" role="test" />
- <file name="phar_ctx_001.phpt" role="test" />
- <file name="phar_get_suppoted_signatures_001.phpt" role="test" />
- <file name="phar_get_suppoted_signatures_002.phpt" role="test" />
- <file name="phar_metadata_read.phpt" role="test" />
- <file name="phar_metadata_write.phpt" role="test" />
- <file name="phar_offset_get_error.phpt" role="test" />
- <file name="phar_oo_001.phpt" role="test" />
- <file name="phar_oo_002.phpt" role="test" />
- <file name="phar_oo_003.phpt" role="test" />
- <file name="phar_oo_004.phpt" role="test" />
- <file name="phar_oo_005.phpt" role="test" />
- <file name="phar_oo_006.phpt" role="test" />
- <file name="phar_oo_007.phpt" role="test" />
- <file name="phar_oo_008.phpt" role="test" />
- <file name="phar_oo_009.phpt" role="test" />
- <file name="phar_oo_010.phpt" role="test" />
- <file name="phar_oo_011.phpt" role="test" />
- <file name="phar_oo_011b.phpt" role="test" />
- <file name="phar_oo_012.phpt" role="test" />
- <file name="phar_oo_012b.phpt" role="test" />
- <file name="phar_oo_012_confirm.phpt" role="test" />
- <file name="phar_oo_compressallbz2.phpt" role="test" />
- <file name="phar_oo_compressallgz.phpt" role="test" />
- <file name="phar_oo_compressed_001.phpt" role="test" />
- <file name="phar_oo_compressed_001b.phpt" role="test" />
- <file name="phar_oo_compressed_002.phpt" role="test" />
- <file name="phar_oo_compressed_002b.phpt" role="test" />
- <file name="phar_oo_test.inc" role="test" />
- <file name="phar_oo_uncompressall.phpt" role="test" />
- <file name="phar_setsignaturealgo1.phpt" role="test" />
- <file name="phar_setsignaturealgo2.phpt" role="test" />
- <file name="phar_stub.phpt" role="test" />
- <file name="phar_stub_error.phpt" role="test" />
- <file name="phar_stub_write.phpt" role="test" />
- <file name="phar_test.inc" role="test" />
- <file name="refcount1.phpt" role="test" />
- <file name="rename.phpt" role="test" />
- </dir> <!-- /tests -->
- <file name="config.m4" role="src" />
- <file name="config.w32" role="src" />
- <file name="CREDITS" role="doc" />
- <file name="LICENSE" role="doc" />
- <file name="Makefile.frag" role="src" />
- <file name="phar.c" role="src" />
- <file name="phar.php" role="php" />
- <file name="phar_internal.h" role="src" />
- <file name="phar_object.c" role="src" />
- <file name="phar_path_check.c" role="src" />
- <file name="phar_path_check.re" role="src" />
- <file name="php_phar.h" role="src" />
- <file name="TODO" role="doc" />
- </dir> <!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>5.2.0</min>
- </php>
- <pearinstaller>
- <min>1.4.3</min>
- </pearinstaller>
- </required>
- <optional>
- <package>
- <name>bz2</name>
- <channel>pecl.php.net</channel>
- <providesextension>bz2</providesextension>
- </package>
- <package>
- <name>hash</name>
- <channel>pecl.php.net</channel>
- <providesextension>hash</providesextension>
- </package>
- <extension>
- <name>spl</name>
- </extension>
- <extension>
- <name>zlib</name>
- </extension>
- </optional>
- </dependencies>
- <providesextension>phar</providesextension>
- <extsrcrelease />
- <changelog>
- <release>
- <version>
- <release>1.2.0</release>
- <api>1.1.0</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <date>2007-05-18</date>
- <license uri="http://www.php.net/license">PHP License</license>
- <notes>
-
- * add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus]
- * add Phar::hasMetadata(), Phar::delMetadata() [Marcus]
- * fix Phar::CanWrite() [Marcus]
- * add preliminary phar command (phar.php) [Marcus]
- * add phar command (phar.phar) [Marcus]
- * list all available compression methods using Phar::getSupportedCompression() [Marcus]
- * remove RINIT [Marcus]
-
- </notes>
- </release>
- <release>
- <version>
- <release>1.1.0</release>
- <api>1.1.0</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <date>2007-04-12</date>
- <license uri="http://www.php.net/license">PHP License</license>
- <notes>* implement ability connect a phar file &apos;phar://whatever&apos; to a directory. That way all
- access to that phar archive are directed to the extracted directory. This
- allows to have the installed files and the archieve keep the same includes.
- [Marcus]
-* implement SHA-2 (256, 512) support [Marcus]
-* implement setSignatureAlgorithm() and Phar::MD5 Phar::SHA1 Phar::SHA256 Phar::SHA512 Phar::PGP to
- choose the kind of signature to use (PGP falls back to SHA1) [Greg]</notes>
- </release>
- <release>
- <version>
- <release>1.0.1</release>
- <api>1.0.1</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <date>2007-03-28</date>
- <license uri="http://www.php.net/license">PHP License</license>
- <notes>* Fix return value of unlink() and rename() when used for phar archievs. [Marcus]</notes>
- </release>
- <release>
- <version>
- <release>1.0.0</release>
- <api>1.0.0</api>
- </version>
- <stability>
- <release>stable</release>
- <api>stable</api>
- </stability>
- <date>2007-03-26</date>
- <license uri="http://www.php.net/license">PHP License</license>
- <notes>*BACKWARDS COMPATIBILITY BREAK*
-Rename Phar-&gt;begin/isFlushingToPhar/commit to startBuffering/isBuffering/stopBuffering
-Note that isBuffering() returns the opposite value to isFlushingToPhar()</notes>
- </release>
- </changelog>
-</package>
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
deleted file mode 100644
index c2b651bb49..0000000000
--- a/ext/phar/phar.c
+++ /dev/null
@@ -1,3561 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2005-2007 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$ */
-
-#define PHAR_MAIN
-#include "phar_internal.h"
-#include "SAPI.h"
-
-ZEND_DECLARE_MODULE_GLOBALS(phar)
-
-/* if the original value is 0 (disabled), then allow setting/unsetting at will
- otherwise, only allow 1 (enabled), and error on disabling */
-ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
-{
- zend_bool old, ini;
-
- if (entry->name_length == 14) {
- old = PHAR_G(readonly_orig);
- } else {
- old = PHAR_G(require_hash_orig);
- }
-
- if (new_value_length == 2 && !strcasecmp("on", new_value)) {
- ini = (zend_bool) 1;
- }
- else if (new_value_length == 3 && !strcasecmp("yes", new_value)) {
- ini = (zend_bool) 1;
- }
- else if (new_value_length == 4 && !strcasecmp("true", new_value)) {
- ini = (zend_bool) 1;
- }
- else {
- ini = (zend_bool) atoi(new_value);
- }
-
- /* do not allow unsetting in runtime */
- if (stage == ZEND_INI_STAGE_STARTUP) {
- if (entry->name_length == 14) {
- PHAR_G(readonly_orig) = ini;
- } else {
- PHAR_G(require_hash_orig) = ini;
- }
- } else if (old && !ini) {
- return FAILURE;
- }
-
- if (entry->name_length == 14) {
- PHAR_G(readonly) = ini;
- } else {
- PHAR_G(require_hash) = ini;
- }
- return SUCCESS;
-}
-/* }}}*/
-
-static void phar_split_extract_list(TSRMLS_D)
-{
- char *tmp = estrdup(PHAR_GLOBALS->extract_list);
- char *key;
- char *lasts;
- char *q;
- int keylen;
-
- zend_hash_clean(&(PHAR_GLOBALS->phar_plain_map));
-
- for (key = php_strtok_r(tmp, ",", &lasts);
- key;
- key = php_strtok_r(NULL, ",", &lasts))
- {
- char *val = strchr(key, '=');
-
- if (val) {
- *val++ = '\0';
- for (q = key; *q; q++) {
- *q = tolower(*q);
- }
- keylen = q - key + 1;
- zend_hash_add(&(PHAR_GLOBALS->phar_plain_map), key, keylen, val, strlen(val)+1, NULL);
- }
- }
- efree(tmp);
-}
-/* }}} */
-
-ZEND_INI_MH(phar_ini_extract_list) /* {{{ */
-{
- PHAR_G(extract_list) = new_value;
-
- if (stage == ZEND_INI_STAGE_RUNTIME) {
- phar_split_extract_list(TSRMLS_C);
- }
-
- return SUCCESS;
-}
-/* }}} */
-
-ZEND_INI_DISP(phar_ini_extract_list_disp) /*void name(zend_ini_entry *ini_entry, int type) {{{ */
-{
- char *value;
-
- if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
- value = ini_entry->orig_value;
- } else if (ini_entry->value) {
- value = ini_entry->value;
- } else {
- value = NULL;
- }
-
- if (value) {
- char *tmp = strdup(value);
- char *key;
- char *lasts;
- char *q;
-
- if (!sapi_module.phpinfo_as_text) {
- php_printf("<ul>");
- }
- for (key = php_strtok_r(tmp, ",", &lasts);
- key;
- key = php_strtok_r(NULL, ",", &lasts))
- {
- char *val = strchr(key, '=');
-
- if (val) {
- *val++ = '\0';
- for (q = key; *q; q++) {
- *q = tolower(*q);
- }
- if (sapi_module.phpinfo_as_text) {
- php_printf("%s => %s", key, val);
- } else {
- php_printf("<li>%s => %s</li>", key, val);
- }
- }
- }
- if (!sapi_module.phpinfo_as_text) {
- php_printf("</ul>");
- }
- free(tmp);
- }
-}
-/* }}} */
-
-PHP_INI_BEGIN()
- STD_PHP_INI_BOOLEAN( "phar.readonly", "1", PHP_INI_ALL, phar_ini_modify_handler, readonly, zend_phar_globals, phar_globals)
- STD_PHP_INI_BOOLEAN( "phar.require_hash", "1", PHP_INI_ALL, phar_ini_modify_handler, require_hash, zend_phar_globals, phar_globals)
- STD_PHP_INI_ENTRY_EX("phar.extract_list", "", PHP_INI_ALL, phar_ini_extract_list, extract_list, zend_phar_globals, phar_globals, phar_ini_extract_list_disp)
-PHP_INI_END()
-
-/**
- * When all uses of a phar have been concluded, this frees the manifest
- * and the phar slot
- */
-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;
- }
- if (data->fname) {
- efree(data->fname);
- }
- if (data->signature) {
- efree(data->signature);
- }
- if (data->manifest.arBuckets) {
- zend_hash_destroy(&data->manifest);
- }
- if (data->metadata) {
- zval_ptr_dtor(&data->metadata);
- data->metadata = 0;
- }
- if (data->fp) {
- php_stream_close(data->fp);
- data->fp = 0;
- }
-
- efree(data);
-}
-/* }}}*/
-
-/**
- * Delete refcount and destruct if needed. On destruct return 1 else 0.
- */
-int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */
-{
- if (--phar->refcount < 0) {
- if (PHAR_GLOBALS->request_done
- || zend_hash_del(&(PHAR_GLOBALS->phar_fname_map), phar->fname, phar->fname_len) != SUCCESS) {
- phar_destroy_phar_data(phar TSRMLS_CC);
- }
- return 1;
- }
- return 0;
-}
-/* }}}*/
-
-/**
- * Destroy phar's in shutdown, here we don't care about aliases
- */
-static void destroy_phar_data_only(void *pDest) /* {{{ */
-{
- phar_archive_data *phar_data = *(phar_archive_data **) pDest;
- TSRMLS_FETCH();
-
- if (EG(exception) || --phar_data->refcount < 0) {
- phar_destroy_phar_data(phar_data TSRMLS_CC);
- }
-}
-/* }}}*/
-
-/**
- * Delete aliases to phar's that got kicked out of the global table
- */
-static int phar_unalias_apply(void *pDest, void *argument TSRMLS_DC) /* {{{ */
-{
- return *(void**)pDest == argument ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
-/**
- * Filename map destructor
- */
-static void destroy_phar_data(void *pDest) /* {{{ */
-{
- phar_archive_data *phar_data = *(phar_archive_data **) pDest;
- TSRMLS_FETCH();
-
- if (PHAR_GLOBALS->request_ends) {
- return destroy_phar_data_only(pDest);
- }
- zend_hash_apply_with_argument(&(PHAR_GLOBALS->phar_alias_map), phar_unalias_apply, phar_data TSRMLS_CC);
- if (--phar_data->refcount < 0) {
- phar_destroy_phar_data(phar_data TSRMLS_CC);
- }
-}
-/* }}}*/
-
-/**
- * destructor for the manifest hash, frees each file's entry
- */
-static void destroy_phar_manifest(void *pDest) /* {{{ */
-{
- phar_entry_info *entry = (phar_entry_info *)pDest;
- TSRMLS_FETCH();
-
- if (entry->cfp) {
- php_stream_close(entry->cfp);
- entry->cfp = 0;
- }
- if (entry->fp) {
- php_stream_close(entry->fp);
- entry->fp = 0;
- }
- if (entry->metadata) {
- zval_ptr_dtor(&entry->metadata);
- entry->metadata = 0;
- }
- if (entry->metadata_str.c) {
- smart_str_free(&entry->metadata_str);
- entry->metadata_str.c = 0;
- }
- efree(entry->filename);
-}
-/* }}} */
-
-/**
- * Looks up a phar archive in the filename map, connecting it to the alias
- * (if any) or returns null
- */
-static int phar_get_archive(phar_archive_data **archive, char *fname, int fname_len, char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *fd, **fd_ptr;
-
- phar_request_initialize(TSRMLS_C);
-
- if (error) {
- *error = NULL;
- }
- *archive = NULL;
- 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))) {
- if (error) {
- spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, (*fd_ptr)->fname, fname);
- }
- return FAILURE;
- }
- *archive = *fd_ptr;
- return SUCCESS;
- }
- }
- if (fname && fname_len) {
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void**)&fd_ptr)) {
- *archive = *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 SUCCESS;
- }
- if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), fname, fname_len, (void**)&fd_ptr)) {
- *archive = *fd_ptr;
- return SUCCESS;
- }
- }
- return FAILURE;
-}
-/* }}} */
-
-/**
- * retrieve information on a file contained within a phar, or null if it ain't there
- */
-phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error TSRMLS_DC) /* {{{ */
-{
- const char *pcr_error;
- phar_entry_info *entry;
-
- if (error) {
- *error = NULL;
- }
-
- if (phar_path_check(&path, &path_len, &pcr_error) > pcr_is_ok) {
- if (error) {
- spprintf(error, 0, "phar error: invalid path \"%s\" contains %s", path, pcr_error);
- }
- return NULL;
- }
-
- if (!&phar->manifest.arBuckets) {
- return NULL;
- }
- if (SUCCESS == zend_hash_find(&phar->manifest, path, path_len, (void**)&entry)) {
- if (entry->is_deleted) {
- /* entry is deleted, but has not been flushed to disk yet */
- return NULL;
- }
- return entry;
- }
- return NULL;
-}
-/* }}} */
-
-#if defined(PHP_VERSION_ID) && PHP_VERSION_ID < 50202
-typedef struct {
- char *data;
- size_t fpos;
- size_t fsize;
- size_t smax;
- int mode;
- php_stream **owner_ptr;
-} php_stream_memory_data;
-#endif
-
-/**
- * Retrieve a copy of the file information on a single file within a phar, or null.
- * This also transfers the open file pointer, if any, to the entry.
- */
-static int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, char *mode, char **error TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *phar;
- phar_entry_info *entry;
- int for_write = mode[0] != 'r' || mode[1] == '+';
- int for_append = mode[0] == 'a';
- int for_create = mode[0] != 'r';
- int for_trunc = mode[0] == 'w';
-
- if (!ret) {
- return FAILURE;
- }
- *ret = NULL;
- if (error) {
- *error = NULL;
- }
- if (for_write && PHAR_G(readonly)) {
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot opened for writing, disabled by ini setting", fname);
- }
- return FAILURE;
- }
- if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
- return FAILURE;
- }
- if ((entry = phar_get_entry_info(phar, path, path_len, for_create && !PHAR_G(readonly) ? NULL : error TSRMLS_CC)) == NULL) {
- if (for_create && !PHAR_G(readonly)) {
- return SUCCESS;
- }
- return FAILURE;
- }
- if (entry->is_modified && !for_write) {
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot opened for reading, writable file pointers are open", fname);
- }
- return FAILURE;
- }
- if (entry->fp_refcount && for_write) {
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot opened for writing, readable file pointers are open", fname);
- }
- return FAILURE;
- }
- if (entry->is_deleted) {
- if (!for_create) {
- return FAILURE;
- }
- entry->is_deleted = 0;
- }
- *ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
- (*ret)->position = 0;
- (*ret)->phar = phar;
- (*ret)->internal_file = entry;
- if (entry->fp) {
- /* make a copy */
- if (for_trunc) {
-#if PHP_VERSION_ID >= 50202
- php_stream_truncate_set_size(entry->fp, 0);
-#else
- if (php_stream_is(entry->fp, PHP_STREAM_IS_TEMP)) {
- if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_MEMORY)) {
- php_stream *inner = *(php_stream**)entry->fp->abstract;
- php_stream_memory_data *memfp = (php_stream_memory_data*)inner->abstract;
- memfp->fpos = 0;
- memfp->fsize = 0;
- } else if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_STDIO)) {
- php_stream_truncate_set_size(*(php_stream**)entry->fp->abstract, 0);
- } else {
- efree(*ret);
- *ret = NULL;
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot opened for writing, no truncate support", fname);
- }
- return FAILURE;
- }
- } else if (php_stream_is(entry->fp, PHP_STREAM_IS_STDIO)) {
- php_stream_truncate_set_size(entry->fp, 0);
- } else {
- efree(*ret);
- *ret = NULL;
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot opened for writing, no truncate support", fname);
- }
- return FAILURE;
- }
-#endif
- entry->is_modified = 1;
- phar->is_modified = 1;
- /* reset file size */
- entry->uncompressed_filesize = 0;
- entry->compressed_filesize = 0;
- entry->crc32 = 0;
- } else if (for_append) {
- php_stream_seek(entry->fp, 0, SEEK_END);
- }
- (*ret)->fp = entry->fp;
- } else {
- (*ret)->fp = 0;
- if (for_write) {
- /* open a new temp file for writing */
- entry->fp = php_stream_fopen_tmpfile();
- if (!entry->fp) {
- if (error) {
- spprintf(error, 0, "phar error: unable to create temporary file");
- }
- return FAILURE;
- }
- (*ret)->fp = entry->fp;
- entry->is_modified = 1;
- phar->is_modified = 1;
- /* reset file size */
- entry->uncompressed_filesize = 0;
- entry->compressed_filesize = 0;
- entry->crc32 = 0;
- entry->flags = PHAR_ENT_PERM_DEF_FILE;
- }
- }
- entry->fp_refcount++;
- entry->phar->refcount++;
- return SUCCESS;
-}
-/* }}} */
-
-int phar_entry_delref(phar_entry_data *idata TSRMLS_DC) /* {{{ */
-{
- int ret = 0;
-
- if (--idata->internal_file->fp_refcount <= 0) {
- idata->internal_file->fp_refcount = 0;
- }
- if (idata->fp && idata->fp != idata->internal_file->fp) {
- php_stream_close(idata->fp);
- }
- phar_archive_delref(idata->internal_file->phar TSRMLS_CC);
- efree(idata);
- return ret;
-}
-/* }}} */
-
-/**
- * Removes an entry, either by actually removing it or by marking it.
- */
-void phar_entry_remove(phar_entry_data *idata, char **error TSRMLS_DC) /* {{{ */
-{
- if (!idata->phar->donotflush) {
- phar_flush(idata->internal_file->phar, 0, 0, error TSRMLS_CC);
- }
- if (idata->internal_file->fp_refcount < 2) {
- if (idata->fp && idata->fp != idata->internal_file->fp) {
- php_stream_close(idata->fp);
- }
- zend_hash_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len);
- idata->phar->refcount--;
- efree(idata);
- } else {
- idata->internal_file->is_deleted = 1;
- phar_entry_delref(idata TSRMLS_CC);
- }
-}
-/* }}} */
-
-/**
- * Create a new dummy file slot within a writeable phar for a newly created file
- */
-phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char **error TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *phar;
- phar_entry_info *entry, etemp;
- phar_entry_data *ret;
- const char *pcr_error;
-
- if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error TSRMLS_CC)) {
- return NULL;
- }
-
- if (FAILURE == phar_get_entry_data(&ret, fname, fname_len, path, path_len, mode, error TSRMLS_CC)) {
- return NULL;
- } else if (ret) {
- return ret;
- }
-
- if (phar_path_check(&path, &path_len, &pcr_error) > pcr_is_ok) {
- if (error) {
- spprintf(error, 0, "phar error: invalid path \"%s\" contains %s", path, pcr_error);
- }
- return NULL;
- }
-
- /* create a new phar data holder */
- ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
-
- /* create an entry, this is a new file */
- memset(&etemp, 0, sizeof(phar_entry_info));
- etemp.filename_len = path_len;
- etemp.fp = php_stream_fopen_tmpfile();
- if (!etemp.fp) {
- if (error) {
- spprintf(error, 0, "phar error: unable to create temporary file");
- }
- return NULL;
- }
- etemp.fp_refcount = 1;
- etemp.is_modified = 1;
- etemp.filename = estrndup(path, path_len);
- etemp.timestamp = time(0);
- etemp.offset_within_phar = -1;
- etemp.is_crc_checked = 1;
- etemp.flags = PHAR_ENT_PERM_DEF_FILE;
- etemp.phar = phar;
- zend_hash_add(&phar->manifest, etemp.filename, path_len, (void*)&etemp, sizeof(phar_entry_info), NULL);
- /* retrieve the phar manifest copy */
- entry = phar_get_entry_info(phar, path, path_len, error TSRMLS_CC);
-
- if (!entry) {
- return NULL;
- }
-
- phar->refcount++;
- ret->phar = phar;
- ret->fp = entry->fp;
- ret->position = 0;
- ret->internal_file = entry;
- return ret;
-}
-/* }}} */
-
-#define MAPPHAR_ALLOC_FAIL(msg) \
- php_stream_close(fp);\
- if (error) {\
- spprintf(error, 0, msg, fname);\
- }\
- return FAILURE;
-
-#define MAPPHAR_FAIL(msg) \
- efree(savebuf);\
- if (mydata) {\
- phar_destroy_phar_data(mydata TSRMLS_CC);\
- }\
- if (signature) {\
- efree(signature);\
- }\
- 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
-# define PHAR_GET_16(buffer, var) \
- var = ((((unsigned char*)(buffer))[1]) << 8) \
- | (((unsigned char*)(buffer))[0]); \
- (buffer) += 2
-#else
-# define PHAR_GET_32(buffer, var) \
- var = *(php_uint32*)(buffer); \
- buffer += 4
-# define PHAR_GET_16(buffer, var) \
- var = *(php_uint16*)(buffer); \
- buffer += 2
-#endif
-
-/**
- * Open an already loaded phar
- */
-static int phar_open_loaded(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *phar;
-
- if (error) {
- *error = NULL;
- }
- if (SUCCESS == phar_get_archive(&phar, fname, fname_len, alias, alias_len, error TSRMLS_CC)
- && fname_len == phar->fname_len
- && !strncmp(fname, phar->fname, fname_len)
- ) {
- if (pphar) {
- *pphar = phar;
- }
- return SUCCESS;
- } else {
- if (pphar) {
- *pphar = NULL;
- }
- if (phar && alias && (options & REPORT_ERRORS)) {
- if (error) {
- spprintf(error, 0, "alias \"%s\" is already used for archive \"%s\" cannot be overloaded with \"%s\"", alias, phar->fname, fname);
- }
- }
- return FAILURE;
- }
-}
-/* }}}*/
-
-/**
- * Parse out metadata from the manifest for a single file
- *
- * Meta-data is in this format:
- * [len32][data...]
- *
- * data is the serialized zval
- */
-static int phar_parse_metadata(php_stream *fp, char **buffer, char *endbuffer, zval **metadata TSRMLS_DC) /* {{{ */
-{
- const unsigned char *p;
- php_uint32 buf_len;
- php_unserialize_data_t var_hash;
-
- PHAR_GET_32(*buffer, buf_len);
-
- if (buf_len) {
- ALLOC_INIT_ZVAL(*metadata);
- p = (const unsigned char*) *buffer;
- PHP_VAR_UNSERIALIZE_INIT(var_hash);
- if (!php_var_unserialize(metadata, &p, p + buf_len, &var_hash TSRMLS_CC)) {
- PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- zval_ptr_dtor(metadata);
- *metadata = NULL;
- return FAILURE;
- }
- PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
- } else {
- *metadata = NULL;
- }
- *buffer += buf_len;
- return SUCCESS;
-}
-/* }}}*/
-
-static const char hexChars[] = "0123456789ABCDEF";
-
-static int phar_hex_str(const char *digest, size_t digest_len, char ** signature)
-{
- int pos = -1;
- size_t len;
-
- *signature = (char*)safe_emalloc(digest_len, 2, 1);
-
- for(len = 0; len < digest_len; ++len) {
- (*signature)[++pos] = hexChars[((const unsigned char *)digest)[len] >> 4];
- (*signature)[++pos] = hexChars[((const unsigned char *)digest)[len] & 0x0F];
- }
- (*signature)[++pos] = '\0';
- return pos;
-}
-
-/**
- * Does not check for a previously opened phar in the cache.
- *
- * Parse a new one and add it to the cache, returning either SUCCESS or
- * FAILURE, and setting pphar to the pointer to the manifest entry
- *
- * This is used by phar_open_filename to process the manifest, but can be called
- * directly.
- */
-int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
-{
- char b32[4], *buffer, *endbuffer, *savebuf;
- phar_archive_data *mydata = NULL;
- phar_entry_info entry;
- php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
- php_uint16 manifest_ver;
- long offset;
- int register_alias, sig_len;
- char *signature = NULL;
-
- if (pphar) {
- *pphar = NULL;
- }
- if (error) {
- *error = NULL;
- }
-
- /* 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 at stub end)")
- }
- if ((*buffer == ' ' || *buffer == '\n') && *(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 at stub end)")
- }
- if ((char) nextchar == '\r') {
- /* if we have an \r we require an \n as well */
- if (EOF == (nextchar = php_stream_getc(fp)) || (char)nextchar != '\n') {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated manifest at stub end)")
- }
- 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 at manifest length)")
- }
- 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 < 10 || manifest_len != php_stream_read(fp, buffer, manifest_len)) {
- 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, lowest nibble currently unused */
- manifest_ver = (((unsigned char)buffer[0]) << 8)
- + ((unsigned char)buffer[1]);
- buffer += 2;
- if ((manifest_ver & PHAR_API_VER_MASK) < PHAR_API_MIN_READ) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" is API version %1.u.%1.u.%1.u, and cannot be processed", fname, manifest_ver >> 12, (manifest_ver >> 8) & 0xF, (manifest_ver >> 4) & 0x0F);
- }
- return FAILURE;
- }
-
- PHAR_GET_32(buffer, manifest_flags);
-
- manifest_flags &= ~PHAR_HDR_COMPRESSION_MASK;
-
- /* The lowest nibble contains the phar wide flags. The compression flags can */
- /* be ignored on reading because it is being generated anyways. */
- if (manifest_flags & PHAR_HDR_SIGNATURE) {
- unsigned char buf[1024];
- int read_size, len;
- char sig_buf[8], *sig_ptr = sig_buf;
- off_t read_len;
-
- if (-1 == php_stream_seek(fp, -8, SEEK_END)
- || (read_len = php_stream_tell(fp)) < 20
- || 8 != php_stream_read(fp, sig_buf, 8)
- || memcmp(sig_buf+4, "GBMB", 4)) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
- }
- return FAILURE;
- }
- PHAR_GET_32(sig_ptr, sig_flags);
- switch(sig_flags) {
-#if HAVE_HASH_EXT
- case PHAR_SIG_SHA512: {
- unsigned char digest[64], saved[64];
- PHP_SHA512_CTX context;
-
- php_stream_rewind(fp);
- PHP_SHA512Init(&context);
- read_len -= sizeof(digest);
- if (read_len > sizeof(buf)) {
- read_size = sizeof(buf);
- } else {
- read_size = (int)read_len;
- }
- while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
- PHP_SHA512Update(&context, buf, len);
- read_len -= (off_t)len;
- if (read_len < read_size) {
- read_size = (int)read_len;
- }
- }
- PHP_SHA512Final(digest, &context);
-
- if (read_len > 0
- || php_stream_read(fp, (char*)saved, sizeof(saved)) != sizeof(saved)
- || memcmp(digest, saved, sizeof(digest))) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
- }
- return FAILURE;
- }
-
- sig_len = phar_hex_str((const char*)digest, sizeof(digest), &signature);
- break;
- }
- case PHAR_SIG_SHA256: {
- unsigned char digest[32], saved[32];
- PHP_SHA256_CTX context;
-
- php_stream_rewind(fp);
- PHP_SHA256Init(&context);
- read_len -= sizeof(digest);
- if (read_len > sizeof(buf)) {
- read_size = sizeof(buf);
- } else {
- read_size = (int)read_len;
- }
- while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
- PHP_SHA256Update(&context, buf, len);
- read_len -= (off_t)len;
- if (read_len < read_size) {
- read_size = (int)read_len;
- }
- }
- PHP_SHA256Final(digest, &context);
-
- if (read_len > 0
- || php_stream_read(fp, (char*)saved, sizeof(saved)) != sizeof(saved)
- || memcmp(digest, saved, sizeof(digest))) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
- }
- return FAILURE;
- }
-
- sig_len = phar_hex_str((const char*)digest, sizeof(digest), &signature);
- break;
- }
-#else
- case PHAR_SIG_SHA512:
- case PHAR_SIG_SHA256:
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a unsupported signature", fname);
- }
- return FAILURE;
-#endif
- case PHAR_SIG_SHA1: {
- unsigned char digest[20], saved[20];
- PHP_SHA1_CTX context;
-
- php_stream_rewind(fp);
- PHP_SHA1Init(&context);
- read_len -= sizeof(digest);
- if (read_len > sizeof(buf)) {
- read_size = sizeof(buf);
- } else {
- read_size = (int)read_len;
- }
- while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
- PHP_SHA1Update(&context, buf, len);
- read_len -= (off_t)len;
- if (read_len < read_size) {
- read_size = (int)read_len;
- }
- }
- PHP_SHA1Final(digest, &context);
-
- if (read_len > 0
- || php_stream_read(fp, (char*)saved, sizeof(saved)) != sizeof(saved)
- || memcmp(digest, saved, sizeof(digest))) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
- }
- return FAILURE;
- }
-
- sig_len = phar_hex_str((const char*)digest, sizeof(digest), &signature);
- break;
- }
- case PHAR_SIG_MD5: {
- unsigned char digest[16], saved[16];
- PHP_MD5_CTX context;
-
- php_stream_rewind(fp);
- PHP_MD5Init(&context);
- read_len -= sizeof(digest);
- if (read_len > sizeof(buf)) {
- read_size = sizeof(buf);
- } else {
- read_size = (int)read_len;
- }
- while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
- PHP_MD5Update(&context, buf, len);
- read_len -= (off_t)len;
- if (read_len < read_size) {
- read_size = (int)read_len;
- }
- }
- PHP_MD5Final(digest, &context);
-
- if (read_len > 0
- || php_stream_read(fp, (char*)saved, sizeof(saved)) != sizeof(saved)
- || memcmp(digest, saved, sizeof(digest))) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a broken signature", fname);
- }
- return FAILURE;
- }
-
- sig_len = phar_hex_str((const char*)digest, sizeof(digest), &signature);
- break;
- }
- default:
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" has a broken or unsupported signature", fname);
- }
- return FAILURE;
- }
- } else if (PHAR_G(require_hash)) {
- efree(savebuf);
- php_stream_close(fp);
- if (error) {
- spprintf(error, 0, "phar \"%s\" does not have a signature", fname);
- }
- return FAILURE;
- } else {
- sig_flags = 0;
- sig_len = 0;
- }
-
- /* 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 != (int)tmp_len || strncmp(alias, buffer, tmp_len)))
- {
- buffer[tmp_len] = '\0';
- efree(savebuf);
- php_stream_close(fp);
- if (signature) {
- efree(signature);
- }
- if (error) {
- spprintf(error, 0, "cannot load phar \"%s\" with implicit alias \"%s\" under different alias \"%s\"", fname, buffer, alias);
- }
- 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)")
- }
-
- mydata = ecalloc(sizeof(phar_archive_data), 1);
-
- /* check whether we have meta data, zero check works regardless of byte order */
- if (phar_parse_metadata(fp, &buffer, endbuffer, &mydata->metadata TSRMLS_CC) == FAILURE) {
- MAPPHAR_FAIL("unable to read phar metadata in .phar file \"%s\"");
- }
-
- /* set up our manifest */
- zend_hash_init(&mydata->manifest, sizeof(phar_entry_info),
- zend_get_hash_value, destroy_phar_manifest, 0);
- offset = 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)")
- }
- memset(&entry, 0, sizeof(phar_entry_info));
- 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 + 20 > 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);
- PHAR_GET_32(buffer, entry.flags);
- if (phar_parse_metadata(fp, &buffer, endbuffer, &entry.metadata TSRMLS_CC) == FAILURE) {
- efree(entry.filename);
- MAPPHAR_FAIL("unable to read file metadata in .phar file \"%s\"");
- }
- entry.offset_within_phar = offset;
- offset += entry.compressed_filesize;
- switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
- case PHAR_ENT_COMPRESSED_GZ:
-#if !HAVE_ZLIB
- if (entry.metadata) {
- zval_ptr_dtor(&entry.metadata);
- }
- efree(entry.filename);
- MAPPHAR_FAIL("zlib extension is required for gz compressed .phar file \"%s\"");
-#endif
- break;
- case PHAR_ENT_COMPRESSED_BZ2:
-#if !HAVE_BZ2
- if (entry.metadata) {
- zval_ptr_dtor(&entry.metadata);
- }
- efree(entry.filename);
- MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
-#endif
- break;
- default:
- if (entry.uncompressed_filesize != entry.compressed_filesize) {
- if (entry.metadata) {
- zval_ptr_dtor(&entry.metadata);
- }
- efree(entry.filename);
- MAPPHAR_FAIL("internal corruption of phar \"%s\" (compressed and uncompressed size does not match for uncompressed entry)");
- }
- break;
- }
- manifest_flags |= (entry.flags & PHAR_ENT_COMPRESSION_MASK);
- entry.is_crc_checked = 0;
- entry.fp = NULL;
- entry.phar = mydata;
- zend_hash_add(&mydata->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_entry_info), NULL);
- }
-
- snprintf(mydata->version, sizeof(mydata->version), "%u.%u.%u", manifest_ver >> 12, (manifest_ver >> 8) & 0xF, (manifest_ver >> 4) & 0xF);
- mydata->internal_file_start = halt_offset + manifest_len + 4;
- mydata->halt_offset = halt_offset;
- mydata->flags = manifest_flags;
- mydata->fp = fp;
- 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;
- mydata->sig_flags = sig_flags;
- mydata->sig_len = sig_len;
- mydata->signature = signature;
- phar_request_initialize(TSRMLS_C);
- zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
- if (register_alias) {
- mydata->is_explicit_alias = 1;
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
- } else {
- mydata->is_explicit_alias = 0;
- }
- efree(savebuf);
-
- if (pphar) {
- *pphar = mydata;
- }
-
- return SUCCESS;
-}
-/* }}} */
-
-/**
- * Create or open a phar for writing
- */
-int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
-{
- phar_archive_data *mydata;
- int register_alias;
- php_stream *fp;
-
- if (!pphar) {
- pphar = &mydata;
- }
- if (error) {
- *error = NULL;
- }
-
- if (phar_open_loaded(fname, fname_len, alias, alias_len, options, pphar, 0 TSRMLS_CC) == SUCCESS) {
- if (!PHAR_G(readonly)) {
- (*pphar)->is_writeable = 1;
- }
- 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, PHAR_G(readonly)?"rb":"r+b", IGNORE_URL|STREAM_MUST_SEEK|0, NULL);
-
- if (fp && phar_open_fp(fp, fname, fname_len, alias, alias_len, options, pphar, 0 TSRMLS_CC) == SUCCESS) {
- if (!PHAR_G(readonly)) {
- (*pphar)->is_writeable = 1;
- }
- return SUCCESS;
- }
-
- if (PHAR_G(readonly)) {
- if (options & REPORT_ERRORS) {
- if (error) {
- spprintf(error, 0, "creating archive \"%s\" disabled by INI setting", fname);
- }
- }
- return FAILURE;
- }
-
- /* set up our manifest */
- mydata = ecalloc(sizeof(phar_archive_data), 1);
- if (pphar) {
- *pphar = mydata;
- }
- zend_hash_init(&mydata->manifest, sizeof(phar_entry_info),
- zend_get_hash_value, destroy_phar_manifest, 0);
- 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), "%s", PHAR_API_VERSION_STR);
- mydata->is_explicit_alias = alias ? 1 : 0;
- mydata->internal_file_start = -1;
- mydata->fp = fp;
- mydata->is_writeable = 1;
- mydata->is_brandnew = 1;
- 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;
- }
- phar_request_initialize(TSRMLS_C);
- 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);
- }
- return SUCCESS;
-}
-/* }}}*/
-
-/**
- * Return an already opened filename.
- *
- * Or scan a phar file for the required __HALT_COMPILER(); ?> token and verify
- * that the manifest is proper, then pass it to phar_open_file(). SUCCESS
- * or FAILURE is returned and pphar is set to a pointer to the phar's manifest
- */
-int phar_open_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */
-{
- php_stream *fp;
-
- if (error) {
- *error = NULL;
- }
-
- if (phar_open_loaded(fname, fname_len, alias, alias_len, options, pphar, error TSRMLS_CC) == SUCCESS) {
- return SUCCESS;
- } else if (*error) {
- return FAILURE;
- }
-
-#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) {
- if (options & REPORT_ERRORS) {
- if (error) {
- spprintf(error, 0, "unable to open phar for reading \"%s\"", fname);
- }
- }
- return FAILURE;
- }
-
- return phar_open_fp(fp, fname, fname_len, alias, alias_len, options, pphar, error TSRMLS_CC);
-}
-/* }}}*/
-
-/**
- * Scan an open fp for the required __HALT_COMPILER(); ?> token and verify
- * that the manifest is proper, then pass it to phar_open_file(). SUCCESS
- * or FAILURE is returned and pphar is set to a pointer to the phar's manifest
- */
-static int phar_open_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error 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;
- size_t got;
-
- /* 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 (error) {
- *error = NULL;
- }
- if (-1 == php_stream_rewind(fp)) {
- 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 ((got = php_stream_read(fp, buffer+tokenlen, readsize)) < tokenlen) {
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated entry)")
- }
- 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, error TSRMLS_CC);
- }
-
- halt_offset += got;
- memmove(buffer, buffer + tokenlen, got + 1);
- }
-
- MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (__HALT_COMPILER(); not found)")
-}
-/* }}} */
-
-int phar_detect_phar_fname_ext(const char *filename, int check_length, char **ext_str, int *ext_len) /* {{{ */
-{
- char end;
- char *pos_p = strstr(filename, ".phar.php");
- char *pos_z = strstr(filename, ".phar.gz");
- char *pos_b = strstr(filename, ".phar.bz2");
-
- 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_b) {
- *ext_str = pos_b;
- *ext_len = 9;
- } else if ((pos_p = strstr(filename, ".phar")) != NULL) {
- *ext_str = pos_p;
- *ext_len = 5;
- } else {
- return FAILURE;
- }
- if (check_length && (*ext_str)[*ext_len] != '\0') {
- return FAILURE;
- }
- end = (*ext_str)[*ext_len];
- if (end != '\0' && end != '/' && end != '\\') {
- return FAILURE;
- }
- return SUCCESS;
-}
-/* }}} */
-
-/**
- * Process a phar stream name, ensuring we can handle any of:
- *
- * - whatever.phar
- * - whatever.phar.gz
- * - whatever.phar.bz2
- * - whatever.phar.php
- *
- * Optionally the name might start with 'phar://'
- *
- * This is used by phar_open_url()
- */
-int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len TSRMLS_DC) /* {{{ */
-{
- char *ext_str;
- int ext_len;
-
- if (!strncasecmp(filename, "phar://", 7)) {
- filename += 7;
- filename_len -= 7;
- }
-
- if (phar_detect_phar_fname_ext(filename, 0, &ext_str, &ext_len) == FAILURE) {
- 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;
-}
-/* }}} */
-
-/**
- * Open a phar file for streams API
- */
-static php_url* phar_open_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC) /* {{{ */
-{
- php_url *resource;
- char *arch = NULL, *entry = NULL, *error;
- int arch_len, entry_len;
-
- if (!strncasecmp(filename, "phar://", 7)) {
- if (mode[0] == 'a') {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: open mode append not supported");
- return NULL;
- }
- 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/.phar.bz2)", filename);
- if (arch) {
- efree(arch);
- }
- if (entry) {
- efree(entry);
- }
- 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 (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
- if (PHAR_G(readonly)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by INI setting");
- php_url_free(resource);
- return NULL;
- }
- if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, options, NULL, &error TSRMLS_CC) == FAILURE)
- {
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- php_url_free(resource);
- return NULL;
- }
- } else {
- if (phar_open_filename(resource->host, arch_len, NULL, 0, options, NULL, &error TSRMLS_CC) == FAILURE)
- {
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- php_url_free(resource);
- return NULL;
- }
- }
- return resource;
- }
-
- return NULL;
-}
-/* }}} */
-
-/**
- * Invoked when a user calls Phar::mapPhar() from within an executing .phar
- * to set up its manifest directly
- */
-int phar_open_compiled_file(char *alias, int alias_len, char **error TSRMLS_DC) /* {{{ */
-{
- char *fname;
- long halt_offset;
- zval *halt_constant;
- php_stream *fp;
- int fname_len;
-
- if (error) {
- *error = NULL;
- }
- fname = zend_get_executed_filename(TSRMLS_C);
-
- fname_len = strlen(fname);
-
- if (alias && phar_open_loaded(fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0 TSRMLS_CC) == SUCCESS) {
- return SUCCESS;
- }
-
- if (!strcmp(fname, "[no active file]")) {
- if (error) {
- spprintf(error, 0, "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);
- if (error) {
- spprintf(error, 0, "__HALT_COMPILER(); must be declared in a phar");
- }
- return FAILURE;
- }
- halt_offset = Z_LVAL(*halt_constant);
- FREE_ZVAL(halt_constant);
-
- fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
-
- if (!fp) {
- if (error) {
- spprintf(error, 0, "unable to open phar for reading \"%s\"", fname);
- }
- return FAILURE;
- }
-
- return phar_open_file(fp, fname, fname_len, alias, alias_len, halt_offset, NULL, error TSRMLS_CC);
-}
-/* }}} */
-
-static php_stream_ops phar_ops = {
- phar_stream_write, /* write */
- phar_stream_read, /* read */
- phar_stream_close, /* close */
- phar_stream_flush, /* flush */
- "phar stream",
- phar_stream_seek, /* seek */
- NULL, /* cast */
- phar_stream_stat, /* stat */
- NULL, /* set option */
-};
-
-static php_stream_ops phar_dir_ops = {
- phar_dir_write, /* write */
- phar_dir_read, /* read */
- phar_dir_close, /* close */
- phar_dir_flush, /* flush */
- "phar dir",
- phar_dir_seek, /* seek */
- NULL, /* cast */
- phar_dir_stat, /* stat */
- NULL, /* set option */
-};
-
-static php_stream_wrapper_ops phar_stream_wops = {
- phar_wrapper_open_url,
- NULL, /* phar_wrapper_close */
- NULL, /* phar_wrapper_stat, */
- phar_wrapper_stat, /* stat_url */
- phar_wrapper_open_dir, /* opendir */
- "phar",
- phar_wrapper_unlink, /* unlink */
- phar_wrapper_rename, /* rename */
- NULL, /* create directory */
- NULL, /* remove directory */
-};
-
-php_stream_wrapper php_stream_phar_wrapper = {
- &phar_stream_wops,
- NULL,
- 0 /* is_url */
-};
-
-/**
- * Validate the CRC32 of a file opened from within the phar
- */
-static int phar_postprocess_file(php_stream_wrapper *wrapper, int options, phar_entry_data *idata, php_uint32 crc32 TSRMLS_DC) /* {{{ */
-{
- php_uint32 crc = ~0;
- int len = idata->internal_file->uncompressed_filesize;
- php_stream *fp = idata->fp;
-
- php_stream_seek(fp, 0, SEEK_SET);
- while (len--) {
- CRC32(crc, php_stream_getc(fp));
- }
- php_stream_seek(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;
- }
-}
-/* }}} */
-
-/**
- * Determine which stream compression filter (if any) we need to read this file
- */
-static char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */
-{
- switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) {
- case PHAR_ENT_COMPRESSED_GZ:
- return "zlib.deflate";
- case PHAR_ENT_COMPRESSED_BZ2:
- return "bzip2.compress";
- default:
- return return_unknown ? "unknown" : NULL;
- }
-}
-/* }}} */
-
-/**
- * Determine which stream decompression filter (if any) we need to read this file
- */
-static char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */
-{
- 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_unknown ? "unknown" : NULL;
- }
-}
-/* }}} */
-
-/**
- * used for fopen('phar://...') and company
- */
-static php_stream * phar_wrapper_open_url(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 *error;
- char *filter_name;
- char *plain_map;
- char tmpbuf[8];
- HashTable *pharcontext;
- php_url *resource = NULL;
- php_stream *fp, *fpf;
- php_stream_filter *filter/*, *consumed */;
- php_uint32 offset, read, total, toread;
- zval **pzoption, *metadata;
- uint host_len;
-
- 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;
- }
-
- host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), resource->host, host_len+1, (void **)&plain_map) == SUCCESS) {
- spprintf(&internal_file, 0, "%s%s", plain_map, resource->path);
- fp = php_stream_open_wrapper_ex(internal_file, mode, options, opened_path, context);
- if (!fp) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: file \"%s\" extracted from \"%s\" could not be opened", internal_file, resource->host);
- }
- php_url_free(resource);
- efree(internal_file);
- return fp;
- }
-
- /* strip leading "/" */
- internal_file = estrdup(resource->path + 1);
- if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
- if (NULL == (idata = phar_get_or_create_entry_data(resource->host, host_len, internal_file, strlen(internal_file), mode, &error TSRMLS_CC))) {
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- } else {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: file \"%s\" could not be created in phar \"%s\"", internal_file, resource->host);
- }
- efree(internal_file);
- php_url_free(resource);
- return NULL;
- }
- if (error) {
- efree(error);
- }
- fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
- php_url_free(resource);
- efree(internal_file);
- if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) {
- pharcontext = HASH_OF(*pzoption);
- if (idata->internal_file->uncompressed_filesize == 0
- && idata->internal_file->compressed_filesize == 0
- && zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS
- && Z_TYPE_PP(pzoption) == IS_LONG
- && (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
- ) {
- idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- idata->internal_file->flags |= Z_LVAL_PP(pzoption);
- }
- if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) {
- if (idata->internal_file->metadata) {
- zval_ptr_dtor(&idata->internal_file->metadata);
- idata->internal_file->metadata = NULL;
- }
-
- MAKE_STD_ZVAL(idata->internal_file->metadata);
- metadata = *pzoption;
- ZVAL_ZVAL(idata->internal_file->metadata, metadata, 1, 0);
- idata->phar->is_modified = 1;
- }
- }
- return fpf;
- } else {
- if ((FAILURE == phar_get_entry_data(&idata, resource->host, host_len, internal_file, strlen(internal_file), "r", &error TSRMLS_CC)) || !idata) {
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- 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);
- efree(internal_file);
- return fpf;
- }
-
-#if PHP_MAJOR_VERSION < 6
- if (PG(safe_mode) && (!php_checkuid(idata->phar->fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- phar_entry_delref(idata TSRMLS_CC);
- efree(internal_file);
- return NULL;
- }
-#endif
-
- if (php_check_open_basedir(idata->phar->fname TSRMLS_CC)) {
- phar_entry_delref(idata TSRMLS_CC);
- 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);
- phar_entry_delref(idata TSRMLS_CC);
- 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);
- phar_entry_delref(idata TSRMLS_CC);
- 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);
- phar_entry_delref(idata TSRMLS_CC);
- efree(internal_file);
- return NULL;
- }
- buffer = (char *) emalloc(8192);
- read = 0;
- total = 0;
-
- idata->fp = php_stream_temp_new();
- idata->internal_file->fp = idata->fp;
- php_stream_filter_append(&idata->fp->writefilters, filter);
- do {
- if ((total + 8192) > idata->internal_file->compressed_filesize) {
- toread = idata->internal_file->compressed_filesize - total;
- } else {
- toread = 8192;
- }
- read = php_stream_read(fp, buffer, toread);
- if (read) {
- total += read;
- if (read != php_stream_write(idata->fp, buffer, read)) {
- efree(buffer);
- 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);
- phar_entry_delref(idata TSRMLS_CC);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- efree(internal_file);
- return NULL;
- }
- if (total == idata->internal_file->compressed_filesize) {
- read = 0;
- }
- }
- } while (read);
- efree(buffer);
- php_stream_filter_flush(filter, 1);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- if (php_stream_tell(fp) != (off_t)(offset + idata->internal_file->compressed_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);
- phar_entry_delref(idata TSRMLS_CC);
- efree(internal_file);
- return NULL;
- }
- if (php_stream_tell(idata->fp) != (off_t)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);
- phar_entry_delref(idata TSRMLS_CC);
- 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();
- idata->internal_file->fp = idata->fp;
- 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);
- phar_entry_delref(idata TSRMLS_CC);
- efree(internal_file);
- return NULL;
- }
- }
-
- /* check length, crc32 */
- if (phar_postprocess_file(wrapper, options, idata, idata->internal_file->crc32 TSRMLS_CC) != SUCCESS) {
- /* already issued the error */
- phar_entry_delref(idata TSRMLS_CC);
- efree(internal_file);
- return NULL;
- }
- idata->internal_file->is_crc_checked = 1;
-
- fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
- efree(internal_file);
- return fpf;
-}
-/* }}} */
-
-/**
- * Used for fclose($fp) where $fp is a phar archive
- */
-static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
-{
- phar_entry_delref((phar_entry_data *)stream->abstract TSRMLS_CC);
-
- return 0;
-}
-/* }}} */
-
-/**
- * Used for closedir($fp) where $fp is an opendir('phar://...') directory handle
- */
-static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC) /* {{{ */
-{
- HashTable *data = (HashTable *)stream->abstract;
-
- if (data && data->arBuckets)
- {
- zend_hash_destroy(data);
- data->arBuckets = 0;
- FREE_HASHTABLE(data);
- stream->abstract = NULL;
- }
- return 0;
-}
-/* }}} */
-
-/**
- * Used for seeking on a phar directory handle
- */
-static int phar_dir_seek(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;
-}
-/* }}} */
-
-/**
- * used for fread($fp) and company on a fopen()ed phar file handle
- */
-static size_t phar_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *)stream->abstract;
- size_t got;
-
- if (data->internal_file->is_deleted) {
- stream->eof = 1;
- return 0;
- }
-
- /* use our proxy position */
- php_stream_seek(data->fp, data->position, SEEK_SET);
-
- got = php_stream_read(data->fp, buf, count);
- if (data->fp->eof) {
- stream->eof = 1;
- }
-
- /* note the position, and restore the stream for the next fp */
- data->position = php_stream_tell(data->fp);
-
- return got;
-}
-/* }}} */
-
-/**
- * Used for readdir() on an opendir()ed phar directory handle
- */
-static size_t phar_dir_read(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);
-}
-/* }}} */
-
-/**
- * Used for fseek($fp) on a phar file handle
- */
-static int phar_stream_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;
- if (whence != SEEK_SET) {
- /* use our proxy position, so the relative stuff works */
- php_stream_seek(data->fp, data->position, SEEK_SET);
- }
- /* now do the actual seek */
- res = php_stream_seek(data->fp, offset, whence);
- *newoffset = php_stream_tell(data->fp);
- data->position = *newoffset;
- return res;
-}
-/* }}} */
-
-/**
- * Used for writing to a phar file
- */
-static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *) stream->abstract;
-
- php_stream_seek(data->fp, data->position, SEEK_SET);
- if (count != php_stream_write(data->fp, buf, count)) {
- php_stream_wrapper_log_error(stream->wrapper, stream->flags TSRMLS_CC, "phar error: Could not write %d characters to \"%s\" in phar \"%s\"", (int) count, data->internal_file->filename, data->phar->fname);
- return -1;
- }
- data->position = php_stream_tell(data->fp);
- if (data->position > (off_t)data->internal_file->uncompressed_filesize) {
- data->internal_file->uncompressed_filesize = data->position;
- }
- data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize;
- data->internal_file->is_modified = 1;
- return count;
-}
-/* }}} */
-
-/**
- * Dummy: Used for writing to a phar directory (i.e. not used)
- */
-static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) /* {{{ */
-{
- return 0;
-}
-/* }}} */
-
-static inline void phar_set_32(char *buffer, int var) /* {{{ */
-{
-#ifdef WORDS_BIGENDIAN
- *((buffer) + 3) = (unsigned char) (((var) >> 24) & 0xFF);
- *((buffer) + 2) = (unsigned char) (((var) >> 16) & 0xFF);
- *((buffer) + 1) = (unsigned char) (((var) >> 8) & 0xFF);
- *((buffer) + 0) = (unsigned char) ((var) & 0xFF);
-#else
- *(php_uint32 *)(buffer) = (php_uint32)(var);
-#endif
-} /* }}} */
-
-/**
- * The only purpose of this is to store the API version, which was stored bigendian for some reason
- * in the original PHP_Archive, so we will do the same
- */
-static inline void phar_set_16(char *buffer, int var) /* {{{ */
-{
-#ifdef WORDS_BIGENDIAN
- *((buffer) + 1) = (unsigned char) (((var) >> 8) & 0xFF); \
- *(buffer) = (unsigned char) ((var) & 0xFF);
-#else
- *(php_uint16 *)(buffer) = (php_uint16)(var);
-#endif
-} /* }}} */
-
-static int phar_flush_clean_deleted_apply(void *data TSRMLS_DC) /* {{{ */
-{
- phar_entry_info *entry = (phar_entry_info *)data;
-
- if (entry->fp_refcount <= 0 && entry->is_deleted) {
- return ZEND_HASH_APPLY_REMOVE;
- } else {
- return ZEND_HASH_APPLY_KEEP;
- }
-}
-/* }}} */
-
-/**
- * Save phar contents to disk
- *
- * user_stub contains either a string, or a resource pointer, if len is a negative length.
- * user_stub and len should be both 0 if the default or existing stub should be used
- */
-int phar_flush(phar_archive_data *archive, char *user_stub, long len, char **error TSRMLS_DC) /* {{{ */
-{
- static const char newstub[] = "<?php __HALT_COMPILER(); ?>\r\n";
- phar_entry_info *entry;
- int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
- char *buf, *pos;
- char manifest[18], entry_buffer[24];
- off_t manifest_ftell;
- long offset;
- size_t wrote;
- php_uint32 manifest_len, mytime, loc, new_manifest_count;
- php_uint32 newcrc32;
- php_stream *file, *oldfile, *newfile, *stubfile;
- php_stream_filter *filter;
- php_serialize_data_t metadata_hash;
- smart_str main_metadata_str = {0};
- int free_user_stub;
-
- if (error) {
- *error = NULL;
- }
-
- if (PHAR_G(readonly)) {
- return EOF;
- }
-
- if (archive->fp && !archive->is_brandnew) {
- oldfile = archive->fp;
- closeoldfile = 0;
- php_stream_rewind(oldfile);
- } else {
- oldfile = php_stream_open_wrapper(archive->fname, "rb", 0, NULL);
- closeoldfile = oldfile != NULL;
- }
- newfile = php_stream_fopen_tmpfile();
- if (!newfile) {
- if (error) {
- spprintf(error, 0, "unable to create temporary file");
- }
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- return EOF;
- }
-
- if (user_stub) {
- if (len < 0) {
- /* resource passed in */
- if (!(php_stream_from_zval_no_verify(stubfile, (zval **)user_stub))) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to access resource to copy stub to new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
- if (len == -1) {
- len = PHP_STREAM_COPY_ALL;
- } else {
- len = -len;
- }
- user_stub = 0;
- if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to read resource to copy stub to new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
- free_user_stub = 1;
- } else {
- free_user_stub = 0;
- }
- if ((pos = strstr(user_stub, "__HALT_COMPILER();")) == NULL)
- {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "illegal stub for phar \"%s\"", archive->fname);
- }
- if (free_user_stub) {
- efree(user_stub);
- }
- return EOF;
- }
- len = pos - user_stub + 18;
- if ((size_t)len != php_stream_write(newfile, user_stub, len)
- || 5 != php_stream_write(newfile, " ?>\r\n", 5)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to create stub from string in new phar \"%s\"", archive->fname);
- }
- if (free_user_stub) {
- efree(user_stub);
- }
- return EOF;
- }
- archive->halt_offset = len + 5;
- if (free_user_stub) {
- efree(user_stub);
- }
- } else {
- if (archive->halt_offset && oldfile && !archive->is_brandnew) {
- if (archive->halt_offset != php_stream_copy_to_stream(oldfile, newfile, archive->halt_offset)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to copy stub of old phar to new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
- } else {
- /* this is a brand new phar */
- archive->halt_offset = sizeof(newstub)-1;
- if (sizeof(newstub)-1 != php_stream_write(newfile, newstub, sizeof(newstub)-1)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to create stub in new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
- }
- }
- manifest_ftell = php_stream_tell(newfile);
- halt_offset = manifest_ftell;
-
- /* Check whether we can get rid of some of the deleted entries which are
- * unused. However some might still be in use so even after this clean-up
- * we need to skip entries marked is_deleted. */
- zend_hash_apply(&archive->manifest, phar_flush_clean_deleted_apply TSRMLS_CC);
-
- /* compress as necessary, calculate crcs, serialize meta-data, manifest size, and file sizes */
- main_metadata_str.c = 0;
- if (archive->metadata) {
- PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&main_metadata_str, &archive->metadata, &metadata_hash TSRMLS_CC);
- PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
- } else {
- main_metadata_str.len = 0;
- }
- new_manifest_count = 0;
- offset = 0;
- buf = (char *) emalloc(8192);
- for (zend_hash_internal_pointer_reset(&archive->manifest);
- zend_hash_has_more_elements(&archive->manifest) == SUCCESS;
- zend_hash_move_forward(&archive->manifest)) {
- if (zend_hash_get_current_data(&archive->manifest, (void **)&entry) == FAILURE) {
- continue;
- }
- if (entry->cfp) {
- /* did we forget to get rid of cfp last time? */
- php_stream_close(entry->cfp);
- entry->cfp = 0;
- }
- if (entry->is_deleted) {
- /* remove this from the new phar */
- continue;
- }
- /* after excluding deleted files, calculate manifest size in bytes and number of entries */
- ++new_manifest_count;
-
- if (entry->metadata) {
- if (entry->metadata_str.c) {
- smart_str_free(&entry->metadata_str);
- }
- entry->metadata_str.c = 0;
- entry->metadata_str.len = 0;
- PHP_VAR_SERIALIZE_INIT(metadata_hash);
- php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash TSRMLS_CC);
- PHP_VAR_SERIALIZE_DESTROY(metadata_hash);
- } else {
- entry->metadata_str.c = 0;
- entry->metadata_str.len = 0;
- }
-
- offset += 4 + entry->filename_len + sizeof(entry_buffer) + entry->metadata_str.len;
-
- /* compress and rehash as necessary */
- if (oldfile && !entry->is_modified) {
- continue;
- }
- if (!entry->fp) {
- /* this should never happen */
- continue;
- }
- file = entry->fp;
- php_stream_rewind(file);
- newcrc32 = ~0;
- mytime = entry->uncompressed_filesize;
- for (loc = 0;loc < mytime; loc++) {
- CRC32(newcrc32, php_stream_getc(file));
- }
- entry->crc32 = ~newcrc32;
- entry->is_crc_checked = 1;
- if (!(entry->flags & PHAR_ENT_COMPRESSION_MASK)) {
- /* not compressed */
- entry->compressed_filesize = entry->uncompressed_filesize;
- continue;
- }
- filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0 TSRMLS_CC);
- if (!filter) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
- if (error) {
- spprintf(error, 0, "unable to gzip compress file \"%s\" to new phar \"%s\"", entry->filename, archive->fname);
- }
- } else {
- if (error) {
- spprintf(error, 0, "unable to bzip2 compress file \"%s\" to new phar \"%s\"", entry->filename, archive->fname);
- }
- }
- efree(buf);
- return EOF;
- }
-
- /* create new file that holds the compressed version */
- /* work around inability to specify freedom in write and strictness
- in read count */
- entry->cfp = php_stream_fopen_tmpfile();
- if (!entry->cfp) {
- if (error) {
- spprintf(error, 0, "unable to create temporary file");
- }
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- efree(buf);
- return EOF;
- }
- php_stream_flush(file);
- php_stream_rewind(file);
- php_stream_filter_append(&file->readfilters, filter);
- entry->compressed_filesize = php_stream_copy_to_stream(file, entry->cfp, entry->uncompressed_filesize+8192 TSRMLS_CC);
- php_stream_filter_flush(filter, 1 TSRMLS_CC);
- entry->compressed_filesize += php_stream_copy_to_stream(file, entry->cfp, entry->uncompressed_filesize+8192 TSRMLS_CC);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- /* generate crc on compressed file */
- php_stream_rewind(entry->cfp);
- entry->is_modified = 1;
- global_flags |= (entry->flags & PHAR_ENT_COMPRESSION_MASK);
- }
- efree(buf);
- global_flags |= PHAR_HDR_SIGNATURE;
-
- /* write out manifest pre-header */
- /* 4: manifest length
- * 4: manifest entry count
- * 2: phar version
- * 4: phar global flags
- * 4: alias length
- * ?: the alias itself
- * 4: phar metadata length
- * ?: phar metadata
- */
- restore_alias_len = archive->alias_len;
- if (!archive->is_explicit_alias) {
- archive->alias_len = 0;
- }
-
- manifest_len = offset + archive->alias_len + sizeof(manifest) + main_metadata_str.len;
- phar_set_32(manifest, manifest_len);
- phar_set_32(manifest+4, new_manifest_count);
- *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF);
- *(manifest + 9) = (unsigned char) (((PHAR_API_VERSION) & 0xF0));
- phar_set_32(manifest+10, global_flags);
- phar_set_32(manifest+14, archive->alias_len);
-
- /* write the manifest header */
- if (sizeof(manifest) != php_stream_write(newfile, manifest, sizeof(manifest))
- || (size_t)archive->alias_len != php_stream_write(newfile, archive->alias, archive->alias_len)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- archive->alias_len = restore_alias_len;
- if (error) {
- spprintf(error, 0, "unable to write manifest header of new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
-
- archive->alias_len = restore_alias_len;
-
- phar_set_32(manifest, main_metadata_str.len);
- if (main_metadata_str.len) {
- if (4 != php_stream_write(newfile, manifest, 4) ||
- main_metadata_str.len != php_stream_write(newfile, main_metadata_str.c, main_metadata_str.len)) {
- smart_str_free(&main_metadata_str);
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- archive->alias_len = restore_alias_len;
- if (error) {
- spprintf(error, 0, "unable to write manifest meta-data of new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
- } else {
- if (4 != php_stream_write(newfile, manifest, 4)) {
- smart_str_free(&main_metadata_str);
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- archive->alias_len = restore_alias_len;
- if (error) {
- spprintf(error, 0, "unable to write manifest header of new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
- }
- smart_str_free(&main_metadata_str);
-
- /* re-calculate the manifest location to simplify later code */
- manifest_ftell = php_stream_tell(newfile);
-
- /* now write the manifest */
- for (zend_hash_internal_pointer_reset(&archive->manifest);
- zend_hash_has_more_elements(&archive->manifest) == SUCCESS;
- zend_hash_move_forward(&archive->manifest)) {
- if (zend_hash_get_current_data(&archive->manifest, (void **)&entry) == FAILURE) {
- continue;
- }
- if (entry->is_deleted) {
- /* remove this from the new phar */
- continue;
- }
- phar_set_32(entry_buffer, entry->filename_len);
- if (4 != php_stream_write(newfile, entry_buffer, 4)
- || entry->filename_len != php_stream_write(newfile, entry->filename, entry->filename_len)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to write filename of file \"%s\" to manifest of new phar \"%s\"", entry->filename, archive->fname);
- }
- return EOF;
- }
- /* set the manifest meta-data:
- 4: uncompressed filesize
- 4: creation timestamp
- 4: compressed filesize
- 4: crc32
- 4: flags
- 4: metadata-len
- +: metadata
- */
- mytime = time(NULL);
- phar_set_32(entry_buffer, entry->uncompressed_filesize);
- phar_set_32(entry_buffer+4, mytime);
- phar_set_32(entry_buffer+8, entry->compressed_filesize);
- phar_set_32(entry_buffer+12, entry->crc32);
- phar_set_32(entry_buffer+16, entry->flags);
- phar_set_32(entry_buffer+20, entry->metadata_str.len);
- if (sizeof(entry_buffer) != php_stream_write(newfile, entry_buffer, sizeof(entry_buffer))
- || entry->metadata_str.len != php_stream_write(newfile, entry->metadata_str.c, entry->metadata_str.len)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to write temporary manifest of file \"%s\" to manifest of new phar \"%s\"", entry->filename, archive->fname);
- }
- return EOF;
- }
- }
-
- /* now copy the actual file data to the new phar */
- offset = 0;
- for (zend_hash_internal_pointer_reset(&archive->manifest);
- zend_hash_has_more_elements(&archive->manifest) == SUCCESS;
- zend_hash_move_forward(&archive->manifest)) {
- if (zend_hash_get_current_data(&archive->manifest, (void **)&entry) == FAILURE) {
- continue;
- }
- if (entry->is_deleted) {
- continue;
- }
- if (entry->cfp) {
- file = entry->cfp;
- php_stream_rewind(file);
- } else if (entry->fp && (entry->is_modified || !oldfile)) {
- file = entry->fp;
- php_stream_rewind(file);
- } else {
- if (!oldfile) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", entry->filename, archive->fname);
- }
- return EOF;
- }
- if (-1 == php_stream_seek(oldfile, entry->offset_within_phar + archive->internal_file_start, SEEK_SET)) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", entry->filename, archive->fname);
- }
- return EOF;
- }
- file = oldfile;
- }
- /* this will have changed for all files that have either
- changed compression or been modified */
- entry->offset_within_phar = offset;
- offset += entry->compressed_filesize;
- wrote = php_stream_copy_to_stream(file, newfile, entry->compressed_filesize);
- if (entry->compressed_filesize != wrote) {
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\"", entry->filename, archive->fname);
- }
- return EOF;
- }
- entry->is_modified = 0;
- if (entry->cfp) {
- php_stream_close(entry->cfp);
- entry->cfp = 0;
- }
- }
-
- /* append signature */
- if (global_flags & PHAR_HDR_SIGNATURE) {
- unsigned char buf[1024];
- int sig_flags = 0, sig_len;
- char sig_buf[4];
-
- php_stream_rewind(newfile);
-
- if (archive->signature) {
- efree(archive->signature);
- }
-
- switch(archive->sig_flags) {
-#if HAVE_HASH_EXT
- case PHAR_SIG_SHA512: {
- unsigned char digest[64];
- PHP_SHA512_CTX context;
-
- PHP_SHA512Init(&context);
- while ((sig_len = php_stream_read(newfile, (char*)buf, sizeof(buf))) > 0) {
- PHP_SHA512Update(&context, buf, sig_len);
- }
- PHP_SHA512Final(digest, &context);
- php_stream_write(newfile, (char *) digest, sizeof(digest));
- sig_flags |= PHAR_SIG_SHA512;
- archive->sig_len = phar_hex_str((const char*)digest, sizeof(digest), &archive->signature);
- break;
- }
- case PHAR_SIG_SHA256: {
- unsigned char digest[32];
- PHP_SHA256_CTX context;
-
- PHP_SHA256Init(&context);
- while ((sig_len = php_stream_read(newfile, (char*)buf, sizeof(buf))) > 0) {
- PHP_SHA256Update(&context, buf, sig_len);
- }
- PHP_SHA256Final(digest, &context);
- php_stream_write(newfile, (char *) digest, sizeof(digest));
- sig_flags |= PHAR_SIG_SHA256;
- archive->sig_len = phar_hex_str((const char*)digest, sizeof(digest), &archive->signature);
- break;
- }
-#else
- case PHAR_SIG_SHA512:
- case PHAR_SIG_SHA256:
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
- php_stream_close(newfile);
- if (error) {
- spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\" with requested hash type", entry->filename, archive->fname);
- }
- return EOF;
-#endif
- case PHAR_SIG_PGP:
- /* TODO: currently fall back to sha1,later do both */
- default:
- case PHAR_SIG_SHA1: {
- unsigned char digest[20];
- PHP_SHA1_CTX context;
-
- PHP_SHA1Init(&context);
- while ((sig_len = php_stream_read(newfile, (char*)buf, sizeof(buf))) > 0) {
- PHP_SHA1Update(&context, buf, sig_len);
- }
- PHP_SHA1Final(digest, &context);
- php_stream_write(newfile, (char *) digest, sizeof(digest));
- sig_flags |= PHAR_SIG_SHA1;
- archive->sig_len = phar_hex_str((const char*)digest, sizeof(digest), &archive->signature);
- break;
- }
- case PHAR_SIG_MD5: {
- unsigned char digest[16];
- PHP_MD5_CTX context;
-
- PHP_MD5Init(&context);
- while ((sig_len = php_stream_read(newfile, (char*)buf, sizeof(buf))) > 0) {
- PHP_MD5Update(&context, buf, sig_len);
- }
- PHP_MD5Final(digest, &context);
- php_stream_write(newfile, (char *) digest, sizeof(digest));
- sig_flags |= PHAR_SIG_MD5;
- archive->sig_len = phar_hex_str((const char*)digest, sizeof(digest), &archive->signature);
- break;
- }
- }
- phar_set_32(sig_buf, sig_flags);
- php_stream_write(newfile, sig_buf, 4);
- php_stream_write(newfile, "GBMB", 4);
- archive->sig_flags = sig_flags;
- }
-
- /* finally, close the temp file, rename the original phar,
- move the temp to the old phar, unlink the old phar, and reload it into memory
- */
- if (archive->fp) {
- php_stream_close(archive->fp);
- }
- if (closeoldfile) {
- php_stream_close(oldfile);
- }
-
- archive->internal_file_start = halt_offset + manifest_len + 4;
- archive->is_brandnew = 0;
-
- php_stream_rewind(newfile);
-
- if (archive->donotflush) {
- /* deferred flush */
- archive->fp = newfile;
- } else {
- archive->fp = php_stream_open_wrapper(archive->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL);
- if (!archive->fp) {
- archive->fp = newfile;
- if (error) {
- spprintf(error, 0, "unable to open new phar \"%s\" for writing", archive->fname);
- }
- return EOF;
- }
- php_stream_copy_to_stream(newfile, archive->fp, PHP_STREAM_COPY_ALL);
- php_stream_close(newfile);
- /* we could also reopen the file in "rb" mode but there is no need for that */
- }
-
- if (-1 == php_stream_seek(archive->fp, archive->halt_offset, SEEK_SET)) {
- if (error) {
- spprintf(error, 0, "unable to seek to __HALT_COMPILER(); in new phar \"%s\"", archive->fname);
- }
- return EOF;
- }
-
- return EOF;
-}
-/* }}} */
-
-/**
- * Used to save work done on a writeable phar
- */
-static int phar_stream_flush(php_stream *stream TSRMLS_DC) /* {{{ */
-{
- char *error;
- int ret;
- if (stream->mode[0] == 'w' || (stream->mode[0] == 'r' && stream->mode[1] == '+')) {
- ret = phar_flush(((phar_entry_data *)stream->abstract)->internal_file->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS TSRMLS_CC, error);
- efree(error);
- }
- return ret;
- } else {
- return EOF;
- }
-}
-/* }}} */
-
-/**
- * Dummy: Used for flushing writes to a phar directory (i.e. not used)
- */
-static int phar_dir_flush(php_stream *stream TSRMLS_DC) /* {{{ */
-{
- return EOF;
-}
-/* }}} */
-
- /* {{{ phar_dostat */
-/**
- * stat an opened phar file handle stream, used by phar_stat()
- */
-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));
-
- if (!is_dir) {
- ssb->sb.st_size = data->uncompressed_filesize;
- ssb->sb.st_mode = data->flags & PHAR_ENT_PERM_MASK;
- 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 = 0777;
- 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
- }
- if (!phar->is_writeable) {
- ssb->sb.st_mode = (ssb->sb.st_mode & 0555) | (ssb->sb.st_mode & ~0777);
- }
-
- 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 = (unsigned short)zend_get_hash_value(tmp, tmp_len);
- efree(tmp);
-#ifndef PHP_WIN32
- ssb->sb.st_blksize = -1;
- ssb->sb.st_blocks = -1;
-#endif
-}
-/* }}}*/
-
-/**
- * Stat an opened phar file handle
- */
-static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *)stream->abstract;
-
- /* If ssb is NULL then someone is misbehaving */
- if (!ssb) {
- return -1;
- }
-
- phar_dostat(data->phar, data->internal_file, ssb, 0, data->phar->alias, data->phar->alias_len TSRMLS_CC);
- return 0;
-}
-/* }}} */
-
-/**
- * Stat a dir in a phar
- */
-static int phar_dir_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC) /* {{{ */
-{
- phar_entry_data *data = (phar_entry_data *)stream->abstract;
-
- /* If ssb is NULL then someone is misbehaving */
- if (!ssb) {
- return -1;
- }
-
- phar_dostat(data->phar, data->internal_file, ssb, 0, data->phar->alias, data->phar->alias_len TSRMLS_CC);
- return 0;
-}
-/* }}} */
-
-/**
- * Stream wrapper stat implementation of stat()
- */
-static int phar_wrapper_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, *error, *plain_map;
- uint keylen;
- ulong unused;
- phar_archive_data *phar;
- phar_entry_info *entry;
- uint host_len;
- int retval;
-
- 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;
- }
-
- host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), resource->host, host_len+1, (void **)&plain_map) == SUCCESS) {
- spprintf(&internal_file, 0, "%s%s", plain_map, resource->path);
- retval = php_stream_stat_path_ex(internal_file, flags, ssb, context);
- if (retval == -1) {
- php_stream_wrapper_log_error(wrapper, 0/* TODO:options */ TSRMLS_CC, "phar error: file \"%s\" extracted from \"%s\" could not be opened", internal_file, resource->host);
- }
- php_url_free(resource);
- efree(internal_file);
- return retval;
- }
-
- 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 (FAILURE == phar_get_archive(&phar, resource->host, strlen(resource->host), NULL, 0, &error TSRMLS_CC)) {
- php_url_free(resource);
- if (error) {
- php_stream_wrapper_log_error(wrapper, flags TSRMLS_CC, error);
- efree(error);
- }
- return 0;
- }
- if (error) {
- efree(error);
- }
- 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;
- }
- if (!phar->manifest.arBuckets) {
- 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
- *
- * This is used to get a unique listing of virtual directories within a phar,
- * for iterating over opendir()ed phar directories.
- */
-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);
-}
-/* }}} */
-
-/**
- * Used for sorting directories alphabetically
- */
-static int phar_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;
- }
-}
-/* }}} */
-
-/**
- * Create a opendir() directory stream handle by iterating over each of the
- * files in a phar and retrieving its relative path. From this, construct
- * a list of files/directories that are "in" the directory represented by dir
- */
-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);
-
- if (*dir == '/' && dirlen == 1 && (manifest->nNumOfElements == 0)) {
- /* make empty root directory for empty phar */
- efree(dir);
- return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
- }
- 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 *) safe_emalloc(found - key, 1, 1);
- memcpy(entry, key, found - key);
- keylen = found - key;
- entry[keylen] = '\0';
- } else {
- entry = (char *) safe_emalloc(keylen, 1, 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 *) safe_emalloc(found - save + dirlen, 1, 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 *) safe_emalloc(keylen - dirlen, 1, 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, phar_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;
- }
-}
-/* }}}*/
-
-#if defined(PHP_VERSION_ID) && (PHP_VERSION_ID < 50300 || PHP_VERSION_ID >= 60000)
-
-static int _php_stream_unlink(char *url, int options, php_stream_context *context TSRMLS_DC)
-{
- php_stream_wrapper *wrapper = php_stream_locate_url_wrapper(url, NULL, options TSRMLS_CC);
-
- if (!wrapper || !wrapper->wops) {
- return 0;
- }
-
- if (!wrapper->wops->unlink) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "%s does not allow unlinking", wrapper->wops->label ? wrapper->wops->label : "Wrapper");
- return 0;
- }
- return wrapper->wops->unlink(wrapper, url, ENFORCE_SAFE_MODE | REPORT_ERRORS, context TSRMLS_CC);
-}
-
-#define php_stream_unlink(url, options, context) _php_stream_unlink((url), (options), (context) TSRMLS_CC)
-
-#endif
-
-/**
- * Unlink a file within a phar archive
- */
-static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
-{
- php_url *resource;
- char *internal_file, *error, *plain_map;
- phar_entry_data *idata;
- uint host_len;
- int retval;
-
- resource = php_url_parse(url);
-
- if (!resource && (resource = phar_open_url(wrapper, url, "rb", options TSRMLS_CC)) == NULL) {
- return 0;
- }
-
- /* 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\"", url);
- return 0;
- }
-
- 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\"", url);
- return 0;
- }
-
- host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), resource->host, host_len+1, (void **)&plain_map) == SUCCESS) {
- spprintf(&internal_file, 0, "%s%s", plain_map, resource->path);
- retval = php_stream_unlink(internal_file, options, context);
- if (!retval) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: file \"%s\" extracted from \"%s\" could not be opened", internal_file, resource->host);
- }
- php_url_free(resource);
- efree(internal_file);
- return retval;
- }
-
- if (PHAR_G(readonly)) {
- php_url_free(resource);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by INI setting");
- return 0;
- }
-
- /* need to copy to strip leading "/", will get touched again */
- internal_file = estrdup(resource->path + 1);
- if (FAILURE == phar_get_entry_data(&idata, resource->host, strlen(resource->host), internal_file, strlen(internal_file), "r", &error TSRMLS_CC)) {
- /* constraints of fp refcount were not met */
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- efree(internal_file);
- php_url_free(resource);
- return 0;
- }
- if (error) {
- efree(error);
- }
- if (!idata) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" is not a file in phar \"%s\", cannot unlink", internal_file, resource->host);
- efree(internal_file);
- php_url_free(resource);
- return 0;
- }
- if (idata->internal_file->fp_refcount > 1) {
- /* more than just our fp resource is open for this file */
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot unlink", internal_file, resource->host);
- efree(internal_file);
- php_url_free(resource);
- phar_entry_delref(idata TSRMLS_CC);
- return 0;
- }
- php_url_free(resource);
- efree(internal_file);
- phar_entry_remove(idata, &error TSRMLS_CC);
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- return 1;
-}
-/* }}} */
-
-static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) /* {{{ */
-{
- php_url *resource_from, *resource_to;
- char *from_file, *to_file, *error, *plain_map;
- phar_entry_data *fromdata, *todata;
- uint host_len;
-
- if (PHAR_G(readonly)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by INI setting");
- return 0;
- }
-
- resource_from = php_url_parse(url_from);
- resource_to = php_url_parse(url_from);
-
- if (!resource_from && (resource_from = phar_open_url(wrapper, url_from, "r+b", options TSRMLS_CC)) == NULL) {
- return 0;
- }
-
- if (!resource_to && (resource_to = phar_open_url(wrapper, url_to, "wb", options TSRMLS_CC)) == NULL) {
- php_url_free(resource_from);
- return 0;
- }
-
- /* we must have at the very least phar://alias.phar/internalfile.php */
- if (!resource_from->scheme || !resource_from->host || !resource_from->path) {
- php_url_free(resource_from);
- php_url_free(resource_to);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url_from);
- return 0;
- }
-
- if (!resource_to->scheme || !resource_to->host || !resource_to->path) {
- php_url_free(resource_from);
- php_url_free(resource_to);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: invalid url \"%s\"", url_to);
- return 0;
- }
-
- if (strcasecmp("phar", resource_from->scheme)) {
- php_url_free(resource_from);
- php_url_free(resource_to);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url_from);
- return 0;
- }
-
- if (strcasecmp("phar", resource_to->scheme)) {
- php_url_free(resource_from);
- php_url_free(resource_to);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: not a phar stream url \"%s\"", url_to);
- return 0;
- }
-
- if (strcmp(resource_from->host, resource_to->host)) {
- php_url_free(resource_from);
- php_url_free(resource_to);
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot rename \"%s\" to \"%s\", not within the same phar archive", url_from, url_to);
- return 0;
- }
-
- host_len = strlen(resource_from->host);
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), resource_from->host, host_len+1, (void **)&plain_map) == SUCCESS) {
- /*TODO:use php_stream_rename() once available*/
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: cannot rename \"%s\" to \"%s\" from extracted phar archive", url_from, url_to);
- return 0;
- }
-
- /* need to copy to strip leading "/", will get touched again */
- from_file = estrdup(resource_from->path + 1);
- to_file = estrdup(resource_to->path + 1);
- if (FAILURE == phar_get_entry_data(&fromdata, resource_from->host, strlen(resource_from->host), from_file, strlen(from_file), "r", &error TSRMLS_CC)) {
- /* constraints of fp refcount were not met */
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- return 0;
- }
- if (error) {
- efree(error);
- }
- if (!fromdata) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" is not a file in phar \"%s\", cannot rename", from_file, resource_from->host);
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- return 0;
- }
- if (!(todata = phar_get_or_create_entry_data(resource_to->host, strlen(resource_to->host), to_file, strlen(to_file), "w", &error TSRMLS_CC))) {
- /* constraints of fp refcount were not met */
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- return 0;
- }
- if (error) {
- efree(error);
- }
- if (fromdata->internal_file->fp_refcount > 1) {
- /* more than just our fp resource is open for this file */
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot rename", from_file, resource_from->host);
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- phar_entry_delref(fromdata TSRMLS_CC);
- phar_entry_delref(todata TSRMLS_CC);
- return 0;
- }
- if (todata->internal_file->fp_refcount > 1) {
- /* more than just our fp resource is open for this file */
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot rename", to_file, resource_to->host);
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- phar_entry_delref(fromdata TSRMLS_CC);
- phar_entry_delref(todata TSRMLS_CC);
- return 0;
- }
-
- php_stream_seek(fromdata->internal_file->fp, 0, SEEK_SET);
- if (fromdata->internal_file->uncompressed_filesize != php_stream_copy_to_stream(fromdata->internal_file->fp, todata->internal_file->fp, PHP_STREAM_COPY_ALL)) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: rename failed \"%s\" to \"%s\"", url_from, url_to);
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- phar_entry_delref(fromdata TSRMLS_CC);
- phar_entry_delref(todata TSRMLS_CC);
- return 0;
- }
- phar_entry_delref(fromdata TSRMLS_CC);
- phar_entry_delref(todata TSRMLS_CC);
- efree(from_file);
- efree(to_file);
- php_url_free(resource_from);
- php_url_free(resource_to);
- phar_wrapper_unlink(wrapper, url_from, 0, 0 TSRMLS_CC);
- return 1;
-}
-/* }}} */
-
-/**
- * Open a directory handle within a phar archive
- */
-static php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, 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, *error, *plain_map;
- uint keylen;
- ulong unused;
- phar_archive_data *phar;
- phar_entry_info *entry;
- uint host_len;
-
- 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/ */
- 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 (always use full path to a new phar)", path, 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/", path, 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 url \"%s\"", path);
- return NULL;
- }
-
- host_len = strlen(resource->host);
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), resource->host, host_len+1, (void **)&plain_map) == SUCCESS) {
- spprintf(&internal_file, 0, "%s%s", plain_map, resource->path);
- ret = php_stream_opendir(internal_file, options, context);
- if (!ret) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: file \"%s\" extracted from \"%s\" could not be opened", internal_file, resource->host);
- }
- php_url_free(resource);
- efree(internal_file);
- return ret;
- }
-
- internal_file = resource->path + 1; /* strip leading "/" */
- if (FAILURE == phar_get_archive(&phar, resource->host, host_len, NULL, 0, &error TSRMLS_CC)) {
- if (error) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, error);
- efree(error);
- }
- php_url_free(resource);
- return NULL;
- }
- if (error) {
- efree(error);
- }
- 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 (!phar->manifest.arBuckets) {
- php_url_free(resource);
- return NULL;
- }
- 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;
-}
-/* }}} */
-
-#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[] */
-};
-/* }}}*/
-
-/* {{{ php_phar_init_globals
- */
-static void php_phar_init_globals_module(zend_phar_globals *phar_globals)
-{
- memset(phar_globals, 0, sizeof(zend_phar_globals));
- phar_globals->readonly = 1;
-}
-/* }}} */
-
-PHP_MINIT_FUNCTION(phar) /* {{{ */
-{
- ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL);
- REGISTER_INI_ENTRIES();
-
- phar_object_init(TSRMLS_C);
-
- 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);
-}
-/* }}} */
-
-void phar_request_initialize(TSRMLS_D) /* {{{ */
-{
- if (!PHAR_GLOBALS->request_init)
- {
- PHAR_GLOBALS->request_init = 1;
- PHAR_GLOBALS->request_ends = 0;
- PHAR_GLOBALS->request_done = 0;
- 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);
- zend_hash_init(&(PHAR_GLOBALS->phar_plain_map), sizeof(const char *), zend_get_hash_value, NULL, 0);
- phar_split_extract_list(TSRMLS_C);
- }
-}
-/* }}} */
-
-PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */
-{
- PHAR_GLOBALS->request_ends = 1;
- if (PHAR_GLOBALS->request_init)
- {
- zend_hash_destroy(&(PHAR_GLOBALS->phar_alias_map));
- zend_hash_destroy(&(PHAR_GLOBALS->phar_fname_map));
- zend_hash_destroy(&(PHAR_GLOBALS->phar_plain_map));
- PHAR_GLOBALS->request_init = 0;
- }
- PHAR_GLOBALS->request_done = 1;
- 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 EXT version", PHAR_EXT_VERSION_STR);
- php_info_print_table_row(2, "Phar API version", PHAR_API_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_end();
-
- php_info_print_box_start(0);
- PUTS("Phar based on pear/PHP_Archive, original concept by Davey Shafik.");
- PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
- PUTS("Phar fully realized by Gregory Beaver and Marcus Boerger.");
- php_info_print_box_end();
-
- DISPLAY_INI_ENTRIES();
-}
-/* }}} */
-
-/* {{{ 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
-#if HAVE_SPL
- ZEND_MOD_REQUIRED("spl")
-#endif
- {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),
- NULL,
- PHP_RSHUTDOWN(phar),
- PHP_MINFO(phar),
- PHAR_EXT_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.phar b/ext/phar/phar.phar
deleted file mode 100755
index 793e7189e8..0000000000
--- a/ext/phar/phar.phar
+++ /dev/null
@@ -1,1227 +0,0 @@
-#!/usr/bin/php
-<?php if (!class_exists('PHP_Archive')) {
-?><?php
-/**
- * PHP_Archive Class (implements .phar)
- *
- * @package PHP_Archive
- * @category PHP
- */
-/**
- * PHP_Archive Class (implements .phar)
- *
- * PHAR files a singular archive from which an entire application can run.
- * To use it, simply package it using {@see PHP_Archive_Creator} and use phar://
- * URIs to your includes. i.e. require_once 'phar://config.php' will include config.php
- * from the root of the PHAR file.
- *
- * Gz code borrowed from the excellent File_Archive package by Vincent Lascaux.
- *
- * @copyright Copyright David Shafik and Synaptic Media 2004. All rights reserved.
- * @author Davey Shafik <davey@synapticmedia.net>
- * @author Greg Beaver <cellog@php.net>
- * @link http://www.synapticmedia.net Synaptic Media
- * @version $Id: Archive.php,v 1.43 2007/05/28 18:20:40 helly Exp $
- * @package PHP_Archive
- * @category PHP
- */
-
-class PHP_Archive
-{
- const GZ = 0x00001000;
- const BZ2 = 0x00002000;
- const SIG = 0x00010000;
- const SHA1 = 0x0002;
- const MD5 = 0x0001;
- /**
- * Whether this archive is compressed with zlib
- *
- * @var bool
- */
- private $_compressed;
- /**
- * @var string Real path to the .phar archive
- */
- private $_archiveName = null;
- /**
- * Current file name in the phar
- * @var string
- */
- protected $currentFilename = null;
- /**
- * Length of current file in the phar
- * @var string
- */
- protected $internalFileLength = null;
- /**
- * Current file statistics (size, creation date, etc.)
- * @var string
- */
- protected $currentStat = null;
- /**
- * @var resource|null Pointer to open .phar
- */
- protected $fp = null;
- /**
- * @var int Current Position of the pointer
- */
- protected $position = 0;
-
- /**
- * Map actual realpath of phars to meta-data about the phar
- *
- * Data is indexed by the alias that is used by internal files. In other
- * words, if a file is included via:
- * <code>
- * require_once 'phar://PEAR.phar/PEAR/Installer.php';
- * </code>
- * then the alias is "PEAR.phar"
- *
- * Information stored is a boolean indicating whether this .phar is compressed
- * with zlib, another for bzip2, phar-specific meta-data, and
- * the precise offset of internal files
- * within the .phar, used with the {@link $_manifest} to load actual file contents
- * @var array
- */
- private static $_pharMapping = array();
- /**
- * Map real file paths to alias used
- *
- * @var array
- */
- private static $_pharFiles = array();
- /**
- * File listing for the .phar
- *
- * The manifest is indexed per phar.
- *
- * Files within the .phar are indexed by their relative path within the
- * .phar. Each file has this information in its internal array
- *
- * - 0 = uncompressed file size
- * - 1 = timestamp of when file was added to phar
- * - 2 = offset of file within phar relative to internal file's start
- * - 3 = compressed file size (actual size in the phar)
- * @var array
- */
- private static $_manifest = array();
- /**
- * Absolute offset of internal files within the .phar, indexed by absolute
- * path to the .phar
- *
- * @var array
- */
- private static $_fileStart = array();
- /**
- * file name of the phar
- *
- * @var string
- */
- private $_basename;
-
-
- /**
- * Default MIME types used for the web front controller
- *
- * @var array
- */
- public static $defaultmimes = array(
- 'aif' => 'audio/x-aiff',
- 'aiff' => 'audio/x-aiff',
- 'arc' => 'application/octet-stream',
- 'arj' => 'application/octet-stream',
- 'art' => 'image/x-jg',
- 'asf' => 'video/x-ms-asf',
- 'asx' => 'video/x-ms-asf',
- 'avi' => 'video/avi',
- 'bin' => 'application/octet-stream',
- 'bm' => 'image/bmp',
- 'bmp' => 'image/bmp',
- 'bz2' => 'application/x-bzip2',
- 'css' => 'text/css',
- 'doc' => 'application/msword',
- 'dot' => 'application/msword',
- 'dv' => 'video/x-dv',
- 'dvi' => 'application/x-dvi',
- 'eps' => 'application/postscript',
- 'exe' => 'application/octet-stream',
- 'gif' => 'image/gif',
- 'gz' => 'application/x-gzip',
- 'gzip' => 'application/x-gzip',
- 'htm' => 'text/html',
- 'html' => 'text/html',
- 'ico' => 'image/x-icon',
- 'jpe' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'jpeg' => 'image/jpeg',
- 'js' => 'application/x-javascript',
- 'log' => 'text/plain',
- 'mid' => 'audio/x-midi',
- 'mov' => 'video/quicktime',
- 'mp2' => 'audio/mpeg',
- 'mp3' => 'audio/mpeg3',
- 'mpg' => 'audio/mpeg',
- 'pdf' => 'aplication/pdf',
- 'png' => 'image/png',
- 'rtf' => 'application/rtf',
- 'tif' => 'image/tiff',
- 'tiff' => 'image/tiff',
- 'txt' => 'text/plain',
- 'xml' => 'text/xml',
- );
-
- public static $defaultphp = array(
- 'php' => true
- );
-
- public static $defaultphps = array(
- 'phps' => true
- );
-
- public static $deny = array('/.+\.inc$/');
-
- public static function viewSource($archive, $file)
- {
- // security, idea borrowed from PHK
- if (!file_exists($archive . '.introspect')) {
- header("HTTP/1.0 404 Not Found");
- exit;
- }
- if (self::_fileExists($archive, $_GET['viewsource'])) {
- $source = highlight_file('phar://@ALIAS@/' .
- $_GET['viewsource'], true);
- header('Content-Type: text/html');
- header('Content-Length: ' . strlen($source));
- echo '<html><head><title>Source of ',
- htmlspecialchars($_GET['viewsource']), '</title></head>';
- echo '<body><h1>Source of ',
- htmlspecialchars($_GET['viewsource']), '</h1>';
- if (isset($_GET['introspect'])) {
- echo '<a href="', htmlspecialchars($_SERVER['PHP_SELF']),
- '?introspect=', urlencode(htmlspecialchars($_GET['introspect'])),
- '">Return to ', htmlspecialchars($_GET['introspect']), '</a><br />';
- }
- echo $source;
- exit;
- } else {
- header("HTTP/1.0 404 Not Found");
- exit;
- }
-
- }
-
- public static function introspect($archive, $dir)
- {
- // security, idea borrowed from PHK
- if (!file_exists($archive . '.introspect')) {
- header("HTTP/1.0 404 Not Found");
- exit;
- }
- if (!$dir) {
- $dir = '/';
- }
- $dir = self::processFile($dir);
- if ($dir[0] != '/') {
- $dir = '/' . $dir;
- }
- try {
- $self = htmlspecialchars($_SERVER['PHP_SELF']);
- $iterate = new DirectoryIterator('phar://@ALIAS@' . $dir);
- echo '<html><head><title>Introspect ', htmlspecialchars($dir),
- '</title></head><body><h1>Introspect ', htmlspecialchars($dir),
- '</h1><ul>';
- if ($dir != '/') {
- echo '<li><a href="', $self, '?introspect=',
- htmlspecialchars(dirname($dir)), '">..</a></li>';
- }
- foreach ($iterate as $entry) {
- if ($entry->isDot()) continue;
- $name = self::processFile($entry->getPathname());
- $name = str_replace('phar://@ALIAS@/', '', $name);
- if ($entry->isDir()) {
- echo '<li><a href="', $self, '?introspect=',
- urlencode(htmlspecialchars($name)),
- '">',
- htmlspecialchars($entry->getFilename()), '/</a> [directory]</li>';
- } else {
- echo '<li><a href="', $self, '?introspect=',
- urlencode(htmlspecialchars($dir)), '&viewsource=',
- urlencode(htmlspecialchars($name)),
- '">',
- htmlspecialchars($entry->getFilename()), '</a></li>';
- }
- }
- exit;
- } catch (Exception $e) {
- echo '<html><head><title>Directory not found: ',
- htmlspecialchars($dir), '</title></head>',
- '<body><h1>Directory not found: ', htmlspecialchars($dir), '</h1>',
- '<p>Try <a href="', htmlspecialchars($_SERVER['PHP_SELF']), '?introspect=/">',
- 'This link</a></p></body></html>';
- exit;
- }
- }
-
- public static function webFrontController($initfile)
- {
- if (isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) {
- $uri = parse_url($_SERVER['REQUEST_URI']);
- $archive = realpath($_SERVER['SCRIPT_FILENAME']);
- $subpath = str_replace('/' . basename($archive), '', $uri['path']);
- if (!$subpath || $subpath == '/') {
- if (isset($_GET['viewsource'])) {
- self::viewSource($archive, $_GET['viewsource']);
- }
- if (isset($_GET['introspect'])) {
- self::introspect($archive, $_GET['introspect']);
- }
- $subpath = '/' . $initfile;
- }
- if (!self::_fileExists($archive, substr($subpath, 1))) {
- header("HTTP/1.0 404 Not Found");
- exit;
- }
- foreach (self::$deny as $pattern) {
- if (preg_match($pattern, $subpath)) {
- header("HTTP/1.0 404 Not Found");
- exit;
- }
- }
- $inf = pathinfo(basename($subpath));
- if (!isset($inf['extension'])) {
- header('Content-Type: text/plain');
- header('Content-Length: ' .
- self::_filesize($archive, substr($subpath, 1)));
- readfile('phar://@ALIAS@' . $subpath);
- exit;
- }
- if (isset(self::$defaultphp[$inf['extension']])) {
- include 'phar://@ALIAS@' . $subpath;
- exit;
- }
- if (isset(self::$defaultmimes[$inf['extension']])) {
- header('Content-Type: ' . self::$defaultmimes[$inf['extension']]);
- header('Content-Length: ' .
- self::_filesize($archive, substr($subpath, 1)));
- readfile('phar://@ALIAS@' . $subpath);
- exit;
- }
- if (isset(self::$defaultphps[$inf['extension']])) {
- header('Content-Type: text/html');
- $c = highlight_file('phar://@ALIAS@' . $subpath, true);
- header('Content-Length: ' . strlen($c));
- echo $c;
- exit;
- }
- header('Content-Type: text/plain');
- header('Content-Length: ' .
- self::_filesize($archive, substr($subpath, 1)));
- readfile('phar://@ALIAS@' . $subpath);
- exit;
- }
- }
-
- /**
- * Detect end of stub
- *
- * @param string $buffer stub past '__HALT_'.'COMPILER();'
- * @return end of stub, prior to length of manifest.
- */
- private static final function _endOfStubLength($buffer)
- {
- $pos = 0;
- if (($buffer[0] == ' ' || $buffer[0] == "\n") && substr($buffer, 1, 2) == '?>')
- {
- $pos += 3;
- if ($buffer[$pos] == "\r" && $buffer[$pos+1] == "\n") {
- $pos += 2;
- }
- else if ($buffer[$pos] == "\n") {
- $pos += 1;
- }
- }
- return $pos;
- }
-
- /**
- * Allows loading an external Phar archive without include()ing it
- *
- * @param string $file phar package to load
- * @param string $alias alias to use
- * @throws Exception
- */
- public static final function loadPhar($file, $alias = NULL)
- {
- $file = realpath($file);
- if ($file) {
- $fp = fopen($file, 'rb');
- $buffer = '';
- while (!$found && !feof($fp)) {
- $buffer .= fread($fp, 8192);
- // don't break phars
- if ($pos = strpos($buffer, '__HALT_COMPI' . 'LER();')) {
- $buffer .= fread($fp, 5);
- fclose($fp);
- $pos += 18;
- $pos += self::_endOfStubLength(substr($buffer, $pos));
- return self::_mapPhar($file, $pos, $alias);
- }
- }
- fclose($fp);
- }
- }
-
- /**
- * Map a full real file path to an alias used to refer to the .phar
- *
- * This function can only be called from the initialization of the .phar itself.
- * Any attempt to call from outside the .phar or to re-alias the .phar will fail
- * as a security measure.
- * @param string $alias
- * @param int $dataoffset the value of __COMPILER_HALT_OFFSET__
- */
- public static final function mapPhar($alias = NULL, $dataoffset = NULL)
- {
- try {
- $file = __FILE__;
- // this ensures that this is safe
- if (!in_array($file, get_included_files())) {
- die('SECURITY ERROR: PHP_Archive::mapPhar can only be called from within ' .
- 'the phar that initiates it');
- }
- if (!isset($dataoffset)) {
- $dataoffset = constant('__COMPILER_HALT_OFFSET'.'__');
- }
- $file = realpath($file);
-
- $fp = fopen($file, 'rb');
- fseek($fp, $dataoffset, SEEK_SET);
- $pos = $dataoffset + self::_endOfStubLength(fread($fp, 5));
- fclose($fp);
- self::_mapPhar($file, $pos);
- } catch (Exception $e) {
- die($e->getMessage());
- }
- }
-
- /**
- * Sub-function, allows recovery from errors
- *
- * @param unknown_type $file
- * @param unknown_type $dataoffset
- */
- private static function _mapPhar($file, $dataoffset, $alias = NULL)
- {
- $file = realpath($file);
- if (isset(self::$_manifest[$file])) {
- return;
- }
- if (!is_array(self::$_pharMapping)) {
- self::$_pharMapping = array();
- }
- $fp = fopen($file, 'rb');
- // seek to __HALT_COMPILER_OFFSET__
- fseek($fp, $dataoffset);
- $manifest_length = unpack('Vlen', fread($fp, 4));
- $manifest = '';
- $last = '1';
- while (strlen($last) && strlen($manifest) < $manifest_length['len']) {
- $read = 8192;
- if ($manifest_length['len'] - strlen($manifest) < 8192) {
- $read = $manifest_length['len'] - strlen($manifest);
- }
- $last = fread($fp, $read);
- $manifest .= $last;
- }
- if (strlen($manifest) < $manifest_length['len']) {
- throw new Exception('ERROR: manifest length read was "' .
- strlen($manifest) .'" should be "' .
- $manifest_length['len'] . '"');
- }
- $info = self::_unserializeManifest($manifest);
- if ($info['alias']) {
- $alias = $info['alias'];
- $explicit = true;
- } else {
- if (!isset($alias)) {
- $alias = $file;
- }
- $explicit = false;
- }
- self::$_manifest[$file] = $info['manifest'];
- $compressed = $info['compressed'];
- self::$_fileStart[$file] = ftell($fp);
- fclose($fp);
- if ($compressed & 0x00001000) {
- if (!function_exists('gzinflate')) {
- throw new Exception('Error: zlib extension is not enabled - gzinflate() function needed' .
- ' for compressed .phars');
- }
- }
- if ($compressed & 0x00002000) {
- if (!function_exists('bzdecompress')) {
- throw new Exception('Error: bzip2 extension is not enabled - bzdecompress() function needed' .
- ' for compressed .phars');
- }
- }
- if (isset(self::$_pharMapping[$alias])) {
- throw new Exception('ERROR: PHP_Archive::mapPhar has already been called for alias "' .
- $alias . '" cannot re-alias to "' . $file . '"');
- }
- self::$_pharMapping[$alias] = array($file, $compressed, $dataoffset, $explicit,
- $info['metadata']);
- self::$_pharFiles[$file] = $alias;
- }
-
- /**
- * extract the manifest into an internal array
- *
- * @param string $manifest
- * @return false|array
- */
- private static function _unserializeManifest($manifest)
- {
- // retrieve the number of files in the manifest
- $info = unpack('V', substr($manifest, 0, 4));
- $apiver = substr($manifest, 4, 2);
- $apiver = bin2hex($apiver);
- $apiver_dots = hexdec($apiver[0]) . '.' . hexdec($apiver[1]) . '.' . hexdec($apiver[2]);
- $majorcompat = hexdec($apiver[0]);
- $calcapi = explode('.', self::APIVersion());
- if ($calcapi[0] != $majorcompat) {
- throw new Exception('Phar is incompatible API version ' . $apiver_dots . ', but ' .
- 'PHP_Archive is API version '.self::APIVersion());
- }
- if ($calcapi[0] === '0') {
- if (self::APIVersion() != $apiver_dots) {
- throw new Exception('Phar is API version ' . $apiver_dots .
- ', but PHP_Archive is API version '.self::APIVersion(), E_USER_ERROR);
- }
- }
- $flags = unpack('V', substr($manifest, 6, 4));
- $ret = array('compressed' => $flags & 0x00003000);
- // signature is not verified by default in PHP_Archive, phar is better
- $ret['hassignature'] = $flags & 0x00010000;
- $aliaslen = unpack('V', substr($manifest, 10, 4));
- if ($aliaslen) {
- $ret['alias'] = substr($manifest, 14, $aliaslen[1]);
- } else {
- $ret['alias'] = false;
- }
- $manifest = substr($manifest, 14 + $aliaslen[1]);
- $metadatalen = unpack('V', substr($manifest, 0, 4));
- if ($metadatalen[1]) {
- $ret['metadata'] = unserialize(substr($manifest, 4, $metadatalen[1]));
- $manifest = substr($manifest, 4 + $metadatalen[1]);
- } else {
- $ret['metadata'] = null;
- $manifest = substr($manifest, 4);
- }
- $offset = 0;
- $start = 0;
- for ($i = 0; $i < $info[1]; $i++) {
- // length of the file name
- $len = unpack('V', substr($manifest, $start, 4));
- $start += 4;
- // file name
- $savepath = substr($manifest, $start, $len[1]);
- $start += $len[1];
- // retrieve manifest data:
- // 0 = uncompressed file size
- // 1 = timestamp of when file was added to phar
- // 2 = compressed filesize
- // 3 = crc32
- // 4 = flags
- // 5 = metadata length
- $ret['manifest'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($manifest, $start, 24)));
- $ret['manifest'][$savepath][3] = sprintf('%u', $ret['manifest'][$savepath][3]);
- if ($ret['manifest'][$savepath][5]) {
- $ret['manifest'][$savepath][6] = unserialize(substr($manifest, $start + 24,
- $ret['manifest'][$savepath][5]));
- } else {
- $ret['manifest'][$savepath][6] = null;
- }
- $ret['manifest'][$savepath][7] = $offset;
- $offset += $ret['manifest'][$savepath][2];
- $start += 24 + $ret['manifest'][$savepath][5];
- }
- return $ret;
- }
-
- /**
- * @param string
- */
- private static function processFile($path)
- {
- if ($path == '.') {
- return '';
- }
- $std = str_replace("\\", "/", $path);
- while ($std != ($std = ereg_replace("[^\/:?]+/\.\./", "", $std))) ;
- $std = str_replace("/./", "", $std);
- if (strlen($std) > 1 && $std[0] == '/') {
- $std = substr($std, 1);
- }
- if (strncmp($std, "./", 2) == 0) {
- return substr($std, 2);
- } else {
- return $std;
- }
- }
-
- /**
- * Seek in the master archive to a matching file or directory
- * @param string
- */
- protected function selectFile($path, $allowdirs = true)
- {
- $std = self::processFile($path);
- if (isset(self::$_manifest[$this->_archiveName][$path])) {
- $this->_setCurrentFile($path);
- return true;
- }
- if (!$allowdirs) {
- return 'Error: "' . $path . '" is not a file in phar "' . $this->_basename . '"';
- }
- foreach (self::$_manifest[$this->_archiveName] as $file => $info) {
- if (empty($std) ||
- //$std is a directory
- strncmp($std.'/', $path, strlen($std)+1) == 0) {
- $this->currentFilename = $this->internalFileLength = $this->currentStat = null;
- return true;
- }
- }
- return 'Error: "' . $path . '" not found in phar "' . $this->_basename . '"';
- }
-
- private function _setCurrentFile($path)
- {
- $this->currentStat = array(
- 2 => 0100444, // file mode, readable by all, writeable by none
- 4 => 0, // uid
- 5 => 0, // gid
- 7 => self::$_manifest[$this->_archiveName][$path][0], // size
- 9 => self::$_manifest[$this->_archiveName][$path][1], // creation time
- );
- $this->currentFilename = $path;
- $this->internalFileLength = self::$_manifest[$this->_archiveName][$path][2];
- // seek to offset of file header within the .phar
- if (is_resource(@$this->fp)) {
- fseek($this->fp, self::$_fileStart[$this->_archiveName] + self::$_manifest[$this->_archiveName][$path][7]);
- }
- }
-
- private static function _fileExists($archive, $path)
- {
- return isset(self::$_manifest[$archive]) &&
- isset(self::$_manifest[$archive][$path]);
- }
-
- private static function _filesize($archive, $path)
- {
- return self::$_manifest[$archive][$path][0];
- }
-
- /**
- * Seek to a file within the master archive, and extract its contents
- * @param string
- * @return array|string an array containing an error message string is returned
- * upon error, otherwise the file contents are returned
- */
- public function extractFile($path)
- {
- $this->fp = @fopen($this->_archiveName, "rb");
- if (!$this->fp) {
- return array('Error: cannot open phar "' . $this->_archiveName . '"');
- }
- if (($e = $this->selectFile($path, false)) === true) {
- $data = '';
- $count = $this->internalFileLength;
- while ($count) {
- if ($count < 8192) {
- $data .= @fread($this->fp, $count);
- $count = 0;
- } else {
- $count -= 8192;
- $data .= @fread($this->fp, 8192);
- }
- }
- @fclose($this->fp);
- if (self::$_manifest[$this->_archiveName][$path][4] & self::GZ) {
- $data = gzinflate($data);
- } elseif (self::$_manifest[$this->_archiveName][$path][4] & self::BZ2) {
- $data = bzdecompress($data);
- }
- if (!isset(self::$_manifest[$this->_archiveName][$path]['ok'])) {
- if (strlen($data) != $this->currentStat[7]) {
- return array("Not valid internal .phar file (size error {$size} != " .
- $this->currentStat[7] . ")");
- }
- if (self::$_manifest[$this->_archiveName][$path][3] != sprintf("%u", crc32($data))) {
- return array("Not valid internal .phar file (checksum error)");
- }
- self::$_manifest[$this->_archiveName][$path]['ok'] = true;
- }
- return $data;
- } else {
- @fclose($this->fp);
- return array($e);
- }
- }
-
- /**
- * Parse urls like phar:///fullpath/to/my.phar/file.txt
- *
- * @param string $file
- * @return false|array
- */
- static protected function parseUrl($file)
- {
- if (substr($file, 0, 7) != 'phar://') {
- return false;
- }
- $file = substr($file, 7);
-
- $ret = array('scheme' => 'phar');
- $pos_p = strpos($file, '.phar.php');
- $pos_z = strpos($file, '.phar.gz');
- $pos_b = strpos($file, '.phar.bz2');
- if ($pos_p) {
- if ($pos_z) {
- return false;
- }
- $ret['host'] = substr($file, 0, $pos_p + strlen('.phar.php'));
- $ret['path'] = substr($file, strlen($ret['host']));
- } elseif ($pos_z) {
- $ret['host'] = substr($file, 0, $pos_z + strlen('.phar.gz'));
- $ret['path'] = substr($file, strlen($ret['host']));
- } elseif ($pos_b) {
- $ret['host'] = substr($file, 0, $pos_z + strlen('.phar.bz2'));
- $ret['path'] = substr($file, strlen($ret['host']));
- } elseif (($pos_p = strpos($file, ".phar")) !== false) {
- $ret['host'] = substr($file, 0, $pos_p + strlen('.phar'));
- $ret['path'] = substr($file, strlen($ret['host']));
- } else {
- return false;
- }
- if (!$ret['path']) {
- $ret['path'] = '/';
- }
- return $ret;
- }
-
- /**
- * Locate the .phar archive in the include_path and detect the file to open within
- * the archive.
- *
- * Possible parameters are phar://pharname.phar/filename_within_phar.ext
- * @param string a file within the archive
- * @return string the filename within the .phar to retrieve
- */
- public function initializeStream($file)
- {
- $file = self::processFile($file);
- $info = @parse_url($file);
- if (!$info) {
- $info = self::parseUrl($file);
- }
- if (!$info) {
- return false;
- }
- if (!isset($info['host'])) {
- // malformed internal file
- return false;
- }
- if (!isset(self::$_pharFiles[$info['host']]) &&
- !isset(self::$_pharMapping[$info['host']])) {
- try {
- self::loadPhar($info['host']);
- // use alias from here out
- $info['host'] = self::$_pharFiles[$info['host']];
- } catch (Exception $e) {
- return false;
- }
- }
- if (!isset($info['path'])) {
- return false;
- } elseif (strlen($info['path']) > 1) {
- $info['path'] = substr($info['path'], 1);
- }
- if (isset(self::$_pharMapping[$info['host']])) {
- $this->_basename = $info['host'];
- $this->_archiveName = self::$_pharMapping[$info['host']][0];
- $this->_compressed = self::$_pharMapping[$info['host']][1];
- } elseif (isset(self::$_pharFiles[$info['host']])) {
- $this->_archiveName = $info['host'];
- $this->_basename = self::$_pharFiles[$info['host']];
- $this->_compressed = self::$_pharMapping[$this->_basename][1];
- }
- $file = $info['path'];
- return $file;
- }
-
- /**
- * Open the requested file - PHP streams API
- *
- * @param string $file String provided by the Stream wrapper
- * @access private
- */
- public function stream_open($file)
- {
- return $this->_streamOpen($file);
- }
-
- /**
- * @param string filename to opne, or directory name
- * @param bool if true, a directory will be matched, otherwise only files
- * will be matched
- * @uses trigger_error()
- * @return bool success of opening
- * @access private
- */
- private function _streamOpen($file, $searchForDir = false)
- {
- $path = $this->initializeStream($file);
- if (!$path) {
- trigger_error('Error: Unknown phar in "' . $file . '"', E_USER_ERROR);
- }
- if (is_array($this->file = $this->extractFile($path))) {
- trigger_error($this->file[0], E_USER_ERROR);
- return false;
- }
- if ($path != $this->currentFilename) {
- if (!$searchForDir) {
- trigger_error("Cannot open '$file', is a directory", E_USER_ERROR);
- return false;
- } else {
- $this->file = '';
- return true;
- }
- }
-
- if (!is_null($this->file) && $this->file !== false) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Read the data - PHP streams API
- *
- * @param int
- * @access private
- */
- public function stream_read($count)
- {
- $ret = substr($this->file, $this->position, $count);
- $this->position += strlen($ret);
- return $ret;
- }
-
- /**
- * Whether we've hit the end of the file - PHP streams API
- * @access private
- */
- function stream_eof()
- {
- return $this->position >= $this->currentStat[7];
- }
-
- /**
- * For seeking the stream - PHP streams API
- * @param int
- * @param SEEK_SET|SEEK_CUR|SEEK_END
- * @access private
- */
- public function stream_seek($pos, $whence)
- {
- switch ($whence) {
- case SEEK_SET:
- if ($pos < 0) {
- return false;
- }
- $this->position = $pos;
- break;
- case SEEK_CUR:
- if ($pos + $this->currentStat[7] < 0) {
- return false;
- }
- $this->position += $pos;
- break;
- case SEEK_END:
- if ($pos + $this->currentStat[7] < 0) {
- return false;
- }
- $this->position = $pos + $this->currentStat[7];
- default:
- return false;
- }
- return true;
- }
-
- /**
- * The current position in the stream - PHP streams API
- * @access private
- */
- public function stream_tell()
- {
- return $this->position;
- }
-
- /**
- * The result of an fstat call, returns mod time from creation, and file size -
- * PHP streams API
- * @uses _stream_stat()
- * @access private
- */
- public function stream_stat()
- {
- return $this->_stream_stat();
- }
-
- /**
- * Retrieve statistics on a file or directory within the .phar
- * @param string file/directory to stat
- * @access private
- */
- public function _stream_stat($file = null)
- {
- $std = $file ? self::processFile($file) : $this->currentFilename;
- if ($file) {
- if (isset(self::$_manifest[$this->_archiveName][$file])) {
- $this->_setCurrentFile($file);
- $isdir = false;
- } else {
- do {
- $isdir = false;
- if ($file == '/') {
- break;
- }
- foreach (self::$_manifest[$this->_archiveName] as $path => $info) {
- if (strpos($path, $file) === 0) {
- if (strlen($path) > strlen($file) &&
- $path[strlen($file)] == '/') {
- break 2;
- }
- }
- }
- // no files exist and no directories match this string
- return false;
- } while (false);
- $isdir = true;
- }
- } else {
- $isdir = false; // open streams must be files
- }
- $mode = $isdir ? 0040444 : 0100444;
- // 040000 = dir, 010000 = file
- // everything is readable, nothing is writeable
- return array(
- 0, 0, $mode, 0, 0, 0, 0, 0, 0, 0, 0, 0, // non-associative indices
- 'dev' => 0, 'ino' => 0,
- 'mode' => $mode,
- 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'blksize' => 0, 'blocks' => 0,
- 'size' => $this->currentStat[7],
- 'atime' => $this->currentStat[9],
- 'mtime' => $this->currentStat[9],
- 'ctime' => $this->currentStat[9],
- );
- }
-
- /**
- * Stat a closed file or directory - PHP streams API
- * @param string
- * @param int
- * @access private
- */
- public function url_stat($url, $flags)
- {
- $path = $this->initializeStream($url);
- return $this->_stream_stat($path);
- }
-
- /**
- * Open a directory in the .phar for reading - PHP streams API
- * @param string directory name
- * @access private
- */
- public function dir_opendir($path)
- {
- $info = @parse_url($path);
- if (!$info) {
- $info = self::parseUrl($path);
- if (!$info) {
- trigger_error('Error: "' . $path . '" is a file, and cannot be opened with opendir',
- E_USER_ERROR);
- return false;
- }
- }
- $path = !empty($info['path']) ?
- $info['host'] . $info['path'] : $info['host'] . '/';
- $path = $this->initializeStream('phar://' . $path);
- if (isset(self::$_manifest[$this->_archiveName][$path])) {
- trigger_error('Error: "' . $path . '" is a file, and cannot be opened with opendir',
- E_USER_ERROR);
- return false;
- }
- if ($path == false) {
- trigger_error('Error: Unknown phar in "' . $file . '"', E_USER_ERROR);
- return false;
- }
- $this->fp = @fopen($this->_archiveName, "rb");
- if (!$this->fp) {
- trigger_error('Error: cannot open phar "' . $this->_archiveName . '"');
- return false;
- }
- $this->_dirFiles = array();
- foreach (self::$_manifest[$this->_archiveName] as $file => $info) {
- if ($path == '/') {
- if (strpos($file, '/')) {
- $a = explode('/', $file);
- $this->_dirFiles[array_shift($a)] = true;
- } else {
- $this->_dirFiles[$file] = true;
- }
- } elseif (strpos($file, $path) === 0) {
- $fname = substr($file, strlen($path) + 1);
- if (strpos($fname, '/')) {
- // this is a directory
- $a = explode('/', $fname);
- $this->_dirFiles[array_shift($a)] = true;
- } elseif ($file[strlen($path)] == '/') {
- // this is a file
- $this->_dirFiles[$fname] = true;
- }
- }
- }
- @fclose($this->fp);
- if (!count($this->_dirFiles)) {
- return false;
- }
- @uksort($this->_dirFiles, 'strnatcmp');
- return true;
- }
-
- /**
- * Read the next directory entry - PHP streams API
- * @access private
- */
- public function dir_readdir()
- {
- $ret = key($this->_dirFiles);
- @next($this->_dirFiles);
- if (!$ret) {
- return false;
- }
- return $ret;
- }
-
- /**
- * Close a directory handle opened with opendir() - PHP streams API
- * @access private
- */
- public function dir_closedir()
- {
- $this->_dirFiles = array();
- reset($this->_dirFiles);
- return true;
- }
-
- /**
- * Rewind to the first directory entry - PHP streams API
- * @access private
- */
- public function dir_rewinddir()
- {
- reset($this->_dirFiles);
- return true;
- }
-
- /**
- * API version of this class
- * @return string
- */
- public final function APIVersion()
- {
- return '1.1.0';
- }
-
- /**
- * Retrieve Phar-specific metadata for a Phar archive
- *
- * @param string $phar full path to Phar archive, or alias
- * @return null|mixed The value that was serialized for the Phar
- * archive's metadata
- * @throws Exception
- */
- public static function getPharMetadata($phar)
- {
- if (isset(self::$_pharFiles[$phar])) {
- $phar = self::$_pharFiles[$phar];
- }
- if (!isset(self::$_pharMapping[$phar])) {
- throw new Exception('Unknown Phar archive: "' . $phar . '"');
- }
- return self::$_pharMapping[$phar][4];
- }
-
- /**
- * Retrieve File-specific metadata for a Phar archive file
- *
- * @param string $phar full path to Phar archive, or alias
- * @param string $file relative path to file within Phar archive
- * @return null|mixed The value that was serialized for the Phar
- * archive's metadata
- * @throws Exception
- */
- public static function getFileMetadata($phar, $file)
- {
- if (!isset(self::$_pharFiles[$phar])) {
- if (!isset(self::$_pharMapping[$phar])) {
- throw new Exception('Unknown Phar archive: "' . $phar . '"');
- }
- $phar = self::$_pharMapping[$phar][0];
- }
- if (!isset(self::$_manifest[$phar])) {
- throw new Exception('Unknown Phar: "' . $phar . '"');
- }
- $file = self::processFile($file);
- if (!isset(self::$_manifest[$phar][$file])) {
- throw new Exception('Unknown file "' . $file . '" within Phar "'. $phar . '"');
- }
- return self::$_manifest[$phar][$file][6];
- }
-
- /**
- * @return list of supported signature algorithmns.
- */
- public static function getsupportedsignatures()
- {
- $ret = array('MD5', 'SHA-1');
- if (extension_loaded('hash')) {
- $ret[] = 'SHA-256';
- $ret[] = 'SHA-512';
- }
- return $ret;
- }
-}
-?><?php
-}
-if (!in_array('phar', stream_get_wrappers())) {
- stream_wrapper_register('phar', 'PHP_Archive');
-}
-if (!class_exists('Phar',0)) {
- include 'phar://'.__FILE__.'/phar.inc';
-}
-?><?php
-
-/** @file phar.php
- * @ingroup Phar
- * @brief class CLICommand
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Phar Command
- */
-
-if (!extension_loaded('phar'))
-{
- if (!class_exists('PHP_Archive', 0))
- {
- echo "Neither Extension Phar nor class PHP_Archive are available.\n";
- exit(1);
- }
- if (!in_array('phar', stream_get_wrappers()))
- {
- stream_wrapper_register('phar', 'PHP_Archive');
- }
- if (!class_exists('Phar',0)) {
- require 'phar://'.__FILE__.'/phar.inc';
- }
-}
-
-foreach(array("SPL", "Reflection") as $ext)
-{
- if (!extension_loaded($ext))
- {
- echo "$argv[0] requires PHP extension $ext.\n";
- exit(1);
- }
-}
-
-function command_include($file)
-{
- $file = 'phar://' . __FILE__ . '/' . $file;
- if (file_exists($file)) {
- include($file);
- }
-}
-
-function command_autoload($classname)
-{
- command_include(strtolower($classname) . '.inc');
-}
-
-Phar::mapPhar();
-
-spl_autoload_register('command_autoload');
-
-new PharCommand($argc, $argv);
-
-__HALT_COMPILER(); ?>
-ˆ
-
-$m¤ŸA ©¥Ä Eê–¤íÀõïÌ>È]î’”{ÆÄwvÞ;¯Õë»ÃÉÉù«WäïQœP&q˜í÷Aº™ÆixBà}œnYVȇ]Àø‹[Ó ƒ<'oßýüVÀó¥ ,v#ä}ÀÂ2'ÿÈ(ÛR±k”Àsyqñ™ð?ð—1©±œK~Zèòæ6/Xä6Èã,Í3ä\ ñþÐ=M‹ ˆ³´«;Êr
-ÔHæsâM<¨‡3дÞ5Â=—ä»ïˆ¡.ÔÀ²F F·teH•IĆ›V`dƒK¶˜·‹¦?†_½—zƒ%Æ/Rdä°`O ÊÀËÐ$‹4¿“ŸŽóºæãôBKü†ÒÀî‚Ä[¡J¤Ÿ eqª¹îÁâ1‘‘HÄ œ+O¤5çyÔuõ¨ìõ䡕ʔƞ­0›ÑNõÝ2|µ1™XÌoÖ¹æ:÷GYAág­H!ÐÑÿ”1£€H×ò‘fPQP&à½,ˆÝŸóÿ‡%,Á”ûÙ¶ùð(åw‡¨n
-Ë•5ÎÎZ‚†CÓE„hÒÚÌ4}8ˆâAãel`2g|‰2pùp§û r>Ҩ͵ÀÍ}Q%hØ"•9Ò¢8+½s£¼×zÙâ *5Mç„T«Å‰²ÏÒÑó¹Xr3ÝÆ­6µYF+þD–åÏXwjIIâͱ¬ëò3Íà+$ôá>ß6‹ÍèÀâ´ˆüOŸÿù¯)Âtbã2
-d
-JÁ’S\µ éFÄÅQúò?>îÚÔ@³D="²óWh12
-G.›Š£È“ÏRO˜¹2™;Yróƒ·àÝDc_ætI_[«ߧ—þ0™‰p¿Æ¡BKá
-V¾G0;$3rF.áß÷ðﯽT®$•äò¿%%?&üÔ_›`•ÄÖ8]ð[H>CƒÇ缃ÿE7 ˆˆ pÔÞÀ ýøÞÂï3¶¹g´ÀXÓ"ÿð/?Xžï>xðø™p ï/F7|éüœìã4Þ—{®µ•N‹c•-àÝÕ(nµ.FÔ ¢€·1ÈSP¾ÄE$°b6‚æV¾OPgtÄé¯ô x­kÀAü
-ÂÁn&¨Æi½›H`ò%õrë$aÃTëŠa[[#õëÍĽ ûrÑ UÊF~äôÊÒ;8È2ТŸê&“åÈ¿Á9Œº*05«@8{¼f¿ÅÕäØŒqZ6.‚ÚÇbfµèÆ)¯e|`GÈ  ÷5œB7N»qb/µ»#*Å”³qç^KÀvë
- ì;5PÖ^–êšRZ;®•ŠLˆk%+9jã'±­ª­Ð aV¦öJ¯Î¼:¼°ûÙjºa"ä˜
-î€|T`ílxpBkàS±
-ÓŸM ŒúÐ3`ÄÃÍ!åÌÀä‘ñ¤¶Ûý¼É\`Sº“&‹«›Ä0:wt:ZKch¦W'.k èº_ź¸ËäZâèeqÔ_Èt$ÜÎÛ7“ŠVj·%Z›Cù3ªg–nì-²˜†SÁ…Ö~¬¤-w!ÿ3Ä@äøjÆskcVœ]<¯ñ^' Z»ïw˜&HpÄIp[ÿò4otÛ­yÙ½+†ÊpåyŽ³ö¬ª¢Ž:jpŽ:CµªcÈc 4ê“™éèO' è‹“?
-•f`J-$Üe(V¸Ã¢ô:ï÷/àÔ”K”`8t+T„'D$0ŸÌ!`Ï‚ˆ­{M„Cî
-ô31¯*ŸMWÙ¸J ×Ha".D‘#èa“Å2å žU1‚é¢ø^”ÐŒŽˆ¬½èùÛ]\$¹ËÕešŒ5Þ@ÇäbÆ«‹³×©YËóÁNz8d;q1»H²é.5°ñh´*2VVÅEÁ—<®‹ yzÈ°‡ðß¿Ãÿµû˜:|R(}úô©vÍ5ðïKö4MØ3^1õˆé'ß.ã"^ &È ˆ
-¹¤Š¾rÄ‹U 2šÓp×ëNÞÀ—ŠYœ²IRÀŒsè@Ì–Lûnv;XlÚkjZò¶™2<²Ø™PÒв`L³çy¿å º Ê ®Áä˜(å÷”󚕲~²-&_ ˜/¿û*Få<>ßÏ~89ŒÚÙ/é7ß‚ÏøõVÓ%Çæ
-Å` g«–ˆ_k9B5–dËUEëVv¬ÖUOÝ›m':I6¸¯.Ëq‘,ɆÐc [qMûá
-"׆ëA+¢è¥(ã«Å%¸»h;An9Ÿ q-W—JŒI@r²ºKá:“” J€GYü>DùˆQ¤_¿ ¶'±À8/8xþÕ\ê¯AÉ‹Ìà¯à¦Á†‰vé¥e¿ ¤y {†­æ @³ù˜ö¸"¯x}qRŒç ìA„ÏO´€3XÀÎ¥¬öˆóÍv¿Qô—|ÅÆà ÀFˆ½‹ÞE°Û‡ðH–âØ ²+[FlU"S ÖAß 
-¶Cªí'¸v<“0ĘIí„&9L Ë+Æ‹pÉAœ?b{lÓ:†A˜B€ ž˜ŒI.j «NeZæ,žÀö¨Ì82zD°YƒÑ;G)«Õ%tƒ†q¥ö±Æª€7_¢n‚µàP\,´$À߉áà¯~,âå¬u0’_YÆÅ͈
-âp°Cä¡Å`¿ñI(hmÐHE~æñ à4¾¡7õ-ÐX@ÄGØ؆¯A‹äø~¸bè“dQe¢wö3› ¥u!Ð
-ˆý®3<
-ßQ<Îh\K€?Ÿ&´ú"Š2d‘’rOÁ]EËHÑrÃü„—:ÙpÖ 4
- dpʦÉlUßlð{ÿ1¬ÕGB ÔŸÔ2~p9Ëš'6RÎöµo’z€ †„íÆt
-Ý–ŒÂÒóøƒÜë‹F84-ôå§þ‚»®ˆ¾Á>¥h·…+§í¸O¯nýHIãBêé¹ÎÔŒ´Œçi·û)Çú2Á'D²$«ÃáÀ‹ù²%Gl¬z-v†o^,dr»…‰Uoübôi8hfÒð$Æ–é DXìkbÕ@±‰æôLUˆök ‚Ö<m’€FÏ~‰p ˆO:šÆCˆâŸ¬×žYòS_ŠÄ.§XÛÇŒl> m}U ¯3„‚É.Ÿ^¹ˆrïðV1­ÂÎ ÐA\pM t>l€öŽa;úãa3>Ø…Ÿîû$rSá[i»ì§@«½4¹jˆÝÓ9‡­Ge¸rèæ¨1ÞÊ1(Ä&©—T2ñ
-îÌ”v
-ídÀÐçôú‘úø5†,µÛ+µ-©+åÄÅ>±=*¶Çº¥gæB¡jÈû&è65¤H"ÖLnVÊ„äö­™aÛSX¯%}
-õ6ᓃF’¢0NS⢼JwY
-+Ub‹­Öñ&\
-¯Ê&qóËÿÁ€'ÚwâXU~†¢×Þh,I¯¬­à$6
-Á:$ßý¬
-åÃï¡Q(¹Ô®ON)ÿ„* § i¾à‚Ò»ÑÒ}D’ t ШÿšS¯ÎE2d9
-.TlÛÑõÀ×±ñ‹=¸¥ÝÅx1Á"‹¥
-…Òñ¼f8¶¬C¥Þ;a^×.Ä—˜’Å^øLl³’Œ¶©¯ Õ­qLË}ÿ5†uíA°¸H "´9sIzßÈ0ï•Ld)V›Ùé@Ìk^rlpPdÚMVÓ®öRhVüÜþ$)Ê‘¯ûÛœ ¬¥r;eº)o¬b’¯Oa2N`w«>p„ý22°½¥áIäØußÕ1ŸuùåÜÇ/´
-qÑ@…Õ(ä”KF9•Ò±ŒWI!®ý“µXEáÖ`•<êª.ÏŒâñ÷à,ËkÜÙËÈEäÓU"QÆÄW¦Iy_üÓµ)vjD©_ÕŠò¿ÌÓJgg°ÕáÐyJùa=’þý$gA—嘹a*˜¨ sFìù”í%ÈÕ‰¨é ¦ùñÕ‹¿(š) 8f@ÿÌWL\J+(ô5‚}²Œ²Ô
-õONÙuº%¯.PØ/ÈûpÙúŒ×ÕºõçXâàQ_¼ƒ¿cê"ó2‚í‹ÇË€/6oØã¹€ãµL;c
-„¢Ç›$ú減†‡’™ZxÉb%—˜¨g´w bs
-#UYUC“ú@•š4p2<T:­Ã°¦i+7÷Ž…Ïc™ºžFfzGí5ÜÆS_c:7à<÷5¦²EOãÄט*Ê=Soc¡w—¾Æ¤ï<K_ã$û Ðv_û£sÝ„l´­Ó2CKéT”'…!Öl×í
- åRkòéÅÞÆQûfØÖcpuŸ /–$^ï¶ ¹-#äLá¢ûˆ–±“Ô*¼eòÈX3‰?â5ûÕ‰w©Ÿ“¥'&™E….ORò/Êg¿ <Ž‘§
-7bä½=vÌЀÔçl$:
-‡×p¶ì{5e4£xQ.’þb›dÎJ”k@J-k€:‘Ýòl’zÐN‡¡À|(1qNC6”ªÚõ‰Á)§­%öõÌm¸ šxRtÚT¤izÉâ‰?K åNÜÂÕÜ ô.»ÁJW°T]ÐF{¨ªQ°öæg ¶ãecx±Õ»ƒKjpP¦ÌzINM͵#]“ÖUy-¯«EÒºQwiHÛ”•!ß'º&dU¤QGh§-¥Ñ5ã7«Ì;YL­˜ÑǦfî“PñN:Ö®jA1Ó*ÿmÁµjj^|H"ì…WRgQI`mÒÜÛ„6`3ATbñ
-0î/öVµ Š ³ºÄ¡6p8Š¬ZÚ¬¸ %ï- vKÙE&-‘Ý´:Ñ‚™dì§7/˜¨!ì_½ÕF‹Ï(¢]$@5f¯}UÔ$y¼^¹Y/片´„]‹Ú3l«dm-}Ð[-x ½‰Z°pýçÐ ¦pñ몈Ç]f–Í‚ÜíQæ­D4”dèUï¯$¢AE 1Tr¯Îú:Ãm¡zPªo›^FA[ÊIg$êjØÆFÀ. mbtïÖ&!šËA ²i¨¼–K@íÇêêŸh$ËCÍ?»©¾HÿTï½è¶ARø8Û^Jܼ‹Fï¢]³nr»RÉ6`Ô•öÀGöZ
-cJÑ»“@ÜïvÜ  +ˆ E(‘ß Ø¤¨ô9†é}5šã|•Uâ1F¤;[þ˜¥°UÎ@ž^™Ù»4Í?òÉÈsì2X¶&çÿœ8×ø®u©‰A q¤ØÜ[ r‰¡œ#•\1&N•Nfšã’gæ…9ØIŽºÛQÜí6V±:Ñô@6t*Jw.Sž ¸t 6¶ª,úº–$ vw YȈ ö‹Í]‘i¨ ÝšîŒ;”+–§µÆˆ›IÕZ7òÉZÕˆƒK¸%”;B£¢Ì†JIey®AÝKÐ(DW]'| H·±Ësä¼X$ð.ÅO1^T‘Nxèhz` <˜ÒÏ:oª³ã;ò@‚0ôÖdž ?g°ì}v×Z œˆ«ƒˆ[™<SfeÂP?;´jœD‰S-4 B3eAª¡؈Û¨s@¿Y7¾¨:F ¦y·—ª(úX$¦¦º{àŸ­ý´× Š30y1£JpM|GÎÍoÖ—Å&„H´ÖñÉ)ä~ˆ&ߎó%H*®¡éLK
-mL1ã/ovfõéK¹?ÝfC¨Œ“±ó¢‰nóM¢í``’z7ƒýö€ø÷ÿG?ÏQ@c16ÝÉZ
-§•ÑùR[Xcû*j)t‹jé/géV^6U™~G§}ÚOUÆôÑ”ëä UMŸRý9E£­¨úì[Nï­ŽW->s}»SÉøÇÖ´‡‘©Áþt+eÌ!æECAÕñ`3]y2ŽÑ.˜YÁÔbÁÄ…ê©MY?2q
-Z0󌯑ì$äÐ?oÞ
-ri?R´ÁјMVLKð¬¹bÏxee`ˆ*tñD‡R‰}N±!þ®nê©df-JæY—’ iØ\öS3¸ ½]=ÓBò>zÆ ªÙIyݘ¬‡Eý(mb¶†âù'Ò;’º‰æ³š¢Ì${M>Áë9´å uëIF½*¼©ºÒ\UV+†õ´®‚?¢© ýY‹Ó-)& ‚ྙ¡ˆ·Ð3Ê“j[!Ì?5Û™×<ít·'jÐJ'-ÙåþšH ÔD
-{<PT´£71Š šðÔböØF•Œ»‰zRÌ\¢ú•I37<¶»uë.ú4ÕÇS~Ѷ>̅⢃‘]KRƒóýµßáЫQ&*ŽoY»¢½ý¶uÛvÞàVOsÝjù[™°¬~„õ¡B°j‹‰þ¤ÕŸl:Ë~g{^Õ·‘×›Ìøò`}ŒyÓRª¾}«Ö]ìZwÔ5tûµ“[y¥$Ñ¥ŠgªaÈœXFÄ¥b/´eúM òÃm®É“ïb²ÍÃïþ B»°˜’ÞW‰´\#bƒìsRÑ—?v…
-ŸKyw&Ju,_ÏÌ´Ò×ü‹„S£t§EàM ,Go6DªÓ9dy9’V½ @”¼ˆäñ7+ ”…fÓH 0×·JV¿BÃ;A²*Úñ KÓEPñü_¤~ÒVÄâ@(Ž¢È¡˜fõÜG¬´Šî­`1(±e–ëVÕ]rÖT×üêåm(ìÆĺ÷ûHˆ@˜Ñ›ïèô—’±ü
-³Òí¯BA ÎcÑ«‘sí‚™¨eG2Q5Å¢©­ô[÷u­ ÜÜ>éÅk€÷âÕPA-hmR4ÓáDuÅT•#7[Ï“ÞÃBô Ô›túw])ZS#DØÃÍK2ÓÇÃb«‘× èHø]¼fA\"ò¯æåé[ÅøªÔ²1†v…âÌõŸ¥G‡kjýÖñkºâÞ\QS00 å㵸tÛz\üíoäkA¿þÙ™.¦÷9[·äkuB9[Bøƒ«†u¾síuŸ£eY¾õ-oJëq´ú›²·ë:>Tdâ^Ýl›uWÃʵøG]Ö©FñvPÓ»ÕÕ ]kÐáaú8åT2¢ Õ´éJé¬ë¤yéÔ¤U†»¾Ž»`CÚ<‚Jr5á7·ù¼Õl}ï
-U!ß?#¹°¸©§Éla…Ïj2;¤C™ÌïšÒá˜F
-˜&e¬`¡Ñ èÛ*Ÿˆ‹ëh« ŒM72FÞiwïM*}ô?É3–Õkv\cKã-bæ
-éQãý%æŽ/d nØž ÚÙ`å?q—ÿŸqáoeÁ×^èý´ç ­ûÂöIž«6k½s­’gôTÙÐ ]ìÖª0½1Z?ÇãÉM®ö{™—e"o1UÆ”a“Tnê·±ï^â:µFÏ;_NÖ4ë&Yûï‡Û¨Ú4ì·b×»€6ÝÇ]ºTЮì¶ÑÞ9®aŸû[]ù&
-S‹éì°uÿ
-MýñUoWå<Âÿ_ˆ{¹̶æ%÷ãvc é{`Ðråý•®¸hþ*v x]x•/ Õk=û%::Æ—ë<ùå!~2S¯ésQ¾in¬ ¡ñàM>bh½wœ”OZ"ÿûÖ¼ ’>8bØÌ,Â:ý¯Ç¤ùÇÆB³`úERí©õÞ‡HýŠÓ&dY¿Õ WÀ½Ÿ­•ŒÐ“P>ò´œû—|Ú!°Êþ–dW÷O^A’²w*ŽÅ‚øG’ã\mu™Uk{TŠ+whÿ´ÙZ€ïn?ûU!uä0Ok7¬U|ßèFlÑ1\ìz$שuÕX ÓÞŒÑååôr ¾Q5D_Œþ<ûâ ¼HFðÅ7°Ò‚Ǿd‡»l_=yDß›#(~Ø›¥ù%`†é±a¶
-ÝÐ_מ÷Ön:Öv^]Ö†J²½®ì©Ú ±\Og}·ã¥öá^) ²ÛЋ'F_±jU”›tÇBN~£s‹>0]\ªHXÄ$“… £;}«CÿÂhtçx™>´M¤A£Ós"¤:Ë-Æ2ÞékL¶ò9ÆôݲÐ&•¸3ï9°ÓVäQ~&ò}o|ØŽ!7@ç?…PÍj1>o ï0ÞªPÝzVÑÒ›¡ô bvv7 É2™A|w“u[ZÅu.óý&«MÛ´RH1›Là½2c¿‘K†‘;š«¥€È1¶&Zøl]/{2X>(ïaÛ‹¿’xÛ‹¯4¸q°S¤ƒ‡‡Tc•ŠâÌó|¯ÝJ@þXÂçì·ø£R0 nUÞ8 oÓ¼x à‘Ñ–þ6ä$EÖõ#ä@Fÿð¢PZcË/ãH‹Y\U°šSî(¹dO–‘s–âœ~d³¾
diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc
deleted file mode 100755
index 455dfa4446..0000000000
--- a/ext/phar/phar/clicommand.inc
+++ /dev/null
@@ -1,377 +0,0 @@
-<?php
-
-/** @file clicommand.inc
- * @ingroup Phar
- * @brief class CLICommand
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Phar Command
- */
-
-/** @ingroup Phar
- * @brief Abstract base console command implementation
- * @author Marcus Boerger
- * @version 1.0
- */
-abstract class CLICommand
-{
- protected $argc;
- protected $argv;
- protected $cmds = array();
- protected $args = array();
- protected $typs = array();
-
- function __construct($argc, array $argv)
- {
- $this->argc = $argc;
- $this->argv = $argv;
- $this->cmds = self::getCommands($this);
- $this->typs = self::getArgTyps($this);
-
- if ($argc < 2) {
- self::error("No command given, check ${argv[0]} help\n");
- } elseif (!isset($this->cmds[$argv[1]]['run'])) {
- self::error("Unknown command '${argv[1]}', check ${argv[0]} help\n");
- } else {
- $command = $argv[1];
- }
-
- if (isset($this->cmds[$command]['arg'])) {
- $this->args = call_user_func(array($this, $this->cmds[$command]['arg']));
- $i = 1;
- $missing = false;
- while (++$i < $argc) {
- if ($argv[$i][0] == '-') {
- if (strlen($argv[$i]) == 2 && isset($this->args[$argv[$i][1]])) {
- $arg = $argv[$i][1];
- if (++$i >= $argc) {
- self::error("Missing argument to parameter '$arg' of command '$command', check ${argv[0]} help\n");
- } else {
- $this->args[$arg]['val'] = $this->checkArgTyp($arg, $i, $argc, $argv);
- }
- } else {
- self::error("Unknown parameter '${argv[$i]}' to command $command, check ${argv[0]} help\n");
- }
- } else {
- break;
- }
- }
- if (isset($this->args[''])) {
- if ($i >= $argc) {
- if (isset($this->args['']['require']) && $this->args['']['require']) {
- self::error("Missing default trailing arguments to command $command, check ${argv[0]} help\n");
- }
- } else {
- $this->args['']['val'] = array();
- while($i < $argc) {
- $this->args['']['val'][] = $argv[$i++];
- }
- }
- } else if ($i < $argc) {
- self::error("Unexpected default arguments to command $command, check ${argv[0]} help\n");
- }
-
- foreach($this->args as $arg => $inf) {
- if (strlen($arg) && !isset($inf['val']) && isset($inf['required']) && $inf['required']) {
- $missing .= "Missing parameter '-$arg' to command $command, check ${argv[0]} help\n";
- }
- }
- if (strlen($missing))
- {
- self::error($missing);
- }
- }
-
- call_user_func(array($this, $this->cmds[$command]['run']), $this->args);
- }
-
- static function notice ($msg)
- {
- fprintf(STDERR, $msg);
- }
-
- static function error ($msg, $exit_code = 1)
- {
- self::notice($msg);
- exit($exit_code);
- }
-
- function checkArgTyp($arg, $i, $argc, $argv)
- {
- $typ = $this->args[$arg]['typ'];
-
- if (isset($this->typs[$typ]['typ'])) {
- return call_user_func(array($this, $this->typs[$typ]['typ']), $argv[$i], $this->args[$arg], $arg);
- } else {
- return $argv[$i];
- }
- }
-
- static function getSubFuncs(CLICommand $cmdclass, $prefix, array $subs)
- {
- $a = array();
- $r = new ReflectionClass($cmdclass);
- $l = strlen($prefix);
-
- foreach($r->getMethods() as $m)
- {
- if (substr($m->name, 0, $l) == $prefix)
- {
- foreach($subs as $sub)
- {
- $what = substr($m->name, $l+strlen($sub)+1);
- $func = $prefix . $sub . '_' . $what;
- $what = str_replace('_', '-', $what);
- if ($r->hasMethod($func))
- {
- if (!isset($a[$what]))
- {
- $a[$what] = array();
- }
- $a[$what][$sub] = /*$m->class . '::' .*/ $func;
- }
- }
- }
- }
- return $a;
- }
-
- static function getCommands(CLICommand $cmdclass)
- {
- return self::getSubFuncs($cmdclass, 'cli_cmd_', array('arg','inf','run'));
- }
-
- static function getArgTyps(CLICommand $cmdclass)
- {
- return self::getSubFuncs($cmdclass, 'cli_arg_', array('typ'));
- }
-
- static function cli_arg_typ_bool($arg, $cfg, $key)
- {
- return (bool)$arg;
- }
-
-
- static function cli_arg_typ_int($arg, $cfg, $key)
- {
- if ((int)$arg != $arg) {
- self::error("Argument to -$key must be an integer.\n");
- }
-
- return (int)$arg;
- }
-
- static function cli_arg_typ_regex($arg, $cfg, $key)
- {
- if (strlen($arg))
- {
- if (strlen($arg) > 1 && $arg[0] == $arg[strlen($arg)-1] && strpos('/,', $arg) !== false)
- {
- return $arg;
- }
- else
- {
- return '/' . $arg . '/';
- }
- }
- else
- {
- return NULL;
- }
- }
-
- static function cli_arg_typ_select($arg, $cfg, $key)
- {
- if (!in_array($arg, array_keys($cfg['select']))) {
- self::error("Parameter value '$arg' not one of '" . join("', '", array_keys($cfg['select'])) . "'.\n");
- }
- return $arg;
- }
-
- static function cli_arg_typ_dir($arg, $cfg, $key)
- {
- $f = realpath($arg);
-
- if ($f===false || !file_exists($f) || !is_dir($f)) {
- self::error("Requested path '$arg' does not exist.\n");
- }
- return $f;
- }
-
- static function cli_arg_typ_file($arg)
- {
- $f = new SplFileInfo($arg);
- $f = $f->getRealPath();
- if ($f===false || !file_exists($f))
- {
- echo "Requested file '$arg' does not exist.\n";
- exit(1);
- }
- return $f;
- }
-
- static function cli_arg_typ_filenew($arg, $cfg, $key)
- {
- $d = dirname($arg);
- $f = realpath($d);
-
- if ($f === false) {
- self::error("Path for file '$arg' does not exist.\n");
- }
- return $f . substr($arg, strlen($d));;
- }
-
- static function cli_arg_typ_filecont($arg, $cfg, $key)
- {
- return file_get_contents(self::cli_arg_typ_file($arg, $cfg, $key));
- }
-
- function cli_get_SP2($l1, $arg_inf)
- {
- return str_repeat(' ', $l1 + 2 + 4 + 8);
- }
-
- function cli_get_SP3($l1, $l2, $arg_inf)
- {
- return str_repeat(' ', $l1 + 2 + 4 + 8 + 2 + $l2 + 2);
- }
-
- static function cli_cmd_inf_help()
- {
- return "This help or help for a selected command.";
- }
-
- private function cli_wordwrap($what, $l, $sp)
- {
- $p = max(79 - $l, 40); // minimum length for paragraph
- $b = substr($what, 0, $l); // strip out initial $l
- $r = substr($what, $l); // remainder
- $r = str_replace("\n", "\n".$sp, $r); // in remainder replace \n's
- return $b . wordwrap($r, $p, "\n".$sp);
- }
-
- private function cli_help_get_args($func, $l, $sp, $required)
- {
- $inf = "";
- foreach(call_user_func($func, $l, $sp) as $arg => $conf)
- {
- if ((isset($conf['required']) && $conf['required']) != $required)
- {
- continue;
- }
- if (strlen($arg))
- {
- $arg = "-$arg ";
- }
- else
- {
- $arg = "... ";
- }
- $sp2 = $this->cli_get_SP2($l, $inf);
- $l2 = strlen($sp2);
- $inf .= $this->cli_wordwrap($sp . $arg . $conf['inf'], $l2, $sp2) . "\n";
- if (isset($conf['select']) && count($conf['select']))
- {
- $ls = 0;
- foreach($conf['select'] as $opt => $what)
- {
- $ls = max($ls, strlen($opt));
- }
- $sp3 = $this->cli_get_SP3($l, $ls, $inf);
- $l3 = strlen($sp3);
- foreach($conf['select'] as $opt => $what)
- {
- $inf .= $this->cli_wordwrap($sp2 . " " . sprintf("%-${ls}s ", $opt) . $what, $l3, $sp3) . "\n";
- }
- }
- }
- if (strlen($inf))
- {
- if ($required)
- {
- return $sp . "Required arguments:\n\n" . $inf;
- }
- else
- {
- return $sp . "Optional arguments:\n\n". $inf;
- }
- }
- }
-
- function cli_cmd_arg_help()
- {
- return array('' => array('typ'=>'any','val'=>NULL,'inf'=>'Optional command to retrieve help for.'));
- }
-
- function cli_cmd_run_help()
- {
- $argv = $this->argv;
- $which = $this->args['']['val'];
- if (isset($which))
- {
- if (count($which) != 1) {
- self::error("More than one command given.\n");
- }
-
- $which = $which[0];
- if (!array_key_exists($which, $this->cmds)) {
- self::error("Unknown command, cannot retrieve help.\n");
- }
-
- $l = strlen($which);
- $cmds = array($which => $this->cmds[$which]);
- } else {
- echo "\n$argv[0] <command> [options]\n\n";
- $l = 0;
- ksort($this->cmds);
- foreach($this->cmds as $name => $funcs) {
- $l = max($l, strlen($name));
- }
- $inf = "Commands:";
- $lst = "";
- $ind = strlen($inf) + 1;
- foreach($this->cmds as $name => $funcs)
- {
- $lst .= ' ' . $name;
- }
- echo $this->cli_wordwrap($inf.$lst, $ind, str_repeat(' ', $ind)) . "\n\n";
- $cmds = $this->cmds;
- }
- $sp = str_repeat(' ', $l + 2);
- foreach($cmds as $name => $funcs)
- {
- $inf = $name . substr($sp, strlen($name));
- if (isset($funcs['inf']))
- {
- $inf .= $this->cli_wordwrap(call_user_func(array($this, $funcs['inf'])), $l, $sp) . "\n";
- if (isset($funcs['arg']))
- {
- $inf .= "\n";
- $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, true);
- $inf .= "\n";
- $inf .= $this->cli_help_get_args(array($this, $funcs['arg']), $l, $sp, false);
- }
- }
- echo "$inf\n\n";
- }
- exit(0);
- }
-
- static function cli_cmd_inf_help_list()
- {
- return "Lists available commands.";
- }
-
- function cli_cmd_run_help_list()
- {
- ksort($this->cmds);
- $lst = '';
- foreach($this->cmds as $name => $funcs) {
- $lst .= $name . ' ';
- }
- echo substr($lst, 0, -1) . "\n";
- }
-}
-
-?>
diff --git a/ext/phar/phar/directorygraphiterator.inc b/ext/phar/phar/directorygraphiterator.inc
deleted file mode 100755
index 5808e3b89e..0000000000
--- a/ext/phar/phar/directorygraphiterator.inc
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/** @file directorygraphiterator.inc
- * @ingroup Examples
- * @brief class DirectoryGraphIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A tree iterator that only shows directories.
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryGraphIterator extends DirectoryTreeIterator
-{
- function __construct($path)
- {
- RecursiveIteratorIterator::__construct(
- new RecursiveCachingIterator(
- new ParentIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- )
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/phar/phar/directorytreeiterator.inc b/ext/phar/phar/directorytreeiterator.inc
deleted file mode 100755
index 8e65d0db12..0000000000
--- a/ext/phar/phar/directorytreeiterator.inc
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/** @file directorytreeiterator.inc
- * @ingroup Examples
- * @brief class DirectoryTreeIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief DirectoryIterator to generate ASCII graphic directory trees
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryTreeIterator extends RecursiveIteratorIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path)
- {
- parent::__construct(
- new RecursiveCachingIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-
- /** @return the current element prefixed with ASCII graphics
- */
- function current()
- {
- $tree = '';
- for ($l=0; $l < $this->getDepth(); $l++) {
- $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
- }
- return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
- . $this->getSubIterator($l)->__toString();
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getSubIterator(), $func), $params);
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/phar/phar/invertedregexiterator.inc b/ext/phar/phar/invertedregexiterator.inc
deleted file mode 100755
index 7eea533a22..0000000000
--- a/ext/phar/phar/invertedregexiterator.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-/** @file invertedregexiterator.inc
- * @ingroup Phar
- * @brief class InvertedRegexIterator
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Inverted RegexIterator
- */
-
-/** @ingroup Phar
- * @brief Inverted RegexIterator
- * @author Marcus Boerger
- * @version 1.0
- */
-class InvertedRegexIterator extends RegexIterator
-{
- /** @return !RegexIterator::accept()
- */
- function accept()
- {
- return !RegexIterator::accept();
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/phar/phar/phar.inc b/ext/phar/phar/phar.inc
deleted file mode 100755
index a7c6f6d5fe..0000000000
--- a/ext/phar/phar/phar.inc
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-/**
- * @file phar.inc
- * @ingroup Phar
- * @brief class Phar
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Phar Command
- */
-// {{{ class Phar extends PHP_Archive
-/**
- * Phar class
- *
- * @ingroup Phar
- * @brief Phar implementation
- * @author Marcus Boerger
- * @version 1.0
- */
-class Phar extends PHP_Archive implements RecursiveIterator
-{
- function getSignature()
- {
- return false;
- }
-
- function getAlias()
- {
- return false;
- }
-
- function rewind()
- {
- }
-
- function valid()
- {
- return false;
- }
-
- function current()
- {
- }
-
- function key()
- {
- }
-
- function next()
- {
- }
-
- function hasChildren()
- {
- return false;
- }
-
- function getChildren()
- {
- }
-
- function hasMetadata()
- {
- }
-
- function getMetadata()
- {
- }
-
- function getStub()
- {
- }
-
- function setStub()
- {
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/phar/phar/phar.php b/ext/phar/phar/phar.php
deleted file mode 100755
index 93a938842c..0000000000
--- a/ext/phar/phar/phar.php
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/php
-<?php
-
-/** @file phar.php
- * @ingroup Phar
- * @brief class CLICommand
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Phar Command
- */
-
-if (!extension_loaded('phar'))
-{
- if (!class_exists('PHP_Archive', 0))
- {
- echo "Neither Extension Phar nor class PHP_Archive are available.\n";
- exit(1);
- }
- if (!in_array('phar', stream_get_wrappers()))
- {
- stream_wrapper_register('phar', 'PHP_Archive');
- }
- if (!class_exists('Phar',0)) {
- require 'phar://'.__FILE__.'/phar.inc';
- }
-}
-
-foreach(array("SPL", "Reflection") as $ext)
-{
- if (!extension_loaded($ext))
- {
- echo "$argv[0] requires PHP extension $ext.\n";
- exit(1);
- }
-}
-
-function command_include($file)
-{
- $file = 'phar://' . __FILE__ . '/' . $file;
- if (file_exists($file)) {
- include($file);
- }
-}
-
-function command_autoload($classname)
-{
- command_include(strtolower($classname) . '.inc');
-}
-
-Phar::mapPhar();
-
-spl_autoload_register('command_autoload');
-
-new PharCommand($argc, $argv);
-
-__HALT_COMPILER(); ?> \ No newline at end of file
diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc
deleted file mode 100755
index 5787845320..0000000000
--- a/ext/phar/phar/pharcommand.inc
+++ /dev/null
@@ -1,1406 +0,0 @@
-<?php
-
-/**
- * @file pharcommand.inc
- * @ingroup Phar
- * @brief class CLICommand
- * @author Marcus Boerger
- * @date 2007 - 2007
- *
- * Phar Command
- */
-// {{{ class PharCommand extends CLICommand
-/**
- * PharCommand class
- *
- * This class handles the handling of the phar
- * commands. It will be used from command line/console
- * in order to retrieve and execute phar functions.
- *
- * @ingroup Phar
- * @brief Phar console command implementation
- * @author Marcus Boerger
- * @version 1.0
- */
-class PharCommand extends CLICommand
-{
- // {{{ public function cli_get_SP2
- public function cli_get_SP2($l1, $arg_inf)
- {
- return str_repeat(' ', $l1 + 2 + 4 + 9);
- }
- // }}}
- // {{{ public function cli_get_SP3
- /**
- * Cli Get SP3
- *
- * @param string $l1 Eleven
- * @param string $l2 Twelve
- * @param string $arg_inf
- * @return string The repeated string.
- */
- function cli_get_SP3($l1, $l2, $arg_inf)
- {
- return str_repeat(' ', $l1 + 2 + 4 + 9 + 2 + $l2 + 2);
- }
- // }}}
- // {{{ static function phar_args
- /**
- * Phar arguments
- *
- * This function contains all the phar commands
- *
- * @param string $which Which argument is chosen.
- * @param string $phartype The type of phar, specific file to work on
- * @return unknown
- */
- static function phar_args($which, $phartype)
- {
- $phar_args = array(
- 'a' => array(
- 'typ' => 'alias',
- 'val' => NULL,
- 'inf' => '<alias> Provide an alias name for the phar file.'
- ),
- 'c' => array(
- 'typ' => 'compalg',
- 'val' => NULL,
- 'inf' => '<algo> Compression algorithm.',
- 'select' => array(
- '0' => 'No compression',
- 'none' => 'No compression',
- 'auto' => 'Automatically select compression algorithm'
- )
- ),
- 'e' => array(
- 'typ' => 'entry',
- 'val' => NULL,
- 'inf' => '<entry> Name of entry to work on (must include PHAR internal directory name if any).'
- ),
- 'f' => array(
- 'typ' => $phartype,
- 'val' => NULL,
- 'inf' => '<file> Specifies the phar file to work on.'
- ),
- 'h' => array(
- 'typ' => 'select',
- 'val' => NULL,
- 'inf' => '<method> Selects the hash algorithmn.',
- 'select' => array('md5' => 'MD5','sha1' => 'SHA1')
- ),
- 'i' => array(
- 'typ' => 'regex',
- 'val' => NULL,
- 'inf' => '<regex> Specifies a regular expression for input files.'
- ),
- 'k' => array(
- 'typ' => 'any',
- 'val' => NULL,
- 'inf' => '<index> Subscription index to work on.',
- ),
- 'l' => array(
- 'typ' => 'int',
- 'val' => 0,
- 'inf' => '<level> Number of preceeding subdirectories to strip from file entries',
- ),
- 'm' => array(
- 'typ' => 'any',
- 'val' => NULL,
- 'inf' => '<meta> Meta data to store with entry (serialized php data).'
- ),
- 'p' => array(
- 'typ' => 'loader',
- 'val' => NULL,
- 'inf' => '<loader> Location of PHP_Archive class file (pear list-files PHP_Archive).'
- .'You can use \'0\' or \'1\' to locate it automatically using the mentioned '
- .'pear command. When using \'0\' the command does not error out when the '
- .'class file cannot be located. This switch also adds some code around the '
- .'stub so that class PHP_Archive gets registered as phar:// stream wrapper '
- .'if necessary. And finally this switch will add the file phar.inc from '
- .'this package and load it to ensure class Phar is present.'
- ,
- ),
- 's' => array(
- 'typ' => 'file',
- 'val' => NULL,
- 'inf' => '<stub> Select the stub file.'
- ),
- 'x' => array(
- 'typ' => 'regex',
- 'val' => NULL,
- 'inf' => '<regex> Regular expression for input files to exclude.'
- ),
-
- );
-
- if (extension_loaded('zlib')) {
- $phar_args['c']['select']['gz'] = 'GZip compression';
- $phar_args['c']['select']['gzip'] = 'GZip compression';
- }
-
- if (extension_loaded('bz2')) {
- $phar_args['c']['select']['bz2'] = 'BZip2 compression';
- $phar_args['c']['select']['bzip2'] = 'BZip2 compression';
- }
-
- $hash_avail = Phar::getSupportedSignatures();
- if (in_array('SHA-256', $hash_avail)) {
- $phar_args['h']['select']['sha256'] = 'SHA256';
- }
-
- if (in_array('SHA-512', Phar::getSupportedSignatures())) {
- $phar_args['h']['select']['sha512'] = 'SHA512';
- }
-
- $args = array();
-
- foreach($phar_args as $lkey => $cfg) {
- $ukey = strtoupper($lkey);
- $required = strpos($which, $ukey) !== false;
- $optional = strpos($which, $lkey) !== false;
-
- if ($required || $optional) {
- $args[$lkey] = $cfg;
- $args[$lkey]['required'] = $required;
- }
- }
- return $args;
- }
- // }}}
- // {{{ static function strEndsWith
- /**
- * String Ends With
- *
- * Wether a string end with another needle.
- *
- * @param string $haystack The haystack
- * @param string $needle The needle.
- * @return mixed false if doesn't end with anything, the string
- * substr'ed if the string ends with the needle.
- */
- static function strEndsWith($haystack, $needle)
- {
- return substr($haystack, -strlen($needle)) == $needle;
- }
- // }}}
- // {{{ static function cli_arg_typ_loader
- /**
- * Argument type loader
- *
- * @param string $arg Either 'auto', 'optional' or an filename that
- * contains class PHP_Archive
- * @param string $cfg Configuration to pass to a new file
- * @param string $key The key
- * @return string $arg The argument.
- */
- static function cli_arg_typ_loader($arg, $cfg, $key)
- {
- if (($arg == '0' || $arg == '1') && !file_exists($arg)) {
- $found = NULL;
- foreach(split("\n", `pear list-files PHP_Archive`) as $ent) {
- $matches = NULL;
- if (preg_match(",^php[ \t]+([^ \t].*pear[\\\\/]PHP[\\\\/]Archive.php)$,", $ent, $matches)) {
- $found = $matches[1];
- break;
- }
- }
- if (!isset($found)) {
- $msg = "Pear package PHP_Archive or Archive.php class file not found.\n";
- if ($arg == '0') {
- self::notice($msg);
- } else {
- self::error($msg);
- }
- }
- $arg = $found;
- }
- return self::cli_arg_typ_file($arg);
- }
- // }}}
- // {{{ static function cli_arg_typ_pharnew
- /**
- * Argument type new phar
- *
- * @param string $arg The new phar component.
- * @param string $cfg Configuration to pass to a new file
- * @param string $key The key
- * @return string $arg The new argument file.
- */
- static function cli_arg_typ_pharnew($arg, $cfg, $key)
- {
- $arg = self::cli_arg_typ_filenew($arg, $cfg, $key);
- if (!Phar::isValidPharFilename($arg)) {
- self::error("Phar files must have file extension '.phar', '.phar.php', '.phar.bz2' or 'phar.gz'.\n");
- }
- return $arg;
- }
- // }}}
- // {{{ static function cli_arg_typ_pharfile
- /**
- * Argument type existing Phar file
- *
- * Return filenam eof an existing Phar.
- *
- * @param string $arg The file in the phar to open.
- * @param string $cfg The configuration information
- * @param string $key The key information.
- * @return string $pharfile The name of the loaded Phar file.
- * @note The Phar will be loaded
- */
- static function cli_arg_typ_pharfile($arg, $cfg, $key)
- {
- try {
- $pharfile = self::cli_arg_typ_file($arg, $cfg, $key);
-
- if (!Phar::loadPhar($pharfile)) {
- self::error("Unable to open phar '$arg'\n");
- }
-
- return $pharfile;
- } catch(Exception $e) {
- self::error("Exception while opening phar '$arg':\n" . $e->getMessage() . "\n");
- }
- }
- // }}}
- // {{{ static function cli_arg_typ_pharurl
- /**
- * Argument type Phar url-like
- *
- * Check the argument as cli_arg_Typ_phar and return its name prefixed
- * with phar://
- *
- * Ex:
- * <code>
- * $arg = 'pharchive.phar/file.php';
- * cli_arg_typ_pharurl($arg)
- * </code>
- *
- * @param string $arg The url-like phar archive to retrieve.
- * @return string The phar file-archive.
- */
- static function cli_arg_typ_pharurl($arg, $cfg, $key)
- {
- return 'phar://' . self::cli_arg_typ_pharfile($arg, $cfg, $key);
- }
- // }}}
- // {{{ static function cli_arg_typ_phar
- /**
- * Cli argument type phar
- *
- * @param string $arg The phar archive to use.
- * @return object new Phar of the passed argument.
- */
- static function cli_arg_typ_phar($arg, $cfg, $key)
- {
- try {
- return new Phar(self::cli_arg_typ_pharfile($arg, $cfg, $key));
- } catch(Exception $e) {
- self::error("Exception while opening phar '$argv':\n" . $e->getMessage() . "\n");
- }
- }
- // }}}
- // {{{ static function cli_arg_typ_entry
- /**
- * Argument type Entry name
- *
- * @param string $arg The argument (the entry)
- * @return string $arg The entry itself.
- */
- static function cli_arg_typ_entry($arg, $cfg, $key)
- {
- // no further check atm, maybe check for no '/' at beginning
- return $arg;
- }
- // }}}
- // {{{ static function cli_arg_typ_compalg
- /**
- * Argument type compression algorithm
- *
- * @param string $arg The phar selection
- * @param string $cfg The config option.
- * @param string $key The key information.
- * @return string $arg The selected algorithm
- */
- static function cli_arg_typ_compalg($arg, $cfg, $key)
- {
- $arg = self::cli_arg_typ_select($arg, $cfg, $key);
-
- switch($arg) {
- case 'auto':
- if (extension_loaded('zlib')) {
- $arg = 'gz';
- } elseif (extension_loaded('bz2')) {
- $arg = 'bz2';
- } else {
- $arg = '0';
- }
- break;
- }
- return $arg;
- }
- // }}}
- // {{{ static function cli_cmd_inf_pack
- /**
- * Information pack
- *
- * @return string A description about packing files into a Phar archive.
- */
- static function cli_cmd_inf_pack()
- {
- return "Pack files into a PHAR archive.\n" .
- "When using -s <stub>, then the stub file is being " .
- "excluded from the list of input files/dirs." .
- "To create an archive that contains PEAR class PHP_Archiave " .
- "then point -p argument to PHP/Archive.php.\n";
- }
- // }}}
- // {{{ static function cli_cmd_arg_pack
- /**
- * Pack a new phar infos
- *
- * @return array $args The arguments for a new Phar archive.
- */
- static function cli_cmd_arg_pack()
- {
- $args = self::phar_args('acFhilpsx', 'pharnew');
-
- $args[''] = array(
- 'typ' => 'any',
- 'val' => NULL,
- 'required' => 1,
- 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching thegiven regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.',
-
- );
-
- return $args;
- }
- // }}}
- // {{{ function phar_set_stub_begin
- /**
- * Set the stub
- */
- public function phar_set_stub_begin(Phar $phar, $stub, $loader = NULL)
- {
- if (isset($stub)) {
- if (isset($loader)) {
- $c = file_get_contents($stub);
- $s = '';
-
- if (substr($c, 0, 2) == '#!') {
- $s .= substr($c, 0, strpos($c, "\n") + 1);
- }
-
- $s .= "<?php if (!class_exists('PHP_Archive')) {\n?>";
- $s .= file_get_contents($loader);
- $s .= "<?php\n";
- $s .= "}\n";
- $s .= "if (!in_array('phar', stream_get_wrappers())) {\n\tstream_wrapper_register('phar', 'PHP_Archive');\n}\n";
- $s .= "if (!class_exists('Phar',0)) {\n";
- $s .= "\tinclude 'phar://'.__FILE__.'/phar.inc';\n";
- $s .= "}\n";
- $s .= '?>';
-
- if (substr($c,0,1) == '#') {
- $s.= substr($c,strpos($c, "\n")+1);
- }
-
- $phar->setStub($s);
- } else {
- $phar->setStub(file_get_contents($stub));
- }
- return new SplFileInfo($stub);
- }
- return NULL;
- }
- // }}}
- // {{{ function phar_set_stub_end
- /**
- * Set stub end
- */
- public function phar_set_stub_end(Phar $phar, $stub, $loader = NULL)
- {
- if (isset($stub) && isset($loader)) {
- if (substr(__FILE__, -15) == 'pharcommand.inc') {
- self::phar_add_file($phar, 0, 'phar.inc', 'phar://'.__FILE__.'/phar.inc', NULL);
- } else {
- self::phar_add_file($phar, 0, 'phar.inc', dirname(__FILE__).'/phar/phar.inc', NULL);
- }
- }
- }
- // }}}
- // {{{ function cli_cmd_run_pack
- /**
- * Pack a new Phar
- *
- * This function will try to pack a new Phar archive.
- *
- * @see Exit to make sure that we are done.
- */
- public function cli_cmd_run_pack()
- {
- if (ini_get('phar.readonly')) {
- self::error("Creating phar files is disabled by ini setting 'phar.readonly'.\n");
- }
-
- if (!Phar::canWrite()) {
- self::error("Creating phar files is disabled, Phar::canWrite() returned false.\n");
- }
-
- $alias = $this->args['a']['val'];
- $archive = $this->args['f']['val'];
- $hash = $this->args['h']['val'];
- $regex = $this->args['i']['val'];
- $level = $this->args['l']['val'];
- $loader = $this->args['p']['val'];
- $stub = $this->args['s']['val'];
- $invregex = $this->args['x']['val'];
- $input = $this->args['']['val'];
-
- $phar = new Phar($archive, 0, $alias);
-
- $phar->startBuffering();
-
- $stub = $this->phar_set_stub_begin($phar, $stub, $loader);
-
- if (!is_array($input)) {
- $this->phar_add($phar, $level, $input, $regex, $invregex, $stub, NULL, isset($loader));
- } else {
- foreach($input as $i) {
- $this->phar_add($phar, $level, $i, $regex, $invregex, $stub, NULL, isset($loader));
- }
- }
-
- $this->phar_set_stub_end($phar, $stub, $loader);
-
- switch($this->args['c']['val']) {
- case 'gz':
- case 'gzip':
- $phar->compressAllFilesGZ();
- break;
- case 'bz2':
- case 'bzip2':
- $phar->compressAllFilesBZIP2();
- break;
- default:
- $phar->uncompressAllFiles();
- break;
- }
-
- if ($hash) {
- $phar->setSignatureAlgorithm($hash);
- }
-
- $phar->stopBuffering();
- exit(0);
- }
- // }}}
- // {{{ static function phar_add
- /**
- * Add files to a phar archive.
- *
- * This function will take a directory and iterate through
- * it and get the files to insert into the Phar archive.
- *
- * @param Phar $phar The phar object.
- * @param string $input The input directory
- * @param string $regex The regex use in RegexIterator.
- * @param string $invregex The InvertedRegexIterator expression.
- * @param SplFileInfo $stub Stub file object
- * @param mixed $compress Compression algorithm or NULL
- * @param boolean $noloader Whether to prevent adding the loader
- */
- static function phar_add(Phar $phar, $level, $input, $regex, $invregex, SplFileInfo $stub = NULL, $compress = NULL, $noloader = false)
- {
- if ($input && is_file($input) && !is_dir($input)) {
- return self::phar_add_file($phar, $level, $input, $input, $compress);
- }
- $dir = new RecursiveDirectoryIterator($input);
- $dir = new RecursiveIteratorIterator($dir);
-
- if (isset($regex)) {
- $dir = new RegexIterator($dir, $regex);
- }
-
- if (isset($invregex)) {
- $dir = new InvertedRegexIterator($dir, $invregex);
- }
-
- try {
- foreach($dir as $file) {
- if (empty($stub) || $file->getRealPath() != $stub->getRealPath()) {
- self::phar_add_file($phar, $level, $dir->getSubPathName(), $file, $compress, $noloader);
- }
- }
- } catch(Excpetion $e) {
- self::error("Unable to complete operation on file '$file'\n" . $e->getMessage() . "\n");
- }
- }
- // }}}
- // {{{ static function phar_add_file
- /**
- * Add a phar file
- *
- * This function adds a file to a phar archive.
- *
- * @param Phar $phar The phar object
- * @param string $level The level of the file.
- * @param string $entry The entry point
- * @param string $file The file to add to the archive
- * @param string $compress The compression scheme for the file.
- * @param boolean $noloader Whether to prevent adding the loader
- */
- static function phar_add_file(Phar $phar, $level, $entry, $file, $compress, $noloader = false)
- {
- $entry = str_replace('//', '/', $entry);
- while($level-- > 0 && ($p = strpos($entry, '/')) !== false) {
- $entry = substr($entry, $p+1);
- }
-
- if ($noloader && $entry == 'phar.inc') {
- return;
- }
-
- echo "$entry\n";
-
- $phar[$entry] = file_get_contents($file);
- switch($compress) {
- case 'gz':
- case 'gzip':
- $phar[$entry]->setCompressedGZ();
- break;
- case 'bz2':
- case 'bzip2':
- $phar[$entry]->setCompressedBZIP2();
- break;
- default:
- break;
- }
- }
- // }}}
- // {{{ public function phar_dir_echo
- /**
- * Echo directory
- *
- * @param string $pn
- * @param unknown_type $f
- */
- public function phar_dir_echo($pn, $f)
- {
- echo "$f\n";
- }
- // }}}
- // {{{ public function phar_dir_operation
- /**
- * Directory operations
- *
- * Phar directory operations.
- *
- * @param RecursiveIteratorIterator $dir The recursiveIteratorIterator object.
- * @param string $func Function to call on the iterations
- * @param array $args Function arguments.
- */
- public function phar_dir_operation(RecursiveIteratorIterator $dir, $func, array $args = array())
- {
- $regex = $this->args['i']['val'];
- $invregex= $this->args['x']['val'];
-
- if (isset($regex)) {
- $dir = new RegexIterator($dir, $regex);
- }
-
- if (isset($invregex)) {
- $dir = new InvertedRegexIterator($dir, $invregex);
- }
-
- foreach($dir as $pn => $f) {
- call_user_func($func, $pn, $f, $args);
- }
- }
- // {{{ static function cli_cmd_inf_list
- /**
- * Cli Command Info List
- *
- * @return string What inf does
- */
- static function cli_cmd_inf_list()
- {
- return "List contents of a PHAR archive.";
- }
- // }}}
- // {{{ static function cli_cmd_arg_list
- /**
- * Cli Command Argument List
- *
- * @return arguments list
- */
- static function cli_cmd_arg_list()
- {
- return self::phar_args('Fix', 'pharurl');
- }
- // }}}
- // {{{ public function cli_cmd_run_list
- /**
- * Cli Command Run List
- *
- * @see $this->phar_dir_operation
- */
- public function cli_cmd_run_list()
- {
- $this->phar_dir_operation(
- new DirectoryTreeIterator(
- $this->args['f']['val']),
- array($this, 'phar_dir_echo')
- );
- }
- // }}}
- // {{{ static function cli_command_inf_tree
- /**
- * Cli Command Inf Tree
- *
- * @return string The description of a directory tree for a Phar archive.
- */
- static function cli_cmd_inf_tree()
- {
- return "Get a directory tree for a PHAR archive.";
- }
- // }}}
- // {{{ static function cli_cmd_arg_tree
- /**
- * Cli Command Argument Tree
- *
- * @return string Arguments in URL format.
- */
- static function cli_cmd_arg_tree()
- {
- return self::phar_args('Fix', 'pharurl');
- }
- // }}}
- // {{{ public function cli_cmd_run_tree
- /**
- * Cli Command Run Tree
- *
- * Set the phar_dir_operation with a directorygraphiterator.
- *
- * @see DirectoryGraphIterator
- * @see $this->phar_dir_operation
- *
- */
- public function cli_cmd_run_tree()
- {
- $this->phar_dir_operation(
- new DirectoryGraphIterator(
- $this->args['f']['val']),
- array($this, 'phar_dir_echo')
- );
- }
- // }}}
- // {{{ cli_cmd_inf_extract
- /**
- * Cli Command Inf Extract
- *
- * @return string The description of the command extra to a directory.
- */
- static function cli_cmd_inf_extract()
- {
- return "Extract a PHAR package to a directory.";
- }
- // }}}
- // {{{ static function cli_cmd_arg_extract
- /**
- * Cli Command Arguments Extract
- *
- * The arguments for the extract function.
- *
- * @return array The arguments for the extraction.
- */
- static function cli_cmd_arg_extract()
- {
- $args = self::phar_args('Fix', 'phar');
-
- $args[''] = array(
- 'type' => 'dir',
- 'val' => '.',
- 'inf' => ' Directory to extract to (defaults to \'.\').',
- );
-
- return $args;
- }
- // }}}
- // {{{ public function cli_cmd_run_extract
- /**
- * Run Extract
- *
- * Run the extraction of a phar Archive.
- *
- * @see $this->phar_dir_operation
- */
- public function cli_cmd_run_extract()
- {
- $dir = $this->args['']['val'];
-
- if (is_array($dir)) {
- if (count($dir) != 1) {
- self::error("Only one target directory allowed.\n");
- } else {
- $dir = $dir[0];
- }
- }
-
- $phar = $args['f']['val'];
- $base = $phar->getPathname();
- $bend = strpos($base, '.phar');
- $bend = strpos($base, '/', $bend);
- $base = substr($base, 0, $bend + 1);
- $blen = strlen($base);
-
- $this->phar_dir_operation(
- new RecursiveIteratorIterator($phar),
- array($this, 'phar_dir_extract'),
- array($blen, $dir)
- );
- }
- // }}}
- // {{{ public function phar_dir_extract
- /**
- * Extract to a directory
- *
- * This function will extract the content of a Phar
- * to a directory and create new files and directories
- * depending on the permissions on that folder.
- *
- * @param string $pn
- * @param string $f The file name
- * @param array $args The directory and Blen informations
- */
- public function phar_dir_extract($pn, $f, $args)
- {
- $blen = $args[0];
- $dir = $args[1];
- $sub = substr($pn, $blen);
- $target = $dir . '/' . $sub;
-
- if (!file_exists(dirname($target))) {
- if (!is_writable(dirname($target))) {
- self::error("Operation could not be completed\n");
- }
-
- mkdir(dirname($target));
- }
-
- echo "$sub";
-
- if (!@copy($f, $target)) {
- echo " ...error\n";
- } else {
- echo " ...ok\n";
- }
- }
- // }}}
- // {{{ static function cli_cmd_inf_delete
- /**
- * Delete an entry from a phar information.
- *
- * @return string The information
- */
- static function cli_cmd_inf_delete()
- {
- return 'Delete entry from a PHAR archive';
- }
- // }}}
- // {{{ static function cli_cmd_arg_delete
- /**
- * The cli command argument for deleting.
- *
- * @return array informations about the arguments to use.
- */
- static function cli_cmd_arg_delete()
- {
- return self::phar_args('FE', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_delete
- /**
- * Deleting execution
- *
- * Execute the deleting of the file from the phar archive.
- */
- public function cli_cmd_run_delete()
- {
- $phar = $this->args['f']['val'];
- $entry = $this->args['e']['val'];
-
- $phar->startBuffering();
- unset($phar[$entry]);
- $phar->stopBuffering();
- }
- // }}}
- // {{{ static function cli_cmd_inf_add
- /**
- * Client comment add file information
- *
- * @return string The description of the feature
- */
- static function cli_cmd_inf_add()
- {
- return "Add entries to a PHAR package.";
- }
- // }}}
- // {{{ static function cli_cmd_arg_add
- /**
- * Add a file arguments
- */
- static function cli_cmd_arg_add()
- {
- $args = self::phar_args('acFilx', 'phar');
- $args[''] = array(
- 'type' => 'any',
- 'val' => NULL,
- 'required' => 1,
- 'inf' => ' Any number of input files and directories. If -i is in use then ONLY files and matching thegiven regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.',
- );
- return $args;
- }
- // }}}
- // {{{ public functio cli_cmd_run_add
- /**
- * Add a file
- *
- * Run the action of adding a file to
- * a phar archive.
- */
- public function cli_cmd_run_add()
- {
- $compress= $this->args['c']['val'];
- $phar = $this->args['f']['val'];
- $regex = $this->args['i']['val'];
- $level = $this->args['l']['val'];
- $invregex= $this->args['x']['val'];
- $input = $this->args['']['val'];
-
- $phar->startBuffering();
-
- if (!is_array($input)) {
- $this->phar_add($phar, $level, $input, $regex, $invregex, NULL, $compress);
- } else {
- foreach($input as $i) {
- $this->phar_add($phar, $level, $i, $regex, $invregex, NULL, $compress);
- }
- }
- $phar->stopBuffering();
- exit(0);
- }
- // }}}
- // {{{ public function cli_cmd_inf_stub_set
- /**
- * Set the stup of a phar file.
- *
- * @return string The stub set description.
- */
- public function cli_cmd_inf_stub_set()
- {
- return "Set the stub of a PHAR file. " .
- "If no input file is specified as stub then stdin is being used.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_stub_set
- /**
- * Set the argument stub
- *
- * @return string arguments for a stub
- */
- public function cli_cmd_arg_stub_set()
- {
- $args = self::phar_args('Fps', 'phar');
- $args['s']['val'] = 'php://stdin';
- return $args;
- }
- // }}}
- // {{{ public function cli_cmd_run_stub_set
- /**
- * Cli Command run stub set
- *
- * @see $phar->setStub()
- */
- public function cli_cmd_run_stub_set()
- {
- $phar = $this->args['f']['val'];
- $stub = $this->args['s']['val'];
- $loader = $this->args['p']['val'];
-
- $this->phar_set_stub_begin($phar, $stub, $loader);
- $this->phar_set_stub_end($phar, $stub, $loader);
- }
- // }}}
- // {{{ public function cli_cmd_inf_stub_get
- /**
- * Get the command stub infos.
- *
- * @return string a description of the stub of a Phar file.
- */
- public function cli_cmd_inf_stub_get()
- {
- return "Get the stub of a PHAR file. " .
- "If no output file is specified as stub then stdout is being used.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_stub_get
- /**
- * Get the argument stub
- *
- * @return array $args The arguments passed to the stub.
- */
- public function cli_cmd_arg_stub_get()
- {
- $args = self::phar_args('Fs', 'phar');
- $args['s']['val'] = 'php://stdin';
- return $args;
- }
- // }}}
- // {{{ public function cli_cmd_run_stub_get
- /**
- * Cli Command Run Stub
- *
- * Get arguments and store them into a stub.
- *
- * @param arguments $args
- * @see $this->args
- */
- public function cli_cmd_run_stub_get($args)
- {
- $phar = $this->args['f']['val'];
- $stub = $this->args['s']['val'];
-
- file_put_contents($stub, $phar->getStub());
- }
- // }}}
- // {{{ public function cli_cmd_inf_compress
- /**
- * Cli Command Inf Compress
- *
- * Cli Command compress informations
- *
- * @return string A description of the command.
- */
- public function cli_cmd_inf_compress()
- {
- return "Compress or uncompress all files or a selected entry.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_cmpress
- /**
- * Cli Command Arg Compress
- *
- * @return array The arguments for compress
- */
- public function cli_cmd_arg_compress()
- {
- return self::phar_args('FCe', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_compress
- /**
- * Cli Command Run Compress
- *
- * @see $this->args
- */
- public function cli_cmd_run_compress()
- {
- $phar = $this->args['f']['val'];
- $entry = $this->args['e']['val'];
-
- switch($this->args['c']['val']) {
- case 'gz':
- case 'gzip':
- if (isset($entry)) {
- $phar[$entry]->setCompressedGZ();
- } else {
- $phar->compressAllFilesGZ();
- }
- break;
- case 'bz2':
- case 'bzip2':
- if (isset($entry)) {
- $phar[$entry]->setCompressedBZIP2();
- } else {
- $phar->compressAllFilesBZIP2();
- }
- break;
- default:
- if (isset($entry)) {
- $phar[$entry]->setUncompressed();
- } else {
- $phar->uncompressAllFiles();
- }
- break;
- }
- }
- // }}}
- // {{{ public function cli_cmd_inf_sign
- /**
- * Cli Command Info Signature
- *
- * @return string A description of the signature arguments.
- */
- public function cli_cmd_inf_sign()
- {
- return "Set signature hash algorithm.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_sign
- /**
- * Cli Command Argument Sign
- *
- * @return array Arguments for Signature
- */
- public function cli_cmd_arg_sign()
- {
- return self::phar_args('FH', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_sign
- /**
- * Cli Command Run Signature
- *
- * @see $phar->setSignaturealgorithm
- */
- public function cli_cmd_run_sign()
- {
- $phar = $this->args['f']['val'];
- $hash = $this->args['h']['val'];
-
- $phar->setSignatureAlgorithm($hash);
- }
- // }}}
- // {{{ public function cli_cmd_inf_meta_set
- /**
- * Cli Command Inf Meta Set
- *
- * @return string A description
- */
- public function cli_cmd_inf_meta_set()
- {
- return "Set meta data of a PHAR entry or a PHAR package using serialized input. " .
- "If no input file is specified for meta data then stdin is being used." .
- "You can also specify a particular index using -k. In that case the metadata is " .
- "expected to be an array and the value of the given index is being set. If " .
- "the metadata is not present or empty a new array will be created. If the " .
- "metadata is present and a flat value then the return value is 1. Also using -k " .
- "the input is been taken directly rather then being serialized.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_meta_set
- /**
- * Cli Command Argument Meta Set
- *
- * @return array The arguments for meta set
- */
- public function cli_cmd_arg_meta_set()
- {
- return self::phar_args('FekM', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_met_set
- /**
- * Cli Command Run Metaset
- *
- * @see $phar->startBuffering
- * @see $phar->setMetadata
- * @see $phar->stopBuffering
- */
- public function cli_cmd_run_meta_set()
- {
- $phar = $this->args['f']['val'];
- $entry = $this->args['e']['val'];
- $index = $this->args['k']['val'];
- $meta = $this->args['m']['val'];
-
- $phar->startBuffering();
-
- if (isset($index)) {
- if (isset($entry)) {
- if ($phar[$entry]->hasMetadata()) {
- $old = $phar[$entry]->getMetadata();
- } else {
- $old = array();
- }
- } else {
- if ($phar->hasMetadata()) {
- $old = $phar->getMetadata();
- } else {
- $old = array();
- }
- }
-
- if (!is_array($old)) {
- self::error('Metadata is a flat value while an index operation was issued.');
- }
-
- $old[$index] = $meta;
- $meta = $old;
- } else {
- $meta = unserialize($meta);
- }
-
- if (isset($entry)) {
- $phar[$entry]->setMetadata($meta);
- } else {
- $phar->setMetadata($meta);
- }
- $phar->stopBuffering();
- }
- // }}}
- // {{{ public function cli_cmd_inf_met_get
- /**
- * Cli Command Inf Metaget
- *
- * @return string A description of the metaget arguments
- */
- public function cli_cmd_inf_meta_get()
- {
- return "Get meta information of a PHAR entry or a PHAR package in serialized from. " .
- "If no output file is specified for meta data then stdout is being used.\n" .
- "You can also specify a particular index using -k. In that case the metadata is " .
- "expected to be an array and the value of the given index is returned using echo " .
- "rather than using serialize. If that index does not exist or no meta data is " .
- "present then the return value is 1.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_meta_get
- /**
- * Cli Command arg metaget
- *
- * @return array The arguments for meta get.
- */
- public function cli_cmd_arg_meta_get()
- {
- return self::phar_args('Fek', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_meta_get
- /**
- * Cli Command Run Metaget
- *
- * @see $this->args
- * @see $phar[$x]->hasMetadata()
- * @see $phar->getMetadata()
- */
- public function cli_cmd_run_meta_get()
- {
- $phar = $this->args['f']['val'];
- $entry = $this->args['e']['val'];
- $index = $this->args['k']['val'];
-
- if (isset($entry)) {
- if (!$phar[$entry]->hasMetadata()) {
- exit(1);
- }
- echo serialize($phar[$entry]->getMetadata());
- } else {
- if (!$phar->hasMetadata()) {
- exit(1);
- }
- $meta = $phar->getMetadata();
- }
-
- if (isset($index)) {
- if (isset($index)) {
- if (isset($meta[$index])) {
- echo $meta[$index];
- exit(0);
- } else {
- exit(1);
- }
- } else {
- echo serialize($meta);
- }
- }
- }
- // }}}
- // {{{ public function cli_cmd_inf_meta_del
- /**
- * Cli Command Inf Metadel
- *
- * @return string A description of the metadel function
- */
- public function cli_cmd_inf_meta_del()
- {
- return "Delete meta information of a PHAR entry or a PHAR package.\n" .
- "If -k is given then the metadata is expected to be an array " .
- "and the given index is being deleted.\n" .
- "If something was deleted the return value is 0 otherwise it is 1.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_meta_del
- /**
- * CliC ommand Arg Metadelete
- *
- * @return array The arguments for metadel
- */
- public function cli_cmd_arg_meta_del()
- {
- return self::phar_args('Fek', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_meta_del
- /**
- * Cli Command Run MetaDel
- *
- * @see $phar[$x]->delMetadata()
- * @see $phar->delMetadata()
- */
- public function cli_cmd_run_meta_del()
- {
- $phar = $this->args['f']['val'];
- $entry = $this->args['e']['val'];
- $index = $this->args['k']['val'];
-
- if (isset($entry)) {
- if (isset($index)) {
- if (!$phar[$entry]->hasMetadata()) {
- exit(1);
- }
- $meta = $phar[$entry]->getMetadata();
-
- // @todo add error message here.
- if (!is_array($meta)) {
- exit(1);
- }
-
- unset($meta[$index]);
- $phar[$entry]->setMetadata($meta);
- } else {
- exit($phar[$entry]->delMetadata() ? 0 : 1);
- }
- } else {
- if (isset($index)) {
- if (!$phar->hasMetadata()) {
- exit(1);
- }
-
- $meta = $phar->getMetadata();
-
- // @todo Add error message
- if (!is_array($meta)) {
- exit(1);
- }
-
- unset($meta[$index]);
- $phar->setMetadata($meta);
- } else {
- exit($phar->delMetadata() ? 0 : 1);
- }
- }
- }
- // }}}
- // {{{ public function cli_cmd_inf_info
- /**
- * CLi Command Inf Info
- *
- * @return string A description about the info commands.
- */
- public function cli_cmd_inf_info()
- {
- return "Get information about a PHAR package.\n" .
- "By using -k it is possible to return a single value.";
- }
- // }}}
- // {{{ public function cli_cmd_arg_info
- /**
- * Cli Command Arg Infos
- *
- * @return array The arguments for info command.
- */
- public function cli_cmd_arg_info()
- {
- return self::phar_args('Fk', 'phar');
- }
- // }}}
- // {{{ public function cli_cmd_run_info
- /**
- * Cli Command Run Info
- *
- * @param args $args
- */
- public function cli_cmd_run_info()
- {
- $phar = $this->args['f']['val'];
- $index = $this->args['k']['val'];
-
- $hash = $phar->getSignature();
- $infos = array();
-
- if ($phar->getAlias()) {
- $infos['Alias'] = $phar->getAlias();
- }
-
- if (!$hash) {
- $infos['Hash-type'] = 'NONE';
- } else {
- $infos['Hash-type'] = $hash['hash_type'];
- $infos['Hash'] = $hash['hash'];
- }
-
- $csize = 0;
- $usize = 0;
- $count = 0;
- $ccount = 0;
- $ucount = 0;
- $mcount = 0;
- $compalg = array('GZ'=>0, 'BZ2'=>0);
-
- foreach(new RecursiveIteratorIterator($phar) as $ent) {
- $count++;
- if ($ent->isCompressed()) {
- $ccount++;
- $csize += $ent->getCompressedSize();
- if ($ent->isCompressedGZ()) {
- $compalg['GZ']++;
- } elseif ($ent->isCompressedBZIP2()) {
- $compalg['BZ2']++;
- }
- } else {
- $ucount++;
- $csize += $ent->getSize();
- }
-
- $usize += $ent->getSize();
-
- if ($ent->hasMetadata()) {
- $mcount++;
- }
- }
-
- $infos['Entries'] = $count;
- $infos['Uncompressed-files'] = $ucount;
- $infos['Compressed-files'] = $ccount;
- $infos['Compressed-gz'] = $compalg['GZ'];
- $infos['Compressed-bz2'] = $compalg['BZ2'];
- $infos['Uncompressed-size'] = $usize;
- $infos['Compressed-size'] = $csize;
- $infos['Compression-ratio'] = sprintf('%.3g%%', $usize ? ($csize * 100) / $usize : 100);
- $infos['Metadata-global'] = $phar->hasMetadata() * 1;
- $infos['Metadata-files'] = $mcount;
- $infos['Stub-size'] = strlen($phar->getStub());
-
- if (isset($index)) {
- if (!isset($infos[$index])) {
- self::error("Requested value does not exist.\n");
- }
-
- echo $infos[$index];
- exit(0);
- }
-
- $l = 0;
- foreach($infos as $which => $val) {
- $l = max(strlen($which), $l);
- }
-
- foreach($infos as $which => $val) {
- echo $which . ':' . str_repeat(' ', $l + 1 - strlen($which)) . $val . "\n";
- }
- }
- // }}}
-}
-// }}}
-?>
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
deleted file mode 100755
index 33ceb3ce4e..0000000000
--- a/ext/phar/phar_internal.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2006-2007 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 "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 "main/php_streams.h"
-#include "ext/standard/info.h"
-#include "ext/standard/basic_functions.h"
-#include "ext/standard/url.h"
-#include "ext/standard/crc32.h"
-#include "ext/standard/md5.h"
-#include "ext/standard/sha1.h"
-#include "ext/standard/php_var.h"
-#include "ext/standard/php_smart_str.h"
-#if HAVE_SPL
-#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 "ext/spl/spl_iterators.h"
-#endif
-#include "php_phar.h"
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#if HAVE_HASH_EXT
-#include "ext/hash/php_hash.h"
-#include "ext/hash/php_hash_sha.h"
-#endif
-
-#ifndef E_RECOVERABLE_ERROR
-#define E_RECOVERABLE_ERROR E_ERROR
-#endif
-
-#define PHAR_EXT_VERSION_STR "1.2.1"
-#define PHAR_API_VERSION_STR "1.1.0"
-/* x.y.z maps to 0xyz0 */
-#define PHAR_API_VERSION 0x1100
-#define PHAR_API_MIN_READ 0x1000
-#define PHAR_API_MAJORVERSION 0x1000
-#define PHAR_API_MAJORVER_MASK 0xF000
-#define PHAR_API_VER_MASK 0xFFF0
-
-#define PHAR_HDR_COMPRESSION_MASK 0x0000F000
-#define PHAR_HDR_COMPRESSED_NONE 0x00000000
-#define PHAR_HDR_COMPRESSED_GZ 0x00001000
-#define PHAR_HDR_COMPRESSED_BZ2 0x00002000
-#define PHAR_HDR_SIGNATURE 0x00010000
-
-#define PHAR_SIG_MD5 0x0001
-#define PHAR_SIG_SHA1 0x0002
-#define PHAR_SIG_SHA256 0x0003
-#define PHAR_SIG_SHA512 0x0004
-#define PHAR_SIG_PGP 0x0010
-
-/* flags byte for each file adheres to these bitmasks.
- All unused values are reserved */
-#define PHAR_ENT_COMPRESSION_MASK 0x0000F000
-#define PHAR_ENT_COMPRESSED_NONE 0x00000000
-#define PHAR_ENT_COMPRESSED_GZ 0x00001000
-#define PHAR_ENT_COMPRESSED_BZ2 0x00002000
-
-#define PHAR_ENT_PERM_MASK 0x000001FF
-#define PHAR_ENT_PERM_MASK_USR 0x000001C0
-#define PHAR_ENT_PERM_SHIFT_USR 6
-#define PHAR_ENT_PERM_MASK_GRP 0x00000038
-#define PHAR_ENT_PERM_SHIFT_GRP 3
-#define PHAR_ENT_PERM_MASK_OTH 0x00000007
-#define PHAR_ENT_PERM_DEF_FILE 0x000001B6
-#define PHAR_ENT_PERM_DEF_DIR 0x000001FF
-
-ZEND_BEGIN_MODULE_GLOBALS(phar)
- HashTable phar_fname_map;
- HashTable phar_alias_map;
- HashTable phar_plain_map;
- char* extract_list;
- int readonly;
- zend_bool readonly_orig;
- zend_bool require_hash_orig;
- int request_init;
- int require_hash;
- int request_done;
- int request_ends;
-ZEND_END_MODULE_GLOBALS(phar)
-
-ZEND_EXTERN_MODULE_GLOBALS(phar)
-
-#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
-
-#ifndef php_uint16
-# if SIZEOF_SHORT == 2
-# define php_uint16 unsigned short
-# else
-# define php_uint16 uint16_t
-# endif
-#endif
-
-#if HAVE_SPL
-typedef union _phar_archive_object phar_archive_object;
-typedef union _phar_entry_object phar_entry_object;
-#endif
-
-typedef struct _phar_archive_data phar_archive_data;
-/* entry for one file in a phar file */
-typedef struct _phar_entry_info {
- /* first bytes are exactly as in file */
- php_uint32 uncompressed_filesize;
- php_uint32 timestamp;
- php_uint32 compressed_filesize;
- php_uint32 crc32;
- php_uint32 flags;
- /* remainder */
- zval *metadata;
- php_uint32 filename_len;
- char *filename;
- long offset_within_phar;
- php_stream *fp;
- php_stream *cfp;
- int fp_refcount;
- int is_crc_checked:1;
- int is_modified:1;
- int is_deleted:1;
- phar_archive_data *phar;
- smart_str metadata_str;
-} phar_entry_info;
-
-/* information about a phar file (the archive itself) */
-struct _phar_archive_data {
- char *fname;
- int fname_len;
- char *alias;
- int alias_len;
- char version[12];
- size_t internal_file_start;
- size_t halt_offset;
- HashTable manifest;
- php_uint32 flags;
- php_uint32 min_timestamp;
- php_uint32 max_timestamp;
- php_stream *fp;
- int refcount;
- php_uint32 sig_flags;
- int sig_len;
- char *signature;
- zval *metadata;
- int is_explicit_alias:1;
- int is_modified:1;
- int is_writeable:1;
- int is_brandnew:1;
- /* defer phar creation */
- int donotflush:1;
-};
-
-
-/* stream access data for one file entry in a phar file */
-typedef struct _phar_entry_data {
- phar_archive_data *phar;
- /* stream position proxy, allows multiple open streams referring to the same fp */
- php_stream *fp;
- off_t position;
- phar_entry_info *internal_file;
-} phar_entry_data;
-
-#if HAVE_SPL
-/* archive php object */
-union _phar_archive_object {
- zend_object std;
- spl_filesystem_object spl;
- struct {
- zend_object std;
- phar_archive_data *archive;
- } arc;
-};
-#endif
-
-#if HAVE_SPL
-/* entry php object */
-union _phar_entry_object {
- zend_object std;
- spl_filesystem_object spl;
- struct {
- zend_object std;
- phar_entry_info *entry;
- } ent;
-};
-#endif
-
-BEGIN_EXTERN_C()
-
-void phar_request_initialize(TSRMLS_D);
-
-void phar_object_init(TSRMLS_D);
-
-int phar_open_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_open_compiled_file(char *alias, int alias_len, char **error TSRMLS_DC);
-
-#ifdef PHAR_MAIN
-
-static int phar_open_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-
-static php_url* phar_open_url(php_stream_wrapper *wrapper, char *filename, char *mode, int options TSRMLS_DC);
-
-static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-static php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
-static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC);
-static int phar_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC);
-static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC);
-
-/* file/stream handlers */
-static size_t phar_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
-static size_t phar_stream_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
-static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC);
-static int phar_stream_flush(php_stream *stream TSRMLS_DC);
-static int phar_stream_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
-static int phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
-
-/* directory handlers */
-static size_t phar_dir_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC);
-static size_t phar_dir_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
-static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
-static int phar_dir_flush(php_stream *stream TSRMLS_DC);
-static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
-static int phar_dir_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
-
-#endif
-
-int phar_archive_delref(phar_archive_data *phar TSRMLS_DC);
-int phar_entry_delref(phar_entry_data *idata TSRMLS_DC);
-
-phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, int path_len, char **error TSRMLS_DC);
-phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, char *mode, char **error TSRMLS_DC);
-int phar_flush(phar_archive_data *archive, char *user_stub, long len, char **error TSRMLS_DC);
-int phar_detect_phar_fname_ext(const char *filename, int check_length, char **ext_str, int *ext_len);
-int phar_split_fname(char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len TSRMLS_DC);
-
-typedef enum {
- pcr_use_query,
- pcr_is_ok,
- pcr_err_double_slash,
- pcr_err_up_dir,
- pcr_err_curr_dir,
- pcr_err_back_slash,
- pcr_err_star,
- pcr_err_illegal_char,
- pcr_err_empty_entry
-} phar_path_check_result;
-
-phar_path_check_result phar_path_check(char **p, int *len, const char **error);
-
-END_EXTERN_C()
-
-/*
- * 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_object.c b/ext/phar/phar_object.c
deleted file mode 100755
index 1cf3793949..0000000000
--- a/ext/phar/phar_object.c
+++ /dev/null
@@ -1,1519 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2005-2007 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$ */
-
-#include "phar_internal.h"
-
-static zend_class_entry *phar_ce_archive;
-static zend_class_entry *phar_ce_PharException;
-
-#if HAVE_SPL
-static zend_class_entry *phar_ce_entry;
-#endif
-
-static int phar_get_extract_list(void *pDest, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
-{
- zval *return_value = va_arg(args, zval*);
-
- add_assoc_string_ex(return_value, *(char**)&hash_key->arKey, hash_key->nKeyLength, (char*)pDest, 1);
-
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
-/* {{ proto array Phar::getExtractList()
- * Return array of extract list
- */
-PHP_METHOD(Phar, getExtractList)
-{
- array_init(return_value);
-
- phar_request_initialize(TSRMLS_C);
- zend_hash_apply_with_arguments(&PHAR_G(phar_plain_map), phar_get_extract_list, 1, return_value);
-}
-/* }}} */
-
-/* {{{ proto mixed Phar::mapPhar([string alias, [int dataoffset]])
- * Reads the currently executed file (a phar) and registers its manifest */
-PHP_METHOD(Phar, mapPhar)
-{
- char *fname, *alias = NULL, *error, *plain_map;
- int fname_len, alias_len = 0;
- long dataoffset;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
- return;
- }
-
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_num_elements(&(PHAR_GLOBALS->phar_plain_map))) {
- fname = zend_get_executed_filename(TSRMLS_C);
- fname_len = strlen(fname);
- if((alias &&
- zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), alias, alias_len+1, (void **)&plain_map) == SUCCESS)
- || (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), fname, fname_len+1, (void **)&plain_map) == SUCCESS)
- ) {
- RETURN_STRING(plain_map, 1);
- }
- }
-
- RETVAL_BOOL(phar_open_compiled_file(alias, alias_len, &error TSRMLS_CC) == SUCCESS);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
-} /* }}} */
-
-/* {{{ proto mixed Phar::loadPhar(string filename [, string alias])
- * Loads any phar archive with an alias */
-PHP_METHOD(Phar, loadPhar)
-{
- char *fname, *alias = NULL, *error, *plain_map;
- 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;
- }
-
- phar_request_initialize(TSRMLS_C);
- if (zend_hash_num_elements(&(PHAR_GLOBALS->phar_plain_map))) {
- if((alias &&
- zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), alias, alias_len+1, (void **)&plain_map) == SUCCESS)
- || (zend_hash_find(&(PHAR_GLOBALS->phar_plain_map), fname, fname_len+1, (void **)&plain_map) == SUCCESS)
- ) {
- RETURN_STRING(plain_map, 1);
- }
- }
-
- RETVAL_BOOL(phar_open_filename(fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, &error TSRMLS_CC) == SUCCESS);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
-} /* }}} */
-
-/* {{{ proto string Phar::apiVersion()
- * Returns the api version */
-PHP_METHOD(Phar, apiVersion)
-{
- RETURN_STRINGL(PHAR_API_VERSION_STR, sizeof(PHAR_API_VERSION_STR)-1, 1);
-}
-/* }}}*/
-
-/* {{{ proto bool Phar::canCompress([int method])
- * Returns whether phar extension supports compression using zlib/bzip2 */
-PHP_METHOD(Phar, canCompress)
-{
- long method = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
- return;
- }
-
- switch (method) {
- case PHAR_ENT_COMPRESSED_GZ:
-#if HAVE_ZLIB
- RETURN_TRUE;
-#else
- RETURN_FALSE;
-#endif
-
- case PHAR_ENT_COMPRESSED_BZ2:
-#if HAVE_BZ2
- RETURN_TRUE;
-#else
- RETURN_FALSE;
-#endif
-
- default:
-#if HAVE_ZLIB || HAVE_BZ2
- RETURN_TRUE;
-#else
- RETURN_FALSE;
-#endif
- }
-}
-/* }}} */
-
-/* {{{ proto bool Phar::canWrite()
- * Returns whether phar extension supports writing and creating phars */
-PHP_METHOD(Phar, canWrite)
-{
- RETURN_BOOL(!PHAR_G(readonly));
-}
-/* }}} */
-
-/* {{{ proto bool Phar::isValidPharFilename(string filename)
- * Returns whether the given filename is a vaild phar filename */
-PHP_METHOD(Phar, isValidPharFilename)
-{
- char *fname, *ext_str;
- int fname_len, ext_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &fname, &fname_len) == FAILURE) {
- return;
- }
-
- RETURN_BOOL(phar_detect_phar_fname_ext(fname, 1, &ext_str, &ext_len) == SUCCESS);
-}
-/* }}} */
-
-#if HAVE_SPL
-/**
- * from spl_directory
- */
-static void phar_spl_foreign_dtor(spl_filesystem_object *object TSRMLS_DC) /* {{{ */
-{
- phar_archive_delref((phar_archive_data *) object->oth TSRMLS_CC);
- object->oth = NULL;
-}
-/* }}} */
-
-/**
- * from spl_directory
- */
-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
-};
-#endif /* HAVE_SPL */
-
-/* {{{ proto void Phar::__construct(string fname [, int flags [, string alias]])
- * Construct a Phar archive object
- */
-PHP_METHOD(Phar, __construct)
-{
-#if !HAVE_SPL
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Cannot instantiate Phar object without SPL extension");
-#else
- char *fname, *alias = NULL, *error;
- 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_or_create_filename(fname, fname_len, alias, alias_len, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) {
- if (error) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot open phar file '%s' with alias '%s': %s", fname, alias, error);
- efree(error);
- } else {
- 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);
-#endif /* HAVE_SPL */
-}
-/* }}} */
-
-#if HAVE_SPL
-
-#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 uninitialized 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 int Phar::getAlias()
- * Returns the alias for the PHAR or NULL
- */
-PHP_METHOD(Phar, getAlias)
-{
- PHAR_ARCHIVE_OBJECT();
-
- if (phar_obj->arc.archive->alias && phar_obj->arc.archive->alias != phar_obj->arc.archive->fname) {
- RETURN_STRINGL(phar_obj->arc.archive->alias, phar_obj->arc.archive->alias_len, 1);
- }
-}
-/* }}} */
-
-/* {{{ 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 void Phar::startBuffering()
- * Do not flush a writeable phar (save its contents) until explicitly requested
- */
-PHP_METHOD(Phar, startBuffering)
-{
- PHAR_ARCHIVE_OBJECT();
-
- phar_obj->arc.archive->donotflush = 1;
-}
-/* }}} */
-
-/* {{{ proto bool Phar::isBuffering()
- * Returns whether write operations are flushing to disk immediately
- */
-PHP_METHOD(Phar, isBuffering)
-{
- PHAR_ARCHIVE_OBJECT();
-
- RETURN_BOOL(!phar_obj->arc.archive->donotflush);
-}
-/* }}} */
-
-/* {{{ proto bool Phar::stopBuffering()
- * Save the contents of a modified phar
- */
-PHP_METHOD(Phar, stopBuffering)
-{
- char *error;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot write out phar archive, phar is read-only");
- }
-
- phar_obj->arc.archive->donotflush = 0;
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
-}
-/* }}} */
-
-/* {{{ proto bool Phar::setStub(string|stream stub [, int len])
- * Change the stub of the archive
- */
-PHP_METHOD(Phar, setStub)
-{
- zval *zstub;
- char *stub, *error;
- int stub_len;
- long len = -1;
- php_stream *stream;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot change stub, phar is read-only");
- }
-
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zstub, &len) == SUCCESS) {
- if ((php_stream_from_zval_no_verify(stream, &zstub)) != NULL) {
- if (len > 0) {
- len = -len;
- } else {
- len = -1;
- }
- phar_flush(phar_obj->arc.archive, (char *) &zstub, len, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- RETURN_TRUE;
- } else {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot change stub, unable to read from input stream");
- }
- } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &stub, &stub_len) == SUCCESS) {
- phar_flush(phar_obj->arc.archive, stub, stub_len, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- RETURN_TRUE;
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array Phar::setSignatureAlgorithm(int sigtype)
- * set the signature algorithm for a phar and apply it. The
- * signature algorithm must be one of Phar::MD5, Phar::SHA1,
- * Phar::SHA256, Phar::SHA512, or Phar::PGP (pgp not yet supported and
- * falls back to SHA-1)
- */
-PHP_METHOD(Phar, setSignatureAlgorithm)
-{
- long algo;
- char *error;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot change stub, phar is read-only");
- }
-
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l", &algo) != SUCCESS) {
- return;
- }
-
- switch (algo) {
- case PHAR_SIG_SHA256 :
- case PHAR_SIG_SHA512 :
-#if !HAVE_HASH_EXT
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled");
-#endif
- case PHAR_SIG_MD5 :
- case PHAR_SIG_SHA1 :
- case PHAR_SIG_PGP :
- phar_obj->arc.archive->sig_flags = algo;
- phar_obj->arc.archive->is_modified = 1;
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
- efree(error);
- }
- break;
- default :
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Unknown signature algorithm specified");
- }
-}
-/* }}} */
-
-/* {{{ proto array Phar::getSupportedSignatures()
- * Return array of supported signature types
- */
-PHP_METHOD(Phar, getSupportedSignatures)
-{
- array_init(return_value);
-
- add_next_index_stringl(return_value, "MD5", 3, 1);
- add_next_index_stringl(return_value, "SHA-1", 5, 1);
-#if HAVE_HASH_EXT
- add_next_index_stringl(return_value, "SHA-256", 7, 1);
- add_next_index_stringl(return_value, "SHA-512", 7, 1);
-#endif
-}
-/* }}} */
-
-/* {{{ proto array Phar::getSupportedCompression()
- * Return array of supported comparession algorithms
- */
-PHP_METHOD(Phar, getSupportedCompression)
-{
- array_init(return_value);
-
-#if !HAVE_ZLIB
- add_next_index_stringl(return_value, "GZ", 2, 1);
-#endif
-#if !HAVE_BZ2
- add_next_index_stringl(return_value, "BZIP2", 5, 1);
-#endif
-}
-/* }}} */
-
-/* {{{ proto array|false Phar::getSignature()
- * Return signature or false
- */
-PHP_METHOD(Phar, getSignature)
-{
- PHAR_ARCHIVE_OBJECT();
-
- if (phar_obj->arc.archive->signature) {
- array_init(return_value);
- add_assoc_stringl(return_value, "hash", phar_obj->arc.archive->signature, phar_obj->arc.archive->sig_len, 1);
- switch(phar_obj->arc.archive->sig_flags) {
- case PHAR_SIG_MD5:
- add_assoc_stringl(return_value, "hash_type", "MD5", 3, 1);
- break;
- case PHAR_SIG_SHA1:
- add_assoc_stringl(return_value, "hash_type", "SHA-1", 5, 1);
- break;
- case PHAR_SIG_SHA256:
- add_assoc_stringl(return_value, "hash_type", "SHA-256", 7, 1);
- break;
- case PHAR_SIG_SHA512:
- add_assoc_stringl(return_value, "hash_type", "SHA-512", 7, 1);
- break;
- }
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto bool Phar::getModified()
- * Return whether phar was modified
- */
-PHP_METHOD(Phar, getModified)
-{
- PHAR_ARCHIVE_OBJECT();
-
- RETURN_BOOL(phar_obj->arc.archive->is_modified);
-}
-/* }}} */
-
-static int phar_set_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
-{
- phar_entry_info *entry = (phar_entry_info *)pDest;
- php_uint32 compress = *(php_uint32 *)argument;
-
- if (entry->is_deleted) {
- return ZEND_HASH_APPLY_KEEP;
- }
- entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry->flags |= compress;
- entry->is_modified = 1;
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
-static int phar_test_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ */
-{
- phar_entry_info *entry = (phar_entry_info *)pDest;
-
- if (entry->is_deleted) {
- return ZEND_HASH_APPLY_KEEP;
- }
-#if !HAVE_BZ2
- if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
- *(int *) argument = 0;
- }
-#endif
-#if !HAVE_ZLIB
- if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
- *(int *) argument = 0;
- }
-#endif
- return ZEND_HASH_APPLY_KEEP;
-}
-/* }}} */
-
-static void pharobj_set_compression(HashTable *manifest, php_uint32 compress TSRMLS_DC) /* {{{ */
-{
- zend_hash_apply_with_argument(manifest, phar_set_compression, &compress TSRMLS_CC);
-}
-/* }}} */
-
-static int pharobj_cancompress(HashTable *manifest TSRMLS_DC) /* {{{ */
-{
- int test;
- test = 1;
- zend_hash_apply_with_argument(manifest, phar_test_compression, &test TSRMLS_CC);
- return test;
-}
-/* }}} */
-
-/* {{{ proto bool Phar::compressAllFilesGZ()
- * compress every file with GZip compression
- */
-PHP_METHOD(Phar, compressAllFilesGZ)
-{
-#if HAVE_ZLIB
- char *error;
-#endif
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar is readonly, cannot change compression");
- }
-#if HAVE_ZLIB
- if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress all files as Gzip, some are compressed as bzip2 and cannot be uncompressed");
- }
- pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_GZ TSRMLS_CC);
- phar_obj->arc.archive->is_modified = 1;
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
- efree(error);
- }
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Gzip compression, zlib extension is not enabled");
-#endif
-}
-/* }}} */
-
-/* {{{ proto bool Phar::compressAllFilesBZIP2()
- * compress every file with BZip2 compression
- */
-PHP_METHOD(Phar, compressAllFilesBZIP2)
-{
-#if HAVE_BZ2
- char *error;
-#endif
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar is readonly, cannot change compression");
- }
-#if HAVE_BZ2
- if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress all files as Bzip2, some are compressed as gzip and cannot be uncompressed");
- }
- pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_BZ2 TSRMLS_CC);
- phar_obj->arc.archive->is_modified = 1;
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
- efree(error);
- }
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Bzip2 compression, bz2 extension is not enabled");
-#endif
-}
-/* }}} */
-
-/* {{{ proto bool Phar::uncompressAllFiles()
- * uncompress every file
- */
-PHP_METHOD(Phar, uncompressAllFiles)
-{
- char *error;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar is readonly, cannot change compression");
- }
- if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot uncompress all files, some are compressed as bzip2 or gzip and cannot be uncompressed");
- }
- pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE TSRMLS_CC);
- phar_obj->arc.archive->is_modified = 1;
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error);
- efree(error);
- }
-}
-/* }}} */
-
-/* {{{ proto int Phar::offsetExists(string offset)
- * determines whether a file exists in the phar
- */
-PHP_METHOD(Phar, offsetExists)
-{
- char *fname;
- int fname_len;
- phar_entry_info *entry;
- 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)) {
- if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
- if (entry->is_deleted) {
- /* entry is deleted, but has not been flushed to disk yet */
- RETURN_FALSE;
- }
- }
- 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, *error;
- 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, &error TSRMLS_CC)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist%s%s", fname, error?", ":"", error?error:"");
- } 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.info_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)
-{
- char *fname, *cont_str = NULL, *error;
- int fname_len, cont_len;
- zval *zresource;
- long contents_len;
- phar_entry_data *data;
- php_stream *contents_file;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by INI setting");
- return;
- }
-
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sr", &fname, &fname_len, &zresource) == FAILURE
- && zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
- return;
- }
-
- if (!(data = phar_get_or_create_entry_data(phar_obj->arc.archive->fname, phar_obj->arc.archive->fname_len, fname, fname_len, "w+b", &error TSRMLS_CC))) {
- if (error) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be created: %s", fname, error);
- efree(error);
- } else {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s does not exist and cannot be created", fname);
- }
- } else {
- if (error) {
- efree(error);
- }
- if (cont_str) {
- contents_len = php_stream_write(data->fp, cont_str, cont_len);
- if (contents_len != cont_len) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", fname);
- }
- } else {
- if (!(php_stream_from_zval_no_verify(contents_file, &zresource))) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Entry %s could not be written to", fname);
- }
- contents_len = php_stream_copy_to_stream(contents_file, data->fp, PHP_STREAM_COPY_ALL);
- }
- data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize = contents_len;
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- phar_entry_delref(data TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- }
-}
-/* }}} */
-
-/* {{{ proto int Phar::offsetUnset()
- * remove a file from a phar
- */
-PHP_METHOD(Phar, offsetUnset)
-{
- char *fname, *error;
- int fname_len;
- phar_entry_info *entry;
- PHAR_ARCHIVE_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Write operations disabled by INI setting");
- return;
- }
-
- 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)) {
- if (SUCCESS == zend_hash_find(&phar_obj->arc.archive->manifest, fname, (uint) fname_len, (void**)&entry)) {
- if (entry->is_deleted) {
- /* entry is deleted, but has not been flushed to disk yet */
- return;
- }
- entry->is_modified = 0;
- entry->is_deleted = 1;
- /* we need to "flush" the stream to save the newly deleted file on disk */
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- RETURN_TRUE;
- }
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto string Phar::getStub()
- * Get the pre-phar stub
- */
-PHP_METHOD(Phar, getStub)
-{
- char *buf;
- size_t len;
- php_stream *fp;
- PHAR_ARCHIVE_OBJECT();
-
- len = phar_obj->arc.archive->halt_offset;
-
- if (phar_obj->arc.archive->fp && !phar_obj->arc.archive->is_brandnew) {
- fp = phar_obj->arc.archive->fp;
- } else {
- fp = php_stream_open_wrapper(phar_obj->arc.archive->fname, "rb", 0, NULL);
- }
-
- if (!fp) {
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
- "Unable to read stub");
- return;
- }
-
- buf = safe_emalloc(len, 1, 1);
- php_stream_rewind(fp);
- if (len != php_stream_read(fp, buf, len)) {
- if (fp != phar_obj->arc.archive->fp) {
- php_stream_close(fp);
- }
- zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC,
- "Unable to read stub");
- efree(buf);
- return;
- }
- if (fp != phar_obj->arc.archive->fp) {
- php_stream_close(fp);
- }
- buf[len] = '\0';
-
- RETURN_STRINGL(buf, len, 0);
-}
-/* }}}*/
-
-/* {{{ proto int Phar::hasMetaData()
- * Returns whether phar has global metadata
- */
-PHP_METHOD(Phar, hasMetadata)
-{
- PHAR_ARCHIVE_OBJECT();
-
- RETURN_BOOL(phar_obj->arc.archive->metadata != NULL);
-}
-/* }}} */
-
-/* {{{ proto int Phar::getMetaData()
- * Returns the global metadata of the phar
- */
-PHP_METHOD(Phar, getMetadata)
-{
- PHAR_ARCHIVE_OBJECT();
-
- if (phar_obj->arc.archive->metadata) {
- RETURN_ZVAL(phar_obj->arc.archive->metadata, 1, 0);
- }
-}
-/* }}} */
-
-/* {{{ proto int Phar::setMetaData(mixed $metadata)
- * Sets the global metadata of the phar
- */
-PHP_METHOD(Phar, setMetadata)
-{
- char *error;
- zval *metadata;
- PHAR_ARCHIVE_OBJECT();
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &metadata) == FAILURE) {
- return;
- }
-
- if (phar_obj->arc.archive->metadata) {
- zval_ptr_dtor(&phar_obj->arc.archive->metadata);
- phar_obj->arc.archive->metadata = NULL;
- }
-
- MAKE_STD_ZVAL(phar_obj->arc.archive->metadata);
- ZVAL_ZVAL(phar_obj->arc.archive->metadata, metadata, 1, 0);
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
-}
-/* }}} */
-
-/* {{{ proto int Phar::delMetaData()
- * Deletes the global metadata of the phar
- */
-PHP_METHOD(Phar, delMetadata)
-{
- char *error;
- PHAR_ARCHIVE_OBJECT();
-
- if (phar_obj->arc.archive->metadata) {
- zval_ptr_dtor(&phar_obj->arc.archive->metadata);
- phar_obj->arc.archive->metadata = NULL;
-
- phar_flush(phar_obj->arc.archive, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto void PharFileInfo::__construct(string entry)
- * Construct a Phar entry object
- */
-PHP_METHOD(PharFileInfo, __construct)
-{
- char *fname, *arch, *entry, *error;
- 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) {
- efree(arch);
- efree(entry);
- 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, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) {
- efree(arch);
- efree(entry);
- if (error) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot open phar file '%s': %s", fname, error);
- efree(error);
- } else {
- 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, &error TSRMLS_CC)) == NULL) {
- efree(arch);
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
- "Cannot access phar file entry '%s' in archive '%s'%s%s", entry, arch, error?", ":"", error?error:"");
- efree(entry);
- return;
- }
-
- efree(arch);
- efree(entry);
-
- 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 uninitialized 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 bool PharFileInfo::isCompressed()
- * Returns whether the entry is compressed
- */
-PHP_METHOD(PharFileInfo, isCompressed)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK);
-}
-/* }}} */
-
-/* {{{ proto bool PharFileInfo::isCompressedGZ()
- * Returns whether the entry is compressed using gz
- */
-PHP_METHOD(PharFileInfo, isCompressedGZ)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ);
-}
-/* }}} */
-
-/* {{{ proto bool PharFileInfo::isCompressedBZIP2()
- * Returns whether the entry is compressed using bzip2
- */
-PHP_METHOD(PharFileInfo, isCompressedBZIP2)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_BOOL(entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2);
-}
-/* }}} */
-
-/* {{{ 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->is_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::isCRCChecked()
- * Returns whether file entry is CRC checked
- */
-PHP_METHOD(PharFileInfo, isCRCChecked)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_BOOL(entry_obj->ent.entry->is_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 & ~(PHAR_ENT_PERM_MASK|PHAR_ENT_COMPRESSION_MASK));
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::chmod()
- * set the file permissions for the Phar. This only allows setting execution bit, read/write
- */
-PHP_METHOD(PharFileInfo, chmod)
-{
- char *error;
- long perms;
- PHAR_ENTRY_OBJECT();
-
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Cannot modify permissions for file \"%s\" write operations are prohibited", entry_obj->ent.entry->filename, entry_obj->ent.entry->phar->fname);
- }
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perms) == FAILURE) {
- return;
- }
- /* clear permissions */
- entry_obj->ent.entry->flags &= ~PHAR_ENT_PERM_MASK;
- perms &= 0777;
- entry_obj->ent.entry->flags |= perms;
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
- /* hackish cache in php_stat needs to be cleared */
- /* if this code fails to work, check main/streams/streams.c, _php_stream_stat_path */
- if (BG(CurrentLStatFile)) {
- efree(BG(CurrentLStatFile));
- }
- if (BG(CurrentStatFile)) {
- efree(BG(CurrentStatFile));
- }
- BG(CurrentLStatFile) = NULL;
- BG(CurrentStatFile) = NULL;
-
- phar_flush(entry_obj->ent.entry->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::hasMetaData()
- * Returns the metadata of the entry
- */
-PHP_METHOD(PharFileInfo, hasMetadata)
-{
- PHAR_ENTRY_OBJECT();
-
- RETURN_BOOL(entry_obj->ent.entry->metadata != NULL);
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::getMetaData()
- * Returns the metadata of the entry
- */
-PHP_METHOD(PharFileInfo, getMetadata)
-{
- PHAR_ENTRY_OBJECT();
-
- if (entry_obj->ent.entry->metadata) {
- RETURN_ZVAL(entry_obj->ent.entry->metadata, 1, 0);
- }
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::setMetaData(mixed $metadata)
- * Sets the metadata of the entry
- */
-PHP_METHOD(PharFileInfo, setMetadata)
-{
- char *error;
- zval *metadata;
- PHAR_ENTRY_OBJECT();
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &metadata) == FAILURE) {
- return;
- }
-
- if (entry_obj->ent.entry->metadata) {
- zval_ptr_dtor(&entry_obj->ent.entry->metadata);
- entry_obj->ent.entry->metadata = NULL;
- }
-
- MAKE_STD_ZVAL(entry_obj->ent.entry->metadata);
- ZVAL_ZVAL(entry_obj->ent.entry->metadata, metadata, 1, 0);
-
- phar_flush(entry_obj->ent.entry->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
-}
-/* }}} */
-
-/* {{{ proto bool PharFileInfo::delMetaData()
- * Deletes the metadata of the entry
- */
-PHP_METHOD(PharFileInfo, delMetadata)
-{
- char *error;
- PHAR_ENTRY_OBJECT();
-
- if (entry_obj->ent.entry->metadata) {
- zval_ptr_dtor(&entry_obj->ent.entry->metadata);
- entry_obj->ent.entry->metadata = NULL;
-
- phar_flush(entry_obj->ent.entry->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::setCompressedGZ()
- * Instructs the Phar class to compress the current file using zlib
- */
-PHP_METHOD(PharFileInfo, setCompressedGZ)
-{
-#if HAVE_ZLIB
- char *error;
- PHAR_ENTRY_OBJECT();
-
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) {
- RETURN_TRUE;
- return;
- }
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar is readonly, cannot change compression");
- }
- if (entry_obj->ent.entry->is_deleted) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress deleted file");
- }
- entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry_obj->ent.entry->flags |= PHAR_ENT_COMPRESSED_GZ;
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
-
- phar_flush(entry_obj->ent.entry->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- RETURN_TRUE;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Gzip compression, zlib extension is not enabled");
-#endif
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::setCompressedBZIP2()
- * Instructs the Phar class to compress the current file using bzip2
- */
-PHP_METHOD(PharFileInfo, setCompressedBZIP2)
-{
-#if HAVE_BZ2
- char *error;
- PHAR_ENTRY_OBJECT();
-
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
- RETURN_TRUE;
- return;
- }
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar is readonly, cannot change compression");
- }
- if (entry_obj->ent.entry->is_deleted) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress deleted file");
- }
- entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry_obj->ent.entry->flags |= PHAR_ENT_COMPRESSED_BZ2;
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
-
- phar_flush(entry_obj->ent.entry->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- RETURN_TRUE;
-#else
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress with Bzip2 compression, bzip2 extension is not enabled");
-#endif
-}
-/* }}} */
-
-/* {{{ proto int PharFileInfo::setUncompressed()
- * Instructs the Phar class to uncompress the current file
- */
-PHP_METHOD(PharFileInfo, setUncompressed)
-{
- char *fname, *error;
- int fname_len;
- PHAR_ENTRY_OBJECT();
-
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSION_MASK) == 0) {
- RETURN_TRUE;
- return;
- }
- if (PHAR_G(readonly)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Phar is readonly, cannot change compression");
- }
- if (entry_obj->ent.entry->is_deleted) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot compress deleted file");
- }
-#if !HAVE_ZLIB
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot uncompress Gzip-compressed file, zlib extension is not enabled");
- }
-#endif
-#if !HAVE_BZ2
- if (entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
- "Cannot uncompress Bzip2-compressed file, bzip2 extension is not enabled");
- }
-#endif
- if (!entry_obj->ent.entry->fp) {
- fname_len = spprintf(&fname, 0, "phar://%s/%s", entry_obj->ent.entry->phar->fname, entry_obj->ent.entry->filename);
- entry_obj->ent.entry->fp = php_stream_open_wrapper_ex(fname, "rb", 0, 0, 0);
- efree(fname);
- }
- entry_obj->ent.entry->flags &= ~PHAR_ENT_COMPRESSION_MASK;
- entry_obj->ent.entry->phar->is_modified = 1;
- entry_obj->ent.entry->is_modified = 1;
-
- phar_flush(entry_obj->ent.entry->phar, 0, 0, &error TSRMLS_CC);
- if (error) {
- zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, error);
- efree(error);
- }
- RETURN_TRUE;
-}
-/* }}} */
-
-#endif /* HAVE_SPL */
-
-/* {{{ phar methods */
-
-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_setStub, 0, 0, 1)
- ZEND_ARG_INFO(0, newstub)
- ZEND_ARG_INFO(0, maxlen)
-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();
-
-#if HAVE_SPL
-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();
-#endif
-
-static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_entry_setMetadata, 0, 0, 1)
- ZEND_ARG_INFO(0, metadata)
-ZEND_END_ARG_INFO();
-
-zend_function_entry php_archive_methods[] = {
-#if !HAVE_SPL
- PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PRIVATE)
-#else
- PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, startBuffering, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, stopBuffering, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, compressAllFilesGZ, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, compressAllFilesBZIP2, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, count, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, delMetadata, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, getAlias, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, getMetadata, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, getModified, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, getSignature, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, getStub, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, getVersion, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, isBuffering, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, hasMetadata, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, setMetadata, arginfo_entry_setMetadata, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, setSignatureAlgorithm, arginfo_entry_setMetadata, ZEND_ACC_PUBLIC)
- PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
- 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, uncompressAllFiles, NULL, ZEND_ACC_PUBLIC)
-#endif
- /* 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, canWrite, NULL, 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)
- PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, getExtractList, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, getSupportedSignatures,NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, getSupportedCompression,NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- PHP_ME(Phar, isValidPharFilename, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
- {NULL, NULL, NULL}
-};
-
-#if HAVE_SPL
-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, isCompressed, NULL, 0)
- PHP_ME(PharFileInfo, isCompressedGZ, NULL, 0)
- PHP_ME(PharFileInfo, isCompressedBZIP2, NULL, 0)
- PHP_ME(PharFileInfo, setUncompressed, NULL, 0)
- PHP_ME(PharFileInfo, setCompressedGZ, NULL, 0)
- PHP_ME(PharFileInfo, setCompressedBZIP2, NULL, 0)
- PHP_ME(PharFileInfo, getCRC32, NULL, 0)
- PHP_ME(PharFileInfo, isCRCChecked, NULL, 0)
- PHP_ME(PharFileInfo, getPharFlags, NULL, 0)
- PHP_ME(PharFileInfo, hasMetadata, NULL, 0)
- PHP_ME(PharFileInfo, getMetadata, NULL, 0)
- PHP_ME(PharFileInfo, setMetadata, arginfo_entry_setMetadata, 0)
- PHP_ME(PharFileInfo, delMetadata, NULL, 0)
- PHP_ME(PharFileInfo, chmod, arginfo_entry_setMetadata, 0)
- {NULL, NULL, NULL}
-};
-#endif
-
-zend_function_entry phar_exception_methods[] = {
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-#define REGISTER_PHAR_CLASS_CONST_LONG(class_name, const_name, value) \
- zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
-
-#if PHP_VERSION_ID < 50200
-# define phar_exception_get_default() zend_exception_get_default()
-#else
-# define phar_exception_get_default() zend_exception_get_default(TSRMLS_C)
-#endif
-
-void phar_object_init(TSRMLS_D) /* {{{ */
-{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods);
- phar_ce_PharException = zend_register_internal_class_ex(&ce, phar_exception_get_default(), NULL TSRMLS_CC);
-
-#if HAVE_SPL
- 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);
-#else
- INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
- phar_ce_archive = zend_register_internal_class(&ce TSRMLS_CC);
- phar_ce_archive->ce_flags |= ZEND_ACC_FINAL_CLASS;
-#endif
-
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "COMPRESSED", PHAR_ENT_COMPRESSION_MASK)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "GZ", PHAR_ENT_COMPRESSED_GZ)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "MD5", PHAR_SIG_MD5)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA1", PHAR_SIG_SHA1)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA256", PHAR_SIG_SHA256)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "SHA512", PHAR_SIG_SHA512)
- REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "PGP", PHAR_SIG_PGP)
-}
-/* }}} */
-
-/*
- * 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_path_check.c b/ext/phar/phar_path_check.c
deleted file mode 100755
index 2d436a5702..0000000000
--- a/ext/phar/phar_path_check.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* Generated by re2c 0.10.5 on Thu Feb 8 23:49:41 2007 */
-#line 1 "ext/phar/phar_path_check.re"
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2007 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: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "phar_internal.h"
-
-phar_path_check_result phar_path_check(char **s, int *len, const char **error)
-{
- const unsigned char *p = (const unsigned char*)*s;
- const unsigned char *m;
-
- if (*len == 1 && *p == '.') {
- *error = "current directory reference";
- return pcr_err_curr_dir;
- } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
- *error = "upper directory reference";
- return pcr_err_up_dir;
- }
-
-#define YYCTYPE unsigned char
-#define YYCURSOR p
-#define YYLIMIT p+*len
-#define YYMARKER m
-#define YYFILL(n)
-
-loop:
-{
-
-#line 48 "ext/phar/phar_path_check.c"
- {
- YYCTYPE yych;
-
- if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
- yych = *YYCURSOR;
- if(yych <= '.') {
- if(yych <= 0x0A) {
- if(yych <= 0x00) goto yy13;
- if(yych <= 0x09) goto yy10;
- goto yy12;
- } else {
- if(yych <= 0x19) goto yy10;
- if(yych == '*') goto yy6;
- goto yy15;
- }
- } else {
- if(yych <= '?') {
- if(yych <= '/') goto yy2;
- if(yych <= '>') goto yy15;
- goto yy8;
- } else {
- if(yych == '\\') goto yy4;
- if(yych <= 0x7F) goto yy15;
- goto yy10;
- }
- }
-yy2:
- yych = *(YYMARKER = ++YYCURSOR);
- if(yych <= 0x00) goto yy16;
- if(yych <= '-') goto yy3;
- if(yych <= '.') goto yy18;
- if(yych <= '/') goto yy20;
-yy3:
-#line 97 "ext/phar/phar_path_check.re"
- {
- goto loop;
- }
-#line 86 "ext/phar/phar_path_check.c"
-yy4:
- ++YYCURSOR;
-#line 60 "ext/phar/phar_path_check.re"
- {
- *error = "back-slash";
- return pcr_err_back_slash;
- }
-#line 94 "ext/phar/phar_path_check.c"
-yy6:
- ++YYCURSOR;
-#line 68 "ext/phar/phar_path_check.re"
- {
- *error = "star";
- return pcr_err_star;
- }
-#line 102 "ext/phar/phar_path_check.c"
-yy8:
- ++YYCURSOR;
-#line 72 "ext/phar/phar_path_check.re"
- {
- if (**s == '/') {
- (*s)++;
- }
- *len = (p - (const unsigned char*)*s) -1;
- *error = NULL;
- return pcr_use_query;
- }
-#line 114 "ext/phar/phar_path_check.c"
-yy10:
- ++YYCURSOR;
-yy11:
-#line 80 "ext/phar/phar_path_check.re"
- {
- *error ="illegal character";
- return pcr_err_illegal_char;
- }
-#line 123 "ext/phar/phar_path_check.c"
-yy12:
- yych = *++YYCURSOR;
- goto yy11;
-yy13:
- ++YYCURSOR;
-#line 84 "ext/phar/phar_path_check.re"
- {
- if (**s == '/') {
- (*s)++;
- (*len)--;
- }
- if ((p - (const unsigned char*)*s) - 1 != *len)
- {
- *error ="illegal character";
- return pcr_err_illegal_char;
- }
- *error = NULL;
- return pcr_is_ok;
- }
-#line 143 "ext/phar/phar_path_check.c"
-yy15:
- yych = *++YYCURSOR;
- goto yy3;
-yy16:
- ++YYCURSOR;
-#line 64 "ext/phar/phar_path_check.re"
- {
- *error = "empty directory";
- return pcr_err_empty_entry;
- }
-#line 154 "ext/phar/phar_path_check.c"
-yy18:
- yych = *++YYCURSOR;
- if(yych <= 0x00) goto yy23;
- if(yych <= '-') goto yy19;
- if(yych <= '.') goto yy22;
- if(yych <= '/') goto yy23;
-yy19:
- YYCURSOR = YYMARKER;
- goto yy3;
-yy20:
- ++YYCURSOR;
-#line 48 "ext/phar/phar_path_check.re"
- {
- *error = "double slash";
- return pcr_err_double_slash;
- }
-#line 171 "ext/phar/phar_path_check.c"
-yy22:
- yych = *++YYCURSOR;
- if(yych <= 0x00) goto yy25;
- if(yych == '/') goto yy25;
- goto yy19;
-yy23:
- ++YYCURSOR;
-#line 56 "ext/phar/phar_path_check.re"
- {
- *error = "current directory reference";
- return pcr_err_curr_dir;
- }
-#line 184 "ext/phar/phar_path_check.c"
-yy25:
- ++YYCURSOR;
-#line 52 "ext/phar/phar_path_check.re"
- {
- *error = "upper directory reference";
- return pcr_err_up_dir;
- }
-#line 192 "ext/phar/phar_path_check.c"
- }
-}
-#line 100 "ext/phar/phar_path_check.re"
-
-}
diff --git a/ext/phar/phar_path_check.re b/ext/phar/phar_path_check.re
deleted file mode 100755
index 6702cdd68d..0000000000
--- a/ext/phar/phar_path_check.re
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | phar php single-file executable PHP extension |
- +----------------------------------------------------------------------+
- | Copyright (c) 2007 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: Marcus Boerger <helly@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "phar_internal.h"
-
-phar_path_check_result phar_path_check(char **s, int *len, const char **error)
-{
- const unsigned char *p = (const unsigned char*)*s;
- const unsigned char *m;
-
- if (*len == 1 && *p == '.') {
- *error = "current directory reference";
- return pcr_err_curr_dir;
- } else if (*len == 2 && p[0] == '.' && p[1] == '.') {
- *error = "upper directory reference";
- return pcr_err_up_dir;
- }
-
-#define YYCTYPE unsigned char
-#define YYCURSOR p
-#define YYLIMIT p+*len
-#define YYMARKER m
-#define YYFILL(n)
-
-loop:
-/*!re2c
-END = "\x00";
-ILL = [\x01-\x19\x80-\xFF];
-EOS = "/" | END;
-ANY = .;
-"//" {
- *error = "double slash";
- return pcr_err_double_slash;
- }
-"/.." EOS {
- *error = "upper directory reference";
- return pcr_err_up_dir;
- }
-"/." EOS {
- *error = "current directory reference";
- return pcr_err_curr_dir;
- }
-"\\" {
- *error = "back-slash";
- return pcr_err_back_slash;
- }
-"/" END {
- *error = "empty directory";
- return pcr_err_empty_entry;
- }
-"*" {
- *error = "star";
- return pcr_err_star;
- }
-"?" {
- if (**s == '/') {
- (*s)++;
- }
- *len = (p - (const unsigned char*)*s) -1;
- *error = NULL;
- return pcr_use_query;
- }
-ILL {
- *error ="illegal character";
- return pcr_err_illegal_char;
- }
-END {
- if (**s == '/') {
- (*s)++;
- (*len)--;
- }
- if ((p - (const unsigned char*)*s) - 1 != *len)
- {
- *error ="illegal character";
- return pcr_err_illegal_char;
- }
- *error = NULL;
- return pcr_is_ok;
- }
-ANY {
- goto loop;
- }
-*/
-}
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
deleted file mode 100644
index f99780fd8c..0000000000
--- a/ext/phar/php_phar.h
+++ /dev/null
@@ -1,45 +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
-
-#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 397501e8e4..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) "1.1.0"
-===DONE===
diff --git a/ext/phar/tests/002.phpt b/ext/phar/tests/002.phpt
deleted file mode 100644
index 5a7b4289ea..0000000000
--- a/ext/phar/tests/002.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest/improper params
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-try {
-Phar::mapPhar(5, 'hio', 'hi');
-
-Phar::mapPhar();
-} catch (Exception $e) {
- echo $e->getMessage();
-}
-__HALT_COMPILER(); ?>
---EXPECTF--
-Warning: Phar::mapPhar() expects at most 2 parameters, 3 given in %s002.php on line %d
-internal corruption of phar "%s002.php" (truncated manifest at manifest length) \ No newline at end of file
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/003a.phpt b/ext/phar/tests/003a.phpt
deleted file mode 100755
index a439cbb8dc..0000000000
--- a/ext/phar/tests/003a.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Phar::canCompress, specific
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---FILE--
-<?php
-var_dump(Phar::canCompress(Phar::GZ) == extension_loaded("zlib"));
-var_dump(Phar::canCompress(Phar::BZ2) == extension_loaded("bz2"));
-?>
-===DONE===
---EXPECT--
-bool(true)
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/004.phpt b/ext/phar/tests/004.phpt
deleted file mode 100644
index 17190a9ec2..0000000000
--- a/ext/phar/tests/004.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Phar::mapPhar no __HALT_COMPILER();
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-try {
-Phar::mapPhar('hio');
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
---EXPECTF--
-__HALT_COMPILER(); must be declared in a phar
diff --git a/ext/phar/tests/005.phpt b/ext/phar/tests/005.phpt
deleted file mode 100644
index c8fddf572f..0000000000
--- a/ext/phar/tests/005.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest (none)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-try {
-Phar::mapPhar('hio');
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-__HALT_COMPILER(); ?>()
---EXPECTF--
-internal corruption of phar "%s" (truncated manifest at manifest length)
diff --git a/ext/phar/tests/006.phpt b/ext/phar/tests/006.phpt
deleted file mode 100644
index 86b1117925..0000000000
--- a/ext/phar/tests/006.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Phar::mapPhar truncated manifest (manifest length truncated)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-try {
-Phar::mapPhar('hio');
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-__HALT_COMPILER(); ?>
---EXPECTF--
-internal corruption of phar "%s" (truncated manifest at manifest length)
diff --git a/ext/phar/tests/007.phpt b/ext/phar/tests/007.phpt
deleted file mode 100644
index 1519f4fe40..0000000000
--- a/ext/phar/tests/007.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Phar::mapPhar manifest too big
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---FILE--
-<?php
-try {
-Phar::mapPhar('hio');
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-__HALT_COMPILER(); ?>~~~~
---EXPECTF--
-manifest cannot be larger than 1 MB in phar "%s"
diff --git a/ext/phar/tests/008.phpt b/ext/phar/tests/008.phpt
deleted file mode 100644
index 81e09dc70b..0000000000
--- a/ext/phar/tests/008.phpt
+++ /dev/null
@@ -1,21 +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);
-try {
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-internal corruption of phar "%s" (truncated manifest header)
diff --git a/ext/phar/tests/009.phpt b/ext/phar/tests/009.phpt
deleted file mode 100644
index 6a480c3852..0000000000
--- a/ext/phar/tests/009.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Phar::mapPhar too many manifest entries
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-$file .= pack('VVnVVV', 500, 500, 0x1000, 0x00000000, 0, 0) . str_repeat('A', 500);
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-try {
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-internal corruption of phar "%s009.phar.php" (too many manifest entries for size of manifest)
diff --git a/ext/phar/tests/010.phpt b/ext/phar/tests/010.phpt
deleted file mode 100644
index 3dcf495d9a..0000000000
--- a/ext/phar/tests/010.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Phar::mapPhar buffer overrun
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---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('VVVVVV', 0, time(), 0, crc32(''), 0x00000000, 0);
-$file .= pack('VVnVV', strlen($manifest), 1, 0x1000, 0x00000000, 3) . 'hio' . pack('V', 0) . $manifest;
-
-file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
-try {
-include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-echo file_get_contents('phar://hio/a');
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-internal corruption of phar "%s" (too many manifest entries for size of manifest)
diff --git a/ext/phar/tests/011.phpt b/ext/phar/tests/011.phpt
deleted file mode 100644
index ac85477841..0000000000
--- a/ext/phar/tests/011.phpt
+++ /dev/null
@@ -1,30 +0,0 @@
---TEST--
-Phar::mapPhar filesize too small in manifest
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-// compressed file length does not match incompressed lentgh for an uncompressed file
-
-$files = array();
-$files['a'] = array('cont'=>'a','ulen'=>1,'clen'=>2);;
-include 'phar_test.inc';
-try {
-include $fname;
-echo file_get_contents('phar://hio/a');
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-internal corruption of phar "%s" (compressed and uncompressed size does not match for uncompressed entry)
diff --git a/ext/phar/tests/012.phpt b/ext/phar/tests/012.phpt
deleted file mode 100644
index f090f2ff12..0000000000
--- a/ext/phar/tests/012.phpt
+++ /dev/null
@@ -1,25 +0,0 @@
---TEST--
-Phar::mapPhar valid file
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-
-include 'phar_test.inc';
-include $fname;
-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 677d8ca81f..0000000000
--- a/ext/phar/tests/013.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Phar::mapPhar filesize mismatch
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-// filesize should be 1, and is 2
-
-$files = array();
-$files['a'] = array('cont'=>'a', 'ulen'=>2, 'clen'=>2);
-include 'phar_test.inc';
-
-echo file_get_contents($pname.'/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (%s 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 70a5b53c35..0000000000
--- a/ext/phar/tests/014.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Phar::mapPhar filesize mismatch
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-// wrong crc32
-
-$files = array();
-$files['a'] = array('cont'=>'a', 'crc32'=>crc32('aX'));
-include 'phar_test.inc';
-
-echo file_get_contents($pname.'/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line %d
diff --git a/ext/phar/tests/015.phpt b/ext/phar/tests/015.phpt
deleted file mode 100644
index b7c4241433..0000000000
--- a/ext/phar/tests/015.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Phar::mapPhar valid file (gzipped)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('cont'=>'a','comp'=>chr(75) . chr(4) . chr(0) /* 'a' gzdeflated */, 'flags'=>0x00001000);
-include 'phar_test.inc';
-
-echo file_get_contents($pname .'/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-a
diff --git a/ext/phar/tests/015b.phpt b/ext/phar/tests/015b.phpt
deleted file mode 100755
index 19640b0f24..0000000000
--- a/ext/phar/tests/015b.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Phar::mapPhar valid file (bzip2)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
-<?php if (!extension_loaded("bz2")) print "skip bz2 not present"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('cont'=>'Hello World', 'comp'=>pack('H*', '425a6834314159265359065c89da0000009780400000400080060490002000310c082031a916c41d41e2ee48a70a1200cb913b40'),'flags'=>0x00002000);
-include 'phar_test.inc';
-
-var_dump(file_get_contents($pname . '/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 89310e7108..0000000000
--- a/ext/phar/tests/016.phpt
+++ /dev/null
@@ -1,39 +0,0 @@
---TEST--
-Phar::mapPhar invalid file (gzipped file length is too short)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-// file length is too short
-
-$files = array();
-// "hi" gzdeflated
-$files['a'] = array('cont'=>'a','comp'=> pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
-$files['b'] = $files['a'];
-$files['c'] = array('cont'=>'*');
-$files['d'] = $files['a'];
-include 'phar_test.inc';
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump(file_get_contents($pname . '/b'));
-var_dump(file_get_contents($pname . '/c'));
-var_dump(file_get_contents($pname . '/d'));
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://%s/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://%s/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://%s/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 124a248fa1..0000000000
--- a/ext/phar/tests/016b.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-Phar::mapPhar invalid file (gzipped file length is too short)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-// file length is too short
-
-$files = array();
-$files['a'] = array('cont'=>'a','flags'=>0x00001000, 'clen' => 1);
-include 'phar_test.inc';
-
-echo file_get_contents($pname . '/a');
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-Warning: file_get_contents(phar://%s/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/017.phpt b/ext/phar/tests/017.phpt
deleted file mode 100644
index a0c1926de7..0000000000
--- a/ext/phar/tests/017.phpt
+++ /dev/null
@@ -1,25 +0,0 @@
---TEST--
-Phar: opendir test - no dir specified at all
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'abc';
-include 'phar_test.inc';
-
-include $fname;
-$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 (always use full path to a new phar) in %s on line %d
diff --git a/ext/phar/tests/018.phpt b/ext/phar/tests/018.phpt
deleted file mode 100644
index 84b8e088b7..0000000000
--- a/ext/phar/tests/018.phpt
+++ /dev/null
@@ -1,33 +0,0 @@
---TEST--
-Phar: opendir test, root directory
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-include 'phar_test.inc';
-
-include $fname;
-$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 818dfd7ec5..0000000000
--- a/ext/phar/tests/019.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar: opendir test, subdirectory
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$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';
-include 'phar_test.inc';
-include $fname;
-$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 f1e6455a80..0000000000
--- a/ext/phar/tests/019b.phpt
+++ /dev/null
@@ -1,65 +0,0 @@
---TEST--
-Phar: opendir test, recurse into
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$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';
-include 'phar_test.inc';
-include $fname;
-
-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 a9c4bbcf4a..0000000000
--- a/ext/phar/tests/019c.phpt
+++ /dev/null
@@ -1,73 +0,0 @@
---TEST--
-Phar: opendir test, recurse into
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$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';
-include 'phar_test.inc';
-include $fname;
-
-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 1b6db82b83..0000000000
--- a/ext/phar/tests/020.phpt
+++ /dev/null
@@ -1,136 +0,0 @@
---TEST--
-Phar: url stat
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$pfile = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$files = array();
-$files['a'] = 'a';
-$files['b/a'] = 'b';
-$files['b/c/d'] = 'c';
-$files['bad/c'] = 'd';
-include 'phar_test.inc';
-include $fname;
-
-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(%d)
- [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(%d)
- ["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(%d)
- [2]=>
- int(16749)
- [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(%d)
- ["mode"]=>
- int(16749)
- ["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 3a237ceb07..0000000000
--- a/ext/phar/tests/021.phpt
+++ /dev/null
@@ -1,85 +0,0 @@
---TEST--
-Phar: stream stat
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$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';
-
-include 'phar_test.inc';
-
-include $fname;
-
-$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(%d)
- [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(%d)
- ["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 70210e1cc7..0000000000
--- a/ext/phar/tests/022.phpt
+++ /dev/null
@@ -1,110 +0,0 @@
---TEST--
-Phar: stream stat
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'abcdefg';
-
-include 'phar_test.inc';
-
-include $fname;
-
-$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 a6d674af45..0000000000
--- a/ext/phar/tests/023.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-Phar: phar:// file_get_contents
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-
-include 'phar_test.inc';
-
-var_dump(file_get_contents($pname . '/a.php'));
-var_dump(file_get_contents($pname . '/b.php'));
-var_dump(file_get_contents($pname . '/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 29cd595c61..0000000000
--- a/ext/phar/tests/024.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-Phar: phar:// include
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-
-include 'phar_test.inc';
-
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/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 b85c85b470..0000000000
--- a/ext/phar/tests/025.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-Phar: phar:// include (repeated names)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$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"; ?>';
-
-include 'phar_test.inc';
-
-include $pname . '/a';
-include $pname . '/b';
-include $pname . '/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 606fa40ee0..0000000000
--- a/ext/phar/tests/026.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar: phar:// require from within
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---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"; ?>';
-
-include 'phar_test.inc';
-
-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 7dc7913ccd..0000000000
--- a/ext/phar/tests/027.phpt
+++ /dev/null
@@ -1,62 +0,0 @@
---TEST--
-Phar: phar:// opendir
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---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"; ?>';
-
-include 'phar_test.inc';
-
-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 c4e4abb32f..0000000000
--- a/ext/phar/tests/028.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Phar::loadPhar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://hio';
-$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"; ?>';
-
-include 'phar_test.inc';
-
-Phar::loadPhar($fname, 'hio');
-
-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 37f7b4edaf..0000000000
--- a/ext/phar/tests/029.phpt
+++ /dev/null
@@ -1,48 +0,0 @@
---TEST--
-Phar::loadPhar overloading alias names
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname1 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.php';
-$fname = $fname1;
-$pname = 'phar://hio';
-$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"; ?>';
-
-include 'phar_test.inc';
-
-file_put_contents($fname2, $file);
-
-var_dump(Phar::loadPhar($fname1, 'hio'));
-var_dump(Phar::loadPhar($fname1, 'copy'));
-try
-{
- var_dump(Phar::loadPhar($fname2, 'copy'));
-}
-catch (Exception $e)
-{
- echo $e->getMessage() . "\n";
-}
-
-?>
-===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)
-alias "copy" is already used for archive "%s029.1.phar.php" cannot be overloaded with "%s029.2.phar.php"
-===DONE===
diff --git a/ext/phar/tests/030.phpt b/ext/phar/tests/030.phpt
deleted file mode 100755
index f8f9c12a26..0000000000
--- a/ext/phar/tests/030.phpt
+++ /dev/null
@@ -1,38 +0,0 @@
---TEST--
-Phar::loadPhar ignoring alias
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---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"; ?>';
-
-include 'phar_test.inc';
-
-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 952ba72a40..0000000000
--- a/ext/phar/tests/031.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Phar: include and parser error
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
---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: %s error%sexpecting%s in phar://%sphar_oo_test.phar.php/a.php on line %d
diff --git a/ext/phar/tests/032.phpt b/ext/phar/tests/032.phpt
deleted file mode 100755
index f7d11c6d64..0000000000
--- a/ext/phar/tests/032.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Phar: require hash
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=1
---FILE--
-<?php
-
-$pharconfig = 0;
-
-require_once 'phar_oo_test.inc';
-
-try {
-Phar::loadPhar($fname);
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-
-phar "%sphar_oo_test.phar.php" does not have a signature===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/033.phpt b/ext/phar/tests/033.phpt
deleted file mode 100644
index ddcc36ae54..0000000000
--- a/ext/phar/tests/033.phpt
+++ /dev/null
@@ -1,33 +0,0 @@
---TEST--
-Phar::chmod
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$pname = 'phar://hio';
-$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
-include 'phar_test.inc';
-$a = new Phar($fname);
-var_dump($a['a.php']->isExecutable());
-$a['a.php']->chmod(0777);
-var_dump($a['a.php']->isExecutable());
-$a['a.php']->chmod(0666);
-var_dump($a['a.php']->isExecutable());
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
-?>
---EXPECTF--
-bool(false)
-bool(true)
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/033a.phpt b/ext/phar/tests/033a.phpt
deleted file mode 100644
index 64a5a01b13..0000000000
--- a/ext/phar/tests/033a.phpt
+++ /dev/null
@@ -1,36 +0,0 @@
---TEST--
-Phar::chmod
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$pname = 'phar://hio';
-$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a.php'] = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
-include 'phar_test.inc';
-try {
- $a = new Phar($fname);
- var_dump($a['a.php']->isExecutable());
- $a['a.php']->chmod(0777);
- var_dump($a['a.php']->isExecutable());
- $a['a.php']->chmod(0666);
- var_dump($a['a.php']->isExecutable());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
-}
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
-?>
---EXPECTF--
-bool(false)
-Cannot modify permissions for file "a.php" write operations are prohibited
-===DONE===
diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt
deleted file mode 100755
index 90e5527e24..0000000000
--- a/ext/phar/tests/create_new_and_modify.phpt
+++ /dev/null
@@ -1,48 +0,0 @@
---TEST--
-Phar: create and modify phar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=1
---FILE--
-<?php
-
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-
-@unlink($fname);
-
-file_put_contents($pname . '/a.php', "brand new!\n");
-
-$phar = new Phar($fname);
-$sig1 = $phar->getSignature();
-
-include $pname . '/a.php';
-
-file_put_contents($pname .'/a.php', "modified!\n");
-file_put_contents($pname .'/b.php', "another!\n");
-
-$phar = new Phar($fname);
-$sig2 = $phar->getSignature();
-
-var_dump($sig1['hash']);
-var_dump($sig2['hash']);
-var_dump($sig1['hash'] != $sig2['hash']);
-
-include $pname . '/a.php';
-include $pname . '/b.php';
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-brand new!
-string(40) "%s"
-string(40) "%s"
-bool(true)
-modified!
-another!
-===DONE===
diff --git a/ext/phar/tests/create_new_phar.phpt b/ext/phar/tests/create_new_phar.phpt
deleted file mode 100644
index 2781f0c7bf..0000000000
--- a/ext/phar/tests/create_new_phar.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-Phar: create a completely new phar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=1
---FILE--
-<?php
-
-file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php',
- 'brand new!');
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-brand new!
-===DONE===
diff --git a/ext/phar/tests/create_new_phar_b.phpt b/ext/phar/tests/create_new_phar_b.phpt
deleted file mode 100755
index 4f0601be10..0000000000
--- a/ext/phar/tests/create_new_phar_b.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Phar: create a completely new phar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=1
---FILE--
-<?php
-
-file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php',
- 'brand new!');
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-
-Warning: file_put_contents(phar://%screate_new_phar_b.phar.php/a.php): failed to open stream: phar error: write operations disabled by INI setting in %screate_new_phar_b.php on line %d
-
-Warning: include(%screate_new_phar_b.phar.php): failed to open stream: No such file or directory in %screate_new_phar_b.php on line %d
-
-Warning: include(phar://%screate_new_phar_b.phar.php/a.php): failed to open stream: No such file or directory in %screate_new_phar_b.php on line %d
-
-Warning: include(): Failed opening 'phar://%screate_new_phar_b.phar.php/a.php' for inclusion (include_path='%s') in %screate_new_phar_b.php on line %d
-
-===DONE===
diff --git a/ext/phar/tests/create_new_phar_c.phpt b/ext/phar/tests/create_new_phar_c.phpt
deleted file mode 100755
index 48702ecec4..0000000000
--- a/ext/phar/tests/create_new_phar_c.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Phar: create a completely new phar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=1
---FILE--
-<?php
-
-file_put_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php',
- 'brand new!');
-
-$phar = new Phar(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
-
-var_dump($phar->getSignature());
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-array(2) {
- ["hash"]=>
- string(40) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-===DONE===
diff --git a/ext/phar/tests/create_path_error.phpt b/ext/phar/tests/create_path_error.phpt
deleted file mode 100755
index eb2dbe43ca..0000000000
--- a/ext/phar/tests/create_path_error.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---TEST--
-Phar: create with illegal path
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=1
---FILE--
-<?php
-
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-
-@unlink($fname);
-
-file_put_contents($pname . '/a.php?', "query");
-file_put_contents($pname . '/b.php?bla', "query");
-
-var_dump(file_get_contents($pname . '/a.php'));
-var_dump(file_get_contents($pname . '/b.php'));
-
-function error_handler($errno, $errmsg)
-{
- echo "Error: $errmsg\n";
-}
-
-set_error_handler('error_handler');
-
-$checks = array('/', '.', '../', 'a/..', 'a/', 'b//a.php');
-foreach($checks as $check)
-{
- file_put_contents($pname . '/' . $check, "error");
-}
-
-$phar = new Phar($fname);
-$checks = array("a\0");
-foreach($checks as $check)
-{
- try
- {
- $phar[$check] = 'error';
- }
- catch(Exception $e)
- {
- echo 'Exception: ' . $e->getMessage() . "\n";
- }
-}
-
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-string(5) "query"
-string(5) "query"
-Error: file_put_contents(phar://%s//): failed to open stream: phar error: invalid path "/" contains empty directory
-Error: file_put_contents(phar://%s/.): failed to open stream: phar error: invalid path "." contains current directory reference
-Error: file_put_contents(phar://%s/../): failed to open stream: phar error: invalid path "../" contains empty directory
-Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: invalid path "a/.." contains upper directory reference
-Error: file_put_contents(phar://%s/a/): failed to open stream: phar error: invalid path "a/" contains empty directory
-Error: file_put_contents(phar://%s/b//a.php): failed to open stream: phar error: invalid path "b//a.php" contains double slash
-Exception: Entry a does not exist and cannot be created: phar error: invalid path "a" contains illegal character
-===DONE===
diff --git a/ext/phar/tests/delete_in_phar.phpt b/ext/phar/tests/delete_in_phar.phpt
deleted file mode 100644
index b33e2b2523..0000000000
--- a/ext/phar/tests/delete_in_phar.phpt
+++ /dev/null
@@ -1,48 +0,0 @@
---TEST--
-Phar: delete a file within a .phar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/b/c.php');
-?>
-===AFTER===
-<?php
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-This is a
-This is b
-This is b/c
-===AFTER===
-This is a
-This is b
-
-Warning: include(%sdelete_in_phar.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.php" in %sdelete_in_phar.php on line %d
-
-Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
-
-===DONE===
- \ No newline at end of file
diff --git a/ext/phar/tests/delete_in_phar_b.phpt b/ext/phar/tests/delete_in_phar_b.phpt
deleted file mode 100755
index c967644d99..0000000000
--- a/ext/phar/tests/delete_in_phar_b.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Phar: delete a file within a .phar
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/b/c.php');
-?>
-===AFTER===
-<?php
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-This is a
-This is b
-This is b/c
-
-Warning: unlink(): phar error: write operations disabled by INI setting in %sdelete_in_phar_b.php on line %d
-===AFTER===
-This is a
-This is b
-This is b/c
-
-===DONE===
diff --git a/ext/phar/tests/delete_in_phar_confirm.phpt b/ext/phar/tests/delete_in_phar_confirm.phpt
deleted file mode 100644
index 11c884bd7b..0000000000
--- a/ext/phar/tests/delete_in_phar_confirm.phpt
+++ /dev/null
@@ -1,51 +0,0 @@
---TEST--
-Phar: delete a file within a .phar (confirm disk file is changed)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-$md5 = md5_file($fname);
-unlink($pname . '/b/c.php');
-clearstatcache();
-$md52 = md5_file($fname);
-if ($md5 == $md52) echo 'file was not modified';
-?>
-===AFTER===
-<?php
-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'); ?>
---EXPECTF--
-This is a
-This is b
-This is b/c
-===AFTER===
-This is a
-This is b
-
-Warning: include(%sdelete_in_phar_confirm.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.php" in %sdelete_in_phar_confirm.php on line %d
-
-Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
-
-===DONE===
diff --git a/ext/phar/tests/extracted.inc b/ext/phar/tests/extracted.inc
deleted file mode 100755
index a6e52246a3..0000000000
--- a/ext/phar/tests/extracted.inc
+++ /dev/null
@@ -1 +0,0 @@
-<?php var_dump(__FILE__); ?>
diff --git a/ext/phar/tests/extracted_001.phpt b/ext/phar/tests/extracted_001.phpt
deleted file mode 100755
index 8f1254d3d1..0000000000
--- a/ext/phar/tests/extracted_001.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Phar: extracted
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
-phar.extract_list="phar_test.phar=test"
---FILE--
-<?php
-var_dump(Phar::getExtractList());
-ini_set('phar.extract_list', 'phar_test.phar='.dirname(__FILE__));
-var_dump(Phar::getExtractList());
-
-$pname = 'phar://phar_test.phar';
-
-var_dump(file_get_contents($pname . '/extracted.inc'));
-
-include $pname . '/extracted.inc';
-
-?>
-===DONE===
---EXPECTF--
-array(1) {
- ["phar_test.phar"]=>
- string(4) "test"
-}
-array(1) {
- ["phar_test.phar"]=>
- string(%d) "%s"
-}
-string(29) "<?php var_dump(__FILE__); ?>
-"
-string(%d) "%sextracted.inc"
-===DONE===
diff --git a/ext/phar/tests/ini_set.phpt b/ext/phar/tests/ini_set.phpt
deleted file mode 100644
index 6cffcd5e33..0000000000
--- a/ext/phar/tests/ini_set.phpt
+++ /dev/null
@@ -1,28 +0,0 @@
---TEST--
-Phar: test ini_set with readonly and require_hash enabled
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=1
-phar.readonly=1
---FILE--
-<?php
-var_dump(ini_set('phar.require_hash', 1));
-var_dump(ini_set('phar.readonly', 1));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-var_dump(ini_set('phar.require_hash', 0));
-var_dump(ini_set('phar.readonly', 0));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-__HALT_COMPILER();
-?>
---EXPECT--
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
diff --git a/ext/phar/tests/ini_set_off.phpt b/ext/phar/tests/ini_set_off.phpt
deleted file mode 100644
index cccf588e47..0000000000
--- a/ext/phar/tests/ini_set_off.phpt
+++ /dev/null
@@ -1,85 +0,0 @@
---TEST--
-Phar: test ini_set with readonly and require_hash disabled
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-var_dump(ini_set('phar.require_hash', 1));
-var_dump(ini_set('phar.readonly', 1));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-ini_set('phar.require_hash', 0);
-ini_set('phar.readonly', 0);
-var_dump(Phar::canWrite());
-?>
-yes
-<?php
-var_dump(ini_set('phar.require_hash', 'yes'));
-var_dump(ini_set('phar.readonly', 'yes'));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-var_dump(Phar::canWrite());
-ini_set('phar.require_hash', 0);
-ini_set('phar.readonly', 0);
-?>
-on
-<?php
-var_dump(ini_set('phar.require_hash', 'on'));
-var_dump(ini_set('phar.readonly', 'on'));
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-var_dump(Phar::canWrite());
-ini_set('phar.require_hash', 0);
-ini_set('phar.readonly', 0);
-?>
-true
-<?php
-var_dump(ini_set('phar.require_hash', 'true'));
-var_dump(ini_set('phar.readonly', 'true'));
-var_dump(Phar::canWrite());
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-?>
-0
-<?php
-var_dump(ini_set('phar.require_hash', 0));
-var_dump(ini_set('phar.readonly', 0));
-var_dump(Phar::canWrite());
-var_dump(ini_get('phar.require_hash'));
-var_dump(ini_get('phar.readonly'));
-?>
-===DONE===
---EXPECT--
-string(1) "0"
-string(1) "0"
-string(1) "1"
-string(1) "1"
-bool(true)
-yes
-string(1) "0"
-string(1) "0"
-string(3) "yes"
-string(3) "yes"
-bool(false)
-on
-string(1) "0"
-string(1) "0"
-string(2) "on"
-string(2) "on"
-bool(false)
-true
-string(1) "0"
-string(1) "0"
-bool(false)
-string(4) "true"
-string(4) "true"
-0
-string(4) "true"
-string(4) "true"
-bool(true)
-string(1) "0"
-string(1) "0"
-===DONE===
diff --git a/ext/phar/tests/metadata_read.phpt b/ext/phar/tests/metadata_read.phpt
deleted file mode 100644
index 83c96cf9e1..0000000000
--- a/ext/phar/tests/metadata_read.phpt
+++ /dev/null
@@ -1,61 +0,0 @@
---TEST--
-Phar with meta-data (read)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('cont' => 'a');
-$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
-$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
-$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
-include 'phar_test.inc';
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-
-$phar = new Phar($fname);
-foreach($files as $name => $cont) {
- var_dump($phar[$name]->getMetadata());
-}
-
-unset($phar);
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-NULL
-string(8) "hi there"
-array(2) {
- [0]=>
- string(2) "hi"
- [1]=>
- string(5) "there"
-}
-array(2) {
- ["hi"]=>
- string(5) "there"
- ["foo"]=>
- string(3) "bar"
-}
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-===DONE===
diff --git a/ext/phar/tests/metadata_write.phpt b/ext/phar/tests/metadata_write.phpt
deleted file mode 100755
index e9be873b2c..0000000000
--- a/ext/phar/tests/metadata_write.phpt
+++ /dev/null
@@ -1,61 +0,0 @@
---TEST--
-Phar with meta-data (write)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('cont' => 'a');
-$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
-$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
-$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
-include 'phar_test.inc';
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-
-$phar = new Phar($fname);
-$phar['a']->setMetadata(42);
-$phar['b']->setMetadata(NULL);
-$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
-$phar['d']->setMetadata(true);
-
-foreach($files as $name => $cont) {
- var_dump($phar[$name]->getMetadata());
-}
-
-unset($phar);
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-int(42)
-NULL
-array(2) {
- [0]=>
- int(25)
- ["foo"]=>
- string(3) "bar"
-}
-bool(true)
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-===DONE===
diff --git a/ext/phar/tests/metadata_write_commit.phpt b/ext/phar/tests/metadata_write_commit.phpt
deleted file mode 100755
index 06a66d9c98..0000000000
--- a/ext/phar/tests/metadata_write_commit.phpt
+++ /dev/null
@@ -1,79 +0,0 @@
---TEST--
-Phar with meta-data (write)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('cont' => 'a');
-$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
-$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
-$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
-include 'phar_test.inc';
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-
-$phar = new Phar($fname);
-$phar->startBuffering();
-$phar['a']->setMetadata(42);
-$phar['b']->setMetadata(NULL);
-$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
-$phar['d']->setMetadata(true);
-
-foreach($files as $name => $cont) {
- var_dump($phar[$name]->getMetadata());
-}
-$phar->stopBuffering();
-
-unset($phar);
-
-$phar = new Phar($fname);
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-
-foreach($files as $name => $cont) {
- var_dump($phar[$name]->getMetadata());
-}
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-int(42)
-NULL
-array(2) {
- [0]=>
- int(25)
- ["foo"]=>
- string(3) "bar"
-}
-bool(true)
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-int(42)
-NULL
-array(2) {
- [0]=>
- int(25)
- ["foo"]=>
- string(3) "bar"
-}
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/open_for_write_existing.phpt b/ext/phar/tests/open_for_write_existing.phpt
deleted file mode 100644
index a1ab33a6b7..0000000000
--- a/ext/phar/tests/open_for_write_existing.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Phar: fopen a .phar for writing (existing file)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-$fp = fopen($pname . '/b/c.php', 'wb');
-fwrite($fp, 'extra');
-fclose($fp);
-include $pname . '/b/c.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-extra
-===DONE===
diff --git a/ext/phar/tests/open_for_write_existing_b.phpt b/ext/phar/tests/open_for_write_existing_b.phpt
deleted file mode 100755
index a4f4d03092..0000000000
--- a/ext/phar/tests/open_for_write_existing_b.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Phar: fopen a .phar for writing (existing file)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-function err_handler($errno, $errstr, $errfile, $errline) {
- echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
-}
-
-set_error_handler("err_handler", E_RECOVERABLE_ERROR);
-
-$fp = fopen($pname . '/b/c.php', 'wb');
-fwrite($fp, 'extra');
-fclose($fp);
-include $pname . '/b/c.php';
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-
-Warning: fopen(phar://%sopen_for_write_existing_b.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
-
-Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
-This is b/c
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/open_for_write_existing_c.phpt b/ext/phar/tests/open_for_write_existing_c.phpt
deleted file mode 100755
index b7a61c7b0b..0000000000
--- a/ext/phar/tests/open_for_write_existing_c.phpt
+++ /dev/null
@@ -1,36 +0,0 @@
---TEST--
-Phar: fopen a .phar for writing (existing file)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-$fp = fopen($pname . '/b/c.php', 'wb');
-fwrite($fp, 'extra');
-fclose($fp);
-include $pname . '/b/c.php';
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-
-Warning: fopen(phar://%sopen_for_write_existing_c.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
-
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
-This is b/c
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/open_for_write_newfile.phpt b/ext/phar/tests/open_for_write_newfile.phpt
deleted file mode 100644
index 0594103f17..0000000000
--- a/ext/phar/tests/open_for_write_newfile.phpt
+++ /dev/null
@@ -1,33 +0,0 @@
---TEST--
-Phar: fopen a .phar for writing (new file)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-$fp = fopen($pname . '/b/new.php', 'wb');
-fwrite($fp, 'extra');
-fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-This is b/c
-extra
-===DONE===
diff --git a/ext/phar/tests/open_for_write_newfile_b.phpt b/ext/phar/tests/open_for_write_newfile_b.phpt
deleted file mode 100755
index 3ee7b70947..0000000000
--- a/ext/phar/tests/open_for_write_newfile_b.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-Phar: fopen a .phar for writing (new file)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-function err_handler($errno, $errstr, $errfile, $errline) {
- echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
-}
-
-set_error_handler("err_handler", E_RECOVERABLE_ERROR);
-
-$fp = fopen($pname . '/b/new.php', 'wb');
-fwrite($fp, 'extra');
-fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-
-Warning: fopen(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
-
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line 20
-This is b/c
-
-Warning: include(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.php" in %sopen_for_write_newfile_b.php on line 22
-
-Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
-
-===DONE===
diff --git a/ext/phar/tests/open_for_write_newfile_c.phpt b/ext/phar/tests/open_for_write_newfile_c.phpt
deleted file mode 100755
index ce0562b48c..0000000000
--- a/ext/phar/tests/open_for_write_newfile_c.phpt
+++ /dev/null
@@ -1,43 +0,0 @@
---TEST--
-Phar: fopen a .phar for writing (new file)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-$fp = fopen($pname . '/b/new.php', 'wb');
-fwrite($fp, 'extra');
-fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-
-Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
-
-Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
-
-Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
-This is b/c
-
-Warning: include(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.php" in %sopen_for_write_newfile_c.php on line %d
-
-Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
-
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_begin_setstub_commit.phpt b/ext/phar/tests/phar_begin_setstub_commit.phpt
deleted file mode 100755
index ece362f350..0000000000
--- a/ext/phar/tests/phar_begin_setstub_commit.phpt
+++ /dev/null
@@ -1,50 +0,0 @@
---TEST--
-Phar::startBuffering()/setStub()/stopBuffering()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
-//var_dump($p->getStub());
-var_dump($p->isBuffering());
-$p->startBuffering();
-var_dump($p->isBuffering());
-$p['a.php'] = '<?php var_dump("Hello");';
-$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
-include 'phar://brandnewphar.phar/a.php';
-var_dump($p->getStub());
-$p['b.php'] = '<?php var_dump("World");';
-$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER();');
-include 'phar://brandnewphar.phar/b.php';
-var_dump($p->getStub());
-$p->stopBuffering();
-echo "===COMMIT===\n";
-var_dump($p->isBuffering());
-include 'phar://brandnewphar.phar/a.php';
-include 'phar://brandnewphar.phar/b.php';
-var_dump($p->getStub());
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/brandnewphar.phar');
-?>
---EXPECT--
-bool(true)
-bool(false)
-string(5) "Hello"
-string(84) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
-"
-string(5) "World"
-string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
-"
-===COMMIT===
-bool(true)
-string(5) "Hello"
-string(5) "World"
-string(85) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>
-"
-===DONE===
diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt
deleted file mode 100644
index 16f35701bd..0000000000
--- a/ext/phar/tests/phar_commitwrite.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Phar::setStub()/stopBuffering()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
-$p['file1.txt'] = 'hi';
-$p->stopBuffering();
-var_dump($p->getStub());
-$p->setStub("<?php
-function __autoload(\$class)
-{
- include 'phar://' . str_replace('_', '/', \$class);
-}
-Phar::mapPhar('brandnewphar.phar');
-include 'phar://brandnewphar.phar/startup.php';
-__HALT_COMPILER();
-?>");
-var_dump($p->getStub());
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/brandnewphar.phar');
-?>
---EXPECT--
-string(29) "<?php __HALT_COMPILER(); ?>
-"
-string(200) "<?php
-function __autoload($class)
-{
- include 'phar://' . str_replace('_', '/', $class);
-}
-Phar::mapPhar('brandnewphar.phar');
-include 'phar://brandnewphar.phar/startup.php';
-__HALT_COMPILER(); ?>
-"
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt
deleted file mode 100644
index b10bf4971c..0000000000
--- a/ext/phar/tests/phar_create_in_cwd.phpt
+++ /dev/null
@@ -1,37 +0,0 @@
---TEST--
-Phar: attempt to create a Phar with relative path
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-chdir(dirname(__FILE__));
-try {
- $p = new Phar('brandnewphar.phar');
- $p['file1.txt'] = 'hi';
- $p->commit();
- var_dump($p->getStub());
- $p->setStub("<?php
-function __autoload(\$class)
-{
- include 'phar://' . str_replace('_', '/', \$class);
-}
-Phar::mapPhar('brandnewphar.phar');
-include 'phar://brandnewphar.phar/startup.php';
-__HALT_COMPILER();
-?>");
- var_dump($p->getStub());
-} catch (Exception $e) {
- echo $e->getMessage() . "\n";
-}
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/brandnewphar.phar');
-?>
---EXPECT--
-RecursiveDirectoryIterator::__construct(phar://brandnewphar.phar): failed to open dir: phar error: no directory in "phar://brandnewphar.phar", must have at least phar://brandnewphar.phar/ for root directory (always use full path to a new phar)
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_ctx_001.phpt b/ext/phar/tests/phar_ctx_001.phpt
deleted file mode 100644
index 11a1ba2520..0000000000
--- a/ext/phar/tests/phar_ctx_001.phpt
+++ /dev/null
@@ -1,100 +0,0 @@
---TEST--
-Phar context
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$context = stream_context_create(array('phar'=> array('compress'=>Phar::GZ, 'metadata' => array(2, 'hi' => 3))));
-$context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
-
-file_put_contents($pname . '/a', 'new a', 0); // no compression
-file_put_contents($pname . '/b', 'new b', 0, $context);
-file_put_contents($pname . '/d', 'new d', 0, $context2);
-
-$phar = new Phar($fname);
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump($phar['a']->getMetaData());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump($phar['b']->getMetaData());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-var_dump($phar['c']->getMetaData());
-var_dump(file_get_contents($pname . '/d'));
-var_dump($phar['d']->isCompressed());
-var_dump($phar['d']->getMetaData());
-$context2 = stream_context_create(array('phar' => array('metadata' => array(4))));
-$fp = fopen($pname . '/b', 'r+', 0, $context2);
-fclose($fp);
-?>
-==AFTER==
-<?php
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump($phar['b']->getMetaData());
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECT--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(5) "new a"
-bool(false)
-NULL
-string(5) "new b"
-bool(true)
-array(2) {
- [0]=>
- int(2)
- ["hi"]=>
- int(3)
-}
-string(1) "c"
-bool(false)
-NULL
-string(5) "new d"
-bool(false)
-array(1) {
- [0]=>
- int(4)
-}
-==AFTER==
-string(5) "new b"
-bool(true)
-array(1) {
- [0]=>
- int(4)
-}
-===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_get_suppoted_signatures_001.phpt b/ext/phar/tests/phar_get_suppoted_signatures_001.phpt
deleted file mode 100755
index 16a0f6df84..0000000000
--- a/ext/phar/tests/phar_get_suppoted_signatures_001.phpt
+++ /dev/null
@@ -1,22 +0,0 @@
---TEST--
-Phar::setSupportedSignatures()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if ( extension_loaded("hash")) print "skip extension hash conflicts"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-var_dump(Phar::getSupportedSignatures());
-?>
-===DONE===
-?>
---EXPECT--
-array(2) {
- [0]=>
- string(3) "MD5"
- [1]=>
- string(5) "SHA-1"
-}
-===DONE===
diff --git a/ext/phar/tests/phar_get_suppoted_signatures_002.phpt b/ext/phar/tests/phar_get_suppoted_signatures_002.phpt
deleted file mode 100755
index db5ac138c5..0000000000
--- a/ext/phar/tests/phar_get_suppoted_signatures_002.phpt
+++ /dev/null
@@ -1,26 +0,0 @@
---TEST--
-Phar::setSupportedSignatures()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("hash")) print "skip extension hash required"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-var_dump(Phar::getSupportedSignatures());
-?>
-===DONE===
-?>
---EXPECT--
-array(4) {
- [0]=>
- string(3) "MD5"
- [1]=>
- string(5) "SHA-1"
- [2]=>
- string(7) "SHA-256"
- [3]=>
- string(7) "SHA-512"
-}
-===DONE===
diff --git a/ext/phar/tests/phar_metadata_read.phpt b/ext/phar/tests/phar_metadata_read.phpt
deleted file mode 100644
index eca2514284..0000000000
--- a/ext/phar/tests/phar_metadata_read.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---TEST--
-Phar with phar-level meta-data (read)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$pmeta = 'hi there';
-$files['a'] = array('cont' => 'a');
-$files['b'] = array('cont' => 'b');
-$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
-$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
-include 'phar_test.inc';
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-
-$phar = new Phar($fname);
-var_dump($phar->getMetaData());
-foreach($files as $name => $cont) {
- var_dump($phar[$name]->getMetadata());
-}
-
-unset($phar);
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-string(8) "hi there"
-NULL
-NULL
-array(2) {
- [0]=>
- string(2) "hi"
- [1]=>
- string(5) "there"
-}
-array(2) {
- ["hi"]=>
- string(5) "there"
- ["foo"]=>
- string(3) "bar"
-}
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-===DONE===
diff --git a/ext/phar/tests/phar_metadata_write.phpt b/ext/phar/tests/phar_metadata_write.phpt
deleted file mode 100644
index a49799a2b4..0000000000
--- a/ext/phar/tests/phar_metadata_write.phpt
+++ /dev/null
@@ -1,69 +0,0 @@
---TEST--
-Phar with phar meta-data (write)
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip";?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php __HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = array('cont' => 'a');
-$files['b'] = array('cont' => 'b', 'meta' => 'hi there');
-$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
-$files['d'] = array('cont' => 'd', 'meta' => array('hi'=>'there','foo'=>'bar'));
-include 'phar_test.inc';
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-
-$phar = new Phar($fname);
-var_dump($phar->getMetadata());
-$phar->setMetadata(array('my' => 'friend'));
-var_dump($phar->getMetadata());
-$phar['a']->setMetadata(42);
-$phar['b']->setMetadata(NULL);
-$phar['c']->setMetadata(array(25, 'foo'=>'bar'));
-$phar['d']->setMetadata(true);
-
-foreach($files as $name => $cont) {
- var_dump($phar[$name]->getMetadata());
-}
-
-unset($phar);
-
-foreach($files as $name => $cont) {
- var_dump(file_get_contents($pname.'/'.$name));
-}
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-NULL
-array(1) {
- ["my"]=>
- string(6) "friend"
-}
-int(42)
-NULL
-array(2) {
- [0]=>
- int(25)
- ["foo"]=>
- string(3) "bar"
-}
-bool(true)
-string(1) "a"
-string(1) "b"
-string(1) "c"
-string(1) "d"
-===DONE===
diff --git a/ext/phar/tests/phar_offset_get_error.phpt b/ext/phar/tests/phar_offset_get_error.phpt
deleted file mode 100755
index e89b98570a..0000000000
--- a/ext/phar/tests/phar_offset_get_error.phpt
+++ /dev/null
@@ -1,37 +0,0 @@
---TEST--
-Phar: ignore filenames starting with / on offsetSet
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=1
---FILE--
-<?php
-
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://'.$fname;
-$iname = '/file.txt';
-$ename = '/error/';
-
-$p = new Phar($fname);
-$p[$iname] = "foobar\n";
-
-try
-{
- $p[$ename] = "foobar\n";
-}
-catch(Exception $e)
-{
- echo $e->getMessage() . "\n";
-}
-
-include($pname . $iname);
-?>
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECT--
-Entry /error/ does not exist and cannot be created: phar error: invalid path "/error/" contains empty directory
-foobar
-===DONE===
diff --git a/ext/phar/tests/phar_oo_001.phpt b/ext/phar/tests/phar_oo_001.phpt
deleted file mode 100755
index b2bb8cc0a7..0000000000
--- a/ext/phar/tests/phar_oo_001.phpt
+++ /dev/null
@@ -1,45 +0,0 @@
---TEST--
-Phar object: basics
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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) "1.0.0"
-int(5)
-string(50) "Cannot call method on an uninitialized 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 080df2c61a..0000000000
--- a/ext/phar/tests/phar_oo_002.phpt
+++ /dev/null
@@ -1,137 +0,0 @@
---TEST--
-Phar object: iterator & entries
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---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 67ac3cf99c..0000000000
--- a/ext/phar/tests/phar_oo_003.phpt
+++ /dev/null
@@ -1,45 +0,0 @@
---TEST--
-Phar object: entry & openFile()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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 55829c744b..0000000000
--- a/ext/phar/tests/phar_oo_004.phpt
+++ /dev/null
@@ -1,126 +0,0 @@
---TEST--
-Phar and DirectoryIteraotr
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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 c3d0c29bb2..0000000000
--- a/ext/phar/tests/phar_oo_005.phpt
+++ /dev/null
@@ -1,59 +0,0 @@
---TEST--
-Phar and RecursiveDirectoryIterator
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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 54c1ce0111..0000000000
--- a/ext/phar/tests/phar_oo_006.phpt
+++ /dev/null
@@ -1,52 +0,0 @@
---TEST--
-Phar object: array access
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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->setInfoClass('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)
-a.php
-MyFile::__construct(phar://%s/b/c.php)
-c.php
-MyFile::__construct(phar://%s/b.php)
-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 d294cd043f..0000000000
--- a/ext/phar/tests/phar_oo_007.phpt
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Phar object: access through SplFileObject
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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->setInfoClass('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 19c7635ee6..0000000000
--- a/ext/phar/tests/phar_oo_008.phpt
+++ /dev/null
@@ -1,119 +0,0 @@
---TEST--
-Phar object: iterating via SplFileObject
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-
-$pharconfig = 1;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass('SplFileObject');
-
-$f = $phar['a.csv'];
-echo "===1===\n";
-foreach($f as $k => $v)
-{
- echo "$k=>$v\n";
-}
-
-$f->setFlags(SplFileObject::DROP_NEW_LINE);
-
-echo "===2===\n";
-foreach($f as $k => $v)
-{
- echo "$k=>$v\n";
-}
-
-class MyCSVFile extends SplFileObject
-{
- function current()
- {
- return parent::fgetcsv(',', '"');
- }
-}
-
-$phar->setInfoClass('MyCSVFile');
-$v = $phar['a.csv'];
-
-echo "===3===\n";
-while(!$v->eof())
-{
- echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n";
-}
-
-echo "===4===\n";
-$v->rewind();
-while(!$v->eof())
-{
- $l = $v->fgetcsv();
- echo $v->key() . "=>" . join('|',$l) . "\n";
-}
-
-echo "===5===\n";
-foreach($v as $k => $d)
-{
- echo "$k=>" . join('|',$d) . "\n";
-}
-
-class MyCSVFile2 extends SplFileObject
-{
- function getCurrentLine()
- {
- echo __METHOD__ . "\n";
- return parent::fgetcsv(',', '"');
- }
-}
-
-$phar->setInfoClass('MyCSVFile2');
-$v = $phar['a.csv'];
-
-echo "===6===\n";
-foreach($v as $k => $d)
-{
- echo "$k=>" . join('|',$d) . "\n";
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-===1===
-0=>1,2,3
-
-1=>2,a,b
-
-2=>3,"c","'e'"
-===2===
-0=>1,2,3
-1=>2,a,b
-2=>3,"c","'e'"
-===3===
-0=>1|2|3
-0=>2|a|b
-1=>3|c|'e'
-===4===
-0=>1|2|3
-1=>2|a|b
-2=>3|c|'e'
-===5===
-0=>1|2|3
-1=>2|a|b
-2=>3|c|'e'
-===6===
-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 dbe4919da2..0000000000
--- a/ext/phar/tests/phar_oo_009.phpt
+++ /dev/null
@@ -1,56 +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'); ?>
---INI--
-phar.require_hash=0
---FILE--
-<?php
-
-$pharconfig = 2;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass('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
-6=>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 1b6c8277a7..0000000000
--- a/ext/phar/tests/phar_oo_010.phpt
+++ /dev/null
@@ -1,55 +0,0 @@
---TEST--
-Phar object: ArrayAccess and isset
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.require_hash=0
---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_011.phpt b/ext/phar/tests/phar_oo_011.phpt
deleted file mode 100644
index 42f7f85cc8..0000000000
--- a/ext/phar/tests/phar_oo_011.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Phar object: add file
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-
-$pharconfig = 0;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass('SplFileObject');
-
-$phar['f.php'] = 'hi';
-var_dump(isset($phar['f.php']));
-echo $phar['f.php'];
-echo "\n";
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-bool(true)
-hi
-===DONE===
diff --git a/ext/phar/tests/phar_oo_011b.phpt b/ext/phar/tests/phar_oo_011b.phpt
deleted file mode 100755
index 7380aa18da..0000000000
--- a/ext/phar/tests/phar_oo_011b.phpt
+++ /dev/null
@@ -1,39 +0,0 @@
---TEST--
-Phar object: add file
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---FILE--
-<?php
-
-try
-{
- $pharconfig = 0;
-
- require_once 'phar_oo_test.inc';
-
- $phar = new Phar($fname);
-
- $phar['f.php'] = 'hi';
- var_dump(isset($phar['f.php']));
- echo $phar['f.php'];
- echo "\n";
-}
-catch (BadMethodCallException $e)
-{
- echo "Exception: " . $e->getMessage() . "\n";
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-Exception: Write operations disabled by INI setting
-===DONE===
diff --git a/ext/phar/tests/phar_oo_012.phpt b/ext/phar/tests/phar_oo_012.phpt
deleted file mode 100644
index a202cfeaae..0000000000
--- a/ext/phar/tests/phar_oo_012.phpt
+++ /dev/null
@@ -1,37 +0,0 @@
---TEST--
-Phar object: unset file
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-
-$pharconfig = 0;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass('SplFileObject');
-
-$phar['f.php'] = 'hi';
-var_dump(isset($phar['f.php']));
-echo $phar['f.php'];
-echo "\n";
-unset($phar['f.php']);
-var_dump(isset($phar['f.php']));
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-bool(true)
-hi
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_012_confirm.phpt b/ext/phar/tests/phar_oo_012_confirm.phpt
deleted file mode 100644
index ebe2451f75..0000000000
--- a/ext/phar/tests/phar_oo_012_confirm.phpt
+++ /dev/null
@@ -1,40 +0,0 @@
---TEST--
-Phar object: unset file (confirm disk file is changed)
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-
-$pharconfig = 0;
-
-require_once 'phar_oo_test.inc';
-
-$phar = new Phar($fname);
-$phar->setInfoClass('SplFileObject');
-
-$phar['f.php'] = 'hi';
-var_dump(isset($phar['f.php']));
-echo $phar['f.php'];
-echo "\n";
-$md5 = md5_file($fname);
-unset($phar['f.php']);
-$md52 = md5_file($fname);
-if ($md5 == $md52) echo 'File on disk has not changed';
-var_dump(isset($phar['f.php']));
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECT--
-bool(true)
-hi
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_012b.phpt b/ext/phar/tests/phar_oo_012b.phpt
deleted file mode 100755
index e0f6ec9129..0000000000
--- a/ext/phar/tests/phar_oo_012b.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Phar object: unset file
---SKIPIF--
-<?php if (!extension_loaded('phar')) die('skip'); ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=1
-phar.require_hash=0
---FILE--
-<?php
-
-try
-{
- $pharconfig = 0;
-
- require_once 'phar_oo_test.inc';
-
- $phar = new Phar($fname);
- $phar->setInfoClass('SplFileObject');
-
- $phar['f.php'] = 'hi';
- var_dump(isset($phar['f.php']));
- echo $phar['f.php'];
- echo "\n";
- unset($phar['f.php']);
- var_dump(isset($phar['f.php']));
-}
-catch (BadMethodCallException $e)
-{
- echo "Exception: " . $e->getMessage() . "\n";
-}
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/phar_oo_test.phar.php');
-__halt_compiler();
-?>
---EXPECTF--
-Exception: Write operations disabled by INI setting
-===DONE===
diff --git a/ext/phar/tests/phar_oo_compressallbz2.phpt b/ext/phar/tests/phar_oo_compressallbz2.phpt
deleted file mode 100644
index d1bd3ccc6a..0000000000
--- a/ext/phar/tests/phar_oo_compressallbz2.phpt
+++ /dev/null
@@ -1,65 +0,0 @@
---TEST--
-Phar::compressAllFilesBZIP2()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("bz2")) print "skip bz2 not present"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$phar = new Phar($fname);
-$phar->compressAllFilesBZIP2();
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressedGZ());
-var_dump($phar['a']->isCompressedBZIP2());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressedGZ());
-var_dump($phar['b']->isCompressedBZIP2());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressedGZ());
-var_dump($phar['b']->isCompressedBZIP2());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(1) "a"
-bool(false)
-bool(true)
-string(1) "b"
-bool(false)
-bool(true)
-string(1) "c"
-bool(false)
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_compressallgz.phpt b/ext/phar/tests/phar_oo_compressallgz.phpt
deleted file mode 100644
index fe962f94c5..0000000000
--- a/ext/phar/tests/phar_oo_compressallgz.phpt
+++ /dev/null
@@ -1,65 +0,0 @@
---TEST--
-Phar::compressAllFilesGZ()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$phar = new Phar($fname);
-$phar->compressAllFilesGZ();
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressedGZ());
-var_dump($phar['a']->isCompressedBZIP2());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressedGZ());
-var_dump($phar['b']->isCompressedBZIP2());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressedGZ());
-var_dump($phar['b']->isCompressedBZIP2());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(1) "a"
-bool(true)
-bool(false)
-string(1) "b"
-bool(true)
-bool(false)
-string(1) "c"
-bool(true)
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_001.phpt b/ext/phar/tests/phar_oo_compressed_001.phpt
deleted file mode 100644
index 803ce8d7b4..0000000000
--- a/ext/phar/tests/phar_oo_compressed_001.phpt
+++ /dev/null
@@ -1,68 +0,0 @@
---TEST--
-Phar::setCompressedGZ()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$phar['a'] = 'new a';
-$phar['a']->setUncompressed();
-$phar['b'] = 'new b';
-$phar['b']->setCompressedGZ();
-$phar['d'] = 'new d';
-
-$phar = new Phar($fname);
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-var_dump(file_get_contents($pname . '/d'));
-var_dump($phar['d']->isCompressed());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(5) "new a"
-bool(false)
-string(5) "new b"
-bool(true)
-string(1) "c"
-bool(false)
-string(5) "new d"
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_001b.phpt b/ext/phar/tests/phar_oo_compressed_001b.phpt
deleted file mode 100755
index e33abb2fa6..0000000000
--- a/ext/phar/tests/phar_oo_compressed_001b.phpt
+++ /dev/null
@@ -1,68 +0,0 @@
---TEST--
-Phar::setCompressedBZip2()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("bz2")) print "skip bz2 not present"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$phar['a'] = 'new a';
-$phar['a']->setUncompressed();
-$phar['b'] = 'new b';
-$phar['b']->setCompressedBZip2();
-$phar['d'] = 'new d';
-
-$phar = new Phar($fname);
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-var_dump(file_get_contents($pname . '/d'));
-var_dump($phar['d']->isCompressed());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(5) "new a"
-bool(false)
-string(5) "new b"
-bool(true)
-string(1) "c"
-bool(false)
-string(5) "new d"
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_002.phpt b/ext/phar/tests/phar_oo_compressed_002.phpt
deleted file mode 100755
index a227904982..0000000000
--- a/ext/phar/tests/phar_oo_compressed_002.phpt
+++ /dev/null
@@ -1,73 +0,0 @@
---TEST--
-Phar: context/compress=GZ
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$context = stream_context_create(array('phar'=>array('compress'=>Phar::GZ)));
-
-file_put_contents($pname . '/b', 'new b');
-file_put_contents($pname . '/c', 'new c', 0, $context);
-file_put_contents($pname . '/d', 'new d');
-file_put_contents($pname . '/e', 'new e', 0, $context);
-
-$phar = new Phar($fname);
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-var_dump(file_get_contents($pname . '/d'));
-var_dump($phar['d']->isCompressed());
-var_dump(file_get_contents($pname . '/e'));
-var_dump($phar['e']->isCompressed());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(1) "a"
-bool(false)
-string(5) "new b"
-bool(false)
-string(5) "new c"
-bool(true)
-string(5) "new d"
-bool(false)
-string(5) "new e"
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_compressed_002b.phpt b/ext/phar/tests/phar_oo_compressed_002b.phpt
deleted file mode 100755
index a0f7008a53..0000000000
--- a/ext/phar/tests/phar_oo_compressed_002b.phpt
+++ /dev/null
@@ -1,73 +0,0 @@
---TEST--
-Phar: context/compress=BZip2
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("bz2")) print "skip bz2 not present"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$context = stream_context_create(array('phar'=>array('compress'=>Phar::BZ2)));
-
-file_put_contents($pname . '/b', 'new b');
-file_put_contents($pname . '/c', 'new c', 0, $context);
-file_put_contents($pname . '/d', 'new d');
-file_put_contents($pname . '/e', 'new e', 0, $context);
-
-$phar = new Phar($fname);
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-var_dump(file_get_contents($pname . '/d'));
-var_dump($phar['d']->isCompressed());
-var_dump(file_get_contents($pname . '/e'));
-var_dump($phar['e']->isCompressed());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(1) "a"
-bool(false)
-string(5) "new b"
-bool(false)
-string(5) "new c"
-bool(true)
-string(5) "new d"
-bool(false)
-string(5) "new e"
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_oo_test.inc b/ext/phar/tests/phar_oo_test.inc
deleted file mode 100755
index 9863e8da93..0000000000
--- a/ext/phar/tests/phar_oo_test.inc
+++ /dev/null
@@ -1,49 +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;
-}
-
-$ftime = mktime(12, 0, 0, 3, 1, 2006);
-include 'phar_test.inc';
-
-?> \ No newline at end of file
diff --git a/ext/phar/tests/phar_oo_uncompressall.phpt b/ext/phar/tests/phar_oo_uncompressall.phpt
deleted file mode 100644
index f72828be69..0000000000
--- a/ext/phar/tests/phar_oo_uncompressall.phpt
+++ /dev/null
@@ -1,79 +0,0 @@
---TEST--
-Phar::uncompressAllFiles()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressed());
-
-$phar = new Phar($fname);
-$phar->compressAllFilesGZ();
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressedGZ());
-var_dump($phar['a']->isCompressedBZIP2());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['b']->isCompressedGZ());
-var_dump($phar['b']->isCompressedBZIP2());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['c']->isCompressedGZ());
-var_dump($phar['b']->isCompressedBZIP2());
-
-$phar->uncompressAllFiles();
-var_dump(file_get_contents($pname . '/a'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/b'));
-var_dump($phar['a']->isCompressed());
-var_dump(file_get_contents($pname . '/c'));
-var_dump($phar['a']->isCompressed());
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-?>
---EXPECTF--
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-string(1) "a"
-bool(true)
-bool(false)
-string(1) "b"
-bool(true)
-bool(false)
-string(1) "c"
-bool(true)
-bool(false)
-string(1) "a"
-bool(false)
-string(1) "b"
-bool(false)
-string(1) "c"
-bool(false)
-===DONE===
diff --git a/ext/phar/tests/phar_setsignaturealgo1.phpt b/ext/phar/tests/phar_setsignaturealgo1.phpt
deleted file mode 100644
index 7aaae500d9..0000000000
--- a/ext/phar/tests/phar_setsignaturealgo1.phpt
+++ /dev/null
@@ -1,69 +0,0 @@
---TEST--
-Phar::setSignatureAlgorithm()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if ( extension_loaded("hash")) print "skip extension hash conflicts"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
-$p['file1.txt'] = 'hi';
-var_dump($p->getSignature());
-$p->setSignatureAlgorithm(Phar::MD5);
-var_dump($p->getSignature());
-$p->setSignatureAlgorithm(Phar::SHA1);
-var_dump($p->getSignature());
-try {
-$p->setSignatureAlgorithm(Phar::SHA256);
-var_dump($p->getSignature());
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-try {
-$p->setSignatureAlgorithm(Phar::SHA512);
-var_dump($p->getSignature());
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-try {
-$p->setSignatureAlgorithm(Phar::PGP);
-var_dump($p->getSignature());
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/brandnewphar.phar');
-?>
---EXPECTF--
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(3) "MD5"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled"
-string (82) "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled"
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-===DONE===
diff --git a/ext/phar/tests/phar_setsignaturealgo2.phpt b/ext/phar/tests/phar_setsignaturealgo2.phpt
deleted file mode 100644
index 47ec0e4ca3..0000000000
--- a/ext/phar/tests/phar_setsignaturealgo2.phpt
+++ /dev/null
@@ -1,79 +0,0 @@
---TEST--
-Phar::setSupportedSignatures() with hash
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("hash")) print "skip extension hash required"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
-$p['file1.txt'] = 'hi';
-var_dump($p->getSignature());
-$p->setSignatureAlgorithm(Phar::MD5);
-var_dump($p->getSignature());
-$p->setSignatureAlgorithm(Phar::SHA1);
-var_dump($p->getSignature());
-try {
-$p->setSignatureAlgorithm(Phar::SHA256);
-var_dump($p->getSignature());
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-try {
-$p->setSignatureAlgorithm(Phar::SHA512);
-var_dump($p->getSignature());
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-try {
-$p->setSignatureAlgorithm(Phar::PGP);
-var_dump($p->getSignature());
-} catch (Exception $e) {
-echo $e->getMessage();
-}
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/brandnewphar.phar');
-?>
---EXPECTF--
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(3) "MD5"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(7) "SHA-256"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(7) "SHA-512"
-}
-array(2) {
- ["hash"]=>
- string(%d) "%s"
- ["hash_type"]=>
- string(5) "SHA-1"
-}
-===DONE===
diff --git a/ext/phar/tests/phar_stub.phpt b/ext/phar/tests/phar_stub.phpt
deleted file mode 100644
index 3cf514b836..0000000000
--- a/ext/phar/tests/phar_stub.phpt
+++ /dev/null
@@ -1,81 +0,0 @@
---TEST--
-Phar::setStub()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$file = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
-$fp = fopen($fname, 'rb');
-//// 1
-echo fread($fp, strlen($file)) . "\n";
-fclose($fp);
-$phar = new Phar($fname);
-$file = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
-
-//// 2
-$phar->setStub($file);
-$fp = fopen($fname, 'rb');
-echo fread($fp, strlen($file)) . "\n";
-fclose($fp);
-
-$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.php';
-$file = '<?php echo "third stub\n"; __HALT_COMPILER(); ?>';
-$fp = fopen($fname2, 'wb');
-fwrite($fp, $file);
-fclose($fp);
-$fp = fopen($fname2, 'rb');
-
-//// 3
-$phar->setStub($fp);
-fclose($fp);
-
-$fp = fopen($fname, 'rb');
-echo fread($fp, strlen($file)) . "\n";
-fclose($fp);
-
-$fp = fopen($fname2, 'ab');
-fwrite($fp, 'booya');
-fclose($fp);
-echo file_get_contents($fname2) . "\n";
-
-$fp = fopen($fname2, 'rb');
-
-//// 4
-$phar->setStub($fp, strlen($file));
-fclose($fp);
-
-$fp = fopen($fname, 'rb');
-echo fread($fp, strlen($file)) . "\n";
-if (fread($fp, strlen('booya')) == 'booya') {
- echo 'failed - copied booya';
-}
-fclose($fp);
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
-__HALT_COMPILER();
-?>
---EXPECT--
-<?php echo "first stub\n"; __HALT_COMPILER(); ?>
-<?php echo "second stub\n"; __HALT_COMPILER(); ?>
-<?php echo "third stub\n"; __HALT_COMPILER(); ?>
-<?php echo "third stub\n"; __HALT_COMPILER(); ?>booya
-<?php echo "third stub\n"; __HALT_COMPILER(); ?>
-===DONE===
diff --git a/ext/phar/tests/phar_stub_error.phpt b/ext/phar/tests/phar_stub_error.phpt
deleted file mode 100755
index 84dbbc6f3b..0000000000
--- a/ext/phar/tests/phar_stub_error.phpt
+++ /dev/null
@@ -1,56 +0,0 @@
---TEST--
-Phar::setStub()/getStub()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
-$file = $stub;
-
-$files = array();
-$files['a'] = 'a';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-var_dump($stub);
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-
-$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
-try
-{
- $phar->setStub($newstub);
-}
-catch(exception $e)
-{
- echo 'Exception: ' . $e->getMessage() . "\n";
-}
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-$phar->stopBuffering();
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-__HALT_COMPILER();
-?>
---EXPECTF--
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-bool(true)
-Exception: illegal stub for phar "%sphar_stub_error.phar.php"
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-bool(true)
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_stub_write.phpt b/ext/phar/tests/phar_stub_write.phpt
deleted file mode 100755
index 2ea475bcf4..0000000000
--- a/ext/phar/tests/phar_stub_write.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---TEST--
-Phar::setStub()/getStub()
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
-$file = $stub;
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-var_dump($stub);
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-
-$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
-$sexp = $stub . "\r\n";
-
-$phar->setStub($stub);
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-var_dump($phar->getStub() == $sexp);
-$phar->stopBuffering();
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-var_dump($phar->getStub() == $sexp);
-
-$phar = new Phar($fname);
-var_dump($phar->getStub() == $stub);
-var_dump($phar->getStub() == $sexp);
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-__HALT_COMPILER();
-?>
---EXPECT--
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-bool(true)
-string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
-"
-bool(false)
-bool(true)
-string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
-"
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_stub_write_file.phpt b/ext/phar/tests/phar_stub_write_file.phpt
deleted file mode 100755
index dbc4b8b8b5..0000000000
--- a/ext/phar/tests/phar_stub_write_file.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---TEST--
-Phar::setStub()/getStub() from file
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.require_hash=0
-phar.readonly=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
-$file = $stub;
-
-$files = array();
-$files['a'] = 'a';
-$files['b'] = 'b';
-$files['c'] = 'c';
-
-include 'phar_test.inc';
-
-$phar = new Phar($fname);
-var_dump($stub);
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-
-$stub = '<?php echo "second stub\n"; __HALT_COMPILER(); ?>';
-$sexp = $stub . "\r\n";
-$stub = fopen('data://,'.$stub, 'r');
-$phar->setStub($stub);
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-var_dump($phar->getStub() == $sexp);
-$phar->stopBuffering();
-var_dump($phar->getStub());
-var_dump($phar->getStub() == $stub);
-var_dump($phar->getStub() == $sexp);
-
-$phar = new Phar($fname);
-var_dump($phar->getStub() == $stub);
-var_dump($phar->getStub() == $sexp);
-
-?>
-===DONE===
---CLEAN--
-<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-__HALT_COMPILER();
-?>
---EXPECT--
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-bool(true)
-string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
-"
-bool(false)
-bool(true)
-string(51) "<?php echo "second stub\n"; __HALT_COMPILER(); ?>
-"
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-===DONE===
diff --git a/ext/phar/tests/phar_test.inc b/ext/phar/tests/phar_test.inc
deleted file mode 100755
index 213e95558c..0000000000
--- a/ext/phar/tests/phar_test.inc
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-if (function_exists('date_default_timezone_set')) {
- date_default_timezone_set('UTC');
-}
-
-$manifest = '';
-$glags = 0;
-
-foreach($files as $name => $cont)
-{
- global $gflags, $files;
-
- $comp = NULL;
- $crc32= NULL;
- $clen = NULL;
- $ulen = NULL;
- $time = isset($ftime) ? $ftime : @mktime(12, 0, 0, 3, 1, 2006);
- $flags= 0;
- $perm = 0x000001B6;
- $meta = NULL;
-
- // overwrite if array
- if (is_array($cont))
- {
- foreach(array('comp','crc32','clen','ulen','time','flags','perm','meta','cont') as $what)
- {
- if (isset($cont[$what]))
- {
- $$what = $cont[$what];
- }
- }
- }
-
- // create if not yet done
- if (empty($comp)) $comp = $cont;
- if (empty($ulen)) $ulen = strlen($cont);
- if (empty($clen)) $clen = strlen($comp);
- if (empty($crc32))$crc32= crc32($cont);
- if (isset($meta)) $meta = serialize($meta);
-
- // write manifest entry
- $manifest .= pack('V', strlen($name)) . $name;
- $manifest .= pack('VVVVVV', $ulen, $time, $clen, $crc32, $flags|$perm, strlen($meta)) . $meta;
-
- // globals
- $gflags |= $flags;
- $files[$name] = $comp;
-}
-
-$alias = 'hio';
-
-if (isset($pmeta)) $pmeta = serialize($pmeta); else $pmeta = '';
-$manifest = pack('VnVV', count($files), 0x1000, $glags, strlen($alias)) . $alias . pack('V', strlen($pmeta)) . $pmeta . $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/ext/phar/tests/refcount1.phpt b/ext/phar/tests/refcount1.phpt
deleted file mode 100644
index 3025fb2bde..0000000000
--- a/ext/phar/tests/refcount1.phpt
+++ /dev/null
@@ -1,53 +0,0 @@
---TEST--
-Phar: test that refcounting avoids problems with deleting a file
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
-<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---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"; ?>';
-$files['b.php'] = '<?php echo "This is b\n"; ?>';
-$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-include 'phar_test.inc';
-
-$fp = fopen($pname . '/b/c.php', 'wb');
-fwrite($fp, "extra");
-fclose($fp);
-echo "===CLOSE===\n";
-$p = new Phar($fname);
-$b = fopen($pname . '/b/c.php', 'rb');
-$a = $p['b/c.php'];
-var_dump($a);
-var_dump(fread($b, 20));
-rewind($b);
-echo "===UNLINK===\n";
-unlink($pname . '/b/c.php');
-var_dump($a);
-var_dump(fread($b, 20));
-include $pname . '/b/c.php';
-?>
-
-===DONE===
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-===CLOSE===
-object(PharFileInfo)#%d (0) {
-}
-string(5) "extra"
-===UNLINK===
-
-Warning: unlink(): phar error: "b/c.php" in phar "%sefcount1.phar.php", has open file pointers, cannot unlink in %sefcount1.php on line %d
-object(PharFileInfo)#%d (0) {
-}
-string(5) "extra"
-extra
-===DONE===
diff --git a/ext/phar/tests/rename.phpt b/ext/phar/tests/rename.phpt
deleted file mode 100644
index 6d3cc2c137..0000000000
--- a/ext/phar/tests/rename.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-Phar: rename test
---SKIPIF--
-<?php if (!extension_loaded("phar")) print "skip"; ?>
---INI--
-phar.readonly=0
-phar.require_hash=0
---FILE--
-<?php
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
-Phar::mapPhar('hio');
-__HALT_COMPILER(); ?>";
-
-$files = array();
-$files['a'] = 'a';
-include 'phar_test.inc';
-include $fname;
-
-echo file_get_contents($pname . '/a') . "\n";
-rename($pname . '/a', $pname . '/b');
-echo file_get_contents($pname . '/b') . "\n";
-echo file_get_contents($pname . '/a') . "\n";
-?>
---CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
---EXPECTF--
-a
-a
-
-Warning: file_get_contents(phar://%srename.phar.php/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d \ 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
-
-
-
-
-
-
-