mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-11 03:00:49 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62e263f01e |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
dbplus
|
||||
Hartmut Holzgraefe
|
||||
@@ -0,0 +1,5 @@
|
||||
this extension is experimental,
|
||||
its functions may change their names
|
||||
or move to extension all together
|
||||
so do not rely to much on them
|
||||
you have been warned!
|
||||
@@ -0,0 +1,3 @@
|
||||
experimental db++ extension
|
||||
for more information on db++ see
|
||||
http://www.concept-asa.de
|
||||
@@ -0,0 +1,47 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
PHP_ARG_WITH(dbplus, for dbplus support,
|
||||
[ --with-dbplus Include dbplus support])
|
||||
|
||||
if test "$PHP_DBPLUS" != "no"; then
|
||||
# --with-dbplus -> check with-path
|
||||
SEARCH_PATH="/usr/dbplus /usr/local/dbplus /opt/dbplus"
|
||||
SEARCH_FOR="/include/dbconfig.h"
|
||||
if test -r $PHP_DBPLUS/; then # path given as parameter
|
||||
DBPLUS_DIR=$PHP_DBPLUS
|
||||
else # search default path list
|
||||
AC_MSG_CHECKING(for dbplus files in default path)
|
||||
for i in $SEARCH_PATH ; do
|
||||
if test -r $i/$SEARCH_FOR; then
|
||||
DBPLUS_DIR=$i
|
||||
AC_MSG_RESULT(found in $i)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$DBPLUS_DIR"; then
|
||||
AC_MSG_RESULT(not found)
|
||||
AC_MSG_ERROR(Please reinstall the dbplus distribution)
|
||||
fi
|
||||
|
||||
# --with-dbplus -> add include path
|
||||
PHP_ADD_INCLUDE($DBPLUS_DIR/include)
|
||||
|
||||
# --with-dbplus -> chech for lib and symbol presence
|
||||
LIBNAME=Ddb
|
||||
LIBSYMBOL=Db_Init
|
||||
old_LIBS=$LIBS
|
||||
LIBS="-L$DBPLUS_DIR/lib -lm -ldl -lDmacc -lDracc"
|
||||
AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_DBPLUSLIB,1,[ ])],
|
||||
[AC_MSG_ERROR(wrong dbplus lib version or lib not found)])
|
||||
LIBS=$old_LIBS
|
||||
|
||||
PHP_SUBST(DBPLUS_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $DBPLUS_DIR/lib, DBPLUS_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(Dmacc, $DBPLUS_DIR/lib, DBPLUS_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(Dracc, $DBPLUS_DIR/lib, DBPLUS_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(dbplus, dbplus.c php_dbplus.c , $ext_shared)
|
||||
fi
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 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: Hartmut Holzgraefe <hartmut@six.de> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "php.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_ini.h"
|
||||
#include "php_dbplus.h"
|
||||
|
||||
#include <saccess.h>
|
||||
#include <relation.h>
|
||||
#include <dblight.h>
|
||||
|
||||
|
||||
/* If you declare any globals in php_dbplus.h uncomment this:
|
||||
ZEND_DECLARE_MODULE_GLOBALS(dbplus)
|
||||
*/
|
||||
|
||||
#ifdef COMPILE_DL_DBPLUS
|
||||
ZEND_GET_MODULE(dbplus)
|
||||
#endif
|
||||
|
||||
|
||||
/* {{{ Resource handling */
|
||||
|
||||
/* True global resources - no need for thread safety here */
|
||||
int le_dbplus_relation;
|
||||
int le_dbplus_tupel;
|
||||
|
||||
void dbplus_destruct_relation(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
relf *conn = (relf *)(rsrc->ptr);
|
||||
|
||||
cdb_close(conn);
|
||||
}
|
||||
|
||||
|
||||
void dbplus_destruct_tupel(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
tuple *t = (tuple *)(rsrc->ptr);
|
||||
|
||||
efree(t);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ function table */
|
||||
|
||||
/* Every user visible function must have an entry in dbplus_functions[].
|
||||
*/
|
||||
function_entry dbplus_functions[] = {
|
||||
PHP_FE(dbplus_add, NULL)
|
||||
PHP_FE(dbplus_aql, NULL)
|
||||
PHP_FE(dbplus_chdir, NULL)
|
||||
PHP_FE(dbplus_close, NULL)
|
||||
PHP_FE(dbplus_curr, NULL)
|
||||
PHP_FE(dbplus_errno, NULL)
|
||||
PHP_FE(dbplus_errcode, NULL)
|
||||
PHP_FE(dbplus_find, NULL)
|
||||
PHP_FE(dbplus_first, NULL)
|
||||
PHP_FE(dbplus_flush, NULL)
|
||||
PHP_FE(dbplus_freealllocks, NULL)
|
||||
PHP_FE(dbplus_freelock, NULL)
|
||||
PHP_FE(dbplus_freerlocks, NULL)
|
||||
PHP_FE(dbplus_getlock, NULL)
|
||||
PHP_FE(dbplus_getunique, NULL)
|
||||
PHP_FE(dbplus_info, NULL)
|
||||
PHP_FE(dbplus_last, NULL)
|
||||
PHP_FE(dbplus_next, NULL)
|
||||
PHP_FE(dbplus_open, NULL)
|
||||
PHP_FE(dbplus_prev, NULL)
|
||||
PHP_FE(dbplus_rchperm, NULL)
|
||||
PHP_FE(dbplus_rcreate, NULL)
|
||||
PHP_FE(dbplus_rcrtexact, NULL)
|
||||
PHP_FE(dbplus_rcrtlike, NULL)
|
||||
PHP_FE(dbplus_resolve, NULL)
|
||||
PHP_FE(dbplus_restorepos, NULL)
|
||||
PHP_FE(dbplus_rkeys, NULL)
|
||||
PHP_FE(dbplus_ropen, NULL)
|
||||
PHP_FE(dbplus_rquery, NULL)
|
||||
PHP_FE(dbplus_rrename, NULL)
|
||||
PHP_FE(dbplus_rsecindex, NULL)
|
||||
PHP_FE(dbplus_runlink, NULL)
|
||||
PHP_FE(dbplus_rzap, NULL)
|
||||
PHP_FE(dbplus_savepos, NULL)
|
||||
PHP_FE(dbplus_setindex, NULL)
|
||||
PHP_FE(dbplus_setindexbynumber, NULL)
|
||||
PHP_FE(dbplus_sql, NULL)
|
||||
PHP_FE(dbplus_tcl, NULL)
|
||||
PHP_FE(dbplus_tremove, NULL)
|
||||
PHP_FE(dbplus_undo, NULL)
|
||||
PHP_FE(dbplus_undoprepare, NULL)
|
||||
PHP_FE(dbplus_unlockrel, NULL)
|
||||
PHP_FE(dbplus_unselect, NULL)
|
||||
PHP_FE(dbplus_update, NULL)
|
||||
PHP_FE(dbplus_xlockrel, NULL)
|
||||
PHP_FE(dbplus_xunlockrel, NULL)
|
||||
{NULL, NULL, NULL} /* Must be the last line in dbplus_functions[] */
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ module entry */
|
||||
|
||||
zend_module_entry dbplus_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"dbplus",
|
||||
dbplus_functions,
|
||||
PHP_MINIT(dbplus),
|
||||
PHP_MSHUTDOWN(dbplus),
|
||||
PHP_RINIT(dbplus), /* Replace with NULL if there's nothing to do at request start */
|
||||
PHP_RSHUTDOWN(dbplus), /* Replace with NULL if there's nothing to do at request end */
|
||||
PHP_MINFO(dbplus),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ ini parameters */
|
||||
|
||||
/* Remove comments and fill if you need to have entries in php.ini
|
||||
PHP_INI_BEGIN()
|
||||
PHP_INI_END()
|
||||
*/
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ module init */
|
||||
|
||||
PHP_MINIT_FUNCTION(dbplus)
|
||||
{
|
||||
/* resource id for cdb connections */
|
||||
le_dbplus_relation = zend_register_list_destructors_ex(dbplus_destruct_relation, NULL, "dbplus_relation", module_number);
|
||||
le_dbplus_tupel = zend_register_list_destructors_ex(dbplus_destruct_tupel , NULL, "dbplus_tuple" , module_number);
|
||||
|
||||
/* constants for DBPLUS error codes */
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_NOERR", ERR_NOERR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_DUPLICATE", ERR_DUPLICATE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_EOSCAN", ERR_EOSCAN, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_EMPTY", ERR_EMPTY, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_CLOSE", ERR_CLOSE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_WLOCKED", ERR_WLOCKED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_LOCKED", ERR_LOCKED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_NOLOCK", ERR_NOLOCK, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_READ", ERR_READ, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_WRITE", ERR_WRITE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_CREATE", ERR_CREATE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_LSEEK", ERR_LSEEK, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_LENGTH", ERR_LENGTH, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_OPEN", ERR_OPEN, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_WOPEN", ERR_WOPEN, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_MAGIC", ERR_MAGIC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_VERSION", ERR_VERSION, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_PGSIZE", ERR_PGSIZE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_CRC", ERR_CRC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_PIPE", ERR_PIPE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_NIDX", ERR_NIDX, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_MALLOC", ERR_MALLOC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_NUSERS", ERR_NUSERS, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_PREEXIT", ERR_PREEXIT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_ONTRAP", ERR_ONTRAP, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_PREPROC", ERR_PREPROC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_DBPARSE", ERR_DBPARSE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_DBRUNERR", ERR_DBRUNERR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_DBPREEXIT", ERR_DBPREEXIT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_WAIT", ERR_WAIT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_CORRUPT_TUPLE", ERR_CORRUPT_TUPLE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_WARNING0", ERR_WARNING0, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_PANIC", ERR_PANIC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_FIFO", ERR_FIFO, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_PERM", ERR_PERM, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_TCL", ERR_TCL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_RESTRICTED", ERR_RESTRICTED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_USER", ERR_USER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("DBPLUS_ERR_UNKNOWN", ERR_UNKNOWN, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ module shutdown */
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(dbplus)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ request init */
|
||||
|
||||
/* Remove if there's nothing to do at request start */
|
||||
PHP_RINIT_FUNCTION(dbplus)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ request shutdown */
|
||||
|
||||
/* Remove if there's nothing to do at request end */
|
||||
PHP_RSHUTDOWN_FUNCTION(dbplus)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ module information */
|
||||
|
||||
PHP_MINFO_FUNCTION(dbplus)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "dbplus support", "enabled");
|
||||
php_info_print_table_end();
|
||||
|
||||
/* Remove comments if you have entries in php.ini
|
||||
DISPLAY_INI_ENTRIES();
|
||||
*/
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 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. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_DBPLUS_H
|
||||
#define PHP_DBPLUS_H
|
||||
|
||||
|
||||
extern zend_module_entry dbplus_module_entry;
|
||||
#define phpext_dbplus_ptr &dbplus_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_DBPLUS_API __declspec(dllexport)
|
||||
#else
|
||||
#define PHP_DBPLUS_API
|
||||
#endif
|
||||
|
||||
PHP_MINIT_FUNCTION(dbplus);
|
||||
PHP_MSHUTDOWN_FUNCTION(dbplus);
|
||||
PHP_RINIT_FUNCTION(dbplus);
|
||||
PHP_RSHUTDOWN_FUNCTION(dbplus);
|
||||
PHP_MINFO_FUNCTION(dbplus);
|
||||
|
||||
PHP_FUNCTION(dbplus_add);
|
||||
PHP_FUNCTION(dbplus_aql);
|
||||
PHP_FUNCTION(dbplus_chdir);
|
||||
PHP_FUNCTION(dbplus_close);
|
||||
PHP_FUNCTION(dbplus_curr);
|
||||
PHP_FUNCTION(dbplus_errno);
|
||||
PHP_FUNCTION(dbplus_errcode);
|
||||
PHP_FUNCTION(dbplus_find);
|
||||
PHP_FUNCTION(dbplus_first);
|
||||
PHP_FUNCTION(dbplus_flush);
|
||||
PHP_FUNCTION(dbplus_freealllocks);
|
||||
PHP_FUNCTION(dbplus_freelock);
|
||||
PHP_FUNCTION(dbplus_freerlocks);
|
||||
PHP_FUNCTION(dbplus_getlock);
|
||||
PHP_FUNCTION(dbplus_getunique);
|
||||
PHP_FUNCTION(dbplus_info);
|
||||
PHP_FUNCTION(dbplus_last);
|
||||
PHP_FUNCTION(dbplus_next);
|
||||
PHP_FUNCTION(dbplus_open);
|
||||
PHP_FUNCTION(dbplus_prev);
|
||||
PHP_FUNCTION(dbplus_rchperm);
|
||||
PHP_FUNCTION(dbplus_rcreate);
|
||||
PHP_FUNCTION(dbplus_rcrtexact);
|
||||
PHP_FUNCTION(dbplus_rcrtlike);
|
||||
PHP_FUNCTION(dbplus_resolve);
|
||||
PHP_FUNCTION(dbplus_restorepos);
|
||||
PHP_FUNCTION(dbplus_rkeys);
|
||||
PHP_FUNCTION(dbplus_ropen);
|
||||
PHP_FUNCTION(dbplus_rquery);
|
||||
PHP_FUNCTION(dbplus_rrename);
|
||||
PHP_FUNCTION(dbplus_rsecindex);
|
||||
PHP_FUNCTION(dbplus_runlink);
|
||||
PHP_FUNCTION(dbplus_rzap);
|
||||
PHP_FUNCTION(dbplus_savepos);
|
||||
PHP_FUNCTION(dbplus_setindex);
|
||||
PHP_FUNCTION(dbplus_setindexbynumber);
|
||||
PHP_FUNCTION(dbplus_sql);
|
||||
PHP_FUNCTION(dbplus_tcl);
|
||||
PHP_FUNCTION(dbplus_tremove);
|
||||
PHP_FUNCTION(dbplus_undo);
|
||||
PHP_FUNCTION(dbplus_undoprepare);
|
||||
PHP_FUNCTION(dbplus_unlockrel);
|
||||
PHP_FUNCTION(dbplus_unselect);
|
||||
PHP_FUNCTION(dbplus_update);
|
||||
PHP_FUNCTION(dbplus_xlockrel);
|
||||
PHP_FUNCTION(dbplus_xunlockrel);
|
||||
|
||||
|
||||
/*
|
||||
Declare any global variables you may need between the BEGIN
|
||||
and END macros here:
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(dbplus)
|
||||
int global_variable;
|
||||
ZEND_END_MODULE_GLOBALS(dbplus)
|
||||
*/
|
||||
|
||||
/* In every function that needs to use variables in php_dbplus_globals,
|
||||
do call DBPLUSLS_FETCH(); after declaring other variables used by
|
||||
that function, and always refer to them as DBPLUSG(variable).
|
||||
You are encouraged to rename these macros something shorter, see
|
||||
examples in any other php module directory.
|
||||
*/
|
||||
|
||||
#ifdef ZTS
|
||||
#define AG(v) TSRMG(dbplus_globals_id, php_dbplus_globals *, v)
|
||||
#else
|
||||
#define DBPLUSG(v) (dbplus_globals.v)
|
||||
#endif
|
||||
|
||||
|
||||
int le_dbplus_relation;
|
||||
int le_dbplus_tuple;
|
||||
|
||||
void dbplus_destruct_relation(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||
void dbplus_destruct_tupel(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||
|
||||
|
||||
#endif /* PHP_DBPLUS_H */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Check for dbplus presence
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("dbplus")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
echo "dbplus extension is available";
|
||||
/*
|
||||
you can add regression tests for your extension here
|
||||
|
||||
the output of your test code has to be equal to the
|
||||
text in the --EXPECT-- section below for the tests
|
||||
to pass, differences between the output and the
|
||||
expected text are interpreted as failure
|
||||
|
||||
see php4/tests/README for further information on
|
||||
writing regression tests
|
||||
*/
|
||||
?>
|
||||
--EXPECT--
|
||||
dbplus extension is available
|
||||
@@ -1,2 +0,0 @@
|
||||
phar
|
||||
Gregory Beaver, Marcus Boerger
|
||||
@@ -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>.
|
||||
@@ -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: $(all_targets) $(builddir)/phar.php $(builddir)/phar.phar
|
||||
|
||||
$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php
|
||||
$(SAPI_CLI_PATH) $(srcdir)/build_precommand.php > $(builddir)/phar.php
|
||||
|
||||
$(builddir)/phar.phar: $(builddir)/phar.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php
|
||||
$(SAPI_CLI_PATH) -dphar.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
|
||||
|
||||
@@ -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]
|
||||
X Add Phar::setAlias() [Greg]
|
||||
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
|
||||
@@ -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";
|
||||
|
||||
?>
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
define ___pharglobals
|
||||
if basic_functions_module.zts
|
||||
set $tsrm_ls = ts_resource_ex(0, 0)
|
||||
set $pharglobals = ((zend_executor_globals) (*((void ***) $tsrm_ls))[phar_globals_id-1])
|
||||
else
|
||||
set $pharglobals = phar_globals
|
||||
end
|
||||
end
|
||||
|
||||
define ____print_pharht
|
||||
set $ht = $arg0
|
||||
set $p = $ht.pListHead
|
||||
|
||||
while $p != 0
|
||||
set $i = $ind
|
||||
while $i > 0
|
||||
printf " "
|
||||
set $i = $i - 1
|
||||
end
|
||||
|
||||
set $temp = *(phar_archive_data*)$p->pDataPtr
|
||||
____print_str $temp.fname $temp.fname_len
|
||||
printf " => "
|
||||
|
||||
if $arg1 == 0
|
||||
|
||||
printf "%i (alias ", $temp.refcount
|
||||
____print_str $temp.alias $temp.alias_len
|
||||
printf ")\n"
|
||||
end
|
||||
|
||||
set $p = $p->pListNext
|
||||
end
|
||||
end
|
||||
|
||||
define print_phar
|
||||
set $ind = 1
|
||||
___pharglobals
|
||||
printf "{"
|
||||
____print_pharht $pharglobals.phar_fname_map 0
|
||||
printf "}\n"
|
||||
end
|
||||
|
||||
document print_phar
|
||||
dumps open phars and their aliases
|
||||
end
|
||||
|
||||
define print_pharfp
|
||||
___pharglobals
|
||||
set $ht = $pharglobals.phar_fname_map
|
||||
set $p = $ht.pListHead
|
||||
set $fpcount = 0
|
||||
|
||||
while $p != 0
|
||||
set $pharname = (*(phar_archive_data*)$p->pDataPtr).fname
|
||||
set $pharrefcount = (*(phar_archive_data*)$p->pDataPtr).refcount
|
||||
if (*(phar_archive_data*)$p->pDataPtr).fp != 0
|
||||
set $fpcount = $fpcount + 1
|
||||
printf "phar %s is open (%i)\n", $pharname, $pharrefcount
|
||||
end
|
||||
set $manifest = (*(phar_archive_data*)$p->pDataPtr).manifest
|
||||
set $m = $manifest.pListHead
|
||||
while $m != 0
|
||||
if (*(phar_entry_info *)$m->pData).fp
|
||||
set $fpcount = $fpcount + 1
|
||||
set $a = (*(phar_entry_info *)$m->pData).fp_refcount
|
||||
printf "phar %s file %s is open (%i)\n", $pharname, (*(phar_entry_info *)$m->pData).filename, $a
|
||||
end
|
||||
set $m = $m->pListNext
|
||||
end
|
||||
|
||||
set $p = $p->pListNext
|
||||
end
|
||||
printf "Open file pointers: %d\n", $fpcount
|
||||
end
|
||||
|
||||
document print_pharfp
|
||||
displays all open file pointers in phar, and the phars plus entries that are open with reference counts
|
||||
end
|
||||
|
||||
define dump_entry
|
||||
___pharglobals
|
||||
set $ht = $pharglobals.phar_fname_map
|
||||
set $p = $ht.pListHead
|
||||
set $done = 0
|
||||
while $p != 0
|
||||
set $t = (*(phar_archive_data*)$p->pDataPtr)
|
||||
if $t.fname[0] == $arg0[0] || $t.alias[0] == $arg0[0]
|
||||
set $manifest = (*(phar_archive_data*)$p->pDataPtr).manifest
|
||||
set $m = $manifest.pListHead
|
||||
while $m != 0
|
||||
if (*(phar_entry_info *)$m->pData).filename[0] == $arg1[0]
|
||||
if $argc == 3
|
||||
output *((phar_entry_info *)$m->pData)->fp
|
||||
end
|
||||
if $argc == 2
|
||||
output *(phar_entry_info *)$m->pData
|
||||
end
|
||||
printf "\n"
|
||||
set $done = 1
|
||||
loop_break
|
||||
end
|
||||
set $m = $m->pListNext
|
||||
end
|
||||
end
|
||||
if $done == 1
|
||||
loop_break
|
||||
end
|
||||
set $p = $p->pListNext
|
||||
end
|
||||
end
|
||||
|
||||
document dump_entry
|
||||
dump_entry "pharname"|"pharalias" "filename" [1]
|
||||
display phar_entry_info for a file within a phar. If the optional third param
|
||||
is passed in, displays the php_stream that is the file's fp
|
||||
end
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
$notes = '
|
||||
* fix creation of Phar object with relative path:
|
||||
$a = new Phar(\'blah.phar\');
|
||||
* fix creation and read of Phar objects on Windows, manage
|
||||
windows path separators (on windows only)
|
||||
* phar.phar is now installed as a script, and can be run as "phar.phar"
|
||||
* phar.phar looks for PHP in /usr/local/bin/php by default
|
||||
* fix Bug #12492: filenew incorrectly creates file path [urkle]
|
||||
* fix Bug #12493: extract throws an error and won\'t open the file [urkle]
|
||||
';
|
||||
|
||||
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',
|
||||
'phar.phar' => 'script',
|
||||
),
|
||||
);
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,353 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.7.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>phar</name>
|
||||
<channel>pecl.php.net</channel>
|
||||
<summary>allows running of complete applications out of .phar files (like Java .jar files)</summary>
|
||||
<description>This is the extension version of PEAR's PHP_Archive package. Support for
|
||||
zlib, 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'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-11-22</date>
|
||||
<time>22:56:05</time>
|
||||
<version>
|
||||
<release>1.2.3</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>
|
||||
|
||||
* fix creation of Phar object with relative path:
|
||||
$a = new Phar('blah.phar');
|
||||
* fix creation and read of Phar objects on Windows, manage
|
||||
windows path separators (on windows only)
|
||||
* phar.phar is now installed as a script, and can be run as "phar.phar"
|
||||
* phar.phar looks for PHP in /usr/local/bin/php by default
|
||||
* fix Bug #12492: filenew incorrectly creates file path [urkle]
|
||||
* fix Bug #12493: extract throws an error and won't open the file [urkle]
|
||||
|
||||
</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.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_setalias.phpt" role="test" />
|
||||
<file name="phar_setalias2.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_stub_write_file.phpt" role="test" />
|
||||
<file name="phar_test.inc" role="test" />
|
||||
<file name="refcount1.phpt" role="test" />
|
||||
<file name="refcount1_5_2.phpt" role="test" />
|
||||
<file name="rename.phpt" role="test" />
|
||||
</dir> <!-- /tests -->
|
||||
<file name="build_precommand.php" role="php" />
|
||||
<file name="config.m4" role="src" />
|
||||
<file name="config.w32" role="src" />
|
||||
<file name="CREDITS" role="doc" />
|
||||
<file name="gdbhelp" role="data" />
|
||||
<file name="LICENSE" role="doc" />
|
||||
<file name="Makefile.frag" role="src" />
|
||||
<file name="phar.c" role="src" />
|
||||
<file name="phar.phar" role="script" />
|
||||
<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.3</release>
|
||||
<api>1.1.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2007-11-22</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
|
||||
* fix creation of Phar object with relative path:
|
||||
$a = new Phar('blah.phar');
|
||||
* fix creation and read of Phar objects on Windows, manage
|
||||
windows path separators (on windows only)
|
||||
* phar.phar is now installed as a script, and can be run as "phar.phar"
|
||||
* phar.phar looks for PHP in /usr/local/bin/php by default
|
||||
* fix Bug #12492: filenew incorrectly creates file path [urkle]
|
||||
* fix Bug #12493: extract throws an error and won't open the file [urkle]
|
||||
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.2.2</release>
|
||||
<api>1.1.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2007-10-03</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>* fix to work with PHP 5.3
|
||||
* fix Bug #12124: Phar object cannot be iterated over
|
||||
* remove unused variables
|
||||
* fix jit file open sprintf calls</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.2.1</release>
|
||||
<api>1.1.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2007-08-29</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>* improve speed of uncompressed phars used readonly by 2x [Greg]
|
||||
* improve speed of phars with signatures 2x [Greg]
|
||||
* add Phar::setAlias() [Greg]
|
||||
* fix too many open file handles issue [Greg]
|
||||
* fix rename [Greg]
|
||||
* 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]</notes>
|
||||
</release>
|
||||
<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 '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]
|
||||
* 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->begin/isFlushingToPhar/commit to startBuffering/isBuffering/stopBuffering
|
||||
Note that isBuffering() returns the opposite value to isFlushingToPhar()</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
-3859
File diff suppressed because it is too large.
Load diff
Binary file not shown.
@@ -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 . '/' . basename($arg);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/usr/local/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(); ?>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,305 +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.3"
|
||||
#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 */
|
||||
/* when changing compression, save old flags in case fp is NULL */
|
||||
php_uint32 old_flags;
|
||||
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;
|
||||
/* used when iterating */
|
||||
int is_dir: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;
|
||||
/* for copies of the phar fp, defines where 0 is */
|
||||
off_t zero;
|
||||
int for_write:1;
|
||||
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_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, 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
|
||||
*/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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"
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
@@ -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===
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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===
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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"
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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)
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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"
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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%sunexpected%s in phar://%sphar_oo_test.phar.php/a.php on line %d
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -1 +0,0 @@
|
||||
<?php var_dump(__FILE__); ?>
|
||||
@@ -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===
|
||||
@@ -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"
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -1,46 +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';
|
||||
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--
|
||||
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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
@@ -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===
|
||||
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user