From 70cc149678b00f8fe32463d1dfcb169967c9de44 Mon Sep 17 00:00:00 2001 From: Andre Pawlowski Date: Thu, 11 Jun 2009 19:59:38 +0200 Subject: [PATCH] Commiting Kastalia a secure filesharing application for Horde 3 --- kastalia/COPYING | 280 +++++++++++++++++++ kastalia/LICENSE.ASL | 48 ++++ kastalia/LICENSE.BSDL | 24 ++ kastalia/README | 59 ++++ kastalia/config/.htaccess | 1 + kastalia/config/conf.php | 13 + kastalia/config/conf.xml | 37 +++ kastalia/datastore/.htaccess | 1 + kastalia/decrypt_menu.php | 104 +++++++ kastalia/docs/CHANGES | 37 +++ kastalia/docs/CREDITS | 9 + kastalia/docs/INSTALL | 180 ++++++++++++ kastalia/docs/RELEASE_NOTES | 14 + kastalia/docs/TODO | 8 + kastalia/download.php | 160 +++++++++++ kastalia/encrypt_decrypt_files.php | 383 ++++++++++++++++++++++++++ kastalia/index.php | 22 ++ kastalia/lib/Block/tree_menu.php | 36 +++ kastalia/lib/Kastalia.php | 52 ++++ kastalia/lib/base.php | 44 +++ kastalia/lib/version.php | 1 + kastalia/list.php | 18 ++ kastalia/locale/en_US/help.xml | 13 + kastalia/main.php | 236 ++++++++++++++++ kastalia/po/README | 1 + kastalia/temp/.htaccess | 1 + kastalia/templates/common-footer.inc | 17 ++ kastalia/templates/common-header.inc | 32 +++ kastalia/templates/menu.inc | 4 + kastalia/themes/graphics/directory_closed.gif | Bin 0 -> 278 bytes kastalia/themes/graphics/directory_open.gif | Bin 0 -> 210 bytes kastalia/themes/graphics/file.gif | Bin 0 -> 125 bytes kastalia/themes/graphics/file_enc.gif | Bin 0 -> 664 bytes kastalia/themes/graphics/kastalia.png | Bin 0 -> 622 bytes kastalia/themes/graphics/loader.gif | Bin 0 -> 7757 bytes kastalia/themes/graphics/menu/upload.png | Bin 0 -> 330 bytes kastalia/themes/screen.css | 44 +++ kastalia/upload.php | 207 ++++++++++++++ kastalia/upload_menu.php | 258 +++++++++++++++++ 39 files changed, 2344 insertions(+) create mode 100644 kastalia/COPYING create mode 100644 kastalia/LICENSE.ASL create mode 100755 kastalia/LICENSE.BSDL create mode 100644 kastalia/README create mode 100644 kastalia/config/.htaccess create mode 100644 kastalia/config/conf.php create mode 100755 kastalia/config/conf.xml create mode 100644 kastalia/datastore/.htaccess create mode 100644 kastalia/decrypt_menu.php create mode 100644 kastalia/docs/CHANGES create mode 100644 kastalia/docs/CREDITS create mode 100644 kastalia/docs/INSTALL create mode 100755 kastalia/docs/RELEASE_NOTES create mode 100644 kastalia/docs/TODO create mode 100755 kastalia/download.php create mode 100644 kastalia/encrypt_decrypt_files.php create mode 100755 kastalia/index.php create mode 100644 kastalia/lib/Block/tree_menu.php create mode 100755 kastalia/lib/Kastalia.php create mode 100755 kastalia/lib/base.php create mode 100755 kastalia/lib/version.php create mode 100755 kastalia/list.php create mode 100755 kastalia/locale/en_US/help.xml create mode 100755 kastalia/main.php create mode 100644 kastalia/po/README create mode 100644 kastalia/temp/.htaccess create mode 100644 kastalia/templates/common-footer.inc create mode 100755 kastalia/templates/common-header.inc create mode 100755 kastalia/templates/menu.inc create mode 100755 kastalia/themes/graphics/directory_closed.gif create mode 100644 kastalia/themes/graphics/directory_open.gif create mode 100644 kastalia/themes/graphics/file.gif create mode 100644 kastalia/themes/graphics/file_enc.gif create mode 100755 kastalia/themes/graphics/kastalia.png create mode 100644 kastalia/themes/graphics/loader.gif create mode 100644 kastalia/themes/graphics/menu/upload.png create mode 100755 kastalia/themes/screen.css create mode 100644 kastalia/upload.php create mode 100644 kastalia/upload_menu.php diff --git a/kastalia/COPYING b/kastalia/COPYING new file mode 100644 index 000000000..5a965fbc5 --- /dev/null +++ b/kastalia/COPYING @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + 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 +this service 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. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + END OF TERMS AND CONDITIONS diff --git a/kastalia/LICENSE.ASL b/kastalia/LICENSE.ASL new file mode 100644 index 000000000..e0b7a1365 --- /dev/null +++ b/kastalia/LICENSE.ASL @@ -0,0 +1,48 @@ +Version 1.0 + +Copyright (c) 2006 The Horde Project. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. The end-user documentation included with the redistribution, if +any, must include the following acknowledgment: + + "This product includes software developed by the Horde Project + (http://www.horde.org/)." + +Alternately, this acknowledgment may appear in the software itself, if +and wherever such third-party acknowledgments normally appear. + +4. The names "Horde", "The Horde Project", and "Skeleton" must not be +used to endorse or promote products derived from this software without +prior written permission. For written permission, please contact +core@horde.org. + +5. Products derived from this software may not be called "Horde" or +"Skeleton", nor may "Horde" or "Skeleton" appear in their name, without +prior written permission of the Horde Project. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE HORDE PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +This software consists of voluntary contributions made by many +individuals on behalf of the Horde Project. For more information on +the Horde Project, please see . diff --git a/kastalia/LICENSE.BSDL b/kastalia/LICENSE.BSDL new file mode 100755 index 000000000..e2b4fbfed --- /dev/null +++ b/kastalia/LICENSE.BSDL @@ -0,0 +1,24 @@ +Copyright (c) 2006 The Horde Project. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HORDE PROJECT +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/kastalia/README b/kastalia/README new file mode 100644 index 000000000..fa02ccff6 --- /dev/null +++ b/kastalia/README @@ -0,0 +1,59 @@ +What is Kastalia? +================= + +:Last update: $Date: 2008-09-16 10:02:53 $ +:Revision: $Revision: 1.0 $ + +.. contents:: Contents +.. section-numbering:: + +Kastalia is a Horde Framework application for secure file sharing. Every uploaded +file can be encrypted by Kastalia and stored secure in the datastore. The user +does not need any additional program for the encryption/decryption. + +Obtaining Kastalia +------------------ + +Further information on Kastalia and the latest version can be obtained at + + http://h4des.org/index.php?inhalt=kastalia + + +Documentation +------------- + +The following documentation is available in the Kastalia distribution: + +:README_: This file +:COPYING_: Copyright and license information +:LICENSE_: Copyright and license information +:`docs/CHANGES`_: Changes by release +:`docs/CREDITS`_: Project developers +:`docs/INSTALL`_: Installation instructions and notes +:`docs/TODO`_: Development TODO list +:`docs/UPGRADING`_: Pointers on upgrading from previous Kastalia versions + + +Installation +------------ + +Instructions for installing Kastalia can be found in the file INSTALL_ in the +``docs/`` directory of the Kastalia distribution. + + +Assistance +---------- + +If you encounter problems with Kastalia, help is available! Please contact the +author of Kastalia. + + +Licensing +--------- + +For licensing and copyright information, please see the file COPYING_/LICENSE_ +in the Kastalia distribution. + +Thanks, + +the Kastalia team \ No newline at end of file diff --git a/kastalia/config/.htaccess b/kastalia/config/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/kastalia/config/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/kastalia/config/conf.php b/kastalia/config/conf.php new file mode 100644 index 000000000..88280373a --- /dev/null +++ b/kastalia/config/conf.php @@ -0,0 +1,13 @@ + + + + + Kastalia Datastore Settings + + /absolute/path/to/horde/kastalia/datastore + + + lost+found + + + + Kastalia Upload Settings + + false + + + 0 + + + /absolute/path/to/horde/kastalia/temp + + + 10 + + + false + + + 0 + + + 1 + + + diff --git a/kastalia/datastore/.htaccess b/kastalia/datastore/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/kastalia/datastore/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/kastalia/decrypt_menu.php b/kastalia/decrypt_menu.php new file mode 100644 index 000000000..ce35e03c3 --- /dev/null +++ b/kastalia/decrypt_menu.php @@ -0,0 +1,104 @@ + + */ + +//das absolute Kastalia directory wird als Konstante definiert +//um damit config Dateien zu includieren +@define('KASTALIA_BASE', dirname(__FILE__)); + +//die Basis von Kastalia wird includiert +//um die Anmeldung zu ueberpruefen +require_once(KASTALIA_BASE . '/lib/base.php'); +//die Konfigurationsdatei von Kastalia wird includiert +//um alle Kastalia Einstellungen in diesem Skript nutzen zu koennen +require(KASTALIA_BASE . '/config/conf.php'); +//das Menu von Kastalia wird includiert +//damit das Menu dem Benutzer angezeigt wird +require_once(KASTALIA_BASE . '/list.php'); + +echo "
Kastalia Datastore - Decryption Password
\n"; +echo "

notice: cookies and javascripts must be enabled to download files!

