-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.php
More file actions
34 lines (30 loc) · 1.01 KB
/
Controller.php
File metadata and controls
34 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\WeatherReports;
use Piwik\Common;
use Piwik\IP;
class Controller extends \Piwik\Plugin\Controller
{
/**
* Public endpoint that returns the visitor's IP as Matomo resolves it
* (honouring proxy_client_headers / proxy_host_headers in config.ini.php).
*
* URL: /index.php?module=WeatherReports&action=getUserIp
*
* Intended as a self-hosted replacement for third-party IP lookups
* (ipapi.co etc.) when WeatherAPI's q=auto:ip cannot be used — for
* example behind a CDN where the client IP needs Matomo's proxy
* configuration to be resolved correctly.
*/
public function getUserIp()
{
Common::sendHeader('Content-Type: application/json; charset=utf-8');
Common::sendHeader('Cache-Control: no-store');
return json_encode(['ip' => IP::getIpFromHeader()]);
}
}