diff options
author | jim-p <jimp@pfsense.org> | 2011-07-19 17:13:47 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2011-07-19 17:13:47 -0400 |
commit | 6eb2826c34930dbda15512f1d64db00a7c7f3859 (patch) | |
tree | 9dfae4e4680cd60d62f5f94b3d17c887be798868 /config/mailreport/mail_reports_generate.php | |
parent | 45d0772b631b7cf8ca286b273f1edacd45fc234b (diff) | |
download | pfsense-packages-6eb2826c34930dbda15512f1d64db00a7c7f3859.tar.gz pfsense-packages-6eb2826c34930dbda15512f1d64db00a7c7f3859.tar.bz2 pfsense-packages-6eb2826c34930dbda15512f1d64db00a7c7f3859.zip |
Add mailreport package for periodic e-mail of RRD graphs. First rev.
Diffstat (limited to 'config/mailreport/mail_reports_generate.php')
-rw-r--r-- | config/mailreport/mail_reports_generate.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/config/mailreport/mail_reports_generate.php b/config/mailreport/mail_reports_generate.php new file mode 100644 index 00000000..7ff7b71e --- /dev/null +++ b/config/mailreport/mail_reports_generate.php @@ -0,0 +1,76 @@ +#!/usr/local/bin/php -q +<?php +/* $Id$ */ +/* + mail_reports.inc + 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. +*/ + +require_once("mail_reports.inc"); +require_once("notices.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!isset($id) && isset($argv[1])) + $id = $argv[1]; + +// No data, no report to run, bail! +if (!isset($id)) + exit; + +// No reports to run, bail! +if (!is_array($config['mailreports']['schedule'])) + exit; + +// The Requested report doesn't exist, bail! +if (!$config['mailreports']['schedule'][$id]) + exit; + +$thisreport = $config['mailreports']['schedule'][$id]; +$graphs = $thisreport['row']; + +// No graphs on the report, bail! +if (!is_array($graphs) || !(count($graphs) > 0)) + exit; + +// Print report header + +// 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']; + $end = $dates['end']; + $attach[] = mail_report_generate_graph($thisgraph['graph'], $thisgraph['style'], $thisgraph['timespan'], $start, $end); +} + +mail_report_send($thisreport['descr'], $attach); + +?>
\ No newline at end of file |