Implementation of a database for mathematical problems, developed for Wurzel e.V.
The idea was to provide a database for 40 years of collected problems, to make them available to the public, searchable, and trackable for intern purposes. Since the mid-1960s, authors can submit problems to the Wurzel, which publishes six of them every month. Readers can propose solutions, which are published later as well.
The idea of a problem base was born out of the following thoughts:
grep
the TeX archive when looking for a problem. Is there a better
way? Sure.That's where the problem base enters the game. Simply a SQLite database, easily accessible through a PHP frontend. A web frontend seemed plausible, as the database can be accessed from different locations, and - originally - to be OS independent. We feature:
The problem base runs on Apache+PHP or nginx+PHP-FPM, supported by a SQLite or PostgreSQL data base. Get a clone by
git clone --recursive git://github.com/wurzeljena/problembase.git
You can either clone into the document root or a subdirectory. In this case,
add an environment variable PBROOT=/path/to/problembase
. Also, add
ErrorDocument 403 /path/to/problembase/error403.php
ErrorDocument 404 /path/to/problembase/error404.php
to your httpd.conf
or similar lines for nginx. If you use Apache, you might
also want to "compile" the .htaccess
files into your httpd.conf
. (e.g, by
using htaccessConverter)
This speeds up your server a bit. Don't forget to adapt the RewriteRule
s to
your needs.
The nginx server should be configured to handle PHP scripts via PHP-FPM. Apart
from that, a pretty basic configuration should work, don't forget to include
conf/nginx_app.conf
in the server directive, between server
, root
etc.
and the code passing PHP files to the FPM server.
Since we are likely dealing with a small number of users, a SQLite database is sufficient. It also makes backups easy. Create the database as follows:
cd sql
sqlite3 -init sqlite.sql problembase.sqlite
In the opening prompt, create a root user:
INSERT INTO users (name, email, root, editor) VALUES ("Your name", "your@email.com", 1, 1);
And we're done: open http://localhost/path/to/problembase
(which might just
be http://localhost/
) and enjoy! Don't forget to set a password for your
first user.
If you expect more users or want to use a separate database server for some
other reason, PostgreSQL is also supported.
Create the tables etc. by executing sql/postgres.sql
. Create an initial user
as above.
To set up the connection, simply set environment variable DATABASE_URL
to
postgres://username:password@host:port/dbname
Although the UI should be straightforward and intuitive, some remarks:
root
user can add users and grant (or revoke) rights.Yeah, whatever. I could as well explain it, maybe later.
Though no terrible things should happen, it is recommended to use a recent browser. I do not test again IE 6 or the like. Since HTML5 provides graceful fallback, the pages should not be interpreted erronously in older browsers, but they might not display as beautiful.
As of now, full HTML5 compliance is not guaranteed. It's definitely on the list, though.
Some effort has been made to ensure that unauthenticated users can't do any harm to the database. However, as authenticated user, you can do a lot. So please backup every once in a while, dear admin. You won't regret. However, thorough security checks still have to be done. Feel free to analyse the code, I'll be happy about critical feedback.
Passwords are stored as salted SHA-512 hash. To prevent password guessing, one has to wait for 10 seconds after a failed attempt.
Take a look at the GitHub issues page. If you think you can solve one, do it. Then send a pull request. If you experience some other issues, please add them or email me. The list is by far not comprehensive, sometimes I don't write problems down when I think they can be solved quickly.