Commit Graph

464 Commits

Author SHA1 Message Date
Greg Beaver
7149523766 add safety check to prevent unlinkArchive() from being called by a file within the archive 2008-05-11 21:15:47 +00:00
Greg Beaver
38d5943ee6 increase code coverage of funcinterceptors to 90%+, fix many bugs, fix errant wrong test condition in fgc_edgecases 2008-05-11 19:17:51 +00:00
Greg Beaver
53e02373d0 fix handling of mounted entries when flushing in all phars, and of deleted entries with open references in tar-based phars, do not extract mounted entries, add to test 2008-05-08 02:58:45 +00:00
Greg Beaver
f134a909c3 optimize phar filename extension detection to first search through known phars. This eliminates several stat/realpath calls for archives with lots of files 2008-05-07 17:24:22 +00:00
Greg Beaver
eda25ddb34 validate user-supplied aliases when converting archives to other formats 2008-05-07 06:36:24 +00:00
Greg Beaver
549bf83bd1 [DOC]
remove phar.extract_list
remove Phar::getExtractList()
2008-05-07 05:38:31 +00:00
Greg Beaver
196f0ef42b fix segfault in buildfromdirectory2 test and potential segfault 2008-05-06 21:23:48 +00:00
Greg Beaver
5ba8ca70a4 fix alias overloading handling for archives that are not in use 2008-05-06 21:14:53 +00:00
Steph Fox
c322c1a94a - Kill Windows warning when int meets short
- All tests still pass
2008-05-03 21:09:56 +00:00
Greg Beaver
a180fcc9bc add Phar::unlinkArchive() to allow complete removal of a parsed phar archive from memory and disk 2008-05-03 02:04:24 +00:00
Greg Beaver
bfbe53eeb2 refactor isTar/isZip/isPhar into isFileFormat(int format) where format is one of Phar::TAR,, Phar::ZIP, Phar::PHAR
[DOC]
2008-05-02 05:05:56 +00:00
Greg Beaver
e0bc2b2be1 update TODO, re-order methods to be alphabetical, tweak extractTo to set permissions and handle NULL for files
# this also matches the docs I just committed :)
2008-05-02 04:44:39 +00:00
Greg Beaver
0a3fc4faba fix unix-only valgrind issue by initializing arch 2008-04-30 23:44:30 +00:00
Greg Beaver
483018e170 remove unneeded exception handling (webPhar is always within an outer zend_execute block which handles exceptions for us, this is unnecessary) 2008-04-30 02:20:48 +00:00
Steph Fox
8559a2dbde - Prevent phars with empty manifests flushing to disk
- This would've fixed that test... removing clean section

