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:
authorEduardo M KALINOWSKI <eduardo@kalinowski.com.br>2022-06-06 23:59:18 +0300
committerEduardo M KALINOWSKI <eduardo@kalinowski.com.br>2022-06-07 00:12:05 +0300
commit11c26cd58f2619f02210cb34faceb39012717d5c (patch)
tree4f9a5431f5996c7285c8518cb2e22d2c3522085c
parent90feb3a7b65b840285f0fb7ec46ff47e6480d8ec (diff)
Adjust queries so they work on PostgreSQL
-rw-r--r--dmarcts-report-viewer-report-data.php4
-rw-r--r--dmarcts-report-viewer-report-list.php4
-rw-r--r--dmarcts-report-viewer.php8
3 files changed, 11 insertions, 5 deletions
diff --git a/dmarcts-report-viewer-report-data.php b/dmarcts-report-viewer-report-data.php
index f60fc6a..09ea80e 100644
--- a/dmarcts-report-viewer-report-data.php
+++ b/dmarcts-report-viewer-report-data.php
@@ -96,6 +96,7 @@ function tmpl_reportData($reportnumber, $reports, $host_lookup = 1) {
$reportdata[] = " </thead>";
$reportdata[] = " <tbody>";
+ global $dbtype;
global $dbh;
$sql = "
@@ -138,6 +139,9 @@ ORDER BY
if ( $row['ip'] ) {
$ip = long2ip($row['ip']);
} elseif ( $row['ip6'] ) {
+ if ( $dbtype == 'pgsql') {
+ $row['ip6'] = stream_get_contents($row['ip6']);
+ }
$ip = inet_ntop($row['ip6']);
} else {
$ip = "-";
diff --git a/dmarcts-report-viewer-report-list.php b/dmarcts-report-viewer-report-list.php
index 05e5fdf..806ed8c 100644
--- a/dmarcts-report-viewer-report-list.php
+++ b/dmarcts-report-viewer-report-list.php
@@ -239,7 +239,9 @@ if( $org_select <> '' ) {
if( $per_select <> '' ) {
$ye = substr( $per_select, 0, 4) + 0;
$mo = substr( $per_select, 5, 2) + 0;
- $where .= ( $where <> '' ? " AND" : " WHERE" ) . " ((year(mindate) = $ye AND month(mindate) = $mo) OR (year(maxdate) = $ye AND month(maxdate) = $mo)) ";
+ $where .= ( $where <> '' ? " AND" : " WHERE" )
+ . " ((extract(year from mindate) = $ye AND extract(month from mindate) = $mo) "
+ . " OR (extract(year from maxdate) = $ye AND extract(month from maxdate) = $mo)) ";
}
// Include the rcount via left join, so we do not have to make an sql query
diff --git a/dmarcts-report-viewer.php b/dmarcts-report-viewer.php
index f060ec5..5730a3d 100644
--- a/dmarcts-report-viewer.php
+++ b/dmarcts-report-viewer.php
@@ -277,16 +277,16 @@ foreach($query as $row) {
$sql = "
(
SELECT
- YEAR(mindate) AS year,
- MONTH(mindate) AS month
+ EXTRACT(YEAR FROM mindate) AS year,
+ EXTRACT(MONTH FROM mindate) AS month
FROM
report
)
UNION
(
SELECT
- YEAR(maxdate) AS year,
- MONTH(maxdate) AS month
+ EXTRACT(YEAR FROM mindate) AS year,
+ EXTRACT(MONTH FROM mindate) AS month
FROM
report
)