diff options
author | pressy <bart@terta.de> | 2017-04-13 00:28:20 +0300 |
---|---|---|
committer | pressy <bart@terta.de> | 2017-04-13 00:28:20 +0300 |
commit | 64fdd8ee683fa969d87e5cc9c4c09465cba82305 (patch) | |
tree | 8560f93313bf7436297f39ecad38dd8a45dc9781 | |
parent | 64ddc06d4549c79aa7d72793d90bb7ca90817473 (diff) |
add support for deaktivation from hostlook which slow down page load.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | default.css | 10 | ||||
-rw-r--r-- | dmarcts-report-viewer-config.php.sample | 2 | ||||
-rw-r--r-- | dmarcts-report-viewer.php | 52 |
5 files changed, 51 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4522dce --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.kateproject* +dmarcts-report-viewer-config.php @@ -12,7 +12,7 @@ Download the required files: git clone https://github.com/techsneeze/dmarcts-report-viewer.git ``` -Once the php files ave been downloaded, you will need to copy `dmarcts-report-viewer-config.php.sample` to `dmarcts-report-viewer-config.php`. +Once the php files ave been downloaded, you will need to copy `dmarcts-report-viewer-config.php.sample` to `dmarcts-report-viewer-config.php`. ``` cp dmarcts-report-viewer-config.php.sample dmarcts-report-viewer-config.php @@ -25,6 +25,8 @@ $dbhost="localhost"; $dbname="dmarc"; $dbuser="dmarc"; $dbpass="xxx"; + +$default_lookup = 1; # 1= on 0=off (on is old behaviour ) ``` Ensure that `dmarcts-report-viewer-config.php`, `dmarcts-report-viewer.php`, and `default.css` are in the same folder. diff --git a/default.css b/default.css index 4e78374..fad73a9 100644 --- a/default.css +++ b/default.css @@ -26,7 +26,7 @@ table.reportlist tbody tr:first-child td { font-weight: bold;
border-top: 2px solid grey;
width: 90%;
- margin-left: auto;
+ margin-left: auto;
margin-right: auto;
}
@@ -70,6 +70,14 @@ table.reportdata tr.yellow { }
+.options {
+ font-size: 90%;
+ text-align: right;
+ border: none;
+ width: 90%;
+}
+
+
.right {
text-align:right;
}
diff --git a/dmarcts-report-viewer-config.php.sample b/dmarcts-report-viewer-config.php.sample index 565eba7..997d8ae 100644 --- a/dmarcts-report-viewer-config.php.sample +++ b/dmarcts-report-viewer-config.php.sample @@ -9,4 +9,6 @@ $dbname="dmarc"; $dbuser="dmarc"; $dbpass="xxx"; +$default_lookup = 1; # 1= on 0=off (on is old behaviour ) + ?> diff --git a/dmarcts-report-viewer.php b/dmarcts-report-viewer.php index 081eaed..6727006 100644 --- a/dmarcts-report-viewer.php +++ b/dmarcts-report-viewer.php @@ -23,7 +23,7 @@ //### configuration ################################################## //#################################################################### -// Copy dmarcts-report-viewer-config.php.sample to +// 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. @@ -36,7 +36,7 @@ function format_date($date, $format) { return $answer; }; -function tmpl_reportList($allowed_reports) { +function tmpl_reportList($allowed_reports, $host_lookup = 1) { $reportlist[] = ""; $reportlist[] = "<!-- Start of report list -->"; @@ -62,7 +62,7 @@ function tmpl_reportList($allowed_reports) { $reportlist[] = " <td class='right'>". format_date($row['maxdate'], $date_output_format). "</td>"; $reportlist[] = " <td class='center'>". $row['domain']. "</td>"; $reportlist[] = " <td class='center'>". $row['org']. "</td>"; - $reportlist[] = " <td class='center'><a href='?report=". $row['serial']. "#rpt". $row['serial']. "'>". $row['reportid']. "</a></td>"; + $reportlist[] = " <td class='center'><a href='?report=" . $row['serial'] . ( $host_lookup ? "&hostlookup=1" : "&hostlookup=0" ) . "#rpt". $row['serial'] . "'>". $row['reportid']. "</a></td>"; $reportlist[] = " <td class='center'>". $row['rcount']. "</td>"; $reportlist[] = " </tr>"; } @@ -77,7 +77,7 @@ function tmpl_reportList($allowed_reports) { return implode("\n ",$reportlist); } -function tmpl_reportData($reportnumber, $allowed_reports) { +function tmpl_reportData($reportnumber, $allowed_reports, $host_lookup = 1) { if (!$reportnumber) { return ""; @@ -135,7 +135,11 @@ function tmpl_reportData($reportnumber, $allowed_reports) { $reportdata[] = " <tr class='".$status."'>"; $reportdata[] = " <td>". $ip. "</td>"; - $reportdata[] = " <td>". gethostbyaddr($ip). "</td>"; + if ( $host_lookup ) { + $reportdata[] = " <td>". gethostbyaddr($ip). "</td>"; + } else { + $reportdata[] = " <td>#off#</td>"; + } $reportdata[] = " <td>". $row['rcount']. "</td>"; $reportdata[] = " <td>". $row['disposition']. "</td>"; $reportdata[] = " <td>". $row['reason']. "</td>"; @@ -155,8 +159,10 @@ function tmpl_reportData($reportnumber, $allowed_reports) { return implode("\n ",$reportdata); } -function tmpl_page ($body) { - $html = array(); +function tmpl_page ($body, $reportid, $host_lookup = 1) { + $html = array(); + $url_switch = ( $reportid ? "?report=$reportid&hostlookup=" : "?hostlookup=" ) + . ($host_lookup ? "0" : "1" ); $html[] = "<!DOCTYPE html>"; $html[] = "<html>"; @@ -166,6 +172,7 @@ function tmpl_page ($body) { $html[] = " </head>"; $html[] = " <body>"; + $html[] = " <div class='options'>Hostlook is " . ($host_lookup ? "on" : "off" ) . " [<a href=\"$url_switch\">" . ($host_lookup ? "off" : "on" ) . "</a>]</div>"; $html[] = $body; @@ -177,7 +184,6 @@ function tmpl_page ($body) { } - //#################################################################### //### main ########################################################### //#################################################################### @@ -186,6 +192,23 @@ function tmpl_page ($body) { // must exist. include "dmarcts-report-viewer-config.php"; + +if(isset($_GET['report']) && is_numeric($_GET['report'])){ + $reportid=$_GET['report']+0; +}elseif(!isset($_GET['report'])){ + $reportid=false; +}else{ + die('Invalid Report ID'); +} +if(isset($_GET['hostlookup']) && is_numeric($_GET['hostlookup'])){ + $hostlookup=$_GET['hostlookup']+0; +}elseif(!isset($_GET['hostlookup'])){ + $hostlookup= isset( $default_lookup ) ? $default_lookup : 1; +}else{ + die('Invalid hostlookup flag'); +} + + // Make a MySQL Connection using mysqli $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if ($mysqli->connect_errno) { @@ -215,16 +238,11 @@ while($row = $query->fetch_assoc()) { } } -if(isset($_GET['report']) && is_numeric($_GET['report'])){ - $reportid=$_GET['report']; -}elseif(!isset($_GET['report'])){ - $reportid=false; -}else{ - die('Invalid Report ID'); -} // Generate Page with report list and report data (if a report is selected). echo tmpl_page( "" - .tmpl_reportList($allowed_reports) - .tmpl_reportData($reportid, $allowed_reports ) + .tmpl_reportList($allowed_reports, $hostlookup) + .tmpl_reportData($reportid, $allowed_reports, $hostlookup ) + , $reportid + , $hostlookup ); ?> |