@Greg: I commented out the call that breaks the Windows build, pending a decision about its future.
2008-04-29 12:06:54 +00:00
Greg Beaver
984ea1f437 fix segfault (now all tests pass here) 2008-04-28 23:00:46 +00:00
Greg Beaver
7220c19556 fix tar generation - we were subtly corrupting the header with \0 because of use of strcpy 2008-04-28 16:44:53 +00:00
Greg Beaver
5da6c48f7d add open_basedir/safe_mode checks for files in Phar::addFile() 2008-04-27 23:59:41 +00:00
Steph Fox
bcd2ddd018 - Kill another one from the gcov site's parameter parsing report 2008-04-27 16:42:03 +00:00
Steph Fox
2ea698eae7 - Make it possible to extract all *and* overwrite 2008-04-27 11:26:15 +00:00
Steph Fox
77dcb8cffd - Kill a few uninitialized vars (thanks gcov) 2008-04-27 10:14:00 +00:00
Greg Beaver
79a45a9666 fix buildfromiterator base to exclude directory separator on unix or windows, fix 10 test to have new tests 2008-04-26 17:09:58 +00:00
Steph Fox
cf7f50e42c - Added a RecursiveIterator/buildFromIterator test
- Fixed up bug13727.phpt to take < 15 minutes :\\ and clean up after itself
- Cleaned up protos/reflection data
- Added myself to package.xml credits
2008-04-26 13:22:38 +00:00
Greg Beaver
0c2f3b760a add Phar::extractTo(dest_directory[, mixed files[, bool overwrite]])
this is very similar to ext/zip's extractTo and is based on that code, with the addition of the third parameter, which
is used to allow overwriting existing files (disallowed by default, unlike ext/zip's implementation)
[DOC]
2008-04-26 05:31:00 +00:00
Steph Fox
dbb4618bd5 - cs 2008-04-26 02:04:09 +00:00
Steph Fox
f040cb6492 - fixed those pesky memleaks 2008-04-26 01:52:22 +00:00
Steph Fox
9bf8d7429e - implemented Phar::buildFromDirectory
@Greg: There are two (identical) recurring memleaks I can't seem to kill, both marked FIXME. Would you please take a look?

[DOC] $phar->buildFromDirectory(dirname[, regex]). Return value is an array pairing each file in the archive index with the original path on the filesystem.
2008-04-25 21:37:41 +00:00
Greg Beaver
8657ab7e5a add test for bug #13727, fix bug #13727 2008-04-25 16:50:22 +00:00
Greg Beaver
84004bf248 new test with code coverage for PharFileInfo::setMetadata/delMetadata, improve error messages 2008-04-25 16:05:05 +00:00
Greg Beaver
13dc477de2 new code coverage test, improve clarity of error message when chmod is used on a temp directory 2008-04-25 15:53:02 +00:00
Greg Beaver
efe519c194 fix access fault on windows, fix memleak on all platforms when accessing a temp directory via offsetGet 2008-04-25 04:34:03 +00:00
Greg Beaver
0db641af3e rework PharFileInfo->decompress and add failing test 2008-04-24 19:57:22 +00:00
Greg Beaver
91e67a4fbd test PharFileInfo::__construct, fix potential segfault, and bad logic in phar detection 2008-04-24 05:18:50 +00:00
Greg Beaver
8f0c9caac5 remove redundant unreachable code in Phar::copy, augment test, and add failing condition that needs to be fixed 2008-04-24 04:14:05 +00:00
Greg Beaver
696dafa370 new test for Phar::decompress() 2008-04-24 04:05:20 +00:00
Greg Beaver
3190bd0884 increase code coverage, fix minor memleak 2008-04-23 18:54:09 +00:00
Greg Beaver
ab1d8adb96 fix default format conversion, increase code coverage 2008-04-23 18:44:43 +00:00
Greg Beaver
3b8fc7309f new test increases code coverage, fix memleak found by test 2008-04-23 18:30:53 +00:00
Greg Beaver
c034683550 new test for Phar::isValidPharFilename. Fix Phar::isValidPharFilename. Fix extension detection for all cases 2008-04-23 18:11:20 +00:00
Greg Beaver
19088c1930 remove/move unreachable code 2008-04-23 17:23:32 +00:00
Greg Beaver
1dc190e680 improve rewrite callback support, add test for callback that does not return string/false 2008-04-23 17:18:28 +00:00
Greg Beaver
ce5732112e new test for invalid rewrite callback 2008-04-23 16:47:12 +00:00
Greg Beaver
76b8f30659 new test for webPhar with phar.extract_list 2008-04-23 16:00:06 +00:00
Greg Beaver
5224d341b6 ensure freeing of cwd/name happens in all cases 2008-04-22 17:34:00 +00:00
Greg Beaver
0338b28939 re-enable disabled cwd code 2008-04-22 17:19:06 +00:00
Greg Beaver
d8b4c2795e remove unreachable code, add test for large non-php file 2008-04-22 17:17:29 +00:00
Greg Beaver
379bcf1f14 remove unreachable code 2008-04-22 17:13:07 +00:00
Greg Beaver
cb8f158cd5 fix PATH_INFO munging, add to test case 2008-04-22 17:11:30 +00:00
Greg Beaver
5ac9c1f23e remove unreachable code, add test for no file extension and unknown file extension with Phar::webPhar 2008-04-22 17:03:10 +00:00
Greg Beaver
4388a65aa8 fix Phar::mount() to also allow running externally with full phar:// path, add test 2008-04-21 18:21:54 +00:00
Greg Beaver
e0873a380d fix Phar::running() 2008-04-21 18:06:20 +00:00
Greg Beaver
25cdc7de2b fix discovery of files hidden in a URL - makes using any regular front controller possible 2008-04-21 17:59:28 +00:00
Greg Beaver
2f56c7f343 new test for custom 404 handler, fix segfault found by test 2008-04-21 17:46:24 +00:00
Greg Beaver
779fec2278 implement opendir for mounted directories - much simpler to do than I initially thought 2008-04-21 16:29:09 +00:00
Greg Beaver
3d858f4aa9 implement symbolic link support within a tar-based phar archive
this also resulted in a major fix for mounted directories, which were recycling the 'link' field which
could cause stupid conflicts with actual links, so move that to new 'tmp' field.
2008-04-21 06:17:51 +00:00
Greg Beaver
f870b8ae74 fix ZTS build and Phar::isValidPharFilename 2008-04-19 17:24:26 +00:00
Greg Beaver
c4f502fae0 COMPLETELY rework filename extension detection. Now the only requirements are:
1 - executable phars must contain '.phar' in the filename
2 - non-executable phars must not contain '.phar' and must have an extension of at least 1 character

In addition, phar filenames must exist if opened for read, and the directory containing the phar must exist if opened for creation
if opened for creation, the file must not already exist
[DOC]
2008-04-18 04:13:13 +00:00
Steph Fox
31596d1b45 - Fix ZTS build 2008-04-14 17:14:54 +00:00
Greg Beaver
0814b2df09 fix build if SPL is disabled 2008-04-12 21:43:39 +00:00
Greg Beaver
b0f281b159 restore Phar->compress/decompress() to simplify $phar->convertToExecutable(NULL, Phar::GZ) to $phar->compress(Phar::GZ)
[DOC]
2008-04-11 13:41:59 +00:00
Greg Beaver
8f28d19d4e cosmetics, extra space 2008-04-11 13:26:36 +00:00
Greg Beaver
3493fb6561 combine PharFileInfo->setCompressedGZ/setCompressedBZIP2 into compress() with parameter Phar::GZ or Phar::BZ2
use ZEND_ACC_PUBLIC in PharFileInfo definitions, to be consistent
[DOC]
2008-04-11 13:26:03 +00:00
Greg Beaver
ab34fcac05 merge PharFileInfo->isCompressed/isCompressedGZ/isCompressedBZIP2 by adding an
optional parameter to isCompressed for testing specific compression algorithm
[DOC]
2008-04-11 13:07:14 +00:00
Greg Beaver
c07a07ea68 change PharFileInfo->setUncompressed to decompress
[DOC]
2008-04-11 12:56:53 +00:00
Greg Beaver
c0d82e966f refactor compress/convertToTar/convertToPhar/convertToZip/convertToExecutable/convertToData
into 2 methods:
convertToExecutable/convertToData.  Both methods accept 3 optional parameters
1 archive type, Phar::PHAR, Phar::TAR, or Phar::ZIP
2 compression Phar::NONE, Phar::GZ, or Phar::BZ2
3 file extension.  Default is <format>.<compression> where .phar.tar is executable .tar
convertToExecutable always returns a Phar object
convertToData always returns a PharData object
also added Phar::PHAR, Phar::TAR, and Phar::ZIP class constants
[DOC]
2008-04-11 04:20:15 +00:00
Greg Beaver
f0ff6fb109 s/getContents/getContent/ 2008-04-10 13:41:29 +00:00
Greg Beaver
61b5fc48e3 re-factor all-file compression. Remove compressAllFilesGZ/compressAllFilesBZ2 in favor of
unifying compressFiles which accepts Phar::GZ or Phar::BZ2 as argument.  rename uncompressAllFiles to decompressFiles
2008-04-10 13:40:26 +00:00
Greg Beaver
06df9bff83 add Phar->isWritable() for detecting whether a phar archive can be written to based on phar.readonly combined with actual file permissions
[DOC]
2008-04-10 03:32:10 +00:00
Greg Beaver
abfc228f36 add addFile/addFromString/addEmptyDir. API is identical to ext/zip
[DOC]
2008-04-09 19:23:31 +00:00
Greg Beaver
e56beeeefd add PharFileInfo->getContents() to retrieve file contents
[DOC]
2008-04-09 18:12:41 +00:00
Greg Beaver
2e9fca4f0b fix read/write for PharData object, update tests to current API 2008-03-24 03:01:31 +00:00
Greg Beaver
b4b890cb8f check for invalid aliases, add tests for this and direct setting of stub/alias 2008-03-24 01:33:30 +00:00
Greg Beaver
cea3169ca6 prevent direct setting of stub or alias in tar/zip 2008-03-24 01:18:50 +00:00
Greg Beaver
95eeee9156 not all tests have been converted over to the new API, but it works
conversion is now split into 3 separate methods
1\) convertToZip\(\) convertToTar\(\) and convertToPhar\(\) exclusively change file format
2\) compress\(\) sets compression, accepting Phar::GZ, Phar::BZ2, or Phar::NONE
3\) convertToExecutable\(\) allows stub creation in tar/zip, convertToData\(\) prevents it