\n"; + +//nun wird ueberprueft, ob das verschluesseln/entschluesseln von Dateien aktiviert wurde +//falls nicht, wird eine Meldung ausgegeben und das Skript beendet +if(!$conf['upload']['securestore']) { + echo "Encryption/Decryption is disabled!"; + exit(0); +} + +//hier wird ueberprueft, ob die zu herunterladende Datei ueberhaupt +//uebergeben wurde, damit Manipulation verhindert wird und um Fehler zu vermeiden +if(isset($_GET['kastalia_filename'])) { + //hier wird ueber GET der Dateiname ermittelt + $kastalia_filename = $_GET['kastalia_filename']; + //hier wird ueberprueft, ob es sich bei der zu herunterladenden Datei um eine ".htaccess" Datei + //handelt. Dabei werden allerdings auch Dateien herausgefiltert, die die Endung ".htaccess" haben. + if(substr($kastalia_filename, -9) == ".htaccess") { + echo "Error: Downloading .htaccess files out of the datastore not allowed!"; + exit(1); + } + //Ueberpruefung nach den Zeichenfolgen "/." und "./" damit + //durch das Manipulieren der Variable kastalia_filename + //keiner aus dem kastalia Datastore entkommen kann (durch Nutzung von "../") + if(strpos($kastalia_filename,'/.') === false && strpos($kastalia_filename,'./') === false) { + //hier wird ueberprueft, ob die zu entschluesselnde Datei existiert oder lesbar ist + if(!is_readable($conf['datastore']['location'] . "/" . $kastalia_filename)) { + echo "Error: File $kastalia_filename doesn't exist or is not readable!"; + exit(1); + } + //hier wird ueberprueft ob es sich bei dem Download um eine von Kastalia verschluesselte Datei handelt (Endung ".kastaliaenc") + //falls es sich nicht um die von Kastalia verwendete Endung handelt, wird ein Fehler ausgegeben + if(substr($kastalia_filename, -12) != ".kastaliaenc") { + echo "Error: File doesn't have the Kastalia file extension!"; + exit(1); + } + } + else { + echo "Error: \$kastalia_filename in decrypt_menu.php contains illegal characters!"; + exit(1); + } +} +else { + echo "Error: \$kastalia_filename in decrypt_menu.php is not set!"; + exit(1); +} +?> + + + + + + +
+ + +
+ + \ No newline at end of file diff --git a/kastalia/docs/CHANGES b/kastalia/docs/CHANGES new file mode 100644 index 000000000..fe2b86160 --- /dev/null +++ b/kastalia/docs/CHANGES @@ -0,0 +1,37 @@ +--- +v1.0.1 +--- + +[sqall] Fixed a problem with the filesize on the download page. +[sqall] Alphabetic sorted file list. +[sqall] Added fake upload loading bar. +[sqall] w3c conformable HTML output. +[sqall] JavaScript upload bug with IE 6 solved. +[sqall] JavaScript bug with unreadable temp dir/disabled encryption solved. + + +--- +v1.0 +--- + +[sqall] Added file encryption feature. + +--- +v0.9.1 +--- + +[sqall] Generate new filenames if file already exists + (existing files cannot be overwritten). +[sqall] Forbid uploading .htaccess files due to security reasons. + +--- +v0.9 +--- + +[sqall] Added upload feature. + +--- +v0.8 +--- + +[sqall] Finished application. \ No newline at end of file diff --git a/kastalia/docs/CREDITS b/kastalia/docs/CREDITS new file mode 100644 index 000000000..545e0e984 --- /dev/null +++ b/kastalia/docs/CREDITS @@ -0,0 +1,9 @@ +=========================== + Kastalia Development Team +=========================== + + +Core Developers +=============== + +- Andre Pawlowski aka sqall \ No newline at end of file diff --git a/kastalia/docs/INSTALL b/kastalia/docs/INSTALL new file mode 100644 index 000000000..82578bb5d --- /dev/null +++ b/kastalia/docs/INSTALL @@ -0,0 +1,180 @@ +========================= + Installing Kastalia 1.0 +========================= + +:Last update: $Date: 2008-11-03 12:25:48 $ +:Revision: $Revision: 1.0 $ + +.. contents:: Contents +.. section-numbering:: + +This document contains instructions for installing the Kastalia download application + +For information on the capabilities and features of Kastalia, see the file +README_ in the top-level directory of the Kastalia distribution. + + +Obtaining Kastalia +================== + +Kastalia can be obtained from the authors website + + http://h4des.org/index.php?inhalt=kastalia + + +Prerequisites +============= + +To function properly, Kastalia **requires** the following: + +1. A working Horde installation. + + Kastalia runs within the `Horde Application Framework`_, a set of common + tools for Web applications written in PHP. You must install Horde before + installing Kastalia. + + .. Important:: Kastalia 1.0 requires version 3.0+ of the Horde Framework - + earlier versions of Horde will **not** work. + + .. _`Horde Application Framework`: http://www.horde.org/horde/ + + The Horde Framework can be obtained from the Horde website and FTP server, + at + + http://www.horde.org/horde/ + + ftp://ftp.horde.org/pub/horde/ + + Many of Kastalia's prerequisites are also Horde prerequisites. + + .. Important:: Be sure to have completed all of the steps in the + `horde/docs/INSTALL`_ file for the Horde Framework before + installing Kastalia. + +2. Install the MCrypt module for php. (optional) + + Kastalia uses the MCrypt module for php to encrypt/decrypt files on the + server. If you want to store files encrypted on the server you have to + install this module. + + For further informations and to get MCrypt take a look at + + http://mcrypt.sourceforge.net/ + + and + + http://php.net/manual/en/mcrypt.setup.php + + +Installing Kastalia +=================== + +Kastalia is written in PHP, and must be installed in a web-accessible +directory. The precise location of this directory will differ from system to +system. Kastalia must be installed directly underneath Horde in the +web server's document tree. + +Since Kastalia is written in PHP, there is no compilation necessary; simply +expand the distribution where you want it to reside and rename the root +directory of the distribution to whatever you wish to appear in the URL. For +example, with the Apache web server's default document root of +``/usr/local/apache/htdocs``, you would type:: + + cd /usr/local/apache/htdocs/horde + tar zxvf /path/to/kastalia-1.0.tar.gz + mv kastalia-1.0 kastalia + +and would then find Kastalia at the URL:: + + http://your-server/horde/kastalia/ + + +Configuring Kastalia +==================== + +1. Configuring Horde for Kastalia + + Register the application + + In ``horde/config/registry.php``, add the following lines: + + $this->applications['kastalia'] = array( + 'fileroot' => dirname(__FILE__) . '/../kastalia', + 'webroot' => $this->applications['horde']['webroot'] . '/kastalia', + 'name' => _("Datastore"), + 'status' => 'active', + ); + + $this->applications['kastalia-menu'] = array( + 'status' => 'block', + 'app' => 'kastalia', + 'blockname' => 'tree_menu', + 'menu_parent' => 'kastalia', + ); + +2. Configuring Kastalia + + You must login to Horde as a Horde Administrator to finish the + configuration of Kastalia. Use the Horde ``Administration`` menu item to + get to the administration page, and then click on the ``Configuration`` + icon to get the configuration page. Select ``Datastore`` from the + selection list of applications. Fill in or change any configuration values + as needed. When done click on ``Generate Kastalia Name Configuration`` to + generate the ``conf.php`` file. If your web server doesn't have write + permissions to the Kastalia configuration directory or file, it will not be + able to write the file. In this case, go back to ``Configuration`` and + choose one of the other methods to create the configuration file + ``kastalia/config/conf.php``. + + Note for international users: Kastalia uses GNU gettext to provide local + translations of text displayed by applications; the translations are found + in the ``po/`` directory. If a translation is not yet available for your + locale (and you wish to create one), see the ``horde/po/README`` file, or + if you're having trouble using a provided translation, please see the + `horde/docs/TRANSLATIONS`_ file for instructions. + +3. Securing Kastalia + + Before you can secure Kastalia, you need a secure Horde installation. Please + read the file in `horde/docs/SECURITY`_ for Horde security information + before proceeding. + + First you have to realize that every directory bellow your chosen Kastalia + datastore will be downloadable with Kastalia. So if you choose the directory + ``/`` every authorized Horde user can download everything readable + from your server. The next point to secure your datastore is to place it + outside the webroot for example ``/srv/kastalia/datastore``. If you + do so, make the directory readable by the webserver and the files owned by + ``root``. If your webserver runs as ``www.www``, do as follows: + + chown root:www kastalia/datastore/* + chmod 440 kastalia/datastore/* + + An additional approach is to make Kastalia's configuration files owned by the + user ``root`` and by a group which only the webserver user belongs to, and + then making them readable only to owner and group. For example, if your + webserver runs as ``www.www``, do as follows: + + chown root.www config/* + chmod 440 config/* + + To ensure you have a secure file sharing application you should use _https_ + instead of http. We also recomment to use the option to store files encrypted + (Prerequisites: 2. Install the MCrypt module for php). + +5. Testing Kastalia + + Once you have configured Kastalia, you can click on the ``Datastore`` link + in the Horde menu. Kastalia will immediately list every file in the configured + datastore. Clicking on a file will start the download. + + +Obtaining Support +================= + +If you encounter problems with Kastalia, help is available! Please contact the +author of Kastalia. + +Thanks for using Kastalia! + +The Kastalia team diff --git a/kastalia/docs/RELEASE_NOTES b/kastalia/docs/RELEASE_NOTES new file mode 100755 index 000000000..b2f3c91c0 --- /dev/null +++ b/kastalia/docs/RELEASE_NOTES @@ -0,0 +1,14 @@ + + */ + +//das absolute Kastalia directory wird als Konstante definiert +//um damit config Dateien zu includieren +@define('KASTALIA_BASE', dirname(__FILE__)); + +//die Konfigurationsdatei von Kastalia wird includiert +//um alle Kastalia Einstellungen in diesem Skript nutzen zu koennen +require(KASTALIA_BASE . '/config/conf.php'); + +//bei dem download.php Skript macht ein includieren von base.php Probleme +//und kann zu Fehlerhaften Downloads fuehren, deshalb wird ein manueller Anmeldecheck durchgefuehrt +//################### ################### +// Check for a prior definition of HORDE_BASE (perhaps by an auto_prepend_file +// definition for site customization). +if (!defined('HORDE_BASE')) { + @define('HORDE_BASE', dirname(__FILE__) . '/..'); +} + +// Load the Horde Framework core, and set up inclusion paths. +require_once HORDE_BASE . '/lib/core.php'; + +// Registry. +$registry = &Registry::singleton(); +if (is_a(($pushed = $registry->pushApp('kastalia', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { + if ($pushed->getCode() == 'permission_denied') { + Horde::authenticationFailureRedirect(); + } + Horde::fatal($pushed, __FILE__, __LINE__, false); +} +//################### ################### + +//als erstes wird ueberprueft, ob die zu herunterladende Datei durch +//eine dafuer vorgesehenen SESSION Variable definiert wurde +//(diese SESSION Variable ist fuer downloads aus dem temporaeren Verzeichnis vorgesehen) +if(isset($_SESSION['kastalia_temp_download'])) { + $kastalia_filename = $_SESSION['kastalia_temp_download']; + //nachdem die SESSION Variable in eine fuer das Skript lokalen Variable gespeichert worden ist + //wird die SESSION Variable aus Sicherheits- und Konfliktgruenden geloescht + unset($_SESSION['kastalia_temp_download']); + //hier wird ueberprueft, ob es sich bei der zu herunterladenden Datei um eine ".htaccess" Datei + //handelt. Dabei werden allerdings auch Dateien herausgefiltert, die die Endung ".htaccess" haben. + if(substr($kastalia_filename, -9) == ".htaccess") { + echo "Error: Downloading .htaccess files out of the temporary directory not allowed!"; + exit(1); + } + //hier wird ueberprueft, ob das verschluesselte speichern von Dateien aktiviert ist... + if($conf['upload']['securestore']) { + //... falls ja, werden weitere Pruefungen durchgefuerht + //Ueberpruefung nach den Zeichenfolgen "/." und "./" damit + //durch das Manipulieren der Variable kastalia_filename + //keiner aus dem temporaeren Verzeichnis entkommen kann (durch Nutzung von "../") + if(strpos($kastalia_filename,'/.') === false && strpos($kastalia_filename,'./') === false) { + //nun wird der Download aus dem temporaeren Verzeichnis gestartet + DownloadFile($conf['upload']['tempdir'], $kastalia_filename); + //nachdem die Datei heruntergeladen wurde, muss sie geloescht werden, + //damit keiner mehr Zugriff auf sie erhaelt + if(!unlink($conf['upload']['tempdir'] . "/" . $kastalia_filename)) { + echo "Error: Unable to delete temporary file after downloading!"; + exit(1); + } + } + else { + echo "Error: \$kastalia_filename in download.php contains illegal characters!"; + exit(1); + } + } + else { + //... ansonsten wird mit einer Meldung abgebrochen + echo "Encryption/Decryption is disabled!"; + exit(0); + } +} +//falls die SESSION Variable nicht gesetzt wurde... +else { + //...wird hier ueberprueft, ob mittels GET der Dateiname gesetzt worden ist + if(isset($_GET['kastalia_filename'])) { + //hier wird ueber GET der Dateiname ermittelt + $kastalia_filename = $_GET['kastalia_filename']; + //hier wird ueberprueft, ob es sich bei der zu herunterladenden Datei um eine ".htaccess" Datei + //handelt. Dabei werden allerdings auch Dateien herausgefiltert, die die Endung ".htaccess" haben. + if(substr($kastalia_filename, -9) == ".htaccess") { + echo "Error: Downloading .htaccess files out of the datastore not allowed!"; + exit(1); + } + //Ueberpruefung nach den Zeichenfolgen "/." und "./" damit + //durch das Manipulieren der Variable kastalia_filename + //keiner aus dem kastalia Datastore entkommen kann (durch Nutzung von "../") + if(strpos($kastalia_filename,'/.') === false && strpos($kastalia_filename,'./') === false) { + //hier wird ueberprueft ob es sich bei dem Download um eine von Kastalia verschluesselte Datei handelt (Endung ".kastaliaenc") + if(substr($kastalia_filename, -12) == ".kastaliaenc") { //SECURE STORED + //hier wird serverseitig ueberprueft, ob ein leeres Passwort uebergeben wurde + //falls ja, wird mit einem Error abgebrochen, da leere Passwoerter verboten sind + if($_POST['kastalia_password'] == "") { + echo "Error: Empty passwords not allowed!"; + exit(1); + } + //hier wird ueberprueft, ob das verschluesselte speichern von Dateien aktiviert ist + if($conf['upload']['securestore']) { + $_SESSION['kastalia_mode'] = "decrypt"; //diese Variable gibt den Modus an in welchem das Skript encrypt_decrypt_files.php ausgefuehrt werden soll + $_SESSION['kastalia_input_name'] = substr($conf['datastore']['location'] . "/" . $kastalia_filename, 0, -12); //diese Variable gibt die zu entschluesselnde Datei an (ohne die Endung ".kastaliaenc") + $_SESSION['kastalia_output_name'] = substr($conf['upload']['tempdir'] . "/" . basename($kastalia_filename), 0, -12); //diese Variable gibt den Ort fuer die entschluesselte Zieldatei an (der temporaere Ordner von Kastalia, das "basename" ist hier wichtig, da ansonsten auch die unterordner vom datastore im Dateinamen stecken) + $_SESSION['kastalia_part_number'] = 0; //diese Variable gibt die aktuelle Entschluesselungsrunde an (die Beginnrunde ist immer 0) + $_SESSION['kastalia_key'] = $_POST['kastalia_password']; //diese Variable gibt den Schluessel zum entschluesseln der Datei an + //mit der encrypt_decrypt_files.php wird die Entschluesselung fuer die Datei ausgefuehrt + //(diese besteht aus mehreren Teilschritten wobei der Browser automatisch das Skript in Intervallen neu aufruft) + include('encrypt_decrypt_files.php'); + } + else { + //falls es deaktiviert ist, wird mit einer Meldung abgebrochen + echo "Encryption/Decryption is disabled!"; + exit(0); + } + } + //falls die zu herunterladende Datei keine von Kastalia verschluesselte Datei ist + //wird der Download einfach gestartet + else { //UNSECURE STORED + DownloadFile($conf['datastore']['location'], $kastalia_filename); + } + } + else { + echo "Error: \$kastalia_filename in download.php contains illegal characters!"; + exit(1); + } + } + //falls der Dateiname nicht gesetzt wurde, wird mit einer Fehlermeldung abgebrochen + else{ + echo "Error: \$kastalia_filename in download.php is not set!"; + exit(1); + } +} + +//diese Funktion setzt die Header zum Download der Datei +//und gibt die Datei an den Browser +function DownloadFile($file_location,$file_name) { + //Ueberpruefung ob Datei existiert und lesbar ist + if(is_readable($file_location . '/' . $file_name)) { + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Length: ' . filesize($file_location . '/' . $file_name)); + header('Content-Disposition: attachment; filename=' . basename($file_name)); + flush(); + readfile($file_location . '/' . $file_name); + } + else { + echo "Error: File $file_name doesn't exist or is not readable!"; + exit(1); + } +} +?> \ No newline at end of file diff --git a/kastalia/encrypt_decrypt_files.php b/kastalia/encrypt_decrypt_files.php new file mode 100644 index 000000000..f689e5edb --- /dev/null +++ b/kastalia/encrypt_decrypt_files.php @@ -0,0 +1,383 @@ + + */ + +//das absolute Kastalia directory wird als Konstante definiert +//um damit config Dateien zu includieren +@define('KASTALIA_BASE', dirname(__FILE__)); + +//die Basis von Kastalia wird includiert +//um die Anmeldung zu ueberpruefen +require_once(KASTALIA_BASE . '/lib/base.php'); +//die Konfigurationsdatei von Kastalia wird includiert +//um alle Kastalia Einstellungen in diesem Skript nutzen zu koennen +require(KASTALIA_BASE . '/config/conf.php'); +//das Menu von Kastalia wird includiert +//damit das Menu dem Benutzer angezeigt wird +require_once(KASTALIA_BASE . '/list.php'); + +echo "
Kastalia Datastore - Encryption/Decryption
\n"; +echo "
\n"; + +//nun wird ueberprueft, ob das verschluesseln/entschluesseln von Dateien aktiviert wurde +//falls nicht, wird eine Meldung ausgegeben und das Skript beendet +if(!$conf['upload']['securestore']) { + //mit dieser Funktion werden aus Sicherheitsgruenden nach der Verschluesselung + //alle SESSION Variablen die damit zu tun haben geloescht + UnsetSessionVars(); + echo "Encryption/Decryption is disabled!"; + exit(0); +} + +//hier werden die fuer die Weiterverarbeitung noetigen SESSION und config Variablen in lokalen Variablen gespeichert +$kastalia_mode = $_SESSION['kastalia_mode']; //diese Variable legt fest, ob ver- oder entschluesselt werden soll +$input_name = $_SESSION['kastalia_input_name']; //gibt den Namen + Ort der Quelldatei an +$output_name = $_SESSION['kastalia_output_name']; //gibt den Namen + Ort der Zieldatei an +$kastalia_part_number = $_SESSION['kastalia_part_number']; //gibt die aktuelle ver/entschluesselungsrunde an +$key = $_SESSION['kastalia_key']; //gibt den key zum ver/entschluesseln an +$kastalia_memory_size = $conf['upload']['memorysize']; //gibt die groesse des zu Verfuegung stehenden Speichers an, mit diesem Wert wird die groesse des zu ver/entschluesselnden Teiles berechnet +$refresh_cycle = $conf['upload']['refreshcycle']; //gibt an, wie lange nach Beendigung einer Ver/Entschluesselungsrunde der naechste Aufruf vom Browser gestartet wird + +//hier wird ueberprueft, ob der Schluessel fuer die Ver/Entschluesselung gesetzt wurde +//falls nicht, wird abgebrochen +if($key == "") { + echo "Error: \$key in encrypt_decrypt_files.php is empty!
\n"; + //falls es sich um die Verschluesselung einer Datei handelt, muss die temporaere unverschluesselte Datei + //unbedingt geloescht werden. Hier wird ueberprueft ob die Datei verschluesselt werden sollte + if($kastalia_mode == "encrypt") { + echo "deleting temporary file...
\n"; + //hier wird nun die temporaere Datei geloescht, falls ein Fehler auftreten sollte, wird ein Error ausgegeben + if(!unlink($input_name)) { + echo "Error: Unable to delete temporary file!
\n"; + echo "This constitutes a breach of security because the content of the uploaded file stored unencrypted.
\n"; + echo "Please contact the administrator to have the temporary file " . $input_name . " deleted.\n"; + } + else { + echo "...done.\n"; + } + } + //mit dieser Funktion werden aus Sicherheitsgruenden nach der Verschluesselung + //alle SESSION Variablen die damit zu tun haben geloescht + UnsetSessionVars(); + exit(1); +} + +//in dieser switch-case Anweisung wird durch kastalia_mode entschieden ob ver- oder entschluesselt werden soll +switch($kastalia_mode) { + case "encrypt": //######################################### SPLIT AND ENCRYPT FILE ######################################### + //hier wird die Anzahl der Dateiteile berechnet, die auch gleichzeitig die Anzahl der Verschluesselungsrunden angibt + $max_parts = ceil(filesize($input_name) / $kastalia_memory_size); + //hier wird ueberprueft, ob alle Verschluesselungsrunden durchlaufen wurden... + if($kastalia_part_number < $max_parts) { + //... falls nein, wird die naechste Verschluesselungsrunde eingeleitet + //mit dieser Funktion wird die Datei in Stuecken ausgelesen und verschluesselt wieder zusammengesetzt + //je ein Stueck pro Verschluesselungsrunde + SplitAndEncryptFile($input_name, $conf['upload']['tempdir'] . "/" . basename($output_name), $kastalia_part_number, $max_parts, $key); + //hier werden die Variablen fuer das weitere vorgehen des Skriptes wieder in die SESSION Variablen gespeichert + $_SESSION['kastalia_mode'] = "encrypt"; //diese Variable legt fest, ob ver- oder entschluesselt werden soll + $_SESSION['kastalia_input_name'] = $input_name; //gibt den Namen + Ort der Quelldatei an + $_SESSION['kastalia_output_name'] = $output_name; //gibt den Namen + Ort der Zieldatei an + $_SESSION['kastalia_part_number'] = $kastalia_part_number + 1; //gibt die aktuelle ver/entschluesselungsrunde an (+1) + $_SESSION['kastalia_key'] = $key; //gibt den key zum ver/entschluesseln an + + //##################### ##################### + //Header Manipulation zum aufrufen der naechsten Verschluesselungsrunde + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + echo "encrypting part " . ($kastalia_part_number + 1) . " of " . $max_parts . "
"; + echo "please wait...
"; + echo "

