Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/techsneeze/dmarcts-report-viewer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjnew-gh <github@hazelden.ca>2021-04-14 21:50:33 +0300
committerjnew-gh <github@hazelden.ca>2021-04-14 21:50:33 +0300
commit218ecb074bdf304f8d28500c33163b089ce6a121 (patch)
tree2c927ad1c274aefed8e9ac37c3805219362ddf2e
parent850cfc98fd75c4463b6d148387a6ab36607c0e37 (diff)
Add Report Status dropdown to option block
This dropdown will filter the results in the Report List depending on the results of the individual tests for SPF/DKIM Authentication and Alignmnet and DMARC results (six results in all), corresponding to the right-hand color-coded circle. This dropdown is analogous to the current "DMARC Results" dropdown filter.
-rw-r--r--dmarcts-report-viewer-common.php22
-rw-r--r--dmarcts-report-viewer-report-list.php13
-rw-r--r--dmarcts-report-viewer.js2
-rw-r--r--dmarcts-report-viewer.php16
4 files changed, 44 insertions, 9 deletions
diff --git a/dmarcts-report-viewer-common.php b/dmarcts-report-viewer-common.php
index 03b9b83..3e6b3d2 100644
--- a/dmarcts-report-viewer-common.php
+++ b/dmarcts-report-viewer-common.php
@@ -42,24 +42,28 @@ $dmarc_result = array(
'status_text' => 'All Passed',
'color' => 'green',
'status_sort_key' => 3,
+ 'status_sql_where' => "dkim_align_min = 2 AND spf_align_min = 2 AND dkim_result_min = 2 AND spf_result_min = 2 AND dmarc_result_min = 2 AND dmarc_result_max = 2",
),
'DMARC_FAIL' => array(
'text' => 'Fail',
'status_text' => 'All Failed',
'color' => 'red',
'status_sort_key' => 0,
+ 'status_sql_where' => "dkim_align_min = 0 AND spf_align_min = 0 AND dkim_result_min = 0 AND spf_result_min = 0 AND dmarc_result_min = 0 AND dmarc_result_max = 0",
),
'DMARC_PASS_AND_FAIL' => array(
'text' => 'Mixed',
'status_text' => 'At least one failed result',
'color' => 'orange',
'status_sort_key' => 1,
+ 'status_sql_where' => "( dkim_align_min = 0 OR spf_align_min = 0 OR dkim_result_min = 0 OR spf_result_min = 0 OR dmarc_result_min = 0 OR dmarc_result_max = 0 )",
),
'DMARC_OTHER_CONDITION' => array(
'text' => 'Other',
'status_text' => 'Other condition',
'color' => 'yellow',
'status_sort_key' => 2,
+ 'status_sql_where' => "( dkim_align_min = 1 OR spf_align_min = 1 OR dkim_result_min = 1 OR spf_result_min = 1 OR dmarc_result_min >= 3 OR dmarc_result_max >= 3 )",
),
);
@@ -106,37 +110,38 @@ function get_report_status($row) {
global $dmarc_result;
$color = "";
$color_sort_key = "";
- $result_text = "";
+ $status_text = "";
+ $status_sql_where = "";
- $dmarc_status_min = min($row['dkim_align_min'],$row['spf_align_min'],$row['dkim_result_min'],$row['spf_result_min'],$row['dmarc_result_min']);
+ $report_status_min = min($row['dkim_align_min'],$row['spf_align_min'],$row['dkim_result_min'],$row['spf_result_min'],$row['dmarc_result_min']);
if ($row['dkim_align_min'] == 0 && $row['spf_align_min'] == 0 && $row['dkim_result_min'] == 0 && $row['spf_result_min'] == 0 && $row['dmarc_result_min'] == 0) {
$color = $dmarc_result['DMARC_FAIL']['color'];
$color_sort_key = $dmarc_result['DMARC_FAIL']['status_sort_key'];
- $result_text = $dmarc_result['DMARC_FAIL']['status_text'];
+ $status_text = $dmarc_result['DMARC_FAIL']['status_text'];
} else {
- switch ($dmarc_status_min) {
+ switch ($report_status_min) {
case 0:
$color = $dmarc_result['DMARC_PASS_AND_FAIL']['color'];
$color_sort_key = $dmarc_result['DMARC_PASS_AND_FAIL']['status_sort_key'];
- $result_text = $dmarc_result['DMARC_PASS_AND_FAIL']['status_text'];
+ $status_text = $dmarc_result['DMARC_PASS_AND_FAIL']['status_text'];
break;
case 1:
$color = $dmarc_result['DMARC_OTHER_CONDITION']['color'];
$color_sort_key = $dmarc_result['DMARC_OTHER_CONDITION']['status_sort_key'];
- $result_text = $dmarc_result['DMARC_OTHER_CONDITION']['status_text'];
+ $status_text = $dmarc_result['DMARC_OTHER_CONDITION']['status_text'];
break;
case 2:
$color = $dmarc_result['DMARC_PASS']['color'];
$color_sort_key = $dmarc_result['DMARC_PASS']['status_sort_key'];
- $result_text = $dmarc_result['DMARC_PASS']['status_text'];
+ $status_text = $dmarc_result['DMARC_PASS']['status_text'];
break;
default:
break;
}
}
- return array('color' => $color, 'status_sort_key' => $color_sort_key, 'status_text' => $result_text);
+ return array('color' => $color, 'status_sort_key' => $color_sort_key, 'status_text' => $status_text);
}
// This function sets variables for individual cells in the Report Data table
@@ -165,4 +170,3 @@ function format_date($date, $format) {
$answer = date($format, strtotime($date));
return $answer;
};
-
diff --git a/dmarcts-report-viewer-report-list.php b/dmarcts-report-viewer-report-list.php
index 671dcf6..82bf647 100644
--- a/dmarcts-report-viewer-report-list.php
+++ b/dmarcts-report-viewer-report-list.php
@@ -108,6 +108,7 @@ $dom_select= '';
$org_select= '';
$per_select= '';
$dmarc_select= '';
+$report_status = '';
$where = '';
// Parameters of GET
@@ -165,6 +166,12 @@ if(isset($_GET['dmarc'])){
$dmarc_select= '';
}
+if(isset($_GET['rptstat'])){
+ $report_status = $_GET['rptstat'];
+}else{
+ $report_status = '';
+}
+
// Debug
// echo "<br />D=$dom_select <br /> O=$org_select <br />";
// echo "<br />DMARC=$dmarc_select<br />";
@@ -217,6 +224,12 @@ switch ($dmarc_select) {
break;
}
+// Report Status
+// --------------------------------------------------------------------------
+if ( $report_status != "all" ) {
+ $where .= ( $where <> '' ? " AND" : " WHERE" ) . " " . $dmarc_result[$report_status]['status_sql_where'];
+}
+
// Domains
// --------------------------------------------------------------------------
if( $dom_select <> '' ) {
diff --git a/dmarcts-report-viewer.js b/dmarcts-report-viewer.js
index 89c64b1..609a22d 100644
--- a/dmarcts-report-viewer.js
+++ b/dmarcts-report-viewer.js
@@ -98,11 +98,13 @@ function showReportlist(str) { // str is the name of the <div> to be filled
var org = document.getElementById('selOrganisation').options[document.getElementById('selOrganisation').selectedIndex].value;
var period = document.getElementById('selPeriod').options[document.getElementById('selPeriod').selectedIndex].value;
var dmarc = document.getElementById('selDMARC').options[document.getElementById('selDMARC').selectedIndex].value;
+ var report_status = document.getElementById('selReportStatus').options[document.getElementById('selReportStatus').selectedIndex].value;
GETstring += "d=" + domain;
GETstring += "&o=" + org;
GETstring += "&p=" + period;
GETstring += "&dmarc=" + dmarc;
+ GETstring += "&rptstat=" + report_status;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange =
diff --git a/dmarcts-report-viewer.php b/dmarcts-report-viewer.php
index 44cae7e..05df618 100644
--- a/dmarcts-report-viewer.php
+++ b/dmarcts-report-viewer.php
@@ -82,6 +82,22 @@ function html ($default_hostlookup = 1, $default_dmarc_result = undef, $default_
$html[] = "</div>";
+ // Report Status select
+ // --------------------------------------------------------------------------
+ $html[] = "<div class='options'><span class='optionlabel'>Report Status:</span><br>";
+ $html[] = "<select name=\"ReportStatus\" id=\"selReportStatus\" onchange=\"showReportlist('reportlistTbl')\">";
+ $html[] = "<option " . ( $default_report_status ? "" : "selected=\"selected\" " ) . "value=\"all\">[all]</option>";
+ foreach($dmarc_result as $key => $value) {
+ $html[] = sprintf("<option style='color: " . $value['color'] . "' %s value=\"%s\">%s</option>",
+ $default_report_status == $key ? "selected=\"selected\"" : "",
+ $key,
+ $value['status_text'],
+ );
+ }
+ $html[] = "</select>";
+ $html[] = "</div>";
+
+
// Period select
// --------------------------------------------------------------------------
if ( count( $periods ) > 0 ) {