mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-10 02:30:50 +00:00
Compare commits
67
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db7b5b196a | ||
|
|
fff93cdb7f | ||
|
|
0230c72c0f | ||
|
|
706aac5cb0 | ||
|
|
5c1b52a8e7 | ||
|
|
0a925c90d4 | ||
|
|
a4b685078b | ||
|
|
4959eb1b5f | ||
|
|
20ad0b9668 | ||
|
|
902f9d52cf | ||
|
|
1da45c2873 | ||
|
|
7de1333bb2 | ||
|
|
c111b20564 | ||
|
|
b6a9bdfb4f | ||
|
|
e145ab54da | ||
|
|
49a1413f50 | ||
|
|
395478d363 | ||
|
|
e40f99303c | ||
|
|
247f707d55 | ||
|
|
437c556926 | ||
|
|
a007611a4f | ||
|
|
f9073ef5a0 | ||
|
|
d478d178bf | ||
|
|
230aea0ff8 | ||
|
|
8080b6bbd3 | ||
|
|
3d08abbc77 | ||
|
|
d8e9ed9ada | ||
|
|
289fb87a5e | ||
|
|
6b642ebfc5 | ||
|
|
985f1c2c60 | ||
|
|
605e6aa687 | ||
|
|
c10af70d05 | ||
|
|
e5183a19e5 | ||
|
|
16a02bafc2 | ||
|
|
e736c01e44 | ||
|
|
96320611a3 | ||
|
|
ae2e30d461 | ||
|
|
20590a100b | ||
|
|
cd7461d5f1 | ||
|
|
ed150e2312 | ||
|
|
cd9a7fe277 | ||
|
|
a508453b1c | ||
|
|
b10c1ea433 | ||
|
|
879184bd6d | ||
|
|
02de761345 | ||
|
|
7a6246385f | ||
|
|
ca4116ace5 | ||
|
|
05910c2415 | ||
|
|
5a482f71e3 | ||
|
|
70b9e3ba14 | ||
|
|
8347c1a487 | ||
|
|
bcd4c34c9b | ||
|
|
8f8421714b | ||
|
|
c987b05b70 | ||
|
|
058c419fd2 | ||
|
|
8a6d3f31a7 | ||
|
|
2b7d0b008f | ||
|
|
5b7ee0399f | ||
|
|
fd987209eb | ||
|
|
a01c31f949 | ||
|
|
f38261cb0d | ||
|
|
1b69324b83 | ||
|
|
be2bbbf1fb | ||
|
|
fafae95684 | ||
|
|
0d9e627878 | ||
|
|
dd1ee78e9e | ||
|
|
ab4de7dc9e |
No files matched your search
@@ -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,25 +0,0 @@
|
||||
|
||||
$(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
|
||||
$(RE2C) -b -o $(srcdir)/phar_path_check.c $(srcdir)/phar_path_check.re)
|
||||
|
||||
pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
|
||||
|
||||
$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
|
||||
if test -x "$(PHP_EXECUTABLE)"; then \
|
||||
export PHP="$(PHP_EXECUTABLE)"; \
|
||||
else \
|
||||
export PHP="$(top_builddir)/$(SAPI_CLI_PATH)"; \
|
||||
fi; \
|
||||
$$PHP $(srcdir)/build_precommand.php > $(builddir)/phar.php
|
||||
|
||||
$(builddir)/phar.phar: $(builddir)/phar.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
|
||||
if test -x "$(PHP_EXECUTABLE)"; then \
|
||||
export PHP="$(PHP_EXECUTABLE)"; \
|
||||
export BANG="$(PHP_EXECUTABLE)"; \
|
||||
else \
|
||||
export PHP="$(top_builddir)/$(SAPI_CLI_PATH)"; \
|
||||
export BANG="$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)"; \
|
||||
fi; \
|
||||
$$PHP -d phar.readonly=0 $(srcdir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x CVS -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$$BANG" $(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);
|
||||
X Phar::delete($what) [Greg]
|
||||
* 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,14 +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 phar2.c phar2_openhash.c, $ext_shared)
|
||||
PHP_ADD_EXTENSION_DEP(phar, zlib, false)
|
||||
PHP_ADD_EXTENSION_DEP(phar, bz2, false)
|
||||
PHP_ADD_EXTENSION_DEP(phar, spl, false)
|
||||
PHP_ADD_EXTENSION_DEP(phar, gnupg, false)
|
||||
PHP_ADD_MAKEFILE_FRAGMENT
|
||||
fi
|
||||
@@ -1,12 +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', false);
|
||||
ADD_EXTENSION_DEP('phar', 'bz2', false);
|
||||
ADD_EXTENSION_DEP('phar', 'spl', false);
|
||||
ADD_EXTENSION_DEP('phar', 'gnupg', 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,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
$notes = '
|
||||
* add Phar::delete() [Greg]
|
||||
';
|
||||
|
||||
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,319 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.6.2" 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-08-24</date>
|
||||
<time>20:06:43</time>
|
||||
<version>
|
||||
<release>1.2.1</release>
|
||||
<api>1.1.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
|
||||
* 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>
|
||||
<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" />
|
||||
<file name="phar.phar" role="php" />
|
||||
</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="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="data" />
|
||||
<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.1</release>
|
||||
<api>1.1.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2007-08-24</date>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
|
||||
* 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>
|
||||
-3958
File diff suppressed because it is too large.
Load diff
@@ -1,948 +0,0 @@
|
||||
<?php if (!class_exists('PHP_Archive')) {
|
||||
?><?php
|
||||
/**
|
||||
* PHP_Archive Class (implements .phar)
|
||||
*
|
||||
* @package PHP_Archive
|
||||
* @category PHP
|
||||
*/
|
||||
/**
|
||||
* PHP_Archive Class (implements .phar)
|
||||
*
|
||||
* PHAR files a singular archive from which an entire application can run.
|
||||
* To use it, simply package it using {@see PHP_Archive_Creator} and use phar://
|
||||
* URIs to your includes. i.e. require_once 'phar://config.php' will include config.php
|
||||
* from the root of the PHAR file.
|
||||
*
|
||||
* Gz code borrowed from the excellent File_Archive package by Vincent Lascaux.
|
||||
*
|
||||
* @copyright Copyright David Shafik and Synaptic Media 2004. All rights reserved.
|
||||
* @author Davey Shafik <davey@synapticmedia.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @link http://www.synapticmedia.net Synaptic Media
|
||||
* @version $Id: Archive.php,v 1.38 2007/02/06 04:31:45 cellog Exp $
|
||||
* @package PHP_Archive
|
||||
* @category PHP
|
||||
*/
|
||||
|
||||
class PHP_Archive
|
||||
{
|
||||
const GZ = 0x00001000;
|
||||
const BZ2 = 0x00002000;
|
||||
const SIG = 0x00010000;
|
||||
const SHA1 = 0x0002;
|
||||
const MD5 = 0x0001;
|
||||
/**
|
||||
* Whether this archive is compressed with zlib
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_compressed;
|
||||
/**
|
||||
* @var string Real path to the .phar archive
|
||||
*/
|
||||
private $_archiveName = null;
|
||||
/**
|
||||
* Current file name in the phar
|
||||
* @var string
|
||||
*/
|
||||
protected $currentFilename = null;
|
||||
/**
|
||||
* Length of current file in the phar
|
||||
* @var string
|
||||
*/
|
||||
protected $internalFileLength = null;
|
||||
/**
|
||||
* Current file statistics (size, creation date, etc.)
|
||||
* @var string
|
||||
*/
|
||||
protected $currentStat = null;
|
||||
/**
|
||||
* @var resource|null Pointer to open .phar
|
||||
*/
|
||||
protected $fp = null;
|
||||
/**
|
||||
* @var int Current Position of the pointer
|
||||
*/
|
||||
protected $position = 0;
|
||||
|
||||
/**
|
||||
* Map actual realpath of phars to meta-data about the phar
|
||||
*
|
||||
* Data is indexed by the alias that is used by internal files. In other
|
||||
* words, if a file is included via:
|
||||
* <code>
|
||||
* require_once 'phar://PEAR.phar/PEAR/Installer.php';
|
||||
* </code>
|
||||
* then the alias is "PEAR.phar"
|
||||
*
|
||||
* Information stored is a boolean indicating whether this .phar is compressed
|
||||
* with zlib, another for bzip2, phar-specific meta-data, and
|
||||
* the precise offset of internal files
|
||||
* within the .phar, used with the {@link $_manifest} to load actual file contents
|
||||
* @var array
|
||||
*/
|
||||
private static $_pharMapping = array();
|
||||
/**
|
||||
* Map real file paths to alias used
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_pharFiles = array();
|
||||
/**
|
||||
* File listing for the .phar
|
||||
*
|
||||
* The manifest is indexed per phar.
|
||||
*
|
||||
* Files within the .phar are indexed by their relative path within the
|
||||
* .phar. Each file has this information in its internal array
|
||||
*
|
||||
* - 0 = uncompressed file size
|
||||
* - 1 = timestamp of when file was added to phar
|
||||
* - 2 = offset of file within phar relative to internal file's start
|
||||
* - 3 = compressed file size (actual size in the phar)
|
||||
* @var array
|
||||
*/
|
||||
private static $_manifest = array();
|
||||
/**
|
||||
* Absolute offset of internal files within the .phar, indexed by absolute
|
||||
* path to the .phar
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_fileStart = array();
|
||||
/**
|
||||
* file name of the phar
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_basename;
|
||||
|
||||
/**
|
||||
* Allows loading an external Phar archive without include()ing it
|
||||
*
|
||||
* @param string $file
|
||||
* @throws Exception
|
||||
*/
|
||||
public static final function loadPhar($file)
|
||||
{
|
||||
$file = realpath($file);
|
||||
if ($file) {
|
||||
$fp = fopen($file, 'rb');
|
||||
$buffer = '';
|
||||
while (!$found && !feof($fp)) {
|
||||
$buffer .= fread($fp, 8192);
|
||||
// don't break phars
|
||||
if ($pos = strpos($buffer, '__HALT_COMPI' . 'LER();')) {
|
||||
fclose($fp);
|
||||
return self::_mapPhar($file, $pos);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a full real file path to an alias used to refer to the .phar
|
||||
*
|
||||
* This function can only be called from the initialization of the .phar itself.
|
||||
* Any attempt to call from outside the .phar or to re-alias the .phar will fail
|
||||
* as a security measure.
|
||||
* @param string $file full realpath() filepath, like /path/to/go-pear.phar
|
||||
* @param string $alias alias used in opening a file within the phar
|
||||
* like phar://go-pear.phar/file
|
||||
* @param bool $compressed determines whether to attempt zlib uncompression
|
||||
* on accessing internal files
|
||||
* @param int $dataoffset the value of __COMPILER_HALT_OFFSET__
|
||||
*/
|
||||
public static final function mapPhar($file, $dataoffset)
|
||||
{
|
||||
try {
|
||||
// this ensures that this is safe
|
||||
if (!in_array($file, get_included_files())) {
|
||||
die('SECURITY ERROR: PHP_Archive::mapPhar can only be called from within ' .
|
||||
'the phar that initiates it');
|
||||
}
|
||||
self::_mapPhar($file, $dataoffset);
|
||||
} catch (Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sub-function, allows recovery from errors
|
||||
*
|
||||
* @param unknown_type $file
|
||||
* @param unknown_type $dataoffset
|
||||
*/
|
||||
private static function _mapPhar($file, $dataoffset)
|
||||
{
|
||||
$file = realpath($file);
|
||||
if (isset(self::$_manifest[$file])) {
|
||||
return;
|
||||
}
|
||||
if (!is_array(self::$_pharMapping)) {
|
||||
self::$_pharMapping = array();
|
||||
}
|
||||
$fp = fopen($file, 'rb');
|
||||
// seek to __HALT_COMPILER_OFFSET__
|
||||
fseek($fp, $dataoffset);
|
||||
$manifest_length = unpack('Vlen', fread($fp, 4));
|
||||
$manifest = '';
|
||||
$last = '1';
|
||||
while (strlen($last) && strlen($manifest) < $manifest_length['len']) {
|
||||
$read = 8192;
|
||||
if ($manifest_length['len'] - strlen($manifest) < 8192) {
|
||||
$read = $manifest_length['len'] - strlen($manifest);
|
||||
}
|
||||
$last = fread($fp, $read);
|
||||
$manifest .= $last;
|
||||
}
|
||||
if (strlen($manifest) < $manifest_length['len']) {
|
||||
throw new Exception('ERROR: manifest length read was "' .
|
||||
strlen($manifest) .'" should be "' .
|
||||
$manifest_length['len'] . '"');
|
||||
}
|
||||
$info = self::_unserializeManifest($manifest);
|
||||
if ($info['alias']) {
|
||||
$alias = $info['alias'];
|
||||
$explicit = true;
|
||||
} else {
|
||||
$alias = $file;
|
||||
$explicit = false;
|
||||
}
|
||||
self::$_manifest[$file] = $info['manifest'];
|
||||
$compressed = $info['compressed'];
|
||||
self::$_fileStart[$file] = ftell($fp);
|
||||
fclose($fp);
|
||||
if ($compressed & 0x00001000) {
|
||||
if (!function_exists('gzinflate')) {
|
||||
throw new Exception('Error: zlib extension is not enabled - gzinflate() function needed' .
|
||||
' for compressed .phars');
|
||||
}
|
||||
}
|
||||
if ($compressed & 0x00002000) {
|
||||
if (!function_exists('bzdecompress')) {
|
||||
throw new Exception('Error: bzip2 extension is not enabled - bzdecompress() function needed' .
|
||||
' for compressed .phars');
|
||||
}
|
||||
}
|
||||
if (isset(self::$_pharMapping[$alias])) {
|
||||
throw new Exception('ERROR: PHP_Archive::mapPhar has already been called for alias "' .
|
||||
$alias . '" cannot re-alias to "' . $file . '"');
|
||||
}
|
||||
self::$_pharMapping[$alias] = array($file, $compressed, $dataoffset, $explicit,
|
||||
$info['metadata']);
|
||||
self::$_pharFiles[$file] = $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* extract the manifest into an internal array
|
||||
*
|
||||
* @param string $manifest
|
||||
* @return false|array
|
||||
*/
|
||||
private static function _unserializeManifest($manifest)
|
||||
{
|
||||
// retrieve the number of files in the manifest
|
||||
$info = unpack('V', substr($manifest, 0, 4));
|
||||
$apiver = substr($manifest, 4, 2);
|
||||
$apiver = bin2hex($apiver);
|
||||
$apiver_dots = hexdec($apiver[0]) . '.' . hexdec($apiver[1]) . '.' . hexdec($apiver[2]);
|
||||
$majorcompat = hexdec($apiver[0]);
|
||||
$calcapi = explode('.', '1.0.0');
|
||||
if ($calcapi[0] != $majorcompat) {
|
||||
throw new Exception('Phar is incompatible API version ' . $apiver_dots . ', but ' .
|
||||
'PHP_Archive is API version 1.0.0');
|
||||
}
|
||||
if ($calcapi[0] === '0') {
|
||||
if ('1.0.0' != $apiver_dots) {
|
||||
throw new Exception('Phar is API version ' . $apiver_dots .
|
||||
', but PHP_Archive is API version 1.0.0', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
$flags = unpack('V', substr($manifest, 6, 4));
|
||||
$ret = array('compressed' => $flags & 0x00003000);
|
||||
// signature is not verified by default in PHP_Archive, phar is better
|
||||
$ret['hassignature'] = $flags & 0x00010000;
|
||||
$aliaslen = unpack('V', substr($manifest, 10, 4));
|
||||
if ($aliaslen) {
|
||||
$ret['alias'] = substr($manifest, 14, $aliaslen[1]);
|
||||
} else {
|
||||
$ret['alias'] = false;
|
||||
}
|
||||
$manifest = substr($manifest, 14 + $aliaslen[1]);
|
||||
$metadatalen = unpack('V', substr($manifest, 0, 4));
|
||||
if ($metadatalen[1]) {
|
||||
$ret['metadata'] = unserialize(substr($manifest, 4, $metadatalen[1]));
|
||||
$manifest = substr($manifest, 4 + $metadatalen[1]);
|
||||
} else {
|
||||
$ret['metadata'] = null;
|
||||
$manifest = substr($manifest, 4);
|
||||
}
|
||||
$offset = 0;
|
||||
$start = 0;
|
||||
for ($i = 0; $i < $info[1]; $i++) {
|
||||
// length of the file name
|
||||
$len = unpack('V', substr($manifest, $start, 4));
|
||||
$start += 4;
|
||||
// file name
|
||||
$savepath = substr($manifest, $start, $len[1]);
|
||||
$start += $len[1];
|
||||
// retrieve manifest data:
|
||||
// 0 = uncompressed file size
|
||||
// 1 = timestamp of when file was added to phar
|
||||
// 2 = compressed filesize
|
||||
// 3 = crc32
|
||||
// 4 = flags
|
||||
// 5 = metadata length
|
||||
$ret['manifest'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($manifest, $start, 24)));
|
||||
$ret['manifest'][$savepath][3] = sprintf('%u', $ret['manifest'][$savepath][3]);
|
||||
if ($ret['manifest'][$savepath][5]) {
|
||||
$ret['manifest'][$savepath][6] = unserialize(substr($manifest, $start + 24,
|
||||
$ret['manifest'][$savepath][5]));
|
||||
} else {
|
||||
$ret['manifest'][$savepath][6] = null;
|
||||
}
|
||||
$ret['manifest'][$savepath][7] = $offset;
|
||||
$offset += $ret['manifest'][$savepath][2];
|
||||
$start += 24 + $ret['manifest'][$savepath][5];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
private static function processFile($path)
|
||||
{
|
||||
if ($path == '.') {
|
||||
return '';
|
||||
}
|
||||
$std = str_replace("\\", "/", $path);
|
||||
while ($std != ($std = ereg_replace("[^\/:?]+/\.\./", "", $std))) ;
|
||||
$std = str_replace("/./", "", $std);
|
||||
if (strlen($std) > 1 && $std[0] == '/') {
|
||||
$std = substr($std, 1);
|
||||
}
|
||||
if (strncmp($std, "./", 2) == 0) {
|
||||
return substr($std, 2);
|
||||
} else {
|
||||
return $std;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek in the master archive to a matching file or directory
|
||||
* @param string
|
||||
*/
|
||||
protected function selectFile($path, $allowdirs = true)
|
||||
{
|
||||
$std = self::processFile($path);
|
||||
if (isset(self::$_manifest[$this->_archiveName][$path])) {
|
||||
$this->_setCurrentFile($path);
|
||||
return true;
|
||||
}
|
||||
if (!$allowdirs) {
|
||||
return 'Error: "' . $path . '" is not a file in phar "' . $this->_basename . '"';
|
||||
}
|
||||
foreach (self::$_manifest[$this->_archiveName] as $file => $info) {
|
||||
if (empty($std) ||
|
||||
//$std is a directory
|
||||
strncmp($std.'/', $path, strlen($std)+1) == 0) {
|
||||
$this->currentFilename = $this->internalFileLength = $this->currentStat = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return 'Error: "' . $path . '" not found in phar "' . $this->_basename . '"';
|
||||
}
|
||||
|
||||
private function _setCurrentFile($path)
|
||||
{
|
||||
$this->currentStat = array(
|
||||
2 => 0100444, // file mode, readable by all, writeable by none
|
||||
4 => 0, // uid
|
||||
5 => 0, // gid
|
||||
7 => self::$_manifest[$this->_archiveName][$path][0], // size
|
||||
9 => self::$_manifest[$this->_archiveName][$path][1], // creation time
|
||||
);
|
||||
$this->currentFilename = $path;
|
||||
$this->internalFileLength = self::$_manifest[$this->_archiveName][$path][2];
|
||||
// seek to offset of file header within the .phar
|
||||
if (is_resource(@$this->fp)) {
|
||||
fseek($this->fp, self::$_fileStart[$this->_archiveName] + self::$_manifest[$this->_archiveName][$path][7]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek to a file within the master archive, and extract its contents
|
||||
* @param string
|
||||
* @return array|string an array containing an error message string is returned
|
||||
* upon error, otherwise the file contents are returned
|
||||
*/
|
||||
public function extractFile($path)
|
||||
{
|
||||
$this->fp = @fopen($this->_archiveName, "rb");
|
||||
if (!$this->fp) {
|
||||
return array('Error: cannot open phar "' . $this->_archiveName . '"');
|
||||
}
|
||||
if (($e = $this->selectFile($path, false)) === true) {
|
||||
$data = '';
|
||||
$count = $this->internalFileLength;
|
||||
while ($count) {
|
||||
if ($count < 8192) {
|
||||
$data .= @fread($this->fp, $count);
|
||||
$count = 0;
|
||||
} else {
|
||||
$count -= 8192;
|
||||
$data .= @fread($this->fp, 8192);
|
||||
}
|
||||
}
|
||||
@fclose($this->fp);
|
||||
if (self::$_manifest[$this->_archiveName][$path][4] & self::GZ) {
|
||||
$data = gzinflate($data);
|
||||
} elseif (self::$_manifest[$this->_archiveName][$path][4] & self::BZ2) {
|
||||
$data = bzdecompress($data);
|
||||
}
|
||||
if (!isset(self::$_manifest[$this->_archiveName][$path]['ok'])) {
|
||||
if (strlen($data) != $this->currentStat[7]) {
|
||||
return array("Not valid internal .phar file (size error {$size} != " .
|
||||
$this->currentStat[7] . ")");
|
||||
}
|
||||
if (self::$_manifest[$this->_archiveName][$path][3] != sprintf("%u", crc32($data))) {
|
||||
return array("Not valid internal .phar file (checksum error)");
|
||||
}
|
||||
self::$_manifest[$this->_archiveName][$path]['ok'] = true;
|
||||
}
|
||||
return $data;
|
||||
} else {
|
||||
@fclose($this->fp);
|
||||
return array($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse urls like phar:///fullpath/to/my.phar/file.txt
|
||||
*
|
||||
* @param string $file
|
||||
* @return false|array
|
||||
*/
|
||||
static protected function parseUrl($file)
|
||||
{
|
||||
if (substr($file, 0, 7) != 'phar://') {
|
||||
return false;
|
||||
}
|
||||
$file = substr($file, 7);
|
||||
|
||||
$ret = array('scheme' => 'phar');
|
||||
$pos_p = strpos($file, '.phar.php');
|
||||
$pos_z = strpos($file, '.phar.gz');
|
||||
$pos_b = strpos($file, '.phar.bz2');
|
||||
if ($pos_p) {
|
||||
if ($pos_z) {
|
||||
return false;
|
||||
}
|
||||
$ret['host'] = substr($file, 0, $pos_p + strlen('.phar.php'));
|
||||
$ret['path'] = substr($file, strlen($ret['host']));
|
||||
} elseif ($pos_z) {
|
||||
$ret['host'] = substr($file, 0, $pos_z + strlen('.phar.gz'));
|
||||
$ret['path'] = substr($file, strlen($ret['host']));
|
||||
} elseif ($pos_b) {
|
||||
$ret['host'] = substr($file, 0, $pos_z + strlen('.phar.bz2'));
|
||||
$ret['path'] = substr($file, strlen($ret['host']));
|
||||
} elseif (($pos_p = strpos($file, ".phar")) !== false) {
|
||||
$ret['host'] = substr($file, 0, $pos_p + strlen('.phar'));
|
||||
$ret['path'] = substr($file, strlen($ret['host']));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (!$ret['path']) {
|
||||
$ret['path'] = '/';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the .phar archive in the include_path and detect the file to open within
|
||||
* the archive.
|
||||
*
|
||||
* Possible parameters are phar://pharname.phar/filename_within_phar.ext
|
||||
* @param string a file within the archive
|
||||
* @return string the filename within the .phar to retrieve
|
||||
*/
|
||||
public function initializeStream($file)
|
||||
{
|
||||
$info = @parse_url($file);
|
||||
if (!$info) {
|
||||
$info = self::parseUrl($file);
|
||||
}
|
||||
if (!$info) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($info['host'])) {
|
||||
// malformed internal file
|
||||
return false;
|
||||
}
|
||||
if (!isset(self::$_pharFiles[$info['host']]) &&
|
||||
!isset(self::$_pharMapping[$info['host']])) {
|
||||
try {
|
||||
self::loadPhar($info['host']);
|
||||
// use alias from here out
|
||||
$info['host'] = self::$_pharFiles[$info['host']];
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!isset($info['path'])) {
|
||||
return false;
|
||||
} elseif (strlen($info['path']) > 1) {
|
||||
$info['path'] = substr($info['path'], 1);
|
||||
}
|
||||
if (isset(self::$_pharMapping[$info['host']])) {
|
||||
$this->_basename = $info['host'];
|
||||
$this->_archiveName = self::$_pharMapping[$info['host']][0];
|
||||
$this->_compressed = self::$_pharMapping[$info['host']][1];
|
||||
} elseif (isset(self::$_pharFiles[$info['host']])) {
|
||||
$this->_archiveName = $info['host'];
|
||||
$this->_basename = self::$_pharFiles[$info['host']];
|
||||
$this->_compressed = self::$_pharMapping[$this->_basename][1];
|
||||
}
|
||||
$file = $info['path'];
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the requested file - PHP streams API
|
||||
*
|
||||
* @param string $file String provided by the Stream wrapper
|
||||
* @access private
|
||||
*/
|
||||
public function stream_open($file)
|
||||
{
|
||||
return $this->_streamOpen($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string filename to opne, or directory name
|
||||
* @param bool if true, a directory will be matched, otherwise only files
|
||||
* will be matched
|
||||
* @uses trigger_error()
|
||||
* @return bool success of opening
|
||||
* @access private
|
||||
*/
|
||||
private function _streamOpen($file, $searchForDir = false)
|
||||
{
|
||||
$path = $this->initializeStream($file);
|
||||
if (!$path) {
|
||||
trigger_error('Error: Unknown phar in "' . $file . '"', E_USER_ERROR);
|
||||
}
|
||||
if (is_array($this->file = $this->extractFile($path))) {
|
||||
trigger_error($this->file[0], E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
if ($path != $this->currentFilename) {
|
||||
if (!$searchForDir) {
|
||||
trigger_error("Cannot open '$file', is a directory", E_USER_ERROR);
|
||||
return false;
|
||||
} else {
|
||||
$this->file = '';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($this->file) && $this->file !== false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data - PHP streams API
|
||||
*
|
||||
* @param int
|
||||
* @access private
|
||||
*/
|
||||
public function stream_read($count)
|
||||
{
|
||||
$ret = substr($this->file, $this->position, $count);
|
||||
$this->position += strlen($ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we've hit the end of the file - PHP streams API
|
||||
* @access private
|
||||
*/
|
||||
function stream_eof()
|
||||
{
|
||||
return $this->position >= $this->currentStat[7];
|
||||
}
|
||||
|
||||
/**
|
||||
* For seeking the stream - PHP streams API
|
||||
* @param int
|
||||
* @param SEEK_SET|SEEK_CUR|SEEK_END
|
||||
* @access private
|
||||
*/
|
||||
public function stream_seek($pos, $whence)
|
||||
{
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($pos < 0) {
|
||||
return false;
|
||||
}
|
||||
$this->position = $pos;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
if ($pos + $this->currentStat[7] < 0) {
|
||||
return false;
|
||||
}
|
||||
$this->position += $pos;
|
||||
break;
|
||||
case SEEK_END:
|
||||
if ($pos + $this->currentStat[7] < 0) {
|
||||
return false;
|
||||
}
|
||||
$this->position = $pos + $this->currentStat[7];
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current position in the stream - PHP streams API
|
||||
* @access private
|
||||
*/
|
||||
public function stream_tell()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result of an fstat call, returns mod time from creation, and file size -
|
||||
* PHP streams API
|
||||
* @uses _stream_stat()
|
||||
* @access private
|
||||
*/
|
||||
public function stream_stat()
|
||||
{
|
||||
return $this->_stream_stat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve statistics on a file or directory within the .phar
|
||||
* @param string file/directory to stat
|
||||
* @access private
|
||||
*/
|
||||
public function _stream_stat($file = null)
|
||||
{
|
||||
$std = $file ? self::processFile($file) : $this->currentFilename;
|
||||
if ($file) {
|
||||
if (isset(self::$_manifest[$this->_archiveName][$file])) {
|
||||
$this->_setCurrentFile($file);
|
||||
$isdir = false;
|
||||
} else {
|
||||
$isdir = true;
|
||||
}
|
||||
} else {
|
||||
$isdir = false; // open streams must be files
|
||||
}
|
||||
$mode = $isdir ? 0040444 : 0100444;
|
||||
// 040000 = dir, 010000 = file
|
||||
// everything is readable, nothing is writeable
|
||||
return array(
|
||||
0, 0, $mode, 0, 0, 0, 0, 0, 0, 0, 0, 0, // non-associative indices
|
||||
'dev' => 0, 'ino' => 0,
|
||||
'mode' => $mode,
|
||||
'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'blksize' => 0, 'blocks' => 0,
|
||||
'size' => $this->currentStat[7],
|
||||
'atime' => $this->currentStat[9],
|
||||
'mtime' => $this->currentStat[9],
|
||||
'ctime' => $this->currentStat[9],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat a closed file or directory - PHP streams API
|
||||
* @param string
|
||||
* @param int
|
||||
* @access private
|
||||
*/
|
||||
public function url_stat($url, $flags)
|
||||
{
|
||||
$path = $this->initializeStream($url);
|
||||
return $this->_stream_stat($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a directory in the .phar for reading - PHP streams API
|
||||
* @param string directory name
|
||||
* @access private
|
||||
*/
|
||||
public function dir_opendir($path)
|
||||
{
|
||||
$info = @parse_url($path);
|
||||
if (!$info) {
|
||||
$info = self::parseUrl($path);
|
||||
if (!$info) {
|
||||
trigger_error('Error: "' . $path . '" is a file, and cannot be opened with opendir',
|
||||
E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$path = !empty($info['path']) ?
|
||||
$info['host'] . $info['path'] : $info['host'] . '/';
|
||||
$path = $this->initializeStream('phar://' . $path);
|
||||
if (isset(self::$_manifest[$this->_archiveName][$path])) {
|
||||
trigger_error('Error: "' . $path . '" is a file, and cannot be opened with opendir',
|
||||
E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
if ($path == false) {
|
||||
trigger_error('Error: Unknown phar in "' . $file . '"', E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
$this->fp = @fopen($this->_archiveName, "rb");
|
||||
if (!$this->fp) {
|
||||
trigger_error('Error: cannot open phar "' . $this->_archiveName . '"');
|
||||
return false;
|
||||
}
|
||||
$this->_dirFiles = array();
|
||||
foreach (self::$_manifest[$this->_archiveName] as $file => $info) {
|
||||
if ($path == '/') {
|
||||
if (strpos($file, '/')) {
|
||||
$a = explode('/', $file);
|
||||
$this->_dirFiles[array_shift($a)] = true;
|
||||
} else {
|
||||
$this->_dirFiles[$file] = true;
|
||||
}
|
||||
} elseif (strpos($file, $path) === 0) {
|
||||
$fname = substr($file, strlen($path) + 1);
|
||||
if (strpos($fname, '/')) {
|
||||
$a = explode('/', $fname);
|
||||
$this->_dirFiles[array_shift($a)] = true;
|
||||
} elseif (strlen($file) != strlen($path)) {
|
||||
// if the two match exactly, the path searched for was
|
||||
// not a directory, but was a file.
|
||||
$this->_dirFiles[$fname] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@fclose($this->fp);
|
||||
@uksort($this->_dirFiles, 'strnatcmp');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next directory entry - PHP streams API
|
||||
* @access private
|
||||
*/
|
||||
public function dir_readdir()
|
||||
{
|
||||
$ret = key($this->_dirFiles);
|
||||
@next($this->_dirFiles);
|
||||
if (!$ret) {
|
||||
return false;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a directory handle opened with opendir() - PHP streams API
|
||||
* @access private
|
||||
*/
|
||||
public function dir_closedir()
|
||||
{
|
||||
$this->_dirFiles = array();
|
||||
reset($this->_dirFiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind to the first directory entry - PHP streams API
|
||||
* @access private
|
||||
*/
|
||||
public function dir_rewinddir()
|
||||
{
|
||||
reset($this->_dirFiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* API version of this class
|
||||
* @return string
|
||||
*/
|
||||
public final function APIVersion()
|
||||
{
|
||||
return '1.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Phar-specific metadata for a Phar archive
|
||||
*
|
||||
* @param string $phar full path to Phar archive, or alias
|
||||
* @return null|mixed The value that was serialized for the Phar
|
||||
* archive's metadata
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getPharMetadata($phar)
|
||||
{
|
||||
if (isset(self::$_pharFiles[$phar])) {
|
||||
$phar = self::$_pharFiles[$phar];
|
||||
}
|
||||
if (!isset(self::$_pharMapping[$phar])) {
|
||||
throw new Exception('Unknown Phar archive: "' . $phar . '"');
|
||||
}
|
||||
return self::$_pharMapping[$phar][4];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve File-specific metadata for a Phar archive file
|
||||
*
|
||||
* @param string $phar full path to Phar archive, or alias
|
||||
* @param string $file relative path to file within Phar archive
|
||||
* @return null|mixed The value that was serialized for the Phar
|
||||
* archive's metadata
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getFileMetadata($phar, $file)
|
||||
{
|
||||
if (!isset(self::$_pharFiles[$phar])) {
|
||||
if (!isset(self::$_pharMapping[$phar])) {
|
||||
throw new Exception('Unknown Phar archive: "' . $phar . '"');
|
||||
}
|
||||
$phar = self::$_pharMapping[$phar][0];
|
||||
}
|
||||
if (!isset(self::$_manifest[$phar])) {
|
||||
throw new Exception('Unknown Phar: "' . $phar . '"');
|
||||
}
|
||||
$file = self::processFile($file);
|
||||
if (!isset(self::$_manifest[$phar][$file])) {
|
||||
throw new Exception('Unknown file "' . $file . '" within Phar "'. $phar . '"');
|
||||
}
|
||||
return self::$_manifest[$phar][$file][6];
|
||||
}
|
||||
}
|
||||
?><?php
|
||||
}
|
||||
if (!in_array('phar', stream_get_wrappers())) {
|
||||
stream_wrapper_register('phar', 'PHP_Archive');
|
||||
}
|
||||
if (!class_exists('Phar',0)) {
|
||||
include 'phar://'.__FILE__.'/phar.inc';
|
||||
}
|
||||
?><?php
|
||||
|
||||
/** @file phar.php
|
||||
* @ingroup Phar
|
||||
* @brief class CLICommand
|
||||
* @author Marcus Boerger
|
||||
* @date 2007 - 2007
|
||||
*
|
||||
* Phar Command
|
||||
*/
|
||||
|
||||
if (!extension_loaded('phar'))
|
||||
{
|
||||
if (!class_exists('PHP_Archive', 0))
|
||||
{
|
||||
echo "Neither Extension Phar nor class PHP_Archive are available.\n";
|
||||
exit(1);
|
||||
}
|
||||
if (!in_array('phar', stream_get_wrappers()))
|
||||
{
|
||||
stream_wrapper_register('phar', 'PHP_Archive');
|
||||
}
|
||||
if (!class_exists('Phar',0)) {
|
||||
require 'phar://'.__FILE__.'/phar.inc';
|
||||
}
|
||||
}
|
||||
|
||||
foreach(array("SPL", "Reflection") as $ext)
|
||||
{
|
||||
if (!extension_loaded($ext))
|
||||
{
|
||||
echo "$argv[0] requires PHP extension $ext.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function command_include($file)
|
||||
{
|
||||
$file = 'phar://' . __FILE__ . '/' . $file;
|
||||
if (file_exists($file)) {
|
||||
include($file);
|
||||
}
|
||||
}
|
||||
|
||||
function command_autoload($classname)
|
||||
{
|
||||
command_include(strtolower($classname) . '.inc');
|
||||
}
|
||||
|
||||
Phar::mapPhar();
|
||||
|
||||
spl_autoload_register('command_autoload');
|
||||
|
||||
new PharCommand($argc, $argv);
|
||||
|
||||
__HALT_COMPILER(); ?>
|
||||
6 | ||||