.
//
//####################################################################
//### configuration ##################################################
//####################################################################
// Copy dmarcts-report-viewer-config.php.sample to
// dmarcts-report-viewer-config.php and edit with the appropriate info
// for your database authentication and location.
//
// Edit the configuration variables in dmarcts-report-viewer.js with your preferences.
//
//####################################################################
//### functions ######################################################
//####################################################################
function html ($domains = array(), $orgs = array(), $dmarc_result_select = array(), $report_status_select = array(), $report_list_columns = array(), $cssfiles = array() ) {
global $dmarc_result;
global $options;
global $cookie_options;
global $html;
$html[] = "";
$html[] = "";
$html[] = "
";
$html[] = " DMARC Report Viewer ";
$html[] = " ";
$html[] = " ";
$html[] = " ";
$html[] = " ";
$html[] = " ";
$html[] = " ";
$html[] = " ";
// if ($_SERVER["REQUEST_METHOD"] == "POST") {
// $html[] = "";
// $html[] = "
";
// $html[] = "Your settings have been saved to the database. ";
// $html[] = "Return to Reports ";
// $html[] = "Return to Options ";
// $html[] = "
";
// $html[] = "
";
// $filter = "style='filter: blur(3px);opacity: 50%;'";
// }
// Note: If the above is implemented, and a blur effect behind the dialog is wanted, instead of using the $filter method, simply use backdrop-filter/-webkit-backdrop-filter on screen_overlay (see https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter)
$html[] = " DMARCTS Options
";
$html[] = " ";
$html[] = " ";
// Page Footer
// --------------------------------------------------------------------------
$html[] = " ";
$html[] = " ";
$html[] = "";
return implode("\n",$html);
}
function create_heading($option_label) {
global $html;
$html[] = " ";
$html[] = " ";
$html[] = " " . $option_label . " ";
$html[] = " ";
$html[] = " ";
}
function create_input_text($option_name, $option = array()) {
global $html;
global $cookie_options;
$extra_options = "";
$after = "";
$values = $option["option_values"];
if (isset($cookie_options[$option_name]) ) {
$value = "value='" . preg_replace("/'/", "'", $cookie_options[$option_name]). "'";
} else {
$value = "";
}
$html[] = " ";
$html[] = " ";
$html[] = " " . $option["option_label"] . " ";
$html[] = " ";
$html[] = " " . $option["option_description"] . " ";
$html[] = " ";
$html[] = " ";
switch ($option["option_type"]) {
case "number":
if ( $values['min'] != "" && $values['max'] != "" ) {
$extra_options = " min='" . $values['min'] . "' max='" . $values['max'] . "'";
}
if ( $values['units'] != "" ) {
$after = " " . $values['units'];
}
break;
default:
break;
}
$html[] = " " . $after . " ";
$html[] = " ";
$html[] = " ";
}
function create_input_radio($option_name) {
global $html;
global $options;
global $cookie_options;
$values = $options[$option_name]["option_values"];
$html[] = " ";
$html[] = " ";
$html[] = " " . $options[$option_name]["option_label"] . " ";
$html[] = " ";
$html[] = " " . $options[$option_name]["option_description"] . " ";
$html[] = " ";
$html[] = " ";
$html[] = " ";
for ($i = 0; $i < sizeof($values); $i+=2) {
$html[] = " ";
$html[] = " " . $values[$i+1] . " ";
}
$html[] = "
";
$html[] = " ";
$html[] = " ";
}
function checked($option_name, $values) {
global $options;
global $cookie_options;
$option_values = $options[$option_name]["option_values"];
if ( is_array($cookie_options[$option_name]) ) {
foreach ( $cookie_options[$option_name] as $cookie_option_value ) {
if ( $cookie_option_value == $values ) {
return " checked=\"checked\"";
}
}
} else {
if ( $cookie_options[$option_name] == $values ) {
return " checked=\"checked\"";
}
}
}
function create_select($option_name, $option = array(), $var) {
global $html;
global $cookie_options;
// $ var is the array variable, e.g. $org
$values = $option["option_values"];
$selected = "";
$js = "";
$html[] = " ";
$html[] = " ";
$html[] = " " . $option["option_label"] . " ";
$html[] = " ";
$html[] = " " . $option["option_description"] . " ";
$html[] = " ";
$html[] = " ";
if ( $option_name == "cssfile" ) {
$js = " onchange='change_stylesheet();'";
}
$html[] = " ";
foreach ($var as $key => $value) {
if ( $cookie_options[$option_name] == $key ) {
$selected = "selected";
} else {
$selected = "";
}
$html[] = " " . $value . " ";
}
$html[] = " ";
$html[] = " ";
}
//####################################################################
//### main ###########################################################
//####################################################################
// These files must exist, in the same folder as this script.
include "dmarcts-report-viewer-config.php";
include "dmarcts-report-viewer-common.php";
// Get all configuration options
// --------------------------------------------------------------------------
configure();
// Make a DB Connection
// --------------------------------------------------------------------------
$dbh = connect_db($dbtype, $dbhost, $dbport, $dbname, $dbuser, $dbpass);
// Get all css files in dmartcts directory
// --------------------------------------------------------------------------
$cssfiles = array();
$dir = dirname(__FILE__);
$scan_arr = scandir($dir);
$files_arr = array_diff($scan_arr, array('.','..') );
foreach ($files_arr as $file) {
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
if ( $file_ext=="css" ) {
$cssfiles[$file] = $file;
}
}
// Get all domains reported
// --------------------------------------------------------------------------
$sql="
SELECT
DISTINCT domain
FROM
report
ORDER BY domain";
$query = $dbh->query($sql);
$domains['all'] = "[all]";
foreach($query as $row) {
$domains[$row['domain']] = $row['domain'];
}
// Get all reporters
// --------------------------------------------------------------------------
$sql="
SELECT
DISTINCT org
FROM
report
ORDER BY org";
$i = 1;
$dmarc_result_select['all'] = "[all]";
foreach($dmarc_result as $key => $value) {
$dmarc_result_select[$key] = $value['text'];
$i++;
}
$i = 1;
$report_status_select['all'] = "[all]";
foreach($dmarc_result as $key => $value) {
$report_status_select[$key] = $value['status_text'];
$i++;
}
$query = $dbh->query($sql);
$orgs['all'] = "[all]";
foreach($query as $row) {
$orgs[$row['org']] = $row['org'];
}
// Generate Page with report list and report data (if a report is selected).
// --------------------------------------------------------------------------
echo html(
$domains,
$orgs,
$dmarc_result_select,
$report_status_select,
$report_list_columns,
$cssfiles
);
// }
?>