pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] [level-comment-tool.pingus] 21 new revisions pushed by addr


From: pingus
Subject: [Pingus-CVS] [level-comment-tool.pingus] 21 new revisions pushed by address@hidden on 2011-10-28 15:05 GMT
Date: Fri, 28 Oct 2011 15:06:39 +0000

21 new revisions:

Revision: 3b0fce3692e1
Author:   David Philippi <address@hidden>
Date:     Fri Apr  9 07:04:34 2004
Log:      added level comment tool
http://code.google.com/p/pingus/source/detail?r=3b0fce3692e1&repo=level-comment-tool

Revision: 82937786838d
Author:   David Philippi <address@hidden>
Date:     Fri Apr  9 11:18:26 2004
Log:      patch for better admin login
http://code.google.com/p/pingus/source/detail?r=82937786838d&repo=level-comment-tool

Revision: bdaac7fbebf6
Author:   David Philippi <address@hidden>
Date:     Sat Apr 10 07:21:06 2004
Log:      new file
http://code.google.com/p/pingus/source/detail?r=bdaac7fbebf6&repo=level-comment-tool

Revision: 4fff7f44cdb4
Author:   David Philippi <address@hidden>
Date:     Sat Apr 10 09:56:22 2004
Log:      changed level ending to .pingus
http://code.google.com/p/pingus/source/detail?r=4fff7f44cdb4&repo=level-comment-tool

Revision: 655f69e71040
Author:   David Philippi <address@hidden>
Date:     Sat Apr 10 11:23:55 2004
Log:      some more changes for .plf --> .pingus
http://code.google.com/p/pingus/source/detail?r=655f69e71040&repo=level-comment-tool

Revision: 1f9594470129
Author:   David Philippi <address@hidden>
Date:     Sun Apr 11 08:10:04 2004
Log:      tiny update
http://code.google.com/p/pingus/source/detail?r=1f9594470129&repo=level-comment-tool

Revision: 00ca3a546eaa
Author:   David Philippi <address@hidden>
Date:     Sun Apr 11 10:43:26 2004
Log:      behaviour patch
http://code.google.com/p/pingus/source/detail?r=00ca3a546eaa&repo=level-comment-tool

Revision: 3320cc4e6a4b
Author:   David Philippi <address@hidden>
Date:     Mon Apr 12 15:39:53 2004
Log:      update
http://code.google.com/p/pingus/source/detail?r=3320cc4e6a4b&repo=level-comment-tool

Revision: 67841941925d
Author:   David Philippi <address@hidden>
Date:     Tue Apr 13 09:01:49 2004
Log:      prettify display
http://code.google.com/p/pingus/source/detail?r=67841941925d&repo=level-comment-tool

Revision: 6cf27461afa1
Author:   David Philippi <address@hidden>
Date:     Wed Apr 14 13:42:00 2004
Log:      caching update
http://code.google.com/p/pingus/source/detail?r=6cf27461afa1&repo=level-comment-tool

Revision: b7434f61a3a0
Author:   David Philippi <address@hidden>
Date:     Thu Apr 15 13:51:34 2004
Log:      update
http://code.google.com/p/pingus/source/detail?r=b7434f61a3a0&repo=level-comment-tool

Revision: c58780d986f1
Author:   David Philippi <address@hidden>
Date:     Thu Apr 15 15:15:43 2004
Log:      cosmetic updates
http://code.google.com/p/pingus/source/detail?r=c58780d986f1&repo=level-comment-tool

Revision: de277ca4b5d1
Author:   David Philippi <address@hidden>
Date:     Fri Apr 16 11:04:36 2004
Log:      minimal fixes
http://code.google.com/p/pingus/source/detail?r=de277ca4b5d1&repo=level-comment-tool

Revision: 0c5f32fcc8eb
Author:   David Philippi <address@hidden>
Date:     Fri Apr 16 11:10:07 2004
Log:      tiny fix
http://code.google.com/p/pingus/source/detail?r=0c5f32fcc8eb&repo=level-comment-tool

Revision: bba82bdc9c99
Author:   David Philippi <address@hidden>
Date:     Sat Apr 17 01:23:17 2004
Log:      various corrections
http://code.google.com/p/pingus/source/detail?r=bba82bdc9c99&repo=level-comment-tool

Revision: 8ee50b5b015d
Author:   David Philippi <address@hidden>
Date:     Sat Apr 17 05:18:09 2004
Log:      db / demo upload patches
http://code.google.com/p/pingus/source/detail?r=8ee50b5b015d&repo=level-comment-tool

Revision: e1920097cfc7
Author:   David Philippi <address@hidden>
Date:     Wed Apr 21 11:43:26 2004
Log:      handle permissions better
http://code.google.com/p/pingus/source/detail?r=e1920097cfc7&repo=level-comment-tool

Revision: a3c30b694354
Author:   David Philippi <address@hidden>
Date:     Wed Apr 28 13:10:28 2004
Log:      login updates
http://code.google.com/p/pingus/source/detail?r=a3c30b694354&repo=level-comment-tool

Revision: f4e6305c909a
Author:   Jason Green <address@hidden>
Date:     Mon Dec  5 09:00:26 2005
Log:      Set SVN end of line style on everything to native....
http://code.google.com/p/pingus/source/detail?r=f4e6305c909a&repo=level-comment-tool

Revision: 8f72d1c616fe
Author:   Ingo Ruhnke <address@hidden>
Date:     Sat Feb 11 06:32:52 2006
Log:      Started Pingus-SDL branch
http://code.google.com/p/pingus/source/detail?r=8f72d1c616fe&repo=level-comment-tool

Revision: 6446569af542
Author:   Ingo Ruhnke <address@hidden>
Date:     Thu Aug 23 11:42:59 2007
Log:      - moved level_comment_tool/ and windows_installer/ to trunk
http://code.google.com/p/pingus/source/detail?r=6446569af542&repo=level-comment-tool

==============================================================================
Revision: 3b0fce3692e1
Author:   David Philippi <address@hidden>
Date:     Fri Apr  9 07:04:34 2004
Log:      added level comment tool


http://code.google.com/p/pingus/source/detail?r=3b0fce3692e1&repo=level-comment-tool

Added:
 /COPYING
 /README
 /default.css
 /file-assoc-help.html
 /gfx/actions/basher.png
 /gfx/actions/blocker.png
 /gfx/actions/boarder.png
 /gfx/actions/bomber.png
 /gfx/actions/bridger.png
 /gfx/actions/climber.png
 /gfx/actions/digger.png
 /gfx/actions/floater.png
 /gfx/actions/jumper.png
 /gfx/actions/miner.png
 /gfx/actions/rocketlauncher.png
 /gfx/actions/slider.png
 /gfx/actions/stopper.png
 /gfx/actions/superman.png
 /gfx/actions/waiter.png
 /index.php
 /level-cache.inc
 /mail-settings.inc
 /play_on-2.png
 /xml-search.inc

