-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
83 lines (71 loc) · 3.46 KB
/
edit.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
77
78
79
80
81
82
83
<?php
session_start();
require 'defines.php';
require 'lib.php';
require_once 'smartydef.php';
$handle = opendir(REPORTDIR);
$smarty->assign('groups', $organs);
$smarty->assign('this', 'edit.php');
if(isset($_GET['organ']) && checkOrgan($_GET['organ'])){
$smarty->assign("read", checkReadPerms($_GET['organ']));
$smarty->assign("write", checkWritePerms($_GET['organ']));
$smarty->assign("admin", checkAdminPerms($_GET['organ']));
}
//post /get?
if(! isset($_POST['text']) && isset($_GET['file']) && isset($_GET['organ'])) { // read file
if (checkOrgan($_GET['organ'])) {
if (checkFilename($_GET['file']) && checkReadPerms($_GET['organ'])) { //input validation: get organ
$text = readFromFile($_GET['organ'], $_GET['file']);
$smarty->assign('text', $text);
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
} else if ($_GET['file'] == 'template' && checkReadPerms($_GET['organ'])) {
$smarty->assign('text', readTemplate($_GET['organ']));
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
} else if ($_GET['file'] == 'email' && checkReadPerms($_GET['organ'])) {
$smarty->assign('text', readEmailTemplate($_GET['organ']));
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
} else if ($_GET['file'] == 'resolutions.txt' && checkReadPerms($_GET['organ'])) {
$smarty->assign('text', readResolutions($_GET['organ']));
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
}
}
}
if(isset($_POST['text']) and isset($_GET['organ']) and isset($_GET['file'])) { //save changes
if (checkOrgan($_GET['organ']) and checkWritePerms($_GET['organ'])) {
if(checkFilename($_GET['file']) and checkLock($_SESSION['user'], $_GET['organ'], $_GET['file'])) {
writeIntoFile($_POST['text'], $_GET['organ'], $_GET['file'], $_SESSION['user']);
$smarty->assign('text', $_POST['text']);
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
deleteLock($_GET['organ'], $_GET['file']);
} else if(checkAdminPerms($_GET['organ'])) {
if ($_GET['file'] == "template") {
writeTemplate($_POST['text'], $_POST['organ']);
$smarty->assign('text', $_POST['text']);
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
deleteLock($_GET['organ'], $_GET['file']);
} else if ($_GET['file'] == "email") {
writeEmailTemplate($_POST['text'], $_GET['organ']);
$smarty->assign('text', $_POST['text']);
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
deleteLock($_GET['organ'], $_GET['file']);
} else if ($_GET['file'] == "resolutions.txt") {
writeResolutions($_POST['text'], $_GET['organ']);
$smarty->assign('text', $_POST['text']);
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('file', $_GET['file']);
deleteLock($_GET['organ'], $_GET['file']);
}
} else {
die('Fehler');
}
}
}
$smarty->display('edit.tpl');
?>