#include "func_interceptors.h"
ZEND_DECLARE_MODULE_GLOBALS(phar)
-int phar_has_bz2;
-int phar_has_zlib;
#if PHP_VERSION_ID >= 50300
char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
#endif
offset += entry.compressed_filesize;
switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
case PHAR_ENT_COMPRESSED_GZ:
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
}
}
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
}
/* to properly decompress, we have to tell zlib to look for a zlib or gzip header */
zval filterparams;
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\" to temporary file, enable zlib extension in php.ini")
}
array_init(&filterparams);
php_stream_filter *filter;
php_stream *temp;
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file, enable bz2 extension in php.ini")
}
/* entire file is bzip-compressed, uncompress to temporary file */
ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL);
REGISTER_INI_ENTRIES();
- phar_has_bz2 = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
- phar_has_zlib = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
phar_orig_compile_file = zend_compile_file;
zend_compile_file = phar_compile_file;
{
if (!PHAR_GLOBALS->request_init)
{
+ PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
+ PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
PHAR_GLOBALS->request_init = 1;
PHAR_GLOBALS->request_ends = 0;
PHAR_GLOBALS->request_done = 0;
PHP_MINFO_FUNCTION(phar) /* {{{ */
{
+ phar_request_initialize(TSRMLS_C);
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", PHP_PHAR_VERSION);
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
- if (phar_has_zlib) {
+ if (PHAR_G(has_zlib)) {
php_info_print_table_row(2, "gzip compression", "enabled");
} else {
php_info_print_table_row(2, "gzip compression", "disabled (install ext/zlib)");
}
- if (phar_has_bz2) {
+ if (PHAR_G(has_bz2)) {
php_info_print_table_row(2, "bzip2 compression", "enabled");
} else {
php_info_print_table_row(2, "bzip2 compression", "disabled (install pecl/bz2)");
*/
static zend_module_dep phar_deps[] = {
ZEND_MOD_OPTIONAL("apc")
- ZEND_MOD_OPTIONAL("zlib")
- ZEND_MOD_OPTIONAL("bz2")
#if HAVE_SPL
ZEND_MOD_REQUIRED("spl")
#endif
return;
}
+ phar_request_initialize(TSRMLS_C);
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
- if (phar_has_zlib) {
+ if (PHAR_G(has_zlib)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
case PHAR_ENT_COMPRESSED_BZ2:
- if (phar_has_bz2) {
+ if (PHAR_G(has_bz2)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
default:
- if (phar_has_zlib || phar_has_bz2) {
+ if (PHAR_G(has_zlib) || PHAR_G(has_bz2)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
{
array_init(return_value);
- if (phar_has_zlib) {
+ phar_request_initialize(TSRMLS_C);
+ if (PHAR_G(has_zlib)) {
add_next_index_stringl(return_value, "GZ", 2, 1);
}
- if (phar_has_bz2) {
+ if (PHAR_G(has_bz2)) {
add_next_index_stringl(return_value, "BZIP2", 5, 1);
}
}
"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
*(int *) argument = 0;
}
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
*(int *) argument = 0;
}
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress files within archive with gzip, enable ext/zlib in php.ini");
return;
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress files within archive with bz2, enable ext/bz2 in php.ini");
return;
return;
}
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with gzip compression, file is already compressed with bzip2 compression and bz2 extension is not enabled, cannot decompress");
return;
return;
}
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with gzip compression, zlib extension is not enabled");
return;
return;
}
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with bzip2 compression, file is already compressed with gzip compression and zlib extension is not enabled, cannot decompress");
return;
return;
}
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with bzip2 compression, bz2 extension is not enabled");
return;
"Cannot compress deleted file");
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !phar_has_zlib) {
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot decompress Gzip-compressed file, zlib extension is not enabled");
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !phar_has_bz2) {
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot decompress Bzip2-compressed file, bz2 extension is not enabled");
return;