=======================================
--- /dev/null
+++ /COPYING    Fri Apr  9 07:04:34 2004
@@ -0,0 +1,340 @@
+                   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
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
=======================================
--- /dev/null
+++ /README     Fri Apr  9 07:04:34 2004
@@ -0,0 +1,38 @@
+Pingus Level Feedback System
+
+Installing:
+
+  1) Make sure you have installed
+     Apache and PHP 4.2+
+
+  2) Uncompress the tar into a directory where Apache
+     can see it.
+
+  3) Create directory 'comments' where the script will
+     write the xml comment files and MAKE IT WRITABLE
+     for Apache.
+
+  4) Create directory 'data' and copy Pingus source directories
+     'levels' into it.
+
+  5) Tweak your .htaccess - you might want to deny from all
+     comments/* and add "AddType application/pingus-level plf"
+
+Copyright
+
+Pingus Level Feedback System is (c) 2003 by Jarno Elonen
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+  MA  02111-1307, USA.
=======================================
--- /dev/null
+++ /default.css        Fri Apr  9 07:04:34 2004
@@ -0,0 +1,187 @@
+/* */
+
+h1,h2,h3,h4
+{
+  font-family: Sans-Serif;
+  margin-top: 0px;
+}
+
+h1
+{
+        background: #607f9b;
+        color: white;
+        border-style: solid;
+        border-color: black;
+       padding-left: 1em;
+        margin-top: 0px;
+        margin-bottom: .5em;
+}
+
+div.menu
+{
+        width: 205px;
+        margin-top: 10px;
+}
+
+div.menu a
+{
+       text-decoration: none;
+}
+
+a.menuitem:hover
+{
+        color: black;
+        background-color: #E0FfFF;
+}
+
+a.menuitem:visited
+{
+        color: black;
+}
+
+a.currentmenuitem:hover
+{
+        color:black;
+}
+
+
+a.currentmenuitem:visited
+{
+        color:black;
+}
+
+
+a.currentmenuitem
+{
+       font-size: 18px;
+       font-family: Sans-Serif;
+       text-align: center;
+        border-color: black;
+        border-style: solid;
+        border-width: thin;
+        background-color: #FFFFFF;
+        background-repeat: repeat-y;
+        color: black;
+        padding: 5px 0px 5px 0px;
+        display: block;
+        margin: 10px 15px 10px 15px;
+}
+
+a.menuitem
+{
+       font-size: 18px;
+       font-family: Sans-Serif;
+       text-align: center;
+
+        border-color: black;
+        border-style: solid;
+        border-width: thin;
+        background-color: #607f9b;
+/*     background-image: url(images/menubackground.png);*/
+        background-repeat: repeat-y;
+        color: black;
+        padding: 5px 0px 5px 0px;
+        display: block;
+        margin: 10px 15px 10px 15px;
+}
+
+div.mainbody
+{
+        background-color: silver;
+        color: black;
+        border-color: black;
+        border-style: solid;
+        padding: 1em;
+}
+
+p.warning {
+        font-size: 1.5em;
+        color: red;
+        background-color: black;
+       font-family: Sans-Serif;
+        border-style: solid;
+        border-color: red;
+        padding: .3em;
+}
+
+p.warning a {
+        color: red;
+}
+
+p.message {
+       background: gray;
+       border-style: dotted;
+       border-color: black;
+       border-width: 1px;
+       color: white;
+       padding-left: 1em;
+}
+
+table.question {
+       font-family: Sans-Serif;
+        background: #607f9b;
+        border-style: solid;
+        border-width: thin;
+        border-color: black;
+        color: white;
+        padding-left: 1em;
+}
+
+P.answer {
+        color: black;
+}
+
+TT.irc {
+        color: rgb(0,0,150);
+}
+
+TT.command {
+        color: rgb(200, 0, 0);
+}
+
+img
+{
+        border-style: none;
+}
+
+img.screenshot {
+        border-style: solid;
+        border-width: medium;
+}
+
+a img.screenshot {
+        border-color: red;
+}
+
+a:visited img.screenshot {
+        border-color: gray;
+}
+
+
+a:hover img.screenshot {
+        border-color: white;
+}
+
+
+a:visited {
+        color: rgb(0,0,100);
+}
+
+a:hover {
+        color: white;
+}
+
+a {
+        color: rgb(50,50,200);
+}
+
+
+body
+{
+       background-position: left top;
+       background-image: url(images/snow_background.jpg);
+       background-repeat: repeat-x;
+       background-color: #707f9b;
+        color: black;
+ /* desert #cdb09e; */
+}
=======================================
--- /dev/null
+++ /file-assoc-help.html       Fri Apr  9 07:04:34 2004
@@ -0,0 +1,71 @@
+<html>
+  <head>
+    <title>Configuring browsers to test Pingus levels</title>
+  </head>
+  <body bgcolor="#ffffcc">
+ <p><big><strong>Configuring browsers to test Pingus levels</strong></big></p>
+
+    <p>When you click on the <em>play</em>-link, the Pingus level comment
+    system tells your web browser that the file it is about to download is
+ of MIME type <code>application/pingus-level</code>. To make it convenient
+    to test the levels, you should configure your browser to launch Pingus
+    automatically. Here's how:</p>
+
+    <p><strong><em>Mozilla / Netscape:</strong></em></p>
+
+    <ol>
+      <li>Click on a 'play' link</li>
+      <li>Pick "Open it with" and browse for Pingus executable</li>
+      <li>(OPTIONAL) Pingus levels don't contain any potentially dangerous
+      executable scripts so you might want to make sure "always show this
+      dialog before handling files of this type" is *not* checked</li>
+      <li>Click OK</li>
+    </ol>
+
+    <p>ALTERNATIVELY: choose from the menu Edit / Preferences /
+    Navigator / Helper Applications / New Type, add...</p>
+    <ul>
+      <li>MIME type "application/pingus-level"</li>
+      <li>Extension "plf" and</li>
+      <li>Open it with "&lt;path and name of pingus executable&gt;".</li>
+    </ul>
+    <p>...and click OK.</p>
+
+    <p><strong><em>Konqueror:</strong></em></p>
+
+    <ol>
+      <li>Open Settings / Configure Konqueror / File Associations</li>
+      <li>Click 'Add'</li>
+ <li>Select 'application' as Group and type "pingus-level" as Type name.</li>
+      <li>Click OK</li>
+      <li>Click Filename Patterns / Add</li>
+      <li>Type "*.plf" and click OK</li>
+      <li>Click Application Preference Order / Add</li>
+      <li>Browse for or type the path to Pingus executable</li>
+      <li>Click OK</li>
+ <li>(OPTIONAL) Write a "Pingus level" (or anything) as Description and choose a nice icon</li>
+      <li>Click Apply or OK</li>
+    </ol>
+
+ <p>You can now also click level files on local disk to try them out.</p>
+
+    <p><strong><em>Internet Explorer:</strong></em></p>
+
+    <p>(Written on a non-english XP workstation; your mileage may vary)</p>
+
+    <ol>
+      <li>Click on a 'play' link</li>
+ <li>Don't save the file, but rather Open/View it with an application</li>
+      <li>Opt to pick an application manually</li>
+ <li>(OPTIONAL) Pingus levels don't contain any potentially dangerous executable + scripts so you might want to clear the "warn before opening" checkbox</li>
+      <li>Click OK</li>
+      <li>Find Pingus with "browse" if it's not already listed</li>
+      <li>Make sure "always open this type of files in selected
+      application" (or something similar) is checked</li>
+      <li>Click OK</li>
+    </ol>
+
+
+  </body>
+</html>
=======================================
--- /dev/null   
+++ /gfx/actions/basher.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/blocker.png    Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/boarder.png    Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/bomber.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/bridger.png    Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/climber.png    Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/digger.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/floater.png    Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/jumper.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/miner.png      Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/rocketlauncher.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/slider.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/stopper.png    Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/superman.png   Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null   
+++ /gfx/actions/waiter.png     Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /index.php  Fri Apr  9 07:04:34 2004
@@ -0,0 +1,516 @@
+<?
+//  Pingus Level Feedback system
+//  Copyright (C) 2003 by Jarno Elonen <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once("xml-search.inc");
+require_once("level-cache.inc");
+require_once("mail-settings.inc");
+
+// ==================================================================
+// Admin login.
+// ==================================================================
+$admin_passwd = "testadmin";
+$is_admin = ($_SERVER['PHP_AUTH_PW'] === $admin_passwd);
+if ( isset($_GET["adminlogin"]))
+{
+  if (!isset($_SERVER['PHP_AUTH_USER']))
+  {
+    header('WWW-Authenticate: Basic realm="Pingus Feedback Admin"');
+    header('HTTP/1.0 401 Unauthorized');
+    echo 'Cancelled. Hit Back.';
+    exit;
+  }
+  else
+  {
+    if ( !isset($_SERVER['PHP_AUTH_PW']) ||
+      $_SERVER['PHP_AUTH_PW'] != $admin_passwd )
+    {
+      header('HTTP/1.0 401 Unauthorized');
+      echo 'Wrong password. Hit Back.';
+      exit;
+    }
+    else
+      $is_admin = True;
+  }
+}
+
+// ==================================================================
+// Thumbnail magick with cookies etc.
+// ==================================================================
+if (isset($_GET["showthumbs"]))
+{
+  $show_thumbs = $_GET["showthumbs"];
+ if (!isset($_COOKIE["showthumbs"]) || $_COOKIE["showthumbs"] != $show_thumbs )
+    setCookie( "showthumbs", $_GET["showthumbs"], time()+3600*24 );
+}
+else if ( isset($_COOKIE["showthumbs"]) )
+  $show_thumbs = $_COOKIE["showthumbs"];
+
+// ==================================================================
+
+?>
+<html>
+  <head>
+    <title>Pingus level feedback database</title>
+    <link rel="stylesheet" type="text/css" href="default.css">
+  </head>
+  <body>
+
+    <h1>Pingus level feedback database</h1>
+    <div class="mainbody">
+
+<?
+
+$preferred_order = Array( 'tutorial', 'playable', 'wip', 'test' );
+
+// ==================================================================
+// Read cathegory and level names from filesystem
+// ==================================================================
+$cathegories = Array();
+$dir = dir("data/levels");
+while ($file = $dir->read())
+{
+  if ($file != "." && $file != ".." && is_dir("data/levels/".$file))
+  {
+    $levels = Array();
+    $dir2 = dir("data/levels/".$file);
+    while ($file2 = $dir2->read())
+      if (strpos($file2, ".plf") !== FALSE)
+        $levels[] = str_replace( ".plf", "", $file2 );
+    $dir2->close();
+    natcasesort( $levels );
+
+    $cath = Array();
+    $cath["name"] = $file;
+    $cath["levels"] = $levels;
+    $key = array_search($cath["name"], $preferred_order);
+    if ( $key === False )
+      $key = max(count($preferred_order), count($cathegories)+1);
+    $cathegories[$key] = $cath;
+  }
+}
+$dir->close();
+ksort( $cathegories );
+
+// ==================================================================
+// Level listing
+// ==================================================================
+if  ( !isset($_GET["l"]) || !isset($_GET["c"]) )
+{
+  if ( $show_thumbs )
+    print "<a href='$PHP_SELF?showthumbs=0'>[hide thumbnails]</a></br>";
+  else
+    print "<a href='$PHP_SELF?showthumbs=1'>[show thumbnails]</a></br>";
+
+  if ( !isset($_GET["c"]))
+  {
+    print "<p><strong>Pick a cathegory</strong>\n<ul>\n";
+    while( list(,$c) = each( $cathegories ))
+      print "<li><a href='$PHP_SELF?c=" . urlencode($c["name"]) . "'>" .
+        htmlentities($c["name"]) . "</a></li>\n";
+    print "</ul>\n";
+  }
+  else
+  {
+    print "<a href='$PHP_SELF'>[Back to cathegory list]</a></br>\n";
+ print "<a href='file-assoc-help.html' target='helpwin'>(Help: how to make 'play' link work)</a></br>\n";
+    while( list(,$c) = each( $cathegories ))
+    {
+      if ( $_GET["c"] == $c["name"] )
+      {
+        $cnt = count($c["levels"]);
+ print "<h2 align='center'>" . htmlentities( $c["name"] ) . " ($cnt)" . "</h2>\n";
+
+        print "<table style='margin-bottom: 1em;' width='100%' ".
+          "border='0' cellspacing='0' cellpadding='4'><tr>\n";
+        $i = $col_cnt = 0;
+        while( list(,$l) = each( $c["levels"] ))
+        {
+          unset( $ldata );
+          $ldata = level_cache_get( $c["name"], $l );
+          $cnt = $ldata["totalcomments"];
+
+          if ( ($i++) % 2 )
+            $celcolor = "bgcolor='#B0B0B0'";
+          else
+            $celcolor = "bgcolor='#A0A0A0'";
+
+ $jpg = htmlentities($c["name"]) . "/" . htmlentities($l) . ".jpg";
+          print "<td valign='top' $celcolor width='25%'><small>\n".
+            "<a href='$PHP_SELF?c=" .
+            urlencode($c["name"]) . "&l=" . urlencode($l) . "'>";
+          if ( $show_thumbs )
+ print "<img src='http://pingus.seul.org/levels/thumb/$jpg' align='left' border='0'>";
+          print "" . htmlentities( $l ) . "</a>";
+
+          if ( $cnt < 1 ) $cnt = "-";
+          print " (<strong>$cnt</strong>)<br>";
+ print "<em>&quot;" . htmlentities($ldata["name"]) . "&quot;</em><br>";
+          if ( strlen($ldata["difficulty"]))
+ print "Difficulty:" . htmlentities($ldata["difficulty"]) . "<br>"; + print "Pingus:" . intval($ldata["pingusmin"]) . "/" . intval($ldata["pingusmax"]) . "<br>";
+          if ( intval($ldata["playable"]) == 0 )
+            print "<b>Not playable</b><br>";
+          if ( $cnt > 0 )
+ print "Rating:" . str_repeat( "*", intval($ldata["avgrating"])) . "<br>"; + print " view <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a>" . + "/<a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> | " . + "play with <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".plf'>CVS</a>" . + " / <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".xml'>0.6</a> version" .
+            "<br>";
+          print "</small></td>\n";
+
+
+          if ($col_cnt++ == 1 )
+          {
+            print "</tr><tr>\n";
+            $col_cnt = 0;
+            $i++; // kludge to make coloring look like checkers.
+          }
+        }
+        print "</tr></table>\n";
+      }
+    }
+  }
+}
+// ==================================================================
+// Info on certain level
+// ==================================================================
+else
+{
+  $c = $_GET["c"];
+  $l = $_GET["l"];
+  $curlevelmd5 = FALSE;
+
+  $levelfile = sandbox_check( "data/levels/$c/$l.plf", "data/" );
+  if ( !is_file( $levelfile ))
+  {
+    print "<h2>Level '" . htmlentities($c) . " / " .
+      htmlentities($l) . "' not found.</h2>\n";
+ print "<p><a href='$PHP_SELF?c=" . urlencode($c) . "'>Back to level list</a></p>";
+  }
+  else
+  {
+    print "<h2>" . htmlentities($c) . " / " . htmlentities($l) . "</h2>\n";
+
+    $curlevelmd5 = md5(implode("", file($levelfile)));
+    $leveldata = level_cache_get( $c, $l );
+    if ( $leveldata["md5sum"] !== $curlevelmd5 )
+      $leveldata = parse_level( $levelfile );
+    $leveldata["totalcomments"] = 0;
+    $leveldata["avgrating"] = 0;
+    $leveldata["md5sum"] = $curlevelmd5;
+
+    // Level description
+    $tbl = Array(
+      "Name" => htmlentities($leveldata["name"]),
+      "Description" => htmlentities($leveldata["description"]),
+      "Comment" => htmlentities($leveldata["comment"]),
+      "Author" => str_replace("@", "<b><small>PingusNoSpam</small></b>@",
+        htmlentities($leveldata["author"])),
+      );
+    print( "<table border='1'>\n" );
+    while( list($key,$val) = each( $tbl ))
+      print("<tr><td><strong>" . htmlentities($key) . "</strong></td>\n" .
+            "<td colspan='2'>" . $val . "</td></tr>\n");
+
+    // Basic info about the level
+    $tbl = Array(
+ "Pingus #" => $leveldata["pingusmin"] ." / " . $leveldata["pingusmax"],
+      "Time" => $leveldata["time"],
+      "Difficulty" => $leveldata["difficulty"],
+      "Playable" => $leveldata["playable"],
+      );
+    $i = 0;
+    while( list($key,$val) = each( $tbl ))
+    {
+      print("<tr><td><strong>" . $key . "</strong></td>");
+      print ("<td width='100%'>\n" . htmlentities($val) . "</td>");
+      // Thumbnail
+      if ( $i++ == 0)
+      {
+        $jpg = htmlentities($c) . "/" . htmlentities($l) . ".jpg";
+        print ("<td rowspan='5' valign='top' align='center'>\n".
+ " <img src='http://pingus.seul.org/levels/thumb/$jpg' border='1'><br/>\n". + " see <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a> / \n". + " <a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> size\n<br>". + "<a href='data/levels/" . htmlentities($c) . "/" . htmlentities($l) . ".plf'>play</a>\n" .
+          "</td>\n" );
+      }
+    }
+
+    print "</tr><tr><td><strong>Actions</strong></td><td>\n";
+
+    // Number of actions
+    reset( $leveldata );
+    while( list($k,$v) = each($leveldata))
+    {
+      if ( substr($k,0,1)=="#" )
+      {
+        $a = substr($k,1);
+        $ac = trim($v);
+        if ( strlen($ac) == 0 )
+          $ac = "<strong>?</strong>";
+        else
+          $ac = htmlentities($ac);
+        print ("<img alt='$a' title='$a' src='gfx/actions/$a.png'> x ".
+          $ac . " ");
+      }
+    }
+
+    print( "</td></tr></table>\n" );
+?>
+    </p>
+    <hr/>
+<?
+    // ==================================================================
+    // Save added comment
+    // ==================================================================
+    if ( isset($_POST["addcomment"]))
+    {
+      if ( strpos($c, "..") !== False || strpos($c, "/") !== False ||
+        strpos($l, "..") !== False || strpos($l, "/") !== False )
+      {
+        print "<strong>ERROR: Illegal level name.</strong>";
+        exit;
+      }
+
+      if ( !is_dir("comments/$c/$l") &&
+           (@mkdir("comments/$c", 0775) || True) &&
+           !(@mkdir("comments/$c/$l", 0775)))
+      {
+        print ("<strong>ERROR: 'comments/$c/$l/' does not exist and ".
+               "could not be created.</strong>\n");
+        exit;
+      }
+      sandbox_check("comments/$c/$l", "comments/" );
+      $str =
+        '<' . '?xml version="1.0"  encoding="ISO-8859-1"?' . ">\n" .
+        "<pingus-level-comment>\n".
+ " <author>" . xmlentities(decode_html(stripslashes($_POST["author"]))) . "</author>\n" . + " <email>" . xmlentities(decode_html(stripslashes($_POST["email"]))) . "</email>\n" .
+        "  <level>" . xmlentities("$c/$l") . "</level>\n" .
+ " <levelmd5>" . xmlentities(stripslashes($_POST["levelmd5"])) . "</levelmd5>\n" .
+        "  <date>" . xmlentities(date("Y-m-d")) . "</date>\n" .
+ " <difficulty>" . xmlentities(stripslashes($_POST["difficulty"])) . "</difficulty>\n" . + " <rating>" . xmlentities(stripslashes($_POST["rating"])) . "</rating>\n" . + " <comment>" . xmlentities(decode_html(stripslashes($_POST["comment"]))) . "</comment>\n" .
+        "</pingus-level-comment>\n";
+
+      $filename = "comments/$c/$l/" . substr(md5($str),0,8) . ".plf";
+      if ( !file_exists($filename) || is_writable($filename))
+      {
+        if (!$fp = fopen($filename, 'w'))
+        {
+          print "<strong>ERROR: Cannot open file ($filename)</strong>\n";
+          exit;
+        }
+        if (!fwrite($fp, $str))
+        {
+ print "<strong>ERROR: Cannot write to file ($filename)</strong>\n";
+          exit;
+        }
+        fclose($fp);
+        chmod($filename, 0775);
+
+        // Send email-notification
+        if ( $mail_notify_enabled )
+        {
+          $mailto = trim($leveldata["author"]);
+          if ( isset($mail_forwards[$mailto]))
+            $mailto = trim($mail_forwards[$mailto]);
+ if ( $mailto !== null && strlen($mailto) > 0 && strpos($mailto,"@") > 0 )
+          {
+            $repl = Array(
+              "@SENDER" => decode_html(stripslashes($_POST["author"])) .
+                " <" . decode_html(stripslashes($_POST["email"])) . ">",
+              "@CATHEGORY" => $c,
+              "@LEVEL" => $l,
+              "@TO" => $mailto,
+ "@RATING" => str_repeat( "*", intval(stripslashes($_POST["rating"]))),
+              "@DIFFICULTY" => stripslashes($_POST["difficulty"]),
+              "@COMMENTS" => stripslashes(decode_html($_POST["comment"]))
+            );
+
+            mail(
+              $mailto,
+ str_replace(array_keys($repl), array_values($repl), $mail_subject), + str_replace(array_keys($repl), array_values($repl), $mail_message),
+              "From: $mail_from\r\n"
+                ."Reply-To: $mail_replyto\r\n"
+                ."X-Mailer: PHP/" . phpversion());
+          }
+        }
+      }
+      else
+        print "<strong>ERROR: File $filename is not writable</strong>\n";
+    }
+    // ==================================================================
+    // Delete comment
+    // ==================================================================
+    if ( $is_admin && isset($_GET["delcomment"]))
+    {
+      sandbox_check($_GET["delcomment"], "comments/" );
+      unlink($_GET["delcomment"]);
+      // Also try to remove the directories but don't mind if it fails:
+      @rmdir("comments/$c/$l");
+      @rmdir("comments/$c");
+ print "<p><strong>Deleted '" . htmlentities($_GET["delcomment"]) . "'</strong></p>";
+    }
+
+    // ==================================================================
+    // List user comments
+    // ==================================================================
+    $comments = parse_level_comments($c, $l);
+    if ( count($comments) > 0 )
+    {
+      while( list(,$cmt) = each($comments))
+      {
+        $leveldata["totalcomments"]++;
+
+        $rating = intval($cmt["rating"]);
+        $leveldata["avgrating"] += $rating;
+
+        if ( $is_admin )
+          $del_link = " <a href='$PHP_SELF?c=" . htmlentities($c) .
+ "&l=" . htmlentities($l) . "&delcomment=" . htmlentities($cmt["filename"]) . "'>[del]</a>\n";
+        $str =
+ "<p class='message'><strong>From:</strong> " . htmlentities($cmt["author"]) .
+          " &lt;" . str_replace("@", "<b><small>PingusNoSpam</small></b>@",
+            htmlentities($cmt["email"])) .
+ "&gt;, <strong>Date: </strong> " . htmlentities($cmt["date"]) . "<br/>\n" .
+          "<b>Difficulty: </b>" . htmlentities($cmt["difficulty"]) . "\n" .
+ ", <b>Rating: </b>" . str_repeat( "*", intval($rating)) . $del_link . "<br/>\n" .
+          "<cite>\n" .
+            str_replace( "\n", "<br/>\n", htmlentities($cmt["comment"])) .
+          "</cite></p>\n";
+
+        if (strtolower($cmt["levelmd5"]) == strtolower($curlevelmd5))
+          $new_comments_text .= $str;
+        else
+          $old_comments_text .= $str;
+      }
+      print("<h2>Comments</h2>\n" . $new_comments_text );
+ print("<h3>Comments for older version(s)</h3>\n" . $old_comments_text);
+    }
+    else print "<em>No comments for this level yet!</em>";
+
+    // Calc avg rating
+    if ( $leveldata["totalcomments"] > 0 )
+ $leveldata["avgrating"] = round($leveldata["avgrating"] / $leveldata["totalcomments"]);
+
+    // Save cache entry
+    level_cache_save( $c, $l, $leveldata );
+
+    // Allow overriding level md5 sum in GET parameters
+    $levelmd5 = $curlevelmd5;
+    if ( isset( $_GET["levelmd5"] ))
+      $levelmd5 = $_GET["levelmd5"];
+?>
+    <hr/>
+    <p><em><strong>Add a comment:</strong></em></p>
+ <form action="<? echo $PHP_SELF . "?c=" . urlencode($c) . "&l=" . urlencode($l); ?>" method="POST">
+      <input type="hidden" name="addcomment" value="1">
+      <input type="hidden" name="c" value="<? echo urlencode("$c"); ?>">
+      <input type="hidden" name="l" value="<? echo urlencode("$l"); ?>">
+ <input type="hidden" name="levelmd5" value="<? echo urlencode($levelmd5); ?>">
+      <table>
+        <tr>
+          <td>Your name</td>
+          <td><input type="text" name="author"></td>
+        </tr>
+        <tr>
+          <td>Your email</td>
+          <td><input type="text" name="email"></td>
+        </tr>
+        <tr>
+          <td>Difficulty</td>
+          <td>
+            <select name="difficulty">
+              <option value="easy">easy</option>
+              <option value="normal">normal</option>
+              <option value="hard">hard</option>
+              <option value="very hard">very hard</option>
+              <option value="unplayable">unplayable</option>
+              <option value="unfinished" selected>unfinished</option>
+            </select>
+          </td>
+        </tr>
+        <tr>
+          <td>Rating</td>
+          <td>
+            <select name="rating">
+              <option value="1">1 bad</option>
+              <option value="2">2 well...</option>
+              <option value="3" selected>3 ok</option>
+              <option value="4">4 good</option>
+              <option value="5">5 very good</option>
+            </select>
+          </td>
+        </tr>
+        <tr>
+          <td>Comments</td>
+          <td><textarea rows="8" cols="40" name="comment"></textarea></td>
+        </tr>
+        <tr>
+          <td colspan="2"><input type="submit"/></td>
+        </tr>
+      </table>
+    </form>
+<?
+ print "<p><a href='$PHP_SELF?c=" . urlencode($c) . "'>Back to level list</a></p>";
+    if ( !$is_admin )
+ print "<div align='right'><a href='$PHP_SELF?adminlogin=1'><small>admin login</small></a></div>";
+  }
+}
+
+close_cache();
+
+?>
+    </div>
+    <div>
+      <small>Pingus level feedback system &copy; 2003 by Jarno Elonen,
+      Licensed under the GNU General Public License (GPL) 2.0 or newer
+      </small>
+    </div>
+  </body>
+</html>
+
+<?
+// ==================================================================
+// Some utilities
+// ==================================================================
+function xmlentities($text, $op=1)
+{
+  if ( $op == 1 )
+  {
+    $tbl = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
+    $tbl = array_flip( $tbl );
+    $text = strtr( $text, $tbl );
+  }
+
+  $text = htmlspecialchars( $text, ENT_QUOTES );
+  return $text;
+}
+
+function decode_html($string)
+{
+ $string = strtr($string, array_flip(get_html_translation_table( HTML_ENTITIES, ENT_QUOTES )));
+  $string = preg_replace("/&#([0-9]+);/me", "chr('\\1')", $string);
+  return $string;
+}
+?>
=======================================
--- /dev/null
+++ /level-cache.inc    Fri Apr  9 07:04:34 2004
@@ -0,0 +1,208 @@
+<?
+//  Pingus Level Feedback system
+//  Copyright (C) 2003 by Jarno Elonen <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once("xml-search.inc");
+
+global $db_handle;
+$db_handle = False;
+
+function open_cache()
+{
+  global $db_handle;
+  if ( !$db_handle )
+  {
+    $db_driver = "db3";
+    //$db_driver = "db4";
+
+    $dbfile = "/home/elonen/public_html/pingus/comments/cache.db";
+    //$dbfile = "/var/www/pingus/comments/cache.db";
+
+    $db_handle = @dba_open ($dbfile, "w", $db_driver);
+    if (!$db_handle)
+      $db_handle = dba_open ($dbfile, "c", $db_driver);
+    if (!$db_handle)
+    {
+ echo '<p><font color="red"><b>ERROR: Cannot open cache file!</b></font></p>';
+      exit;
+    }
+  }
+}
+
+function close_cache()
+{
+  global $db_handle;
+  if ( $db_handle !== False )
+  {
+    dba_close($db_handle);
+    $db_handle = False;
+  }
+}
+
+function make_db_key( $cathegory, $level )
+{
+  return $cathegory . "//" . $level;
+}
+
+function level_cache_get( $cathegory, $level )
+{
+  global $db_handle;
+  open_cache();
+  $data = dba_fetch( make_db_key( $cathegory, $level ), $db_handle );
+  if ( $data === False )
+  {
+ $levelfile = sandbox_check( "data/levels/$cathegory/$level.plf", "data/" );
+    $leveldata = parse_level( $levelfile );
+    $leveldata["md5sum"] = md5(implode("", file($levelfile)));
+
+    $comments = parse_level_comments($cathegory, $level);
+    $avgrating = 0;
+    if (count($comments) > 0 )
+    {
+      while( list(,$v) = each($comments))
+        $avgrating += intval($v["rating"]);
+      $avgrating /= count($comments);
+    }
+    $leveldata["avgrating"] = $avgrating;
+    $leveldata["totalcomments"] = count($comments);
+
+    level_cache_save( $cathegory, $level, $leveldata );
+    return $leveldata;
+  }
+  $ret = Array();
+  $arr = explode("\255", $data);
+  while (list(,$fld) = each($arr))
+  {
+    if ( strlen($fld))
+    {
+      list($k,$v) = explode("=", $fld, 2);
+      $ret[$k] = $v;
+    }
+  }
+  unset( $data );
+  return $ret;
+}
+
+function level_cache_del( $cathegory, $level )
+{
+  global $db_handle;
+  open_cache();
+  if ( !dba_delete(make_db_key( $cathegory, $level ), $db_handle))
+  {
+ echo '<p><font color="red"><b>ERROR: Cannot delete cache key!</b></font></p>';
+    return False;
+  }
+  else return True;
+}
+
+function level_cache_save( $cathegory, $level, $arr )
+{
+  global $db_handle;
+  open_cache();
+  $data = "";
+  reset( $arr );
+  while (list($k,$v) = each($arr))
+    $data .= $k . "=" . $v . "\255";
+  if (!dba_replace( make_db_key( $cathegory, $level ), $data, $db_handle ))
+  {
+ echo '<p><font color="red"><b>ERROR: Cannot save level cache entry!</b></font></p>';
+    return False;
+  }
+  else return True;
+}
+
+function parse_level( $filename )
+{
+  $searches = Array(
+    "name" => "pingus-level/global/address@hidden",
+    "description" => "pingus-level/global/address@hidden",
+    "comment" => "pingus-level/global/comment",
+    "author" => "pingus-level/global/author",
+    "pingusmin" => "pingus-level/global/number-to-save",
+    "pingusmax" => "pingus-level/global/number-of-pingus",
+    "time" => "pingus-level/global/time",
+    "difficulty" => "pingus-level/global/difficulty",
+    "playable" => "pingus-level/global/playable"
+    );
+  $actions = Array(
+    "basher", "blocker", "bomber", "bridger", "climber",
+    "digger", "floater", "jumper", "miner", "slider" );
+  foreach( $actions as $a )
+    $searches["#$a"] = "pingus-level/action-list/$a";
+
+  $arr = Array();
+  $res = xml_search( $filename, $searches );
+  while( list($k,$v) = each($res))
+  {
+    if ( substr($k,0,1) == "#" )
+      $arr[$k] = $v["a"]["COUNT"];
+    else
+      $arr[$k] = $v["v"];
+      //$arr[$k] = decode_html($v["v"]);
+  }
+  unset( $res );
+  return $arr;
+}
+
+function parse_level_comments( $cathegory, $level )
+{
+  $res = Array();
+  $comment_dir = "comments/$cathegory/$level";
+  if ( !is_dir( $comment_dir ))
+    return $res;
+  sandbox_check($comment_dir, "comments/");
+
+  $dir = dir($comment_dir);
+  $comments = Array();
+  while ($file = $dir->read())
+    if ($file != "." && $file != ".." && file_exists("$comment_dir/$file"))
+      $comments[] = "$comment_dir/$file";
+  $dir->close();
+
+  while( list($key, $filename) = each($comments))
+  {
+    $cmt = xml_search( $filename, Array(
+      "author" => "pingus-level-comment/author",
+      "email" => "pingus-level-comment/email",
+      "date" => "pingus-level-comment/date",
+      "difficulty" => "pingus-level-comment/difficulty",
+      "rating" => "pingus-level-comment/rating",
+      "comment" => "pingus-level-comment/comment",
+      "levelmd5" => "pingus-level-comment/levelmd5"
+    ));
+
+    // We don't need tag names and attributes, strip them off:
+    while( list($k,$v) = each($cmt))
+      $cmt[$k] = $v["v"];
+
+    $cmt["filename"] = $filename;
+    $res[] = $cmt;
+  }
+  return $res;
+}
+
+function sandbox_check($filename, $sandbox)
+{
+  $file = realpath( $filename );
+  $sandbox = realpath( $sandbox );
+ if ( strlen($file) < strlen($sandbox) || substr($file, 0, strlen($sandbox)) !== $sandbox )
+    die( "<b>TRIED TO ACCESS A FILE OUTSIDE SANDBOX: '" .
+      htmlentities($filename) . "'! ABORTING!</b>");
+  return $filename;
+}
+
+?>
=======================================
--- /dev/null
+++ /mail-settings.inc  Fri Apr  9 07:04:34 2004
@@ -0,0 +1,33 @@
+<?
+
+$mail_notify_enabled = True;
+
+//$mail_from = "Pingus level comment tool <address@hidden>";
+//$mail_replyto = "Pingus developer list <address@hidden>";
+$mail_from = "Pingus level comment tool <address@hidden>";
+$mail_replyto = "Pingus developer list <address@hidden>";
+$mail_forwards = Array(
+  "address@hidden" => "address@hidden",
+  "address@hidden" => null
+);
+
+$mail_subject = "[Pingus levels] comments on @CATHEGORY/@LEVEL";
+$mail_message = <<<EOMSG
address@hidden
+has commented on your Pingus level at
+http://elonen.iki.fi/pingus/address@hidden&address@hidden
+
+Rating: @RATING
+Difficulty: @DIFFICULTY
+Comments:
+
+---------
address@hidden
+---------
+
+This is an automatically generated notification mail.
+If you wish not to receive comments anymore, write a
+short note to Pingus developer list address@hidden
+EOMSG;
+
+?>
=======================================
--- /dev/null   
+++ /play_on-2.png      Fri Apr  9 07:04:34 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /xml-search.inc     Fri Apr  9 07:04:34 2004
@@ -0,0 +1,124 @@
+<?
+  /*
+   *  XML_Search 1.0 - diet-XPath for PHP
+   *
+   *  Copyright (C) 2003 by Jarno Elonen <address@hidden>
+   *
+   *  This program is free software; you can redistribute it and/or
+   *  modify it under the terms of the GNU General Public License
+   *  as published by the Free Software Foundation; either version 2
+   *  of the License, or (at your option) any later version.
+   *
+   *  This program is distributed in the hope that it will be useful,
+   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   *  GNU General Public License for more details.
+   *
+   *  You should have received a copy of the GNU General Public License
+   *  along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+   */
+
+  function xml_search( $filename, $searches )
+  {
+    // Parses an XML file with SAX, applies given searches
+    // to it on the fly and returns the corresponding nodes,
+    // if found.
+    //
+    // $searches is an array that contains search
+    // paths indexed with keys under which the nodes
+    // will be mapped in the result.
+    //
+    // For example, if $searches contained...
+    //   "name" => "movie/info/address@hidden",
+    // ...the function would look for...
+    //   <movie><info><title lang="en">DATA</title></info></movie>
+    // ...and return it in the result array as:
+ // "name" => Array( "n"=>"TITLE", "v"=>"data", "a"=>Array("LANG"=>"en"))
+    //
+    // There can be any number of attribute equality tests,  for example:
+ // "address@hidden/info/address@hidden@director=James address@hidden"
+    //
+    // Limitations: NOT re-entrant, no wildcards,
+    // only equality test for attributes
+
+    global $xmls_searches, $xmls_results, $xmls_elemstack;
+    $xmls_searches = $searches;
+    $xmls_elemstack = Array();
+    $xmls_results = Array();
+
+    set_time_limit( 20 );
+    $xml_parser = xml_parser_create();
+ xml_set_element_handler($xml_parser, "xmls_start_element", "xmls_end_element");
+    xml_set_character_data_handler($xml_parser, "xmls_character_data");
+    if (!($fp = fopen($filename, "r")))
+        die("could not open XML input");
+    while ($data = fread($fp, 4096))
+        if (!xml_parse($xml_parser, $data, feof($fp)))
+            die(sprintf("XML error: %s at line %d",
+                        xml_error_string(xml_get_error_code($xml_parser)),
+                        xml_get_current_line_number($xml_parser)));
+    @fclose($fp);
+    xml_parser_free($xml_parser);
+    return $xmls_results;
+  }
+
+  $xmls_searches = Array();
+  $xmls_results = Array();
+  $xmls_elemstack = Array();
+
+  function xmls_start_element($parser, $name, $attrs)
+  {
+      global $xmls_elemstack;
+ array_push($xmls_elemstack, Array( "n"=>$name, "a"=>$attrs, "v"=>""));
+  }
+
+  function xmls_end_element($parser, $name)
+  {
+    global $xmls_elemstack, $xmls_searches, $xmls_results;
+    reset( $xmls_searches );
+    while( list($path_key, $path) = each($xmls_searches))
+    {
+      $cmp = explode("/", $path);
+      if ( count($cmp) !== count($xmls_elemstack))
+        break;
+
+      $found = True;
+      reset( $xmls_elemstack );
+      while( list(,$node) = each( $xmls_elemstack ))
+      {
+        $c = explode( "@", current($cmp));
+        next($cmp);
+        if ( strcasecmp($c[0], $node["n"]) != 0 )
+        {
+          $found = False;
+          break;
+        }
+        for ( $i=1; $i<count($c); ++$i )
+        {
+          list($attr_k, $attr_v) = explode("=", $c[$i], 2);
+          $attr_k = strtoupper($attr_k);
+ if ( !isset($node["a"][$attr_k]) || $node["a"][$attr_k] !== $attr_v )
+          {
+            $found = False;
+            break;
+          }
+        }
+      }
+      if ( $found && each( $xmls_elemstack ) === False )
+      {
+        $node =& end($xmls_elemstack);
+        $xmls_results[$path_key] = $node;
+        unset($xmls_searches[$path_key]);
+      }
+    }
+    array_pop($xmls_elemstack);
+  }
+
+  function xmls_character_data($parser, $data)
+  {
+    global $xmls_elemstack;
+    end($xmls_elemstack);
+    $xmls_elemstack[key($xmls_elemstack)]["v"] .= $data;
+  }
+?>

