From: Steph Fox Date: Tue, 12 Feb 2008 16:42:35 +0000 (+0000) Subject: - it helps if you add the new files :) X-Git-Tag: RELEASE_2_0_0a1~502 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ad96985c76309facd14e0425d46dbd17eadb73e;p=php - it helps if you add the new files :) --- diff --git a/ext/phar/tests/tar/files/frontcontroller.phar.inc b/ext/phar/tests/tar/files/frontcontroller.phar.inc new file mode 100644 index 0000000000..6f426e8864 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller.phar.inc @@ -0,0 +1,13 @@ +setStub(' diff --git a/ext/phar/tests/tar/files/frontcontroller.phar.tar b/ext/phar/tests/tar/files/frontcontroller.phar.tar new file mode 100644 index 0000000000..522d097845 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller10.phar.inc b/ext/phar/tests/tar/files/frontcontroller10.phar.inc new file mode 100644 index 0000000000..5b132fa117 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller10.phar.inc @@ -0,0 +1,20 @@ +setStub(' diff --git a/ext/phar/tests/tar/files/frontcontroller10.phar.tar b/ext/phar/tests/tar/files/frontcontroller10.phar.tar new file mode 100644 index 0000000000..d43ed916a1 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller10.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller11.phar.inc b/ext/phar/tests/tar/files/frontcontroller11.phar.inc new file mode 100644 index 0000000000..2fa15f097e --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller11.phar.inc @@ -0,0 +1,20 @@ +setStub(' diff --git a/ext/phar/tests/tar/files/frontcontroller11.phar.tar b/ext/phar/tests/tar/files/frontcontroller11.phar.tar new file mode 100644 index 0000000000..c8f98a1e78 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller11.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.inc b/ext/phar/tests/tar/files/frontcontroller12.phar.inc new file mode 100644 index 0000000000..693ef0aa01 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller12.phar.inc @@ -0,0 +1,20 @@ +setStub(' diff --git a/ext/phar/tests/tar/files/frontcontroller12.phar.tar b/ext/phar/tests/tar/files/frontcontroller12.phar.tar new file mode 100644 index 0000000000..06e7e59b03 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller12.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller2.phar.inc b/ext/phar/tests/tar/files/frontcontroller2.phar.inc new file mode 100644 index 0000000000..8ae1171a38 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller2.phar.inc @@ -0,0 +1,12 @@ +setStub(' diff --git a/ext/phar/tests/tar/files/frontcontroller2.phar.tar b/ext/phar/tests/tar/files/frontcontroller2.phar.tar new file mode 100644 index 0000000000..857b116890 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller2.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.inc b/ext/phar/tests/tar/files/frontcontroller3.phar.inc new file mode 100644 index 0000000000..9729d0065b --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller3.phar.inc @@ -0,0 +1,18 @@ +setStub(' "a.phps"); + if (isset($b[$a])) return $b[$a]; + return $a; +} +Phar::webPhar("whatever", "/index.php", null, array(), "s"); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller3.phar.tar b/ext/phar/tests/tar/files/frontcontroller3.phar.tar new file mode 100644 index 0000000000..f733884d12 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller3.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.inc b/ext/phar/tests/tar/files/frontcontroller4.phar.inc new file mode 100644 index 0000000000..eb1d56f0d4 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller4.phar.inc @@ -0,0 +1,18 @@ +setStub(' false); + if (isset($b[$a])) return $b[$a]; + return $a; +} +Phar::webPhar("whatever", "index.php", null, array(), "s"); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller4.phar.tar b/ext/phar/tests/tar/files/frontcontroller4.phar.tar new file mode 100644 index 0000000000..5d11af499c Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller4.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller5.phar.inc b/ext/phar/tests/tar/files/frontcontroller5.phar.inc new file mode 100644 index 0000000000..d6204c7d97 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller5.phar.inc @@ -0,0 +1,12 @@ +setStub(' "oops")); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller5.phar.tar b/ext/phar/tests/tar/files/frontcontroller5.phar.tar new file mode 100644 index 0000000000..e6e9015bf8 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller5.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller6.phar.inc b/ext/phar/tests/tar/files/frontcontroller6.phar.inc new file mode 100644 index 0000000000..66212d82e8 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller6.phar.inc @@ -0,0 +1,12 @@ +setStub(' 100)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller6.phar.tar b/ext/phar/tests/tar/files/frontcontroller6.phar.tar new file mode 100644 index 0000000000..d30b7ab9eb Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller6.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller7.phar.inc b/ext/phar/tests/tar/files/frontcontroller7.phar.inc new file mode 100644 index 0000000000..74adf2c008 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller7.phar.inc @@ -0,0 +1,12 @@ +setStub(' null)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller7.phar.tar b/ext/phar/tests/tar/files/frontcontroller7.phar.tar new file mode 100644 index 0000000000..c7ccc940c1 Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller7.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller8.phar.inc b/ext/phar/tests/tar/files/frontcontroller8.phar.inc new file mode 100644 index 0000000000..f51a762806 --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller8.phar.inc @@ -0,0 +1,13 @@ +setStub(' "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller8.phar.tar b/ext/phar/tests/tar/files/frontcontroller8.phar.tar new file mode 100644 index 0000000000..98495717ce Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller8.phar.tar differ diff --git a/ext/phar/tests/tar/files/frontcontroller9.phar.inc b/ext/phar/tests/tar/files/frontcontroller9.phar.inc new file mode 100644 index 0000000000..758ce4ff4e --- /dev/null +++ b/ext/phar/tests/tar/files/frontcontroller9.phar.inc @@ -0,0 +1,14 @@ +setStub(' "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/tar/files/frontcontroller9.phar.tar b/ext/phar/tests/tar/files/frontcontroller9.phar.tar new file mode 100644 index 0000000000..481864c1cf Binary files /dev/null and b/ext/phar/tests/tar/files/frontcontroller9.phar.tar differ diff --git a/ext/phar/tests/tar/files/make_invalid_tar.php.inc b/ext/phar/tests/tar/files/make_invalid_tar.php.inc new file mode 100644 index 0000000000..c18bd199b3 --- /dev/null +++ b/ext/phar/tests/tar/files/make_invalid_tar.php.inc @@ -0,0 +1,9 @@ +tmp, 'oopsie'); + fclose($this->tmp); +} +} \ No newline at end of file diff --git a/ext/phar/tests/tar/files/tarmaker.php.inc b/ext/phar/tests/tar/files/tarmaker.php.inc new file mode 100644 index 0000000000..902507881a --- /dev/null +++ b/ext/phar/tests/tar/files/tarmaker.php.inc @@ -0,0 +1,169 @@ +compress = $compress; + if ($compress === 'bz2' && !function_exists('bzopen')) { + throw new PEAR2_Pyrus_Developer_Creator_Exception( + 'bzip2 extension not available'); + } + if ($compress === 'zlib' && !function_exists('gzopen')) { + throw new PEAR2_Pyrus_Developer_Creator_Exception( + 'zlib extension not available'); + } + $this->path = $path; + } + + /** + * save a file inside this package + * + * This code is modified from Vincent Lascaux's File_Archive + * package, which is licensed under the LGPL license. + * @param string relative path within the package + * @param string|resource file contents or open file handle + */ + function addFile($path, $fileOrStream, $stat = null) + { + clearstatcache(); + if ($stat === null) { + if (is_resource($fileOrStream)) { + $stat = fstat($fileOrStream); + } else { + $stat = array( + 'mode' => 0x8000 + 0644, + 'uid' => 0, + 'gid' => 0, + 'size' => strlen($fileOrStream), + 'mtime' => time(), + ); + } + } + + $link = null; + if ($stat['mode'] & 0x4000) { + $type = 5; // Directory + } else if ($stat['mode'] & 0x8000) { + $type = 0; // Regular + } else if ($stat['mode'] & 0xA000) { + $type = 1; // Link + $link = @readlink($current); + } else { + $type = 9; // Unknown + } + + $filePrefix = ''; + if (strlen($path) > 255) { + throw new Exception( + "$path is too long, must be 255 characters or less" + ); + } else if (strlen($path) > 100) { + $filePrefix = substr($path, 0, strlen($path)-100); + $path = substr($path, -100); + } + + $block = pack('a100a8a8a8a12A12', + $path, + decoct($stat['mode']), + sprintf('%6s ',decoct($stat['uid'])), + sprintf('%6s ',decoct($stat['gid'])), + sprintf('%11s ',decoct($stat['size'])), + sprintf('%11s ',decoct($stat['mtime'])) + ); + + $blockend = pack('a1a100a6a2a32a32a8a8a155a12', + $type, + $link, + 'ustar', + '00', + 'Pyrus', + 'Pyrus', + '', + '', + $filePrefix, + ''); + + $checkheader = array_merge(str_split($block), str_split($blockend)); + if (!function_exists('_pear2tarchecksum')) { + function _pear2tarchecksum($a, $b) {return $a + ord($b);} + } + $checksum = 256; // 8 * ord(' '); + $checksum += array_reduce($checkheader, '_pear2tarchecksum'); + + $checksum = pack('a8', sprintf('%6s ', decoct($checksum))); + + fwrite($this->tmp, $block . $checksum . $blockend, 512); + if (is_resource($fileOrStream)) { + stream_copy_to_stream($fileOrStream, $this->tmp); + if ($stat['size'] % 512) { + fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512)); + } + } else { + fwrite($this->tmp, $fileOrStream); + if (strlen($fileOrStream) % 512) { + fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512)); + } + } + } + + /** + * Initialize the package creator + */ + function init() + { + switch ($this->compress) { + case 'zlib' : + $this->tmp = gzopen($this->path, 'wb'); + break; + case 'bz2' : + $this->tmp = bzopen($this->path, 'w'); + break; + case 'none' : + $this->tmp = fopen($this->path, 'wb'); + break; + default : + throw new Exception( + 'unknown compression type ' . $this->compress); + } + } + + /** + * Create an internal directory, creating parent directories as needed + * + * @param string $dir + */ + function mkdir($dir) + { + $this->addFile($dir, "", array( + 'mode' => 0x4000 + 0644, + 'uid' => 0, + 'gid' => 0, + 'size' => 0, + 'mtime' => time(), + )); + } + + /** + * Finish saving the package + */ + function close() + { + fwrite($this->tmp, pack('a1024', '')); + fclose($this->tmp); + } +} \ No newline at end of file