commit e5c43dbdcdbce19f9a84db9f872be8f114847be6 Author: Julien Malik Date: Mon Jan 13 13:49:21 2014 +0100 import jirafeau rev 3994a35 diff --git a/sources/COPYING b/sources/COPYING new file mode 100644 index 0000000..dba13ed --- /dev/null +++ b/sources/COPYING @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/sources/admin.php b/sources/admin.php new file mode 100755 index 0000000..5ae2d6e --- /dev/null +++ b/sources/admin.php @@ -0,0 +1,304 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); + +require (JIRAFEAU_ROOT . 'lib/config.original.php'); +require (JIRAFEAU_ROOT . 'lib/settings.php'); +require (JIRAFEAU_ROOT . 'lib/functions.php'); +require (JIRAFEAU_ROOT . 'lib/lang.php'); + +/* Check if installation is OK. */ +if (file_exists (JIRAFEAU_ROOT . 'install.php') + && !file_exists (JIRAFEAU_ROOT . 'lib/config.local.php')) +{ + header('Location: install.php'); + exit; +} + +/* Check if the install.php script is still in the directory. */ +if (file_exists (JIRAFEAU_ROOT . 'install.php')) +{ + require (JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

'. + t('Installer script still present') . + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +/* Disable admin interface if we have a empty admin password. */ +if (!$cfg['admin_password']) +{ + require (JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

'. + t('Sorry, the admin interface is not enabled.') . + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +/* Check session. */ +session_start(); + +/* Unlog if asked. */ +if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0)) + $_SESSION['admin_auth'] = false; + +/* Check password. */ +if (isset ($_POST['admin_password'])) +{ + if (strcmp ($cfg['admin_password'], $_POST['admin_password']) == 0) + $_SESSION['admin_auth'] = true; + else + { + $_SESSION['admin_auth'] = false; + require (JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

'. + t('Wrong password.') . '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; + } +} +/* Ask for password. */ +elseif (!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true) +{ + require (JIRAFEAU_ROOT . 'lib/template/header.php'); ?> +
+
+ + + + + + + + + +
+ +
+
+
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + + +
+ + + + + +
+ + + + + +
+
+ + +
+
' . NL; + echo '

'; + echo t('Number of cleaned files') . ' : ' . $total; + echo '

'; + } + elseif (strcmp ($_POST['action'], 'clean_async') == 0) + { + $total = jirafeau_admin_clean_async (); + echo '
' . NL; + echo '

'; + echo t('Number of cleaned files') . ' : ' . $total; + echo '

'; + } + elseif (strcmp ($_POST['action'], 'clean_block') == 0) + { + $total = jirafeau_admin_clean_block (); + echo '
' . NL; + echo '

'; + echo t('Number of cleaned files') . ' : ' . $total; + echo '

'; + } + elseif (strcmp ($_POST['action'], 'list') == 0) + { + jirafeau_admin_list ("", "", ""); + } + elseif (strcmp ($_POST['action'], 'search_by_name') == 0) + { + jirafeau_admin_list ($_POST['name'], "", ""); + } + elseif (strcmp ($_POST['action'], 'search_by_file_hash') == 0) + { + jirafeau_admin_list ("", $_POST['hash'], ""); + } + elseif (strcmp ($_POST['action'], 'search_link') == 0) + { + jirafeau_admin_list ("", "", $_POST['link']); + } + elseif (strcmp ($_POST['action'], 'delete_link') == 0) + { + jirafeau_delete_link ($_POST['link']); + echo '
' . NL; + echo '

' . t('Link deleted') . '

'; + } + elseif (strcmp ($_POST['action'], 'delete_file') == 0) + { + $count = jirafeau_delete_file ($_POST['md5']); + echo '
' . NL; + echo '

' . t('Deleted links') . ' : ' . $count . '

'; + } + elseif (strcmp ($_POST['action'], 'download') == 0) + { + $l = jirafeau_get_link ($_POST['link']); + if (!count ($l)) + return; + $p = s2p ($l['md5']); + header ('Content-Length: ' . $l['file_size']); + header ('Content-Type: ' . $l['mime_type']); + header ('Content-Disposition: attachment; filename="' . + $l['file_name'] . '"'); + if (file_exists(VAR_FILES . $p . $l['md5'])) + readfile (VAR_FILES . $p . $l['md5']); + } +} + +require (JIRAFEAU_ROOT.'lib/template/footer.php'); + +?> diff --git a/sources/f.php b/sources/f.php new file mode 100644 index 0000000..6f8f836 --- /dev/null +++ b/sources/f.php @@ -0,0 +1,267 @@ + + * Copyright (C) 2012 Jerome Jutteau + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); + +require (JIRAFEAU_ROOT . 'lib/lang.php'); +require (JIRAFEAU_ROOT . 'lib/config.original.php'); +require (JIRAFEAU_ROOT . 'lib/settings.php'); +require (JIRAFEAU_ROOT . 'lib/functions.php'); + +if (!isset ($_GET['h']) || empty ($_GET['h'])) +{ + header ('Location: ' . $cfg['web_root']); + exit; +} + +/* Operations may take a long time. + * Be sure PHP's safe mode is off. + */ +@set_time_limit(0); +/* Remove errors. */ +@error_reporting(0); + +$link_name = $_GET['h']; + +if (!preg_match ('/[0-9a-zA-Z_-]+$/', $link_name)) +{ + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

' . t('Sorry, the requested file is not found') . '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +$link = jirafeau_get_link ($link_name); +if (count ($link) == 0) +{ + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

' . t('Sorry, the requested file is not found') . + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +$delete_code = ''; +if (isset ($_GET['d']) && !empty ($_GET['d'])) + $delete_code = $_GET['d']; + +$crypt_key = ''; +if (isset ($_GET['k']) && !empty ($_GET['k'])) + $crypt_key = $_GET['k']; + +$button_download = false; +if (isset ($_GET['bd']) && !empty ($_GET['bd'])) + $button_download = true; + +$button_preview = false; +if (isset ($_GET['bp']) && !empty ($_GET['bp'])) + $button_preview = true; + +$p = s2p ($link['md5']); +if (!file_exists (VAR_FILES . $p . $link['md5'])) +{ + jirafeau_delete_link ($link_name); + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

'.t('File not available.'). + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +if (!empty ($delete_code) && $delete_code == $link['link_code']) +{ + jirafeau_delete_link ($link_name); + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

'.t('File has been deleted.'). + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +if ($link['time'] != JIRAFEAU_INFINITY && time () > $link['time']) +{ + jirafeau_delete_link ($link_name); + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

'. + t('The time limit of this file has expired.') . ' ' . + t('File has been deleted.') . + '

'; + require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; +} + +if (empty ($crypt_key) && $link['crypted']) +{ + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

' . t('Sorry, the requested file is not found') . + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +$password_challenged = false; +if (!empty ($link['key'])) +{ + if (!isset ($_POST['key'])) + { + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '
' . + '
'; ?> + ' . + '' . t('Password protection') . + '' . + '' . + '
' . + t('Give the password of this file') . ' : ' . + '' . + '
' . + t('By using our services, you accept of our'). ' ' . t('Term Of Service') . '' . + '
'; + ?>
'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; + } + else + { + if ($link['key'] == md5 ($_POST['key'])) + $password_challenged = true; + else + { + header ("Access denied"); + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '

' . t('Access denied') . + '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; + } + } +} + +if ($cfg['download_page'] && !$password_challenged && !$button_download && !$button_preview) +{ + require (JIRAFEAU_ROOT.'lib/template/header.php'); + echo '
' . + '
'; ?> + ' . $link['file_name'] . '' . + '' . + ''; + echo '
' . + t('You are about to download') . ' "' . $link['file_name'] . '" (' . jirafeau_human_size($link['file_size']) . ')' . + '
' . + t('By using our services, you accept of our'). ' ' . t('Term Of Service') . ''; + ?>
'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; +} + +header ('HTTP/1.0 200 OK'); +header ('Content-Length: ' . $link['file_size']); +if (!jirafeau_is_viewable ($link['mime_type']) || !$cfg['preview'] || $button_download) + header ('Content-Disposition: attachment; filename="' . + $link['file_name'] . '"'); +else + header ('Content-Type: ' . $link['mime_type']); + +/* Read encrypted file. */ +if ($link['crypted']) +{ + /* Init module */ + $m = mcrypt_module_open('rijndael-256', '', 'ofb', ''); + /* Extract key and iv. */ + $md5_key = md5 ($crypt_key); + $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size($m)); + /* Init module. */ + mcrypt_generic_init ($m, $md5_key, $iv); + /* Decrypt file. */ + $r = fopen (VAR_FILES . $p . $link['md5'], 'r'); + while (!feof ($r)) + { + $dec = mdecrypt_generic($m, fread ($r, 1024)); + print $dec; + ob_flush(); + } + fclose ($r); + /* Cleanup. */ + mcrypt_generic_deinit($m); + mcrypt_module_close($m); +} +/* Read file. */ +else +{ + $r = fopen (VAR_FILES . $p . $link['md5'], 'r'); + while (!feof ($r)) + { + print fread ($r, 1024); + ob_flush(); + } + fclose ($r); +} + +if ($link['onetime'] == 'O') + jirafeau_delete_link ($link_name); +exit; + +?> diff --git a/sources/favicon.ico b/sources/favicon.ico new file mode 100644 index 0000000..c42c696 Binary files /dev/null and b/sources/favicon.ico differ diff --git a/sources/index.php b/sources/index.php new file mode 100755 index 0000000..d267140 --- /dev/null +++ b/sources/index.php @@ -0,0 +1,191 @@ + + * Jimmy Beauvois + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); + +require (JIRAFEAU_ROOT . 'lib/config.original.php'); +require (JIRAFEAU_ROOT . 'lib/settings.php'); +require (JIRAFEAU_ROOT . 'lib/functions.php'); +require (JIRAFEAU_ROOT . 'lib/lang.php'); +require (JIRAFEAU_ROOT . 'lib/template/header.php'); + +check_errors (); +if (has_error ()) +{ + show_errors (); + require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; +} + +/* Ask password if upload password is set. */ +if (strlen ($cfg['upload_password']) > 0) +{ + session_start(); + + /* Unlog if asked. */ + if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0)) + $_SESSION['upload_auth'] = false; + + /* Auth. */ + if (isset ($_POST['upload_password'])) + { + if (strcmp ($cfg['upload_password'], $_POST['upload_password']) == 0) + $_SESSION['upload_auth'] = true; + else + { + $_SESSION['admin_auth'] = false; + echo '

' . t('Wrong password.') . '

'; + require (JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; + } + } + + /* Show auth page. */ + if (!isset ($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true) + { + ?> +
+
+ + + + + + + + + +
+ +
+
+
+ +
+

+ : +
+ +
+

+ +

+ : +
+ +

+ +

+ : +

+

+
+ +
+

+

+

+
+ +
+
+ + + +

+ +

+ +
+ + + + + + + + + + + + + +

+

+ + + +

+
:
+
+ + 0) + { + ?> +
+ + +
+ + +
+ + + diff --git a/sources/install.php b/sources/install.php new file mode 100755 index 0000000..d8e5fdf --- /dev/null +++ b/sources/install.php @@ -0,0 +1,361 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); +define ('NL', "\n"); +define ('QUOTE', "'"); + +define ('JIRAFEAU_CFG', JIRAFEAU_ROOT.'lib/config.local.php'); +define ('JIRAFEAU_VAR_RAND_LENGTH', 15); + +require (JIRAFEAU_ROOT . 'lib/lang.php'); +require (JIRAFEAU_ROOT . 'lib/config.original.php'); + +function +jirafeau_quoted ($str) +{ + return QUOTE . str_replace (QUOTE, "\'", $str) . QUOTE; +} + +function +jirafeau_export_cfg ($cfg) +{ + $handle = fopen (JIRAFEAU_CFG, 'w'); + fwrite ($handle, ' $item) + { + fwrite ($handle, '$cfg[' . jirafeau_quoted ($key) . '] = '); + if (is_bool ($item)) + fwrite ($handle, ($item ? 'true' : 'false')); + else if (is_string ($item)) + fwrite ($handle, jirafeau_quoted ($item)); + else if (is_int ($item)) + fwrite ($handle, $item); + else + fwrite ($handle, 'null'); + fwrite ($handle, ';'.NL); + } + /* No newline at the end of the file to be able to send headers. */ + fwrite ($handle, '?>'); + fclose ($handle); +} + +function +jirafeau_mkdir ($path) +{ + if (!file_exists ($path) && !@mkdir ($path, 0755)) + return false; + return true; +} + +/** + * Returns true whether the path is writable or we manage to make it + * so, which essentially is the same thing. + * @param $path is the file or directory to be tested. + * @return true if $path is writable. + */ +function +jirafeau_is_writable ($path) +{ + /* "@" gets rid of error messages. */ + return is_writable ($path) || @chmod ($path, 0777); +} + +function +jirafeau_check_var_dir ($path) +{ + $mkdir_str1 = t('The following directory could not be created') . ':'; + $mkdir_str2 = t('You should create this directory by hand.'); + $write_str1 = t('The following directory is not writable') . ':'; + $write_str2 = t('You should give the write right to the web server on ' . + 'this directory.'); + $solution_str = t('Here is a solution') . ':'; + + if (!jirafeau_mkdir ($path) || !jirafeau_is_writable ($path)) + return array ('has_error' => true, + 'why' => $mkdir_str1 . '
' . + $path . '
' . $solution_str . + '
' . $mkdir_str2); + + foreach (array ('files', 'links', 'async', 'block') as $subdir) + { + $subpath = $path.$subdir; + + if (!jirafeau_mkdir ($subpath) || !jirafeau_is_writable ($subpath)) + return array ('has_error' => true, + 'why' => $mkdir_str1 . '
' . + $subpath . '
' . $solution_str . + '
' . $mkdir_str2); + } + + return array ('has_error' => false, 'why' => ''); +} + +function +jirafeau_add_ending_slash ($path) +{ + return $path . ((substr ($path, -1) == '/') ? '' : '/'); +} + +if (!file_exists (JIRAFEAU_CFG)) +{ + /* We try to create an empty one. */ + if (!@touch (JIRAFEAU_CFG)) + { + require (JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

' . + t('The local configuration file could not be created. Create a ' . + 'lib/config.local.php file and give the write ' . + 'right to the web server (preferred solution), or give the ' . + 'write right to the web server on the lib ' . + 'directory.') . + '

'; + require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; + } +} + +if (!is_writable (JIRAFEAU_CFG) && !@chmod (JIRAFEAU_CFG, '0666')) +{ + require (JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

' . + t('The local configuration is not writable by the web server. ' . + 'Give the write right to the web server on the ' . + 'lib/config.local.php file.') . + '

'; + require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; +} + +if (isset ($_POST['step']) && isset ($_POST['next'])) +{ + switch ($_POST['step']) + { + case 1: + $cfg['lang'] = $_POST['lang']; + jirafeau_export_cfg ($cfg); + break; + + case 2: + $cfg['admin_password'] = $_POST['admin_password']; + jirafeau_export_cfg ($cfg); + break; + + case 3: + $cfg['web_root'] = jirafeau_add_ending_slash ($_POST['web_root']); + $cfg['var_root'] = jirafeau_add_ending_slash ($_POST['var_root']); + jirafeau_export_cfg ($cfg); + break; + + case 4: + $cfg['web_root'] = jirafeau_add_ending_slash ($_POST['web_root']); + $cfg['var_root'] = jirafeau_add_ending_slash ($_POST['var_root']); + jirafeau_export_cfg ($cfg); + break; + + default: break; + } + +} + +require (JIRAFEAU_ROOT . 'lib/settings.php'); +require (JIRAFEAU_ROOT . 'lib/template/header.php'); + +$current = 1; +if (isset ($_POST['next'])) + $current = $_POST['step'] + 1; +else if (isset ($_POST['previous'])) + $current = $_POST['step'] - 1; +else if (isset ($_POST['retry'])) + $current = $_POST['step']; + +switch ($current) +{ +case 1: +default: + ?>

" method = "post"> " />
+ + + + +
+ +
+

" method = "post"> " />
+ + + + +
+

" method = "post"> " />
+ + + +
+ +
+

" method = "post"> " />
+
+

'.$err['why'].'
'.NL; + ?>

" />" />
+ '; + } + else + { + echo '

' . + t('Jirafeau is now fully operational') . ':' . + '
' . + $cfg['web_root'].'

'; + } +break; +} + +require (JIRAFEAU_ROOT . 'lib/template/footer.php'); +?> diff --git a/sources/lib/config.original.php b/sources/lib/config.original.php new file mode 100644 index 0000000..17de2bb --- /dev/null +++ b/sources/lib/config.original.php @@ -0,0 +1,64 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* + * default configuration + * if you want to change this, overwrite in a config.local.php file + */ + global $cfg; + +/* don't forget the ending '/' */ +$cfg['web_root'] = ''; +$cfg['var_root'] = ''; + +/* Lang choice between 'auto', 'en' and 'fr'. + 'auto' mode will take the user's browser informations. Will take english if + user's langage is not available. + */ +$cfg['lang'] = 'auto'; +$cfg['style'] = 'modern'; +$cfg['rewrite'] = false; +/* An empty admin password will disable the admin interface. */ +$cfg['admin_password'] = ''; +/* preview: false (will download file) or true (will preview in browser if + * possible) . */ +$cfg['preview'] = true; +/* Download page: + * true: Will show a download page (with preview if permited and possible). + * false: Will directly download file or preview (if permited and possible). */ +$cfg['download_page'] = false; +/* Block feature: + The scripting interface can propose to create, read, write, delete blocks + of data. */ +$cfg['enable_blocks'] = false; +/* Encryption feature. disable it by default. + * By enabling it, file-level deduplication won't work. */ +$cfg['enable_crypt'] = false; +/* Split lenght of link refenrece. */ +$cfg['link_name_lenght'] = 8; +/* Upload password. Empty string disable the password. */ +$cfg['upload_password'] = ''; + +if ((basename (__FILE__) != 'config.local.php') + && file_exists (JIRAFEAU_ROOT.'lib/config.local.php')) +{ + require (JIRAFEAU_ROOT.'lib/config.local.php'); +} + +?> diff --git a/sources/lib/functions.js b/sources/lib/functions.js new file mode 100755 index 0000000..8922e0e --- /dev/null +++ b/sources/lib/functions.js @@ -0,0 +1,301 @@ +/* + * Jirafeau, your web file repository + * Copyright (C) 2012 Jerome Jutteau + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +function show_link (url, reference, delete_code, crypt_key, date) +{ + var download_link = url + 'f.php?h=' + reference; + var download_link_href = url + 'f.php?h=' + reference; + if (crypt_key.length > 0) + { + download_link += '&k=' + crypt_key; + download_link_href += '&k=' + crypt_key; + } + + var delete_link = url + 'f.php?h=' + reference + '&d=' + delete_code; + var delete_link_href = url + 'f.php?h=' + reference + '&d=' + delete_code; + + document.getElementById('upload_link').innerHTML = download_link; + document.getElementById('upload_link').href = download_link_href; + document.getElementById('delete_link').innerHTML = delete_link; + document.getElementById('delete_link').href = delete_link_href; + if (date) + { + document.getElementById('date').innerHTML = date; + document.getElementById('validity').style.display = ''; + } + else + document.getElementById('validity').style.display = 'none'; + + document.getElementById('uploading').style.display = 'none'; + document.getElementById('upload').style.display = 'none'; + document.getElementById('upload_finished').style.display = ''; + document.title = 'Jirafeau - 100%'; +} + +function show_upload_progression (p) +{ + document.getElementById('uploaded_percentage').innerHTML = p; + document.title = 'Jirafeau - ' + p; +} + +function upload_progress (e) +{ + if (!e.lengthComputable) + return; + /* Show the user the operation do not reach 100%, the server need time + * to give a response before providing the link. + */ + var p = Math.round (e.loaded * 100 / e.total); + if (p == 100) + show_upload_progression (' '); + else + show_upload_progression (p.toString() + '%'); +} + +function upload_failed (e) +{ + /* Todo: Considere showing a error div. */ + alert ('Sorry, upload failed'); +} + +function classic_upload (url, file, time, password, one_time, upload_password) +{ + var req = new XMLHttpRequest (); + req.upload.addEventListener ("progress", upload_progress, false); + req.addEventListener ("error", upload_failed, false); + req.addEventListener ("abort", upload_failed, false); + req.onreadystatechange = function () + { + if (req.readyState == 4 && req.status == 200) + { + var res = req.responseText; + if (res == "Error") + return; + res = res.split ("\n"); + if (time != 'none') + { + var d = new Date(); + if (time == 'minute') + d.setSeconds (d.getSeconds() + 60); + else if (time == 'hour') + d.setSeconds (d.getSeconds() + 3600); + else if (time == 'day') + d.setSeconds (d.getSeconds() + 86400); + else if (time == 'week') + d.setSeconds (d.getSeconds() + 604800); + else if (time == 'month') + d.setSeconds (d.getSeconds() + 2419200); + else + return; + show_link (url, res[0], res[1], res[2], d.toString()); + } + else + show_link (url, res[0], res[1], res[2]); + } + } + req.open ("POST", url + 'script.php' , true); + + var form = new FormData(); + form.append ("file", file); + if (time) + form.append ("time", time); + if (password) + form.append ("key", password); + if (one_time) + form.append ("one_time_download", '1'); + if (upload_password.length > 0) + form.append ("upload_password", upload_password); + + req.send (form); +} + +function check_html5_file_api () +{ + if (window.File && window.FileReader && window.FileList && window.Blob) + return true; + return false; +} + +var async_global_transfered = 0; +var async_global_url = ''; +var async_global_file; +var async_global_ref = ''; +var async_global_max_size = 0; +var async_global_time; +var async_global_transfering = 0; + +function async_upload_start (url, max_size, file, time, password, one_time, upload_password) +{ + async_global_transfered = 0; + async_global_url = url; + async_global_file = file; + async_global_max_size = max_size; + async_global_time = time; + + var req = new XMLHttpRequest (); + req.addEventListener ("error", upload_failed, false); + req.addEventListener ("abort", upload_failed, false); + req.onreadystatechange = function () + { + if (req.readyState == 4 && req.status == 200) + { + var res = req.responseText; + if (res == "Error") + return; + res = res.split ("\n"); + async_global_ref = res[0]; + var code = res[1]; + async_upload_push (code); + } + } + req.open ("POST", async_global_url + 'script.php?init_async' , true); + + var form = new FormData(); + form.append ("filename", async_global_file.name); + form.append ("type", async_global_file.type); + if (time) + form.append ("time", time); + if (password) + form.append ("key", password); + if (one_time) + form.append ("one_time_download", '1'); + if (upload_password.length > 0) + form.append ("upload_password", upload_password); + + req.send (form); +} + +function async_upload_progress (e) +{ + if (!e.lengthComputable && async_global_file.size != 0) + return; + var p = Math.round ((e.loaded + async_global_transfered) * 100 / (async_global_file.size)); + if (p == 100) + show_upload_progression (' '); + else + show_upload_progression (p.toString() + '%'); +} + +function async_upload_push (code) +{ + if (async_global_transfered == async_global_file.size) + { + async_upload_end (code); + return; + } + var req = new XMLHttpRequest (); + req.upload.addEventListener ("progress", async_upload_progress, false); + req.addEventListener ("error", upload_failed, false); + req.addEventListener ("abort", upload_failed, false); + req.onreadystatechange = function () + { + if (req.readyState == 4 && req.status == 200) + { + var res = req.responseText; + if (res == "Error") + return; + res = res.split ("\n"); + var code = res[0] + async_global_transfered = async_global_transfering; + async_upload_push (code); + } + } + req.open ("POST", async_global_url + 'script.php?push_async' , true); + + var chunk_size = parseInt (async_global_max_size * 0.50); + var start = async_global_transfered; + var end = start + chunk_size; + if (end >= async_global_file.size) + end = async_global_file.size; + var blob = async_global_file.slice (start, end); + async_global_transfering = end; + + var form = new FormData(); + form.append ("ref", async_global_ref); + form.append ("data", blob); + form.append ("code", code); + req.send (form); +} + +function async_upload_end (code) +{ + var req = new XMLHttpRequest (); + req.addEventListener ("error", upload_failed, false); + req.addEventListener ("abort", upload_failed, false); + req.onreadystatechange = function () + { + if (req.readyState == 4 && req.status == 200) + { + var res = req.responseText; + if (res == "Error") + return; + res = res.split ("\n"); + if (async_global_time != 'none') + { + var d = new Date(); + if (async_global_time == 'minute') + d.setSeconds (d.getSeconds() + 60); + else if (async_global_time == 'hour') + d.setSeconds (d.getSeconds() + 3600); + else if (async_global_time == 'day') + d.setSeconds (d.getSeconds() + 86400); + else if (async_global_time == 'week') + d.setSeconds (d.getSeconds() + 604800); + else if (async_global_time == 'month') + d.setSeconds (d.getSeconds() + 2419200); + else + return; + show_link (async_global_url, res[0], res[1], res[2], d.toString()); + } + else + show_link (async_global_url, res[0], res[1], res[2]); + } + } + req.open ("POST", async_global_url + 'script.php?end_async' , true); + + var form = new FormData(); + form.append ("ref", async_global_ref); + form.append ("code", code); + req.send (form); +} + +function upload (url, max_size) +{ + if (check_html5_file_api () + && document.getElementById('file_select').files[0].size >= max_size) + { + async_upload_start (url, + max_size, + document.getElementById('file_select').files[0], + document.getElementById('select_time').value, + document.getElementById('input_key').value, + document.getElementById('one_time_download').checked, + document.getElementById('upload_password').value + ); + } + else + { + classic_upload (url, + document.getElementById('file_select').files[0], + document.getElementById('select_time').value, + document.getElementById('input_key').value, + document.getElementById('one_time_download').checked, + document.getElementById('upload_password').value + ); + } +} diff --git a/sources/lib/functions.php b/sources/lib/functions.php new file mode 100755 index 0000000..15c7a3e --- /dev/null +++ b/sources/lib/functions.php @@ -0,0 +1,1380 @@ + + * Copyright (C) 2012 Jerome Jutteau + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/** + * Transform a string in a path by seperating each letters by a '/'. + * @return path finishing with a '/' + */ +function +s2p ($s) +{ + $p = ''; + for ($i = 0; $i < strlen ($s); $i++) + $p .= $s{$i} . '/'; + return $p; +} + +/** + * Convert base 16 to base 64 + * @returns A string based on 64 characters (0-9, a-z, A-Z, "-" and "_") + */ +function +base_16_to_64 ($num) +{ + $m = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'; + $hex2bin = array ('0000', # 0 + '0001', # 1 + '0010', # 2 + '0011', # 3 + '0100', # 4 + '0101', # 5 + '0110', # 6 + '0111', # 7 + '1000', # 8 + '1001', # 9 + '1010', # a + '1011', # b + '1100', # c + '1101', # d + '1110', # e + '1111'); # f + $o = ''; + $b = ''; + $i = 0; + # Convert long hex string to bin. + $size = strlen ($num); + for ($i = 0; $i < $size; $i++) + $b .= $hex2bin{hexdec ($num{$i})}; + # Convert long bin to base 64. + $size *= 4; + for ($i = $size - 6; $i >= 0; $i -= 6) + $o = $m{bindec (substr ($b, $i, 6))} . $o; + # Some few bits remaining ? + if ($i < 0 && $i > -6) + $o = $m{bindec (substr ($b, 0, $i + 6))} . $o; + return $o; +} + +/** + * Generate a random code. + * @param $l code length + * @return random code. + */ +function +jirafeau_gen_random ($l) +{ + if ($l <= 0) + return 42; + + $code=""; + for ($i = 0; $i < $l; $i++) + $code .= dechex (rand (0, 15)); + + return $code; +} + +function +jirafeau_human_size ($octets) +{ + $u = array ('B', 'KB', 'MB', 'GB', 'TB'); + $o = max ($octets, 0); + $p = min (floor (($o ? log ($o) : 0) / log (1024)), count ($u) - 1); + $o /= pow (1024, $p); + return round ($o, 1) . $u[$p]; +} + +function +jirafeau_clean_rm_link ($link) +{ + $p = s2p ("$link"); + if (file_exists (VAR_LINKS . $p . $link)) + unlink (VAR_LINKS . $p . $link); + $parse = VAR_LINKS . $p; + $scan = array(); + while (file_exists ($parse) + && ($scan = scandir ($parse)) + && count ($scan) == 2 // '.' and '..' folders => empty. + && basename ($parse) != basename (VAR_LINKS)) + { + rmdir ($parse); + $parse = substr ($parse, 0, strlen($parse) - strlen(basename ($parse)) - 1); + } +} + +function +jirafeau_clean_rm_file ($md5) +{ + $p = s2p ("$md5"); + $f = VAR_FILES . $p . $md5; + if (file_exists ($f) && is_file ($f)) + unlink ($f); + if (file_exists ($f . '_count') && is_file ($f . '_count')) + unlink ($f . '_count'); + $parse = VAR_FILES . $p; + $scan = array(); + while (file_exists ($parse) + && ($scan = scandir ($parse)) + && count ($scan) == 2 // '.' and '..' folders => empty. + && basename ($parse) != basename (VAR_FILES)) + { + rmdir ($parse); + $parse = substr ($parse, 0, strlen($parse) - strlen(basename ($parse)) - 1); + } +} + +/** + * transforms a php.ini string representing a value in an integer + * @param $value the value from php.ini + * @returns an integer for this value + */ +function jirafeau_ini_to_bytes ($value) +{ + $modifier = substr ($value, -1); + $bytes = substr ($value, 0, -1); + switch (strtoupper ($modifier)) + { + case 'P': + $bytes *= 1024; + case 'T': + $bytes *= 1024; + case 'G': + $bytes *= 1024; + case 'M': + $bytes *= 1024; + case 'K': + $bytes *= 1024; + default: + break; + } + return $bytes; +} + +/** + * gets the maximum upload size according to php.ini + * @returns the maximum upload size in bytes + */ +function +jirafeau_get_max_upload_size_bytes () +{ + return min (jirafeau_ini_to_bytes (ini_get ('post_max_size')), + jirafeau_ini_to_bytes (ini_get ('upload_max_filesize'))); +} + +/** + * gets the maximum upload size according to php.ini + * @returns the maximum upload size string + */ +function +jirafeau_get_max_upload_size () +{ + return jirafeau_human_size( + min (jirafeau_ini_to_bytes (ini_get ('post_max_size')), + jirafeau_ini_to_bytes (ini_get ('upload_max_filesize')))); +} + +/** + * gets a string explaining the error + * @param $code the error code + * @returns a string explaining the error + */ +function +jirafeau_upload_errstr ($code) +{ + switch ($code) + { + case UPLOAD_ERR_INI_SIZE: + case UPLOAD_ERR_FORM_SIZE: + return t('Your file exceeds the maximum authorized file size. '); + break; + + case UPLOAD_ERR_PARTIAL: + case UPLOAD_ERR_NO_FILE: + return + t + ('Your file was not uploaded correctly. You may succeed in retrying. '); + break; + + case UPLOAD_ERR_NO_TMP_DIR: + case UPLOAD_ERR_CANT_WRITE: + case UPLOAD_ERR_EXTENSION: + return t('Internal error. You may not succeed in retrying. '); + break; + + default: + break; + } + return t('Unknown error. '); +} + +/** Remove link and it's file + * @param $link the link's name (hash) + */ + +function +jirafeau_delete_link ($link) +{ + $l = jirafeau_get_link ($link); + if (!count ($l)) + return; + + jirafeau_clean_rm_link ($link); + + $md5 = $l['md5']; + $p = s2p ("$md5"); + + $counter = 1; + if (file_exists (VAR_FILES . $p . $md5. '_count')) + { + $content = file (VAR_FILES . $p . $md5. '_count'); + $counter = trim ($content[0]); + } + $counter--; + + if ($counter >= 1) + { + $handle = fopen (VAR_FILES . $p . $md5. '_count', 'w'); + fwrite ($handle, $counter); + fclose ($handle); + } + + if ($counter == 0) + jirafeau_clean_rm_file ($md5); +} + +/** + * Delete a file and it's links. + */ +function +jirafeau_delete_file ($md5) +{ + $count = 0; + /* Get all links files. */ + $stack = array (VAR_LINKS); + while (($d = array_shift ($stack)) && $d != NULL) + { + $dir = scandir ($d); + + foreach ($dir as $node) + { + if (strcmp ($node, '.') == 0 || strcmp ($node, '..') == 0 || + preg_match ('/\.tmp/i', "$node")) + continue; + + if (is_dir ($d . $node)) + { + /* Push new found directory. */ + $stack[] = $d . $node . '/'; + } + elseif (is_file ($d . $node)) + { + /* Read link informations. */ + $l = jirafeau_get_link (basename ($node)); + if (!count ($l)) + continue; + if ($l['md5'] == $md5) + { + $count++; + jirafeau_delete_link ($node); + } + } + } + } + jirafeau_clean_rm_file ($md5); + return $count; +} + +/** + * handles an uploaded file + * @param $file the file struct given by $_FILE[] + * @param $one_time_download is the file a one time download ? + * @param $key if not empty, protect the file with this key + * @param $time the time of validity of the file + * @param $ip uploader's ip + * @param $crypt boolean asking to crypt or not + * @param $link_name_length size of the link name + * @returns an array containing some information + * 'error' => information on possible errors + * 'link' => the link name of the uploaded file + * 'delete_link' => the link code to delete file + */ +function +jirafeau_upload ($file, $one_time_download, $key, $time, $ip, $crypt, $link_name_length) +{ + if (empty ($file['tmp_name']) || !is_uploaded_file ($file['tmp_name'])) + { + return (array( + 'error' => + array ('has_error' => true, + 'why' => jirafeau_upload_errstr ($file['error'])), + 'link' => '', + 'delete_link' => '')); + } + + /* array representing no error */ + $noerr = array ('has_error' => false, 'why' => ''); + + /* Crypt file if option is enabled. */ + $crypted = false; + $crypt_key = ''; + if ($crypt == true && extension_loaded('mcrypt')) + { + $crypt_key = jirafeau_encrypt_file ($file['tmp_name'], $file['tmp_name']); + if (strlen($crypt_key) > 0) + $crypted = true; + } + + /* file informations */ + $md5 = md5_file ($file['tmp_name']); + $name = str_replace (NL, '', trim ($file['name'])); + $mime_type = $file['type']; + $size = $file['size']; + + /* does file already exist ? */ + $rc = false; + $p = s2p ("$md5"); + if (file_exists (VAR_FILES . $p . $md5)) + { + $rc = unlink ($file['tmp_name']); + } + elseif ((file_exists (VAR_FILES . $p) || @mkdir (VAR_FILES . $p, 0755, true)) + && move_uploaded_file ($file['tmp_name'], VAR_FILES . $p . $md5)) + { + $rc = true; + } + if (!$rc) + { + return (array( + 'error' => + array ('has_error' => true, + 'why' => t('Internal error during file creation.')), + 'link' =>'', + 'delete_link' => '')); + } + + /* Increment or create count file. */ + $counter = 0; + if (file_exists (VAR_FILES . $p . $md5 . '_count')) + { + $content = file (VAR_FILES . $p . $md5. '_count'); + $counter = trim ($content[0]); + } + $counter++; + $handle = fopen (VAR_FILES . $p . $md5. '_count', 'w'); + fwrite ($handle, $counter); + fclose ($handle); + + /* Create delete code. */ + $delete_link_code = jirafeau_gen_random (5); + + /* md5 password or empty. */ + $password = ''; + if (!empty ($key)) + $password = md5 ($key); + + /* create link file */ + $link_tmp_name = VAR_LINKS . $md5 . rand (0, 10000) . '.tmp'; + $handle = fopen ($link_tmp_name, 'w'); + fwrite ($handle, + $name . NL. $mime_type . NL. $size . NL. $password . NL. $time . + NL . $md5. NL . ($one_time_download ? 'O' : 'R') . NL . date ('U') . + NL . $ip . NL. $delete_link_code . NL . ($crypted ? 'C' : 'O')); + fclose ($handle); + $md5_link = substr(base_16_to_64 (md5_file ($link_tmp_name)), 0, $link_name_length); + $l = s2p ("$md5_link"); + if (!@mkdir (VAR_LINKS . $l, 0755, true) || + !rename ($link_tmp_name, VAR_LINKS . $l . $md5_link)) + { + if (file_exists ($link_tmp_name)) + unlink ($link_tmp_name); + + $counter--; + if ($counter >= 1) + { + $handle = fopen (VAR_FILES . $p . $md5. '_count', 'w'); + fwrite ($handle, $counter); + fclose ($handle); + } + else + { + jirafeau_clean_rm_file ($md5_link); + } + return (array( + 'error' => + array ('has_error' => true, + 'why' => t('Internal error during file creation. ')), + 'link' =>'', + 'delete_link' => '')); + } + return (array ('error' => $noerr, + 'link' => $md5_link, + 'delete_link' => $delete_link_code, + 'crypt_key' => $crypt_key)); +} + +/** + * tells if a mime-type is viewable in a browser + * @param $mime the mime type + * @returns a boolean telling if a mime type is viewable + */ +function +jirafeau_is_viewable ($mime) +{ + if (!empty ($mime)) + { + /* Actually, verify if mime-type is an image or a text. */ + $viewable = array ('image', 'text'); + $decomposed = explode ('/', $mime); + return in_array ($decomposed[0], $viewable); + } + return false; +} + +// Error handling functions. +//! Global array that contains all registered errors. +$error_list = array (); + +/** + * Adds an error to the list of errors. + * @param $title the error's title + * @param $description is a human-friendly description of the problem. + */ +function +add_error ($title, $description) +{ + global $error_list; + $error_list[] = '

' . $title. '
' . $description. '

'; +} + +/** + * Informs whether any error has been registered yet. + * @return true if there are errors. + */ +function +has_error () +{ + global $error_list; + return !empty ($error_list); +} + +/** + * Displays all the errors. + */ +function +show_errors () +{ + if (has_error ()) + { + global $error_list; + echo '
'; + foreach ($error_list as $error) + { + echo $error; + } + echo '
'; + } +} + +function check_errors () +{ + if (file_exists (JIRAFEAU_ROOT . 'install.php') + && !file_exists (JIRAFEAU_ROOT . 'lib/config.local.php')) + { + header('Location: install.php'); + exit; + } + + /* check if the destination dirs are writable */ + $writable = is_writable (VAR_FILES) && is_writable (VAR_LINKS); + + /* Checking for errors. */ + if (!is_writable (VAR_FILES)) + add_error (t('The file directory is not writable!'), VAR_FILES); + + if (!is_writable (VAR_LINKS)) + add_error (t('The link directory is not writable!'), VAR_LINKS); + + if (!is_writable (VAR_ASYNC)) + add_error (t('The async directory is not writable!'), VAR_ASYNC); + + if (!is_writable (VAR_BLOCK)) + add_error (t('The block directory is not writable!'), VAR_BLOCK); + + /* Check if the install.php script is still in the directory. */ + if (file_exists (JIRAFEAU_ROOT . 'install.php')) + add_error (t('Installer script still present'), + t('Please make sure to delete the installer script ' . + '"install.php" before continuing.')); +} + +/** + * Read link informations + * @return array containing informations. + */ +function +jirafeau_get_link ($hash) +{ + $out = array (); + $link = VAR_LINKS . s2p ("$hash") . $hash; + + if (!file_exists ($link)) + return $out; + + $c = file ($link); + $out['file_name'] = trim ($c[0]); + $out['mime_type'] = trim ($c[1]); + $out['file_size'] = trim ($c[2]); + $out['key'] = trim ($c[3], NL); + $out['time'] = trim ($c[4]); + $out['md5'] = trim ($c[5]); + $out['onetime'] = trim ($c[6]); + $out['upload_date'] = trim ($c[7]); + $out['ip'] = trim ($c[8]); + $out['link_code'] = trim ($c[9]); + if (trim ($c[10]) == 'C') + $out['crypted'] = true; + + return $out; +} + +/** + * List files in admin interface. + */ +function +jirafeau_admin_list ($name, $file_hash, $link_hash) +{ + echo '
'; + if (!empty ($name)) + echo t('Filename') . ": $name "; + if (!empty ($file_hash)) + echo t('file') . ": $file_hash "; + if (!empty ($link_hash)) + echo t('link') . ": $link_hash "; + if (empty ($name) && empty ($file_hash) && empty ($link_hash)) + echo t('List all files'); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + /* Get all links files. */ + $stack = array (VAR_LINKS); + while (($d = array_shift ($stack)) && $d != NULL) + { + $dir = scandir ($d); + foreach ($dir as $node) + { + if (strcmp ($node, '.') == 0 || strcmp ($node, '..') == 0 || + preg_match ('/\.tmp/i', "$node")) + continue; + if (is_dir ($d . $node)) + { + /* Push new found directory. */ + $stack[] = $d . $node . '/'; + } + elseif (is_file ($d . $node)) + { + /* Read link informations. */ + $l = jirafeau_get_link ($node); + if (!count ($l)) + continue; + + /* Filter. */ + if (!empty ($name) && !preg_match ("/$name/i", $l['file_name'])) + continue; + if (!empty ($file_hash) && $file_hash != $l['md5']) + continue; + if (!empty ($link_hash) && $link_hash != $node) + continue; + /* Print link informations. */ + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + } + } + echo '
' . t('Filename') . '' . t('Type') . '' . t('Size') . '' . t('Expire') . '' . t('Onetime') . '' . t('Upload date') . '' . t('Origin') . '' . t('Action') . '
' . + '
' . + '' . + '' . + '' . + '
'; + echo '
' . $l['mime_type'] . '' . jirafeau_human_size ($l['file_size']) . '' . ($l['time'] == -1 ? '' : strftime ('%c', $l['time'])) . + '' . $l['onetime'] . '' . strftime ('%c', $l['upload_date']) . '' . $l['ip'] . '' . + '
' . + '' . + '' . + '' . + '
' . + '
' . + '' . + '' . + '' . + '
' . + '
'; +} + +/** + * Clean expired files. + * @return number of cleaned files. + */ +function +jirafeau_admin_clean () +{ + $count = 0; + /* Get all links files. */ + $stack = array (VAR_LINKS); + while (($d = array_shift ($stack)) && $d != NULL) + { + $dir = scandir ($d); + + foreach ($dir as $node) + { + if (strcmp ($node, '.') == 0 || strcmp ($node, '..') == 0 || + preg_match ('/\.tmp/i', "$node")) + continue; + + if (is_dir ($d . $node)) + { + /* Push new found directory. */ + $stack[] = $d . $node . '/'; + } + elseif (is_file ($d . $node)) + { + /* Read link informations. */ + $l = jirafeau_get_link (basename ($node)); + if (!count ($l)) + continue; + $p = s2p ($l['md5']); + if ($l['time'] > 0 && $l['time'] < time () || // expired + !file_exists (VAR_FILES . $p . $l['md5']) || // invalid + !file_exists (VAR_FILES . $p . $l['md5'] . '_count')) // invalid + { + jirafeau_delete_link ($node); + $count++; + } + } + } + } + return $count; +} + + +/** + * Clean old async transferts. + * @return number of cleaned files. + */ +function +jirafeau_admin_clean_async () +{ + $count = 0; + /* Get all links files. */ + $stack = array (VAR_ASYNC); + while (($d = array_shift ($stack)) && $d != NULL) + { + $dir = scandir ($d); + + foreach ($dir as $node) + { + if (strcmp ($node, '.') == 0 || strcmp ($node, '..') == 0 || + preg_match ('/\.tmp/i', "$node")) + continue; + + if (is_dir ($d . $node)) + { + /* Push new found directory. */ + $stack[] = $d . $node . '/'; + } + elseif (is_file ($d . $node)) + { + /* Read async informations. */ + $a = jirafeau_get_async_ref (basename ($node)); + if (!count ($a)) + continue; + /* Delete transferts older than 1 hour. */ + if (date ('U') - $a['last_edited'] > 3600) + { + jirafeau_async_delete (basename ($node)); + $count++; + } + } + } + } + return $count; +} +/** + * Read async transfert informations + * @return array containing informations. + */ +function +jirafeau_get_async_ref ($ref) +{ + $out = array (); + $refinfos = VAR_ASYNC . s2p ("$ref") . "$ref"; + + if (!file_exists ($refinfos)) + return $out; + + $c = file ($refinfos); + $out['file_name'] = trim ($c[0]); + $out['mime_type'] = trim ($c[1]); + $out['key'] = trim ($c[2], NL); + $out['time'] = trim ($c[3]); + $out['onetime'] = trim ($c[4]); + $out['ip'] = trim ($c[5]); + $out['last_edited'] = trim ($c[6]); + $out['next_code'] = trim ($c[7]); + return $out; +} + +/** + * Delete async transfert informations + */ +function +jirafeau_async_delete ($ref) +{ + $p = s2p ("$ref"); + if (file_exists (VAR_ASYNC . $p . $ref)) + unlink (VAR_ASYNC . $p . $ref); + if (file_exists (VAR_ASYNC . $p . $ref . '_data')) + unlink (VAR_ASYNC . $p . $ref . '_data'); + $parse = VAR_ASYNC . $p; + $scan = array(); + while (file_exists ($parse) + && ($scan = scandir ($parse)) + && count ($scan) == 2 // '.' and '..' folders => empty. + && basename ($parse) != basename (VAR_ASYNC)) + { + rmdir ($parse); + $parse = substr ($parse, 0, strlen($parse) - strlen(basename ($parse)) - 1); + } +} + +/** + * Init a new asynchronous upload. + * @param $finename Name of the file to send + * @param $one_time One time upload parameter + * @param $key eventual password (or blank) + * @param $time time limit + * @param $ip ip address of the client + * @return a string containing a temporary reference followed by a code or the string "Error" + */ +function +jirafeau_async_init ($filename, $type, $one_time, $key, $time, $ip) +{ + $res = 'Error'; + + /* Create temporary folder. */ + $ref; + $p; + $code = jirafeau_gen_random (4); + do + { + $ref = jirafeau_gen_random (32); + $p = VAR_ASYNC . s2p ($ref); + } while (file_exists ($p)); + @mkdir ($p, 0755, true); + if (!file_exists ($p)) + { + echo "Error"; + return; + } + + /* md5 password or empty */ + $password = ''; + if (!empty ($key)) + $password = md5 ($key); + + /* Store informations. */ + $p .= $ref; + $handle = fopen ($p, 'w'); + fwrite ($handle, + str_replace (NL, '', trim ($filename)) . NL . + str_replace (NL, '', trim ($type)) . NL . $password . NL . + $time . NL . ($one_time ? 'O' : 'R') . NL . $ip . NL . + date ('U') . NL . $code . NL); + fclose ($handle); + + return $ref . NL . $code ; +} + +/** + * Append a piece of file on the asynchronous upload. + * @param $ref asynchronous upload reference + * @param $file piece of data + * @param $code client code for this operation + * @return a string containing a next code to use or the string "Error" + */ +function +jirafeau_async_push ($ref, $data, $code) +{ + /* Get async infos. */ + $a = jirafeau_get_async_ref ($ref); + + /* Check some errors. */ + if (count ($a) == 0 + || $a['next_code'] != "$code" + || empty ($data['tmp_name']) + || !is_uploaded_file ($data['tmp_name'])) + return "Error"; + + $p = s2p ($ref); + + /* Concatenate data. */ + $r = fopen ($data['tmp_name'], 'r'); + $w = fopen (VAR_ASYNC . $p . $ref . '_data', 'a'); + while (!feof ($r)) + { + if (fwrite ($w, fread ($r, 1024)) === false) + { + fclose ($r); + fclose ($w); + jirafeau_async_delete ($ref); + return "Error"; + } + } + fclose ($r); + fclose ($w); + unlink ($data['tmp_name']); + + /* Update async file. */ + $code = jirafeau_gen_random (4); + $handle = fopen (VAR_ASYNC . $p . $ref, 'w'); + fwrite ($handle, + $a['file_name'] . NL. $a['mime_type'] . NL. $a['key'] . NL . + $a['time'] . NL . $a['onetime'] . NL . $a['ip'] . NL . + date ('U') . NL . $code . NL); + fclose ($handle); + return $code; +} + +/** + * Finalyze an asynchronous upload. + * @param $ref asynchronous upload reference + * @param $code client code for this operation + * @param $crypt boolean asking to crypt or not + * @param $link_name_length link name lenght + * @return a string containing the download reference followed by a delete code or the string "Error" + */ +function +jirafeau_async_end ($ref, $code, $crypt, $link_name_length) +{ + /* Get async infos. */ + $a = jirafeau_get_async_ref ($ref); + if (count ($a) == 0 + || $a['next_code'] != "$code") + return "Error"; + + /* Generate link infos. */ + $p = VAR_ASYNC . s2p ($ref) . $ref . "_data"; + if (!file_exists($p)) + return "Error"; + + $crypted = false; + $crypt_key = ''; + if ($crypt == true && extension_loaded('mcrypt')) + { + $crypt_key = jirafeau_encrypt_file ($p, $p); + if (strlen($crypt_key) > 0) + $crypted = true; + } + + $md5 = md5_file ($p); + $size = filesize($p); + $np = s2p ($md5); + $delete_link_code = jirafeau_gen_random (5); + + /* File already exist ? */ + if (!file_exists (VAR_FILES . $np)) + @mkdir (VAR_FILES . $np, 0755, true); + if (!file_exists (VAR_FILES . $np . $md5)) + rename ($p, VAR_FILES . $np . $md5); + + /* Increment or create count file. */ + $counter = 0; + if (file_exists (VAR_FILES . $np . $md5 . '_count')) + { + $content = file (VAR_FILES . $np . $md5. '_count'); + $counter = trim ($content[0]); + } + $counter++; + $handle = fopen (VAR_FILES . $np . $md5. '_count', 'w'); + fwrite ($handle, $counter); + fclose ($handle); + + /* Create link. */ + $link_tmp_name = VAR_LINKS . $md5 . rand (0, 10000) . '.tmp'; + $handle = fopen ($link_tmp_name, 'w'); + fwrite ($handle, + $a['file_name'] . NL . $a['mime_type'] . NL . $size . NL . + $a['key'] . NL . $a['time'] . NL . $md5 . NL . $a['onetime'] . NL . + date ('U') . NL . $a['ip'] . NL . $delete_link_code . NL . ($crypted ? 'C' : 'O')); + fclose ($handle); + $md5_link = substr(base_16_to_64 (md5_file ($link_tmp_name)), 0, $link_name_length); + $l = s2p ("$md5_link"); + if (!@mkdir (VAR_LINKS . $l, 0755, true) || + !rename ($link_tmp_name, VAR_LINKS . $l . $md5_link)) + echo "Error"; + + /* Clean async upload. */ + jirafeau_async_delete ($ref); + return $md5_link . NL . $delete_link_code . NL . urlencode($crypt_key); +} + +/** + * Delete a block. + * @param $id identifier of the block. + */ +function +jirafeau_block_delete_ ($id) +{ + $p = VAR_BLOCK . s2p ($id); + if (!file_exists ($p)) + return; + + if (file_exists ($p . $id)) + unlink ($p . $id); + if (file_exists ($p . $id . '_infos')) + unlink ($p . $id . '_infos'); + $parse = $p; + $scan = array(); + while (file_exists ($parse) + && ($scan = scandir ($parse)) + && count ($scan) == 2 // '.' and '..' folders => empty. + && basename ($parse) != basename (VAR_BLOCK)) + { + rmdir ($parse); + $parse = substr ($parse, 0, strlen($parse) - strlen(basename ($parse)) - 1); + } +} + +/** + * Create a file filled with zeros. + * @param $size size of the file. + * @return a string corresponding to an id or the string "Error" + */ +function +jirafeau_block_init ($size) +{ + if (!ctype_digit ($size) || $size <= 0) + return "Error"; + + /* Create folder. */ + $id; + do + { + $id = jirafeau_gen_random (32); + $p = VAR_BLOCK . s2p ($id); + } while (file_exists ($p)); + @mkdir ($p, 0755, true); + if (!file_exists ($p)) + { + echo "Error"; + return; + } + + /* Create block. */ + $p .= $id; + $h = fopen ($p, 'w'); + $fill = str_repeat ("\0", 1024); + for ($cnt = 0; $cnt < $size; $cnt += 1024) + { + if ($size - $cnt < 1024) + $fill = str_repeat ("\0", $size - $cnt); + if (fwrite ($h, $fill) === false) + { + fclose ($h); + jirafeau_block_delete_ ($id); + return "Error"; + } + } + fclose ($h); + + /* Generate a write/delete code. */ + $code = jirafeau_gen_random (12); + + /* Add block infos. */ + if (file_put_contents ($p . '_infos', date ('U') . NL . $size . NL . $code) === FALSE) + { + jirafeau_block_delete_ ($id); + return "Error"; + } + + return $id . NL . $code; +} + +/** Get block size in bytes. + * @param $id identifier of the block + * @return block size in bytes + */ +function +jirafeau_block_get_size ($id) +{ + $p = VAR_BLOCK . s2p ($id) . $id; + if (!file_exists ($p)) + return "Error"; + + /* Check date. */ + $f = file ($p . '_infos'); + $date = trim ($f[0]); + $block_size = trim ($f[1]); + $stored_code = trim ($f[2]); + /* Update date. */ + if (date ('U') - $date > JIRAFEAU_HOUR + && date ('U') - $date < JIRAFEAU_MONTH) + { + if (file_put_contents ($p . '_infos', date ('U') . NL . $block_size . NL . $stored_code) === FALSE) + { + jirafeau_block_delete_ ($id); + return "Error"; + } + } + /* Remove data. */ + elseif (date ('U') - $date >= JIRAFEAU_MONTH) + { + echo date ('U'). " $date "; + jirafeau_block_delete_ ($id); + return "Error"; + } + + return $block_size; +} + +/** + * Read some data in a block. + * @param $id identifier of the block + * @param $start where to read data (starting from zero). + * @param $length length to read. + * @return echo data + */ +function +jirafeau_block_read ($id, $start, $length) +{ + if (!ctype_digit ($start) || $start < 0 + || !ctype_digit ($length) || $length <= 0) + { + echo "Error"; + return; + } + + $p = VAR_BLOCK . s2p ($id) . $id; + if (!file_exists ($p)) + { + echo "Error"; + return; + } + + /* Check date. */ + $f = file ($p . '_infos'); + $date = trim ($f[0]); + $block_size = trim ($f[1]); + $stored_code = trim ($f[2]); + /* Update date. */ + if (date ('U') - $date > JIRAFEAU_HOUR + && date ('U') - $date < JIRAFEAU_MONTH) + { + if (file_put_contents ($p . '_infos', date ('U') . NL . $block_size . NL . $stored_code) === FALSE) + { + jirafeau_block_delete_ ($id); + echo "Error"; + return; + } + } + /* Remove data. */ + elseif (date ('U') - $date >= JIRAFEAU_MONTH) + { + echo date ('U'). " $date "; + jirafeau_block_delete_ ($id); + echo "Error"; + return; + } + + if ($start + $length > $block_size) + { + echo "Error"; + return; + } + + /* Read content. */ + header ('Content-Length: ' . $length); + header ('Content-Disposition: attachment'); + + $r = fopen ($p, 'r'); + if (fseek ($r, $start) != 0) + { + echo "Error"; + return; + } + $c = 1024; + for ($cnt = 0; $cnt < $length && !feof ($r); $cnt += 1024) + { + if ($length - $cnt < 1024) + $c = $length - $cnt; + print fread ($r, $c); + ob_flush(); + } + fclose ($r); +} + +/** + * Write some data in a block. + * @param $id identifier of the block + * @param $start where to writing data (starting from zero). + * @param $data data to write. + * @param $code code to allow writing. + * @return string "Ok" or string "Error". + */ +function +jirafeau_block_write ($id, $start, $data, $code) +{ + if (!ctype_digit ($start) || $start < 0 + || strlen ($code) == 0) + return "Error"; + + $p = VAR_BLOCK . s2p ($id) . $id; + if (!file_exists ($p)) + return "Error"; + + /* Check date. */ + $f = file ($p . '_infos'); + $date = trim ($f[0]); + $block_size = trim ($f[1]); + $stored_code = trim ($f[2]); + /* Update date. */ + if (date ('U') - $date > JIRAFEAU_HOUR + && date ('U') - $date < JIRAFEAU_MONTH) + { + if (file_put_contents ($p . '_infos', date ('U') . NL . $block_size . NL . $stored_code) === FALSE) + { + jirafeau_block_delete_ ($id); + return "Error"; + } + } + /* Remove data. */ + elseif (date ('U') - $date >= JIRAFEAU_MONTH) + { + jirafeau_block_delete_ ($id); + return "Error"; + } + + /* Check code. */ + if ($stored_code != $code) + { + echo "Error"; + return; + } + + /* Check data. */ + $size = $data['size']; + if ($size <= 0) + return "Error"; + if ($start + $size > $block_size) + return "Error"; + + /* Open data. */ + $r = fopen ($data['tmp_name'], 'r'); + + /* Open Block. */ + $w = fopen ($p, 'r+'); + if (fseek ($w, $start) != 0) + return "Error"; + + /* Write content. */ + $c = 1024; + for ($cnt = 0; $cnt <= $size && !feof ($w); $cnt += 1024) + { + if ($size - $cnt < 1024) + $c = $size - $cnt; + $d = fread ($r, $c); + fwrite ($w, $d); + } + fclose ($r); + fclose ($w); + unlink ($data['tmp_name']); + return "Ok"; +} + +/** + * Delete a block. + * @param $id identifier of the block. + * @param $code code to allow writing. + * @return string "Ok" or string "Error". + */ +function +jirafeau_block_delete ($id, $code) +{ + $p = VAR_BLOCK . s2p ($id) . $id; + + if (!file_exists ($p)) + return "Error"; + + $f = file ($p . '_infos'); + $date = trim ($f[0]); + $block_size = trim ($f[1]); + $stored_code = trim ($f[2]); + + if ($code != $stored_code) + return "Error"; + + jirafeau_block_delete_ ($id); + return "Ok"; +} + +/** + * Clean old unused blocks. + * @return number of cleaned blocks. + */ +function +jirafeau_admin_clean_block () +{ + $count = 0; + /* Get all blocks. */ + $stack = array (VAR_BLOCK); + while (($d = array_shift ($stack)) && $d != NULL) + { + $dir = scandir ($d); + + foreach ($dir as $node) + { + if (strcmp ($node, '.') == 0 || strcmp ($node, '..') == 0) + continue; + + if (is_dir ($d . $node)) + { + /* Push new found directory. */ + $stack[] = $d . $node . '/'; + } + elseif (is_file ($d . $node) && preg_match ('/\_infos/i', "$node")) + { + /* Read block informations. */ + $f = file ($d . $node); + $date = trim ($f[0]); + $block_size = trim ($f[1]); + if (date ('U') - $date >= JIRAFEAU_MONTH) + { + jirafeau_block_delete_ (substr($node, 0, -6)); + $count++; + } + } + } + } + return $count; +} + +function +jirafeau_crypt_create_iv($base, $size) +{ + $iv = ''; + while (strlen ($iv) < $size) + $iv = $iv . $base; + $iv = substr($iv, 0, $size); + return $iv; +} + +/** + * Crypt file and returns decrypt key. + * @param $fp_src file path to the file to crypt. + * @param $fp_dst file path to the file to write crypted file (could be the same). + * @return decrypt key composed of the key and the iv separated by a point ('.') + */ +function +jirafeau_encrypt_file ($fp_src, $fp_dst) +{ + $fs = filesize ($fp_src); + if ($fs === false || $fs == 0 || !extension_loaded('mcrypt')) + return ''; + + /* Prepare module. */ + $m = mcrypt_module_open('rijndael-256', '', 'ofb', ''); + /* Generate key. */ + $crypt_key = jirafeau_gen_random (10); + $md5_key = md5($crypt_key); + $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size($m)); + /* Init module. */ + mcrypt_generic_init($m, $md5_key, $iv); + /* Crypt file. */ + $r = fopen ($fp_src, 'r'); + $w = fopen ($fp_dst, 'c'); + while (!feof ($r)) + { + $enc = mcrypt_generic($m, fread ($r, 1024)); + if (fwrite ($w, $enc) === false) + return ''; + } + fclose ($r); + fclose ($w); + /* Cleanup. */ + mcrypt_generic_deinit($m); + mcrypt_module_close($m); + return $crypt_key; +} + +/** + * Decrypt file. + * @param $fp_src file path to the file to decrypt. + * @param $fp_dst file path to the file to write decrypted file (could be the same). + * @param $k string composed of the key and the iv separated by a point ('.') + * @return key used to decrypt. a string of length 0 is returned if failed. + */ +function +jirafeau_decrypt_file ($fp_src, $fp_dst, $k) +{ + $fs = filesize ($fp_src); + if ($fs === false || $fs == 0 || !extension_loaded('mcrypt')) + return false; + + /* Init module */ + $m = mcrypt_module_open('rijndael-256', '', 'ofb', ''); + /* Extract key and iv. */ + $crypt_key = $k; + $md5_key = md5($crypt_key); + $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size($m)); + /* Decrypt file. */ + $r = fopen ($fp_src, 'r'); + $w = fopen ($fp_dst, 'c'); + while (!feof ($r)) + { + $dec = mdecrypt_generic($m, fread ($r, 1024)); + if (fwrite ($w, $dec) === false) + return false; + } + fclose ($r); + fclose ($w); + /* Cleanup. */ + mcrypt_generic_deinit($m); + mcrypt_module_close($m); + return true; +} + +?> diff --git a/sources/lib/lang.php b/sources/lib/lang.php new file mode 100755 index 0000000..bf74e8d --- /dev/null +++ b/sources/lib/lang.php @@ -0,0 +1,57 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + + global $languages_list; + $languages_list = array ('auto' => 'Automatic', + 'en' => 'English', + 'fr' => 'Français'); + +/* Translation */ +function t ($text) +{ + $cfg = $GLOBALS['cfg']; + $languages_list = $GLOBALS['languages_list']; + + /* Detect user's langage if we are in automatic mode. */ + if (strcmp ($cfg['lang'], 'auto') == 0) + $l = substr ($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); + else + $l = $cfg['lang']; + + /* Is the langage in the list ? */ + $found = false; + foreach ($languages_list as $key => $v) + if (strcmp ($l, $key) == 0) + $found = true; + + /* Get translation execpt for english. */ + if ($found && strcmp ($l, "en")) + { + /* $tr is defined in this requirement. */ + require (JIRAFEAU_ROOT . "lib/lang/$l.php"); + + foreach ($tr as $o => $t) + if (strcmp ($text, $o) == 0) + return "$t"; + } + /* Return original text if no translation is found or already in english. */ + return ($text); +} + +?> diff --git a/sources/lib/lang/fr.php b/sources/lib/lang/fr.php new file mode 100755 index 0000000..9dcb524 --- /dev/null +++ b/sources/lib/lang/fr.php @@ -0,0 +1,178 @@ + + * Jimmy Beauvois + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +$tr = array ( + /* index.php */ + 'Jirafeau, your web file repository' => 'Jirafeau, votre dépot de fichiers', + 'Select a file' => 'Sélectionner un fichier à envoyer:', + 'Send' => 'Envoyer', + 'Uploading ...' => 'Envoi en cours ...', + 'One time download' => 'Téléchargement unique', + 'Password' => 'Mot de passe', + 'Time limit' => 'Limite de temps', + 'Maximum file size' => 'Taille maximale', + 'powered by Open-Source project Jirafeau' => 'Propulsé par le projet Open-Source Jirafeau', + 'Jirafeau Project' => 'Projet Jirafeau', + 'None' => 'Aucune', + 'One minute' => 'Une minute', + 'One hour' => 'Une heure', + 'One day' => 'Une journée', + 'One week' => 'Une semaine', + 'One month' => 'Un mois', + 'Upload password' => 'Mot de passe', + 'The file directory is not writable' => 'Le dossier \'file\' ne peut être écrit.', + 'The link directory is not writable' => 'Le dossier \'link\' ne peut être écrit.', + 'The async directory is not writable!' => 'Le dossier \'async\' ne peut être écrit.', + 'Installer script still present' => 'Le script d\'installation est toujours présent', + 'Please make sure to delete the installer script "install.php" before continuing.' => 'Merci de supprimer le fichier "install.php" avant de continuer.', + 'An error occurred.' => 'Une erreur s\'est produite', + 'File uploaded! Copy the following URL to get it' => 'Fichier envoyé! Le fichier sera accessible à l\'adresse suivante', + 'This file is valid until the following date' => 'Ce fichier est valable jusqu\'à la date suivante', + 'Keep the following URL to delete it at any moment' => 'Vous pouvez supprimer le fichier lorsque vous le désirez via l\'adresse suivante', + /* f.php */ + 'Download' => 'Télécharger', + 'Sorry, the requested file is not found' => 'Désolé, le fichier que vous demandez n\'existe pas ou n\'existe plus', + 'File not available.' => 'Fichier non disponible', + 'File has been deleted.' => 'Le fichier a été supprimé.', + 'The time limit of this file has expired.' => 'La limite de temps est dépassée.', + 'Password protection' => 'Protection par mot de passe', + 'Give the password of this file' => 'Donnez le mot de passe pour ce fichier', + 'Access denied' => 'Accès interdit', + 'You are about to download' => 'Vous êtes sur le point de télécharger', + 'By using our services, you accept of our' => 'En utilisant nos services, vous acceptez nos', + 'Term Of Service' => 'Conditions d\'utilisation', + /* functions.php */ + 'Internal error during file creation.' => 'Erreur interne lors la creation de fichier.', + /* install.hpp */ + 'This file was generated by the install process. You can edit it. Please see config.original.php to understand the configuration items.' => 'Ce fichier a été généré par le processus d\'installation. Vous pouvez l\'éditer. Merci de se référer à config.original.php pour comprendre les éléments de configuration.', + 'The following directory could not be created' => 'Le dossier suivant ne peut être créé', + 'You should create this directory by hand.' => 'Vous devriez creer manuelement ce dossier', + 'The following directory is not writable' => 'Le dossier suivant ne peut être créé', + 'You should give the write right to the web server on this directory.' => 'Vous devriez donner le droits d\'écriture à ce repertoire pour le rendre accessible par le serveur web.', + 'Here is a solution' => 'Une solution possible', + 'The local configuration file could not be created. Create a ' . + 'lib/config.local.php file and give the write ' . + 'right to the web server (preferred solution), or give the ' . + 'write right to the web server on the lib ' . + 'directory.' => 'Le fichier de configuration local ne peut être créé. Creez le fichier lib/config.local.php et donnez lui les droits d\'écriture par le serveur web (solution préférable) ou bien donnez les accès en écriture au dossier lib', + 'The local configuration is not writable by the web server. ' . + 'Give the write right to the web server on the ' . + 'lib/config.local.php file.' => 'Le fichier de configuration local ne peut être écrit. Donnez les droits d\'écriture au fichier lib/config.local.php par le serveur web.', + 'Installation of Jirafeau' => 'Installation de Jirafeau', + 'step' => 'étape', + 'out of' => 'sur', + 'Administration password' => 'Mot de passe d\'administration', + 'Clean unused blocks' => 'Nettoie les bloques inutilisés', + 'Finalisation' => 'Finalisation', + 'Jirafeau is setting the website according to the configuration you provided.' => 'Jirafeau se configure selon les paramêtres donnés', + 'Previous step' => 'Etape précedente', + 'Retry this step' => 'Ressayer cette étape', + 'Jirafeau is now fully operational' => 'Jirafeau est maintenant utilisable', + 'Information' => 'Information', + 'The base address of Jirafeau is the first part of the URL, until (and including) the last slash. For example: "http://www.example.com/". Do not forget the ending slash!' + => 'L\'adresse d\'origine de Jirafeau est la première partie de l\'URL (slash de fin inclue). Par exemple: "http://www.exemple.com/". N\'oubliez pas le slash de fin !', + 'Base address' => 'Addresse d\'origine', + 'The data directory is where your files and information about your files will be stored. You should put it outside your web site, or at least restrict the access of this directory. Do not forget the ending slash!' + => 'Le dossier "data" est là où seront stoqués les fichiers ainsi que leurs informations. Ce dossier ne devrait pas être accessible directement par l\'utilisateur. N\'oubliez pas le slash de fin !', + 'Data directory' => 'Dossier de stockage des données', + 'Jirafeau is internationalised. Choose a specific langage or choose Automatic (langage is provided by user\'s browser).' + => 'Jirafeau supporte plusieurs languages. Choisissez un langage spécific ou Automatic (la langue utilisée est alors fournie par le navigateur du visiteur).', + 'Choose the default language' => 'Choisissez la langue par defaut', + 'Next step' => 'Etape suivante', + 'Jirafeau has an administration interface (through admin.php). ' . + 'You can set a password to access the intercace or let it be empty ' . + 'to disable the interface.' => 'Jirafeau a une interface d\'administration (accessible via admin.php). Vous pouvez saisir un mot de passe pour y acceder ou ne pas en mettre pour désactiver l\'accès à l\'interface.', + 'Administration password' => 'Mot de passe d\'administration', + /* admin.php */ + 'Sorry, the admin interface is not enabled.' => 'Désolé, l\'interface d\'administration n\'est pas activée.', + 'Login' => 'Connexion', + 'Wrong password.' => 'Mot de passe invalide.', + 'Admin interface' => 'Interface d\'administration', + 'Clean expired files' => 'Nettoyer les fichiers périmés', + 'Clean old unfinished transferts' => 'Nettoyer les anciens transferts inachevés', + 'Clean' => 'Nettoyage', + 'Search files by name' => 'Rechercher les fichiers par leur nom', + 'Search' => 'Rechercher', + 'List all files' => 'Lister tous les fichiers', + 'List' => 'Lister', + 'Actions' => 'Actions', + 'Search files by file hash' => 'Rechercher par empreinte de fichier', + 'Search a specific link' => 'Rechercher un lien particulier', + 'Number of cleaned files' => 'Nombre de fichiers nettoyés', + 'Logout' => 'Déconnexion', + 'You are now Logout' => 'Vous êtes maintenant déconnecté', + 'Link deleted' => 'Lien supprimé', + 'Filename' => 'Nom', + 'file' => 'fichier', + 'link' => 'lien', + 'Type' => 'Type', + 'Size' => 'Taille', + 'Expire' => 'Expiration', + 'Onetime' => 'Une fois', + 'Upload date' => 'Date d\'envoie', + 'Origin' => 'Origine', + 'Action' => 'Action', + 'Del link' => 'Supprimer le lien', + 'Del file and links' => 'Supprimer fichier et liens', + 'Deleted links' => 'Liens supprimés', + /* script.php */ + 'Welcome to Jirafeau\'s query interface' => 'Bienvenue sur l\'interface programmable de Jirafeau', + 'This interface permits to script your uploads and downloads.' => 'Cette interface permet de programmer vos envoie et téléversements.', + 'The instructions above show how to query this interface.' => 'Les instructions ci-dessous montrent comment interroger cette interface.', + 'Get server capacity' => 'Récupérer la capacité d\'envoie du serveur', + 'Get Jirafeau\'s version' => 'Récupérer la version de Jirafeau', + 'Send a GET query to' => 'Envoyez une requette GET à', + 'Send a POST query to' => 'Envoyez une requette POST à', + 'Upload a file' => 'Envoyer un fichier', + 'Get a file' => 'Récupérer un ficher', + 'Required' => 'Requis', + 'Optional' => 'Optionel', + 'Parameters' => 'Paramètres', + 'This will return brut text content.' => 'Retourne un texte brut.', + 'First line is the download reference and the second line the delete code.' => 'La première ligne correspond à la reference de l\'envoie et la seconde ligne correspond au code de suppréssion.', + 'First line is the server capacity (in Bytes).' => 'La première ligne correspond à la capacité du serveur (en octets).', + 'Example' => 'Exemple', + 'If a password has been set, send a POST request with it.' => 'Si un mot de passe a été définis, envoyer une requette POST avec.', + 'Delete a file' => 'Supprimer un fichier', + 'This will return "Ok" if succeded, "Error" otherwhise.' => 'Retourne "OK" en cas de succès, "Error" dans le cas contraire.', + 'Get a generated scripts' => 'Récupérer un script généré', + 'This will return brut text content of the code.' => 'Renvoie le code sous forme the texte brut.', + 'Initalize a asynchronous transfert' => 'Initialiser un transfert asynchrone', + 'The goal is to permit to transfert big file, chunk by chunk.' => 'Le but est de permettre de transférer de gros fichiers, morceaux par morceaux.', + 'Chunks of data must be sent in order.' => 'Chaque morceau doit être envoyé dans l\'ordre.', + 'First line is the asynchronous transfert reference and the second line the code to use in the next operation.' + => 'La première ligne correspond à la référence de transfert asynchrone, la seconde au code à utiliser dans la prochaine requette.', + 'Push data during asynchronous transfert' => 'Envoyer des données pendant un transfert asynchrone', + 'Returns the next code to use.' => 'Renvoie le prochain code à utiliser.', + 'Finalize asynchronous transfert' => 'Finaliser un transfert asynchrone', + 'Create a data block' => 'Creer un bloque de données', + 'This interface permits to create a block of data filled with zeros.' => 'Cette interface permet de creer un bloque de données remplies de zeros.', + 'You can read selected parts, write (using a code) and delete the block.' => 'Vous pouvez lire, écrire (en utilisant un code) et supprimer le bloque.', + 'Blocks may be removed after a month of non usage.' => 'Les bloques non utilisés depuis plus d\'un mois seront probablement supprimés.', + 'Get block size' => 'Récupérer la taille d\'un bloque', + 'Read data in a block' => 'Lire des données dans un bloque', + 'Write data in a block' => 'Ecrire des données dans un bloque', + 'First line is a block id the second line the edit/delete code.' => 'La premiere ligne est l\'identifiant du bloque, la seconde est son code d\'écriture/suppression.', + 'This will return asked data or "Error" string.' => 'Retourne les données ou la chaine "Error".', + 'Delete a block' => 'Supprimer un bloque', + 'This will return "Ok" or "Error" string.' => 'Retourn la chaine "Ok" ou "Error".', + ); + ?> diff --git a/sources/lib/settings.php b/sources/lib/settings.php new file mode 100644 index 0000000..133113d --- /dev/null +++ b/sources/lib/settings.php @@ -0,0 +1,40 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Jirafeau constants */ +define ('JIRAFEAU_PACKAGE', 'Jirafeau'); +define ('JIRAFEAU_VERSION', '1.0'); + +/* Directories. */ +define ('VAR_FILES', $cfg['var_root'] . 'files/'); +define ('VAR_LINKS', $cfg['var_root'] . 'links/'); +define ('VAR_ASYNC', $cfg['var_root'] . 'async/'); +define ('VAR_BLOCK', $cfg['var_root'] . 'block/'); + +/* Useful constants. */ +if (!defined ('NL')) + define ('NL', "\n"); + +define ('JIRAFEAU_INFINITY', -1); +define ('JIRAFEAU_MINUTE', 60); // 60 +define ('JIRAFEAU_HOUR', 3600); // JIRAFEAU_MINUTE * 60 +define ('JIRAFEAU_DAY', 86400); // JIRAFEAU_HOUR * 24 +define ('JIRAFEAU_WEEK', 604800); // JIRAFEAU_DAY * 7 +define ('JIRAFEAU_MONTH', 2419200); // JIRAFEAU_WEEK * 4 + +?> diff --git a/sources/lib/template/footer.php b/sources/lib/template/footer.php new file mode 100644 index 0000000..a72decf --- /dev/null +++ b/sources/lib/template/footer.php @@ -0,0 +1,9 @@ + + + +
+
+ + diff --git a/sources/lib/template/header.php b/sources/lib/template/header.php new file mode 100644 index 0000000..264cf34 --- /dev/null +++ b/sources/lib/template/header.php @@ -0,0 +1,34 @@ + + + + + <?php echo t('Jirafeau, your web file repository'); ?> + + + + + +
+

diff --git a/sources/media/default/error.png b/sources/media/default/error.png new file mode 100644 index 0000000..4990130 Binary files /dev/null and b/sources/media/default/error.png differ diff --git a/sources/media/default/jirafeau.png b/sources/media/default/jirafeau.png new file mode 100644 index 0000000..e141069 Binary files /dev/null and b/sources/media/default/jirafeau.png differ diff --git a/sources/media/default/ok.png b/sources/media/default/ok.png new file mode 100644 index 0000000..c1ce846 Binary files /dev/null and b/sources/media/default/ok.png differ diff --git a/sources/media/default/style.css.php b/sources/media/default/style.css.php new file mode 100644 index 0000000..dbe946e --- /dev/null +++ b/sources/media/default/style.css.php @@ -0,0 +1,178 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* + * This stylesheet is the default stylesheet for Jirafeau. + * The content is dynamically generated for easier handling. + */ + +$dark = '#8B4513'; + +header("Content-type: text/css"); + +?> + +body { + text-align: center; + font-family: sans-serif; + width: 60em; + margin: 2ex auto; + border: 5px solid; +} + +h1 a { + text-decoration: none; + color: black; + border-bottom: 1px dotted; +} + +#content { + padding: 0 4em; + background: url('jirafeau.png') left top repeat-y; +} + +#upload { + width: 25em; + margin: 5ex auto; +} + +#upload table { + width: 100%; +} + +#upload .config { + font-size: smaller; +} + +#upload .info { + text-align: left; + font-size: smaller; + border-bottom: 1px dashed; +} + +#upload .more { + cursor: pointer; +} + +#upload .more:after { + content: ' ▼'; +} + +#upload .activation { + text-align: left; + font-style: italic; +} + +#upload .label { + text-align: left; + vertical-align: top; + font-size: smaller; +} + +#upload .field { + text-align: right; + vertical-align: bottom; +} + +#upload p { + margin: 0.8ex 0; +} + +#moreoptions p { + text-align: left; +} + +#copyright { + font-size: smaller; +} + +.error, .message { + width: 50em; + margin: 5ex auto; +} + +.error { + padding-bottom: 1ex; + border: red 2px solid; + background-color: #FBB; +} + +.error p:before { + content: url('error.png'); + padding-right: 1ex; +} + +.message { + padding: 1ex; + border: green 2px solid; + background-color: #BFB; +} + +.message p:before { + content: url('ok.png'); + padding-right: 1ex; +} + +#install { + width: 40em; + margin: 5ex auto; +} + +#install table { + width: 100%; +} + +#install label { + font-style: italic; +} + +#install .info { + text-align: justify; + padding-bottom: 1ex; +} + +#install .label { + text-align: justify; + vertical-align: top; +} + +#install .field { + text-align: right; + vertical-align: bottom; +} + +#install .nav { + padding-top: 2em; +} + +#install .next { + text-align: right; +} + +#install .previous { + text-align: left; +} + +#install .navright { + float: right; +} + +#install .navleft { + float: left; +} diff --git a/sources/media/industrial/bandeau.png b/sources/media/industrial/bandeau.png new file mode 100755 index 0000000..970ad95 Binary files /dev/null and b/sources/media/industrial/bandeau.png differ diff --git a/sources/media/industrial/error.png b/sources/media/industrial/error.png new file mode 100755 index 0000000..4990130 Binary files /dev/null and b/sources/media/industrial/error.png differ diff --git a/sources/media/industrial/jyraphe.png b/sources/media/industrial/jyraphe.png new file mode 100755 index 0000000..066e9de Binary files /dev/null and b/sources/media/industrial/jyraphe.png differ diff --git a/sources/media/industrial/ok.png b/sources/media/industrial/ok.png new file mode 100755 index 0000000..c1ce846 Binary files /dev/null and b/sources/media/industrial/ok.png differ diff --git a/sources/media/industrial/style.css.php b/sources/media/industrial/style.css.php new file mode 100755 index 0000000..2474b11 --- /dev/null +++ b/sources/media/industrial/style.css.php @@ -0,0 +1,183 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* + * This stylesheet is the default stylesheet for Jyraphe. + * The content is dynamically generated for easier handling. + */ + +$dark = '#8B4513'; + +header("Content-type: text/css"); + +?> + +body { + font-family: sans-serif; + text-align: center; + margin: 2ex auto; + background: white; + /* border: 5px solid; */ +} + +fieldset { + text-align: left; + width: 40em; + margin: auto; + background: #E2f5ff; + border: 2px solid #02233f; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + +fieldset legend { + color: white; + background: #02233f; + border: 2px solid #02233f; + padding: 1px 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +h1 { + width: 100%; + text-align: center; + background: url('bandeau.png') left top repeat-x; + height: 70px; + padding-top: 30px; +} + +h1 a { + text-decoration: none; + color: white; +} + +fieldset p { + margin-left: 25%; +} + +.jyraphe_info { + font-size: small; + margin-left: 30%; +} + +label { + float: left; + width: 12em; +} + +input[type=text], input[type=submit], select { + color: black; + width: 15em; + border: 1px #02233f solid; + background: white; +} + +input:hover { + color: white; + background: #02233f; +} + +#jyraphe { + background: url('jyraphe.png') right bottom no-repeat; + position: fixed; + bottom: 0; + right: 0; + height: 100px; + width: 100px; + clear:both; +} + +#copyright { + text-align: center; +} + +.error, .message { + width: 50em; + margin: 5ex auto; +} + +.error { + padding-bottom: 1ex; + border: red 2px solid; + background-color: #FBB; +} + +.error p:before { + content: url('error.png'); + padding-right: 1ex; +} + +.message { + padding: 1ex; + border: green 2px solid; + background-color: #BFB; +} + +.message p:before { + content: url('ok.png'); + padding-right: 1ex; +} + +.info { + text-align: left; + width: 40em; + margin: auto; + background: #E2f5ff; + border: 2px solid #02233f; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + +.info h2 { + text-align: center; +} + +.info h3 { + text-align: center; +} + +.info p { + margin-left: 5%; + margin-right: 5%; +} + +#upload { + text-align: center; + width: 30em; + background: #E2f5ff; + border: 2px solid #02233f; + margin: auto; +} + +#uploading { + text-align: center; + width: 30em; + background: #E2f5ff; + border: 2px solid #02233f; + margin: auto; +} + +#upload_finished { + text-align: center; + width: 60em; + background: #E2f5ff; + border: 2px solid #02233f; + margin: auto; +} diff --git a/sources/media/modern/bandeau.png b/sources/media/modern/bandeau.png new file mode 100755 index 0000000..970ad95 Binary files /dev/null and b/sources/media/modern/bandeau.png differ diff --git a/sources/media/modern/error.png b/sources/media/modern/error.png new file mode 100755 index 0000000..20d6f5e Binary files /dev/null and b/sources/media/modern/error.png differ diff --git a/sources/media/modern/jyraphe.png b/sources/media/modern/jyraphe.png new file mode 100755 index 0000000..a9f2019 Binary files /dev/null and b/sources/media/modern/jyraphe.png differ diff --git a/sources/media/modern/ok.png b/sources/media/modern/ok.png new file mode 100755 index 0000000..46c0a29 Binary files /dev/null and b/sources/media/modern/ok.png differ diff --git a/sources/media/modern/style.css.php b/sources/media/modern/style.css.php new file mode 100755 index 0000000..fa992e0 --- /dev/null +++ b/sources/media/modern/style.css.php @@ -0,0 +1,216 @@ + + * Jimmy Beauvois + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* + * This stylesheet is the default stylesheet for Jyraphe. + * The content is dynamically generated for easier handling. + */ + +$dark = '#8B4513'; + +header("Content-type: text/css"); + +?> + +body { +font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif; +font-size: 100%; +color:#333333; +margin:0; +background:#e5e5e5; +} + +a, a:link, a:visited { + color: #223344; + text-decoration: underlined; +} + +fieldset { + text-align: left; + font-size:90%; + width: 50em; + margin: auto; + background: white; + border: 2px solid #dbdbdb; +-webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +fieldset legend { + + color: white; + font-size:130%; + background: #cf3b19; + border: 1px solid #A52E13; + padding: 5px 20px; +-webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +h1 { + + font-size: 175%; + width: 100%; + text-align: center; + height: 50px; + padding-top: 30px; +} + +h1 a { + text-decoration: none; + color: #333; +} + +fieldset p { + margin-left: 25%; +} + +.jyraphe_info { + font-size: 120%; + margin-left: 30%; +} + +label { + float: left; + width: 12em; +} + +input[type=text], input[type=submit], select { + width: 15em; + font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif; + +} + + +#jyraphe { + background: url('jyraphe.png') right bottom no-repeat; + position: fixed; + bottom: 0; + right: 0; + height: 50px; + width: 50px; + clear:both; +} + +#copyright { + text-align: center; + font-size: 70%; + +} + +.error, .message { + width: 50em; + margin: 5ex auto; +} + +.error { +text-align: center; + padding-bottom: 1ex; + border: #FB7373 2px solid; + background-color: #FBB; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.error p:before { +text-align: center; + content: url('error.png'); + padding-right: 1ex; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.message { +text-align: center; + padding: 1ex; + border: #91C27C 2px solid; + background-color: #BFB; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +.message p:before { + content: url('ok.png'); + padding-right: 1ex; +} + +.info { + text-align: left; + width: 50em; + margin: auto; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +.info h2 { + text-align: left; +} + +.info h3 { + text-align: center; +} + +.info p { + margin-left: 5%; + margin-right: 5%; +} + +#upload { + text-align: left; + font-size: 90%; + width: 50em; + background: #e5e5e5; + border: 0px solid #CCCCCC; + margin: auto; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +#uploading { + text-align: center; + width: 50em; + background: white; + border: 2px solid #CCCCCC; + margin: auto; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} + +#upload_finished { +font-size:90%; + text-align: center; + padding-top: 20px; + padding-bottom: 20px; + width: 50em; + background: #B6D7A8; + border: 2px solid #91C27C; + margin: auto; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; +} diff --git a/sources/script.php b/sources/script.php new file mode 100755 index 0000000..19f14a8 --- /dev/null +++ b/sources/script.php @@ -0,0 +1,658 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* + * This file permits to easyly script file sending, receiving, deleting, ... + * If you don't want this feature, you can simply delete this file from your + * web directory. + */ + +define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); + +require (JIRAFEAU_ROOT . 'lib/config.original.php'); +require (JIRAFEAU_ROOT . 'lib/settings.php'); +require (JIRAFEAU_ROOT . 'lib/functions.php'); +require (JIRAFEAU_ROOT . 'lib/lang.php'); + + global $script_langages; + $script_langages = array ('bash' => 'Bash'); + +/* Operations may take a long time. + * Be sure PHP's safe mode is off. + */ +@set_time_limit(0); +/* Remove errors. */ +@error_reporting(0); + +if ($_SERVER['REQUEST_METHOD'] == "GET" && count ($_GET) == 0) +{ + require (JIRAFEAU_ROOT . 'lib/template/header.php'); + check_errors (); + if (has_error ()) + { + show_errors (); + require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; + } + echo '
'; + echo '

' . t('Welcome to Jirafeau\'s query interface') . '

