-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22c3e16
Showing
15 changed files
with
455 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tests/UI/processed-ui-screenshots/ | ||
tests/System/processed/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\IPReports; | ||
|
||
use Piwik\Archive; | ||
use Piwik\Network\IP; | ||
use Piwik\Piwik; | ||
|
||
/** | ||
* The IP Reports API lets you access reports for your visitors IP-Addresses. | ||
* | ||
* @method static \Piwik\Plugins\IPReports\API getInstance() | ||
*/ | ||
class API extends \Piwik\Plugin\API | ||
{ | ||
public function getIPs($idSite, $period, $date, $segment = false) | ||
{ | ||
Piwik::checkUserHasViewAccess($idSite); | ||
$archive = Archive::build($idSite, $period, $date, $segment); | ||
$dataTable = $archive->getDataTable(Archiver::IPREPORTS_RECORD_NAME); | ||
$dataTable->filter('GroupBy', array('label', function($value) { | ||
return IP::fromBinaryIP($value)->toString(); | ||
})); | ||
$dataTable->queueFilter('ReplaceColumnNames'); | ||
$dataTable->queueFilter('ReplaceSummaryRowLabel'); | ||
return $dataTable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\IPReports; | ||
|
||
use Piwik\Metrics; | ||
|
||
class Archiver extends \Piwik\Plugin\Archiver | ||
{ | ||
const IPREPORTS_RECORD_NAME = 'IPReports_ips'; | ||
const IPREPORTS_FIELD = 'location_ip'; | ||
|
||
public function aggregateDayReport() | ||
{ | ||
$metrics = $this->getLogAggregator()->getMetricsFromVisitByDimension(self::IPREPORTS_FIELD)->asDataTable(); | ||
$report = $metrics->getSerialized($this->maximumRows, null, Metrics::INDEX_NB_VISITS); | ||
$this->getProcessor()->insertBlobRecord(self::IPREPORTS_RECORD_NAME, $report); | ||
} | ||
|
||
public function aggregateMultipleReports() | ||
{ | ||
$columnsAggregationOperation = null; | ||
|
||
$this->getProcessor()->aggregateDataTableRecords( | ||
array(self::IPREPORTS_RECORD_NAME), | ||
$this->maximumRows, | ||
$maximumRowsInSubDataTable = null, | ||
$columnToSortByBeforeTruncation = null, | ||
$columnsAggregationOperation, | ||
$columnsToRenameAfterAggregation = null, | ||
$countRowsRecursive = array() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\IPReports\Columns; | ||
|
||
use Piwik\Plugin\Dimension\VisitDimension; | ||
|
||
class IP extends VisitDimension | ||
{ | ||
protected $category = 'UserCountry_VisitLocation'; | ||
protected $nameSingular = 'IPReports_IP'; | ||
protected $namePlural = 'IPReports_IPs'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Piwik - Open source web analytics | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
namespace Piwik\Plugins\IPReports; | ||
|
||
use Piwik\Plugin; | ||
|
||
/** | ||
* | ||
*/ | ||
class IPReports extends Plugin | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Piwik IP Reports Plugin | ||
|
||
[![Build Status](https://travis-ci.org/sgiehl/piwik-plugin-IPReports.png?branch=master)](https://travis-ci.org/sgiehl/piwik-plugin-IPReports) [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=sgiehl&url=https://github.com/sgiehl/piwik-plugin-IPReports&title=Piwik%20Plugin%20IP%20Reports&language=&tags=github&category=software) | ||
|
||
## Description | ||
|
||
This plugin adds an additional report "Top IP-Addresses" to Piwik. | ||
|
||
### Requirements | ||
|
||
[Piwik](https://github.com/piwik/piwik) 3.0.0-b1 or higher is required. | ||
|
||
## Support | ||
|
||
Please direct any feedback to [[email protected]](mailto:[email protected]) | ||
|
||
## Contribute | ||
|
||
Feel free to create issues and pull requests. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\IPReports\Reports; | ||
|
||
use Piwik\Piwik; | ||
use Piwik\Plugin\Report; | ||
use Piwik\Plugin\ViewDataTable; | ||
use Piwik\Plugins\IPReports\Columns\IP; | ||
|
||
class GetIPs extends Report | ||
{ | ||
protected function init() | ||
{ | ||
$this->categoryId = 'General_Visitors'; | ||
$this->dimension = new IP(); | ||
$this->name = Piwik::translate('IPReports_WidgetIPs'); | ||
$this->order = 50; | ||
|
||
$this->subcategoryId = 'UserCountry_SubmenuLocations'; | ||
} | ||
|
||
public function configureView(ViewDataTable $view) | ||
{ | ||
$view->requestConfig->filter_limit = 5; | ||
$view->config->addTranslation('label', $this->dimension->getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"IPReports": { | ||
"IP": "IP-Address", | ||
"IPs": "IP-Addresses", | ||
"WidgetIPs": "Top IP-Addresses" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "IPReports", | ||
"version": "0.1.0", | ||
"description": "Adds new IP reports to Piwik.", | ||
"keywords": ["ip", "ips", "report"], | ||
"license": "GPL v3+", | ||
"homepage": "http://github.com/sgiehl/piwik-plugin-IPReports", | ||
"require": { | ||
"piwik": ">=3.0.0,<4.0.0-b1", | ||
"php": ">=5.5.0" | ||
}, | ||
"support": { | ||
"email": "[email protected]", | ||
"issues": "https://github.com/sgiehl/piwik-plugin-IPReports/issues", | ||
"source": "https://github.com/sgiehl/piwik-plugin-IPReports" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Stefan Giehl", | ||
"email": "[email protected]", | ||
"homepage": "http://github.com/sgiehl" | ||
} | ||
], | ||
"donate": { | ||
"paypal": "[email protected]", | ||
"flattr": "https://flattr.com/thing/3787742/sgiehlpiwik-plugin-IPReports-on-GitHub", | ||
"bitcoin": "1NxyWNfsjSNQULGxPVJUkgf8D3rpdJEgM6" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Plugins\IPReports\tests\Fixtures; | ||
|
||
use Piwik\Tests\Framework\Fixture; | ||
use Piwik\Date; | ||
|
||
class IPFixture extends Fixture | ||
{ | ||
public $dateTime = '2014-09-04 00:00:00'; | ||
public $idSite = 1; | ||
|
||
public function setUp() | ||
{ | ||
$this->setUpWebsite(); | ||
$this->trackVisits(); | ||
} | ||
|
||
private function setUpWebsite() | ||
{ | ||
if (!self::siteCreated($this->idSite)) { | ||
$idSite = self::createWebsite($this->dateTime); | ||
$this->assertSame($this->idSite, $idSite); | ||
} | ||
} | ||
|
||
private function getIPAddresses() { | ||
return array( | ||
'192.23.33.55', '234.6.45.44', '9.9.9.9', '4.33.44.154', | ||
'2003:f6:93bf:907:9ec7:a6ff:fe29:27de', '234.6.45.44', 'fe80::74e6:b5f3:fe92:830e', | ||
'92.34.0.87', '5.88.3.45', 'fe80:0000:0000:0000:0202:b3ff:fe1e:8329' | ||
); | ||
} | ||
|
||
private function trackVisits() { | ||
|
||
$tracker = self::getTracker( | ||
$this->idSite, | ||
$this->dateTime, | ||
$defaultInit = false | ||
); | ||
$tracker->setTokenAuth(self::getTokenAuth()); | ||
|
||
$hour = 1; | ||
foreach ($this->getIPAddresses() as $ip) { | ||
|
||
$tracker->setForceVisitDateTime( | ||
Date::factory($this->dateTime)->addHour($hour++)->getDatetime() | ||
); | ||
|
||
$tracker->setIp($ip); | ||
|
||
self::checkResponse($tracker->doTrackPageView("Viewing homepage")); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\IPReports\tests\System; | ||
|
||
|
||
use Piwik\Plugins\IPReports\tests\Fixtures\IPFixture; | ||
use Piwik\Tests\Framework\TestCase\SystemTestCase; | ||
|
||
/** | ||
* @package Piwik\Plugins\IPReports\tests | ||
* @group Plugins | ||
* @group IPReports | ||
*/ | ||
class ApiTest extends SystemTestCase { | ||
|
||
public static $fixture = null; | ||
|
||
public static function getOutputPrefix() | ||
{ | ||
return ''; | ||
} | ||
|
||
/** | ||
* @param $api | ||
* @param $params | ||
* @dataProvider getApiForTesting | ||
*/ | ||
public function testApi($api, $params) | ||
{ | ||
$this->runApiTests($api, $params); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getApiForTesting() | ||
{ | ||
$apiToCall = array( | ||
"IPReports.getIPs", | ||
); | ||
|
||
$apiToTest = array(); | ||
|
||
$apiToTest[] = array( | ||
$apiToCall, | ||
array( | ||
'idSite' => self::$fixture->idSite, | ||
'date' => self::$fixture->dateTime, | ||
'periods' => array('day') | ||
) | ||
); | ||
|
||
return $apiToTest; | ||
} | ||
|
||
|
||
public static function getPathToTestDirectory() | ||
{ | ||
return dirname(__FILE__); | ||
} | ||
|
||
} | ||
|
||
ApiTest::$fixture = new IPFixture(); |
Oops, something went wrong.