diff --git a/default.css b/default.css index 517b08d..2ed8f1f 100644 --- a/default.css +++ b/default.css @@ -418,6 +418,19 @@ form { display: inline-block; } +.circle_whole { + border-bottom-right-radius: 500px; + border-top-right-radius: 500px; + border-bottom-left-radius: 500px; + border-top-left-radius: 500px; + width: 14px; + height: 14px; + margin-top: 4px; + margin-bottom: 2px; + /* border-right: 0; */ + display: inline-block; +} + .circle_yellow { width: 6px; height: 12px; diff --git a/dmarcts-report-viewer-common.php b/dmarcts-report-viewer-common.php index 6d5be4c..7faa495 100644 --- a/dmarcts-report-viewer-common.php +++ b/dmarcts-report-viewer-common.php @@ -69,6 +69,32 @@ ), ); +// The order in which the options appear here is the order they appear in the TLS-RPT Report Status dropdown box +$tls_result = array( + + 'TLS_PASS' => array( + 'text' => 'Pass', + 'status_text' => 'All Passed', + 'color' => 'green', + 'status_sort_key' => 3, + 'status_sql_where' => " summary_successful > 0 AND summary_failure = 0", + ), + 'TLS_FAIL' => array( + 'text' => 'Fail', + 'status_text' => 'All Failed', + 'color' => 'red', + 'status_sort_key' => 0, + 'status_sql_where' => " summary_successful = 0 AND summary_failure > 0", + ), + 'TLS_PASS_AND_FAIL' => array( + 'text' => 'Mixed', + 'status_text' => 'Mixed result', + 'color' => 'orange', + 'status_sort_key' => 1, + 'status_sql_where' => " summary_successful > 0 AND summary_failure > 0", + ), +); + // Sortable Report List column headers // -------------------------------------------------------------------------- // Array to be used in 'Default sort column' option in dmarcts-report-viewer-options.php @@ -322,6 +348,34 @@ function get_report_status($row) { return array('color' => $color, 'status_sort_key' => $color_sort_key, 'status_text' => $status_text); } +// This function sets variables for the TLS-RPT Result in the Report List +function get_tls_result($row) { + + global $tls_result; + $color = ""; + $color_sort_key = ""; + $result_text = ""; + + if (($row['summary_successful'] == 0) && ($row['summary_failure'] > 0)) { + $color = $tls_result['TLS_FAIL']['color']; + $color_sort_key = $tls_result['TLS_FAIL']['status_sort_key']; + $result_text = $tls_result['TLS_FAIL']['text']; + } elseif (($row['summary_successful'] > 0) && ($row['summary_failure'] > 0)) { + $color = $tls_result['TLS_PASS_AND_FAIL']['color']; + $color_sort_key = $tls_result['TLS_PASS_AND_FAIL']['status_sort_key']; + $result_text = $tls_result['TLS_PASS_AND_FAIL']['text']; + } elseif (($row['summary_successful'] > 0) && ($row['summary_failure'] == 0)) { + $color = $tls_result['TLS_PASS']['color']; + $color_sort_key = $tls_result['TLS_PASS']['status_sort_key']; + $result_text = $tls_result['TLS_PASS']['text']; + } else { + $color = $tls_result['TLS_OTHER_CONDITION']['color']; + $color_sort_key = $tls_result['TLS_OTHER_CONDITION']['status_sort_key']; + $result_text = $tls_result['TLS_OTHER_CONDITION']['text']; + } + return array('color' => $color, 'status_sort_key' => $color_sort_key, 'result' => $result_text); +} + // This function sets variables for individual cells in the Report Data table function get_status_color($result) { diff --git a/dmarcts-report-viewer.js b/dmarcts-report-viewer.js index 0187f9c..becf6ca 100644 --- a/dmarcts-report-viewer.js +++ b/dmarcts-report-viewer.js @@ -59,7 +59,7 @@ function reset_report_list() { // Function to refesh the data shown in the report_list_table using the currently selected "; + $html[] = ""; + $html[] = ""; + $html[] = ""; + $html[] = ""; + $html[] = ""; + $html[] = " "; + $html[] = " "; + $html[] = " "; + $html[] = " "; + $html[] = " "; + + + // // DMARC select + // // -------------------------------------------------------------------------- + // $html[] = "
DMARC Result:
"; + // $html[] = ""; + // $html[] = "
"; + // + // + // Report Status select + // -------------------------------------------------------------------------- + $html[] = "
Report Status:
"; + $html[] = ""; + $html[] = "
"; + + + // Period select + // -------------------------------------------------------------------------- + if ( count( $periods ) > 0 ) { + $html[] = "
Month:
"; + $html[] = ""; + $html[] = "
"; + } + + + // Domains select + // -------------------------------------------------------------------------- + if ( count( $domains ) >= 1 ) { + $html[] = "
Domain(s):
"; + $html[] = ""; + $html[] = "
"; + } + + + // Organizations select + // -------------------------------------------------------------------------- + if ( count( $orgs ) > 0 ) { + $html[] = "
Reporter(s):
"; + $html[] = ""; + $html[] = "
"; + } + + // Refresh button + // -------------------------------------------------------------------------- + $html[] = "
"; + $html[] = " 
"; + $html[] = "
"; + + // Reset button + // -------------------------------------------------------------------------- + $html[] = "
"; + $html[] = " 
"; + $html[] = "
"; + + // Configuration Settings icon + // -------------------------------------------------------------------------- + $html[] = ""; + + // End optionblock + // -------------------------------------------------------------------------- + $html[] = ""; + + + // Dropdown menu + // -------------------------------------------------------------------------- + $html[] = ""; + + + // Report divs + // -------------------------------------------------------------------------- + $html[] = ""; + $html[] = "
TLS Reports
"; + $html[] = "
"; + $html[] = "
"; + $html[] = ""; + + $html[] = ""; + $html[] = "
"; + $html[] = "
"; + $html[] = ""; + + // Page Footer + // -------------------------------------------------------------------------- + $html[] = " "; + $html[] = " "; + $html[] = ""; + + return implode("\n",$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(); + +setcookie("dmarcts-options-tmp", "", time() - 3600, "/"); + +// Make a DB Connection +// -------------------------------------------------------------------------- +$dbh = connect_db($dbtype, $dbhost, $dbport, $dbname, $dbuser, $dbpass); + + +// Get all domains reported +// -------------------------------------------------------------------------- +$sql = " +SELECT DISTINCT + domain +FROM + tls_report +ORDER BY + domain +"; + +$query = $dbh->query($sql); + +foreach($query as $row) { + $domains[] = $row['domain']; +} + +// Get all organisations +// -------------------------------------------------------------------------- +$sql = " +SELECT DISTINCT + org +FROM + tls_report +ORDER BY + org +"; + +$query = $dbh->query($sql); + +foreach($query as $row) { + $orgs[] = $row['org']; +} + +// Get all periods +// -------------------------------------------------------------------------- +$sql = " +( + SELECT + EXTRACT(YEAR FROM mindate) AS year, + EXTRACT(MONTH FROM mindate) AS month + FROM + tls_report +) +UNION +( + SELECT + EXTRACT(YEAR FROM mindate) AS year, + EXTRACT(MONTH FROM mindate) AS month + FROM + tls_report +) +ORDER BY + year DESC, + month DESC +"; + +$query = $dbh->query($sql); + +foreach($query as $row) { + $periods[] = sprintf( "%'.04d-%'.02d", $row['year'], $row['month'] ); +} + +// When arrays of data do not exist, for example in a new & empty set-up, create empty arrays +// -------------------------------------------------------------------------- +if(!isset($domains)){ + $domains = array(); +} +if(!isset($orgs)){ + $orgs = array(); +} +if(!isset($periods)){ + $periods = array(); +} + +// Generate Page with report list and report data (if a report is selected). +// -------------------------------------------------------------------------- +echo html( + $domains, + $orgs, + $periods +); +?>