-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.php
33 lines (25 loc) · 1.1 KB
/
create.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
<?php
session_start();
require 'defines.php';
require 'lib.php';
if(isset($_POST["organ"]) && isset($_POST["date"])) {
if (checkOrgan($_POST["organ"]) &&
checkWritePerms($_POST["organ"]) &&
checkDateRegex($_POST['date'])) {
$date = explode("/", $_POST['date']);
$filename = $date[0] . "-" . $date[1] . "-" . $date[2] . ".md";
$filenamePub = REPORTDIR . SUBPUBLISHED . $_POST['organ'] . "/" . $date[0] . "-" . $date[1] . "-" . $date[2] . ".md";
if (is_file(REPORTDIR . SUBUNPUBLISHED . $_POST['organ'] . "/" . $filename)) { // locate to edit.php
header('Location: edit.php?file='.$filename . "&organ=" . $_POST['organ']);
exit();
}
if (is_file(REPORTDIR . SUBPUBLISHED . $_POST['organ'] . "/". $filename)) {
die("Already published");
}
// Copy Template file and open editor
copy(REPORTDIR . $_POST['organ'] . ".template.md", REPORTDIR . SUBUNPUBLISHED . $_POST['organ'] . "/" . $filename);
header('Location: edit.php?file='.$filename . "&organ=" . $_POST['organ']);
exit();
}
}
?>