From 1d483520776732066020a3e6c380051f71c6401a Mon Sep 17 00:00:00 2001 From: Rich Evans <32852052+revansx@users.noreply.github.com> Date: Wed, 12 Aug 2020 12:07:34 -0400 Subject: [PATCH 1/2] Write Unique User Hit Data to file updates public function uniqueTotals with simple fopen, fwrite, and fclose commands to write the data to a local file that is readily readable off the server base url. This allows Extension:External Data to read the data in on all wikis and generate summary sand plots showing wiki usage trends across the entire server. --- SpecialWiretap.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SpecialWiretap.php b/SpecialWiretap.php index b40886e..06392b3 100644 --- a/SpecialWiretap.php +++ b/SpecialWiretap.php @@ -307,10 +307,17 @@ public function uniqueTotals ( $showUniquePageHits = false ) { $rows = $this->getUniqueRows( $showUniquePageHits, "DESC" ); + // This writes the Unique User-Hit data to a file named "UUHitsforWiki_.csv" that is accessible by browser off of the server base url. + $fp = fopen("/opt/htdocs/UUHitsforWiki_".str_replace("/","",str_replace("Special:Wiretap","",SpecialPage::getTitleFor('Wiretap')->getLocalURL())).".csv", 'w'); + fwrite($fp, "Date UUHits\n" ); + foreach($rows as $row) { $html .= "{$row['date']}{$row['hits']}"; + fwrite($fp, "{$row['date']}, {$row['hits']}\n" ); } + fclose($fp); + $html .= ""; $wgOut->addHTML( $html ); From 6ff11f2de5ff3844d82af0b78bf93e5ad3cc5684 Mon Sep 17 00:00:00 2001 From: Rich Evans <32852052+revansx@users.noreply.github.com> Date: Wed, 12 Aug 2020 12:11:04 -0400 Subject: [PATCH 2/2] Update SpecialWiretap.php --- SpecialWiretap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpecialWiretap.php b/SpecialWiretap.php index 06392b3..e57d829 100644 --- a/SpecialWiretap.php +++ b/SpecialWiretap.php @@ -309,7 +309,7 @@ public function uniqueTotals ( $showUniquePageHits = false ) { // This writes the Unique User-Hit data to a file named "UUHitsforWiki_.csv" that is accessible by browser off of the server base url. $fp = fopen("/opt/htdocs/UUHitsforWiki_".str_replace("/","",str_replace("Special:Wiretap","",SpecialPage::getTitleFor('Wiretap')->getLocalURL())).".csv", 'w'); - fwrite($fp, "Date UUHits\n" ); + fwrite($fp, "Date, UUHits\n" ); foreach($rows as $row) { $html .= "{$row['date']}{$row['hits']}";