==============================================================================
Revision: 82937786838d
Author:   David Philippi <address@hidden>
Date:     Fri Apr  9 11:18:26 2004
Log:      patch for better admin login


http://code.google.com/p/pingus/source/detail?r=82937786838d&repo=level-comment-tool

Modified:
 /README
 /index.php

=======================================
--- /README     Fri Apr  9 07:04:34 2004
+++ /README     Fri Apr  9 11:18:26 2004
@@ -20,7 +20,7 @@

 Copyright

-Pingus Level Feedback System is (c) 2003 by Jarno Elonen
+Pingus Level Feedback System is (c) 2003-2004 by Jarno Elonen

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
@@ -36,3 +36,9 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
   MA  02111-1307, USA.
+
+NOTE:
+
+  Unlike other parts, 'htpasswd.inc' is licensed under Modified BSD
+  license, which is less restrictive than GPL. You can, however,
+  relicense it under the GPL, if necessary.
=======================================
--- /index.php  Fri Apr  9 07:04:34 2004
+++ /index.php  Fri Apr  9 11:18:26 2004
@@ -19,12 +19,17 @@
 require_once("xml-search.inc");
 require_once("level-cache.inc");
 require_once("mail-settings.inc");
+require_once("htpasswd.inc");

 // ==================================================================
 // Admin login.
 // ==================================================================
-$admin_passwd = "testadmin";
-$is_admin = ($_SERVER['PHP_AUTH_PW'] === $admin_passwd);
+
+$htpasswd = load_htpasswd();
+$is_admin = False;
+if ( isset($_SERVER['PHP_AUTH_PW']))
+ $is_admin = test_htpasswd( $htpasswd, "admin", $_SERVER['PHP_AUTH_PW'] );
+
 if ( isset($_GET["adminlogin"]))
 {
   if (!isset($_SERVER['PHP_AUTH_USER']))
@@ -37,7 +42,7 @@
   else
   {
     if ( !isset($_SERVER['PHP_AUTH_PW']) ||
-      $_SERVER['PHP_AUTH_PW'] != $admin_passwd )
+      !test_htpasswd( $htpasswd,  "admin", $_SERVER['PHP_AUTH_PW'] ))
     {
       header('HTTP/1.0 401 Unauthorized');
       echo 'Wrong password. Hit Back.';

==============================================================================
Revision: bdaac7fbebf6
Author:   David Philippi <address@hidden>
Date:     Sat Apr 10 07:21:06 2004
Log:      new file


http://code.google.com/p/pingus/source/detail?r=bdaac7fbebf6&repo=level-comment-tool

Added:
 /htpasswd.inc

=======================================
--- /dev/null
+++ /htpasswd.inc       Sat Apr 10 07:21:06 2004
@@ -0,0 +1,96 @@
+<?php
+
+// .htpasswd file functions
+// Copyright (C) 2004 Jarno Elonen <address@hidden>
+//
+// 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.
+// * The name of the author may not be used to endorse or promote products derived
+//   from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +// 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.
+//
+// Usage
+// =====
+//   require_once('htpasswd.inc');
+//   $pass_array = load_htpasswd();
+//
+//   if ( test_htpasswd( $pass_array,  $user, $pass ))
+//       print "Access granted."
+//
+//   $pass_array[$new_user] = rand_salt_crypt($new_pass);
+//   save_htpasswd($pass_array);
+
+define("HTPASSWDFILE", ".htpasswd");
+
+// Loads htpasswd file into an array of form
+// Array( username => crypted_pass, ... )
+function load_htpasswd()
+{
+  if ( !file_exists(HTPASSWDFILE))
+      return Array();
+
+  $res = Array();
+  foreach(file(HTPASSWDFILE) as $l)
+  {
+    $array = explode(':',$l);
+    $user = $array[0];
+    $pass = chop($array[1]);
+    $res[$user] = $pass;
+  }
+  return $res;
+}
+
+// Saves the array given by load_htpasswd
+function save_htpasswd( $pass_array )
+{
+ ignore_user_abort(true);
+  $fp = fopen(HTPASSWDFILE, "w+");
+  if (flock($fp, LOCK_EX))
+  {
+    while( list($u,$p) = each($pass_array))
+      fputs($fp, "$u:$p\n");
+    flock($fp, LOCK_UN); // release the lock
+  }
+  else
+  {
+    print "<strong>ERROR! Could not save (lock) .htpasswd!</strong><br>";
+  }
+  fclose($fp);
+  ignore_user_abort(false);
+}
+
+// Generates a htpasswd compatible crypted password string.
+function rand_salt_crypt( $pass )
+{
+  // Randomize a 2-letter crypt() salt:
+ $cset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
+  $salt = substr($cset, time() & 63, 1) .
+          substr($cset, time()/64 & 63, 1);
+  return crypt($pass, $salt);
+}
+
+// Returns true if the user exists and the password matches, false otherwise
+function test_htpasswd( $pass_array, $user, $pass )
+{
+  if ( !isset($pass_array[$user]))
+      return False;
+  $crypted = $pass_array[$user];
+  return crypt( $pass, substr($crypted,0,2) ) == $crypted;
+}
+
+?>

==============================================================================
Revision: 4fff7f44cdb4
Author:   David Philippi <address@hidden>
Date:     Sat Apr 10 09:56:22 2004
Log:      changed level ending to .pingus


http://code.google.com/p/pingus/source/detail?r=4fff7f44cdb4&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Fri Apr  9 11:18:26 2004
+++ /index.php  Sat Apr 10 09:56:22 2004
@@ -94,8 +94,8 @@
     $levels = Array();
     $dir2 = dir("data/levels/".$file);
     while ($file2 = $dir2->read())
-      if (strpos($file2, ".plf") !== FALSE)
-        $levels[] = str_replace( ".plf", "", $file2 );
+      if (strpos($file2, ".pingus") !== FALSE)
+        $levels[] = str_replace( ".pingus", "", $file2 );
     $dir2->close();
     natcasesort( $levels );

@@ -174,7 +174,7 @@
print "Rating:" . str_repeat( "*", intval($ldata["avgrating"])) . "<br>"; print " view <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a>" . "/<a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> | " . - "play with <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".plf'>CVS</a>" . + "play with <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".pingus'>Subversion</a>" . " / <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".xml'>0.6</a> version" .
             "<br>";
           print "</small></td>\n";
@@ -201,7 +201,7 @@
   $l = $_GET["l"];
   $curlevelmd5 = FALSE;

-  $levelfile = sandbox_check( "data/levels/$c/$l.plf", "data/" );
+  $levelfile = sandbox_check( "data/levels/$c/$l.pingus", "data/" );
   if ( !is_file( $levelfile ))
   {
     print "<h2>Level '" . htmlentities($c) . " / " .
@@ -253,7 +253,7 @@
" <img src='http://pingus.seul.org/levels/thumb/$jpg' border='1'><br/>\n". " see <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a> / \n". " <a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> size\n<br>". - "<a href='data/levels/" . htmlentities($c) . "/" . htmlentities($l) . ".plf'>play</a>\n" . + "<a href='data/levels/" . htmlentities($c) . "/" . htmlentities($l) . ".pingus'>play</a>\n" .
           "</td>\n" );
       }
     }
@@ -316,7 +316,7 @@
" <comment>" . xmlentities(decode_html(stripslashes($_POST["comment"]))) . "</comment>\n" .
         "</pingus-level-comment>\n";