\n"; + echo "\n"; + //##################### ##################### + + } + else { + //... falls ja, werden die letzten Schritte nach der Verschluesselung durchgefuert + //mit dieser Funktion werden aus Sicherheitsgruenden nach der Verschluesselung + //alle SESSION Variablen die damit zu tun haben geloescht + UnsetSessionVars(); + //hier wird die temporaere verschluesselte Datei an die richtige finale Stelle verschoben, + //damit sie heruntergeladen werden kann + if(!rename($conf['upload']['tempdir'] . "/" . basename($output_name) . ".kastaliaenc", $output_name . ".kastaliaenc")) { + //sollte ein Fehler beim verschieben der temporaeren verschluesselten Datei auftreten + //wird eine Fehlermeldung ausgegeben, aber nicht abgebrochen, da die nachfolgenden Befehle noch abgearbeitet werden muessen + echo "Error: Encrypted file couldn't be moved to final position " . $output_name . ".kastaliaenc
\n"; + } + echo "Encryption done...
\n"; + echo "File successfully stored under " . substr($output_name, strlen($conf['datastore']['location'] . "/")) . " !\n"; + //hier wird nun die temporaere unverschluesselte Datei geloescht (Wichtig: sollte hier ein Fehler auftreten + //liegt eine unverschluesselte Version der Datei in dem temporaeren Verzeichnis!) + if(!unlink($input_name)) { + echo "Error: Unable to delete temporary file after encryption!
\n"; + echo "This constitutes a breach of security because the content of the uploaded file still stored unencrypted.
\n"; + echo "Please contact the administrator to have the temporary file " . $input_name . " deleted.\n"; + exit(1); + } + } + break; + case "decrypt": //######################################### DECRYPT AND MERGE FILES ######################################### + //hier wird die Endung ".kastaliaenc" an den input_name gesetzt, da die von Kastalia verschluesselten + //Dateien immer diese Endung besitzen + $temp_input_name = $input_name . ".kastaliaenc"; + //hier wird die Anzahl der Dateiteile berechnet, die auch gleichzeitig die Anzahl der Entschluesselungsrunden angibt + $max_parts = ceil(filesize($temp_input_name) / $kastalia_memory_size); + //hier wird ueberprueft, ob alle Entschluesselungsrunden durchlaufen wurden... + if($kastalia_part_number < $max_parts) { + //... falls nein, wird die naechste Entschluesselungsrunde eingeleitet + //mit dieser Funktion wird die Datei in Stuecken ausgelesen und entschluesselt wieder zusammengesetzt + //je ein Stueck pro Entschluesselungsrunde + MergeAndDecryptFile($input_name, $output_name, $kastalia_part_number, $max_parts, $key); + //hier werden die Variablen fuer das weitere vorgehen des Skriptes wieder in die SESSION Variablen gespeichert + $_SESSION['kastalia_mode'] = "decrypt"; //diese Variable legt fest, ob ver- oder entschluesselt werden soll + $_SESSION['kastalia_input_name'] = $input_name; //gibt den Namen + Ort der Quelldatei an + $_SESSION['kastalia_output_name'] = $output_name; //gibt den Namen + Ort der Zieldatei an + $_SESSION['kastalia_part_number'] = $kastalia_part_number + 1; //gibt die aktuelle ver/entschluesselungsrunde an (+1) + $_SESSION['kastalia_key'] = $key; //gibt den key zum ver/entschluesseln an + + //##################### ##################### + //Header Manipulation zum aufrufen der naechsten Entschluesselungsrunde + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + echo "decrypting part " . ($kastalia_part_number + 1) . " of " . $max_parts . "
"; + echo "please wait...
"; + echo "

