diff options
Diffstat (limited to 'ext/phar/tests/zip/files')
26 files changed, 266 insertions, 0 deletions
diff --git a/ext/phar/tests/zip/files/frontcontroller.phar.inc b/ext/phar/tests/zip/files/frontcontroller.phar.inc new file mode 100644 index 0000000000..241dceb57b --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller.phar.inc @@ -0,0 +1,13 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a['index.php'] = 'here is my index'; +$a->setStub('<?php +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller.phar.zip b/ext/phar/tests/zip/files/frontcontroller.phar.zip Binary files differnew file mode 100644 index 0000000000..4ee905dd3a --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller10.phar.inc b/ext/phar/tests/zip/files/frontcontroller10.phar.inc new file mode 100644 index 0000000000..c973cc15d9 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller10.phar.inc @@ -0,0 +1,20 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller10.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.zip'); +$a['index.php'] = '<?php +var_dump($_SERVER["PHP_SELF"]); +var_dump($_SERVER["SCRIPT_NAME"]); +var_dump($_SERVER["SCRIPT_FILENAME"]); +var_dump($_SERVER["REQUEST_URI"]); +var_dump($_SERVER["PHAR_PHP_SELF"]); +var_dump($_SERVER["PHAR_SCRIPT_NAME"]); +var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); +var_dump($_SERVER["PHAR_REQUEST_URI"]); +'; +$a->setStub('<?php +Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE")); +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller10.phar.zip b/ext/phar/tests/zip/files/frontcontroller10.phar.zip Binary files differnew file mode 100644 index 0000000000..c37cb381fb --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller10.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller11.phar.inc b/ext/phar/tests/zip/files/frontcontroller11.phar.inc new file mode 100644 index 0000000000..c24a6f14e4 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller11.phar.inc @@ -0,0 +1,20 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller11.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.zip'); +$a['index.php'] = '<?php +var_dump($_SERVER["PHP_SELF"]); +var_dump($_SERVER["SCRIPT_NAME"]); +var_dump($_SERVER["SCRIPT_FILENAME"]); +var_dump($_SERVER["REQUEST_URI"]); +var_dump($_SERVER["PHAR_PHP_SELF"]); +var_dump($_SERVER["PHAR_SCRIPT_NAME"]); +var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); +var_dump($_SERVER["PHAR_REQUEST_URI"]); +'; +$a->setStub('<?php +Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI")); +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller11.phar.zip b/ext/phar/tests/zip/files/frontcontroller11.phar.zip Binary files differnew file mode 100644 index 0000000000..48e5fc678a --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller11.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.inc b/ext/phar/tests/zip/files/frontcontroller12.phar.inc new file mode 100644 index 0000000000..77c4a1dd0e --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller12.phar.inc @@ -0,0 +1,20 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller12.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.zip'); +$a['index.php'] = '<?php +var_dump($_SERVER["PHP_SELF"]); +var_dump($_SERVER["SCRIPT_NAME"]); +var_dump($_SERVER["SCRIPT_FILENAME"]); +var_dump($_SERVER["REQUEST_URI"]); +var_dump($_SERVER["PHAR_PHP_SELF"]); +var_dump($_SERVER["PHAR_SCRIPT_NAME"]); +var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]); +var_dump($_SERVER["PHAR_REQUEST_URI"]); +'; +$a->setStub('<?php +Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI")); +Phar::webPhar(); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller12.phar.zip b/ext/phar/tests/zip/files/frontcontroller12.phar.zip Binary files differnew file mode 100644 index 0000000000..c086c4d4a4 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller12.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller2.phar.inc b/ext/phar/tests/zip/files/frontcontroller2.phar.inc new file mode 100644 index 0000000000..6cfa052a83 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller2.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller2.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "a.php"); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller2.phar.zip b/ext/phar/tests/zip/files/frontcontroller2.phar.zip Binary files differnew file mode 100644 index 0000000000..7ef43dc000 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller2.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller3.phar.inc b/ext/phar/tests/zip/files/frontcontroller3.phar.inc new file mode 100644 index 0000000000..ab28f7b3d0 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller3.phar.inc @@ -0,0 +1,18 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller3.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +function s($a) +{ + static $b = array("/hi" => "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/zip/files/frontcontroller3.phar.zip b/ext/phar/tests/zip/files/frontcontroller3.phar.zip Binary files differnew file mode 100644 index 0000000000..40c1d4994b --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller3.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller4.phar.inc b/ext/phar/tests/zip/files/frontcontroller4.phar.inc new file mode 100644 index 0000000000..d78399142e --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller4.phar.inc @@ -0,0 +1,18 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller4.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +function s($a) +{ + static $b = array("/hi" => 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/zip/files/frontcontroller4.phar.zip b/ext/phar/tests/zip/files/frontcontroller4.phar.zip Binary files differnew file mode 100644 index 0000000000..4dc83408b0 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller4.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller5.phar.inc b/ext/phar/tests/zip/files/frontcontroller5.phar.inc new file mode 100644 index 0000000000..931fa975e1 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller5.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller5.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array(0 => "oops")); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller5.phar.zip b/ext/phar/tests/zip/files/frontcontroller5.phar.zip Binary files differnew file mode 100644 index 0000000000..0ab0472101 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller5.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller6.phar.inc b/ext/phar/tests/zip/files/frontcontroller6.phar.inc new file mode 100644 index 0000000000..3b551f268d --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller6.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller6.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array("blah" => 100)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller6.phar.zip b/ext/phar/tests/zip/files/frontcontroller6.phar.zip Binary files differnew file mode 100644 index 0000000000..bf98255fe9 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller6.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller7.phar.inc b/ext/phar/tests/zip/files/frontcontroller7.phar.inc new file mode 100644 index 0000000000..42c10bc739 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller7.phar.inc @@ -0,0 +1,12 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller7.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.zip'); +$a['a.php'] = 'hio'; +$a['a.jpg'] = 'hio'; +$a['a.phps'] = '<?php function hio(){}'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array("blah" => null)); +echo "oops did not run\n"; +var_dump($_ENV, $_SERVER); +__HALT_COMPILER();'); +?> diff --git a/ext/phar/tests/zip/files/frontcontroller7.phar.zip b/ext/phar/tests/zip/files/frontcontroller7.phar.zip Binary files differnew file mode 100644 index 0000000000..02fc3e27b6 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller7.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller8.phar.inc b/ext/phar/tests/zip/files/frontcontroller8.phar.inc new file mode 100644 index 0000000000..e04ac414e9 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller8.phar.inc @@ -0,0 +1,13 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller8.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.zip'); +$a['a.phps'] = 'hio1'; +$a['a.jpg'] = 'hio2'; +$a['a.php'] = '<?php function hio(){}'; +$a['fronk.gronk'] = 'hio3'; +$a->setStub('<?php +Phar::webPhar("whatever", "index.php", null, array("jpg" => "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/zip/files/frontcontroller8.phar.zip b/ext/phar/tests/zip/files/frontcontroller8.phar.zip Binary files differnew file mode 100644 index 0000000000..41952ce745 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller8.phar.zip diff --git a/ext/phar/tests/zip/files/frontcontroller9.phar.inc b/ext/phar/tests/zip/files/frontcontroller9.phar.inc new file mode 100644 index 0000000000..50440451f7 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller9.phar.inc @@ -0,0 +1,14 @@ +<?php +@unlink(dirname(__FILE__) . '/frontcontroller9.phar.zip'); +$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.zip'); +$a['a.phps'] = 'hio1'; +$a['a.jpg'] = 'hio2'; +$a['a.php'] = '<?php function hio(){}'; +$a['fronk.gronk'] = 'hio3'; +$a->setStub('<?php +Phar::mungServer(array()); +Phar::webPhar("whatever", "index.php", null, array("jpg" => "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/zip/files/frontcontroller9.phar.zip b/ext/phar/tests/zip/files/frontcontroller9.phar.zip Binary files differnew file mode 100644 index 0000000000..d3f4ff8404 --- /dev/null +++ b/ext/phar/tests/zip/files/frontcontroller9.phar.zip diff --git a/ext/phar/tests/zip/files/make_invalid_tar.php.inc b/ext/phar/tests/zip/files/make_invalid_tar.php.inc new file mode 100644 index 0000000000..cec8ef7793 --- /dev/null +++ b/ext/phar/tests/zip/files/make_invalid_tar.php.inc @@ -0,0 +1,12 @@ +<?php +include dirname(__FILE__) . '/tarmaker.php.inc'; +class corrupter extends tarmaker { +function close() +{ + parent::close(); + $fp = fopen($this->path, 'r+b'); + fseek($fp, 20); + fwrite($fp, 'oopsie'); + fclose($fp); +} +}
\ No newline at end of file diff --git a/ext/phar/tests/zip/files/zipmaker.php.inc b/ext/phar/tests/zip/files/zipmaker.php.inc new file mode 100644 index 0000000000..aceab0d26b --- /dev/null +++ b/ext/phar/tests/zip/files/zipmaker.php.inc @@ -0,0 +1,70 @@ +<?php +// stolen from PEAR2_Pyrus_Developer_Creator_Zip by Greg Beaver, the original author, for use in unit tests +class zipmaker +{ + /** + * Path to archive file + * + * @var string + */ + protected $archive; + /** + * @var ZIPArchive + */ + protected $zip; + protected $path; + function __construct($path) + { + if (!class_exists('ZIPArchive')) { + throw new Exception( + 'Zip extension is not available'); + } + $this->path = $path; + } + + /** + * save a file inside this package + * @param string relative path within the package + * @param string|resource file contents or open file handle + */ + function addFile($path, $fileOrStream) + { + if (is_resource($fileOrStream)) { + $this->zip->addFromString($path, stream_get_contents($fileOrStream)); + } else { + $this->zip->addFromString($path, $fileOrStream); + } + } + + /** + * Initialize the package creator + */ + function init() + { + $this->zip = new ZipArchive; + if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) { + throw new Exception( + 'Cannot open ZIP archive ' . $this->path + ); + } + } + + /** + * Create an internal directory, creating parent directories as needed + * + * This is a no-op for the tar creator + * @param string $dir + */ + function mkdir($dir) + { + $this->zip->addEmptyDir($dir); + } + + /** + * Finish saving the package + */ + function close() + { + $this->zip->close(); + } +}
\ No newline at end of file |