-      $filename = "comments/$c/$l/" . substr(md5($str),0,8) . ".plf";
+      $filename = "comments/$c/$l/" . substr(md5($str),0,8) . ".pingus";
       if ( !file_exists($filename) || is_writable($filename))
       {
         if (!$fp = fopen($filename, 'w'))

==============================================================================
Revision: 655f69e71040
Author:   David Philippi <address@hidden>
Date:     Sat Apr 10 11:23:55 2004
Log:      some more changes for .plf --> .pingus


http://code.google.com/p/pingus/source/detail?r=655f69e71040&repo=level-comment-tool

Modified:
 /file-assoc-help.html
 /level-cache.inc

=======================================
--- /file-assoc-help.html       Fri Apr  9 07:04:34 2004
+++ /file-assoc-help.html       Sat Apr 10 11:23:55 2004
@@ -26,7 +26,7 @@
     Navigator / Helper Applications / New Type, add...</p>
     <ul>
       <li>MIME type "application/pingus-level"</li>
-      <li>Extension "plf" and</li>
+      <li>Extension "pingus" and</li>
       <li>Open it with "&lt;path and name of pingus executable&gt;".</li>
     </ul>
     <p>...and click OK.</p>
@@ -39,7 +39,7 @@
<li>Select 'application' as Group and type "pingus-level" as Type name.</li>
       <li>Click OK</li>
       <li>Click Filename Patterns / Add</li>
-      <li>Type "*.plf" and click OK</li>
+      <li>Type "*.pingus" and click OK</li>
       <li>Click Application Preference Order / Add</li>
       <li>Browse for or type the path to Pingus executable</li>
       <li>Click OK</li>
=======================================
--- /level-cache.inc    Fri Apr  9 07:04:34 2004
+++ /level-cache.inc    Sat Apr 10 11:23:55 2004
@@ -29,7 +29,7 @@
     $db_driver = "db3";
     //$db_driver = "db4";

-    $dbfile = "/home/elonen/public_html/pingus/comments/cache.db";
+ $dbfile = "/home/pingus/public_html/level_comment_tool/comments/cache.db";
     //$dbfile = "/var/www/pingus/comments/cache.db";

     $db_handle = @dba_open ($dbfile, "w", $db_driver);
@@ -65,7 +65,7 @@
   $data = dba_fetch( make_db_key( $cathegory, $level ), $db_handle );
   if ( $data === False )
   {
- $levelfile = sandbox_check( "data/levels/$cathegory/$level.plf", "data/" ); + $levelfile = sandbox_check( "data/levels/$cathegory/$level.pingus", "data/" );
     $leveldata = parse_level( $levelfile );
     $leveldata["md5sum"] = md5(implode("", file($levelfile)));


==============================================================================
Revision: 1f9594470129
Author:   David Philippi <address@hidden>
Date:     Sun Apr 11 08:10:04 2004
Log:      tiny update


http://code.google.com/p/pingus/source/detail?r=1f9594470129&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Sat Apr 10 09:56:22 2004
+++ /index.php  Sun Apr 11 08:10:04 2004
@@ -488,7 +488,7 @@
 ?>
     </div>
     <div>
-      <small>Pingus level feedback system &copy; 2003 by Jarno Elonen,
+ <small>Pingus level feedback system &copy; 2003, 2004 by Jarno Elonen,
       Licensed under the GNU General Public License (GPL) 2.0 or newer
       </small>
     </div>

==============================================================================
Revision: 00ca3a546eaa
Author:   David Philippi <address@hidden>
Date:     Sun Apr 11 10:43:26 2004
Log:      behaviour patch


http://code.google.com/p/pingus/source/detail?r=00ca3a546eaa&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Sun Apr 11 08:10:04 2004
+++ /index.php  Sun Apr 11 10:43:26 2004
@@ -116,10 +116,16 @@
 // ==================================================================
 if  ( !isset($_GET["l"]) || !isset($_GET["c"]) )
 {
+  if ( !isset($_GET["c"]) )
+    $showCath = '';
+  else
+    $showCath = '&c=' . $_GET["c"];
+
   if ( $show_thumbs )
-    print "<a href='$PHP_SELF?showthumbs=0'>[hide thumbnails]</a></br>";
+ print "<a href='$PHP_SELF?showthumbs=0$showCath'>[hide thumbnails]</a></br>";
+
   else
-    print "<a href='$PHP_SELF?showthumbs=1'>[show thumbnails]</a></br>";
+ print "<a href='$PHP_SELF?showthumbs=1$showCath'>[show thumbnails]</a></br>";

   if ( !isset($_GET["c"]))
   {

==============================================================================
Revision: 3320cc4e6a4b
Author:   David Philippi <address@hidden>
Date:     Mon Apr 12 15:39:53 2004
Log:      update


http://code.google.com/p/pingus/source/detail?r=3320cc4e6a4b&repo=level-comment-tool

Added:
 /COPYRIGHT
Deleted:
 /COPYING
Modified:
 /README
 /index.php
 /level-cache.inc
 /xml-search.inc

=======================================
--- /dev/null
+++ /COPYRIGHT  Mon Apr 12 15:39:53 2004
@@ -0,0 +1,26 @@
+Pingus Level Comment Tool
+
+Copyright (C) by
+
+  2003-2004, Jarno Elonen <address@hidden>
+
+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.
+ + The name of the author may not be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +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.
=======================================
--- /COPYING    Fri Apr  9 07:04:34 2004
+++ /dev/null
@@ -1,340 +0,0 @@
-                   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
-
-           How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year  name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
=======================================
--- /README     Fri Apr  9 11:18:26 2004
+++ /README     Mon Apr 12 15:39:53 2004
@@ -1,4 +1,4 @@
-Pingus Level Feedback System
+Pingus Level Comment Tool

 Installing:

@@ -22,23 +22,23 @@

 Pingus Level Feedback System is (c) 2003-2004 by Jarno Elonen

-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-  MA  02111-1307, USA.
-
-NOTE:
-
-  Unlike other parts, 'htpasswd.inc' is licensed under Modified BSD
-  license, which is less restrictive than GPL. You can, however,
-  relicense it under the GPL, if necessary.
+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.
+ + The name of the author may not be used to endorse or promote products derived
+   from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +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.
=======================================
--- /index.php  Sun Apr 11 10:43:26 2004
+++ /index.php  Mon Apr 12 15:39:53 2004
@@ -1,20 +1,27 @@
 <?
-//  Pingus Level Feedback system
+//  Pingus Level Comment Tool
 //  Copyright (C) 2003 by Jarno Elonen <address@hidden>
 //
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
 //
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
+// + 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.
+// + The name of the author may not be used to endorse or promote products derived
+//   from this software without specific prior written permission.
 //
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +// 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.

 require_once("xml-search.inc");
 require_once("level-cache.inc");
@@ -34,7 +41,7 @@
 {
   if (!isset($_SERVER['PHP_AUTH_USER']))
   {
-    header('WWW-Authenticate: Basic realm="Pingus Feedback Admin"');
+    header('WWW-Authenticate: Basic realm="Pingus Comment Tool Admin"');
     header('HTTP/1.0 401 Unauthorized');
     echo 'Cancelled. Hit Back.';
     exit;
@@ -70,17 +77,17 @@
 ?>
 <html>
   <head>
-    <title>Pingus level feedback database</title>
+    <title>Pingus level comment database</title>
     <link rel="stylesheet" type="text/css" href="default.css">
   </head>
   <body>

-    <h1>Pingus level feedback database</h1>
+    <h1>Pingus level comment database</h1>
     <div class="mainbody">

 <?

-$preferred_order = Array( 'tutorial', 'playable', 'wip', 'test' );
+$preferred_order = Array( 'tutorial', 'playable', 'volcano', 'wip', 'test' );

 // ==================================================================
 // Read cathegory and level names from filesystem
@@ -120,10 +127,10 @@
     $showCath = '';
   else
     $showCath = '&c=' . $_GET["c"];
-
+
   if ( $show_thumbs )
print "<a href='$PHP_SELF?showthumbs=0$showCath'>[hide thumbnails]</a></br>";
-
+
   else
print "<a href='$PHP_SELF?showthumbs=1$showCath'>[show thumbnails]</a></br>";

@@ -494,8 +501,8 @@
 ?>
     </div>
     <div>
- <small>Pingus level feedback system &copy; 2003, 2004 by Jarno Elonen,
-      Licensed under the GNU General Public License (GPL) 2.0 or newer
+      <small>Pingus level comment tool &copy; 2003, 2004 by Jarno Elonen,
+      Licensed under the Modified BSD License
       </small>
     </div>
   </body>
=======================================
--- /level-cache.inc    Sat Apr 10 11:23:55 2004
+++ /level-cache.inc    Mon Apr 12 15:39:53 2004
@@ -2,19 +2,26 @@
 //  Pingus Level Feedback system
 //  Copyright (C) 2003 by Jarno Elonen <address@hidden>
 //
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
 //
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
+// + 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.
+// + The name of the author may not be used to endorse or promote products derived
+//   from this software without specific prior written permission.
 //
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +// 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.

 require_once("xml-search.inc");

=======================================
--- /xml-search.inc     Fri Apr  9 07:04:34 2004
+++ /xml-search.inc     Mon Apr 12 15:39:53 2004
@@ -1,23 +1,28 @@
 <?
-  /*
-   *  XML_Search 1.0 - diet-XPath for PHP
-   *
-   *  Copyright (C) 2003 by Jarno Elonen <address@hidden>
-   *
-   *  This program is free software; you can redistribute it and/or
-   *  modify it under the terms of the GNU General Public License
-   *  as published by the Free Software Foundation; either version 2
-   *  of the License, or (at your option) any later version.
-   *
-   *  This program is distributed in the hope that it will be useful,
-   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
-   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   *  GNU General Public License for more details.
-   *
-   *  You should have received a copy of the GNU General Public License
-   *  along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-   */
+// XML_Search 1.0 - diet-XPath for PHP
+//
+// Copyright (C) 2003 by Jarno Elonen <address@hidden>
+//
+// 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.
+// + The name of the author may not be used to endorse or promote products derived
+//   from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +// 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.

   function xml_search( $filename, $searches )
   {

==============================================================================
Revision: 67841941925d
Author:   David Philippi <address@hidden>
Date:     Tue Apr 13 09:01:49 2004
Log:      prettify display


http://code.google.com/p/pingus/source/detail?r=67841941925d&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Mon Apr 12 15:39:53 2004
+++ /index.php  Tue Apr 13 09:01:49 2004
@@ -168,13 +168,21 @@
             $celcolor = "bgcolor='#A0A0A0'";

$jpg = htmlentities($c["name"]) . "/" . htmlentities($l) . ".jpg";
-          print "<td valign='top' $celcolor width='25%'><small>\n".
-            "<a href='$PHP_SELF?c=" .
-            urlencode($c["name"]) . "&l=" . urlencode($l) . "'>";
-          if ( $show_thumbs )
- print "<img src='http://pingus.seul.org/levels/thumb/$jpg' align='left' border='0'>";
-          print "" . htmlentities( $l ) . "</a>";
-
+          print "<td valign='top' $celcolor width='50%'>\n";
+          if ( $show_thumbs )//additional column only when thumbs are shown
+         {
+            print "<table width='100%' border='0'>\n" .
+             "<tr><td style='width:160px; height:120px;'>" .
+ "<a href='$PHP_SELF?c=" . urlencode($c["name"]) . "&l=" . urlencode($l) . "'>". + "<img src='http://pingus.seul.org/levels/thumb/$jpg' align='left' border='0'>".
+             "</a></td><td>\n";
+          }
+
+          print "<small>".
+          "<a href='$PHP_SELF?c=" .
+          urlencode($c["name"]) . "&l=" . urlencode($l) . "'>".
+          urlencode($l) . "</a>\n";
+
           if ( $cnt < 1 ) $cnt = "-";
           print " (<strong>$cnt</strong>)<br>";
print "<em>&quot;" . htmlentities($ldata["name"]) . "&quot;</em><br>";
@@ -185,12 +193,18 @@
             print "<b>Not playable</b><br>";
           if ( $cnt > 0 )
print "Rating:" . str_repeat( "*", intval($ldata["avgrating"])) . "<br>"; - print " view <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a>" . - "/<a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> | " . - "play with <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".pingus'>Subversion</a>" . + print " view <a href='http://pingus.seul.org/levels/33/$jpg' target='levelview'>third</a>". + " / <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a>" . + " / <a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a><br>" . + /*"play with <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".pingus'>Subversion</a>" . " / <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".xml'>0.6</a> version" .
-            "<br>";
-          print "</small></td>\n";
+            "<br>";*/
+ "<a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".pingus'>play level</a>" .
+            " (requires Pingus 0.6.1 or later)".
+            "</small>\n";
+          if ( $show_thumbs )
+            print "</td></tr></table>\n";
+          print "</td>\n";


           if ($col_cnt++ == 1 )

==============================================================================
Revision: 6cf27461afa1
Author:   David Philippi <address@hidden>
Date:     Wed Apr 14 13:42:00 2004
Log:      caching update


http://code.google.com/p/pingus/source/detail?r=6cf27461afa1&repo=level-comment-tool

Modified:
 /index.php
 /level-cache.inc

=======================================
--- /index.php  Tue Apr 13 09:01:49 2004
+++ /index.php  Wed Apr 14 13:42:00 2004
@@ -159,7 +159,7 @@
         while( list(,$l) = each( $c["levels"] ))
         {
           unset( $ldata );
-          $ldata = level_cache_get( $c["name"], $l );
+          $ldata = level_cache_get( $c["name"], $l, False );
           $cnt = $ldata["totalcomments"];

           if ( ($i++) % 2 )
@@ -170,19 +170,19 @@
$jpg = htmlentities($c["name"]) . "/" . htmlentities($l) . ".jpg";
           print "<td valign='top' $celcolor width='50%'>\n";
           if ( $show_thumbs )//additional column only when thumbs are shown
-         {
+             {
             print "<table width='100%' border='0'>\n" .
              "<tr><td style='width:160px; height:120px;'>" .
"<a href='$PHP_SELF?c=" . urlencode($c["name"]) . "&l=" . urlencode($l) . "'>". "<img src='http://pingus.seul.org/levels/thumb/$jpg' align='left' border='0'>".
              "</a></td><td>\n";
           }
-
+
           print "<small>".
           "<a href='$PHP_SELF?c=" .
           urlencode($c["name"]) . "&l=" . urlencode($l) . "'>".
           urlencode($l) . "</a>\n";
-
+
           if ( $cnt < 1 ) $cnt = "-";
           print " (<strong>$cnt</strong>)<br>";
print "<em>&quot;" . htmlentities($ldata["name"]) . "&quot;</em><br>";
@@ -240,9 +240,9 @@
     print "<h2>" . htmlentities($c) . " / " . htmlentities($l) . "</h2>\n";

     $curlevelmd5 = md5(implode("", file($levelfile)));
-    $leveldata = level_cache_get( $c, $l );
+    $leveldata = level_cache_get( $c, $l, False );
     if ( $leveldata["md5sum"] !== $curlevelmd5 )
-      $leveldata = parse_level( $levelfile );
+      $leveldata = level_cache_get( $c, $l, True );
     $leveldata["totalcomments"] = 0;
     $leveldata["avgrating"] = 0;
     $leveldata["md5sum"] = $curlevelmd5;
=======================================
--- /level-cache.inc    Mon Apr 12 15:39:53 2004
+++ /level-cache.inc    Wed Apr 14 13:42:00 2004
@@ -25,27 +25,106 @@

 require_once("xml-search.inc");

+// set some globals for various DBMS
+global $DBMS;
 global $db_handle;
+global $db_tablename;
+global $db_name;
+global $db_host;
+global $db_user;
+global $db_pass;
+
+$DBMS = 'DBA';
 $db_handle = False;
+$db_tablename = 'lct_cache';
+$db_name = 'pingus';
+$db_host = 'localhost';
+$db_user = '';
+$db_pass = '';
+
+function create_table( $tablename )
+{
+  global $db_name;
+  global $db_handle;
+
+  $table_exists = False;
+  $res = mysql_list_tables( $db_name );
+
+  for ($i=0;$i<mysql_num_rows( $res );$i++)
+    if (mysql_tablename( $res, $i ) == $tablename)
+      $table_exists = True;
+
+  if (!$table_exists)
+  {
+ $SQL = "CREATE TABLE `$tablename` (`Key` VARCHAR( 255 ) NOT NULL ,`Value` TEXT NOT NULL , PRIMARY KEY ( `Key` ) );";
+    $res = mysql_query( $SQL, $db_handle );
+       if (!$res)
+         return False;
+       else
+         return $tablename;
+  }
+  else
+    return $tablename;
+}

 function open_cache()
 {
   global $db_handle;
+  global $DBMS;
+  global $db_tablename;
+  global $db_name;
+
+
   if ( !$db_handle )
   {
-    $db_driver = "db3";
-    //$db_driver = "db4";
-
- $dbfile = "/home/pingus/public_html/level_comment_tool/comments/cache.db";
-    //$dbfile = "/var/www/pingus/comments/cache.db";
-
-    $db_handle = @dba_open ($dbfile, "w", $db_driver);
-    if (!$db_handle)
-      $db_handle = dba_open ($dbfile, "c", $db_driver);
-    if (!$db_handle)
-    {
- echo '<p><font color="red"><b>ERROR: Cannot open cache file!</b></font></p>';
-      exit;
+    switch( $DBMS )
+    {
+         //DBA is used as cache
+      case "DBA":
+        $db_driver = "db3";
+
+ $dbfile = "/home/pingus/public_html/level_comment_tool/comments/cache.db";
+        //$dbfile = "/var/www/pingus/comments/cache.db";
+
+        $db_handle = @dba_open ($dbfile, "w", $db_driver);
+        if (!$db_handle)
+          $db_handle = dba_open ($dbfile, "c", $db_driver);
+        if (!$db_handle)
+        {
+ echo '<p><font color="red"><b>ERROR: Cannot open cache file!</b></font></p>';
+          exit;
+        }
+        break;
+
+      //MySQL is used as cache
+      case "MySQL":
+               $db_handle = mysql_connect( $db_host, $db_user, $db_pass );
+               if (!$db_handle)
+               {
+ echo "<p><font color=\"red\"><b>ERROR: Cannot open connection to database server ($db_host)!</b></font></p>";
+          exit;
+        }
+
+        if (! mysql_select_db( $db_name, $db_handle ))
+               {
+ echo "<p><font color=\"red\"><b>ERROR: Cannot select database '$db_name'!</b></font></p>";
+          exit;
+        }
+
+ $db_tablename = create_table($db_tablename);//creates the table if necessary and returns the tablename
+
+        if (!$db_tablename)
+        {
+ echo '<p><font color="red"><b>ERROR: Cannot create cache table!</b></font></p>';
+          echo mysql_error( $db_handle );
+          exit;
+        }
+        break;
+
+      // unsupported DBMS
+      default:
+ echo '<p><font color="red"><b>ERROR: specified DBMS is not yet supported!</b></font></p>';
+        exit;
     }
   }
 }
@@ -53,10 +132,24 @@
 function close_cache()
 {
   global $db_handle;
-  if ( $db_handle !== False )
-  {
-    dba_close($db_handle);
-    $db_handle = False;
+  global $DBMS;
+
+  if ($db_handle !== False)
+  {
+    switch ($DBMS)
+    {
+      //DBA is used as cache
+      case "DBA":
+        dba_close($db_handle);
+        $db_handle = False;
+        break;
+
+      //MySQL is used as cache
+      case "MySQL":
+               mysql_close($db_handle);
+               $db_handle = False;
+           break;
+    }
   }
 }

@@ -65,12 +158,52 @@
   return $cathegory . "//" . $level;
 }

-function level_cache_get( $cathegory, $level )
+function fetch_from_DB( $cathegory, $level )
+{
+  global $db_handle;
+  global $DBMS;
+  global $db_tablename;
+
+  switch ($DBMS)
+  {
+    case "DBA":
+      $data = dba_fetch( make_db_key( $cathegory, $level ), $db_handle );
+      break;
+
+    case "MySQL":
+ $SQL = "SELECT * FROM `$db_tablename` WHERE `Key`='" . make_db_key( $cathegory, $level ) . "'";
+      $res = mysql_query( $SQL, $db_handle );
+      if (mysql_num_rows($res) != 1)
+       $data = False;
+      else
+        list(,$data) = mysql_fetch_row( $res );
+      break;
+  }
+
+  if ( !$data )
+    return False;
+  else
+  {
+    $ret = Array();
+    $arr = explode("\255", $data);
+    while (list(,$fld) = each($arr))
+    {
+      if ( strlen($fld))
+      {
+        list($k,$v) = explode("=", $fld, 2);
+        $ret[$k] = $v;
+      }
+    }
+    return $ret;
+  }
+}
+
+function level_cache_get( $cathegory, $level, $recache )
 {
   global $db_handle;
   open_cache();
-  $data = dba_fetch( make_db_key( $cathegory, $level ), $db_handle );
-  if ( $data === False )
+  $data = fetch_from_DB( $cathegory, $level );
+  if ( $data == False || $recache == True )
   {
$levelfile = sandbox_check( "data/levels/$cathegory/$level.pingus", "data/" );
     $leveldata = parse_level( $levelfile );
@@ -90,46 +223,77 @@
     level_cache_save( $cathegory, $level, $leveldata );
     return $leveldata;
   }
-  $ret = Array();
-  $arr = explode("\255", $data);
-  while (list(,$fld) = each($arr))
-  {
-    if ( strlen($fld))
-    {
-      list($k,$v) = explode("=", $fld, 2);
-      $ret[$k] = $v;
-    }
-  }
-  unset( $data );
-  return $ret;
+  return $data;
 }

 function level_cache_del( $cathegory, $level )
 {
   global $db_handle;
+  global $DBMS;
+  global $db_tablename;
+
   open_cache();
-  if ( !dba_delete(make_db_key( $cathegory, $level ), $db_handle))
+
+  switch ($DBMS)
+  {
+    case "DBA":
+      $ret = dba_delete(make_db_key( $cathegory, $level ), $db_handle);
+         break;
+
+       case "MySQL":
+         $key = make_db_key( $cathegory, $level );
+         $SQL = "DELETE * FROM $db_tablename WHERE LevelID='$key'";
+         $ret = mysql_query( $SQL, $db_handle );
+         break;
+  }
+
+  if ( !$ret )
   {
echo '<p><font color="red"><b>ERROR: Cannot delete cache key!</b></font></p>';
     return False;
   }
-  else return True;
+  else
+    return True;
 }

 function level_cache_save( $cathegory, $level, $arr )
 {
   global $db_handle;
+  global $db_tablename;
+  global $DBMS;
+
   open_cache();
   $data = "";
+  $key = make_db_key( $cathegory, $level );
   reset( $arr );
+
   while (list($k,$v) = each($arr))
     $data .= $k . "=" . $v . "\255";
-  if (!dba_replace( make_db_key( $cathegory, $level ), $data, $db_handle ))
+
+  switch ($DBMS)
+  {
+    case "DBA":
+ $ret = dba_replace( make_db_key( $cathegory, $level ), $data, $db_handle );
+      break;
+
+    case "MySQL":
+ $SQL = "SELECT * FROM `$db_tablename` WHERE `Key`='" . make_db_key( $cathegory, $level ) . "'";
+      $ret = mysql_query( $SQL, $db_handle );
+      if (mysql_num_rows( $ret ) == 1)
+ $SQL = "UPDATE `$db_tablename` SET `Value`='" . str_replace( "'", "\'", $data ) . "' WHERE `Key`='$key'";
+      else
+ $SQL = "INSERT INTO $db_tablename (`Key`,`Value`) VALUES ('$key','" . str_replace( "'", "\'", $data ) . "')";
+      $ret = mysql_query( $SQL, $db_handle );
+      break;
+  }
+
+  if (!$ret)
   {
echo '<p><font color="red"><b>ERROR: Cannot save level cache entry!</b></font></p>';
     return False;
   }
-  else return True;
+  else
+    return True;
 }

 function parse_level( $filename )

==============================================================================
Revision: b7434f61a3a0
Author:   David Philippi <address@hidden>
Date:     Thu Apr 15 13:51:34 2004
Log:      update


http://code.google.com/p/pingus/source/detail?r=b7434f61a3a0&repo=level-comment-tool

Modified:
 /index.php
 /level-cache.inc

=======================================
--- /index.php  Wed Apr 14 13:42:00 2004
+++ /index.php  Thu Apr 15 13:51:34 2004
@@ -278,7 +278,8 @@
         $jpg = htmlentities($c) . "/" . htmlentities($l) . ".jpg";
         print ("<td rowspan='5' valign='top' align='center'>\n".
" <img src='http://pingus.seul.org/levels/thumb/$jpg' border='1'><br/>\n". - " see <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a> / \n". + " see <a href='http://pingus.seul.org/levels/33/$jpg' target='levelview'>third</a> /". + " <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a> / \n". " <a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> size\n<br>". "<a href='data/levels/" . htmlentities($c) . "/" . htmlentities($l) . ".pingus'>play</a>\n" .
           "</td>\n" );
@@ -299,8 +300,12 @@
           $ac = "<strong>?</strong>";
         else
           $ac = htmlentities($ac);
-        print ("<img alt='$a' title='$a' src='gfx/actions/$a.png'> x ".
-          $ac . " ");
+          print ("<img id='Pic$a' name='$a' alt='$a' title='$a' " .
+                 "style='cursor: pointer' src='gfx/actions/$a.png' " .
+ "onclick='document.getElementById(\"CommentForm\").comment.value = " . + "document.getElementById(\"CommentForm\").comment.value + " .
+                 "document.getElementById(\"Pic$a\").name'></a> x " .
+                 $ac . " ");
       }
     }

@@ -338,6 +343,7 @@
         "  <level>" . xmlentities("$c/$l") . "</level>\n" .
" <levelmd5>" . xmlentities(stripslashes($_POST["levelmd5"])) . "</levelmd5>\n" .
         "  <date>" . xmlentities(date("Y-m-d")) . "</date>\n" .
+        "  <time>" . xmlentities(date("H:i:s")) . "</time>\n" .
" <difficulty>" . xmlentities(stripslashes($_POST["difficulty"])) . "</difficulty>\n" . " <rating>" . xmlentities(stripslashes($_POST["rating"])) . "</rating>\n" . " <comment>" . xmlentities(decode_html(stripslashes($_POST["comment"]))) . "</comment>\n" .
@@ -404,12 +410,89 @@
print "<p><strong>Deleted '" . htmlentities($_GET["delcomment"]) . "'</strong></p>";
     }

+       // ==================================================================
+    // Save uploaded Demofile
     // ==================================================================
-    // List user comments
+    if ( isset($_POST["adddemo"]))
+    {
+      //create directory if necessary
+      if ( !is_dir("comments/$c/$l/demos") &&
+           (@mkdir("comments/$c", 0775) || True) &&
+           (@mkdir("comments/$c/$l", 0775) || True) &&
+           !(@mkdir("comments/$c/$l/demos", 0775)))
+      {
+        print ("<strong>ERROR: 'comments/$c/$l/demos' does not exist and ".
+               "could not be created.</strong>\n");
+        exit;
+      }
+
+      $uploaddir = sandbox_check( "comments/$c/$l/demos", "comments/" );
+
+      if(!strpos( strtolower( $_FILES["demofile"]["name"] ), ".xml" ))
+        print("<strong> Please upload only .xml files </strong><hr/>");
+      else
+      {
+ if (move_uploaded_file($_FILES['demofile']['tmp_name'], $uploaddir. '/' . $_FILES['demofile']['name']))
+        {
+          print("<strong>File uploaded successfully</strong><hr/>");
+ $str = '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . ">\n" .
+                "<pingus-demo-metafile>\n".
+ " <username>" . xmlentities(decode_html(stripslashes($_POST["username"]))) . "</username>\n" . + " <email>" . xmlentities(decode_html(stripslashes($_POST["email"]))) . "</email>\n" .
+                "  <level>" . xmlentities("$c/$l") . "</level>\n" .
+ " <levelmd5>" . xmlentities(stripslashes($_POST["levelmd5"])) . "</levelmd5>\n" .
+                "  <date>" . xmlentities(date("Y-m-d")) . "</date>\n" .
+                "  <time>" . xmlentities(date("H:i:s")) . "</time>\n" .
+ " <demofile>" . xmlentities( $_FILES['demofile']['name'] ) . "</demofile>\n" .
+                "</pingus-demo-metafile>\n";
+
+ $filename = "comments/$c/$l/demos/" . substr(md5($str),0,8) . ".demo";
+          if ( !file_exists($filename) || is_writable($filename))
+          {
+            if (!$fp = fopen($filename, 'w'))
+            {
+ print "<strong>ERROR: Cannot open file ($filename)</strong>\n";
+              exit;
+            }
+            if (!fwrite($fp, $str))
+            {
+ print "<strong>ERROR: Cannot write to file ($filename)</strong>\n";
+              exit;
+            }
+            fclose($fp);
+            chmod($filename, 0775);
+         }
+       }
+        else
+        {
+          print("<strong>error:");
+          print_r($_FILES);
+          print("</strong><hr/>");
+        }
+      }
+    }
+
     // ==================================================================
-    $comments = parse_level_comments($c, $l);
+    // List user comments and demo files
+    // ==================================================================
+    if (isset( $_GET["o"] )) //determine order of comments
+    {
+      $comments = parse_level_comments($c, $l, $_GET["o"]);
+      if ($_GET["o"] == "ASC")
+ $OrderLink = " (<a href='$PHP_SELF?c=$c&l=$l&o=DESC'>revert order</a>)";
+      else
+ $OrderLink = " (<a href='$PHP_SELF?c=$c&l=$l&o=ASC'>revert order</a>)";
+    }
+    else
+    {
+      $comments = parse_level_comments($c, $l, "ASC");
+ $OrderLink = " (<a href='$PHP_SELF?c=$c&l=$l&o=DESC'>revert order</a>)";
+    }
+    $showComments = False;
+    $showDemos = False;
     if ( count($comments) > 0 )
     {
+      $showComments = True;
       while( list(,$cmt) = each($comments))
       {
         $leveldata["totalcomments"]++;
@@ -424,7 +507,8 @@
"<p class='message'><strong>From:</strong> " . htmlentities($cmt["author"]) .
           " &lt;" . str_replace("@", "<b><small>PingusNoSpam</small></b>@",
             htmlentities($cmt["email"])) .
- "&gt;, <strong>Date: </strong> " . htmlentities($cmt["date"]) . "<br/>\n" .
+            "&gt;, <strong>Date: </strong> " . htmlentities($cmt["date"]) .
+ ", <strong>Time: </strong> " . htmlentities($cmt["time"]) . "<br/>\n" .
           "<b>Difficulty: </b>" . htmlentities($cmt["difficulty"]) . "\n" .
", <b>Rating: </b>" . str_repeat( "*", intval($rating)) . $del_link . "<br/>\n" .
           "<cite>\n" .
@@ -436,10 +520,49 @@
         else
           $old_comments_text .= $str;
       }
-      print("<h2>Comments</h2>\n" . $new_comments_text );
- print("<h3>Comments for older version(s)</h3>\n" . $old_comments_text);
-    }
-    else print "<em>No comments for this level yet!</em>";
+    }
+
+    $demos = parse_level_demos( $c, $l );
+    if ( count($demos) > 0 )
+    {
+      $showDemos = True;
+
+      while( list(,$cmt) = each($demos))
+      {
+        $leveldata["totaldemos"]++;
+
+        $str =
+ "<p class='message'><strong>From:</strong> " . htmlentities($cmt["username"]) . + " &lt;" . str_replace("@", "<b><small>PingusNoSpam</small></b>@", htmlentities($cmt["email"])) .
+          "&gt;<br><strong>Date: </strong> " . htmlentities($cmt["date"]) .
+ ", <strong>Time: </strong> " . htmlentities($cmt["time"]) . "<br/>\n" . + "<b>Demofile: </b><a href='comments/$c/$l/demos/" . $cmt["demofile"] . "'>" .
+          $cmt["demofile"] . "</a><br/>\n" .
+          "</p>\n";
+
+        if (strtolower($cmt["levelmd5"]) == strtolower($curlevelmd5))
+          $new_demos_text .= $str;
+        else
+          $old_demos_text .= $str;
+      }
+    }
+
+ print("<table width='100%' cellpadding='10'><tr><td width='60%' valign='top'>");
+    if ($showComments)
+ print ("<table cellpadding='5'><tr><td valign='bottom'><h2>Comments</h2></td>" . + "<td valign='bottom'><strong>$OrderLink</strong></td></tr></table>\n" . $new_comments_text . + "<h3>Comments for older version(s)</h3>\n" . $old_comments_text);
+    else
+     print ("<em>No comments for this level yet!</em>");
+
+    print("</td><td valign='top'>");
+    if ($showDemos)
+ print ("<table cellpadding='5'><tr><td valign='bottom'><h2>Demo Files</h2></td></tr></table>\n" . + $new_demos_text . "<h3>Demos for older version(s)</h3>\n" . $old_demos_text);
+       else
+      print ("<em>No Demos for this level yet!</em>");
+
+    print ("</td></tr></table>");

     // Calc avg rating
     if ( $leveldata["totalcomments"] > 0 )
@@ -454,55 +577,92 @@
       $levelmd5 = $_GET["levelmd5"];
 ?>
     <hr/>
-    <p><em><strong>Add a comment:</strong></em></p>
- <form action="<? echo $PHP_SELF . "?c=" . urlencode($c) . "&l=" . urlencode($l); ?>" method="POST">
-      <input type="hidden" name="addcomment" value="1">
-      <input type="hidden" name="c" value="<? echo urlencode("$c"); ?>">
-      <input type="hidden" name="l" value="<? echo urlencode("$l"); ?>">
- <input type="hidden" name="levelmd5" value="<? echo urlencode($levelmd5); ?>">
-      <table>
-        <tr>
-          <td>Your name</td>
-          <td><input type="text" name="author"></td>
-        </tr>
-        <tr>
-          <td>Your email</td>
-          <td><input type="text" name="email"></td>
-        </tr>
-        <tr>
-          <td>Difficulty</td>
-          <td>
-            <select name="difficulty">
-              <option value="easy">easy</option>
-              <option value="normal">normal</option>
-              <option value="hard">hard</option>
-              <option value="very hard">very hard</option>
-              <option value="unplayable">unplayable</option>
-              <option value="unfinished" selected>unfinished</option>
-            </select>
-          </td>
-        </tr>
-        <tr>
-          <td>Rating</td>
-          <td>
-            <select name="rating">
-              <option value="1">1 bad</option>
-              <option value="2">2 well...</option>
-              <option value="3" selected>3 ok</option>
-              <option value="4">4 good</option>
-              <option value="5">5 very good</option>
-            </select>
-          </td>
-        </tr>
-        <tr>
-          <td>Comments</td>
-          <td><textarea rows="8" cols="40" name="comment"></textarea></td>
-        </tr>
-        <tr>
-          <td colspan="2"><input type="submit"/></td>
-        </tr>
-      </table>
-    </form>
+    <table width="100%">
+      <tr>
+        <td width="60%" valign="top">
+          <p><em><strong>Add a comment:</strong></em></p>
+ <form id="CommentForm" action="<? echo $PHP_SELF . "?c=" . urlencode($c) . "&l=" . urlencode($l); ?>" method="POST">
+            <input type="hidden" name="addcomment" value="1">
+ <input type="hidden" name="c" value="<? echo urlencode("$c"); ?>"> + <input type="hidden" name="l" value="<? echo urlencode("$l"); ?>"> + <input type="hidden" name="levelmd5" value="<? echo urlencode($levelmd5); ?>">
+            <table>
+              <tr>
+                <td>Your name</td>
+                <td><input type="text" name="author"></td>
+              </tr>
+              <tr>
+                <td>Your email</td>
+                <td><input type="text" name="email"></td>
+              </tr>
+              <tr>
+                <td>Difficulty</td>
+                <td>
+                  <select name="difficulty">
+                    <option value="easy">easy</option>
+                    <option value="normal">normal</option>
+                    <option value="hard">hard</option>
+                    <option value="very hard">very hard</option>
+                    <option value="unplayable">unplayable</option>
+                    <option value="unfinished" selected>unfinished</option>
+                  </select>
+                </td>
+              </tr>
+              <tr>
+                <td>Rating</td>
+                <td>
+                  <select name="rating">
+                    <option value="1">1 bad</option>
+                    <option value="2">2 well...</option>
+                    <option value="3" selected>3 ok</option>
+                    <option value="4">4 good</option>
+                    <option value="5">5 very good</option>
+                  </select>
+                </td>
+              </tr>
+              <tr>
+                <td>Comments</td>
+ <td><textarea rows="8" cols="40" name="comment"></textarea></td>
+              </tr>
+              <tr>
+                <td colspan="2"><input type="submit"/></td>
+              </tr>
+            </table>
+          </form>
+        </td>
+        <td width="50%" valign="top">
+          <p><em><strong>Upload a demofile:</strong></em></p>
+ <form enctype="multipart/form-data" name="UploadDemo" action="<? echo $PHP_SELF . "?c=" . urlencode($c) . "&l=" . urlencode($l); ?>" method="POST">
+            <input type="hidden" name="adddemo" value="1">
+ <input type="hidden" name="c" value="<? echo urlencode("$c"); ?>"> + <input type="hidden" name="l" value="<? echo urlencode("$l"); ?>"> + <input type="hidden" name="levelmd5" value="<? echo urlencode($levelmd5); ?>">
+            <table>
+              <tr>
+                <td>Your name</td>
+                <td><input type="text" name="username"></td>
+              </tr>
+              <tr>
+                <td>Your email</td>
+                <td><input type="text" name="email"></td>
+              </tr>
+              <tr>
+                <td>Demofile</td>
+                <td>
+                  <input type="file" name="demofile">
+                </td>
+              </tr>
+              <tr>
+                <td colspan="2">
+                  <input type="submit" value="Upload file">
+               </td>
+              </tr>
+            </table>
+          </form>
+        </td>
+      </tr>
+    </table>
+
 <?
print "<p><a href='$PHP_SELF?c=" . urlencode($c) . "'>Back to level list</a></p>";
     if ( !$is_admin )
=======================================
--- /level-cache.inc    Wed Apr 14 13:42:00 2004
+++ /level-cache.inc    Thu Apr 15 13:51:34 2004
@@ -56,12 +56,12 @@

   if (!$table_exists)
   {
- $SQL = "CREATE TABLE `$tablename` (`Key` VARCHAR( 255 ) NOT NULL ,`Value` TEXT NOT NULL , PRIMARY KEY ( `Key` ) );";
-    $res = mysql_query( $SQL, $db_handle );
+ $SQL = "CREATE TABLE `$tablename` (`Key` VARCHAR( 255 ) NOT NULL ,`Value` TEXT NOT NULL , PRIMARY KEY ( `Key` ) );";
+    $res = mysql_query( $SQL, $db_handle );
        if (!$res)
          return False;
        else
-         return $tablename;
+         return $tablename;
   }
   else
     return $tablename;
@@ -175,11 +175,11 @@
       $res = mysql_query( $SQL, $db_handle );
       if (mysql_num_rows($res) != 1)
        $data = False;
-      else
-        list(,$data) = mysql_fetch_row( $res );
+      else
+        list(,$data) = mysql_fetch_row( $res );
       break;
   }
-
+
   if ( !$data )
     return False;
   else
@@ -209,7 +209,7 @@
     $leveldata = parse_level( $levelfile );
     $leveldata["md5sum"] = md5(implode("", file($levelfile)));

-    $comments = parse_level_comments($cathegory, $level);
+    $comments = parse_level_comments($cathegory, $level, "ASC");
     $avgrating = 0;
     if (count($comments) > 0 )
     {
@@ -266,10 +266,10 @@
   $data = "";
   $key = make_db_key( $cathegory, $level );
   reset( $arr );
-
+
   while (list($k,$v) = each($arr))
     $data .= $k . "=" . $v . "\255";
-
+
   switch ($DBMS)
   {
     case "DBA":
@@ -282,7 +282,7 @@
       if (mysql_num_rows( $ret ) == 1)
$SQL = "UPDATE `$db_tablename` SET `Value`='" . str_replace( "'", "\'", $data ) . "' WHERE `Key`='$key'";
       else
- $SQL = "INSERT INTO $db_tablename (`Key`,`Value`) VALUES ('$key','" . str_replace( "'", "\'", $data ) . "')"; + $SQL = "INSERT INTO $db_tablename (`Key`,`Value`) VALUES ('$key','" . str_replace( "'", "\'", $data ) . "')";
       $ret = mysql_query( $SQL, $db_handle );
       break;
   }
@@ -329,7 +329,7 @@
   return $arr;
 }

-function parse_level_comments( $cathegory, $level )
+function parse_level_comments( $cathegory, $level, $order )
 {
   $res = Array();
   $comment_dir = "comments/$cathegory/$level";
@@ -340,7 +340,7 @@
   $dir = dir($comment_dir);
   $comments = Array();
   while ($file = $dir->read())
-    if ($file != "." && $file != ".." && file_exists("$comment_dir/$file"))
+ if ($file != "." && $file != ".." && file_exists("$comment_dir/$file") && !is_dir("$comment_dir/$file"))
       $comments[] = "$comment_dir/$file";
   $dir->close();

@@ -350,6 +350,7 @@
       "author" => "pingus-level-comment/author",
       "email" => "pingus-level-comment/email",
       "date" => "pingus-level-comment/date",
+         "time" => "pingus-level-comment/time",
       "difficulty" => "pingus-level-comment/difficulty",
       "rating" => "pingus-level-comment/rating",
       "comment" => "pingus-level-comment/comment",
@@ -361,8 +362,58 @@
       $cmt[$k] = $v["v"];

     $cmt["filename"] = $filename;
-    $res[] = $cmt;
-  }
+
+    // is the time set? (it is not in old comment files)
+       if (isset($cmt["time"]))
+         $res[$cmt["date"] . '-' . $cmt["time"]] = $cmt;
+    else
+ $res[$cmt["date"] . '-' . substr(md5(implode("", file($filename))),0,8)] = $cmt;
+  }
+  if ($order == "DESC")
+    arsort($res);
+  else
+    asort($res);
+
+  return $res;
+}
+
+function parse_level_demos( $cathegory, $level )
+{
+  $res = Array();
+  $demo_dir = "comments/$cathegory/$level/demos";
+  if ( !is_dir( $demo_dir ))
+    return $res;
+  sandbox_check($demo_dir, "comments/");
+
+  $dir = dir($demo_dir);
+  $demos = Array();
+  while ($file = $dir->read())
+    if ($file != "." && $file != ".." && file_exists("$demo_dir/$file")
+        && !is_dir("$demo_dir/$file") && strpos( $file, ".demo" ))
+      $demos[] = "$demo_dir/$file";
+  $dir->close();
+
+  while( list($key, $filename) = each($demos))
+  {
+    $cmt = xml_search( $filename, Array(
+      "username" => "pingus-demo-metafile/username",
+      "email" => "pingus-demo-metafile/email",
+      "date" => "pingus-demo-metafile/date",
+         "time" => "pingus-demo-metafile/time",
+         "demofile" => "pingus-demo-metafile/demofile",
+      "levelmd5" => "pingus-demo-metafile/levelmd5"
+    ));
+
+    // We don't need tag names and attributes, strip them off:
+    while( list($k,$v) = each($cmt))
+      $cmt[$k] = $v["v"];
+
+    $cmt["filename"] = $filename;
+
+    $res[$cmt["date"] . '-' . $cmt["time"]] = $cmt;
+  }
+  asort($res);
+
   return $res;
 }


==============================================================================
Revision: c58780d986f1
Author:   David Philippi <address@hidden>
Date:     Thu Apr 15 15:15:43 2004
Log:      cosmetic updates


http://code.google.com/p/pingus/source/detail?r=c58780d986f1&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Thu Apr 15 13:51:34 2004
+++ /index.php  Thu Apr 15 15:15:43 2004
@@ -174,7 +174,7 @@
             print "<table width='100%' border='0'>\n" .
              "<tr><td style='width:160px; height:120px;'>" .
"<a href='$PHP_SELF?c=" . urlencode($c["name"]) . "&l=" . urlencode($l) . "'>". - "<img src='http://pingus.seul.org/levels/thumb/$jpg' align='left' border='0'>". + "<img src='/levels/thumb/$jpg' align='left' border='0' alt='thumbnail'>".
              "</a></td><td>\n";
           }

@@ -193,9 +193,9 @@
             print "<b>Not playable</b><br>";
           if ( $cnt > 0 )
print "Rating:" . str_repeat( "*", intval($ldata["avgrating"])) . "<br>"; - print " view <a href='http://pingus.seul.org/levels/33/$jpg' target='levelview'>third</a>". - " / <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a>" . - " / <a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a><br>" . + print " view <a href='/levels/33/$jpg' target='levelview'>third</a>".
+            " / <a href='/levels/50/$jpg' target='levelview'>half</a>" .
+ " / <a href='/levels/100/$jpg' target='levelview'>full</a><br>" . /*"play with <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".pingus'>Subversion</a>" . " / <a href='data/levels/" . urlencode($c["name"]) . "/" . urlencode($l) . ".xml'>0.6</a> version" .
             "<br>";*/
@@ -255,7 +255,7 @@
       "Author" => str_replace("@", "<b><small>PingusNoSpam</small></b>@",
         htmlentities($leveldata["author"])),
       );
-    print( "<table border='1'>\n" );
+    print( "<table border='1' width='100%'>\n" );
     while( list($key,$val) = each( $tbl ))
       print("<tr><td><strong>" . htmlentities($key) . "</strong></td>\n" .
             "<td colspan='2'>" . $val . "</td></tr>\n");
@@ -271,18 +271,18 @@
     while( list($key,$val) = each( $tbl ))
     {
       print("<tr><td><strong>" . $key . "</strong></td>");
-      print ("<td width='100%'>\n" . htmlentities($val) . "</td>");
+      print ("<td>\n" . htmlentities($val) . "</td>");
       // Thumbnail
       if ( $i++ == 0)
       {
         $jpg = htmlentities($c) . "/" . htmlentities($l) . ".jpg";
-        print ("<td rowspan='5' valign='top' align='center'>\n".
- " <img src='http://pingus.seul.org/levels/thumb/$jpg' border='1'><br/>\n". - " see <a href='http://pingus.seul.org/levels/33/$jpg' target='levelview'>third</a> /". - " <a href='http://pingus.seul.org/levels/50/$jpg' target='levelview'>half</a> / \n". - " <a href='http://pingus.seul.org/levels/100/$jpg' target='levelview'>full</a> size\n<br>". - "<a href='data/levels/" . htmlentities($c) . "/" . htmlentities($l) . ".pingus'>play</a>\n" .
-          "</td>\n" );
+ print ("<td rowspan='5' valign='top' align='center' style='width:160px;'><small>\n". + " <img src='/levels/thumb/$jpg' border='1' alt='thumbnail'><br/>\n".
+          "  see <a href='/levels/33/$jpg' target='levelview'>third</a> /".
+          " <a href='/levels/50/$jpg' target='levelview'>half</a> / \n".
+ " <a href='/levels/100/$jpg' target='levelview'>full</a> size\n<br>". + "<a href='data/levels/" . htmlentities($c) . "/" . htmlentities($l) . ".pingus'>play level</a>" .
+          " (requires Pingus 0.6.1 or later)</small></td>\n" );
       }
     }

@@ -304,14 +304,13 @@
                  "style='cursor: pointer' src='gfx/actions/$a.png' " .
"onclick='document.getElementById(\"CommentForm\").comment.value = " . "document.getElementById(\"CommentForm\").comment.value + " .
-                 "document.getElementById(\"Pic$a\").name'></a> x " .
+                 "document.getElementById(\"Pic$a\").name'> x " .
                  $ac . " ");
       }
     }

     print( "</td></tr></table>\n" );
 ?>