\n"; + echo "\n"; + //##################### ##################### + + } + else { + //... falls ja, werden die letzten Schritte nach der Entschluesselung durchgefuert + //mit dieser Funktion werden aus Sicherheitsgruenden nach der Entschluesselung + //alle SESSION Variablen die damit zu tun haben geloescht + UnsetSessionVars(); + //diese Variable gibt fuer das download.php Skript den Dateinamen zum herunterladen an + $_SESSION['kastalia_temp_download'] = basename($output_name); + + //##################### ##################### + //Header Manipulation zum aufrufen des Downloadskriptes + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + echo "starting download
"; + echo "please wait...
"; + echo "

\n"; + echo "\n"; + //##################### ##################### + + } + break; + default: + //falls der Modus weder "encrypt" noch "decrypt" ist, ist ein unerwarteter Fehler aufgetreten + echo "Error: Unexpected value of \$kastalia_mode in encrypt_decrypt_files.php!"; + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + exit(1); + break; +} + +//diese Funktion verschluesselt die errechneten Dateiteile und fuegt sie in eine Datei an die richtige Stelle +function SplitAndEncryptFile($input_file_name, $output_name, $part_number, $max_parts, $key) { + //hier wird der Name fuer die verschluesselte Datei mit der Endung ".kastaliaenc" versehen + $output_file_name = $output_name . ".kastaliaenc"; + //hier wird ueberprueft ob die verschluesselte Enddatei schon existiert und es die erste Verschluesselungsrunde ist + //(damit die gerade zu verschluesselnde und erstellte Datei nicht mit in die Pruefung einbezogen wird) + //falls ja wird mit einem Error abgebrochen + if($part_number == 0 && file_exists($output_file_name)) { + echo "Error: File " . $output_file_name . " already exists! Stopping encryption!
"; + //wenn die verschluesselte Datei schon existiert, wird die temporaere unverschluesselte Datei + //geloescht damit diese nicht auf dem Server unverschluesselt gespeichert bleibt + echo "deleting temporary file...
\n"; + //hier wird nun die temporaere Datei geloescht, falls ein Fehler auftreten sollte, wird ein Error ausgegeben + if(!unlink($input_file_name)) { + echo "Error: Unable to delete temporary file!
\n"; + echo "This constitutes a breach of security because the content of the uploaded file stored unencrypted.
\n"; + echo "Please contact the administrator to have the temporary file " . $input_file_name . " deleted.\n"; + } + else { + echo "...done.\n"; + } + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + exit(1); + } + //hier wird die zu verschluesselnde Datei fuer das Lesen geoeffnet + if($input_file_handle = fopen($input_file_name, 'rb')) { + $input_file_size = filesize($input_file_name); + //hier wird die groesse (in Bytes) fuer die einzelnen zu verschluesselnden Datenteile berrechnet + $parts_size = floor($input_file_size/$max_parts); + //da durch die Groessenberechnung fuer die einzelnen Datenteile (durch die Nutzung von "floor") + //ein Rest entstehen kann, wird dieser hier berrechnet um ihn an den letzten Datenteil anzuhaengen + //damit kein Datenverlust entstehen kann + $last_bytes = $input_file_size % $max_parts; + //nun wird die Datei in die die verschluesselten Daten geschrieben werden sollen geoeffnet + //(der Dateizeiger zeigt in diesem Modus auf das Ende der Datei) + if($output_file_handle = fopen($output_file_name ,'ab')) { + //hier wird der Dateizeiger an die richtige Position gesetzt um die Daten fuer die jetzige Verschluesselungsrunde zu lesen + fseek($input_file_handle, $part_number * $parts_size, SEEK_SET); + //hier wird ueberprueft, ob es sich um die letzte Verschluesselungsrunde handelt + if($part_number == ($max_parts-1) ) { + //die groesse des letzten Datenteils wird um den Rest ($last_bytes) der Groessenberechnung erhoeht + fwrite($output_file_handle, EncryptData($key, fread($input_file_handle, $parts_size + $last_bytes))); + } + else { + fwrite($output_file_handle, EncryptData($key, fread($input_file_handle, $parts_size))); + } + //die verschluesselte Zieldatei wird geschlossen + fclose($output_file_handle); + } + else { + echo "Error: Can't open file " . $output_file_name . "!"; + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + exit(1); + } + //die zu verschluesselnde Datei wird geschlossen + fclose($input_file_handle); + } + else { + echo "Error: Can't open file " . $input_file_name . "!"; + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + exit(1); + } + return true; +} + +//diese Funktion entschluesselt die errechneten Dateiteile und fuegt sie in eine Datei an die richtige Stelle +function MergeAndDecryptFile($input_name, $output_file_name, $part_number, $max_parts, $key) { + //die Konfigurationsdatei von Kastalia wird includiert + //um alle Kastalia Einstellungen in dieser function nutzen zu koennen + require(KASTALIA_BASE . '/config/conf.php'); + //hier wird ueberprueft ob die entschluesselte Enddatei schon existiert (dies kann passieren wenn + //jemand die Datei gerade entschluesselt um sie herunterzuladen) und es die erste Entschluesselungsrunde ist + //(damit die gerade zu entschluesselnde und erstellte Datei nicht mit in die Pruefung einbezogen wird) + //falls ja wird mit einem Error abgebrochen + if(file_exists($output_file_name) && $part_number == 0) { + echo "Error: File " . $output_file_name . " already exists! Stopping decryption!
\n"; + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + //hier wird die ctime von der schon existierenden Datei ermittelt um zu berechnen + //wann Kastalia spaetestens diese Date iloeschen wird und es dem Nutzer mitzuteilen + if($file_ctime = filectime($output_file_name)) { + //hier wird berechnet wie lange die Datei noch laengstens bestehen wird bevor sie von Kastalia geloescht wird + $file_ctime = $file_ctime + (60 * $conf['upload']['tempctime']) - time(); + //sollte die Zeitrechnung negativ werden, ist ein Fehler aufgetreten und eine andere Nachricht wird ausgegeben + if($file_ctime >= 0) { + //die Angabe in Minuten wird auf 2 stellen hinter dem Komma gerundet + echo "Kastalia will delete the file in about " . round($file_ctime / 60, 2) . " minutes at the latest. Then try again.\n"; + } + else { + //wird ausgegeben wenn die Zeitrechnung negativ wird + //und somit die automatische Loeschung nicht funktioniert hat + echo "Please contact the administrator to have the file deleted."; + } + } + else { + //wird ausgegeben wenn die ctime Ermittlung erfolglos war und dementsprechend die automatische + //Loeschung auch nicht erfolgen wird + echo "Please contact the administrator to have the file deleted."; + } + exit(1); + } + //hier wird der Name fuer die verschluesselte Datei mit der Endung ".kastaliaenc" versehen + //da sie so auf dem Dateisystem gespeichert wurde + $input_file_name = $input_name . ".kastaliaenc"; + //die Datei wird zum schreiben geoeffnet mit dem Dateizeiger auf das Ende der Datei + if($input_file_handle = fopen($input_file_name, 'rb')) { + $input_file_size = filesize($input_file_name); + //hier wird die groesse (in Bytes) fuer die einzelnen zu entschluesselnden Datenteile berrechnet + $parts_size = floor($input_file_size/$max_parts); + //da durch die Groessenberechnung fuer die einzelnen Datenteile (durch die Nutzung von "floor") + //ein Rest entstehen kann, wird dieser hier berrechnet um ihn an den letzten Datenteil anzuhaengen + //damit kein Datenverlust entstehen kann + $last_bytes = $input_file_size % $max_parts; + //nun wird die Datei in die die entschluesselten Daten geschrieben werden sollen geoeffnet + //(der Dateizeiger zeigt in diesem Modus auf das Ende der Datei) + if($output_file_handle = fopen($output_file_name, 'ab')) { + //hier wird der Dateizeiger an die richtige Position gesetzt um die Daten fuer die jetzige Entschluesselungsrunde zu lesen + fseek($input_file_handle, $part_number * $parts_size, SEEK_SET); + //hier wird ueberprueft, ob es sich um die letzte Entschluesselungsrunde handelt + if($part_number == ($max_parts-1) ) { + //die groesse des letzten Datenteils wird um den Rest ($last_bytes) der Groessenberechnung erhoeht + fwrite($output_file_handle, DecryptData($key, fread($input_file_handle, $parts_size + $last_bytes))); + } + else { + fwrite($output_file_handle, DecryptData($key, fread($input_file_handle, $parts_size))); + } + //der entschluesselte Zieldatei wird geschlossen + fclose($output_file_handle); + } + else { + echo "Error: Can't open file " . $output_file_name . "!"; + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + exit(1); + } + //die zu entschluesselnde Datei wird geschlossen + fclose($input_file_handle); + } + else { + echo "Error: Can't open file " . $input_file_name . "!"; + //mit dieser Funktion werden aus Sicherheitsgruenden beim Abbruch + //alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben geloescht + UnsetSessionVars(); + exit(1); + } + return true; +} + +//diese Funktion verschluesselt die uebergebenden Daten mit den uebergebenden key +//und gibt die verschluesselten Daten zurueck +function EncryptData($key, $plaintext) { +//erstellt den initialisierungsvektor in der groesse des ausgewaehlten algorithmuses +//aus der md5 summe des uebergebenden keys +$iv = substr(md5($key), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH,MCRYPT_MODE_CFB)); +//verschluesselt die Daten mit dem angegebenen Modus und Algorithmuses +return mcrypt_cfb(MCRYPT_BLOWFISH, $key, $plaintext, MCRYPT_ENCRYPT, $iv); +} + +//diese Funktion entschluesselt die uebergebenden Daten mit den uebergebenden key +//und gibt die entschluesselten Daten zurueck +function DecryptData($key, $ciphertext) { +//erstellt den initialisierungsvektor in der groesse des ausgewaehlten algorithmuses +//aus der md5 summe des uebergebenden keys +$iv = substr(md5($key), 0, mcrypt_get_iv_size(MCRYPT_BLOWFISH,MCRYPT_MODE_CFB)); +//entschluesselt die Daten mit dem angegebenen Modus und Algorithmuses +return mcrypt_cfb(MCRYPT_BLOWFISH, $key, $ciphertext, MCRYPT_DECRYPT, $iv); +} + +//diese Funktion loescht alle SESSION Variablen die mit der Ver/Entschluesselung zu tun haben +function UnsetSessionVars() { + unset($_SESSION['kastalia_mode']); + unset($_SESSION['kastalia_input_name']); + unset($_SESSION['kastalia_output_name']); + unset($_SESSION['kastalia_part_number']); + unset($_SESSION['kastalia_key']); +} +?> + + \ No newline at end of file diff --git a/kastalia/index.php b/kastalia/index.php new file mode 100755 index 000000000..2a9e0acfc --- /dev/null +++ b/kastalia/index.php @@ -0,0 +1,22 @@ + + */ + +@define('KASTALIA_BASE', dirname(__FILE__)); +$kastalia_configured = (is_readable(KASTALIA_BASE . '/config/conf.php')); + +if (!$kastalia_configured) { + require KASTALIA_BASE . '/../lib/Test.php'; + Horde_Test::configFilesMissing('Kastalia', KASTALIA_BASE, + array('conf.php')); +} + +require KASTALIA_BASE . '/list.php'; +require KASTALIA_BASE . '/main.php'; diff --git a/kastalia/lib/Block/tree_menu.php b/kastalia/lib/Block/tree_menu.php new file mode 100644 index 000000000..7e854c2f2 --- /dev/null +++ b/kastalia/lib/Block/tree_menu.php @@ -0,0 +1,36 @@ + + * @package Tree_Menu + */ + +$block_name = _("Menu List"); +$block_type = 'tree'; + +class Horde_Block_kastalia_tree_menu extends Horde_Block { + + var $_app = 'kastalia'; + + function _buildTree(&$tree, $indent = 0, $parent = null) + { + global $registry; + + require_once dirname(__FILE__) . '/../base.php'; + + $tree->addNode($parent . '__upload', + $parent, + _("Upload"), + $indent + 1, + false, + array('icon' => 'menu/upload.png', + 'icondir' => $registry->getImageDir('kastalia'), + 'url' => Horde::applicationUrl('upload_menu.php'))); + } + +} diff --git a/kastalia/lib/Kastalia.php b/kastalia/lib/Kastalia.php new file mode 100755 index 000000000..c7915d5dc --- /dev/null +++ b/kastalia/lib/Kastalia.php @@ -0,0 +1,52 @@ + + * @package Kastalia + */ +class Kastalia { + + /** + * Build Kastalia's list of menu items. + */ + function getMenu($returnType = 'object') + { + global $conf, $registry, $browser, $print_link; + + require_once 'Horde/Menu.php'; + + $menu = new Menu(HORDE_MENU_MASK_ALL); + + $menu->add(Horde::applicationUrl('upload_menu.php'), _("Upload"), 'menu/upload.png', $registry->getImageDir('kastalia')); + + + if ($returnType == 'object') { + return $menu; + } else { + return $menu->render(); + } + } + + //diese Funktion entfernt aus einem String alle hier angegebenen Sonderzeichen + function ReplaceSpecialChars($text) { + $charstochange = array("Ü","Ö","Ä","ä","ü","ö","ß"," ","'","\\","+","/"); + $changetochars = array("Ue","Oe","Ae","ae","ue","oe","ss","_","_","_","_","_"); + $text = str_replace($charstochange,$changetochars,$text); + return $text; + } + + //diese Funktion entfernt aus einem String alle hier angegebenen Sonderzeichen + function ConvertToUriString($text) { + $charstochange = array(" "); + $changetochars = array("%20"); + $text = str_replace($charstochange,$changetochars,$text); + return $text; + } +} diff --git a/kastalia/lib/base.php b/kastalia/lib/base.php new file mode 100755 index 000000000..bbf2e9e4c --- /dev/null +++ b/kastalia/lib/base.php @@ -0,0 +1,44 @@ + + */ + +// Check for a prior definition of HORDE_BASE (perhaps by an auto_prepend_file +// definition for site customization). +if (!defined('HORDE_BASE')) { + @define('HORDE_BASE', dirname(__FILE__) . '/../..'); +} + +// Load the Horde Framework core, and set up inclusion paths. +require_once HORDE_BASE . '/lib/core.php'; + +// Registry. +$registry = &Registry::singleton(); +if (is_a(($pushed = $registry->pushApp('kastalia', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { + if ($pushed->getCode() == 'permission_denied') { + Horde::authenticationFailureRedirect(); + } + Horde::fatal($pushed, __FILE__, __LINE__, false); +} +$conf = &$GLOBALS['conf']; +@define('KASTALIA_TEMPLATES', $registry->get('templates')); + +// Notification system. +$notification = &Notification::singleton(); +$notification->attach('status'); + +// Define the base file path of Kastalia. +@define('KASTALIA_BASE', dirname(__FILE__) . '/..'); + +// Kastalia base library +require_once KASTALIA_BASE . '/lib/Kastalia.php'; + +// Start output compression. +Horde::compressOutput(); diff --git a/kastalia/lib/version.php b/kastalia/lib/version.php new file mode 100755 index 000000000..1977071c5 --- /dev/null +++ b/kastalia/lib/version.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/kastalia/list.php b/kastalia/list.php new file mode 100755 index 000000000..1c4f40a5a --- /dev/null +++ b/kastalia/list.php @@ -0,0 +1,18 @@ + + */ + +@define('KASTALIA_BASE', dirname(__FILE__)); +require_once KASTALIA_BASE . '/lib/base.php'; + +$title = _("List"); + +require KASTALIA_TEMPLATES . '/common-header.inc'; +require KASTALIA_TEMPLATES . '/menu.inc'; diff --git a/kastalia/locale/en_US/help.xml b/kastalia/locale/en_US/help.xml new file mode 100755 index 000000000..8c7b613a4 --- /dev/null +++ b/kastalia/locale/en_US/help.xml @@ -0,0 +1,13 @@ + + + + + Kastalia Overview + + What is Kastalia? + Use this module as a secure file sharing application for the Horde Framework. + Every uploaded file can be encrypted by Kastalia and stored secure in the datastore. + The user does not need any additional program for the encryption/decryption. + + + diff --git a/kastalia/main.php b/kastalia/main.php new file mode 100755 index 000000000..5ddd34e78 --- /dev/null +++ b/kastalia/main.php @@ -0,0 +1,236 @@ + + */ + +//das absolute Kastalia directory wird als Konstante definiert +//um damit config Dateien zu includieren +@define('KASTALIA_BASE', dirname(__FILE__)); + +//die Basis von Kastalia wird includiert +//um die Anmeldung zu ueberpruefen +require_once(KASTALIA_BASE . '/lib/base.php'); +//die Konfigurationsdatei von Kastalia wird includiert +//um alle Kastalia Einstellungen in diesem Skript nutzen zu koennen +require(KASTALIA_BASE . '/config/conf.php'); + + + + +echo Auth::getAuth(); + +echo $registry->hasPermission(Auth::getAuth(), PERMS_EDIT); +if($registry->hasPermission(Auth::getAuth(), PERMS_EDIT)) { + echo "TASTA"; + exit(0); +} + +?> + + + +
Kastalia Datastore - Download
+

