-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmit.php
29 lines (23 loc) · 809 Bytes
/
submit.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
<?php
require("config.php");
requireLogin();
$data = json_decode($_POST["data"], true);
$output = "";
$output .= "#" . date("M d, Y", strtotime($data["date"])) . "\n"; // TODO: Should date have leading 0?
$output .= "#" . $data["names"] . "\n";
$output .= "#" . $data["topic"] . "\n";
$output .= "\n";
foreach ($data["entries"] as $entry) {
$output .= $entry[0] . "\n" . $entry[1] . "\n";
if ($entry[2] != "") {
$output .= "[" . $entry[2] . "]\n";
}
$output .= "\n";
}
$_SESSION["submission"] = $output;
file_put_contents(FIELDNOTES_FILE, $output, FILE_APPEND | LOCK_EX);
header("Location: submission-received.php");
if (FIELDNOTES_FILE !== false && BACKUP_DIR !== false) {
copy(FIELDNOTES_FILE, BACKUP_DIR . "/" . date("Y-m-d_H.i.s") . ".txt"); // Create a backup
}
?>