aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/mailreport/mail_reports.inc29
-rw-r--r--config/mailreport/mail_reports_generate.php35
-rw-r--r--config/mailreport/mailreport.xml14
-rw-r--r--config/mailreport/status_mail_report.php12
-rw-r--r--config/mailreport/status_mail_report_add_cmd.php138
-rw-r--r--config/mailreport/status_mail_report_add_graph.php15
-rw-r--r--config/mailreport/status_mail_report_add_log.php166
-rw-r--r--config/mailreport/status_mail_report_edit.php126
8 files changed, 494 insertions, 41 deletions
diff --git a/config/mailreport/mail_reports.inc b/config/mailreport/mail_reports.inc
index 8ab31301..7d68055d 100644
--- a/config/mailreport/mail_reports.inc
+++ b/config/mailreport/mail_reports.inc
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+require_once("globals.inc");
require_once("config.inc");
require_once("filter.inc");
require_once("rrd.inc");
@@ -162,7 +163,7 @@ function set_mail_report_cron_jobs($a_mailreports) {
include('phpmailer/class.phpmailer.php');
-function mail_report_send($headertext, $attachments) {
+function mail_report_send($headertext, $cmdtext, $logtext, $attachments) {
global $config, $g;
if (empty($config['notifications']['smtp']['ipaddress']))
@@ -191,7 +192,11 @@ function mail_report_send($headertext, $attachments) {
$address = $config['notifications']['smtp']['notifyemailaddress'];
$mail->AddAddress($address, "Report Recipient");
$mail->Subject = "{$config['system']['hostname']}.{$config['system']['domain']} Graph Report: {$headertext}";
- $mail->Body .= "This is a periodic graph report from your firewall, {$config['system']['hostname']}.{$config['system']['domain']}.<br/><br/>Current report: {$headertext}\n";
+ $mail->Body .= "This is a periodic report from your firewall, {$config['system']['hostname']}.{$config['system']['domain']}.<br /><br />Current report: {$headertext}<br />\n<br />\n";
+ if (!empty($cmdtext))
+ $mail->Body .= $cmdtext;
+ if (!empty($logtext))
+ $mail->Body .= $logtext;
if(is_array($attachments)) {
foreach($attachments as $filename) {
$shortname = basename($filename);
@@ -1201,4 +1206,24 @@ function timeDiff($time, $opt = array()) {
return $str;
}
+function mail_report_get_log($logfile, $tail, $grepfor) {
+ global $g, $config;
+ $logfile = "{$g['varlog_path']}/{$logfile}";
+ $logarr = "";
+ $grepline = " ";
+ if(is_array($grepfor))
+ foreach($grepfor as $agrep)
+ $grepline .= " | grep \"$agrep\"";
+ if($config['system']['disablesyslogclog']) {
+ exec("cat {$logfile}{$grepline} | /usr/bin/tail -n {$tail}", $logarr);
+ } else {
+ if(isset($config['system']['usefifolog'])) {
+ exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail -n {$tail}", $logarr);
+ } else {
+ exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail -n {$tail}", $logarr);
+ }
+ }
+ return($logarr);
+}
+
?>
diff --git a/config/mailreport/mail_reports_generate.php b/config/mailreport/mail_reports_generate.php
index 7ff7b71e..81205ecb 100644
--- a/config/mailreport/mail_reports_generate.php
+++ b/config/mailreport/mail_reports_generate.php
@@ -53,17 +53,42 @@ if (!$config['mailreports']['schedule'][$id])
exit;
$thisreport = $config['mailreports']['schedule'][$id];
+$cmds = $thisreport['cmd']['row'];
+$logs = $thisreport['log']['row'];
$graphs = $thisreport['row'];
-// No graphs on the report, bail!
-if (!is_array($graphs) || !(count($graphs) > 0))
- exit;
+// If there is nothing to do, bail!
+if ((!is_array($cmds) || !(count($cmds) > 0))
+ && (!is_array($logs) || !(count($logs) > 0))
+ && (!is_array($graphs) || !(count($graphs) > 0)))
+ return;
// Print report header
+// Print command output
+$cmdtext = "";
+foreach ($cmds as $cmd) {
+ $output = "";
+ $cmdtext .= "Command output for {$cmd['descr']}<br />\n";
+ exec($cmd['detail'], $output);
+ $cmdtext .= "<pre>\n";
+ $cmdtext .= implode("\n", $output);
+ $cmdtext .= "\n</pre>";
+}
+
+// Print log output
+$logtext = "";
+foreach ($logs as $log) {
+ $lines = empty($log['lines']) ? 50 : $log['lines'];
+ $filter = empty($log['detail']) ? null : array($log['detail']);
+ $logtext .= "Log output for {$log['logfile']}<br />\n";
+ $logtext .= "<pre>\n";
+ $logtext .= implode("\n", mail_report_get_log($log['logfile'], $lines, $filter));
+ $logtext .= "\n</pre>";
+}
+
// For each graph, print a header and the graph
$attach = array();
-$idx=0;
foreach ($graphs as $thisgraph) {
$dates = get_dates($thisgraph['period'], $thisgraph['timespan']);
$start = $dates['start'];
@@ -71,6 +96,6 @@ foreach ($graphs as $thisgraph) {
$attach[] = mail_report_generate_graph($thisgraph['graph'], $thisgraph['style'], $thisgraph['timespan'], $start, $end);
}
-mail_report_send($thisreport['descr'], $attach);
+mail_report_send($thisreport['descr'], $cmdtext, $logtext, $attach);
?> \ No newline at end of file
diff --git a/config/mailreport/mailreport.xml b/config/mailreport/mailreport.xml
index 613ac42f..a437851c 100644
--- a/config/mailreport/mailreport.xml
+++ b/config/mailreport/mailreport.xml
@@ -37,7 +37,7 @@
]]>
</copyright>
<name>mailreport</name>
- <version>1.0</version>
+ <version>2.0</version>
<title>Status: Mail Reports</title>
<additional_files_needed>
<prefix>/usr/local/bin/</prefix>
@@ -70,11 +70,19 @@
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
+ <item>http://www.pfsense.com/packages/config/mailreport/status_mail_report_add_cmd.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <item>http://www.pfsense.com/packages/config/mailreport/status_mail_report_add_log.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
<item>http://www.pfsense.com/packages/config/mailreport/status_mail_report_add_graph.php</item>
</additional_files_needed>
<menu>
- <name>RRD E-Mail Reports</name>
- <tooltiptext>Setup periodic e-mail reports with RRD graphs.</tooltiptext>
+ <name>E-Mail Reports</name>
+ <tooltiptext>Setup periodic e-mail reports.</tooltiptext>
<section>Status</section>
<url>/status_mail_report.php</url>
</menu>
diff --git a/config/mailreport/status_mail_report.php b/config/mailreport/status_mail_report.php
index 4dc195bc..b1705fac 100644
--- a/config/mailreport/status_mail_report.php
+++ b/config/mailreport/status_mail_report.php
@@ -74,11 +74,13 @@ include("head.inc");
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td><div id="mainarea">
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td colspan="4">Here you can define a list of reports, containing multiple RRD graphs, to be sent by e-mail. </td></tr>
+ <tr><td colspan="4">Here you can define a list of reports to be sent by e-mail. </td></tr>
<tr><td>&nbsp;</td></tr>
<tr>
- <td width="45%" class="listhdr"><?=gettext("Description");?></td>
- <td width="35%" class="listhdr"><?=gettext("Schedule");?></td>
+ <td width="35%" class="listhdr"><?=gettext("Description");?></td>
+ <td width="25%" class="listhdr"><?=gettext("Schedule");?></td>
+ <td width="10%" class="listhdr"><?=gettext("Cmds");?></td>
+ <td width="10%" class="listhdr"><?=gettext("Logs");?></td>
<td width="10%" class="listhdr"><?=gettext("Graphs");?></td>
<td width="10%" class="list"><a href="status_mail_report_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
@@ -86,6 +88,8 @@ include("head.inc");
<tr ondblclick="document.location='status_mail_report_edit.php?id=<?=$i;?>'">
<td class="listlr"><?php echo $mailreport['descr']; ?></td>
<td class="listlr"><?php echo $mailreport['schedule_friendly']; ?></td>
+ <td class="listlr"><?php echo count($mailreport['cmd']['row']); ?></td>
+ <td class="listlr"><?php echo count($mailreport['log']['row']); ?></td>
<td class="listlr"><?php echo count($mailreport['row']); ?></td>
<td valign="middle" nowrap class="list">
<a href="status_mail_report_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
@@ -95,7 +99,7 @@ include("head.inc");
</tr>
<?php $i++; endforeach; ?>
<tr>
- <td class="list" colspan="3"></td>
+ <td class="list" colspan="5"></td>
<td class="list"><a href="status_mail_report_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
<tr>
diff --git a/config/mailreport/status_mail_report_add_cmd.php b/config/mailreport/status_mail_report_add_cmd.php
new file mode 100644
index 00000000..adbdcd77
--- /dev/null
+++ b/config/mailreport/status_mail_report_add_cmd.php
@@ -0,0 +1,138 @@
+<?php
+/* $Id$ */
+/*
+ status_rrd_graph.php
+ Part of pfSense
+ Copyright (C) 2011 Jim Pingle <jimp@pfsense.org>
+ Portions Copyright (C) 2007-2011 Seth Mos <seth.mos@dds.nl>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+/*
+ pfSense_MODULE: system
+*/
+
+##|+PRIV
+##|*IDENT=page-status-rrdgraphs
+##|*NAME=Status: RRD Graphs page
+##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
+##|*MATCH=status_rrd_graph.php*
+##|-PRIV
+
+require("guiconfig.inc");
+require_once("mail_reports.inc");
+
+$reportid = $_REQUEST['reportid'];
+$id = $_REQUEST['id'];
+
+if (!is_array($config['mailreports']['schedule']))
+ $config['mailreports']['schedule'] = array();
+
+$a_mailreports = &$config['mailreports']['schedule'];
+
+if (!isset($reportid) || !isset($a_mailreports[$reportid])) {
+ header("Location: status_mail_report.php");
+ return;
+}
+
+if (!is_array($a_mailreports[$reportid]['cmd']['row'])) {
+ $a_mailreports[$reportid]['cmd'] = array();
+ $a_mailreports[$reportid]['cmd']['row'] = array();
+}
+$a_cmds = $a_mailreports[$reportid]['cmd']['row'];
+
+if (isset($id) && $a_cmds[$id]) {
+ $pconfig = $a_cmds[$id];
+} else {
+ $pconfig = array();
+}
+
+if (isset($id) && !($a_cmds[$id])) {
+ header("Location: status_mail_report_edit.php?id={$reportid}");
+ return;
+}
+
+if ($_POST) {
+ unset($_POST['__csrf_magic']);
+ $pconfig = $_POST;
+
+ if (isset($id) && $a_cmds[$id])
+ $a_cmds[$id] = $pconfig;
+ else
+ $a_cmds[] = $pconfig;
+
+ $a_mailreports[$reportid]['cmd']['row'] = $a_cmds;
+
+ write_config();
+ header("Location: status_mail_report_edit.php?id={$reportid}");
+ return;
+}
+
+
+$pgtitle = array(gettext("Status"),gettext("Add Mail Report Command"));
+include("head.inc");
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td><div id="mainarea">
+ <form action="status_mail_report_add_cmd.php" method="post" name="iform" id="iform">
+ <table class="tabcont" width="100%" border="0" cellpadding="1" cellspacing="1">
+ <tr>
+ <td class="listtopic" colspan="2">Command Settings</td>
+ </tr>
+ <tr>
+ <td width="20%" class="listhdr">
+ <?=gettext("Name:");?>
+ </td>
+ <td width="80%" class="listhdr">
+ <input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td class="listhdr">
+ <?=gettext("Command:");?>
+ </td>
+ <td class="listhdr">
+ <input name="detail" type="text" class="formfld unknown" id="detail" size="60" value="<?=htmlspecialchars($pconfig['detail']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>">
+ <a href="status_mail_report_edit.php?id=<?php echo $reportid;?>"><input name="cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>"></a>
+ <input name="reportid" type="hidden" value="<?=htmlspecialchars($reportid);?>">
+ <?php if (isset($id) && $a_graphs[$id]): ?>
+ <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
+ <?php endif; ?>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+ </form>
+ </div></td></tr>
+</table>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/mailreport/status_mail_report_add_graph.php b/config/mailreport/status_mail_report_add_graph.php
index c0287367..165124f3 100644
--- a/config/mailreport/status_mail_report_add_graph.php
+++ b/config/mailreport/status_mail_report_add_graph.php
@@ -50,13 +50,8 @@ if(! isset($config['rrd']['enable'])) {
header("Location: status_rrd_graph_settings.php");
}
-$reportid = $_GET['reportid'];
-if (isset($_POST['reportid']))
- $reportid = $_POST['reportid'];
-
-$id = $_GET['id'];
-if (isset($_POST['id']))
- $id = $_POST['id'];
+$reportid = $_REQUEST['reportid'];
+$id = $_REQUEST['id'];
if (!is_array($config['mailreports']['schedule']))
$config['mailreports']['schedule'] = array();
@@ -65,7 +60,7 @@ $a_mailreports = &$config['mailreports']['schedule'];
if (!isset($reportid) || !isset($a_mailreports[$reportid])) {
header("Location: status_mail_report.php");
- exit;
+ return;
}
if (!is_array($a_mailreports[$reportid]['row']))
@@ -80,7 +75,7 @@ if (isset($id) && $a_graphs[$id]) {
if (isset($id) && !($a_graphs[$id])) {
header("Location: status_mail_report_edit.php?id={$reportid}");
- exit;
+ return;
}
@@ -159,7 +154,7 @@ if ($_POST) {
write_config();
header("Location: status_mail_report_edit.php?id={$reportid}");
- exit;
+ return;
}
diff --git a/config/mailreport/status_mail_report_add_log.php b/config/mailreport/status_mail_report_add_log.php
new file mode 100644
index 00000000..5a2261be
--- /dev/null
+++ b/config/mailreport/status_mail_report_add_log.php
@@ -0,0 +1,166 @@
+<?php
+/* $Id$ */
+/*
+ status_rrd_graph.php
+ Part of pfSense
+ Copyright (C) 2011 Jim Pingle <jimp@pfsense.org>
+ Portions Copyright (C) 2007-2011 Seth Mos <seth.mos@dds.nl>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+/*
+ pfSense_MODULE: system
+*/
+
+##|+PRIV
+##|*IDENT=page-status-rrdgraphs
+##|*NAME=Status: RRD Graphs page
+##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
+##|*MATCH=status_rrd_graph.php*
+##|-PRIV
+
+require("guiconfig.inc");
+require_once("mail_reports.inc");
+
+$reportid = $_REQUEST['reportid'];
+$id = $_REQUEST['id'];
+
+if (!is_array($config['mailreports']['schedule']))
+ $config['mailreports']['schedule'] = array();
+
+$a_mailreports = &$config['mailreports']['schedule'];
+
+if (!isset($reportid) || !isset($a_mailreports[$reportid])) {
+ header("Location: status_mail_report.php");
+ return;
+}
+
+if (!is_array($a_mailreports[$reportid]['log']['row'])) {
+ $a_mailreports[$reportid]['log'] = array();
+ $a_mailreports[$reportid]['log']['row'] = array();
+}
+$a_logs = $a_mailreports[$reportid]['log']['row'];
+
+if (isset($id) && $a_logs[$id]) {
+ $pconfig = $a_logs[$id];
+} else {
+ $pconfig = array();
+}
+
+if (isset($id) && !($a_logs[$id])) {
+ header("Location: status_mail_report_edit.php?id={$reportid}");
+ return;
+}
+
+
+
+
+$logpath = "/var/log/";
+chdir($logpath);
+$logfiles = glob("*.log");
+
+sort($logfiles);
+
+if ($_POST) {
+ unset($_POST['__csrf_magic']);
+ $pconfig = $_POST;
+
+ if (isset($id) && $a_logs[$id])
+ $a_logs[$id] = $pconfig;
+ else
+ $a_logs[] = $pconfig;
+
+ $a_mailreports[$reportid]['log']['row'] = $a_logs;
+
+ write_config();
+ header("Location: status_mail_report_edit.php?id={$reportid}");
+ return;
+}
+
+
+$pgtitle = array(gettext("Status"),gettext("Add Mail Report Log"));
+include("head.inc");
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr><td><div id="mainarea">
+ <form action="status_mail_report_add_log.php" method="post" name="iform" id="iform">
+ <table class="tabcont" width="100%" border="0" cellpadding="1" cellspacing="1">
+ <tr>
+ <td class="listtopic" colspan="2">Log Settings</td>
+ </tr>
+ <tr>
+ <td width="20%" class="listhdr">
+ <?=gettext("Logs:");?>
+ </td>
+ <td width="80%" class="listhdr">
+ <select name="logfile" class="formselect" style="z-index: -10;">
+ <?php
+ foreach ($logfiles as $logfile) {
+ $friendly = str_replace(".log", "", $logfile);
+ echo "<option value=\"{$logfile}\"";
+ if ($pconfig['logfile'] == $logfile) {
+ echo " selected";
+ }
+ echo ">" . htmlspecialchars($friendly) . "</option>\n";
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="20%" class="listhdr">
+ <?=gettext("# Rows:");?>
+ </td>
+ <td width="80%" class="listhdr">
+ <input name="lines" type="text" class="formfld unknown" id="lines" size="10" value="<?=htmlspecialchars($pconfig['lines']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td class="listhdr">
+ <?=gettext("Filter:");?>
+ </td>
+ <td class="listhdr">
+ <input name="detail" type="text" class="formfld unknown" id="detail" size="60" value="<?=htmlspecialchars($pconfig['detail']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>">
+ <a href="status_mail_report_edit.php?id=<?php echo $reportid;?>"><input name="cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>"></a>
+ <input name="reportid" type="hidden" value="<?=htmlspecialchars($reportid);?>">
+ <?php if (isset($id) && $a_logs[$id]): ?>
+ <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
+ <?php endif; ?>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+ </form>
+ </div></td></tr>
+</table>
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/config/mailreport/status_mail_report_edit.php b/config/mailreport/status_mail_report_edit.php
index 3102e958..c1289442 100644
--- a/config/mailreport/status_mail_report_edit.php
+++ b/config/mailreport/status_mail_report_edit.php
@@ -44,16 +44,13 @@ require_once("mail_reports.inc");
/* if the rrd graphs are not enabled redirect to settings page */
if(! isset($config['rrd']['enable'])) {
header("Location: status_rrd_graph_settings.php");
- exit;
+ return;
}
-$graphid = $_GET['graphid'];
-if (isset($_POST['graphid']))
- $graphid = $_POST['graphid'];
-
-$id = $_GET['id'];
-if (isset($_POST['id']))
- $id = $_POST['id'];
+$cmdid = $_REQUEST['cmdid'];
+$logid = $_REQUEST['logid'];
+$graphid = $_REQUEST['graphid'];
+$id = $_REQUEST['id'];
if (!is_array($config['mailreports']['schedule']))
$config['mailreports']['schedule'] = array();
@@ -63,19 +60,40 @@ if (isset($id) && $a_mailreports[$id]) {
if (!is_array($a_mailreports[$id]['row']))
$a_mailreports[$id]['row'] = array();
$pconfig = $a_mailreports[$id];
+ $a_cmds = $a_mailreports[$id]['cmd']['row'];
+ $a_logs = $a_mailreports[$id]['log']['row'];
$a_graphs = $a_mailreports[$id]['row'];
-} else {
+}
+
+if (!is_array($pconfig))
$pconfig = array();
+if (!is_array($a_cmds))
+ $a_cmds = array();
+if (!is_array($a_logs))
+ $a_logs = array();
+if (!is_array($a_graphs))
$a_graphs = array();
-}
+
if ($_GET['act'] == "del") {
- if ($a_graphs[$graphid]) {
+ if (is_numeric($cmdid) && $a_cmds[$cmdid]) {
+ unset($a_cmds[$cmdid]);
+ $a_mailreports[$id]['cmd']['row'] = $a_cmds;
+ write_config();
+ header("Location: status_mail_report_edit.php?id={$id}");
+ return;
+ } elseif (is_numeric($logid) && $a_logs[$logid]) {
+ unset($a_logs[$logid]);
+ $a_mailreports[$id]['log']['row'] = $a_logs;
+ write_config();
+ header("Location: status_mail_report_edit.php?id={$id}");
+ return;
+ } elseif (is_numeric($graphid) && $a_graphs[$graphid]) {
unset($a_graphs[$graphid]);
$a_mailreports[$id]['row'] = $a_graphs;
write_config();
header("Location: status_mail_report_edit.php?id={$id}");
- exit;
+ return;
}
}
@@ -97,7 +115,7 @@ if ($_POST) {
if ($_POST['Submit'] == "Send Now") {
mwexec_bg("/usr/local/bin/mail_reports_generate.php {$id}");
header("Location: status_mail_report_edit.php?id={$id}");
- exit;
+ return;
}
$friendly = "";
@@ -124,7 +142,9 @@ if ($_POST) {
unset($pconfig['dayofmonth']);
}
- // Copy graphs back into the schedule.
+ // Copy back into the schedule.
+ $pconfig['cmd']["row"] = $a_cmds;
+ $pconfig['log']["row"] = $a_logs;
$pconfig["row"] = $a_graphs;
$pconfig['schedule_friendly'] = $friendly;
@@ -139,7 +159,7 @@ if ($_POST) {
write_config();
configure_cron();
header("Location: status_mail_report.php");
- exit;
+ return;
}
$pgtitle = array(gettext("Status"),gettext("Edit Mail Reports"));
@@ -220,6 +240,78 @@ include("head.inc");
<td></td>
</tr>
<tr>
+ <td class="listtopic" colspan="4">Report Commands</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td width="30%" class="listhdr"><?=gettext("Name");?></td>
+ <td width="60%" colspan="3" class="listhdr"><?=gettext("Command");?></td>
+ <td width="10%" class="list">
+ <?php if (isset($id) && $a_mailreports[$id]): ?>
+ <a href="status_mail_report_add_cmd.php?reportid=<?php echo $id ;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
+ </td>
+ <?php else: ?>
+ </td>
+ <tr><td colspan="5" align="center"><br/>Save the report first, then items may be added.<br/></td></tr>
+ <?php endif; ?>
+ </tr>
+ <?php $i = 0; foreach ($a_cmds as $cmd): ?>
+ <tr ondblclick="document.location='status_mail_report_add_cmd.php?reportid=<?php echo $id ;?>&amp;id=<?=$i;?>'">
+ <td class="listlr"><?php echo htmlspecialchars($cmd['descr']); ?></td>
+ <td colspan="3" class="listlr"><?php echo htmlspecialchars($cmd['detail']); ?></td>
+ <td valign="middle" nowrap class="list">
+ <a href="status_mail_report_add_cmd.php?reportid=<?php echo $id ;?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
+ &nbsp;
+ <a href="status_mail_report_edit.php?act=del&id=<?php echo $id ;?>&cmdid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <?php if (isset($id) && $a_mailreports[$id]): ?>
+ <a href="status_mail_report_add_cmd.php?reportid=<?php echo $id ;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
+ <td class="listtopic" colspan="4">Report Logs</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td width="30%" class="listhdr"><?=gettext("Log");?></td>
+ <td width="20%" class="listhdr"><?=gettext("# Rows");?></td>
+ <td width="40%" colspan="2" class="listhdr"><?=gettext("Filter");?></td>
+ <td width="10%" class="list">
+ <?php if (isset($id) && $a_mailreports[$id]): ?>
+ <a href="status_mail_report_add_log.php?reportid=<?php echo $id ;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
+ </td>
+ <?php else: ?>
+ </td>
+ <tr><td colspan="5" align="center"><br/>Save the report first, then items may be added.<br/></td></tr>
+ <?php endif; ?>
+ </tr>
+ <?php $i = 0; foreach ($a_logs as $log): ?>
+ <tr ondblclick="document.location='status_mail_report_add_log.php?reportid=<?php echo $id ;?>&amp;id=<?=$i;?>'">
+ <td class="listlr"><?php echo $log['logfile']; ?></td>
+ <td class="listlr"><?php echo $log['lines']; ?></td>
+ <td colspan="2" class="listlr"><?php echo $log['detail']; ?></td>
+ <td valign="middle" nowrap class="list">
+ <a href="status_mail_report_add_cmd.php?reportid=<?php echo $id ;?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
+ &nbsp;
+ <a href="status_mail_report_edit.php?act=del&id=<?php echo $id ;?>&logid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <?php if (isset($id) && $a_mailreports[$id]): ?>
+ <a href="status_mail_report_add_log.php?reportid=<?php echo $id ;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr>
<td class="listtopic" colspan="4">Report Graphs</td>
<td></td>
</tr>
@@ -234,7 +326,7 @@ include("head.inc");
</td>
<?php else: ?>
</td>
- <tr><td colspan="5" align="center"><br/>Save the report first, then you may add graphs.<br/></td></tr>
+ <tr><td colspan="5" align="center"><br/>Save the report first, then items may be added.<br/></td></tr>
<?php endif; ?>
</tr>
<?php $i = 0; foreach ($a_graphs as $graph):
@@ -246,7 +338,7 @@ include("head.inc");
}
$prettyprint = ucwords(implode(" :: ", $optionc));
?>
- <tr ondblclick="document.location='status_mail_report_edit.php?id=<?=$i;?>'">
+ <tr ondblclick="document.location='status_mail_report_add_graph.php?reportid=<?php echo $id ;?>&amp;id=<?=$i;?>'">
<td class="listlr"><?php echo $prettyprint; ?></td>
<td class="listlr"><?php echo $graph['style']; ?></td>
<td class="listlr"><?php echo $graph['timespan']; ?></td>