notice: cookies and javascripts must be enabled to download files!

+ +\n"; + //diese beiden Arrays werden dazu benoetigt, die Ordner- bzw + //Dateinamen zwischen zu speichern und zu sortieren + $directory_array = array(); + $file_array = array(); + //der Inhalt des Ordners wird in dieser Schleife durchgegangen und jedes Element bearbeitet + //falls es sich um einen Ordner handelt, wird dieser wieder rekursiv geoeffnet und die Elemente bearbeitet + while(false !== ($file = readdir($dir_handle))) { + //Ueberpruefung ob es sich bei dem Element um einen Ordner handelt + //und ob dieser nicht in der Liste der Ordner ist, die nicht angezeigt werden sollen + //falls ja, wird der Name in einem Array gespeichert + if($file != "." && $file != ".." && is_dir($dir_name . '/' . $file) && !in_array($file, $conf['datastore']['directoryexcludes'])) { //SAVE DIRECTORYNAMES + $directory_array[] = $file; + } + //Ueberpruefung ob es sich bei dem Element um eine Datei handelt (und keine .htaccess Datei) + //falls ja, wird dieses Element in einem Array gespeichert + if($file != "." && $file != ".." && $file != ".htaccess" && is_file($dir_name . '/' . $file)) { //SAVE FILENAMES + $file_array[] = $file; + } + } + //die Arrays mit den Ordnernamen und den Dateinamen werden sortiert + asort($directory_array); + asort($file_array); + //in dieser Schleife werden die Ordnernamen aus dem sortierten Array + //ausgegeben und deren Inhalt jeweils noch einmal + //mit Aufruf dieser Funktion ausgelesen + foreach($directory_array as $directory_element) { //PRINT DIRECTORY + //hier wird der eindeutige Elementname fuer das JavaScript Menu festgelegt + //(der Pfad zu dem Ordner mit entfernten Sonderzeichen wie z.B. '/', da dieser einmalig) + $tempscriptname = Kastalia::ReplaceSpecialChars(substr($dir_name . '/' . $directory_element, strlen($conf['datastore']['location'] . '/'))); + echo "
  • \n"; + echo "\n"; + echo "\"directory\n"; + echo $directory_element; + echo "\n\n"; + echo "
  • \n"; + echo "
  • \n"; + echo "
    \n"; + //der Ordner wird nun mit einem erneuten aufrufen der Funktion ausgelesen und der Inhalt bearbeitet + ScanDirectory($dir_name . '/' . $directory_element); + echo "
    \n"; + echo "
  • \n"; + } + //in dieser Schleife werden die dateinamen aus dem sortierten Array + //ausgegeben und jeweils nochmal ueberprueft + //ob diese Dateien mit Kastalia verschluesselt wurden oder nicht + foreach($file_array as $file_element) { + //hier wird ueberprueft, ob die Datei von Kastalia verschluesselt wurde (die Endung ".kastaliaenc" wird dafuer benutzt) + if(substr($file_element, -12) == ".kastaliaenc") { //PRINT ENCRYPTED FILE DOWNLOAD + echo "
  • \n"; + //hier wird der Link fuer das Entschluesselungs Menu fuer diese Datei zusammengesetzt + //aus dem Link werden vorher alle Zeichen die in der URI nicht stehen duerfen ersetzt (bsp. " " mit "%20") + echo "\n"; + //hier wird bei der Ausgabe des Dateinamens die Endung .kastaliaenc entfernt + echo substr($file_element, 0, -12); + //Nutzerfreundliche Ausgabe der Dateigroesse (auf 2 stellen hinter dem Komma gerundet) + $tempfilesize = filesize($dir_name . "/" . $file_element) / 1024 / 1024; + if($tempfilesize < 1) { + //hier wird ueberprueft, ob die ermittelte Dateigroesse negativ ist + //dies kann passieren, wenn die Datei groesser als 2GB ist und der 32Bit signed integer + //Wert der Rueckgabe von filesize() zu gross ist + if($tempfilesize < 0) { + echo " (>2GB)"; + } + else { + echo " (" . round(filesize($dir_name . "/" . $file_element) / 1024, 2) . "kB)"; + } + } + else { + echo " (" . round($tempfilesize, 2) . "MB)"; + } + echo "\n"; + echo "
  • \n"; + } + //falls es sich nicht um eine von Kastalia verschluesselte Datei handelt + else { //PRINT UNENCRYPTED FILE DOWNLOAD + echo "
  • \n"; + //hier wird der Link fuer das herunterladen der Datei zusammengesetzt + //aus dem Link werden vorher alle Zeichen die in der URI nicht stehen duerfen ersetzt (bsp. " " mit "%20") + echo "\n"; + echo $file_element; + //Nutzerfreundliche Ausgabe der Dateigroesse (auf 2 stellen hinter dem Komma gerundet) + $tempfilesize = filesize($dir_name . "/" . $file_element) / 1024 / 1024; + if($tempfilesize < 1) { + //hier wird ueberprueft, ob die ermittelte Dateigroesse negativ ist + //dies kann passieren, wenn die Datei groesser als 2GB ist und der 32Bit signed integer + //Wert der Rueckgabe von filesize() zu gross ist + if($tempfilesize < 0) { + echo " (>2GB)"; + } + else { + echo " (" . round(filesize($dir_name . "/" . $file_element) / 1024, 2) . "kB)"; + } + } + else { + echo " (" . round($tempfilesize, 2) . "MB)"; + } + echo "\n"; + echo "
  • \n"; + } + } + echo "\n"; + //nachdem der Ordner vollstaendig ausgelesen wurde, wird dieser geschlossen + closedir($dir_handle); + } + else { + echo "Error: Can't open directory \"$dir_name\"!"; + } +} + +//diese Funktion liest den temporaeren Ordner von Kastalia aus +//und loescht alle Dateien die zu lange existieren +function CleanDirectory($dir_name) { + //die Konfigurationsdatei von Kastalia wird includiert + //damit die Konfigurationen auch innerhalb dieser Funktion benutzt werden koennen + require(KASTALIA_BASE . '/config/conf.php'); + if($dir_handle = opendir($dir_name)) { + //der Inhalt des Ordners wird in dieser Schleife durchgegangen und jedes Element bearbeitet + //falls es sich um eine Datei handelt, wird die ctime von dieser Datei ermittelt + while(false !== ($file = readdir($dir_handle))) { + //Ueberpruefung ob es sich bei dem Element um eine Datei handelt (und keine .htaccess Datei) + if($file != "." && $file != ".." && $file != ".htaccess" && is_file($dir_name . '/' . $file)) { + //hier wird die ctime der Datei fuer weitere Pruefungen ermittelt + if($file_ctime = filectime($dir_name . '/' . $file)) { + //die ctime der Datei (wird angegeben in Sekunden seit January 1 1970 00:00:00 GMT) + //wird mit der in der Config angegebenen Dauer (in Minuten) + //wie lange eine temporaere Datei existieren darf addiert... + $file_ctime = $file_ctime + (60 * $conf['upload']['tempctime']); + //... um zu ueberpruefen, ob die aktuelle Zeit in Sekunden seit der Unix Epoche + //(January 1 1970 00:00:00 GMT) groesser oder gleich der errechneten Zeit ist + //die eine temporaere Datei existieren darf + if($file_ctime <= time()) { + //wenn die aktuelle Zeit in Sekunden seit der Unix Epoche groesser ist + //wird die temporaere Datei geloescht + if(!unlink($dir_name . '/' . $file)) { + //falls ein Fehler beim loeschen auftritt, wird eine Error Nachricht ausgegeben + //aber das Skript nicht abgebrochen, da der Rest noch abgearbeitet werden soll + echo "Error: Unable to delete temporary file!
    \n"; + echo "This constitutes a breach of security because the content of the uploaded file stored unencrypted.
    \n"; + echo "Please contact the administrator to have the temporary file " . $dir_name . '/' . $file . " deleted.\n"; + } + } + } + else { + //falls die ctime der Datei nicht ermittelt werden kann, wird eine Nachricht ausgegeben + //aber nicht abgebrochen, da der Rest des Skriptes noch abgearbeitet werden soll + echo "Error: Unable to get the ctime of the file: " . $dir_name . '/' . $file . "!
    "; + echo "This constitutes a breach of security because the uploaded file will not be deleted and the content stored unencrypted.
    \n"; + echo "Please contact the administrator to have the file deleted.\n"; + } + } + } + } + else { + echo "Error: Can't open directory \"$dir_name\"!"; + } +} +?> + + \ No newline at end of file diff --git a/kastalia/po/README b/kastalia/po/README new file mode 100644 index 000000000..a985e94aa --- /dev/null +++ b/kastalia/po/README @@ -0,0 +1 @@ +see horde/po/README diff --git a/kastalia/temp/.htaccess b/kastalia/temp/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/kastalia/temp/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/kastalia/templates/common-footer.inc b/kastalia/templates/common-footer.inc new file mode 100644 index 000000000..fffa1d915 --- /dev/null +++ b/kastalia/templates/common-footer.inc @@ -0,0 +1,17 @@ + + +notify(array('listeners' => array('audio', 'javascript'))); ?> + + diff --git a/kastalia/templates/common-header.inc b/kastalia/templates/common-header.inc new file mode 100755 index 000000000..42411868b --- /dev/null +++ b/kastalia/templates/common-header.inc @@ -0,0 +1,32 @@ + + + + + +' : '' ?> + + + + +get('name'); +if (!empty($title)) $page_title .= ' :: ' . $title; +if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) { + echo "\n"; +} + +Horde::includeScriptFiles(); + +?> +<?php echo htmlspecialchars($page_title) ?> + + + + +> diff --git a/kastalia/templates/menu.inc b/kastalia/templates/menu.inc new file mode 100755 index 000000000..dc4aabd6c --- /dev/null +++ b/kastalia/templates/menu.inc @@ -0,0 +1,4 @@ + +notify(array('listeners' => 'status')) ?> diff --git a/kastalia/themes/graphics/directory_closed.gif b/kastalia/themes/graphics/directory_closed.gif new file mode 100755 index 0000000000000000000000000000000000000000..c4f1138bf9e9e3c0b491032059049950bdcb58dc GIT binary patch literal 278 zcmZ?wbhEHbRAUfec+9~71Pu)hbLKFdJD2?b+?@aa=Y0SE{r~@S|8W4te>TZQsfi`2 zDGF)%MG7AIMJcHYi3J5YnaPPInfZAN-igH}i8+~xdU|?X8W|-e1y=g{873*I#d`Tg z>6#3RKUo;L7&sVoKsJNiz`)WhaME-2UW?afe~T(`R4h@EI36f+=ml$mO!%RM`_2+s zjSv5~G3dJLEaPInzVtcspB9nEEZ4O{lO&fNeA(=`Bvfmm!Lg*Oh7zj|0j`4&ul`uI zC1dBC7a>0HW>2@Th*PVsDXuSb@ON&jWhsd?GIB2NOX=@WjklO%Q94UFYtiD&12zI~zq literal 0 HcmV?d00001 diff --git a/kastalia/themes/graphics/directory_open.gif b/kastalia/themes/graphics/directory_open.gif new file mode 100644 index 0000000000000000000000000000000000000000..09755aafcd40895a2615dd392f8833d0f1313ea2 GIT binary patch literal 210 zcmZ?wbhEHbRAUfec+9~71Pu)hbLKFdJD2?b+?@aa=Y0SE{r~@S|8W4tpDc`A3>*wP zAe|sH7+C5BPI|81Yw`N5wV1+--pL6P$2EH#U+7SS*+V83Q)Qy*y>wGugfu~Y62`xRI8UkI-YglJ~@on6)Ns`+`dh5maMiFv17?{el pEA#SAi&;8d8{PHw#nn=4yOU3W%PTA_tf;8i(9m$^%$fgSp!k!8k&A(yL5BedKx!G7 zoho+S`Dbv-b2YO>3&WalN5!sN>5R&eCC^%xN#1tK_c|Atd%9xr^2U40DZ-pB(;xAk Z{Lx$C^L)}u2@VrUzA2~PsxdHF0{{thEouM& literal 0 HcmV?d00001 diff --git a/kastalia/themes/graphics/file_enc.gif b/kastalia/themes/graphics/file_enc.gif new file mode 100644 index 0000000000000000000000000000000000000000..8bd8bac3d84b7168a464495ce4e7ca46d08d47c8 GIT binary patch literal 664 zcmZ?wbhEHbRAUfeIF`@gpeAIiDQ#$I=&U0f7#J876ciB=(H^Q;66c+onmRc~c1nzF zT3T9WX6B3})%^VYxoO&SGYuCNSoT$<&Z>-9TkW)^%4}Vo^R^nx_4TgXYppgkxOH}R zZfx?{*>hh|}D{HE^Y}s;kUH#UrTd!|y z-o1PGogIA#4jj0*d*Z#lQ;r-t@?ih;hX;UY#-l^CpPgEE;lhQB7cbtrb?eTZJ9qEi z{ZBej{O9SNSX`2rlbNWHmS3dckzbUOs^C_Xn44OjUzE+Ikx^1oV5P60VUm(ste0Pu zuAiBgl3JlxkWpZtnU|56Q(~J9)vw8*_>+Z^i=m!DhXDvc5zN58qM^R2xuvzOy`!_M zjW;DPmbH6Qr+khKe{>e-P zG{DVJV0))QMof^Gi;!+w{{SeJqU3O;n}0?zQQrM+JJi zI$Nqs@V#!;ObYR~wzf5OiRftPpU`C(HtWZQgNKiC2nccUEh=bn>EISOD>)JHu;EC* K0yirYgEau9=SrRc literal 0 HcmV?d00001 diff --git a/kastalia/themes/graphics/kastalia.png b/kastalia/themes/graphics/kastalia.png new file mode 100755 index 0000000000000000000000000000000000000000..99460f978ef8ddd735a31f28963500a275fb3827 GIT binary patch literal 622 zcmV-!0+IcRP)WFU8GbZ8({Xk{QrNlj4iWF>9@00GiTL_t(I%axN)NRx3G z$3O3%^~Ni<%zO!wW_c+~8MEjTb&!&vS%G-bgM<)WJQ>s>5)VNg^0qXrSQ!l~Fz2?5 zd65xj!j74Th>h@4(~Wn(y_I`Agu>Xn-ufP&KOdeid>;wm>&S?$1p>HfZDJzxGLZ-l zTUKhTrUGbwKYB-pE5MshH}5Pa46Cc`^7)L*U0t)=7M%3cEb#pH4FV_H*&#{HJ$p=W@cMRtr(x_R5~+T{ zyEm`#9%-Y!cYt&K0|;3|m}bSCBOtT5z+7~iOZ`^>5cwPn$s`_4a|aZ2>r7tlqpk3T z;#wMjPs{Jo8w^yn(s4y)G5iqQ%+Y%06zdYQ9-gmTG2KZs-S$aA~Q-i{x z-fJj(nkk7i+OIqZd_G4&nT3_;6y&q`yU(N49|gNea%Ps=rei3o$NhrC!5+TPPtx3X z6HwT+OrAWL=H67iYF5eso|;-thhmhFu>MGS00>XjQ{`u07*qo IM6N<$fW zAI33b7$1gG{_hJHFZ%>ngo~@oLg>e!|HozA-%tD?tLXGd|FOV$+;39xfJZ_TIi-!C zWziLNUBf(IUEhDQorHfj>@gXUnEt_Uyw&*BS#x{fC#h>IWqpG68?H89QWOmd%6En- zPkbI%Whola9+s*?hH*F3Ak&KF4c)+$dB34oaGynAU)k^e z&em%y^Xw=_*1{|t%Mk0&tLwlzGZhL)y>8EhyDlR)Pi;>21? z_HS?uo5`e_bd3@ipC~;zW{@x9qZf6#@shPew?FNl`SwGe<29zDf%|K(KIv6oU#i^uY%q9pNxKihG?BN0Cn7|M z(oHtgZT18T9X%HpAye_=wRX7f37X0xh6^lgiH;=w4KZ^;(5g*)HoaM!`S03;9~^B8 zefj$Z+CvyQVN}~Dl0 zwoWHPtTEy@*$`Jq#}8)bRWx)AxWB(}^PA=A|1KYRJh2J(nmiKooIEN&Vc0?lbINaC z%yG)))dr{BdNcx(6VY2Bc|-CBAm{$&yrjW8xcGz2dLM$OH*OkPB-QU=#4BNFc;Gi{ z=W+PjYFf9*%vZsy?G!c2u_RoMXIoCI5eGvlJJEZBq^EPPIpt%x)BeNl5qpcA@M1+d z`{5s&Vs-Z8aHOJTC-j_S9)j=OsA+e_B!0`m0Nbf&2Mrwnh*I=7bOgIs}mZK$#;8zVexz#?6BrtBU z?3Y+r<>Ym})K%I0j*qhcXZ7~i)s1NXO{3~!L;QvJ`OdJbzF<1T4(MC`R}eN*91;b> zR(X00tDY_mnzb3I7rc)J>au~wKuu_Fht#})n~)m*g&wGJ1T9e0Q&m9ixT~B&5;*!e z(LlWs5z$NCll2z$&%euh4l1dQ=N!5q>p^ru8l6c}|Gh%yUlRmQf1qgjs;^@ZP|oAeXgC@;|qF}+`&_kPjq<*88{p}99R zk4T#IbFDntUfdRAgyvpsCYXB*AD*dt8XNHKmjL}?BZSUB7y!`ZrqGE1O@kc}nKTN0 zt&L1XYW?XlW~?en1vl2odeJOufMgw4Cr=75Fyh@a!uE`!|93NC(!b32&@assjPZew zgit*SylNtxL02>9hk)HJ_1F-%s3~7ObLm-N_Wg1TFwfk)5SViY0->Ovv;(trqaK*` zMVdMr8TXzzfG!gsU?!{Jj#_#jnkDe3uIK73XGw)de8VgAsyENQH{?t{e2bp~?Z}`U zlQF%I(r{4D8HV^}kDTSW>~(e*WVTc>4?yOPM~BV;vmG6L?u4c2TI%7mVD2sGIuGWD zM@eqI55t=M9)YLdz>XD}utkiAHnP~0zLYNGFa0%D1sBBN`q3v}kU#c@mzBNX%pijOyja zyB5-dw6_%c_Y)7Gzxpn#Z8YdXbnnSHnFQL%xsj!5j6`2h=s9`Jl~AGUdW#(y#!E=a zP_?otpNI^;0ilD~xAooJzwDj;py!ZZ$w;0Xf!!Ah`;aYF?j(!A22)G0p_u&l;`qD_ zgV_&GGZS^=j6PHeX}c~_?jR*`%n0|Kx6F<=)gxusOLabo`r9llRFA>h_?4r}@TOOf zfe5KRTZ+9ijh7UnpR0>y4YX|cpJ zWR7_|mdQ8J)6iNo5fQ5MVzCewo`j@U>n%pvTbAJ)llDesShUVcLrE(vP|~2%D~*fR zgJr1n>KPp!b}KWMa7>!Yz*O@EGBwx0wIgQA-jehiOPz&& zp@xz^nX>>S{V6E*iZ2CVc~Rhc=2gK&Q0lHu%N?Nhg-6B;Ya;#BCpX`2Hv|s( z+~`Q{|F+VE6xI4*&u-*t{7>nlH8%Zn7^jKA#LeLl*T@X;Q)c@uGz(7EE#W#CT!~zw zp;{c_(mzw`Hv2@2;N|o<+1{wLfKnfhEZu%O8uV|7? zN(PEQo<^Vn>L6m_f?2EU1dCy~X09N7*TF4e%f4OjOQ@pDuKdMdoRK4&6KSZa}u}Z75PD%9D2Px2YMl?zQ=oz* zHy5*x*W}iVh6G=|ZG9a=ttiV5IScgl51M#pW0d)CXT_s4?H`s!wp#d*pDK|753 z10Iw2gZ<@Qeb21a)ziRIJafiXcEDcDx>%bVmpUXkt<3|IIw#^$VFQs}v9(h*>r_cc zP~Y{SXL0pN_9QYkkd56XRi@~bcVNtZ0&_mozFrJJrj-@i`JO%&+6FE~K;@{7GK<`R z36j4II_S-(k1^VjwabZi4!!oTJ1oN^VCa=K@ybEab3oA0{J=k8-e(2XB z8D<3M9B3`Pb`}cS9u!q|*63JL;-OiO#P)~k%i}~5QbwvCbq8keCurv}WgEoIqgrB- zo!El2c!pb62qXv8f^-X}4&$En68#60#v=>55ar#UKns!dv}C~J1gLacUhSS);3KyO zet-V>2dqkf4h5AyHYCUe?EvWGt$oB!;i|Ly{fdR{4|@I)H1b1%8>2OlVR{g2TPJ0R z^z1U2-AbU$WAZnO?MJj|g`E@dp&S)XZRWFL)%cYbDh_op{Uv&gv*}n#%TZ2rBeV`l zT>$+Fgx*&N&|o8n&-VuCdjP!_Bz<&9a0jfz$j>)cuokPQ1m-tC3>><2uK7a$^-r^` zyK8-DjA;zL|0#_oxt6vP2ImtvbD3hA7I0R1gMTeJYZyCzowMqc@aMZ}rGIf}Lbe<NRss;A4@(IYU#G^3WU=Kg}%Dqr=BhNdzu_yIhxQ zblgI0vXUw;zUAX~tgJ1@iCqPY1sedXW<2(p4gHRiZyV&4^3aVo4`)huuV0n6)++_fy|%7kr5+Q zlrv@-8ifFCBG=nCAhdH(JI(_%I5mN+Vb4{k?mf5yuE9Rj z-Sl?=^esG64A2V}LxZ~h1HYiu!xeYB>wgJssj^Wg{q6Gzg~!#M($46ilf?T)vdKgLX2;zYBY1sN_KsFH*Ek@lb# zBt08ST7JgW49$=9+RmvRQ;r{awC|nB&vX9PS~$5=SkbWGvsgI0rY9?Cfy38<61rAMU{C)!r&ozD~X9&1*uEvOQu-=9qV>3;GdVaWe)SniQM=R+yuUFW=d$*gP%0 zKGL9?vgUSs@2}V1In``^e(=jGB&{vf4a?Sq5O(wQ*i2ZtiNK#=@TQ2-JGBWiJEd@j z2_A0o)`hav@}uf(9cERj>eZ+oqtxere~a+qzBvm*kM^Uobjb~9e@WYCIyehDRKt&X zj}J5c4DNO#YI0@fDaWrr+6M#uINloI2KupSZ{Q(e)en}AYr`Yu*==q#tdHog45cW6 zk)=UVQvBU;9C|BZ7q}hEz}+NeQGVcCMr!S$)^7j-& zM~}*m?nZfE0#MTi?=Z$^fMpn*?3x9=3T>lyfLEcpvMu0MXxHf@_X`H5Jo|-SsvH{r z>9WOE@>rH#Y7M2CYVLr;v~8Nm7rbPkn|R}hd>oy#UuF zLsHtyPk=ExJ@&>@v}k6TFKg6n{ppjSI%m=g$L%Qi464UPkTftWvMtH(?;O9d#z{22e~Y;3DiS>2AgjpP>AEubLcV|2M&@p>g~Uw zSr~#PjH?r*8uLKX{kn^PKIyK8iC{Z??(E0#YWLB8tls}!zHu3}62o@gq(J>h@@xS8 zSnn+Y>TO$}L<9ATy}y1VtV-{=0IBb^KLP!q`Rl_#KQz1A`UwiU9{Vqe(D)xO{i^X}MZwv^WrBI1~Ph^W3EGU7`0@N98%+NA3u) z|1IgA`F`rXtR4epIk@^?KmR&#?k)n2*!LK;_=9Bdw#f$jpX|A6Xv;6n)?R_ literal 0 HcmV?d00001 diff --git a/kastalia/themes/graphics/menu/upload.png b/kastalia/themes/graphics/menu/upload.png new file mode 100644 index 0000000000000000000000000000000000000000..1e228254b68100302bed2e20d3cbbfa93112f70c GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPSCliN|!O?mB_klv!JzX3_EKX0obk>u_QN;D(`l^MJ z9BChz1k%~=aQ-V{NmF1`bW?0%v=Edy*kF;wpwAetrm(B*R#>rc5gqoP(y3- z%;hsHBTrB9k~F(8(IQHo$<2er`{`#>o|7BhM@I~&qq;n5yLc%s{@Rpc%uWO9k zs?qx;vU}Y`yX?TS1^!VzyuaE$*>@W)%5P6S{U@?S`Bz9~_w`w><`>?(ot9s-@raR9 zSi}R)`-|`7rfJQ*`B-v(#Sv$hnlm*Yo$ox5V&9=Lv$DT@jq;<_PZ^Dh<-;w0u`ave Vag(o?dp*#L44$rjF6*2UngAA%f4~3$ literal 0 HcmV?d00001 diff --git a/kastalia/themes/screen.css b/kastalia/themes/screen.css new file mode 100755 index 000000000..a219ca1bb --- /dev/null +++ b/kastalia/themes/screen.css @@ -0,0 +1,44 @@ +a.kastalia_directory { + text-decoration: none; + font-weight: bold; + color: #000000; +} + +div.kastalia_filelist { + margin-left: 0px; +} + +img.kastalia_picture { + border: 0px; + margin-right: 2px; +} + +li.kastalia_directory { + list-style: none; + display: block; + padding-top: 5px; + padding-left: 4px; +} + +li.kastalia_file { +/* list-style: none;*/ + list-style-image: url('graphics/file.gif'); + padding-left: 4px; +} + +li.kastalia_file_enc { +/* list-style: none;*/ + list-style-image: url('graphics/file_enc.gif'); + padding-left: 4px; +} + +select.kastalia_upload { + width: 300px; +} + +ul.kastalia_root { + list-style-position: inside; + margin-left: 5px; + padding-left: 10px; + vertical-align: middle; +} \ No newline at end of file diff --git a/kastalia/upload.php b/kastalia/upload.php new file mode 100644 index 000000000..e82ecbc1e --- /dev/null +++ b/kastalia/upload.php @@ -0,0 +1,207 @@ + + */ + +//das absolute Kastalia directory wird als Konstante definiert +//um damit config Dateien zu includieren +@define('KASTALIA_BASE', dirname(__FILE__)); + +//die Basis von Kastalia wird includiert +//um die Anmeldung zu ueberpruefen +require_once(KASTALIA_BASE . '/lib/base.php'); +//die Konfigurationsdatei von Kastalia wird includiert +//um alle Kastalia Einstellungen in diesem Skript nutzen zu koennen +require(KASTALIA_BASE . '/config/conf.php'); +//das Menu von Kastalia wird includiert +//damit das Menu dem Benutzer angezeigt wird +require_once(KASTALIA_BASE . '/list.php'); + +echo "
    Kastalia Datastore - Upload
    \n"; +echo "
    \n"; + +//nun wird ueberprueft, ob das hochladen von Dateien ueberhaupt erlaubt ist +//falls nicht, wird eine Meldung ausgegeben und das Skript beendet +if(!$conf['upload']['uploadenabled']) { + echo "File uploads are disabled!"; + exit(0); +} + +//hier wird ueberprueft, ob der Zielordner zum hochladen gesetzt ist +if(isset($_POST['kastalia_targetlocation'])) { + //hier wird mittels POST der uploadzielordner ermittelt + $kastalia_targetlocation = $_POST['kastalia_targetlocation']; + //Ueberpruefung nach den Zeichenfolgen "/." und "./" damit + //durch das Manipulieren der Variable kastalia_targetlocation + //keiner aus dem kastalia Datastore entkommen kann (durch Nutzung von "../") + if(strpos($kastalia_targetlocation,'/.') === false && strpos($kastalia_targetlocation,'./') === false) { + //ueberpruefung ob die Datei eine ".htaccess" ist, falls ja wird zur Sicherheit abgebrochen, damit niemand diese + //ueberschreiben kann oder damit regeln fuer den webserver festlegen kann + if(Kastalia::ReplaceSpecialChars($_FILES['userfile']['name']) != ".htaccess") { + //hier wird serverseitig ueberprueft, ob die hochgeladene Datei die Endung ".kastaliaenc" besitzt + //falls ja wird mit einem Fehler abgebrochen, da diese intern von Kastalia verwendet wird + //um von Kastalia verschluesselte Dateien ausfindig zu machen + if(substr(Kastalia::ReplaceSpecialChars($_FILES['userfile']['name']), -12) == ".kastaliaenc") { + echo "Error: File extension \".kastaliaenc\" not allowed!"; + exit(1); + } + //hier wird der absolute Pfad mit Dateiname (Sonderzeichen werden entfernt) zusammengesetzt + //wohin die Datei hochgeladen werden soll + $target_directory = $conf['datastore']['location'] . $kastalia_targetlocation; + $target_location = $target_directory . "/" . Kastalia::ReplaceSpecialChars($_FILES['userfile']['name']); + //diese Funktion fuehrt den Upload aus + UploadFile($target_location); + } + else { + echo "Error: .htaccess files not allowed for upload!"; + exit(1); + } + } + else { + echo "Error: \$kastalia_targetlocation in upload.php contains illegal characters!"; + exit(1); + } +} +//falls der Dateiname nicht gesetzt wurde, wird mit einer Fehlermeldung abgebrochen +else { + echo "Error: \$kastalia_targetlocation in upload.php is not set!"; + exit(1); +} + +//diese Funktion ueberprueft Fehler die beim upload vorkommen koennen +//und fuehrt den upload durch +function UploadFile($upload_target) { + //die Konfigurationsdatei von Kastalia wird includiert + require(KASTALIA_BASE . '/config/conf.php'); + if(!empty($_FILES)) { + switch ($_FILES['userfile']['error']) { + case 0: //UPLOAD_ERR_OK + //hier wird die in der Config eingestellte maximale Dateigroesse mit + //der Dateigroesse der hochgeladenen Datei abgeglichen + if($_FILES['userfile']['size'] <= $conf['upload']['maxfilesize']) { + //Sicherheitsueberpruefung ob Datei mittels HTTP POST hochgeladen wurde + //und nicht eine andere Datei weiterbearbeitet wird + if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { + //hier wird ueberprueft ob der Upload verschluesselt gespeichert werden soll + if(isset($_POST['kastalia_secure_store']) && $_POST['kastalia_secure_store'] == true) { //SECURE STORE + //hier wird ueberprueft, ob das verschluesselte Speichern von Dateien ueberhaupt aktiviert ist + //falls nicht, wird die Weiterverarbeitung abgebrochen und eine Meldung ausgegeben + if(!$conf['upload']['securestore']) { + echo "Encryption/Decryption is disabled!"; + exit(1); + } + //sollte die Datei mit der Endung ".kastaliaenc" schon existieren, wird ein "_" an sie drangehaengt, + //damit die existierende Datei nicht ueberschrieben wird + while(file_exists($upload_target . ".kastaliaenc")) { + $upload_target = $upload_target . "_"; + } + //hier wird serverseitig ueberprueft ob das Passwort fuer die Verschluesselung leer ist + //falls ja, wird mit einem Fehler abgebrochen, da dies verboten ist (und die temporaere Datei von + //PHP automatisch geloescht) + if($_POST['kastalia_password'] == "") { + echo "Error: Empty passwords not allowed!"; + exit(1); + } + //die hochgeladene Datei wird nun ersteinmal in das temporaere Verzeichnis von Kastalia verschoben + //und mit der Endung "_kastalia" versehen + if(move_uploaded_file($_FILES['userfile']['tmp_name'], $conf['upload']['tempdir'] . "/" . basename($_FILES['userfile']['tmp_name']) . "_kastalia")) { + //die SESSION Variablen fuer die Verschluesselung werden gesetzt + $_SESSION['kastalia_mode'] = "encrypt"; //diese Variable gibt den Modus an in welchem das Skript encrypt_decrypt_files.php ausgefuehrt werden soll + $_SESSION['kastalia_input_name'] = $conf['upload']['tempdir'] . "/" . basename($_FILES['userfile']['tmp_name']) . "_kastalia"; //diese Variable gibt die zu verschluesselnde Datei an + $_SESSION['kastalia_output_name'] = $upload_target; //diese Variable gibt das Ziel fuer die verschluesselte Datei an + $_SESSION['kastalia_part_number'] = 0; //diese Variable gibt die aktuelle Verschluesselungsrunde an (die Beginnrunde ist immer 0) + $_SESSION['kastalia_key'] = $_POST['kastalia_password']; //diese Variable beinhaltet das Passwort, welches fuer die Verschluesselung benutzt wird + //mit der encrypt_decrypt_files.php wird die Verschluesselung fuer die Datei ausgefuehrt + //(diese besteht aus mehreren Teilschritten wobei der Browser automatisch das Skript in Intervallen neu aufruft) + include('encrypt_decrypt_files.php'); + } + else { + echo "Error: File couldn't be moved to temporary directory!"; + //Debuging + //print_r($_FILES); + exit(1); + } + } + else { //UNSECURE STORE + //sollte die Datei schon existieren, wird ein "_" an sie drangehaengt, + //damit die existierende Datei nicht ueberschrieben wird + while(file_exists($upload_target)) { + $upload_target = $upload_target . "_"; + } + //die hochgeladene Datei wird nun an die dafuer vorgesehene stelle kopiert + if(move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_target)) { + echo "File successfully stored under " . substr($upload_target, strlen($conf['datastore']['location'] . "/")) . " !\n"; + } + else { + echo "Error: File couldn't be moved!"; + //Debuging + //print_r($_FILES); + exit(1); + } + } + } + else { + echo "Error: Used file is not uploaded via HTTP POST!"; + exit(1); + } + + } + else { + echo "Error: The uploaded file exceeds the configured file size!"; + exit(1); + } + break; + case 1: //UPLOAD_ERR_INI_SIZE + echo "Error: The uploaded file exceeds the upload_max_filesize directive in php.ini!"; + exit(1); + break; + case '2': //UPLOAD_ERR_FORM_SIZE + echo "Error: The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form!"; + exit(1); + break; + case 3: //UPLOAD_ERR_PARTIAL + echo "Error: The file was only partially uploaded!"; + exit(1); + break; + case 4: //UPLOAD_ERR_NO_FILE + echo "Error: No file was uploaded!"; + exit(1); + break; + case 6: //UPLOAD_ERR_NO_TMP_DIR + echo "Error: Missing a temporary folder!"; + exit(1); + break; + case 7: //UPLOAD_ERR_CANT_WRITE + echo "Error: Failed to write file to disk!"; + exit(1); + break; + case 8: //UPLOAD_ERR_EXTENSION + echo "Error: File upload stopped by extension!"; + exit(1); + break; + default: + echo "Error: Unexpected value of \$_FILES['file']['error'] in upload.php!"; + exit(1); + break; + } + } + else { + echo "Error: \$_FILES is empty!

    "; + echo "Possible reasons:
    "; + echo "-upload_max_filesize, post_max_size or memory_limit value is too low in php.ini.
    "; + echo "-file_uploads is set to Off in php.ini."; + exit(1); + } +} +?> + + \ No newline at end of file diff --git a/kastalia/upload_menu.php b/kastalia/upload_menu.php new file mode 100644 index 000000000..3e07018ed --- /dev/null +++ b/kastalia/upload_menu.php @@ -0,0 +1,258 @@ + + */ + +//das absolute Kastalia directory wird als Konstante definiert +//um damit config Dateien zu includieren +@define('KASTALIA_BASE', dirname(__FILE__)); + +//die Basis von Kastalia wird includiert +//um die Anmeldung zu ueberpruefen +require_once(KASTALIA_BASE . '/lib/base.php'); +//die Konfigurationsdatei von Kastalia wird includiert +//um alle Kastalia Einstellungen in diesem Skript nutzen zu koennen +require(KASTALIA_BASE . '/config/conf.php'); +//das Menu von Kastalia wird includiert +//damit das Menu dem Benutzer angezeigt wird +require_once(KASTALIA_BASE . '/list.php'); + +echo "
    Kastalia Datastore - Upload
    \n"; + +//nun wird ueberprueft, ob das hochladen von Dateien ueberhaupt erlaubt ist +//falls nicht, wird eine Meldung ausgegeben und das Skript beendet +if (!$conf['upload']['uploadenabled']) { + echo "
    "; + echo "File uploads are disabled!"; + exit(0); +} +?> + + + + + + + +

    notice: cookies and javascripts must be enabled to upload files! | maximal upload size: + + + +

    + + + + + + + +
    +
    +choose file: + + +
    + +encrypt file?:\n"; + echo "\n"; + //dieser Teil wird nur angezeigt, wenn die checkbox zum + //verschluesselten speichern der Daten aktiviert ist + echo "
    \n"; + echo "
    password:\n"; + echo "\n"; + echo "\n"; + echo "
    suggested password:\n"; + echo "\n"; + echo "
    \n"; + } + //falls das temporaere Verzeichnis nicht beschreibbar ist, wird eine Warnmeldung ausgegeben + //und die Option Daten verschluesselt zu speichern wird ausgeblendet + else { + echo "
    Warning: The option to store files encrypted is enabled by the administrator but still deactivated by Kastalia itself!
    \n"; + echo "Check if the temporary directory exists and is writable.\n"; + } +} +?> + +
    +
    +

    choose folder:

    + +
    +
    + + +"; + echo substr($directory_element, strlen($conf['datastore']['location'])); + echo ""; + } + //die Funktion wird noch einmal aufgerufen mit dem aktuellen Ordner um zu ueberpruefen + //ob Unterordner Schreibrechte enthalten + ScanDirectory($directory_element); + } + closedir($dir_handle); + } + else { + echo "Error: Can't open directory \"$dir_name\"!"; + exit(1); + } +} + +//diese Funktion generiert ein zufaelliges Passwort mit der uebergebenden laenge +function CreateRandomPassword($passwordlength) { + //diese Zeichen koennen alle in dem Passwort vorkommen (beliebig veraenderbar) + $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-#*!$%="; + $password = ''; + for($i=0;$i<$passwordlength;$i++) { + $randomnumber = mt_rand() % strlen($chars); + $password = $password . substr($chars, $randomnumber, 1); + } + return $password; +} +?> + + \ No newline at end of file -- 2.11.0