2006-01-06 16:11:54 +00:00
|
|
|
--TEST--
|
|
|
|
Phar: phar:// file_get_contents
|
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("phar")) print "skip"; ?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
$file = "<?php __HALT_COMPILER(); ?>";
|
|
|
|
|
2006-01-11 00:50:33 +00:00
|
|
|
$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"; ?>';
|
2006-01-06 16:11:54 +00:00
|
|
|
$manifest = '';
|
2006-01-11 00:50:33 +00:00
|
|
|
foreach($files as $name => $cont) {
|
|
|
|
$len = strlen($cont);
|
|
|
|
$manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), $len, crc32($cont), 0x00);
|
|
|
|
}
|
|
|
|
$alias = 'hio';
|
|
|
|
$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest;
|
|
|
|
$file .= pack('V', strlen($manifest)) . $manifest;
|
|
|
|
foreach($files as $cont)
|
|
|
|
{
|
|
|
|
$file .= $cont;
|
|
|
|
}
|
2006-01-06 16:11:54 +00:00
|
|
|
|
|
|
|
file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
|
|
|
|
|
|
|
|
var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php'));
|
|
|
|
var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php'));
|
|
|
|
var_dump(file_get_contents('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/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===
|