-    </p>
     <hr/>
 <?
     // ==================================================================

==============================================================================
Revision: de277ca4b5d1
Author:   David Philippi <address@hidden>
Date:     Fri Apr 16 11:04:36 2004
Log:      minimal fixes


http://code.google.com/p/pingus/source/detail?r=de277ca4b5d1&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Thu Apr 15 15:15:43 2004
+++ /index.php  Fri Apr 16 11:04:36 2004
@@ -172,9 +172,9 @@
           if ( $show_thumbs )//additional column only when thumbs are shown
              {
             print "<table width='100%' border='0'>\n" .
-             "<tr><td style='width:160px; height:120px;'>" .
+             "<tr><td style='width:160px; height:120px;' align='center'>" .
"<a href='$PHP_SELF?c=" . urlencode($c["name"]) . "&l=" . urlencode($l) . "'>". - "<img src='/levels/thumb/$jpg' align='left' border='0' alt='thumbnail'>".
+             "<img src='/levels/thumb/$jpg' border='0' alt='thumbnail'>".
              "</a></td><td>\n";
           }

@@ -276,7 +276,7 @@
       if ( $i++ == 0)
       {
         $jpg = htmlentities($c) . "/" . htmlentities($l) . ".jpg";
- print ("<td rowspan='5' valign='top' align='center' style='width:160px;'><small>\n". + print ("<td rowspan='5' valign='top' align='center' style='width:160px;' align='center'><small>\n". " <img src='/levels/thumb/$jpg' border='1' alt='thumbnail'><br/>\n".
           "  see <a href='/levels/33/$jpg' target='levelview'>third</a> /".
           " <a href='/levels/50/$jpg' target='levelview'>half</a> / \n".

==============================================================================
Revision: 0c5f32fcc8eb
Author:   David Philippi <address@hidden>
Date:     Fri Apr 16 11:10:07 2004
Log:      tiny fix


http://code.google.com/p/pingus/source/detail?r=0c5f32fcc8eb&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Fri Apr 16 11:04:36 2004
+++ /index.php  Fri Apr 16 11:10:07 2004
@@ -265,7 +265,7 @@
"Pingus #" => $leveldata["pingusmin"] ." / " . $leveldata["pingusmax"],
       "Time" => $leveldata["time"],
       "Difficulty" => $leveldata["difficulty"],
-      "Playable" => $leveldata["playable"],
+      "Playable" => ($leveldata["playable"] == 1) ? "yes" : "no",
       );
     $i = 0;
     while( list($key,$val) = each( $tbl ))

==============================================================================
Revision: bba82bdc9c99
Author:   David Philippi <address@hidden>
Date:     Sat Apr 17 01:23:17 2004
Log:      various corrections


http://code.google.com/p/pingus/source/detail?r=bba82bdc9c99&repo=level-comment-tool

Modified:
 /level-cache.inc

=======================================
--- /level-cache.inc    Thu Apr 15 13:51:34 2004
+++ /level-cache.inc    Sat Apr 17 01:23:17 2004
@@ -39,8 +39,8 @@
 $db_tablename = 'lct_cache';
 $db_name = 'pingus';
 $db_host = 'localhost';
-$db_user = '';
-$db_pass = '';
+$db_user = 'pingus';
+$db_pass = 'pingus';

 function create_table( $tablename )
 {

==============================================================================
Revision: 8ee50b5b015d
Author:   David Philippi <address@hidden>
Date:     Sat Apr 17 05:18:09 2004
Log:      db / demo upload patches


http://code.google.com/p/pingus/source/detail?r=8ee50b5b015d&repo=level-comment-tool

Modified:
 /index.php
 /level-cache.inc

=======================================
--- /index.php  Fri Apr 16 11:10:07 2004
+++ /index.php  Sat Apr 17 05:18:09 2004
@@ -412,7 +412,7 @@
        // ==================================================================
     // Save uploaded Demofile
     // ==================================================================
-    if ( isset($_POST["adddemo"]))
+    if ( $_POST["adddemo"] == 1)
     {
       //create directory if necessary
       if ( !is_dir("comments/$c/$l/demos") &&
=======================================
--- /level-cache.inc    Sat Apr 17 01:23:17 2004
+++ /level-cache.inc    Sat Apr 17 05:18:09 2004
@@ -34,7 +34,7 @@
 global $db_user;
 global $db_pass;

-$DBMS = 'DBA';
+$DBMS = 'MySQL';
 $db_handle = False;
 $db_tablename = 'lct_cache';
 $db_name = 'pingus';
@@ -69,11 +69,13 @@

 function open_cache()
 {
-  global $db_handle;
   global $DBMS;
+  global $db_handle;
   global $db_tablename;
   global $db_name;
-
+  global $db_host;
+  global $db_user;
+  global $db_pass;

   if ( !$db_handle )
   {

==============================================================================
Revision: e1920097cfc7
Author:   David Philippi <address@hidden>
Date:     Wed Apr 21 11:43:26 2004
Log:      handle permissions better


http://code.google.com/p/pingus/source/detail?r=e1920097cfc7&repo=level-comment-tool

Modified:
 /index.php

=======================================
--- /index.php  Sat Apr 17 05:18:09 2004
+++ /index.php  Wed Apr 21 11:43:26 2004
@@ -325,14 +325,19 @@
         exit;
       }

-      if ( !is_dir("comments/$c/$l") &&
-           (@mkdir("comments/$c", 0775) || True) &&
-           !(@mkdir("comments/$c/$l", 0775)))
-      {
-        print ("<strong>ERROR: 'comments/$c/$l/' does not exist and ".
+      if ( !is_dir("comments/$c/$l"))
+      {
+        mkdir("comments/$c",0777);
+        mkdir("comments/$c/$l",0777);
+        chmod("comments/$c",0777);
+        chmod("comments/$c/$l",0777);
+        if ( !is_dir("comments/$c/$l"))
+        {
+          print ("<strong>ERROR: 'comments/$c/$l/' does not exist and ".
                "could not be created.</strong>\n");
-        exit;
-      }
+          exit;
+        }
+      }
       sandbox_check("comments/$c/$l", "comments/" );
       $str =
         '<' . '?xml version="1.0"  encoding="ISO-8859-1"?' . ">\n" .
@@ -362,7 +367,7 @@
           exit;
         }
         fclose($fp);
-        chmod($filename, 0775);
+        chmod($filename, 0777);

         // Send email-notification
         if ( $mail_notify_enabled )
@@ -415,16 +420,21 @@
     if ( $_POST["adddemo"] == 1)
     {
       //create directory if necessary
-      if ( !is_dir("comments/$c/$l/demos") &&
-           (@mkdir("comments/$c", 0775) || True) &&
-           (@mkdir("comments/$c/$l", 0775) || True) &&
-           !(@mkdir("comments/$c/$l/demos", 0775)))
-      {
-        print ("<strong>ERROR: 'comments/$c/$l/demos' does not exist and ".
-               "could not be created.</strong>\n");
-        exit;
-      }
-
+      if ( !is_dir("comments/$c/$l/demos"))
+      {
+        mkdir("comments/$c", 0777);
+        mkdir("comments/$c/$l", 0777);
+        mkdir("comments/$c/$l/demos", 0777);
+        chmod("comments/$c",0777);
+        chmod("comments/$c/$l",0777);
+        chmod("comments/$c/$l/demos",0777);
+        if ( !is_dir("comments/$c/$l/demos"))
+        {
+ print ("<strong>ERROR: 'comments/$c/$l/demos' does not exist and ".
+                 "could not be created.</strong>\n");
+          exit;
+        }
+      }
       $uploaddir = sandbox_check( "comments/$c/$l/demos", "comments/" );

       if(!strpos( strtolower( $_FILES["demofile"]["name"] ), ".xml" ))
@@ -433,6 +443,7 @@
       {
if (move_uploaded_file($_FILES['demofile']['tmp_name'], $uploaddir. '/' . $_FILES['demofile']['name']))
         {
+ chmod( "comments/$c/$l/demos/" . $_FILES['demofile']['name'], 0777 );
           print("<strong>File uploaded successfully</strong><hr/>");
$str = '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . ">\n" .
                 "<pingus-demo-metafile>\n".
@@ -459,7 +470,7 @@
               exit;
             }
             fclose($fp);
-            chmod($filename, 0775);
+            chmod($filename, 0777);
          }
        }
         else

==============================================================================
Revision: a3c30b694354
Author:   David Philippi <address@hidden>
Date:     Wed Apr 28 13:10:28 2004
Log:      login updates


http://code.google.com/p/pingus/source/detail?r=a3c30b694354&repo=level-comment-tool

Added:
 /database.inc
 /login-system.inc
Modified:
 /index.php
 /level-cache.inc

=======================================
--- /dev/null
+++ /database.inc       Wed Apr 28 13:10:28 2004
@@ -0,0 +1,50 @@
+<?
+// variables and functions used for database acces
+// this file is being imported in index.php as the first file, so all other
+// .inc files can use its functionality.
+//
+// Copyright (C) 2004 Björn Fischer <address@hidden>
+//
+// 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.
+// * The name of the author may not be used to endorse or promote products derived
+//   from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +// 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.
+
+
+// set some globals for various DBMS
+global $DBMS;
+global $db_handle;
+global $db_tablename;
+global $db_name;
+global $db_host;
+global $db_user;
+global $db_pass;
+global $db_conn;          //used in login-system.inc
+global $db_usertablename; //used in login-system.inc
+
+$DBMS = 'MySQL';
+$db_handle = False;
+$db_tablename = 'lct_cache';
+$db_name = 'pingus';
+$db_host = 'localhost';
+$db_user = 'pingus';
+$db_pass = 'pingus';
+$db_conn = False;
+$db_usertablename = "lct_users";
+?>
=======================================
--- /dev/null
+++ /login-system.inc   Wed Apr 28 13:10:28 2004
@@ -0,0 +1,537 @@
+<?php
+
+// functions concering user signup and login
+// this file needs a working MySQL database with the correct values
+// set in level-cache.inc!!!
+//
+// Copyright (C) 2004 Björn Fischer <address@hidden>
+//
+// 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.
+// * The name of the author may not be used to endorse or promote products derived
+//   from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''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 AUTHOR +// 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.
+
+
+
+// ==================================================================
+// opens database connection
+// ==================================================================
+function open_db()
+{
+  global $db_conn;
+  global $db_name;
+  global $db_host;
+  global $db_user;
+  global $db_pass;
+
+  $db_conn = mysql_connect( $db_host, $db_user, $db_pass );
+  if (!$db_conn)
+  {
+ echo "<p><font color=\"red\"><b>ERROR: Cannot open connection to database server ($db_host)!</b></font></p>";
+    exit;
+  }
+
+  if (! mysql_select_db( $db_name, $db_conn ))
+  {
+ echo "<p><font color=\"red\"><b>ERROR: Cannot select database '$db_name'!</b></font></p>";
+    exit;
+  }
+}
+
+// ==================================================================
+// closes database connection
+// ==================================================================
+function close_db()
+{
+  global $db_conn;
+
+  if ($db_conn !== False)
+  {
+    mysql_close($db_conn);
+    $db_conn = False;
+  }
+}
+
+// ==================================================================
+// saves the dataset of a user
+// ==================================================================
+function save_user_data( $name, $email, $com_mailer, $update )
+{
+  global $db_conn;
+  global $db_usertablename;
+  global $db_name;
+
+  if ($com_mailer == "on")
+    $com_mailer = 1;
+  else
+    $com_mailer = 0;
+
+  open_db();
+ $SQL = "CREATE TABLE `$db_usertablename` (`ID` INT NOT NULL AUTO_INCREMENT ,`Name` VARCHAR( 100 ) NOT NULL ,". + "`eMail` VARCHAR( 100 ) NOT NULL ,`commentmailer` TINYINT( 1 ) NOT NULL ,PRIMARY KEY ( `ID` ) ,".
+         "UNIQUE (`eMail`));";
+ $db_usertablename = create_table( $db_conn, $db_name, $db_usertablename, $SQL );
+
+  if ($update)
+ $SQL = "UPDATE $db_usertablename SET `Name`='$name',`commentmailer`=$com_mailer".
+           " WHERE `eMail`='$email'";
+  else
+ $SQL = "INSERT INTO $db_usertablename (`Name`,`eMail`,`commentmailer`)".
+         " VALUES ('$name','$email',$com_mailer)";
+
+  if (!mysql_query( $SQL, $db_conn ))
+  {
+ echo '<p><font color="red"><b>ERROR: Cannot save user data!</b></font></p>';
+    close_db();
+    return False;
+  }
+  else
+  {
+    close_db();
+    return True;
+  }
+}
+
+// ==================================================================
+// loads user data from database
+// ==================================================================
+function get_user_data( $u_email )
+{
+  global $db_conn;
+  global $db_usertablename;
+  $ret = Array();
+
+  open_db();
+
+ $SQL = "SELECT * FROM $db_usertablename WHERE eMail='".strtolower($u_email)."'";
+  $succ = mysql_query( $SQL, $db_conn );
+  if (!$succ)
+  {
+ echo "<p><font color='red'><b>ERROR: Cannot find data for user $u_email!</b></font></p>";
+    exit;
+  }
+
+  list( ,$name,$email,$com_mailer ) = mysql_fetch_row( $succ );
+  $ret["name"] = htmlspecialchars($name);
+  $ret["email"] = htmlspecialchars($email);
+  $ret["com_mailer"] = htmlspecialchars($com_mailer);
+
+  close_db();
+
+  return $ret;
+}
+
+// ==================================================================
+// Detetes users data from the table
+// ==================================================================
+function del_user_data( $u_email )
+{
+  global $db_conn;
+  global $db_usertablename;
+
+  open_db();
+ $SQL = "DELETE FROM $db_usertablename WHERE eMail='".strtolower($u_email)."'";
+  $succ = mysql_query( $SQL, $db_conn );
+  close_db();
+
+  if ($succ)
+    return True;
+  else
+    return False;
+}
+
+// ==================================================================
+// Show a signup form
+// ==================================================================
+function show_signup_form()
+{
+  $params = "?" . get_params();
+
+  echo '<script language = "JavaScript">'."\n".
+       '<!--'."\n".
+       'function TestError()'."\n".
+       '{'."\n".
+       '  var f = document.Signup;'."\n".
+       '  var errors = "";'."\n".
+       '  var i;'."\n".
+       '  var IsError = false;'."\n\n".
+ ' if ((f.elements["username"].value == "") || (f.elements["username"].value == null))'."\n".
+       '  {'."\n".
+       '    errors += "Please enter your Name!\n";'."\n".
+       '    IsError = true;'."\n".
+       '  } '."\n\n".
+ ' if ((f.elements["email"].value == "") || (f.elements["email"].value == null))'."\n".
+       '  {'."\n".
+       '    errors += "Please enter your email adress!\n";'."\n".
+       '    IsError = true;'."\n".
+       '  } '."\n\n".
+ ' if ((f.elements["pass"].value == "") || (f.elements["pass"].value == null))'."\n".
+       '  {'."\n".
+       '    errors += "Please choose a password!\n";'."\n".
+       '    IsError = true;'."\n".
+       '  } '."\n\n".
+ ' if ((f.elements["pass2"].value == "") || (f.elements["pass2"].value == null))'."\n".
+       '  {'."\n".
+       '    errors += "Please retype your password!\n";'."\n".
+       '    IsError = true;'."\n".
+       '  }'."\n\n".
+       '  if (f.elements["pass"].value != f.elements["pass2"].value)'."\n".
+       '  {'."\n".
+ ' errors += "The passwords do not match, please retype them!\n";'."\n".
+       '    IsError = true;'."\n".
+       '  }'."\n\n".
+ ' if ((f.elements["email"].value.indexOf("@") == -1) || (f.elements["email"].value.length < 3))'."\n".
+       '  {'."\n".
+       '    errors += "Please enter a valid email adress!\n";'."\n".
+       '    IsError = true;'."\n".
+       '  }  '."\n\n".
+       '  if (IsError==true)'."\n".
+       '  {'."\n".
+       '    alert(errors);'."\n".
+       '    return false;'."\n".
+       '  } '."\n".
+       '  return true;'."\n".
+       '}'."\n".
+       '--></script>'."\n\n";
+
+  echo "<H2>Pingus level comment database - user signup</H2>".
+       "Please keep the following in mind:".
+       "<UL><LI>enter your real name and a valid eMail adress</LI>".
+ "<LI>please remember your password since there is no possibility to mail it to you yet</LI>".
+       "<LI>after signup your login name is the entered mail adress<LI>".
+       "</UL>By activating the checkbox you can".
+ " activate the comment mailer, that means you will receive comments about your own levels".
+       " by eMail (this is only important for level designers).<br><br>\n";
+
+ echo '<form enctype="multipart/form-data" name="Signup" action="'.$PHP_SELF.$params.'" method="POST" onsubmit="return TestError()">'."\n".
+       '<input type="hidden" name="usersignedup" value="1">'."\n".
+       '<table>'."\n".
+       ' <tr>'."\n".
+       '  <td>Your name</td>'."\n".
+       '  <td><input type="text" name="username"></td>'."\n".
+       ' </tr>'."\n".
+       ' <tr>'."\n".
+       '  <td>Your email</td>'."\n".
+       '  <td><input type="text" name="email"></td>'."\n".
+       ' </tr>'."\n".
+       ' <tr>'."\n".
+       '  <td>Comment mailer</td>'."\n".
+       '  <td><input type="checkbox" name="commentmailer"></td>'."\n".
+       ' </tr>'."\n".
+       ' <tr>'."\n".
+       '  <td>Pick a password</td>'."\n".
+       '  <td><input type="password" name="pass"></td>'."\n".
+       ' </tr>'."\n".
+       ' <tr>'."\n".
+       '  <td>Retype password</td>'."\n".
+       '  <td><input type="password" name="pass2"></td>'."\n".
+       ' </tr>'."\n".
+       ' <tr>'."\n".
+ ' <td colspan="2"><input type="submit" value="signup now"></td>'."\n".
+       ' </tr>'."\n".
+       '</table>'."\n".
+       '</form>'."\n";
+}
+
+// ==================================================================
+// Save singed up user data
+// ==================================================================
+function signup_user()
+{
+  global $DBMS;
+  global $db_usertablename;
+  global $db_conn;
+  global $db_name;
+
+  if (!isset( $_POST["usersignedup"] ))
+    exit;
+
+  if ($DBMS != "MySQL")
+  {
+ echo "<p><font color='red'><b>ERROR: MySQL support necessary. Signup not possible!</b></font></p>";
+    exit;
+  }
+
+  $u_name = $_POST["username"];
+  $u_email = strtolower($_POST["email"]);
+  $u_com_mailer = $_POST["commentmailer"];
+  $u_pass = $_POST["pass"];
+
+  // look if user already exists
+  $pass_arr = load_htpasswd();
+  while (list($u, $p) = each($pass_arr))
+  {
+    if ($u_email == $u)
+    {
+ echo '<p><font color="red"><b>ERROR: This mailadress already has a user account!</b></font></p>';
+      return False;
+    }
+  }
+
+  if (save_user_data( $u_name, $u_email, $u_com_mailer, False ))
+  {
+    $pass_arr[$u_email] = rand_salt_crypt($u_pass);
+    save_htpasswd( $pass_arr );
+ echo '<p><font color="green"><b>Your data has been saved. You can now login via the link on the right.<br>'. + 'Please remember that your eMail adress is used as login name<br></b></font></p>';
+  }
+}
+
+// ==================================================================
+// Show list of users (with delete link for admin)
+// ==================================================================
+function show_user_list( $is_admin )
+{
+  $params = get_params();
+
+  echo "<H2>Pingus level comment tool - user list</H2>\n";
+  echo "<table border='1' cellpadding='10'>\n";
+  echo "  <tr>\n";
+  echo "    <th>\n";
+  echo "      Name\n";
+  echo "    </th>\n";
+  echo "    <th>\n";
+  echo "      eMail\n";
+  echo "    </th>\n";
+  echo "    <th>\n";
+  echo "      Comment mailer\n";
+  echo "    </th>\n";
+  if ( $is_admin )
+  {
+    echo "    <th>\n";
+    echo "      Delete\n";
+    echo "    </th>\n";
+  }
+  echo "  </tr>\n";
+
+  $htpasswd = load_htpasswd();
+  while (list($u,$p) = each($htpasswd))
+  {
+    if ( $u != "admin" )
+    {
+      $u_data = get_user_data( $u );
+      echo "  <tr>\n";
+      echo "    <td>\n";
+      echo "      ".htmlentities($u_data["name"])."\n";
+      echo "    </td>\n";
+      echo "    <td>\n";
+      echo "      ".$u_data["email"]."\n";
+      echo "    </td>\n";
+      echo "    <td align='center'>\n";
+      echo ($u_data["com_mailer"]==1)?"yes":"no";
+      echo "\n";
+      echo "    </td>\n";
+      if ( $is_admin )
+      {
+        echo "    <td>\n";
+?>
+        <form enctype="multipart/form-data"  name="DeleteUser"
+              action="<? echo "$PHP_SELF?$params"; ?>" method="POST"
+ onsubmit="return confirm('Do you really want to delete user <? echo $u_data["email"]; ?>?')">
+          <input type="hidden" name="deluser" value="1">
+ <input type="hidden" name="user_email" value="<? echo $u_data["email"]; ?>">
+          <input type="submit" value="delete">
+        </form>
+
+<?
+        echo "    </td>\n";
+      }
+      echo "  </tr>\n";
+    }
+  } //end while
+  echo "</table>\n";
+}
+
+// ==================================================================
+// Delete userdata from database
+// ==================================================================
+function delete_user( $u_email )
+{
+  $htpasswd = load_htpasswd();
+  $new_htpasswd = array_flip( $htpasswd );
+
+  $index = array_search( strtolower($u_email), $new_htpasswd );
+  if (!$index)
+  {
+ echo "<p><font color='red'><b>ERROR: User $u_email not found in .htpasswd!</b></font></p>";
+  }
+  else
+  {
+ $new_htpasswd = array_diff( $new_htpasswd, array( $index => strtolower($u_email)) );
+    if (!del_user_data( $u_email ))
+ echo "<p><font color='red'><b>ERROR: User $u_email not found in database!</b></font></p>";
+    else
+    {
+      $htpasswd = array_flip( $new_htpasswd );
+      save_htpasswd( $htpasswd );
+ echo "<p><font color='green'><b>User deleted successfully!</b></font></p>";
+    }
+  }
+}
+
+// ==================================================================
+// Show form to change user's data
+// ==================================================================
+function show_change_form( $u_email )
+{
+    $params = "?" . get_params();
+    $user_data = get_user_data( $u_email );
+
+    echo '<script language = "JavaScript">'."\n".
+         '<!--'."\n".
+         'function TestError()'."\n".
+         '{'."\n".
+         '  var f = document.Changeuser;'."\n".
+         '  var errors = "";'."\n".
+         '  var i;'."\n".
+         '  var IsError = false;'."\n\n".
+ ' if ((f.elements["username"].value == "") || (f.elements["username"].value == null))'."\n".
+         '  {'."\n".
+         '    errors += "Please enter your Name!\n";'."\n".
+         '    IsError = true;'."\n".
+         '  } '."\n\n".
+ ' if (f.elements["pass"].value != f.elements["pass2"].value)'."\n".
+         '  {'."\n".
+ ' errors += "The passwords do not match, please retype them!\n";'."\n".
+         '    IsError = true;'."\n".
+         '  }'."\n\n".
+ ' if ((f.elements["email"].value.indexOf("@") == -1) || (f.elements["email"].value.length < 3))'."\n".
+         '  {'."\n".
+         '    errors += "Please enter a valid email adress!\n";'."\n".
+         '    IsError = true;'."\n".
+         '  }  '."\n\n".
+         '  if (IsError==true)'."\n".
+         '  {'."\n".
+         '    alert(errors);'."\n".
+         '    return false;'."\n".
+         '  } '."\n".
+         '  return true;'."\n".
+         '}'."\n".
+         '--></script>'."\n\n";
+
+    echo "<H2>Change data for user ".$user_data["name"]."</H2>".
+         "Please keep the following in mind:".
+         "<UL><LI>enter your real name and a valid eMail adress</LI>".
+ "<LI>please remember your password since there is no possibility to mail it to you yet</LI>".
+         "<LI>always log in using your email adress as username<LI>".
+         "</UL>By activating the checkbox you can".
+ " activate the comment mailer, that means you will receive comments about your own levels". + " by eMail (this is only important for level designers).<br><br>\n";
+
+ echo '<form enctype="multipart/form-data" name="Changeuser" action="'.$PHP_SELF.$params.'" method="POST" onsubmit="return TestError()">'."\n".
+         '<input type="hidden" name="savechangeddata" value="1">'."\n".
+ '<input type="hidden" name="email" value="'.$user_data["email"].'">'."\n".
+         '<table>'."\n".
+         ' <tr>'."\n".
+         '  <td>Your name</td>'."\n".
+ ' <td><input type="text" name="username" value="'.$user_data["name"].'"></td>'."\n".
+         ' </tr>'."\n".
+         ' <tr>'."\n".
+         '  <td>Comment mailer</td>'."\n";
+    if ( $user_data["com_mailer"] == 1 )
+ echo ' <td><input type="checkbox" name="commentmailer" checked></td>'."\n";
+    else
+      echo '  <td><input type="checkbox" name="commentmailer"></td>'."\n";
+
+    echo ' </tr>'."\n".
+         ' <tr>'."\n".
+         '  <td>New password</td>'."\n".
+         '  <td><input type="password" name="pass"></td>'."\n".
+         ' </tr>'."\n".
+         ' <tr>'."\n".
+         '  <td>Retype password</td>'."\n".
+         '  <td><input type="password" name="pass2"></td>'."\n".
+         ' </tr>'."\n".
+         ' <tr>'."\n".
+ ' <td colspan="2"><input type="submit" value="update my data"></td>'."\n".
+         ' </tr>'."\n".
+         '</table>'."\n".
+         '</form>'."\n".
+         '<br>'."\n";
+
+ echo '<form enctype="multipart/form-data" name="Deluser" action="'.$PHP_SELF.$params.'" method="POST">'."\n".
+         '<input type="hidden" name="deleteuser" value="1">'."\n".
+ '<input type="hidden" name="email" value="'.$user_data["email"].'">'."\n".
+         '<table>'."\n".
+         ' <tr>'."\n".
+ " <td><input style=\"background-color:#FF0000\" type=\"submit\" value=\"DELETE ACCOUNT!!!\"". + " onclick=\"return confirm('Do you really want to delete your user account?\\nThis will ".
+               "not be reverseable!');\"></td>"."\n".
+         ' </tr>'."\n".
+         '</table>'."\n".
+         '</form>'."\n";
+}
+
+// ==================================================================
+// Save changed user data
+// ==================================================================
+function change_user_data()
+{
+  global $DBMS;
+  global $db_usertablename;
+  global $db_conn;
+  global $db_name;
+
+ if (!isset( $_POST["savechangeddata"] ) && !isset( $_POST["deleteuser"] ))
+    exit;
+
+  if ($DBMS != "MySQL")
+  {
+ echo "<p><font color='red'><b>ERROR: MySQL support necessary. Signup not possible!</b></font></p>";
+    exit;
+  }
+
+  if (isset( $_POST["savechangeddata"] ))
+  {
+    $u_name = $_POST["username"];
+    $u_email = strtolower($_POST["email"]);
+    $u_com_mailer = $_POST["commentmailer"];
+    $u_pass = $_POST["pass"];
+
+    $pass_arr = load_htpasswd();
+    $user_found = False;
+    while (list($u, $p) = each($pass_arr))
+    {
+      if ($u_email == $u)
+      {
+        $user_found = True;
+      }
+    }
+
+    if (!$user_found)
+    {
+ echo "<p><font color='red'><b>ERROR: User not found in .htpasswd!</b></font></p>";
+      exit;
+    }
+
+    if (save_user_data( $u_name, $u_email, $u_com_mailer, True))
+    {
+      if (strlen($u_pass) > 0)
+      {
+        $pass_arr[$u_email] = rand_salt_crypt($u_pass);
+        save_htpasswd( $pass_arr );
+      }
+ echo '<p><font color="green"><b>Your data has been updated.<br></b></font></p>';
+    }
+  }
+  else
+    delete_user( strtolower($_POST["email"]) );
+}
+
+?>
=======================================
--- /index.php  Wed Apr 21 11:43:26 2004
+++ /index.php  Wed Apr 28 13:10:28 2004
@@ -23,20 +23,47 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+require_once("database.inc");
 require_once("xml-search.inc");
 require_once("level-cache.inc");
 require_once("mail-settings.inc");
 require_once("htpasswd.inc");
+require_once("login-system.inc");

 // ==================================================================
-// Admin login.
+// Returns the get-parameters (like cathegory, level and others)
 // ==================================================================
-
+function get_params()
+{
+  $params = "";
+  if (isset( $_GET["c"] ))
+    $params .= 'c='.urlencode($_GET["c"]).'&';
+  if (isset( $_GET["l"] ))
+    $params .= 'l='.urlencode($_GET["l"]).'&';
+  if (isset( $_GET["o"] ))
+    $params .= 'o='.urlencode($_GET["o"]).'&';
+  if (isset( $_GET["showthumbs"] ))
+    $params .= 'showthumbs='.urlencode($_GET["showthumbs"]).'&';
+
+  return $params;
+}
+
+// ==================================================================
+// User/Admin login or signup new user
+// ==================================================================
 $htpasswd = load_htpasswd();
 $is_admin = False;
-if ( isset($_SERVER['PHP_AUTH_PW']))
- $is_admin = test_htpasswd( $htpasswd, "admin", $_SERVER['PHP_AUTH_PW'] );
-
+$is_user = False;
+$user_data = Array();
+if ( isset($_SERVER['PHP_AUTH_PW']) && isset($_SERVER['PHP_AUTH_USER']))
+  if ($_SERVER['PHP_AUTH_USER'] == "admin")
+ $is_admin = test_htpasswd( $htpasswd, "admin", $_SERVER['PHP_AUTH_PW'] );
+  else
+  {
+ $is_user = test_htpasswd( $htpasswd, strtolower($_SERVER['PHP_AUTH_USER']), $_SERVER['PHP_AUTH_PW'] );
+    $user_data = get_user_data( $_SERVER['PHP_AUTH_USER'] );
+  }
+
 if ( isset($_GET["adminlogin"]))
 {
   if (!isset($_SERVER['PHP_AUTH_USER']))
@@ -48,17 +75,44 @@
   }
   else
   {
-    if ( !isset($_SERVER['PHP_AUTH_PW']) ||
-      !test_htpasswd( $htpasswd,  "admin", $_SERVER['PHP_AUTH_PW'] ))
-    {
+    if ( !test_htpasswd( $htpasswd, "admin", $_SERVER['PHP_AUTH_PW'] ))
+    {
+      header('WWW-Authenticate: Basic realm="Pingus Comment Tool Admin"');
       header('HTTP/1.0 401 Unauthorized');
-      echo 'Wrong password. Hit Back.';
+      echo 'Cancelled. Hit Back.';
       exit;
     }
     else
       $is_admin = True;
   }
 }
+
+if ( isset($_GET["userlogin"]))
+{
+  if (!isset($_SERVER['PHP_AUTH_USER']))
+  {
+    header('WWW-Authenticate: Basic realm="Pingus Comment Tool User"');
+    header('HTTP/1.0 401 Unauthorized');
+    echo 'Cancelled. Hit Back.';
+    exit;
+  }
+  else
+  {
+ if ( !test_htpasswd( $htpasswd, strtolower($_SERVER['PHP_AUTH_USER']), $_SERVER['PHP_AUTH_PW'] ))
+    {
+      header('WWW-Authenticate: Basic realm="Pingus Comment Tool User"');
+      header('HTTP/1.0 401 Unauthorized');
+      echo 'Cancelled. Hit Back.';
+      exit;
+    }
+    else
+    {
+      $is_user = True;
+      $user_data = get_user_data( $_SERVER['PHP_AUTH_USER'] );
+    }
+  }
+}
+

 // ==================================================================
 // Thumbnail magick with cookies etc.
@@ -83,15 +137,93 @@
   <body>

     <h1>Pingus level comment database</h1>
+
+ <?
+// ==================================================================
+// Show login and signup link
+// ==================================================================
+    $params = get_params();
+
+    if (!$is_user && !$is_admin)
+    {
+ ?>
+    <div align="right">
+      <table border="0" align="right" cellspacing="10">
+        <tr>
+          <td>
+ <a href="<? echo "$PHP_SELF?$params"."userlogin=1" ?>">Login</a>
+          </td>
+          <td>
+            <a href="<? echo "$PHP_SELF?$params"."signup=1" ?>">Signup</a>
+          </td>
+        </tr>
+      </table>
+    </div>
+ <? }
+    else
+    {
+ ?>
+    <div align="right">
+      <table border="0" align="right" cellspacing="10">
+        <tr>
+          <td align="right">
+           <a href="<? echo "$PHP_SELF?$params"."changeuser=1\">";
+ echo ($is_admin) ? 'admin' : $user_data["name"]; ?></a> is logged in<br>
+           <? echo "<a href='$PHP_SELF?$params";
+ echo (isset($_GET["listusers"])) ? "'>Show comments" : "listusers=1'>List users";
+              echo "</a>"; ?>
+         </td>
+       </tr>
+      </table>
+    </div>
+ <?
+    }
+ ?>
     <div class="mainbody">

 <?
-
-$preferred_order = Array( 'tutorial', 'playable', 'volcano', 'wip', 'test' );
+// ==================================================================
+// Signup for new user or change user settings
+// ==================================================================
+if (isset( $_GET["signup"] ))
+{
+  show_signup_form();
+  exit;
+}
+if (isset( $_POST["usersignedup"] ))
+{
+  signup_user();
+}
+if (isset( $_GET["changeuser"] ) && $is_user)
+{
+  show_change_form( $user_data["email"] );
+  exit;
+}
+if ((isset( $_POST["savechangeddata"] ) || isset( $_POST["deleteuser"])) && $is_user)
+{
+  change_user_data();
+}
+
+
+// ==================================================================
+// Show list of users or delete user (for admin only)
+// ==================================================================
+if (isset( $_GET["listusers"] ))
+{
+  show_user_list( $is_admin );
+  exit;
+}
+if (isset( $_POST["deluser"] ) && $is_admin)
+{
+  delete_user( $_POST["user_email"] );
+  show_user_list( $is_admin );
+  exit;
+}

 // ==================================================================
 // Read cathegory and level names from filesystem
 // ==================================================================
+$preferred_order = Array( 'tutorial', 'playable', 'volcano', 'wip', 'test' );
 $cathegories = Array();
 $dir = dir("data/levels");
 while ($file = $dir->read())
@@ -129,8 +261,7 @@
     $showCath = '&c=' . $_GET["c"];

   if ( $show_thumbs )
- print "<a href='$PHP_SELF?showthumbs=0$showCath'>[hide thumbnails]</a></br>";
-
+ print "<a href='$PHP_SELF?showthumbs=0$showCath'>[hide thumbnails]</a></br>";
   else
print "<a href='$PHP_SELF?showthumbs=1$showCath'>[show thumbnails]</a></br>";

@@ -327,10 +458,12 @@

       if ( !is_dir("comments/$c/$l"))
       {
-        mkdir("comments/$c",0777);
-        mkdir("comments/$c/$l",0777);
-        chmod("comments/$c",0777);
-        chmod("comments/$c/$l",0777);
+        @mkdir("comments/$c",0775);
+        @mkdir("comments/$c/$l",0775);
+        chmod("comments/$c",0775);
+        chgrp("comments/$c","pingus");
+        chmod("comments/$c/$l",0775);
+        chgrp("comments/$c/$l","pingus");
         if ( !is_dir("comments/$c/$l"))
         {
           print ("<strong>ERROR: 'comments/$c/$l/' does not exist and ".
@@ -367,7 +500,8 @@
           exit;
         }
         fclose($fp);
-        chmod($filename, 0777);
+        chmod($filename, 0775);
+        chgrp($filename,"pingus");

         // Send email-notification
         if ( $mail_notify_enabled )
@@ -404,7 +538,7 @@
     // ==================================================================
     // Delete comment
     // ==================================================================
-    if ( $is_admin && isset($_GET["delcomment"]))
+    if ( ($is_admin || $is_user) && isset($_GET["delcomment"]))
     {
       sandbox_check($_GET["delcomment"], "comments/" );
       unlink($_GET["delcomment"]);
@@ -413,8 +547,32 @@
       @rmdir("comments/$c");
print "<p><strong>Deleted '" . htmlentities($_GET["delcomment"]) . "'</strong></p>";
     }
-
-       // ==================================================================
+
+    // ==================================================================
+    // Delete demo file and metafile
+    // ==================================================================
+    if ( ($is_admin || $is_user) && isset($_GET["deldemo"]))
+    {
+      sandbox_check($_GET["deldemo"], "comments/" );
+
+      $demos = parse_level_demos( $c, $l );
+      while( list(,$cmt) = each($demos))
+      {
+        if ($_GET["deldemo"] == $cmt["filename"])
+        {
+          //delete demofile and metafile
+          unlink( "comments/$c/$l/demos/".$cmt["demofile"] );
+          unlink( $_GET["deldemo"] );
+        }
+      }
+      // Also try to remove the directories but don't mind if it fails:
+      @rmdir("comments/$c/$l/demos");
+      @rmdir("comments/$c/$l");
+      @rmdir("comments/$c");
+ print "<p><strong>Deleted '" . htmlentities($_GET["deldemo"]) . "'</strong></p>";
+    }
+
+    // ==================================================================
     // Save uploaded Demofile
     // ==================================================================
     if ( $_POST["adddemo"] == 1)
@@ -422,12 +580,16 @@
       //create directory if necessary
       if ( !is_dir("comments/$c/$l/demos"))
       {
-        mkdir("comments/$c", 0777);
-        mkdir("comments/$c/$l", 0777);
-        mkdir("comments/$c/$l/demos", 0777);
-        chmod("comments/$c",0777);
-        chmod("comments/$c/$l",0777);
-        chmod("comments/$c/$l/demos",0777);
+        @mkdir("comments/$c", 0777);
+        @mkdir("comments/$c/$l", 0777);
+        @mkdir("comments/$c/$l/demos", 0777);
+        chmod("comments/$c",0775);
+        chgrp("comments/$c","pingus");
+        chmod("comments/$c/$l",0775);
+        chgrp("comments/$c/$l","pingus");
+        chmod("comments/$c/$l/demos",0775);
+        chgrp("comments/$c/$l/demos","pingus");
+
         if ( !is_dir("comments/$c/$l/demos"))
         {
print ("<strong>ERROR: 'comments/$c/$l/demos' does not exist and ".
@@ -443,7 +605,8 @@
       {
if (move_uploaded_file($_FILES['demofile']['tmp_name'], $uploaddir. '/' . $_FILES['demofile']['name']))
         {
- chmod( "comments/$c/$l/demos/" . $_FILES['demofile']['name'], 0777 ); + chmod( "comments/$c/$l/demos/" . $_FILES['demofile']['name'], 0775 ); + chgrp( "comments/$c/$l/demos/" . $_FILES['demofile']['name'], "pingus" );
           print("<strong>File uploaded successfully</strong><hr/>");
$str = '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . ">\n" .
                 "<pingus-demo-metafile>\n".
@@ -470,7 +633,8 @@
               exit;
             }
             fclose($fp);
-            chmod($filename, 0777);
+            chmod($filename, 0775);
+            chgrp($filename, "pingus");
          }
        }
         else
@@ -510,7 +674,7 @@
         $rating = intval($cmt["rating"]);
         $leveldata["avgrating"] += $rating;

-        if ( $is_admin )
+ if ( $is_admin || ($is_user && $user_data["email"] == $cmt["email"]) )
           $del_link = " <a href='$PHP_SELF?c=" . htmlentities($c) .
"&l=" . htmlentities($l) . "&delcomment=" . htmlentities($cmt["filename"]) . "'>[del]</a>\n";
         $str =
@@ -536,18 +700,21 @@
     if ( count($demos) > 0 )
     {
       $showDemos = True;
-
+      $del_link="";
       while( list(,$cmt) = each($demos))
       {
         $leveldata["totaldemos"]++;

+ if ( $is_admin || ($is_user && $user_data["email"] == $cmt["email"])) + $del_link = " - <a href='$PHP_SELF?c=" . htmlentities($c)."&l=" . htmlentities($l) .
+                 "&deldemo=" . htmlentities($cmt["filename"]) . 
"'>[del]</a>\n";
         $str =
"<p class='message'><strong>From:</strong> " . htmlentities($cmt["username"]) . " &lt;" . str_replace("@", "<b><small>PingusNoSpam</small></b>@", htmlentities($cmt["email"])) .
           "&gt;<br><strong>Date: </strong> " . htmlentities($cmt["date"]) .
", <strong>Time: </strong> " . htmlentities($cmt["time"]) . "<br/>\n" . "<b>Demofile: </b><a href='comments/$c/$l/demos/" . $cmt["demofile"] . "'>" .
-          $cmt["demofile"] . "</a><br/>\n" .
+          $cmt["demofile"] . "</a>$del_link<br/>\n" .
           "</p>\n";

         if (strtolower($cmt["levelmd5"]) == strtolower($curlevelmd5))
@@ -585,6 +752,17 @@
     $levelmd5 = $curlevelmd5;
     if ( isset( $_GET["levelmd5"] ))
       $levelmd5 = $_GET["levelmd5"];
+
+    if ($is_user)
+    {
+ $input_name = '<input type="text" name="author" value="' . $user_data["name"] . '">'; + $input_mail = '<input type="text" name="email" value="' . $user_data["email"] . '">';
+    }
+    else
+    {
+      $input_name = '<input type="text" name="author">';
+      $input_mail = '<input type="text" name="email">';
+    }
 ?>
     <hr/>
     <table width="100%">
@@ -599,11 +777,11 @@
             <table>
               <tr>
                 <td>Your name</td>
-                <td><input type="text" name="author"></td>
+                <td><? echo ($input_name); ?></td>
               </tr>
               <tr>
                 <td>Your email</td>
-                <td><input type="text" name="email"></td>
+                <td><? echo ($input_mail); ?></td>
               </tr>
               <tr>
                 <td>Difficulty</td>
@@ -641,6 +819,9 @@
           </form>
         </td>
         <td width="50%" valign="top">
+       <? if ($is_user || $is_admin)
+          {
+       ?>
           <p><em><strong>Upload a demofile:</strong></em></p>
<form enctype="multipart/form-data" name="UploadDemo" action="<? echo $PHP_SELF . "?c=" . urlencode($c) . "&l=" . urlencode($l); ?>" method="POST">
             <input type="hidden" name="adddemo" value="1">
@@ -650,11 +831,15 @@
             <table>
               <tr>
                 <td>Your name</td>
-                <td><input type="text" name="username"></td>
+                <td><input type="text" name="username"<? if ($is_user)
+ echo ' value="'.$user_data["name"].'"'?>>
+                </td>
               </tr>
               <tr>
                 <td>Your email</td>
-                <td><input type="text" name="email"></td>
+                <td><input type="text" name="email"<? if ($is_user)
+ echo ' value="'.$user_data["email"].'"' ?>>
+                </td>
               </tr>
               <tr>
                 <td>Demofile</td>
@@ -669,14 +854,19 @@
               </tr>
             </table>
           </form>
+       <? }
+       ?>
         </td>
       </tr>
     </table>

 <?
print "<p><a href='$PHP_SELF?c=" . urlencode($c) . "'>Back to level list</a></p>";
-    if ( !$is_admin )
- print "<div align='right'><a href='$PHP_SELF?adminlogin=1'><small>admin login</small></a></div>";
+    if ( !$is_admin && !$is_user)
+    {
+      $params = get_params();
+ print "<div align='right'><a href='$PHP_SELF?$params"."adminlogin=1'><small>admin login</small></a></div>";
+    }
   }
 }

=======================================
--- /level-cache.inc    Sat Apr 17 05:18:09 2004
+++ /level-cache.inc    Wed Apr 28 13:10:28 2004
@@ -25,30 +25,13 @@

 require_once("xml-search.inc");

-// set some globals for various DBMS
-global $DBMS;
-global $db_handle;
-global $db_tablename;
-global $db_name;
-global $db_host;
-global $db_user;
-global $db_pass;
-
-$DBMS = 'MySQL';
-$db_handle = False;
-$db_tablename = 'lct_cache';
-$db_name = 'pingus';
-$db_host = 'localhost';
-$db_user = 'pingus';
-$db_pass = 'pingus';
-
-function create_table( $tablename )
-{
-  global $db_name;
-  global $db_handle;
-
+// ==================================================================
+// Creates a table if necessary and returns the tablename
+// ==================================================================
+function create_table( $conn, $db, $tablename, $SQL )
+{
   $table_exists = False;
-  $res = mysql_list_tables( $db_name );
+  $res = mysql_list_tables( $db );

   for ($i=0;$i<mysql_num_rows( $res );$i++)
     if (mysql_tablename( $res, $i ) == $tablename)
@@ -56,16 +39,16 @@

   if (!$table_exists)
   {
- $SQL = "CREATE TABLE `$tablename` (`Key` VARCHAR( 255 ) NOT NULL ,`Value` TEXT NOT NULL , PRIMARY KEY ( `Key` ) );";
-    $res = mysql_query( $SQL, $db_handle );
-       if (!$res)
-         return False;
-       else
-         return $tablename;
+    $res = mysql_query( $SQL, $conn );
+    if (!$res)
+      return False;
+    else
+      return $tablename;
   }
   else
     return $tablename;
 }
+

 function open_cache()
 {
@@ -100,20 +83,21 @@

       //MySQL is used as cache
       case "MySQL":
-               $db_handle = mysql_connect( $db_host, $db_user, $db_pass );
-               if (!$db_handle)
-               {
+       $db_handle = mysql_connect( $db_host, $db_user, $db_pass );
+       if (!$db_handle)
+       {
echo "<p><font color=\"red\"><b>ERROR: Cannot open connection to database server ($db_host)!</b></font></p>";
           exit;
         }

         if (! mysql_select_db( $db_name, $db_handle ))
-               {
+       {
echo "<p><font color=\"red\"><b>ERROR: Cannot select database '$db_name'!</b></font></p>";
           exit;
         }
-
- $db_tablename = create_table($db_tablename);//creates the table if necessary and returns the tablename
+       $SQL = "CREATE TABLE `$tablename` (`Key` VARCHAR( 255 ) NOT NULL".
+              " ,`Value` TEXT NOT NULL , PRIMARY KEY ( `Key` ) );";
+ $db_tablename = create_table($db_handle, $db_name, $db_tablename, $SQL);//creates the table if necessary and returns the tablename

         if (!$db_tablename)
         {
@@ -352,7 +336,7 @@
       "author" => "pingus-level-comment/author",
       "email" => "pingus-level-comment/email",
       "date" => "pingus-level-comment/date",
-         "time" => "pingus-level-comment/time",
+      "time" => "pingus-level-comment/time",
       "difficulty" => "pingus-level-comment/difficulty",
       "rating" => "pingus-level-comment/rating",
       "comment" => "pingus-level-comment/comment",
@@ -366,8 +350,8 @@
     $cmt["filename"] = $filename;

     // is the time set? (it is not in old comment files)
-       if (isset($cmt["time"]))
-         $res[$cmt["date"] . '-' . $cmt["time"]] = $cmt;
+    if (isset($cmt["time"]))
+      $res[$cmt["date"] . '-' . $cmt["time"]] = $cmt;
     else
$res[$cmt["date"] . '-' . substr(md5(implode("", file($filename))),0,8)] = $cmt;
   }
@@ -401,8 +385,8 @@
       "username" => "pingus-demo-metafile/username",
       "email" => "pingus-demo-metafile/email",
       "date" => "pingus-demo-metafile/date",
-         "time" => "pingus-demo-metafile/time",
-         "demofile" => "pingus-demo-metafile/demofile",
+      "time" => "pingus-demo-metafile/time",
+      "demofile" => "pingus-demo-metafile/demofile",
       "levelmd5" => "pingus-demo-metafile/levelmd5"
     ));


==============================================================================
Revision: f4e6305c909a
Author:   Jason Green <address@hidden>
Date:     Mon Dec  5 09:00:26 2005
Log:      Set SVN end of line style on everything to native.
Got rid of colmap hack in preparation for my Clanlib patch.
Cleaned up a few unneeded #includes.

http://code.google.com/p/pingus/source/detail?r=f4e6305c909a&repo=level-comment-tool



==============================================================================
Revision: 8f72d1c616fe
Author:   Ingo Ruhnke <address@hidden>
Date:     Sat Feb 11 06:32:52 2006
Log:      Started Pingus-SDL branch


http://code.google.com/p/pingus/source/detail?r=8f72d1c616fe&repo=level-comment-tool



==============================================================================
Revision: 6446569af542
Author:   Ingo Ruhnke <address@hidden>
Date:     Thu Aug 23 11:42:59 2007
Log:      - moved level_comment_tool/ and windows_installer/ to trunk

http://code.google.com/p/pingus/source/detail?r=6446569af542&repo=level-comment-tool



reply via email to

[Prev in Thread] Current Thread [Next in Thread]