-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
76 lines (65 loc) · 2.02 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require_once('lib/settings.php');
require_once('lib/db.php');
require_once('lib/users.php');
require_once('lib/session.php');
require_once('lib/login.php');
require_once('lib/voc.php');
if(!connect_mysql()) {
exit();
}
include('lib/loginfilter.php');
include('lib/navbar.php');
$lastname = htmlspecialchars($_SESSION['userinfo']->lastname, 0, 'UTF-8');
if(isset($_POST['lastname'])) {
$newlastname = trim($_POST['lastname']);
if(strlen($newlastname) < 2)
setError('Dein Nachname ist ungütig!');
else {
if(setLastName($_SESSION['userid'], $newlastname)) {
$_SESSION['userinfo']->lastname = $newlastname;
setInfo('Nachname wurde gespeichert!');
} else
setError('Fehler beim speichern des Nachnamen!');
}
header("location: {$SETTINGS['url']}/settings");
exit();
}
if(isset($_POST['password']) && isset($_POST['password2'])) {
$password = $_POST['password'];
$password2 = $_POST['password2'];
if(strlen(trim($password)) < 5)
setError('Passwort zu kurz!');
else if($password != $password2)
setError('Du hast das Passwort nicht richtig wiederholt!');
else {
if(setPassword($_SESSION['userid'], $password))
setInfo('Passwort gespeichert!');
else
setError('Fehler beim speichern des Passwortes!');
}
header("location: {$SETTINGS['url']}/settings");
exit();
}
$TITLE = 'Einstellungen';
$CONTENT = <<< EOT
<h2>Einstellungen</h2>
<div class="settingsbox">
<form method="post" action="{$SETTINGS['path']}/settings">
<label for="lastname">Nachname:</label>
<input type="text" name="lastname" value="$lastname" />
<input type="submit" name="setlastname" value="Speichern" />
</form>
</div>
<div class="settingsbox">
<form method="post" action="{$SETTINGS['path']}/settings">
<label for="password">Passwort:</label>
<input type="password" name="password" value="" /><br />
<label for="password2">Passwort (Bestätigung):</label>
<input type="password" name="password2" value="" /><br />
<input type="submit" name="setpassword" value="Speichern" />
</form>
</div>
EOT;
include('lib/template.php');
exit();