-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
106 lines (86 loc) · 2.92 KB
/
index.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
session_start();
// put full path to Smarty.class.php
require 'defines.php';
require 'lib.php';
require_once 'permissions.config.php';
require_once 'smartydef.php'; // init $smarty var
function readDirIntoArray($folder, $endsFilter, & $arr)
{
$handle = opendir($folder);
while (false !== ($entry = readdir($handle))) {
if (endsWith($entry, $endsFilter)) {
$arr[] = $entry;
}
}
}
function getPublishedArray($folder, & $arr)
{
$tmp = array();
readDirIntoArray($folder, ".md", $tmp);
sort($tmp);
$tmp = array_reverse($tmp);
$arr = array();
foreach($tmp as $file) {
$add = array();
$add[] = $file;
if (file_exists($folder . $file . ".html")) {
$add[] = $file . ".html";
}
if (file_exists($folder . $file . ".pdf")) {
$add[] = $file . ".pdf";
}
$arr[] = $add;
}
}
$smarty->assign('organs', $organs); // include from permissions.config.php
$smarty->assign('this', 'index.php');
//post/get?
if (isset($_GET['organ']) && checkOrgan($_GET['organ'])){
if (isset($_GET['withdraw'])) {
if (checkOrgan($_GET['organ']) &&
checkAdminPerms($_GET['organ']) &&
checkFilename($_GET['report'])) {
$mdfile = $_GET['report'];
$mdpath = REPORTDIR.SUBPUBLISHED.$_GET['organ']."/" . $mdfile;
$htmlpath = $mdpath.".html";
$pdfpath = $mdpath.".pdf";
rename($mdpath, REPORTDIR . SUBUNPUBLISHED. $_GET['organ'] . "/" . $mdfile);
unlink($htmlpath);
unlink($pdfpath);
//write Email:
$sub = "Protokoll zurueckgezogen : " . $_GET["organ"] . $_GET['report'];
rlyWriteEmail($emailFrom[$_GET['organ']], 'APVEL', $emailUN[$_GET['organ']], $sub, "Begruendung folgt gleich", array());
}
} else {
//show unpublished reports?
$smarty->assign("read", checkReadPerms($_GET['organ']));
$smarty->assign("write", checkWritePerms($_GET['organ']));
$smarty->assign("admin", checkAdminPerms($_GET['organ']));
//show unpublished reports
$folderPub = REPORTDIR . SUBPUBLISHED. $_GET['organ'] . '/';
$folderUnPub = REPORTDIR . SUBUNPUBLISHED. $_GET['organ'] . '/';
if (! is_dir($folderPub)) {
die("Wrong folder structure: " . $folderPub);
}
if (! is_dir($folderUnPub)) {
die("Wrong folder structure: " . $folderUnPub);
}
$unpublishedReports = array();
$publishedReports = array();
getPublishedArray($folderPub, $publishedReports);
readDirIntoArray($folderUnPub, ".md", $unpublishedReports);
sort($unpublishedReports);
if(isset($_GET['page'])) {
$_GET['page'] = intval($_GET['page']);
} else {
$_GET['page'] = 0;
}
$smarty->assign('organ', $_GET['organ']);
$smarty->assign('unPubRep', $unpublishedReports);
$smarty->assign('page', $_GET['page']);
$smarty->assign('pubRep', $publishedReports);
}
}
$smarty->display('index.tpl');
?>