forked from initrd/opsweekly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_generic_weekly.php
29 lines (26 loc) · 1.14 KB
/
add_generic_weekly.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
<?php
include_once 'phplib/base.php';
if (!db::connect()) {
echo "Database connection failed, cannot continue. ";
} else {
$timestamp = time();
$username = getUsername();
$range_start = db::escape($_POST['range_start']);
$range_end = db::escape($_POST['range_end']);
$report_id = generateWeeklyReportID($username, $range_start, $range_end);
$state = "final";
$report = db::escape($_POST['weeklyupdate']);
$query = "INSERT INTO generic_weekly (report_id, range_start, range_end, timestamp, user, state, report) VALUES ('$report_id', '$range_start', '$range_end', '$timestamp', '$username', '$state', '$report')";
if (!db::query($query)) {
echo "Database update failed, error: " . db::error();
} else {
if (isset($_POST['do_email'])) {
# The user clicked the email button so also email a copy of the report
if (sendEmailReport($username, $report, $range_start, $range_end)) {
Header("Location: {$ROOT_URL}/add.php?weekly_succ_email=hellyeah");
}
} else {
Header("Location: {$ROOT_URL}/add.php?weekly_succ=hellyeah");
}
}
}