'; + echo '

'; + echo t('This interface permits to script your uploads and downloads.') . + ' ' . t('The instructions above show how to query this interface.'); + echo '

'; + + echo '

' . t('Get Jirafeau\'s version') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "get_version=1 (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('First line is the version number.') . '

'; + echo '

'; + echo t('Example') . ": " . $web_root . "script.php?get_version=1 "; + echo '

'; + + echo '

' . t('Get server capacity') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "get_capacity=1 (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('First line is the server capacity (in Bytes).') . '

'; + echo '

'; + echo t('Example') . ": " . $web_root . "script.php?get_capacity=1 "; + echo '

'; + + echo '

' . t('Upload a file') . ':

'; + echo '

'; + echo t('Send a POST query to') . ': ' . $web_root . 'script.php
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "file=C:\\your\\file\\path (" . t('Required') . ")
"; + echo "time=[minute|hour|day|week|month|none] (" . t('Optional') . ', '. t('default: none') . ")
"; + echo "password=your_password (" . t('Optional') . ")
"; + echo "one_time_download=1 (" . t('Optional') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('First line is the download reference and the second line the delete code.') . '

'; + + echo '

' . t('Get a file') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "h=your_download_reference (" . t('Required') . ")
"; + echo '

'; + echo '

'; + echo t('If a password has been set, send a POST request with it.'); + echo '
'; + echo t('Parameters') . ':
'; + echo "password=your_password (" . t('Optional') . ")
"; + echo '

'; + echo '

'; + echo t('Example') . ": " . $web_root . "script.php?h=30ngy0hsDcpfrF8zR7x9iU "; + echo '

'; + + echo '

' . t('Delete a file') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "h=your_download_reference (" . t('Required') . ")
"; + echo "d=yout_delete_code (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return "Ok" if succeded, "Error" otherwhise.') . '

'; + echo '

'; + echo t('Example') . ": " . $web_root . "script.php?h=30ngy0hsDcpfrF8zR7x9iU&d=0d210a952 "; + echo '

'; + + echo '

' . t('Get a generated scripts') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "lang=["; + foreach ($script_langages as $lang => $name) + echo $lang; + echo "] (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content of the code.') . '

'; + echo '

'; + echo t('Example') . ":
"; + foreach ($script_langages as $lang => $name) + echo "$name: " . $web_root . "script.php?lang=$lang "; + echo '

'; + + echo '

' . t('Initalize a asynchronous transfert') . ':

'; + echo '

'; + echo t('The goal is to permit to transfert big file, chunk by chunk.') . ' '; + echo t('Chunks of data must be sent in order.'); + echo '

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?init_async
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "filename=file_name.ext (" . t('Required') . ")
"; + echo "type=MIME_TYPE (" . t('Optional') . ")
"; + echo "time=[minute|hour|day|week|month|none] (" . t('Optional') . ', '. t('default: none') . ")
"; + echo "password=your_password (" . t('Optional') . ")
"; + echo "one_time_download=1 (" . t('Optional') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('First line is the asynchronous transfert reference and the second line the code to use in the next operation.') . '

'; + + echo '

' . t('Push data during asynchronous transfert') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?push_async
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "ref=async_reference (" . t('Required') . ")
"; + echo "data=data_chunk (" . t('Required') . ")
"; + echo "code=last_provided_code (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('Returns the next code to use.') . '

'; + + echo '

' . t('Finalize asynchronous transfert') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?end_async
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "ref=async_reference (" . t('Required') . ")
"; + echo "code=last_provided_code (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('First line is the download reference and the second line the delete code.') . '

'; + + if ($cfg['enable_blocks']) + { + echo '

' . t('Create a data block') . ':

'; + echo '

'; + echo t('This interface permits to create a block of data filled with zeros.') . + ' ' . t('You can read selected parts, write (using a code) and delete the block.') . + ' ' . t('Blocks may be removed after a month of non usage.'); + echo '

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?init_block
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "size=size_in_bytes (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return brut text content.') . ' ' . + t('First line is a block id the second line the edit/delete code.') . '

'; + + echo '

' . t('Get block size') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?get_block_size
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "id=block_id (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return asked data or "Error" string.') . '

'; + + echo '

' . t('Read data in a block') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?read_block
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "id=block_id (" . t('Required') . ")
"; + echo "start=byte_position_starting_from_zero (" . t('Required') . ")
"; + echo "length=length_to_read_in_bytes (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return asked data or "Error" string.') . '

'; + + echo '

' . t('Write data in a block') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?write_block
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "id=block_id (" . t('Required') . ")
"; + echo "code=block_code (" . t('Required') . ")
"; + echo "start=byte_position_starting_from_zero (" . t('Required') . ")
"; + echo "data=data_to_write (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return "Ok" or "Error" string.') . '

'; + + echo '

' . t('Delete a block') . ':

'; + echo '

'; + echo t('Send a GET query to') . ': ' . $web_root . 'script.php?delete_block
'; + echo '
'; + echo t('Parameters') . ':
'; + echo "id=block_id (" . t('Required') . ")
"; + echo "code=block_code (" . t('Required') . ")
"; + echo '

'; + echo '

' . t('This will return "Ok" or "Error" string.') . '

'; + } + + echo '

'; + require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + exit; +} + +/* Lets use interface now. */ +header('Content-Type: text; charset=utf-8'); + +check_errors (); +if (has_error ()) +{ + echo "Error"; + exit; +} + +/* Upload file */ +if (isset ($_FILES['file']) && is_writable (VAR_FILES) + && is_writable (VAR_LINKS)) +{ + if (strlen ($cfg['upload_password']) > 0 && (!isset ($_POST['upload_password']) || $_POST['upload_password'] != $cfg['upload_password'])) + { + echo "Error"; + exit; + } + + $key = ''; + if (isset ($_POST['key'])) + $key = $_POST['key']; + + $time = time (); + if (!isset ($_POST['time'])) + $time = JIRAFEAU_INFINITY; + else + switch ($_POST['time']) + { + case 'minute': + $time += JIRAFEAU_MINUTE; + break; + case 'hour': + $time += JIRAFEAU_HOUR; + break; + case 'day': + $time += JIRAFEAU_DAY; + break; + case 'week': + $time += JIRAFEAU_WEEK; + break; + case 'month': + $time += JIRAFEAU_MONTH; + break; + default: + $time = JIRAFEAU_INFINITY; + break; + } + $res = jirafeau_upload ($_FILES['file'], + isset ($_POST['one_time_download']), + $key, $time, $_SERVER['REMOTE_ADDR'], + $cfg['enable_crypt'], $cfg['link_name_lenght']); + + if (empty($res) || $res['error']['has_error']) + { + echo "Error"; + exit; + } + /* Print direct link. */ + echo $res['link']; + /* Print delete link. */ + echo NL; + echo $res['delete_link']; + /* Print decrypt key. */ + echo NL; + echo urlencode($res['crypt_key']); +} +elseif (isset ($_GET['h'])) +{ + $link_name = $_GET['h']; + $key = ''; + if (isset ($_POST['key'])) + $key = $_POST['key']; + $d = ''; + if (isset ($_GET['d'])) + $d = $_GET['d']; + + if (!preg_match ('/[0-9a-zA-Z_-]+$/', $link_name)) + { + echo "Error"; + exit; + } + + $link = jirafeau_get_link ($link_name); + if (count ($link) == 0) + { + echo "Error"; + exit; + } + if (strlen ($d) > 0 && $d == $link['link_code']) + { + jirafeau_delete_link ($link_name); + echo "Ok"; + exit; + } + if ($link['time'] != JIRAFEAU_INFINITY && time () > $link['time']) + { + jirafeau_delete_link ($link_name); + echo "Error"; + exit; + } + if (strlen ($link['key']) > 0 && md5 ($key) != $link['key']) + { + echo "Error"; + exit; + } + $p = s2p ($link['md5']); + if (!file_exists (VAR_FILES . $p . $link['md5'])) + { + echo "Error"; + exit; + } + + /* Read file. */ + header ('Content-Length: ' . $link['file_size']); + header ('Content-Type: ' . $link['mime_type']); + header ('Content-Disposition: attachment; filename="' . + $link['file_name'] . '"'); + + $r = fopen (VAR_FILES . $p . $link['md5'], 'r'); + while (!feof ($r)) + { + print fread ($r, 1024); + ob_flush(); + } + fclose ($r); + + if ($link['onetime'] == 'O') + jirafeau_delete_link ($link_name); + exit; +} +elseif (isset ($_GET['get_capacity'])) +{ + echo min (jirafeau_ini_to_bytes (ini_get ('post_max_size')), + jirafeau_ini_to_bytes (ini_get ('upload_max_filesize'))); +} +elseif (isset ($_GET['get_version'])) +{ + echo JIRAFEAU_VERSION; +} +elseif (isset ($_GET['lang'])) +{ + $l=$_GET['lang']; + if ($l == "bash") + { +?> +#!/bin/bash + +# This script has been auto-generated by Jirafeau but you can still edit +# options below. + +# Config +proxy='' # ex: proxy='proxysever.test.com:3128' or set JIRAFEAU_PROXY global variable +url='' # or set JIRAFEAU_URL ex: url='http://mysite/jirafeau/script.php' +time='none' # minute, hour, day, week, month or none. Or set JIRAFEAU_TIME. +one_time='' # ex: one_time="1" or set JIRAFEAU_ONE_TIME. +curl='' # curl path to download or set JIRAFEAU_CURL_PATH. +# End of config + +if [ -n "$JIRAFEAU_PROXY" ]; then + proxy="$JIRAFEAU_PROXY" +fi + +if [ -n "$JIRAFEAU_URL" ]; then + url="$JIRAFEAU_URL" +fi + +if [ -z "$url" ]; then + echo "Please set url in script parameters or export JIRAFEAU_URL" +fi + +if [ -n "$JIRAFEAU_TIME" ]; then + time="$JIRAFEAU_TIME" +fi + +if [ -n "$JIRAFEAU_ONE_TIME" ]; then + one_time='1' +fi + +if [ -z "$curl" ]; then + curl="$JIRAFEAU_CURL_PATH" +fi + +if [ -z "$curl" ] && [ -e "/usr/bin/curl" ]; then + curl="/usr/bin/curl" +fi + +if [ -z "$curl" ] && [ -e "/bin/curl.exe" ]; then + curl="/bin/curl.exe" +fi + +if [ -z "$curl" ]; then + echo "Please set your curl binary path (by editing this script or export JIRAFEAU_CURL_PATH global variable)." + exit +fi + +if [ -z "$2" ]; then + echo "man:" + echo " $0 send PATH [PASSWORD]" + echo " $0 get URL [PASSWORD]" + echo " $0 delete URL" + echo "" + echo "Global variables to export:" + echo " JIRAFEAU_PROXY : example: proxysever.test.com:3128" + echo " JIRAFEAU_URL : example: http://mysite/jirafeau/script.php" + echo " JIRAFEAU_TIME : minute, hour, day, week, month or none" + echo " JIRAFEAU_ONE_TIME : set anything or set empty" + echo " JIRAFEAU_CURL : path to your curl binary" + + exit 0 +fi + +if [ -n "$proxy" ]; then + proxy="-x $proxy" +fi + +options='' +if [ -n "$one_time" ]; then + options="$options -F one_time_download=1" +fi + +password='' +if [ -n "$3" ]; then + password="$3" + options="$options -F key=$password" +fi + +if [ "$1" == "send" ]; then + if [ ! -f "$2" ]; then + echo "File \"$2\" does not exists." + exit + fi + + # Ret result + res=$($curl -X POST --http1.0 $proxy $options \ + -F "time=$time" \ + -F "file=@$2" \ + $url) + + if [[ "$res" == "Error" ]]; then + echo "Error while uploading." + exit + fi + + # Not using head or tail to minimise command dependencies + code=$(cnt=0; echo "$res" | while read l; do + if [[ "$cnt" == "0" ]]; then + echo "$l" + fi + cnt=$(( cnt + 1 )) + done) + del_code=$(cnt=0; echo "$res" | while read l; do + if [[ "$cnt" == "1" ]]; then + echo "$l" + fi + cnt=$(( cnt + 1 )) + done) + echo "${url}?h=$code" + echo "${url}?h=$code&d=$del_code" +elif [ "$1" == "get" ]; then + if [ -z "$password" ]; then + $curl $proxy -OJ "$2" + else + $curl $proxy -OJ -X POST -F key=$password "$2" + fi +elif [ "$1" == "delete" ]; then + $curl $proxy "$2" +fi + 0 && (!isset ($_POST['upload_password']) || $_POST['upload_password'] != $cfg['upload_password'])) + { + echo "Error"; + exit; + } + + if (!isset ($_POST['filename'])) + { + echo "Error"; + exit; + } + + $type = ''; + if (isset ($_POST['type'])) + $type = $_POST['type']; + + $key = ''; + if (isset ($_POST['password'])) + $key = $_POST['password']; + + $time = time (); + if (!isset ($_POST['time'])) + $time = JIRAFEAU_INFINITY; + else + switch ($_POST['time']) + { + case 'minute': + $time += JIRAFEAU_MINUTE; + break; + case 'hour': + $time += JIRAFEAU_HOUR; + break; + case 'day': + $time += JIRAFEAU_DAY; + break; + case 'week': + $time += JIRAFEAU_WEEK; + break; + case 'month': + $time += JIRAFEAU_MONTH; + break; + default: + $time = JIRAFEAU_INFINITY; + break; + } + echo jirafeau_async_init ($_POST['filename'], + $type, + isset ($_POST['one_time_download']), + $key, + $time, + $_SERVER['REMOTE_ADDR']); +} +/* Continue an asynchronous upload. */ +elseif (isset ($_GET['push_async'])) +{ + if ((!isset ($_POST['ref'])) + || (!isset ($_FILES['data'])) + || (!isset ($_POST['code']))) + echo "Error"; + else + echo jirafeau_async_push ($_POST['ref'], $_FILES['data'], $_POST['code']); +} +/* Finalize an asynchronous upload. */ +elseif (isset ($_GET['end_async'])) +{ + if (!isset ($_POST['ref']) + || !isset ($_POST['code'])) + echo "Error"; + else + echo jirafeau_async_end ($_POST['ref'], $_POST['code'], $cfg['enable_crypt'], $cfg['link_name_lenght']); +} +/* Initialize block. */ +elseif (isset ($_GET['init_block']) && $cfg['enable_blocks']) +{ + if (strlen ($cfg['upload_password']) > 0 && (!isset ($_POST['upload_password']) || $_POST['upload_password'] != $cfg['upload_password'])) + { + echo "Error"; + exit; + } + + if (!isset ($_POST['size'])) + echo "Error"; + else + echo jirafeau_block_init ($_POST['size']); +} +/* Get block size. */ +elseif (isset ($_GET['get_block_size']) && $cfg['enable_blocks']) +{ + if (!isset ($_POST['id'])) + echo "Error"; + else + echo jirafeau_block_get_size ($_POST['id']); +} +/* Read data in block. */ +elseif (isset ($_GET['read_block']) && $cfg['enable_blocks']) +{ + if (!isset ($_POST['id']) + || !isset ($_POST['start']) + || !isset ($_POST['length'])) + echo "Error"; + else + jirafeau_block_read ($_POST['id'], $_POST['start'], $_POST['length']); +} +/* Write data in block. */ +elseif (isset ($_GET['write_block']) && $cfg['enable_blocks']) +{ + if (!isset ($_POST['id']) + || !isset ($_POST['start']) + || !isset ($_FILES['data']) + || !isset ($_POST['code'])) + echo "Error"; + else + echo jirafeau_block_write ($_POST['id'], $_POST['start'], $_FILES['data'], $_POST['code']); +} +/* Delete block. */ +elseif (isset ($_GET['delete_block']) && $cfg['enable_blocks']) +{ + if (!isset ($_POST['id']) + || !isset ($_POST['code'])) + echo "Error"; + else + echo jirafeau_block_delete ($_POST['id'], $_POST['code']); +} +else + echo "Error"; +exit; +?> diff --git a/sources/tos.php b/sources/tos.php new file mode 100755 index 0000000..d84704d --- /dev/null +++ b/sources/tos.php @@ -0,0 +1,26 @@ +Terms of Service'; +echo '
'; +echo ''; +echo '

This license text is under Creative Commons - Attribution 3.0 Unported.

It has been based on this work: http://opensource.org/ToS

'; +echo '
'; +require (JIRAFEAU_ROOT . 'lib/template/footer.php'); +?> diff --git a/sources/tos_text.php b/sources/tos_text.php new file mode 100755 index 0000000..818d00b --- /dev/null +++ b/sources/tos_text.php @@ -0,0 +1,63 @@ +http://opensource.org/ToS + */ +$tos=" +TERMS OF SERVICE + +1. ACCEPTANCE OF TERMS +$org provides the information on this Web site as provided in these Terms of Service (\"TOS\"). $org may update the TOS at any time and without prior notice by posting a new version at $url. The information on this site and your use of it is subject to the most recent version of the TOS posted. + +2. DESCRIPTION OF SERVICE +$org provides you an upload service and a variety of other services. (\"$org Service\"). Unless explicitly stated otherwise, any new features that augment or enhance the current $org Service shall be subject to the TOS. + +3. CONDUCT +You understand that all information, data, text, software, graphics or other materials (\"Content\"), whether publicly posted or privately transmitted, are the sole responsibility of the person from whom such Content originated. This means that you, and not $org, are entirely responsible for all Content that you upload, post, email, transmit or otherwise make available via the $org Service. $org does not control the Content posted via the $org Service and, as such, does not guarantee the accuracy, integrity or quality of such Content. Under no circumstances will $org be liable in any way for any Content, including, but not limited to, any errors or omissions in any Content, or any loss or damage of any kind incurred as a result of the use of any Content posted, emailed, transmitted or otherwise made available via the $org Service. You agree to not use the $org Service to: + 1) upload, post, email, transmit or otherwise make available any Content that is unlawful, harmful, threatening, abusive, harassing, tortuous, defamatory, vulgar, obscene, libelous, invasive of another's privacy, hateful, or racially, ethnically or otherwise objectionable or harm minors; + 2) impersonate any person or entity or falsely state or otherwise misrepresent your affiliation with a person or entity; + 3) forge headers or otherwise manipulate identifiers in order to disguise the origin of any Content transmitted through the $org Service; + 4) upload, post, email, transmit or otherwise make available any Content that you do not have a right to make available under any law or under contractual or other relationships; + 5) upload, post, email, transmit or otherwise make available any Content that infringes any patent, trademark, trade secret, copyright or other proprietary rights of any party; + 6) upload, post, email, transmit or otherwise make available any unsolicited or unauthorized advertising, promotional materials, \"junk mail,\" \"spam,\" or any other form of solicitation; + 7) upload, post, email, transmit or otherwise make available any material that contains software viruses or any other computer code, files or programs designed to interrupt, destroy or limit the functionality of any computer software or hardware or telecommunications equipment; + 8) disrupt the normal flow of dialogue, or otherwise act in a manner that negatively affects other users' ability to engage in discussions or exchanges; + 9) interfere with or disrupt the $org Service or servers or networks connected to the $org Service, or disobey any requirements, procedures, policies or regulations of networks connected to the $org Service; + 10) intentionally or unintentionally violate any applicable local, state, national or international law, + 11) \"stalk\" or otherwise harass another; and/or + 12) collect or store personal data about other users in connection with the prohibited conduct and activities set forth in paragraphs above. You acknowledge that $org may or may not pre-screen Content, but that $org and its designees shall have the right (but not the obligation) in their sole discretion to pre-screen, refuse, move, or remove any Content that is available via the $org Service and which violates the TOS. You agree that you must evaluate, and bear all risks associated with, the use of any Content, including any reliance on the accuracy, completeness, or usefulness of such Content. You acknowledge, consent and agree that $org may access, preserve and disclose your account information and Content if required to do so by law or in a good faith belief that such access preservation or disclosure is reasonably necessary to: + (a) comply with legal process; + (b) enforce the TOS; + (c) respond to claims that any Content violates the rights of third parties; + (d) respond to your requests for customer service; or (e) protect the rights, property or personal safety of $org its users and the public. + +4. CONTENT MADE AVAILABLE FOR INCLUSION ON THE $org SERVICE +$org does not claim ownership of Content you submit or make available for inclusion via the $org Service. However, with respect to Content you submit or make available for inclusion on the publicly available $org Service, you irrevocably grant $org the perpetual, worldwide, royalty-free and non-exclusive license, with the right to sublicense through multiple tiers of sublicensees, to use, distribute, reproduce, modify, adapt, publicly perform and publicly display such Content, in whole or in part, on the $org Service or other publications by $org in any media whether now existing or which come into the existence into the future and to provide that information under the license set forth on the initial page of the $url Web site. And for Content you submit for private discussions, you grant $org the worldwide, royalty-free and non-exclusive license to use, distribute, reproduce, modify, adapt, publicly perform and publicly display such Content on the associated private discussion group. + +5. INDEMNITY +You agree to indemnify and hold $org and its subsidiaries, affiliates, officers, agents, employees, partners and licensors harmless from any claim or demand, including but not limited to reasonable attorneys' fees, made by any third party due to or arising out of Content you submit, post, transmit or otherwise make available through the Service, your use of the $org Service, your connection to the Service, your violation of the TOS, or your violation of any rights of another. + +6. MODIFICATIONS TO $org SERVICE You acknowledge that $org may establish general practices and limits concerning use of the $org Service, including without limitation the maximum number of days that email messages, message board postings or other uploaded Content will be retained by the $org Service.. You further acknowledge that $org reserves the right to modify these general practices and limits from time to time. $org reserves the right at any time and from time to time to modify or discontinue, temporarily or permanently, the $org Service (or any part thereof) with or without notice. You agree that $org shall not be liable to you or to any third party for any modification, suspension or discontinuance of the $org Service. + +7. TERMINATION +You agree that $org may terminate your access to the $org Service for violations of the TOS and/or requests by authorized law enforcement or other government agencies. + +8. LINKS +The $org Service may provide, or third parties may provide, links to other World Wide Web sites or resources. Because $org has no control over such sites and resources, you acknowledge and agree that $org is not responsible for the availability of such external sites or resources, and does not endorse and is not responsible or liable for any Content, advertising, products or other materials on or available from such sites or resources. You further acknowledge and agree that $org shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such Content, goods or services available on or through any such site or resource. + +9. DISCLAIMER OF WARRANTIES +You expressly understand and agree that: Your use of the $org service is at your sole risk. $org service is provided on an \"as is\" and \"as available\" basis. $org and its subsidiaries, affiliates, officers, employees and licensors expressly disclaim all warranties of any kind, whether express or implied, including, but not limited to the implied warranties of merchantability, fitness for a particular purpose and non-infringement. $org and its subsidiaries, affiliates, officers, employees and licensors make no warranty that +(i) The $org service will meet your requirements; +(ii) The $org service will be uninterrupted, timely, secure or error-free and +(iii) The results that may be obtained from the use of the $org service will be accurate or reliable. No advice or information, whether oral or written, obtained by you from $org or through or from the service shall create any warranty not expressly stated in the TOS. + +10. LIMITATION OF LIABILITY +You expressly understand and agree that $org and its subsidiaries, affiliates, officers, employees, agents, partners and licensors shall not be liable to you for any direct, indirect, incidental, special, consequential or exemplary damages, including, but not limited to, damages for loss of profits, goodwill, use, data or other intangible losses (even if $org has been advised of the possibility of such damages), resulting from the use or the inability to use the $org service. + +11. NOTICE AND PROCEDURE FOR MAKING CLAIMS OF COPYRIGHT INFRINGEMENT +$org respects the copyright of others, and we ask our users to do the same. $org may, in appropriate circumstances and at its discretion, disable and/or terminate the access of users who may be repeat infringers. If you believe that your work has been copied in a way that constitutes copyright infringement, please provide $org's Copyright Agent the following information: an electronic or physical signature of the person authorized to act on behalf of the owner of the copyright; a description of the copyrighted work that you claim has been infringed; a description of where the material that you claim is infringing is located on the site; your address, telephone number, and email address; a statement by you that you have a good faith belief that the disputed use is not authorized by the copyright owner, its agent, or the law; a statement by you, made under penalty of perjury, that the above information in your Notice is accurate and that you are the copyright owner or authorized to act on the copyright owner's behalf. + +$org's Agent for Notice of claims of copyright infringement can be reached as follows: + +$contact +"; +?>