aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-04-14 08:35:13 +0200
committerroot2014-04-14 08:35:13 +0200
commit12734da8826299ffd24c0a15f6dbf205892d7221 (patch)
tree3b894dd30e332df23a564ce44e42ce164c8abd78
parent7b9d516cd3bcdb8eaa5f1eb533d71010061c681b (diff)
downloadjungegemeinde-12734da8826299ffd24c0a15f6dbf205892d7221.tar.gz
Pushed to v3
-rw-r--r--.gitignore9
-rwxr-xr-xblob/nginx_rewrite_rules70
-rw-r--r--oldwww/LICENSE (renamed from www/LICENSE)0
-rw-r--r--oldwww/account.php58
-rw-r--r--oldwww/auth.php8
-rw-r--r--oldwww/check.php (renamed from www/check.php)0
-rw-r--r--oldwww/config/401.css (renamed from config/401.css)0
-rw-r--r--oldwww/config/404.css (renamed from config/404.css)0
-rwxr-xr-xoldwww/config/dead_link.png (renamed from config/dead_link.png)bin51119 -> 51119 bytes
-rw-r--r--oldwww/config/error-handler-404.html (renamed from config/error-handler-404.html)0
-rwxr-xr-xoldwww/config/favicon.ico (renamed from config/favicon.ico)bin5242 -> 5242 bytes
-rw-r--r--oldwww/config/fonts/2Q-AW1e_taO6pHwMXcXW5w.ttf (renamed from config/fonts/2Q-AW1e_taO6pHwMXcXW5w.ttf)bin72404 -> 72404 bytes
-rw-r--r--oldwww/config/fonts/BfQP1MR3mJNaumtWa4Tizg.ttf (renamed from config/fonts/BfQP1MR3mJNaumtWa4Tizg.ttf)bin56260 -> 56260 bytes
-rw-r--r--oldwww/config/fonts/Muli.css (renamed from config/fonts/Muli.css)0
-rw-r--r--oldwww/config/fonts/Ubuntu.css (renamed from config/fonts/Ubuntu.css)0
-rw-r--r--oldwww/config/fonts/muli.tff (renamed from config/fonts/muli.tff)bin56260 -> 56260 bytes
-rw-r--r--oldwww/config/fonts/ubuntu.ttf (renamed from config/fonts/ubuntu.ttf)bin72404 -> 72404 bytes
-rw-r--r--oldwww/config/index.html (renamed from config/index.html)0
-rw-r--r--oldwww/config/status-401.html (renamed from config/status-401.html)0
-rw-r--r--oldwww/config/test_401.css (renamed from config/test_401.css)0
-rwxr-xr-xoldwww/favicon.icobin0 -> 5242 bytes
-rw-r--r--oldwww/files.php (renamed from www/files.php)0
-rw-r--r--oldwww/header.php (renamed from www/header.php)0
-rw-r--r--oldwww/help.php11
-rw-r--r--oldwww/hyperstyle.css (renamed from www/hyperstyle.css)0
-rw-r--r--oldwww/index.php51
-rw-r--r--oldwww/inreg.php (renamed from www/inreg.php)0
-rw-r--r--oldwww/insert.php68
-rw-r--r--oldwww/liste.php145
-rw-r--r--oldwww/login.php70
-rw-r--r--oldwww/logout.php (renamed from www/logout.php)0
-rw-r--r--oldwww/lolrndm.php (renamed from www/lolrndm.php)0
-rw-r--r--oldwww/member_login.php (renamed from www/member_login.php)0
-rw-r--r--oldwww/piwik.php (renamed from www/piwik.php)0
-rw-r--r--oldwww/quote.php79
-rw-r--r--oldwww/redirect.php (renamed from www/redirect.php)0
-rw-r--r--oldwww/register.php54
-rw-r--r--oldwww/reset.php128
-rwxr-xr-xoldwww/robots.txt2
-rw-r--r--oldwww/setup.php14
-rw-r--r--oldwww/share.php (renamed from www/share.php)0
-rw-r--r--oldwww/to-do-list.php (renamed from www/to-do-list.php)0
-rw-r--r--oldwww/update.php53
-rw-r--r--www/account.php57
-rw-r--r--www/auth.php11
-rw-r--r--www/config/index.html2
-rw-r--r--www/constants.php39
-rwxr-xr-xwww/functions/func_failure.php13
-rwxr-xr-xwww/functions/func_interface.php27
-rwxr-xr-xwww/functions/func_login.php87
-rw-r--r--www/functions/func_password.php77
-rwxr-xr-xwww/functions/func_register.php61
-rwxr-xr-xwww/functions/func_user.php337
-rwxr-xr-xwww/functions/notused/func_content.php121
-rw-r--r--www/functions/notused/func_delete.php207
-rw-r--r--www/functions/notused/func_download.php123
-rw-r--r--www/functions/notused/func_folder.php162
-rwxr-xr-xwww/functions/notused/func_invite.php62
-rwxr-xr-xwww/functions/notused/func_rewrite.php30
-rwxr-xr-xwww/functions/notused/func_select.php62
-rwxr-xr-xwww/functions/notused/func_upload.php192
-rw-r--r--www/help.php6
-rwxr-xr-xwww/include.php42
-rwxr-xr-x[-rw-r--r--]www/index.php212
-rw-r--r--www/insert.php72
-rw-r--r--www/liste.php45
-rw-r--r--www/login.php32
-rw-r--r--www/print_index.php48
-rw-r--r--www/quote.php68
-rw-r--r--www/register.php23
-rw-r--r--www/reset.php142
-rw-r--r--www/services.php162
-rwxr-xr-x[-rw-r--r--]www/setup.php88
-rw-r--r--www/static/head.php52
-rw-r--r--www/static/header.php62
-rw-r--r--www/static/hyperstyle.css214
-rw-r--r--www/to-do-list.html25
-rw-r--r--www/update.php75
78 files changed, 3469 insertions, 389 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..51b4de0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+files/
+database/
+temp/
+tmp/
+
+ineigenersache.php
+*swp
+piwik.php
+
diff --git a/blob/nginx_rewrite_rules b/blob/nginx_rewrite_rules
new file mode 100755
index 0000000..571c3fe
--- /dev/null
+++ b/blob/nginx_rewrite_rules
@@ -0,0 +1,70 @@
+error_page 401 /httperror.php?e=401;
+error_page 403 /httperror.php?e=403;
+error_page 404 /httperror.php?e=404;
+
+error_page 500 /httperror.php?e=500;
+error_page 502 /httperror.php?e=502;
+error_page 504 /httperror.php?e=504;
+
+location /robots.txt {} #stop rewriting the robots.txt
+
+location /favicon.ico {}
+location /static {}
+
+location ~* ^/liste {
+ rewrite ^/liste/?$ /index.php?task=liste;
+ rewrite ^/liste/([0-9]+)/?$ /index.php?task=liste&id=$1;
+}
+
+rewrite ^/quote/?$ /index.php?task=quote;
+rewrite ^/quote/([0-9]+)/?$ /index.php?task=quote&id=$1;
+rewrite ^/new_member/? /index.php?task=new_member;
+rewrite ^/update/? /index.php?task=update;
+rewrite ^/Startseite/? /index.php;
+rewrite ^/startseite/? /index.php;
+rewrite ^/help/? /help.php;
+rewrite ^/hilfe/? /help.php;
+rewrite ^/services?/? /index.php?task=services;
+
+location ~* ^/account {
+ rewrite ^/account/?$ /index.php?task=account;
+ rewrite ^/account/change:(user)/?$ /index.php?task=account&change=$1;
+ rewrite ^/account/change:(password)/?$ /index.php?task=account&change=$1;
+}
+
+location ~* ^/?login/?([a-z0-9]+=[a-z0-9]+(&[a-z0-9]+=[a-z0-9]+)?)?$ {
+ rewrite ^/?login([?/]?.*) /index.php?task=login&arguments=$1 last;
+}
+
+location ~* ^/?logout/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {
+ rewrite ^/?logout([?/]?.*) /index.php?task=logout&arguments=$1 last;
+}
+
+
+location ~* ^/?register/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {
+ rewrite ^/?register(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=register&arguments=$1 last;
+}
+
+#location ~* ^/?invite/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {
+# rewrite ^/?invite(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=invite&arguments=$1 last;
+#}
+
+location ~* ^/?user/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {
+ rewrite ^/?user(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=user&arguments=$1 last;
+}
+
+#location ~* ^/?download/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {
+# rewrite ^/?download(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=download&arguments=$1 last;
+#}
+
+location ~* ^/password_recover/?(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {
+ rewrite ^/?password_recover(\?[0-9a-zA-Z]*(=[0-9a-zA-Z]*)?)? /index.php?task=password_recover&arguments=$1 last;
+}
+#location ~* \.php(\?[0-9a-zA-Z]+(=[0-9a-zA-Z]*)?)?$ {} #empty block to catch all
+
+#location / {
+# rewrite ^/([0-9a-zA-Z-_]+)/(.*) /index.php?name=$1&folder=$2 last;
+# rewrite ^/([0-9a-zA-Z-_]+)$ /index.php?name=$1&folder= last;
+# rewrite ^/$ /index.php last;
+# break;
+#}
diff --git a/www/LICENSE b/oldwww/LICENSE
index 4ba7077..4ba7077 100644
--- a/www/LICENSE
+++ b/oldwww/LICENSE
diff --git a/oldwww/account.php b/oldwww/account.php
new file mode 100644
index 0000000..2db7e85
--- /dev/null
+++ b/oldwww/account.php
@@ -0,0 +1,58 @@
+<?php include('auth.php');
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include("header.php");
+
+if ($_SESSION["username"] != "jg-adlershof"){
+
+ $username = $_SESSION["username"];
+ $db_check = new SQLite3("../database/database.sqlite");
+
+ $safe_username = SQLite3::escapeString("$username");
+ $email_db = $db_check->query("SELECT email FROM user where name='$safe_username';");
+ while($email_array = $email_db->fetchArray(SQLITE3_NUM)){
+ foreach($email_array as $thirdelement){
+ $email=$thirdelement;
+ }
+ }
+
+ /*Anzahl der hochgeladenen Dateien.*/
+ $count_db = $db_check->query("SELECT count(*) as count FROM file where fk=(SELECT id from user where name='$safe_username');");
+ $count_array = $count_db->fetchArray();
+ $count = $count_array["count"];
+
+
+//echo "$username Test $email";
+echo "
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
+ </div>
+ </div>
+
+<br>
+<div class='mittlereschrift'>
+ Verwalte deine Account Informationen hier.
+</div>
+<br>
+
+
+<table><tr>
+<td><p>Name:&#160</td><td align='right'>$username</p></td></tr>
+<tr><td><p>E-Mail:</td><td align='right'>$email</p></td></tr>
+<tr><td align='left'><p>Stored files:</td> <td align='right'>$count</p></td></tr>
+</table>
+
+
+";
+
+
+} else {
+header("Location: member_login.php");
+exit;
+}
+
+?>
diff --git a/oldwww/auth.php b/oldwww/auth.php
new file mode 100644
index 0000000..a63e5ea
--- /dev/null
+++ b/oldwww/auth.php
@@ -0,0 +1,8 @@
+<?php
+ session_start();
+
+ if (!isset($_SESSION['login']) || !$_SESSION['login']) {
+ header('Location: login.php');
+ exit;
+ }
+?>
diff --git a/www/check.php b/oldwww/check.php
index 3e575a9..3e575a9 100644
--- a/www/check.php
+++ b/oldwww/check.php
diff --git a/config/401.css b/oldwww/config/401.css
index b017224..b017224 100644
--- a/config/401.css
+++ b/oldwww/config/401.css
diff --git a/config/404.css b/oldwww/config/404.css
index 08276dd..08276dd 100644
--- a/config/404.css
+++ b/oldwww/config/404.css
diff --git a/config/dead_link.png b/oldwww/config/dead_link.png
index 37eb36b..37eb36b 100755
--- a/config/dead_link.png
+++ b/oldwww/config/dead_link.png
Binary files differ
diff --git a/config/error-handler-404.html b/oldwww/config/error-handler-404.html
index 6264849..6264849 100644
--- a/config/error-handler-404.html
+++ b/oldwww/config/error-handler-404.html
diff --git a/config/favicon.ico b/oldwww/config/favicon.ico
index eff0501..eff0501 100755
--- a/config/favicon.ico
+++ b/oldwww/config/favicon.ico
Binary files differ
diff --git a/config/fonts/2Q-AW1e_taO6pHwMXcXW5w.ttf b/oldwww/config/fonts/2Q-AW1e_taO6pHwMXcXW5w.ttf
index 0e35cfb..0e35cfb 100644
--- a/config/fonts/2Q-AW1e_taO6pHwMXcXW5w.ttf
+++ b/oldwww/config/fonts/2Q-AW1e_taO6pHwMXcXW5w.ttf
Binary files differ
diff --git a/config/fonts/BfQP1MR3mJNaumtWa4Tizg.ttf b/oldwww/config/fonts/BfQP1MR3mJNaumtWa4Tizg.ttf
index cf324e4..cf324e4 100644
--- a/config/fonts/BfQP1MR3mJNaumtWa4Tizg.ttf
+++ b/oldwww/config/fonts/BfQP1MR3mJNaumtWa4Tizg.ttf
Binary files differ
diff --git a/config/fonts/Muli.css b/oldwww/config/fonts/Muli.css
index 4fa7a93..4fa7a93 100644
--- a/config/fonts/Muli.css
+++ b/oldwww/config/fonts/Muli.css
diff --git a/config/fonts/Ubuntu.css b/oldwww/config/fonts/Ubuntu.css
index 6ab025f..6ab025f 100644
--- a/config/fonts/Ubuntu.css
+++ b/oldwww/config/fonts/Ubuntu.css
diff --git a/config/fonts/muli.tff b/oldwww/config/fonts/muli.tff
index cf324e4..cf324e4 100644
--- a/config/fonts/muli.tff
+++ b/oldwww/config/fonts/muli.tff
Binary files differ
diff --git a/config/fonts/ubuntu.ttf b/oldwww/config/fonts/ubuntu.ttf
index 0e35cfb..0e35cfb 100644
--- a/config/fonts/ubuntu.ttf
+++ b/oldwww/config/fonts/ubuntu.ttf
Binary files differ
diff --git a/config/index.html b/oldwww/config/index.html
index 267f175..267f175 100644
--- a/config/index.html
+++ b/oldwww/config/index.html
diff --git a/config/status-401.html b/oldwww/config/status-401.html
index e980ac9..e980ac9 100644
--- a/config/status-401.html
+++ b/oldwww/config/status-401.html
diff --git a/config/test_401.css b/oldwww/config/test_401.css
index 80ad4d0..80ad4d0 100644
--- a/config/test_401.css
+++ b/oldwww/config/test_401.css
diff --git a/oldwww/favicon.ico b/oldwww/favicon.ico
new file mode 100755
index 0000000..41f6475
--- /dev/null
+++ b/oldwww/favicon.ico
Binary files differ
diff --git a/www/files.php b/oldwww/files.php
index 1c38d68..1c38d68 100644
--- a/www/files.php
+++ b/oldwww/files.php
diff --git a/www/header.php b/oldwww/header.php
index e4a0ba6..e4a0ba6 100644
--- a/www/header.php
+++ b/oldwww/header.php
diff --git a/oldwww/help.php b/oldwww/help.php
new file mode 100644
index 0000000..8a3aa22
--- /dev/null
+++ b/oldwww/help.php
@@ -0,0 +1,11 @@
+<?php include('auth.php');
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include("header.php");
+
+echo "<br><br><h1>Noch nicht implementiert.</h1>";
+
+header("Refresh: 3; index.php");
+?>
diff --git a/www/hyperstyle.css b/oldwww/hyperstyle.css
index 74176fc..74176fc 100644
--- a/www/hyperstyle.css
+++ b/oldwww/hyperstyle.css
diff --git a/oldwww/index.php b/oldwww/index.php
new file mode 100644
index 0000000..88a7fa6
--- /dev/null
+++ b/oldwww/index.php
@@ -0,0 +1,51 @@
+<?php include('auth.php');
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include("header.php");
+?>
+
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
+ </div>
+ </div>
+<?php
+if($_SESSION["username"] == "jg-adlershof"){
+$name = "Gast";
+} else {
+$name = $_SESSION["username"];
+}
+ echo "
+<br>
+<div class='kleineschrift'>
+<div style='width:800px;' class='katze' id='behaelter' align='center'>
+ Hallo $name.<br> Willkommen auf der Webpage für die Junge Gemeinde in Adlershof. Für einen persönlichen Zugang, und um alle Features zu nutzen, registriere dich doch <a
+style='text-decoration:underline;color:blue;' href='register.php'>hier</a>. Wenn du Probleme bei der Navigation hast, dann schau unter <a style='text-decoration: underline;color:blue;'
+href='help.php'>Hilfe</a> nach. <br>
+ Für Anregungen und Kritik bin ich immer zu haben. Schick mir einfach ne Mail oder sags mir nächsten Donnerstag. ;)
+ <br><bR>
+ PS: Du kannst dich nach einer Registrierung auch mit deinem Username einloggen.
+</div>
+</div>
+";
+?>
+
+<br><br>
+<div class='katze' align='center'><pre>
+ ,/| _.--''^``-...___.._.,;
+ /, \'. _-' ,--,,,--'''
+ { \ `_-'' ' /}
+ `;;' ; ; ;
+ ._.--'' ._,,, _..' .;.'
+ (,_....----''' (,..--''
+</pre></div>
+
+
+</div>
+</div>
+</body>
+</html>
+
diff --git a/www/inreg.php b/oldwww/inreg.php
index 341ba06..341ba06 100644
--- a/www/inreg.php
+++ b/oldwww/inreg.php
diff --git a/oldwww/insert.php b/oldwww/insert.php
new file mode 100644
index 0000000..17002e3
--- /dev/null
+++ b/oldwww/insert.php
@@ -0,0 +1,68 @@
+<?php include('auth.php');
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include("header.php");
+
+if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ $db = new SQLite3('../database/database.sqlite');
+
+ $safe1 = SQLite3::escapeString("$_POST[name]");
+ $safe2 = SQLite3::escapeString("$_POST[adresse]");
+ $safe3 = SQLite3::escapeString("$_POST[telefonnummer]");
+ $safe4 = SQLite3::escapeString("$_POST[handynummer]");
+ $safe5 = SQLite3::escapeString("$_POST[email]");
+ $safe6 = SQLite3::escapeString("$_POST[geburtstag]");
+ $query = "INSERT INTO member(id, name, adresse, telefonnummer, handynummer, email, geburtstag) VALUES(NULL,'$safe1','$safe2','$safe3','$safe4','$safe5','$safe6');";
+ $result = $db->exec("$query");
+}
+
+echo "
+
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
+ </div>
+ </div>
+";
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+echo "
+<center>
+<br>
+Vielen Dank, der Eintrag zu $_POST[name] wurde erfolgreich hinzugefügt.<br>
+<br>
+
+<tr>
+ <td align='center'><img src='http://i.imgur.com/UQDEVQy.png' alt='Teh wizzard'></td>
+</tr>
+<br>
+<br>
+Einen Moment, sie werden gleich weitergeleitet.
+
+";
+header("Refresh: 4; /liste.php");
+
+ } else {
+ echo "
+ <br><a2>Trage einfach die Daten von unserem neuen Mitglied ein: </a2><br>
+ <form method='post' action='insert.php' ><table><tr>
+ <td align='right'><a2>Name: <input type='text' name='name' ></a2> </td>
+ <td align='right'><a2>Adresse: <input type='text' name='adresse' > </a2></td>
+ <td align='right'><a2>Telefon: <input type='text' name='telefonnummer'></a2> </td></tr>
+ <tr align='right'><td><a2>Handy: <input type='text' name='handynummer' ></a2> </td>
+ <td align='right'><a2>E-Mail: <input type='text' name='email' ></a2> </td>
+ <td align='right'><a2>Geburtstag: <input type='text' name='geburtstag' ></a2> </td></tr>
+ <tr><td>&#160;</td><td align='center'><input type='submit' name='submit' value='Hinzufügen'/></td><td>&#160;</td></tr>
+ </table></form>
+ ";
+
+}
+/*
+</body>";
+*/
+
+//echo '<br><a href="login.php?x=$cryptedip">Zur&uuml;ck</a></center>';
+
+?>
diff --git a/oldwww/liste.php b/oldwww/liste.php
new file mode 100644
index 0000000..94deb1a
--- /dev/null
+++ b/oldwww/liste.php
@@ -0,0 +1,145 @@
+<?php include('auth.php');
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include("header.php");
+
+$db = new SQLite3("../database/database.sqlite");
+
+?>
+
+<script>
+// Elemente einblenden
+function show_elements()
+ {
+ var elementNames = show_elements.arguments;
+ for (var i=0; i<elementNames.length; i++)
+ {
+ var elementName = elementNames[i];
+ document.getElementById(elementName).style.display='block';
+ }
+ }
+// Elemente ausblenden
+function hide_elements()
+ {
+ var elementNames = hide_elements.arguments;
+ for (var i=0; i<elementNames.length; i++)
+ {
+ var elementName = elementNames[i];
+ document.getElementById(elementName).style.display='none';
+ }
+ }
+</script>
+
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
+ </div>
+ </div>
+
+<?php if($_GET["id"] == 0 || $_GET["id"] == "" || !isset($_GET["id"])){
+
+echo"
+<br><br>
+ <table height='350' border='1' rules='all' cellpadding='20' cellbording='20' cellspacing='20'>
+ <!-- Wenn mir mal einer erklären könnte, warum die Zellen trotzdem keinen Abstand haben? -->
+ <thead>
+ <tr>
+ <th><a3>&#160;</a3></th>
+ <th><a3>Name</a3></th>
+ <th><a3>Adresse</a3></th>
+ <th><a3>Telefon</a3></th>
+ <th><a3>Handynummer</a3></th>
+ <th><a3>E-Mail</a3></th>
+ <th><a3>Geburtstag</a3></th>
+ <tr>
+ </thead>
+ <tbody cellpadding='20' cellbording='20' cellspacing='20'>
+
+";
+ $ergebnis = $db->query("SELECT * FROM member");
+ while($row=$ergebnis->fetchArray(SQLITE3_NUM)){
+ $id=$row[0];
+ echo "<tr>";
+ foreach($row as $element){
+ echo "<td align='left'><a href=\"?id=$id\" onclick=\"document.location.href='liste.php?id=$id'\">$element</a></td>";
+ }
+
+ echo "
+ </tr>";
+ }
+
+echo "
+ </tbody>
+ </table>
+
+<br><br>
+<div style='width:1000px;' class='mittlereschrift'>
+Da es in letzter Zeit doch öfters vorgekommen ist, dass jemand seine Adresse geändert hat, ist es jetzt möglich, einen Eintrag in der Adressliste zu ändern oder zu ergänzen.
+Wenn du deine Adresse <b>ändern</b> möchtest, dann drücke einfach auf deinen Namen in der richtigen Zeile. <a href='insert.php'>Möchtest du jemanden <b>hinzufügen</b>, dann drücke bitte <u>hier</u>.</a>
+</div>
+
+<br><br>
+";
+} else {
+
+
+ $id = $_GET["id"];
+ $safe_id = SQLite3::escapeString("$id");
+ $ergebnis = $db->query("SELECT * FROM member where id=$safe_id;");
+ while($row=$ergebnis->fetchArray()){
+ echo "<br><a2>Trage einfach die neuen Daten von $row[name] ein: </a2><br>
+ <form method='post' action='update.php' ><table><tr>";
+ echo "<td align='right'><a2>Name: <input type='text' name='name' value='$row[name]'></a2> </td>
+ <td align='right'><a2>Adresse: <input type='text' name='adresse' value='$row[adresse]'> </a2></td>
+ <td align='right'><a2>Telefon: <input type='text' name='telefonnummer' value='$row[telefonnummer]'></a2> </td></tr>
+ <tr align='right'><td><a2>Handy: <input type='text' name='handynummer' value='$row[handynummer]'></a2> </td>
+ <td align='right'><a2>E-Mail: <input type='text' name='email' value='$row[email]'></a2> </td>
+ <td align='right'><a2>Geburtstag: <input type='text' name='geburtstag' value='$row[geburtstag]'></a2> </td></tr>
+ <tr><td>&#160;<input type='hidden' name='id' value='$id'></td><td align='center'><input type='submit' name='submit' value='Update!'/></td><td>&#160;</td></tr>
+ </table></form>
+ ";
+ }
+}
+?>
+
+<!--AUSKOMMENTIERT#################################################################################
+<table width="400px" >
+<colgroup width="170" span="3"></colgroup>
+<tr align='center'>
+<td nowrap>
+<div id="show_update" class='unterstrich'>
+ <a style='color:blue;' href="#" title="Anzeigen" onclick="show_elements('update_db');">Eintrag aktualisieren?</a>
+
+
+</div>
+</td>
+<td>
+oder
+</td>
+<td nowrap>
+<div id="show_update" class='unterstrich'>
+ <a style='color:blue;' href="#" title="Anzeigen" onclick="show_elements('update_db');">Eintrag ergänzen?</a>
+</div>
+</td>
+</table>
+
+<div id="update_db" class="noscript">
+
+<br><br>
+ <form method='get' action='index.php' >
+ <table><tr>
+ <td><input type=</td>
+ <td><p>Nummer:</p></td><td><p><input type='text' name='id' size='1'/></p></td>
+ <td><p><input type='submit' name=submit value='weiter'/></p></td>
+ </table>
+ </form>
+
+
+</div>
+-->
+ </div>
+</body>
+</html>
diff --git a/oldwww/login.php b/oldwww/login.php
new file mode 100644
index 0000000..bfba63e
--- /dev/null
+++ b/oldwww/login.php
@@ -0,0 +1,70 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+if ($_GET["logout"] == 1) {
+ $logout = "<br><div style='color:red;'>Ausloggen erfolgreich</div>";
+}
+if ($_GET["failure"] == 1) {
+ $logout = "<br><div style='color:red;'>Name oder Passwort falsch!</div>";
+}
+
+
+?>
+<!doctype html public '-//W3C//DTD XHTML 1.0 //EN'>
+
+<html>
+<head>
+ <title>Junge Gemeinde Adlershof.</title>
+ <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
+ <link rel='stylesheet' type='text/css' href='hyperstyle.css' />
+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
+</head>
+
+<body link='#000000' vlink='#000000' alink='#FF0000'>
+
+<div class='kleineschrift'>
+ <div id='header' >
+ <br><br>
+ <hr>
+ </div>
+
+ <div id='content_container' align='center'>
+ <br>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p></div>
+ <div id='container' align='center'>
+
+ <?php echo $logout; ?>
+ <br>
+ <form method='post' action='check.php' >
+ <div class='hundertfuenfzig'><p>Login:</p></div>
+ <p><input type='text' name='username' size='40'/></p>
+ <p><input type='password' name='password' size='40'/></p>
+
+
+ <p><input type='submit' name='submit' value='Miau!'/></p>
+
+ </form><br>
+ Info: You have five attempts. You will be banned for 6 hours after your login attempts run out.<br>
+ <a style='text-decoration:underline;' href='reset.php'>Passwort vergessen? Klick hier.</a>
+
+
+ <br><br>
+ <div class='katze' align='center'>
+<pre>
+ _ ___ _.--.
+ \`.|\..----...-'` `-._.-'_.-'`
+ / ' ` , __.--'
+ )/' _/ \ `-_, /
+ `-''' `''\_,_.-;_.-\_ ',
+ _.-'_./ {_.' ; /
+ {_.-``-' {_/
+</pre>
+ </div>
+ </div>
+ </div>
+</div>
+</body>
+</html>
+
diff --git a/www/logout.php b/oldwww/logout.php
index 7c527b2..7c527b2 100644
--- a/www/logout.php
+++ b/oldwww/logout.php
diff --git a/www/lolrndm.php b/oldwww/lolrndm.php
index d24fd0b..d24fd0b 100644
--- a/www/lolrndm.php
+++ b/oldwww/lolrndm.php
diff --git a/www/member_login.php b/oldwww/member_login.php
index 8628a44..8628a44 100644
--- a/www/member_login.php
+++ b/oldwww/member_login.php
diff --git a/www/piwik.php b/oldwww/piwik.php
index 86bfb94..86bfb94 100644
--- a/www/piwik.php
+++ b/oldwww/piwik.php
diff --git a/oldwww/quote.php b/oldwww/quote.php
new file mode 100644
index 0000000..b0bc136
--- /dev/null
+++ b/oldwww/quote.php
@@ -0,0 +1,79 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include('auth.php');
+include("header.php");
+
+$zufall = $_GET["id"];
+
+/*__Datenbank___*/
+$db = new SQLite3("../database/database.sqlite");
+$rows = $db->query("SELECT count(*) as count FROM sprueche;");
+$row = $rows->fetchArray();
+$numRows = $row["count"];
+
+if ($zufall == ""){
+ $zufall = mt_rand(1,$numRows);
+}
+
+
+$safe_zufall = SQLite3::escapeString("$zufall");
+$ergebnis = $db->query("SELECT * FROM sprueche where id=$safe_zufall;");
+
+echo"
+
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p></div>
+ </div>
+ <div id='container' align='center'>
+
+<br><br><br>
+
+<b>Zitat Nummer #$zufall</b><br><br><div id='bgcolor'>";
+
+
+if (preg_match('/[0-9]/',$zufall)){ // I really need this hack to get the 404 when /[0-9][a-zA-Z]/ is happening. Bad PHP!
+ if (preg_match('/[^0-9]/',$zufall)){
+ $zufall = 0;
+ }
+}
+
+
+
+if ($zufall > 0 && $zufall <= ($numRows)){
+ while($row=$ergebnis->fetchArray()){
+ echo $row["spruch"];
+ }
+} else {
+echo "\"Sorry, can't find the quote, but a cat is fine too, right?\"<br><br>
+<pre>
+ ,/| _.--''^``-...___.._.,;
+ /, \'. _-' ,--,,,--'''
+ { \ `_-'' ' /}
+ `;;' ; ; ;
+ ._.--'' ._,,, _..' .;.'
+ (,_....----''' (,..--''
+</pre><br><br>
+<i>404 - Eintrag nicht vorhanden.</i>";
+}
+
+echo "</div>
+
+<br><br><br>
+ -----------------------------------------------------------------
+<div class='kleineschrift'><p>Es sind momentan <b><i>$numRows</i></b> Zitate in der Datenbank enthalten.</p>
+Du suchst ein bestimmtes Zitat? Gib hier dessen Nummer ein: <form method='get' action='quote.php' >
+ <input name='id' type='text' size='2' maxlength='30'>
+ <input type='submit' style='display:none'/>
+
+ </form>
+</div>
+
+</div></div></div>
+</body></html>";
+
+?>
diff --git a/www/redirect.php b/oldwww/redirect.php
index e45e078..e45e078 100644
--- a/www/redirect.php
+++ b/oldwww/redirect.php
diff --git a/oldwww/register.php b/oldwww/register.php
new file mode 100644
index 0000000..39d22f9
--- /dev/null
+++ b/oldwww/register.php
@@ -0,0 +1,54 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include('auth.php');
+include("header.php");
+
+if ($_GET["false"] == 1){
+$failure= "<div style='color:red;'>Fehler! Entweder ist der Nutzer schon registriert oder dein Passwort war leer!</div><br>";
+}
+
+echo "
+
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'>
+ <p>JUNGE GEMEINDE ADLERSHOF</p>
+ </div>
+
+
+
+<br><div style='width:800px;' id='behaelter' align='center' class='katze'>
+Registriere dich, um einen persönlichen Zugang zu erhalten. Such dir einen beliebigen Spitznamen und ein geeignetes Passwort aus. Keine Angst, dein Passwort wird sicher verwahrt und nicht im Klartext abgelegt.
+<br><br>Die E-Mail Adresse ist keine Pflicht, aber notwendig, wenn du dein Passwort vergessen hast.
+<br/><br/>
+
+$failure
+
+<div class='katze'>
+<form method='post' action='inreg.php'>
+<table width='320px'>
+<tr>
+ <td align='left'><p>Name:</td><td align='right'><input name='name' type='text' size='20' maxlength='30'></p></td>
+</tr>
+<tr>
+ <td align='left'><p>Passwort:</td><td align='right'><input name='pswd' type='password' size='20' maxlength='30'></p></td>
+</tr>
+<tr><td align='left'><p>E-Mail:</td> <td align='right'><input name='email' type='text' size='20' maxlength='30'></p></td>
+</tr>
+</table>
+<center><input type='submit' name='submit' value='Register'/></center>
+</form>
+</div>
+
+</div>
+</body>
+</html>
+";
+
+
+
+?>
diff --git a/oldwww/reset.php b/oldwww/reset.php
new file mode 100644
index 0000000..b18f8eb
--- /dev/null
+++ b/oldwww/reset.php
@@ -0,0 +1,128 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+session_start() ?>
+<!doctype html>
+
+<html>
+ <head>
+ <title>Junge Gemeinde Adlershof.</title>
+ <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
+ <link rel='stylesheet' type='text/css' href='hyperstyle.css' />
+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
+ </head>
+
+ <body link="#000000" vlink="#000000" alink="#FF0000">
+
+<?php
+
+if($_SESSION["login"]){
+
+include("header.php");
+
+} else {
+ echo "
+ <div id='header' class='kleineschrift'>
+ <br><br>
+ <hr>
+ </div>
+ ";
+
+$startseite="<div class='kleineschrift'><a style='text-decoration:underline;' href='login.php'>Zurück zur Startseite.</a></div>";
+}
+?>
+ <div id='content_container' align="center"><br>
+
+ <div align='center'>
+ <p5>JUNGE GEMEINDE ADLERSHOF</p5>
+<br><br><div id='behaelter' align='center'>
+
+<?php
+
+$email_post = $_POST["email"];
+$try = $_POST["try"];
+
+if (empty($email_post)){
+echo "
+<a5>Gib deine E-Mail Adresse ein, um dir ein neues Passwort zuzuschicken.</a5><br><br>
+<form action='reset.php' method='post'>
+<input type='text' name='email' size='30'/>
+</form>
+";
+} else {
+
+ /*___Datenbank___*/
+ $db_check = new SQLite3("../database/database.sqlite");
+ $safe_email = SQLite3::escapeString("$email_post");
+
+ $email_db = $db_check->query("SELECT email FROM user WHERE email='$safe_email';");
+ while($email_array = $email_db->fetchArray(SQLITE3_NUM)){
+ foreach($email_array as $thirdelement){
+ $email=$thirdelement;
+ }
+ }
+
+ if (empty($email)){
+ $try = $try +1;
+
+ if ($try > 0){
+ header("HTTP/1.0 401 Unauthorized");
+ }
+ $maxtry = 3 - $try;
+
+ if ($maxtry == 0) {
+ echo "<a4><b>YOU ARE BANNED! ;_;</b></a4><br> ";
+ header("Refresh: 3; /401");
+
+ } else {
+ echo "<a5>Die E-Mail ist nicht in der Datenbank gespeichert. Achte auf Tippfehler und probiere noch einmal.<br>
+ Du hast noch $maxtry Versuche, bevor du gesperrt wirst.</a5>
+ <br><br>
+ <form action='reset.php' method='post'>
+ <input type='text' name='email' size='30'/>
+ <input type='hidden' name='try' value='$try'/>
+ </form>
+ ";
+ }
+ } else {
+
+ $secret = explode(" ", "a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9");
+ shuffle($secret);
+ $secret = substr(implode($secret), 0, 10);
+
+ $salt = uniqid(mt_rand(), true);
+ $password = "$salt"."$secret";
+ $hash_password = md5($password);
+ for($i=0;$i<15000;$i++)
+ $hash_password = md5($hash_password);
+
+ if($db_check->exec("UPDATE user SET password='$hash_password', salt='$salt' where email='$email';")){
+ if(mail($email, "Dein neues Passwort", "Dein neues Passwort für https://jungegemeinde.iamfabulous.de lautet: '" . $secret . "'. Wenn du diese E-Mail nicht erwartet hast, bitte sende eine Nachricht an max-moehring@web.de. Danke.", "From: no-reply@jg-adlershof.de")){
+ echo "Wir haben deine E-Mail in der Datenbank. Eine E-Mail mit deinem neuen Passwort wurde soeben verschickt.<br>";
+ } else {
+ echo "Fehler mit der mail() Funktion. Bitte schick eine Benachrichtigung an <a href='mailto:max-moehring@web.de'>max-moehring@web.de</a>.";
+ }
+ } else {
+ echo "Fataler Datenbankfehler. Schick eine Nachricht an: <a href='mailto:max-moehring@web.de'>max-moehring@web.de</a>.";
+ }
+
+// exec('curl -vv --user max:sommer13 -F sender="mailer-daemon@jg-adlershof.de" -F recipient="'.$email.'" -F subject="Angefordertes neues Passwort - BITTE NICHT ANTWORTEN" -F message="Dein neues Passwort lautet: '.$secret.'." http://playground.oweissbarth.de/mail/send.php');
+
+
+ }
+
+
+}
+
+?>
+<br>
+<?php echo $startseite; ?>
+</div>
+</div>
+</div>
+</body>
+</html>
+<?php
+?>
diff --git a/oldwww/robots.txt b/oldwww/robots.txt
new file mode 100755
index 0000000..1f53798
--- /dev/null
+++ b/oldwww/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow: /
diff --git a/oldwww/setup.php b/oldwww/setup.php
new file mode 100644
index 0000000..2465822
--- /dev/null
+++ b/oldwww/setup.php
@@ -0,0 +1,14 @@
+<?
+
+$db = new SQLite3("../database/database.sqlite");
+
+if($db-exec("
+ BEGIN TRANSACTION;
+ CREATE TABLE log (id INTEGER PRIMARY KEY, user INTEGER, login TEXT, FOREIGN KEY(user) REFERENCES user(id));
+ CREATE TABLE user (id INTEGER PRIMARY KEY, name TEXT, adresse TEXT, telefonnummer TEXT, handynummer TEXT, email TEXT, geburtstag TEXT, salt TEXT, password TEXT);
+ COMMIT;
+ ")){
+ echo "Success!";
+else{
+ echo "Failure. :(";
+}
diff --git a/www/share.php b/oldwww/share.php
index 59af81f..59af81f 100644
--- a/www/share.php
+++ b/oldwww/share.php
diff --git a/www/to-do-list.php b/oldwww/to-do-list.php
index 1dc1dde..1dc1dde 100644
--- a/www/to-do-list.php
+++ b/oldwww/to-do-list.php
diff --git a/oldwww/update.php b/oldwww/update.php
new file mode 100644
index 0000000..e59bf8e
--- /dev/null
+++ b/oldwww/update.php
@@ -0,0 +1,53 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+include('auth.php');
+/*error_reporting(E_ALL);
+
+ini_set('display_errors', '1');*/
+
+$id = SQLite3::escapeString($_POST["id"]);
+$name = SQLite3::escapeString($_POST["name"]);
+$adresse = SQLite3::escapeString($_POST["adresse"]);
+$telefonnummer = SQLite3::escapeString($_POST["telefonnummer"]);
+$handynummer = SQLite3::escapeString($_POST["handynummer"]);
+$email = SQLite3::escapeString($_POST["email"]);
+$bday = SQLite3::escapeString($_POST["geburtstag"]);
+
+//echo "$name<br> $adresse<br>$telefonnummer<br>$handynummer<br>$email<br>$bday<br>$ip<br>$cryptedip";
+
+
+
+$db = new SQLite3('../database/database.sqlite');
+
+$db->exec("UPDATE member SET name='$name' where id=$id;");
+$db->exec("UPDATE member SET adresse='$adresse' where id=$id;");
+$db->exec("UPDATE member SET telefonnummer='$telefonnummer' where id=$id;");
+$db->exec("UPDATE member SET handynummer='$handynummer' where id=$id;");
+$db->exec("UPDATE member SET email='$email' where id=$id;");
+$db->exec("UPDATE member SET geburtstag='$bday' where id=$id;");
+
+/*echo "
+<!doctype html public '-//W3C//DTD XHTML 1.0 //EN'>
+
+<html>
+ <head>
+ <title>Junge Gemeinde Adlershof - Update erfolgreich!</title>
+ <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
+ <link rel='stylesheet' type='text/css' href='style.css' />
+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
+ </head>
+
+ <body>
+<center>
+<p5>Update erfolgreich!</p5><br><br>
+<a4>Weiterleitung in 3.. 2.. 1..</a4>
+</center></body></html>";*/
+
+header("Refresh: 0; liste.php");
+
+
+
+?>
diff --git a/www/account.php b/www/account.php
index 2db7e85..0b1543d 100644
--- a/www/account.php
+++ b/www/account.php
@@ -1,58 +1,5 @@
-<?php include('auth.php');
+<?php
-/* Copyright Maximilian Möhring, 2013
-Licensed under the GPL. Read LICENSE for more Information.*/
+function account($db){
-include("header.php");
-
-if ($_SESSION["username"] != "jg-adlershof"){
-
- $username = $_SESSION["username"];
- $db_check = new SQLite3("../database/database.sqlite");
-
- $safe_username = SQLite3::escapeString("$username");
- $email_db = $db_check->query("SELECT email FROM user where name='$safe_username';");
- while($email_array = $email_db->fetchArray(SQLITE3_NUM)){
- foreach($email_array as $thirdelement){
- $email=$thirdelement;
- }
- }
-
- /*Anzahl der hochgeladenen Dateien.*/
- $count_db = $db_check->query("SELECT count(*) as count FROM file where fk=(SELECT id from user where name='$safe_username');");
- $count_array = $count_db->fetchArray();
- $count = $count_array["count"];
-
-
-//echo "$username Test $email";
-echo "
-<div id='content_container' align='center'>
- <br>
- <div class='kleineschrift'>
- <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
- </div>
- </div>
-
-<br>
-<div class='mittlereschrift'>
- Verwalte deine Account Informationen hier.
-</div>
-<br>
-
-
-<table><tr>
-<td><p>Name:&#160</td><td align='right'>$username</p></td></tr>
-<tr><td><p>E-Mail:</td><td align='right'>$email</p></td></tr>
-<tr><td align='left'><p>Stored files:</td> <td align='right'>$count</p></td></tr>
-</table>
-
-
-";
-
-
-} else {
-header("Location: member_login.php");
-exit;
}
-
-?>
diff --git a/www/auth.php b/www/auth.php
index a63e5ea..4851f7b 100644
--- a/www/auth.php
+++ b/www/auth.php
@@ -1,8 +1,7 @@
<?php
- session_start();
+//session_start();
- if (!isset($_SESSION['login']) || !$_SESSION['login']) {
- header('Location: login.php');
- exit;
- }
-?>
+if ((!isset($_SESSION['login']) || !$_SESSION['login']) && $_GET["task"] != "login" && $_GET["task"] != "password_recover") {
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/login");
+ exit;
+}
diff --git a/www/config/index.html b/www/config/index.html
index 267f175..c04f57f 100644
--- a/www/config/index.html
+++ b/www/config/index.html
@@ -1,4 +1,4 @@
-<!doctype html public "-//W3C//DTD XHTML 1.0 //EN">
+<!doctype html>
<html>
<head>
diff --git a/www/constants.php b/www/constants.php
new file mode 100644
index 0000000..05e4192
--- /dev/null
+++ b/www/constants.php
@@ -0,0 +1,39 @@
+<?php
+define("EMPTY", 0);
+
+define("LOGIN_SUCCESSFULL", 1);
+define("LOGIN_DATABASE", 2);
+define("LOGIN_PASSWORD", 3);
+
+define("LOGOUT_SUCCESSFULL", 4);
+define("LOGOUT_FAILURE", 5);
+
+define("REGISTER_SUCCESSFULL", 6);
+define("REGISTER_PASSWORD", 7);
+define("REGISTER_EMAIL", 8);
+define("REGISTER_DATABASE", 9);
+define("REGISTER_PROHIBITED", 10);
+define("REGISTER_INVITEKEY", 11);
+define("REGISTER_USERNAME", 12);
+define("REGISTER_INVITE", 13);
+
+define("INVITE_SUCCESSFULL", 14);
+define("INVITE_INVITES", 15);
+define("INVITE_DATABASE", 16);
+define("INVITE_USEREXISTS", 17);
+
+define("PASSWORD_SUCCESS", 18);
+define("PASSWORD_PASSWORD", 19);
+define("PASSWORD_DATABASE", 20);
+
+define("RECOVER_SUCCESS", 21);
+define("RECOVER_EMAIL", 22);
+define("RECOVER_PROHIBITED", 23);
+
+define("NOT_LOGED_IN", 67);
+define("FOLDER_NOT_OWNER", 68);
+define("DATABASE", 69);
+define("CH_USERNAME_EXISTS", 70);
+define("CH_USERNAME_SUCCESS", 71);
+define("CH_EMAIL_EXISTS", 72);
+define("CH_EMAIL_SUCCESS", 73);
diff --git a/www/functions/func_failure.php b/www/functions/func_failure.php
new file mode 100755
index 0000000..e54cfaf
--- /dev/null
+++ b/www/functions/func_failure.php
@@ -0,0 +1,13 @@
+<?php
+/* --PAGE NOT FOUND - 404 -- */
+
+//function get_404($working_path, $wrong_folder){
+// include("httperror.php");
+// exit;
+//}
+
+function failure($reason){
+ echo "A 404 error occurred. <br>";
+ echo $reason;
+ exit;
+}
diff --git a/www/functions/func_interface.php b/www/functions/func_interface.php
new file mode 100755
index 0000000..08b9790
--- /dev/null
+++ b/www/functions/func_interface.php
@@ -0,0 +1,27 @@
+<?php
+
+//function print_invite($var){
+// include("invite.php");
+//}
+
+/*
+function print_recover_password(){
+ echo "
+ <!DOCTYPE html>
+ <html>
+ <body>
+ <form method='POST' action='/password_reset'>
+ <p>E-Mail <input type='text' name='email'></p>
+ </form>
+ </body>
+ ";
+}
+*/
+
+//function print_login($var){
+// echo "Coming soon";
+//}
+
+//function print_index(){
+// echo "Coming soon";
+//}
diff --git a/www/functions/func_login.php b/www/functions/func_login.php
new file mode 100755
index 0000000..3afb3d8
--- /dev/null
+++ b/www/functions/func_login.php
@@ -0,0 +1,87 @@
+<?php
+function login($db){
+
+ /*___Database Query: Login___*/
+ $username = $_POST["username"];
+ $password = $_POST["password"];
+ $safe_username = SQLite3::escapeString("$username");
+
+ $pepper = file_get_contents("../database/pepper.txt");
+ $password = $password . $pepper;
+
+ $real_password = "";
+
+ $real_password_db = $db->query("SELECT password FROM user WHERE name='" . $safe_username . "';");
+ while($real_password_array = $real_password_db->fetchArray(SQLITE3_NUM)){
+ foreach($real_password_array as $secondelement){
+ $real_password=$secondelement;
+ }
+ }
+
+ /*___Login___*/
+ if (!password_verify($password, $real_password)) {
+ return LOGIN_PASSWORD;
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO log (id, user, login) VALUES (NULL, (SELECT id FROM user WHERE name='" . $username . "'), (SELECT strftime('%s', 'now')));
+ COMMIT;
+ ")){
+
+ $id = user_id($db, $username);
+
+ $_SESSION["login"] = true;
+ $_SESSION["username"] = $username;
+ $_SESSION["userid"] = $id;
+
+ return LOGIN_SUCCESSFULL;
+
+ } else {
+ return LOGIN_DATABASE;
+ }
+}
+
+function logout(){
+
+ if(session_destroy()){
+ return LOGOUT_SUCCESSFULL;
+ } else {
+ return LOGOUT_FAILURE;
+ }
+}
+
+function brutforce_protection($db){
+ $_SESSION["login_attempts"] = $_SESSION["login_attempts"] - 1;
+
+ if($_SESSION["login_attempts"] <= 0){
+ $remote_ip = $_SERVER["REMOTE_ADDR"];
+ $session_id = session_id();
+ $time = $_SERVER["REQUEST_TIME"];
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO banned_user (id, ip, session_id, time) VALUES (NULL, '".SQLite3::escapeString($remote_ip)."', '".SQLite3::escapeString($session_id)."', ".$time.");
+ COMMIT;
+ ")){
+ echo "You are banned. ;_;";
+ }
+ exit;
+ }
+}
+
+function check_if_banned($db){
+
+ $remote_ip = $_SERVER["REMOTE_ADDR"];
+ $session_id = session_id();
+ $check_db = $db->query("SELECT time FROM banned_user WHERE ip='".SQLite3::escapeString($remote_ip)."' OR session_id='".SQLite3::escapeString($session_id)."';");
+ $check_ar = $check_db->fetchArray(SQLITE3_NUM);
+
+ $accepted_time = $_SERVER["REQUEST_TIME"] - 21600; // == 6h
+
+ if($check_ar[0] < $accepted_time){
+ return false; // not longer banned
+ } else {
+ return true; // still banned
+ }
+}
diff --git a/www/functions/func_password.php b/www/functions/func_password.php
new file mode 100644
index 0000000..3ee496b
--- /dev/null
+++ b/www/functions/func_password.php
@@ -0,0 +1,77 @@
+<?php
+
+function change_password($db, $first_password, $second_password){
+ if($_SESSION["login"]){
+ $username = user_id($db, $_SESSION["username"]);
+ } else {
+ $username_db = $db->query("SELECT id FROM user WHERE email='" . SQLite3::escapeString($_POST['email']) . "';");
+ $username_ar = $username_db->fetchArray(SQLITE3_NUM);
+ $username = $username_ar[0];
+ }
+
+ if($first_password != $second_password || !isset($first_password) || empty($first_password) || $first_password == ""){
+ return PASSWORD_PASSWORD;
+ }
+
+ $pepper = file_get_contents("../database/pepper.txt");
+ $password = $first_password . $pepper;
+
+ $hash_password = password_hash($password, PASSWORD_DEFAULT);
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE user SET password='" . $hash_password . "' WHERE id=" . $username . ";
+ COMMIT;
+ ")){
+ return PASSWORD_SUCCESS;
+ } else {
+ return PASSWORD_DATABASE;
+ }
+}
+
+function recover_password($db){
+ $test_email_db = $db->query("SELECT 1 FROM user WHERE email='" . SQLite3::escapeString($_POST['email']) . "';");
+ $test_email_ar = $test_email_db->fetchArray(SQLITE3_NUM);
+
+ if($test_email_ar[0] == 1){
+ $password_array = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "-", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" );
+
+ $length = count($password_array);
+ $password = "";
+
+ for ($i=0;$i<21;$i++){
+ $index = mt_rand(0,$length-1);
+ $password = "$password".$password_array[$index];
+ }
+
+ $var = change_password($db, $password, $password);
+
+ if($var == PASSWORD_SUCCESS){
+
+ $subject = "Your new password is" . $password;
+ if(mail($_POST['email'], "New password", $subject, "From: mail@iamfabulous.de")){
+ return RECOVER_SUCCESS;
+ } else {
+ return RECOVER_EMAIL;
+ }
+ } else {
+ return $var;
+ }
+ } else {
+ return RECOVER_PROHIBITED;
+ }
+}
+
+function validate_password($db, $username, $password){
+ $res_db = $db->query("SELECT password FROM user WHERE name='".$db->escapeString($username)."'");
+ $res_ar = $res_db->fetchArray(SQLITE3_NUM);
+
+ $pepper = file_get_contents("../database/pepper.txt");
+ $password .= $pepper;
+
+ if(password_verify($password, $res_ar[0])){
+ return true;
+ } else {
+ return false;
+ }
+}
diff --git a/www/functions/func_register.php b/www/functions/func_register.php
new file mode 100755
index 0000000..3cb79ad
--- /dev/null
+++ b/www/functions/func_register.php
@@ -0,0 +1,61 @@
+<?php
+function register($db){
+
+ $name = $_POST["name"];
+ $cleartext_password = $_POST["pswd"];
+ $second_password = $_POST["2ndpswd"];
+ $email = $_POST["email"];
+
+ /* checking for empty password etc. */
+
+ if(($cleartext_password != $second_password) || !isset($_POST["pswd"]) || !isset($_POST["2ndpswd"]) || $cleartext_password == "" || empty($_POST["pswd"]) || empty($_POST["2ndpswd"])){
+ return REGISTER_PASSWORD;
+ }
+
+ if(!empty($email)){
+ if(!preg_match("/[^.+@.+]/", $email)){
+ return REGISTER_EMAIL;
+ }
+ } else {
+ $email = "";
+ }
+
+ $safe_name = SQLite3::escapeString("$name");
+ $safe_email = SQLite3::escapeString("$email");
+
+ /*Checks the validation of the registration attempt*/
+
+ $doubleusername_db = $db->query("SELECT 1 FROM user WHERE name='" . $safe_name . "';");
+ $doubleusername_ar = $doubleusername_db->fetchArray(SQLITE3_NUM);
+
+ if($doubleusername_ar[0] == 1){
+ return REGISTER_USERNAME;
+ }
+
+ /*Generates the encrypted password and the database transaction*/
+
+ $pepper = file_get_contents("../database/pepper.txt");
+ $password = $cleartext_password . $pepper;
+
+ $hash_password = password_hash($password, PASSWORD_DEFAULT);
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO user (id, name, password, email, status, register) VALUES (NULL, '".$safe_name."', '".$hash_password."', '".$safe_email."', 1, (SELECT strftime('%s', 'now')));
+ INSERT INTO log (id, user, login) VALUES (NULL, (SELECT id FROM user WHERE name='" . $safe_name. "'), (SELECT strftime('%s', 'now')));
+ COMMIT;")
+ ){
+
+ $userid = user_id($db, $safe_name);
+
+ $_SESSION["login"] = true;
+ $_SESSION["username"] = $name;
+ $_SESSION["userid"] = $userid;
+
+ return REGISTER_SUCCESSFULL;
+
+ } else {
+ return REGISTER_DATABASE;
+ }
+
+}
diff --git a/www/functions/func_user.php b/www/functions/func_user.php
new file mode 100755
index 0000000..d9e202d
--- /dev/null
+++ b/www/functions/func_user.php
@@ -0,0 +1,337 @@
+<?php
+function account($db, $var){
+
+ if(empty($_GET["id"])){
+ $info_db = $db->query("SELECT * FROM user WHERE name='".$_SESSION["username"]."';");
+ $info_ar = $info_db->fetchArray(SQLITE3_NUM);
+
+ $ls_db = $db->query("SELECT login FROM log WHERE user=".$info_ar[0]." ORDER BY id DESC");
+ $last_seen = $ls_db->fetchArray(SQLITE3_NUM);
+ }
+
+ echo "
+ <!doctype html>
+
+ <html>
+ <head>
+ <title>Account :: Junge Gemeinde Adlershof</title>
+ <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
+ <link rel='stylesheet' type='text/css' href='/static/hyperstyle.css' />
+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
+ <script>
+ function showChangeUsername(){
+ document.getElementById(\"newUsername\").style.visibility = \"visible\";
+
+ return;
+ }
+
+ function showNewPassword(){
+ document.getElementById(\"newPassword\").style.visibility = \"visible\";
+
+ return;
+ }
+ </script>
+ <style type='text/css'>
+ #newUsername{
+ width: 100%;
+ height: 100%;
+ background: #ecece1;
+ position: fixed;
+ z-index: 99;
+ top: 0px;
+ opacity: 0.85;
+ visibility: hidden;
+ }
+
+ #newUsername-area{
+ height: 190px;
+ width: 400px;
+ position: fixed;
+ top: 50%;
+ margin-top: -100px;
+ padding: 10px;
+ left: 50%;
+ margin-left: -200px;
+ border: 1px solid black;
+ }
+
+ #newPassword{
+ width: 100%;
+ height: 100%;
+ background: #ecece1;
+ position: fixed;
+ z-index: 99;
+ top: 0px;
+ opacity: 0.85;
+ visibility: hidden;
+ }
+
+ #newPassword-area{
+ height: 190px;
+ width: 400px;
+ position: fixed;
+ top: 50%;
+ margin-top: -100px;
+ padding: 10px;
+ left: 50%;
+ margin-left: -200px;
+ border: 1px solid black;
+ }
+
+ #UserData-area{
+ width: 20%;
+ height: 120%;
+ /*opacity: 0.75;*/
+ /*background: white;*/
+
+ }
+
+ </style>
+ </head>
+ ";
+ include("static/head.php");
+// echo "loged in as: " . $_SESSION["username"];
+/*
+ echo "<center>
+
+ <table width='400px' border='1' rules='group'>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>E-Mail</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr><td align='center'>".$info_ar[1]."</td><td align='center'>".$info_ar[3]."</td></tr>
+
+ ";
+*/
+
+ switch($var){
+ case("password"):
+ $passage = "<font color='red'>Falsches Passwort.</font><br>";
+ break;
+ case(PASSWORD_SUCCESS):
+ $passage = "<font color='red'>Dein Passwort wurde erfolgreich geändert.</font><br>";
+ break;
+ case(CH_USERNAME_SUCCESS):
+ $passage = "<font color='red'>Erfolg! Ab sofort bist du unter ".$_SESSION["username"]." bekannt.</font><br>";
+ break;
+ case(CH_EMAIL_SUCCESS):
+ $passage = "<font color='red'>Deine E-Mail Adresse wurde erfolgreich geändert.</font><br>";
+ break;
+ case(CH_EMAIL_EXISTS):
+ $passage = "<font color='red'>Diese E-Mail Adresse ist schon in Benutzung.</font><br>";
+ break;
+ case(CH_USERNAME_EXISTS):
+ $passage = "<font color='red'>Dieser Name ist schon in Benutzung.</font><br>";
+ break;
+ default:
+ $passage = "";
+ break;
+ }
+
+ echo "<center>
+
+ <br><br>
+ <div id='content_container' align='center'>
+ <div class='kleineschrift'><div class='ueberschrift'><p>Account Informationen</p></div></div>
+ <br>
+ ".$passage."
+ <br>
+
+ <div id='UserData-area'>
+ <p>Deine Daten: (<a href='#' onclick='showChangeUsername()' style='text-decoration:underline; font-size:15px'>ändern?</a>)</p>
+ <br>
+ <table >
+ <tr><td>
+ Name:
+ </td><td>
+ &#160;
+ </td><td>
+ ".$info_ar[1]."
+ </td><td>
+ <tr><td>
+ E-Mail:
+ </td><td>
+ &#160;
+ </td><td>
+ ".$info_ar[3]."
+ </td></tr>
+ <tr><td>&#160;</td></tr>
+ <tr><td>
+ Registrierungsdatum:
+ </td><td>
+ &#160;
+ </td><td>
+ ".date("j.n.Y / H:i:s", $info_ar[5])."
+ </td><td>
+ </td><td>
+ &#160;
+ </td></tr>
+ <tr><td>
+ Zuletzt gesehen:
+ </td><td>
+ &#160;
+ </td><td>
+ ".date("j.n.Y / H:i:s", $last_seen[0])."
+ </td></tr>
+ </table>
+ <br>
+
+ </div>
+
+ <br>
+ <div style='width:400px'><hr></div>
+ <br>
+ <br>
+ <p>Passwort Verwaltung:</p>
+ <br>
+ <table>
+ <tr><td>
+ <a href='#' onclick='showNewPassword()' style='text-decoration:underline;'>Passwort ändern?</a>
+ </td>
+ <td>
+ &#160;
+ </td>
+ <td>
+ |
+ </td>
+ <td>
+ &#160;
+ </td>
+ <td>
+ <a href='/password_recover' style='text-decoration:underline;'>Passwort vergessen?</a>
+ </td></tr>
+ </table>
+
+
+ <div id='newUsername'>
+ <div id='newUsername-area'>
+ <p>Wechsle deinen Spitznamen oder deine E-Mail Adresse. Bitte bestätige die Änderung mit deinem Passwort.</p>
+ <br>
+ <form method='POST' action='/account/change:user'>
+ <table>
+ <tr><td>
+ Name:
+ </td>
+ <td>
+ <input type='text' name='name' value='".$info_ar[1]."'>
+ </td></tr>
+ <tr><td>
+ E-Mail:
+ </td>
+ <td>
+ <input type='text' name='email' value='".$info_ar[3]."'>
+ </td></tr>
+ <tr><td>
+ Passwort:
+ </td>
+ <td>
+ <input type='password' name='pswd'>
+ </td></tr>
+ <tr><td>
+ </td>
+ <td>
+ <input type='submit' value='ändern'>
+ </td></tr>
+ </table>
+ </form>
+ </div>
+ </div>
+ <br>
+ <div id='newPassword'>
+ <div id='newPassword-area'>
+ <p>Aktualisiere deine Passwort. Bitte bestätige die Änderung mit deinem aktuell gültigen Passwort.
+ <form method='POST' action='/account/change:password'>
+ <table>
+ <tr><td>
+ Neues Passwort:
+ </td>
+ <td>
+ <input type='password' name='pswd'>
+ </td></tr>
+ <tr><td>
+ Neues Passwort wiederholen:
+ </td>
+ <td>
+ <input type='password' name='2ndpswd'>
+ </td></tr>
+ <tr><td>
+ </td>
+ <td>
+ </td></tr>
+ <tr><td>
+ Altes Passwort:
+ </td>
+ <td>
+ <input type='password' name='oldpswd'>
+ </td></tr>
+ <tr><td>
+ </td>
+ <td>
+ <input type='submit' value='ändern'>
+ </td></tr>
+ </table>
+ </form>
+ </div>
+ </div>
+ </div>
+ ";
+ return true;
+}
+
+function user_id($db, $user){
+
+ $owner_db = $db->query("SELECT id FROM user WHERE name='" . SQLite3::escapeString($user) . "';");
+ $owner_ar = $owner_db->fetchArray(SQLITE3_NUM);
+ if(empty($owner_ar[0])){
+ return false;
+ }
+
+ $owner = $owner_ar[0];
+ return $owner;
+}
+
+function change_username($db, $oldname, $newname){
+ $oldname = $db->escapeString($oldname);
+ $newname = $db->escapeString($newname);
+ $check_db = $db->query("SELECT 1 FROM user WHERE name='".$newname."'");
+ $check_ar = $check_db->fetchArray(SQLITE3_NUM);
+
+ if($check_ar[0] == 1){
+ return CH_USERNAME_EXISTS;
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE user SET name='".$newname."'WHERE name='".$oldname."';
+ COMMIT;
+ ")){
+ $_SESSION["username"] = $newname;
+ return CH_USERNAME_SUCCESS;
+ } else {
+ return DATABASE;
+ }
+}
+
+function change_email($db, $name, $email){
+ $res_db = $db->query("SELECT 1, name FROM user WHERE email='".$db->escapeString($email)."'");
+ $res_ar = $res_db->fetchArray(SQLITE3_NUM);
+
+ if($res_ar[0] == 1){
+ if($name != $res_ar[1]){
+ return CH_EMAIL_EXISTS;
+ }
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE user SET email='".$db->escapeString($email)."' WHERE name='".$db->escapeString($name)."';
+ COMMIT;
+ ")){
+ return CH_EMAIL_SUCCESS;
+ } else {
+ return DATABASE;
+ }
+}
diff --git a/www/functions/notused/func_content.php b/www/functions/notused/func_content.php
new file mode 100755
index 0000000..ad0c87e
--- /dev/null
+++ b/www/functions/notused/func_content.php
@@ -0,0 +1,121 @@
+<?php
+
+function collect_content($db,$username, $folder_path){
+ $owner = user_id($db, $username);
+
+ if(!$owner){
+ failure("This user doesn't exist!");
+ }
+
+ $file_id = select_file_id($db, $owner, $folder_path);
+
+ if(!$file_id){
+ return FILE_NOT_FOUND;
+ }
+
+ $content = get_content($db, $file_id, $owner);
+
+ if(!$content){
+ return EMPTY_FOLDER;
+ }
+
+ return $content;
+}
+
+function get_content($db, $file_id, $owner){
+
+ if($_SESSION["login"] && $_SESSION["userid"] == $owner){
+ $share="";
+ } else {
+ $share =" AND share='PUBLIC'";
+ }
+
+ $content_db = $db->query("SELECT * FROM files WHERE parent=" . $file_id . " AND owner=" . $owner . $share . " ORDER BY folder, name;");
+
+ $count=0;
+
+ while($row = $content_db->fetchArray(SQLITE3_NUM)){
+ $content[$count][0] = $row[0];
+ $content[$count][1] = $row[1];
+ $content[$count][2] = $row[2];
+ $content[$count][3] = $row[3];
+ $content[$count][4] = $row[4];
+ $content[$count][5] = $row[5];
+ $content[$count][6] = $row[6];
+ $content[$count][7] = $row[7];
+ $content[$count][8] = $row[8];
+ $count++;
+ }
+
+ if(!empty($content)){
+ return $content; // returns everything listed in the folder which is commited as parameter
+ } else {
+ return false; // empty folder
+ }
+}
+
+function get_path_to_wrong_folder($db, $username, $folder_path){
+
+ $owner = user_id($db, $username);
+
+ if($_SESSION["login"] && $_SESSION["userid"] == $owner){
+ $share = "";
+ } else {
+ $share =" AND share='PUBLIC'";
+ }
+
+ $folder_array_unsafe = explode("/",$folder_path);
+ $length = count($folder_array_unsafe);
+
+ $root_db = $db->query("SELECT id FROM files WHERE parent=0 AND owner=" . SQLite3::escapeString($owner) . " AND folder='DIRECTORY' " . $share . ";");
+ $root_ar = $root_db->fetchArray(SQLITE3_NUM);
+ $root_id = $root_ar[0];
+
+ if(empty($root_id)){
+ return FOLDER_NOT_PUBLIC;
+ }
+
+ $parentdir = $root_id;
+
+ for($i=0; $i<$length; $i++){
+ $parentdir_db = $db->query("SELECT id, parent FROM files WHERE owner=" . $owner . $share . " AND parent=". $parentdir . " AND name='" . SQLite3::escapeString($folder_array_unsafe[$i]) . "';");
+ $prim_id = $parentdir_db->fetchArray(SQLITE3_NUM);
+
+ if($parentdir != $prim_id[1]){
+ $wrong_folder = $folder_array_unsafe[$i];
+ $working_path[0] = $wrong_folder;
+
+ for($j=0; $j<$i; $j++){
+ $working_path[$j] = $folder_array_unsafe[$j];
+ }
+
+ $lwp = count($working_path);
+ $working_path[$lwp] = $wrong_folder;
+
+ if($i == 0){
+ $working_path[0] = ""; // shows just the root slash
+ }
+
+ return $working_path; // returns working path and wrong folder as an array
+ }
+
+ $parentdir = $prim_id[0];
+
+ }
+
+ return false;
+}
+
+function print_wrong_folder($content){
+
+ $length = count($content);
+
+ $wrong_folder = $content[$length-1];
+ $working_path[0] = $wrong_folder; // initialize empty array
+
+ for($i=0; $i<$length-1; $i++){
+ $working_path[$i] = $content[$i];
+ }
+
+ get_404($working_path, $wrong_folder);
+}
diff --git a/www/functions/notused/func_delete.php b/www/functions/notused/func_delete.php
new file mode 100644
index 0000000..6220f8a
--- /dev/null
+++ b/www/functions/notused/func_delete.php
@@ -0,0 +1,207 @@
+<?php
+
+/*
+ expected state: tested?; but broken
+*/
+
+function check_if_deletable($db, $id, $hash){
+ $check_db = $db->query("SELECT hash FROM files WHERE id!=".$id." AND folder='FILE';");
+
+ $count = 0;
+ while($check_ar = $check_db->fetchArray(SQLITE3_NUM)){
+ if($check_ar[0] == $hash){
+ $count = $count +1;
+ break;
+ }
+ }
+
+ if($count == 0){
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function delete_file($user, $path){
+
+ if(!$_SESSION["login"]){
+ return DELETE_FILE_LOGIN;
+ }
+
+ $db = $GLOBALS["db"];
+ $uploaddir = "../files/";
+
+ $file_id = select_file_id($db, $user, $path);
+
+ $file_owner_db = $db->query("SELECT owner FROM files WHERE id=".$file_id.";");
+ $file_owner_ar = $file_owner_db->fetchArray(SQLITE3_NUM);
+
+ if($file_owner_ar[0] != $_SESSION["userid"]){
+ return DELETE_FILE_NOT_OWNER;
+ }
+
+ $check_if_file_db = $db->query("SELECT folder, hash FROM files WHERE id=".$file_id.";");
+ $check_if_file_ar = $check_if_file_db->fetchArray(SQLITE3_NUM);
+
+ if($check_if_file_ar[0] != "FILE"){
+ return DELETE_FILE_NO_FILE;
+ }
+
+ $file_hash = $check_if_file_ar[1];
+
+ $hash_array_db = $db->query("SELECT hash FROM files WHERE hash='".$file_hash.";'");
+ $count = 0;
+
+ while($row1 = $hash_array_db->fetchArray(SQLITE3_NUM)){
+ $hash_ar[$count] = $row1[0];
+ $count++;
+ }
+
+ $count = 0;
+
+ for($i=0; $i<count($hash_ar); $i++){
+ $file_id_owner_db = $db->query("SELECT id, owner FROM files WHERE folder='FILE' AND hash='".$hash_ar[$i]. "';");
+ while($row2 = $file_id_owner->fetchArray(SQLITE3_NUM)){
+ if($row2[1] != $_SESSION["userid"]){
+ $saved_files[$count] = $hash_ar[$i];
+ }
+ $count++;
+ }
+ }
+
+ for($i=0; $i<count($saved_files); $i++){
+ $cur = $saved_files[$i];
+ for($j=0; $j<count($hash_ar); $j++){
+ if($cur == $hash_ar[$j]){
+ $hash_ar[$j] = "";
+ }
+ }
+ }
+
+ for($i=0; $i<count($hash_ar); $i++){
+ if(!$file_hash[$i] != ""){
+ if(!unlink($uploaddir.$file_hash.".gz")){
+ return DELETE_FILE_UNLINK;
+ }
+ }
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ DELETE FROM files WHERE id=".$file_id.";
+ COMMIT;
+ ")){
+ return DELETE_FILE_SUCCESS;
+ } else {
+ return DELETE_FILE_DATABASE;
+ }
+}
+
+function delete_folder($user, $path){
+
+ if(!$_SESSION["login"]){
+ return DELETE_FOLDER_LOGIN;
+ }
+
+ $db = $GLOBALS["db"];
+
+ $folder_id = select_file_id($db, $user, $path);
+
+ $folder_owner_db = $db->query("SELECT owner FROM files WHERE id=".$folder_id.";");
+ $folder_owner_ar = $db->fetchArray(SQLITE3_NUM);
+
+ if($folder_owner_ar[0] != $_SESSION["userid"]){
+ return DELETE_FOLDER_NOT_OWNER;
+ }
+
+ $folder_content_db = $db->query("SELECT id FROM files WHERE parent=".$folder_id.";");
+ $folder_content_ar = $folder_content_db->fetchArray(SQLITE3_NUM);
+
+ if(empty($folder_content_ar[0])){
+ return DELETE_FOLDER_NOT_EMPTY;
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ DELETE FROM files WHERE id=".$folder_id.";
+ COMMIT;
+ ")){
+ return DELETE_FOLDER_SUCCESS;
+ } else {
+ return DELETE_FOLDER_DATABASE;
+ }
+}
+
+function delete_user($user, $password, $password_verify){
+
+ if(!$_SESSION["login"]){
+ return DELETE_USER_LOGIN;
+ }
+
+ $db = $GLOBALS["db"];
+ $uploaddir = "../files/";
+
+ $owner = user_id($db, $user);
+
+ if(($password != $password_verify ) || $password = ""){
+ return DELETE_USER_EMPTY_PASSWORD;
+ }
+
+ $password_hash_db = $db->query("SELECT password FROM user WHERE id=".$owner.";");
+ $password_hash_ar = $password_hash_db->fetchArray(SQLITE3_NUM);
+
+ $admin_password_hash_db = $db->query("SELECT password FROM user WHERE id=1;");
+ $admin_password_hash_ar = $admin_password_hash_db->fetchArray(SQLITE3_NUM);
+
+ if(!password_verify($password, $password_hash_ar[0]) || !password_verify($password, $admin_password_hash_ar[0])){
+ return DELETE_USER_WRONG_PASSWORD;
+ }
+
+ $hash_array_db = $db->query("SELECT hash FROM files WHERE folder='FILE' AND owner=".$owner.";");
+
+ $count = 0;
+
+ while($row1 = $hash_array_db->fetchArray(SQLITE3_NUM)){
+ $hash_ar[$count] = $row1[0];
+ $count++;
+ }
+
+ $count = 0;
+
+ for($i=0; $i<count($hash_ar); $i++){
+ $file_id_owner_db = $db->query("SELECT id, owner FROM files WHERE folder='FILE' AND hash='".$hash_ar[$i]."';");
+ while($row2 = $file_id_owner->fetchArray(SQLITE3_NUM)){
+ if($row2[1] != $_SESSION["userid"]){
+ $saved_files[$count] = $hash_ar[$i];
+ }
+ $count++;
+ }
+ }
+
+ for($i=0; $i<count($saved_files); $i++){
+ $cur = $saved_files[$i];
+ for($j=0;$j<count($hash_ar); $j++){
+ if($cur == $hash_ar[$j]){
+ $hash_ar[$j] = "";
+ }
+ }
+ }
+
+ for($i=0; $ii<count($hash_ar); $i++){
+ if($hash_ar[$i] != ""){
+ if(!unlink($uploaddir.$hash_ar[$i].".gz")){
+ return DELETE_USER_FILE_DELETE;
+ }
+ }
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ DELETE FROM user WHERE id=".$owner.";
+ COMMIT;
+ ")){
+ return DELETE_USER_SUCCESS;
+ } else {
+ return DELETE_USER_DATABASE;
+ }
+}
diff --git a/www/functions/notused/func_download.php b/www/functions/notused/func_download.php
new file mode 100644
index 0000000..26b25b1
--- /dev/null
+++ b/www/functions/notused/func_download.php
@@ -0,0 +1,123 @@
+<?php
+
+/*
+ Expected state: tested, should work.
+*/
+
+function check_if_file($db, $name, $folder_path){
+
+ $owner = user_id($db, $name);
+
+ $file_id = select_file_id($db, $owner, $folder_path);
+
+ if($file_id){
+ $check_if_file_db = $db->query("SELECT folder FROM files WHERE id=".$file_id.";");
+ $check_if_file_ar = $check_if_file_db->fetchArray(SQLITE3_NUM);
+
+ if($check_if_file_ar[0] == "FILE"){
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ //$content = get_path_to_empty_folder($db, $name, $folder_path);
+ //print_empty_folder($content);
+ //get_404("/", "Protected file");
+ return false;
+ }
+}
+
+function start_file_download($user, $path){
+
+ $db = $GLOBALS["db"];
+
+ $owner = user_id($db, $user);
+
+ $file_id = select_file_id($db, $owner, $path);
+
+ $file_db = $db->query("SELECT owner, share FROM files WHERE id=" . $file_id . ";");
+ $file_ar = $file_db->fetchArray(SQLITE3_NUM);
+ $file_owner = $file_ar[0];
+ $share = $file_ar[1];
+
+ if($_SESSION["login"] && ($_SESSION["userid"] == $file_owner)){
+ if(download_file($db, $file_id)){
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ if($share != "PUBLIC"){
+ return false;
+ }
+
+ if(download_file($db, $file_id)){
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
+function check_file_hash($db, $file_id, $download_hash){
+ if(preg_match("/[^0-9]/", $file_id)){
+ return DOWNLOAD_FALSE_ID;
+ }
+
+ $check_hash_db = $db->query("SELECT owner, folder, share, download_link FROM files WHERE id=" . SQLite3::escapeString($file_id).";");
+ $check_hash_ar = $check_hash_db->fetchArray(SQLITE3_NUM);
+
+ if($check_hash_ar[1] != "FILE"){
+ return DOWNLOAD_NOT_FILE;
+ }
+
+ if($check_hash_ar[2] != "PUBLIC"){
+ if($_SESSION["userid"] != $check_hash_ar[0]){
+ if($check_hash_ar[3] != $download_hash){
+ return DOWNLOAD_PRIVATE_FILE;
+ }
+ }
+ }
+
+ if(!download_file($db, $file_id)){
+ return false;
+ } else {
+ return true;
+ }
+
+}
+
+function download_file($db, $file_id){
+
+ $file_db = $db->query("SELECT name, mime, size, hash FROM files WHERE id=". SQLite3::escapeString($file_id).";");
+ $file_ar = $file_db->fetchArray(SQLITE3_NUM);
+
+ $file_name = $file_ar[0];
+ $file_mime = $file_ar[1];
+ $file_size = $file_ar[2];
+ $file_hash = $file_ar[3];
+
+ $uploaddir = "../files/";
+ $gzip_file = $uploaddir . $file_hash . ".gz";
+
+//TODO: buffer output, print if reading == true
+
+ header("Content-Type: ".$file_mime);
+
+ if(!preg_match("/^image\/.+/", $file_mime)){
+ header("Content-Disposition: attachment; filename=\"".$file_name."\"");
+ } else {
+ header("filename=".$file_name."");
+ }
+ header("Content-Length: ".$file_size);
+ set_time_limit(0);
+ $uncompressed_file = readgzfile($gzip_file);
+
+ if($uncompressed_file){
+ return true;
+ } else {
+ return false;
+ }
+
+
+}
diff --git a/www/functions/notused/func_folder.php b/www/functions/notused/func_folder.php
new file mode 100644
index 0000000..044fd8e
--- /dev/null
+++ b/www/functions/notused/func_folder.php
@@ -0,0 +1,162 @@
+<?php
+
+function database_mkdir($db, $file_id, $new_folder_name, $share){
+ if($db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO files (id, parent, owner, name, folder, size, share, hash) VALUES (Null, " . $file_id . ", " . $_SESSION['userid'] . ", '" . SQLite3::escapeString($new_folder_name) . "', 'DIRECTORY', 0, '" . SQLite3::escapeString($share) . "', '');
+ COMMIT;
+ ")){
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function create_folder($path, $new_folder_name, $share){
+
+ $db = $GLOBALS["db"];
+
+ if(!$_SESSION["login"]){
+ return MKDIR_LOGIN;
+ }
+
+ $file_id = select_file_id($db, $_SESSION["userid"], $path);
+
+ $owner_db = $db->query("SELECT owner FROM files WHERE id=" . SQLite3::escapeString($file_id) . ";");
+ $owner_ar = $owner_db->fetchArray(SQLITE3_NUM);
+
+ if($owner_ar[0] != $_SESSION["userid"]){
+ return MKDIR_OWNER;
+ }
+
+ //TODO: Cut trailing or leading slash
+ //TODO: Maye create two folders instead of returning an error?
+ if(preg_match("/\//", $new_folder_name)){
+ return SLASH_IN_FOLDER_NAME;
+ }
+
+ $dupl_db = $db->query("SELECT parent FROM files WHERE name='" . SQLite3::escapeString($new_folder_name) . "' AND owner=".$_SESSION["userid"].";");
+ while($dupl_ar = $dupl_db->fetchArray(SQLITE3_NUM)){
+ if($dupl_ar[0] == $file_id){
+ return MKDIR_DUPLICATE;
+ }
+ }
+
+ if(database_mkdir($db, $file_id, $new_folder_name, $share)){
+ return MKDIR_SUCCESS;
+ } else {
+ return MKDIR_DATABASE;
+ }
+}
+
+function move_folder($old_path, $new_path){
+
+ if(!$_SESSION["login"]){
+ return NOT_LOGED_IN;
+ }
+
+ $db = $GLOBALS["db"];
+ $old_file_id = select_file_id($db, $_SESSION["userid"], $old_path);
+ $new_file_id = select_file_id($db, $_SESSION["userid"], $new_path);
+
+ $old_folder_owner_db = $db->query("SELECT owner FROM files WHERE id=".$old_file_id.";");
+ $old_folder_owner_ar = $old_folder_owner_db->fetchArray(SQLITE3_NUM);
+
+ if($_SESSION["userid"] != $old_folder_owner_ar[0]){
+ return MV_OLD_FOLDER_NOT_OWNER;
+ }
+
+ if(!$new_file_id){
+ return MV_FOLDER_TARGET_NOT_EXIST;
+ }
+
+ $new_folder_owner_db = $db->query("SELECT owner FROM files WHERE id=".$new_file_id.";");
+ $new_folder_owner_ar = $new_folder_owner_db->fetchArray(SQLITE3_NUM);
+
+ if($_SESSION["userid"] != $new_folder_owner_ar[0]){
+ return MV_NEW_FOLDER_NOT_OWNER; }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE files SET parent=".$new_file_id." WHERE id=".$old_file_id.";
+ COMMIT;
+ ")){
+ return MV_FOLDER_SUCCESS;
+ } else {
+ return MV_FOLDER_DATABASE;
+ }
+}
+
+function rename_folder($path, $new_name){
+ if(!$_SESSION["login"]){
+ return NOT_LOGED_IN;
+ }
+
+ $db = $GLOBALS["db"];
+
+ $file_id = select_file_id($db, $_SESSION["username"], $path);
+
+ $folder_owner_db = $db->query("SELECT owner FROM fiiles where id=".$file_id.";");
+ $folder_owner_ar = $folder_owner_db->fetchArray(SQLITE3_NUM);
+
+ if($folder_owner_ar[0] != $_SESSION["userid"]){
+ return FOLDER_NOT_OWNER;
+ }
+
+ if(preg_match("/\//", $new_name)){
+ return SLASH_IN_FOLDER_NAME;
+ }
+
+ $dupl_db = $db->query("SELECT parent FROM files WHERE name='" . SQLite3::escapeString($new_name) . "' AND owner=".$_SESSION["userid"].";");
+ while($dupl_ar = $dupl_db->fetchArray(SQLITE3_NUM)){
+ if($dupl_ar[0] == $file_id){
+ return MKDIR_DUPLICATE;
+ }
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE files SET name='".SQLite3::escapeString($new_name)."' WHERE id=".$file_id.";
+ COMMIT;
+ ")){
+ return true;
+ } else {
+ return DATABASE;
+ }
+}
+
+function generate_download_link($file_id){
+
+ if(!$_SESSION["login"]){
+ return NOT_LOGED_IN;
+ }
+
+ $db = $GLOBALS["db"];
+
+ $folder_owner_db = $db->query("SELECT owner FROM files where id=".$file_id.";");
+ $folder_owner_ar = $folder_owner_db->fetchArray(SQLITE3_NUM);
+
+ if($folder_owner_ar[0] != $_SESSION["userid"]){
+ return FOLDER_NOT_OWNER;
+ }
+
+ $key_array = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "-", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" );
+
+ $length = count($key_array);
+ $key = "";
+
+ for ($i=0;$i<21;$i++){
+ $index = mt_rand(0,$length-1);
+ $key = $key.$key_array[$index];
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE files SET download_link='".$key."' WHERE id=".$file_id.";
+ COMMIT;
+ ")){
+ return $key;
+ } else {
+ return DATABASE;
+ }
+}
diff --git a/www/functions/notused/func_invite.php b/www/functions/notused/func_invite.php
new file mode 100755
index 0000000..d7613d5
--- /dev/null
+++ b/www/functions/notused/func_invite.php
@@ -0,0 +1,62 @@
+<?php
+function invite($db){
+
+ $name=$_SESSION["username"];
+ $safe_name = SQLite3::escapeString("$name");
+
+ $email=$_POST["email"];
+ $safe_email=SQLite3::escapeString("$email");
+
+ $invite_db = $db->query("SELECT invites FROM user WHERE name='" . $safe_name . "';");
+ $invite_ar = $invite_db->fetchArray(SQLITE3_NUM);
+ $invite = $invite_ar[0];
+
+ if($invite <= 0){
+ return INVITE_INVITES;
+ }
+
+ $email_db = $db->query("Select 1 FROM user WHERE email='" . $safe_email . "';");
+ $email_ar = $email_db->fetchArray(SQLITE3_NUM);
+
+ if($email_ar[0] == 1){
+ return INVITE_USEREXISTS;
+ }
+
+ /*Generates the invite key => [-_0-9a-zA-Z]{11}*/
+
+ $key_array = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "-", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" );
+
+ $length = count($key_array);
+ $key = "";
+
+ for ($i=0;$i<11;$i++){
+ $index = mt_rand(0,$length-1);
+ $key = "$key".$key_array[$index];
+ }
+
+ $id_db = $db->query("SELECT id FROM USER WHERE name='" . $safe_name . "';");
+ $id_ar = $id_db->fetchArray(SQLITE3_NUM);
+ $id = $id_ar[0];
+
+ /*Generates the new user and decrease the invites*/
+
+ $invite = $invite-1;
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO user (id, name, email, senpai, key, status) VALUES (NULL, NULL, '" . $safe_email . "', '" . $id . "', '" . $key . "', 0);
+ UPDATE user SET invites='" . $invite . "' WHERE id='" . $id . "';
+ COMMIT;")
+ ){
+
+ $subject="Welcome, you were invited to the new virtual filesystem.\nYour key is " . $key . "\nVisit files.iamfabulous.de/register to complete your registration.";
+
+ // Doesn't work with GMX or Web.de atm.
+ mail($email, "Invite", $subject, "From: mail@iamfabulous.de");
+
+ return INVITE_SUCCESSFULL;
+
+ } else {
+ return INVITE_DATABASE;
+ }
+}
diff --git a/www/functions/notused/func_rewrite.php b/www/functions/notused/func_rewrite.php
new file mode 100755
index 0000000..0a123d6
--- /dev/null
+++ b/www/functions/notused/func_rewrite.php
@@ -0,0 +1,30 @@
+<?php
+function rewrite($db){
+
+ /* test if first argument a username or folder */
+
+ $name = user_id($db, $_GET["name"]);
+
+ if($name == ""){
+
+ /* if first argument wasn't valid, rewrite the URL to include the username */
+
+ $folder = $_GET["folder"];
+
+ if(preg_match("/\/$/", $_GET["folder"])){
+ $folder = substr($_GET["folder"], 0, -1);
+ }
+
+ if($_SESSION["login"]){
+ $scheme = $GLOBALS["scheme"];
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/" . $_SESSION['username'] . "/" . $_GET["name"] . "/" . $folder . "");
+ exit;
+ }
+
+ return false;
+
+ } else {
+ return true;
+ }
+}
+
diff --git a/www/functions/notused/func_select.php b/www/functions/notused/func_select.php
new file mode 100755
index 0000000..9f10cd6
--- /dev/null
+++ b/www/functions/notused/func_select.php
@@ -0,0 +1,62 @@
+<?php
+function select_file_id($db, $owner, $folder_path){
+
+ if($_SESSION["login"] && $_SESSION["userid"] == $owner){ // TODO: Check if loged in user really the user who does the query - fix 12.3.14
+ $share=""; // to print all files, even hidden ones
+ } else {
+ $share =" AND share='PUBLIC'"; // just use files with the correct permissions
+ }
+
+ $folder_array_unsafe = explode("/",$folder_path);
+
+ $root_db = $db->query("SELECT id FROM files WHERE parent=0 AND owner=" . SQLite3::escapeString($owner) . " AND folder='DIRECTORY' " . $share . ";");
+ $root_ar = $root_db->fetchArray(SQLITE3_NUM);
+ $root_id = $root_ar[0];
+ if(empty($root_ar[0])){
+ failure("Seems like the user doesn't want to show his tree: " . $root_id);
+ }
+
+ $tmp_length = count($folder_array_unsafe);
+
+ if(empty($folder_array_unsafe[$tmp_length-1])){
+ $length = $tmp_length-1;
+ } else {
+ $length = $tmp_length;
+ }
+
+ $parentdir = SQLite3::escapeString($root_id);
+
+ if(empty($folder_array_unsafe[0])){
+ return $root_id; // returns the primary key from the root dir
+ }
+
+ for($i=0; $i<$length; $i++){
+
+ $parentdir_db = $db->query("SELECT id, parent FROM files WHERE owner=" . $owner . $share . " AND parent=" . $parentdir . " AND name='" . SQLite3::escapeString($folder_array_unsafe[$i]) . "' COLLATE NOCASE;");
+
+ $prim_id = $parentdir_db->fetchArray(SQLITE3_NUM);
+
+
+ if($parentdir != $prim_id[1]){
+
+/*
+ $wrong_folder = $folder_array_unsafe[$i];
+ $working_path[0] = $wrong_folder;
+
+ for($j=0; $j<$i; $j++){
+ $working_path[$j] = $folder_array_unsafe[$j];
+ }
+
+ get_404($working_path, $wrong_folder);
+*/
+
+ return false;
+ }
+
+
+ $parentdir = $prim_id[0];
+ }
+
+ return $parentdir; // returns the primary key from the last entry in the folder array
+
+}
diff --git a/www/functions/notused/func_upload.php b/www/functions/notused/func_upload.php
new file mode 100755
index 0000000..31fe304
--- /dev/null
+++ b/www/functions/notused/func_upload.php
@@ -0,0 +1,192 @@
+<?php
+
+function database_upload($db, $parentdir, $owner, $filename, $folder, $mime, $size, $share, $filehash){
+ if($db->exec("
+ BEGIN TRANSACTION;
+ INSERT INTO files (id, parent, owner, name, folder, mime, size, share, hash) VALUES (NULL, " . $parentdir . ", " . $owner . ", '" . $filename . "', '" . $folder . "', '" . $mime . "', '" . $size . "', '" . $share ."', '" . $filehash . "');
+ COMMIT;
+ ")){
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function database_upload_update($db, $id, $name, $mime, $size, $share, $filehash){
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE files SET name='".$name."', mime='".$mime."', size='".$size."', share='".$share."', hash='".$filehash."' WHERE id=".$id.";
+ COMMIT;
+ ")){
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function upload($path){
+
+ $db = $GLOBALS["db"];
+
+ set_time_limit(0);
+
+ if(!$_SESSION["login"]){
+ return UPLOAD_LOGIN;
+ }
+
+ if($_FILES["userfile"]["error"] > 0 || !$_FILES['userfile']['size'] > 0 || empty($_FILES['userfile']['size'])){
+ return UPLOAD_UPLOAD;
+ }
+
+ $parentdir = select_file_id($db, $_SESSION["userid"], $path);
+
+ $folder_owner_db = $db->query("SELECT owner FROM files WHERE id=".$parentdir.";");
+ $folder_owner_ar = $folder_owner_db->fetchArray(SQLITE3_NUM);
+
+ if($folder_owner_ar[0] != $_SESSION["userid"]){
+ return UPLOAD_FOLDER_NOT_OWNER;
+ }
+
+ $owner = $_SESSION["userid"];
+
+ $overall_size_db = $db->query("SELECT size FROM files WHERE owner=" . $owner . " AND size > 0;");
+ $overall_size = 0;
+ while($row = $overall_size_db->fetchArray(SQLITE3_NUM)){
+ $overall_size = $overall_size + $row[0];
+ }
+
+ if($overall_size > 2147483648){ // == 2GB
+ return UPLOAD_QUOTA;
+ }
+
+ $filename = $_FILES['userfile']['name'];
+
+ $folder = "FILE";
+ $mime = $_FILES['userfile']['type'];
+ $size = $_FILES['userfile']['size'];
+
+ if(isset($_POST["share"])){
+ $share = "PUBLIC";
+ } else {
+ $share = "PRIVATE";
+ }
+
+ $uploaddir = "../files/";
+
+ //$filehash = hash_file("md5", $uploaddir . $filename);
+ $filehash = hash_file("md5", $_FILES['userfile']['tmp_name']);
+
+ $exists = false;
+ $check_if_filename_already_exists_db = $db->query("SELECT id, name FROM files WHERE parent=".$parentdir." AND folder='FILE'");
+
+ while($row = $check_if_filename_already_exists_db->fetchArray(SQLITE3_NUM)){
+ if($row[1] == $filename){
+ $fileid = $row[0];
+ $exists = true;
+ break;
+ }
+ }
+
+ $hashtest_db = $db->query("SELECT hash FROM files WHERE hash='" . $filehash ."';");
+ $hashtest_ar = $hashtest_db->fetchArray(SQLITE3_NUM);
+
+ /* new file was uploaded */
+ if(empty($hashtest_ar[0])){
+
+ if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])){
+ return UPLOAD_MOVING;
+ }
+
+ /* checks if filename exists in the same directory */
+ if($exists){
+ $delete_file_db = $db->query("SELECT hash FROM files WHERE name='".$filename."' AND parent='".$parentdir."';");
+ $delete_file_ar = $delete_file_db->fetchArray(SQLITE3_NUM);
+
+ if(check_if_deletable($db, $fileid, $delete_file_ar[0])){
+
+ if(!unlink($uploaddir.$delete_file_ar[0].".gz")){
+ return UPLOAD_FILE_HANDLING;
+ }
+ }
+ if(!database_upload_update($db, $fileid, $filename, $mime, $size, $share, $filehash)){
+ return UPLOAD_DATABASE;
+ }
+ } else {
+ if(!database_upload($db, $parentdir, $owner, $filename, $folder, $mime, $size, $share, $filehash)){
+ return UPLOAD_DATABASE;
+ }
+ }
+
+ $gzfile = $uploaddir . $filehash . ".gz";
+ $fp = gzopen($gzfile, 'w9');
+
+ if(!gzwrite($fp, file_get_contents($uploaddir . $filename))){
+ return UPLOAD_FILE_HANDLING;
+ }
+
+ if(!gzclose($fp)){
+ return UPLOAD_FILE_HANDLING;
+ }
+
+ if(!unlink($uploaddir . $filename)){
+ return UPLOAD_FILE_HANDLING;
+ }
+
+ return UPLOAD_SUCCESS;
+
+ /* new file already exists, only thing is a new entry in the database */
+ } else {
+
+ $dupl_db = $db->query("SELECT parent, mime, size, share, name FROM files WHERE hash='" . $filehash . "';");
+
+ while($row = $dupl_db->fetchArray(SQLITE3_NUM)){
+ if($row[0] == $parentdir){
+ if($mime == $row[1] && $size == $row[2] && $share == $row[3] && $filename == $row[4]){
+ return UPLOAD_DUPLICATE;
+ }
+ }
+ }
+
+ if($exists){
+ $delete_file_db = $db->query("SELECT hash FROM files WHERE name='".$filename."' AND parent='".$parentdir."';");
+ $delete_file_ar = $delete_file_db->fetchArray(SQLITE3_NUM);
+
+ if(check_if_deletable($db, $fileid, $delete_file_ar[0])){
+ if(!unlink($uploaddir.$delete_file_ar[0].".gz")){
+ return UPLOAD_FILE_HANDLING;
+ }
+ }
+ if(!database_upload_update($db, $fileid, $filename, $mime, $size, $share, $filehash)){
+ return UPLOAD_DATABASE;
+ }
+ } else {
+ if(!database_upload($db, $parentdir, $owner, $filename, $folder, $mime, $size, $share, $filehash)){
+ return UPLOAD_DATABASE;
+ }
+ }
+
+ if(!unlink($_FILES['userfile']['tmp_name'])){
+ return UPLOAD_FILE_HANDLING;
+ }
+
+ return UPLOAD_SUCCESS;
+ }
+}
+
+//not used atm
+
+//function web_upload($db){
+// $url = $_POST["url"];
+// if(!preg_match("/^((https?|ftp)?://|www\.|ftp\.)?([-a-z0-9+&@#/%?=~_|!:,.;]+\.)+[a-z]{2}[a-z]*/i", $url)){
+// echo "no hyperlink";
+// return false;
+// }
+// if(!preg_match("/^[a-zA-Z]+://", $url){
+// $url = "http://".$url;
+// }
+// $file = file_get_contents($url);
+// if(!$file){
+// echo "Couldn't download ".$url;
+// return false;
+// }
+//}
diff --git a/www/help.php b/www/help.php
index 8a3aa22..89d7e33 100644
--- a/www/help.php
+++ b/www/help.php
@@ -1,11 +1,11 @@
-<?php include('auth.php');
+<?php
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-include("header.php");
+include("static/header.php");
+header("Refresh: 3; https://".$_SERVER["HTTP_HOST"]."/Startseite");
echo "<br><br><h1>Noch nicht implementiert.</h1>";
-header("Refresh: 3; index.php");
?>
diff --git a/www/include.php b/www/include.php
new file mode 100755
index 0000000..59aa1a9
--- /dev/null
+++ b/www/include.php
@@ -0,0 +1,42 @@
+<?php
+
+$db = new SQLite3("../database/sqlite.db");
+
+$scheme="http://";
+
+if(isset($_SERVER["HTTPS"])){
+ if($_SERVER["HTTPS"] == "on"){
+ $scheme="https://";
+ }
+}
+
+require_once("constants.php");
+require_once("auth.php");
+
+$func_dir = "functions/";
+
+require_once($func_dir . "func_failure.php"); // 404 and other errors
+require_once($func_dir . "func_interface.php"); // presents the vfs content
+//require_once($func_dir . "func_invite.php"); // handles the invite routine
+require_once($func_dir . "func_login.php"); // handles also logout
+require_once($func_dir . "func_register.php"); // processing the registration
+//require_once($func_dir . "func_rewrite.php"); // rewrites URL if user forgot to add the username while loged in
+//require_once($func_dir . "func_select.php"); // get the primary key from the last folder
+require_once($func_dir . "func_user.php"); // gets the userid and account specific stuff
+//require_once($func_dir . "func_content.php"); // get the vfs content
+require_once($func_dir . "func_password.php"); // changes the user password
+//require_once($func_dir . "func_folder.php"); // creates a new folder
+//require_once($func_dir . "func_delete.php"); // deletes files, folder and user
+//require_once($func_dir . "func_download.php"); // handles the file download
+//require_once($func_dir . "func_upload.php"); // handles the file upload
+
+require_once("login.php"); // prints the login page
+require_once("register.php"); // prints the register page
+require_once("reset.php"); // prints the password recover page
+require_once("liste.php");
+require_once("quote.php");
+require_once("insert.php");
+require_once("update.php");
+require_once("print_index.php");
+require_once("services.php");
+//require_once("browse.php"); // prints the file browser page
diff --git a/www/index.php b/www/index.php
index 88a7fa6..a8dc53f 100644..100755
--- a/www/index.php
+++ b/www/index.php
@@ -1,51 +1,171 @@
-<?php include('auth.php');
+<?php
+session_start();
-/* Copyright Maximilian Möhring, 2013
-Licensed under the GPL. Read LICENSE for more Information.*/
+if(!isset($_SESSION["login"])){
+ $_SESSION["login"] = false;
+}
-include("header.php");
-?>
+require_once("include.php"); // handles all the stuff that needs to be included
-<div id='content_container' align='center'>
- <br>
- <div class='kleineschrift'>
- <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
- </div>
- </div>
-<?php
-if($_SESSION["username"] == "jg-adlershof"){
-$name = "Gast";
-} else {
-$name = $_SESSION["username"];
+if(!isset($_SESSION["login_attempts"])){
+ $_SESSION["login_attempts"] = 6;
}
- echo "
-<br>
-<div class='kleineschrift'>
-<div style='width:800px;' class='katze' id='behaelter' align='center'>
- Hallo $name.<br> Willkommen auf der Webpage für die Junge Gemeinde in Adlershof. Für einen persönlichen Zugang, und um alle Features zu nutzen, registriere dich doch <a
-style='text-decoration:underline;color:blue;' href='register.php'>hier</a>. Wenn du Probleme bei der Navigation hast, dann schau unter <a style='text-decoration: underline;color:blue;'
-href='help.php'>Hilfe</a> nach. <br>
- Für Anregungen und Kritik bin ich immer zu haben. Schick mir einfach ne Mail oder sags mir nächsten Donnerstag. ;)
- <br><bR>
- PS: Du kannst dich nach einer Registrierung auch mit deinem Username einloggen.
-</div>
-</div>
-";
-?>
-
-<br><br>
-<div class='katze' align='center'><pre>
- ,/| _.--''^``-...___.._.,;
- /, \'. _-' ,--,,,--'''
- { \ `_-'' ' /}
- `;;' ; ; ;
- ._.--'' ._,,, _..' .;.'
- (,_....----''' (,..--''
-</pre></div>
-
-
-</div>
-</div>
-</body>
-</html>
+if(check_if_banned($db)){
+ echo "You are banned. ;_;";
+ exit;
+}
+
+if(empty($_GET)){
+ print_index($db);
+} else {
+ switch($_GET["task"]){
+ case("login"):
+ if($_SESSION["login"]){
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/");
+ exit;
+ }
+
+ if($_SERVER['REQUEST_METHOD'] == 'POST'){
+ $var = login($db);
+ if($var == LOGIN_SUCCESSFULL){
+ $_SESSION["login_attempts"] = 6;
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/");
+ } elseif ($var == LOGIN_PASSWORD){
+ brutforce_protection($db);
+ print_login($var);
+
+ } else {
+ print_login($var);
+ }
+ } else {
+ print_login(constant("EMPTY"));
+ }
+ break;
+
+ case("logout"):
+ if(!$_SESSION["login"]){
+ print_login(constant("EMPTY"));
+ exit;
+ }
+
+ $var = logout();
+ if($var == LOGOUT_SUCCESSFULL){
+ print_login($var);
+ } else {
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/httperror.php?e=500");
+ }
+ break;
+
+ case("register"):
+// if($_SESSION["login"]){
+// header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/");
+// exit;
+// }
+
+ if($_SERVER['REQUEST_METHOD'] == 'POST'){
+ $var = register($db);
+ if($var == REGISTER_SUCCESSFULL){
+ print_index($db);
+ } else {
+ print_register($var);
+ }
+ } else {
+ print_register(constant("EMPTY"));
+ }
+ break;
+
+ case("password_recover"):
+ if($_SERVER['REQUEST_METHOD'] == 'POST'){
+ $var = recover_password($db); //TODO: Print error message
+ if($var == RECOVER_PROHIBITED || $var = RECOVER_EMAIL){
+ brutforce_protection($db);
+ print_recover_password($var);
+ }
+ } else {
+ print_recover_password("");
+ }
+ break;
+
+ case("liste"):
+ print_list($db);
+ break;
+
+ case("quote"):
+ print_quote($db);
+ break;
+
+ case("new_member"):
+ if($_SERVER["REQUEST_METHOD"] == "POST"){
+ if(!insert_db($db)){
+ echo "Database error. Please send me a <a href'mailto:max-moehring@web.de?subject=database error'>mail</a>";
+ exit;
+ } else {
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/liste");
+ }
+ } else {
+ print_insert();
+ }
+ break;
+
+ case("update"):
+ if($_SERVER["REQUEST_METHOD"] == "POST"){
+ $var = update_db($db);
+ if($var){
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/liste");
+ } else {
+ echo "Database error. Please send me a <a href'mailto:max-moehring@web.de?subject=database error'>mail</a>";
+ exit;
+ }
+ } else {
+ header("Refresh: 0; ".$scheme.$_SERVER["HTTP_HOST"]."/liste");
+ }
+
+ break;
+
+ case("account"):
+ $var = "";
+
+ if($_SERVER["REQUEST_METHOD"] == "POST"){
+ if($_GET["change"] == "password"){
+ if(validate_password($db, $_SESSION["username"], $_POST["oldpswd"])){
+ $var=change_password($db, $_POST["pswd"], $_POST["2ndpswd"]);
+ } else {
+ $var = "password";
+ }
+
+ } elseif($_GET["change"] == "user"){
+ if(validate_password($db, $_SESSION["username"], $_POST["pswd"])){
+ $var = change_email($db, $_SESSION["username"], $_POST["email"]);
+ if($var != CH_MAIL_EXISTS && $var != DATABASE){
+ $eb = true;
+ $var = change_username($db, $_SESSION["username"], $_POST["name"]);
+ if($eb && $var == CH_USERNAME_EXISTS){
+ $var = CH_EMAIL_SUCCESS;
+ }
+ }
+ } else {
+ $var = "password";
+ }
+ /*if($var != CH_USERNAME_EXISTS && $var != DATABASE){
+ $var="success";
+ }*/
+ }
+ }
+
+ account($db, $var);
+ break;
+
+ case("services"):
+ print_services();
+ break;
+
+ default:
+ echo "404";
+ //get_404($_GET["task"], $_GET["task"]); //TODO: Commit EMPTY constant
+ break;
+ }
+}
+include("piwik.php");
+echo "</body>";
+echo "</html>";
diff --git a/www/insert.php b/www/insert.php
index 17002e3..c0b30e5 100644
--- a/www/insert.php
+++ b/www/insert.php
@@ -1,12 +1,9 @@
-<?php include('auth.php');
+<?php
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-include("header.php");
-
-if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $db = new SQLite3('../database/database.sqlite');
+function insert_db($db){
$safe1 = SQLite3::escapeString("$_POST[name]");
$safe2 = SQLite3::escapeString("$_POST[adresse]");
@@ -14,10 +11,21 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$safe4 = SQLite3::escapeString("$_POST[handynummer]");
$safe5 = SQLite3::escapeString("$_POST[email]");
$safe6 = SQLite3::escapeString("$_POST[geburtstag]");
- $query = "INSERT INTO member(id, name, adresse, telefonnummer, handynummer, email, geburtstag) VALUES(NULL,'$safe1','$safe2','$safe3','$safe4','$safe5','$safe6');";
- $result = $db->exec("$query");
+ $query = "INSERT INTO jg (id, name, adresse, telefonnummer, handynummer, email, geburtstag) VALUES(NULL,'$safe1','$safe2','$safe3','$safe4','$safe5','$safe6');";
+ if($db->exec("
+ BEGIN TRANSACTION;
+ ".$query."
+ COMMIT;
+ ")){
+ return true;
+ } else {
+ return false;
+ }
}
+function print_insert(){
+
+ include("static/header.php");
echo "
<div id='content_container' align='center'>
@@ -26,8 +34,33 @@ echo "
<div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
</div>
</div>
-";
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ <br><a2>Trage einfach die Daten von unserem neuen Mitglied ein: </a2><br>
+ <form method='post' action='/new_member' >
+ <table>
+ <tr>
+ <td align='right'><a2>Name: <input type='text' name='name' ></a2> </td>
+ <td align='right'><a2>Adresse: <input type='text' name='adresse' > </a2></td>
+ <td align='right'><a2>Telefon: <input type='text' name='telefonnummer'></a2> </td></tr>
+ <tr align='right'><td><a2>Handy: <input type='text' name='handynummer' ></a2> </td>
+ <td align='right'><a2>E-Mail: <input type='text' name='email' ></a2> </td>
+ <td align='right'><a2>Geburtstag: <input type='text' name='geburtstag' ></a2> </td>
+ </tr>
+ <tr>
+ <td>&#160;</td>
+ <td align='center'><input type='submit' name='submit' value='Hinzufügen'/></td>
+ <td>&#160;</td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ ";
+
+}
+/*
+</body>";
+*/
+
+/*
echo "
<center>
<br>
@@ -43,26 +76,5 @@ Einen Moment, sie werden gleich weitergeleitet.
";
header("Refresh: 4; /liste.php");
-
- } else {
- echo "
- <br><a2>Trage einfach die Daten von unserem neuen Mitglied ein: </a2><br>
- <form method='post' action='insert.php' ><table><tr>
- <td align='right'><a2>Name: <input type='text' name='name' ></a2> </td>
- <td align='right'><a2>Adresse: <input type='text' name='adresse' > </a2></td>
- <td align='right'><a2>Telefon: <input type='text' name='telefonnummer'></a2> </td></tr>
- <tr align='right'><td><a2>Handy: <input type='text' name='handynummer' ></a2> </td>
- <td align='right'><a2>E-Mail: <input type='text' name='email' ></a2> </td>
- <td align='right'><a2>Geburtstag: <input type='text' name='geburtstag' ></a2> </td></tr>
- <tr><td>&#160;</td><td align='center'><input type='submit' name='submit' value='Hinzufügen'/></td><td>&#160;</td></tr>
- </table></form>
- ";
-
-}
-/*
-</body>";
*/
-
//echo '<br><a href="login.php?x=$cryptedip">Zur&uuml;ck</a></center>';
-
-?>
diff --git a/www/liste.php b/www/liste.php
index 94deb1a..2ff3490 100644
--- a/www/liste.php
+++ b/www/liste.php
@@ -3,12 +3,10 @@
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-include("header.php");
-
-$db = new SQLite3("../database/database.sqlite");
-
-?>
+function print_list($db){
+ include("static/header.php");
+ echo "
<script>
// Elemente einblenden
function show_elements()
@@ -38,10 +36,10 @@ function hide_elements()
<div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
</div>
</div>
+ ";
+ if($_GET["id"] == 0 || $_GET["id"] == "" || !isset($_GET["id"])){
-<?php if($_GET["id"] == 0 || $_GET["id"] == "" || !isset($_GET["id"])){
-
-echo"
+ echo"
<br><br>
<table height='350' border='1' rules='all' cellpadding='20' cellbording='20' cellspacing='20'>
<!-- Wenn mir mal einer erklären könnte, warum die Zellen trotzdem keinen Abstand haben? -->
@@ -58,18 +56,16 @@ echo"
</thead>
<tbody cellpadding='20' cellbording='20' cellspacing='20'>
-";
- $ergebnis = $db->query("SELECT * FROM member");
+ ";
+ $ergebnis = $db->query("SELECT id, name, adresse, telefonnummer, handynummer, email, geburtstag FROM jg");
+ $count = 1;
while($row=$ergebnis->fetchArray(SQLITE3_NUM)){
- $id=$row[0];
- echo "<tr>";
- foreach($row as $element){
- echo "<td align='left'><a href=\"?id=$id\" onclick=\"document.location.href='liste.php?id=$id'\">$element</a></td>";
+
+ //echo "<r><td align='left'><a href=\"/liste/.".$id."\" onclick=\"document.location.href='/liste/."$id."'\">$element</a></td></tr>";
+ echo "<tr><td align='left'><a href=\"/liste/".$row[0]."\">".$count."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[1]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[2]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[3]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[4]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[5]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[6]."</a></td><tr>";
+ $count++;
}
- echo "
- </tr>";
- }
echo "
</tbody>
@@ -78,20 +74,19 @@ echo "
<br><br>
<div style='width:1000px;' class='mittlereschrift'>
Da es in letzter Zeit doch öfters vorgekommen ist, dass jemand seine Adresse geändert hat, ist es jetzt möglich, einen Eintrag in der Adressliste zu ändern oder zu ergänzen.
-Wenn du deine Adresse <b>ändern</b> möchtest, dann drücke einfach auf deinen Namen in der richtigen Zeile. <a href='insert.php'>Möchtest du jemanden <b>hinzufügen</b>, dann drücke bitte <u>hier</u>.</a>
+Wenn du deine Adresse <b>ändern</b> möchtest, dann drücke einfach auf deinen Namen in der richtigen Zeile. <a href='/new_member'>Möchtest du jemanden <b>hinzufügen</b>, dann drücke bitte <u>hier</u>.</a>
</div>
<br><br>
";
} else {
-
$id = $_GET["id"];
$safe_id = SQLite3::escapeString("$id");
- $ergebnis = $db->query("SELECT * FROM member where id=$safe_id;");
+ $ergebnis = $db->query("SELECT * FROM jg where id=$safe_id;");
while($row=$ergebnis->fetchArray()){
echo "<br><a2>Trage einfach die neuen Daten von $row[name] ein: </a2><br>
- <form method='post' action='update.php' ><table><tr>";
+ <form method='post' action='/update' ><table><tr>";
echo "<td align='right'><a2>Name: <input type='text' name='name' value='$row[name]'></a2> </td>
<td align='right'><a2>Adresse: <input type='text' name='adresse' value='$row[adresse]'> </a2></td>
<td align='right'><a2>Telefon: <input type='text' name='telefonnummer' value='$row[telefonnummer]'></a2> </td></tr>
@@ -103,8 +98,8 @@ Wenn du deine Adresse <b>ändern</b> möchtest, dann drücke einfach auf deinen
";
}
}
-?>
+/*
<!--AUSKOMMENTIERT#################################################################################
<table width="400px" >
<colgroup width="170" span="3"></colgroup>
@@ -140,6 +135,8 @@ oder
</div>
-->
+*/
+ echo"
</div>
-</body>
-</html>
+";
+}
diff --git a/www/login.php b/www/login.php
index bfba63e..f20a568 100644
--- a/www/login.php
+++ b/www/login.php
@@ -3,22 +3,23 @@
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-if ($_GET["logout"] == 1) {
- $logout = "<br><div style='color:red;'>Ausloggen erfolgreich</div>";
-}
-if ($_GET["failure"] == 1) {
- $logout = "<br><div style='color:red;'>Name oder Passwort falsch!</div>";
-}
+function print_login($var){
+ if ($var == LOGOUT_SUCCESSFULL) {
+ $logout = "<br><div style='color:red;'>Ausloggen erfolgreich</div>";
+ }
+ if ($var == LOGIN_PASSWORD) {
+ $logout = "<br><div style='color:red;'>Name oder Passwort falsch!</div>";
+ }
-?>
-<!doctype html public '-//W3C//DTD XHTML 1.0 //EN'>
+ echo "
+<!doctype html>
<html>
<head>
<title>Junge Gemeinde Adlershof.</title>
<meta http-equiv='Content-type' content='text/html; charset=utf-8' />
- <link rel='stylesheet' type='text/css' href='hyperstyle.css' />
+ <link rel='stylesheet' type='text/css' href='/static/hyperstyle.css' />
<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
</head>
@@ -35,9 +36,9 @@ if ($_GET["failure"] == 1) {
<div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p></div>
<div id='container' align='center'>
- <?php echo $logout; ?>
+ $logout
<br>
- <form method='post' action='check.php' >
+ <form method='post' action='/login' >
<div class='hundertfuenfzig'><p>Login:</p></div>
<p><input type='text' name='username' size='40'/></p>
<p><input type='password' name='password' size='40'/></p>
@@ -46,8 +47,8 @@ if ($_GET["failure"] == 1) {
<p><input type='submit' name='submit' value='Miau!'/></p>
</form><br>
- Info: You have five attempts. You will be banned for 6 hours after your login attempts run out.<br>
- <a style='text-decoration:underline;' href='reset.php'>Passwort vergessen? Klick hier.</a>
+ Info: You have ".$_SESSION["login_attempts"]." attempts. You will be banned for six hours after your login attempts run out.<br>
+ <a style='text-decoration:underline;' href='/password_recover'>Passwort vergessen? Klick hier.</a>
<br><br>
@@ -65,6 +66,5 @@ if ($_GET["failure"] == 1) {
</div>
</div>
</div>
-</body>
-</html>
-
+";
+}
diff --git a/www/print_index.php b/www/print_index.php
new file mode 100644
index 0000000..9a8e96d
--- /dev/null
+++ b/www/print_index.php
@@ -0,0 +1,48 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+function print_index(){
+ include("static/header.php");
+
+ if($_SESSION["username"] == "jg-adlershof"){
+ $name = "Gast";
+ } else {
+ $name = $_SESSION["username"];
+ }
+
+ echo "
+<div id='content_container' align='center'>
+ <br>
+ <div class='kleineschrift'>
+ <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p>
+ </div>
+ </div>
+<br>
+<div class='kleineschrift'>
+<div style='width:800px;' class='katze' id='behaelter' align='center'>
+ Hallo ".$name.".<br> Willkommen auf der Webpage für die Junge Gemeinde in Adlershof. Für einen persönlichen Zugang, und um alle Features zu nutzen, registriere dich doch <a
+style='text-decoration:underline;color:blue;' href='/register'>hier</a>. Wenn du Probleme bei der Navigation hast, dann schau unter <a style='text-decoration: underline;color:blue;'
+href='/help'>Hilfe</a> nach. <br>
+ Für Anregungen und Kritik bin ich immer zu haben. Schick mir einfach ne Mail oder sags mir nächsten Donnerstag. ;)
+ <br><bR>
+ PS: Du kannst dich nach einer Registrierung auch mit deinem Username einloggen.
+</div>
+</div>
+
+<br><br>
+<div class='katze' align='center'><pre>
+ ,/| _.--''^``-...___.._.,;
+ /, \'. _-' ,--,,,--'''
+ { \ `_-'' ' /}
+ `;;' ; ; ;
+ ._.--'' ._,,, _..' .;.'
+ (,_....----''' (,..--''
+</pre></div>
+
+
+</div>
+</div>
+ ";
+}
diff --git a/www/quote.php b/www/quote.php
index b0bc136..70b1b84 100644
--- a/www/quote.php
+++ b/www/quote.php
@@ -3,26 +3,29 @@
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-include('auth.php');
-include("header.php");
+function print_quote($db){
+ include("static/header.php");
-$zufall = $_GET["id"];
+ if(!empty($_GET["id"])){
+ $zufall = $_GET["id"];
+ } else {
+ $zufall = "";
+ }
-/*__Datenbank___*/
-$db = new SQLite3("../database/database.sqlite");
-$rows = $db->query("SELECT count(*) as count FROM sprueche;");
-$row = $rows->fetchArray();
-$numRows = $row["count"];
+ /*__Datenbank___*/
+ $rows = $db->query("SELECT count(*) as count FROM sprueche;");
+ $row = $rows->fetchArray();
+ $numRows = $row["count"];
-if ($zufall == ""){
- $zufall = mt_rand(1,$numRows);
-}
+ if ($zufall == ""){
+ $zufall = mt_rand(1,$numRows);
+ }
-$safe_zufall = SQLite3::escapeString("$zufall");
-$ergebnis = $db->query("SELECT * FROM sprueche where id=$safe_zufall;");
+ $safe_zufall = SQLite3::escapeString("$zufall");
+ $ergebnis = $db->query("SELECT * FROM sprueche where id=$safe_zufall;");
-echo"
+ echo"
<div id='content_container' align='center'>
<br>
@@ -33,23 +36,24 @@ echo"
<br><br><br>
-<b>Zitat Nummer #$zufall</b><br><br><div id='bgcolor'>";
+<b>Zitat Nummer #$zufall</b><br><br><div id='bgcolor'>
+ ";
-if (preg_match('/[0-9]/',$zufall)){ // I really need this hack to get the 404 when /[0-9][a-zA-Z]/ is happening. Bad PHP!
- if (preg_match('/[^0-9]/',$zufall)){
- $zufall = 0;
+ if (preg_match('/[0-9]/',$zufall)){ // I really need this hack to get the 404 when /[0-9][a-zA-Z]/ is happening. Bad PHP!
+ if (preg_match('/[^0-9]/',$zufall)){
+ $zufall = 0;
+ }
}
-}
-if ($zufall > 0 && $zufall <= ($numRows)){
- while($row=$ergebnis->fetchArray()){
- echo $row["spruch"];
- }
-} else {
-echo "\"Sorry, can't find the quote, but a cat is fine too, right?\"<br><br>
+ if ($zufall > 0 && $zufall <= ($numRows)){
+ while($row=$ergebnis->fetchArray()){
+ echo $row["spruch"];
+ }
+ } else {
+ echo "\"Sorry, can't find the quote, but a cat is fine too, right?\"<br><br>
<pre>
,/| _.--''^``-...___.._.,;
/, \'. _-' ,--,,,--'''
@@ -58,15 +62,16 @@ echo "\"Sorry, can't find the quote, but a cat is fine too, right?\"<br><br>
._.--'' ._,,, _..' .;.'
(,_....----''' (,..--''
</pre><br><br>
-<i>404 - Eintrag nicht vorhanden.</i>";
-}
+<i>404 - Eintrag nicht vorhanden.</i>
+ ";
+ }
-echo "</div>
+ echo "</div>
<br><br><br>
-----------------------------------------------------------------
<div class='kleineschrift'><p>Es sind momentan <b><i>$numRows</i></b> Zitate in der Datenbank enthalten.</p>
-Du suchst ein bestimmtes Zitat? Gib hier dessen Nummer ein: <form method='get' action='quote.php' >
+Du suchst ein bestimmtes Zitat? Gib hier dessen Nummer ein: <form method='get' action='/quote' >
<input name='id' type='text' size='2' maxlength='30'>
<input type='submit' style='display:none'/>
@@ -74,6 +79,5 @@ Du suchst ein bestimmtes Zitat? Gib hier dessen Nummer ein: <form method='get' a
</div>
</div></div></div>
-</body></html>";
-
-?>
+";
+}
diff --git a/www/register.php b/www/register.php
index 39d22f9..6283f14 100644
--- a/www/register.php
+++ b/www/register.php
@@ -3,12 +3,13 @@
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-include('auth.php');
-include("header.php");
+function print_register($var){
-if ($_GET["false"] == 1){
-$failure= "<div style='color:red;'>Fehler! Entweder ist der Nutzer schon registriert oder dein Passwort war leer!</div><br>";
-}
+ include("static/header.php");
+
+ if ($var != ""){
+ $failure= "<div style='color:red;'>Fehler! Entweder ist der Nutzer schon registriert oder dein Passwort war leer!</div><br>";
+ }
echo "
@@ -29,7 +30,7 @@ Registriere dich, um einen persönlichen Zugang zu erhalten. Such dir einen beli
$failure
<div class='katze'>
-<form method='post' action='inreg.php'>
+<form method='post' action='/register'>
<table width='320px'>
<tr>
<td align='left'><p>Name:</td><td align='right'><input name='name' type='text' size='20' maxlength='30'></p></td>
@@ -37,6 +38,9 @@ $failure
<tr>
<td align='left'><p>Passwort:</td><td align='right'><input name='pswd' type='password' size='20' maxlength='30'></p></td>
</tr>
+<tr>
+ <td align='left'><p>Passwort wiederholen:</td><td align='right'><input name='2ndpswd' type='password' size='20' maxlength='30'></p></td>
+</tr>
<tr><td align='left'><p>E-Mail:</td> <td align='right'><input name='email' type='text' size='20' maxlength='30'></p></td>
</tr>
</table>
@@ -45,10 +49,5 @@ $failure
</div>
</div>
-</body>
-</html>
";
-
-
-
-?>
+}
diff --git a/www/reset.php b/www/reset.php
index b18f8eb..4d6069e 100644
--- a/www/reset.php
+++ b/www/reset.php
@@ -3,126 +3,68 @@
/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/
-session_start() ?>
+function print_recover_password($var){
+
+ echo "
<!doctype html>
<html>
<head>
<title>Junge Gemeinde Adlershof.</title>
<meta http-equiv='Content-type' content='text/html; charset=utf-8' />
- <link rel='stylesheet' type='text/css' href='hyperstyle.css' />
+ <link rel='stylesheet' type='text/css' href='/static/hyperstyle.css' />
<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
</head>
- <body link="#000000" vlink="#000000" alink="#FF0000">
-
-<?php
+";
-if($_SESSION["login"]){
+ if($_SESSION["login"]){
+ include("static/head.php");
-include("header.php");
+ } else {
+ echo "
+ <div id='header' class='kleineschrift'>
+ <br><br>
+ <hr>
+ </div>
+ ";
+ include("piwik.php");
+ }
-} else {
+ $startseite="<div class='kleineschrift'><a style='text-decoration:underline;' href='/'>Zurück zur Startseite.</a></div>";
echo "
- <div id='header' class='kleineschrift'>
- <br><br>
- <hr>
- </div>
- ";
-
-$startseite="<div class='kleineschrift'><a style='text-decoration:underline;' href='login.php'>Zurück zur Startseite.</a></div>";
-}
-?>
- <div id='content_container' align="center"><br>
+ <div id='content_container' align='center'><br>
<div align='center'>
<p5>JUNGE GEMEINDE ADLERSHOF</p5>
<br><br><div id='behaelter' align='center'>
+ ";
-<?php
-
-$email_post = $_POST["email"];
-$try = $_POST["try"];
-
-if (empty($email_post)){
-echo "
-<a5>Gib deine E-Mail Adresse ein, um dir ein neues Passwort zuzuschicken.</a5><br><br>
-<form action='reset.php' method='post'>
-<input type='text' name='email' size='30'/>
-</form>
-";
-} else {
-
- /*___Datenbank___*/
- $db_check = new SQLite3("../database/database.sqlite");
- $safe_email = SQLite3::escapeString("$email_post");
-
- $email_db = $db_check->query("SELECT email FROM user WHERE email='$safe_email';");
- while($email_array = $email_db->fetchArray(SQLITE3_NUM)){
- foreach($email_array as $thirdelement){
- $email=$thirdelement;
- }
- }
-
- if (empty($email)){
- $try = $try +1;
-
- if ($try > 0){
- header("HTTP/1.0 401 Unauthorized");
- }
- $maxtry = 3 - $try;
-
- if ($maxtry == 0) {
- echo "<a4><b>YOU ARE BANNED! ;_;</b></a4><br> ";
- header("Refresh: 3; /401");
-
- } else {
- echo "<a5>Die E-Mail ist nicht in der Datenbank gespeichert. Achte auf Tippfehler und probiere noch einmal.<br>
- Du hast noch $maxtry Versuche, bevor du gesperrt wirst.</a5>
- <br><br>
- <form action='reset.php' method='post'>
- <input type='text' name='email' size='30'/>
- <input type='hidden' name='try' value='$try'/>
- </form>
- ";
- }
+ if($var == RECOVER_EMAIL){
+ $p = "
+ <a5>Die E-Mail ist nicht in der Datenbank gespeichert. Achte auf Tippfehler und probiere noch einmal.<br>
+ Du hast noch ".$_SESSION["login_attempts"] ."Versuche, bevor du gesperrt wirst.</a5>
+ ";
} else {
-
- $secret = explode(" ", "a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9");
- shuffle($secret);
- $secret = substr(implode($secret), 0, 10);
-
- $salt = uniqid(mt_rand(), true);
- $password = "$salt"."$secret";
- $hash_password = md5($password);
- for($i=0;$i<15000;$i++)
- $hash_password = md5($hash_password);
-
- if($db_check->exec("UPDATE user SET password='$hash_password', salt='$salt' where email='$email';")){
- if(mail($email, "Dein neues Passwort", "Dein neues Passwort für https://jungegemeinde.iamfabulous.de lautet: '" . $secret . "'. Wenn du diese E-Mail nicht erwartet hast, bitte sende eine Nachricht an max-moehring@web.de. Danke.", "From: no-reply@jg-adlershof.de")){
- echo "Wir haben deine E-Mail in der Datenbank. Eine E-Mail mit deinem neuen Passwort wurde soeben verschickt.<br>";
- } else {
- echo "Fehler mit der mail() Funktion. Bitte schick eine Benachrichtigung an <a href='mailto:max-moehring@web.de'>max-moehring@web.de</a>.";
- }
- } else {
- echo "Fataler Datenbankfehler. Schick eine Nachricht an: <a href='mailto:max-moehring@web.de'>max-moehring@web.de</a>.";
- }
-
-// exec('curl -vv --user max:sommer13 -F sender="mailer-daemon@jg-adlershof.de" -F recipient="'.$email.'" -F subject="Angefordertes neues Passwort - BITTE NICHT ANTWORTEN" -F message="Dein neues Passwort lautet: '.$secret.'." http://playground.oweissbarth.de/mail/send.php');
-
-
+ $p = "<a5>Gib deine E-Mail Adresse ein, um dir ein neues Passwort zuzuschicken.</a5><br><br>";
}
+ echo
+ $p.
+ "
+ <form action='/password_recover' method='post'>
+ <input type='text' name='email' size='30'/>
+ </form>
+ <br>
+ $startseite
+ </div>
+ </div>
+ </div>
+ ";
+ //if(mail($email, "Dein neues Passwort", "Dein neues Passwort für https://jungegemeinde.iamfabulous.de lautet: '" . $secret . "'. Wenn du diese E-Mail nicht erwartet hast, bitte sende eine Nachricht an max-moehring@web.de. Danke.", "From: no-reply@jg-adlershof.de")){
+// echo "Wir haben deine E-Mail in der Datenbank. Eine E-Mail mit deinem neuen Passwort wurde soeben verschickt.<br>";
+// } else {
+// echo "Fehler mit der mail() Funktion. Bitte schick eine Benachrichtigung an <a href='mailto:max-moehring@web.de'>max-moehring@web.de</a>.";
+// }
}
-
-?>
-<br>
-<?php echo $startseite; ?>
-</div>
-</div>
-</div>
-</body>
-</html>
-<?php
-?>
diff --git a/www/services.php b/www/services.php
new file mode 100644
index 0000000..5c24a0f
--- /dev/null
+++ b/www/services.php
@@ -0,0 +1,162 @@
+<?php
+
+function print_services(){
+
+ echo "<!doctype html>
+
+ <html>
+ <head>
+ <title>Services :: Junge Gemeinde Adlershof</title>
+ <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
+ <link rel='stylesheet' type='text/css' href='/static/hyperstyle.css' />
+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
+ </head>
+ ";
+ include("static/head.php");
+
+ echo "
+ <br><br>
+ <div class='kleineschrift'><div class='ueberschrift'><p>In eigener Sache</p></div></div>
+ <br>
+
+ <div align='center'>
+ <table width='700px'>
+ <tr><td>
+ <p>Hallo,</p>
+ </td></tr>
+ <tr><td>
+ <p>ich möchte diesen Platz hier nutzen um ein paar Projekte zu bewerben, die ich in meiner Freizeit so betreue.</p>
+ </td></tr>
+ <tr><td>
+ <p>Sie haben alle was mit Computern zu tun, natürlich. ;)</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p><b>#1</b> ist eine Website, welche dir <b>zufällige Youtube Videos</b> präsentiert.</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>Der Algorithmus ist etwas komplex, aber ich kann dir versichern, dass die Videos wirklich zufällig sind. Ausgewählt werden sie durch eine Reihe von Umgebungsvariablen, die allesamt zufällig ausgesucht sind.</p>
+ </td></tr>
+ <tr><td>
+ <p>Ich hab schon viele Stunden davor verbracht und mir die skurillsten Sachen angesehen, deswegen möchte ich die Seite gerne mit dir teilen.</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>->Link: <a href='https://random.iamfabulous.de/youtube' style='text-decoration:underline;'>https://random.iamfabulous.de/youtube</a></p>
+ </td></tr>
+ <tr><td>
+ <p style='font-size:11px'>Solltet ihr ab und zu mal einen '500er' Fehler sehen, keine Sorge. Das muss so, einfach die Seite neuladen, es ging nichts kaputt.</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p><b>#2 Der Dropbox Ersatz</b></p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ Suchst du nach einer Möglichkeit, einfach 'einen Ordner im Internet' anzulegen, über den du einfach und schnell Dateien mit jemand anderem tauschen kannst?</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>Ein Freund und ich setzen gerade ein Projekt um, dass eine Strukur wie ein Dateisystem abbildet, nur das der Zugriff komplett über das Internet erfolgt!<p>
+ </td></tr>
+ <tr><td>
+ <p>Also mit anderen Worten, du kannst Ordner anlegen, verschieben, Bilder, Filme, Musik hochladen, sie auf privat stellen oder mit deinen Freunden oder dem Rest der Welt teilen.</p>
+ </td></tr>
+ <tr><td>
+ <p>Wer einen ersten Einblick erlangen will, der kann sich zB meinen Ordner anschauen:</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>->Link: <a href='https://files.iamfabulous.de/max' style='text-decoration:underline;'>https://files.iamfabulous.de/max</a></p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p><b>#3 Der garantiert abhörsichere Chat</b></p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>Da ich im Zuge des NSA-Skandals zu dem Entschluss gekommen bin, dass ich wenigstens einen abhörsicheren Kommunikationskanal brauch, habe ich auf meinem Server zu Hause einen eigenen Chat-Server laufen.</p>
+ </td></tr>
+ <tr><td>
+ <p>Man kann sich frei verbinden, ohne Konsequenzen oder Logs, und ich biete eine garantiert abhörsicherbare Verschlüsselung an. Ich nutze den Server um täglich mit Freunden zu chatten, ohne dass irgendjemand fremdes mit liest.</p>
+ </td></tr>
+ <tr><td>
+ <p>Ihr solltet euch vor in den <a href='https://de.wikipedia.org/wiki/Internet_Relay_Chat' style='text-decoration:underline;'>Internet Relay Chat</a> einlesen.</p>
+ </td></tr>
+ <tr><td>
+ <p>Kommt vorbei, und wer weiß, vielleicht trefft ihr ja sogar tux. ;)</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>->Link: <a href='irc://irc.iamfabulous.de' style='text-decoration:underline;'>irc://irc.iamfabulous.de</a></p>
+ </td><tr>
+ <tr><td>
+ <p style='font-size:11px'>Port 9999 ist verschlüsselt. Das Zertifikat ist selber unterschrieben, dafür aber Heartbleed sicher. :)</p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p><b>#n+1 Dotfiles, bots, autonome Systeme, custom E-Mail und noch vieles mehr</b></p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>Der Platz reicht hier leider auch nicht aus, alles aufzuzählen. Aber das wichtigste sollte dabei gewesen sein.</p>
+ </td></tr>
+ <tr><td>
+ <p>Bei Fragen, Kritik, Anregungen oder Projekte, ihr kennt ja meine E-Mail.<p>
+ </td></tr>
+ <tr><td>
+ <p>Kleiner Nachtrag: Ich lizenziere so gut wie jeden Quellcode meiner Projekte unter der GPL, darunter auch der dieser Website für die JG. Wen es interessiert, was unter der Haube läuft, der findet die Sammlung auf meinem privaten Git Server. Wo ihr natürlich auch ein Repo haben könntet. ;) </p>
+ </td></tr>
+ <tr><td>
+ <br>
+ </td></tr>
+ <tr><td>
+ <p>->Link: <a href='https://git.iamfabulous.de' style='text-decoration:underline;'>https://git.iamfabulous.de</a></p>
+ </td></tr>
+
+
+ </table>
+ </div>
+ </div>
+ <br>
+ <br>
+ <br>
+ <!-- You lost the game -->
+ ";
+}
+
+
diff --git a/www/setup.php b/www/setup.php
index 2465822..3e8ca76 100644..100755
--- a/www/setup.php
+++ b/www/setup.php
@@ -1,14 +1,76 @@
-<?
-
-$db = new SQLite3("../database/database.sqlite");
-
-if($db-exec("
- BEGIN TRANSACTION;
- CREATE TABLE log (id INTEGER PRIMARY KEY, user INTEGER, login TEXT, FOREIGN KEY(user) REFERENCES user(id));
- CREATE TABLE user (id INTEGER PRIMARY KEY, name TEXT, adresse TEXT, telefonnummer TEXT, handynummer TEXT, email TEXT, geburtstag TEXT, salt TEXT, password TEXT);
- COMMIT;
- ")){
- echo "Success!";
-else{
- echo "Failure. :(";
+<?php
+
+/*
+ Sets up the database with the necessary tables. Add ?drop to drop _everything_!
+ Don't forget to create a individual pepper in ../database/pepper.txt first!
+*/
+
+$db = new SQLite3("../database/sqlite.db");
+session_start();
+
+$bool = false;
+
+if (version_compare(phpversion(), '5.5', '<')) {
+ echo "You need at least PHP version 5.5 or higher";
+ exit;
+}
+
+foreach ($_GET as $name => $value) {
+ if(preg_match("/drop(ped)?/i",$name)){
+ $bool=true;
+ }
}
+
+if($bool){
+ if(isset($_SESSION["login"])){
+ session_destroy();
+ }
+ if($db->exec("
+ BEGIN TRANSACTION;
+ DROP TRIGGER delete_files;
+ PRAGMA writable_schema = 1;
+ DELETE FROM sqlite_master WHERE type = 'table';
+ PRAGMA writable_schema = 0;
+ COMMIT;
+ VACUUM;")
+ ){
+ echo "dropped everything";
+ } else {
+ echo "error with database";
+ }
+} else {
+ $cleartext_password="password";
+ $email="admin@iamfabulous.de";
+ $pepper = file_get_contents("../database/pepper.txt");
+ if(!$pepper){
+ echo "There is no pepper in '../database/pepper.txt'! <br> Please generate one manually and run this script again.";
+ exit;
+ }
+ $password = $cleartext_password . $pepper;
+
+ $hash_password = password_hash($password, PASSWORD_DEFAULT);
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ CREATE TABLE IF NOT EXISTS user (id INTEGER PRIMARY KEY, name TEXT UNIQUE, password TEXT, email TEXT UNIQUE, status INTEGER, register INTEGER);
+ INSERT INTO user (id, name, status, password, email, register) VALUES (NULL, 'admin', 0, '" . $hash_password . "', '" . $email . "', (SELECT strftime('%s', 'now')));
+ CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY, user INTEGER, login INTEGER, FOREIGN KEY(user) REFERENCES user(id));
+ CREATE TABLE IF NOT EXISTS banned_user (id INTEGER PRIMARY KEY, ip TEXT, session_id TEXT, time INTEGER);
+ CREATE TABLE IF NOT EXISTS jg(id INTEGER PRIMARY KEY, name TEXT, adresse TEXT, telefonnummer INTEGER, handynummer INTEGER, email TEXT, geburtstag TEXT);
+ CREATE TRIGGER IF NOT EXISTS delete_files AFTER DELETE ON user FOR EACH ROW BEGIN DELETE FROM files WHERE owner=OLD.id; END;
+ COMMIT;")
+ ) {
+ $_SESSION["login"] = true;
+ $_SESSION["username"] = "admin";
+ $_SESSION["userid"] = 1;
+
+ include("include.php");
+ header("Refresh: 2; ".$scheme.$_SERVER["HTTP_HOST"]."/");
+ echo "Success! You will redirected any moment.";
+ } else {
+ echo "Failure! :( <br>";
+ echo "Your password: ".$hash_password;
+ }
+}
+// INSERT INT0 user (id, name, salt, password, status, invites, email, senpai, key) VALUES (NULL, 'admin', '$salt', '$hash_password', 1, 5, 'admin@iamfabulous.de', 0, '11111');
+
diff --git a/www/static/head.php b/www/static/head.php
new file mode 100644
index 0000000..3750d9b
--- /dev/null
+++ b/www/static/head.php
@@ -0,0 +1,52 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+
+if ($_SESSION["username"] == "jg-adlershof"){
+ $account ="<td><a href='member_login.php'>Login</a></td>
+ <td>|</td>
+ <td><a href='/register'>Register</a></td>
+ <td>|</td>
+" ;
+} else {
+ $account ="<td><a href='/account'>Account</a></td>
+ <td>|</td>
+";
+}
+
+?>
+<body link='#000000' vlink='#000000' alink='#FF0000'>
+
+<?php //include("piwik.php");?>
+
+<div class='kleineschrif'>
+
+<div id='header' class='kleineschrift'>
+ <table width='700px'><tr>
+ <td><a href='/Startseite'>Home</a></td>
+ <td>|</td>
+ <td><a href='/liste'>Adressliste</a></td>
+ <td>|</td>
+<?php /* <td><a href='/help'>Kalender</a></td>
+ <td>|</td>
+ <td><a href='/help'>Share</a></td>
+ <td>|</td>
+*/ ?>
+ <td><a href='/quote'>Zitat</a></td>
+ <td>|</td>
+ <td><a href='/to-do-list.html'>to-do</a></td>
+ <td>|</td>
+ <td><a href='/help'>Hilfe</a></td>
+ <td>|</td>
+<?php echo " $account"; ?>
+ <td><a href='/services'>Services</a></td>
+ <td>|</td>
+ <td><a href='/logout'>Logout</a></td>
+ <tr></table>
+
+ <br>
+ <hr>
+</div>
+
diff --git a/www/static/header.php b/www/static/header.php
new file mode 100644
index 0000000..33a6a7d
--- /dev/null
+++ b/www/static/header.php
@@ -0,0 +1,62 @@
+<?php
+
+/* Copyright Maximilian Möhring, 2013
+Licensed under the GPL. Read LICENSE for more Information.*/
+
+
+if ($_SESSION["username"] == "jg-adlershof"){
+ $account ="<td><a href='member_login.php'>Login</a></td>
+ <td>|</td>
+ <td><a href='/register'>Register</a></td>
+ <td>|</td>
+" ;
+} else {
+ $account ="<td><a href='/account'>Account</a></td>
+ <td>|</td>
+";
+}
+
+?>
+<!doctype html>
+
+<html>
+<head>
+ <title>Junge Gemeinde Adlershof.</title>
+ <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
+ <link rel='stylesheet' type='text/css' href='/static/hyperstyle.css' />
+ <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
+</head>
+
+<body link='#000000' vlink='#000000' alink='#FF0000'>
+
+<?php //include("piwik.php");?>
+
+<div class='kleineschrif'>
+
+<div id='header' class='kleineschrift'>
+ <table width='700px'><tr>
+ <td><a href='/Startseite'>Home</a></td>
+ <td>|</td>
+ <td><a href='/liste'>Adressliste</a></td>
+ <td>|</td>
+<?php /* <td><a href='/help'>Kalender</a></td>
+ <td>|</td>
+ <td><a href='/help'>Share</a></td>
+ <td>|</td>
+*/ ?>
+ <td><a href='/quote'>Zitat</a></td>
+ <td>|</td>
+ <td><a href='/to-do-list.html'>to-do</a></td>
+ <td>|</td>
+ <td><a href='/help'>Hilfe</a></td>
+ <td>|</td>
+<?php echo " $account"; ?>
+ <td><a href='/services'>Services</a></td>
+ <td>|</td>
+ <td><a href='/logout'>Logout</a></td>
+ <tr></table>
+
+ <br>
+ <hr>
+</div>
+
diff --git a/www/static/hyperstyle.css b/www/static/hyperstyle.css
new file mode 100644
index 0000000..74176fc
--- /dev/null
+++ b/www/static/hyperstyle.css
@@ -0,0 +1,214 @@
+/*
+This is a random mess. I'm studying Computer Science, not Art & Design.
+*/
+
+@import "/config/fonts/Muli.css";
+@import "/config/fonts/Ubuntu.css";
+
+
+* {
+margin:0;
+padding:0;
+}
+
+.noscript{
+display: none;
+}
+
+.katze {
+font-family: 'Muli';
+font-size: 120%;
+color: black;
+}
+
+.hundertfuenfzig {
+font-family: 'Muli';
+font-size: 150%;
+color: black;
+}
+
+.ueberschrift {
+font-family: 'Muli';
+font-size: 350%;
+color: black;
+text-align: center;
+}
+
+.kleineschrift {
+font-family: 'Ubuntu';
+font-size:75%;
+color: black;
+}
+
+.mittlereschrift {
+font-family: 'Ubuntu';
+font-size: 100%;
+color: black;
+}
+
+
+/*
+#footer {
+ position:fixed;
+ bottom:0px;
+}
+*/
+#content_container{
+/* padding-top:3.00em;*/
+ padding-bottom:3em;
+ padding-left:0;
+}
+/*
+#content_container {
+ height:95%;
+ overflow:auto;
+ }
+*/
+#header {
+ position:;
+ top:0px; left:0px; right:0px;
+ background:;
+ text-align:center;
+ padding:10px;
+/* color: #f0ecde;*/
+ width: 700px;
+ height: 20px;
+ margin: 0px auto;
+}
+
+html, body {
+height: 100%;
+width: 100%;
+background: #ecece1;
+}
+
+#distance {
+width: 10px;
+height: 45%;
+margin-bottom: -250px;
+float: left;
+/*background-color: #f00; nur zu Demozwecken*/
+}
+
+#container {
+margin: 0 auto;
+position: relative;
+height: 500px;
+width: 700px;
+clear: left;
+/*background-color: #ADFF2F;*/
+}
+
+#behaelter {
+margin: 0 auto;
+position: relative;
+/*height: 500px;
+width: 700px;*/
+clear: left;
+/*background-color: #ADFF2F;*/
+}
+
+#balken {
+position: relative;
+height: 10 px;
+width: 450px;
+background-color: grey;
+}
+
+#bgcolor {
+background-color: #f0ecde;
+}
+
+/*body {
+}*/
+
+a:link, a:visited {
+ /*font-family:Arial,Helvetica,sans-serif;
+ font-size: 12px;*/
+ text-decoration: none;
+/* color: #009F00;*/
+ }
+
+h1 {
+font-family: 'Muli:400';
+/*font-family: Calibri;*/
+font-size: 260%;
+color: black;
+text-align: center;
+}
+
+h2 {
+font-family: 'Muli:400';
+/*font-family: Calibri;*/
+font-size: 130%;
+color: black;
+text-align: center;
+}
+
+
+p2 {
+font-family: 'Ubuntu';
+/*font-family: Calibri;*/
+font-size: 100%;
+color: grey;
+text-align: center;
+}
+
+p3 {
+font-family: 'Ubuntu';
+/*font-family: Calibri;*/
+/*font-size: 250%;*/
+color: black;
+text-align: center;
+}
+
+p4 {
+font-family: 'Ubuntu';
+/*font-family: Calibri;*/
+font-size: 350%;
+color: black;
+text-align: center;
+}
+
+p5 {
+font-family: 'Muli';
+/*font-family: Calibri;*/
+font-size: 270%;
+color: black;
+text-align: center;
+}
+
+
+a2 {
+font-family: 'Ubuntu';
+/*font-family: 'Nobile';*/
+/*font-family: Calibri;*/
+font-size: 125%;
+color: black;
+text-align: grey;
+}
+
+a3 {
+font-family: 'Ubuntu';
+/*font-family: Calibri;*/
+font-size: 130%;
+color: black;
+text-align: grey;
+}
+
+a4 {
+font-family: 'Ubuntu';
+/*font-family: Calibri;*/
+font-size: 100%;
+color: black;
+}
+
+a5 {
+font-family: 'Ubuntu';
+font-size:75%;
+/*font-family: Calibri;*/
+color: black;
+}
+
+
+.unterstrich {text-decoration: underline;}
diff --git a/www/to-do-list.html b/www/to-do-list.html
new file mode 100644
index 0000000..f324642
--- /dev/null
+++ b/www/to-do-list.html
@@ -0,0 +1,25 @@
+TODO!!
+<br>
+<br>
+
+Wenn jemand Lust hat, sich in Webdesign zu schulen und das Design dieser Webseite aufzumöbeln, nur her damit! <br>
+Wir können sicher gemeinsam daran arbeiten.
+<br>
+<br>
+<a href='/Startseite'>Zurück zur Startseite</a>
+<!-- Piwik -->
+<script type="text/javascript">
+ var _paq = _paq || [];
+ _paq.push(["trackPageView"]);
+ _paq.push(["enableLinkTracking"]);
+
+ (function() {
+ var u=(("https:" == document.location.protocol) ? "https" : "http") + "://a.iamfabulous.de/";
+ _paq.push(["setTrackerUrl", u+"piwik.php"]);
+ _paq.push(["setSiteId", "2"]);
+ var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
+ g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
+ })();
+</script>
+<noscript><img src="https://a.iamfabulous.de/piwik.php?idsite=2&amp;rec=1" style="border:0" alt="" /></noscript>
+<!-- End Piwik Code -->
diff --git a/www/update.php b/www/update.php
index e59bf8e..04df988 100644
--- a/www/update.php
+++ b/www/update.php
@@ -1,53 +1,26 @@
<?php
-/* Copyright Maximilian Möhring, 2013
-Licensed under the GPL. Read LICENSE for more Information.*/
-
-include('auth.php');
-/*error_reporting(E_ALL);
-
-ini_set('display_errors', '1');*/
-
-$id = SQLite3::escapeString($_POST["id"]);
-$name = SQLite3::escapeString($_POST["name"]);
-$adresse = SQLite3::escapeString($_POST["adresse"]);
-$telefonnummer = SQLite3::escapeString($_POST["telefonnummer"]);
-$handynummer = SQLite3::escapeString($_POST["handynummer"]);
-$email = SQLite3::escapeString($_POST["email"]);
-$bday = SQLite3::escapeString($_POST["geburtstag"]);
-
-//echo "$name<br> $adresse<br>$telefonnummer<br>$handynummer<br>$email<br>$bday<br>$ip<br>$cryptedip";
-
-
-
-$db = new SQLite3('../database/database.sqlite');
-
-$db->exec("UPDATE member SET name='$name' where id=$id;");
-$db->exec("UPDATE member SET adresse='$adresse' where id=$id;");
-$db->exec("UPDATE member SET telefonnummer='$telefonnummer' where id=$id;");
-$db->exec("UPDATE member SET handynummer='$handynummer' where id=$id;");
-$db->exec("UPDATE member SET email='$email' where id=$id;");
-$db->exec("UPDATE member SET geburtstag='$bday' where id=$id;");
-
-/*echo "
-<!doctype html public '-//W3C//DTD XHTML 1.0 //EN'>
-
-<html>
- <head>
- <title>Junge Gemeinde Adlershof - Update erfolgreich!</title>
- <meta http-equiv='Content-type' content='text/html; charset=utf-8' />
- <link rel='stylesheet' type='text/css' href='style.css' />
- <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
- </head>
-
- <body>
-<center>
-<p5>Update erfolgreich!</p5><br><br>
-<a4>Weiterleitung in 3.. 2.. 1..</a4>
-</center></body></html>";*/
-
-header("Refresh: 0; liste.php");
-
-
-
-?>
+function update_db($db){
+
+ $id = SQLite3::escapeString($_POST["id"]);
+ $name = SQLite3::escapeString($_POST["name"]);
+ $adresse = SQLite3::escapeString($_POST["adresse"]);
+ $telefonnummer = SQLite3::escapeString($_POST["telefonnummer"]);
+ $handynummer = SQLite3::escapeString($_POST["handynummer"]);
+ $email = SQLite3::escapeString($_POST["email"]);
+ $bday = SQLite3::escapeString($_POST["geburtstag"]);
+
+ if(!preg_match("/^[0-9]+$/", $id) || !preg_match("/[0-9]+$/", $telefonnummer) || !preg_match("/^.+@.+$/", $email)){
+ return false;
+ }
+
+ if($db->exec("
+ BEGIN TRANSACTION;
+ UPDATE jg SET name='".$name."', adresse='".$adresse."', telefonnummer='".$telefonnummer."', handynummer='".$handynummer."', email='".$email."', geburtstag='".$bday."' WHERE id=".$id.";
+ COMMIT;
+ ")){
+ return true;
+ } else {
+ return false;
+ }
+}