all methods return either Phar or PharData objects, allowing fluent interface.

only 1 test has been converted to the new format, but the API works
2008-03-23 22:42:45 +00:00
Greg Beaver
cac70206f2 add Phar->getPath() for retrieving the full path to the phar archive.
this is useful for renaming and also always returns the realpath()
2008-03-23 19:03:15 +00:00
Greg Beaver
ca92928b48 fix param parsing for Phar::running() to be optional
# this is the last bug for ZF app - it now works!
2008-03-23 17:36:57 +00:00
Greg Beaver
39c4f38c27 rename Phar::getRunningPhar\(\) to Phar::running\(\) and by default return the full
phar url, if optional parameter is false, return the path to the phar on disk.  Fix a double free on failed mount
2008-03-23 06:00:31 +00:00
Greg Beaver
15f8facded fix Bug #13110: using rewrite parameter to webPhar causes memory error 2008-03-22 22:56:04 +00:00
Greg Beaver
6cef8da201 move all blah++ to ++blah where possible for those with crapass compilers 2008-03-22 22:11:49 +00:00
Greg Beaver
1b05ce68d7 fix all frontcontroller tests - cgi sapi was not being detected, only fastcgi 2008-03-22 22:04:21 +00:00
Steph Fox
c0619c6523 Make versioning more standard 2008-03-22 17:09:24 +00:00
Marcus Boerger
e08556eb2e - Constify 2008-03-22 00:11:43 +00:00
Marcus Boerger
4d8073056c - Don't throw exception for uninitialized instance 2008-03-21 23:56:52 +00:00
Greg Beaver
891067c975 fix the memleak - but this breaks the \*compressAllFiles\*() methods because of fatal flaw
in renaming implementation - see pecl-dev email for details
2008-03-21 19:54:07 +00:00
Steph Fox
c11bcd5414 Deliberate test breakage (no idea how many) in an attempt to see where the valgrind 'bad news' is coming from on gcov.php.net. 2008-03-21 05:22:10 +00:00
Antony Dovgal
044f39293b fix 5_3 ZTS build 2008-03-17 08:55:56 +00:00
Marcus Boerger
58f7de98f4 - Fix build 2008-03-13 19:43:14 +00:00
Steph Fox
3ee08069a6 Rename archive during compressAllFiles*()
Note: this only works for tar archives at present pending a fix for bug #13352
2008-03-09 04:46:16 +00:00
Steph Fox
8343d7c139 - A bit more work on PharData creation/conversion.
- If readonly=0, why not $phardata->convertToPhar()?
- Known issue with directories creating 'as-file' copies within the archive (all formats)
@Greg/Marcus/Tony: This passes all tests on my box, 5.2/5.3/release_ts/debug_ts, and I can't find any more memleaks. Obviously this is too good to be true, so if conversion is still messy elsewhere please feel free to fix, or bug and assign to me.
2008-03-03 08:41:15 +00:00
Steph Fox
15fefd3692 All tests pass here now. Thanks Philip for reporting compiler errors that don't show on my setup. 2008-03-01 21:31:03 +00:00
Steph Fox
ad0a7679ac Kill an unnecessary bit of internal docu and add 'compression' to the TODO 2008-02-28 02:09:49 +00:00
Steph Fox
413df68971 Forgot to return... not that I understand this stuff... 2008-02-28 01:16:43 +00:00
Steph Fox
9e61358eda Allow alias for phar.tar/phar.zip 2008-02-28 01:08:34 +00:00
Steph Fox
001ffec19f Initial support for PharData object.
Note: two tests currently fail. IMHO we should be throwing E_ERROR on encountering a corrupted archive, not trying to throw a trail of exceptions...
New tests still to be written, not all functionality is in place yet.
2008-02-27 21:34:26 +00:00
Steph Fox
6a63b3921e Update protos. 2008-02-25 16:27:23 +00:00
Steph Fox
f5ab70a3b9 Update reflection info 2008-02-25 12:21:19 +00:00
Greg Beaver
ec7f89fe79 implement Phar::mount() for directories, add test
# opendir not yet implemented for mounted directories
2008-02-25 04:23:36 +00:00
Steph Fox
8513db73bb A bunch of stuff to do with filename conversion. Hopefully it won't sink the ship. 2008-02-24 22:29:06 +00:00
Greg Beaver
0e6457b2cf free spprintf'ed stub after using it 2008-02-23 14:59:52 +00:00
Steph Fox
b2dbfbc321 As the line below says - there shouldn't be an exception here. 2008-02-21 18:51:54 +00:00
Steph Fox
6cc2426ff1 A much better solution for setDefaultStub(). The convertTo*() fixes should be trivial now. 2008-02-21 00:24:38 +00:00
Steph Fox
d8bebd7259 Implement $phar->setDefaultStub()
Note that Phar::createDefaultStub() still exists at this point
2008-02-20 19:22:12 +00:00
Steph Fox
9752739cf2 Let's have reflection reflect reality... 2008-02-20 17:58:56 +00:00
Steph Fox
7bb00d024e Allow createDefaultStub() to accept 0, 1 or 2 parameters. Default for both CLI and web is 'index.php'.
@Greg: this breaks a handful of tests due to the change in stub.h - will fix in a bit. The only one that's interesting is you can't do strlen(Phar::createDefaultStub()) and expect anything other than an exception now.
2008-02-18 21:45:02 +00:00
Steph Fox
87626d56d2 Fix ZTS build *nicely* 2008-02-18 04:42:04 +00:00
Greg Beaver
6798dc44ed add Phar::mount() to manually mount a file or directory
# TODO: implement directory mounting.  Involves scanning paths that are not exact matches for a partial match.
# this also means maintaining a per-phar hash of mounted directories for quick matching
2008-02-18 04:32:50 +00:00
Greg Beaver
f72ce59e95 remove refcount hack to workaround zlib memleak fixed in zlib
intercepted file functions now fall through if the file is not found in the phar, this allows access to external libraries
actually use include_path for locating files for inclusion and in file_get_contents/fopen when include_path is requested.
This allows applications like Zend Framework MVC implementation to function properly
2008-02-13 15:00:31 +00:00
Greg Beaver
ba002c5b9c revert last commit to phar_object.c
fix open file pointers issue on windows
2008-02-11 17:13:18 +00:00
Greg Beaver
4c68617106 add destructor for Phar object to decrease refcount 2008-02-11 16:49:53 +00:00
Greg Beaver
d659ce7a0c fix windows pathname issues 2008-02-11 07:33:20 +00:00
Greg Beaver
8cd58822c3 fix TSRM and 5.2 build 2008-02-11 06:58:56 +00:00
Greg Beaver
de5238a3bc minor refactoring to remove 1 call to zend_get_executed_filename() 2008-02-11 06:49:22 +00:00
Greg Beaver
78e8eb3900 major refactoring of internal handling of aliases.
1) rename is_explicit_alias to is_temporary_alias for clarity and flip the value
2) fix setAlias so that it sets a permanent to-be-saved alias, and restores the old one on error
3) fix Phar constructor to work with sub-directories in RecursiveDirectoryIterator
2008-02-11 06:46:44 +00:00
Greg Beaver
3874e12ee5 fix 5.2 build 2008-02-11 04:48:58 +00:00
Antony Dovgal
6d9453aa91 add ifdefs and fix folding 2008-02-08 09:25:02 +00:00
Antony Dovgal
271e0394d7 fix 5_3 build 2008-02-08 09:21:24 +00:00
Greg Beaver
c31f04b5f3 SEPARATE_ZVAL does not work for this situation. We always want
to duplicate and copy, so do it manually and reset refcount to 1
2008-02-08 03:53:17 +00:00
Greg Beaver
a3c910739f fix flipped logic 2008-02-08 01:08:02 +00:00
Greg Beaver
43f2638634 better fix for invalid mem access 2008-02-08 00:58:39 +00:00
Greg Beaver
7575b012f2 fix invalid read/write if strstr() returns NULL 2008-02-08 00:55:38 +00:00
Greg Beaver
e67c584348 [DOC]
refactor the $rewrites parameter in Phar::webPhar.  Now it is a callback
that accepts the path requested.  This callback should return the actual filename
requested as a string, or false to deny access as HTTP 403.
Also fix incorrect munging of SCRIPT_NAME variable in mungServer
More importantly, Phar::webPhar now finds the filename hidden in:
http://localhost/myphar.phar/internal/file.php/extra/stuff
as 'internal/file.php' in phar 'myphar.phar' with REQUEST_URI '/internal/file.php/extra/stuff'
this will allow pharring up apps that use REQUEST_URI for front controller stuff.
2008-02-07 23:42:03 +00:00
Greg Beaver
1cac0aa8e2 fix webPhar() in CGI sapi, update tests to reflect reality of how these ENV vars are passed 2008-02-07 04:24:58 +00:00
Greg Beaver
2b9a4279dd fix logic of path redirection. always prepend index_php with "/" if it doesn't have it,
and then if path_info ends with "/" just use entry + 1
2008-02-02 05:20:37 +00:00
Greg Beaver
47320359e9 remove unused variable, eliminate an invalid read reported by valgrind 2008-02-01 19:50:06 +00:00
Antony Dovgal
addf32d7d9 we don't want to modify the pointer contents, we just want to change the pointer itself 2008-02-01 11:25:59 +00:00
Marcus Boerger
7d3758fa08 - SPL has been changed 2008-01-30 23:50:23 +00:00
Marcus Boerger
33dc86c435 - Fixed glob:// stream handling in (Recursive)DirectoryIterator. 2008-01-30 20:31:09 +00:00
Greg Beaver
f4e4ad0cd1 fix PharFileInfo->setAlias (was wildly broken)
fix directory creation in zip archives
update zip tests to use phar to create the zip, and then copy to a new file
2008-01-28 20:18:15 +00:00
Steph Fox
9fd5c0b438 - Moved phar_unixify_path_separators() to a single central point
- The last two VC 6 compiler warnings gone. Please test under *nix.
2008-01-28 14:39:17 +00:00
Greg Beaver
6cdabede4c remove ext/zip dependency entirely, write better native zip support
re-organize, create util.c, move entry_info/archive_data/entry_data access methods to this file
refactor entry->fp, now this is abstracted with phar_get_efp() and phar_seek_efp(), fixes all weird dependency issues
permanently solve the "millions of file pointers" issue for read access.  All compressed files are read into a single
temporary stream, and their constraints are controlled by the entry->fp abstraction

