summaryrefslogtreecommitdiff
path: root/ext/phar/tests/zip/files
diff options
context:
space:
mode:
authorSteph Fox <sfox@php.net>2008-02-11 20:55:44 +0000
committerSteph Fox <sfox@php.net>2008-02-11 20:55:44 +0000
commitef46f3e3a2a7d267e31be072be3e5843901ea278 (patch)
tree0ed8a5108359c0516ff904f91f47f42231983648 /ext/phar/tests/zip/files
parent914c94d497ac1bc2433fa431dc0cee881c3ec06c (diff)
downloadphp-git-ef46f3e3a2a7d267e31be072be3e5843901ea278.tar.gz
Funnily enough those frontcontroller tests still pass here! Investigating...
Diffstat (limited to 'ext/phar/tests/zip/files')
-rw-r--r--ext/phar/tests/zip/files/frontcontroller.phar.inc13
-rw-r--r--ext/phar/tests/zip/files/frontcontroller.phar.zipbin0 -> 625 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller10.phar.inc20
-rw-r--r--ext/phar/tests/zip/files/frontcontroller10.phar.zipbin0 -> 471 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller11.phar.inc20
-rw-r--r--ext/phar/tests/zip/files/frontcontroller11.phar.zipbin0 -> 461 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.inc20
-rw-r--r--ext/phar/tests/zip/files/frontcontroller12.phar.zipbin0 -> 465 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller2.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller2.phar.zipbin0 -> 531 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.inc18
-rw-r--r--ext/phar/tests/zip/files/frontcontroller3.phar.zipbin0 -> 826 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.inc18
-rw-r--r--ext/phar/tests/zip/files/frontcontroller4.phar.zipbin0 -> 822 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller5.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller5.phar.zipbin0 -> 554 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller6.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller6.phar.zipbin0 -> 559 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller7.phar.inc12
-rw-r--r--ext/phar/tests/zip/files/frontcontroller7.phar.zipbin0 -> 559 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller8.phar.inc13
-rw-r--r--ext/phar/tests/zip/files/frontcontroller8.phar.zipbin0 -> 684 bytes
-rw-r--r--ext/phar/tests/zip/files/frontcontroller9.phar.inc14
-rw-r--r--ext/phar/tests/zip/files/frontcontroller9.phar.zipbin0 -> 697 bytes
-rw-r--r--ext/phar/tests/zip/files/make_invalid_tar.php.inc12
-rw-r--r--ext/phar/tests/zip/files/zipmaker.php.inc70
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
new file mode 100644
index 0000000000..4ee905dd3a
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..c37cb381fb
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller10.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..48e5fc678a
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller11.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..c086c4d4a4
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller12.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..7ef43dc000
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller2.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..40c1d4994b
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller3.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..4dc83408b0
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller4.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..0ab0472101
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller5.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..bf98255fe9
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller6.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..02fc3e27b6
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller7.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..41952ce745
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller8.phar.zip
Binary files differ
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
new file mode 100644
index 0000000000..d3f4ff8404
--- /dev/null
+++ b/ext/phar/tests/zip/files/frontcontroller9.phar.zip
Binary files differ
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