--- /dev/null
+<?php
+ if ($db = new PDO('sqlite:var/banane.db')) {
+ $db->query('CREATE TABLE IF NOT EXISTS students
+ (mnumber int, firstname string, lastname string, email string, password string, PRIMARY KEY (mnumber))');
+ $db->query('CREATE TABLE IF NOT EXISTS workdone
+ (mnumber int, session int, manydone int, thisdone string)');
+ }
+?>
--- /dev/null
+<?php
+
+ $lec_lines = file('var/lecture.txt');
+
+ foreach ($lec_lines as $line_num => $line) {
+ $lecture[$line_num] = $line;
+ }
+
+ print "<table>";
+ print "<tr><th align=\"left\">Banana Exercise Management</th><tr>";
+ print "<tr><th bgcolor=blue><font color=white> $lecture[0] $lecture[1], Group: $lecture[2] </font></th></tr>";
+ print "</table>";
+
+ print "<br>";
+?>
\ No newline at end of file
--- /dev/null
+<?php
+ include 'nav.inc';
+ include 'lecture.inc';
+
+ if(isset($_POST['submit']) && $_POST['mnumber']!="") {
+ require 'createdb.inc';
+ require 'session.inc';
+
+ $mnumber = trim($_POST['mnumber']);
+ $password = trim($_POST['password']);
+
+ $sessionid = strtotime(end($sessions)[0]);
+
+ if (! ( $mnumber == 007 AND $password == 007 )) {
+ require 'usercheck.inc';
+ $result = $db->query("SELECT thisdone FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0];
+ if ($result == "") {
+ print "<table bgcolor=\"red\">";
+ print "<tr><th><b><font color=\"white\">no submit</font></b></th><tr>";
+ print "</table>";
+ print "No results were submitted for " . end($sessions)[0] . ".";
+ break;
+ }
+ else {
+ print $result;
+ }
+ }
+ else {
+ $result = $db->query("SELECT students.firstname, students.lastname, students.mnumber, workdone.manydone, workdone.thisdone FROM workdone, students WHERE workdone.session = $sessionid AND workdone.mnumber = students.mnumber");
+ //print $result[0];
+
+ print "<table>";
+
+ while ($row = $result->fetch(PDO::FETCH_NUM)) {
+ print "<tr>";
+ echo "<td>$row[0] $row[1] </td> <td>$row[2] </td> <td>$row[4] </td> <td>$row[3]/$lstsession_nex </td>";
+ print "</tr>";
+ }
+
+ print "</table>";
+ }
+
+ break;
+ }
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+ <table bgcolor="black">
+ <tr><th><b><font color="white">Last submission</font></b></th><tr>
+ </table>
+
+ <table>
+ <tr>
+ <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
+ </tr>
+ <tr>
+ <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
+ </tr>
+ <tr><th colspan=2></th></tr>
+
+ <tr>
+ <th align="left"><input type="submit" name="submit" value="Show"></th> <th></th>
+ </tr>
+ </table>
+</form>
--- /dev/null
+<?php
+ $lec_lines = file('var/lecture.txt');
+ foreach ($lec_lines as $line_num => $line) {
+ $lecture[$line_num] = $line;
+ }
+?>
--- /dev/null
+<?php
+ require "head.inc";
+?>
+
+<style type="text/css">
+ a:link { text-decoration:none; font-weight:normal; color:blue; }
+ a:visited { text-decoration:none; font-weight:normal; color:blue; }
+ a:hover { text-decoration:none; font-weight:normal; background-color:yellow; }
+ a:active { text-decoration:none; font-weight:normal; color:blue; }
+ a:focus { text-decoration:none; font-weight:normal; color:blue; }
+</style>
+
+
+<a href="submit.php">submit</a>
+ |
+<a href="register.php">register</a>
+ |
+<a href="lastsubmit.php">last submit</a>
+
+<br><br>
--- /dev/null
+<?php
+require 'nav.inc';
+
+if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!=""
+ && $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
+{
+ $firstname = $_POST['firstname'];
+ $lastname = $_POST['lastname'];
+ $mnumber = $_POST['mnumber'];
+ $email = $_POST['email'];
+ $password = $_POST['password'];
+
+ require 'createdb.inc';
+
+ // user already exists //
+ if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 1) {
+ print "<table bgcolor=\"red\">";
+ print "<tr><th><b><font color=\"white\">user already registered</font></b></th><tr>";
+ print "</table>";
+ break;
+ }
+
+ $db->query("INSERT INTO students (mnumber,firstname,lastname,email,password)
+ VALUES (\"$mnumber\",\"$firstname\",\"$lastname\",\"$email\",\"$password\")");
+
+ print "<table bgcolor=\"lightgreen\">";
+ print "<tr><th><b><font color=\"white\">registration successfull</font></b></th><tr>";
+ print "</table>";
+
+ echo "$firstname $lastname was successfully registered.<br>";
+
+ // send password-email //
+ $lec_lines = file('var/lecture.txt');
+ foreach ($lec_lines as $line_num => $line) {
+ $lecture[$line_num] = $line;
+ }
+ $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . trim($lecture[0]) . " " . trim($lecture[1]) . ".\nRemember your password: $password\n\nYours,\nBanana.";
+ //$nachricht = wordwrap($nachricht,70);
+ $empfaenger = 'niemand@example.com';
+ $betreff = 'Der Betreff';
+ $header = 'From: banana@treefish.org' . "\r\n" .
+ 'Reply-To: noreply@treefish.org' . "\r\n" .
+ 'X-Mailer: PHP/' . phpversion();
+ mail($email, "Banana Registration: " . trim($lecture[0]) . " " . trim($lecture[1]), $nachricht, $header);
+
+ break;
+}
+?>
+
+<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+ <table bgcolor="black">
+ <tr><th><b><font color="white">registration</font></b></th><tr>
+ </table>
+
+ <table>
+ <tr>
+ <th align="left">First name:</th> <th><input type="text" name="firstname"></th>
+ </tr>
+ <tr>
+ <th align="left">Last name:</th> <th><input type="text" name="lastname"></th>
+ </tr>
+ <tr>
+ <th align="left">Mat.nummer:</th> <th><input type="text" name="mnumber"></th>
+ </tr>
+ <tr>
+ <th align="left">Email:</th> <th><input type="text" name="email"></th>
+ </tr>
+ <tr>
+ <th align="left">Password:</th> <th><input type="text" name="password"></th>
+ </tr>
+
+ <tr>
+ <th></th> <th align="right"><input type="submit" name="submit" value="Register"></th>
+ </tr>
+ </table>
+</form>
--- /dev/null
+<?php
+ $lines_sessions = file('var/sessions.txt');
+
+ foreach ($lines_sessions as $line_num => $line) {
+ $sessions[$line_num] = explode("\t",$line);
+ }
+
+ $lstsession_nex = count(explode(',',end($sessions)[1]));
+?>
--- /dev/null
+<?php
+ require 'nav.inc';
+
+ $lines = file('var/sessions.txt');
+
+ foreach ($lines as $line_num => $line) {
+ $sessions[$line_num] = explode("\t",$line);
+ }
+
+ if ( strtotime("now") > strtotime(end($sessions)[0]) ) {
+ print '<table bgcolor="red">';
+ print '<tr><th><b><font color="white">submission closed</font></b></th><tr>';
+ print '</table>';
+ break;
+ }
+
+ if(isset($_POST['submit']) && $_POST['mnumber']!="") {
+ require 'usercheck.inc';
+
+ $exchecked = $_POST['exchecked'];
+
+ $mnumber = $_POST['mnumber'];
+ $sessionid = strtotime(end($sessions)[0]);
+
+ if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0] == 1) {
+ print '<table bgcolor="red">';
+ print '<tr><th><b><font color="white">You already submitted results for this session</font></b></th><tr>';
+ print '</table>';
+ print "You can only submit your calculated examples once!";
+ break;
+ }
+
+ $excount = count($exchecked);
+ $donestring = implode(', ', $exchecked);
+
+ $db->query("INSERT INTO workdone (mnumber,session,manydone,thisdone)
+ VALUES (\"$mnumber\", \"$sessionid\", \"$excount\", \"$donestring\")");
+
+ print '<table bgcolor="lightgreen">';
+ print '<tr><th><b><font color="white">submitted</font></b></th><tr>';
+ print '</table>';
+ break;
+ }
+?>
+
+ <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
+ <table bgcolor="black">
+ <tr><th><b><font color="white">submit examples for <?php echo end($sessions)[0]; ?></font></b></th><tr>
+ </table>
+
+ <table>
+ <tr>
+ <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
+ </tr>
+ <tr>
+ <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
+ </tr>
+
+ <tr><th colspan=2></th></tr>
+
+ <tr>
+ <th align="left">Examples:</th>
+ <th>
+
+ <?php
+ $exnum=0;
+ foreach (explode(",",end($sessions)[1]) as $exid) {
+ print " <input type='checkbox' name='exchecked[]' value=$exid>$exid ";
+ $exnum++;
+ if ($exnum%3 == 0) { print ""; }
+ }
+ ?>
+ </th>
+ </tr>
+
+ <tr><th colspan=2></th></tr>
+
+ <tr>
+ <th align="left"><input type="submit" name="submit" value="Submit"></th> <th></th>
+ </tr>
+ </table>
+</form>
--- /dev/null
+<?php
+ require 'createdb.inc';
+
+ $mnumber = $_POST['mnumber'];
+ $password = $_POST['password'];
+
+ if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) {
+ print '<table bgcolor="red">';
+ print '<tr><th><b><font color="white">Mat.nummer not found</font></b></th><tr>';
+ print '</table>';
+ print "Mat.Nummer was not found. You have to register first!";
+ break;
+ }
+
+ if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber AND password = \"$password\"")->fetch(PDO::FETCH_NUM)[0] == 0) {
+ print '<table bgcolor="red">';
+ print '<tr><th><b><font color="white">wrong password</font></b></th><tr>';
+ print '</table>';
+ break;
+ }
+
+?>
\ No newline at end of file
--- /dev/null
+Theoretische Mechanik
+WS2012
+Alex
--- /dev/null
+27.09.2012 10:30 1a,1b,1c,2a,2b,3