<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar(5, 'hio', false);
__HALT_COMPILER(); ?>";
$file .= pack('V', 500) . 'notenough';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Fatal error: Phar::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar(5, 'hio', false);
__HALT_COMPILER(); ?>";
$file .= pack('VV', 500, 500) . str_repeat('A', 500);
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Fatal error: Phar::mapPhar(): too many manifest entries for size of manifest in phar "%s" in %s on line %d
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar(5, 'hio', false);
__HALT_COMPILER(); ?>";
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 1);
// this fails because the manifest length does not include the 4-byte "length of manifest" data
$file .= pack('VV', strlen($manifest), 1) . $manifest . pack('VV', crc32('a'), 1) . 'a';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Fatal error: Phar::mapPhar(): internal corruption of phar "%s" (buffer overrun) in %s on line %d
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar(5, 'hio', false);
__HALT_COMPILER(); ?>";
// compressed file length does not include 8 bytes for crc/file length and should
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 1);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 1) . 'a';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Fatal error: Phar::mapPhar(): internal corruption of phar "%s" (file size in phar is not large enough) in %s on line %d
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', false);
__HALT_COMPILER(); ?>";
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 9);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 1) . 'a';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
a
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', false);
__HALT_COMPILER(); ?>";
// filesize should be 1, and is 2
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 9);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 2) . 'a';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (filesize mismatch on file "a") in %s on line 12
\ No newline at end of file
+Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (filesize mismatch on file "a") in %s on line %d
<?php if (!extension_loaded("phar")) print "skip";?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', false);
__HALT_COMPILER(); ?>";
// wrong crc32
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 9);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('b'), 1) . 'a';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line 12
\ No newline at end of file
+Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (crc32 mismatch on file "a") in %s on line %d
\ No newline at end of file
if (!PHP_Archive::canCompress()) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', true);
__HALT_COMPILER(); ?>";
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 11);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 1) . chr(75) . chr(4) . chr(0); // 'a' gzdeflated
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
a
\ No newline at end of file
if (!PHP_Archive::canCompress()) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', true);
__HALT_COMPILER(); ?>";
// file length is too short
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 9);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 1) . chr(0) . chr(4) . chr(0); // 'a' gzdeflated
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
echo file_get_contents('phar://hio/a');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: decompression failed in %s on line %d
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', true);
__HALT_COMPILER(); ?>";
// file length is too short
$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 9);
$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 1) . 'a';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$dir = opendir('phar://hio');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
Warning: opendir(phar://hio): failed to open dir: phar error: no directory in "phar://hio", must have at least phar://hio/ for root directory in %s on line %d
\ No newline at end of file
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', true);
__HALT_COMPILER(); ?>";
$manifest .
pack('VV', crc32('a'), 1) . 'a' .
pack('VV', crc32('b'), 1) . 'b';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$dir = opendir('phar://hio/');
while (false !== ($a = readdir($dir))) {
var_dump($a);
var_dump(is_dir('phar://hio/' . $a));
}
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
string(1) "a"
bool(false)
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', true);
__HALT_COMPILER(); ?>";
pack('VV', crc32('b'), 1) . 'b';
pack('VV', crc32('c'), 1) . 'c';
pack('VV', crc32('d'), 1) . 'd';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$dir = opendir('phar://hio/b');
while (false !== ($a = readdir($dir))) {
var_dump($a);
var_dump(is_dir('phar://hio/b/' . $a));
}
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
string(1) "a"
bool(false)
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', true);
__HALT_COMPILER(); ?>";
pack('VV', crc32('b'), 1) . 'b';
pack('VV', crc32('c'), 1) . 'c';
pack('VV', crc32('d'), 1) . 'd';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
function dump($phar, $base)
{
dump('phar://hio', '/');
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
string(11) "phar://hio/"
string(2) "/a"
pack('VV', crc32('b'), 1) . 'b' .
pack('VV', crc32('c'), 1) . 'c' .
pack('VV', crc32('d'), 1) . 'd';
-file_put_contents(dirname(__FILE__) . '/019c.phar.php', $file);
-include dirname(__FILE__) . '/019c.phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
function dump($phar, $base)
{
?>
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/019c.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
string(11) "phar://hio/"
string(2) "/a"
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', false);
__HALT_COMPILER(); ?>";
pack('VV', crc32('b'), 1) . 'b';
pack('VV', crc32('c'), 1) . 'c';
pack('VV', crc32('d'), 1) . 'd';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
var_dump(stat('phar://hio/a'), stat('phar://hio/b'));
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
array(26) {
[0]=>
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', false);
__HALT_COMPILER(); ?>";
pack('VV', crc32('b'), 1) . 'b';
pack('VV', crc32('c'), 1) . 'c';
pack('VV', crc32('d'), 1) . 'd';
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$fp = fopen('phar://hio/a', 'r');
var_dump(fstat($fp));
fclose($fp);
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
array(26) {
[0]=>
<?php if (!extension_loaded("phar")) print "skip"; ?>
--FILE--
<?php
-function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
-register_shutdown_function('cleanup');
$file = "<?php
Phar::mapPhar('hio', false);
__HALT_COMPILER(); ?>";
$file .= pack('VV', strlen($manifest) + 4, 1) .
$manifest .
pack('VV', crc32($contents), strlen($contents)) . $contents;
-file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
-include dirname(__FILE__) . '/008_phar.php';
+file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
+include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$fp = fopen('phar://hio/a', 'r');
var_dump(ftell($fp));
echo 'fseek($fp, 1)';var_dump(fseek($fp, 1));
var_dump(ftell($fp));
fclose($fp);
?>
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECT--
int(0)
fseek($fp, 1)int(0)
int(4)
fseek($fp, 3, SEEK_CUR)int(0)
int(7)
-
-
-
-
-
-
-
-
-
-