Commit 7d0062dedde2f202d6ab7fc6abe755b6b699d75f
1 parent
e09cc82f
Updated SVN properties
Committed By: Kevin Reviewed By: Conrad git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@6820 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
163 changed files
with
72161 additions
and
72161 deletions
Too many changes.
To preserve performance only 100 of 163 files are displayed.
about.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: preferences.php 6203 2007-02-08 10:41:00Z kevin_fourie $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
bin/openoffice/pdfgen.py
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | # | 2 | # |
| 3 | # | 3 | # |
| 4 | -# $Id: view.php 6203 2007-02-08 10:41:00Z kevin_fourie $ | 4 | +# $Id$ |
| 5 | # | 5 | # |
| 6 | # The contents of this file are subject to the KnowledgeTree Public | 6 | # The contents of this file are subject to the KnowledgeTree Public |
| 7 | # License Version 1.1.2 ("License"); You may not use this file except in | 7 | # License Version 1.1.2 ("License"); You may not use this file except in |
bin/storageverification.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
bin/upgrade/pear-upgrade.bat
| 1 | - | ||
| 2 | -; TEST ALL PEAR LIBRARIES BEFORE UPGRADING INTO RELEASE | ||
| 3 | - | ||
| 4 | -PATH=%PATH%;c:\php5\PEAR | ||
| 5 | - | ||
| 6 | -pear channel-update pear.php.net | ||
| 7 | -pear config-set php_dir "C:\kt\kt.trunk\thirdparty\pear" | ||
| 8 | - | ||
| 9 | -pear config-set preferred_state stable | ||
| 10 | - | ||
| 11 | -pear upgrade --alldeps PEAR | ||
| 12 | -pear upgrade --alldeps Cache_Lite | ||
| 13 | -pear upgrade --alldeps Config | ||
| 14 | -pear upgrade --alldeps DB | ||
| 15 | -pear upgrade --alldeps File | ||
| 16 | - | ||
| 17 | -;pear upgrade --alldeps MDB2#mysql | ||
| 18 | - | ||
| 19 | -pear upgrade --alldeps Log | ||
| 20 | -pear upgrade --alldeps PHP_Compat | ||
| 21 | - | ||
| 22 | -pear config-set preferred_state beta | ||
| 23 | -pear upgrade --alldeps File_Gettext | ||
| 24 | -pear upgrade --alldeps Net_LDAP | ||
| 25 | -pear upgrade --alldeps SOAP | ||
| 26 | -pear config-set preferred_state stable | ||
| 27 | - | 1 | + |
| 2 | +; TEST ALL PEAR LIBRARIES BEFORE UPGRADING INTO RELEASE | ||
| 3 | + | ||
| 4 | +PATH=%PATH%;c:\php5\PEAR | ||
| 5 | + | ||
| 6 | +pear channel-update pear.php.net | ||
| 7 | +pear config-set php_dir "C:\kt\kt.trunk\thirdparty\pear" | ||
| 8 | + | ||
| 9 | +pear config-set preferred_state stable | ||
| 10 | + | ||
| 11 | +pear upgrade --alldeps PEAR | ||
| 12 | +pear upgrade --alldeps Cache_Lite | ||
| 13 | +pear upgrade --alldeps Config | ||
| 14 | +pear upgrade --alldeps DB | ||
| 15 | +pear upgrade --alldeps File | ||
| 16 | + | ||
| 17 | +;pear upgrade --alldeps MDB2#mysql | ||
| 18 | + | ||
| 19 | +pear upgrade --alldeps Log | ||
| 20 | +pear upgrade --alldeps PHP_Compat | ||
| 21 | + | ||
| 22 | +pear config-set preferred_state beta | ||
| 23 | +pear upgrade --alldeps File_Gettext | ||
| 24 | +pear upgrade --alldeps Net_LDAP | ||
| 25 | +pear upgrade --alldeps SOAP | ||
| 26 | +pear config-set preferred_state stable | ||
| 27 | + |
docs/COPYING
| 1 | -KNOWLEDGETREE PUBLIC LICENSE | ||
| 2 | -Version 1.1.2 | ||
| 3 | - | ||
| 4 | -1. Definitions. | ||
| 5 | - | ||
| 6 | -1.0.1. "Commercial Use" means distribution or otherwise making the Covered Code available to a third party. | ||
| 7 | - | ||
| 8 | -1.1. "Contributor" means each entity that creates or contributes to the creation of Modifications. | ||
| 9 | - | ||
| 10 | -1.2. "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. | ||
| 11 | - | ||
| 12 | -1.3. "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. | ||
| 13 | - | ||
| 14 | -1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. | ||
| 15 | - | ||
| 16 | -1.5. "Executable" means Covered Code in any form other than Source Code. | ||
| 17 | - | ||
| 18 | -1.6. "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. | ||
| 19 | - | ||
| 20 | -1.7. "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. | ||
| 21 | - | ||
| 22 | -1.8. "License" means this document. | ||
| 23 | - | ||
| 24 | -1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. | ||
| 25 | - | ||
| 26 | -1.9. "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: | ||
| 27 | - | ||
| 28 | -A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. | ||
| 29 | - | ||
| 30 | -B. Any new file that contains any part of the Original Code or previous Modifications. | ||
| 31 | - | ||
| 32 | -1.10. "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. | ||
| 33 | - | ||
| 34 | -1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. | ||
| 35 | - | ||
| 36 | -1.11. "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. | ||
| 37 | - | ||
| 38 | -1.12. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. | ||
| 39 | - | ||
| 40 | -2. Source Code License. | ||
| 41 | - | ||
| 42 | -2.1. The Initial Developer Grant. | ||
| 43 | -The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: | ||
| 44 | - | ||
| 45 | -(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and | ||
| 46 | - | ||
| 47 | -(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). | ||
| 48 | - | ||
| 49 | -(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. | ||
| 50 | - | ||
| 51 | -(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. | ||
| 52 | - | ||
| 53 | -2.2. Contributor Grant. | ||
| 54 | -Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license | ||
| 55 | - | ||
| 56 | - | ||
| 57 | -(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and | ||
| 58 | - | ||
| 59 | -(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). | ||
| 60 | - | ||
| 61 | -(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code. | ||
| 62 | - | ||
| 63 | -(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. | ||
| 64 | - | ||
| 65 | - | ||
| 66 | -3. Distribution Obligations. | ||
| 67 | - | ||
| 68 | -3.1. Application of License. | ||
| 69 | -The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. | ||
| 70 | - | ||
| 71 | -3.2. Availability of Source Code. | ||
| 72 | -Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. | ||
| 73 | - | ||
| 74 | -3.3. Description of Modifications. | ||
| 75 | -You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. | ||
| 76 | - | ||
| 77 | -3.4. Intellectual Property Matters | ||
| 78 | - | ||
| 79 | -(a) Third Party Claims. | ||
| 80 | -If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. | ||
| 81 | - | ||
| 82 | -(b) Contributor APIs. | ||
| 83 | -If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file. | ||
| 84 | - | ||
| 85 | -(c) Representations. | ||
| 86 | - | ||
| 87 | -Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. | ||
| 88 | - | ||
| 89 | - | ||
| 90 | -3.5. Required Notices. | ||
| 91 | -You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. | ||
| 92 | - | ||
| 93 | -3.6. Distribution of Executable Versions. | ||
| 94 | -You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. | ||
| 95 | - | ||
| 96 | -3.7. Larger Works. | ||
| 97 | -You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. | ||
| 98 | - | ||
| 99 | -4. Inability to Comply Due to Statute or Regulation. | ||
| 100 | - | ||
| 101 | -If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. | ||
| 102 | - | ||
| 103 | -5. Application of this License. | ||
| 104 | - | ||
| 105 | -This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. | ||
| 106 | - | ||
| 107 | -6. Versions of the License. | ||
| 108 | - | ||
| 109 | -6.1. New Versions. | ||
| 110 | -The Jam Warehouse Software (Pty) Ltd may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. | ||
| 111 | - | ||
| 112 | -6.2. Effect of New Versions. | ||
| 113 | -Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by The Jam Warehouse Software (Pty) Ltd, trading as KnowledgeTree. No one other than The Jam Warehouse Software (Pty) Ltd has the right to modify the terms applicable to Covered Code created under this License. | ||
| 114 | - | ||
| 115 | -6.3. Derivative Works. | ||
| 116 | -If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases "KnowledgeTree", "KPL" or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the KnowledgeTree Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) | ||
| 117 | - | ||
| 118 | -7. DISCLAIMER OF WARRANTY. | ||
| 119 | - | ||
| 120 | -COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. | ||
| 121 | - | ||
| 122 | -8. TERMINATION. | ||
| 123 | - | ||
| 124 | -8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. | ||
| 125 | - | ||
| 126 | -8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: | ||
| 127 | - | ||
| 128 | -(a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. | ||
| 129 | - | ||
| 130 | -(b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant. | ||
| 131 | - | ||
| 132 | -8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. | ||
| 133 | - | ||
| 134 | -8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. | ||
| 135 | - | ||
| 136 | -9. LIMITATION OF LIABILITY. | ||
| 137 | - | ||
| 138 | -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. | ||
| 139 | - | ||
| 140 | -10. U.S. GOVERNMENT END USERS. | ||
| 141 | - | ||
| 142 | -The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. | ||
| 143 | - | ||
| 144 | -11. MISCELLANEOUS. | ||
| 145 | - | ||
| 146 | -This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. | ||
| 147 | - | ||
| 148 | -12. RESPONSIBILITY FOR CLAIMS. | ||
| 149 | - | ||
| 150 | -As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. | ||
| 151 | - | ||
| 152 | -13. MULTIPLE-LICENSED CODE. | ||
| 153 | - | ||
| 154 | -Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the SPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A. | ||
| 155 | -KnowledgeTree Public License 1.1.2 - Exhibit A | ||
| 156 | - | ||
| 157 | -The contents of this file are subject to the KnowledgeTree Public | ||
| 158 | -License Version 1.1.2 ("License"); You may not use this file except in | ||
| 159 | -compliance with the License. You may obtain a copy of the License at | ||
| 160 | -http://www.knowledgetree.com/KPL | ||
| 161 | - | ||
| 162 | -Software distributed under the License is distributed on an "AS IS" | ||
| 163 | -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
| 164 | -See the License for the specific language governing rights and | ||
| 165 | -limitations under the License. | ||
| 166 | - | ||
| 167 | -All copies of the Covered Code must include on each user interface screen: | ||
| 168 | - (i) the "Powered by KnowledgeTree" logo and | ||
| 169 | - (ii) the KnowledgeTree copyright notice | ||
| 170 | -in the same form as they appear in the distribution. See the License for | ||
| 171 | -requirements. | ||
| 172 | - | ||
| 173 | -The Original Code is: KnowledgeTree Open Source | ||
| 174 | - | ||
| 175 | -The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 176 | -(Pty) Ltd, trading as KnowledgeTree. | ||
| 177 | -Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 178 | -(C) 2007 The Jam Warehouse Software (Pty) Ltd; | ||
| 179 | -All Rights Reserved. | ||
| 180 | -Contributor( s): ______________________________________ | ||
| 181 | - | ||
| 182 | -[NOTE: The text of this Exhibit A may differ slightly from the text of the notices in the Source Code files of the Original Code. You should use the text of this Exhibit A rather than the text found in the Original Code Source Code for Your Modifications.] | ||
| 183 | -KnowledgeTree Public License 1.1.2 - Exihibit B | ||
| 184 | - | ||
| 185 | -Additional Terms applicable to the KnowledgeTree Public License. | ||
| 186 | - | ||
| 187 | -I. Effect. | ||
| 188 | -These additional terms described in this KnowledgeTree Public License - Additional Terms shall apply to the Covered Code under this License. | ||
| 189 | - | ||
| 190 | -II. KnowledgeTree and logo. | ||
| 191 | -This License does not grant any rights to use the trademarks "KnowledgeTree" and the "KnowledgeTree" logos even if such marks are included in the Original Code or Modifications. | ||
| 192 | - | ||
| 193 | -However, in addition to the other notice obligations, all copies of the Covered Code in Executable and Source Code form distributed must, as a form of attribution of the original author, include on each user interface screen (i) the "KnowledgeTree Document Management Made Simple" logo and (ii) the copyright notice in the same form as the latest version of the Covered Code distributed by The Jam Warehouse Software (Pty) Ltd. at the time of distribution of such copy. In addition, the "KnowledgeTree Document Management Made Simple" logo must be visible to all users and be located at the top right-hand corner of each user interface screen, other than the user log-in page, on which it must be located at the top-center of the user log-in form. Notwithstanding the above, the dimensions of the "KnowledgeTree Document Management Made Simple" logo must be at least 200 x 40 pixels. When users click on the "KnowledgeTree Document Management Made Simple" logo it must direct them back to http://www.knowledgetree.com. In addition, the copyright notice must remain visible to all users at all times at the bottom of the user interface screen. When users click on the copyright notice, it must direct them back to http://www.knowledgetree.com | 1 | +KNOWLEDGETREE PUBLIC LICENSE |
| 2 | +Version 1.1.2 | ||
| 3 | + | ||
| 4 | +1. Definitions. | ||
| 5 | + | ||
| 6 | +1.0.1. "Commercial Use" means distribution or otherwise making the Covered Code available to a third party. | ||
| 7 | + | ||
| 8 | +1.1. "Contributor" means each entity that creates or contributes to the creation of Modifications. | ||
| 9 | + | ||
| 10 | +1.2. "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. | ||
| 11 | + | ||
| 12 | +1.3. "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. | ||
| 13 | + | ||
| 14 | +1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. | ||
| 15 | + | ||
| 16 | +1.5. "Executable" means Covered Code in any form other than Source Code. | ||
| 17 | + | ||
| 18 | +1.6. "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. | ||
| 19 | + | ||
| 20 | +1.7. "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. | ||
| 21 | + | ||
| 22 | +1.8. "License" means this document. | ||
| 23 | + | ||
| 24 | +1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. | ||
| 25 | + | ||
| 26 | +1.9. "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: | ||
| 27 | + | ||
| 28 | +A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. | ||
| 29 | + | ||
| 30 | +B. Any new file that contains any part of the Original Code or previous Modifications. | ||
| 31 | + | ||
| 32 | +1.10. "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. | ||
| 33 | + | ||
| 34 | +1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. | ||
| 35 | + | ||
| 36 | +1.11. "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. | ||
| 37 | + | ||
| 38 | +1.12. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. | ||
| 39 | + | ||
| 40 | +2. Source Code License. | ||
| 41 | + | ||
| 42 | +2.1. The Initial Developer Grant. | ||
| 43 | +The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: | ||
| 44 | + | ||
| 45 | +(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and | ||
| 46 | + | ||
| 47 | +(b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). | ||
| 48 | + | ||
| 49 | +(c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. | ||
| 50 | + | ||
| 51 | +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. | ||
| 52 | + | ||
| 53 | +2.2. Contributor Grant. | ||
| 54 | +Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license | ||
| 55 | + | ||
| 56 | + | ||
| 57 | +(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and | ||
| 58 | + | ||
| 59 | +(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). | ||
| 60 | + | ||
| 61 | +(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code. | ||
| 62 | + | ||
| 63 | +(d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. | ||
| 64 | + | ||
| 65 | + | ||
| 66 | +3. Distribution Obligations. | ||
| 67 | + | ||
| 68 | +3.1. Application of License. | ||
| 69 | +The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. | ||
| 70 | + | ||
| 71 | +3.2. Availability of Source Code. | ||
| 72 | +Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. | ||
| 73 | + | ||
| 74 | +3.3. Description of Modifications. | ||
| 75 | +You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. | ||
| 76 | + | ||
| 77 | +3.4. Intellectual Property Matters | ||
| 78 | + | ||
| 79 | +(a) Third Party Claims. | ||
| 80 | +If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. | ||
| 81 | + | ||
| 82 | +(b) Contributor APIs. | ||
| 83 | +If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file. | ||
| 84 | + | ||
| 85 | +(c) Representations. | ||
| 86 | + | ||
| 87 | +Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. | ||
| 88 | + | ||
| 89 | + | ||
| 90 | +3.5. Required Notices. | ||
| 91 | +You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. | ||
| 92 | + | ||
| 93 | +3.6. Distribution of Executable Versions. | ||
| 94 | +You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. | ||
| 95 | + | ||
| 96 | +3.7. Larger Works. | ||
| 97 | +You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. | ||
| 98 | + | ||
| 99 | +4. Inability to Comply Due to Statute or Regulation. | ||
| 100 | + | ||
| 101 | +If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. | ||
| 102 | + | ||
| 103 | +5. Application of this License. | ||
| 104 | + | ||
| 105 | +This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. | ||
| 106 | + | ||
| 107 | +6. Versions of the License. | ||
| 108 | + | ||
| 109 | +6.1. New Versions. | ||
| 110 | +The Jam Warehouse Software (Pty) Ltd may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. | ||
| 111 | + | ||
| 112 | +6.2. Effect of New Versions. | ||
| 113 | +Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by The Jam Warehouse Software (Pty) Ltd, trading as KnowledgeTree. No one other than The Jam Warehouse Software (Pty) Ltd has the right to modify the terms applicable to Covered Code created under this License. | ||
| 114 | + | ||
| 115 | +6.3. Derivative Works. | ||
| 116 | +If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases "KnowledgeTree", "KPL" or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the KnowledgeTree Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) | ||
| 117 | + | ||
| 118 | +7. DISCLAIMER OF WARRANTY. | ||
| 119 | + | ||
| 120 | +COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. | ||
| 121 | + | ||
| 122 | +8. TERMINATION. | ||
| 123 | + | ||
| 124 | +8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. | ||
| 125 | + | ||
| 126 | +8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: | ||
| 127 | + | ||
| 128 | +(a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. | ||
| 129 | + | ||
| 130 | +(b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant. | ||
| 131 | + | ||
| 132 | +8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. | ||
| 133 | + | ||
| 134 | +8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. | ||
| 135 | + | ||
| 136 | +9. LIMITATION OF LIABILITY. | ||
| 137 | + | ||
| 138 | +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. | ||
| 139 | + | ||
| 140 | +10. U.S. GOVERNMENT END USERS. | ||
| 141 | + | ||
| 142 | +The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. | ||
| 143 | + | ||
| 144 | +11. MISCELLANEOUS. | ||
| 145 | + | ||
| 146 | +This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. | ||
| 147 | + | ||
| 148 | +12. RESPONSIBILITY FOR CLAIMS. | ||
| 149 | + | ||
| 150 | +As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. | ||
| 151 | + | ||
| 152 | +13. MULTIPLE-LICENSED CODE. | ||
| 153 | + | ||
| 154 | +Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the SPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A. | ||
| 155 | +KnowledgeTree Public License 1.1.2 - Exhibit A | ||
| 156 | + | ||
| 157 | +The contents of this file are subject to the KnowledgeTree Public | ||
| 158 | +License Version 1.1.2 ("License"); You may not use this file except in | ||
| 159 | +compliance with the License. You may obtain a copy of the License at | ||
| 160 | +http://www.knowledgetree.com/KPL | ||
| 161 | + | ||
| 162 | +Software distributed under the License is distributed on an "AS IS" | ||
| 163 | +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
| 164 | +See the License for the specific language governing rights and | ||
| 165 | +limitations under the License. | ||
| 166 | + | ||
| 167 | +All copies of the Covered Code must include on each user interface screen: | ||
| 168 | + (i) the "Powered by KnowledgeTree" logo and | ||
| 169 | + (ii) the KnowledgeTree copyright notice | ||
| 170 | +in the same form as they appear in the distribution. See the License for | ||
| 171 | +requirements. | ||
| 172 | + | ||
| 173 | +The Original Code is: KnowledgeTree Open Source | ||
| 174 | + | ||
| 175 | +The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 176 | +(Pty) Ltd, trading as KnowledgeTree. | ||
| 177 | +Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 178 | +(C) 2007 The Jam Warehouse Software (Pty) Ltd; | ||
| 179 | +All Rights Reserved. | ||
| 180 | +Contributor( s): ______________________________________ | ||
| 181 | + | ||
| 182 | +[NOTE: The text of this Exhibit A may differ slightly from the text of the notices in the Source Code files of the Original Code. You should use the text of this Exhibit A rather than the text found in the Original Code Source Code for Your Modifications.] | ||
| 183 | +KnowledgeTree Public License 1.1.2 - Exihibit B | ||
| 184 | + | ||
| 185 | +Additional Terms applicable to the KnowledgeTree Public License. | ||
| 186 | + | ||
| 187 | +I. Effect. | ||
| 188 | +These additional terms described in this KnowledgeTree Public License - Additional Terms shall apply to the Covered Code under this License. | ||
| 189 | + | ||
| 190 | +II. KnowledgeTree and logo. | ||
| 191 | +This License does not grant any rights to use the trademarks "KnowledgeTree" and the "KnowledgeTree" logos even if such marks are included in the Original Code or Modifications. | ||
| 192 | + | ||
| 193 | +However, in addition to the other notice obligations, all copies of the Covered Code in Executable and Source Code form distributed must, as a form of attribution of the original author, include on each user interface screen (i) the "KnowledgeTree Document Management Made Simple" logo and (ii) the copyright notice in the same form as the latest version of the Covered Code distributed by The Jam Warehouse Software (Pty) Ltd. at the time of distribution of such copy. In addition, the "KnowledgeTree Document Management Made Simple" logo must be visible to all users and be located at the top right-hand corner of each user interface screen, other than the user log-in page, on which it must be located at the top-center of the user log-in form. Notwithstanding the above, the dimensions of the "KnowledgeTree Document Management Made Simple" logo must be at least 200 x 40 pixels. When users click on the "KnowledgeTree Document Management Made Simple" logo it must direct them back to http://www.knowledgetree.com. In addition, the copyright notice must remain visible to all users at all times at the bottom of the user interface screen. When users click on the copyright notice, it must direct them back to http://www.knowledgetree.com |
ktwsapi/README.txt
| 1 | -KnowledgeTree WebService API | ||
| 2 | -============================ | ||
| 3 | - | ||
| 4 | -This folder contains the object model in various languages, used to access | 1 | +KnowledgeTree WebService API |
| 2 | +============================ | ||
| 3 | + | ||
| 4 | +This folder contains the object model in various languages, used to access | ||
| 5 | KnowledgeTree via web services. | 5 | KnowledgeTree via web services. |
| 6 | \ No newline at end of file | 6 | \ No newline at end of file |
lib/actions/bulkaction.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: documentaction.inc.php 5848 2006-08-16 15:58:51Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/actions/documentviewlet.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: documentaction.inc.php 5848 2006-08-16 15:58:51Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/actions/entitylist.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: entity.php 5758 2006-07-27 10:17:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/authentication/interceptorinstances.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: authenticationsource.inc.php 5758 2006-07-27 10:17:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/browse/columnentry.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: columnentry.inc.php 5492 2006-06-04 20:50:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/browse/columnregistry.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: columnregistry.inc.php 5492 2006-06-04 20:50:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/metadata/fieldsetregistry.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/util/KTStopwords.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: config.inc.php 5758 2006-07-27 10:17:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/validation/basevalidator.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/validation/validatorfactory.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/widgets/basewidget.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/widgets/forms.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/widgets/widgetfactory.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/workflow/workflowadminutil.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
lib/workflow/workflowtrigger.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: workflowtrigger.inc.php 5268 2006-04-18 13:42:22Z nbm $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * Provides a base class for workflow triggers. This includes | 5 | * Provides a base class for workflow triggers. This includes |
| 6 | * the ability to serialise configuration arrays into the db | 6 | * the ability to serialise configuration arrays into the db |
lib/workflow/workflowtriggerinstance.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: workflowtriggerinstance.inc.php 5268 2006-04-18 13:42:22Z nbm $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * Provides both association between a transition and a trigger, and a | 5 | * Provides both association between a transition and a trigger, and a |
| 6 | * way to store the configuration for that instance. | 6 | * way to store the configuration for that instance. |
olddashboard.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: dashboard.php 6039 2006-11-03 10:01:51Z bryndivey $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * Main dashboard page -- This page is presented to the user after login. | 6 | * Main dashboard page -- This page is presented to the user after login. |
| 7 | * It contains a high level overview of the users subscriptions, checked out | 7 | * It contains a high level overview of the users subscriptions, checked out |
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | * Contributor( s): ______________________________________ | 33 | * Contributor( s): ______________________________________ |
| 34 | * | 34 | * |
| 35 | * | 35 | * |
| 36 | - * @version $Revision: 6039 $ | 36 | + * @version $Revision$ |
| 37 | * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | 37 | * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa |
| 38 | */ | 38 | */ |
| 39 | 39 |
plugins/ktcore/KTColumns.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/KTValidators.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/KTWidgets.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/KTWorkflowTriggers.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: KTWorkflowTriggers.php 5439 2006-05-25 13:20:15Z bryndivey $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/admin/documentFieldsv2.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: documentFields.php 5801 2006-08-15 10:06:22Z bryndivey $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/admin/expungeList.php
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | ||
| 4 | - * | ||
| 5 | - * The contents of this file are subject to the KnowledgeTree Public | ||
| 6 | - * License Version 1.1.2 ("License"); You may not use this file except in | ||
| 7 | - * compliance with the License. You may obtain a copy of the License at | ||
| 8 | - * http://www.knowledgetree.com/KPL | ||
| 9 | - * | ||
| 10 | - * Software distributed under the License is distributed on an "AS IS" | ||
| 11 | - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing rights and | ||
| 13 | - * limitations under the License. | ||
| 14 | - * | ||
| 15 | - * All copies of the Covered Code must include on each user interface screen: | ||
| 16 | - * (i) the "Powered by KnowledgeTree" logo and | ||
| 17 | - * (ii) the KnowledgeTree copyright notice | ||
| 18 | - * in the same form as they appear in the distribution. See the License for | ||
| 19 | - * requirements. | ||
| 20 | - * | ||
| 21 | - * The Original Code is: KnowledgeTree Open Source | ||
| 22 | - * | ||
| 23 | - * The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 24 | - * (Pty) Ltd, trading as KnowledgeTree. | ||
| 25 | - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 26 | - * (C) 2007 The Jam Warehouse Software (Pty) Ltd; | ||
| 27 | - * All Rights Reserved. | ||
| 28 | - * Contributor( s): ______________________________________ | ||
| 29 | - */ | ||
| 30 | - | ||
| 31 | -require_once('../../../config/dmsDefaults.php'); | ||
| 32 | -require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); | ||
| 33 | - | ||
| 34 | -require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); | ||
| 35 | -require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); | ||
| 36 | - | ||
| 37 | -$aDocuments =& Document::getList("status_id=" . DELETED); | ||
| 38 | - | ||
| 39 | -$pageNum = $_REQUEST['page']; | ||
| 40 | - | ||
| 41 | -$items = count($aDocuments); | ||
| 42 | -if(fmod($items, 10) > 0){ | ||
| 43 | - $pages = floor($items/10)+1; | ||
| 44 | -}else{ | ||
| 45 | - $pages = ($items/10); | ||
| 46 | -} | ||
| 47 | -if($pageNum == 1){ | ||
| 48 | - $listStart = 0; | ||
| 49 | - $listEnd = 9; | ||
| 50 | -}elseif($pageNum == $pages){ | ||
| 51 | - $listStart = (10*($pageNum-1)); | ||
| 52 | - $listEnd = count($aDocuments)-1; | ||
| 53 | -}else{ | ||
| 54 | - $listStart = (10*($pageNum-1)); | ||
| 55 | - $listEnd = $listStart+9; | ||
| 56 | -} | ||
| 57 | -for($i = $listStart; $i <= $listEnd; $i++){ | ||
| 58 | - $output .= "<tr> | ||
| 59 | - <td><input type='checkbox' name='selected_docs[]' value='".$aDocuments[$i]->getId()."'/></td> | ||
| 60 | - <td>".$aDocuments[$i]->getName()."</td> | ||
| 61 | - <td>".$aDocuments[$i]->getLastModifiedDate()."</td> | ||
| 62 | - <td>".$aDocuments[$i]->getLastDeletionComment()."</td> | ||
| 63 | - </tr>"; | ||
| 64 | -} | ||
| 65 | -echo $output; | ||
| 66 | -?> | 1 | +<?php |
| 2 | +/** | ||
| 3 | + * $Id$ | ||
| 4 | + * | ||
| 5 | + * The contents of this file are subject to the KnowledgeTree Public | ||
| 6 | + * License Version 1.1.2 ("License"); You may not use this file except in | ||
| 7 | + * compliance with the License. You may obtain a copy of the License at | ||
| 8 | + * http://www.knowledgetree.com/KPL | ||
| 9 | + * | ||
| 10 | + * Software distributed under the License is distributed on an "AS IS" | ||
| 11 | + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing rights and | ||
| 13 | + * limitations under the License. | ||
| 14 | + * | ||
| 15 | + * All copies of the Covered Code must include on each user interface screen: | ||
| 16 | + * (i) the "Powered by KnowledgeTree" logo and | ||
| 17 | + * (ii) the KnowledgeTree copyright notice | ||
| 18 | + * in the same form as they appear in the distribution. See the License for | ||
| 19 | + * requirements. | ||
| 20 | + * | ||
| 21 | + * The Original Code is: KnowledgeTree Open Source | ||
| 22 | + * | ||
| 23 | + * The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 24 | + * (Pty) Ltd, trading as KnowledgeTree. | ||
| 25 | + * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 26 | + * (C) 2007 The Jam Warehouse Software (Pty) Ltd; | ||
| 27 | + * All Rights Reserved. | ||
| 28 | + * Contributor( s): ______________________________________ | ||
| 29 | + */ | ||
| 30 | + | ||
| 31 | +require_once('../../../config/dmsDefaults.php'); | ||
| 32 | +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); | ||
| 33 | + | ||
| 34 | +require_once(KT_LIB_DIR . '/documentmanagement/Document.inc'); | ||
| 35 | +require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); | ||
| 36 | + | ||
| 37 | +$aDocuments =& Document::getList("status_id=" . DELETED); | ||
| 38 | + | ||
| 39 | +$pageNum = $_REQUEST['page']; | ||
| 40 | + | ||
| 41 | +$items = count($aDocuments); | ||
| 42 | +if(fmod($items, 10) > 0){ | ||
| 43 | + $pages = floor($items/10)+1; | ||
| 44 | +}else{ | ||
| 45 | + $pages = ($items/10); | ||
| 46 | +} | ||
| 47 | +if($pageNum == 1){ | ||
| 48 | + $listStart = 0; | ||
| 49 | + $listEnd = 9; | ||
| 50 | +}elseif($pageNum == $pages){ | ||
| 51 | + $listStart = (10*($pageNum-1)); | ||
| 52 | + $listEnd = count($aDocuments)-1; | ||
| 53 | +}else{ | ||
| 54 | + $listStart = (10*($pageNum-1)); | ||
| 55 | + $listEnd = $listStart+9; | ||
| 56 | +} | ||
| 57 | +for($i = $listStart; $i <= $listEnd; $i++){ | ||
| 58 | + $output .= "<tr> | ||
| 59 | + <td><input type='checkbox' name='selected_docs[]' value='".$aDocuments[$i]->getId()."'/></td> | ||
| 60 | + <td>".$aDocuments[$i]->getName()."</td> | ||
| 61 | + <td>".$aDocuments[$i]->getLastModifiedDate()."</td> | ||
| 62 | + <td>".$aDocuments[$i]->getLastDeletionComment()."</td> | ||
| 63 | + </tr>"; | ||
| 64 | +} | ||
| 65 | +echo $output; | ||
| 66 | +?> |
plugins/ktcore/admin/fieldsets/basic.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: documentFields.php 5801 2006-08-15 10:06:22Z bryndivey $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/admin/fieldsets/conditional.inc.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: documentFields.php 5801 2006-08-15 10:06:22Z bryndivey $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/admin/manageViews.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/admin/workflow/newworkflow.inc.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktcore/admin/workflowsv2.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | 3 | + * $Id$ |
| 4 | * | 4 | * |
| 5 | * The contents of this file are subject to the KnowledgeTree Public | 5 | * The contents of this file are subject to the KnowledgeTree Public |
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktstandard/ImmutableActionPlugin.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: KTBulkExportPlugin.php 5758 2006-07-27 10:17:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktstandard/KTDocumentLinksColumns.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: KTDocumentLinks.php 5758 2006-07-27 10:17:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktstandard/KTWebDAVDashletPlugin.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: KTWebDAVDashletPlugin.php 6609 2007-05-30 14:40:10Z kevin_fourie $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
plugins/ktstandard/contents/XmlHtmlIndexer.php
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | - * $Id: OpenDocumentIndexer.php 5758 2006-07-27 10:17:43Z bshuttle $ | 4 | + * $Id$ |
| 5 | * | 5 | * |
| 6 | * The contents of this file are subject to the KnowledgeTree Public | 6 | * The contents of this file are subject to the KnowledgeTree Public |
| 7 | * License Version 1.1.2 ("License"); You may not use this file except in | 7 | * License Version 1.1.2 ("License"); You may not use this file except in |
resources/css/kt-ie-7.css
rss.php
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id: view.php 6584 2007-05-23 13:43:15Z kevin_fourie $ | ||
| 4 | - * | ||
| 5 | - * The contents of this file are subject to the KnowledgeTree Public | ||
| 6 | - * License Version 1.1.2 ("License"); You may not use this file except in | ||
| 7 | - * compliance with the License. You may obtain a copy of the License at | ||
| 8 | - * http://www.knowledgetree.com/KPL | ||
| 9 | - * | ||
| 10 | - * Software distributed under the License is distributed on an "AS IS" | ||
| 11 | - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing rights and | ||
| 13 | - * limitations under the License. | ||
| 14 | - * | ||
| 15 | - * All copies of the Covered Code must include on each user interface screen: | ||
| 16 | - * (i) the "Powered by KnowledgeTree" logo and | ||
| 17 | - * (ii) the KnowledgeTree copyright notice | ||
| 18 | - * in the same form as they appear in the distribution. See the License for | ||
| 19 | - * requirements. | ||
| 20 | - * | ||
| 21 | - * The Original Code is: KnowledgeTree Open Source | ||
| 22 | - * | ||
| 23 | - * The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 24 | - * (Pty) Ltd, trading as KnowledgeTree. | ||
| 25 | - * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 26 | - * (C) 2007 The Jam Warehouse Software (Pty) Ltd; | ||
| 27 | - * All Rights Reserved. | ||
| 28 | - * Contributor( s): ______________________________________ | ||
| 29 | - */ | ||
| 30 | - | ||
| 31 | -require_once('config/dmsDefaults.php'); | ||
| 32 | -require_once(KT_LIB_DIR .'/authentication/DBAuthenticator.inc'); | ||
| 33 | -require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); | ||
| 34 | -require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); | ||
| 35 | - | ||
| 36 | -// widget includes. | ||
| 37 | -require_once(KT_LIB_DIR . "/widgets/portlet.inc.php"); | ||
| 38 | -require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php"); | ||
| 39 | -require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php"); | ||
| 40 | -require_once(KT_LIB_DIR . "/actions/documentaction.inc.php"); | ||
| 41 | -require_once(KT_LIB_DIR . "/browse/browseutil.inc.php"); | ||
| 42 | - | ||
| 43 | -require_once(KT_LIB_DIR . '/mime.inc.php'); | ||
| 44 | - | ||
| 45 | -// workaround to get http authentication working in cgi mode | ||
| 46 | -$altinfo = KTUtil::arrayGet( $_SERVER, 'kt_auth', KTUtil::arrayGet( $_SERVER, 'REDIRECT_kt_auth')); | ||
| 47 | -if ( !empty( $altinfo) && !isset( $_SERVER['PHP_AUTH_USER'])) { | ||
| 48 | - $val = $altinfo; | ||
| 49 | - $pieces = explode( ' ', $val); // bad. | ||
| 50 | - if ( $pieces[0] == 'Basic') { | ||
| 51 | - $chunk = $pieces[1]; | ||
| 52 | - $decoded = base64_decode( $chunk); | ||
| 53 | - $credential_info = explode( ':', $decoded); | ||
| 54 | - if ( count( $credential_info) == 2) { | ||
| 55 | - $_SERVER['PHP_AUTH_USER'] = $credential_info[0]; | ||
| 56 | - $_SERVER['PHP_AUTH_PW'] = $credential_info[1]; | ||
| 57 | - $_SERVER["AUTH_TYPE"] = 'Basic'; | ||
| 58 | - } | ||
| 59 | - } | ||
| 60 | -} | ||
| 61 | - | ||
| 62 | -if (!validateUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { | ||
| 63 | - header('WWW-Authenticate: Basic realm="KnowledgeTree DMS"'); | ||
| 64 | - header('HTTP/1.0 401 Unauthorized'); | ||
| 65 | - echo 'This RSS feed requires authentication. Please enter your username and password.'; | ||
| 66 | - exit; | ||
| 67 | -} else { | ||
| 68 | - $user = DBAuthenticator::getUser($_SERVER['PHP_AUTH_USER'], array('id'=>'id',)); | ||
| 69 | - $id = $user[$_SERVER['PHP_AUTH_USER']]['id']; | ||
| 70 | - | ||
| 71 | - | ||
| 72 | - if(KTUtil::arrayGet($_REQUEST, 'docId')){ // if a docId parameter is passed | ||
| 73 | - // get document id from http request object | ||
| 74 | - $iDocumentId = KTUtil::arrayGet($_REQUEST, 'docId'); | ||
| 75 | - | ||
| 76 | - if(KTrss::validateDocumentPermissions($id, $iDocumentId)){ // if document passes validation check | ||
| 77 | - // get document info | ||
| 78 | - $aDocumentInfo[] = KTrss::getOneDocument($iDocumentId, $id); | ||
| 79 | - | ||
| 80 | - if($aDocumentInfo){ | ||
| 81 | - // create rss xml for document | ||
| 82 | - $documentFeed = KTrss::arrayToXML($aDocumentInfo); | ||
| 83 | - }else{ | ||
| 84 | - // create rss xml for the error | ||
| 85 | - $error = KTrss::errorToXML(_kt('This document has returned a empty response')); | ||
| 86 | - } | ||
| 87 | - }else{ | ||
| 88 | - // create rss xml for error | ||
| 89 | - $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this document or it does not exist.' . | ||
| 90 | - ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid document.')); | ||
| 91 | - } | ||
| 92 | - if(isset($error)){ // if an error exist, output...else out the result | ||
| 93 | - echo $error; | ||
| 94 | - }else{ | ||
| 95 | - echo $documentFeed; | ||
| 96 | - } | ||
| 97 | - }elseif(KTUtil::arrayGet($_REQUEST, 'folderId')){ // if a folderId parameter is passed | ||
| 98 | - // get folder id from http request object | ||
| 99 | - $iFolderId = KTUtil::arrayGet($_REQUEST, 'folderId'); | ||
| 100 | - | ||
| 101 | - if(KTrss::validateFolderPermissions($id, $iFolderId)){ // if folder passes validation check | ||
| 102 | - // get folder info | ||
| 103 | - $aFolderInfo[] = KTrss::getOneFolder($iFolderId); | ||
| 104 | - | ||
| 105 | - if($aFolderInfo){ | ||
| 106 | - // create rss xml for folder | ||
| 107 | - $folderFeed = KTrss::arrayToXML($aFolderInfo); | ||
| 108 | - }else{ | ||
| 109 | - // create rss xml for error | ||
| 110 | - $error = KTrss::errorToXML(_kt('This document has returned a empty response')); | ||
| 111 | - } | ||
| 112 | - }else{ | ||
| 113 | - // create rss xml for error | ||
| 114 | - $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' . | ||
| 115 | - ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid folder.')); | ||
| 116 | - } | ||
| 117 | - if(isset($error)){ // if an error exist, output...else out the result | ||
| 118 | - echo $error; | ||
| 119 | - }else{ | ||
| 120 | - echo $folderFeed; | ||
| 121 | - } | ||
| 122 | - }else{ // else do normal rss parsing | ||
| 123 | - // get full list of subscribed documents and folders | ||
| 124 | - $aFullList = array_merge(KTrss::getDocuments($id), KTrss::getFolders($id)); | ||
| 125 | - $internalFeed = KTrss::arrayToXML($aFullList); | ||
| 126 | - echo $internalFeed; | ||
| 127 | - } | ||
| 128 | -} | ||
| 129 | - | ||
| 130 | -// Validate user credentials | ||
| 131 | -function validateUser($username, $password){ | ||
| 132 | - return DBAuthenticator::checkPassword($username, $password); | ||
| 133 | -} | ||
| 134 | -?> | 1 | +<?php |
| 2 | +/** | ||
| 3 | + * $Id$ | ||
| 4 | + * | ||
| 5 | + * The contents of this file are subject to the KnowledgeTree Public | ||
| 6 | + * License Version 1.1.2 ("License"); You may not use this file except in | ||
| 7 | + * compliance with the License. You may obtain a copy of the License at | ||
| 8 | + * http://www.knowledgetree.com/KPL | ||
| 9 | + * | ||
| 10 | + * Software distributed under the License is distributed on an "AS IS" | ||
| 11 | + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing rights and | ||
| 13 | + * limitations under the License. | ||
| 14 | + * | ||
| 15 | + * All copies of the Covered Code must include on each user interface screen: | ||
| 16 | + * (i) the "Powered by KnowledgeTree" logo and | ||
| 17 | + * (ii) the KnowledgeTree copyright notice | ||
| 18 | + * in the same form as they appear in the distribution. See the License for | ||
| 19 | + * requirements. | ||
| 20 | + * | ||
| 21 | + * The Original Code is: KnowledgeTree Open Source | ||
| 22 | + * | ||
| 23 | + * The Initial Developer of the Original Code is The Jam Warehouse Software | ||
| 24 | + * (Pty) Ltd, trading as KnowledgeTree. | ||
| 25 | + * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | ||
| 26 | + * (C) 2007 The Jam Warehouse Software (Pty) Ltd; | ||
| 27 | + * All Rights Reserved. | ||
| 28 | + * Contributor( s): ______________________________________ | ||
| 29 | + */ | ||
| 30 | + | ||
| 31 | +require_once('config/dmsDefaults.php'); | ||
| 32 | +require_once(KT_LIB_DIR .'/authentication/DBAuthenticator.inc'); | ||
| 33 | +require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); | ||
| 34 | +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); | ||
| 35 | + | ||
| 36 | +// widget includes. | ||
| 37 | +require_once(KT_LIB_DIR . "/widgets/portlet.inc.php"); | ||
| 38 | +require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php"); | ||
| 39 | +require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php"); | ||
| 40 | +require_once(KT_LIB_DIR . "/actions/documentaction.inc.php"); | ||
| 41 | +require_once(KT_LIB_DIR . "/browse/browseutil.inc.php"); | ||
| 42 | + | ||
| 43 | +require_once(KT_LIB_DIR . '/mime.inc.php'); | ||
| 44 | + | ||
| 45 | +// workaround to get http authentication working in cgi mode | ||
| 46 | +$altinfo = KTUtil::arrayGet( $_SERVER, 'kt_auth', KTUtil::arrayGet( $_SERVER, 'REDIRECT_kt_auth')); | ||
| 47 | +if ( !empty( $altinfo) && !isset( $_SERVER['PHP_AUTH_USER'])) { | ||
| 48 | + $val = $altinfo; | ||
| 49 | + $pieces = explode( ' ', $val); // bad. | ||
| 50 | + if ( $pieces[0] == 'Basic') { | ||
| 51 | + $chunk = $pieces[1]; | ||
| 52 | + $decoded = base64_decode( $chunk); | ||
| 53 | + $credential_info = explode( ':', $decoded); | ||
| 54 | + if ( count( $credential_info) == 2) { | ||
| 55 | + $_SERVER['PHP_AUTH_USER'] = $credential_info[0]; | ||
| 56 | + $_SERVER['PHP_AUTH_PW'] = $credential_info[1]; | ||
| 57 | + $_SERVER["AUTH_TYPE"] = 'Basic'; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +if (!validateUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { | ||
| 63 | + header('WWW-Authenticate: Basic realm="KnowledgeTree DMS"'); | ||
| 64 | + header('HTTP/1.0 401 Unauthorized'); | ||
| 65 | + echo 'This RSS feed requires authentication. Please enter your username and password.'; | ||
| 66 | + exit; | ||
| 67 | +} else { | ||
| 68 | + $user = DBAuthenticator::getUser($_SERVER['PHP_AUTH_USER'], array('id'=>'id',)); | ||
| 69 | + $id = $user[$_SERVER['PHP_AUTH_USER']]['id']; | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + if(KTUtil::arrayGet($_REQUEST, 'docId')){ // if a docId parameter is passed | ||
| 73 | + // get document id from http request object | ||
| 74 | + $iDocumentId = KTUtil::arrayGet($_REQUEST, 'docId'); | ||
| 75 | + | ||
| 76 | + if(KTrss::validateDocumentPermissions($id, $iDocumentId)){ // if document passes validation check | ||
| 77 | + // get document info | ||
| 78 | + $aDocumentInfo[] = KTrss::getOneDocument($iDocumentId, $id); | ||
| 79 | + | ||
| 80 | + if($aDocumentInfo){ | ||
| 81 | + // create rss xml for document | ||
| 82 | + $documentFeed = KTrss::arrayToXML($aDocumentInfo); | ||
| 83 | + }else{ | ||
| 84 | + // create rss xml for the error | ||
| 85 | + $error = KTrss::errorToXML(_kt('This document has returned a empty response')); | ||
| 86 | + } | ||
| 87 | + }else{ | ||
| 88 | + // create rss xml for error | ||
| 89 | + $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this document or it does not exist.' . | ||
| 90 | + ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid document.')); | ||
| 91 | + } | ||
| 92 | + if(isset($error)){ // if an error exist, output...else out the result | ||
| 93 | + echo $error; | ||
| 94 | + }else{ | ||
| 95 | + echo $documentFeed; | ||
| 96 | + } | ||
| 97 | + }elseif(KTUtil::arrayGet($_REQUEST, 'folderId')){ // if a folderId parameter is passed | ||
| 98 | + // get folder id from http request object | ||
| 99 | + $iFolderId = KTUtil::arrayGet($_REQUEST, 'folderId'); | ||
| 100 | + | ||
| 101 | + if(KTrss::validateFolderPermissions($id, $iFolderId)){ // if folder passes validation check | ||
| 102 | + // get folder info | ||
| 103 | + $aFolderInfo[] = KTrss::getOneFolder($iFolderId); | ||
| 104 | + | ||
| 105 | + if($aFolderInfo){ | ||
| 106 | + // create rss xml for folder | ||
| 107 | + $folderFeed = KTrss::arrayToXML($aFolderInfo); | ||
| 108 | + }else{ | ||
| 109 | + // create rss xml for error | ||
| 110 | + $error = KTrss::errorToXML(_kt('This document has returned a empty response')); | ||
| 111 | + } | ||
| 112 | + }else{ | ||
| 113 | + // create rss xml for error | ||
| 114 | + $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' . | ||
| 115 | + ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid folder.')); | ||
| 116 | + } | ||
| 117 | + if(isset($error)){ // if an error exist, output...else out the result | ||
| 118 | + echo $error; | ||
| 119 | + }else{ | ||
| 120 | + echo $folderFeed; | ||
| 121 | + } | ||
| 122 | + }else{ // else do normal rss parsing | ||
| 123 | + // get full list of subscribed documents and folders | ||
| 124 | + $aFullList = array_merge(KTrss::getDocuments($id), KTrss::getFolders($id)); | ||
| 125 | + $internalFeed = KTrss::arrayToXML($aFullList); | ||
| 126 | + echo $internalFeed; | ||
| 127 | + } | ||
| 128 | +} | ||
| 129 | + | ||
| 130 | +// Validate user credentials | ||
| 131 | +function validateUser($username, $password){ | ||
| 132 | + return DBAuthenticator::checkPassword($username, $password); | ||
| 133 | +} | ||
| 134 | +?> |
sql/mysql/install/rebuild.bat
| 1 | -@ECHO OFF | ||
| 2 | -CLS | ||
| 3 | -ECHO. | ||
| 4 | -FOR /F "tokens=5* delims= " %%A IN ('VOL C: ^| FIND "drive C"') DO SET OLDLABEL=%%B | ||
| 5 | -ECHO Enter name of database (default is dms): | ||
| 6 | -FOR /F "TOKENS=*" %%? IN ('LABEL C: 2^>NUL') DO SET INPUT=%%? | ||
| 7 | -SET INPUT | ||
| 8 | -CLS | ||
| 9 | -LABEL C: %OLDLABEL% | ||
| 10 | -PAUSE | ||
| 11 | -CLS | ||
| 12 | -ECHO ---- Dropping database %INPUT% ---- | ||
| 13 | -mysqladmin -u root -p -f drop %INPUT% | ||
| 14 | -ECHO ---- Creating database %INPUT% ---- | ||
| 15 | -mysqladmin -u root -p create %INPUT% | ||
| 16 | -ECHO ---- Creating structure for database %INPUT% ---- | ||
| 17 | -mysql -u root %INPUT%<structure.sql | ||
| 18 | -ECHO ---- Inserting data into database %INPUT% ---- | ||
| 19 | -mysql -u root -p %INPUT%< data.sql | ||
| 20 | -ECHO ---- Creating user information for database %INPUT% ---- | 1 | +@ECHO OFF |
| 2 | +CLS | ||
| 3 | +ECHO. | ||
| 4 | +FOR /F "tokens=5* delims= " %%A IN ('VOL C: ^| FIND "drive C"') DO SET OLDLABEL=%%B | ||
| 5 | +ECHO Enter name of database (default is dms): | ||
| 6 | +FOR /F "TOKENS=*" %%? IN ('LABEL C: 2^>NUL') DO SET INPUT=%%? | ||
| 7 | +SET INPUT | ||
| 8 | +CLS | ||
| 9 | +LABEL C: %OLDLABEL% | ||
| 10 | +PAUSE | ||
| 11 | +CLS | ||
| 12 | +ECHO ---- Dropping database %INPUT% ---- | ||
| 13 | +mysqladmin -u root -p -f drop %INPUT% | ||
| 14 | +ECHO ---- Creating database %INPUT% ---- | ||
| 15 | +mysqladmin -u root -p create %INPUT% | ||
| 16 | +ECHO ---- Creating structure for database %INPUT% ---- | ||
| 17 | +mysql -u root %INPUT%<structure.sql | ||
| 18 | +ECHO ---- Inserting data into database %INPUT% ---- | ||
| 19 | +mysql -u root -p %INPUT%< data.sql | ||
| 20 | +ECHO ---- Creating user information for database %INPUT% ---- | ||
| 21 | mysql -u root -p %INPUT%<user.sql | 21 | mysql -u root -p %INPUT%<user.sql |
| 22 | \ No newline at end of file | 22 | \ No newline at end of file |
sql/mysql/upgrade/3.3.1/rss.sql
| 1 | -CREATE TABLE `plugin_rss` | ||
| 2 | -( `id` int(11) NOT NULL, | ||
| 3 | - `user_id` int(11) NOT NULL, | ||
| 4 | - `url` varchar(200) NOT NULL, | ||
| 5 | - `title` varchar(20) NOT NULL, | ||
| 6 | - PRIMARY KEY (`id`)) | ||
| 7 | -ENGINE=MyISAM DEFAULT CHARSET=utf8; | ||
| 8 | - | ||
| 9 | -CREATE TABLE `zseq_plugin_rss` | ||
| 10 | -( | ||
| 11 | - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
| 12 | - PRIMARY KEY (`id`) | ||
| 13 | -) ENGINE=MyISAM AUTO_INCREMENT=1; | ||
| 14 | - | 1 | +CREATE TABLE `plugin_rss` |
| 2 | +( `id` int(11) NOT NULL, | ||
| 3 | + `user_id` int(11) NOT NULL, | ||
| 4 | + `url` varchar(200) NOT NULL, | ||
| 5 | + `title` varchar(20) NOT NULL, | ||
| 6 | + PRIMARY KEY (`id`)) | ||
| 7 | +ENGINE=MyISAM DEFAULT CHARSET=utf8; | ||
| 8 | + | ||
| 9 | +CREATE TABLE `zseq_plugin_rss` | ||
| 10 | +( | ||
| 11 | + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
| 12 | + PRIMARY KEY (`id`) | ||
| 13 | +) ENGINE=MyISAM AUTO_INCREMENT=1; | ||
| 14 | + | ||
| 15 | INSERT INTO `zseq_plugin_rss` (id) VALUES ('1'); | 15 | INSERT INTO `zseq_plugin_rss` (id) VALUES ('1'); |
| 16 | \ No newline at end of file | 16 | \ No newline at end of file |
sql/mysql/upgrade/3.3.2/tagclouds.sql
| 1 | -CREATE TABLE `tag_words` ( | ||
| 2 | - `id` int(10) NOT NULL, | ||
| 3 | - `tag` varchar(100) default NULL, | ||
| 4 | - PRIMARY KEY (`id`)) | ||
| 5 | -ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 6 | - | ||
| 7 | -CREATE TABLE `document_tags` ( | ||
| 8 | - `document_id` int(10) NOT NULL, | ||
| 9 | - `tag_id` int(10) NOT NULL, | ||
| 10 | - PRIMARY KEY (`document_id`,`tag_id`), | ||
| 11 | - CONSTRAINT fk_document_tags_document_id FOREIGN KEY (document_id) REFERENCES documents(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
| 12 | - CONSTRAINT fk_document_tags_tag_id FOREIGN KEY (tag_id) REFERENCES tag_words(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
| 13 | -) | ||
| 14 | -ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 15 | - | ||
| 16 | -CREATE TABLE `zseq_document_tags` ( | ||
| 17 | - `id` int(10) NOT NULL auto_increment, | ||
| 18 | - PRIMARY KEY (`id`)) | ||
| 19 | -ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; | ||
| 20 | -INSERT INTO `zseq_document_tags` (id) VALUES ('1'); | ||
| 21 | - | ||
| 22 | -CREATE TABLE `zseq_tag_words` ( | ||
| 23 | - `id` int(10) NOT NULL auto_increment, | ||
| 24 | - PRIMARY KEY (`id`)) | ||
| 25 | -ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; | ||
| 26 | -INSERT INTO `zseq_tag_words` (id) VALUES ('1'); | ||
| 27 | - | 1 | +CREATE TABLE `tag_words` ( |
| 2 | + `id` int(10) NOT NULL, | ||
| 3 | + `tag` varchar(100) default NULL, | ||
| 4 | + PRIMARY KEY (`id`)) | ||
| 5 | +ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 6 | + | ||
| 7 | +CREATE TABLE `document_tags` ( | ||
| 8 | + `document_id` int(10) NOT NULL, | ||
| 9 | + `tag_id` int(10) NOT NULL, | ||
| 10 | + PRIMARY KEY (`document_id`,`tag_id`), | ||
| 11 | + CONSTRAINT fk_document_tags_document_id FOREIGN KEY (document_id) REFERENCES documents(id) ON UPDATE CASCADE ON DELETE CASCADE, | ||
| 12 | + CONSTRAINT fk_document_tags_tag_id FOREIGN KEY (tag_id) REFERENCES tag_words(id) ON UPDATE CASCADE ON DELETE CASCADE | ||
| 13 | +) | ||
| 14 | +ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 15 | + | ||
| 16 | +CREATE TABLE `zseq_document_tags` ( | ||
| 17 | + `id` int(10) NOT NULL auto_increment, | ||
| 18 | + PRIMARY KEY (`id`)) | ||
| 19 | +ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; | ||
| 20 | +INSERT INTO `zseq_document_tags` (id) VALUES ('1'); | ||
| 21 | + | ||
| 22 | +CREATE TABLE `zseq_tag_words` ( | ||
| 23 | + `id` int(10) NOT NULL auto_increment, | ||
| 24 | + PRIMARY KEY (`id`)) | ||
| 25 | +ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; | ||
| 26 | +INSERT INTO `zseq_tag_words` (id) VALUES ('1'); | ||
| 27 | + |
sql/mysql/upgrade/3.3.3/fieldsets_disable.sql
sql/mysql/upgrade/3.4.0/upload_download.sql
| 1 | -CREATE TABLE `uploaded_files` ( | ||
| 2 | -`tempfilename` varchar(100) NOT NULL, | ||
| 3 | -`filename` varchar(100) NOT NULL, | ||
| 4 | -`userid` int(11) NOT NULL, | ||
| 5 | -`uploaddate` timestamp NOT NULL, | ||
| 6 | -`action` char(1) NOT NULL COMMENT 'A = Add, C = Checkin', | ||
| 7 | -`document_id` int(11) default NULL | ||
| 8 | -) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 9 | - | ||
| 10 | -CREATE TABLE `download_files` ( | ||
| 11 | -`document_id` int(10) unsigned NOT NULL, | ||
| 12 | -`session` varchar(100) NOT NULL, | ||
| 13 | -`download_date` timestamp NULL default CURRENT_TIMESTAMP, | ||
| 14 | -`downloaded` int(10) unsigned NOT NULL default '0', | ||
| 15 | -`filesize` int(10) unsigned NOT NULL, | ||
| 16 | -`content_version` int(10) unsigned NOT NULL, | ||
| 17 | -`hash` varchar(100) NOT NULL, | ||
| 18 | -PRIMARY KEY (`document_id`,`session`) | ||
| 19 | -) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 20 | - | ||
| 21 | -CREATE TABLE `index_files` ( | ||
| 22 | -`document_id` int(10) unsigned NOT NULL, | ||
| 23 | -`user_id` int(10) unsigned NOT NULL, | ||
| 24 | -`indexdate` timestamp NOT NULL, | ||
| 25 | -PRIMARY KEY (`document_id`) | 1 | +CREATE TABLE `uploaded_files` ( |
| 2 | +`tempfilename` varchar(100) NOT NULL, | ||
| 3 | +`filename` varchar(100) NOT NULL, | ||
| 4 | +`userid` int(11) NOT NULL, | ||
| 5 | +`uploaddate` timestamp NOT NULL, | ||
| 6 | +`action` char(1) NOT NULL COMMENT 'A = Add, C = Checkin', | ||
| 7 | +`document_id` int(11) default NULL | ||
| 8 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 9 | + | ||
| 10 | +CREATE TABLE `download_files` ( | ||
| 11 | +`document_id` int(10) unsigned NOT NULL, | ||
| 12 | +`session` varchar(100) NOT NULL, | ||
| 13 | +`download_date` timestamp NULL default CURRENT_TIMESTAMP, | ||
| 14 | +`downloaded` int(10) unsigned NOT NULL default '0', | ||
| 15 | +`filesize` int(10) unsigned NOT NULL, | ||
| 16 | +`content_version` int(10) unsigned NOT NULL, | ||
| 17 | +`hash` varchar(100) NOT NULL, | ||
| 18 | +PRIMARY KEY (`document_id`,`session`) | ||
| 19 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
| 20 | + | ||
| 21 | +CREATE TABLE `index_files` ( | ||
| 22 | +`document_id` int(10) unsigned NOT NULL, | ||
| 23 | +`user_id` int(10) unsigned NOT NULL, | ||
| 24 | +`indexdate` timestamp NOT NULL, | ||
| 25 | +PRIMARY KEY (`document_id`) | ||
| 26 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | 26 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
| 27 | \ No newline at end of file | 27 | \ No newline at end of file |
templates/ktstandard/PDFPlugin/PDFPlugin.smarty
| 1 | -<h2><img src="{if $config->get("ui/morphEnabled") == '1'}{$rootUrl}/skins/kts_{$config->get("ui/morphTo")}/title_bullet.png{else}{$rootUrl}/resources/graphics/title_bullet.png{/if}"/>{i18n}Generate PDF of{/i18n}:<br />{$context->oDocument->getName()}</h2> | ||
| 2 | - | ||
| 3 | -{$form->render()} | 1 | +<h2><img src="{if $config->get("ui/morphEnabled") == '1'}{$rootUrl}/skins/kts_{$config->get("ui/morphTo")}/title_bullet.png{else}{$rootUrl}/resources/graphics/title_bullet.png{/if}"/>{i18n}Generate PDF of{/i18n}:<br />{$context->oDocument->getName()}</h2> |
| 2 | + | ||
| 3 | +{$form->render()} |
templates/ktstandard/ktwebdavdashlet/dashlet.smarty
| 1 | -<div> | ||
| 2 | -<p>{i18n arg_appname="$appname"}To connect to #appname# via a third-party WebDAV client, please use the following address{/i18n}:<br/> | ||
| 3 | -<b><a href="{$url}ktwebdav/ktwebdav.php" target="_blank">{$url}ktwebdav/ktwebdav.php</a></b><br/><br/> | ||
| 4 | -{i18n arg_appname="$appname"}To connect with the #appname# Tools Suite, use this address{/i18n}:<br/> | ||
| 5 | -<b>{$url}</b><br/><br/> | ||
| 6 | -</p> | ||
| 7 | -</div> | ||
| 8 | - | 1 | +<div> |
| 2 | +<p>{i18n arg_appname="$appname"}To connect to #appname# via a third-party WebDAV client, please use the following address{/i18n}:<br/> | ||
| 3 | +<b><a href="{$url}ktwebdav/ktwebdav.php" target="_blank">{$url}ktwebdav/ktwebdav.php</a></b><br/><br/> | ||
| 4 | +{i18n arg_appname="$appname"}To connect with the #appname# Tools Suite, use this address{/i18n}:<br/> | ||
| 5 | +<b>{$url}</b><br/><br/> | ||
| 6 | +</p> | ||
| 7 | +</div> | ||
| 8 | + |
thirdparty/pear/Console/Getopt.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Author: Andrei Zmievski <andrei@php.net> | | 16 | // | Author: Andrei Zmievski <andrei@php.net> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: Getopt.php,v 1.21.4.7 2003/12/05 21:57:01 andrei Exp $ | 19 | +// $Id$ |
| 20 | 20 | ||
| 21 | require_once 'PEAR.php'; | 21 | require_once 'PEAR.php'; |
| 22 | 22 |
thirdparty/pear/GraphViz.php
| @@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
| 21 | * @author Michael Lively Jr. <mlively@ft11.net> | 21 | * @author Michael Lively Jr. <mlively@ft11.net> |
| 22 | * @copyright 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> | 22 | * @copyright 2001-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> |
| 23 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 | 23 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
| 24 | - * @version CVS: $Id: GraphViz.php,v 1.25 2006/05/16 15:49:19 sebastian Exp $ | 24 | + * @version CVS: $Id$ |
| 25 | * @link http://pear.php.net/package/Image_GraphViz | 25 | * @link http://pear.php.net/package/Image_GraphViz |
| 26 | * @since File available since Release 0.1 | 26 | * @since File available since Release 0.1 |
| 27 | */ | 27 | */ |
thirdparty/pear/HTTP/Client.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Author: Alexey Borzov <avb@php.net> | | 16 | // | Author: Alexey Borzov <avb@php.net> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: Client.php,v 1.4 2004/03/23 13:35:37 avb Exp $ | 19 | +// $Id$ |
| 20 | 20 | ||
| 21 | require_once 'HTTP/Request.php'; | 21 | require_once 'HTTP/Request.php'; |
| 22 | require_once 'HTTP/Client/CookieManager.php'; | 22 | require_once 'HTTP/Client/CookieManager.php'; |
| @@ -29,7 +29,7 @@ require_once 'HTTP/Client/CookieManager.php'; | @@ -29,7 +29,7 @@ require_once 'HTTP/Client/CookieManager.php'; | ||
| 29 | * | 29 | * |
| 30 | * @package HTTP_Client | 30 | * @package HTTP_Client |
| 31 | * @author Alexey Borzov <avb@php.net> | 31 | * @author Alexey Borzov <avb@php.net> |
| 32 | - * @version $Revision: 1.4 $ | 32 | + * @version $Revision$ |
| 33 | */ | 33 | */ |
| 34 | class HTTP_Client | 34 | class HTTP_Client |
| 35 | { | 35 | { |
thirdparty/pear/HTTP/Client/CookieManager.php
| @@ -16,14 +16,14 @@ | @@ -16,14 +16,14 @@ | ||
| 16 | // | Author: Alexey Borzov <avb@php.net> | | 16 | // | Author: Alexey Borzov <avb@php.net> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: CookieManager.php,v 1.3 2004/04/10 10:04:52 avb Exp $ | 19 | +// $Id$ |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | * This class is used to store cookies and pass them between HTTP requests. | 22 | * This class is used to store cookies and pass them between HTTP requests. |
| 23 | * | 23 | * |
| 24 | * @package HTTP_Client | 24 | * @package HTTP_Client |
| 25 | * @author Alexey Borzov <avb@php.net> | 25 | * @author Alexey Borzov <avb@php.net> |
| 26 | - * @version $Revision: 1.3 $ | 26 | + * @version $Revision$ |
| 27 | */ | 27 | */ |
| 28 | class HTTP_Client_CookieManager | 28 | class HTTP_Client_CookieManager |
| 29 | { | 29 | { |
thirdparty/pear/HTTP/Download.php
| 1 | -<?php | ||
| 2 | -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | - | ||
| 4 | -/** | ||
| 5 | - * HTTP::Download | ||
| 6 | - * | ||
| 7 | - * PHP versions 4 and 5 | ||
| 8 | - * | ||
| 9 | - * @category HTTP | ||
| 10 | - * @package HTTP_Download | ||
| 11 | - * @author Michael Wallner <mike@php.net> | ||
| 12 | - * @copyright 2003-2005 Michael Wallner | ||
| 13 | - * @license BSD, revised | ||
| 14 | - * @version CVS: $Id: Download.php,v 1.75 2005/11/13 19:18:53 mike Exp $ | ||
| 15 | - * @link http://pear.php.net/package/HTTP_Download | ||
| 16 | - */ | ||
| 17 | - | ||
| 18 | -// {{{ includes | ||
| 19 | -/** | ||
| 20 | - * Requires PEAR | ||
| 21 | - */ | ||
| 22 | -require_once 'PEAR.php'; | ||
| 23 | - | ||
| 24 | -/** | ||
| 25 | - * Requires HTTP_Header | ||
| 26 | - */ | ||
| 27 | -require_once 'HTTP/Header.php'; | ||
| 28 | -// }}} | ||
| 29 | - | ||
| 30 | -// {{{ constants | ||
| 31 | -/**#@+ Use with HTTP_Download::setContentDisposition() **/ | ||
| 32 | -/** | ||
| 33 | - * Send data as attachment | ||
| 34 | - */ | ||
| 35 | -define('HTTP_DOWNLOAD_ATTACHMENT', 'attachment'); | ||
| 36 | -/** | ||
| 37 | - * Send data inline | ||
| 38 | - */ | ||
| 39 | -define('HTTP_DOWNLOAD_INLINE', 'inline'); | ||
| 40 | -/**#@-**/ | ||
| 41 | - | ||
| 42 | -/**#@+ Use with HTTP_Download::sendArchive() **/ | ||
| 43 | -/** | ||
| 44 | - * Send as uncompressed tar archive | ||
| 45 | - */ | ||
| 46 | -define('HTTP_DOWNLOAD_TAR', 'TAR'); | ||
| 47 | -/** | ||
| 48 | - * Send as gzipped tar archive | ||
| 49 | - */ | ||
| 50 | -define('HTTP_DOWNLOAD_TGZ', 'TGZ'); | ||
| 51 | -/** | ||
| 52 | - * Send as bzip2 compressed tar archive | ||
| 53 | - */ | ||
| 54 | -define('HTTP_DOWNLOAD_BZ2', 'BZ2'); | ||
| 55 | -/** | ||
| 56 | - * Send as zip archive | ||
| 57 | - */ | ||
| 58 | -define('HTTP_DOWNLOAD_ZIP', 'ZIP'); | ||
| 59 | -/**#@-**/ | ||
| 60 | - | ||
| 61 | -/**#@+ | ||
| 62 | - * Error constants | ||
| 63 | - */ | ||
| 64 | -define('HTTP_DOWNLOAD_E_HEADERS_SENT', -1); | ||
| 65 | -define('HTTP_DOWNLOAD_E_NO_EXT_ZLIB', -2); | ||
| 66 | -define('HTTP_DOWNLOAD_E_NO_EXT_MMAGIC', -3); | ||
| 67 | -define('HTTP_DOWNLOAD_E_INVALID_FILE', -4); | ||
| 68 | -define('HTTP_DOWNLOAD_E_INVALID_PARAM', -5); | ||
| 69 | -define('HTTP_DOWNLOAD_E_INVALID_RESOURCE', -6); | ||
| 70 | -define('HTTP_DOWNLOAD_E_INVALID_REQUEST', -7); | ||
| 71 | -define('HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE', -8); | ||
| 72 | -define('HTTP_DOWNLOAD_E_INVALID_ARCHIVE_TYPE', -9); | ||
| 73 | -/**#@-**/ | ||
| 74 | -// }}} | ||
| 75 | - | ||
| 76 | -/** | ||
| 77 | - * Send HTTP Downloads/Responses. | ||
| 78 | - * | ||
| 79 | - * With this package you can handle (hidden) downloads. | ||
| 80 | - * It supports partial downloads, resuming and sending | ||
| 81 | - * raw data ie. from database BLOBs. | ||
| 82 | - * | ||
| 83 | - * <i>ATTENTION:</i> | ||
| 84 | - * You shouldn't use this package together with ob_gzhandler or | ||
| 85 | - * zlib.output_compression enabled in your php.ini, especially | ||
| 86 | - * if you want to send already gzipped data! | ||
| 87 | - * | ||
| 88 | - * @access public | ||
| 89 | - * @version $Revision: 1.75 $ | ||
| 90 | - */ | ||
| 91 | -class HTTP_Download | ||
| 92 | -{ | ||
| 93 | - // {{{ protected member variables | ||
| 94 | - /** | ||
| 95 | - * Path to file for download | ||
| 96 | - * | ||
| 97 | - * @see HTTP_Download::setFile() | ||
| 98 | - * @access protected | ||
| 99 | - * @var string | ||
| 100 | - */ | ||
| 101 | - var $file = ''; | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * Data for download | ||
| 105 | - * | ||
| 106 | - * @see HTTP_Download::setData() | ||
| 107 | - * @access protected | ||
| 108 | - * @var string | ||
| 109 | - */ | ||
| 110 | - var $data = null; | ||
| 111 | - | ||
| 112 | - /** | ||
| 113 | - * Resource handle for download | ||
| 114 | - * | ||
| 115 | - * @see HTTP_Download::setResource() | ||
| 116 | - * @access protected | ||
| 117 | - * @var int | ||
| 118 | - */ | ||
| 119 | - var $handle = null; | ||
| 120 | - | ||
| 121 | - /** | ||
| 122 | - * Whether to gzip the download | ||
| 123 | - * | ||
| 124 | - * @access protected | ||
| 125 | - * @var bool | ||
| 126 | - */ | ||
| 127 | - var $gzip = false; | ||
| 128 | - | ||
| 129 | - /** | ||
| 130 | - * Whether to allow caching of the download on the clients side | ||
| 131 | - * | ||
| 132 | - * @access protected | ||
| 133 | - * @var bool | ||
| 134 | - */ | ||
| 135 | - var $cache = true; | ||
| 136 | - | ||
| 137 | - /** | ||
| 138 | - * Size of download | ||
| 139 | - * | ||
| 140 | - * @access protected | ||
| 141 | - * @var int | ||
| 142 | - */ | ||
| 143 | - var $size = 0; | ||
| 144 | - | ||
| 145 | - /** | ||
| 146 | - * Last modified | ||
| 147 | - * | ||
| 148 | - * @access protected | ||
| 149 | - * @var int | ||
| 150 | - */ | ||
| 151 | - var $lastModified = 0; | ||
| 152 | - | ||
| 153 | - /** | ||
| 154 | - * HTTP headers | ||
| 155 | - * | ||
| 156 | - * @access protected | ||
| 157 | - * @var array | ||
| 158 | - */ | ||
| 159 | - var $headers = array( | ||
| 160 | - 'Content-Type' => 'application/x-octetstream', | ||
| 161 | - 'Pragma' => 'cache', | ||
| 162 | - 'Cache-Control' => 'public, must-revalidate, max-age=0', | ||
| 163 | - 'Accept-Ranges' => 'bytes', | ||
| 164 | - 'X-Sent-By' => 'PEAR::HTTP::Download' | ||
| 165 | - ); | ||
| 166 | - | ||
| 167 | - /** | ||
| 168 | - * HTTP_Header | ||
| 169 | - * | ||
| 170 | - * @access protected | ||
| 171 | - * @var object | ||
| 172 | - */ | ||
| 173 | - var $HTTP = null; | ||
| 174 | - | ||
| 175 | - /** | ||
| 176 | - * ETag | ||
| 177 | - * | ||
| 178 | - * @access protected | ||
| 179 | - * @var string | ||
| 180 | - */ | ||
| 181 | - var $etag = ''; | ||
| 182 | - | ||
| 183 | - /** | ||
| 184 | - * Buffer Size | ||
| 185 | - * | ||
| 186 | - * @access protected | ||
| 187 | - * @var int | ||
| 188 | - */ | ||
| 189 | - var $bufferSize = 2097152; | ||
| 190 | - | ||
| 191 | - /** | ||
| 192 | - * Throttle Delay | ||
| 193 | - * | ||
| 194 | - * @access protected | ||
| 195 | - * @var float | ||
| 196 | - */ | ||
| 197 | - var $throttleDelay = 0; | ||
| 198 | - | ||
| 199 | - /** | ||
| 200 | - * Sent Bytes | ||
| 201 | - * | ||
| 202 | - * @access public | ||
| 203 | - * @var int | ||
| 204 | - */ | ||
| 205 | - var $sentBytes = 0; | ||
| 206 | - // }}} | ||
| 207 | - | ||
| 208 | - // {{{ constructor | ||
| 209 | - /** | ||
| 210 | - * Constructor | ||
| 211 | - * | ||
| 212 | - * Set supplied parameters. | ||
| 213 | - * | ||
| 214 | - * @access public | ||
| 215 | - * @param array $params associative array of parameters | ||
| 216 | - * | ||
| 217 | - * <b>one of:</b> | ||
| 218 | - * o 'file' => path to file for download | ||
| 219 | - * o 'data' => raw data for download | ||
| 220 | - * o 'resource' => resource handle for download | ||
| 221 | - * <br/> | ||
| 222 | - * <b>and any of:</b> | ||
| 223 | - * o 'cache' => whether to allow cs caching | ||
| 224 | - * o 'gzip' => whether to gzip the download | ||
| 225 | - * o 'lastmodified' => unix timestamp | ||
| 226 | - * o 'contenttype' => content type of download | ||
| 227 | - * o 'contentdisposition' => content disposition | ||
| 228 | - * o 'buffersize' => amount of bytes to buffer | ||
| 229 | - * o 'throttledelay' => amount of secs to sleep | ||
| 230 | - * o 'cachecontrol' => cache privacy and validity | ||
| 231 | - * | ||
| 232 | - * <br /> | ||
| 233 | - * 'Content-Disposition' is not HTTP compliant, but most browsers | ||
| 234 | - * follow this header, so it was borrowed from MIME standard. | ||
| 235 | - * | ||
| 236 | - * It looks like this: <br /> | ||
| 237 | - * "Content-Disposition: attachment; filename=example.tgz". | ||
| 238 | - * | ||
| 239 | - * @see HTTP_Download::setContentDisposition() | ||
| 240 | - */ | ||
| 241 | - function HTTP_Download($params = array()) | ||
| 242 | - { | ||
| 243 | - $this->HTTP = &new HTTP_Header; | ||
| 244 | - $this->setParams($params); | ||
| 245 | - } | ||
| 246 | - // }}} | ||
| 247 | - | ||
| 248 | - // {{{ public methods | ||
| 249 | - /** | ||
| 250 | - * Set parameters | ||
| 251 | - * | ||
| 252 | - * Set supplied parameters through its accessor methods. | ||
| 253 | - * | ||
| 254 | - * @access public | ||
| 255 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 256 | - * @param array $params associative array of parameters | ||
| 257 | - * | ||
| 258 | - * @see HTTP_Download::HTTP_Download() | ||
| 259 | - */ | ||
| 260 | - function setParams($params) | ||
| 261 | - { | ||
| 262 | - foreach((array) $params as $param => $value){ | ||
| 263 | - $method = 'set'. $param; | ||
| 264 | - | ||
| 265 | - if (!method_exists($this, $method)) { | ||
| 266 | - return PEAR::raiseError( | ||
| 267 | - "Method '$method' doesn't exist.", | ||
| 268 | - HTTP_DOWNLOAD_E_INVALID_PARAM | ||
| 269 | - ); | ||
| 270 | - } | ||
| 271 | - | ||
| 272 | - $e = call_user_func_array(array(&$this, $method), (array) $value); | ||
| 273 | - | ||
| 274 | - if (PEAR::isError($e)) { | ||
| 275 | - return $e; | ||
| 276 | - } | ||
| 277 | - } | ||
| 278 | - return true; | ||
| 279 | - } | ||
| 280 | - | ||
| 281 | - /** | ||
| 282 | - * Set path to file for download | ||
| 283 | - * | ||
| 284 | - * The Last-Modified header will be set to files filemtime(), actually. | ||
| 285 | - * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_FILE) if file doesn't exist. | ||
| 286 | - * Sends HTTP 404 status if $send_404 is set to true. | ||
| 287 | - * | ||
| 288 | - * @access public | ||
| 289 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 290 | - * @param string $file path to file for download | ||
| 291 | - * @param bool $send_404 whether to send HTTP/404 if | ||
| 292 | - * the file wasn't found | ||
| 293 | - */ | ||
| 294 | - function setFile($file, $send_404 = true) | ||
| 295 | - { | ||
| 296 | - $file = realpath($file); | ||
| 297 | - if (!is_file($file)) { | ||
| 298 | - if ($send_404) { | ||
| 299 | - $this->HTTP->sendStatusCode(404); | ||
| 300 | - } | ||
| 301 | - return PEAR::raiseError( | ||
| 302 | - "File '$file' not found.", | ||
| 303 | - HTTP_DOWNLOAD_E_INVALID_FILE | ||
| 304 | - ); | ||
| 305 | - } | ||
| 306 | - $this->setLastModified(filemtime($file)); | ||
| 307 | - $this->file = $file; | ||
| 308 | - $this->size = filesize($file); | ||
| 309 | - return true; | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - /** | ||
| 313 | - * Set data for download | ||
| 314 | - * | ||
| 315 | - * Set $data to null if you want to unset this. | ||
| 316 | - * | ||
| 317 | - * @access public | ||
| 318 | - * @return void | ||
| 319 | - * @param $data raw data to send | ||
| 320 | - */ | ||
| 321 | - function setData($data = null) | ||
| 322 | - { | ||
| 323 | - $this->data = $data; | ||
| 324 | - $this->size = strlen($data); | ||
| 325 | - } | ||
| 326 | - | ||
| 327 | - /** | ||
| 328 | - * Set resource for download | ||
| 329 | - * | ||
| 330 | - * The resource handle supplied will be closed after sending the download. | ||
| 331 | - * Returns a PEAR_Error (HTTP_DOWNLOAD_E_INVALID_RESOURCE) if $handle | ||
| 332 | - * is no valid resource. Set $handle to null if you want to unset this. | ||
| 333 | - * | ||
| 334 | - * @access public | ||
| 335 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 336 | - * @param int $handle resource handle | ||
| 337 | - */ | ||
| 338 | - function setResource($handle = null) | ||
| 339 | - { | ||
| 340 | - if (!isset($handle)) { | ||
| 341 | - $this->handle = null; | ||
| 342 | - $this->size = 0; | ||
| 343 | - return true; | ||
| 344 | - } | ||
| 345 | - | ||
| 346 | - if (is_resource($handle)) { | ||
| 347 | - $this->handle = $handle; | ||
| 348 | - $filestats = fstat($handle); | ||
| 349 | - $this->size = $filestats['size']; | ||
| 350 | - return true; | ||
| 351 | - } | ||
| 352 | - | ||
| 353 | - return PEAR::raiseError( | ||
| 354 | - "Handle '$handle' is no valid resource.", | ||
| 355 | - HTTP_DOWNLOAD_E_INVALID_RESOURCE | ||
| 356 | - ); | ||
| 357 | - } | ||
| 358 | - | ||
| 359 | - /** | ||
| 360 | - * Whether to gzip the download | ||
| 361 | - * | ||
| 362 | - * Returns a PEAR_Error (HTTP_DOWNLOAD_E_NO_EXT_ZLIB) | ||
| 363 | - * if ext/zlib is not available/loadable. | ||
| 364 | - * | ||
| 365 | - * @access public | ||
| 366 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 367 | - * @param bool $gzip whether to gzip the download | ||
| 368 | - */ | ||
| 369 | - function setGzip($gzip = false) | ||
| 370 | - { | ||
| 371 | - if ($gzip && !PEAR::loadExtension('zlib')){ | ||
| 372 | - return PEAR::raiseError( | ||
| 373 | - 'GZIP compression (ext/zlib) not available.', | ||
| 374 | - HTTP_DOWNLOAD_E_NO_EXT_ZLIB | ||
| 375 | - ); | ||
| 376 | - } | ||
| 377 | - $this->gzip = (bool) $gzip; | ||
| 378 | - return true; | ||
| 379 | - } | ||
| 380 | - | ||
| 381 | - /** | ||
| 382 | - * Whether to allow caching | ||
| 383 | - * | ||
| 384 | - * If set to true (default) we'll send some headers that are commonly | ||
| 385 | - * used for caching purposes like ETag, Cache-Control and Last-Modified. | ||
| 386 | - * | ||
| 387 | - * If caching is disabled, we'll send the download no matter if it | ||
| 388 | - * would actually be cached at the client side. | ||
| 389 | - * | ||
| 390 | - * @access public | ||
| 391 | - * @return void | ||
| 392 | - * @param bool $cache whether to allow caching | ||
| 393 | - */ | ||
| 394 | - function setCache($cache = true) | ||
| 395 | - { | ||
| 396 | - $this->cache = (bool) $cache; | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | - /** | ||
| 400 | - * Whether to allow proxies to cache | ||
| 401 | - * | ||
| 402 | - * If set to 'private' proxies shouldn't cache the response. | ||
| 403 | - * This setting defaults to 'public' and affects only cached responses. | ||
| 404 | - * | ||
| 405 | - * @access public | ||
| 406 | - * @return bool | ||
| 407 | - * @param string $cache private or public | ||
| 408 | - * @param int $maxage maximum age of the client cache entry | ||
| 409 | - */ | ||
| 410 | - function setCacheControl($cache = 'public', $maxage = 0) | ||
| 411 | - { | ||
| 412 | - switch ($cache = strToLower($cache)) | ||
| 413 | - { | ||
| 414 | - case 'private': | ||
| 415 | - case 'public': | ||
| 416 | - $this->headers['Cache-Control'] = | ||
| 417 | - $cache .', must-revalidate, max-age='. abs($maxage); | ||
| 418 | - return true; | ||
| 419 | - break; | ||
| 420 | - } | ||
| 421 | - return false; | ||
| 422 | - } | ||
| 423 | - | ||
| 424 | - /** | ||
| 425 | - * Set ETag | ||
| 426 | - * | ||
| 427 | - * Sets a user-defined ETag for cache-validation. The ETag is usually | ||
| 428 | - * generated by HTTP_Download through its payload information. | ||
| 429 | - * | ||
| 430 | - * @access public | ||
| 431 | - * @return void | ||
| 432 | - * @param string $etag Entity tag used for strong cache validation. | ||
| 433 | - */ | ||
| 434 | - function setETag($etag = null) | ||
| 435 | - { | ||
| 436 | - $this->etag = (string) $etag; | ||
| 437 | - } | ||
| 438 | - | ||
| 439 | - /** | ||
| 440 | - * Set Size of Buffer | ||
| 441 | - * | ||
| 442 | - * The amount of bytes specified as buffer size is the maximum amount | ||
| 443 | - * of data read at once from resources or files. The default size is 2M | ||
| 444 | - * (2097152 bytes). Be aware that if you enable gzip compression and | ||
| 445 | - * you set a very low buffer size that the actual file size may grow | ||
| 446 | - * due to added gzip headers for each sent chunk of the specified size. | ||
| 447 | - * | ||
| 448 | - * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_PARAM) if $size is not | ||
| 449 | - * greater than 0 bytes. | ||
| 450 | - * | ||
| 451 | - * @access public | ||
| 452 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 453 | - * @param int $bytes Amount of bytes to use as buffer. | ||
| 454 | - */ | ||
| 455 | - function setBufferSize($bytes = 2097152) | ||
| 456 | - { | ||
| 457 | - if (0 >= $bytes) { | ||
| 458 | - return PEAR::raiseError( | ||
| 459 | - 'Buffer size must be greater than 0 bytes ('. $bytes .' given)', | ||
| 460 | - HTTP_DOWNLOAD_E_INVALID_PARAM); | ||
| 461 | - } | ||
| 462 | - $this->bufferSize = abs($bytes); | ||
| 463 | - return true; | ||
| 464 | - } | ||
| 465 | - | ||
| 466 | - /** | ||
| 467 | - * Set Throttle Delay | ||
| 468 | - * | ||
| 469 | - * Set the amount of seconds to sleep after each chunck that has been | ||
| 470 | - * sent. One can implement some sort of throttle through adjusting the | ||
| 471 | - * buffer size and the throttle delay. With the following settings | ||
| 472 | - * HTTP_Download will sleep a second after each 25 K of data sent. | ||
| 473 | - * | ||
| 474 | - * <code> | ||
| 475 | - * Array( | ||
| 476 | - * 'throttledelay' => 1, | ||
| 477 | - * 'buffersize' => 1024 * 25, | ||
| 478 | - * ) | ||
| 479 | - * </code> | ||
| 480 | - * | ||
| 481 | - * Just be aware that if gzipp'ing is enabled, decreasing the chunk size | ||
| 482 | - * too much leads to proportionally increased network traffic due to added | ||
| 483 | - * gzip header and bottom bytes around each chunk. | ||
| 484 | - * | ||
| 485 | - * @access public | ||
| 486 | - * @return void | ||
| 487 | - * @param float $seconds Amount of seconds to sleep after each | ||
| 488 | - * chunk that has been sent. | ||
| 489 | - */ | ||
| 490 | - function setThrottleDelay($seconds = 0) | ||
| 491 | - { | ||
| 492 | - $this->throttleDelay = abs($seconds) * 1000; | ||
| 493 | - } | ||
| 494 | - | ||
| 495 | - /** | ||
| 496 | - * Set "Last-Modified" | ||
| 497 | - * | ||
| 498 | - * This is usually determined by filemtime() in HTTP_Download::setFile() | ||
| 499 | - * If you set raw data for download with HTTP_Download::setData() and you | ||
| 500 | - * want do send an appropiate "Last-Modified" header, you should call this | ||
| 501 | - * method. | ||
| 502 | - * | ||
| 503 | - * @access public | ||
| 504 | - * @return void | ||
| 505 | - * @param int unix timestamp | ||
| 506 | - */ | ||
| 507 | - function setLastModified($last_modified) | ||
| 508 | - { | ||
| 509 | - $this->lastModified = $this->headers['Last-Modified'] = (int) $last_modified; | ||
| 510 | - } | ||
| 511 | - | ||
| 512 | - /** | ||
| 513 | - * Set Content-Disposition header | ||
| 514 | - * | ||
| 515 | - * @see HTTP_Download::HTTP_Download | ||
| 516 | - * | ||
| 517 | - * @access public | ||
| 518 | - * @return void | ||
| 519 | - * @param string $disposition whether to send the download | ||
| 520 | - * inline or as attachment | ||
| 521 | - * @param string $file_name the filename to display in | ||
| 522 | - * the browser's download window | ||
| 523 | - * | ||
| 524 | - * <b>Example:</b> | ||
| 525 | - * <code> | ||
| 526 | - * $HTTP_Download->setContentDisposition( | ||
| 527 | - * HTTP_DOWNLOAD_ATTACHMENT, | ||
| 528 | - * 'download.tgz' | ||
| 529 | - * ); | ||
| 530 | - * </code> | ||
| 531 | - */ | ||
| 532 | - function setContentDisposition( $disposition = HTTP_DOWNLOAD_ATTACHMENT, | ||
| 533 | - $file_name = null) | ||
| 534 | - { | ||
| 535 | - $cd = $disposition; | ||
| 536 | - if (isset($file_name)) { | ||
| 537 | - $cd .= '; filename="' . $file_name . '"'; | ||
| 538 | - } elseif ($this->file) { | ||
| 539 | - $cd .= '; filename="' . basename($this->file) . '"'; | ||
| 540 | - } | ||
| 541 | - $this->headers['Content-Disposition'] = $cd; | ||
| 542 | - } | ||
| 543 | - | ||
| 544 | - /** | ||
| 545 | - * Set content type of the download | ||
| 546 | - * | ||
| 547 | - * Default content type of the download will be 'application/x-octetstream'. | ||
| 548 | - * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) if | ||
| 549 | - * $content_type doesn't seem to be valid. | ||
| 550 | - * | ||
| 551 | - * @access public | ||
| 552 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 553 | - * @param string $content_type content type of file for download | ||
| 554 | - */ | ||
| 555 | - function setContentType($content_type = 'application/x-octetstream') | ||
| 556 | - { | ||
| 557 | - if (!preg_match('/^[a-z]+\w*\/[a-z]+[\w.;= -]*$/', $content_type)) { | ||
| 558 | - return PEAR::raiseError( | ||
| 559 | - "Invalid content type '$content_type' supplied.", | ||
| 560 | - HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE | ||
| 561 | - ); | ||
| 562 | - } | ||
| 563 | - $this->headers['Content-Type'] = $content_type; | ||
| 564 | - return true; | ||
| 565 | - } | ||
| 566 | - | ||
| 567 | - /** | ||
| 568 | - * Guess content type of file | ||
| 569 | - * | ||
| 570 | - * First we try to use PEAR::MIME_Type, if installed, to detect the content | ||
| 571 | - * type, else we check if ext/mime_magic is loaded and properly configured. | ||
| 572 | - * | ||
| 573 | - * Returns PEAR_Error if: | ||
| 574 | - * o if PEAR::MIME_Type failed to detect a proper content type | ||
| 575 | - * (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) | ||
| 576 | - * o ext/magic.mime is not installed, or not properly configured | ||
| 577 | - * (HTTP_DOWNLOAD_E_NO_EXT_MMAGIC) | ||
| 578 | - * o mime_content_type() couldn't guess content type or returned | ||
| 579 | - * a content type considered to be bogus by setContentType() | ||
| 580 | - * (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) | ||
| 581 | - * | ||
| 582 | - * @access public | ||
| 583 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 584 | - */ | ||
| 585 | - function guessContentType() | ||
| 586 | - { | ||
| 587 | - if (class_exists('MIME_Type') || @include_once 'MIME/Type.php') { | ||
| 588 | - if (PEAR::isError($mime_type = MIME_Type::autoDetect($this->file))) { | ||
| 589 | - return PEAR::raiseError($mime_type->getMessage(), | ||
| 590 | - HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE); | ||
| 591 | - } | ||
| 592 | - return $this->setContentType($mime_type); | ||
| 593 | - } | ||
| 594 | - if (!function_exists('mime_content_type')) { | ||
| 595 | - return PEAR::raiseError( | ||
| 596 | - 'This feature requires ext/mime_magic!', | ||
| 597 | - HTTP_DOWNLOAD_E_NO_EXT_MMAGIC | ||
| 598 | - ); | ||
| 599 | - } | ||
| 600 | - if (!is_file(ini_get('mime_magic.magicfile'))) { | ||
| 601 | - return PEAR::raiseError( | ||
| 602 | - 'ext/mime_magic is loaded but not properly configured!', | ||
| 603 | - HTTP_DOWNLOAD_E_NO_EXT_MMAGIC | ||
| 604 | - ); | ||
| 605 | - } | ||
| 606 | - if (!$content_type = @mime_content_type($this->file)) { | ||
| 607 | - return PEAR::raiseError( | ||
| 608 | - 'Couldn\'t guess content type with mime_content_type().', | ||
| 609 | - HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE | ||
| 610 | - ); | ||
| 611 | - } | ||
| 612 | - return $this->setContentType($content_type); | ||
| 613 | - } | ||
| 614 | - | ||
| 615 | - /** | ||
| 616 | - * Send | ||
| 617 | - * | ||
| 618 | - * Returns PEAR_Error if: | ||
| 619 | - * o HTTP headers were already sent (HTTP_DOWNLOAD_E_HEADERS_SENT) | ||
| 620 | - * o HTTP Range was invalid (HTTP_DOWNLOAD_E_INVALID_REQUEST) | ||
| 621 | - * | ||
| 622 | - * @access public | ||
| 623 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 624 | - * @param bool $autoSetContentDisposition Whether to set the | ||
| 625 | - * Content-Disposition header if it isn't already. | ||
| 626 | - */ | ||
| 627 | - function send($autoSetContentDisposition = true) | ||
| 628 | - { | ||
| 629 | - if (headers_sent()) { | ||
| 630 | - return PEAR::raiseError( | ||
| 631 | - 'Headers already sent.', | ||
| 632 | - HTTP_DOWNLOAD_E_HEADERS_SENT | ||
| 633 | - ); | ||
| 634 | - } | ||
| 635 | - | ||
| 636 | - if (!ini_get('safe_mode')) { | ||
| 637 | - @set_time_limit(0); | ||
| 638 | - } | ||
| 639 | - | ||
| 640 | - if ($autoSetContentDisposition && | ||
| 641 | - !isset($this->headers['Content-Disposition'])) { | ||
| 642 | - $this->setContentDisposition(); | ||
| 643 | - } | ||
| 644 | - | ||
| 645 | - if ($this->cache) { | ||
| 646 | - $this->headers['ETag'] = $this->generateETag(); | ||
| 647 | - if ($this->isCached()) { | ||
| 648 | - $this->HTTP->sendStatusCode(304); | ||
| 649 | - $this->sendHeaders(); | ||
| 650 | - return true; | ||
| 651 | - } | ||
| 652 | - } else { | ||
| 653 | - unset($this->headers['Last-Modified']); | ||
| 654 | - } | ||
| 655 | - | ||
| 656 | - while (@ob_end_clean()); | ||
| 657 | - | ||
| 658 | - if ($this->gzip) { | ||
| 659 | - @ob_start('ob_gzhandler'); | ||
| 660 | - } else { | ||
| 661 | - ob_start(); | ||
| 662 | - } | ||
| 663 | - | ||
| 664 | - $this->sentBytes = 0; | ||
| 665 | - | ||
| 666 | - if ($this->isRangeRequest()) { | ||
| 667 | - $this->HTTP->sendStatusCode(206); | ||
| 668 | - $chunks = $this->getChunks(); | ||
| 669 | - } else { | ||
| 670 | - $this->HTTP->sendStatusCode(200); | ||
| 671 | - $chunks = array(array(0, $this->size)); | ||
| 672 | - if (!$this->gzip && count(ob_list_handlers()) < 2) { | ||
| 673 | - $this->headers['Content-Length'] = $this->size; | ||
| 674 | - } | ||
| 675 | - } | ||
| 676 | - | ||
| 677 | - if (PEAR::isError($e = $this->sendChunks($chunks))) { | ||
| 678 | - ob_end_clean(); | ||
| 679 | - $this->HTTP->sendStatusCode(416); | ||
| 680 | - return $e; | ||
| 681 | - } | ||
| 682 | - | ||
| 683 | - ob_end_flush(); | ||
| 684 | - flush(); | ||
| 685 | - return true; | ||
| 686 | - } | ||
| 687 | - | ||
| 688 | - /** | ||
| 689 | - * Static send | ||
| 690 | - * | ||
| 691 | - * @see HTTP_Download::HTTP_Download() | ||
| 692 | - * @see HTTP_Download::send() | ||
| 693 | - * | ||
| 694 | - * @static | ||
| 695 | - * @access public | ||
| 696 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 697 | - * @param array $params associative array of parameters | ||
| 698 | - * @param bool $guess whether HTTP_Download::guessContentType() | ||
| 699 | - * should be called | ||
| 700 | - */ | ||
| 701 | - function staticSend($params, $guess = false) | ||
| 702 | - { | ||
| 703 | - $d = &new HTTP_Download(); | ||
| 704 | - $e = $d->setParams($params); | ||
| 705 | - if (PEAR::isError($e)) { | ||
| 706 | - return $e; | ||
| 707 | - } | ||
| 708 | - if ($guess) { | ||
| 709 | - $e = $d->guessContentType(); | ||
| 710 | - if (PEAR::isError($e)) { | ||
| 711 | - return $e; | ||
| 712 | - } | ||
| 713 | - } | ||
| 714 | - return $d->send(); | ||
| 715 | - } | ||
| 716 | - | ||
| 717 | - /** | ||
| 718 | - * Send a bunch of files or directories as an archive | ||
| 719 | - * | ||
| 720 | - * Example: | ||
| 721 | - * <code> | ||
| 722 | - * require_once 'HTTP/Download.php'; | ||
| 723 | - * HTTP_Download::sendArchive( | ||
| 724 | - * 'myArchive.tgz', | ||
| 725 | - * '/var/ftp/pub/mike', | ||
| 726 | - * HTTP_DOWNLOAD_TGZ, | ||
| 727 | - * '', | ||
| 728 | - * '/var/ftp/pub' | ||
| 729 | - * ); | ||
| 730 | - * </code> | ||
| 731 | - * | ||
| 732 | - * @see Archive_Tar::createModify() | ||
| 733 | - * @deprecated use HTTP_Download_Archive::send() | ||
| 734 | - * @static | ||
| 735 | - * @access public | ||
| 736 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 737 | - * @param string $name name the sent archive should have | ||
| 738 | - * @param mixed $files files/directories | ||
| 739 | - * @param string $type archive type | ||
| 740 | - * @param string $add_path path that should be prepended to the files | ||
| 741 | - * @param string $strip_path path that should be stripped from the files | ||
| 742 | - */ | ||
| 743 | - function sendArchive( $name, | ||
| 744 | - $files, | ||
| 745 | - $type = HTTP_DOWNLOAD_TGZ, | ||
| 746 | - $add_path = '', | ||
| 747 | - $strip_path = '') | ||
| 748 | - { | ||
| 749 | - require_once 'HTTP/Download/Archive.php'; | ||
| 750 | - return HTTP_Download_Archive::send($name, $files, $type, | ||
| 751 | - $add_path, $strip_path); | ||
| 752 | - } | ||
| 753 | - // }}} | ||
| 754 | - | ||
| 755 | - // {{{ protected methods | ||
| 756 | - /** | ||
| 757 | - * Generate ETag | ||
| 758 | - * | ||
| 759 | - * @access protected | ||
| 760 | - * @return string | ||
| 761 | - */ | ||
| 762 | - function generateETag() | ||
| 763 | - { | ||
| 764 | - if (!$this->etag) { | ||
| 765 | - if ($this->data) { | ||
| 766 | - $md5 = md5($this->data); | ||
| 767 | - } else { | ||
| 768 | - $fst = is_resource($this->handle) ? | ||
| 769 | - fstat($this->handle) : stat($this->file); | ||
| 770 | - $md5 = md5($fst['mtime'] .'='. $fst['ino'] .'='. $fst['size']); | ||
| 771 | - } | ||
| 772 | - $this->etag = '"' . $md5 . '-' . crc32($md5) . '"'; | ||
| 773 | - } | ||
| 774 | - return $this->etag; | ||
| 775 | - } | ||
| 776 | - | ||
| 777 | - /** | ||
| 778 | - * Send multiple chunks | ||
| 779 | - * | ||
| 780 | - * @access protected | ||
| 781 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 782 | - * @param array $chunks | ||
| 783 | - */ | ||
| 784 | - function sendChunks($chunks) | ||
| 785 | - { | ||
| 786 | - if (count($chunks) == 1) { | ||
| 787 | - return $this->sendChunk(array_shift($chunks)); | ||
| 788 | - } | ||
| 789 | - | ||
| 790 | - $bound = uniqid('HTTP_DOWNLOAD-', true); | ||
| 791 | - $cType = $this->headers['Content-Type']; | ||
| 792 | - $this->headers['Content-Type'] = | ||
| 793 | - 'multipart/byteranges; boundary=' . $bound; | ||
| 794 | - $this->sendHeaders(); | ||
| 795 | - foreach ($chunks as $chunk){ | ||
| 796 | - if (PEAR::isError($e = $this->sendChunk($chunk, $cType, $bound))) { | ||
| 797 | - return $e; | ||
| 798 | - } | ||
| 799 | - } | ||
| 800 | - #echo "\r\n--$bound--\r\n"; | ||
| 801 | - return true; | ||
| 802 | - } | ||
| 803 | - | ||
| 804 | - /** | ||
| 805 | - * Send chunk of data | ||
| 806 | - * | ||
| 807 | - * @access protected | ||
| 808 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 809 | - * @param array $chunk start and end offset of the chunk to send | ||
| 810 | - * @param string $cType actual content type | ||
| 811 | - * @param string $bound boundary for multipart/byteranges | ||
| 812 | - */ | ||
| 813 | - function sendChunk($chunk, $cType = null, $bound = null) | ||
| 814 | - { | ||
| 815 | - list($offset, $lastbyte) = $chunk; | ||
| 816 | - $length = ($lastbyte - $offset) + 1; | ||
| 817 | - | ||
| 818 | - if ($length < 1) { | ||
| 819 | - return PEAR::raiseError( | ||
| 820 | - "Error processing range request: $offset-$lastbyte/$length", | ||
| 821 | - HTTP_DOWNLOAD_E_INVALID_REQUEST | ||
| 822 | - ); | ||
| 823 | - } | ||
| 824 | - | ||
| 825 | - $range = $offset . '-' . $lastbyte . '/' . $this->size; | ||
| 826 | - | ||
| 827 | - if (isset($cType, $bound)) { | ||
| 828 | - echo "\r\n--$bound\r\n", | ||
| 829 | - "Content-Type: $cType\r\n", | ||
| 830 | - "Content-Range: bytes $range\r\n\r\n"; | ||
| 831 | - } else { | ||
| 832 | - if ($this->isRangeRequest()) { | ||
| 833 | - $this->headers['Content-Range'] = 'bytes '. $range; | ||
| 834 | - } | ||
| 835 | - $this->sendHeaders(); | ||
| 836 | - } | ||
| 837 | - | ||
| 838 | - if ($this->data) { | ||
| 839 | - while (($length -= $this->bufferSize) > 0) { | ||
| 840 | - $this->flush(substr($this->data, $offset, $this->bufferSize)); | ||
| 841 | - $this->throttleDelay and $this->sleep(); | ||
| 842 | - $offset += $this->bufferSize; | ||
| 843 | - } | ||
| 844 | - if ($length) { | ||
| 845 | - $this->flush(substr($this->data, $offset, $this->bufferSize + $length)); | ||
| 846 | - } | ||
| 847 | - } else { | ||
| 848 | - if (!is_resource($this->handle)) { | ||
| 849 | - $this->handle = fopen($this->file, 'rb'); | ||
| 850 | - } | ||
| 851 | - fseek($this->handle, $offset); | ||
| 852 | - while (($length -= $this->bufferSize) > 0) { | ||
| 853 | - $this->flush(fread($this->handle, $this->bufferSize)); | ||
| 854 | - $this->throttleDelay and $this->sleep(); | ||
| 855 | - } | ||
| 856 | - if ($length) { | ||
| 857 | - $this->flush(fread($this->handle, $this->bufferSize + $length)); | ||
| 858 | - } | ||
| 859 | - } | ||
| 860 | - return true; | ||
| 861 | - } | ||
| 862 | - | ||
| 863 | - /** | ||
| 864 | - * Get chunks to send | ||
| 865 | - * | ||
| 866 | - * @access protected | ||
| 867 | - * @return array | ||
| 868 | - */ | ||
| 869 | - function getChunks() | ||
| 870 | - { | ||
| 871 | - $parts = array(); | ||
| 872 | - foreach (explode(',', $this->getRanges()) as $chunk){ | ||
| 873 | - list($o, $e) = explode('-', $chunk); | ||
| 874 | - if ($e >= $this->size || (empty($e) && $e !== 0 && $e !== '0')) { | ||
| 875 | - $e = $this->size - 1; | ||
| 876 | - } | ||
| 877 | - if (empty($o) && $o !== 0 && $o !== '0') { | ||
| 878 | - $o = $this->size - $e; | ||
| 879 | - $e = $this->size - 1; | ||
| 880 | - } | ||
| 881 | - $parts[] = array($o, $e); | ||
| 882 | - } | ||
| 883 | - return $parts; | ||
| 884 | - } | ||
| 885 | - | ||
| 886 | - /** | ||
| 887 | - * Check if range is requested | ||
| 888 | - * | ||
| 889 | - * @access protected | ||
| 890 | - * @return bool | ||
| 891 | - */ | ||
| 892 | - function isRangeRequest() | ||
| 893 | - { | ||
| 894 | - if (!isset($_SERVER['HTTP_RANGE'])) { | ||
| 895 | - return false; | ||
| 896 | - } | ||
| 897 | - return $this->isValidRange(); | ||
| 898 | - } | ||
| 899 | - | ||
| 900 | - /** | ||
| 901 | - * Get range request | ||
| 902 | - * | ||
| 903 | - * @access protected | ||
| 904 | - * @return array | ||
| 905 | - */ | ||
| 906 | - function getRanges() | ||
| 907 | - { | ||
| 908 | - return preg_match('/^bytes=((\d*-\d*,? ?)+)$/', | ||
| 909 | - @$_SERVER['HTTP_RANGE'], $matches) ? $matches[1] : array(); | ||
| 910 | - } | ||
| 911 | - | ||
| 912 | - /** | ||
| 913 | - * Check if entity is cached | ||
| 914 | - * | ||
| 915 | - * @access protected | ||
| 916 | - * @return bool | ||
| 917 | - */ | ||
| 918 | - function isCached() | ||
| 919 | - { | ||
| 920 | - return ( | ||
| 921 | - (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && | ||
| 922 | - $this->lastModified == strtotime(current($a = explode( | ||
| 923 | - ';', $_SERVER['HTTP_IF_MODIFIED_SINCE'])))) || | ||
| 924 | - (isset($_SERVER['HTTP_IF_NONE_MATCH']) && | ||
| 925 | - $this->compareAsterisk('HTTP_IF_NONE_MATCH', $this->etag)) | ||
| 926 | - ); | ||
| 927 | - } | ||
| 928 | - | ||
| 929 | - /** | ||
| 930 | - * Check if entity hasn't changed | ||
| 931 | - * | ||
| 932 | - * @access protected | ||
| 933 | - * @return bool | ||
| 934 | - */ | ||
| 935 | - function isValidRange() | ||
| 936 | - { | ||
| 937 | - if (isset($_SERVER['HTTP_IF_MATCH']) && | ||
| 938 | - !$this->compareAsterisk('HTTP_IF_MATCH', $this->etag)) { | ||
| 939 | - return false; | ||
| 940 | - } | ||
| 941 | - if (isset($_SERVER['HTTP_IF_RANGE']) && | ||
| 942 | - $_SERVER['HTTP_IF_RANGE'] !== $this->etag && | ||
| 943 | - strtotime($_SERVER['HTTP_IF_RANGE']) !== $this->lastModified) { | ||
| 944 | - return false; | ||
| 945 | - } | ||
| 946 | - if (isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE'])) { | ||
| 947 | - $lm = array_shift(explode(';', $_SERVER['HTTP_IF_UNMODIFIED_SINCE'])); | ||
| 948 | - if (strtotime($lm) !== $this->lastModified) { | ||
| 949 | - return false; | ||
| 950 | - } | ||
| 951 | - } | ||
| 952 | - if (isset($_SERVER['HTTP_UNLESS_MODIFIED_SINCE'])) { | ||
| 953 | - $lm = array_shift(explode(';', $_SERVER['HTTP_UNLESS_MODIFIED_SINCE'])); | ||
| 954 | - if (strtotime($lm) !== $this->lastModified) { | ||
| 955 | - return false; | ||
| 956 | - } | ||
| 957 | - } | ||
| 958 | - return true; | ||
| 959 | - } | ||
| 960 | - | ||
| 961 | - /** | ||
| 962 | - * Compare against an asterisk or check for equality | ||
| 963 | - * | ||
| 964 | - * @access protected | ||
| 965 | - * @return bool | ||
| 966 | - * @param string key for the $_SERVER array | ||
| 967 | - * @param string string to compare | ||
| 968 | - */ | ||
| 969 | - function compareAsterisk($svar, $compare) | ||
| 970 | - { | ||
| 971 | - foreach (array_map('trim', explode(',', $_SERVER[$svar])) as $request) { | ||
| 972 | - if ($request === '*' || $request === $compare) { | ||
| 973 | - return true; | ||
| 974 | - } | ||
| 975 | - } | ||
| 976 | - return false; | ||
| 977 | - } | ||
| 978 | - | ||
| 979 | - /** | ||
| 980 | - * Send HTTP headers | ||
| 981 | - * | ||
| 982 | - * @access protected | ||
| 983 | - * @return void | ||
| 984 | - */ | ||
| 985 | - function sendHeaders() | ||
| 986 | - { | ||
| 987 | - foreach ($this->headers as $header => $value) { | ||
| 988 | - $this->HTTP->setHeader($header, $value); | ||
| 989 | - } | ||
| 990 | - $this->HTTP->sendHeaders(); | ||
| 991 | - /* NSAPI won't output anything if we did this */ | ||
| 992 | - if (strncasecmp(PHP_SAPI, 'nsapi', 5)) { | ||
| 993 | - ob_flush(); | ||
| 994 | - flush(); | ||
| 995 | - } | ||
| 996 | - } | ||
| 997 | - | ||
| 998 | - /** | ||
| 999 | - * Flush | ||
| 1000 | - * | ||
| 1001 | - * @access protected | ||
| 1002 | - * @return void | ||
| 1003 | - * @param string $data | ||
| 1004 | - */ | ||
| 1005 | - function flush($data = '') | ||
| 1006 | - { | ||
| 1007 | - if ($dlen = strlen($data)) { | ||
| 1008 | - $this->sentBytes += $dlen; | ||
| 1009 | - echo $data; | ||
| 1010 | - } | ||
| 1011 | - ob_flush(); | ||
| 1012 | - flush(); | ||
| 1013 | - } | ||
| 1014 | - | ||
| 1015 | - /** | ||
| 1016 | - * Sleep | ||
| 1017 | - * | ||
| 1018 | - * @access protected | ||
| 1019 | - * @return void | ||
| 1020 | - */ | ||
| 1021 | - function sleep() | ||
| 1022 | - { | ||
| 1023 | - if (OS_WINDOWS) { | ||
| 1024 | - com_message_pump($this->throttleDelay); | ||
| 1025 | - } else { | ||
| 1026 | - usleep($this->throttleDelay * 1000); | ||
| 1027 | - } | ||
| 1028 | - } | ||
| 1029 | - // }}} | ||
| 1030 | -} | ||
| 1031 | -?> | 1 | +<?php |
| 2 | +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * HTTP::Download | ||
| 6 | + * | ||
| 7 | + * PHP versions 4 and 5 | ||
| 8 | + * | ||
| 9 | + * @category HTTP | ||
| 10 | + * @package HTTP_Download | ||
| 11 | + * @author Michael Wallner <mike@php.net> | ||
| 12 | + * @copyright 2003-2005 Michael Wallner | ||
| 13 | + * @license BSD, revised | ||
| 14 | + * @version CVS: $Id$ | ||
| 15 | + * @link http://pear.php.net/package/HTTP_Download | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +// {{{ includes | ||
| 19 | +/** | ||
| 20 | + * Requires PEAR | ||
| 21 | + */ | ||
| 22 | +require_once 'PEAR.php'; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Requires HTTP_Header | ||
| 26 | + */ | ||
| 27 | +require_once 'HTTP/Header.php'; | ||
| 28 | +// }}} | ||
| 29 | + | ||
| 30 | +// {{{ constants | ||
| 31 | +/**#@+ Use with HTTP_Download::setContentDisposition() **/ | ||
| 32 | +/** | ||
| 33 | + * Send data as attachment | ||
| 34 | + */ | ||
| 35 | +define('HTTP_DOWNLOAD_ATTACHMENT', 'attachment'); | ||
| 36 | +/** | ||
| 37 | + * Send data inline | ||
| 38 | + */ | ||
| 39 | +define('HTTP_DOWNLOAD_INLINE', 'inline'); | ||
| 40 | +/**#@-**/ | ||
| 41 | + | ||
| 42 | +/**#@+ Use with HTTP_Download::sendArchive() **/ | ||
| 43 | +/** | ||
| 44 | + * Send as uncompressed tar archive | ||
| 45 | + */ | ||
| 46 | +define('HTTP_DOWNLOAD_TAR', 'TAR'); | ||
| 47 | +/** | ||
| 48 | + * Send as gzipped tar archive | ||
| 49 | + */ | ||
| 50 | +define('HTTP_DOWNLOAD_TGZ', 'TGZ'); | ||
| 51 | +/** | ||
| 52 | + * Send as bzip2 compressed tar archive | ||
| 53 | + */ | ||
| 54 | +define('HTTP_DOWNLOAD_BZ2', 'BZ2'); | ||
| 55 | +/** | ||
| 56 | + * Send as zip archive | ||
| 57 | + */ | ||
| 58 | +define('HTTP_DOWNLOAD_ZIP', 'ZIP'); | ||
| 59 | +/**#@-**/ | ||
| 60 | + | ||
| 61 | +/**#@+ | ||
| 62 | + * Error constants | ||
| 63 | + */ | ||
| 64 | +define('HTTP_DOWNLOAD_E_HEADERS_SENT', -1); | ||
| 65 | +define('HTTP_DOWNLOAD_E_NO_EXT_ZLIB', -2); | ||
| 66 | +define('HTTP_DOWNLOAD_E_NO_EXT_MMAGIC', -3); | ||
| 67 | +define('HTTP_DOWNLOAD_E_INVALID_FILE', -4); | ||
| 68 | +define('HTTP_DOWNLOAD_E_INVALID_PARAM', -5); | ||
| 69 | +define('HTTP_DOWNLOAD_E_INVALID_RESOURCE', -6); | ||
| 70 | +define('HTTP_DOWNLOAD_E_INVALID_REQUEST', -7); | ||
| 71 | +define('HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE', -8); | ||
| 72 | +define('HTTP_DOWNLOAD_E_INVALID_ARCHIVE_TYPE', -9); | ||
| 73 | +/**#@-**/ | ||
| 74 | +// }}} | ||
| 75 | + | ||
| 76 | +/** | ||
| 77 | + * Send HTTP Downloads/Responses. | ||
| 78 | + * | ||
| 79 | + * With this package you can handle (hidden) downloads. | ||
| 80 | + * It supports partial downloads, resuming and sending | ||
| 81 | + * raw data ie. from database BLOBs. | ||
| 82 | + * | ||
| 83 | + * <i>ATTENTION:</i> | ||
| 84 | + * You shouldn't use this package together with ob_gzhandler or | ||
| 85 | + * zlib.output_compression enabled in your php.ini, especially | ||
| 86 | + * if you want to send already gzipped data! | ||
| 87 | + * | ||
| 88 | + * @access public | ||
| 89 | + * @version $Revision$ | ||
| 90 | + */ | ||
| 91 | +class HTTP_Download | ||
| 92 | +{ | ||
| 93 | + // {{{ protected member variables | ||
| 94 | + /** | ||
| 95 | + * Path to file for download | ||
| 96 | + * | ||
| 97 | + * @see HTTP_Download::setFile() | ||
| 98 | + * @access protected | ||
| 99 | + * @var string | ||
| 100 | + */ | ||
| 101 | + var $file = ''; | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * Data for download | ||
| 105 | + * | ||
| 106 | + * @see HTTP_Download::setData() | ||
| 107 | + * @access protected | ||
| 108 | + * @var string | ||
| 109 | + */ | ||
| 110 | + var $data = null; | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * Resource handle for download | ||
| 114 | + * | ||
| 115 | + * @see HTTP_Download::setResource() | ||
| 116 | + * @access protected | ||
| 117 | + * @var int | ||
| 118 | + */ | ||
| 119 | + var $handle = null; | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * Whether to gzip the download | ||
| 123 | + * | ||
| 124 | + * @access protected | ||
| 125 | + * @var bool | ||
| 126 | + */ | ||
| 127 | + var $gzip = false; | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * Whether to allow caching of the download on the clients side | ||
| 131 | + * | ||
| 132 | + * @access protected | ||
| 133 | + * @var bool | ||
| 134 | + */ | ||
| 135 | + var $cache = true; | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * Size of download | ||
| 139 | + * | ||
| 140 | + * @access protected | ||
| 141 | + * @var int | ||
| 142 | + */ | ||
| 143 | + var $size = 0; | ||
| 144 | + | ||
| 145 | + /** | ||
| 146 | + * Last modified | ||
| 147 | + * | ||
| 148 | + * @access protected | ||
| 149 | + * @var int | ||
| 150 | + */ | ||
| 151 | + var $lastModified = 0; | ||
| 152 | + | ||
| 153 | + /** | ||
| 154 | + * HTTP headers | ||
| 155 | + * | ||
| 156 | + * @access protected | ||
| 157 | + * @var array | ||
| 158 | + */ | ||
| 159 | + var $headers = array( | ||
| 160 | + 'Content-Type' => 'application/x-octetstream', | ||
| 161 | + 'Pragma' => 'cache', | ||
| 162 | + 'Cache-Control' => 'public, must-revalidate, max-age=0', | ||
| 163 | + 'Accept-Ranges' => 'bytes', | ||
| 164 | + 'X-Sent-By' => 'PEAR::HTTP::Download' | ||
| 165 | + ); | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * HTTP_Header | ||
| 169 | + * | ||
| 170 | + * @access protected | ||
| 171 | + * @var object | ||
| 172 | + */ | ||
| 173 | + var $HTTP = null; | ||
| 174 | + | ||
| 175 | + /** | ||
| 176 | + * ETag | ||
| 177 | + * | ||
| 178 | + * @access protected | ||
| 179 | + * @var string | ||
| 180 | + */ | ||
| 181 | + var $etag = ''; | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * Buffer Size | ||
| 185 | + * | ||
| 186 | + * @access protected | ||
| 187 | + * @var int | ||
| 188 | + */ | ||
| 189 | + var $bufferSize = 2097152; | ||
| 190 | + | ||
| 191 | + /** | ||
| 192 | + * Throttle Delay | ||
| 193 | + * | ||
| 194 | + * @access protected | ||
| 195 | + * @var float | ||
| 196 | + */ | ||
| 197 | + var $throttleDelay = 0; | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * Sent Bytes | ||
| 201 | + * | ||
| 202 | + * @access public | ||
| 203 | + * @var int | ||
| 204 | + */ | ||
| 205 | + var $sentBytes = 0; | ||
| 206 | + // }}} | ||
| 207 | + | ||
| 208 | + // {{{ constructor | ||
| 209 | + /** | ||
| 210 | + * Constructor | ||
| 211 | + * | ||
| 212 | + * Set supplied parameters. | ||
| 213 | + * | ||
| 214 | + * @access public | ||
| 215 | + * @param array $params associative array of parameters | ||
| 216 | + * | ||
| 217 | + * <b>one of:</b> | ||
| 218 | + * o 'file' => path to file for download | ||
| 219 | + * o 'data' => raw data for download | ||
| 220 | + * o 'resource' => resource handle for download | ||
| 221 | + * <br/> | ||
| 222 | + * <b>and any of:</b> | ||
| 223 | + * o 'cache' => whether to allow cs caching | ||
| 224 | + * o 'gzip' => whether to gzip the download | ||
| 225 | + * o 'lastmodified' => unix timestamp | ||
| 226 | + * o 'contenttype' => content type of download | ||
| 227 | + * o 'contentdisposition' => content disposition | ||
| 228 | + * o 'buffersize' => amount of bytes to buffer | ||
| 229 | + * o 'throttledelay' => amount of secs to sleep | ||
| 230 | + * o 'cachecontrol' => cache privacy and validity | ||
| 231 | + * | ||
| 232 | + * <br /> | ||
| 233 | + * 'Content-Disposition' is not HTTP compliant, but most browsers | ||
| 234 | + * follow this header, so it was borrowed from MIME standard. | ||
| 235 | + * | ||
| 236 | + * It looks like this: <br /> | ||
| 237 | + * "Content-Disposition: attachment; filename=example.tgz". | ||
| 238 | + * | ||
| 239 | + * @see HTTP_Download::setContentDisposition() | ||
| 240 | + */ | ||
| 241 | + function HTTP_Download($params = array()) | ||
| 242 | + { | ||
| 243 | + $this->HTTP = &new HTTP_Header; | ||
| 244 | + $this->setParams($params); | ||
| 245 | + } | ||
| 246 | + // }}} | ||
| 247 | + | ||
| 248 | + // {{{ public methods | ||
| 249 | + /** | ||
| 250 | + * Set parameters | ||
| 251 | + * | ||
| 252 | + * Set supplied parameters through its accessor methods. | ||
| 253 | + * | ||
| 254 | + * @access public | ||
| 255 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 256 | + * @param array $params associative array of parameters | ||
| 257 | + * | ||
| 258 | + * @see HTTP_Download::HTTP_Download() | ||
| 259 | + */ | ||
| 260 | + function setParams($params) | ||
| 261 | + { | ||
| 262 | + foreach((array) $params as $param => $value){ | ||
| 263 | + $method = 'set'. $param; | ||
| 264 | + | ||
| 265 | + if (!method_exists($this, $method)) { | ||
| 266 | + return PEAR::raiseError( | ||
| 267 | + "Method '$method' doesn't exist.", | ||
| 268 | + HTTP_DOWNLOAD_E_INVALID_PARAM | ||
| 269 | + ); | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + $e = call_user_func_array(array(&$this, $method), (array) $value); | ||
| 273 | + | ||
| 274 | + if (PEAR::isError($e)) { | ||
| 275 | + return $e; | ||
| 276 | + } | ||
| 277 | + } | ||
| 278 | + return true; | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + /** | ||
| 282 | + * Set path to file for download | ||
| 283 | + * | ||
| 284 | + * The Last-Modified header will be set to files filemtime(), actually. | ||
| 285 | + * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_FILE) if file doesn't exist. | ||
| 286 | + * Sends HTTP 404 status if $send_404 is set to true. | ||
| 287 | + * | ||
| 288 | + * @access public | ||
| 289 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 290 | + * @param string $file path to file for download | ||
| 291 | + * @param bool $send_404 whether to send HTTP/404 if | ||
| 292 | + * the file wasn't found | ||
| 293 | + */ | ||
| 294 | + function setFile($file, $send_404 = true) | ||
| 295 | + { | ||
| 296 | + $file = realpath($file); | ||
| 297 | + if (!is_file($file)) { | ||
| 298 | + if ($send_404) { | ||
| 299 | + $this->HTTP->sendStatusCode(404); | ||
| 300 | + } | ||
| 301 | + return PEAR::raiseError( | ||
| 302 | + "File '$file' not found.", | ||
| 303 | + HTTP_DOWNLOAD_E_INVALID_FILE | ||
| 304 | + ); | ||
| 305 | + } | ||
| 306 | + $this->setLastModified(filemtime($file)); | ||
| 307 | + $this->file = $file; | ||
| 308 | + $this->size = filesize($file); | ||
| 309 | + return true; | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + /** | ||
| 313 | + * Set data for download | ||
| 314 | + * | ||
| 315 | + * Set $data to null if you want to unset this. | ||
| 316 | + * | ||
| 317 | + * @access public | ||
| 318 | + * @return void | ||
| 319 | + * @param $data raw data to send | ||
| 320 | + */ | ||
| 321 | + function setData($data = null) | ||
| 322 | + { | ||
| 323 | + $this->data = $data; | ||
| 324 | + $this->size = strlen($data); | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + /** | ||
| 328 | + * Set resource for download | ||
| 329 | + * | ||
| 330 | + * The resource handle supplied will be closed after sending the download. | ||
| 331 | + * Returns a PEAR_Error (HTTP_DOWNLOAD_E_INVALID_RESOURCE) if $handle | ||
| 332 | + * is no valid resource. Set $handle to null if you want to unset this. | ||
| 333 | + * | ||
| 334 | + * @access public | ||
| 335 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 336 | + * @param int $handle resource handle | ||
| 337 | + */ | ||
| 338 | + function setResource($handle = null) | ||
| 339 | + { | ||
| 340 | + if (!isset($handle)) { | ||
| 341 | + $this->handle = null; | ||
| 342 | + $this->size = 0; | ||
| 343 | + return true; | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + if (is_resource($handle)) { | ||
| 347 | + $this->handle = $handle; | ||
| 348 | + $filestats = fstat($handle); | ||
| 349 | + $this->size = $filestats['size']; | ||
| 350 | + return true; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + return PEAR::raiseError( | ||
| 354 | + "Handle '$handle' is no valid resource.", | ||
| 355 | + HTTP_DOWNLOAD_E_INVALID_RESOURCE | ||
| 356 | + ); | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + /** | ||
| 360 | + * Whether to gzip the download | ||
| 361 | + * | ||
| 362 | + * Returns a PEAR_Error (HTTP_DOWNLOAD_E_NO_EXT_ZLIB) | ||
| 363 | + * if ext/zlib is not available/loadable. | ||
| 364 | + * | ||
| 365 | + * @access public | ||
| 366 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 367 | + * @param bool $gzip whether to gzip the download | ||
| 368 | + */ | ||
| 369 | + function setGzip($gzip = false) | ||
| 370 | + { | ||
| 371 | + if ($gzip && !PEAR::loadExtension('zlib')){ | ||
| 372 | + return PEAR::raiseError( | ||
| 373 | + 'GZIP compression (ext/zlib) not available.', | ||
| 374 | + HTTP_DOWNLOAD_E_NO_EXT_ZLIB | ||
| 375 | + ); | ||
| 376 | + } | ||
| 377 | + $this->gzip = (bool) $gzip; | ||
| 378 | + return true; | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + /** | ||
| 382 | + * Whether to allow caching | ||
| 383 | + * | ||
| 384 | + * If set to true (default) we'll send some headers that are commonly | ||
| 385 | + * used for caching purposes like ETag, Cache-Control and Last-Modified. | ||
| 386 | + * | ||
| 387 | + * If caching is disabled, we'll send the download no matter if it | ||
| 388 | + * would actually be cached at the client side. | ||
| 389 | + * | ||
| 390 | + * @access public | ||
| 391 | + * @return void | ||
| 392 | + * @param bool $cache whether to allow caching | ||
| 393 | + */ | ||
| 394 | + function setCache($cache = true) | ||
| 395 | + { | ||
| 396 | + $this->cache = (bool) $cache; | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + /** | ||
| 400 | + * Whether to allow proxies to cache | ||
| 401 | + * | ||
| 402 | + * If set to 'private' proxies shouldn't cache the response. | ||
| 403 | + * This setting defaults to 'public' and affects only cached responses. | ||
| 404 | + * | ||
| 405 | + * @access public | ||
| 406 | + * @return bool | ||
| 407 | + * @param string $cache private or public | ||
| 408 | + * @param int $maxage maximum age of the client cache entry | ||
| 409 | + */ | ||
| 410 | + function setCacheControl($cache = 'public', $maxage = 0) | ||
| 411 | + { | ||
| 412 | + switch ($cache = strToLower($cache)) | ||
| 413 | + { | ||
| 414 | + case 'private': | ||
| 415 | + case 'public': | ||
| 416 | + $this->headers['Cache-Control'] = | ||
| 417 | + $cache .', must-revalidate, max-age='. abs($maxage); | ||
| 418 | + return true; | ||
| 419 | + break; | ||
| 420 | + } | ||
| 421 | + return false; | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + /** | ||
| 425 | + * Set ETag | ||
| 426 | + * | ||
| 427 | + * Sets a user-defined ETag for cache-validation. The ETag is usually | ||
| 428 | + * generated by HTTP_Download through its payload information. | ||
| 429 | + * | ||
| 430 | + * @access public | ||
| 431 | + * @return void | ||
| 432 | + * @param string $etag Entity tag used for strong cache validation. | ||
| 433 | + */ | ||
| 434 | + function setETag($etag = null) | ||
| 435 | + { | ||
| 436 | + $this->etag = (string) $etag; | ||
| 437 | + } | ||
| 438 | + | ||
| 439 | + /** | ||
| 440 | + * Set Size of Buffer | ||
| 441 | + * | ||
| 442 | + * The amount of bytes specified as buffer size is the maximum amount | ||
| 443 | + * of data read at once from resources or files. The default size is 2M | ||
| 444 | + * (2097152 bytes). Be aware that if you enable gzip compression and | ||
| 445 | + * you set a very low buffer size that the actual file size may grow | ||
| 446 | + * due to added gzip headers for each sent chunk of the specified size. | ||
| 447 | + * | ||
| 448 | + * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_PARAM) if $size is not | ||
| 449 | + * greater than 0 bytes. | ||
| 450 | + * | ||
| 451 | + * @access public | ||
| 452 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 453 | + * @param int $bytes Amount of bytes to use as buffer. | ||
| 454 | + */ | ||
| 455 | + function setBufferSize($bytes = 2097152) | ||
| 456 | + { | ||
| 457 | + if (0 >= $bytes) { | ||
| 458 | + return PEAR::raiseError( | ||
| 459 | + 'Buffer size must be greater than 0 bytes ('. $bytes .' given)', | ||
| 460 | + HTTP_DOWNLOAD_E_INVALID_PARAM); | ||
| 461 | + } | ||
| 462 | + $this->bufferSize = abs($bytes); | ||
| 463 | + return true; | ||
| 464 | + } | ||
| 465 | + | ||
| 466 | + /** | ||
| 467 | + * Set Throttle Delay | ||
| 468 | + * | ||
| 469 | + * Set the amount of seconds to sleep after each chunck that has been | ||
| 470 | + * sent. One can implement some sort of throttle through adjusting the | ||
| 471 | + * buffer size and the throttle delay. With the following settings | ||
| 472 | + * HTTP_Download will sleep a second after each 25 K of data sent. | ||
| 473 | + * | ||
| 474 | + * <code> | ||
| 475 | + * Array( | ||
| 476 | + * 'throttledelay' => 1, | ||
| 477 | + * 'buffersize' => 1024 * 25, | ||
| 478 | + * ) | ||
| 479 | + * </code> | ||
| 480 | + * | ||
| 481 | + * Just be aware that if gzipp'ing is enabled, decreasing the chunk size | ||
| 482 | + * too much leads to proportionally increased network traffic due to added | ||
| 483 | + * gzip header and bottom bytes around each chunk. | ||
| 484 | + * | ||
| 485 | + * @access public | ||
| 486 | + * @return void | ||
| 487 | + * @param float $seconds Amount of seconds to sleep after each | ||
| 488 | + * chunk that has been sent. | ||
| 489 | + */ | ||
| 490 | + function setThrottleDelay($seconds = 0) | ||
| 491 | + { | ||
| 492 | + $this->throttleDelay = abs($seconds) * 1000; | ||
| 493 | + } | ||
| 494 | + | ||
| 495 | + /** | ||
| 496 | + * Set "Last-Modified" | ||
| 497 | + * | ||
| 498 | + * This is usually determined by filemtime() in HTTP_Download::setFile() | ||
| 499 | + * If you set raw data for download with HTTP_Download::setData() and you | ||
| 500 | + * want do send an appropiate "Last-Modified" header, you should call this | ||
| 501 | + * method. | ||
| 502 | + * | ||
| 503 | + * @access public | ||
| 504 | + * @return void | ||
| 505 | + * @param int unix timestamp | ||
| 506 | + */ | ||
| 507 | + function setLastModified($last_modified) | ||
| 508 | + { | ||
| 509 | + $this->lastModified = $this->headers['Last-Modified'] = (int) $last_modified; | ||
| 510 | + } | ||
| 511 | + | ||
| 512 | + /** | ||
| 513 | + * Set Content-Disposition header | ||
| 514 | + * | ||
| 515 | + * @see HTTP_Download::HTTP_Download | ||
| 516 | + * | ||
| 517 | + * @access public | ||
| 518 | + * @return void | ||
| 519 | + * @param string $disposition whether to send the download | ||
| 520 | + * inline or as attachment | ||
| 521 | + * @param string $file_name the filename to display in | ||
| 522 | + * the browser's download window | ||
| 523 | + * | ||
| 524 | + * <b>Example:</b> | ||
| 525 | + * <code> | ||
| 526 | + * $HTTP_Download->setContentDisposition( | ||
| 527 | + * HTTP_DOWNLOAD_ATTACHMENT, | ||
| 528 | + * 'download.tgz' | ||
| 529 | + * ); | ||
| 530 | + * </code> | ||
| 531 | + */ | ||
| 532 | + function setContentDisposition( $disposition = HTTP_DOWNLOAD_ATTACHMENT, | ||
| 533 | + $file_name = null) | ||
| 534 | + { | ||
| 535 | + $cd = $disposition; | ||
| 536 | + if (isset($file_name)) { | ||
| 537 | + $cd .= '; filename="' . $file_name . '"'; | ||
| 538 | + } elseif ($this->file) { | ||
| 539 | + $cd .= '; filename="' . basename($this->file) . '"'; | ||
| 540 | + } | ||
| 541 | + $this->headers['Content-Disposition'] = $cd; | ||
| 542 | + } | ||
| 543 | + | ||
| 544 | + /** | ||
| 545 | + * Set content type of the download | ||
| 546 | + * | ||
| 547 | + * Default content type of the download will be 'application/x-octetstream'. | ||
| 548 | + * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) if | ||
| 549 | + * $content_type doesn't seem to be valid. | ||
| 550 | + * | ||
| 551 | + * @access public | ||
| 552 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 553 | + * @param string $content_type content type of file for download | ||
| 554 | + */ | ||
| 555 | + function setContentType($content_type = 'application/x-octetstream') | ||
| 556 | + { | ||
| 557 | + if (!preg_match('/^[a-z]+\w*\/[a-z]+[\w.;= -]*$/', $content_type)) { | ||
| 558 | + return PEAR::raiseError( | ||
| 559 | + "Invalid content type '$content_type' supplied.", | ||
| 560 | + HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE | ||
| 561 | + ); | ||
| 562 | + } | ||
| 563 | + $this->headers['Content-Type'] = $content_type; | ||
| 564 | + return true; | ||
| 565 | + } | ||
| 566 | + | ||
| 567 | + /** | ||
| 568 | + * Guess content type of file | ||
| 569 | + * | ||
| 570 | + * First we try to use PEAR::MIME_Type, if installed, to detect the content | ||
| 571 | + * type, else we check if ext/mime_magic is loaded and properly configured. | ||
| 572 | + * | ||
| 573 | + * Returns PEAR_Error if: | ||
| 574 | + * o if PEAR::MIME_Type failed to detect a proper content type | ||
| 575 | + * (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) | ||
| 576 | + * o ext/magic.mime is not installed, or not properly configured | ||
| 577 | + * (HTTP_DOWNLOAD_E_NO_EXT_MMAGIC) | ||
| 578 | + * o mime_content_type() couldn't guess content type or returned | ||
| 579 | + * a content type considered to be bogus by setContentType() | ||
| 580 | + * (HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE) | ||
| 581 | + * | ||
| 582 | + * @access public | ||
| 583 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 584 | + */ | ||
| 585 | + function guessContentType() | ||
| 586 | + { | ||
| 587 | + if (class_exists('MIME_Type') || @include_once 'MIME/Type.php') { | ||
| 588 | + if (PEAR::isError($mime_type = MIME_Type::autoDetect($this->file))) { | ||
| 589 | + return PEAR::raiseError($mime_type->getMessage(), | ||
| 590 | + HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE); | ||
| 591 | + } | ||
| 592 | + return $this->setContentType($mime_type); | ||
| 593 | + } | ||
| 594 | + if (!function_exists('mime_content_type')) { | ||
| 595 | + return PEAR::raiseError( | ||
| 596 | + 'This feature requires ext/mime_magic!', | ||
| 597 | + HTTP_DOWNLOAD_E_NO_EXT_MMAGIC | ||
| 598 | + ); | ||
| 599 | + } | ||
| 600 | + if (!is_file(ini_get('mime_magic.magicfile'))) { | ||
| 601 | + return PEAR::raiseError( | ||
| 602 | + 'ext/mime_magic is loaded but not properly configured!', | ||
| 603 | + HTTP_DOWNLOAD_E_NO_EXT_MMAGIC | ||
| 604 | + ); | ||
| 605 | + } | ||
| 606 | + if (!$content_type = @mime_content_type($this->file)) { | ||
| 607 | + return PEAR::raiseError( | ||
| 608 | + 'Couldn\'t guess content type with mime_content_type().', | ||
| 609 | + HTTP_DOWNLOAD_E_INVALID_CONTENT_TYPE | ||
| 610 | + ); | ||
| 611 | + } | ||
| 612 | + return $this->setContentType($content_type); | ||
| 613 | + } | ||
| 614 | + | ||
| 615 | + /** | ||
| 616 | + * Send | ||
| 617 | + * | ||
| 618 | + * Returns PEAR_Error if: | ||
| 619 | + * o HTTP headers were already sent (HTTP_DOWNLOAD_E_HEADERS_SENT) | ||
| 620 | + * o HTTP Range was invalid (HTTP_DOWNLOAD_E_INVALID_REQUEST) | ||
| 621 | + * | ||
| 622 | + * @access public | ||
| 623 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 624 | + * @param bool $autoSetContentDisposition Whether to set the | ||
| 625 | + * Content-Disposition header if it isn't already. | ||
| 626 | + */ | ||
| 627 | + function send($autoSetContentDisposition = true) | ||
| 628 | + { | ||
| 629 | + if (headers_sent()) { | ||
| 630 | + return PEAR::raiseError( | ||
| 631 | + 'Headers already sent.', | ||
| 632 | + HTTP_DOWNLOAD_E_HEADERS_SENT | ||
| 633 | + ); | ||
| 634 | + } | ||
| 635 | + | ||
| 636 | + if (!ini_get('safe_mode')) { | ||
| 637 | + @set_time_limit(0); | ||
| 638 | + } | ||
| 639 | + | ||
| 640 | + if ($autoSetContentDisposition && | ||
| 641 | + !isset($this->headers['Content-Disposition'])) { | ||
| 642 | + $this->setContentDisposition(); | ||
| 643 | + } | ||
| 644 | + | ||
| 645 | + if ($this->cache) { | ||
| 646 | + $this->headers['ETag'] = $this->generateETag(); | ||
| 647 | + if ($this->isCached()) { | ||
| 648 | + $this->HTTP->sendStatusCode(304); | ||
| 649 | + $this->sendHeaders(); | ||
| 650 | + return true; | ||
| 651 | + } | ||
| 652 | + } else { | ||
| 653 | + unset($this->headers['Last-Modified']); | ||
| 654 | + } | ||
| 655 | + | ||
| 656 | + while (@ob_end_clean()); | ||
| 657 | + | ||
| 658 | + if ($this->gzip) { | ||
| 659 | + @ob_start('ob_gzhandler'); | ||
| 660 | + } else { | ||
| 661 | + ob_start(); | ||
| 662 | + } | ||
| 663 | + | ||
| 664 | + $this->sentBytes = 0; | ||
| 665 | + | ||
| 666 | + if ($this->isRangeRequest()) { | ||
| 667 | + $this->HTTP->sendStatusCode(206); | ||
| 668 | + $chunks = $this->getChunks(); | ||
| 669 | + } else { | ||
| 670 | + $this->HTTP->sendStatusCode(200); | ||
| 671 | + $chunks = array(array(0, $this->size)); | ||
| 672 | + if (!$this->gzip && count(ob_list_handlers()) < 2) { | ||
| 673 | + $this->headers['Content-Length'] = $this->size; | ||
| 674 | + } | ||
| 675 | + } | ||
| 676 | + | ||
| 677 | + if (PEAR::isError($e = $this->sendChunks($chunks))) { | ||
| 678 | + ob_end_clean(); | ||
| 679 | + $this->HTTP->sendStatusCode(416); | ||
| 680 | + return $e; | ||
| 681 | + } | ||
| 682 | + | ||
| 683 | + ob_end_flush(); | ||
| 684 | + flush(); | ||
| 685 | + return true; | ||
| 686 | + } | ||
| 687 | + | ||
| 688 | + /** | ||
| 689 | + * Static send | ||
| 690 | + * | ||
| 691 | + * @see HTTP_Download::HTTP_Download() | ||
| 692 | + * @see HTTP_Download::send() | ||
| 693 | + * | ||
| 694 | + * @static | ||
| 695 | + * @access public | ||
| 696 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 697 | + * @param array $params associative array of parameters | ||
| 698 | + * @param bool $guess whether HTTP_Download::guessContentType() | ||
| 699 | + * should be called | ||
| 700 | + */ | ||
| 701 | + function staticSend($params, $guess = false) | ||
| 702 | + { | ||
| 703 | + $d = &new HTTP_Download(); | ||
| 704 | + $e = $d->setParams($params); | ||
| 705 | + if (PEAR::isError($e)) { | ||
| 706 | + return $e; | ||
| 707 | + } | ||
| 708 | + if ($guess) { | ||
| 709 | + $e = $d->guessContentType(); | ||
| 710 | + if (PEAR::isError($e)) { | ||
| 711 | + return $e; | ||
| 712 | + } | ||
| 713 | + } | ||
| 714 | + return $d->send(); | ||
| 715 | + } | ||
| 716 | + | ||
| 717 | + /** | ||
| 718 | + * Send a bunch of files or directories as an archive | ||
| 719 | + * | ||
| 720 | + * Example: | ||
| 721 | + * <code> | ||
| 722 | + * require_once 'HTTP/Download.php'; | ||
| 723 | + * HTTP_Download::sendArchive( | ||
| 724 | + * 'myArchive.tgz', | ||
| 725 | + * '/var/ftp/pub/mike', | ||
| 726 | + * HTTP_DOWNLOAD_TGZ, | ||
| 727 | + * '', | ||
| 728 | + * '/var/ftp/pub' | ||
| 729 | + * ); | ||
| 730 | + * </code> | ||
| 731 | + * | ||
| 732 | + * @see Archive_Tar::createModify() | ||
| 733 | + * @deprecated use HTTP_Download_Archive::send() | ||
| 734 | + * @static | ||
| 735 | + * @access public | ||
| 736 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 737 | + * @param string $name name the sent archive should have | ||
| 738 | + * @param mixed $files files/directories | ||
| 739 | + * @param string $type archive type | ||
| 740 | + * @param string $add_path path that should be prepended to the files | ||
| 741 | + * @param string $strip_path path that should be stripped from the files | ||
| 742 | + */ | ||
| 743 | + function sendArchive( $name, | ||
| 744 | + $files, | ||
| 745 | + $type = HTTP_DOWNLOAD_TGZ, | ||
| 746 | + $add_path = '', | ||
| 747 | + $strip_path = '') | ||
| 748 | + { | ||
| 749 | + require_once 'HTTP/Download/Archive.php'; | ||
| 750 | + return HTTP_Download_Archive::send($name, $files, $type, | ||
| 751 | + $add_path, $strip_path); | ||
| 752 | + } | ||
| 753 | + // }}} | ||
| 754 | + | ||
| 755 | + // {{{ protected methods | ||
| 756 | + /** | ||
| 757 | + * Generate ETag | ||
| 758 | + * | ||
| 759 | + * @access protected | ||
| 760 | + * @return string | ||
| 761 | + */ | ||
| 762 | + function generateETag() | ||
| 763 | + { | ||
| 764 | + if (!$this->etag) { | ||
| 765 | + if ($this->data) { | ||
| 766 | + $md5 = md5($this->data); | ||
| 767 | + } else { | ||
| 768 | + $fst = is_resource($this->handle) ? | ||
| 769 | + fstat($this->handle) : stat($this->file); | ||
| 770 | + $md5 = md5($fst['mtime'] .'='. $fst['ino'] .'='. $fst['size']); | ||
| 771 | + } | ||
| 772 | + $this->etag = '"' . $md5 . '-' . crc32($md5) . '"'; | ||
| 773 | + } | ||
| 774 | + return $this->etag; | ||
| 775 | + } | ||
| 776 | + | ||
| 777 | + /** | ||
| 778 | + * Send multiple chunks | ||
| 779 | + * | ||
| 780 | + * @access protected | ||
| 781 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 782 | + * @param array $chunks | ||
| 783 | + */ | ||
| 784 | + function sendChunks($chunks) | ||
| 785 | + { | ||
| 786 | + if (count($chunks) == 1) { | ||
| 787 | + return $this->sendChunk(array_shift($chunks)); | ||
| 788 | + } | ||
| 789 | + | ||
| 790 | + $bound = uniqid('HTTP_DOWNLOAD-', true); | ||
| 791 | + $cType = $this->headers['Content-Type']; | ||
| 792 | + $this->headers['Content-Type'] = | ||
| 793 | + 'multipart/byteranges; boundary=' . $bound; | ||
| 794 | + $this->sendHeaders(); | ||
| 795 | + foreach ($chunks as $chunk){ | ||
| 796 | + if (PEAR::isError($e = $this->sendChunk($chunk, $cType, $bound))) { | ||
| 797 | + return $e; | ||
| 798 | + } | ||
| 799 | + } | ||
| 800 | + #echo "\r\n--$bound--\r\n"; | ||
| 801 | + return true; | ||
| 802 | + } | ||
| 803 | + | ||
| 804 | + /** | ||
| 805 | + * Send chunk of data | ||
| 806 | + * | ||
| 807 | + * @access protected | ||
| 808 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 809 | + * @param array $chunk start and end offset of the chunk to send | ||
| 810 | + * @param string $cType actual content type | ||
| 811 | + * @param string $bound boundary for multipart/byteranges | ||
| 812 | + */ | ||
| 813 | + function sendChunk($chunk, $cType = null, $bound = null) | ||
| 814 | + { | ||
| 815 | + list($offset, $lastbyte) = $chunk; | ||
| 816 | + $length = ($lastbyte - $offset) + 1; | ||
| 817 | + | ||
| 818 | + if ($length < 1) { | ||
| 819 | + return PEAR::raiseError( | ||
| 820 | + "Error processing range request: $offset-$lastbyte/$length", | ||
| 821 | + HTTP_DOWNLOAD_E_INVALID_REQUEST | ||
| 822 | + ); | ||
| 823 | + } | ||
| 824 | + | ||
| 825 | + $range = $offset . '-' . $lastbyte . '/' . $this->size; | ||
| 826 | + | ||
| 827 | + if (isset($cType, $bound)) { | ||
| 828 | + echo "\r\n--$bound\r\n", | ||
| 829 | + "Content-Type: $cType\r\n", | ||
| 830 | + "Content-Range: bytes $range\r\n\r\n"; | ||
| 831 | + } else { | ||
| 832 | + if ($this->isRangeRequest()) { | ||
| 833 | + $this->headers['Content-Range'] = 'bytes '. $range; | ||
| 834 | + } | ||
| 835 | + $this->sendHeaders(); | ||
| 836 | + } | ||
| 837 | + | ||
| 838 | + if ($this->data) { | ||
| 839 | + while (($length -= $this->bufferSize) > 0) { | ||
| 840 | + $this->flush(substr($this->data, $offset, $this->bufferSize)); | ||
| 841 | + $this->throttleDelay and $this->sleep(); | ||
| 842 | + $offset += $this->bufferSize; | ||
| 843 | + } | ||
| 844 | + if ($length) { | ||
| 845 | + $this->flush(substr($this->data, $offset, $this->bufferSize + $length)); | ||
| 846 | + } | ||
| 847 | + } else { | ||
| 848 | + if (!is_resource($this->handle)) { | ||
| 849 | + $this->handle = fopen($this->file, 'rb'); | ||
| 850 | + } | ||
| 851 | + fseek($this->handle, $offset); | ||
| 852 | + while (($length -= $this->bufferSize) > 0) { | ||
| 853 | + $this->flush(fread($this->handle, $this->bufferSize)); | ||
| 854 | + $this->throttleDelay and $this->sleep(); | ||
| 855 | + } | ||
| 856 | + if ($length) { | ||
| 857 | + $this->flush(fread($this->handle, $this->bufferSize + $length)); | ||
| 858 | + } | ||
| 859 | + } | ||
| 860 | + return true; | ||
| 861 | + } | ||
| 862 | + | ||
| 863 | + /** | ||
| 864 | + * Get chunks to send | ||
| 865 | + * | ||
| 866 | + * @access protected | ||
| 867 | + * @return array | ||
| 868 | + */ | ||
| 869 | + function getChunks() | ||
| 870 | + { | ||
| 871 | + $parts = array(); | ||
| 872 | + foreach (explode(',', $this->getRanges()) as $chunk){ | ||
| 873 | + list($o, $e) = explode('-', $chunk); | ||
| 874 | + if ($e >= $this->size || (empty($e) && $e !== 0 && $e !== '0')) { | ||
| 875 | + $e = $this->size - 1; | ||
| 876 | + } | ||
| 877 | + if (empty($o) && $o !== 0 && $o !== '0') { | ||
| 878 | + $o = $this->size - $e; | ||
| 879 | + $e = $this->size - 1; | ||
| 880 | + } | ||
| 881 | + $parts[] = array($o, $e); | ||
| 882 | + } | ||
| 883 | + return $parts; | ||
| 884 | + } | ||
| 885 | + | ||
| 886 | + /** | ||
| 887 | + * Check if range is requested | ||
| 888 | + * | ||
| 889 | + * @access protected | ||
| 890 | + * @return bool | ||
| 891 | + */ | ||
| 892 | + function isRangeRequest() | ||
| 893 | + { | ||
| 894 | + if (!isset($_SERVER['HTTP_RANGE'])) { | ||
| 895 | + return false; | ||
| 896 | + } | ||
| 897 | + return $this->isValidRange(); | ||
| 898 | + } | ||
| 899 | + | ||
| 900 | + /** | ||
| 901 | + * Get range request | ||
| 902 | + * | ||
| 903 | + * @access protected | ||
| 904 | + * @return array | ||
| 905 | + */ | ||
| 906 | + function getRanges() | ||
| 907 | + { | ||
| 908 | + return preg_match('/^bytes=((\d*-\d*,? ?)+)$/', | ||
| 909 | + @$_SERVER['HTTP_RANGE'], $matches) ? $matches[1] : array(); | ||
| 910 | + } | ||
| 911 | + | ||
| 912 | + /** | ||
| 913 | + * Check if entity is cached | ||
| 914 | + * | ||
| 915 | + * @access protected | ||
| 916 | + * @return bool | ||
| 917 | + */ | ||
| 918 | + function isCached() | ||
| 919 | + { | ||
| 920 | + return ( | ||
| 921 | + (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && | ||
| 922 | + $this->lastModified == strtotime(current($a = explode( | ||
| 923 | + ';', $_SERVER['HTTP_IF_MODIFIED_SINCE'])))) || | ||
| 924 | + (isset($_SERVER['HTTP_IF_NONE_MATCH']) && | ||
| 925 | + $this->compareAsterisk('HTTP_IF_NONE_MATCH', $this->etag)) | ||
| 926 | + ); | ||
| 927 | + } | ||
| 928 | + | ||
| 929 | + /** | ||
| 930 | + * Check if entity hasn't changed | ||
| 931 | + * | ||
| 932 | + * @access protected | ||
| 933 | + * @return bool | ||
| 934 | + */ | ||
| 935 | + function isValidRange() | ||
| 936 | + { | ||
| 937 | + if (isset($_SERVER['HTTP_IF_MATCH']) && | ||
| 938 | + !$this->compareAsterisk('HTTP_IF_MATCH', $this->etag)) { | ||
| 939 | + return false; | ||
| 940 | + } | ||
| 941 | + if (isset($_SERVER['HTTP_IF_RANGE']) && | ||
| 942 | + $_SERVER['HTTP_IF_RANGE'] !== $this->etag && | ||
| 943 | + strtotime($_SERVER['HTTP_IF_RANGE']) !== $this->lastModified) { | ||
| 944 | + return false; | ||
| 945 | + } | ||
| 946 | + if (isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE'])) { | ||
| 947 | + $lm = array_shift(explode(';', $_SERVER['HTTP_IF_UNMODIFIED_SINCE'])); | ||
| 948 | + if (strtotime($lm) !== $this->lastModified) { | ||
| 949 | + return false; | ||
| 950 | + } | ||
| 951 | + } | ||
| 952 | + if (isset($_SERVER['HTTP_UNLESS_MODIFIED_SINCE'])) { | ||
| 953 | + $lm = array_shift(explode(';', $_SERVER['HTTP_UNLESS_MODIFIED_SINCE'])); | ||
| 954 | + if (strtotime($lm) !== $this->lastModified) { | ||
| 955 | + return false; | ||
| 956 | + } | ||
| 957 | + } | ||
| 958 | + return true; | ||
| 959 | + } | ||
| 960 | + | ||
| 961 | + /** | ||
| 962 | + * Compare against an asterisk or check for equality | ||
| 963 | + * | ||
| 964 | + * @access protected | ||
| 965 | + * @return bool | ||
| 966 | + * @param string key for the $_SERVER array | ||
| 967 | + * @param string string to compare | ||
| 968 | + */ | ||
| 969 | + function compareAsterisk($svar, $compare) | ||
| 970 | + { | ||
| 971 | + foreach (array_map('trim', explode(',', $_SERVER[$svar])) as $request) { | ||
| 972 | + if ($request === '*' || $request === $compare) { | ||
| 973 | + return true; | ||
| 974 | + } | ||
| 975 | + } | ||
| 976 | + return false; | ||
| 977 | + } | ||
| 978 | + | ||
| 979 | + /** | ||
| 980 | + * Send HTTP headers | ||
| 981 | + * | ||
| 982 | + * @access protected | ||
| 983 | + * @return void | ||
| 984 | + */ | ||
| 985 | + function sendHeaders() | ||
| 986 | + { | ||
| 987 | + foreach ($this->headers as $header => $value) { | ||
| 988 | + $this->HTTP->setHeader($header, $value); | ||
| 989 | + } | ||
| 990 | + $this->HTTP->sendHeaders(); | ||
| 991 | + /* NSAPI won't output anything if we did this */ | ||
| 992 | + if (strncasecmp(PHP_SAPI, 'nsapi', 5)) { | ||
| 993 | + ob_flush(); | ||
| 994 | + flush(); | ||
| 995 | + } | ||
| 996 | + } | ||
| 997 | + | ||
| 998 | + /** | ||
| 999 | + * Flush | ||
| 1000 | + * | ||
| 1001 | + * @access protected | ||
| 1002 | + * @return void | ||
| 1003 | + * @param string $data | ||
| 1004 | + */ | ||
| 1005 | + function flush($data = '') | ||
| 1006 | + { | ||
| 1007 | + if ($dlen = strlen($data)) { | ||
| 1008 | + $this->sentBytes += $dlen; | ||
| 1009 | + echo $data; | ||
| 1010 | + } | ||
| 1011 | + ob_flush(); | ||
| 1012 | + flush(); | ||
| 1013 | + } | ||
| 1014 | + | ||
| 1015 | + /** | ||
| 1016 | + * Sleep | ||
| 1017 | + * | ||
| 1018 | + * @access protected | ||
| 1019 | + * @return void | ||
| 1020 | + */ | ||
| 1021 | + function sleep() | ||
| 1022 | + { | ||
| 1023 | + if (OS_WINDOWS) { | ||
| 1024 | + com_message_pump($this->throttleDelay); | ||
| 1025 | + } else { | ||
| 1026 | + usleep($this->throttleDelay * 1000); | ||
| 1027 | + } | ||
| 1028 | + } | ||
| 1029 | + // }}} | ||
| 1030 | +} | ||
| 1031 | +?> |
thirdparty/pear/HTTP/Download/Archive.php
| 1 | -<?php | ||
| 2 | -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | - | ||
| 4 | -/** | ||
| 5 | - * HTTP::Download::Archive | ||
| 6 | - * | ||
| 7 | - * PHP versions 4 and 5 | ||
| 8 | - * | ||
| 9 | - * @category HTTP | ||
| 10 | - * @package HTTP_Download | ||
| 11 | - * @author Michael Wallner <mike@php.net> | ||
| 12 | - * @copyright 2003-2005 Michael Wallner | ||
| 13 | - * @license BSD, revisewd | ||
| 14 | - * @version CVS: $Id: Archive.php,v 1.4 2005/11/13 19:18:55 mike Exp $ | ||
| 15 | - * @link http://pear.php.net/package/HTTP_Download | ||
| 16 | - */ | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * Requires HTTP_Download | ||
| 20 | - */ | ||
| 21 | -require_once 'HTTP/Download.php'; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * Requires System | ||
| 25 | - */ | ||
| 26 | -require_once 'System.php'; | ||
| 27 | - | ||
| 28 | -/** | ||
| 29 | - * HTTP_Download_Archive | ||
| 30 | - * | ||
| 31 | - * Helper class for sending Archives. | ||
| 32 | - * | ||
| 33 | - * @access public | ||
| 34 | - * @version $Revision: 1.4 $ | ||
| 35 | - */ | ||
| 36 | -class HTTP_Download_Archive | ||
| 37 | -{ | ||
| 38 | - /** | ||
| 39 | - * Send a bunch of files or directories as an archive | ||
| 40 | - * | ||
| 41 | - * Example: | ||
| 42 | - * <code> | ||
| 43 | - * require_once 'HTTP/Download/Archive.php'; | ||
| 44 | - * HTTP_Download_Archive::send( | ||
| 45 | - * 'myArchive.tgz', | ||
| 46 | - * '/var/ftp/pub/mike', | ||
| 47 | - * HTTP_DOWNLOAD_BZ2, | ||
| 48 | - * '', | ||
| 49 | - * '/var/ftp/pub' | ||
| 50 | - * ); | ||
| 51 | - * </code> | ||
| 52 | - * | ||
| 53 | - * @see Archive_Tar::createModify() | ||
| 54 | - * @static | ||
| 55 | - * @access public | ||
| 56 | - * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 57 | - * @param string $name name the sent archive should have | ||
| 58 | - * @param mixed $files files/directories | ||
| 59 | - * @param string $type archive type | ||
| 60 | - * @param string $add_path path that should be prepended to the files | ||
| 61 | - * @param string $strip_path path that should be stripped from the files | ||
| 62 | - */ | ||
| 63 | - function send($name, $files, $type = HTTP_DOWNLOAD_TGZ, $add_path = '', $strip_path = '') | ||
| 64 | - { | ||
| 65 | - $tmp = System::mktemp(); | ||
| 66 | - | ||
| 67 | - switch ($type = strToUpper($type)) | ||
| 68 | - { | ||
| 69 | - case HTTP_DOWNLOAD_TAR: | ||
| 70 | - include_once 'Archive/Tar.php'; | ||
| 71 | - $arc = &new Archive_Tar($tmp); | ||
| 72 | - $content_type = 'x-tar'; | ||
| 73 | - break; | ||
| 74 | - | ||
| 75 | - case HTTP_DOWNLOAD_TGZ: | ||
| 76 | - include_once 'Archive/Tar.php'; | ||
| 77 | - $arc = &new Archive_Tar($tmp, 'gz'); | ||
| 78 | - $content_type = 'x-gzip'; | ||
| 79 | - break; | ||
| 80 | - | ||
| 81 | - case HTTP_DOWNLOAD_BZ2: | ||
| 82 | - include_once 'Archive/Tar.php'; | ||
| 83 | - $arc = &new Archive_Tar($tmp, 'bz2'); | ||
| 84 | - $content_type = 'x-bzip2'; | ||
| 85 | - break; | ||
| 86 | - | ||
| 87 | - case HTTP_DOWNLOAD_ZIP: | ||
| 88 | - include_once 'Archive/Zip.php'; | ||
| 89 | - $arc = &new Archive_Zip($tmp); | ||
| 90 | - $content_type = 'x-zip'; | ||
| 91 | - break; | ||
| 92 | - | ||
| 93 | - default: | ||
| 94 | - return PEAR::raiseError( | ||
| 95 | - 'Archive type not supported: ' . $type, | ||
| 96 | - HTTP_DOWNLOAD_E_INVALID_ARCHIVE_TYPE | ||
| 97 | - ); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - if ($type == HTTP_DOWNLOAD_ZIP) { | ||
| 101 | - $options = array( 'add_path' => $add_path, | ||
| 102 | - 'remove_path' => $strip_path); | ||
| 103 | - if (!$arc->create($files, $options)) { | ||
| 104 | - return PEAR::raiseError('Archive creation failed.'); | ||
| 105 | - } | ||
| 106 | - } else { | ||
| 107 | - if (!$e = $arc->createModify($files, $add_path, $strip_path)) { | ||
| 108 | - return PEAR::raiseError('Archive creation failed.'); | ||
| 109 | - } | ||
| 110 | - if (PEAR::isError($e)) { | ||
| 111 | - return $e; | ||
| 112 | - } | ||
| 113 | - } | ||
| 114 | - unset($arc); | ||
| 115 | - | ||
| 116 | - $dl = &new HTTP_Download(array('file' => $tmp)); | ||
| 117 | - $dl->setContentType('application/' . $content_type); | ||
| 118 | - $dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, $name); | ||
| 119 | - return $dl->send(); | ||
| 120 | - } | ||
| 121 | -} | ||
| 122 | -?> | 1 | +<?php |
| 2 | +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * HTTP::Download::Archive | ||
| 6 | + * | ||
| 7 | + * PHP versions 4 and 5 | ||
| 8 | + * | ||
| 9 | + * @category HTTP | ||
| 10 | + * @package HTTP_Download | ||
| 11 | + * @author Michael Wallner <mike@php.net> | ||
| 12 | + * @copyright 2003-2005 Michael Wallner | ||
| 13 | + * @license BSD, revisewd | ||
| 14 | + * @version CVS: $Id$ | ||
| 15 | + * @link http://pear.php.net/package/HTTP_Download | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Requires HTTP_Download | ||
| 20 | + */ | ||
| 21 | +require_once 'HTTP/Download.php'; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * Requires System | ||
| 25 | + */ | ||
| 26 | +require_once 'System.php'; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * HTTP_Download_Archive | ||
| 30 | + * | ||
| 31 | + * Helper class for sending Archives. | ||
| 32 | + * | ||
| 33 | + * @access public | ||
| 34 | + * @version $Revision$ | ||
| 35 | + */ | ||
| 36 | +class HTTP_Download_Archive | ||
| 37 | +{ | ||
| 38 | + /** | ||
| 39 | + * Send a bunch of files or directories as an archive | ||
| 40 | + * | ||
| 41 | + * Example: | ||
| 42 | + * <code> | ||
| 43 | + * require_once 'HTTP/Download/Archive.php'; | ||
| 44 | + * HTTP_Download_Archive::send( | ||
| 45 | + * 'myArchive.tgz', | ||
| 46 | + * '/var/ftp/pub/mike', | ||
| 47 | + * HTTP_DOWNLOAD_BZ2, | ||
| 48 | + * '', | ||
| 49 | + * '/var/ftp/pub' | ||
| 50 | + * ); | ||
| 51 | + * </code> | ||
| 52 | + * | ||
| 53 | + * @see Archive_Tar::createModify() | ||
| 54 | + * @static | ||
| 55 | + * @access public | ||
| 56 | + * @return mixed Returns true on success or PEAR_Error on failure. | ||
| 57 | + * @param string $name name the sent archive should have | ||
| 58 | + * @param mixed $files files/directories | ||
| 59 | + * @param string $type archive type | ||
| 60 | + * @param string $add_path path that should be prepended to the files | ||
| 61 | + * @param string $strip_path path that should be stripped from the files | ||
| 62 | + */ | ||
| 63 | + function send($name, $files, $type = HTTP_DOWNLOAD_TGZ, $add_path = '', $strip_path = '') | ||
| 64 | + { | ||
| 65 | + $tmp = System::mktemp(); | ||
| 66 | + | ||
| 67 | + switch ($type = strToUpper($type)) | ||
| 68 | + { | ||
| 69 | + case HTTP_DOWNLOAD_TAR: | ||
| 70 | + include_once 'Archive/Tar.php'; | ||
| 71 | + $arc = &new Archive_Tar($tmp); | ||
| 72 | + $content_type = 'x-tar'; | ||
| 73 | + break; | ||
| 74 | + | ||
| 75 | + case HTTP_DOWNLOAD_TGZ: | ||
| 76 | + include_once 'Archive/Tar.php'; | ||
| 77 | + $arc = &new Archive_Tar($tmp, 'gz'); | ||
| 78 | + $content_type = 'x-gzip'; | ||
| 79 | + break; | ||
| 80 | + | ||
| 81 | + case HTTP_DOWNLOAD_BZ2: | ||
| 82 | + include_once 'Archive/Tar.php'; | ||
| 83 | + $arc = &new Archive_Tar($tmp, 'bz2'); | ||
| 84 | + $content_type = 'x-bzip2'; | ||
| 85 | + break; | ||
| 86 | + | ||
| 87 | + case HTTP_DOWNLOAD_ZIP: | ||
| 88 | + include_once 'Archive/Zip.php'; | ||
| 89 | + $arc = &new Archive_Zip($tmp); | ||
| 90 | + $content_type = 'x-zip'; | ||
| 91 | + break; | ||
| 92 | + | ||
| 93 | + default: | ||
| 94 | + return PEAR::raiseError( | ||
| 95 | + 'Archive type not supported: ' . $type, | ||
| 96 | + HTTP_DOWNLOAD_E_INVALID_ARCHIVE_TYPE | ||
| 97 | + ); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + if ($type == HTTP_DOWNLOAD_ZIP) { | ||
| 101 | + $options = array( 'add_path' => $add_path, | ||
| 102 | + 'remove_path' => $strip_path); | ||
| 103 | + if (!$arc->create($files, $options)) { | ||
| 104 | + return PEAR::raiseError('Archive creation failed.'); | ||
| 105 | + } | ||
| 106 | + } else { | ||
| 107 | + if (!$e = $arc->createModify($files, $add_path, $strip_path)) { | ||
| 108 | + return PEAR::raiseError('Archive creation failed.'); | ||
| 109 | + } | ||
| 110 | + if (PEAR::isError($e)) { | ||
| 111 | + return $e; | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + unset($arc); | ||
| 115 | + | ||
| 116 | + $dl = &new HTTP_Download(array('file' => $tmp)); | ||
| 117 | + $dl->setContentType('application/' . $content_type); | ||
| 118 | + $dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, $name); | ||
| 119 | + return $dl->send(); | ||
| 120 | + } | ||
| 121 | +} | ||
| 122 | +?> |
thirdparty/pear/HTTP/Download/PgLOB.php
| 1 | -<?php | ||
| 2 | -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | - | ||
| 4 | -/** | ||
| 5 | - * HTTP::Download::PgLOB | ||
| 6 | - * | ||
| 7 | - * PHP versions 4 and 5 | ||
| 8 | - * | ||
| 9 | - * @category HTTP | ||
| 10 | - * @package HTTP_Download | ||
| 11 | - * @author Michael Wallner <mike@php.net> | ||
| 12 | - * @copyright 2003-2005 Michael Wallner | ||
| 13 | - * @license BSD, revised | ||
| 14 | - * @version CVS: $Id: PgLOB.php,v 1.14 2005/11/13 19:18:55 mike Exp $ | ||
| 15 | - * @link http://pear.php.net/package/HTTP_Download | ||
| 16 | - */ | ||
| 17 | - | ||
| 18 | -$GLOBALS['_HTTP_Download_PgLOB_Connection'] = null; | ||
| 19 | -stream_register_wrapper('pglob', 'HTTP_Download_PgLOB'); | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * PgSQL large object stream interface for HTTP_Download | ||
| 23 | - * | ||
| 24 | - * Usage: | ||
| 25 | - * <code> | ||
| 26 | - * require_once 'HTTP/Download.php'; | ||
| 27 | - * require_once 'HTTP/Download/PgLOB.php'; | ||
| 28 | - * $db = &DB::connect('pgsql://user:pass@host/db'); | ||
| 29 | - * // or $db = pg_connect(...); | ||
| 30 | - * $lo = HTTP_Download_PgLOB::open($db, 12345); | ||
| 31 | - * $dl = &new HTTP_Download; | ||
| 32 | - * $dl->setResource($lo); | ||
| 33 | - * $dl->send() | ||
| 34 | - * </code> | ||
| 35 | - * | ||
| 36 | - * @access public | ||
| 37 | - * @version $Revision: 1.14 $ | ||
| 38 | - */ | ||
| 39 | -class HTTP_Download_PgLOB | ||
| 40 | -{ | ||
| 41 | - /** | ||
| 42 | - * Set Connection | ||
| 43 | - * | ||
| 44 | - * @static | ||
| 45 | - * @access public | ||
| 46 | - * @return bool | ||
| 47 | - * @param mixed $conn | ||
| 48 | - */ | ||
| 49 | - function setConnection($conn) | ||
| 50 | - { | ||
| 51 | - if (is_a($conn, 'DB_Common')) { | ||
| 52 | - $conn = $conn->dbh; | ||
| 53 | - } elseif ( is_a($conn, 'MDB_Common') || | ||
| 54 | - is_a($conn, 'MDB2_Driver_Common')) { | ||
| 55 | - $conn = $conn->connection; | ||
| 56 | - } | ||
| 57 | - if ($isResource = is_resource($conn)) { | ||
| 58 | - $GLOBALS['_HTTP_Download_PgLOB_Connection'] = $conn; | ||
| 59 | - } | ||
| 60 | - return $isResource; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - /** | ||
| 64 | - * Get Connection | ||
| 65 | - * | ||
| 66 | - * @static | ||
| 67 | - * @access public | ||
| 68 | - * @return resource | ||
| 69 | - */ | ||
| 70 | - function getConnection() | ||
| 71 | - { | ||
| 72 | - if (is_resource($GLOBALS['_HTTP_Download_PgLOB_Connection'])) { | ||
| 73 | - return $GLOBALS['_HTTP_Download_PgLOB_Connection']; | ||
| 74 | - } | ||
| 75 | - return null; | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - /** | ||
| 79 | - * Open | ||
| 80 | - * | ||
| 81 | - * @static | ||
| 82 | - * @access public | ||
| 83 | - * @return resource | ||
| 84 | - * @param mixed $conn | ||
| 85 | - * @param int $loid | ||
| 86 | - * @param string $mode | ||
| 87 | - */ | ||
| 88 | - function open($conn, $loid, $mode = 'rb') | ||
| 89 | - { | ||
| 90 | - HTTP_Download_PgLOB::setConnection($conn); | ||
| 91 | - return fopen('pglob:///'. $loid, $mode); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - /**#@+ | ||
| 95 | - * Stream Interface Implementation | ||
| 96 | - * @internal | ||
| 97 | - */ | ||
| 98 | - var $ID = 0; | ||
| 99 | - var $size = 0; | ||
| 100 | - var $conn = null; | ||
| 101 | - var $handle = null; | ||
| 102 | - | ||
| 103 | - function stream_open($path, $mode) | ||
| 104 | - { | ||
| 105 | - if (!$this->conn = HTTP_Download_PgLOB::getConnection()) { | ||
| 106 | - return false; | ||
| 107 | - } | ||
| 108 | - if (!preg_match('/(\d+)/', $path, $matches)) { | ||
| 109 | - return false; | ||
| 110 | - } | ||
| 111 | - $this->ID = $matches[1]; | ||
| 112 | - | ||
| 113 | - if (!pg_query($this->conn, 'BEGIN')) { | ||
| 114 | - return false; | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - $this->handle = pg_lo_open($this->conn, $this->ID, $mode); | ||
| 118 | - if (!is_resource($this->handle)) { | ||
| 119 | - return false; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - // fetch size of lob | ||
| 123 | - pg_lo_seek($this->handle, 0, PGSQL_SEEK_END); | ||
| 124 | - $this->size = (int) pg_lo_tell($this->handle); | ||
| 125 | - pg_lo_seek($this->handle, 0, PGSQL_SEEK_SET); | ||
| 126 | - | ||
| 127 | - return true; | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - function stream_read($length) | ||
| 131 | - { | ||
| 132 | - return pg_lo_read($this->handle, $length); | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - function stream_seek($offset, $whence = SEEK_SET) | ||
| 136 | - { | ||
| 137 | - return pg_lo_seek($this->handle, $offset, $whence); | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - function stream_tell() | ||
| 141 | - { | ||
| 142 | - return pg_lo_tell($this->handle); | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - function stream_eof() | ||
| 146 | - { | ||
| 147 | - return pg_lo_tell($this->handle) >= $this->size; | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - function stream_flush() | ||
| 151 | - { | ||
| 152 | - return true; | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - function stream_stat() | ||
| 156 | - { | ||
| 157 | - return array('size' => $this->size, 'ino' => $this->ID); | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - function stream_write($data) | ||
| 161 | - { | ||
| 162 | - return pg_lo_write($this->handle, $data); | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - function stream_close() | ||
| 166 | - { | ||
| 167 | - if (pg_lo_close($this->handle)) { | ||
| 168 | - return pg_query($this->conn, 'COMMIT'); | ||
| 169 | - } else { | ||
| 170 | - pg_query($this->conn ,'ROLLBACK'); | ||
| 171 | - return false; | ||
| 172 | - } | ||
| 173 | - } | ||
| 174 | - /**#@-*/ | ||
| 175 | -} | ||
| 176 | - | ||
| 177 | -?> | 1 | +<?php |
| 2 | +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * HTTP::Download::PgLOB | ||
| 6 | + * | ||
| 7 | + * PHP versions 4 and 5 | ||
| 8 | + * | ||
| 9 | + * @category HTTP | ||
| 10 | + * @package HTTP_Download | ||
| 11 | + * @author Michael Wallner <mike@php.net> | ||
| 12 | + * @copyright 2003-2005 Michael Wallner | ||
| 13 | + * @license BSD, revised | ||
| 14 | + * @version CVS: $Id$ | ||
| 15 | + * @link http://pear.php.net/package/HTTP_Download | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +$GLOBALS['_HTTP_Download_PgLOB_Connection'] = null; | ||
| 19 | +stream_register_wrapper('pglob', 'HTTP_Download_PgLOB'); | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * PgSQL large object stream interface for HTTP_Download | ||
| 23 | + * | ||
| 24 | + * Usage: | ||
| 25 | + * <code> | ||
| 26 | + * require_once 'HTTP/Download.php'; | ||
| 27 | + * require_once 'HTTP/Download/PgLOB.php'; | ||
| 28 | + * $db = &DB::connect('pgsql://user:pass@host/db'); | ||
| 29 | + * // or $db = pg_connect(...); | ||
| 30 | + * $lo = HTTP_Download_PgLOB::open($db, 12345); | ||
| 31 | + * $dl = &new HTTP_Download; | ||
| 32 | + * $dl->setResource($lo); | ||
| 33 | + * $dl->send() | ||
| 34 | + * </code> | ||
| 35 | + * | ||
| 36 | + * @access public | ||
| 37 | + * @version $Revision$ | ||
| 38 | + */ | ||
| 39 | +class HTTP_Download_PgLOB | ||
| 40 | +{ | ||
| 41 | + /** | ||
| 42 | + * Set Connection | ||
| 43 | + * | ||
| 44 | + * @static | ||
| 45 | + * @access public | ||
| 46 | + * @return bool | ||
| 47 | + * @param mixed $conn | ||
| 48 | + */ | ||
| 49 | + function setConnection($conn) | ||
| 50 | + { | ||
| 51 | + if (is_a($conn, 'DB_Common')) { | ||
| 52 | + $conn = $conn->dbh; | ||
| 53 | + } elseif ( is_a($conn, 'MDB_Common') || | ||
| 54 | + is_a($conn, 'MDB2_Driver_Common')) { | ||
| 55 | + $conn = $conn->connection; | ||
| 56 | + } | ||
| 57 | + if ($isResource = is_resource($conn)) { | ||
| 58 | + $GLOBALS['_HTTP_Download_PgLOB_Connection'] = $conn; | ||
| 59 | + } | ||
| 60 | + return $isResource; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * Get Connection | ||
| 65 | + * | ||
| 66 | + * @static | ||
| 67 | + * @access public | ||
| 68 | + * @return resource | ||
| 69 | + */ | ||
| 70 | + function getConnection() | ||
| 71 | + { | ||
| 72 | + if (is_resource($GLOBALS['_HTTP_Download_PgLOB_Connection'])) { | ||
| 73 | + return $GLOBALS['_HTTP_Download_PgLOB_Connection']; | ||
| 74 | + } | ||
| 75 | + return null; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * Open | ||
| 80 | + * | ||
| 81 | + * @static | ||
| 82 | + * @access public | ||
| 83 | + * @return resource | ||
| 84 | + * @param mixed $conn | ||
| 85 | + * @param int $loid | ||
| 86 | + * @param string $mode | ||
| 87 | + */ | ||
| 88 | + function open($conn, $loid, $mode = 'rb') | ||
| 89 | + { | ||
| 90 | + HTTP_Download_PgLOB::setConnection($conn); | ||
| 91 | + return fopen('pglob:///'. $loid, $mode); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /**#@+ | ||
| 95 | + * Stream Interface Implementation | ||
| 96 | + * @internal | ||
| 97 | + */ | ||
| 98 | + var $ID = 0; | ||
| 99 | + var $size = 0; | ||
| 100 | + var $conn = null; | ||
| 101 | + var $handle = null; | ||
| 102 | + | ||
| 103 | + function stream_open($path, $mode) | ||
| 104 | + { | ||
| 105 | + if (!$this->conn = HTTP_Download_PgLOB::getConnection()) { | ||
| 106 | + return false; | ||
| 107 | + } | ||
| 108 | + if (!preg_match('/(\d+)/', $path, $matches)) { | ||
| 109 | + return false; | ||
| 110 | + } | ||
| 111 | + $this->ID = $matches[1]; | ||
| 112 | + | ||
| 113 | + if (!pg_query($this->conn, 'BEGIN')) { | ||
| 114 | + return false; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + $this->handle = pg_lo_open($this->conn, $this->ID, $mode); | ||
| 118 | + if (!is_resource($this->handle)) { | ||
| 119 | + return false; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + // fetch size of lob | ||
| 123 | + pg_lo_seek($this->handle, 0, PGSQL_SEEK_END); | ||
| 124 | + $this->size = (int) pg_lo_tell($this->handle); | ||
| 125 | + pg_lo_seek($this->handle, 0, PGSQL_SEEK_SET); | ||
| 126 | + | ||
| 127 | + return true; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + function stream_read($length) | ||
| 131 | + { | ||
| 132 | + return pg_lo_read($this->handle, $length); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + function stream_seek($offset, $whence = SEEK_SET) | ||
| 136 | + { | ||
| 137 | + return pg_lo_seek($this->handle, $offset, $whence); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + function stream_tell() | ||
| 141 | + { | ||
| 142 | + return pg_lo_tell($this->handle); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + function stream_eof() | ||
| 146 | + { | ||
| 147 | + return pg_lo_tell($this->handle) >= $this->size; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + function stream_flush() | ||
| 151 | + { | ||
| 152 | + return true; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + function stream_stat() | ||
| 156 | + { | ||
| 157 | + return array('size' => $this->size, 'ino' => $this->ID); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + function stream_write($data) | ||
| 161 | + { | ||
| 162 | + return pg_lo_write($this->handle, $data); | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + function stream_close() | ||
| 166 | + { | ||
| 167 | + if (pg_lo_close($this->handle)) { | ||
| 168 | + return pg_query($this->conn, 'COMMIT'); | ||
| 169 | + } else { | ||
| 170 | + pg_query($this->conn ,'ROLLBACK'); | ||
| 171 | + return false; | ||
| 172 | + } | ||
| 173 | + } | ||
| 174 | + /**#@-*/ | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +?> |
thirdparty/pear/HTTP/Header.php
| 1 | -<?php | ||
| 2 | -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | - | ||
| 4 | -/** | ||
| 5 | - * HTTP::Header | ||
| 6 | - * | ||
| 7 | - * PHP versions 4 and 5 | ||
| 8 | - * | ||
| 9 | - * @category HTTP | ||
| 10 | - * @package HTTP_Header | ||
| 11 | - * @author Wolfram Kriesing <wk@visionp.de> | ||
| 12 | - * @author Davey Shafik <davey@php.net> | ||
| 13 | - * @author Michael Wallner <mike@php.net> | ||
| 14 | - * @copyright 2003-2005 The Authors | ||
| 15 | - * @license BSD, revised | ||
| 16 | - * @version CVS: $Id: Header.php,v 1.32 2005/11/08 19:06:10 mike Exp $ | ||
| 17 | - * @link http://pear.php.net/package/HTTP_Header | ||
| 18 | - */ | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * Requires HTTP | ||
| 22 | - */ | ||
| 23 | -require_once 'HTTP.php'; | ||
| 24 | - | ||
| 25 | -/**#@+ | ||
| 26 | - * Information Codes | ||
| 27 | - */ | ||
| 28 | -define('HTTP_HEADER_STATUS_100', '100 Continue'); | ||
| 29 | -define('HTTP_HEADER_STATUS_101', '101 Switching Protocols'); | ||
| 30 | -define('HTTP_HEADER_STATUS_102', '102 Processing'); | ||
| 31 | -define('HTTP_HEADER_STATUS_INFORMATIONAL',1); | ||
| 32 | -/**#@-*/ | ||
| 33 | - | ||
| 34 | -/**#+ | ||
| 35 | - * Success Codes | ||
| 36 | - */ | ||
| 37 | -define('HTTP_HEADER_STATUS_200', '200 OK'); | ||
| 38 | -define('HTTP_HEADER_STATUS_201', '201 Created'); | ||
| 39 | -define('HTTP_HEADER_STATUS_202', '202 Accepted'); | ||
| 40 | -define('HTTP_HEADER_STATUS_203', '203 Non-Authoritative Information'); | ||
| 41 | -define('HTTP_HEADER_STATUS_204', '204 No Content'); | ||
| 42 | -define('HTTP_HEADER_STATUS_205', '205 Reset Content'); | ||
| 43 | -define('HTTP_HEADER_STATUS_206', '206 Partial Content'); | ||
| 44 | -define('HTTP_HEADER_STATUS_207', '207 Multi-Status'); | ||
| 45 | -define('HTTP_HEADER_STATUS_SUCCESSFUL',2); | ||
| 46 | -/**#@-*/ | ||
| 47 | - | ||
| 48 | -/**#@+ | ||
| 49 | - * Redirection Codes | ||
| 50 | - */ | ||
| 51 | -define('HTTP_HEADER_STATUS_300', '300 Multiple Choices'); | ||
| 52 | -define('HTTP_HEADER_STATUS_301', '301 Moved Permanently'); | ||
| 53 | -define('HTTP_HEADER_STATUS_302', '302 Found'); | ||
| 54 | -define('HTTP_HEADER_STATUS_303', '303 See Other'); | ||
| 55 | -define('HTTP_HEADER_STATUS_304', '304 Not Modified'); | ||
| 56 | -define('HTTP_HEADER_STATUS_305', '305 Use Proxy'); | ||
| 57 | -define('HTTP_HEADER_STATUS_306', '306 (Unused)'); | ||
| 58 | -define('HTTP_HEADER_STATUS_307', '307 Temporary Redirect'); | ||
| 59 | -define('HTTP_HEADER_STATUS_REDIRECT',3); | ||
| 60 | -/**#@-*/ | ||
| 61 | - | ||
| 62 | -/**#@+ | ||
| 63 | - * Error Codes | ||
| 64 | - */ | ||
| 65 | -define('HTTP_HEADER_STATUS_400', '400 Bad Request'); | ||
| 66 | -define('HTTP_HEADER_STATUS_401', '401 Unauthorized'); | ||
| 67 | -define('HTTP_HEADER_STATUS_402', '402 Payment Granted'); | ||
| 68 | -define('HTTP_HEADER_STATUS_403', '403 Forbidden'); | ||
| 69 | -define('HTTP_HEADER_STATUS_404', '404 File Not Found'); | ||
| 70 | -define('HTTP_HEADER_STATUS_405', '405 Method Not Allowed'); | ||
| 71 | -define('HTTP_HEADER_STATUS_406', '406 Not Acceptable'); | ||
| 72 | -define('HTTP_HEADER_STATUS_407', '407 Proxy Authentication Required'); | ||
| 73 | -define('HTTP_HEADER_STATUS_408', '408 Request Time-out'); | ||
| 74 | -define('HTTP_HEADER_STATUS_409', '409 Conflict'); | ||
| 75 | -define('HTTP_HEADER_STATUS_410', '410 Gone'); | ||
| 76 | -define('HTTP_HEADER_STATUS_411', '411 Length Required'); | ||
| 77 | -define('HTTP_HEADER_STATUS_412', '412 Precondition Failed'); | ||
| 78 | -define('HTTP_HEADER_STATUS_413', '413 Request Entity Too Large'); | ||
| 79 | -define('HTTP_HEADER_STATUS_414', '414 Request-URI Too Large'); | ||
| 80 | -define('HTTP_HEADER_STATUS_415', '415 Unsupported Media Type'); | ||
| 81 | -define('HTTP_HEADER_STATUS_416', '416 Requested range not satisfiable'); | ||
| 82 | -define('HTTP_HEADER_STATUS_417', '417 Expectation Failed'); | ||
| 83 | -define('HTTP_HEADER_STATUS_422', '422 Unprocessable Entity'); | ||
| 84 | -define('HTTP_HEADER_STATUS_423', '423 Locked'); | ||
| 85 | -define('HTTP_HEADER_STATUS_424', '424 Failed Dependency'); | ||
| 86 | -define('HTTP_HEADER_STATUS_CLIENT_ERROR',4); | ||
| 87 | -/**#@-*/ | ||
| 88 | - | ||
| 89 | -/**#@+ | ||
| 90 | - * Server Errors | ||
| 91 | - */ | ||
| 92 | -define('HTTP_HEADER_STATUS_500', '500 Internal Server Error'); | ||
| 93 | -define('HTTP_HEADER_STATUS_501', '501 Not Implemented'); | ||
| 94 | -define('HTTP_HEADER_STATUS_502', '502 Bad Gateway'); | ||
| 95 | -define('HTTP_HEADER_STATUS_503', '503 Service Unavailable'); | ||
| 96 | -define('HTTP_HEADER_STATUS_504', '504 Gateway Time-out'); | ||
| 97 | -define('HTTP_HEADER_STATUS_505', '505 HTTP Version not supported'); | ||
| 98 | -define('HTTP_HEADER_STATUS_507', '507 Insufficient Storage'); | ||
| 99 | -define('HTTP_HEADER_STATUS_SERVER_ERROR',5); | ||
| 100 | -/**#@-*/ | ||
| 101 | - | ||
| 102 | -/** | ||
| 103 | - * HTTP_Header | ||
| 104 | - * | ||
| 105 | - * @package HTTP_Header | ||
| 106 | - * @category HTTP | ||
| 107 | - * @access public | ||
| 108 | - * @version $Revision: 1.32 $ | ||
| 109 | - */ | ||
| 110 | -class HTTP_Header extends HTTP | ||
| 111 | -{ | ||
| 112 | - /** | ||
| 113 | - * Default Headers | ||
| 114 | - * | ||
| 115 | - * The values that are set as default, are the same as PHP sends by default. | ||
| 116 | - * | ||
| 117 | - * @var array | ||
| 118 | - * @access private | ||
| 119 | - */ | ||
| 120 | - var $_headers = array( | ||
| 121 | - 'content-type' => 'text/html', | ||
| 122 | - 'pragma' => 'no-cache', | ||
| 123 | - 'cache-control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' | ||
| 124 | - ); | ||
| 125 | - | ||
| 126 | - /** | ||
| 127 | - * HTTP version | ||
| 128 | - * | ||
| 129 | - * @var string | ||
| 130 | - * @access private | ||
| 131 | - */ | ||
| 132 | - var $_httpVersion = '1.0'; | ||
| 133 | - | ||
| 134 | - /** | ||
| 135 | - * Constructor | ||
| 136 | - * | ||
| 137 | - * Sets HTTP version. | ||
| 138 | - * | ||
| 139 | - * @access public | ||
| 140 | - * @return object HTTP_Header | ||
| 141 | - */ | ||
| 142 | - function HTTP_Header() | ||
| 143 | - { | ||
| 144 | - if (isset($_SERVER['SERVER_PROTOCOL'])) { | ||
| 145 | - $this->setHttpVersion(substr($_SERVER['SERVER_PROTOCOL'], -3)); | ||
| 146 | - } | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - /** | ||
| 150 | - * Set HTTP version | ||
| 151 | - * | ||
| 152 | - * @access public | ||
| 153 | - * @return bool Returns true on success or false if version doesn't | ||
| 154 | - * match 1.0 or 1.1 (note: 1 will result in 1.0) | ||
| 155 | - * @param mixed $version HTTP version, either 1.0 or 1.1 | ||
| 156 | - */ | ||
| 157 | - function setHttpVersion($version) | ||
| 158 | - { | ||
| 159 | - $version = round((float) $version, 1); | ||
| 160 | - if ($version < 1.0 || $version > 1.1) { | ||
| 161 | - return false; | ||
| 162 | - } | ||
| 163 | - $this->_httpVersion = sprintf('%0.1f', $version); | ||
| 164 | - return true; | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - /** | ||
| 168 | - * Get HTTP version | ||
| 169 | - * | ||
| 170 | - * @access public | ||
| 171 | - * @return string | ||
| 172 | - */ | ||
| 173 | - function getHttpVersion() | ||
| 174 | - { | ||
| 175 | - return $this->_httpVersion; | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - /** | ||
| 179 | - * Set Header | ||
| 180 | - * | ||
| 181 | - * The default value for the Last-Modified header will be current | ||
| 182 | - * date and atime if $value is omitted. | ||
| 183 | - * | ||
| 184 | - * @access public | ||
| 185 | - * @return bool Returns true on success or false if $key was empty or | ||
| 186 | - * $value was not of an scalar type. | ||
| 187 | - * @param string $key The name of the header. | ||
| 188 | - * @param string $value The value of the header. (NULL to unset header) | ||
| 189 | - */ | ||
| 190 | - function setHeader($key, $value = null) | ||
| 191 | - { | ||
| 192 | - if (empty($key) || (isset($value) && !is_scalar($value))) { | ||
| 193 | - return false; | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - $key = strToLower($key); | ||
| 197 | - if ($key == 'last-modified') { | ||
| 198 | - if (!isset($value)) { | ||
| 199 | - $value = HTTP::Date(time()); | ||
| 200 | - } elseif (is_numeric($value)) { | ||
| 201 | - $value = HTTP::Date($value); | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - if (isset($value)) { | ||
| 206 | - $this->_headers[$key] = $value; | ||
| 207 | - } else { | ||
| 208 | - unset($this->_headers[$key]); | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - return true; | ||
| 212 | - } | ||
| 213 | - | ||
| 214 | - /** | ||
| 215 | - * Get Header | ||
| 216 | - * | ||
| 217 | - * If $key is omitted, all stored headers will be returned. | ||
| 218 | - * | ||
| 219 | - * @access public | ||
| 220 | - * @return mixed Returns string value of the requested header, | ||
| 221 | - * array values of all headers or false if header $key | ||
| 222 | - * is not set. | ||
| 223 | - * @param string $key The name of the header to fetch. | ||
| 224 | - */ | ||
| 225 | - function getHeader($key = null) | ||
| 226 | - { | ||
| 227 | - if (!isset($key)) { | ||
| 228 | - return $this->_headers; | ||
| 229 | - } | ||
| 230 | - | ||
| 231 | - $key = strToLower($key); | ||
| 232 | - | ||
| 233 | - if (!isset($this->_headers[$key])) { | ||
| 234 | - return false; | ||
| 235 | - } | ||
| 236 | - | ||
| 237 | - return $this->_headers[$key]; | ||
| 238 | - } | ||
| 239 | - | ||
| 240 | - /** | ||
| 241 | - * Send Headers | ||
| 242 | - * | ||
| 243 | - * Send out the header that you set via setHeader(). | ||
| 244 | - * | ||
| 245 | - * @access public | ||
| 246 | - * @return bool Returns true on success or false if headers are already | ||
| 247 | - * sent. | ||
| 248 | - * @param array $keys Headers to (not) send, see $include. | ||
| 249 | - * @param array $include If true only $keys matching headers will be | ||
| 250 | - * sent, if false only header not matching $keys will be | ||
| 251 | - * sent. | ||
| 252 | - */ | ||
| 253 | - function sendHeaders($keys = array(), $include = true) | ||
| 254 | - { | ||
| 255 | - if (headers_sent()) { | ||
| 256 | - return false; | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - if (count($keys)) { | ||
| 260 | - array_change_key_case($keys, CASE_LOWER); | ||
| 261 | - foreach ($this->_headers as $key => $value) { | ||
| 262 | - if ($include ? in_array($key, $keys) : !in_array($key, $keys)) { | ||
| 263 | - header($key .': '. $value); | ||
| 264 | - } | ||
| 265 | - } | ||
| 266 | - } else { | ||
| 267 | - foreach ($this->_headers as $header => $value) { | ||
| 268 | - header($header .': '. $value); | ||
| 269 | - } | ||
| 270 | - } | ||
| 271 | - return true; | ||
| 272 | - } | ||
| 273 | - | ||
| 274 | - /** | ||
| 275 | - * Send Satus Code | ||
| 276 | - * | ||
| 277 | - * Send out the given HTTP-Status code. Use this for example when you | ||
| 278 | - * want to tell the client this page is cached, then you would call | ||
| 279 | - * sendStatusCode(304). | ||
| 280 | - * | ||
| 281 | - * @see HTTP_Header_Cache::exitIfCached() | ||
| 282 | - * | ||
| 283 | - * @access public | ||
| 284 | - * @return bool Returns true on success or false if headers are already | ||
| 285 | - * sent. | ||
| 286 | - * @param int $code The status code to send, i.e. 404, 304, 200, etc. | ||
| 287 | - */ | ||
| 288 | - function sendStatusCode($code) | ||
| 289 | - { | ||
| 290 | - if (headers_sent()) { | ||
| 291 | - return false; | ||
| 292 | - } | ||
| 293 | - | ||
| 294 | - if ($code == (int) $code && defined('HTTP_HEADER_STATUS_'. $code)) { | ||
| 295 | - $code = constant('HTTP_HEADER_STATUS_'. $code); | ||
| 296 | - } | ||
| 297 | - | ||
| 298 | - if (strncasecmp(PHP_SAPI, 'cgi', 3)) { | ||
| 299 | - header('HTTP/'. $this->_httpVersion .' '. $code); | ||
| 300 | - } else { | ||
| 301 | - header('Status: '. $code); | ||
| 302 | - } | ||
| 303 | - return true; | ||
| 304 | - } | ||
| 305 | - | ||
| 306 | - /** | ||
| 307 | - * Date to Timestamp | ||
| 308 | - * | ||
| 309 | - * Converts dates like | ||
| 310 | - * Mon, 31 Mar 2003 15:26:34 GMT | ||
| 311 | - * Tue, 15 Nov 1994 12:45:26 GMT | ||
| 312 | - * into a timestamp, strtotime() didn't do it in older versions. | ||
| 313 | - * | ||
| 314 | - * @deprecated Use PHPs strtotime() instead. | ||
| 315 | - * @access public | ||
| 316 | - * @return mixed Returns int unix timestamp or false if the date doesn't | ||
| 317 | - * seem to be a valid GMT date. | ||
| 318 | - * @param string $date The GMT date. | ||
| 319 | - */ | ||
| 320 | - function dateToTimestamp($date) | ||
| 321 | - { | ||
| 322 | - static $months = array( | ||
| 323 | - null => 0, 'Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4, | ||
| 324 | - 'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8, 'Sep' => 9, | ||
| 325 | - 'Oct' => 10, 'Nov' => 11, 'Dec' => 12 | ||
| 326 | - ); | ||
| 327 | - | ||
| 328 | - if (-1 < $timestamp = strToTime($date)) { | ||
| 329 | - return $timestamp; | ||
| 330 | - } | ||
| 331 | - | ||
| 332 | - if (!preg_match('~[^,]*,\s(\d+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+).*~', | ||
| 333 | - $date, $m)) { | ||
| 334 | - return false; | ||
| 335 | - } | ||
| 336 | - | ||
| 337 | - // [0] => Mon, 31 Mar 2003 15:42:55 GMT | ||
| 338 | - // [1] => 31 [2] => Mar [3] => 2003 [4] => 15 [5] => 42 [6] => 55 | ||
| 339 | - return mktime($m[4], $m[5], $m[6], $months[$m[2]], $m[1], $m[3]); | ||
| 340 | - } | ||
| 341 | - | ||
| 342 | - /** | ||
| 343 | - * Redirect | ||
| 344 | - * | ||
| 345 | - * This function redirects the client. This is done by issuing a Location | ||
| 346 | - * header and exiting. Additionally to HTTP::redirect() you can also add | ||
| 347 | - * parameters to the url. | ||
| 348 | - * | ||
| 349 | - * If you dont need parameters to be added, simply use HTTP::redirect() | ||
| 350 | - * otherwise use HTTP_Header::redirect(). | ||
| 351 | - * | ||
| 352 | - * @see HTTP::redirect() | ||
| 353 | - * @author Wolfram Kriesing <wk@visionp.de> | ||
| 354 | - * @access public | ||
| 355 | - * @return void | ||
| 356 | - * @param string $url The URL to redirect to, if none is given it | ||
| 357 | - * redirects to the current page. | ||
| 358 | - * @param array $param Array of query string parameters to add; usually | ||
| 359 | - * a set of key => value pairs; if an array entry consists | ||
| 360 | - * only of an value it is used as key and the respective | ||
| 361 | - * value is fetched from $GLOBALS[$value] | ||
| 362 | - * @param bool $session Whether the session name/id should be added | ||
| 363 | - */ | ||
| 364 | - function redirect($url = null, $param = array(), $session = false) | ||
| 365 | - { | ||
| 366 | - if (!isset($url)) { | ||
| 367 | - $url = $_SERVER['PHP_SELF']; | ||
| 368 | - } | ||
| 369 | - | ||
| 370 | - $qs = array(); | ||
| 371 | - | ||
| 372 | - if ($session) { | ||
| 373 | - $qs[] = session_name() .'='. session_id(); | ||
| 374 | - } | ||
| 375 | - | ||
| 376 | - if (is_array($param) && count($param)) { | ||
| 377 | - if (count($param)) { | ||
| 378 | - foreach ($param as $key => $val) { | ||
| 379 | - if (is_string($key)) { | ||
| 380 | - $qs[] = urlencode($key) .'='. urlencode($val); | ||
| 381 | - } else { | ||
| 382 | - $qs[] = urlencode($val) .'='. urlencode(@$GLOBALS[$val]); | ||
| 383 | - } | ||
| 384 | - } | ||
| 385 | - } | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | - if ($qstr = implode('&', $qs)) { | ||
| 389 | - $purl = parse_url($url); | ||
| 390 | - $url .= (isset($purl['query']) ? '&' : '?') . $qstr; | ||
| 391 | - } | ||
| 392 | - | ||
| 393 | - parent::redirect($url); | ||
| 394 | - } | ||
| 395 | - | ||
| 396 | - /**#@+ | ||
| 397 | - * @author Davey Shafik <davey@php.net> | ||
| 398 | - * @param int $http_code HTTP Code to check | ||
| 399 | - * @access public | ||
| 400 | - */ | ||
| 401 | - | ||
| 402 | - /** | ||
| 403 | - * Return HTTP Status Code Type | ||
| 404 | - * | ||
| 405 | - * @return int|false | ||
| 406 | - */ | ||
| 407 | - function getStatusType($http_code) | ||
| 408 | - { | ||
| 409 | - if(is_int($http_code) && defined('HTTP_HEADER_STATUS_' .$http_code) || defined($http_code)) { | ||
| 410 | - $type = substr($http_code,0,1); | ||
| 411 | - switch ($type) { | ||
| 412 | - case HTTP_HEADER_STATUS_INFORMATIONAL: | ||
| 413 | - case HTTP_HEADER_STATUS_SUCCESSFUL: | ||
| 414 | - case HTTP_HEADER_STATUS_REDIRECT: | ||
| 415 | - case HTTP_HEADER_STATUS_CLIENT_ERROR: | ||
| 416 | - case HTTP_HEADER_STATUS_SERVER_ERROR: | ||
| 417 | - return $type; | ||
| 418 | - break; | ||
| 419 | - default: | ||
| 420 | - return false; | ||
| 421 | - break; | ||
| 422 | - } | ||
| 423 | - } else { | ||
| 424 | - return false; | ||
| 425 | - } | ||
| 426 | - } | ||
| 427 | - | ||
| 428 | - /** | ||
| 429 | - * Return Status Code Message | ||
| 430 | - * | ||
| 431 | - * @return string|false | ||
| 432 | - */ | ||
| 433 | - function getStatusText($http_code) | ||
| 434 | - { | ||
| 435 | - if ($this->getStatusType($http_code)) { | ||
| 436 | - if (is_int($http_code) && defined('HTTP_HEADER_STATUS_' .$http_code)) { | ||
| 437 | - return substr(constant('HTTP_HEADER_STATUS_' .$http_code),4); | ||
| 438 | - } else { | ||
| 439 | - return substr($http_code,4); | ||
| 440 | - } | ||
| 441 | - } else { | ||
| 442 | - return false; | ||
| 443 | - } | ||
| 444 | - } | ||
| 445 | - | ||
| 446 | - /** | ||
| 447 | - * Checks if HTTP Status code is Information (1xx) | ||
| 448 | - * | ||
| 449 | - * @return boolean | ||
| 450 | - */ | ||
| 451 | - function isInformational($http_code) | ||
| 452 | - { | ||
| 453 | - if ($status_type = $this->getStatusType($http_code)) { | ||
| 454 | - return $status_type{0} == HTTP_HEADER_STATUS_INFORMATIONAL; | ||
| 455 | - } else { | ||
| 456 | - return false; | ||
| 457 | - } | ||
| 458 | - } | ||
| 459 | - | ||
| 460 | - /** | ||
| 461 | - * Checks if HTTP Status code is Successful (2xx) | ||
| 462 | - * | ||
| 463 | - * @return boolean | ||
| 464 | - */ | ||
| 465 | - function isSuccessful($http_code) | ||
| 466 | - { | ||
| 467 | - if ($status_type = $this->getStatusType($http_code)) { | ||
| 468 | - return $status_type{0} == HTTP_HEADER_STATUS_SUCCESSFUL; | ||
| 469 | - } else { | ||
| 470 | - return false; | ||
| 471 | - } | ||
| 472 | - } | ||
| 473 | - | ||
| 474 | - /** | ||
| 475 | - * Checks if HTTP Status code is a Redirect (3xx) | ||
| 476 | - * | ||
| 477 | - * @return boolean | ||
| 478 | - */ | ||
| 479 | - function isRedirect($http_code) | ||
| 480 | - { | ||
| 481 | - if ($status_type = $this->getStatusType($http_code)) { | ||
| 482 | - return $status_type{0} == HTTP_HEADER_STATUS_REDIRECT; | ||
| 483 | - } else { | ||
| 484 | - return false; | ||
| 485 | - } | ||
| 486 | - } | ||
| 487 | - | ||
| 488 | - /** | ||
| 489 | - * Checks if HTTP Status code is a Client Error (4xx) | ||
| 490 | - * | ||
| 491 | - * @return boolean | ||
| 492 | - */ | ||
| 493 | - function isClientError($http_code) | ||
| 494 | - { | ||
| 495 | - if ($status_type = $this->getStatusType($http_code)) { | ||
| 496 | - return $status_type{0} == HTTP_HEADER_STATUS_CLIENT_ERROR; | ||
| 497 | - } else { | ||
| 498 | - return false; | ||
| 499 | - } | ||
| 500 | - } | ||
| 501 | - | ||
| 502 | - /** | ||
| 503 | - * Checks if HTTP Status code is Server Error (5xx) | ||
| 504 | - * | ||
| 505 | - * @return boolean | ||
| 506 | - */ | ||
| 507 | - function isServerError($http_code) | ||
| 508 | - { | ||
| 509 | - if ($status_type = $this->getStatusType($http_code)) { | ||
| 510 | - return $status_type{0} == HTTP_HEADER_STATUS_SERVER_ERROR; | ||
| 511 | - } else { | ||
| 512 | - return false; | ||
| 513 | - } | ||
| 514 | - } | ||
| 515 | - | ||
| 516 | - /** | ||
| 517 | - * Checks if HTTP Status code is Server OR Client Error (4xx or 5xx) | ||
| 518 | - * | ||
| 519 | - * @return boolean | ||
| 520 | - */ | ||
| 521 | - function isError($http_code) | ||
| 522 | - { | ||
| 523 | - if ($status_type = $this->getStatusType($http_code)) { | ||
| 524 | - return (($status_type == HTTP_HEADER_STATUS_CLIENT_ERROR) || ($status_type == HTTP_HEADER_STATUS_SERVER_ERROR)) ? true : false; | ||
| 525 | - } else { | ||
| 526 | - return false; | ||
| 527 | - } | ||
| 528 | - } | ||
| 529 | - /**#@-*/ | ||
| 530 | -} | ||
| 531 | -?> | 1 | +<?php |
| 2 | +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * HTTP::Header | ||
| 6 | + * | ||
| 7 | + * PHP versions 4 and 5 | ||
| 8 | + * | ||
| 9 | + * @category HTTP | ||
| 10 | + * @package HTTP_Header | ||
| 11 | + * @author Wolfram Kriesing <wk@visionp.de> | ||
| 12 | + * @author Davey Shafik <davey@php.net> | ||
| 13 | + * @author Michael Wallner <mike@php.net> | ||
| 14 | + * @copyright 2003-2005 The Authors | ||
| 15 | + * @license BSD, revised | ||
| 16 | + * @version CVS: $Id$ | ||
| 17 | + * @link http://pear.php.net/package/HTTP_Header | ||
| 18 | + */ | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Requires HTTP | ||
| 22 | + */ | ||
| 23 | +require_once 'HTTP.php'; | ||
| 24 | + | ||
| 25 | +/**#@+ | ||
| 26 | + * Information Codes | ||
| 27 | + */ | ||
| 28 | +define('HTTP_HEADER_STATUS_100', '100 Continue'); | ||
| 29 | +define('HTTP_HEADER_STATUS_101', '101 Switching Protocols'); | ||
| 30 | +define('HTTP_HEADER_STATUS_102', '102 Processing'); | ||
| 31 | +define('HTTP_HEADER_STATUS_INFORMATIONAL',1); | ||
| 32 | +/**#@-*/ | ||
| 33 | + | ||
| 34 | +/**#+ | ||
| 35 | + * Success Codes | ||
| 36 | + */ | ||
| 37 | +define('HTTP_HEADER_STATUS_200', '200 OK'); | ||
| 38 | +define('HTTP_HEADER_STATUS_201', '201 Created'); | ||
| 39 | +define('HTTP_HEADER_STATUS_202', '202 Accepted'); | ||
| 40 | +define('HTTP_HEADER_STATUS_203', '203 Non-Authoritative Information'); | ||
| 41 | +define('HTTP_HEADER_STATUS_204', '204 No Content'); | ||
| 42 | +define('HTTP_HEADER_STATUS_205', '205 Reset Content'); | ||
| 43 | +define('HTTP_HEADER_STATUS_206', '206 Partial Content'); | ||
| 44 | +define('HTTP_HEADER_STATUS_207', '207 Multi-Status'); | ||
| 45 | +define('HTTP_HEADER_STATUS_SUCCESSFUL',2); | ||
| 46 | +/**#@-*/ | ||
| 47 | + | ||
| 48 | +/**#@+ | ||
| 49 | + * Redirection Codes | ||
| 50 | + */ | ||
| 51 | +define('HTTP_HEADER_STATUS_300', '300 Multiple Choices'); | ||
| 52 | +define('HTTP_HEADER_STATUS_301', '301 Moved Permanently'); | ||
| 53 | +define('HTTP_HEADER_STATUS_302', '302 Found'); | ||
| 54 | +define('HTTP_HEADER_STATUS_303', '303 See Other'); | ||
| 55 | +define('HTTP_HEADER_STATUS_304', '304 Not Modified'); | ||
| 56 | +define('HTTP_HEADER_STATUS_305', '305 Use Proxy'); | ||
| 57 | +define('HTTP_HEADER_STATUS_306', '306 (Unused)'); | ||
| 58 | +define('HTTP_HEADER_STATUS_307', '307 Temporary Redirect'); | ||
| 59 | +define('HTTP_HEADER_STATUS_REDIRECT',3); | ||
| 60 | +/**#@-*/ | ||
| 61 | + | ||
| 62 | +/**#@+ | ||
| 63 | + * Error Codes | ||
| 64 | + */ | ||
| 65 | +define('HTTP_HEADER_STATUS_400', '400 Bad Request'); | ||
| 66 | +define('HTTP_HEADER_STATUS_401', '401 Unauthorized'); | ||
| 67 | +define('HTTP_HEADER_STATUS_402', '402 Payment Granted'); | ||
| 68 | +define('HTTP_HEADER_STATUS_403', '403 Forbidden'); | ||
| 69 | +define('HTTP_HEADER_STATUS_404', '404 File Not Found'); | ||
| 70 | +define('HTTP_HEADER_STATUS_405', '405 Method Not Allowed'); | ||
| 71 | +define('HTTP_HEADER_STATUS_406', '406 Not Acceptable'); | ||
| 72 | +define('HTTP_HEADER_STATUS_407', '407 Proxy Authentication Required'); | ||
| 73 | +define('HTTP_HEADER_STATUS_408', '408 Request Time-out'); | ||
| 74 | +define('HTTP_HEADER_STATUS_409', '409 Conflict'); | ||
| 75 | +define('HTTP_HEADER_STATUS_410', '410 Gone'); | ||
| 76 | +define('HTTP_HEADER_STATUS_411', '411 Length Required'); | ||
| 77 | +define('HTTP_HEADER_STATUS_412', '412 Precondition Failed'); | ||
| 78 | +define('HTTP_HEADER_STATUS_413', '413 Request Entity Too Large'); | ||
| 79 | +define('HTTP_HEADER_STATUS_414', '414 Request-URI Too Large'); | ||
| 80 | +define('HTTP_HEADER_STATUS_415', '415 Unsupported Media Type'); | ||
| 81 | +define('HTTP_HEADER_STATUS_416', '416 Requested range not satisfiable'); | ||
| 82 | +define('HTTP_HEADER_STATUS_417', '417 Expectation Failed'); | ||
| 83 | +define('HTTP_HEADER_STATUS_422', '422 Unprocessable Entity'); | ||
| 84 | +define('HTTP_HEADER_STATUS_423', '423 Locked'); | ||
| 85 | +define('HTTP_HEADER_STATUS_424', '424 Failed Dependency'); | ||
| 86 | +define('HTTP_HEADER_STATUS_CLIENT_ERROR',4); | ||
| 87 | +/**#@-*/ | ||
| 88 | + | ||
| 89 | +/**#@+ | ||
| 90 | + * Server Errors | ||
| 91 | + */ | ||
| 92 | +define('HTTP_HEADER_STATUS_500', '500 Internal Server Error'); | ||
| 93 | +define('HTTP_HEADER_STATUS_501', '501 Not Implemented'); | ||
| 94 | +define('HTTP_HEADER_STATUS_502', '502 Bad Gateway'); | ||
| 95 | +define('HTTP_HEADER_STATUS_503', '503 Service Unavailable'); | ||
| 96 | +define('HTTP_HEADER_STATUS_504', '504 Gateway Time-out'); | ||
| 97 | +define('HTTP_HEADER_STATUS_505', '505 HTTP Version not supported'); | ||
| 98 | +define('HTTP_HEADER_STATUS_507', '507 Insufficient Storage'); | ||
| 99 | +define('HTTP_HEADER_STATUS_SERVER_ERROR',5); | ||
| 100 | +/**#@-*/ | ||
| 101 | + | ||
| 102 | +/** | ||
| 103 | + * HTTP_Header | ||
| 104 | + * | ||
| 105 | + * @package HTTP_Header | ||
| 106 | + * @category HTTP | ||
| 107 | + * @access public | ||
| 108 | + * @version $Revision$ | ||
| 109 | + */ | ||
| 110 | +class HTTP_Header extends HTTP | ||
| 111 | +{ | ||
| 112 | + /** | ||
| 113 | + * Default Headers | ||
| 114 | + * | ||
| 115 | + * The values that are set as default, are the same as PHP sends by default. | ||
| 116 | + * | ||
| 117 | + * @var array | ||
| 118 | + * @access private | ||
| 119 | + */ | ||
| 120 | + var $_headers = array( | ||
| 121 | + 'content-type' => 'text/html', | ||
| 122 | + 'pragma' => 'no-cache', | ||
| 123 | + 'cache-control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' | ||
| 124 | + ); | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * HTTP version | ||
| 128 | + * | ||
| 129 | + * @var string | ||
| 130 | + * @access private | ||
| 131 | + */ | ||
| 132 | + var $_httpVersion = '1.0'; | ||
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * Constructor | ||
| 136 | + * | ||
| 137 | + * Sets HTTP version. | ||
| 138 | + * | ||
| 139 | + * @access public | ||
| 140 | + * @return object HTTP_Header | ||
| 141 | + */ | ||
| 142 | + function HTTP_Header() | ||
| 143 | + { | ||
| 144 | + if (isset($_SERVER['SERVER_PROTOCOL'])) { | ||
| 145 | + $this->setHttpVersion(substr($_SERVER['SERVER_PROTOCOL'], -3)); | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * Set HTTP version | ||
| 151 | + * | ||
| 152 | + * @access public | ||
| 153 | + * @return bool Returns true on success or false if version doesn't | ||
| 154 | + * match 1.0 or 1.1 (note: 1 will result in 1.0) | ||
| 155 | + * @param mixed $version HTTP version, either 1.0 or 1.1 | ||
| 156 | + */ | ||
| 157 | + function setHttpVersion($version) | ||
| 158 | + { | ||
| 159 | + $version = round((float) $version, 1); | ||
| 160 | + if ($version < 1.0 || $version > 1.1) { | ||
| 161 | + return false; | ||
| 162 | + } | ||
| 163 | + $this->_httpVersion = sprintf('%0.1f', $version); | ||
| 164 | + return true; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * Get HTTP version | ||
| 169 | + * | ||
| 170 | + * @access public | ||
| 171 | + * @return string | ||
| 172 | + */ | ||
| 173 | + function getHttpVersion() | ||
| 174 | + { | ||
| 175 | + return $this->_httpVersion; | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + /** | ||
| 179 | + * Set Header | ||
| 180 | + * | ||
| 181 | + * The default value for the Last-Modified header will be current | ||
| 182 | + * date and atime if $value is omitted. | ||
| 183 | + * | ||
| 184 | + * @access public | ||
| 185 | + * @return bool Returns true on success or false if $key was empty or | ||
| 186 | + * $value was not of an scalar type. | ||
| 187 | + * @param string $key The name of the header. | ||
| 188 | + * @param string $value The value of the header. (NULL to unset header) | ||
| 189 | + */ | ||
| 190 | + function setHeader($key, $value = null) | ||
| 191 | + { | ||
| 192 | + if (empty($key) || (isset($value) && !is_scalar($value))) { | ||
| 193 | + return false; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + $key = strToLower($key); | ||
| 197 | + if ($key == 'last-modified') { | ||
| 198 | + if (!isset($value)) { | ||
| 199 | + $value = HTTP::Date(time()); | ||
| 200 | + } elseif (is_numeric($value)) { | ||
| 201 | + $value = HTTP::Date($value); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + if (isset($value)) { | ||
| 206 | + $this->_headers[$key] = $value; | ||
| 207 | + } else { | ||
| 208 | + unset($this->_headers[$key]); | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + return true; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * Get Header | ||
| 216 | + * | ||
| 217 | + * If $key is omitted, all stored headers will be returned. | ||
| 218 | + * | ||
| 219 | + * @access public | ||
| 220 | + * @return mixed Returns string value of the requested header, | ||
| 221 | + * array values of all headers or false if header $key | ||
| 222 | + * is not set. | ||
| 223 | + * @param string $key The name of the header to fetch. | ||
| 224 | + */ | ||
| 225 | + function getHeader($key = null) | ||
| 226 | + { | ||
| 227 | + if (!isset($key)) { | ||
| 228 | + return $this->_headers; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + $key = strToLower($key); | ||
| 232 | + | ||
| 233 | + if (!isset($this->_headers[$key])) { | ||
| 234 | + return false; | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + return $this->_headers[$key]; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + /** | ||
| 241 | + * Send Headers | ||
| 242 | + * | ||
| 243 | + * Send out the header that you set via setHeader(). | ||
| 244 | + * | ||
| 245 | + * @access public | ||
| 246 | + * @return bool Returns true on success or false if headers are already | ||
| 247 | + * sent. | ||
| 248 | + * @param array $keys Headers to (not) send, see $include. | ||
| 249 | + * @param array $include If true only $keys matching headers will be | ||
| 250 | + * sent, if false only header not matching $keys will be | ||
| 251 | + * sent. | ||
| 252 | + */ | ||
| 253 | + function sendHeaders($keys = array(), $include = true) | ||
| 254 | + { | ||
| 255 | + if (headers_sent()) { | ||
| 256 | + return false; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + if (count($keys)) { | ||
| 260 | + array_change_key_case($keys, CASE_LOWER); | ||
| 261 | + foreach ($this->_headers as $key => $value) { | ||
| 262 | + if ($include ? in_array($key, $keys) : !in_array($key, $keys)) { | ||
| 263 | + header($key .': '. $value); | ||
| 264 | + } | ||
| 265 | + } | ||
| 266 | + } else { | ||
| 267 | + foreach ($this->_headers as $header => $value) { | ||
| 268 | + header($header .': '. $value); | ||
| 269 | + } | ||
| 270 | + } | ||
| 271 | + return true; | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + /** | ||
| 275 | + * Send Satus Code | ||
| 276 | + * | ||
| 277 | + * Send out the given HTTP-Status code. Use this for example when you | ||
| 278 | + * want to tell the client this page is cached, then you would call | ||
| 279 | + * sendStatusCode(304). | ||
| 280 | + * | ||
| 281 | + * @see HTTP_Header_Cache::exitIfCached() | ||
| 282 | + * | ||
| 283 | + * @access public | ||
| 284 | + * @return bool Returns true on success or false if headers are already | ||
| 285 | + * sent. | ||
| 286 | + * @param int $code The status code to send, i.e. 404, 304, 200, etc. | ||
| 287 | + */ | ||
| 288 | + function sendStatusCode($code) | ||
| 289 | + { | ||
| 290 | + if (headers_sent()) { | ||
| 291 | + return false; | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + if ($code == (int) $code && defined('HTTP_HEADER_STATUS_'. $code)) { | ||
| 295 | + $code = constant('HTTP_HEADER_STATUS_'. $code); | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + if (strncasecmp(PHP_SAPI, 'cgi', 3)) { | ||
| 299 | + header('HTTP/'. $this->_httpVersion .' '. $code); | ||
| 300 | + } else { | ||
| 301 | + header('Status: '. $code); | ||
| 302 | + } | ||
| 303 | + return true; | ||
| 304 | + } | ||
| 305 | + | ||
| 306 | + /** | ||
| 307 | + * Date to Timestamp | ||
| 308 | + * | ||
| 309 | + * Converts dates like | ||
| 310 | + * Mon, 31 Mar 2003 15:26:34 GMT | ||
| 311 | + * Tue, 15 Nov 1994 12:45:26 GMT | ||
| 312 | + * into a timestamp, strtotime() didn't do it in older versions. | ||
| 313 | + * | ||
| 314 | + * @deprecated Use PHPs strtotime() instead. | ||
| 315 | + * @access public | ||
| 316 | + * @return mixed Returns int unix timestamp or false if the date doesn't | ||
| 317 | + * seem to be a valid GMT date. | ||
| 318 | + * @param string $date The GMT date. | ||
| 319 | + */ | ||
| 320 | + function dateToTimestamp($date) | ||
| 321 | + { | ||
| 322 | + static $months = array( | ||
| 323 | + null => 0, 'Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4, | ||
| 324 | + 'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8, 'Sep' => 9, | ||
| 325 | + 'Oct' => 10, 'Nov' => 11, 'Dec' => 12 | ||
| 326 | + ); | ||
| 327 | + | ||
| 328 | + if (-1 < $timestamp = strToTime($date)) { | ||
| 329 | + return $timestamp; | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + if (!preg_match('~[^,]*,\s(\d+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+).*~', | ||
| 333 | + $date, $m)) { | ||
| 334 | + return false; | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + // [0] => Mon, 31 Mar 2003 15:42:55 GMT | ||
| 338 | + // [1] => 31 [2] => Mar [3] => 2003 [4] => 15 [5] => 42 [6] => 55 | ||
| 339 | + return mktime($m[4], $m[5], $m[6], $months[$m[2]], $m[1], $m[3]); | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + /** | ||
| 343 | + * Redirect | ||
| 344 | + * | ||
| 345 | + * This function redirects the client. This is done by issuing a Location | ||
| 346 | + * header and exiting. Additionally to HTTP::redirect() you can also add | ||
| 347 | + * parameters to the url. | ||
| 348 | + * | ||
| 349 | + * If you dont need parameters to be added, simply use HTTP::redirect() | ||
| 350 | + * otherwise use HTTP_Header::redirect(). | ||
| 351 | + * | ||
| 352 | + * @see HTTP::redirect() | ||
| 353 | + * @author Wolfram Kriesing <wk@visionp.de> | ||
| 354 | + * @access public | ||
| 355 | + * @return void | ||
| 356 | + * @param string $url The URL to redirect to, if none is given it | ||
| 357 | + * redirects to the current page. | ||
| 358 | + * @param array $param Array of query string parameters to add; usually | ||
| 359 | + * a set of key => value pairs; if an array entry consists | ||
| 360 | + * only of an value it is used as key and the respective | ||
| 361 | + * value is fetched from $GLOBALS[$value] | ||
| 362 | + * @param bool $session Whether the session name/id should be added | ||
| 363 | + */ | ||
| 364 | + function redirect($url = null, $param = array(), $session = false) | ||
| 365 | + { | ||
| 366 | + if (!isset($url)) { | ||
| 367 | + $url = $_SERVER['PHP_SELF']; | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + $qs = array(); | ||
| 371 | + | ||
| 372 | + if ($session) { | ||
| 373 | + $qs[] = session_name() .'='. session_id(); | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + if (is_array($param) && count($param)) { | ||
| 377 | + if (count($param)) { | ||
| 378 | + foreach ($param as $key => $val) { | ||
| 379 | + if (is_string($key)) { | ||
| 380 | + $qs[] = urlencode($key) .'='. urlencode($val); | ||
| 381 | + } else { | ||
| 382 | + $qs[] = urlencode($val) .'='. urlencode(@$GLOBALS[$val]); | ||
| 383 | + } | ||
| 384 | + } | ||
| 385 | + } | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + if ($qstr = implode('&', $qs)) { | ||
| 389 | + $purl = parse_url($url); | ||
| 390 | + $url .= (isset($purl['query']) ? '&' : '?') . $qstr; | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + parent::redirect($url); | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + /**#@+ | ||
| 397 | + * @author Davey Shafik <davey@php.net> | ||
| 398 | + * @param int $http_code HTTP Code to check | ||
| 399 | + * @access public | ||
| 400 | + */ | ||
| 401 | + | ||
| 402 | + /** | ||
| 403 | + * Return HTTP Status Code Type | ||
| 404 | + * | ||
| 405 | + * @return int|false | ||
| 406 | + */ | ||
| 407 | + function getStatusType($http_code) | ||
| 408 | + { | ||
| 409 | + if(is_int($http_code) && defined('HTTP_HEADER_STATUS_' .$http_code) || defined($http_code)) { | ||
| 410 | + $type = substr($http_code,0,1); | ||
| 411 | + switch ($type) { | ||
| 412 | + case HTTP_HEADER_STATUS_INFORMATIONAL: | ||
| 413 | + case HTTP_HEADER_STATUS_SUCCESSFUL: | ||
| 414 | + case HTTP_HEADER_STATUS_REDIRECT: | ||
| 415 | + case HTTP_HEADER_STATUS_CLIENT_ERROR: | ||
| 416 | + case HTTP_HEADER_STATUS_SERVER_ERROR: | ||
| 417 | + return $type; | ||
| 418 | + break; | ||
| 419 | + default: | ||
| 420 | + return false; | ||
| 421 | + break; | ||
| 422 | + } | ||
| 423 | + } else { | ||
| 424 | + return false; | ||
| 425 | + } | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + /** | ||
| 429 | + * Return Status Code Message | ||
| 430 | + * | ||
| 431 | + * @return string|false | ||
| 432 | + */ | ||
| 433 | + function getStatusText($http_code) | ||
| 434 | + { | ||
| 435 | + if ($this->getStatusType($http_code)) { | ||
| 436 | + if (is_int($http_code) && defined('HTTP_HEADER_STATUS_' .$http_code)) { | ||
| 437 | + return substr(constant('HTTP_HEADER_STATUS_' .$http_code),4); | ||
| 438 | + } else { | ||
| 439 | + return substr($http_code,4); | ||
| 440 | + } | ||
| 441 | + } else { | ||
| 442 | + return false; | ||
| 443 | + } | ||
| 444 | + } | ||
| 445 | + | ||
| 446 | + /** | ||
| 447 | + * Checks if HTTP Status code is Information (1xx) | ||
| 448 | + * | ||
| 449 | + * @return boolean | ||
| 450 | + */ | ||
| 451 | + function isInformational($http_code) | ||
| 452 | + { | ||
| 453 | + if ($status_type = $this->getStatusType($http_code)) { | ||
| 454 | + return $status_type{0} == HTTP_HEADER_STATUS_INFORMATIONAL; | ||
| 455 | + } else { | ||
| 456 | + return false; | ||
| 457 | + } | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + /** | ||
| 461 | + * Checks if HTTP Status code is Successful (2xx) | ||
| 462 | + * | ||
| 463 | + * @return boolean | ||
| 464 | + */ | ||
| 465 | + function isSuccessful($http_code) | ||
| 466 | + { | ||
| 467 | + if ($status_type = $this->getStatusType($http_code)) { | ||
| 468 | + return $status_type{0} == HTTP_HEADER_STATUS_SUCCESSFUL; | ||
| 469 | + } else { | ||
| 470 | + return false; | ||
| 471 | + } | ||
| 472 | + } | ||
| 473 | + | ||
| 474 | + /** | ||
| 475 | + * Checks if HTTP Status code is a Redirect (3xx) | ||
| 476 | + * | ||
| 477 | + * @return boolean | ||
| 478 | + */ | ||
| 479 | + function isRedirect($http_code) | ||
| 480 | + { | ||
| 481 | + if ($status_type = $this->getStatusType($http_code)) { | ||
| 482 | + return $status_type{0} == HTTP_HEADER_STATUS_REDIRECT; | ||
| 483 | + } else { | ||
| 484 | + return false; | ||
| 485 | + } | ||
| 486 | + } | ||
| 487 | + | ||
| 488 | + /** | ||
| 489 | + * Checks if HTTP Status code is a Client Error (4xx) | ||
| 490 | + * | ||
| 491 | + * @return boolean | ||
| 492 | + */ | ||
| 493 | + function isClientError($http_code) | ||
| 494 | + { | ||
| 495 | + if ($status_type = $this->getStatusType($http_code)) { | ||
| 496 | + return $status_type{0} == HTTP_HEADER_STATUS_CLIENT_ERROR; | ||
| 497 | + } else { | ||
| 498 | + return false; | ||
| 499 | + } | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + /** | ||
| 503 | + * Checks if HTTP Status code is Server Error (5xx) | ||
| 504 | + * | ||
| 505 | + * @return boolean | ||
| 506 | + */ | ||
| 507 | + function isServerError($http_code) | ||
| 508 | + { | ||
| 509 | + if ($status_type = $this->getStatusType($http_code)) { | ||
| 510 | + return $status_type{0} == HTTP_HEADER_STATUS_SERVER_ERROR; | ||
| 511 | + } else { | ||
| 512 | + return false; | ||
| 513 | + } | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + /** | ||
| 517 | + * Checks if HTTP Status code is Server OR Client Error (4xx or 5xx) | ||
| 518 | + * | ||
| 519 | + * @return boolean | ||
| 520 | + */ | ||
| 521 | + function isError($http_code) | ||
| 522 | + { | ||
| 523 | + if ($status_type = $this->getStatusType($http_code)) { | ||
| 524 | + return (($status_type == HTTP_HEADER_STATUS_CLIENT_ERROR) || ($status_type == HTTP_HEADER_STATUS_SERVER_ERROR)) ? true : false; | ||
| 525 | + } else { | ||
| 526 | + return false; | ||
| 527 | + } | ||
| 528 | + } | ||
| 529 | + /**#@-*/ | ||
| 530 | +} | ||
| 531 | +?> |
thirdparty/pear/HTTP/Header/Cache.php
| 1 | -<?php | ||
| 2 | -/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | - | ||
| 4 | -/** | ||
| 5 | - * HTTP::Header::Cache | ||
| 6 | - * | ||
| 7 | - * PHP versions 4 and 5 | ||
| 8 | - * | ||
| 9 | - * @category HTTP | ||
| 10 | - * @package HTTP_Header | ||
| 11 | - * @author Wolfram Kriesing <wk@visionp.de> | ||
| 12 | - * @author Michael Wallner <mike@php.net> | ||
| 13 | - * @copyright 2003-2005 The Authors | ||
| 14 | - * @license BSD, revised | ||
| 15 | - * @version CVS: $Id: Cache.php,v 1.24 2005/11/08 19:06:14 mike Exp $ | ||
| 16 | - * @link http://pear.php.net/package/HTTP_Header | ||
| 17 | - */ | ||
| 18 | - | ||
| 19 | -/** | ||
| 20 | - * Requires HTTP_Header | ||
| 21 | - */ | ||
| 22 | -require_once 'HTTP/Header.php'; | ||
| 23 | - | ||
| 24 | -/** | ||
| 25 | - * HTTP_Header_Cache | ||
| 26 | - * | ||
| 27 | - * This package provides methods to easier handle caching of HTTP pages. That | ||
| 28 | - * means that the pages can be cached at the client (user agent or browser) and | ||
| 29 | - * your application only needs to send "hey client you already have the pages". | ||
| 30 | - * | ||
| 31 | - * Which is done by sending the HTTP-Status "304 Not Modified", so that your | ||
| 32 | - * application load and the network traffic can be reduced, since you only need | ||
| 33 | - * to send the complete page once. This is really an advantage e.g. for | ||
| 34 | - * generated style sheets, or simply pages that do only change rarely. | ||
| 35 | - * | ||
| 36 | - * Usage: | ||
| 37 | - * <code> | ||
| 38 | - * require_once 'HTTP/Header/Cache.php'; | ||
| 39 | - * $httpCache = new HTTP_Header_Cache(4, 'weeks'); | ||
| 40 | - * $httpCache->sendHeaders(); | ||
| 41 | - * // your code goes here | ||
| 42 | - * </code> | ||
| 43 | - * | ||
| 44 | - * @package HTTP_Header | ||
| 45 | - * @category HTTP | ||
| 46 | - * @access public | ||
| 47 | - * @version $Revision: 1.24 $ | ||
| 48 | - */ | ||
| 49 | -class HTTP_Header_Cache extends HTTP_Header | ||
| 50 | -{ | ||
| 51 | - /** | ||
| 52 | - * Constructor | ||
| 53 | - * | ||
| 54 | - * Set the amount of time to cache. | ||
| 55 | - * | ||
| 56 | - * @access public | ||
| 57 | - * @return object HTTP_Header_Cache | ||
| 58 | - * @param int $expires | ||
| 59 | - * @param string $unit | ||
| 60 | - */ | ||
| 61 | - function HTTP_Header_Cache($expires = 0, $unit = 'seconds') | ||
| 62 | - { | ||
| 63 | - parent::HTTP_Header(); | ||
| 64 | - $this->setHeader('Pragma', 'cache'); | ||
| 65 | - $this->setHeader('Last-Modified', $this->getCacheStart()); | ||
| 66 | - $this->setHeader('Cache-Control', 'private, must-revalidate, max-age=0'); | ||
| 67 | - | ||
| 68 | - if ($expires) { | ||
| 69 | - if (!$this->isOlderThan($expires, $unit)) { | ||
| 70 | - $this->exitCached(); | ||
| 71 | - } | ||
| 72 | - $this->setHeader('Last-Modified', time()); | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - /** | ||
| 77 | - * Get Cache Start | ||
| 78 | - * | ||
| 79 | - * Returns the unix timestamp of the If-Modified-Since HTTP header or the | ||
| 80 | - * current time if the header was not sent by the client. | ||
| 81 | - * | ||
| 82 | - * @access public | ||
| 83 | - * @return int unix timestamp | ||
| 84 | - */ | ||
| 85 | - function getCacheStart() | ||
| 86 | - { | ||
| 87 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && !$this->isPost()) { | ||
| 88 | - return strtotime(current($array = explode(';', | ||
| 89 | - $_SERVER['HTTP_IF_MODIFIED_SINCE']))); | ||
| 90 | - } | ||
| 91 | - return time(); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - /** | ||
| 95 | - * Is Older Than | ||
| 96 | - * | ||
| 97 | - * You can call it like this: | ||
| 98 | - * <code> | ||
| 99 | - * $httpCache->isOlderThan(1, 'day'); | ||
| 100 | - * $httpCache->isOlderThan(47, 'days'); | ||
| 101 | - * | ||
| 102 | - * $httpCache->isOlderThan(1, 'week'); | ||
| 103 | - * $httpCache->isOlderThan(3, 'weeks'); | ||
| 104 | - * | ||
| 105 | - * $httpCache->isOlderThan(1, 'hour'); | ||
| 106 | - * $httpCache->isOlderThan(5, 'hours'); | ||
| 107 | - * | ||
| 108 | - * $httpCache->isOlderThan(1, 'minute'); | ||
| 109 | - * $httpCache->isOlderThan(15, 'minutes'); | ||
| 110 | - * | ||
| 111 | - * $httpCache->isOlderThan(1, 'second'); | ||
| 112 | - * $httpCache->isOlderThan(15); | ||
| 113 | - * </code> | ||
| 114 | - * | ||
| 115 | - * If you specify something greater than "weeks" as time untit, it just | ||
| 116 | - * works approximatly, because a month is taken to consist of 4.3 weeks. | ||
| 117 | - * | ||
| 118 | - * @access public | ||
| 119 | - * @return bool Returns true if requested page is older than specified. | ||
| 120 | - * @param int $time The amount of time. | ||
| 121 | - * @param string $unit The unit of the time amount - (year[s], month[s], | ||
| 122 | - * week[s], day[s], hour[s], minute[s], second[s]). | ||
| 123 | - */ | ||
| 124 | - function isOlderThan($time = 0, $unit = 'seconds') | ||
| 125 | - { | ||
| 126 | - if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || $this->isPost()) { | ||
| 127 | - return true; | ||
| 128 | - } | ||
| 129 | - if (!$time) { | ||
| 130 | - return false; | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - switch (strtolower($unit)) | ||
| 134 | - { | ||
| 135 | - case 'year': | ||
| 136 | - case 'years': | ||
| 137 | - $time *= 12; | ||
| 138 | - case 'month': | ||
| 139 | - case 'months': | ||
| 140 | - $time *= 4.3; | ||
| 141 | - case 'week': | ||
| 142 | - case 'weeks': | ||
| 143 | - $time *= 7; | ||
| 144 | - case 'day': | ||
| 145 | - case 'days': | ||
| 146 | - $time *= 24; | ||
| 147 | - case 'hour': | ||
| 148 | - case 'hours': | ||
| 149 | - $time *= 60; | ||
| 150 | - case 'minute': | ||
| 151 | - case 'minutes': | ||
| 152 | - $time *= 60; | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - return (time() - $this->getCacheStart()) > $time; | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - /** | ||
| 159 | - * Is Cached | ||
| 160 | - * | ||
| 161 | - * Check whether we can consider to be cached on the client side. | ||
| 162 | - * | ||
| 163 | - * @access public | ||
| 164 | - * @return bool Whether the page/resource is considered to be cached. | ||
| 165 | - * @param int $lastModified Unix timestamp of last modification. | ||
| 166 | - */ | ||
| 167 | - function isCached($lastModified = 0) | ||
| 168 | - { | ||
| 169 | - if ($this->isPost()) { | ||
| 170 | - return false; | ||
| 171 | - } | ||
| 172 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && !$lastModified) { | ||
| 173 | - return true; | ||
| 174 | - } | ||
| 175 | - if (!$seconds = time() - $lastModified) { | ||
| 176 | - return false; | ||
| 177 | - } | ||
| 178 | - return !$this->isOlderThan($seconds); | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - /** | ||
| 182 | - * Is Post | ||
| 183 | - * | ||
| 184 | - * Check if request method is "POST". | ||
| 185 | - * | ||
| 186 | - * @access public | ||
| 187 | - * @return bool | ||
| 188 | - */ | ||
| 189 | - function isPost() | ||
| 190 | - { | ||
| 191 | - return isset($_SERVER['REQUEST_METHOD']) and | ||
| 192 | - 'POST' == $_SERVER['REQUEST_METHOD']; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - /** | ||
| 196 | - * Exit If Cached | ||
| 197 | - * | ||
| 198 | - * Exit with "HTTP 304 Not Modified" if we consider to be cached. | ||
| 199 | - * | ||
| 200 | - * @access public | ||
| 201 | - * @return void | ||
| 202 | - * @param int $lastModified Unix timestamp of last modification. | ||
| 203 | - */ | ||
| 204 | - function exitIfCached($lastModified = 0) | ||
| 205 | - { | ||
| 206 | - if ($this->isCached($lastModified)) { | ||
| 207 | - $this->exitCached(); | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - /** | ||
| 212 | - * Exit Cached | ||
| 213 | - * | ||
| 214 | - * Exit with "HTTP 304 Not Modified". | ||
| 215 | - * | ||
| 216 | - * @access public | ||
| 217 | - * @return void | ||
| 218 | - */ | ||
| 219 | - function exitCached() | ||
| 220 | - { | ||
| 221 | - $this->sendHeaders(); | ||
| 222 | - $this->sendStatusCode(304); | ||
| 223 | - exit; | ||
| 224 | - } | ||
| 225 | - | ||
| 226 | - /** | ||
| 227 | - * Set Last Modified | ||
| 228 | - * | ||
| 229 | - * @access public | ||
| 230 | - * @return void | ||
| 231 | - * @param int $lastModified The unix timestamp of last modification. | ||
| 232 | - */ | ||
| 233 | - function setLastModified($lastModified = null) | ||
| 234 | - { | ||
| 235 | - $this->setHeader('Last-Modified', $lastModified); | ||
| 236 | - } | ||
| 237 | -} | ||
| 238 | -?> | 1 | +<?php |
| 2 | +/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * HTTP::Header::Cache | ||
| 6 | + * | ||
| 7 | + * PHP versions 4 and 5 | ||
| 8 | + * | ||
| 9 | + * @category HTTP | ||
| 10 | + * @package HTTP_Header | ||
| 11 | + * @author Wolfram Kriesing <wk@visionp.de> | ||
| 12 | + * @author Michael Wallner <mike@php.net> | ||
| 13 | + * @copyright 2003-2005 The Authors | ||
| 14 | + * @license BSD, revised | ||
| 15 | + * @version CVS: $Id$ | ||
| 16 | + * @link http://pear.php.net/package/HTTP_Header | ||
| 17 | + */ | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Requires HTTP_Header | ||
| 21 | + */ | ||
| 22 | +require_once 'HTTP/Header.php'; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * HTTP_Header_Cache | ||
| 26 | + * | ||
| 27 | + * This package provides methods to easier handle caching of HTTP pages. That | ||
| 28 | + * means that the pages can be cached at the client (user agent or browser) and | ||
| 29 | + * your application only needs to send "hey client you already have the pages". | ||
| 30 | + * | ||
| 31 | + * Which is done by sending the HTTP-Status "304 Not Modified", so that your | ||
| 32 | + * application load and the network traffic can be reduced, since you only need | ||
| 33 | + * to send the complete page once. This is really an advantage e.g. for | ||
| 34 | + * generated style sheets, or simply pages that do only change rarely. | ||
| 35 | + * | ||
| 36 | + * Usage: | ||
| 37 | + * <code> | ||
| 38 | + * require_once 'HTTP/Header/Cache.php'; | ||
| 39 | + * $httpCache = new HTTP_Header_Cache(4, 'weeks'); | ||
| 40 | + * $httpCache->sendHeaders(); | ||
| 41 | + * // your code goes here | ||
| 42 | + * </code> | ||
| 43 | + * | ||
| 44 | + * @package HTTP_Header | ||
| 45 | + * @category HTTP | ||
| 46 | + * @access public | ||
| 47 | + * @version $Revision$ | ||
| 48 | + */ | ||
| 49 | +class HTTP_Header_Cache extends HTTP_Header | ||
| 50 | +{ | ||
| 51 | + /** | ||
| 52 | + * Constructor | ||
| 53 | + * | ||
| 54 | + * Set the amount of time to cache. | ||
| 55 | + * | ||
| 56 | + * @access public | ||
| 57 | + * @return object HTTP_Header_Cache | ||
| 58 | + * @param int $expires | ||
| 59 | + * @param string $unit | ||
| 60 | + */ | ||
| 61 | + function HTTP_Header_Cache($expires = 0, $unit = 'seconds') | ||
| 62 | + { | ||
| 63 | + parent::HTTP_Header(); | ||
| 64 | + $this->setHeader('Pragma', 'cache'); | ||
| 65 | + $this->setHeader('Last-Modified', $this->getCacheStart()); | ||
| 66 | + $this->setHeader('Cache-Control', 'private, must-revalidate, max-age=0'); | ||
| 67 | + | ||
| 68 | + if ($expires) { | ||
| 69 | + if (!$this->isOlderThan($expires, $unit)) { | ||
| 70 | + $this->exitCached(); | ||
| 71 | + } | ||
| 72 | + $this->setHeader('Last-Modified', time()); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * Get Cache Start | ||
| 78 | + * | ||
| 79 | + * Returns the unix timestamp of the If-Modified-Since HTTP header or the | ||
| 80 | + * current time if the header was not sent by the client. | ||
| 81 | + * | ||
| 82 | + * @access public | ||
| 83 | + * @return int unix timestamp | ||
| 84 | + */ | ||
| 85 | + function getCacheStart() | ||
| 86 | + { | ||
| 87 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && !$this->isPost()) { | ||
| 88 | + return strtotime(current($array = explode(';', | ||
| 89 | + $_SERVER['HTTP_IF_MODIFIED_SINCE']))); | ||
| 90 | + } | ||
| 91 | + return time(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * Is Older Than | ||
| 96 | + * | ||
| 97 | + * You can call it like this: | ||
| 98 | + * <code> | ||
| 99 | + * $httpCache->isOlderThan(1, 'day'); | ||
| 100 | + * $httpCache->isOlderThan(47, 'days'); | ||
| 101 | + * | ||
| 102 | + * $httpCache->isOlderThan(1, 'week'); | ||
| 103 | + * $httpCache->isOlderThan(3, 'weeks'); | ||
| 104 | + * | ||
| 105 | + * $httpCache->isOlderThan(1, 'hour'); | ||
| 106 | + * $httpCache->isOlderThan(5, 'hours'); | ||
| 107 | + * | ||
| 108 | + * $httpCache->isOlderThan(1, 'minute'); | ||
| 109 | + * $httpCache->isOlderThan(15, 'minutes'); | ||
| 110 | + * | ||
| 111 | + * $httpCache->isOlderThan(1, 'second'); | ||
| 112 | + * $httpCache->isOlderThan(15); | ||
| 113 | + * </code> | ||
| 114 | + * | ||
| 115 | + * If you specify something greater than "weeks" as time untit, it just | ||
| 116 | + * works approximatly, because a month is taken to consist of 4.3 weeks. | ||
| 117 | + * | ||
| 118 | + * @access public | ||
| 119 | + * @return bool Returns true if requested page is older than specified. | ||
| 120 | + * @param int $time The amount of time. | ||
| 121 | + * @param string $unit The unit of the time amount - (year[s], month[s], | ||
| 122 | + * week[s], day[s], hour[s], minute[s], second[s]). | ||
| 123 | + */ | ||
| 124 | + function isOlderThan($time = 0, $unit = 'seconds') | ||
| 125 | + { | ||
| 126 | + if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || $this->isPost()) { | ||
| 127 | + return true; | ||
| 128 | + } | ||
| 129 | + if (!$time) { | ||
| 130 | + return false; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + switch (strtolower($unit)) | ||
| 134 | + { | ||
| 135 | + case 'year': | ||
| 136 | + case 'years': | ||
| 137 | + $time *= 12; | ||
| 138 | + case 'month': | ||
| 139 | + case 'months': | ||
| 140 | + $time *= 4.3; | ||
| 141 | + case 'week': | ||
| 142 | + case 'weeks': | ||
| 143 | + $time *= 7; | ||
| 144 | + case 'day': | ||
| 145 | + case 'days': | ||
| 146 | + $time *= 24; | ||
| 147 | + case 'hour': | ||
| 148 | + case 'hours': | ||
| 149 | + $time *= 60; | ||
| 150 | + case 'minute': | ||
| 151 | + case 'minutes': | ||
| 152 | + $time *= 60; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + return (time() - $this->getCacheStart()) > $time; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /** | ||
| 159 | + * Is Cached | ||
| 160 | + * | ||
| 161 | + * Check whether we can consider to be cached on the client side. | ||
| 162 | + * | ||
| 163 | + * @access public | ||
| 164 | + * @return bool Whether the page/resource is considered to be cached. | ||
| 165 | + * @param int $lastModified Unix timestamp of last modification. | ||
| 166 | + */ | ||
| 167 | + function isCached($lastModified = 0) | ||
| 168 | + { | ||
| 169 | + if ($this->isPost()) { | ||
| 170 | + return false; | ||
| 171 | + } | ||
| 172 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && !$lastModified) { | ||
| 173 | + return true; | ||
| 174 | + } | ||
| 175 | + if (!$seconds = time() - $lastModified) { | ||
| 176 | + return false; | ||
| 177 | + } | ||
| 178 | + return !$this->isOlderThan($seconds); | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * Is Post | ||
| 183 | + * | ||
| 184 | + * Check if request method is "POST". | ||
| 185 | + * | ||
| 186 | + * @access public | ||
| 187 | + * @return bool | ||
| 188 | + */ | ||
| 189 | + function isPost() | ||
| 190 | + { | ||
| 191 | + return isset($_SERVER['REQUEST_METHOD']) and | ||
| 192 | + 'POST' == $_SERVER['REQUEST_METHOD']; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * Exit If Cached | ||
| 197 | + * | ||
| 198 | + * Exit with "HTTP 304 Not Modified" if we consider to be cached. | ||
| 199 | + * | ||
| 200 | + * @access public | ||
| 201 | + * @return void | ||
| 202 | + * @param int $lastModified Unix timestamp of last modification. | ||
| 203 | + */ | ||
| 204 | + function exitIfCached($lastModified = 0) | ||
| 205 | + { | ||
| 206 | + if ($this->isCached($lastModified)) { | ||
| 207 | + $this->exitCached(); | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + /** | ||
| 212 | + * Exit Cached | ||
| 213 | + * | ||
| 214 | + * Exit with "HTTP 304 Not Modified". | ||
| 215 | + * | ||
| 216 | + * @access public | ||
| 217 | + * @return void | ||
| 218 | + */ | ||
| 219 | + function exitCached() | ||
| 220 | + { | ||
| 221 | + $this->sendHeaders(); | ||
| 222 | + $this->sendStatusCode(304); | ||
| 223 | + exit; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + /** | ||
| 227 | + * Set Last Modified | ||
| 228 | + * | ||
| 229 | + * @access public | ||
| 230 | + * @return void | ||
| 231 | + * @param int $lastModified The unix timestamp of last modification. | ||
| 232 | + */ | ||
| 233 | + function setLastModified($lastModified = null) | ||
| 234 | + { | ||
| 235 | + $this->setHeader('Last-Modified', $lastModified); | ||
| 236 | + } | ||
| 237 | +} | ||
| 238 | +?> |
thirdparty/pear/HTTP/Request.php
| @@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
| 32 | // | Author: Richard Heyes <richard@phpguru.org> | | 32 | // | Author: Richard Heyes <richard@phpguru.org> | |
| 33 | // +-----------------------------------------------------------------------+ | 33 | // +-----------------------------------------------------------------------+ |
| 34 | // | 34 | // |
| 35 | -// $Id: Request.php,v 1.43 2005/11/06 18:29:14 avb Exp $ | 35 | +// $Id$ |
| 36 | // | 36 | // |
| 37 | // HTTP_Request Class | 37 | // HTTP_Request Class |
| 38 | // | 38 | // |
thirdparty/pear/HTTP/Request/Listener.php
| @@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
| 32 | // | Author: Alexey Borzov <avb@php.net> | | 32 | // | Author: Alexey Borzov <avb@php.net> | |
| 33 | // +-----------------------------------------------------------------------+ | 33 | // +-----------------------------------------------------------------------+ |
| 34 | // | 34 | // |
| 35 | -// $Id: Listener.php,v 1.2 2003/10/26 10:28:29 avb Exp $ | 35 | +// $Id$ |
| 36 | // | 36 | // |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| @@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
| 42 | * | 42 | * |
| 43 | * @package HTTP_Request | 43 | * @package HTTP_Request |
| 44 | * @author Alexey Borzov <avb@php.net> | 44 | * @author Alexey Borzov <avb@php.net> |
| 45 | - * @version $Revision: 1.2 $ | 45 | + * @version $Revision$ |
| 46 | */ | 46 | */ |
| 47 | class HTTP_Request_Listener | 47 | class HTTP_Request_Listener |
| 48 | { | 48 | { |
thirdparty/pear/HTTP/Upload.php
| 1 | -<?php | ||
| 2 | -// ********************************************** | ||
| 3 | -// | ||
| 4 | -// This software is licensed by the LGPL | ||
| 5 | -// -> http://www.gnu.org/copyleft/lesser.txt | ||
| 6 | -// (c) 2001-2004 by Tomas Von Veschler Cox | ||
| 7 | -// | ||
| 8 | -// ********************************************** | ||
| 9 | -// | ||
| 10 | -// $Id: Upload.php,v 1.42 2004/08/08 09:37:50 wenz Exp $ | ||
| 11 | - | ||
| 12 | -/* | ||
| 13 | - * Pear File Uploader class. Easy and secure managment of files | ||
| 14 | - * submitted via HTML Forms. | ||
| 15 | - * | ||
| 16 | - * Leyend: | ||
| 17 | - * - you can add error msgs in your language in the HTTP_Upload_Error class | ||
| 18 | - * | ||
| 19 | - * TODO: | ||
| 20 | - * - try to think a way of having all the Error system in other | ||
| 21 | - * file and only include it when an error ocurrs | ||
| 22 | - * | ||
| 23 | - * -- Notes for users HTTP_Upload >= 0.9.0 -- | ||
| 24 | - * | ||
| 25 | - * Error detection was enhanced, so you no longer need to | ||
| 26 | - * check for PEAR::isError() in $upload->getFiles() or call | ||
| 27 | - * $upload->isMissing(). Instead you'll | ||
| 28 | - * get the error when do a check for $file->isError(). | ||
| 29 | - * | ||
| 30 | - * Example: | ||
| 31 | - * | ||
| 32 | - * $upload = new HTTP_Upload('en'); | ||
| 33 | - * $file = $upload->getFiles('i_dont_exist_in_form_definition'); | ||
| 34 | - * if ($file->isError()) { | ||
| 35 | - * die($file->getMessage()); | ||
| 36 | - * } | ||
| 37 | - * | ||
| 38 | - * -- | ||
| 39 | - * | ||
| 40 | - */ | ||
| 41 | - | ||
| 42 | -require_once 'PEAR.php'; | ||
| 43 | - | ||
| 44 | -/** | ||
| 45 | - * defines default chmod | ||
| 46 | - */ | ||
| 47 | -define('HTTP_UPLOAD_DEFAULT_CHMOD', 0660); | ||
| 48 | - | ||
| 49 | -/** | ||
| 50 | - * Error Class for HTTP_Upload | ||
| 51 | - * | ||
| 52 | - * @author Tomas V.V.Cox <cox@idecnet.com> | ||
| 53 | - * @see http://vulcanonet.com/soft/index.php?pack=uploader | ||
| 54 | - * @package HTTP_Upload | ||
| 55 | - * @category HTTP | ||
| 56 | - * @access public | ||
| 57 | - */ | ||
| 58 | -class HTTP_Upload_Error extends PEAR | ||
| 59 | -{ | ||
| 60 | - /** | ||
| 61 | - * Selected language for error messages | ||
| 62 | - * @var string | ||
| 63 | - */ | ||
| 64 | - var $lang = 'en'; | ||
| 65 | - | ||
| 66 | - /** | ||
| 67 | - * Whether HTML entities shall be encoded automatically | ||
| 68 | - * @var boolean | ||
| 69 | - */ | ||
| 70 | - var $html = false; | ||
| 71 | - | ||
| 72 | - /** | ||
| 73 | - * Constructor | ||
| 74 | - * | ||
| 75 | - * Creates a new PEAR_Error | ||
| 76 | - * | ||
| 77 | - * @param string $lang The language selected for error code messages | ||
| 78 | - * @access public | ||
| 79 | - */ | ||
| 80 | - function HTTP_Upload_Error($lang = null, $html = false) | ||
| 81 | - { | ||
| 82 | - $this->lang = ($lang !== null) ? $lang : $this->lang; | ||
| 83 | - $this->html = ($html !== false) ? $html : $this->html; | ||
| 84 | - $ini_size = preg_replace('/m/i', '000000', ini_get('upload_max_filesize')); | ||
| 85 | - | ||
| 86 | - if (function_exists('version_compare') && | ||
| 87 | - version_compare(phpversion(), '4.1', 'ge')) { | ||
| 88 | - $maxsize = (isset($_POST['MAX_FILE_SIZE'])) ? | ||
| 89 | - $_POST['MAX_FILE_SIZE'] : null; | ||
| 90 | - } else { | ||
| 91 | - global $HTTP_POST_VARS; | ||
| 92 | - $maxsize = (isset($HTTP_POST_VARS['MAX_FILE_SIZE'])) ? | ||
| 93 | - $HTTP_POST_VARS['MAX_FILE_SIZE'] : null; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - if (empty($maxsize) || ($maxsize > $ini_size)) { | ||
| 97 | - $maxsize = $ini_size; | ||
| 98 | - } | ||
| 99 | - // XXXXX Add here error messages in your language | ||
| 100 | - $this->error_codes = array( | ||
| 101 | - 'TOO_LARGE' => array( | ||
| 102 | - 'es' => "Fichero demasiado largo. El maximo permitido es: $maxsize bytes.", | ||
| 103 | - 'en' => "File size too large. The maximum permitted size is: $maxsize bytes.", | ||
| 104 | - 'de' => "Datei zu groß. Die zulässige Maximalgröße ist: $maxsize Bytes.", | ||
| 105 | - 'nl' => "Het bestand is te groot, de maximale grootte is: $maxsize bytes.", | ||
| 106 | - 'fr' => "Le fichier est trop gros. La taille maximum autorisée est: $maxsize bytes.", | ||
| 107 | - 'it' => "Il file é troppo grande. Il massimo permesso é: $maxsize bytes.", | ||
| 108 | - 'pt_BR' => "Arquivo muito grande. O tamanho máximo permitido é $maxsize bytes." | ||
| 109 | - ), | ||
| 110 | - 'MISSING_DIR' => array( | ||
| 111 | - 'es' => 'Falta directorio destino.', | ||
| 112 | - 'en' => 'Missing destination directory.', | ||
| 113 | - 'de' => 'Kein Zielverzeichnis definiert.', | ||
| 114 | - 'nl' => 'Geen bestemmings directory.', | ||
| 115 | - 'fr' => 'Le répertoire de destination n\'est pas défini.', | ||
| 116 | - 'it' => 'Manca la directory di destinazione.', | ||
| 117 | - 'pt_BR' => 'Ausência de diretório de destino.' | ||
| 118 | - ), | ||
| 119 | - 'IS_NOT_DIR' => array( | ||
| 120 | - 'es' => 'El directorio destino no existe o es un fichero regular.', | ||
| 121 | - 'en' => 'The destination directory doesn\'t exist or is a regular file.', | ||
| 122 | - 'de' => 'Das angebene Zielverzeichnis existiert nicht oder ist eine Datei.', | ||
| 123 | - 'nl' => 'De doeldirectory bestaat niet, of is een gewoon bestand.', | ||
| 124 | - 'fr' => 'Le répertoire de destination n\'existe pas ou il s\'agit d\'un fichier régulier.', | ||
| 125 | - 'it' => 'La directory di destinazione non esiste o é un file.', | ||
| 126 | - 'pt_BR' => 'O diretório de destino não existe ou é um arquivo.' | ||
| 127 | - ), | ||
| 128 | - 'NO_WRITE_PERMS' => array( | ||
| 129 | - 'es' => 'El directorio destino no tiene permisos de escritura.', | ||
| 130 | - 'en' => 'The destination directory doesn\'t have write perms.', | ||
| 131 | - 'de' => 'Fehlende Schreibrechte für das Zielverzeichnis.', | ||
| 132 | - 'nl' => 'Geen toestemming om te schrijven in de doeldirectory.', | ||
| 133 | - 'fr' => 'Le répertoire de destination n\'a pas les droits en écriture.', | ||
| 134 | - 'it' => 'Non si hanno i permessi di scrittura sulla directory di destinazione.', | ||
| 135 | - 'pt_BR' => 'O diretório de destino não possui permissão para escrita.' | ||
| 136 | - ), | ||
| 137 | - 'NO_USER_FILE' => array( | ||
| 138 | - 'es' => 'No se ha escogido fichero para el upload.', | ||
| 139 | - 'en' => 'You haven\'t selected any file for uploading.', | ||
| 140 | - 'de' => 'Es wurde keine Datei für den Upload ausgewählt.', | ||
| 141 | - 'nl' => 'Er is geen bestand opgegeven om te uploaden.', | ||
| 142 | - 'fr' => 'Vous n\'avez pas sélectionné de fichier à envoyer.', | ||
| 143 | - 'it' => 'Nessun file selezionato per l\'upload.', | ||
| 144 | - 'pt_BR' => 'Nenhum arquivo selecionado para upload.' | ||
| 145 | - ), | ||
| 146 | - 'BAD_FORM' => array( | ||
| 147 | - 'es' => 'El formulario no contiene method="post" enctype="multipart/form-data" requerido.', | ||
| 148 | - 'en' => 'The html form doesn\'t contain the required method="post" enctype="multipart/form-data".', | ||
| 149 | - 'de' => 'Das HTML-Formular enthält nicht die Angabe method="post" enctype="multipart/form-data" '. | ||
| 150 | - 'im >form<-Tag.', | ||
| 151 | - 'nl' => 'Het HTML-formulier bevat niet de volgende benodigde '. | ||
| 152 | - 'eigenschappen: method="post" enctype="multipart/form-data".', | ||
| 153 | - 'fr' => 'Le formulaire HTML ne contient pas les attributs requis : '. | ||
| 154 | - ' method="post" enctype="multipart/form-data".', | ||
| 155 | - 'it' => 'Il modulo HTML non contiene gli attributi richiesti: "'. | ||
| 156 | - ' method="post" enctype="multipart/form-data".', | ||
| 157 | - 'pt_BR' => 'O formulário HTML não possui o method="post" enctype="multipart/form-data" requerido.' | ||
| 158 | - ), | ||
| 159 | - 'E_FAIL_COPY' => array( | ||
| 160 | - 'es' => 'Fallo al copiar el fichero temporal.', | ||
| 161 | - 'en' => 'Failed to copy the temporary file.', | ||
| 162 | - 'de' => 'Temporäre Datei konnte nicht kopiert werden.', | ||
| 163 | - 'nl' => 'Het tijdelijke bestand kon niet gekopieerd worden.', | ||
| 164 | - 'fr' => 'L\'enregistrement du fichier temporaire a échoué.', | ||
| 165 | - 'it' => 'Copia del file temporaneo fallita.', | ||
| 166 | - 'pt_BR' => 'Falha ao copiar o arquivo temporário.' | ||
| 167 | - ), | ||
| 168 | - 'E_FAIL_MOVE' => array( | ||
| 169 | - 'es' => 'No puedo mover el fichero.', | ||
| 170 | - 'en' => 'Impossible to move the file.', | ||
| 171 | - 'de' => 'Datei kann nicht verschoben werden.', | ||
| 172 | - 'nl' => 'Het bestand kon niet verplaatst worden.', | ||
| 173 | - 'fr' => 'Impossible de déplacer le fichier.', | ||
| 174 | - 'pt_BR' => 'Não foi possível mover o arquivo.' | ||
| 175 | - ), | ||
| 176 | - 'FILE_EXISTS' => array( | ||
| 177 | - 'es' => 'El fichero destino ya existe.', | ||
| 178 | - 'en' => 'The destination file already exists.', | ||
| 179 | - 'de' => 'Die zu erzeugende Datei existiert bereits.', | ||
| 180 | - 'nl' => 'Het doelbestand bestaat al.', | ||
| 181 | - 'fr' => 'Le fichier de destination existe déjà.', | ||
| 182 | - 'it' => 'File destinazione già esistente.', | ||
| 183 | - 'pt_BR' => 'O arquivo de destino já existe.' | ||
| 184 | - ), | ||
| 185 | - 'CANNOT_OVERWRITE' => array( | ||
| 186 | - 'es' => 'El fichero destino ya existe y no se puede sobreescribir.', | ||
| 187 | - 'en' => 'The destination file already exists and could not be overwritten.', | ||
| 188 | - 'de' => 'Die zu erzeugende Datei existiert bereits und konnte nicht überschrieben werden.', | ||
| 189 | - 'nl' => 'Het doelbestand bestaat al, en kon niet worden overschreven.', | ||
| 190 | - 'fr' => 'Le fichier de destination existe déjà et ne peux pas être remplacé.', | ||
| 191 | - 'it' => 'File destinazione già esistente e non si può sovrascrivere.', | ||
| 192 | - 'pt_BR' => 'O arquivo de destino já existe e não pôde ser sobrescrito.' | ||
| 193 | - ), | ||
| 194 | - 'NOT_ALLOWED_EXTENSION' => array( | ||
| 195 | - 'es' => 'Extension de fichero no permitida.', | ||
| 196 | - 'en' => 'File extension not permitted.', | ||
| 197 | - 'de' => 'Unerlaubte Dateiendung.', | ||
| 198 | - 'nl' => 'Niet toegestane bestands-extensie.', | ||
| 199 | - 'fr' => 'Le fichier a une extension non autorisée.', | ||
| 200 | - 'it' => 'Estensione del File non permessa.', | ||
| 201 | - 'pt_BR' => 'Extensão de arquivo não permitida.' | ||
| 202 | - ), | ||
| 203 | - 'PARTIAL' => array( | ||
| 204 | - 'es' => 'El fichero fue parcialmente subido', | ||
| 205 | - 'en' => 'The file was only partially uploaded.', | ||
| 206 | - 'de' => 'Die Datei wurde unvollständig übertragen.', | ||
| 207 | - 'nl' => 'Het bestand is slechts gedeeltelijk geupload.', | ||
| 208 | - 'pt_BR' => 'O arquivo nรฃo foi enviado por completo.' | ||
| 209 | - ), | ||
| 210 | - 'ERROR' => array( | ||
| 211 | - 'es' => 'Error en subida:', | ||
| 212 | - 'en' => 'Upload error:', | ||
| 213 | - 'de' => 'Fehler beim Upload:', | ||
| 214 | - 'nl' => 'Upload fout:', | ||
| 215 | - 'pt_BR' => 'Erro de upload:' | ||
| 216 | - ), | ||
| 217 | - 'DEV_NO_DEF_FILE' => array( | ||
| 218 | - 'es' => 'No estรก definido en el formulario este nombre de fichero como <input type="file" name=?>.', | ||
| 219 | - 'en' => 'This filename is not defined in the form as <input type="file" name=?>.', | ||
| 220 | - 'de' => 'Dieser Dateiname ist im Formular nicht als <input type="file" name=?> definiert.', | ||
| 221 | - 'nl' => 'Deze bestandsnaam is niett gedefineerd in het formulier als <input type="file" name=?>.' | ||
| 222 | - ) | ||
| 223 | - ); | ||
| 224 | - } | ||
| 225 | - | ||
| 226 | - /** | ||
| 227 | - * returns the error code | ||
| 228 | - * | ||
| 229 | - * @param string $e_code type of error | ||
| 230 | - * @return string Error message | ||
| 231 | - */ | ||
| 232 | - function errorCode($e_code) | ||
| 233 | - { | ||
| 234 | - if (!empty($this->error_codes[$e_code][$this->lang])) { | ||
| 235 | - $msg = $this->html ? | ||
| 236 | - html_entity_decode($this->error_codes[$e_code][$this->lang]) : | ||
| 237 | - $this->error_codes[$e_code][$this->lang]; | ||
| 238 | - } else { | ||
| 239 | - $msg = $e_code; | ||
| 240 | - } | ||
| 241 | - | ||
| 242 | - if (!empty($this->error_codes['ERROR'][$this->lang])) { | ||
| 243 | - $error = $this->error_codes['ERROR'][$this->lang]; | ||
| 244 | - } else { | ||
| 245 | - $error = $this->error_codes['ERROR']['en']; | ||
| 246 | - } | ||
| 247 | - return $error.' '.$msg; | ||
| 248 | - } | ||
| 249 | - | ||
| 250 | - /** | ||
| 251 | - * Overwrites the PEAR::raiseError method | ||
| 252 | - * | ||
| 253 | - * @param string $e_code type of error | ||
| 254 | - * @return object PEAR_Error a PEAR-Error object | ||
| 255 | - * @access public | ||
| 256 | - */ | ||
| 257 | - function raiseError($e_code) | ||
| 258 | - { | ||
| 259 | - return PEAR::raiseError($this->errorCode($e_code), $e_code); | ||
| 260 | - } | ||
| 261 | -} | ||
| 262 | - | ||
| 263 | -/** | ||
| 264 | - * This class provides an advanced file uploader system | ||
| 265 | - * for file uploads made from html forms | ||
| 266 | - | ||
| 267 | - * | ||
| 268 | - * @author Tomas V.V.Cox <cox@idecnet.com> | ||
| 269 | - * @see http://vulcanonet.com/soft/index.php?pack=uploader | ||
| 270 | - * @package HTTP_Upload | ||
| 271 | - * @category HTTP | ||
| 272 | - * @access public | ||
| 273 | - */ | ||
| 274 | -class HTTP_Upload extends HTTP_Upload_Error | ||
| 275 | -{ | ||
| 276 | - /** | ||
| 277 | - * Contains an array of "uploaded files" objects | ||
| 278 | - * @var array | ||
| 279 | - */ | ||
| 280 | - var $files = array(); | ||
| 281 | - | ||
| 282 | - /** | ||
| 283 | - * Contains the desired chmod for uploaded files | ||
| 284 | - * @var int | ||
| 285 | - * @access private | ||
| 286 | - */ | ||
| 287 | - var $_chmod = HTTP_UPLOAD_DEFAULT_CHMOD; | ||
| 288 | - | ||
| 289 | - /** | ||
| 290 | - * Constructor | ||
| 291 | - * | ||
| 292 | - * @param string $lang Language to use for reporting errors | ||
| 293 | - * @see Upload_Error::error_codes | ||
| 294 | - * @access public | ||
| 295 | - */ | ||
| 296 | - function HTTP_Upload($lang = null) | ||
| 297 | - { | ||
| 298 | - $this->HTTP_Upload_Error($lang); | ||
| 299 | - if (function_exists('version_compare') && | ||
| 300 | - version_compare(phpversion(), '4.1', 'ge')) | ||
| 301 | - { | ||
| 302 | - $this->post_files = $_FILES; | ||
| 303 | - if (isset($_SERVER['CONTENT_TYPE'])) { | ||
| 304 | - $this->content_type = $_SERVER['CONTENT_TYPE']; | ||
| 305 | - } | ||
| 306 | - } else { | ||
| 307 | - global $HTTP_POST_FILES, $HTTP_SERVER_VARS; | ||
| 308 | - $this->post_files = $HTTP_POST_FILES; | ||
| 309 | - if (isset($HTTP_SERVER_VARS['CONTENT_TYPE'])) { | ||
| 310 | - $this->content_type = $HTTP_SERVER_VARS['CONTENT_TYPE']; | ||
| 311 | - } | ||
| 312 | - } | ||
| 313 | - } | ||
| 314 | - | ||
| 315 | - /** | ||
| 316 | - * Get files | ||
| 317 | - * | ||
| 318 | - * @param mixed $file If: | ||
| 319 | - * - not given, function will return array of upload_file objects | ||
| 320 | - * - is int, will return the $file position in upload_file objects array | ||
| 321 | - * - is string, will return the upload_file object corresponding | ||
| 322 | - * to $file name of the form. For ex: | ||
| 323 | - * if form is <input type="file" name="userfile"> | ||
| 324 | - * to get this file use: $upload->getFiles('userfile') | ||
| 325 | - * | ||
| 326 | - * @return mixed array or object (see @param $file above) or Pear_Error | ||
| 327 | - * @access public | ||
| 328 | - */ | ||
| 329 | - function &getFiles($file = null) | ||
| 330 | - { | ||
| 331 | - static $is_built = false; | ||
| 332 | - //build only once for multiple calls | ||
| 333 | - if (!$is_built) { | ||
| 334 | - $files = &$this->_buildFiles(); | ||
| 335 | - if (PEAR::isError($files)) { | ||
| 336 | - // there was an error with the form. | ||
| 337 | - // Create a faked upload embedding the error | ||
| 338 | - $this->files['_error'] = &new HTTP_Upload_File( | ||
| 339 | - '_error', null, | ||
| 340 | - null, null, | ||
| 341 | - null, $files->getCode(), | ||
| 342 | - $this->lang, $this->_chmod); | ||
| 343 | - } else { | ||
| 344 | - $this->files = $files; | ||
| 345 | - } | ||
| 346 | - $is_built = true; | ||
| 347 | - } | ||
| 348 | - if ($file !== null) { | ||
| 349 | - if (is_int($file)) { | ||
| 350 | - $pos = 0; | ||
| 351 | - foreach ($this->files as $obj) { | ||
| 352 | - if ($pos == $file) { | ||
| 353 | - return $obj; | ||
| 354 | - } | ||
| 355 | - $pos++; | ||
| 356 | - } | ||
| 357 | - } elseif (is_string($file) && isset($this->files[$file])) { | ||
| 358 | - return $this->files[$file]; | ||
| 359 | - } | ||
| 360 | - if (isset($this->files['_error'])) { | ||
| 361 | - return $this->files['_error']; | ||
| 362 | - } else { | ||
| 363 | - // developer didn't specify this name in the form | ||
| 364 | - // warn him about it with a faked upload | ||
| 365 | - return new HTTP_Upload_File( | ||
| 366 | - '_error', null, | ||
| 367 | - null, null, | ||
| 368 | - null, 'DEV_NO_DEF_FILE', | ||
| 369 | - $this->lang); | ||
| 370 | - } | ||
| 371 | - } | ||
| 372 | - return $this->files; | ||
| 373 | - } | ||
| 374 | - | ||
| 375 | - /** | ||
| 376 | - * Creates the list of the uploaded file | ||
| 377 | - * | ||
| 378 | - * @return array of HTTP_Upload_File objects for every file | ||
| 379 | - */ | ||
| 380 | - function &_buildFiles() | ||
| 381 | - { | ||
| 382 | - // Form method check | ||
| 383 | - if (!isset($this->content_type) || | ||
| 384 | - strpos($this->content_type, 'multipart/form-data') !== 0) | ||
| 385 | - { | ||
| 386 | - return $this->raiseError('BAD_FORM'); | ||
| 387 | - } | ||
| 388 | - // In 4.1 $_FILES isn't initialized when no uploads | ||
| 389 | - // XXX (cox) afaik, in >= 4.1 and <= 4.3 only | ||
| 390 | - if (function_exists('version_compare') && | ||
| 391 | - version_compare(phpversion(), '4.1', 'ge')) | ||
| 392 | - { | ||
| 393 | - $error = $this->isMissing(); | ||
| 394 | - if (PEAR::isError($error)) { | ||
| 395 | - return $error; | ||
| 396 | - } | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | - // map error codes from 4.2.0 $_FILES['userfile']['error'] | ||
| 400 | - if (function_exists('version_compare') && | ||
| 401 | - version_compare(phpversion(), '4.2.0', 'ge')) { | ||
| 402 | - $uploadError = array( | ||
| 403 | - 1 => 'TOO_LARGE', | ||
| 404 | - 2 => 'TOO_LARGE', | ||
| 405 | - 3 => 'PARTIAL', | ||
| 406 | - 4 => 'NO_USER_FILE' | ||
| 407 | - ); | ||
| 408 | - } | ||
| 409 | - | ||
| 410 | - | ||
| 411 | - // Parse $_FILES (or $HTTP_POST_FILES) | ||
| 412 | - $files = array(); | ||
| 413 | - foreach ($this->post_files as $userfile => $value) { | ||
| 414 | - if (is_array($value['name'])) { | ||
| 415 | - foreach ($value['name'] as $key => $val) { | ||
| 416 | - $err = $value['error'][$key]; | ||
| 417 | - if (isset($err) && $err !== 0 && isset($uploadError[$err])) { | ||
| 418 | - $error = $uploadError[$err]; | ||
| 419 | - } else { | ||
| 420 | - $error = null; | ||
| 421 | - } | ||
| 422 | - $name = basename($value['name'][$key]); | ||
| 423 | - $tmp_name = $value['tmp_name'][$key]; | ||
| 424 | - $size = $value['size'][$key]; | ||
| 425 | - $type = $value['type'][$key]; | ||
| 426 | - $formname = $userfile . "[$key]"; | ||
| 427 | - $files[$formname] = new HTTP_Upload_File($name, $tmp_name, | ||
| 428 | - $formname, $type, $size, $error, $this->lang, $this->_chmod); | ||
| 429 | - } | ||
| 430 | - // One file | ||
| 431 | - } else { | ||
| 432 | - $err = $value['error']; | ||
| 433 | - if (isset($err) && $err !== 0 && isset($uploadError[$err])) { | ||
| 434 | - $error = $uploadError[$err]; | ||
| 435 | - } else { | ||
| 436 | - $error = null; | ||
| 437 | - } | ||
| 438 | - $name = basename($value['name']); | ||
| 439 | - $tmp_name = $value['tmp_name']; | ||
| 440 | - $size = $value['size']; | ||
| 441 | - $type = $value['type']; | ||
| 442 | - $formname = $userfile; | ||
| 443 | - $files[$formname] = new HTTP_Upload_File($name, $tmp_name, | ||
| 444 | - $formname, $type, $size, $error, $this->lang, $this->_chmod); | ||
| 445 | - } | ||
| 446 | - } | ||
| 447 | - return $files; | ||
| 448 | - } | ||
| 449 | - | ||
| 450 | - /** | ||
| 451 | - * Checks if the user submited or not some file | ||
| 452 | - * | ||
| 453 | - * @return mixed False when are files or PEAR_Error when no files | ||
| 454 | - * @access public | ||
| 455 | - * @see Read the note in the source code about this function | ||
| 456 | - */ | ||
| 457 | - function isMissing() | ||
| 458 | - { | ||
| 459 | - if (count($this->post_files) < 1) { | ||
| 460 | - return $this->raiseError('NO_USER_FILE'); | ||
| 461 | - } | ||
| 462 | - //we also check if at least one file has more than 0 bytes :) | ||
| 463 | - $files = array(); | ||
| 464 | - $size = 0; | ||
| 465 | - foreach ($this->post_files as $userfile => $value) { | ||
| 466 | - if (is_array($value['name'])) { | ||
| 467 | - foreach ($value['name'] as $key => $val) { | ||
| 468 | - $size += $value['size'][$key]; | ||
| 469 | - } | ||
| 470 | - } else { //one file | ||
| 471 | - $size = $value['size']; | ||
| 472 | - } | ||
| 473 | - } | ||
| 474 | - if ($size == 0) { | ||
| 475 | - $this->raiseError('NO_USER_FILE'); | ||
| 476 | - } | ||
| 477 | - return false; | ||
| 478 | - } | ||
| 479 | - | ||
| 480 | - /** | ||
| 481 | - * Sets the chmod to be used for uploaded files | ||
| 482 | - * | ||
| 483 | - * @param int Desired mode | ||
| 484 | - */ | ||
| 485 | - function setChmod($mode) | ||
| 486 | - { | ||
| 487 | - $this->_chmod = $mode; | ||
| 488 | - } | ||
| 489 | -} | ||
| 490 | - | ||
| 491 | -/** | ||
| 492 | - * This class provides functions to work with the uploaded file | ||
| 493 | - * | ||
| 494 | - * @author Tomas V.V.Cox <cox@idecnet.com> | ||
| 495 | - * @see http://vulcanonet.com/soft/index.php?pack=uploader | ||
| 496 | - * @package HTTP_Upload | ||
| 497 | - * @category HTTP | ||
| 498 | - * @access public | ||
| 499 | - */ | ||
| 500 | -class HTTP_Upload_File extends HTTP_Upload_Error | ||
| 501 | -{ | ||
| 502 | - /** | ||
| 503 | - * If the random seed was initialized before or not | ||
| 504 | - * @var boolean; | ||
| 505 | - */ | ||
| 506 | - var $_seeded = 0; | ||
| 507 | - | ||
| 508 | - /** | ||
| 509 | - * Assoc array with file properties | ||
| 510 | - * @var array | ||
| 511 | - */ | ||
| 512 | - var $upload = array(); | ||
| 513 | - | ||
| 514 | - /** | ||
| 515 | - * If user haven't selected a mode, by default 'safe' will be used | ||
| 516 | - * @var boolean | ||
| 517 | - */ | ||
| 518 | - var $mode_name_selected = false; | ||
| 519 | - | ||
| 520 | - /** | ||
| 521 | - * It's a common security risk in pages who has the upload dir | ||
| 522 | - * under the document root (remember the hack of the Apache web?) | ||
| 523 | - * | ||
| 524 | - * @var array | ||
| 525 | - * @access private | ||
| 526 | - * @see HTTP_Upload_File::setValidExtensions() | ||
| 527 | - */ | ||
| 528 | - var $_extensions_check = array('php', 'phtm', 'phtml', 'php3', 'inc'); | ||
| 529 | - | ||
| 530 | - /** | ||
| 531 | - * @see HTTP_Upload_File::setValidExtensions() | ||
| 532 | - * @var string | ||
| 533 | - * @access private | ||
| 534 | - */ | ||
| 535 | - var $_extensions_mode = 'deny'; | ||
| 536 | - | ||
| 537 | - /** | ||
| 538 | - * Contains the desired chmod for uploaded files | ||
| 539 | - * @var int | ||
| 540 | - * @access private | ||
| 541 | - */ | ||
| 542 | - var $_chmod = HTTP_UPLOAD_DEFAULT_CHMOD; | ||
| 543 | - | ||
| 544 | - /** | ||
| 545 | - * Constructor | ||
| 546 | - * | ||
| 547 | - * @param string $name destination file name | ||
| 548 | - * @param string $tmp temp file name | ||
| 549 | - * @param string $formname name of the form | ||
| 550 | - * @param string $type Mime type of the file | ||
| 551 | - * @param string $size size of the file | ||
| 552 | - * @param string $error error on upload | ||
| 553 | - * @param string $lang used language for errormessages | ||
| 554 | - * @access public | ||
| 555 | - */ | ||
| 556 | - function HTTP_Upload_File($name = null, $tmp = null, $formname = null, | ||
| 557 | - $type = null, $size = null, $error = null, | ||
| 558 | - $lang = null, $chmod = HTTP_UPLOAD_DEFAULT_CHMOD) | ||
| 559 | - { | ||
| 560 | - $this->HTTP_Upload_Error($lang); | ||
| 561 | - $ext = null; | ||
| 562 | - | ||
| 563 | - if (empty($name) || $size == 0) { | ||
| 564 | - $error = 'NO_USER_FILE'; | ||
| 565 | - } elseif ($tmp == 'none') { | ||
| 566 | - $error = 'TOO_LARGE'; | ||
| 567 | - } else { | ||
| 568 | - // strpos needed to detect files without extension | ||
| 569 | - if (($pos = strrpos($name, '.')) !== false) { | ||
| 570 | - $ext = substr($name, $pos + 1); | ||
| 571 | - } | ||
| 572 | - } | ||
| 573 | - | ||
| 574 | - if (function_exists('version_compare') && | ||
| 575 | - version_compare(phpversion(), '4.1', 'ge')) { | ||
| 576 | - if (isset($_POST['MAX_FILE_SIZE']) && | ||
| 577 | - $size > $_POST['MAX_FILE_SIZE']) { | ||
| 578 | - $error = 'TOO_LARGE'; | ||
| 579 | - } | ||
| 580 | - } else { | ||
| 581 | - global $HTTP_POST_VARS; | ||
| 582 | - if (isset($HTTP_POST_VARS['MAX_FILE_SIZE']) && | ||
| 583 | - $size > $HTTP_POST_VARS['MAX_FILE_SIZE']) { | ||
| 584 | - $error = 'TOO_LARGE'; | ||
| 585 | - } | ||
| 586 | - } | ||
| 587 | - | ||
| 588 | - $this->upload = array( | ||
| 589 | - 'real' => $name, | ||
| 590 | - 'name' => $name, | ||
| 591 | - 'form_name' => $formname, | ||
| 592 | - 'ext' => $ext, | ||
| 593 | - 'tmp_name' => $tmp, | ||
| 594 | - 'size' => $size, | ||
| 595 | - 'type' => $type, | ||
| 596 | - 'error' => $error | ||
| 597 | - ); | ||
| 598 | - | ||
| 599 | - $this->_chmod = $chmod; | ||
| 600 | - } | ||
| 601 | - | ||
| 602 | - /** | ||
| 603 | - * Sets the name of the destination file | ||
| 604 | - * | ||
| 605 | - * @param string $mode A valid mode: 'uniq', 'safe' or 'real' or a file name | ||
| 606 | - * @param string $prepend A string to prepend to the name | ||
| 607 | - * @param string $append A string to append to the name | ||
| 608 | - * | ||
| 609 | - * @return string The modified name of the destination file | ||
| 610 | - * @access public | ||
| 611 | - */ | ||
| 612 | - function setName($mode, $prepend = null, $append = null) | ||
| 613 | - { | ||
| 614 | - switch ($mode) { | ||
| 615 | - case 'uniq': | ||
| 616 | - $name = $this->nameToUniq(); | ||
| 617 | - $this->upload['ext'] = $this->nameToSafe($this->upload['ext'], 10); | ||
| 618 | - $name .= '.' . $this->upload['ext']; | ||
| 619 | - break; | ||
| 620 | - case 'safe': | ||
| 621 | - $name = $this->nameToSafe($this->upload['real']); | ||
| 622 | - if (($pos = strrpos($name, '.')) !== false) { | ||
| 623 | - $this->upload['ext'] = substr($name, $pos + 1); | ||
| 624 | - } else { | ||
| 625 | - $this->upload['ext'] = ''; | ||
| 626 | - } | ||
| 627 | - break; | ||
| 628 | - case 'real': | ||
| 629 | - $name = $this->upload['real']; | ||
| 630 | - break; | ||
| 631 | - default: | ||
| 632 | - $name = $mode; | ||
| 633 | - } | ||
| 634 | - $this->upload['name'] = $prepend . $name . $append; | ||
| 635 | - $this->mode_name_selected = true; | ||
| 636 | - return $this->upload['name']; | ||
| 637 | - } | ||
| 638 | - | ||
| 639 | - /** | ||
| 640 | - * Unique file names in the form: 9022210413b75410c28bef.html | ||
| 641 | - * @see HTTP_Upload_File::setName() | ||
| 642 | - */ | ||
| 643 | - function nameToUniq() | ||
| 644 | - { | ||
| 645 | - if (! $this->_seeded) { | ||
| 646 | - srand((double) microtime() * 1000000); | ||
| 647 | - $this->_seeded = 1; | ||
| 648 | - } | ||
| 649 | - $uniq = uniqid(rand()); | ||
| 650 | - return $uniq; | ||
| 651 | - } | ||
| 652 | - | ||
| 653 | - /** | ||
| 654 | - * Format a file name to be safe | ||
| 655 | - * | ||
| 656 | - * @param string $file The string file name | ||
| 657 | - * @param int $maxlen Maximun permited string lenght | ||
| 658 | - * @return string Formatted file name | ||
| 659 | - * @see HTTP_Upload_File::setName() | ||
| 660 | - */ | ||
| 661 | - function nameToSafe($name, $maxlen=250) | ||
| 662 | - { | ||
| 663 | - $noalpha = 'รรรรรรรกรฉรญรณรบรฝรรรรรรขรชรฎรดรปรรรรรร รจรฌรฒรนรรรรรรครซรฏรถรผรฟรรฃรรตร รฅรรฑรรง@ยฐยบยช'; | ||
| 664 | - $alpha = 'AEIOUYaeiouyAEIOUaeiouAEIOUaeiouAEIOUaeiouyAaOoAaNnCcaooa'; | ||
| 665 | - | ||
| 666 | - $name = substr($name, 0, $maxlen); | ||
| 667 | - $name = strtr($name, $noalpha, $alpha); | ||
| 668 | - // not permitted chars are replaced with "_" | ||
| 669 | - return preg_replace('/[^a-zA-Z0-9,._\+\()\-]/', '_', $name); | ||
| 670 | - } | ||
| 671 | - | ||
| 672 | - /** | ||
| 673 | - * The upload was valid | ||
| 674 | - * | ||
| 675 | - * @return bool If the file was submitted correctly | ||
| 676 | - * @access public | ||
| 677 | - */ | ||
| 678 | - function isValid() | ||
| 679 | - { | ||
| 680 | - if ($this->upload['error'] === null) { | ||
| 681 | - return true; | ||
| 682 | - } | ||
| 683 | - return false; | ||
| 684 | - } | ||
| 685 | - | ||
| 686 | - /** | ||
| 687 | - * User haven't submit a file | ||
| 688 | - * | ||
| 689 | - * @return bool If the user submitted a file or not | ||
| 690 | - * @access public | ||
| 691 | - */ | ||
| 692 | - function isMissing() | ||
| 693 | - { | ||
| 694 | - if ($this->upload['error'] == 'NO_USER_FILE') { | ||
| 695 | - return true; | ||
| 696 | - } | ||
| 697 | - return false; | ||
| 698 | - } | ||
| 699 | - | ||
| 700 | - /** | ||
| 701 | - * Some error occured during upload (most common due a file size problem, | ||
| 702 | - * like max size exceeded or 0 bytes long). | ||
| 703 | - * @return bool If there were errors submitting the file (probably | ||
| 704 | - * because the file excess the max permitted file size) | ||
| 705 | - * @access public | ||
| 706 | - */ | ||
| 707 | - function isError() | ||
| 708 | - { | ||
| 709 | - if (in_array($this->upload['error'], array('TOO_LARGE', 'BAD_FORM','DEV_NO_DEF_FILE'))) { | ||
| 710 | - return true; | ||
| 711 | - } | ||
| 712 | - return false; | ||
| 713 | - } | ||
| 714 | - | ||
| 715 | - /** | ||
| 716 | - * Moves the uploaded file to its destination directory. | ||
| 717 | - * | ||
| 718 | - * @param string $dir_dest Destination directory | ||
| 719 | - * @param bool $overwrite Overwrite if destination file exists? | ||
| 720 | - * @return mixed True on success or Pear_Error object on error | ||
| 721 | - * @access public | ||
| 722 | - */ | ||
| 723 | - function moveTo($dir_dest, $overwrite = true) | ||
| 724 | - { | ||
| 725 | - if (!$this->isValid()) { | ||
| 726 | - return $this->raiseError($this->upload['error']); | ||
| 727 | - } | ||
| 728 | - | ||
| 729 | - //Valid extensions check | ||
| 730 | - if (!$this->_evalValidExtensions()) { | ||
| 731 | - return $this->raiseError('NOT_ALLOWED_EXTENSION'); | ||
| 732 | - } | ||
| 733 | - | ||
| 734 | - $err_code = $this->_chk_dir_dest($dir_dest); | ||
| 735 | - if ($err_code !== false) { | ||
| 736 | - return $this->raiseError($err_code); | ||
| 737 | - } | ||
| 738 | - // Use 'safe' mode by default if no other was selected | ||
| 739 | - if (!$this->mode_name_selected) { | ||
| 740 | - $this->setName('safe'); | ||
| 741 | - } | ||
| 742 | - | ||
| 743 | - $name_dest = $dir_dest . DIRECTORY_SEPARATOR . $this->upload['name']; | ||
| 744 | - | ||
| 745 | - if (@is_file($name_dest)) { | ||
| 746 | - if ($overwrite !== true) { | ||
| 747 | - return $this->raiseError('FILE_EXISTS'); | ||
| 748 | - } elseif (!is_writable($name_dest)) { | ||
| 749 | - return $this->raiseError('CANNOT_OVERWRITE'); | ||
| 750 | - } | ||
| 751 | - } | ||
| 752 | - | ||
| 753 | - // copy the file and let php clean the tmp | ||
| 754 | - if (!@move_uploaded_file($this->upload['tmp_name'], $name_dest)) { | ||
| 755 | - return $this->raiseError('E_FAIL_MOVE'); | ||
| 756 | - } | ||
| 757 | - @chmod($name_dest, $this->_chmod); | ||
| 758 | - return $this->getProp('name'); | ||
| 759 | - } | ||
| 760 | - | ||
| 761 | - /** | ||
| 762 | - * Check for a valid destination dir | ||
| 763 | - * | ||
| 764 | - * @param string $dir_dest Destination dir | ||
| 765 | - * @return mixed False on no errors or error code on error | ||
| 766 | - */ | ||
| 767 | - function _chk_dir_dest($dir_dest) | ||
| 768 | - { | ||
| 769 | - if (!$dir_dest) { | ||
| 770 | - return 'MISSING_DIR'; | ||
| 771 | - } | ||
| 772 | - if (!@is_dir ($dir_dest)) { | ||
| 773 | - return 'IS_NOT_DIR'; | ||
| 774 | - } | ||
| 775 | - if (!is_writeable ($dir_dest)) { | ||
| 776 | - return 'NO_WRITE_PERMS'; | ||
| 777 | - } | ||
| 778 | - return false; | ||
| 779 | - } | ||
| 780 | - /** | ||
| 781 | - * Retrive properties of the uploaded file | ||
| 782 | - * @param string $name The property name. When null an assoc array with | ||
| 783 | - * all the properties will be returned | ||
| 784 | - * @return mixed A string or array | ||
| 785 | - * @see HTTP_Upload_File::HTTP_Upload_File() | ||
| 786 | - * @access public | ||
| 787 | - */ | ||
| 788 | - function getProp($name = null) | ||
| 789 | - { | ||
| 790 | - if ($name === null) { | ||
| 791 | - return $this->upload; | ||
| 792 | - } | ||
| 793 | - return $this->upload[$name]; | ||
| 794 | - } | ||
| 795 | - | ||
| 796 | - /** | ||
| 797 | - * Returns a error message, if a error occured | ||
| 798 | - * (deprecated) Use getMessage() instead | ||
| 799 | - * @return string a Error message | ||
| 800 | - * @access public | ||
| 801 | - */ | ||
| 802 | - function errorMsg() | ||
| 803 | - { | ||
| 804 | - return $this->errorCode($this->upload['error']); | ||
| 805 | - } | ||
| 806 | - | ||
| 807 | - /** | ||
| 808 | - * Returns a error message, if a error occured | ||
| 809 | - * @return string a Error message | ||
| 810 | - * @access public | ||
| 811 | - */ | ||
| 812 | - function getMessage() | ||
| 813 | - { | ||
| 814 | - return $this->errorCode($this->upload['error']); | ||
| 815 | - } | ||
| 816 | - | ||
| 817 | - /** | ||
| 818 | - * Function to restrict the valid extensions on file uploads | ||
| 819 | - * | ||
| 820 | - * @param array $exts File extensions to validate | ||
| 821 | - * @param string $mode The type of validation: | ||
| 822 | - * 1) 'deny' Will deny only the supplied extensions | ||
| 823 | - * 2) 'accept' Will accept only the supplied extensions | ||
| 824 | - * as valid | ||
| 825 | - * @access public | ||
| 826 | - */ | ||
| 827 | - function setValidExtensions($exts, $mode = 'deny') | ||
| 828 | - { | ||
| 829 | - $this->_extensions_check = $exts; | ||
| 830 | - $this->_extensions_mode = $mode; | ||
| 831 | - } | ||
| 832 | - | ||
| 833 | - /** | ||
| 834 | - * Evaluates the validity of the extensions set by setValidExtensions | ||
| 835 | - * | ||
| 836 | - * @return bool False on non valid extension, true if they are valid | ||
| 837 | - * @access private | ||
| 838 | - */ | ||
| 839 | - function _evalValidExtensions() | ||
| 840 | - { | ||
| 841 | - $exts = $this->_extensions_check; | ||
| 842 | - settype($exts, 'array'); | ||
| 843 | - if ($this->_extensions_mode == 'deny') { | ||
| 844 | - if (in_array($this->getProp('ext'), $exts)) { | ||
| 845 | - return false; | ||
| 846 | - } | ||
| 847 | - // mode == 'accept' | ||
| 848 | - } else { | ||
| 849 | - if (!in_array($this->getProp('ext'), $exts)) { | ||
| 850 | - return false; | ||
| 851 | - } | ||
| 852 | - } | ||
| 853 | - return true; | ||
| 854 | - } | ||
| 855 | -} | 1 | +<?php |
| 2 | +// ********************************************** | ||
| 3 | +// | ||
| 4 | +// This software is licensed by the LGPL | ||
| 5 | +// -> http://www.gnu.org/copyleft/lesser.txt | ||
| 6 | +// (c) 2001-2004 by Tomas Von Veschler Cox | ||
| 7 | +// | ||
| 8 | +// ********************************************** | ||
| 9 | +// | ||
| 10 | +// $Id$ | ||
| 11 | + | ||
| 12 | +/* | ||
| 13 | + * Pear File Uploader class. Easy and secure managment of files | ||
| 14 | + * submitted via HTML Forms. | ||
| 15 | + * | ||
| 16 | + * Leyend: | ||
| 17 | + * - you can add error msgs in your language in the HTTP_Upload_Error class | ||
| 18 | + * | ||
| 19 | + * TODO: | ||
| 20 | + * - try to think a way of having all the Error system in other | ||
| 21 | + * file and only include it when an error ocurrs | ||
| 22 | + * | ||
| 23 | + * -- Notes for users HTTP_Upload >= 0.9.0 -- | ||
| 24 | + * | ||
| 25 | + * Error detection was enhanced, so you no longer need to | ||
| 26 | + * check for PEAR::isError() in $upload->getFiles() or call | ||
| 27 | + * $upload->isMissing(). Instead you'll | ||
| 28 | + * get the error when do a check for $file->isError(). | ||
| 29 | + * | ||
| 30 | + * Example: | ||
| 31 | + * | ||
| 32 | + * $upload = new HTTP_Upload('en'); | ||
| 33 | + * $file = $upload->getFiles('i_dont_exist_in_form_definition'); | ||
| 34 | + * if ($file->isError()) { | ||
| 35 | + * die($file->getMessage()); | ||
| 36 | + * } | ||
| 37 | + * | ||
| 38 | + * -- | ||
| 39 | + * | ||
| 40 | + */ | ||
| 41 | + | ||
| 42 | +require_once 'PEAR.php'; | ||
| 43 | + | ||
| 44 | +/** | ||
| 45 | + * defines default chmod | ||
| 46 | + */ | ||
| 47 | +define('HTTP_UPLOAD_DEFAULT_CHMOD', 0660); | ||
| 48 | + | ||
| 49 | +/** | ||
| 50 | + * Error Class for HTTP_Upload | ||
| 51 | + * | ||
| 52 | + * @author Tomas V.V.Cox <cox@idecnet.com> | ||
| 53 | + * @see http://vulcanonet.com/soft/index.php?pack=uploader | ||
| 54 | + * @package HTTP_Upload | ||
| 55 | + * @category HTTP | ||
| 56 | + * @access public | ||
| 57 | + */ | ||
| 58 | +class HTTP_Upload_Error extends PEAR | ||
| 59 | +{ | ||
| 60 | + /** | ||
| 61 | + * Selected language for error messages | ||
| 62 | + * @var string | ||
| 63 | + */ | ||
| 64 | + var $lang = 'en'; | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * Whether HTML entities shall be encoded automatically | ||
| 68 | + * @var boolean | ||
| 69 | + */ | ||
| 70 | + var $html = false; | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * Constructor | ||
| 74 | + * | ||
| 75 | + * Creates a new PEAR_Error | ||
| 76 | + * | ||
| 77 | + * @param string $lang The language selected for error code messages | ||
| 78 | + * @access public | ||
| 79 | + */ | ||
| 80 | + function HTTP_Upload_Error($lang = null, $html = false) | ||
| 81 | + { | ||
| 82 | + $this->lang = ($lang !== null) ? $lang : $this->lang; | ||
| 83 | + $this->html = ($html !== false) ? $html : $this->html; | ||
| 84 | + $ini_size = preg_replace('/m/i', '000000', ini_get('upload_max_filesize')); | ||
| 85 | + | ||
| 86 | + if (function_exists('version_compare') && | ||
| 87 | + version_compare(phpversion(), '4.1', 'ge')) { | ||
| 88 | + $maxsize = (isset($_POST['MAX_FILE_SIZE'])) ? | ||
| 89 | + $_POST['MAX_FILE_SIZE'] : null; | ||
| 90 | + } else { | ||
| 91 | + global $HTTP_POST_VARS; | ||
| 92 | + $maxsize = (isset($HTTP_POST_VARS['MAX_FILE_SIZE'])) ? | ||
| 93 | + $HTTP_POST_VARS['MAX_FILE_SIZE'] : null; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + if (empty($maxsize) || ($maxsize > $ini_size)) { | ||
| 97 | + $maxsize = $ini_size; | ||
| 98 | + } | ||
| 99 | + // XXXXX Add here error messages in your language | ||
| 100 | + $this->error_codes = array( | ||
| 101 | + 'TOO_LARGE' => array( | ||
| 102 | + 'es' => "Fichero demasiado largo. El maximo permitido es: $maxsize bytes.", | ||
| 103 | + 'en' => "File size too large. The maximum permitted size is: $maxsize bytes.", | ||
| 104 | + 'de' => "Datei zu groß. Die zulässige Maximalgröße ist: $maxsize Bytes.", | ||
| 105 | + 'nl' => "Het bestand is te groot, de maximale grootte is: $maxsize bytes.", | ||
| 106 | + 'fr' => "Le fichier est trop gros. La taille maximum autorisée est: $maxsize bytes.", | ||
| 107 | + 'it' => "Il file é troppo grande. Il massimo permesso é: $maxsize bytes.", | ||
| 108 | + 'pt_BR' => "Arquivo muito grande. O tamanho máximo permitido é $maxsize bytes." | ||
| 109 | + ), | ||
| 110 | + 'MISSING_DIR' => array( | ||
| 111 | + 'es' => 'Falta directorio destino.', | ||
| 112 | + 'en' => 'Missing destination directory.', | ||
| 113 | + 'de' => 'Kein Zielverzeichnis definiert.', | ||
| 114 | + 'nl' => 'Geen bestemmings directory.', | ||
| 115 | + 'fr' => 'Le répertoire de destination n\'est pas défini.', | ||
| 116 | + 'it' => 'Manca la directory di destinazione.', | ||
| 117 | + 'pt_BR' => 'Ausência de diretório de destino.' | ||
| 118 | + ), | ||
| 119 | + 'IS_NOT_DIR' => array( | ||
| 120 | + 'es' => 'El directorio destino no existe o es un fichero regular.', | ||
| 121 | + 'en' => 'The destination directory doesn\'t exist or is a regular file.', | ||
| 122 | + 'de' => 'Das angebene Zielverzeichnis existiert nicht oder ist eine Datei.', | ||
| 123 | + 'nl' => 'De doeldirectory bestaat niet, of is een gewoon bestand.', | ||
| 124 | + 'fr' => 'Le répertoire de destination n\'existe pas ou il s\'agit d\'un fichier régulier.', | ||
| 125 | + 'it' => 'La directory di destinazione non esiste o é un file.', | ||
| 126 | + 'pt_BR' => 'O diretório de destino não existe ou é um arquivo.' | ||
| 127 | + ), | ||
| 128 | + 'NO_WRITE_PERMS' => array( | ||
| 129 | + 'es' => 'El directorio destino no tiene permisos de escritura.', | ||
| 130 | + 'en' => 'The destination directory doesn\'t have write perms.', | ||
| 131 | + 'de' => 'Fehlende Schreibrechte für das Zielverzeichnis.', | ||
| 132 | + 'nl' => 'Geen toestemming om te schrijven in de doeldirectory.', | ||
| 133 | + 'fr' => 'Le répertoire de destination n\'a pas les droits en écriture.', | ||
| 134 | + 'it' => 'Non si hanno i permessi di scrittura sulla directory di destinazione.', | ||
| 135 | + 'pt_BR' => 'O diretório de destino não possui permissão para escrita.' | ||
| 136 | + ), | ||
| 137 | + 'NO_USER_FILE' => array( | ||
| 138 | + 'es' => 'No se ha escogido fichero para el upload.', | ||
| 139 | + 'en' => 'You haven\'t selected any file for uploading.', | ||
| 140 | + 'de' => 'Es wurde keine Datei für den Upload ausgewählt.', | ||
| 141 | + 'nl' => 'Er is geen bestand opgegeven om te uploaden.', | ||
| 142 | + 'fr' => 'Vous n\'avez pas sélectionné de fichier à envoyer.', | ||
| 143 | + 'it' => 'Nessun file selezionato per l\'upload.', | ||
| 144 | + 'pt_BR' => 'Nenhum arquivo selecionado para upload.' | ||
| 145 | + ), | ||
| 146 | + 'BAD_FORM' => array( | ||
| 147 | + 'es' => 'El formulario no contiene method="post" enctype="multipart/form-data" requerido.', | ||
| 148 | + 'en' => 'The html form doesn\'t contain the required method="post" enctype="multipart/form-data".', | ||
| 149 | + 'de' => 'Das HTML-Formular enthält nicht die Angabe method="post" enctype="multipart/form-data" '. | ||
| 150 | + 'im >form<-Tag.', | ||
| 151 | + 'nl' => 'Het HTML-formulier bevat niet de volgende benodigde '. | ||
| 152 | + 'eigenschappen: method="post" enctype="multipart/form-data".', | ||
| 153 | + 'fr' => 'Le formulaire HTML ne contient pas les attributs requis : '. | ||
| 154 | + ' method="post" enctype="multipart/form-data".', | ||
| 155 | + 'it' => 'Il modulo HTML non contiene gli attributi richiesti: "'. | ||
| 156 | + ' method="post" enctype="multipart/form-data".', | ||
| 157 | + 'pt_BR' => 'O formulário HTML não possui o method="post" enctype="multipart/form-data" requerido.' | ||
| 158 | + ), | ||
| 159 | + 'E_FAIL_COPY' => array( | ||
| 160 | + 'es' => 'Fallo al copiar el fichero temporal.', | ||
| 161 | + 'en' => 'Failed to copy the temporary file.', | ||
| 162 | + 'de' => 'Temporäre Datei konnte nicht kopiert werden.', | ||
| 163 | + 'nl' => 'Het tijdelijke bestand kon niet gekopieerd worden.', | ||
| 164 | + 'fr' => 'L\'enregistrement du fichier temporaire a échoué.', | ||
| 165 | + 'it' => 'Copia del file temporaneo fallita.', | ||
| 166 | + 'pt_BR' => 'Falha ao copiar o arquivo temporário.' | ||
| 167 | + ), | ||
| 168 | + 'E_FAIL_MOVE' => array( | ||
| 169 | + 'es' => 'No puedo mover el fichero.', | ||
| 170 | + 'en' => 'Impossible to move the file.', | ||
| 171 | + 'de' => 'Datei kann nicht verschoben werden.', | ||
| 172 | + 'nl' => 'Het bestand kon niet verplaatst worden.', | ||
| 173 | + 'fr' => 'Impossible de déplacer le fichier.', | ||
| 174 | + 'pt_BR' => 'Não foi possível mover o arquivo.' | ||
| 175 | + ), | ||
| 176 | + 'FILE_EXISTS' => array( | ||
| 177 | + 'es' => 'El fichero destino ya existe.', | ||
| 178 | + 'en' => 'The destination file already exists.', | ||
| 179 | + 'de' => 'Die zu erzeugende Datei existiert bereits.', | ||
| 180 | + 'nl' => 'Het doelbestand bestaat al.', | ||
| 181 | + 'fr' => 'Le fichier de destination existe déjà.', | ||
| 182 | + 'it' => 'File destinazione già esistente.', | ||
| 183 | + 'pt_BR' => 'O arquivo de destino já existe.' | ||
| 184 | + ), | ||
| 185 | + 'CANNOT_OVERWRITE' => array( | ||
| 186 | + 'es' => 'El fichero destino ya existe y no se puede sobreescribir.', | ||
| 187 | + 'en' => 'The destination file already exists and could not be overwritten.', | ||
| 188 | + 'de' => 'Die zu erzeugende Datei existiert bereits und konnte nicht überschrieben werden.', | ||
| 189 | + 'nl' => 'Het doelbestand bestaat al, en kon niet worden overschreven.', | ||
| 190 | + 'fr' => 'Le fichier de destination existe déjà et ne peux pas être remplacé.', | ||
| 191 | + 'it' => 'File destinazione già esistente e non si può sovrascrivere.', | ||
| 192 | + 'pt_BR' => 'O arquivo de destino já existe e não pôde ser sobrescrito.' | ||
| 193 | + ), | ||
| 194 | + 'NOT_ALLOWED_EXTENSION' => array( | ||
| 195 | + 'es' => 'Extension de fichero no permitida.', | ||
| 196 | + 'en' => 'File extension not permitted.', | ||
| 197 | + 'de' => 'Unerlaubte Dateiendung.', | ||
| 198 | + 'nl' => 'Niet toegestane bestands-extensie.', | ||
| 199 | + 'fr' => 'Le fichier a une extension non autorisée.', | ||
| 200 | + 'it' => 'Estensione del File non permessa.', | ||
| 201 | + 'pt_BR' => 'Extensão de arquivo não permitida.' | ||
| 202 | + ), | ||
| 203 | + 'PARTIAL' => array( | ||
| 204 | + 'es' => 'El fichero fue parcialmente subido', | ||
| 205 | + 'en' => 'The file was only partially uploaded.', | ||
| 206 | + 'de' => 'Die Datei wurde unvollständig übertragen.', | ||
| 207 | + 'nl' => 'Het bestand is slechts gedeeltelijk geupload.', | ||
| 208 | + 'pt_BR' => 'O arquivo nรฃo foi enviado por completo.' | ||
| 209 | + ), | ||
| 210 | + 'ERROR' => array( | ||
| 211 | + 'es' => 'Error en subida:', | ||
| 212 | + 'en' => 'Upload error:', | ||
| 213 | + 'de' => 'Fehler beim Upload:', | ||
| 214 | + 'nl' => 'Upload fout:', | ||
| 215 | + 'pt_BR' => 'Erro de upload:' | ||
| 216 | + ), | ||
| 217 | + 'DEV_NO_DEF_FILE' => array( | ||
| 218 | + 'es' => 'No estรก definido en el formulario este nombre de fichero como <input type="file" name=?>.', | ||
| 219 | + 'en' => 'This filename is not defined in the form as <input type="file" name=?>.', | ||
| 220 | + 'de' => 'Dieser Dateiname ist im Formular nicht als <input type="file" name=?> definiert.', | ||
| 221 | + 'nl' => 'Deze bestandsnaam is niett gedefineerd in het formulier als <input type="file" name=?>.' | ||
| 222 | + ) | ||
| 223 | + ); | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + /** | ||
| 227 | + * returns the error code | ||
| 228 | + * | ||
| 229 | + * @param string $e_code type of error | ||
| 230 | + * @return string Error message | ||
| 231 | + */ | ||
| 232 | + function errorCode($e_code) | ||
| 233 | + { | ||
| 234 | + if (!empty($this->error_codes[$e_code][$this->lang])) { | ||
| 235 | + $msg = $this->html ? | ||
| 236 | + html_entity_decode($this->error_codes[$e_code][$this->lang]) : | ||
| 237 | + $this->error_codes[$e_code][$this->lang]; | ||
| 238 | + } else { | ||
| 239 | + $msg = $e_code; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + if (!empty($this->error_codes['ERROR'][$this->lang])) { | ||
| 243 | + $error = $this->error_codes['ERROR'][$this->lang]; | ||
| 244 | + } else { | ||
| 245 | + $error = $this->error_codes['ERROR']['en']; | ||
| 246 | + } | ||
| 247 | + return $error.' '.$msg; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * Overwrites the PEAR::raiseError method | ||
| 252 | + * | ||
| 253 | + * @param string $e_code type of error | ||
| 254 | + * @return object PEAR_Error a PEAR-Error object | ||
| 255 | + * @access public | ||
| 256 | + */ | ||
| 257 | + function raiseError($e_code) | ||
| 258 | + { | ||
| 259 | + return PEAR::raiseError($this->errorCode($e_code), $e_code); | ||
| 260 | + } | ||
| 261 | +} | ||
| 262 | + | ||
| 263 | +/** | ||
| 264 | + * This class provides an advanced file uploader system | ||
| 265 | + * for file uploads made from html forms | ||
| 266 | + | ||
| 267 | + * | ||
| 268 | + * @author Tomas V.V.Cox <cox@idecnet.com> | ||
| 269 | + * @see http://vulcanonet.com/soft/index.php?pack=uploader | ||
| 270 | + * @package HTTP_Upload | ||
| 271 | + * @category HTTP | ||
| 272 | + * @access public | ||
| 273 | + */ | ||
| 274 | +class HTTP_Upload extends HTTP_Upload_Error | ||
| 275 | +{ | ||
| 276 | + /** | ||
| 277 | + * Contains an array of "uploaded files" objects | ||
| 278 | + * @var array | ||
| 279 | + */ | ||
| 280 | + var $files = array(); | ||
| 281 | + | ||
| 282 | + /** | ||
| 283 | + * Contains the desired chmod for uploaded files | ||
| 284 | + * @var int | ||
| 285 | + * @access private | ||
| 286 | + */ | ||
| 287 | + var $_chmod = HTTP_UPLOAD_DEFAULT_CHMOD; | ||
| 288 | + | ||
| 289 | + /** | ||
| 290 | + * Constructor | ||
| 291 | + * | ||
| 292 | + * @param string $lang Language to use for reporting errors | ||
| 293 | + * @see Upload_Error::error_codes | ||
| 294 | + * @access public | ||
| 295 | + */ | ||
| 296 | + function HTTP_Upload($lang = null) | ||
| 297 | + { | ||
| 298 | + $this->HTTP_Upload_Error($lang); | ||
| 299 | + if (function_exists('version_compare') && | ||
| 300 | + version_compare(phpversion(), '4.1', 'ge')) | ||
| 301 | + { | ||
| 302 | + $this->post_files = $_FILES; | ||
| 303 | + if (isset($_SERVER['CONTENT_TYPE'])) { | ||
| 304 | + $this->content_type = $_SERVER['CONTENT_TYPE']; | ||
| 305 | + } | ||
| 306 | + } else { | ||
| 307 | + global $HTTP_POST_FILES, $HTTP_SERVER_VARS; | ||
| 308 | + $this->post_files = $HTTP_POST_FILES; | ||
| 309 | + if (isset($HTTP_SERVER_VARS['CONTENT_TYPE'])) { | ||
| 310 | + $this->content_type = $HTTP_SERVER_VARS['CONTENT_TYPE']; | ||
| 311 | + } | ||
| 312 | + } | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + /** | ||
| 316 | + * Get files | ||
| 317 | + * | ||
| 318 | + * @param mixed $file If: | ||
| 319 | + * - not given, function will return array of upload_file objects | ||
| 320 | + * - is int, will return the $file position in upload_file objects array | ||
| 321 | + * - is string, will return the upload_file object corresponding | ||
| 322 | + * to $file name of the form. For ex: | ||
| 323 | + * if form is <input type="file" name="userfile"> | ||
| 324 | + * to get this file use: $upload->getFiles('userfile') | ||
| 325 | + * | ||
| 326 | + * @return mixed array or object (see @param $file above) or Pear_Error | ||
| 327 | + * @access public | ||
| 328 | + */ | ||
| 329 | + function &getFiles($file = null) | ||
| 330 | + { | ||
| 331 | + static $is_built = false; | ||
| 332 | + //build only once for multiple calls | ||
| 333 | + if (!$is_built) { | ||
| 334 | + $files = &$this->_buildFiles(); | ||
| 335 | + if (PEAR::isError($files)) { | ||
| 336 | + // there was an error with the form. | ||
| 337 | + // Create a faked upload embedding the error | ||
| 338 | + $this->files['_error'] = &new HTTP_Upload_File( | ||
| 339 | + '_error', null, | ||
| 340 | + null, null, | ||
| 341 | + null, $files->getCode(), | ||
| 342 | + $this->lang, $this->_chmod); | ||
| 343 | + } else { | ||
| 344 | + $this->files = $files; | ||
| 345 | + } | ||
| 346 | + $is_built = true; | ||
| 347 | + } | ||
| 348 | + if ($file !== null) { | ||
| 349 | + if (is_int($file)) { | ||
| 350 | + $pos = 0; | ||
| 351 | + foreach ($this->files as $obj) { | ||
| 352 | + if ($pos == $file) { | ||
| 353 | + return $obj; | ||
| 354 | + } | ||
| 355 | + $pos++; | ||
| 356 | + } | ||
| 357 | + } elseif (is_string($file) && isset($this->files[$file])) { | ||
| 358 | + return $this->files[$file]; | ||
| 359 | + } | ||
| 360 | + if (isset($this->files['_error'])) { | ||
| 361 | + return $this->files['_error']; | ||
| 362 | + } else { | ||
| 363 | + // developer didn't specify this name in the form | ||
| 364 | + // warn him about it with a faked upload | ||
| 365 | + return new HTTP_Upload_File( | ||
| 366 | + '_error', null, | ||
| 367 | + null, null, | ||
| 368 | + null, 'DEV_NO_DEF_FILE', | ||
| 369 | + $this->lang); | ||
| 370 | + } | ||
| 371 | + } | ||
| 372 | + return $this->files; | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + /** | ||
| 376 | + * Creates the list of the uploaded file | ||
| 377 | + * | ||
| 378 | + * @return array of HTTP_Upload_File objects for every file | ||
| 379 | + */ | ||
| 380 | + function &_buildFiles() | ||
| 381 | + { | ||
| 382 | + // Form method check | ||
| 383 | + if (!isset($this->content_type) || | ||
| 384 | + strpos($this->content_type, 'multipart/form-data') !== 0) | ||
| 385 | + { | ||
| 386 | + return $this->raiseError('BAD_FORM'); | ||
| 387 | + } | ||
| 388 | + // In 4.1 $_FILES isn't initialized when no uploads | ||
| 389 | + // XXX (cox) afaik, in >= 4.1 and <= 4.3 only | ||
| 390 | + if (function_exists('version_compare') && | ||
| 391 | + version_compare(phpversion(), '4.1', 'ge')) | ||
| 392 | + { | ||
| 393 | + $error = $this->isMissing(); | ||
| 394 | + if (PEAR::isError($error)) { | ||
| 395 | + return $error; | ||
| 396 | + } | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + // map error codes from 4.2.0 $_FILES['userfile']['error'] | ||
| 400 | + if (function_exists('version_compare') && | ||
| 401 | + version_compare(phpversion(), '4.2.0', 'ge')) { | ||
| 402 | + $uploadError = array( | ||
| 403 | + 1 => 'TOO_LARGE', | ||
| 404 | + 2 => 'TOO_LARGE', | ||
| 405 | + 3 => 'PARTIAL', | ||
| 406 | + 4 => 'NO_USER_FILE' | ||
| 407 | + ); | ||
| 408 | + } | ||
| 409 | + | ||
| 410 | + | ||
| 411 | + // Parse $_FILES (or $HTTP_POST_FILES) | ||
| 412 | + $files = array(); | ||
| 413 | + foreach ($this->post_files as $userfile => $value) { | ||
| 414 | + if (is_array($value['name'])) { | ||
| 415 | + foreach ($value['name'] as $key => $val) { | ||
| 416 | + $err = $value['error'][$key]; | ||
| 417 | + if (isset($err) && $err !== 0 && isset($uploadError[$err])) { | ||
| 418 | + $error = $uploadError[$err]; | ||
| 419 | + } else { | ||
| 420 | + $error = null; | ||
| 421 | + } | ||
| 422 | + $name = basename($value['name'][$key]); | ||
| 423 | + $tmp_name = $value['tmp_name'][$key]; | ||
| 424 | + $size = $value['size'][$key]; | ||
| 425 | + $type = $value['type'][$key]; | ||
| 426 | + $formname = $userfile . "[$key]"; | ||
| 427 | + $files[$formname] = new HTTP_Upload_File($name, $tmp_name, | ||
| 428 | + $formname, $type, $size, $error, $this->lang, $this->_chmod); | ||
| 429 | + } | ||
| 430 | + // One file | ||
| 431 | + } else { | ||
| 432 | + $err = $value['error']; | ||
| 433 | + if (isset($err) && $err !== 0 && isset($uploadError[$err])) { | ||
| 434 | + $error = $uploadError[$err]; | ||
| 435 | + } else { | ||
| 436 | + $error = null; | ||
| 437 | + } | ||
| 438 | + $name = basename($value['name']); | ||
| 439 | + $tmp_name = $value['tmp_name']; | ||
| 440 | + $size = $value['size']; | ||
| 441 | + $type = $value['type']; | ||
| 442 | + $formname = $userfile; | ||
| 443 | + $files[$formname] = new HTTP_Upload_File($name, $tmp_name, | ||
| 444 | + $formname, $type, $size, $error, $this->lang, $this->_chmod); | ||
| 445 | + } | ||
| 446 | + } | ||
| 447 | + return $files; | ||
| 448 | + } | ||
| 449 | + | ||
| 450 | + /** | ||
| 451 | + * Checks if the user submited or not some file | ||
| 452 | + * | ||
| 453 | + * @return mixed False when are files or PEAR_Error when no files | ||
| 454 | + * @access public | ||
| 455 | + * @see Read the note in the source code about this function | ||
| 456 | + */ | ||
| 457 | + function isMissing() | ||
| 458 | + { | ||
| 459 | + if (count($this->post_files) < 1) { | ||
| 460 | + return $this->raiseError('NO_USER_FILE'); | ||
| 461 | + } | ||
| 462 | + //we also check if at least one file has more than 0 bytes :) | ||
| 463 | + $files = array(); | ||
| 464 | + $size = 0; | ||
| 465 | + foreach ($this->post_files as $userfile => $value) { | ||
| 466 | + if (is_array($value['name'])) { | ||
| 467 | + foreach ($value['name'] as $key => $val) { | ||
| 468 | + $size += $value['size'][$key]; | ||
| 469 | + } | ||
| 470 | + } else { //one file | ||
| 471 | + $size = $value['size']; | ||
| 472 | + } | ||
| 473 | + } | ||
| 474 | + if ($size == 0) { | ||
| 475 | + $this->raiseError('NO_USER_FILE'); | ||
| 476 | + } | ||
| 477 | + return false; | ||
| 478 | + } | ||
| 479 | + | ||
| 480 | + /** | ||
| 481 | + * Sets the chmod to be used for uploaded files | ||
| 482 | + * | ||
| 483 | + * @param int Desired mode | ||
| 484 | + */ | ||
| 485 | + function setChmod($mode) | ||
| 486 | + { | ||
| 487 | + $this->_chmod = $mode; | ||
| 488 | + } | ||
| 489 | +} | ||
| 490 | + | ||
| 491 | +/** | ||
| 492 | + * This class provides functions to work with the uploaded file | ||
| 493 | + * | ||
| 494 | + * @author Tomas V.V.Cox <cox@idecnet.com> | ||
| 495 | + * @see http://vulcanonet.com/soft/index.php?pack=uploader | ||
| 496 | + * @package HTTP_Upload | ||
| 497 | + * @category HTTP | ||
| 498 | + * @access public | ||
| 499 | + */ | ||
| 500 | +class HTTP_Upload_File extends HTTP_Upload_Error | ||
| 501 | +{ | ||
| 502 | + /** | ||
| 503 | + * If the random seed was initialized before or not | ||
| 504 | + * @var boolean; | ||
| 505 | + */ | ||
| 506 | + var $_seeded = 0; | ||
| 507 | + | ||
| 508 | + /** | ||
| 509 | + * Assoc array with file properties | ||
| 510 | + * @var array | ||
| 511 | + */ | ||
| 512 | + var $upload = array(); | ||
| 513 | + | ||
| 514 | + /** | ||
| 515 | + * If user haven't selected a mode, by default 'safe' will be used | ||
| 516 | + * @var boolean | ||
| 517 | + */ | ||
| 518 | + var $mode_name_selected = false; | ||
| 519 | + | ||
| 520 | + /** | ||
| 521 | + * It's a common security risk in pages who has the upload dir | ||
| 522 | + * under the document root (remember the hack of the Apache web?) | ||
| 523 | + * | ||
| 524 | + * @var array | ||
| 525 | + * @access private | ||
| 526 | + * @see HTTP_Upload_File::setValidExtensions() | ||
| 527 | + */ | ||
| 528 | + var $_extensions_check = array('php', 'phtm', 'phtml', 'php3', 'inc'); | ||
| 529 | + | ||
| 530 | + /** | ||
| 531 | + * @see HTTP_Upload_File::setValidExtensions() | ||
| 532 | + * @var string | ||
| 533 | + * @access private | ||
| 534 | + */ | ||
| 535 | + var $_extensions_mode = 'deny'; | ||
| 536 | + | ||
| 537 | + /** | ||
| 538 | + * Contains the desired chmod for uploaded files | ||
| 539 | + * @var int | ||
| 540 | + * @access private | ||
| 541 | + */ | ||
| 542 | + var $_chmod = HTTP_UPLOAD_DEFAULT_CHMOD; | ||
| 543 | + | ||
| 544 | + /** | ||
| 545 | + * Constructor | ||
| 546 | + * | ||
| 547 | + * @param string $name destination file name | ||
| 548 | + * @param string $tmp temp file name | ||
| 549 | + * @param string $formname name of the form | ||
| 550 | + * @param string $type Mime type of the file | ||
| 551 | + * @param string $size size of the file | ||
| 552 | + * @param string $error error on upload | ||
| 553 | + * @param string $lang used language for errormessages | ||
| 554 | + * @access public | ||
| 555 | + */ | ||
| 556 | + function HTTP_Upload_File($name = null, $tmp = null, $formname = null, | ||
| 557 | + $type = null, $size = null, $error = null, | ||
| 558 | + $lang = null, $chmod = HTTP_UPLOAD_DEFAULT_CHMOD) | ||
| 559 | + { | ||
| 560 | + $this->HTTP_Upload_Error($lang); | ||
| 561 | + $ext = null; | ||
| 562 | + | ||
| 563 | + if (empty($name) || $size == 0) { | ||
| 564 | + $error = 'NO_USER_FILE'; | ||
| 565 | + } elseif ($tmp == 'none') { | ||
| 566 | + $error = 'TOO_LARGE'; | ||
| 567 | + } else { | ||
| 568 | + // strpos needed to detect files without extension | ||
| 569 | + if (($pos = strrpos($name, '.')) !== false) { | ||
| 570 | + $ext = substr($name, $pos + 1); | ||
| 571 | + } | ||
| 572 | + } | ||
| 573 | + | ||
| 574 | + if (function_exists('version_compare') && | ||
| 575 | + version_compare(phpversion(), '4.1', 'ge')) { | ||
| 576 | + if (isset($_POST['MAX_FILE_SIZE']) && | ||
| 577 | + $size > $_POST['MAX_FILE_SIZE']) { | ||
| 578 | + $error = 'TOO_LARGE'; | ||
| 579 | + } | ||
| 580 | + } else { | ||
| 581 | + global $HTTP_POST_VARS; | ||
| 582 | + if (isset($HTTP_POST_VARS['MAX_FILE_SIZE']) && | ||
| 583 | + $size > $HTTP_POST_VARS['MAX_FILE_SIZE']) { | ||
| 584 | + $error = 'TOO_LARGE'; | ||
| 585 | + } | ||
| 586 | + } | ||
| 587 | + | ||
| 588 | + $this->upload = array( | ||
| 589 | + 'real' => $name, | ||
| 590 | + 'name' => $name, | ||
| 591 | + 'form_name' => $formname, | ||
| 592 | + 'ext' => $ext, | ||
| 593 | + 'tmp_name' => $tmp, | ||
| 594 | + 'size' => $size, | ||
| 595 | + 'type' => $type, | ||
| 596 | + 'error' => $error | ||
| 597 | + ); | ||
| 598 | + | ||
| 599 | + $this->_chmod = $chmod; | ||
| 600 | + } | ||
| 601 | + | ||
| 602 | + /** | ||
| 603 | + * Sets the name of the destination file | ||
| 604 | + * | ||
| 605 | + * @param string $mode A valid mode: 'uniq', 'safe' or 'real' or a file name | ||
| 606 | + * @param string $prepend A string to prepend to the name | ||
| 607 | + * @param string $append A string to append to the name | ||
| 608 | + * | ||
| 609 | + * @return string The modified name of the destination file | ||
| 610 | + * @access public | ||
| 611 | + */ | ||
| 612 | + function setName($mode, $prepend = null, $append = null) | ||
| 613 | + { | ||
| 614 | + switch ($mode) { | ||
| 615 | + case 'uniq': | ||
| 616 | + $name = $this->nameToUniq(); | ||
| 617 | + $this->upload['ext'] = $this->nameToSafe($this->upload['ext'], 10); | ||
| 618 | + $name .= '.' . $this->upload['ext']; | ||
| 619 | + break; | ||
| 620 | + case 'safe': | ||
| 621 | + $name = $this->nameToSafe($this->upload['real']); | ||
| 622 | + if (($pos = strrpos($name, '.')) !== false) { | ||
| 623 | + $this->upload['ext'] = substr($name, $pos + 1); | ||
| 624 | + } else { | ||
| 625 | + $this->upload['ext'] = ''; | ||
| 626 | + } | ||
| 627 | + break; | ||
| 628 | + case 'real': | ||
| 629 | + $name = $this->upload['real']; | ||
| 630 | + break; | ||
| 631 | + default: | ||
| 632 | + $name = $mode; | ||
| 633 | + } | ||
| 634 | + $this->upload['name'] = $prepend . $name . $append; | ||
| 635 | + $this->mode_name_selected = true; | ||
| 636 | + return $this->upload['name']; | ||
| 637 | + } | ||
| 638 | + | ||
| 639 | + /** | ||
| 640 | + * Unique file names in the form: 9022210413b75410c28bef.html | ||
| 641 | + * @see HTTP_Upload_File::setName() | ||
| 642 | + */ | ||
| 643 | + function nameToUniq() | ||
| 644 | + { | ||
| 645 | + if (! $this->_seeded) { | ||
| 646 | + srand((double) microtime() * 1000000); | ||
| 647 | + $this->_seeded = 1; | ||
| 648 | + } | ||
| 649 | + $uniq = uniqid(rand()); | ||
| 650 | + return $uniq; | ||
| 651 | + } | ||
| 652 | + | ||
| 653 | + /** | ||
| 654 | + * Format a file name to be safe | ||
| 655 | + * | ||
| 656 | + * @param string $file The string file name | ||
| 657 | + * @param int $maxlen Maximun permited string lenght | ||
| 658 | + * @return string Formatted file name | ||
| 659 | + * @see HTTP_Upload_File::setName() | ||
| 660 | + */ | ||
| 661 | + function nameToSafe($name, $maxlen=250) | ||
| 662 | + { | ||
| 663 | + $noalpha = 'รรรรรรรกรฉรญรณรบรฝรรรรรรขรชรฎรดรปรรรรรร รจรฌรฒรนรรรรรรครซรฏรถรผรฟรรฃรรตร รฅรรฑรรง@ยฐยบยช'; | ||
| 664 | + $alpha = 'AEIOUYaeiouyAEIOUaeiouAEIOUaeiouAEIOUaeiouyAaOoAaNnCcaooa'; | ||
| 665 | + | ||
| 666 | + $name = substr($name, 0, $maxlen); | ||
| 667 | + $name = strtr($name, $noalpha, $alpha); | ||
| 668 | + // not permitted chars are replaced with "_" | ||
| 669 | + return preg_replace('/[^a-zA-Z0-9,._\+\()\-]/', '_', $name); | ||
| 670 | + } | ||
| 671 | + | ||
| 672 | + /** | ||
| 673 | + * The upload was valid | ||
| 674 | + * | ||
| 675 | + * @return bool If the file was submitted correctly | ||
| 676 | + * @access public | ||
| 677 | + */ | ||
| 678 | + function isValid() | ||
| 679 | + { | ||
| 680 | + if ($this->upload['error'] === null) { | ||
| 681 | + return true; | ||
| 682 | + } | ||
| 683 | + return false; | ||
| 684 | + } | ||
| 685 | + | ||
| 686 | + /** | ||
| 687 | + * User haven't submit a file | ||
| 688 | + * | ||
| 689 | + * @return bool If the user submitted a file or not | ||
| 690 | + * @access public | ||
| 691 | + */ | ||
| 692 | + function isMissing() | ||
| 693 | + { | ||
| 694 | + if ($this->upload['error'] == 'NO_USER_FILE') { | ||
| 695 | + return true; | ||
| 696 | + } | ||
| 697 | + return false; | ||
| 698 | + } | ||
| 699 | + | ||
| 700 | + /** | ||
| 701 | + * Some error occured during upload (most common due a file size problem, | ||
| 702 | + * like max size exceeded or 0 bytes long). | ||
| 703 | + * @return bool If there were errors submitting the file (probably | ||
| 704 | + * because the file excess the max permitted file size) | ||
| 705 | + * @access public | ||
| 706 | + */ | ||
| 707 | + function isError() | ||
| 708 | + { | ||
| 709 | + if (in_array($this->upload['error'], array('TOO_LARGE', 'BAD_FORM','DEV_NO_DEF_FILE'))) { | ||
| 710 | + return true; | ||
| 711 | + } | ||
| 712 | + return false; | ||
| 713 | + } | ||
| 714 | + | ||
| 715 | + /** | ||
| 716 | + * Moves the uploaded file to its destination directory. | ||
| 717 | + * | ||
| 718 | + * @param string $dir_dest Destination directory | ||
| 719 | + * @param bool $overwrite Overwrite if destination file exists? | ||
| 720 | + * @return mixed True on success or Pear_Error object on error | ||
| 721 | + * @access public | ||
| 722 | + */ | ||
| 723 | + function moveTo($dir_dest, $overwrite = true) | ||
| 724 | + { | ||
| 725 | + if (!$this->isValid()) { | ||
| 726 | + return $this->raiseError($this->upload['error']); | ||
| 727 | + } | ||
| 728 | + | ||
| 729 | + //Valid extensions check | ||
| 730 | + if (!$this->_evalValidExtensions()) { | ||
| 731 | + return $this->raiseError('NOT_ALLOWED_EXTENSION'); | ||
| 732 | + } | ||
| 733 | + | ||
| 734 | + $err_code = $this->_chk_dir_dest($dir_dest); | ||
| 735 | + if ($err_code !== false) { | ||
| 736 | + return $this->raiseError($err_code); | ||
| 737 | + } | ||
| 738 | + // Use 'safe' mode by default if no other was selected | ||
| 739 | + if (!$this->mode_name_selected) { | ||
| 740 | + $this->setName('safe'); | ||
| 741 | + } | ||
| 742 | + | ||
| 743 | + $name_dest = $dir_dest . DIRECTORY_SEPARATOR . $this->upload['name']; | ||
| 744 | + | ||
| 745 | + if (@is_file($name_dest)) { | ||
| 746 | + if ($overwrite !== true) { | ||
| 747 | + return $this->raiseError('FILE_EXISTS'); | ||
| 748 | + } elseif (!is_writable($name_dest)) { | ||
| 749 | + return $this->raiseError('CANNOT_OVERWRITE'); | ||
| 750 | + } | ||
| 751 | + } | ||
| 752 | + | ||
| 753 | + // copy the file and let php clean the tmp | ||
| 754 | + if (!@move_uploaded_file($this->upload['tmp_name'], $name_dest)) { | ||
| 755 | + return $this->raiseError('E_FAIL_MOVE'); | ||
| 756 | + } | ||
| 757 | + @chmod($name_dest, $this->_chmod); | ||
| 758 | + return $this->getProp('name'); | ||
| 759 | + } | ||
| 760 | + | ||
| 761 | + /** | ||
| 762 | + * Check for a valid destination dir | ||
| 763 | + * | ||
| 764 | + * @param string $dir_dest Destination dir | ||
| 765 | + * @return mixed False on no errors or error code on error | ||
| 766 | + */ | ||
| 767 | + function _chk_dir_dest($dir_dest) | ||
| 768 | + { | ||
| 769 | + if (!$dir_dest) { | ||
| 770 | + return 'MISSING_DIR'; | ||
| 771 | + } | ||
| 772 | + if (!@is_dir ($dir_dest)) { | ||
| 773 | + return 'IS_NOT_DIR'; | ||
| 774 | + } | ||
| 775 | + if (!is_writeable ($dir_dest)) { | ||
| 776 | + return 'NO_WRITE_PERMS'; | ||
| 777 | + } | ||
| 778 | + return false; | ||
| 779 | + } | ||
| 780 | + /** | ||
| 781 | + * Retrive properties of the uploaded file | ||
| 782 | + * @param string $name The property name. When null an assoc array with | ||
| 783 | + * all the properties will be returned | ||
| 784 | + * @return mixed A string or array | ||
| 785 | + * @see HTTP_Upload_File::HTTP_Upload_File() | ||
| 786 | + * @access public | ||
| 787 | + */ | ||
| 788 | + function getProp($name = null) | ||
| 789 | + { | ||
| 790 | + if ($name === null) { | ||
| 791 | + return $this->upload; | ||
| 792 | + } | ||
| 793 | + return $this->upload[$name]; | ||
| 794 | + } | ||
| 795 | + | ||
| 796 | + /** | ||
| 797 | + * Returns a error message, if a error occured | ||
| 798 | + * (deprecated) Use getMessage() instead | ||
| 799 | + * @return string a Error message | ||
| 800 | + * @access public | ||
| 801 | + */ | ||
| 802 | + function errorMsg() | ||
| 803 | + { | ||
| 804 | + return $this->errorCode($this->upload['error']); | ||
| 805 | + } | ||
| 806 | + | ||
| 807 | + /** | ||
| 808 | + * Returns a error message, if a error occured | ||
| 809 | + * @return string a Error message | ||
| 810 | + * @access public | ||
| 811 | + */ | ||
| 812 | + function getMessage() | ||
| 813 | + { | ||
| 814 | + return $this->errorCode($this->upload['error']); | ||
| 815 | + } | ||
| 816 | + | ||
| 817 | + /** | ||
| 818 | + * Function to restrict the valid extensions on file uploads | ||
| 819 | + * | ||
| 820 | + * @param array $exts File extensions to validate | ||
| 821 | + * @param string $mode The type of validation: | ||
| 822 | + * 1) 'deny' Will deny only the supplied extensions | ||
| 823 | + * 2) 'accept' Will accept only the supplied extensions | ||
| 824 | + * as valid | ||
| 825 | + * @access public | ||
| 826 | + */ | ||
| 827 | + function setValidExtensions($exts, $mode = 'deny') | ||
| 828 | + { | ||
| 829 | + $this->_extensions_check = $exts; | ||
| 830 | + $this->_extensions_mode = $mode; | ||
| 831 | + } | ||
| 832 | + | ||
| 833 | + /** | ||
| 834 | + * Evaluates the validity of the extensions set by setValidExtensions | ||
| 835 | + * | ||
| 836 | + * @return bool False on non valid extension, true if they are valid | ||
| 837 | + * @access private | ||
| 838 | + */ | ||
| 839 | + function _evalValidExtensions() | ||
| 840 | + { | ||
| 841 | + $exts = $this->_extensions_check; | ||
| 842 | + settype($exts, 'array'); | ||
| 843 | + if ($this->_extensions_mode == 'deny') { | ||
| 844 | + if (in_array($this->getProp('ext'), $exts)) { | ||
| 845 | + return false; | ||
| 846 | + } | ||
| 847 | + // mode == 'accept' | ||
| 848 | + } else { | ||
| 849 | + if (!in_array($this->getProp('ext'), $exts)) { | ||
| 850 | + return false; | ||
| 851 | + } | ||
| 852 | + } | ||
| 853 | + return true; | ||
| 854 | + } | ||
| 855 | +} | ||
| 856 | ?> | 856 | ?> |
| 857 | \ No newline at end of file | 857 | \ No newline at end of file |
thirdparty/pear/HTTP/WebDAV/Server.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Christian Stocker <chregu@bitflux.ch> | | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: Server.php,v 1.36 2005/09/24 20:08:57 hholzgra Exp $ | 20 | +// $Id$ |
| 21 | // | 21 | // |
| 22 | require_once "HTTP/WebDAV/Tools/_parse_propfind.php"; | 22 | require_once "HTTP/WebDAV/Tools/_parse_propfind.php"; |
| 23 | require_once "HTTP/WebDAV/Tools/_parse_proppatch.php"; | 23 | require_once "HTTP/WebDAV/Tools/_parse_proppatch.php"; |
thirdparty/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Christian Stocker <chregu@bitflux.ch> | | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: _parse_lockinfo.php,v 1.2 2004/01/05 12:32:40 hholzgra Exp $ | 20 | +// $Id$ |
| 21 | // | 21 | // |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
thirdparty/pear/HTTP/WebDAV/Tools/_parse_propfind.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Christian Stocker <chregu@bitflux.ch> | | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: _parse_propfind.php,v 1.2 2004/01/05 12:33:22 hholzgra Exp $ | 20 | +// $Id$ |
| 21 | // | 21 | // |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
thirdparty/pear/HTTP/WebDAV/Tools/_parse_proppatch.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Christian Stocker <chregu@bitflux.ch> | | 17 | // | Christian Stocker <chregu@bitflux.ch> | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: _parse_proppatch.php,v 1.3 2004/01/05 12:41:34 hholzgra Exp $ | 20 | +// $Id$ |
| 21 | // | 21 | // |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
thirdparty/pear/JSON.php
| @@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
| 51 | * @author Matt Knapp <mdknapp[at]gmail[dot]com> | 51 | * @author Matt Knapp <mdknapp[at]gmail[dot]com> |
| 52 | * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com> | 52 | * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com> |
| 53 | * @copyright 2005 Michal Migurski | 53 | * @copyright 2005 Michal Migurski |
| 54 | - * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ | 54 | + * @version CVS: $Id$ |
| 55 | * @license http://www.opensource.org/licenses/bsd-license.php | 55 | * @license http://www.opensource.org/licenses/bsd-license.php |
| 56 | * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 | 56 | * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 |
| 57 | */ | 57 | */ |
thirdparty/pear/Net/CheckIP.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Guido Haeger <gh-lists@ecora.de> | | 17 | // | Guido Haeger <gh-lists@ecora.de> | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: CheckIP.php,v 1.5 2002/08/17 09:41:24 mj Exp $ | 20 | +// $Id$ |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | * Class to validate the syntax of IPv4 adresses | 23 | * Class to validate the syntax of IPv4 adresses |
thirdparty/pear/Net/Curl.php
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | * @author Joe Stump <joe@joestump.net> | 18 | * @author Joe Stump <joe@joestump.net> |
| 19 | * @copyright 1997-2005 The PHP Group | 19 | * @copyright 1997-2005 The PHP Group |
| 20 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 | 20 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
| 21 | - * @version CVS: $Revision: 1.11 $ | 21 | + * @version CVS: $Revision$ |
| 22 | * @link http://pear.php.net/package/Net_Curl | 22 | * @link http://pear.php.net/package/Net_Curl |
| 23 | */ | 23 | */ |
| 24 | 24 |
thirdparty/pear/Net/DIME.php
| 1 | -<?php | ||
| 2 | -// | ||
| 3 | -// +----------------------------------------------------------------------+ | ||
| 4 | -// | PHP Version 4 | | ||
| 5 | -// +----------------------------------------------------------------------+ | ||
| 6 | -// | Copyright (c) 1997-2002 The PHP Group | | ||
| 7 | -// +----------------------------------------------------------------------+ | ||
| 8 | -// | This source file is subject to version 2.02 of the PHP license, | | ||
| 9 | -// | that is bundled with this package in the file LICENSE, and is | | ||
| 10 | -// | available at through the world-wide-web at | | ||
| 11 | -// | http://www.php.net/license/2_02.txt. | | ||
| 12 | -// | If you did not receive a copy of the PHP license and are unable to | | ||
| 13 | -// | obtain it through the world-wide-web, please send a note to | | ||
| 14 | -// | license@php.net so we can mail you a copy immediately. | | ||
| 15 | -// +----------------------------------------------------------------------+ | ||
| 16 | -// | Authors: Shane Caraveo <shane@caraveo.com> | | ||
| 17 | -// | Ralf Hofmann <ralf.hofmann@verdisoft.com> | | ||
| 18 | -// +----------------------------------------------------------------------+ | ||
| 19 | -// | ||
| 20 | -// $Id: DIME.php,v 1.5 2002/09/29 01:55:16 shane Exp $ | ||
| 21 | -// | ||
| 22 | - | ||
| 23 | -require_once 'PEAR.php'; | ||
| 24 | -/** | ||
| 25 | - * | ||
| 26 | - * DIME Encoding/Decoding | ||
| 27 | - * | ||
| 28 | - * What is it? | ||
| 29 | - * This class enables you to manipulate and build | ||
| 30 | - * a DIME encapsulated message. | ||
| 31 | - * | ||
| 32 | - * http://www.ietf.org/internet-drafts/draft-nielsen-dime-02.txt | ||
| 33 | - * | ||
| 34 | - * 09/18/02 Ralf - A huge number of changes to be compliant | ||
| 35 | - * with the DIME Specification Release 17 June 2002 | ||
| 36 | - * | ||
| 37 | - * TODO: lots of stuff needs to be tested. | ||
| 38 | - * Definitily have to go through DIME spec and | ||
| 39 | - * make things work right, most importantly, sec 3.3 | ||
| 40 | - * make examples, document | ||
| 41 | - * | ||
| 42 | - * see test/dime_mesage_test.php for example of usage | ||
| 43 | - * | ||
| 44 | - * @author Shane Caraveo <shane@caraveo.com>, | ||
| 45 | - * Ralf Hofmann <ralf.hofmann@verdisoft.com> | ||
| 46 | - * @version $Revision: 1.5 $ | ||
| 47 | - * @package Net_DIME | ||
| 48 | - */ | ||
| 49 | -define('NET_DIME_TYPE_UNCHANGED',0x00); | ||
| 50 | -define('NET_DIME_TYPE_MEDIA',0x01); | ||
| 51 | -define('NET_DIME_TYPE_URI',0x02); | ||
| 52 | -define('NET_DIME_TYPE_UNKNOWN',0x03); | ||
| 53 | -define('NET_DIME_TYPE_NONE',0x04); | ||
| 54 | - | ||
| 55 | -define('NET_DIME_VERSION',0x0001); | ||
| 56 | - | ||
| 57 | -define('NET_DIME_RECORD_HEADER',12); | ||
| 58 | - | ||
| 59 | -define('NET_DIME_FLAGS', 0); | ||
| 60 | -define('NET_DIME_OPTS_LEN', 1); | ||
| 61 | -define('NET_DIME_ID_LEN', 2); | ||
| 62 | -define('NET_DIME_TYPE_LEN', 3); | ||
| 63 | -define('NET_DIME_DATA_LEN', 4); | ||
| 64 | -define('NET_DIME_OPTS', 5); | ||
| 65 | -define('NET_DIME_ID', 6); | ||
| 66 | -define('NET_DIME_TYPE', 7); | ||
| 67 | -define('NET_DIME_DATA', 8); | ||
| 68 | - | ||
| 69 | -class Net_DIME_Record extends PEAR | ||
| 70 | -{ | ||
| 71 | - // these are used to hold the padded length | ||
| 72 | - var $OPTS_LENGTH = 0; | ||
| 73 | - var $ID_LENGTH = 0; | ||
| 74 | - var $TYPE_LENGTH = 0; | ||
| 75 | - var $DATA_LENGTH = 0; | ||
| 76 | - var $_haveOpts = FALSE; | ||
| 77 | - var $_haveID = FALSE; | ||
| 78 | - var $_haveType = FALSE; | ||
| 79 | - var $_haveData = FALSE; | ||
| 80 | - var $debug = FALSE; | ||
| 81 | - var $padstr = "\0"; | ||
| 82 | - /** | ||
| 83 | - * Elements | ||
| 84 | - * [NET_DIME_FLAGS], 16 bits: VERSION:MB:ME:CF:TYPE_T | ||
| 85 | - * [NET_DIME_OPTS_LEN], 16 bits: OPTIONS_LENGTH | ||
| 86 | - * [NET_DIME_ID_LEN], 16 bits: ID_LENGTH | ||
| 87 | - * [NET_DIME_TYPE_LEN], 16 bits: TYPE_LENGTH | ||
| 88 | - * [NET_DIME_DATA_LEN], 32 bits: DATA_LENGTH | ||
| 89 | - * [NET_DIME_OPTS] : OPTIONS | ||
| 90 | - * [NET_DIME_ID] : ID | ||
| 91 | - * [NET_DIME_TYPE] : TYPE | ||
| 92 | - * [NET_DIME_DATA] : DATA | ||
| 93 | - */ | ||
| 94 | - var $Elements = array(NET_DIME_FLAGS => 0, NET_DIME_OPTS_LEN => 0, | ||
| 95 | - NET_DIME_ID_LEN => 0, NET_DIME_TYPE_LEN => 0, | ||
| 96 | - NET_DIME_DATA_LEN => 0, | ||
| 97 | - NET_DIME_OPTS => '', | ||
| 98 | - NET_DIME_ID => '', | ||
| 99 | - NET_DIME_TYPE => '', | ||
| 100 | - NET_DIME_DATA => ''); | ||
| 101 | - | ||
| 102 | - function Net_DIME_Record($debug = FALSE) | ||
| 103 | - { | ||
| 104 | - $this->debug = $debug; | ||
| 105 | - if ($debug) $this->padstr = '*'; | ||
| 106 | - } | ||
| 107 | - | ||
| 108 | - function setMB() | ||
| 109 | - { | ||
| 110 | - $this->Elements[NET_DIME_FLAGS] |= 0x0400; | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - function setME() | ||
| 114 | - { | ||
| 115 | - $this->Elements[NET_DIME_FLAGS] |= 0x0200; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - function setCF() | ||
| 119 | - { | ||
| 120 | - $this->Elements[NET_DIME_FLAGS] |= 0x0100; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - function isChunk() | ||
| 124 | - { | ||
| 125 | - return $this->Elements[NET_DIME_FLAGS] & 0x0100; | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - function isEnd() | ||
| 129 | - { | ||
| 130 | - return $this->Elements[NET_DIME_FLAGS] & 0x0200; | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - function isStart() | ||
| 134 | - { | ||
| 135 | - return $this->Elements[NET_DIME_FLAGS] & 0x0400; | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - function getID() | ||
| 139 | - { | ||
| 140 | - return $this->Elements[NET_DIME_ID]; | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - function getType() | ||
| 144 | - { | ||
| 145 | - return $this->Elements[NET_DIME_TYPE]; | ||
| 146 | - } | ||
| 147 | - | ||
| 148 | - function getData() | ||
| 149 | - { | ||
| 150 | - return $this->Elements[NET_DIME_DATA]; | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - function getDataLength() | ||
| 154 | - { | ||
| 155 | - return $this->Elements[NET_DIME_DATA_LEN]; | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - function setType($typestring, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 159 | - { | ||
| 160 | - $typelen = strlen($typestring) & 0xFFFF; | ||
| 161 | - $type = $type << 4; | ||
| 162 | - $this->Elements[NET_DIME_FLAGS] = ($this->Elements[NET_DIME_FLAGS] & 0xFF0F) | $type; | ||
| 163 | - $this->Elements[NET_DIME_TYPE_LEN] = $typelen; | ||
| 164 | - $this->TYPE_LENGTH = $this->_getPadLength($typelen); | ||
| 165 | - $this->Elements[NET_DIME_TYPE] = $typestring; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - function generateID() | ||
| 169 | - { | ||
| 170 | - $id = md5(time()); | ||
| 171 | - $this->setID($id); | ||
| 172 | - return $id; | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - function setID($id) | ||
| 176 | - { | ||
| 177 | - $idlen = strlen($id) & 0xFFFF; | ||
| 178 | - $this->Elements[NET_DIME_ID_LEN] = $idlen; | ||
| 179 | - $this->ID_LENGTH = $this->_getPadLength($idlen); | ||
| 180 | - $this->Elements[NET_DIME_ID] = $id; | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | - function setData($data, $size=0) | ||
| 184 | - { | ||
| 185 | - $datalen = $size?$size:strlen($data); | ||
| 186 | - $this->Elements[NET_DIME_DATA_LEN] = $datalen; | ||
| 187 | - $this->DATA_LENGTH = $this->_getPadLength($datalen); | ||
| 188 | - $this->Elements[NET_DIME_DATA] = $data; | ||
| 189 | - } | ||
| 190 | - | ||
| 191 | - function encode() | ||
| 192 | - { | ||
| 193 | - // insert version | ||
| 194 | - $this->Elements[NET_DIME_FLAGS] = ($this->Elements[NET_DIME_FLAGS] & 0x07FF) | (NET_DIME_VERSION << 11); | ||
| 195 | - | ||
| 196 | - // the real dime encoding | ||
| 197 | - $format = '%c%c%c%c%c%c%c%c%c%c%c%c'. | ||
| 198 | - '%'.$this->OPTS_LENGTH.'s'. | ||
| 199 | - '%'.$this->ID_LENGTH.'s'. | ||
| 200 | - '%'.$this->TYPE_LENGTH.'s'. | ||
| 201 | - '%'.$this->DATA_LENGTH.'s'; | ||
| 202 | - return sprintf($format, | ||
| 203 | - ($this->Elements[NET_DIME_FLAGS]&0x0000FF00)>>8, | ||
| 204 | - ($this->Elements[NET_DIME_FLAGS]&0x000000FF), | ||
| 205 | - ($this->Elements[NET_DIME_OPTS_LEN]&0x0000FF00)>>8, | ||
| 206 | - ($this->Elements[NET_DIME_OPTS_LEN]&0x000000FF), | ||
| 207 | - ($this->Elements[NET_DIME_ID_LEN]&0x0000FF00)>>8, | ||
| 208 | - ($this->Elements[NET_DIME_ID_LEN]&0x000000FF), | ||
| 209 | - ($this->Elements[NET_DIME_TYPE_LEN]&0x0000FF00)>>8, | ||
| 210 | - ($this->Elements[NET_DIME_TYPE_LEN]&0x000000FF), | ||
| 211 | - ($this->Elements[NET_DIME_DATA_LEN]&0xFF000000)>>24, | ||
| 212 | - ($this->Elements[NET_DIME_DATA_LEN]&0x00FF0000)>>16, | ||
| 213 | - ($this->Elements[NET_DIME_DATA_LEN]&0x0000FF00)>>8, | ||
| 214 | - ($this->Elements[NET_DIME_DATA_LEN]&0x000000FF), | ||
| 215 | - str_pad($this->Elements[NET_DIME_OPTS], $this->OPTS_LENGTH, $this->padstr), | ||
| 216 | - str_pad($this->Elements[NET_DIME_ID], $this->ID_LENGTH, $this->padstr), | ||
| 217 | - str_pad($this->Elements[NET_DIME_TYPE], $this->TYPE_LENGTH, $this->padstr), | ||
| 218 | - str_pad($this->Elements[NET_DIME_DATA], $this->DATA_LENGTH, $this->padstr)); | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | - function _getPadLength($len) | ||
| 222 | - { | ||
| 223 | - $pad = 0; | ||
| 224 | - if ($len) { | ||
| 225 | - $pad = $len % 4; | ||
| 226 | - if ($pad) $pad = 4 - $pad; | ||
| 227 | - } | ||
| 228 | - return $len + $pad; | ||
| 229 | - } | ||
| 230 | - | ||
| 231 | - function decode(&$data) | ||
| 232 | - { | ||
| 233 | - // REAL DIME decoding | ||
| 234 | - $this->Elements[NET_DIME_FLAGS] = (hexdec(bin2hex($data[0]))<<8) + hexdec(bin2hex($data[1])); | ||
| 235 | - $this->Elements[NET_DIME_OPTS_LEN] = (hexdec(bin2hex($data[2]))<<8) + hexdec(bin2hex($data[3])); | ||
| 236 | - $this->Elements[NET_DIME_ID_LEN] = (hexdec(bin2hex($data[4]))<<8) + hexdec(bin2hex($data[5])); | ||
| 237 | - $this->Elements[NET_DIME_TYPE_LEN] = (hexdec(bin2hex($data[6]))<<8) + hexdec(bin2hex($data[7])); | ||
| 238 | - $this->Elements[NET_DIME_DATA_LEN] = (hexdec(bin2hex($data[8]))<<24) + | ||
| 239 | - (hexdec(bin2hex($data[9]))<<16) + | ||
| 240 | - (hexdec(bin2hex($data[10]))<<8) + | ||
| 241 | - hexdec(bin2hex($data[11])); | ||
| 242 | - $p = 12; | ||
| 243 | - | ||
| 244 | - $version = (($this->Elements[NET_DIME_FLAGS]>>11) & 0x001F); | ||
| 245 | - | ||
| 246 | - if ($version == NET_DIME_VERSION) | ||
| 247 | - { | ||
| 248 | - $this->OPTS_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_OPTS_LEN]); | ||
| 249 | - $this->ID_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_ID_LEN]); | ||
| 250 | - $this->TYPE_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_TYPE_LEN]); | ||
| 251 | - $this->DATA_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_DATA_LEN]); | ||
| 252 | - | ||
| 253 | - $datalen = strlen($data); | ||
| 254 | - $this->Elements[NET_DIME_OPTS] = substr($data,$p,$this->Elements[NET_DIME_OPTS_LEN]); | ||
| 255 | - $this->_haveOpts = (strlen($this->Elements[NET_DIME_OPTS]) == $this->Elements[NET_DIME_OPTS_LEN]); | ||
| 256 | - if ($this->_haveOpts) { | ||
| 257 | - $p += $this->OPTS_LENGTH; | ||
| 258 | - $this->Elements[NET_DIME_ID] = substr($data,$p,$this->Elements[NET_DIME_ID_LEN]); | ||
| 259 | - $this->_haveID = (strlen($this->Elements[NET_DIME_ID]) == $this->Elements[NET_DIME_ID_LEN]); | ||
| 260 | - if ($this->_haveID) { | ||
| 261 | - $p += $this->ID_LENGTH; | ||
| 262 | - $this->Elements[NET_DIME_TYPE] = substr($data,$p,$this->Elements[NET_DIME_TYPE_LEN]); | ||
| 263 | - $this->_haveType = (strlen($this->Elements[NET_DIME_TYPE]) == $this->Elements[NET_DIME_TYPE_LEN]); | ||
| 264 | - if ($this->_haveType) { | ||
| 265 | - $p += $this->TYPE_LENGTH; | ||
| 266 | - $this->Elements[NET_DIME_DATA] = substr($data,$p,$this->Elements[NET_DIME_DATA_LEN]); | ||
| 267 | - $this->_haveData = (strlen($this->Elements[NET_DIME_DATA]) == $this->Elements[NET_DIME_DATA_LEN]); | ||
| 268 | - if ($this->_haveData) { | ||
| 269 | - $p += $this->DATA_LENGTH; | ||
| 270 | - } else { | ||
| 271 | - $p += strlen($this->Elements[NET_DIME_DATA]); | ||
| 272 | - } | ||
| 273 | - } else { | ||
| 274 | - $p += strlen($this->Elements[NET_DIME_TYPE]); | ||
| 275 | - } | ||
| 276 | - } else { | ||
| 277 | - $p += strlen($this->Elements[NET_DIME_ID]); | ||
| 278 | - } | ||
| 279 | - } else { | ||
| 280 | - $p += strlen($this->Elements[NET_DIME_OPTS]); | ||
| 281 | - } | ||
| 282 | - } | ||
| 283 | - return substr($data, $p); | ||
| 284 | - } | ||
| 285 | - | ||
| 286 | - function addData(&$data) | ||
| 287 | - { | ||
| 288 | - $datalen = strlen($data); | ||
| 289 | - $p = 0; | ||
| 290 | - if (!$this->_haveOpts) { | ||
| 291 | - $have = strlen($this->Elements[NET_DIME_OPTS]); | ||
| 292 | - $this->Elements[NET_DIME_OPTS] .= substr($data,$p,$this->Elements[NET_DIME_OPTS_LEN]-$have); | ||
| 293 | - $this->_haveOpts = (strlen($this->Elements[NET_DIME_OPTS]) == $this->Elements[DIME_OTPS_LEN]); | ||
| 294 | - if (!$this->_haveOpts) return NULL; | ||
| 295 | - $p += $this->OPTS_LENGTH-$have; | ||
| 296 | - } | ||
| 297 | - if (!$this->_haveID) { | ||
| 298 | - $have = strlen($this->Elements[NET_DIME_ID]); | ||
| 299 | - $this->Elements[NET_DIME_ID] .= substr($data,$p,$this->Elements[NET_DIME_ID_LEN]-$have); | ||
| 300 | - $this->_haveID = (strlen($this->Elements[NET_DIME_ID]) == $this->Elements[NET_DIME_ID_LEN]); | ||
| 301 | - if (!$this->_haveID) return NULL; | ||
| 302 | - $p += $this->ID_LENGTH-$have; | ||
| 303 | - } | ||
| 304 | - if (!$this->_haveType && $p < $datalen) { | ||
| 305 | - $have = strlen($this->Elements[NET_DIME_TYPE]); | ||
| 306 | - $this->Elements[NET_DIME_TYPE] .= substr($data,$p,$this->Elements[NET_DIME_TYPE_LEN]-$have); | ||
| 307 | - $this->_haveType = (strlen($this->Elements[NET_DIME_TYPE]) == $this->Elements[NET_DIME_TYPE_LEN]); | ||
| 308 | - if (!$this->_haveType) return NULL; | ||
| 309 | - $p += $this->TYPE_LENGTH-$have; | ||
| 310 | - } | ||
| 311 | - if (!$this->_haveData && $p < $datalen) { | ||
| 312 | - $have = strlen($this->Elements[NET_DIME_DATA]); | ||
| 313 | - $this->Elements[NET_DIME_DATA] .= substr($data,$p,$this->Elements[NET_DIME_DATA_LEN]-$have); | ||
| 314 | - $this->_haveData = (strlen($this->Elements[NET_DIME_DATA]) == $this->Elements[NET_DIME_DATA_LEN]); | ||
| 315 | - if (!$this->_haveData) return NULL; | ||
| 316 | - $p += $this->DATA_LENGTH-$have; | ||
| 317 | - } | ||
| 318 | - return substr($data,$p); | ||
| 319 | - } | ||
| 320 | -} | ||
| 321 | - | ||
| 322 | - | ||
| 323 | -class Net_DIME_Message extends PEAR | ||
| 324 | -{ | ||
| 325 | - | ||
| 326 | - var $record_size = 4096; | ||
| 327 | - #var $records =array(); | ||
| 328 | - var $parts = array(); | ||
| 329 | - var $currentPart = -1; | ||
| 330 | - var $stream = NULL; | ||
| 331 | - var $_currentRecord; | ||
| 332 | - var $_proc = array(); | ||
| 333 | - var $type; | ||
| 334 | - var $typestr; | ||
| 335 | - var $mb = 1; | ||
| 336 | - var $me = 0; | ||
| 337 | - var $cf = 0; | ||
| 338 | - var $id = NULL; | ||
| 339 | - var $debug = FALSE; | ||
| 340 | - /** | ||
| 341 | - * constructor | ||
| 342 | - * | ||
| 343 | - * this currently takes a file pointer as provided | ||
| 344 | - * by fopen | ||
| 345 | - * | ||
| 346 | - * TODO: integrate with the php streams stuff | ||
| 347 | - */ | ||
| 348 | - function Net_DIME_Message($stream=NULL, $record_size = 4096, $debug = FALSE) | ||
| 349 | - { | ||
| 350 | - $this->stream = $stream; | ||
| 351 | - $this->record_size = $record_size; | ||
| 352 | - $this->debug = $debug; | ||
| 353 | - } | ||
| 354 | - | ||
| 355 | - function _makeRecord(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 356 | - { | ||
| 357 | - $record = new Net_DIME_Record($this->debug); | ||
| 358 | - if ($this->mb) { | ||
| 359 | - $record->setMB(); | ||
| 360 | - // all subsequent records are not message begin! | ||
| 361 | - $this->mb = 0; | ||
| 362 | - } | ||
| 363 | - if ($this->me) $record->setME(); | ||
| 364 | - if ($this->cf) $record->setCF(); | ||
| 365 | - $record->setData($data); | ||
| 366 | - $record->setType($typestr,$type); | ||
| 367 | - if ($id) $record->setID($id); | ||
| 368 | - #if ($this->debug) { | ||
| 369 | - # print str_replace('\0','*',$record->encode()); | ||
| 370 | - #} | ||
| 371 | - return $record->encode(); | ||
| 372 | - } | ||
| 373 | - | ||
| 374 | - function startChunk(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 375 | - { | ||
| 376 | - $this->me = 0; | ||
| 377 | - $this->cf = 1; | ||
| 378 | - $this->type = $type; | ||
| 379 | - $this->typestr = $typestr; | ||
| 380 | - if ($id) { | ||
| 381 | - $this->id = $id; | ||
| 382 | - } else { | ||
| 383 | - $this->id = md5(time()); | ||
| 384 | - } | ||
| 385 | - return $this->_makeRecord($data, $this->typestr, $this->id, $this->type); | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | - function doChunk(&$data) | ||
| 389 | - { | ||
| 390 | - $this->me = 0; | ||
| 391 | - $this->cf = 1; | ||
| 392 | - return $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_UNCHANGED); | ||
| 393 | - } | ||
| 394 | - | ||
| 395 | - function endChunk() | ||
| 396 | - { | ||
| 397 | - $this->cf = 0; | ||
| 398 | - $data = NULL; | ||
| 399 | - $rec = $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_UNCHANGED); | ||
| 400 | - $this->id = 0; | ||
| 401 | - $this->cf = 0; | ||
| 402 | - $this->id = 0; | ||
| 403 | - $this->type = NET_DIME_TYPE_UNKNOWN; | ||
| 404 | - $this->typestr = NULL; | ||
| 405 | - return $rec; | ||
| 406 | - } | ||
| 407 | - | ||
| 408 | - function endMessage() | ||
| 409 | - { | ||
| 410 | - $this->me = 1; | ||
| 411 | - $data = NULL; | ||
| 412 | - $rec = $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_NONE); | ||
| 413 | - $this->me = 0; | ||
| 414 | - $this->mb = 1; | ||
| 415 | - $this->id = 0; | ||
| 416 | - return $rec; | ||
| 417 | - } | ||
| 418 | - | ||
| 419 | - /** | ||
| 420 | - * sendRecord | ||
| 421 | - * | ||
| 422 | - * given a chunk of data, it creates DIME records | ||
| 423 | - * and writes them to the stream | ||
| 424 | - * | ||
| 425 | - */ | ||
| 426 | - function sendData(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 427 | - { | ||
| 428 | - $len = strlen($data); | ||
| 429 | - if ($len > $this->record_size) { | ||
| 430 | - $chunk = substr($data, 0, $this->record_size); | ||
| 431 | - $p = $this->record_size; | ||
| 432 | - $rec = $this->startChunk($chunk,$typestr,$id,$type); | ||
| 433 | - fwrite($this->stream, $rec); | ||
| 434 | - while ($p < $len) { | ||
| 435 | - $chunk = substr($data, $p, $this->record_size); | ||
| 436 | - $p += $this->record_size; | ||
| 437 | - $rec = $this->doChunk($chunk); | ||
| 438 | - fwrite($this->stream, $rec); | ||
| 439 | - } | ||
| 440 | - $rec = $this->endChunk(); | ||
| 441 | - fwrite($this->stream, $rec); | ||
| 442 | - return; | ||
| 443 | - } | ||
| 444 | - $rec = $this->_makeRecord($data, $typestr,$id,$type); | ||
| 445 | - fwrite($this->stream, $rec); | ||
| 446 | - } | ||
| 447 | - | ||
| 448 | - function sendEndMessage() | ||
| 449 | - { | ||
| 450 | - $rec = $this->endMessage(); | ||
| 451 | - fwrite($this->stream, $rec); | ||
| 452 | - } | ||
| 453 | - | ||
| 454 | - /** | ||
| 455 | - * sendFile | ||
| 456 | - * | ||
| 457 | - * given a filename, it reads the file, | ||
| 458 | - * creates records and writes them to the stream | ||
| 459 | - * | ||
| 460 | - */ | ||
| 461 | - function sendFile($filename, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 462 | - { | ||
| 463 | - $f = fopen($filename, "rb"); | ||
| 464 | - if ($f) { | ||
| 465 | - if ($data = fread($f, $this->record_size)) { | ||
| 466 | - $this->startChunk($data,$typestr,$id,$type); | ||
| 467 | - } | ||
| 468 | - while ($data = fread($f, $this->record_size)) { | ||
| 469 | - $this->doChunk($data,$typestr,$id,$type); | ||
| 470 | - } | ||
| 471 | - $this->endChunk(); | ||
| 472 | - fclose($f); | ||
| 473 | - } | ||
| 474 | - } | ||
| 475 | - | ||
| 476 | - /** | ||
| 477 | - * encodeData | ||
| 478 | - * | ||
| 479 | - * given data, encode it in DIME | ||
| 480 | - * | ||
| 481 | - */ | ||
| 482 | - function encodeData($data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 483 | - { | ||
| 484 | - $len = strlen($data); | ||
| 485 | - $resp = ''; | ||
| 486 | - if ($len > $this->record_size) { | ||
| 487 | - $chunk = substr($data, 0, $this->record_size); | ||
| 488 | - $p = $this->record_size; | ||
| 489 | - $resp .= $this->startChunk($chunk,$typestr,$id,$type); | ||
| 490 | - while ($p < $len) { | ||
| 491 | - $chunk = substr($data, $p, $this->record_size); | ||
| 492 | - $p += $this->record_size; | ||
| 493 | - $resp .= $this->doChunk($chunk); | ||
| 494 | - } | ||
| 495 | - $resp .= $this->endChunk(); | ||
| 496 | - } else { | ||
| 497 | - $resp .= $this->_makeRecord($data, $typestr,$id,$type); | ||
| 498 | - } | ||
| 499 | - return $resp; | ||
| 500 | - } | ||
| 501 | - | ||
| 502 | - /** | ||
| 503 | - * sendFile | ||
| 504 | - * | ||
| 505 | - * given a filename, it reads the file, | ||
| 506 | - * creates records and writes them to the stream | ||
| 507 | - * | ||
| 508 | - */ | ||
| 509 | - function encodeFile($filename, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 510 | - { | ||
| 511 | - $f = fopen($filename, "rb"); | ||
| 512 | - if ($f) { | ||
| 513 | - if ($data = fread($f, $this->record_size)) { | ||
| 514 | - $resp = $this->startChunk($data,$typestr,$id,$type); | ||
| 515 | - } | ||
| 516 | - while ($data = fread($f, $this->record_size)) { | ||
| 517 | - $resp = $this->doChunk($data,$typestr,$id,$type); | ||
| 518 | - } | ||
| 519 | - $resp = $this->endChunk(); | ||
| 520 | - fclose($f); | ||
| 521 | - } | ||
| 522 | - return $resp; | ||
| 523 | - } | ||
| 524 | - | ||
| 525 | - /** | ||
| 526 | - * _processData | ||
| 527 | - * | ||
| 528 | - * creates Net_DIME_Records from provided data | ||
| 529 | - * | ||
| 530 | - */ | ||
| 531 | - function _processData(&$data) | ||
| 532 | - { | ||
| 533 | - $leftover = NULL; | ||
| 534 | - if (!$this->_currentRecord) { | ||
| 535 | - $this->_currentRecord = new Net_DIME_Record($this->debug); | ||
| 536 | - $data = $this->_currentRecord->decode($data); | ||
| 537 | - } else { | ||
| 538 | - $data = $this->_currentRecord->addData($data); | ||
| 539 | - } | ||
| 540 | - | ||
| 541 | - if ($this->_currentRecord->_haveData) { | ||
| 542 | - if (count($this->parts)==0 && !$this->_currentRecord->isStart()) { | ||
| 543 | - // raise an error! | ||
| 544 | - return PEAR::raiseError('First Message is not a DIME begin record!'); | ||
| 545 | - } | ||
| 546 | - | ||
| 547 | - if ($this->_currentRecord->isEnd() && $this->_currentRecord->getDataLength()==0) { | ||
| 548 | - return NULL; | ||
| 549 | - } | ||
| 550 | - | ||
| 551 | - if ($this->currentPart < 0 && !$this->_currentRecord->isChunk()) { | ||
| 552 | - $this->parts[] = array(); | ||
| 553 | - $this->currentPart = count($this->parts)-1; | ||
| 554 | - $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID(); | ||
| 555 | - $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType(); | ||
| 556 | - $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData(); | ||
| 557 | - $this->currentPart = -1; | ||
| 558 | - } else { | ||
| 559 | - if ($this->currentPart < 0) { | ||
| 560 | - $this->parts[] = array(); | ||
| 561 | - $this->currentPart = count($this->parts)-1; | ||
| 562 | - $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID(); | ||
| 563 | - $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType(); | ||
| 564 | - $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData(); | ||
| 565 | - } else { | ||
| 566 | - $this->parts[$this->currentPart]['data'] .= $this->_currentRecord->getData(); | ||
| 567 | - if (!$this->_currentRecord->isChunk()) { | ||
| 568 | - // we reached the end of the chunk | ||
| 569 | - $this->currentPart = -1; | ||
| 570 | - } | ||
| 571 | - } | ||
| 572 | - } | ||
| 573 | - #$this->records[] = $this->_currentRecord; | ||
| 574 | - if (!$this->_currentRecord->isEnd()) $this->_currentRecord = NULL; | ||
| 575 | - } | ||
| 576 | - return NULL; | ||
| 577 | - } | ||
| 578 | - | ||
| 579 | - /** | ||
| 580 | - * decodeData | ||
| 581 | - * | ||
| 582 | - * decodes a DIME encrypted string of data | ||
| 583 | - * | ||
| 584 | - */ | ||
| 585 | - function decodeData(&$data) { | ||
| 586 | - while (strlen($data) >= NET_DIME_RECORD_HEADER) { | ||
| 587 | - $err = $this->_processData($data); | ||
| 588 | - if (PEAR::isError($err)) { | ||
| 589 | - return $err; | ||
| 590 | - } | ||
| 591 | - } | ||
| 592 | - } | ||
| 593 | - | ||
| 594 | - /** | ||
| 595 | - * read | ||
| 596 | - * | ||
| 597 | - * reads the stream and creates | ||
| 598 | - * an array of records | ||
| 599 | - * | ||
| 600 | - * it can accept the start of a previously read buffer | ||
| 601 | - * this is usefull in situations where you need to read | ||
| 602 | - * headers before discovering that the data is DIME encoded | ||
| 603 | - * such as in the case of reading an HTTP response. | ||
| 604 | - */ | ||
| 605 | - function read($buf=NULL) | ||
| 606 | - { | ||
| 607 | - while ($data = fread($this->stream, 8192)) { | ||
| 608 | - if ($buf) { | ||
| 609 | - $data = $buf.$data; | ||
| 610 | - $buf = NULL; | ||
| 611 | - } | ||
| 612 | - if ($this->debug) | ||
| 613 | - echo "read: ".strlen($data)." bytes\n"; | ||
| 614 | - $err = $this->decodeData($data); | ||
| 615 | - if (PEAR::isError($err)) { | ||
| 616 | - return $err; | ||
| 617 | - } | ||
| 618 | - | ||
| 619 | - // store any leftover data to be used again | ||
| 620 | - // should be < NET_DIME_RECORD_HEADER bytes | ||
| 621 | - $buf = $data; | ||
| 622 | - } | ||
| 623 | - if (!$this->_currentRecord || !$this->_currentRecord->isEnd()) { | ||
| 624 | - return PEAR::raiseError('reached stream end without end record'); | ||
| 625 | - } | ||
| 626 | - return NULL; | ||
| 627 | - } | ||
| 628 | -} | 1 | +<?php |
| 2 | +// | ||
| 3 | +// +----------------------------------------------------------------------+ | ||
| 4 | +// | PHP Version 4 | | ||
| 5 | +// +----------------------------------------------------------------------+ | ||
| 6 | +// | Copyright (c) 1997-2002 The PHP Group | | ||
| 7 | +// +----------------------------------------------------------------------+ | ||
| 8 | +// | This source file is subject to version 2.02 of the PHP license, | | ||
| 9 | +// | that is bundled with this package in the file LICENSE, and is | | ||
| 10 | +// | available at through the world-wide-web at | | ||
| 11 | +// | http://www.php.net/license/2_02.txt. | | ||
| 12 | +// | If you did not receive a copy of the PHP license and are unable to | | ||
| 13 | +// | obtain it through the world-wide-web, please send a note to | | ||
| 14 | +// | license@php.net so we can mail you a copy immediately. | | ||
| 15 | +// +----------------------------------------------------------------------+ | ||
| 16 | +// | Authors: Shane Caraveo <shane@caraveo.com> | | ||
| 17 | +// | Ralf Hofmann <ralf.hofmann@verdisoft.com> | | ||
| 18 | +// +----------------------------------------------------------------------+ | ||
| 19 | +// | ||
| 20 | +// $Id$ | ||
| 21 | +// | ||
| 22 | + | ||
| 23 | +require_once 'PEAR.php'; | ||
| 24 | +/** | ||
| 25 | + * | ||
| 26 | + * DIME Encoding/Decoding | ||
| 27 | + * | ||
| 28 | + * What is it? | ||
| 29 | + * This class enables you to manipulate and build | ||
| 30 | + * a DIME encapsulated message. | ||
| 31 | + * | ||
| 32 | + * http://www.ietf.org/internet-drafts/draft-nielsen-dime-02.txt | ||
| 33 | + * | ||
| 34 | + * 09/18/02 Ralf - A huge number of changes to be compliant | ||
| 35 | + * with the DIME Specification Release 17 June 2002 | ||
| 36 | + * | ||
| 37 | + * TODO: lots of stuff needs to be tested. | ||
| 38 | + * Definitily have to go through DIME spec and | ||
| 39 | + * make things work right, most importantly, sec 3.3 | ||
| 40 | + * make examples, document | ||
| 41 | + * | ||
| 42 | + * see test/dime_mesage_test.php for example of usage | ||
| 43 | + * | ||
| 44 | + * @author Shane Caraveo <shane@caraveo.com>, | ||
| 45 | + * Ralf Hofmann <ralf.hofmann@verdisoft.com> | ||
| 46 | + * @version $Revision$ | ||
| 47 | + * @package Net_DIME | ||
| 48 | + */ | ||
| 49 | +define('NET_DIME_TYPE_UNCHANGED',0x00); | ||
| 50 | +define('NET_DIME_TYPE_MEDIA',0x01); | ||
| 51 | +define('NET_DIME_TYPE_URI',0x02); | ||
| 52 | +define('NET_DIME_TYPE_UNKNOWN',0x03); | ||
| 53 | +define('NET_DIME_TYPE_NONE',0x04); | ||
| 54 | + | ||
| 55 | +define('NET_DIME_VERSION',0x0001); | ||
| 56 | + | ||
| 57 | +define('NET_DIME_RECORD_HEADER',12); | ||
| 58 | + | ||
| 59 | +define('NET_DIME_FLAGS', 0); | ||
| 60 | +define('NET_DIME_OPTS_LEN', 1); | ||
| 61 | +define('NET_DIME_ID_LEN', 2); | ||
| 62 | +define('NET_DIME_TYPE_LEN', 3); | ||
| 63 | +define('NET_DIME_DATA_LEN', 4); | ||
| 64 | +define('NET_DIME_OPTS', 5); | ||
| 65 | +define('NET_DIME_ID', 6); | ||
| 66 | +define('NET_DIME_TYPE', 7); | ||
| 67 | +define('NET_DIME_DATA', 8); | ||
| 68 | + | ||
| 69 | +class Net_DIME_Record extends PEAR | ||
| 70 | +{ | ||
| 71 | + // these are used to hold the padded length | ||
| 72 | + var $OPTS_LENGTH = 0; | ||
| 73 | + var $ID_LENGTH = 0; | ||
| 74 | + var $TYPE_LENGTH = 0; | ||
| 75 | + var $DATA_LENGTH = 0; | ||
| 76 | + var $_haveOpts = FALSE; | ||
| 77 | + var $_haveID = FALSE; | ||
| 78 | + var $_haveType = FALSE; | ||
| 79 | + var $_haveData = FALSE; | ||
| 80 | + var $debug = FALSE; | ||
| 81 | + var $padstr = "\0"; | ||
| 82 | + /** | ||
| 83 | + * Elements | ||
| 84 | + * [NET_DIME_FLAGS], 16 bits: VERSION:MB:ME:CF:TYPE_T | ||
| 85 | + * [NET_DIME_OPTS_LEN], 16 bits: OPTIONS_LENGTH | ||
| 86 | + * [NET_DIME_ID_LEN], 16 bits: ID_LENGTH | ||
| 87 | + * [NET_DIME_TYPE_LEN], 16 bits: TYPE_LENGTH | ||
| 88 | + * [NET_DIME_DATA_LEN], 32 bits: DATA_LENGTH | ||
| 89 | + * [NET_DIME_OPTS] : OPTIONS | ||
| 90 | + * [NET_DIME_ID] : ID | ||
| 91 | + * [NET_DIME_TYPE] : TYPE | ||
| 92 | + * [NET_DIME_DATA] : DATA | ||
| 93 | + */ | ||
| 94 | + var $Elements = array(NET_DIME_FLAGS => 0, NET_DIME_OPTS_LEN => 0, | ||
| 95 | + NET_DIME_ID_LEN => 0, NET_DIME_TYPE_LEN => 0, | ||
| 96 | + NET_DIME_DATA_LEN => 0, | ||
| 97 | + NET_DIME_OPTS => '', | ||
| 98 | + NET_DIME_ID => '', | ||
| 99 | + NET_DIME_TYPE => '', | ||
| 100 | + NET_DIME_DATA => ''); | ||
| 101 | + | ||
| 102 | + function Net_DIME_Record($debug = FALSE) | ||
| 103 | + { | ||
| 104 | + $this->debug = $debug; | ||
| 105 | + if ($debug) $this->padstr = '*'; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + function setMB() | ||
| 109 | + { | ||
| 110 | + $this->Elements[NET_DIME_FLAGS] |= 0x0400; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + function setME() | ||
| 114 | + { | ||
| 115 | + $this->Elements[NET_DIME_FLAGS] |= 0x0200; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + function setCF() | ||
| 119 | + { | ||
| 120 | + $this->Elements[NET_DIME_FLAGS] |= 0x0100; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + function isChunk() | ||
| 124 | + { | ||
| 125 | + return $this->Elements[NET_DIME_FLAGS] & 0x0100; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + function isEnd() | ||
| 129 | + { | ||
| 130 | + return $this->Elements[NET_DIME_FLAGS] & 0x0200; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + function isStart() | ||
| 134 | + { | ||
| 135 | + return $this->Elements[NET_DIME_FLAGS] & 0x0400; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + function getID() | ||
| 139 | + { | ||
| 140 | + return $this->Elements[NET_DIME_ID]; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + function getType() | ||
| 144 | + { | ||
| 145 | + return $this->Elements[NET_DIME_TYPE]; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + function getData() | ||
| 149 | + { | ||
| 150 | + return $this->Elements[NET_DIME_DATA]; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + function getDataLength() | ||
| 154 | + { | ||
| 155 | + return $this->Elements[NET_DIME_DATA_LEN]; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + function setType($typestring, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 159 | + { | ||
| 160 | + $typelen = strlen($typestring) & 0xFFFF; | ||
| 161 | + $type = $type << 4; | ||
| 162 | + $this->Elements[NET_DIME_FLAGS] = ($this->Elements[NET_DIME_FLAGS] & 0xFF0F) | $type; | ||
| 163 | + $this->Elements[NET_DIME_TYPE_LEN] = $typelen; | ||
| 164 | + $this->TYPE_LENGTH = $this->_getPadLength($typelen); | ||
| 165 | + $this->Elements[NET_DIME_TYPE] = $typestring; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + function generateID() | ||
| 169 | + { | ||
| 170 | + $id = md5(time()); | ||
| 171 | + $this->setID($id); | ||
| 172 | + return $id; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + function setID($id) | ||
| 176 | + { | ||
| 177 | + $idlen = strlen($id) & 0xFFFF; | ||
| 178 | + $this->Elements[NET_DIME_ID_LEN] = $idlen; | ||
| 179 | + $this->ID_LENGTH = $this->_getPadLength($idlen); | ||
| 180 | + $this->Elements[NET_DIME_ID] = $id; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + function setData($data, $size=0) | ||
| 184 | + { | ||
| 185 | + $datalen = $size?$size:strlen($data); | ||
| 186 | + $this->Elements[NET_DIME_DATA_LEN] = $datalen; | ||
| 187 | + $this->DATA_LENGTH = $this->_getPadLength($datalen); | ||
| 188 | + $this->Elements[NET_DIME_DATA] = $data; | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + function encode() | ||
| 192 | + { | ||
| 193 | + // insert version | ||
| 194 | + $this->Elements[NET_DIME_FLAGS] = ($this->Elements[NET_DIME_FLAGS] & 0x07FF) | (NET_DIME_VERSION << 11); | ||
| 195 | + | ||
| 196 | + // the real dime encoding | ||
| 197 | + $format = '%c%c%c%c%c%c%c%c%c%c%c%c'. | ||
| 198 | + '%'.$this->OPTS_LENGTH.'s'. | ||
| 199 | + '%'.$this->ID_LENGTH.'s'. | ||
| 200 | + '%'.$this->TYPE_LENGTH.'s'. | ||
| 201 | + '%'.$this->DATA_LENGTH.'s'; | ||
| 202 | + return sprintf($format, | ||
| 203 | + ($this->Elements[NET_DIME_FLAGS]&0x0000FF00)>>8, | ||
| 204 | + ($this->Elements[NET_DIME_FLAGS]&0x000000FF), | ||
| 205 | + ($this->Elements[NET_DIME_OPTS_LEN]&0x0000FF00)>>8, | ||
| 206 | + ($this->Elements[NET_DIME_OPTS_LEN]&0x000000FF), | ||
| 207 | + ($this->Elements[NET_DIME_ID_LEN]&0x0000FF00)>>8, | ||
| 208 | + ($this->Elements[NET_DIME_ID_LEN]&0x000000FF), | ||
| 209 | + ($this->Elements[NET_DIME_TYPE_LEN]&0x0000FF00)>>8, | ||
| 210 | + ($this->Elements[NET_DIME_TYPE_LEN]&0x000000FF), | ||
| 211 | + ($this->Elements[NET_DIME_DATA_LEN]&0xFF000000)>>24, | ||
| 212 | + ($this->Elements[NET_DIME_DATA_LEN]&0x00FF0000)>>16, | ||
| 213 | + ($this->Elements[NET_DIME_DATA_LEN]&0x0000FF00)>>8, | ||
| 214 | + ($this->Elements[NET_DIME_DATA_LEN]&0x000000FF), | ||
| 215 | + str_pad($this->Elements[NET_DIME_OPTS], $this->OPTS_LENGTH, $this->padstr), | ||
| 216 | + str_pad($this->Elements[NET_DIME_ID], $this->ID_LENGTH, $this->padstr), | ||
| 217 | + str_pad($this->Elements[NET_DIME_TYPE], $this->TYPE_LENGTH, $this->padstr), | ||
| 218 | + str_pad($this->Elements[NET_DIME_DATA], $this->DATA_LENGTH, $this->padstr)); | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + function _getPadLength($len) | ||
| 222 | + { | ||
| 223 | + $pad = 0; | ||
| 224 | + if ($len) { | ||
| 225 | + $pad = $len % 4; | ||
| 226 | + if ($pad) $pad = 4 - $pad; | ||
| 227 | + } | ||
| 228 | + return $len + $pad; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + function decode(&$data) | ||
| 232 | + { | ||
| 233 | + // REAL DIME decoding | ||
| 234 | + $this->Elements[NET_DIME_FLAGS] = (hexdec(bin2hex($data[0]))<<8) + hexdec(bin2hex($data[1])); | ||
| 235 | + $this->Elements[NET_DIME_OPTS_LEN] = (hexdec(bin2hex($data[2]))<<8) + hexdec(bin2hex($data[3])); | ||
| 236 | + $this->Elements[NET_DIME_ID_LEN] = (hexdec(bin2hex($data[4]))<<8) + hexdec(bin2hex($data[5])); | ||
| 237 | + $this->Elements[NET_DIME_TYPE_LEN] = (hexdec(bin2hex($data[6]))<<8) + hexdec(bin2hex($data[7])); | ||
| 238 | + $this->Elements[NET_DIME_DATA_LEN] = (hexdec(bin2hex($data[8]))<<24) + | ||
| 239 | + (hexdec(bin2hex($data[9]))<<16) + | ||
| 240 | + (hexdec(bin2hex($data[10]))<<8) + | ||
| 241 | + hexdec(bin2hex($data[11])); | ||
| 242 | + $p = 12; | ||
| 243 | + | ||
| 244 | + $version = (($this->Elements[NET_DIME_FLAGS]>>11) & 0x001F); | ||
| 245 | + | ||
| 246 | + if ($version == NET_DIME_VERSION) | ||
| 247 | + { | ||
| 248 | + $this->OPTS_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_OPTS_LEN]); | ||
| 249 | + $this->ID_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_ID_LEN]); | ||
| 250 | + $this->TYPE_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_TYPE_LEN]); | ||
| 251 | + $this->DATA_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_DATA_LEN]); | ||
| 252 | + | ||
| 253 | + $datalen = strlen($data); | ||
| 254 | + $this->Elements[NET_DIME_OPTS] = substr($data,$p,$this->Elements[NET_DIME_OPTS_LEN]); | ||
| 255 | + $this->_haveOpts = (strlen($this->Elements[NET_DIME_OPTS]) == $this->Elements[NET_DIME_OPTS_LEN]); | ||
| 256 | + if ($this->_haveOpts) { | ||
| 257 | + $p += $this->OPTS_LENGTH; | ||
| 258 | + $this->Elements[NET_DIME_ID] = substr($data,$p,$this->Elements[NET_DIME_ID_LEN]); | ||
| 259 | + $this->_haveID = (strlen($this->Elements[NET_DIME_ID]) == $this->Elements[NET_DIME_ID_LEN]); | ||
| 260 | + if ($this->_haveID) { | ||
| 261 | + $p += $this->ID_LENGTH; | ||
| 262 | + $this->Elements[NET_DIME_TYPE] = substr($data,$p,$this->Elements[NET_DIME_TYPE_LEN]); | ||
| 263 | + $this->_haveType = (strlen($this->Elements[NET_DIME_TYPE]) == $this->Elements[NET_DIME_TYPE_LEN]); | ||
| 264 | + if ($this->_haveType) { | ||
| 265 | + $p += $this->TYPE_LENGTH; | ||
| 266 | + $this->Elements[NET_DIME_DATA] = substr($data,$p,$this->Elements[NET_DIME_DATA_LEN]); | ||
| 267 | + $this->_haveData = (strlen($this->Elements[NET_DIME_DATA]) == $this->Elements[NET_DIME_DATA_LEN]); | ||
| 268 | + if ($this->_haveData) { | ||
| 269 | + $p += $this->DATA_LENGTH; | ||
| 270 | + } else { | ||
| 271 | + $p += strlen($this->Elements[NET_DIME_DATA]); | ||
| 272 | + } | ||
| 273 | + } else { | ||
| 274 | + $p += strlen($this->Elements[NET_DIME_TYPE]); | ||
| 275 | + } | ||
| 276 | + } else { | ||
| 277 | + $p += strlen($this->Elements[NET_DIME_ID]); | ||
| 278 | + } | ||
| 279 | + } else { | ||
| 280 | + $p += strlen($this->Elements[NET_DIME_OPTS]); | ||
| 281 | + } | ||
| 282 | + } | ||
| 283 | + return substr($data, $p); | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + function addData(&$data) | ||
| 287 | + { | ||
| 288 | + $datalen = strlen($data); | ||
| 289 | + $p = 0; | ||
| 290 | + if (!$this->_haveOpts) { | ||
| 291 | + $have = strlen($this->Elements[NET_DIME_OPTS]); | ||
| 292 | + $this->Elements[NET_DIME_OPTS] .= substr($data,$p,$this->Elements[NET_DIME_OPTS_LEN]-$have); | ||
| 293 | + $this->_haveOpts = (strlen($this->Elements[NET_DIME_OPTS]) == $this->Elements[DIME_OTPS_LEN]); | ||
| 294 | + if (!$this->_haveOpts) return NULL; | ||
| 295 | + $p += $this->OPTS_LENGTH-$have; | ||
| 296 | + } | ||
| 297 | + if (!$this->_haveID) { | ||
| 298 | + $have = strlen($this->Elements[NET_DIME_ID]); | ||
| 299 | + $this->Elements[NET_DIME_ID] .= substr($data,$p,$this->Elements[NET_DIME_ID_LEN]-$have); | ||
| 300 | + $this->_haveID = (strlen($this->Elements[NET_DIME_ID]) == $this->Elements[NET_DIME_ID_LEN]); | ||
| 301 | + if (!$this->_haveID) return NULL; | ||
| 302 | + $p += $this->ID_LENGTH-$have; | ||
| 303 | + } | ||
| 304 | + if (!$this->_haveType && $p < $datalen) { | ||
| 305 | + $have = strlen($this->Elements[NET_DIME_TYPE]); | ||
| 306 | + $this->Elements[NET_DIME_TYPE] .= substr($data,$p,$this->Elements[NET_DIME_TYPE_LEN]-$have); | ||
| 307 | + $this->_haveType = (strlen($this->Elements[NET_DIME_TYPE]) == $this->Elements[NET_DIME_TYPE_LEN]); | ||
| 308 | + if (!$this->_haveType) return NULL; | ||
| 309 | + $p += $this->TYPE_LENGTH-$have; | ||
| 310 | + } | ||
| 311 | + if (!$this->_haveData && $p < $datalen) { | ||
| 312 | + $have = strlen($this->Elements[NET_DIME_DATA]); | ||
| 313 | + $this->Elements[NET_DIME_DATA] .= substr($data,$p,$this->Elements[NET_DIME_DATA_LEN]-$have); | ||
| 314 | + $this->_haveData = (strlen($this->Elements[NET_DIME_DATA]) == $this->Elements[NET_DIME_DATA_LEN]); | ||
| 315 | + if (!$this->_haveData) return NULL; | ||
| 316 | + $p += $this->DATA_LENGTH-$have; | ||
| 317 | + } | ||
| 318 | + return substr($data,$p); | ||
| 319 | + } | ||
| 320 | +} | ||
| 321 | + | ||
| 322 | + | ||
| 323 | +class Net_DIME_Message extends PEAR | ||
| 324 | +{ | ||
| 325 | + | ||
| 326 | + var $record_size = 4096; | ||
| 327 | + #var $records =array(); | ||
| 328 | + var $parts = array(); | ||
| 329 | + var $currentPart = -1; | ||
| 330 | + var $stream = NULL; | ||
| 331 | + var $_currentRecord; | ||
| 332 | + var $_proc = array(); | ||
| 333 | + var $type; | ||
| 334 | + var $typestr; | ||
| 335 | + var $mb = 1; | ||
| 336 | + var $me = 0; | ||
| 337 | + var $cf = 0; | ||
| 338 | + var $id = NULL; | ||
| 339 | + var $debug = FALSE; | ||
| 340 | + /** | ||
| 341 | + * constructor | ||
| 342 | + * | ||
| 343 | + * this currently takes a file pointer as provided | ||
| 344 | + * by fopen | ||
| 345 | + * | ||
| 346 | + * TODO: integrate with the php streams stuff | ||
| 347 | + */ | ||
| 348 | + function Net_DIME_Message($stream=NULL, $record_size = 4096, $debug = FALSE) | ||
| 349 | + { | ||
| 350 | + $this->stream = $stream; | ||
| 351 | + $this->record_size = $record_size; | ||
| 352 | + $this->debug = $debug; | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + function _makeRecord(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 356 | + { | ||
| 357 | + $record = new Net_DIME_Record($this->debug); | ||
| 358 | + if ($this->mb) { | ||
| 359 | + $record->setMB(); | ||
| 360 | + // all subsequent records are not message begin! | ||
| 361 | + $this->mb = 0; | ||
| 362 | + } | ||
| 363 | + if ($this->me) $record->setME(); | ||
| 364 | + if ($this->cf) $record->setCF(); | ||
| 365 | + $record->setData($data); | ||
| 366 | + $record->setType($typestr,$type); | ||
| 367 | + if ($id) $record->setID($id); | ||
| 368 | + #if ($this->debug) { | ||
| 369 | + # print str_replace('\0','*',$record->encode()); | ||
| 370 | + #} | ||
| 371 | + return $record->encode(); | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + function startChunk(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 375 | + { | ||
| 376 | + $this->me = 0; | ||
| 377 | + $this->cf = 1; | ||
| 378 | + $this->type = $type; | ||
| 379 | + $this->typestr = $typestr; | ||
| 380 | + if ($id) { | ||
| 381 | + $this->id = $id; | ||
| 382 | + } else { | ||
| 383 | + $this->id = md5(time()); | ||
| 384 | + } | ||
| 385 | + return $this->_makeRecord($data, $this->typestr, $this->id, $this->type); | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + function doChunk(&$data) | ||
| 389 | + { | ||
| 390 | + $this->me = 0; | ||
| 391 | + $this->cf = 1; | ||
| 392 | + return $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_UNCHANGED); | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + function endChunk() | ||
| 396 | + { | ||
| 397 | + $this->cf = 0; | ||
| 398 | + $data = NULL; | ||
| 399 | + $rec = $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_UNCHANGED); | ||
| 400 | + $this->id = 0; | ||
| 401 | + $this->cf = 0; | ||
| 402 | + $this->id = 0; | ||
| 403 | + $this->type = NET_DIME_TYPE_UNKNOWN; | ||
| 404 | + $this->typestr = NULL; | ||
| 405 | + return $rec; | ||
| 406 | + } | ||
| 407 | + | ||
| 408 | + function endMessage() | ||
| 409 | + { | ||
| 410 | + $this->me = 1; | ||
| 411 | + $data = NULL; | ||
| 412 | + $rec = $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_NONE); | ||
| 413 | + $this->me = 0; | ||
| 414 | + $this->mb = 1; | ||
| 415 | + $this->id = 0; | ||
| 416 | + return $rec; | ||
| 417 | + } | ||
| 418 | + | ||
| 419 | + /** | ||
| 420 | + * sendRecord | ||
| 421 | + * | ||
| 422 | + * given a chunk of data, it creates DIME records | ||
| 423 | + * and writes them to the stream | ||
| 424 | + * | ||
| 425 | + */ | ||
| 426 | + function sendData(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 427 | + { | ||
| 428 | + $len = strlen($data); | ||
| 429 | + if ($len > $this->record_size) { | ||
| 430 | + $chunk = substr($data, 0, $this->record_size); | ||
| 431 | + $p = $this->record_size; | ||
| 432 | + $rec = $this->startChunk($chunk,$typestr,$id,$type); | ||
| 433 | + fwrite($this->stream, $rec); | ||
| 434 | + while ($p < $len) { | ||
| 435 | + $chunk = substr($data, $p, $this->record_size); | ||
| 436 | + $p += $this->record_size; | ||
| 437 | + $rec = $this->doChunk($chunk); | ||
| 438 | + fwrite($this->stream, $rec); | ||
| 439 | + } | ||
| 440 | + $rec = $this->endChunk(); | ||
| 441 | + fwrite($this->stream, $rec); | ||
| 442 | + return; | ||
| 443 | + } | ||
| 444 | + $rec = $this->_makeRecord($data, $typestr,$id,$type); | ||
| 445 | + fwrite($this->stream, $rec); | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | + function sendEndMessage() | ||
| 449 | + { | ||
| 450 | + $rec = $this->endMessage(); | ||
| 451 | + fwrite($this->stream, $rec); | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + /** | ||
| 455 | + * sendFile | ||
| 456 | + * | ||
| 457 | + * given a filename, it reads the file, | ||
| 458 | + * creates records and writes them to the stream | ||
| 459 | + * | ||
| 460 | + */ | ||
| 461 | + function sendFile($filename, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 462 | + { | ||
| 463 | + $f = fopen($filename, "rb"); | ||
| 464 | + if ($f) { | ||
| 465 | + if ($data = fread($f, $this->record_size)) { | ||
| 466 | + $this->startChunk($data,$typestr,$id,$type); | ||
| 467 | + } | ||
| 468 | + while ($data = fread($f, $this->record_size)) { | ||
| 469 | + $this->doChunk($data,$typestr,$id,$type); | ||
| 470 | + } | ||
| 471 | + $this->endChunk(); | ||
| 472 | + fclose($f); | ||
| 473 | + } | ||
| 474 | + } | ||
| 475 | + | ||
| 476 | + /** | ||
| 477 | + * encodeData | ||
| 478 | + * | ||
| 479 | + * given data, encode it in DIME | ||
| 480 | + * | ||
| 481 | + */ | ||
| 482 | + function encodeData($data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 483 | + { | ||
| 484 | + $len = strlen($data); | ||
| 485 | + $resp = ''; | ||
| 486 | + if ($len > $this->record_size) { | ||
| 487 | + $chunk = substr($data, 0, $this->record_size); | ||
| 488 | + $p = $this->record_size; | ||
| 489 | + $resp .= $this->startChunk($chunk,$typestr,$id,$type); | ||
| 490 | + while ($p < $len) { | ||
| 491 | + $chunk = substr($data, $p, $this->record_size); | ||
| 492 | + $p += $this->record_size; | ||
| 493 | + $resp .= $this->doChunk($chunk); | ||
| 494 | + } | ||
| 495 | + $resp .= $this->endChunk(); | ||
| 496 | + } else { | ||
| 497 | + $resp .= $this->_makeRecord($data, $typestr,$id,$type); | ||
| 498 | + } | ||
| 499 | + return $resp; | ||
| 500 | + } | ||
| 501 | + | ||
| 502 | + /** | ||
| 503 | + * sendFile | ||
| 504 | + * | ||
| 505 | + * given a filename, it reads the file, | ||
| 506 | + * creates records and writes them to the stream | ||
| 507 | + * | ||
| 508 | + */ | ||
| 509 | + function encodeFile($filename, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN) | ||
| 510 | + { | ||
| 511 | + $f = fopen($filename, "rb"); | ||
| 512 | + if ($f) { | ||
| 513 | + if ($data = fread($f, $this->record_size)) { | ||
| 514 | + $resp = $this->startChunk($data,$typestr,$id,$type); | ||
| 515 | + } | ||
| 516 | + while ($data = fread($f, $this->record_size)) { | ||
| 517 | + $resp = $this->doChunk($data,$typestr,$id,$type); | ||
| 518 | + } | ||
| 519 | + $resp = $this->endChunk(); | ||
| 520 | + fclose($f); | ||
| 521 | + } | ||
| 522 | + return $resp; | ||
| 523 | + } | ||
| 524 | + | ||
| 525 | + /** | ||
| 526 | + * _processData | ||
| 527 | + * | ||
| 528 | + * creates Net_DIME_Records from provided data | ||
| 529 | + * | ||
| 530 | + */ | ||
| 531 | + function _processData(&$data) | ||
| 532 | + { | ||
| 533 | + $leftover = NULL; | ||
| 534 | + if (!$this->_currentRecord) { | ||
| 535 | + $this->_currentRecord = new Net_DIME_Record($this->debug); | ||
| 536 | + $data = $this->_currentRecord->decode($data); | ||
| 537 | + } else { | ||
| 538 | + $data = $this->_currentRecord->addData($data); | ||
| 539 | + } | ||
| 540 | + | ||
| 541 | + if ($this->_currentRecord->_haveData) { | ||
| 542 | + if (count($this->parts)==0 && !$this->_currentRecord->isStart()) { | ||
| 543 | + // raise an error! | ||
| 544 | + return PEAR::raiseError('First Message is not a DIME begin record!'); | ||
| 545 | + } | ||
| 546 | + | ||
| 547 | + if ($this->_currentRecord->isEnd() && $this->_currentRecord->getDataLength()==0) { | ||
| 548 | + return NULL; | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + if ($this->currentPart < 0 && !$this->_currentRecord->isChunk()) { | ||
| 552 | + $this->parts[] = array(); | ||
| 553 | + $this->currentPart = count($this->parts)-1; | ||
| 554 | + $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID(); | ||
| 555 | + $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType(); | ||
| 556 | + $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData(); | ||
| 557 | + $this->currentPart = -1; | ||
| 558 | + } else { | ||
| 559 | + if ($this->currentPart < 0) { | ||
| 560 | + $this->parts[] = array(); | ||
| 561 | + $this->currentPart = count($this->parts)-1; | ||
| 562 | + $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID(); | ||
| 563 | + $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType(); | ||
| 564 | + $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData(); | ||
| 565 | + } else { | ||
| 566 | + $this->parts[$this->currentPart]['data'] .= $this->_currentRecord->getData(); | ||
| 567 | + if (!$this->_currentRecord->isChunk()) { | ||
| 568 | + // we reached the end of the chunk | ||
| 569 | + $this->currentPart = -1; | ||
| 570 | + } | ||
| 571 | + } | ||
| 572 | + } | ||
| 573 | + #$this->records[] = $this->_currentRecord; | ||
| 574 | + if (!$this->_currentRecord->isEnd()) $this->_currentRecord = NULL; | ||
| 575 | + } | ||
| 576 | + return NULL; | ||
| 577 | + } | ||
| 578 | + | ||
| 579 | + /** | ||
| 580 | + * decodeData | ||
| 581 | + * | ||
| 582 | + * decodes a DIME encrypted string of data | ||
| 583 | + * | ||
| 584 | + */ | ||
| 585 | + function decodeData(&$data) { | ||
| 586 | + while (strlen($data) >= NET_DIME_RECORD_HEADER) { | ||
| 587 | + $err = $this->_processData($data); | ||
| 588 | + if (PEAR::isError($err)) { | ||
| 589 | + return $err; | ||
| 590 | + } | ||
| 591 | + } | ||
| 592 | + } | ||
| 593 | + | ||
| 594 | + /** | ||
| 595 | + * read | ||
| 596 | + * | ||
| 597 | + * reads the stream and creates | ||
| 598 | + * an array of records | ||
| 599 | + * | ||
| 600 | + * it can accept the start of a previously read buffer | ||
| 601 | + * this is usefull in situations where you need to read | ||
| 602 | + * headers before discovering that the data is DIME encoded | ||
| 603 | + * such as in the case of reading an HTTP response. | ||
| 604 | + */ | ||
| 605 | + function read($buf=NULL) | ||
| 606 | + { | ||
| 607 | + while ($data = fread($this->stream, 8192)) { | ||
| 608 | + if ($buf) { | ||
| 609 | + $data = $buf.$data; | ||
| 610 | + $buf = NULL; | ||
| 611 | + } | ||
| 612 | + if ($this->debug) | ||
| 613 | + echo "read: ".strlen($data)." bytes\n"; | ||
| 614 | + $err = $this->decodeData($data); | ||
| 615 | + if (PEAR::isError($err)) { | ||
| 616 | + return $err; | ||
| 617 | + } | ||
| 618 | + | ||
| 619 | + // store any leftover data to be used again | ||
| 620 | + // should be < NET_DIME_RECORD_HEADER bytes | ||
| 621 | + $buf = $data; | ||
| 622 | + } | ||
| 623 | + if (!$this->_currentRecord || !$this->_currentRecord->isEnd()) { | ||
| 624 | + return PEAR::raiseError('reached stream end without end record'); | ||
| 625 | + } | ||
| 626 | + return NULL; | ||
| 627 | + } | ||
| 628 | +} | ||
| 629 | ?> | 629 | ?> |
| 630 | \ No newline at end of file | 630 | \ No newline at end of file |
thirdparty/pear/Net/Dict.php
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | // | Authors: Chandrashekhar Bhosle <cnb@php.net> | | 20 | // | Authors: Chandrashekhar Bhosle <cnb@php.net> | |
| 21 | // +----------------------------------------------------------------------+ | 21 | // +----------------------------------------------------------------------+ |
| 22 | // | 22 | // |
| 23 | -// $Id: Dict.php,v 1.3 2002/10/06 04:55:33 cnb Exp $ | 23 | +// $Id$ |
| 24 | 24 | ||
| 25 | // }}} | 25 | // }}} |
| 26 | // {{{ includes | 26 | // {{{ includes |
thirdparty/pear/Net/Dig.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Author: Colin Viebrock <colin@easyDNS.com> | | 16 | // | Author: Colin Viebrock <colin@easyDNS.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: Dig.php,v 1.1 2002/04/25 14:57:23 cmv Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | // A nice friendly OO interface to dig | 21 | // A nice friendly OO interface to dig |
| 22 | // | 22 | // |
thirdparty/pear/Net/Finger.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Sebastian Nohn <sebastian@nohn.net> | | 16 | // | Authors: Sebastian Nohn <sebastian@nohn.net> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: Finger.php,v 1.5 2003/01/04 11:55:46 mj Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | require_once 'PEAR.php'; | 22 | require_once 'PEAR.php'; |
| @@ -27,7 +27,7 @@ require_once 'Net/Socket.php'; | @@ -27,7 +27,7 @@ require_once 'Net/Socket.php'; | ||
| 27 | * | 27 | * |
| 28 | * Provides functions useful for Finger-Queries. | 28 | * Provides functions useful for Finger-Queries. |
| 29 | * | 29 | * |
| 30 | - * @version $Revision: 1.5 $ | 30 | + * @version $Revision$ |
| 31 | * @author Sebastian Nohn <sebastian@nohn.net> | 31 | * @author Sebastian Nohn <sebastian@nohn.net> |
| 32 | * @package Net | 32 | * @package Net |
| 33 | */ | 33 | */ |
thirdparty/pear/Net/Geo.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | | | 17 | // | | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: Geo.php,v 1.7 2004/02/18 22:59:20 lsmith Exp $ | 20 | +// $Id$ |
| 21 | 21 | ||
| 22 | require_once 'PEAR.php'; | 22 | require_once 'PEAR.php'; |
| 23 | require_once 'Cache/Function.php'; | 23 | require_once 'Cache/Function.php'; |
thirdparty/pear/Net/IPv4.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | * @author Florian Anderiasch <fa@php.net> | 17 | * @author Florian Anderiasch <fa@php.net> |
| 18 | * @copyright 1997-2005 The PHP Group | 18 | * @copyright 1997-2005 The PHP Group |
| 19 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 | 19 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
| 20 | -* @version CVS: $Id: IPv4.php,v 1.11 2005/11/29 12:56:35 fa Exp $ | 20 | +* @version CVS: $Id$ |
| 21 | * @link http://pear.php.net/package/Net_IPv4 | 21 | * @link http://pear.php.net/package/Net_IPv4 |
| 22 | */ | 22 | */ |
| 23 | 23 |
thirdparty/pear/Net/IPv6.php
| 1 | -<?php | ||
| 2 | -// | ||
| 3 | -// +----------------------------------------------------------------------+ | ||
| 4 | -// | PHP Version 4 | | ||
| 5 | -// +----------------------------------------------------------------------+ | ||
| 6 | -// | Copyright (c) 1997-2003 The PHP Group | | ||
| 7 | -// +----------------------------------------------------------------------+ | ||
| 8 | -// | This source file is subject to version 2.0 of the PHP license, | | ||
| 9 | -// | that is bundled with this package in the file LICENSE, and is | | ||
| 10 | -// | available at through the world-wide-web at | | ||
| 11 | -// | http://www.php.net/license/2_02.txt. | | ||
| 12 | -// | If you did not receive a copy of the PHP license and are unable to | | ||
| 13 | -// | obtain it through the world-wide-web, please send a note to | | ||
| 14 | -// | license@php.net so we can mail you a copy immediately. | | ||
| 15 | -// +----------------------------------------------------------------------+ | ||
| 16 | -// | Authors: Alexander Merz <alexander.merz@web.de> | | ||
| 17 | -// +----------------------------------------------------------------------+ | ||
| 18 | -// | ||
| 19 | -// $Id: IPv6.php,v 1.12 2005/09/01 12:42:00 alexmerz Exp $ | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | -* Class to validate and to work with IPv6 | ||
| 23 | -* | ||
| 24 | -* @author Alexander Merz <alexander.merz@t-online.de> | ||
| 25 | -* @author elfrink at introweb dot nl | ||
| 26 | -* @package Net_IPv6 | ||
| 27 | -* @version $Id: IPv6.php,v 1.12 2005/09/01 12:42:00 alexmerz Exp $ | ||
| 28 | -* @access public | ||
| 29 | -*/ | ||
| 30 | -class Net_IPv6 { | ||
| 31 | - | ||
| 32 | - // {{{ Uncompress() | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * Uncompresses an IPv6 adress | ||
| 36 | - * | ||
| 37 | - * RFC 2373 allows you to compress zeros in an adress to '::'. This | ||
| 38 | - * function expects an valid IPv6 adress and expands the '::' to | ||
| 39 | - * the required zeros. | ||
| 40 | - * | ||
| 41 | - * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 | ||
| 42 | - * ::1 -> 0:0:0:0:0:0:0:1 | ||
| 43 | - * | ||
| 44 | - * @access public | ||
| 45 | - * @see Compress() | ||
| 46 | - * @static | ||
| 47 | - * @param string $ip a valid IPv6-adress (hex format) | ||
| 48 | - * @return string the uncompressed IPv6-adress (hex format) | ||
| 49 | - */ | ||
| 50 | - function Uncompress($ip) { | ||
| 51 | - $uip = $ip; | ||
| 52 | - $c1 = -1; | ||
| 53 | - $c2 = -1; | ||
| 54 | - if (false !== strpos($ip, '::') ) { | ||
| 55 | - list($ip1, $ip2) = explode('::', $ip); | ||
| 56 | - if(""==$ip1) { | ||
| 57 | - $c1 = -1; | ||
| 58 | - } else { | ||
| 59 | - $pos = 0; | ||
| 60 | - if(0 < ($pos = substr_count($ip1, ':'))) { | ||
| 61 | - $c1 = $pos; | ||
| 62 | - } else { | ||
| 63 | - $c1 = 0; | ||
| 64 | - } | ||
| 65 | - } | ||
| 66 | - if(""==$ip2) { | ||
| 67 | - $c2 = -1; | ||
| 68 | - } else { | ||
| 69 | - $pos = 0; | ||
| 70 | - if(0 < ($pos = substr_count($ip2, ':'))) { | ||
| 71 | - $c2 = $pos; | ||
| 72 | - } else { | ||
| 73 | - $c2 = 0; | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - if(strstr($ip2, '.')) { | ||
| 77 | - $c2++; | ||
| 78 | - } | ||
| 79 | - if(-1 == $c1 && -1 == $c2) { // :: | ||
| 80 | - $uip = "0:0:0:0:0:0:0:0"; | ||
| 81 | - } else if(-1==$c1) { // ::xxx | ||
| 82 | - $fill = str_repeat('0:', 7-$c2); | ||
| 83 | - $uip = str_replace('::', $fill, $uip); | ||
| 84 | - } else if(-1==$c2) { // xxx:: | ||
| 85 | - $fill = str_repeat(':0', 7-$c1); | ||
| 86 | - $uip = str_replace('::', $fill, $uip); | ||
| 87 | - } else { // xxx::xxx | ||
| 88 | - $fill = str_repeat(':0:', 6-$c2-$c1); | ||
| 89 | - $uip = str_replace('::', $fill, $uip); | ||
| 90 | - $uip = str_replace('::', ':', $uip); | ||
| 91 | - } | ||
| 92 | - } | ||
| 93 | - return $uip; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - // }}} | ||
| 97 | - // {{{ Compress() | ||
| 98 | - | ||
| 99 | - /** | ||
| 100 | - * Compresses an IPv6 adress | ||
| 101 | - * | ||
| 102 | - * RFC 2373 allows you to compress zeros in an adress to '::'. This | ||
| 103 | - * function expects an valid IPv6 adress and compresses successive zeros | ||
| 104 | - * to '::' | ||
| 105 | - * | ||
| 106 | - * Example: FF01:0:0:0:0:0:0:101 -> FF01::101 | ||
| 107 | - * 0:0:0:0:0:0:0:1 -> ::1 | ||
| 108 | - * | ||
| 109 | - * @access public | ||
| 110 | - * @see Uncompress() | ||
| 111 | - * @static | ||
| 112 | - * @param string $ip a valid IPv6-adress (hex format) | ||
| 113 | - * @return string the compressed IPv6-adress (hex format) | ||
| 114 | - * @author elfrink at introweb dot nl | ||
| 115 | - */ | ||
| 116 | - function Compress($ip) { | ||
| 117 | - $cip = $ip; | ||
| 118 | - | ||
| 119 | - if (!strstr($ip, '::')) { | ||
| 120 | - $ipp = explode(':',$ip); | ||
| 121 | - for($i=0; $i<count($ipp); $i++) { | ||
| 122 | - $ipp[$i] = dechex(hexdec($ipp[$i])); | ||
| 123 | - } | ||
| 124 | - $cip = ':' . join(':',$ipp) . ':'; | ||
| 125 | - preg_match_all("/(:0)+/", $cip, $zeros); | ||
| 126 | - if (count($zeros[0])>0) { | ||
| 127 | - $match = ''; | ||
| 128 | - foreach($zeros[0] as $zero) { | ||
| 129 | - if (strlen($zero) > strlen($match)) | ||
| 130 | - $match = $zero; | ||
| 131 | - } | ||
| 132 | - $cip = preg_replace('/' . $match . '/', ':', $cip, 1); | ||
| 133 | - } | ||
| 134 | - $cip = preg_replace('/((^:)|(:$))/', '' ,$cip); | ||
| 135 | - $cip = preg_replace('/((^:)|(:$))/', '::' ,$cip); | ||
| 136 | - } | ||
| 137 | - return $cip; | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - // }}} | ||
| 141 | - // {{{ SplitV64() | ||
| 142 | - | ||
| 143 | - /** | ||
| 144 | - * Splits an IPv6 adress into the IPv6 and a possible IPv4 part | ||
| 145 | - * | ||
| 146 | - * RFC 2373 allows you to note the last two parts of an IPv6 adress as | ||
| 147 | - * an IPv4 compatible adress | ||
| 148 | - * | ||
| 149 | - * Example: 0:0:0:0:0:0:13.1.68.3 | ||
| 150 | - * 0:0:0:0:0:FFFF:129.144.52.38 | ||
| 151 | - * | ||
| 152 | - * @access public | ||
| 153 | - * @static | ||
| 154 | - * @param string $ip a valid IPv6-adress (hex format) | ||
| 155 | - * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format) | ||
| 156 | - */ | ||
| 157 | - function SplitV64($ip) { | ||
| 158 | - $ip = Net_IPv6::Uncompress($ip); | ||
| 159 | - if (strstr($ip, '.')) { | ||
| 160 | - $pos = strrpos($ip, ':'); | ||
| 161 | - $ip{$pos} = '_'; | ||
| 162 | - $ipPart = explode('_', $ip); | ||
| 163 | - return $ipPart; | ||
| 164 | - } else { | ||
| 165 | - return array($ip, ""); | ||
| 166 | - } | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - // }}} | ||
| 170 | - // {{{ checkIPv6 | ||
| 171 | - | ||
| 172 | - /** | ||
| 173 | - * Checks an IPv6 adress | ||
| 174 | - * | ||
| 175 | - * Checks if the given IP is IPv6-compatible | ||
| 176 | - * | ||
| 177 | - * @access public | ||
| 178 | - * @static | ||
| 179 | - * @param string $ip a valid IPv6-adress | ||
| 180 | - * @return boolean true if $ip is an IPv6 adress | ||
| 181 | - */ | ||
| 182 | - function checkIPv6($ip) { | ||
| 183 | - | ||
| 184 | - $ipPart = Net_IPv6::SplitV64($ip); | ||
| 185 | - $count = 0; | ||
| 186 | - if (!empty($ipPart[0])) { | ||
| 187 | - $ipv6 =explode(':', $ipPart[0]); | ||
| 188 | - for ($i = 0; $i < count($ipv6); $i++) { | ||
| 189 | - $dec = hexdec($ipv6[$i]); | ||
| 190 | - $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i])); | ||
| 191 | - if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) { | ||
| 192 | - $count++; | ||
| 193 | - } | ||
| 194 | - } | ||
| 195 | - if (8 == $count) { | ||
| 196 | - return true; | ||
| 197 | - } elseif (6 == $count and !empty($ipPart[1])) { | ||
| 198 | - $ipv4 = explode('.',$ipPart[1]); | ||
| 199 | - $count = 0; | ||
| 200 | - for ($i = 0; $i < count($ipv4); $i++) { | ||
| 201 | - if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) { | ||
| 202 | - $count++; | ||
| 203 | - } | ||
| 204 | - } | ||
| 205 | - if (4 == $count) { | ||
| 206 | - return true; | ||
| 207 | - } | ||
| 208 | - } else { | ||
| 209 | - return false; | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - } else { | ||
| 213 | - return false; | ||
| 214 | - } | ||
| 215 | - } | ||
| 216 | - // }}} | ||
| 217 | -} | ||
| 218 | -?> | 1 | +<?php |
| 2 | +// | ||
| 3 | +// +----------------------------------------------------------------------+ | ||
| 4 | +// | PHP Version 4 | | ||
| 5 | +// +----------------------------------------------------------------------+ | ||
| 6 | +// | Copyright (c) 1997-2003 The PHP Group | | ||
| 7 | +// +----------------------------------------------------------------------+ | ||
| 8 | +// | This source file is subject to version 2.0 of the PHP license, | | ||
| 9 | +// | that is bundled with this package in the file LICENSE, and is | | ||
| 10 | +// | available at through the world-wide-web at | | ||
| 11 | +// | http://www.php.net/license/2_02.txt. | | ||
| 12 | +// | If you did not receive a copy of the PHP license and are unable to | | ||
| 13 | +// | obtain it through the world-wide-web, please send a note to | | ||
| 14 | +// | license@php.net so we can mail you a copy immediately. | | ||
| 15 | +// +----------------------------------------------------------------------+ | ||
| 16 | +// | Authors: Alexander Merz <alexander.merz@web.de> | | ||
| 17 | +// +----------------------------------------------------------------------+ | ||
| 18 | +// | ||
| 19 | +// $Id$ | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | +* Class to validate and to work with IPv6 | ||
| 23 | +* | ||
| 24 | +* @author Alexander Merz <alexander.merz@t-online.de> | ||
| 25 | +* @author elfrink at introweb dot nl | ||
| 26 | +* @package Net_IPv6 | ||
| 27 | +* @version $Id$ | ||
| 28 | +* @access public | ||
| 29 | +*/ | ||
| 30 | +class Net_IPv6 { | ||
| 31 | + | ||
| 32 | + // {{{ Uncompress() | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Uncompresses an IPv6 adress | ||
| 36 | + * | ||
| 37 | + * RFC 2373 allows you to compress zeros in an adress to '::'. This | ||
| 38 | + * function expects an valid IPv6 adress and expands the '::' to | ||
| 39 | + * the required zeros. | ||
| 40 | + * | ||
| 41 | + * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 | ||
| 42 | + * ::1 -> 0:0:0:0:0:0:0:1 | ||
| 43 | + * | ||
| 44 | + * @access public | ||
| 45 | + * @see Compress() | ||
| 46 | + * @static | ||
| 47 | + * @param string $ip a valid IPv6-adress (hex format) | ||
| 48 | + * @return string the uncompressed IPv6-adress (hex format) | ||
| 49 | + */ | ||
| 50 | + function Uncompress($ip) { | ||
| 51 | + $uip = $ip; | ||
| 52 | + $c1 = -1; | ||
| 53 | + $c2 = -1; | ||
| 54 | + if (false !== strpos($ip, '::') ) { | ||
| 55 | + list($ip1, $ip2) = explode('::', $ip); | ||
| 56 | + if(""==$ip1) { | ||
| 57 | + $c1 = -1; | ||
| 58 | + } else { | ||
| 59 | + $pos = 0; | ||
| 60 | + if(0 < ($pos = substr_count($ip1, ':'))) { | ||
| 61 | + $c1 = $pos; | ||
| 62 | + } else { | ||
| 63 | + $c1 = 0; | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + if(""==$ip2) { | ||
| 67 | + $c2 = -1; | ||
| 68 | + } else { | ||
| 69 | + $pos = 0; | ||
| 70 | + if(0 < ($pos = substr_count($ip2, ':'))) { | ||
| 71 | + $c2 = $pos; | ||
| 72 | + } else { | ||
| 73 | + $c2 = 0; | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + if(strstr($ip2, '.')) { | ||
| 77 | + $c2++; | ||
| 78 | + } | ||
| 79 | + if(-1 == $c1 && -1 == $c2) { // :: | ||
| 80 | + $uip = "0:0:0:0:0:0:0:0"; | ||
| 81 | + } else if(-1==$c1) { // ::xxx | ||
| 82 | + $fill = str_repeat('0:', 7-$c2); | ||
| 83 | + $uip = str_replace('::', $fill, $uip); | ||
| 84 | + } else if(-1==$c2) { // xxx:: | ||
| 85 | + $fill = str_repeat(':0', 7-$c1); | ||
| 86 | + $uip = str_replace('::', $fill, $uip); | ||
| 87 | + } else { // xxx::xxx | ||
| 88 | + $fill = str_repeat(':0:', 6-$c2-$c1); | ||
| 89 | + $uip = str_replace('::', $fill, $uip); | ||
| 90 | + $uip = str_replace('::', ':', $uip); | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + return $uip; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + // }}} | ||
| 97 | + // {{{ Compress() | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * Compresses an IPv6 adress | ||
| 101 | + * | ||
| 102 | + * RFC 2373 allows you to compress zeros in an adress to '::'. This | ||
| 103 | + * function expects an valid IPv6 adress and compresses successive zeros | ||
| 104 | + * to '::' | ||
| 105 | + * | ||
| 106 | + * Example: FF01:0:0:0:0:0:0:101 -> FF01::101 | ||
| 107 | + * 0:0:0:0:0:0:0:1 -> ::1 | ||
| 108 | + * | ||
| 109 | + * @access public | ||
| 110 | + * @see Uncompress() | ||
| 111 | + * @static | ||
| 112 | + * @param string $ip a valid IPv6-adress (hex format) | ||
| 113 | + * @return string the compressed IPv6-adress (hex format) | ||
| 114 | + * @author elfrink at introweb dot nl | ||
| 115 | + */ | ||
| 116 | + function Compress($ip) { | ||
| 117 | + $cip = $ip; | ||
| 118 | + | ||
| 119 | + if (!strstr($ip, '::')) { | ||
| 120 | + $ipp = explode(':',$ip); | ||
| 121 | + for($i=0; $i<count($ipp); $i++) { | ||
| 122 | + $ipp[$i] = dechex(hexdec($ipp[$i])); | ||
| 123 | + } | ||
| 124 | + $cip = ':' . join(':',$ipp) . ':'; | ||
| 125 | + preg_match_all("/(:0)+/", $cip, $zeros); | ||
| 126 | + if (count($zeros[0])>0) { | ||
| 127 | + $match = ''; | ||
| 128 | + foreach($zeros[0] as $zero) { | ||
| 129 | + if (strlen($zero) > strlen($match)) | ||
| 130 | + $match = $zero; | ||
| 131 | + } | ||
| 132 | + $cip = preg_replace('/' . $match . '/', ':', $cip, 1); | ||
| 133 | + } | ||
| 134 | + $cip = preg_replace('/((^:)|(:$))/', '' ,$cip); | ||
| 135 | + $cip = preg_replace('/((^:)|(:$))/', '::' ,$cip); | ||
| 136 | + } | ||
| 137 | + return $cip; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + // }}} | ||
| 141 | + // {{{ SplitV64() | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * Splits an IPv6 adress into the IPv6 and a possible IPv4 part | ||
| 145 | + * | ||
| 146 | + * RFC 2373 allows you to note the last two parts of an IPv6 adress as | ||
| 147 | + * an IPv4 compatible adress | ||
| 148 | + * | ||
| 149 | + * Example: 0:0:0:0:0:0:13.1.68.3 | ||
| 150 | + * 0:0:0:0:0:FFFF:129.144.52.38 | ||
| 151 | + * | ||
| 152 | + * @access public | ||
| 153 | + * @static | ||
| 154 | + * @param string $ip a valid IPv6-adress (hex format) | ||
| 155 | + * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format) | ||
| 156 | + */ | ||
| 157 | + function SplitV64($ip) { | ||
| 158 | + $ip = Net_IPv6::Uncompress($ip); | ||
| 159 | + if (strstr($ip, '.')) { | ||
| 160 | + $pos = strrpos($ip, ':'); | ||
| 161 | + $ip{$pos} = '_'; | ||
| 162 | + $ipPart = explode('_', $ip); | ||
| 163 | + return $ipPart; | ||
| 164 | + } else { | ||
| 165 | + return array($ip, ""); | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + // }}} | ||
| 170 | + // {{{ checkIPv6 | ||
| 171 | + | ||
| 172 | + /** | ||
| 173 | + * Checks an IPv6 adress | ||
| 174 | + * | ||
| 175 | + * Checks if the given IP is IPv6-compatible | ||
| 176 | + * | ||
| 177 | + * @access public | ||
| 178 | + * @static | ||
| 179 | + * @param string $ip a valid IPv6-adress | ||
| 180 | + * @return boolean true if $ip is an IPv6 adress | ||
| 181 | + */ | ||
| 182 | + function checkIPv6($ip) { | ||
| 183 | + | ||
| 184 | + $ipPart = Net_IPv6::SplitV64($ip); | ||
| 185 | + $count = 0; | ||
| 186 | + if (!empty($ipPart[0])) { | ||
| 187 | + $ipv6 =explode(':', $ipPart[0]); | ||
| 188 | + for ($i = 0; $i < count($ipv6); $i++) { | ||
| 189 | + $dec = hexdec($ipv6[$i]); | ||
| 190 | + $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i])); | ||
| 191 | + if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) { | ||
| 192 | + $count++; | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + if (8 == $count) { | ||
| 196 | + return true; | ||
| 197 | + } elseif (6 == $count and !empty($ipPart[1])) { | ||
| 198 | + $ipv4 = explode('.',$ipPart[1]); | ||
| 199 | + $count = 0; | ||
| 200 | + for ($i = 0; $i < count($ipv4); $i++) { | ||
| 201 | + if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) { | ||
| 202 | + $count++; | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + if (4 == $count) { | ||
| 206 | + return true; | ||
| 207 | + } | ||
| 208 | + } else { | ||
| 209 | + return false; | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + } else { | ||
| 213 | + return false; | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + // }}} | ||
| 217 | +} | ||
| 218 | +?> |
thirdparty/pear/Net/Ident.php
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | // | Original author: Gavin Brown <gavin.brown@uk.com> | | 18 | // | Original author: Gavin Brown <gavin.brown@uk.com> | |
| 19 | // +----------------------------------------------------------------------+ | 19 | // +----------------------------------------------------------------------+ |
| 20 | // | 20 | // |
| 21 | -// $Id: Ident.php,v 1.7 2005/03/07 11:23:26 nepto Exp $ | 21 | +// $Id$ |
| 22 | // | 22 | // |
| 23 | // Identification Protocol implementation | 23 | // Identification Protocol implementation |
| 24 | // | 24 | // |
thirdparty/pear/Net/POP3.php
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | // | Co-Author: Damian Fernandez Sosa <damlists@cnba.uba.ar> | | 33 | // | Co-Author: Damian Fernandez Sosa <damlists@cnba.uba.ar> | |
| 34 | // +-----------------------------------------------------------------------+ | 34 | // +-----------------------------------------------------------------------+ |
| 35 | // | 35 | // |
| 36 | -// $Id: POP3.php,v 1.2 2004/12/05 16:34:39 damian Exp $ | 36 | +// $Id$ |
| 37 | 37 | ||
| 38 | require_once('Net/Socket.php'); | 38 | require_once('Net/Socket.php'); |
| 39 | 39 |
thirdparty/pear/Net/Ping.php
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | // | Kai Schrรถder <k.schroeder@php.net> | | 19 | // | Kai Schrรถder <k.schroeder@php.net> | |
| 20 | // +----------------------------------------------------------------------+ | 20 | // +----------------------------------------------------------------------+ |
| 21 | // | 21 | // |
| 22 | -// $Id: Ping.php,v 1.36 2004/02/08 23:17:22 jan Exp $ | 22 | +// $Id$ |
| 23 | 23 | ||
| 24 | require_once "PEAR.php"; | 24 | require_once "PEAR.php"; |
| 25 | require_once "OS/Guess.php"; | 25 | require_once "OS/Guess.php"; |
| @@ -65,7 +65,7 @@ define('NET_PING_RESULT_UNSUPPORTED_BACKEND', 4); | @@ -65,7 +65,7 @@ define('NET_PING_RESULT_UNSUPPORTED_BACKEND', 4); | ||
| 65 | * ?> | 65 | * ?> |
| 66 | * | 66 | * |
| 67 | * @author Jan Lehnardt <jan@php.net> | 67 | * @author Jan Lehnardt <jan@php.net> |
| 68 | -* @version $Revision: 1.36 $ | 68 | +* @version $Revision$ |
| 69 | * @package Net | 69 | * @package Net |
| 70 | * @access public | 70 | * @access public |
| 71 | */ | 71 | */ |
| @@ -524,7 +524,7 @@ class Net_Ping | @@ -524,7 +524,7 @@ class Net_Ping | ||
| 524 | * Container class for Net_Ping results | 524 | * Container class for Net_Ping results |
| 525 | * | 525 | * |
| 526 | * @author Jan Lehnardt <jan@php.net> | 526 | * @author Jan Lehnardt <jan@php.net> |
| 527 | -* @version $Revision: 1.36 $ | 527 | +* @version $Revision$ |
| 528 | * @package Net | 528 | * @package Net |
| 529 | * @access private | 529 | * @access private |
| 530 | */ | 530 | */ |
thirdparty/pear/Net/SMTP.php
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | // | Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> | | 18 | // | Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> | |
| 19 | // +----------------------------------------------------------------------+ | 19 | // +----------------------------------------------------------------------+ |
| 20 | // | 20 | // |
| 21 | -// $Id: SMTP.php,v 1.54 2005/08/16 03:44:15 jon Exp $ | 21 | +// $Id$ |
| 22 | 22 | ||
| 23 | require_once 'PEAR.php'; | 23 | require_once 'PEAR.php'; |
| 24 | require_once 'Net/Socket.php'; | 24 | require_once 'Net/Socket.php'; |
thirdparty/pear/Net/SmartIRC.php
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | - * $Id: SmartIRC.php,v 1.54.2.14 2005/05/27 23:40:09 meebey Exp $ | ||
| 4 | - * $Revision: 1.54.2.14 $ | ||
| 5 | - * $Author: meebey $ | ||
| 6 | - * $Date: 2005/05/27 23:40:09 $ | 3 | + * $Id$ |
| 4 | + * $Revision$ | ||
| 5 | + * $Author$ | ||
| 6 | + * $Date$ | ||
| 7 | * | 7 | * |
| 8 | * Net_SmartIRC | 8 | * Net_SmartIRC |
| 9 | * This is a PHP class for communication with IRC networks, | 9 | * This is a PHP class for communication with IRC networks, |
| @@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
| 46 | include_once('SmartIRC/defines.php'); | 46 | include_once('SmartIRC/defines.php'); |
| 47 | include_once('SmartIRC/irccommands.php'); | 47 | include_once('SmartIRC/irccommands.php'); |
| 48 | include_once('SmartIRC/messagehandler.php'); | 48 | include_once('SmartIRC/messagehandler.php'); |
| 49 | -define('SMARTIRC_VERSION', '1.0.0 ($Revision: 1.54.2.14 $)'); | 49 | +define('SMARTIRC_VERSION', '1.0.0 ($Revision$)'); |
| 50 | define('SMARTIRC_VERSIONSTRING', 'Net_SmartIRC '.SMARTIRC_VERSION); | 50 | define('SMARTIRC_VERSIONSTRING', 'Net_SmartIRC '.SMARTIRC_VERSION); |
| 51 | 51 | ||
| 52 | /** | 52 | /** |
thirdparty/pear/Net/Socket.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Chuck Hagenbuch <chuck@horde.org> | | 17 | // | Chuck Hagenbuch <chuck@horde.org> | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: Socket.php,v 1.24 2005/02/03 20:40:16 chagenbu Exp $ | 20 | +// $Id$ |
| 21 | 21 | ||
| 22 | require_once 'PEAR.php'; | 22 | require_once 'PEAR.php'; |
| 23 | 23 |
thirdparty/pear/Net/Whois.php
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | // | Author: Seamus Venasse <seamus.venasse@polaris.ca> | | 18 | // | Author: Seamus Venasse <seamus.venasse@polaris.ca> | |
| 19 | // +----------------------------------------------------------------------+ | 19 | // +----------------------------------------------------------------------+ |
| 20 | // | 20 | // |
| 21 | -// $Id: Whois.php,v 1.11 2003/01/04 11:55:54 mj Exp $ | 21 | +// $Id$ |
| 22 | // | 22 | // |
| 23 | // Whois Class | 23 | // Whois Class |
| 24 | // | 24 | // |
thirdparty/pear/SOAP/Type/hexBinary.php
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | | 17 | // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | |
| 18 | // +----------------------------------------------------------------------+ | 18 | // +----------------------------------------------------------------------+ |
| 19 | // | 19 | // |
| 20 | -// $Id: hexBinary.php,v 1.6 2005/03/10 23:16:39 yunosh Exp $ | 20 | +// $Id$ |
| 21 | // | 21 | // |
| 22 | class SOAP_Type_hexBinary | 22 | class SOAP_Type_hexBinary |
| 23 | { | 23 | { |
thirdparty/pear/SOAP/example/com_client.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: com_client.php,v 1.3 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | // SOAPStruct is defined in the following file | 21 | // SOAPStruct is defined in the following file |
| 22 | require_once 'example_types.php'; | 22 | require_once 'example_types.php'; |
thirdparty/pear/SOAP/example/disco_server.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Author: Dmitri Vinogradov <dimitri@vinogradov.de> | | 16 | // | Author: Dmitri Vinogradov <dimitri@vinogradov.de> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: disco_server.php,v 1.5 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | 20 | ||
| 21 | /* | 21 | /* |
| 22 | This example shows how to mark up a server object so that | 22 | This example shows how to mark up a server object so that |
thirdparty/pear/SOAP/example/email_client.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: email_client.php,v 1.4 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
thirdparty/pear/SOAP/example/email_gateway.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: email_gateway.php,v 1.5 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
thirdparty/pear/SOAP/example/email_pop_gateway.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: email_pop_gateway.php,v 1.6 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | /* include the Email server class, which knows how to | 22 | /* include the Email server class, which knows how to |
thirdparty/pear/SOAP/example/email_pop_server.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: email_pop_server.php,v 1.6 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | /* include the Email server class, which knows how to | 22 | /* include the Email server class, which knows how to |
thirdparty/pear/SOAP/example/email_server.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: email_server.php,v 1.5 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
thirdparty/pear/SOAP/example/example_server.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: example_server.php,v 1.5 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | // first, include the SOAP/Server class | 22 | // first, include the SOAP/Server class |
thirdparty/pear/SOAP/example/server.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: server.php,v 1.10 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | // first, include the SOAP/Server class | 22 | // first, include the SOAP/Server class |
thirdparty/pear/SOAP/example/server2.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: server2.php,v 1.3 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | // first, include the SOAP/Server class | 22 | // first, include the SOAP/Server class |
thirdparty/pear/SOAP/example/smtp.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: smtp.php,v 1.5 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | // include soap client class | 21 | // include soap client class |
| 22 | include("SOAP/Client.php"); | 22 | include("SOAP/Client.php"); |
thirdparty/pear/SOAP/example/stockquote.php
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | | 18 | // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | |
| 19 | // +----------------------------------------------------------------------+ | 19 | // +----------------------------------------------------------------------+ |
| 20 | // | 20 | // |
| 21 | -// $Id: stockquote.php,v 1.7 2005/03/10 23:16:40 yunosh Exp $ | 21 | +// $Id$ |
| 22 | // | 22 | // |
| 23 | // include soap client class | 23 | // include soap client class |
| 24 | include("SOAP/Client.php"); | 24 | include("SOAP/Client.php"); |
thirdparty/pear/SOAP/example/tcp_client.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Hanna <iordy_at_iordy_dot_com> | | 16 | // | Authors: Shane Hanna <iordy_at_iordy_dot_com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: tcp_client.php,v 1.3 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | require_once('SOAP/Client.php'); | 22 | require_once('SOAP/Client.php'); |
thirdparty/pear/SOAP/example/tcp_server.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: tcp_server.php,v 1.4 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | // first, include the SOAP/Server class | 22 | // first, include the SOAP/Server class |
thirdparty/pear/SOAP/example/wsdl_client.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | | 16 | // | Authors: Shane Caraveo <Shane@Caraveo.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: wsdl_client.php,v 1.3 2005/03/10 23:16:40 yunosh Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | include("SOAP/Client.php"); | 21 | include("SOAP/Client.php"); |
| 22 | 22 |
thirdparty/pear/System.php
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | // | Authors: Tomas V.V.Cox <cox@idecnet.com> | | 16 | // | Authors: Tomas V.V.Cox <cox@idecnet.com> | |
| 17 | // +----------------------------------------------------------------------+ | 17 | // +----------------------------------------------------------------------+ |
| 18 | // | 18 | // |
| 19 | -// $Id: System.php,v 1.36 2004/06/15 16:33:46 pajoye Exp $ | 19 | +// $Id$ |
| 20 | // | 20 | // |
| 21 | 21 | ||
| 22 | require_once 'PEAR.php'; | 22 | require_once 'PEAR.php'; |
| @@ -48,7 +48,7 @@ $GLOBALS['_System_temp_files'] = array(); | @@ -48,7 +48,7 @@ $GLOBALS['_System_temp_files'] = array(); | ||
| 48 | * | 48 | * |
| 49 | * @package System | 49 | * @package System |
| 50 | * @author Tomas V.V.Cox <cox@idecnet.com> | 50 | * @author Tomas V.V.Cox <cox@idecnet.com> |
| 51 | -* @version $Revision: 1.36 $ | 51 | +* @version $Revision$ |
| 52 | * @access public | 52 | * @access public |
| 53 | * @see http://pear.php.net/manual/ | 53 | * @see http://pear.php.net/manual/ |
| 54 | */ | 54 | */ |
thirdparty/simpletest/simpletest/exceptions.php
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | * base include file for SimpleTest | 3 | * base include file for SimpleTest |
| 4 | * @package SimpleTest | 4 | * @package SimpleTest |
| 5 | * @subpackage UnitTester | 5 | * @subpackage UnitTester |
| 6 | - * @version $Id: exceptions.php,v 1.12 2006/11/09 23:14:48 lastcraft Exp $ | 6 | + * @version $Id$ |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | /**#@+ | 9 | /**#@+ |
thirdpartyjs/curvycorners/lgpl.txt
| 1 | - GNU LESSER GENERAL PUBLIC LICENSE | ||
| 2 | - Version 2.1, February 1999 | ||
| 3 | - | ||
| 4 | - Copyright (C) 1991, 1999 Free Software Foundation, Inc. | ||
| 5 | - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
| 6 | - Everyone is permitted to copy and distribute verbatim copies | ||
| 7 | - of this license document, but changing it is not allowed. | ||
| 8 | - | ||
| 9 | -[This is the first released version of the Lesser GPL. It also counts | ||
| 10 | - as the successor of the GNU Library Public License, version 2, hence | ||
| 11 | - the version number 2.1.] | ||
| 12 | - | ||
| 13 | - Preamble | ||
| 14 | - | ||
| 15 | - The licenses for most software are designed to take away your | ||
| 16 | -freedom to share and change it. By contrast, the GNU General Public | ||
| 17 | -Licenses are intended to guarantee your freedom to share and change | ||
| 18 | -free software--to make sure the software is free for all its users. | ||
| 19 | - | ||
| 20 | - This license, the Lesser General Public License, applies to some | ||
| 21 | -specially designated software packages--typically libraries--of the | ||
| 22 | -Free Software Foundation and other authors who decide to use it. You | ||
| 23 | -can use it too, but we suggest you first think carefully about whether | ||
| 24 | -this license or the ordinary General Public License is the better | ||
| 25 | -strategy to use in any particular case, based on the explanations below. | ||
| 26 | - | ||
| 27 | - When we speak of free software, we are referring to freedom of use, | ||
| 28 | -not price. Our General Public Licenses are designed to make sure that | ||
| 29 | -you have the freedom to distribute copies of free software (and charge | ||
| 30 | -for this service if you wish); that you receive source code or can get | ||
| 31 | -it if you want it; that you can change the software and use pieces of | ||
| 32 | -it in new free programs; and that you are informed that you can do | ||
| 33 | -these things. | ||
| 34 | - | ||
| 35 | - To protect your rights, we need to make restrictions that forbid | ||
| 36 | -distributors to deny you these rights or to ask you to surrender these | ||
| 37 | -rights. These restrictions translate to certain responsibilities for | ||
| 38 | -you if you distribute copies of the library or if you modify it. | ||
| 39 | - | ||
| 40 | - For example, if you distribute copies of the library, whether gratis | ||
| 41 | -or for a fee, you must give the recipients all the rights that we gave | ||
| 42 | -you. You must make sure that they, too, receive or can get the source | ||
| 43 | -code. If you link other code with the library, you must provide | ||
| 44 | -complete object files to the recipients, so that they can relink them | ||
| 45 | -with the library after making changes to the library and recompiling | ||
| 46 | -it. And you must show them these terms so they know their rights. | ||
| 47 | - | ||
| 48 | - We protect your rights with a two-step method: (1) we copyright the | ||
| 49 | -library, and (2) we offer you this license, which gives you legal | ||
| 50 | -permission to copy, distribute and/or modify the library. | ||
| 51 | - | ||
| 52 | - To protect each distributor, we want to make it very clear that | ||
| 53 | -there is no warranty for the free library. Also, if the library is | ||
| 54 | -modified by someone else and passed on, the recipients should know | ||
| 55 | -that what they have is not the original version, so that the original | ||
| 56 | -author's reputation will not be affected by problems that might be | ||
| 57 | -introduced by others. | ||
| 58 | - | ||
| 59 | - Finally, software patents pose a constant threat to the existence of | ||
| 60 | -any free program. We wish to make sure that a company cannot | ||
| 61 | -effectively restrict the users of a free program by obtaining a | ||
| 62 | -restrictive license from a patent holder. Therefore, we insist that | ||
| 63 | -any patent license obtained for a version of the library must be | ||
| 64 | -consistent with the full freedom of use specified in this license. | ||
| 65 | - | ||
| 66 | - Most GNU software, including some libraries, is covered by the | ||
| 67 | -ordinary GNU General Public License. This license, the GNU Lesser | ||
| 68 | -General Public License, applies to certain designated libraries, and | ||
| 69 | -is quite different from the ordinary General Public License. We use | ||
| 70 | -this license for certain libraries in order to permit linking those | ||
| 71 | -libraries into non-free programs. | ||
| 72 | - | ||
| 73 | - When a program is linked with a library, whether statically or using | ||
| 74 | -a shared library, the combination of the two is legally speaking a | ||
| 75 | -combined work, a derivative of the original library. The ordinary | ||
| 76 | -General Public License therefore permits such linking only if the | ||
| 77 | -entire combination fits its criteria of freedom. The Lesser General | ||
| 78 | -Public License permits more lax criteria for linking other code with | ||
| 79 | -the library. | ||
| 80 | - | ||
| 81 | - We call this license the "Lesser" General Public License because it | ||
| 82 | -does Less to protect the user's freedom than the ordinary General | ||
| 83 | -Public License. It also provides other free software developers Less | ||
| 84 | -of an advantage over competing non-free programs. These disadvantages | ||
| 85 | -are the reason we use the ordinary General Public License for many | ||
| 86 | -libraries. However, the Lesser license provides advantages in certain | ||
| 87 | -special circumstances. | ||
| 88 | - | ||
| 89 | - For example, on rare occasions, there may be a special need to | ||
| 90 | -encourage the widest possible use of a certain library, so that it becomes | ||
| 91 | -a de-facto standard. To achieve this, non-free programs must be | ||
| 92 | -allowed to use the library. A more frequent case is that a free | ||
| 93 | -library does the same job as widely used non-free libraries. In this | ||
| 94 | -case, there is little to gain by limiting the free library to free | ||
| 95 | -software only, so we use the Lesser General Public License. | ||
| 96 | - | ||
| 97 | - In other cases, permission to use a particular library in non-free | ||
| 98 | -programs enables a greater number of people to use a large body of | ||
| 99 | -free software. For example, permission to use the GNU C Library in | ||
| 100 | -non-free programs enables many more people to use the whole GNU | ||
| 101 | -operating system, as well as its variant, the GNU/Linux operating | ||
| 102 | -system. | ||
| 103 | - | ||
| 104 | - Although the Lesser General Public License is Less protective of the | ||
| 105 | -users' freedom, it does ensure that the user of a program that is | ||
| 106 | -linked with the Library has the freedom and the wherewithal to run | ||
| 107 | -that program using a modified version of the Library. | ||
| 108 | - | ||
| 109 | - The precise terms and conditions for copying, distribution and | ||
| 110 | -modification follow. Pay close attention to the difference between a | ||
| 111 | -"work based on the library" and a "work that uses the library". The | ||
| 112 | -former contains code derived from the library, whereas the latter must | ||
| 113 | -be combined with the library in order to run. | ||
| 114 | - | ||
| 115 | - GNU LESSER GENERAL PUBLIC LICENSE | ||
| 116 | - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
| 117 | - | ||
| 118 | - 0. This License Agreement applies to any software library or other | ||
| 119 | -program which contains a notice placed by the copyright holder or | ||
| 120 | -other authorized party saying it may be distributed under the terms of | ||
| 121 | -this Lesser General Public License (also called "this License"). | ||
| 122 | -Each licensee is addressed as "you". | ||
| 123 | - | ||
| 124 | - A "library" means a collection of software functions and/or data | ||
| 125 | -prepared so as to be conveniently linked with application programs | ||
| 126 | -(which use some of those functions and data) to form executables. | ||
| 127 | - | ||
| 128 | - The "Library", below, refers to any such software library or work | ||
| 129 | -which has been distributed under these terms. A "work based on the | ||
| 130 | -Library" means either the Library or any derivative work under | ||
| 131 | -copyright law: that is to say, a work containing the Library or a | ||
| 132 | -portion of it, either verbatim or with modifications and/or translated | ||
| 133 | -straightforwardly into another language. (Hereinafter, translation is | ||
| 134 | -included without limitation in the term "modification".) | ||
| 135 | - | ||
| 136 | - "Source code" for a work means the preferred form of the work for | ||
| 137 | -making modifications to it. For a library, complete source code means | ||
| 138 | -all the source code for all modules it contains, plus any associated | ||
| 139 | -interface definition files, plus the scripts used to control compilation | ||
| 140 | -and installation of the library. | ||
| 141 | - | ||
| 142 | - Activities other than copying, distribution and modification are not | ||
| 143 | -covered by this License; they are outside its scope. The act of | ||
| 144 | -running a program using the Library is not restricted, and output from | ||
| 145 | -such a program is covered only if its contents constitute a work based | ||
| 146 | -on the Library (independent of the use of the Library in a tool for | ||
| 147 | -writing it). Whether that is true depends on what the Library does | ||
| 148 | -and what the program that uses the Library does. | ||
| 149 | - | ||
| 150 | - 1. You may copy and distribute verbatim copies of the Library's | ||
| 151 | -complete source code as you receive it, in any medium, provided that | ||
| 152 | -you conspicuously and appropriately publish on each copy an | ||
| 153 | -appropriate copyright notice and disclaimer of warranty; keep intact | ||
| 154 | -all the notices that refer to this License and to the absence of any | ||
| 155 | -warranty; and distribute a copy of this License along with the | ||
| 156 | -Library. | ||
| 157 | - | ||
| 158 | - You may charge a fee for the physical act of transferring a copy, | ||
| 159 | -and you may at your option offer warranty protection in exchange for a | ||
| 160 | -fee. | ||
| 161 | - | ||
| 162 | - 2. You may modify your copy or copies of the Library or any portion | ||
| 163 | -of it, thus forming a work based on the Library, and copy and | ||
| 164 | -distribute such modifications or work under the terms of Section 1 | ||
| 165 | -above, provided that you also meet all of these conditions: | ||
| 166 | - | ||
| 167 | - a) The modified work must itself be a software library. | ||
| 168 | - | ||
| 169 | - b) You must cause the files modified to carry prominent notices | ||
| 170 | - stating that you changed the files and the date of any change. | ||
| 171 | - | ||
| 172 | - c) You must cause the whole of the work to be licensed at no | ||
| 173 | - charge to all third parties under the terms of this License. | ||
| 174 | - | ||
| 175 | - d) If a facility in the modified Library refers to a function or a | ||
| 176 | - table of data to be supplied by an application program that uses | ||
| 177 | - the facility, other than as an argument passed when the facility | ||
| 178 | - is invoked, then you must make a good faith effort to ensure that, | ||
| 179 | - in the event an application does not supply such function or | ||
| 180 | - table, the facility still operates, and performs whatever part of | ||
| 181 | - its purpose remains meaningful. | ||
| 182 | - | ||
| 183 | - (For example, a function in a library to compute square roots has | ||
| 184 | - a purpose that is entirely well-defined independent of the | ||
| 185 | - application. Therefore, Subsection 2d requires that any | ||
| 186 | - application-supplied function or table used by this function must | ||
| 187 | - be optional: if the application does not supply it, the square | ||
| 188 | - root function must still compute square roots.) | ||
| 189 | - | ||
| 190 | -These requirements apply to the modified work as a whole. If | ||
| 191 | -identifiable sections of that work are not derived from the Library, | ||
| 192 | -and can be reasonably considered independent and separate works in | ||
| 193 | -themselves, then this License, and its terms, do not apply to those | ||
| 194 | -sections when you distribute them as separate works. But when you | ||
| 195 | -distribute the same sections as part of a whole which is a work based | ||
| 196 | -on the Library, the distribution of the whole must be on the terms of | ||
| 197 | -this License, whose permissions for other licensees extend to the | ||
| 198 | -entire whole, and thus to each and every part regardless of who wrote | ||
| 199 | -it. | ||
| 200 | - | ||
| 201 | -Thus, it is not the intent of this section to claim rights or contest | ||
| 202 | -your rights to work written entirely by you; rather, the intent is to | ||
| 203 | -exercise the right to control the distribution of derivative or | ||
| 204 | -collective works based on the Library. | ||
| 205 | - | ||
| 206 | -In addition, mere aggregation of another work not based on the Library | ||
| 207 | -with the Library (or with a work based on the Library) on a volume of | ||
| 208 | -a storage or distribution medium does not bring the other work under | ||
| 209 | -the scope of this License. | ||
| 210 | - | ||
| 211 | - 3. You may opt to apply the terms of the ordinary GNU General Public | ||
| 212 | -License instead of this License to a given copy of the Library. To do | ||
| 213 | -this, you must alter all the notices that refer to this License, so | ||
| 214 | -that they refer to the ordinary GNU General Public License, version 2, | ||
| 215 | -instead of to this License. (If a newer version than version 2 of the | ||
| 216 | -ordinary GNU General Public License has appeared, then you can specify | ||
| 217 | -that version instead if you wish.) Do not make any other change in | ||
| 218 | -these notices. | ||
| 219 | - | ||
| 220 | - Once this change is made in a given copy, it is irreversible for | ||
| 221 | -that copy, so the ordinary GNU General Public License applies to all | ||
| 222 | -subsequent copies and derivative works made from that copy. | ||
| 223 | - | ||
| 224 | - This option is useful when you wish to copy part of the code of | ||
| 225 | -the Library into a program that is not a library. | ||
| 226 | - | ||
| 227 | - 4. You may copy and distribute the Library (or a portion or | ||
| 228 | -derivative of it, under Section 2) in object code or executable form | ||
| 229 | -under the terms of Sections 1 and 2 above provided that you accompany | ||
| 230 | -it with the complete corresponding machine-readable source code, which | ||
| 231 | -must be distributed under the terms of Sections 1 and 2 above on a | ||
| 232 | -medium customarily used for software interchange. | ||
| 233 | - | ||
| 234 | - If distribution of object code is made by offering access to copy | ||
| 235 | -from a designated place, then offering equivalent access to copy the | ||
| 236 | -source code from the same place satisfies the requirement to | ||
| 237 | -distribute the source code, even though third parties are not | ||
| 238 | -compelled to copy the source along with the object code. | ||
| 239 | - | ||
| 240 | - 5. A program that contains no derivative of any portion of the | ||
| 241 | -Library, but is designed to work with the Library by being compiled or | ||
| 242 | -linked with it, is called a "work that uses the Library". Such a | ||
| 243 | -work, in isolation, is not a derivative work of the Library, and | ||
| 244 | -therefore falls outside the scope of this License. | ||
| 245 | - | ||
| 246 | - However, linking a "work that uses the Library" with the Library | ||
| 247 | -creates an executable that is a derivative of the Library (because it | ||
| 248 | -contains portions of the Library), rather than a "work that uses the | ||
| 249 | -library". The executable is therefore covered by this License. | ||
| 250 | -Section 6 states terms for distribution of such executables. | ||
| 251 | - | ||
| 252 | - When a "work that uses the Library" uses material from a header file | ||
| 253 | -that is part of the Library, the object code for the work may be a | ||
| 254 | -derivative work of the Library even though the source code is not. | ||
| 255 | -Whether this is true is especially significant if the work can be | ||
| 256 | -linked without the Library, or if the work is itself a library. The | ||
| 257 | -threshold for this to be true is not precisely defined by law. | ||
| 258 | - | ||
| 259 | - If such an object file uses only numerical parameters, data | ||
| 260 | -structure layouts and accessors, and small macros and small inline | ||
| 261 | -functions (ten lines or less in length), then the use of the object | ||
| 262 | -file is unrestricted, regardless of whether it is legally a derivative | ||
| 263 | -work. (Executables containing this object code plus portions of the | ||
| 264 | -Library will still fall under Section 6.) | ||
| 265 | - | ||
| 266 | - Otherwise, if the work is a derivative of the Library, you may | ||
| 267 | -distribute the object code for the work under the terms of Section 6. | ||
| 268 | -Any executables containing that work also fall under Section 6, | ||
| 269 | -whether or not they are linked directly with the Library itself. | ||
| 270 | - | ||
| 271 | - 6. As an exception to the Sections above, you may also combine or | ||
| 272 | -link a "work that uses the Library" with the Library to produce a | ||
| 273 | -work containing portions of the Library, and distribute that work | ||
| 274 | -under terms of your choice, provided that the terms permit | ||
| 275 | -modification of the work for the customer's own use and reverse | ||
| 276 | -engineering for debugging such modifications. | ||
| 277 | - | ||
| 278 | - You must give prominent notice with each copy of the work that the | ||
| 279 | -Library is used in it and that the Library and its use are covered by | ||
| 280 | -this License. You must supply a copy of this License. If the work | ||
| 281 | -during execution displays copyright notices, you must include the | ||
| 282 | -copyright notice for the Library among them, as well as a reference | ||
| 283 | -directing the user to the copy of this License. Also, you must do one | ||
| 284 | -of these things: | ||
| 285 | - | ||
| 286 | - a) Accompany the work with the complete corresponding | ||
| 287 | - machine-readable source code for the Library including whatever | ||
| 288 | - changes were used in the work (which must be distributed under | ||
| 289 | - Sections 1 and 2 above); and, if the work is an executable linked | ||
| 290 | - with the Library, with the complete machine-readable "work that | ||
| 291 | - uses the Library", as object code and/or source code, so that the | ||
| 292 | - user can modify the Library and then relink to produce a modified | ||
| 293 | - executable containing the modified Library. (It is understood | ||
| 294 | - that the user who changes the contents of definitions files in the | ||
| 295 | - Library will not necessarily be able to recompile the application | ||
| 296 | - to use the modified definitions.) | ||
| 297 | - | ||
| 298 | - b) Use a suitable shared library mechanism for linking with the | ||
| 299 | - Library. A suitable mechanism is one that (1) uses at run time a | ||
| 300 | - copy of the library already present on the user's computer system, | ||
| 301 | - rather than copying library functions into the executable, and (2) | ||
| 302 | - will operate properly with a modified version of the library, if | ||
| 303 | - the user installs one, as long as the modified version is | ||
| 304 | - interface-compatible with the version that the work was made with. | ||
| 305 | - | ||
| 306 | - c) Accompany the work with a written offer, valid for at | ||
| 307 | - least three years, to give the same user the materials | ||
| 308 | - specified in Subsection 6a, above, for a charge no more | ||
| 309 | - than the cost of performing this distribution. | ||
| 310 | - | ||
| 311 | - d) If distribution of the work is made by offering access to copy | ||
| 312 | - from a designated place, offer equivalent access to copy the above | ||
| 313 | - specified materials from the same place. | ||
| 314 | - | ||
| 315 | - e) Verify that the user has already received a copy of these | ||
| 316 | - materials or that you have already sent this user a copy. | ||
| 317 | - | ||
| 318 | - For an executable, the required form of the "work that uses the | ||
| 319 | -Library" must include any data and utility programs needed for | ||
| 320 | -reproducing the executable from it. However, as a special exception, | ||
| 321 | -the materials to be distributed need not include anything that is | ||
| 322 | -normally distributed (in either source or binary form) with the major | ||
| 323 | -components (compiler, kernel, and so on) of the operating system on | ||
| 324 | -which the executable runs, unless that component itself accompanies | ||
| 325 | -the executable. | ||
| 326 | - | ||
| 327 | - It may happen that this requirement contradicts the license | ||
| 328 | -restrictions of other proprietary libraries that do not normally | ||
| 329 | -accompany the operating system. Such a contradiction means you cannot | ||
| 330 | -use both them and the Library together in an executable that you | ||
| 331 | -distribute. | ||
| 332 | - | ||
| 333 | - 7. You may place library facilities that are a work based on the | ||
| 334 | -Library side-by-side in a single library together with other library | ||
| 335 | -facilities not covered by this License, and distribute such a combined | ||
| 336 | -library, provided that the separate distribution of the work based on | ||
| 337 | -the Library and of the other library facilities is otherwise | ||
| 338 | -permitted, and provided that you do these two things: | ||
| 339 | - | ||
| 340 | - a) Accompany the combined library with a copy of the same work | ||
| 341 | - based on the Library, uncombined with any other library | ||
| 342 | - facilities. This must be distributed under the terms of the | ||
| 343 | - Sections above. | ||
| 344 | - | ||
| 345 | - b) Give prominent notice with the combined library of the fact | ||
| 346 | - that part of it is a work based on the Library, and explaining | ||
| 347 | - where to find the accompanying uncombined form of the same work. | ||
| 348 | - | ||
| 349 | - 8. You may not copy, modify, sublicense, link with, or distribute | ||
| 350 | -the Library except as expressly provided under this License. Any | ||
| 351 | -attempt otherwise to copy, modify, sublicense, link with, or | ||
| 352 | -distribute the Library is void, and will automatically terminate your | ||
| 353 | -rights under this License. However, parties who have received copies, | ||
| 354 | -or rights, from you under this License will not have their licenses | ||
| 355 | -terminated so long as such parties remain in full compliance. | ||
| 356 | - | ||
| 357 | - 9. You are not required to accept this License, since you have not | ||
| 358 | -signed it. However, nothing else grants you permission to modify or | ||
| 359 | -distribute the Library or its derivative works. These actions are | ||
| 360 | -prohibited by law if you do not accept this License. Therefore, by | ||
| 361 | -modifying or distributing the Library (or any work based on the | ||
| 362 | -Library), you indicate your acceptance of this License to do so, and | ||
| 363 | -all its terms and conditions for copying, distributing or modifying | ||
| 364 | -the Library or works based on it. | ||
| 365 | - | ||
| 366 | - 10. Each time you redistribute the Library (or any work based on the | ||
| 367 | -Library), the recipient automatically receives a license from the | ||
| 368 | -original licensor to copy, distribute, link with or modify the Library | ||
| 369 | -subject to these terms and conditions. You may not impose any further | ||
| 370 | -restrictions on the recipients' exercise of the rights granted herein. | ||
| 371 | -You are not responsible for enforcing compliance by third parties with | ||
| 372 | -this License. | ||
| 373 | - | ||
| 374 | - 11. If, as a consequence of a court judgment or allegation of patent | ||
| 375 | -infringement or for any other reason (not limited to patent issues), | ||
| 376 | -conditions are imposed on you (whether by court order, agreement or | ||
| 377 | -otherwise) that contradict the conditions of this License, they do not | ||
| 378 | -excuse you from the conditions of this License. If you cannot | ||
| 379 | -distribute so as to satisfy simultaneously your obligations under this | ||
| 380 | -License and any other pertinent obligations, then as a consequence you | ||
| 381 | -may not distribute the Library at all. For example, if a patent | ||
| 382 | -license would not permit royalty-free redistribution of the Library by | ||
| 383 | -all those who receive copies directly or indirectly through you, then | ||
| 384 | -the only way you could satisfy both it and this License would be to | ||
| 385 | -refrain entirely from distribution of the Library. | ||
| 386 | - | ||
| 387 | -If any portion of this section is held invalid or unenforceable under any | ||
| 388 | -particular circumstance, the balance of the section is intended to apply, | ||
| 389 | -and the section as a whole is intended to apply in other circumstances. | ||
| 390 | - | ||
| 391 | -It is not the purpose of this section to induce you to infringe any | ||
| 392 | -patents or other property right claims or to contest validity of any | ||
| 393 | -such claims; this section has the sole purpose of protecting the | ||
| 394 | -integrity of the free software distribution system which is | ||
| 395 | -implemented by public license practices. Many people have made | ||
| 396 | -generous contributions to the wide range of software distributed | ||
| 397 | -through that system in reliance on consistent application of that | ||
| 398 | -system; it is up to the author/donor to decide if he or she is willing | ||
| 399 | -to distribute software through any other system and a licensee cannot | ||
| 400 | -impose that choice. | ||
| 401 | - | ||
| 402 | -This section is intended to make thoroughly clear what is believed to | ||
| 403 | -be a consequence of the rest of this License. | ||
| 404 | - | ||
| 405 | - 12. If the distribution and/or use of the Library is restricted in | ||
| 406 | -certain countries either by patents or by copyrighted interfaces, the | ||
| 407 | -original copyright holder who places the Library under this License may add | ||
| 408 | -an explicit geographical distribution limitation excluding those countries, | ||
| 409 | -so that distribution is permitted only in or among countries not thus | ||
| 410 | -excluded. In such case, this License incorporates the limitation as if | ||
| 411 | -written in the body of this License. | ||
| 412 | - | ||
| 413 | - 13. The Free Software Foundation may publish revised and/or new | ||
| 414 | -versions of the Lesser General Public License from time to time. | ||
| 415 | -Such new versions will be similar in spirit to the present version, | ||
| 416 | -but may differ in detail to address new problems or concerns. | ||
| 417 | - | ||
| 418 | -Each version is given a distinguishing version number. If the Library | ||
| 419 | -specifies a version number of this License which applies to it and | ||
| 420 | -"any later version", you have the option of following the terms and | ||
| 421 | -conditions either of that version or of any later version published by | ||
| 422 | -the Free Software Foundation. If the Library does not specify a | ||
| 423 | -license version number, you may choose any version ever published by | ||
| 424 | -the Free Software Foundation. | ||
| 425 | - | ||
| 426 | - 14. If you wish to incorporate parts of the Library into other free | ||
| 427 | -programs whose distribution conditions are incompatible with these, | ||
| 428 | -write to the author to ask for permission. For software which is | ||
| 429 | -copyrighted by the Free Software Foundation, write to the Free | ||
| 430 | -Software Foundation; we sometimes make exceptions for this. Our | ||
| 431 | -decision will be guided by the two goals of preserving the free status | ||
| 432 | -of all derivatives of our free software and of promoting the sharing | ||
| 433 | -and reuse of software generally. | ||
| 434 | - | ||
| 435 | - NO WARRANTY | ||
| 436 | - | ||
| 437 | - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO | ||
| 438 | -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. | ||
| 439 | -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR | ||
| 440 | -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY | ||
| 441 | -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 442 | -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 443 | -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE | ||
| 444 | -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME | ||
| 445 | -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | ||
| 446 | - | ||
| 447 | - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN | ||
| 448 | -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY | ||
| 449 | -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU | ||
| 450 | -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR | ||
| 451 | -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE | ||
| 452 | -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | ||
| 453 | -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | ||
| 454 | -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | ||
| 455 | -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | ||
| 456 | -DAMAGES. | ||
| 457 | - | ||
| 458 | - END OF TERMS AND CONDITIONS | ||
| 459 | - | ||
| 460 | - How to Apply These Terms to Your New Libraries | ||
| 461 | - | ||
| 462 | - If you develop a new library, and you want it to be of the greatest | ||
| 463 | -possible use to the public, we recommend making it free software that | ||
| 464 | -everyone can redistribute and change. You can do so by permitting | ||
| 465 | -redistribution under these terms (or, alternatively, under the terms of the | ||
| 466 | -ordinary General Public License). | ||
| 467 | - | ||
| 468 | - To apply these terms, attach the following notices to the library. It is | ||
| 469 | -safest to attach them to the start of each source file to most effectively | ||
| 470 | -convey the exclusion of warranty; and each file should have at least the | ||
| 471 | -"copyright" line and a pointer to where the full notice is found. | ||
| 472 | - | ||
| 473 | - <one line to give the library's name and a brief idea of what it does.> | ||
| 474 | - Copyright (C) <year> <name of author> | ||
| 475 | - | ||
| 476 | - This library is free software; you can redistribute it and/or | ||
| 477 | - modify it under the terms of the GNU Lesser General Public | ||
| 478 | - License as published by the Free Software Foundation; either | ||
| 479 | - version 2.1 of the License, or (at your option) any later version. | ||
| 480 | - | ||
| 481 | - This library is distributed in the hope that it will be useful, | ||
| 482 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 483 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 484 | - Lesser General Public License for more details. | ||
| 485 | - | ||
| 486 | - You should have received a copy of the GNU Lesser General Public | ||
| 487 | - License along with this library; if not, write to the Free Software | ||
| 488 | - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
| 489 | - | ||
| 490 | -Also add information on how to contact you by electronic and paper mail. | ||
| 491 | - | ||
| 492 | -You should also get your employer (if you work as a programmer) or your | ||
| 493 | -school, if any, to sign a "copyright disclaimer" for the library, if | ||
| 494 | -necessary. Here is a sample; alter the names: | ||
| 495 | - | ||
| 496 | - Yoyodyne, Inc., hereby disclaims all copyright interest in the | ||
| 497 | - library `Frob' (a library for tweaking knobs) written by James Random Hacker. | ||
| 498 | - | ||
| 499 | - <signature of Ty Coon>, 1 April 1990 | ||
| 500 | - Ty Coon, President of Vice | ||
| 501 | - | 1 | + GNU LESSER GENERAL PUBLIC LICENSE |
| 2 | + Version 2.1, February 1999 | ||
| 3 | + | ||
| 4 | + Copyright (C) 1991, 1999 Free Software Foundation, Inc. | ||
| 5 | + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
| 6 | + Everyone is permitted to copy and distribute verbatim copies | ||
| 7 | + of this license document, but changing it is not allowed. | ||
| 8 | + | ||
| 9 | +[This is the first released version of the Lesser GPL. It also counts | ||
| 10 | + as the successor of the GNU Library Public License, version 2, hence | ||
| 11 | + the version number 2.1.] | ||
| 12 | + | ||
| 13 | + Preamble | ||
| 14 | + | ||
| 15 | + The licenses for most software are designed to take away your | ||
| 16 | +freedom to share and change it. By contrast, the GNU General Public | ||
| 17 | +Licenses are intended to guarantee your freedom to share and change | ||
| 18 | +free software--to make sure the software is free for all its users. | ||
| 19 | + | ||
| 20 | + This license, the Lesser General Public License, applies to some | ||
| 21 | +specially designated software packages--typically libraries--of the | ||
| 22 | +Free Software Foundation and other authors who decide to use it. You | ||
| 23 | +can use it too, but we suggest you first think carefully about whether | ||
| 24 | +this license or the ordinary General Public License is the better | ||
| 25 | +strategy to use in any particular case, based on the explanations below. | ||
| 26 | + | ||
| 27 | + When we speak of free software, we are referring to freedom of use, | ||
| 28 | +not price. Our General Public Licenses are designed to make sure that | ||
| 29 | +you have the freedom to distribute copies of free software (and charge | ||
| 30 | +for this service if you wish); that you receive source code or can get | ||
| 31 | +it if you want it; that you can change the software and use pieces of | ||
| 32 | +it in new free programs; and that you are informed that you can do | ||
| 33 | +these things. | ||
| 34 | + | ||
| 35 | + To protect your rights, we need to make restrictions that forbid | ||
| 36 | +distributors to deny you these rights or to ask you to surrender these | ||
| 37 | +rights. These restrictions translate to certain responsibilities for | ||
| 38 | +you if you distribute copies of the library or if you modify it. | ||
| 39 | + | ||
| 40 | + For example, if you distribute copies of the library, whether gratis | ||
| 41 | +or for a fee, you must give the recipients all the rights that we gave | ||
| 42 | +you. You must make sure that they, too, receive or can get the source | ||
| 43 | +code. If you link other code with the library, you must provide | ||
| 44 | +complete object files to the recipients, so that they can relink them | ||
| 45 | +with the library after making changes to the library and recompiling | ||
| 46 | +it. And you must show them these terms so they know their rights. | ||
| 47 | + | ||
| 48 | + We protect your rights with a two-step method: (1) we copyright the | ||
| 49 | +library, and (2) we offer you this license, which gives you legal | ||
| 50 | +permission to copy, distribute and/or modify the library. | ||
| 51 | + | ||
| 52 | + To protect each distributor, we want to make it very clear that | ||
| 53 | +there is no warranty for the free library. Also, if the library is | ||
| 54 | +modified by someone else and passed on, the recipients should know | ||
| 55 | +that what they have is not the original version, so that the original | ||
| 56 | +author's reputation will not be affected by problems that might be | ||
| 57 | +introduced by others. | ||
| 58 | + | ||
| 59 | + Finally, software patents pose a constant threat to the existence of | ||
| 60 | +any free program. We wish to make sure that a company cannot | ||
| 61 | +effectively restrict the users of a free program by obtaining a | ||
| 62 | +restrictive license from a patent holder. Therefore, we insist that | ||
| 63 | +any patent license obtained for a version of the library must be | ||
| 64 | +consistent with the full freedom of use specified in this license. | ||
| 65 | + | ||
| 66 | + Most GNU software, including some libraries, is covered by the | ||
| 67 | +ordinary GNU General Public License. This license, the GNU Lesser | ||
| 68 | +General Public License, applies to certain designated libraries, and | ||
| 69 | +is quite different from the ordinary General Public License. We use | ||
| 70 | +this license for certain libraries in order to permit linking those | ||
| 71 | +libraries into non-free programs. | ||
| 72 | + | ||
| 73 | + When a program is linked with a library, whether statically or using | ||
| 74 | +a shared library, the combination of the two is legally speaking a | ||
| 75 | +combined work, a derivative of the original library. The ordinary | ||
| 76 | +General Public License therefore permits such linking only if the | ||
| 77 | +entire combination fits its criteria of freedom. The Lesser General | ||
| 78 | +Public License permits more lax criteria for linking other code with | ||
| 79 | +the library. | ||
| 80 | + | ||
| 81 | + We call this license the "Lesser" General Public License because it | ||
| 82 | +does Less to protect the user's freedom than the ordinary General | ||
| 83 | +Public License. It also provides other free software developers Less | ||
| 84 | +of an advantage over competing non-free programs. These disadvantages | ||
| 85 | +are the reason we use the ordinary General Public License for many | ||
| 86 | +libraries. However, the Lesser license provides advantages in certain | ||
| 87 | +special circumstances. | ||
| 88 | + | ||
| 89 | + For example, on rare occasions, there may be a special need to | ||
| 90 | +encourage the widest possible use of a certain library, so that it becomes | ||
| 91 | +a de-facto standard. To achieve this, non-free programs must be | ||
| 92 | +allowed to use the library. A more frequent case is that a free | ||
| 93 | +library does the same job as widely used non-free libraries. In this | ||
| 94 | +case, there is little to gain by limiting the free library to free | ||
| 95 | +software only, so we use the Lesser General Public License. | ||
| 96 | + | ||
| 97 | + In other cases, permission to use a particular library in non-free | ||
| 98 | +programs enables a greater number of people to use a large body of | ||
| 99 | +free software. For example, permission to use the GNU C Library in | ||
| 100 | +non-free programs enables many more people to use the whole GNU | ||
| 101 | +operating system, as well as its variant, the GNU/Linux operating | ||
| 102 | +system. | ||
| 103 | + | ||
| 104 | + Although the Lesser General Public License is Less protective of the | ||
| 105 | +users' freedom, it does ensure that the user of a program that is | ||
| 106 | +linked with the Library has the freedom and the wherewithal to run | ||
| 107 | +that program using a modified version of the Library. | ||
| 108 | + | ||
| 109 | + The precise terms and conditions for copying, distribution and | ||
| 110 | +modification follow. Pay close attention to the difference between a | ||
| 111 | +"work based on the library" and a "work that uses the library". The | ||
| 112 | +former contains code derived from the library, whereas the latter must | ||
| 113 | +be combined with the library in order to run. | ||
| 114 | + | ||
| 115 | + GNU LESSER GENERAL PUBLIC LICENSE | ||
| 116 | + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
| 117 | + | ||
| 118 | + 0. This License Agreement applies to any software library or other | ||
| 119 | +program which contains a notice placed by the copyright holder or | ||
| 120 | +other authorized party saying it may be distributed under the terms of | ||
| 121 | +this Lesser General Public License (also called "this License"). | ||
| 122 | +Each licensee is addressed as "you". | ||
| 123 | + | ||
| 124 | + A "library" means a collection of software functions and/or data | ||
| 125 | +prepared so as to be conveniently linked with application programs | ||
| 126 | +(which use some of those functions and data) to form executables. | ||
| 127 | + | ||
| 128 | + The "Library", below, refers to any such software library or work | ||
| 129 | +which has been distributed under these terms. A "work based on the | ||
| 130 | +Library" means either the Library or any derivative work under | ||
| 131 | +copyright law: that is to say, a work containing the Library or a | ||
| 132 | +portion of it, either verbatim or with modifications and/or translated | ||
| 133 | +straightforwardly into another language. (Hereinafter, translation is | ||
| 134 | +included without limitation in the term "modification".) | ||
| 135 | + | ||
| 136 | + "Source code" for a work means the preferred form of the work for | ||
| 137 | +making modifications to it. For a library, complete source code means | ||
| 138 | +all the source code for all modules it contains, plus any associated | ||
| 139 | +interface definition files, plus the scripts used to control compilation | ||
| 140 | +and installation of the library. | ||
| 141 | + | ||
| 142 | + Activities other than copying, distribution and modification are not | ||
| 143 | +covered by this License; they are outside its scope. The act of | ||
| 144 | +running a program using the Library is not restricted, and output from | ||
| 145 | +such a program is covered only if its contents constitute a work based | ||
| 146 | +on the Library (independent of the use of the Library in a tool for | ||
| 147 | +writing it). Whether that is true depends on what the Library does | ||
| 148 | +and what the program that uses the Library does. | ||
| 149 | + | ||
| 150 | + 1. You may copy and distribute verbatim copies of the Library's | ||
| 151 | +complete source code as you receive it, in any medium, provided that | ||
| 152 | +you conspicuously and appropriately publish on each copy an | ||
| 153 | +appropriate copyright notice and disclaimer of warranty; keep intact | ||
| 154 | +all the notices that refer to this License and to the absence of any | ||
| 155 | +warranty; and distribute a copy of this License along with the | ||
| 156 | +Library. | ||
| 157 | + | ||
| 158 | + You may charge a fee for the physical act of transferring a copy, | ||
| 159 | +and you may at your option offer warranty protection in exchange for a | ||
| 160 | +fee. | ||
| 161 | + | ||
| 162 | + 2. You may modify your copy or copies of the Library or any portion | ||
| 163 | +of it, thus forming a work based on the Library, and copy and | ||
| 164 | +distribute such modifications or work under the terms of Section 1 | ||
| 165 | +above, provided that you also meet all of these conditions: | ||
| 166 | + | ||
| 167 | + a) The modified work must itself be a software library. | ||
| 168 | + | ||
| 169 | + b) You must cause the files modified to carry prominent notices | ||
| 170 | + stating that you changed the files and the date of any change. | ||
| 171 | + | ||
| 172 | + c) You must cause the whole of the work to be licensed at no | ||
| 173 | + charge to all third parties under the terms of this License. | ||
| 174 | + | ||
| 175 | + d) If a facility in the modified Library refers to a function or a | ||
| 176 | + table of data to be supplied by an application program that uses | ||
| 177 | + the facility, other than as an argument passed when the facility | ||
| 178 | + is invoked, then you must make a good faith effort to ensure that, | ||
| 179 | + in the event an application does not supply such function or | ||
| 180 | + table, the facility still operates, and performs whatever part of | ||
| 181 | + its purpose remains meaningful. | ||
| 182 | + | ||
| 183 | + (For example, a function in a library to compute square roots has | ||
| 184 | + a purpose that is entirely well-defined independent of the | ||
| 185 | + application. Therefore, Subsection 2d requires that any | ||
| 186 | + application-supplied function or table used by this function must | ||
| 187 | + be optional: if the application does not supply it, the square | ||
| 188 | + root function must still compute square roots.) | ||
| 189 | + | ||
| 190 | +These requirements apply to the modified work as a whole. If | ||
| 191 | +identifiable sections of that work are not derived from the Library, | ||
| 192 | +and can be reasonably considered independent and separate works in | ||
| 193 | +themselves, then this License, and its terms, do not apply to those | ||
| 194 | +sections when you distribute them as separate works. But when you | ||
| 195 | +distribute the same sections as part of a whole which is a work based | ||
| 196 | +on the Library, the distribution of the whole must be on the terms of | ||
| 197 | +this License, whose permissions for other licensees extend to the | ||
| 198 | +entire whole, and thus to each and every part regardless of who wrote | ||
| 199 | +it. | ||
| 200 | + | ||
| 201 | +Thus, it is not the intent of this section to claim rights or contest | ||
| 202 | +your rights to work written entirely by you; rather, the intent is to | ||
| 203 | +exercise the right to control the distribution of derivative or | ||
| 204 | +collective works based on the Library. | ||
| 205 | + | ||
| 206 | +In addition, mere aggregation of another work not based on the Library | ||
| 207 | +with the Library (or with a work based on the Library) on a volume of | ||
| 208 | +a storage or distribution medium does not bring the other work under | ||
| 209 | +the scope of this License. | ||
| 210 | + | ||
| 211 | + 3. You may opt to apply the terms of the ordinary GNU General Public | ||
| 212 | +License instead of this License to a given copy of the Library. To do | ||
| 213 | +this, you must alter all the notices that refer to this License, so | ||
| 214 | +that they refer to the ordinary GNU General Public License, version 2, | ||
| 215 | +instead of to this License. (If a newer version than version 2 of the | ||
| 216 | +ordinary GNU General Public License has appeared, then you can specify | ||
| 217 | +that version instead if you wish.) Do not make any other change in | ||
| 218 | +these notices. | ||
| 219 | + | ||
| 220 | + Once this change is made in a given copy, it is irreversible for | ||
| 221 | +that copy, so the ordinary GNU General Public License applies to all | ||
| 222 | +subsequent copies and derivative works made from that copy. | ||
| 223 | + | ||
| 224 | + This option is useful when you wish to copy part of the code of | ||
| 225 | +the Library into a program that is not a library. | ||
| 226 | + | ||
| 227 | + 4. You may copy and distribute the Library (or a portion or | ||
| 228 | +derivative of it, under Section 2) in object code or executable form | ||
| 229 | +under the terms of Sections 1 and 2 above provided that you accompany | ||
| 230 | +it with the complete corresponding machine-readable source code, which | ||
| 231 | +must be distributed under the terms of Sections 1 and 2 above on a | ||
| 232 | +medium customarily used for software interchange. | ||
| 233 | + | ||
| 234 | + If distribution of object code is made by offering access to copy | ||
| 235 | +from a designated place, then offering equivalent access to copy the | ||
| 236 | +source code from the same place satisfies the requirement to | ||
| 237 | +distribute the source code, even though third parties are not | ||
| 238 | +compelled to copy the source along with the object code. | ||
| 239 | + | ||
| 240 | + 5. A program that contains no derivative of any portion of the | ||
| 241 | +Library, but is designed to work with the Library by being compiled or | ||
| 242 | +linked with it, is called a "work that uses the Library". Such a | ||
| 243 | +work, in isolation, is not a derivative work of the Library, and | ||
| 244 | +therefore falls outside the scope of this License. | ||
| 245 | + | ||
| 246 | + However, linking a "work that uses the Library" with the Library | ||
| 247 | +creates an executable that is a derivative of the Library (because it | ||
| 248 | +contains portions of the Library), rather than a "work that uses the | ||
| 249 | +library". The executable is therefore covered by this License. | ||
| 250 | +Section 6 states terms for distribution of such executables. | ||
| 251 | + | ||
| 252 | + When a "work that uses the Library" uses material from a header file | ||
| 253 | +that is part of the Library, the object code for the work may be a | ||
| 254 | +derivative work of the Library even though the source code is not. | ||
| 255 | +Whether this is true is especially significant if the work can be | ||
| 256 | +linked without the Library, or if the work is itself a library. The | ||
| 257 | +threshold for this to be true is not precisely defined by law. | ||
| 258 | + | ||
| 259 | + If such an object file uses only numerical parameters, data | ||
| 260 | +structure layouts and accessors, and small macros and small inline | ||
| 261 | +functions (ten lines or less in length), then the use of the object | ||
| 262 | +file is unrestricted, regardless of whether it is legally a derivative | ||
| 263 | +work. (Executables containing this object code plus portions of the | ||
| 264 | +Library will still fall under Section 6.) | ||
| 265 | + | ||
| 266 | + Otherwise, if the work is a derivative of the Library, you may | ||
| 267 | +distribute the object code for the work under the terms of Section 6. | ||
| 268 | +Any executables containing that work also fall under Section 6, | ||
| 269 | +whether or not they are linked directly with the Library itself. | ||
| 270 | + | ||
| 271 | + 6. As an exception to the Sections above, you may also combine or | ||
| 272 | +link a "work that uses the Library" with the Library to produce a | ||
| 273 | +work containing portions of the Library, and distribute that work | ||
| 274 | +under terms of your choice, provided that the terms permit | ||
| 275 | +modification of the work for the customer's own use and reverse | ||
| 276 | +engineering for debugging such modifications. | ||
| 277 | + | ||
| 278 | + You must give prominent notice with each copy of the work that the | ||
| 279 | +Library is used in it and that the Library and its use are covered by | ||
| 280 | +this License. You must supply a copy of this License. If the work | ||
| 281 | +during execution displays copyright notices, you must include the | ||
| 282 | +copyright notice for the Library among them, as well as a reference | ||
| 283 | +directing the user to the copy of this License. Also, you must do one | ||
| 284 | +of these things: | ||
| 285 | + | ||
| 286 | + a) Accompany the work with the complete corresponding | ||
| 287 | + machine-readable source code for the Library including whatever | ||
| 288 | + changes were used in the work (which must be distributed under | ||
| 289 | + Sections 1 and 2 above); and, if the work is an executable linked | ||
| 290 | + with the Library, with the complete machine-readable "work that | ||
| 291 | + uses the Library", as object code and/or source code, so that the | ||
| 292 | + user can modify the Library and then relink to produce a modified | ||
| 293 | + executable containing the modified Library. (It is understood | ||
| 294 | + that the user who changes the contents of definitions files in the | ||
| 295 | + Library will not necessarily be able to recompile the application | ||
| 296 | + to use the modified definitions.) | ||
| 297 | + | ||
| 298 | + b) Use a suitable shared library mechanism for linking with the | ||
| 299 | + Library. A suitable mechanism is one that (1) uses at run time a | ||
| 300 | + copy of the library already present on the user's computer system, | ||
| 301 | + rather than copying library functions into the executable, and (2) | ||
| 302 | + will operate properly with a modified version of the library, if | ||
| 303 | + the user installs one, as long as the modified version is | ||
| 304 | + interface-compatible with the version that the work was made with. | ||
| 305 | + | ||
| 306 | + c) Accompany the work with a written offer, valid for at | ||
| 307 | + least three years, to give the same user the materials | ||
| 308 | + specified in Subsection 6a, above, for a charge no more | ||
| 309 | + than the cost of performing this distribution. | ||
| 310 | + | ||
| 311 | + d) If distribution of the work is made by offering access to copy | ||
| 312 | + from a designated place, offer equivalent access to copy the above | ||
| 313 | + specified materials from the same place. | ||
| 314 | + | ||
| 315 | + e) Verify that the user has already received a copy of these | ||
| 316 | + materials or that you have already sent this user a copy. | ||
| 317 | + | ||
| 318 | + For an executable, the required form of the "work that uses the | ||
| 319 | +Library" must include any data and utility programs needed for | ||
| 320 | +reproducing the executable from it. However, as a special exception, | ||
| 321 | +the materials to be distributed need not include anything that is | ||
| 322 | +normally distributed (in either source or binary form) with the major | ||
| 323 | +components (compiler, kernel, and so on) of the operating system on | ||
| 324 | +which the executable runs, unless that component itself accompanies | ||
| 325 | +the executable. | ||
| 326 | + | ||
| 327 | + It may happen that this requirement contradicts the license | ||
| 328 | +restrictions of other proprietary libraries that do not normally | ||
| 329 | +accompany the operating system. Such a contradiction means you cannot | ||
| 330 | +use both them and the Library together in an executable that you | ||
| 331 | +distribute. | ||
| 332 | + | ||
| 333 | + 7. You may place library facilities that are a work based on the | ||
| 334 | +Library side-by-side in a single library together with other library | ||
| 335 | +facilities not covered by this License, and distribute such a combined | ||
| 336 | +library, provided that the separate distribution of the work based on | ||
| 337 | +the Library and of the other library facilities is otherwise | ||
| 338 | +permitted, and provided that you do these two things: | ||
| 339 | + | ||
| 340 | + a) Accompany the combined library with a copy of the same work | ||
| 341 | + based on the Library, uncombined with any other library | ||
| 342 | + facilities. This must be distributed under the terms of the | ||
| 343 | + Sections above. | ||
| 344 | + | ||
| 345 | + b) Give prominent notice with the combined library of the fact | ||
| 346 | + that part of it is a work based on the Library, and explaining | ||
| 347 | + where to find the accompanying uncombined form of the same work. | ||
| 348 | + | ||
| 349 | + 8. You may not copy, modify, sublicense, link with, or distribute | ||
| 350 | +the Library except as expressly provided under this License. Any | ||
| 351 | +attempt otherwise to copy, modify, sublicense, link with, or | ||
| 352 | +distribute the Library is void, and will automatically terminate your | ||
| 353 | +rights under this License. However, parties who have received copies, | ||
| 354 | +or rights, from you under this License will not have their licenses | ||
| 355 | +terminated so long as such parties remain in full compliance. | ||
| 356 | + | ||
| 357 | + 9. You are not required to accept this License, since you have not | ||
| 358 | +signed it. However, nothing else grants you permission to modify or | ||
| 359 | +distribute the Library or its derivative works. These actions are | ||
| 360 | +prohibited by law if you do not accept this License. Therefore, by | ||
| 361 | +modifying or distributing the Library (or any work based on the | ||
| 362 | +Library), you indicate your acceptance of this License to do so, and | ||
| 363 | +all its terms and conditions for copying, distributing or modifying | ||
| 364 | +the Library or works based on it. | ||
| 365 | + | ||
| 366 | + 10. Each time you redistribute the Library (or any work based on the | ||
| 367 | +Library), the recipient automatically receives a license from the | ||
| 368 | +original licensor to copy, distribute, link with or modify the Library | ||
| 369 | +subject to these terms and conditions. You may not impose any further | ||
| 370 | +restrictions on the recipients' exercise of the rights granted herein. | ||
| 371 | +You are not responsible for enforcing compliance by third parties with | ||
| 372 | +this License. | ||
| 373 | + | ||
| 374 | + 11. If, as a consequence of a court judgment or allegation of patent | ||
| 375 | +infringement or for any other reason (not limited to patent issues), | ||
| 376 | +conditions are imposed on you (whether by court order, agreement or | ||
| 377 | +otherwise) that contradict the conditions of this License, they do not | ||
| 378 | +excuse you from the conditions of this License. If you cannot | ||
| 379 | +distribute so as to satisfy simultaneously your obligations under this | ||
| 380 | +License and any other pertinent obligations, then as a consequence you | ||
| 381 | +may not distribute the Library at all. For example, if a patent | ||
| 382 | +license would not permit royalty-free redistribution of the Library by | ||
| 383 | +all those who receive copies directly or indirectly through you, then | ||
| 384 | +the only way you could satisfy both it and this License would be to | ||
| 385 | +refrain entirely from distribution of the Library. | ||
| 386 | + | ||
| 387 | +If any portion of this section is held invalid or unenforceable under any | ||
| 388 | +particular circumstance, the balance of the section is intended to apply, | ||
| 389 | +and the section as a whole is intended to apply in other circumstances. | ||
| 390 | + | ||
| 391 | +It is not the purpose of this section to induce you to infringe any | ||
| 392 | +patents or other property right claims or to contest validity of any | ||
| 393 | +such claims; this section has the sole purpose of protecting the | ||
| 394 | +integrity of the free software distribution system which is | ||
| 395 | +implemented by public license practices. Many people have made | ||
| 396 | +generous contributions to the wide range of software distributed | ||
| 397 | +through that system in reliance on consistent application of that | ||
| 398 | +system; it is up to the author/donor to decide if he or she is willing | ||
| 399 | +to distribute software through any other system and a licensee cannot | ||
| 400 | +impose that choice. | ||
| 401 | + | ||
| 402 | +This section is intended to make thoroughly clear what is believed to | ||
| 403 | +be a consequence of the rest of this License. | ||
| 404 | + | ||
| 405 | + 12. If the distribution and/or use of the Library is restricted in | ||
| 406 | +certain countries either by patents or by copyrighted interfaces, the | ||
| 407 | +original copyright holder who places the Library under this License may add | ||
| 408 | +an explicit geographical distribution limitation excluding those countries, | ||
| 409 | +so that distribution is permitted only in or among countries not thus | ||
| 410 | +excluded. In such case, this License incorporates the limitation as if | ||
| 411 | +written in the body of this License. | ||
| 412 | + | ||
| 413 | + 13. The Free Software Foundation may publish revised and/or new | ||
| 414 | +versions of the Lesser General Public License from time to time. | ||
| 415 | +Such new versions will be similar in spirit to the present version, | ||
| 416 | +but may differ in detail to address new problems or concerns. | ||
| 417 | + | ||
| 418 | +Each version is given a distinguishing version number. If the Library | ||
| 419 | +specifies a version number of this License which applies to it and | ||
| 420 | +"any later version", you have the option of following the terms and | ||
| 421 | +conditions either of that version or of any later version published by | ||
| 422 | +the Free Software Foundation. If the Library does not specify a | ||
| 423 | +license version number, you may choose any version ever published by | ||
| 424 | +the Free Software Foundation. | ||
| 425 | + | ||
| 426 | + 14. If you wish to incorporate parts of the Library into other free | ||
| 427 | +programs whose distribution conditions are incompatible with these, | ||
| 428 | +write to the author to ask for permission. For software which is | ||
| 429 | +copyrighted by the Free Software Foundation, write to the Free | ||
| 430 | +Software Foundation; we sometimes make exceptions for this. Our | ||
| 431 | +decision will be guided by the two goals of preserving the free status | ||
| 432 | +of all derivatives of our free software and of promoting the sharing | ||
| 433 | +and reuse of software generally. | ||
| 434 | + | ||
| 435 | + NO WARRANTY | ||
| 436 | + | ||
| 437 | + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO | ||
| 438 | +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. | ||
| 439 | +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR | ||
| 440 | +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY | ||
| 441 | +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 442 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 443 | +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE | ||
| 444 | +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME | ||
| 445 | +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | ||
| 446 | + | ||
| 447 | + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN | ||
| 448 | +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY | ||
| 449 | +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU | ||
| 450 | +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR | ||
| 451 | +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE | ||
| 452 | +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | ||
| 453 | +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | ||
| 454 | +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | ||
| 455 | +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | ||
| 456 | +DAMAGES. | ||
| 457 | + | ||
| 458 | + END OF TERMS AND CONDITIONS | ||
| 459 | + | ||
| 460 | + How to Apply These Terms to Your New Libraries | ||
| 461 | + | ||
| 462 | + If you develop a new library, and you want it to be of the greatest | ||
| 463 | +possible use to the public, we recommend making it free software that | ||
| 464 | +everyone can redistribute and change. You can do so by permitting | ||
| 465 | +redistribution under these terms (or, alternatively, under the terms of the | ||
| 466 | +ordinary General Public License). | ||
| 467 | + | ||
| 468 | + To apply these terms, attach the following notices to the library. It is | ||
| 469 | +safest to attach them to the start of each source file to most effectively | ||
| 470 | +convey the exclusion of warranty; and each file should have at least the | ||
| 471 | +"copyright" line and a pointer to where the full notice is found. | ||
| 472 | + | ||
| 473 | + <one line to give the library's name and a brief idea of what it does.> | ||
| 474 | + Copyright (C) <year> <name of author> | ||
| 475 | + | ||
| 476 | + This library is free software; you can redistribute it and/or | ||
| 477 | + modify it under the terms of the GNU Lesser General Public | ||
| 478 | + License as published by the Free Software Foundation; either | ||
| 479 | + version 2.1 of the License, or (at your option) any later version. | ||
| 480 | + | ||
| 481 | + This library is distributed in the hope that it will be useful, | ||
| 482 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 483 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 484 | + Lesser General Public License for more details. | ||
| 485 | + | ||
| 486 | + You should have received a copy of the GNU Lesser General Public | ||
| 487 | + License along with this library; if not, write to the Free Software | ||
| 488 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
| 489 | + | ||
| 490 | +Also add information on how to contact you by electronic and paper mail. | ||
| 491 | + | ||
| 492 | +You should also get your employer (if you work as a programmer) or your | ||
| 493 | +school, if any, to sign a "copyright disclaimer" for the library, if | ||
| 494 | +necessary. Here is a sample; alter the names: | ||
| 495 | + | ||
| 496 | + Yoyodyne, Inc., hereby disclaims all copyright interest in the | ||
| 497 | + library `Frob' (a library for tweaking knobs) written by James Random Hacker. | ||
| 498 | + | ||
| 499 | + <signature of Ty Coon>, 1 April 1990 | ||
| 500 | + Ty Coon, President of Vice | ||
| 501 | + | ||
| 502 | That's all there is to it! | 502 | That's all there is to it! |
| 503 | \ No newline at end of file | 503 | \ No newline at end of file |
thirdpartyjs/yui/animation/README
| 1 | -Animation Release Notes | ||
| 2 | - | ||
| 3 | -*** version 0.12.0 *** | ||
| 4 | - | ||
| 5 | -* added boolean finish argument to Anim.stop() | ||
| 6 | - | ||
| 7 | -*** version 0.11.3 *** | ||
| 8 | - | ||
| 9 | -* no changes | ||
| 10 | - | ||
| 11 | -*** version 0.11.1 *** | ||
| 12 | - | ||
| 13 | -* changed "prototype" shorthand to "proto" (workaround firefox < 1.5 scoping | ||
| 14 | -bug) | ||
| 15 | - | ||
| 16 | -*** version 0.11.0 *** | ||
| 17 | - | ||
| 18 | -* ColorAnim subclass added | ||
| 19 | -* Motion and Scroll now inherit from ColorAnim | ||
| 20 | -* getDefaultUnit method added | ||
| 21 | -* defaultUnit and defaultUnits deprecated | ||
| 22 | -* getDefault and setDefault methods deprecated | ||
| 23 | - | ||
| 24 | -*** version 0.10.0 *** | ||
| 25 | - | ||
| 26 | -* Scroll now handles relative ("by") animation correctly | ||
| 27 | - | ||
| 28 | -* Now converts "auto" values of "from" to appropriate initial values | ||
| 29 | - | ||
| 30 | -*** version 0.9.0 *** | ||
| 31 | - | ||
| 32 | -* Initial release | ||
| 33 | - | ||
| 34 | - | 1 | +Animation Release Notes |
| 2 | + | ||
| 3 | +*** version 0.12.0 *** | ||
| 4 | + | ||
| 5 | +* added boolean finish argument to Anim.stop() | ||
| 6 | + | ||
| 7 | +*** version 0.11.3 *** | ||
| 8 | + | ||
| 9 | +* no changes | ||
| 10 | + | ||
| 11 | +*** version 0.11.1 *** | ||
| 12 | + | ||
| 13 | +* changed "prototype" shorthand to "proto" (workaround firefox < 1.5 scoping | ||
| 14 | +bug) | ||
| 15 | + | ||
| 16 | +*** version 0.11.0 *** | ||
| 17 | + | ||
| 18 | +* ColorAnim subclass added | ||
| 19 | +* Motion and Scroll now inherit from ColorAnim | ||
| 20 | +* getDefaultUnit method added | ||
| 21 | +* defaultUnit and defaultUnits deprecated | ||
| 22 | +* getDefault and setDefault methods deprecated | ||
| 23 | + | ||
| 24 | +*** version 0.10.0 *** | ||
| 25 | + | ||
| 26 | +* Scroll now handles relative ("by") animation correctly | ||
| 27 | + | ||
| 28 | +* Now converts "auto" values of "from" to appropriate initial values | ||
| 29 | + | ||
| 30 | +*** version 0.9.0 *** | ||
| 31 | + | ||
| 32 | +* Initial release | ||
| 33 | + | ||
| 34 | + |