Improvements in this zip implementation over ext/zip:
 * full read/write support for bzip2 compressed files
 * much more efficient access for accessing only a few files within large zip files, as crc/header validation is
   done just-in-time
 * full stream support for opendir/rename/rmdir/mkdir as well as all of the other stream funcs
 * full support for setting file perms via Phar::chmod(), stored as zip-standard extra field
 * no problem with large zips and many open file pointers

# TODO: add big-endian system support for tar/zip file format headers, otherwise the implementation is complete
# TODO: test on windows and fix any windows-specific issues
# TODO: verify zips created work with unzip/winzip/windows explorer and so on
2008-01-28 08:52:08 +00:00
Steph Fox
69afbc1099 "What helly said" 2008-01-25 16:05:26 +00:00
Steph Fox
61c3a60815 Make all possible build combinations work under doze (external zip library) 2008-01-25 15:00:24 +00:00
Greg Beaver
b2412c4568 fix problems found while documenting. Throw consistent exceptions, chmod is not allowed on
temporary directories, but is allowed on regular ones
allow uncompressAllFiles() to decompress a gzip/bzipped tar archive
fix some protos
2008-01-21 05:28:09 +00:00
Greg Beaver
117f5e2639 add web-based support for default stub, now phars written with webPhar() will work
out of the box regardless of server configuration with phar file format
split up stub.h strings into 2046 byte chunks because MS VC 6 is friggin stupid
2008-01-20 00:49:45 +00:00
Greg Beaver
d583fae0cc add Phar::createDefaultStub(), which can take as an argument the filename
that should be loaded as a "bootstrap" for the phar archive
2008-01-19 04:26:22 +00:00
Greg Beaver
9a59e60657 remove HAVE_ZIP defines just as we removed HAVE_BZ2 defines and for the same reason
update outdated description of phar in config.m4
make zip extension mandatory on windows for compiling purposes
2008-01-17 03:59:07 +00:00
Greg Beaver
a3718dcfa3 no need to use conditional defines for bz2, we don't call it except indirectly through stream wrappers.
After removing HAVE_BZ2 conditionals, phar works even if bz2 is not present on installation through pecl
2008-01-17 03:48:29 +00:00
Greg Beaver
0e934c70d7 add optional whole-file compression to convertToTar/convertToPhar 2008-01-16 21:09:32 +00:00
Greg Beaver
31ed60001c fix build on windows 2008-01-16 20:17:47 +00:00
Greg Beaver
d1eda9c8ac add Phar::convertToTar(), Phar::convertToZip(), and Phar::convertToPhar() 2008-01-16 07:24:39 +00:00
Greg Beaver
cb40b39b5b add support for creation of gzipped and bzipped tar-based phars 2008-01-15 23:41:44 +00:00
Greg Beaver
ab99c77a5e add a whole slew of missing returns after throwing an exception, and remove 1 spurious return after RETURN_TRUE 2008-01-14 05:12:46 +00:00
Greg Beaver
f5e4ff21dd fix segfault in Phar::mungServer() found in frontcontroller20.phpt 2008-01-12 22:21:50 +00:00
Greg Beaver
56e84a390c fix segfault in Phar::webPhar() if file is in root directory, found in frontcontroller16.phpt 2008-01-12 22:16:00 +00:00
Greg Beaver
4df43510b9 make zip optional 2008-01-12 05:17:12 +00:00
Greg Beaver
e9ee7dbfc5 fix compile on windows
remove internal libzip
add required dep on zip (will make optional in a few minutes)
2008-01-12 04:32:19 +00:00
Greg Beaver
36f3d80779 stupid windows doesn't allow varargs macros, so remove it. remove unused variable 2008-01-11 07:39:02 +00:00
Greg Beaver
8fb4205a8d add Phar::interceptFileFuncs()
To intercept fopen(), file_get_contents(), opendir(), and all the stat-based functions so that
code like "if (is_readable('./config.inc.php'))" actually works inside of a phar
[DOC]
2008-01-11 07:30:03 +00:00
Greg Beaver
a38e4ff9a7 always mung PATH_INFO and PATH_TRANSLATED, fix segfault if tar-based phar has no stub 2008-01-11 02:52:13 +00:00
Greg Beaver
ab4c2caf4b add interception of is_dir(), file_exists() and file_get_contents() - will make these optional shortly 2008-01-10 15:13:00 +00:00
Greg Beaver
f6b16061d1 implement whole-file compression of phars for phar/tar-based phars
still not 100% working, add failing test
add Phar::isCompressed(), which returns either 0, Phar::GZ, or Phar::BZ2
[DOC]
2008-01-09 07:09:04 +00:00
Greg Beaver
9f5b3a229f fix empty directories in phar, add test 2008-01-09 00:58:37 +00:00
Greg Beaver
1a3624494e implement mkdir (compiles, not yet tested), support for empty directories in phar (not yet tested)
revert last commit of efree(), it's necessary.
2008-01-08 22:14:16 +00:00
Greg Beaver
b93b48663d complete set of new tests for zip-based phars (need to test compression for zip-based phars)
fix a whole bunch of zip-related bugs
tar tests need some naming
add phar information to error messages, fix existing tests to reflect this
2008-01-08 07:08:46 +00:00
Greg Beaver
36efc2a907 eliminate potential double-free of alias
major improvement of zip/tar-based phar stub execution, now __FILE__ says it is the phar, and not phar/.phar/stub.php,
so that the same stub can be used for phar or tar/zip-based phars
ridiculous speedup of rename() within a phar (something like 1000%)
last of the tar-based phar fixes
new tests for tar-based phars, fix existing tests to use new format of __FILE__
2008-01-07 22:21:10 +00:00
Greg Beaver
71f6ae0be5 fix segfault (now all existing tests pass 2008-01-07 17:31:53 +00:00
Greg Beaver
ed312a7a05 fix segfault (duh, can't free something that was not initialized) 2008-01-07 17:28:45 +00:00
Greg Beaver
8a46146f37 fix stat of directory in tar/zip
improve phar recognition of tar/zip-based phars in phar_compile_file
fix segfault in Phar::webPhar() with invalid redirect
add Phar->isTar()/isZip()/isPhar() to determine internal file format
fix creation of tar-based phars from filename in some circumstances
fix read of corrupted file contents from a tar if the tar had been opened readonly and then modified
ensure directories are marked with is_dir in tar file format entries
copy fp_refcount logic into phar_tar_flush() from phar_flush()
fix segfault when flushing a tar with a new stub/alias
2008-01-07 05:41:09 +00:00
Greg Beaver
bd0d9e8de3 remove mung server list hash destroy, this is done in shutdown 2008-01-05 22:48:06 +00:00
Greg Beaver
2410cc96b6 complete tests for Phar::mungServer 2008-01-05 22:02:33 +00:00
Greg Beaver
efc22a3726 new tests, fix mime type overrides (all web front controller primary features are now tested and working for regular phar files) 2008-01-05 06:14:43 +00:00
Greg Beaver
e864f512bb new test, free resources on error in webPhar() (thanks new test\!) 2008-01-05 05:47:47 +00:00
Greg Beaver
dd11d4f64e new test 2008-01-05 05:12:44 +00:00
Greg Beaver
b859c9dd4b beautify 404 error handler, and note missing file.
throw exception if webPhar() is attempted with an extracted file, as webPhar() makes no sense on-disk
2008-01-05 04:03:33 +00:00
Greg Beaver
08b7b76418 fix Location header for index if request has a /, 2 new tests, add index.php to frontcontroller phar 2008-01-05 03:49:01 +00:00
Greg Beaver
653dc9e8ce fix front controller tests (requires patch to run-tests.php posted to internals a little while ago)
allow phars to have extension .php as last resort
fix phar-based phars for MIME_OTHER type
2008-01-05 03:41:43 +00:00
Marcus Boerger
4aec466e95 - Pendantic changes 2008-01-04 14:06:50 +00:00
Greg Beaver
e8a5b20514 replace crappy $_SERVER munging with explicit munging via
Phar::mungServer().  This static method takes an array with one of these 4 indices (case-sensitive):
'PHP_SELF', 'SCRIPT_NAME', 'SCRIPT_FILENAME', 'REQUEST_URI'
and removes any reference to the actual path on the server.  This allows older apps to function unmodified inside a phar.
the variables are re-registered as PHAR_PHP_SELF and company to allow access from clever script files
[DOC]
2008-01-04 04:57:11 +00:00
Greg Beaver
8e18f1cae1 Phar::webPhar() and various problems relating to shutdown in an apache process fixed 2008-01-04 01:45:37 +00:00
Greg Beaver
8ee4266b3f initial tar support - a few kinks to work on in phar creation, but read works 2008-01-03 04:45:00 +00:00
Greg Beaver
652d39c330 add zip-based phar support. not quite working is webPhar(), not sure why yet 2007-12-31 22:42:40 +00:00
Greg Beaver
b8592e228d make blah.phar/ access indexfile just like blah.phar 2007-12-29 02:40:49 +00:00
Greg Beaver
f56865ad4d fix redirects and s/redirects/rewrites/ 2007-12-29 02:38:29 +00:00
Greg Beaver
9320ac9893 remove FIXME - it's been fixed 2007-12-29 02:04:09 +00:00
Greg Beaver
3dcee1c8c7 fix index/custom 404 page 2007-12-29 02:01:12 +00:00
Greg Beaver
06a98d96c7 update proto, arginfo for webPhar 2007-12-29 01:37:12 +00:00
Greg Beaver
acc44900de add vastly improved 404 handling 2007-12-29 01:35:46 +00:00
Greg Beaver
60dc8e5ff4 fix redirect to index file 2007-12-28 23:33:15 +00:00
Greg Beaver
e1a41da652 fix on windows
# it works! it works!
2007-12-26 16:59:01 +00:00
Greg Beaver
4ae47c1df9 remove unused variable 2007-12-24 20:48:12 +00:00
Greg Beaver
5200481aaf fix mem leak 2007-12-24 20:30:44 +00:00
Greg Beaver
02c7ff1343 complete re-factoring of front controller. Now it is done with
Phar->webPhar():
<?php
Phar::webPhar();
__HALT_COMPILER();

With the above stub, the default front controller will kick in.  An array of mime type overrides, and another
array mapping phar file entry -> redirected entry can be used to further customize
[DOC]
2007-12-23 21:12:42 +00:00
Greg Beaver
8e4cc4b3dd first attempt at major new feature: default front controller for web
Currently, an entire phar entry is leaked for no obvious reason, otherwise it works.  Sample code:
The phar has to be created using Phar->useFrontController(); and the stub performs actual resolution of which file to load:
<?php
Phar::mapPhar();
include 'phar://' . __FILE__ . '/' . substr($_SERVER['REQUEST_URI'], strlen(basename(__FILE__)));
__HALT_COMPILER();
?>

Phar automatically determines mime type from the file extension and either parses or displays the file.  Modification of REQUEST_URI
and other variables should happen in the stub
[DOC]
2007-12-22 07:46:53 +00:00
Greg Beaver
0c51d58138 [unfinished] magically handle getcwd() and fopen() with include_path inside phar
this work is incomplete, but compiles and existing tests pass
2007-12-18 17:01:24 +00:00
Greg Beaver
7fa0b43518 fully implement Phar->copy(), fix test 2007-12-16 06:31:00 +00:00
Greg Beaver
f11103a9a1 Phar::copy() [not yet working] 2007-12-16 00:57:39 +00:00
Greg Beaver
bb4096ff29 Phar->buildFromIterator now can also accept a stream handle as a value in addition
to a file path (string) or SplFileInfo object
[DOC]
2007-12-14 19:45:22 +00:00
Greg Beaver
2c77090174 better fix, revert unintentional commit to Makefile.frag 2007-12-14 04:10:14 +00:00
Greg Beaver
63f3d5958d fix build on windows, fix segfault in tsrm by uninitialized pointer 2007-12-14 04:08:34 +00:00
Greg Beaver
3b356d5ed8 new test
now, SplDirectoryIterator can be used directly with Phar->buildFromIterator() in order to populate the
files in a phar archive.  When combined with a RegexIterator and other filters, it becomes very easy to create
a phar archive with 1 line of code
[DOC]
2007-12-13 05:22:06 +00:00
Greg Beaver
d243f9ff99 code re-organize to make it more logical 2007-12-13 01:16:56 +00:00
Greg Beaver
38b35f1448 Phar->buildFromIterator: fix another mem leak, fix test 2007-12-13 01:05:59 +00:00
Greg Beaver
5051732d4c kill 1 memleak 2007-12-13 01:01:27 +00:00
Greg Beaver
463731e2de Phar->buildFromIterator: use spl_iterator_apply(), add 4 tests (mem leaks not yet fixed in the 4th) 2007-12-13 00:54:15 +00:00
Greg Beaver
5af85b4f8f implement Phar::buildFromIterator()
first argument is an iterator that returns as values paths to files to add to the phar archive
the key should be the path that the file should be saved as within the phar archive
if the optional second parameter is passed, then the key is ignored and substr(value, strlen(base_directory)) is
used as the save path within the phar archive
[DOC]
2007-12-12 18:01:40 +00:00
Greg Beaver
4bcb68a4e8 fix errors found in delMetaData(), add get/delMetaData() to MetaData read test 2007-11-25 05:04:40 +00:00
Greg Beaver
bdff161e87 WS (spaces instead of tabs) 2007-11-24 04:09:01 +00:00
Greg Beaver
a72251be6e experimental support for optional bz2 extension - should make windows users a whole lot happier 2007-11-24 04:06:44 +00:00
Greg Beaver
be023d6f62 much better fix for the problem of phar://c:\path\to\blah.phar
don't use php_parse_url() at all, and always unixify paths on copied strings.
our modification was modifying the zval original string, so a user would pass in
phar://c:\path\to\blah.phar

and their string would change to phar://c:/path/to/blah.phar - bad.

Now using

include 'phar://' . __FILE__ . '/index.php';

works on both unix and windows seamlessly, as well as $a = new Phar(__FILE__)

for use in the loader stub
2007-11-19 23:10:05 +00:00
Greg Beaver
9d7d44d60c typo 2007-11-16 04:17:37 +00:00
Greg Beaver
999961f080 begin win32 fixes for Phar object - still have a problem I can't track down yet, but it's only a matter of time before it is killed too
when passing in a full path with drive letter to the Phar object, we were
then passing "phar://C:/path/to/blah.phar" to php_parse_url(), which
thinks it is getting a valid url scheme "phar", host "C" path "/path/to/blah.phar"

we now pass "phar:///C:/path/to/blah.phar" to make it fail, and then properly
parse the url inside phar
2007-11-13 05:57:14 +00:00
Greg Beaver
eb67969b73 fix Bug #12124: Phar object cannot be iterated over
remove unused variables
fix jit file open sprintf calls
2007-10-04 03:33:21 +00:00
Greg Beaver
ccb840fb92 add missing /* }}} */ 2007-08-25 01:36:21 +00:00
Greg Beaver
543ad01efd move to 1.3.0 development
add Phar::delete()
2007-08-25 01:32:35 +00:00
Greg Beaver
5178a94545 add test for pre-existing alias failure, fix source to fail if alias already exists 2007-08-23 23:23:26 +00:00
Greg Beaver
0bd0d85673 implement Phar->setAlias() 2007-08-23 04:49:39 +00:00
Greg Beaver
5d8919938d fix issue with large number of open file handles killing php with large phars on creation
- close file handles that have no references for entries
- add just-in-time re-processing of file handles
- make sure file size is set in renaming
- add old_flags to phar_entry_info so we can decompress when flushing a modified entry whose fp is closed
2007-08-17 04:47:50 +00:00
Marcus Boerger
511bd55758 - Make compatible with PEAR/PHP_Archive CVS 2007-05-28 18:07:49 +00:00
Marcus Boerger
f2cec0600c - Make Pahr::loadPhar() and Phar::mapPhar() respect extract list 2007-05-21 16:43:53 +00:00
Marcus Boerger
05459db504 - Better handling of alias = NULL 2007-05-19 16:06:49 +00:00
Marcus Boerger
8e561453ec - Add Phar::getAlias() 2007-05-18 17:50:39 +00:00
Marcus Boerger
c1c9d21ec4 - Add Phar::isValidPharfilename() really 2007-05-18 05:48:20 +00:00
Marcus Boerger
5e3af23d20 - Reduce overhead of Phar's RINIT 2007-05-16 23:16:51 +00:00
Marcus Boerger
b83a515920 - Add Phar::delMetadata()
- Add Phar::hasMetadata()
- Add Phar::isValidPharFilename()
2007-05-15 20:42:38 +00:00
Marcus Boerger
35299957c7 - Add Phar::getSupportedCompression() 2007-05-14 18:31:18 +00:00
Marcus Boerger
e289a06c83 - Flush on changes 2007-05-14 18:11:53 +00:00
Marcus Boerger
6e3ac5dbcd - Add PharFileInfo::hasMetadata() & delMetadata() 2007-05-14 17:13:07 +00:00
Marcus Boerger
7aa7448a32 - Fix Phar::canWrite(), had inverted logic
- Support PHP & builds
2007-05-09 18:09:41 +00:00
Greg Beaver
0deb79b705 fix tests, add missing break to setSignatureAlgorithm() 2007-03-26 00:29:22 +00:00
Greg Beaver
4af9e7192b update note 2007-03-26 00:03:53 +00:00
Greg Beaver
a92eeb61c4 [DOC]
implement setSignatureAlgorithm() and add class constants Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, Phar::PGP
2007-03-26 00:00:56 +00:00
Marcus Boerger
c42a870b7e - Add general SHA-2 support by optional pecl/hash dependency
# We actually need support to select the signature type somehow
2007-03-25 21:43:49 +00:00
Marcus Boerger
b983973a1d - Add ini: phar.extract_list
- Add Phar::getExtractList
- Both allow to set a mapping <phar-file> to <extract-dir>
[[DOC]]
2007-03-25 19:03:38 +00:00
Greg Beaver
18cb2d59d4 rename begin/isFlushingToPhar/commit to startBuffering/isBuffering/stopBuffering 2007-03-22 16:31:46 +00:00
Marcus Boerger
5dfeed6e14 - Simplify 2007-02-13 17:56:37 +00:00
Marcus Boerger
ac73e981c4 - Inherit interface ArrayAccess correctly 2007-02-13 17:39:46 +00:00
Marcus Boerger
e8e7815e89 - Fix offset writing 2007-02-13 01:19:58 +00:00
Johannes Schlüter
30dad44aa3 - Add possibility to check for a specific compression method 2007-02-06 23:56:39 +00:00
Greg Beaver
bc17dcfcd1 fix several potential segfaults, add tests for chmod(), fix chmod() 2007-02-06 17:09:37 +00:00
Greg Beaver
70dc64e95a add PharFileInfo->chmod() to set permissions (no other way to do it) 2007-02-06 05:41:18 +00:00
Greg Beaver
40b66a8035 copyright year updates 2007-02-05 21:38:50 +00:00
Marcus Boerger
250119fa38 - Fix signed/unsigned warnings
- Use safe_emalloc where usefull
2007-02-05 20:34:23 +00:00
Marcus Boerger
f210205e70 - PHP_VERSION_ID exists only in newer PHPs (5.1+)
- Improve error checking
2007-02-04 20:10:03 +00:00
Marcus Boerger
725148cc94 - Allow building with 5.1 (not all works thenperfectly though) 2007-02-03 16:31:36 +00:00
Marcus Boerger
d47db8526b - Fix protos 2007-02-03 13:42:10 +00:00
Marcus Boerger
1b5b78ce18 - Provide both version strings, api and ext 2007-02-03 13:20:12 +00:00
Greg Beaver
93b387d327 fix mem leak on error, fix cwd issue. go back to BadMethodCallException for Phar->set*CompressedAllFiles(). ALL TESTS PASS, RELEASE IS IMMINENT 2007-02-03 04:04:18 +00:00
Greg Beaver
340e9b24fc s/isFlushing/isFlushingToPhar much clearer purpose in method name 2007-02-03 00:45:24 +00:00
Marcus Boerger
5f8256cfc1 - Update TODO
- Add Phar::isFlushing()
- Improve test
2007-01-30 20:58:14 +00:00
Greg Beaver
c7a5d062f5 throw exceptions from Phar object, and errors from stream wrapper
# we need to account for uncaught exceptions in shutdown, 2 tests leak because of this
2007-01-29 06:02:19 +00:00
Greg Beaver
c6dc9be489 implement Phar->getMetadata() Phar->setMetadata(), add tests, implement meta-data in the header 2007-01-29 03:59:55 +00:00
Marcus Boerger
0bc1b90ec3 - Split commit into commit and setStub 2007-01-28 22:11:28 +00:00
Marcus Boerger
8cfaa44955 - Make new flushing work 2007-01-28 21:26:54 +00:00
Marcus Boerger
d13719ace8 - In Commit reset donotflush 2007-01-28 19:56:09 +00:00
Greg Beaver
2273af3104 beginWrite()/commitWrite() => begin()/commit(), note optional rollback() for 1.1 2007-01-28 19:09:12 +00:00
Marcus Boerger
834337f85a - Fixx illeagal memory access 2007-01-28 10:43:18 +00:00
Greg Beaver
e8cabb46f6 fix commitWrite test, enable creation of Phars with phar object 2007-01-28 05:40:18 +00:00
Greg Beaver
2513903e40 stream context for specifying meta-data 2007-01-28 03:25:53 +00:00
Marcus Boerger
d4fb3cb4d3 - Fix warning 2007-01-27 21:37:22 +00:00
Marcus Boerger
d5bbd84d76 - Prevent memory corruption 2007-01-27 21:23:02 +00:00