summaryrefslogtreecommitdiff
path: root/test/index.php
diff options
context:
space:
mode:
authorpabs <pabs@pablotron.org>2009-01-29 20:39:34 +0000
committerpabs <pabs@pablotron.org>2009-01-29 20:39:34 +0000
commit7d675c8721af127bc941d0bde8f333fdbdcb47f5 (patch)
tree8c84d42199d858aa1c993b2bcf667dc9981d112a /test/index.php
parentcf40446dfb8469f295bbb4147128a5451ec2b3b4 (diff)
downloadzipstream-php-7d675c8721af127bc941d0bde8f333fdbdcb47f5.tar.bz2
zipstream-php-7d675c8721af127bc941d0bde8f333fdbdcb47f5.zip
update test/index.phpv0.2.0
Diffstat (limited to 'test/index.php')
-rw-r--r--test/index.php33
1 files changed, 27 insertions, 6 deletions
diff --git a/test/index.php b/test/index.php
index 33e2fc5..ec89f76 100644
--- a/test/index.php
+++ b/test/index.php
@@ -3,29 +3,50 @@
# load zipstream class
require '../zipstream.php';
+# get path to current file
+$pwd = dirname(__FILE__);
+
# add some random files
$files = array(
- '/store/dl/wurfl.xml.gz',
- '/store/dl/hugh_hefner_interview.html',
+ '../extras/zip-appnote-6.3.1-20070411.txt',
+ '../zipstream.php',
);
+# create new zip stream object
$zip = new ZipStream('test.zip', array(
'comment' => 'this is a zip file comment. hello?'
));
+# common file options
$file_opt = array(
+ # file creation time (2 hours ago)
'time' => time() - 2 * 3600,
+
+ # file comment
'comment' => 'this is a file comment. hi!',
);
# add files under folder 'asdf'
-foreach ($files as $file)
- $zip->add_file('asdf/' . basename($file), file_get_contents($file), $file_opt);
+foreach ($files as $file) {
+ # build absolute path and get file data
+ $path = ($file[0] == '/') ? $file : "$pwd/$file";
+ $data = file_get_contents($path);
+
+ # add file to archive
+ $zip->add_file('asdf/' . basename($file), $data, $file_opt);
+}
# add same files again wihtout a folder
-foreach ($files as $file)
- $zip->add_file(basename($file), file_get_contents($file), $file_opt);
+foreach ($files as $file) {
+ # build absolute path and get file data
+ $path = ($file[0] == '/') ? $file : "$pwd/$file";
+ $data = file_get_contents($path);
+
+ # add file to archive
+ $zip->add_file(basename($file), $data, $file_opt);
+}
+# finish archive
$zip->finish();
?>