import phar tests

Now that phars sort of work, we can import their tests and they don't spew everywhere.
Esse commit está contido em:
Paul Tarjan
2013-07-23 00:28:34 -07:00
commit de Sara Golemon
commit ad394c4f06
78 arquivos alterados com 1569 adições e 4 exclusões
+11
Ver Arquivo
@@ -0,0 +1,11 @@
<?php
$e = dirname(__FILE__) . '/files/';
for ($i = 1; $i <= 5; $i++) {
try {
new Phar($e . "badalias$i.phar.tar");
} catch (Exception $ee) {
echo $ee->getMessage(), "\n";
}
}
?>
===DONE===
@@ -0,0 +1,6 @@
phar error: invalid alias "hi/thereaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." in tar-based phar "%sbadalias1.phar.tar"
phar error: invalid alias "hi\there" in tar-based phar "%sbadalias2.phar.tar"
phar error: invalid alias "hi;there" in tar-based phar "%sbadalias3.phar.tar"
phar error: invalid alias "hi:there" in tar-based phar "%sbadalias4.phar.tar"
phar error: tar-based phar "%sbadalias5.phar.tar" has alias that is larger than 511 bytes, cannot process
===DONE===
@@ -0,0 +1,21 @@
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
$pname = 'phar://' . $fname;
include dirname(__FILE__) . '/files/corrupt_tarmaker.php.inc';
$a = new corrupt_tarmaker($fname, 'none');
$a->init();
$a->addFile('hithere', 'contents', null, 'checksum');
$a->close();
try {
$p = new PharData($fname);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===?>
<?php
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
?>
@@ -0,0 +1,2 @@
phar error: "%sbadchecksum.tar" is a corrupted tar file (checksum mismatch of file "hithere")
===DONE===
+10
Ver Arquivo
@@ -0,0 +1,10 @@
<?php
$fname = str_replace('\\', '/', dirname(__FILE__) . '/files/Structures_Graph-1.0.3.tgz');
$tar = new PharData($fname);
$files = array();
foreach (new RecursiveIteratorIterator($tar) as $file) {
$files[] = str_replace($fname, '*', $file->getPathName());
}
print_r($files);
?>
===DONE===
@@ -0,0 +1,33 @@
Array
(
[0] => phar://*/Structures_Graph-1.0.3/LICENSE
[1] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Manipulator/AcyclicTest.php
[2] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Manipulator/TopologicalSorter.php
[3] => phar://*/Structures_Graph-1.0.3/Structures/Graph/Node.php
[4] => phar://*/Structures_Graph-1.0.3/Structures/Graph.php
[5] => phar://*/Structures_Graph-1.0.3/docs/generate.sh
[6] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph.html
[7] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Manipulator_AcyclicTest.html
[8] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Manipulator_TopologicalSorter.html
[9] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/Structures_Graph_Node.html
[10] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Manipulator_AcyclicTest_php.html
[11] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Manipulator_TopologicalSorter_php.html
[12] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_Node_php.html
[13] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/_Structures_Graph_php.html
[14] => phar://*/Structures_Graph-1.0.3/docs/html/Structures_Graph/tutorial_Structures_Graph.pkg.html
[15] => phar://*/Structures_Graph-1.0.3/docs/html/classtrees_Structures_Graph.html
[16] => phar://*/Structures_Graph-1.0.3/docs/html/elementindex.html
[17] => phar://*/Structures_Graph-1.0.3/docs/html/elementindex_Structures_Graph.html
[18] => phar://*/Structures_Graph-1.0.3/docs/html/errors.html
[19] => phar://*/Structures_Graph-1.0.3/docs/html/index.html
[20] => phar://*/Structures_Graph-1.0.3/docs/html/li_Structures_Graph.html
[21] => phar://*/Structures_Graph-1.0.3/docs/html/media/banner.css
[22] => phar://*/Structures_Graph-1.0.3/docs/html/media/stylesheet.css
[23] => phar://*/Structures_Graph-1.0.3/docs/html/packages.html
[24] => phar://*/Structures_Graph-1.0.3/docs/html/todolist.html
[25] => phar://*/Structures_Graph-1.0.3/docs/tutorials/Structures_Graph/Structures_Graph.pkg
[26] => phar://*/Structures_Graph-1.0.3/tests/AllTests.php
[27] => phar://*/Structures_Graph-1.0.3/tests/testCase/BasicGraph.php
[28] => phar://*/package.xml
)
===DONE===
+26
Ver Arquivo
@@ -0,0 +1,26 @@
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
$pname = 'phar://' . $fname;
include dirname(__FILE__) . '/files/corrupt_tarmaker.php.inc';
$a = new corrupt_tarmaker($fname, 'none');
$a->init();
$a->addFile('hardlink', 'internal/file.txt', array(
'mode' => 0xA000 + 0644,
'uid' => 0,
'gid' => 0,
'size' => 0,
'mtime' => time(),
));
$a->close();
try {
$p = new PharData($fname);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===?>
<?php
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
?>
@@ -0,0 +1,2 @@
phar error: "%slinks2.tar" is a corrupted tar file - hard link to non-existent file "internal/file.txt"
===DONE===
+20
Ver Arquivo
@@ -0,0 +1,20 @@
<?php
include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
$tar = new corrupter(dirname(__FILE__) . '/tar_001.phar.tar', 'none');
$tar->init();
$tar->addFile('tar_001.phpt', __FILE__);
$tar->close();
$tar = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar.tar/tar_001.phpt', 'rb');
try {
$phar = new Phar(dirname(__FILE__) . '/tar_001.phar.tar');
echo "should not execute\n";
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===?>
<?php
@unlink(dirname(__FILE__) . '/tar_001.phar.tar');
?>
@@ -0,0 +1,3 @@
HipHop Warning: %s
phar error: "%star_001.phar.tar" is a corrupted tar file (truncated)
===DONE===
@@ -0,0 +1,13 @@
<?php
try {
$p = new PharData(dirname(__FILE__) . '/files/trunc.tar');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===?>
<?php
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
?>
@@ -0,0 +1,2 @@
phar error: "%strunc.tar" is a corrupted tar file (truncated)
===DONE===
+11
Ver Arquivo
@@ -0,0 +1,11 @@
<?php
$e = dirname(__FILE__) . '/files/';
for ($i = 1; $i <= 5; $i++) {
try {
new Phar($e . "badalias$i.phar.zip");
} catch (Exception $ee) {
echo $ee->getMessage(), "\n";
}
}
?>
===DONE===
@@ -0,0 +1,6 @@
phar error: invalid alias "hi/there" in zip-based phar "%sbadalias1.phar.zip"
phar error: invalid alias "hi\there" in zip-based phar "%sbadalias2.phar.zip"
phar error: invalid alias "hi\there" in zip-based phar "%sbadalias3.phar.zip"
phar error: invalid alias "hi;there" in zip-based phar "%sbadalias4.phar.zip"
phar error: invalid alias "hi:there" in zip-based phar "%sbadalias5.phar.zip"
===DONE===
@@ -0,0 +1,4 @@
<?php
echo file_get_contents('phar://' . dirname(__FILE__) . '/files/test.odt/content.xml'), "\n";
?>
===DONE===
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
+13
Ver Arquivo
@@ -0,0 +1,13 @@
<?php
try {
$a = new PharData(dirname(__FILE__) . '/files/bzip2.zip');
foreach ($a as $entry => $file) {
echo $file->getContent();
}
$a = new Phar(dirname(__FILE__) . '/files/bz2_alias.phar.zip');
var_dump($a->getAlias());
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,62 @@
<?php
include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii');
$a->addFile('hi2', null, 'hii2', null, null, 'encrypt', 'encrypt');
$a->writeZip(dirname(__FILE__) . '/encrypted.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii');
$a->addFile('', null, 'stdin');
$a->writeZip(dirname(__FILE__) . '/stdin.zip');
$a = new corrupt_zipmaker;
$a->addFile('hii', null, 'hii', null, null, 'filename_len', 'filename_len');
$a->addFile('hi', null, 'hii');
$a->writeZip(dirname(__FILE__) . '/truncfilename.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress');
$a->writeZip(dirname(__FILE__) . '/compress_unsup1.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 2);
$a->writeZip(dirname(__FILE__) . '/compress_unsup2.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 3);
$a->writeZip(dirname(__FILE__) . '/compress_unsup3.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 4);
$a->writeZip(dirname(__FILE__) . '/compress_unsup4.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 5);
$a->writeZip(dirname(__FILE__) . '/compress_unsup5.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 6);
$a->writeZip(dirname(__FILE__) . '/compress_unsup6.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 7);
$a->writeZip(dirname(__FILE__) . '/compress_unsup7.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 9);
$a->writeZip(dirname(__FILE__) . '/compress_unsup9.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 10);
$a->writeZip(dirname(__FILE__) . '/compress_unsup10.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 14);
$a->writeZip(dirname(__FILE__) . '/compress_unsup14.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 18);
$a->writeZip(dirname(__FILE__) . '/compress_unsup18.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 19);
$a->writeZip(dirname(__FILE__) . '/compress_unsup19.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 97);
$a->writeZip(dirname(__FILE__) . '/compress_unsup97.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 98);
$a->writeZip(dirname(__FILE__) . '/compress_unsup98.zip');
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11);
$a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip');
?>
string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
===DONE===
@@ -0,0 +1,13 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/count1.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/count2.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,3 @@
phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar "%scount1.zip"
phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar "%scount2.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/nozipend.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: end of central directory not found in zip-based phar "%snozipend.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/filecomment.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: corrupt zip archive, zip file comment truncated in zip-based phar "%sfilecomment.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/cdir_offset.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: corrupted central directory entry, no magic signature in zip-based phar "%scdir_offset.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/encrypted.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: Cannot process encrypted zip files in zip-based phar "%sencrypted.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/stdin.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: Cannot process zips created from stdin (zero-length filename) in zip-based phar "%sstdin.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/truncfilename.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: corrupted central directory entry, no magic signature in zip-based phar "%struncfilename.zip"
===DONE===
@@ -0,0 +1,78 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup1.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup2.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup3.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup4.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup5.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup6.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup7.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup9.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup10.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup14.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup18.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup19.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup97.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsup98.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new PharData(dirname(__FILE__) . '/files/compress_unsupunknown.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,16 @@
phar error: unsupported compression method (Shrunk) used in this zip in zip-based phar "%scompress_unsup1.zip"
phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup2.zip"
phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup3.zip"
phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup4.zip"
phar error: unsupported compression method (Reduce) used in this zip in zip-based phar "%scompress_unsup5.zip"
phar error: unsupported compression method (Implode) used in this zip in zip-based phar "%scompress_unsup6.zip"
phar error: unsupported compression method (Tokenize) used in this zip in zip-based phar "%scompress_unsup7.zip"
phar error: unsupported compression method (Deflate64) used in this zip in zip-based phar "%scompress_unsup9.zip"
phar error: unsupported compression method (PKWare Implode/old IBM TERSE) used in this zip in zip-based phar "%scompress_unsup10.zip"
phar error: unsupported compression method (LZMA) used in this zip in zip-based phar "%scompress_unsup14.zip"
phar error: unsupported compression method (IBM TERSE) used in this zip in zip-based phar "%scompress_unsup18.zip"
phar error: unsupported compression method (IBM LZ77) used in this zip in zip-based phar "%scompress_unsup19.zip"
phar error: unsupported compression method (WavPack) used in this zip in zip-based phar "%scompress_unsup97.zip"
phar error: unsupported compression method (PPMd) used in this zip in zip-based phar "%scompress_unsup98.zip"
phar error: unsupported compression method (unknown) used in this zip in zip-based phar "%scompress_unsupunknown.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/extralen_toolong.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: Unable to process extra field header for file in central directory in zip-based phar "%sextralen_toolong.zip"
===DONE===
@@ -0,0 +1,8 @@
<?php
try {
new PharData(dirname(__FILE__) . '/files/disknumber.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
phar error: split archives spanning multiple zips cannot be processed in zip-based phar "%sdisknumber.zip"
===DONE===
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?php
$a = new PharData(dirname(__FILE__) . '/files/odt.odt');
foreach (new RecursiveIteratorIterator($a, RecursiveIteratorIterator::LEAVES_ONLY) as $b) {
if ($b->isDir()) {
echo "dir " . $b->getPathName() . "\n";
} else {
echo $b->getPathName() . "\n";
}
}
// this next line is for increased code coverage
try {
$b = new Phar(dirname(__FILE__) . '/files/odt.odt');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,10 @@
phar://%sodt.odt/Configurations2/accelerator%ccurrent.xml
phar://%sodt.odt/META-INF%cmanifest.xml
phar://%sodt.odt/Thumbnails%cthumbnail.png
phar://%sodt.odt%ccontent.xml
phar://%sodt.odt%cmeta.xml
phar://%sodt.odt%cmimetype
phar://%sodt.odt%csettings.xml
phar://%sodt.odt%cstyles.xml
Cannot create phar '%sodt.odt', file extension (or combination) not recognised or the directory does not exist
===DONE===
+15
Ver Arquivo
@@ -0,0 +1,15 @@
<?php
$a = new PharData(dirname(__FILE__) . '/files/zip.zip');
foreach ($a as $b) {
if ($b->isDir()) {
echo "dir " . $b->getPathName() . "\n";
} else {
echo $b->getPathName(), "\n";
echo file_get_contents($b->getPathName()), "\n";
}
}
if (isset($a['notempty/hi.txt'])) {
echo $a['notempty/hi.txt']->getPathName() . "\n";
}
?>
===DONE===
@@ -0,0 +1,7 @@
dir phar://%s/zip.zip%cempty
phar://%s/zip.zip%chi.txt
hi there
dir phar://%s/zip.zip%cnotempty
phar://%s/zip.zip/notempty%chi.txt
===DONE===
+9
Ver Arquivo
@@ -0,0 +1,9 @@
<?php
try {
$a = new Phar(dirname(__FILE__) . '/files/zlib_alias.phar.zip');
var_dump($a->getAlias());
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,2 @@
string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip"
===DONE===
+4
Ver Arquivo
@@ -0,0 +1,4 @@
<?php
var_dump(Phar::apiVersion());
?>
===DONE===
@@ -0,0 +1,2 @@
string(5) "1.1.1"
===DONE===
+9
Ver Arquivo
@@ -0,0 +1,9 @@
<?php
try {
Phar::mapPhar(5, 'hio', 'hi');
Phar::mapPhar();
} catch (Exception $e) {
echo $e->getMessage();
}
__HALT_COMPILER(); ?>
@@ -0,0 +1,2 @@
HipHop Warning: %s
internal corruption of phar "%s002.php" (truncated manifest at manifest length)
+6
Ver Arquivo
@@ -0,0 +1,6 @@
<?php
/* check this works and actually returns the boolean value */
var_dump(Phar::canCompress() == (
extension_loaded("zlib") || extension_loaded("bz2")
));
?>
@@ -0,0 +1 @@
bool(true)
+5
Ver Arquivo
@@ -0,0 +1,5 @@
<?php
var_dump(Phar::canCompress(Phar::GZ) == extension_loaded("zlib"));
var_dump(Phar::canCompress(Phar::BZ2) == extension_loaded("bz2"));
?>
===DONE===
@@ -0,0 +1,3 @@
bool(true)
bool(true)
===DONE===
+7
Ver Arquivo
@@ -0,0 +1,7 @@
<?php
try {
Phar::mapPhar('hio');
} catch (Exception $e) {
echo $e->getMessage();
}
__HALT_COMPILER(); ?>()
@@ -0,0 +1 @@
internal corruption of phar "%s" (truncated manifest at manifest length)
+7
Ver Arquivo
@@ -0,0 +1,7 @@
<?php
try {
Phar::mapPhar('hio');
} catch (Exception $e) {
echo $e->getMessage();
}
__HALT_COMPILER(); ?>
@@ -0,0 +1 @@
internal corruption of phar "%s" (truncated manifest at manifest length)
+7
Ver Arquivo
@@ -0,0 +1,7 @@
<?php
try {
Phar::mapPhar('hio');
} catch (Exception $e) {
echo $e->getMessage();
}
__HALT_COMPILER(); ?>~~~~
@@ -0,0 +1 @@
manifest cannot be larger than 100 MB in phar "%s"
Arquivo binário não exibido.
+12
Ver Arquivo
@@ -0,0 +1,12 @@
<?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();
}
?><?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
@@ -0,0 +1 @@
internal corruption of phar "%s" (truncated manifest header)
+19
Ver Arquivo
@@ -0,0 +1,19 @@
<?php
$a = dirname(__FILE__) .'/mytest';
try {
new phar($a);
} catch (exception $e) { }
var_dump($a);
try {
new phar($a);
} catch (exception $e) { }
var_dump($a);
new phardata('0000000000000000000');
?>
===DONE===
@@ -0,0 +1,7 @@
%string|unicode%(%d) "%smytest"
%string|unicode%(%d) "%smytest"
HipHop Fatal error: %s
Stack trace:
#0 %sbug46032.php(%d): PharData->__construct('000000000000000...')
#1 {main}
thrown in %sbug46032.php on line %d
+9
Ver Arquivo
@@ -0,0 +1,9 @@
<?php
try {
phar::mount(1,1);
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
@@ -0,0 +1 @@
string(25) "Mounting of 1 to 1 failed"
+10
Ver Arquivo
@@ -0,0 +1,10 @@
<?php
$nx = new Phar();
try {
$nx->getLinkTarget();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
@@ -0,0 +1,2 @@
HipHop Warning: %s
SplFileInfo::getLinkTarget(): Empty filename
+4
Ver Arquivo
@@ -0,0 +1,4 @@
<?php
include dirname(__FILE__) . '/files/nophar.phar';
?>
===DONE===
@@ -0,0 +1,4 @@
in b
<?php include "b/c.php";
in d
===DONE===
@@ -0,0 +1,30 @@
<?php
try {
var_dump(Phar::createDefaultStub());
echo "============================================================================\n";
echo "============================================================================\n";
var_dump(Phar::createDefaultStub('my/custom/thingy.php'));
echo "============================================================================\n";
echo "============================================================================\n";
var_dump(strlen(Phar::createDefaultStub(str_repeat('a', 400))));
echo "============================================================================\n";
echo "============================================================================\n";
var_dump(Phar::createDefaultStub(str_repeat('a', 401)));
} catch(Exception $e) {
echo $e->getMessage() . "\n";
}
echo "============================================================================\n";
echo "============================================================================\n";
echo "============================================================================\n";
echo "============================================================================\n";
try {
var_dump(Phar::createDefaultStub('my/custom/thingy.php', 'the/web.php'));
echo "============================================================================\n";
echo "============================================================================\n";
var_dump(strlen(Phar::createDefaultStub('index.php', str_repeat('a', 400))));
var_dump(Phar::createDefaultStub('hio', str_repeat('a', 401)));
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
@@ -0,0 +1,893 @@
string(6683) "<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
}
if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
Extract_Phar::go(true);
$mimes = array(
'phps' => 2,
'c' => 'text/plain',
'cc' => 'text/plain',
'cpp' => 'text/plain',
'c++' => 'text/plain',
'dtd' => 'text/plain',
'h' => 'text/plain',
'log' => 'text/plain',
'rng' => 'text/plain',
'txt' => 'text/plain',
'xsd' => 'text/plain',
'php' => 1,
'inc' => 1,
'avi' => 'video/avi',
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'htmls' => 'text/html',
'ico' => 'image/x-ico',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'js' => 'application/x-javascript',
'midi' => 'audio/midi',
'mid' => 'audio/midi',
'mod' => 'audio/mod',
'mov' => 'movie/quicktime',
'mp3' => 'audio/mp3',
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'swf' => 'application/shockwave-flash',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'wav' => 'audio/wav',
'xbm' => 'image/xbm',
'xml' => 'text/xml',
);
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
$basename = basename(__FILE__);
if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
chdir(Extract_Phar::$temp);
include $web;
return;
}
$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
if (!$pt || $pt == '/') {
$pt = $web;
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
exit;
}
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
if (!isset($b['extension'])) {
header('Content-Type: text/plain');
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
if (isset($mimes[$b['extension']])) {
if ($mimes[$b['extension']] === 1) {
include $a;
exit;
}
if ($mimes[$b['extension']] === 2) {
highlight_file($a);
exit;
}
header('Content-Type: ' .$mimes[$b['extension']]);
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
}
class Extract_Phar
{
static $temp;
static $origdir;
const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
const LEN = 6685;
static function go($return = false)
{
$fp = fopen(__FILE__, 'rb');
fseek($fp, self::LEN);
$L = unpack('V', $a = (binary)fread($fp, 4));
$m = (binary)'';
do {
$read = 8192;
if ($L[1] - strlen($m) < 8192) {
$read = $L[1] - strlen($m);
}
$last = (binary)fread($fp, $read);
$m .= $last;
} while (strlen($last) && strlen($m) < $L[1]);
if (strlen($m) < $L[1]) {
die('ERROR: manifest length read was "' .
strlen($m) .'" should be "' .
$L[1] . '"');
}
$info = self::_unpack($m);
$f = $info['c'];
if ($f & self::GZ) {
if (!function_exists('gzinflate')) {
die('Error: zlib extension is not enabled -' .
' gzinflate() function needed for zlib-compressed .phars');
}
}
if ($f & self::BZ2) {
if (!function_exists('bzdecompress')) {
die('Error: bzip2 extension is not enabled -' .
' bzdecompress() function needed for bz2-compressed .phars');
}
}
$temp = self::tmpdir();
if (!$temp || !is_writable($temp)) {
$sessionpath = session_save_path();
if (strpos ($sessionpath, ";") !== false)
$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
die('Could not locate temporary directory to extract phar');
}
$temp = $sessionpath;
}
$temp .= '/pharextract/'.basename(__FILE__, '.phar');
self::$temp = $temp;
self::$origdir = getcwd();
@mkdir($temp, 0777, true);
$temp = realpath($temp);
if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
self::_removeTmpFiles($temp, getcwd());
@mkdir($temp, 0777, true);
@file_put_contents($temp . '/' . md5_file(__FILE__), '');
foreach ($info['m'] as $path => $file) {
$a = !file_exists(dirname($temp . '/' . $path));
@mkdir(dirname($temp . '/' . $path), 0777, true);
clearstatcache();
if ($path[strlen($path) - 1] == '/') {
@mkdir($temp . '/' . $path, 0777);
} else {
file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
@chmod($temp . '/' . $path, 0666);
}
}
}
chdir($temp);
if (!$return) {
include self::START;
}
}
static function tmpdir()
{
if (strpos(PHP_OS, 'WIN') !== false) {
if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
return $var;
}
if (is_dir('/temp') || mkdir('/temp')) {
return realpath('/temp');
}
return false;
}
if ($var = getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
}
static function _unpack($m)
{
$info = unpack('V', substr($m, 0, 4));
$l = unpack('V', substr($m, 10, 4));
$m = substr($m, 14 + $l[1]);
$s = unpack('V', substr($m, 0, 4));
$o = 0;
$start = 4 + $s[1];
$ret['c'] = 0;
for ($i = 0; $i < $info[1]; $i++) {
$len = unpack('V', substr($m, $start, 4));
$start += 4;
$savepath = substr($m, $start, $len[1]);
$start += $len[1];
$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
& 0xffffffff);
$ret['m'][$savepath][7] = $o;
$o += $ret['m'][$savepath][2];
$start += 24 + $ret['m'][$savepath][5];
$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
}
return $ret;
}
static function extractFile($path, $entry, $fp)
{
$data = '';
$c = $entry[2];
while ($c) {
if ($c < 8192) {
$data .= @fread($fp, $c);
$c = 0;
} else {
$c -= 8192;
$data .= @fread($fp, 8192);
}
}
if ($entry[4] & self::GZ) {
$data = gzinflate($data);
} elseif ($entry[4] & self::BZ2) {
$data = bzdecompress($data);
}
if (strlen($data) != $entry[0]) {
die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[7] . ")");
}
if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
return $data;
}
static function _removeTmpFiles($temp, $origdir)
{
chdir($temp);
foreach (glob('*') as $f) {
if (file_exists($f)) {
is_dir($f) ? @rmdir($f) : @unlink($f);
if (file_exists($f) && is_dir($f)) {
self::_removeTmpFiles($f, getcwd());
}
}
}
@rmdir($temp);
clearstatcache();
chdir($origdir);
}
}
Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
string(6694) "<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
}
if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
Extract_Phar::go(true);
$mimes = array(
'phps' => 2,
'c' => 'text/plain',
'cc' => 'text/plain',
'cpp' => 'text/plain',
'c++' => 'text/plain',
'dtd' => 'text/plain',
'h' => 'text/plain',
'log' => 'text/plain',
'rng' => 'text/plain',
'txt' => 'text/plain',
'xsd' => 'text/plain',
'php' => 1,
'inc' => 1,
'avi' => 'video/avi',
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'htmls' => 'text/html',
'ico' => 'image/x-ico',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'js' => 'application/x-javascript',
'midi' => 'audio/midi',
'mid' => 'audio/midi',
'mod' => 'audio/mod',
'mov' => 'movie/quicktime',
'mp3' => 'audio/mp3',
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'swf' => 'application/shockwave-flash',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'wav' => 'audio/wav',
'xbm' => 'image/xbm',
'xml' => 'text/xml',
);
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
$basename = basename(__FILE__);
if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
chdir(Extract_Phar::$temp);
include $web;
return;
}
$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
if (!$pt || $pt == '/') {
$pt = $web;
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
exit;
}
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
if (!isset($b['extension'])) {
header('Content-Type: text/plain');
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
if (isset($mimes[$b['extension']])) {
if ($mimes[$b['extension']] === 1) {
include $a;
exit;
}
if ($mimes[$b['extension']] === 2) {
highlight_file($a);
exit;
}
header('Content-Type: ' .$mimes[$b['extension']]);
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
}
class Extract_Phar
{
static $temp;
static $origdir;
const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
const LEN = 6696;
static function go($return = false)
{
$fp = fopen(__FILE__, 'rb');
fseek($fp, self::LEN);
$L = unpack('V', $a = (binary)fread($fp, 4));
$m = (binary)'';
do {
$read = 8192;
if ($L[1] - strlen($m) < 8192) {
$read = $L[1] - strlen($m);
}
$last = (binary)fread($fp, $read);
$m .= $last;
} while (strlen($last) && strlen($m) < $L[1]);
if (strlen($m) < $L[1]) {
die('ERROR: manifest length read was "' .
strlen($m) .'" should be "' .
$L[1] . '"');
}
$info = self::_unpack($m);
$f = $info['c'];
if ($f & self::GZ) {
if (!function_exists('gzinflate')) {
die('Error: zlib extension is not enabled -' .
' gzinflate() function needed for zlib-compressed .phars');
}
}
if ($f & self::BZ2) {
if (!function_exists('bzdecompress')) {
die('Error: bzip2 extension is not enabled -' .
' bzdecompress() function needed for bz2-compressed .phars');
}
}
$temp = self::tmpdir();
if (!$temp || !is_writable($temp)) {
$sessionpath = session_save_path();
if (strpos ($sessionpath, ";") !== false)
$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
die('Could not locate temporary directory to extract phar');
}
$temp = $sessionpath;
}
$temp .= '/pharextract/'.basename(__FILE__, '.phar');
self::$temp = $temp;
self::$origdir = getcwd();
@mkdir($temp, 0777, true);
$temp = realpath($temp);
if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
self::_removeTmpFiles($temp, getcwd());
@mkdir($temp, 0777, true);
@file_put_contents($temp . '/' . md5_file(__FILE__), '');
foreach ($info['m'] as $path => $file) {
$a = !file_exists(dirname($temp . '/' . $path));
@mkdir(dirname($temp . '/' . $path), 0777, true);
clearstatcache();
if ($path[strlen($path) - 1] == '/') {
@mkdir($temp . '/' . $path, 0777);
} else {
file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
@chmod($temp . '/' . $path, 0666);
}
}
}
chdir($temp);
if (!$return) {
include self::START;
}
}
static function tmpdir()
{
if (strpos(PHP_OS, 'WIN') !== false) {
if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
return $var;
}
if (is_dir('/temp') || mkdir('/temp')) {
return realpath('/temp');
}
return false;
}
if ($var = getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
}
static function _unpack($m)
{
$info = unpack('V', substr($m, 0, 4));
$l = unpack('V', substr($m, 10, 4));
$m = substr($m, 14 + $l[1]);
$s = unpack('V', substr($m, 0, 4));
$o = 0;
$start = 4 + $s[1];
$ret['c'] = 0;
for ($i = 0; $i < $info[1]; $i++) {
$len = unpack('V', substr($m, $start, 4));
$start += 4;
$savepath = substr($m, $start, $len[1]);
$start += $len[1];
$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
& 0xffffffff);
$ret['m'][$savepath][7] = $o;
$o += $ret['m'][$savepath][2];
$start += 24 + $ret['m'][$savepath][5];
$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
}
return $ret;
}
static function extractFile($path, $entry, $fp)
{
$data = '';
$c = $entry[2];
while ($c) {
if ($c < 8192) {
$data .= @fread($fp, $c);
$c = 0;
} else {
$c -= 8192;
$data .= @fread($fp, 8192);
}
}
if ($entry[4] & self::GZ) {
$data = gzinflate($data);
} elseif ($entry[4] & self::BZ2) {
$data = bzdecompress($data);
}
if (strlen($data) != $entry[0]) {
die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[7] . ")");
}
if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
return $data;
}
static function _removeTmpFiles($temp, $origdir)
{
chdir($temp);
foreach (glob('*') as $f) {
if (file_exists($f)) {
is_dir($f) ? @rmdir($f) : @unlink($f);
if (file_exists($f) && is_dir($f)) {
self::_removeTmpFiles($f, getcwd());
}
}
}
@rmdir($temp);
clearstatcache();
chdir($origdir);
}
}
Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
int(7074)
============================================================================
============================================================================
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
============================================================================
============================================================================
============================================================================
============================================================================
string(6696) "<?php
$web = 'the/web.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
}
if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
Extract_Phar::go(true);
$mimes = array(
'phps' => 2,
'c' => 'text/plain',
'cc' => 'text/plain',
'cpp' => 'text/plain',
'c++' => 'text/plain',
'dtd' => 'text/plain',
'h' => 'text/plain',
'log' => 'text/plain',
'rng' => 'text/plain',
'txt' => 'text/plain',
'xsd' => 'text/plain',
'php' => 1,
'inc' => 1,
'avi' => 'video/avi',
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'htmls' => 'text/html',
'ico' => 'image/x-ico',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'js' => 'application/x-javascript',
'midi' => 'audio/midi',
'mid' => 'audio/midi',
'mod' => 'audio/mod',
'mov' => 'movie/quicktime',
'mp3' => 'audio/mp3',
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'swf' => 'application/shockwave-flash',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'wav' => 'audio/wav',
'xbm' => 'image/xbm',
'xml' => 'text/xml',
);
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
$basename = basename(__FILE__);
if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
chdir(Extract_Phar::$temp);
include $web;
return;
}
$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
if (!$pt || $pt == '/') {
$pt = $web;
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
exit;
}
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
if (!isset($b['extension'])) {
header('Content-Type: text/plain');
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
if (isset($mimes[$b['extension']])) {
if ($mimes[$b['extension']] === 1) {
include $a;
exit;
}
if ($mimes[$b['extension']] === 2) {
highlight_file($a);
exit;
}
header('Content-Type: ' .$mimes[$b['extension']]);
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
}
class Extract_Phar
{
static $temp;
static $origdir;
const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
const LEN = 6698;
static function go($return = false)
{
$fp = fopen(__FILE__, 'rb');
fseek($fp, self::LEN);
$L = unpack('V', $a = (binary)fread($fp, 4));
$m = (binary)'';
do {
$read = 8192;
if ($L[1] - strlen($m) < 8192) {
$read = $L[1] - strlen($m);
}
$last = (binary)fread($fp, $read);
$m .= $last;
} while (strlen($last) && strlen($m) < $L[1]);
if (strlen($m) < $L[1]) {
die('ERROR: manifest length read was "' .
strlen($m) .'" should be "' .
$L[1] . '"');
}
$info = self::_unpack($m);
$f = $info['c'];
if ($f & self::GZ) {
if (!function_exists('gzinflate')) {
die('Error: zlib extension is not enabled -' .
' gzinflate() function needed for zlib-compressed .phars');
}
}
if ($f & self::BZ2) {
if (!function_exists('bzdecompress')) {
die('Error: bzip2 extension is not enabled -' .
' bzdecompress() function needed for bz2-compressed .phars');
}
}
$temp = self::tmpdir();
if (!$temp || !is_writable($temp)) {
$sessionpath = session_save_path();
if (strpos ($sessionpath, ";") !== false)
$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
die('Could not locate temporary directory to extract phar');
}
$temp = $sessionpath;
}
$temp .= '/pharextract/'.basename(__FILE__, '.phar');
self::$temp = $temp;
self::$origdir = getcwd();
@mkdir($temp, 0777, true);
$temp = realpath($temp);
if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
self::_removeTmpFiles($temp, getcwd());
@mkdir($temp, 0777, true);
@file_put_contents($temp . '/' . md5_file(__FILE__), '');
foreach ($info['m'] as $path => $file) {
$a = !file_exists(dirname($temp . '/' . $path));
@mkdir(dirname($temp . '/' . $path), 0777, true);
clearstatcache();
if ($path[strlen($path) - 1] == '/') {
@mkdir($temp . '/' . $path, 0777);
} else {
file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
@chmod($temp . '/' . $path, 0666);
}
}
}
chdir($temp);
if (!$return) {
include self::START;
}
}
static function tmpdir()
{
if (strpos(PHP_OS, 'WIN') !== false) {
if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
return $var;
}
if (is_dir('/temp') || mkdir('/temp')) {
return realpath('/temp');
}
return false;
}
if ($var = getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
}
static function _unpack($m)
{
$info = unpack('V', substr($m, 0, 4));
$l = unpack('V', substr($m, 10, 4));
$m = substr($m, 14 + $l[1]);
$s = unpack('V', substr($m, 0, 4));
$o = 0;
$start = 4 + $s[1];
$ret['c'] = 0;
for ($i = 0; $i < $info[1]; $i++) {
$len = unpack('V', substr($m, $start, 4));
$start += 4;
$savepath = substr($m, $start, $len[1]);
$start += $len[1];
$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
& 0xffffffff);
$ret['m'][$savepath][7] = $o;
$o += $ret['m'][$savepath][2];
$start += 24 + $ret['m'][$savepath][5];
$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
}
return $ret;
}
static function extractFile($path, $entry, $fp)
{
$data = '';
$c = $entry[2];
while ($c) {
if ($c < 8192) {
$data .= @fread($fp, $c);
$c = 0;
} else {
$c -= 8192;
$data .= @fread($fp, 8192);
}
}
if ($entry[4] & self::GZ) {
$data = gzinflate($data);
} elseif ($entry[4] & self::BZ2) {
$data = bzdecompress($data);
}
if (strlen($data) != $entry[0]) {
die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[7] . ")");
}
if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}
return $data;
}
static function _removeTmpFiles($temp, $origdir)
{
chdir($temp);
foreach (glob('*') as $f) {
if (file_exists($f)) {
is_dir($f) ? @rmdir($f) : @unlink($f);
if (file_exists($f) && is_dir($f)) {
self::_removeTmpFiles($f, getcwd());
}
}
}
@rmdir($temp);
clearstatcache();
chdir($origdir);
}
}
Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
int(7074)
Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE===
+4
Ver Arquivo
@@ -0,0 +1,4 @@
<?php
include dirname(__FILE__) . '/files/nophar.phar';
?>
===DONE===
@@ -0,0 +1,4 @@
in b
<?php include "b/c.php";
in d
===DONE===
+7
Ver Arquivo
@@ -0,0 +1,7 @@
<?php
try {
Phar::mapPhar('hio');
} catch (Exception $e) {
echo $e->getMessage();
}
?>
@@ -0,0 +1 @@
__HALT_COMPILER(); must be declared in a phar
@@ -0,0 +1,4 @@
<?php
var_dump(Phar::getSupportedCompression());
?>
===DONE===
@@ -0,0 +1,3 @@
array(0) {
}
===DONE===
-4
Ver Arquivo
@@ -110,7 +110,6 @@ no_import = (
'/ext/pdo_oci',
'/ext/pdo_odbc',
'/ext/pdo_pgsql',
'/ext/phar',
'/ext/pspell',
'/ext/readline',
'/ext/recode',
@@ -144,9 +143,6 @@ bad_tests = (
'/zend/unset_cv05.php',
'/zend/unset_cv06.php',
# not implemented extensions
'phar', # this appears in filenames
# works in interp but not others
'/tests-lang/bug25922.php',
'/zend/bug34064.php',