. // //#################################################################### //### 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(), $periods = array() ) { global $dmarc_result; global $options; global $cookie_options; $html = array(); $html[] = ""; $html[] = ""; $html[] = " "; $html[] = " DMARC Report Viewer"; $html[] = " "; $html[] = " "; if ( $cookie_options['xml_data_hljs'] ) { $html[] = " "; $html[] = " "; } $html[] = " "; $html[] = " "; $html[] = " "; $html[] = " "; $html[] = " "; $html[] = " "; $html[] = "
"; $html[] = "
"; // Optionblock form // -------------------------------------------------------------------------- $html[] = "
"; // Host lookup option // -------------------------------------------------------------------------- $html[] = "
Hostname(s):
"; $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[] = "
DMARC 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 report ORDER BY domain "; $query = $dbh->query($sql); foreach($query as $row) { $domains[] = $row['domain']; } // Get all organisations // -------------------------------------------------------------------------- $sql = " SELECT DISTINCT org FROM 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 report ) UNION ( SELECT EXTRACT(YEAR FROM mindate) AS year, EXTRACT(MONTH FROM mindate) AS month FROM 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 ); ?>