├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── API.php ├── CHANGELOG-v0.md ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── IPtoCompany.php ├── LICENSE ├── Libraries └── IPInfo.php ├── README.md ├── Reports ├── Base.php └── GetCompanies.php ├── SystemSettings.php ├── Tasks.php ├── Updates └── 0.2.0.php ├── UserSettings.php ├── config ├── config.php └── tracker.php ├── data └── countries.json ├── docs ├── faq.md └── index.md ├── lang ├── am.json ├── ar.json ├── be.json ├── bg.json ├── bs.json ├── ca.json ├── cs.json ├── cy.json ├── da.json ├── de.json ├── el.json ├── en.json ├── es-ar.json ├── es.json ├── et.json ├── eu.json ├── fa.json ├── fi.json ├── fr.json ├── ga.json ├── gl.json ├── he.json ├── hi.json ├── hr.json ├── hu.json ├── id.json ├── is.json ├── it.json ├── ja.json ├── ka.json ├── ko.json ├── lt.json ├── lv.json ├── nb.json ├── nl.json ├── nn.json ├── pl.json ├── pt-br.json ├── pt.json ├── ro.json ├── ru.json ├── sk.json ├── sl.json ├── sq.json ├── sr.json ├── sv.json ├── ta.json ├── te.json ├── th.json ├── tl.json ├── tr.json ├── uk.json ├── ur.json ├── vi.json ├── zh-cn.json └── zh-tw.json ├── plugin.json ├── screenshots ├── .gitkeep ├── full-view-of-the-report.png ├── list-of-ips-and-their-associated-company.png └── user-setting-subscribe-to-email-report.png └── stylesheets └── iptocompany.less /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [romain] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /API.php: -------------------------------------------------------------------------------- 1 | cacheLifeTimeForResults->getValue(); 38 | $this->cacheLifeTimeForResults = $cacheLifeTimeForResults <= 0 ? 2 : $cacheLifeTimeForResults; 39 | $this->staticContainer = $staticContainer; 40 | } 41 | 42 | /** 43 | * Returns a data table with the visits. 44 | * @param int $idSite 45 | * @param string $period 46 | * @param string $date 47 | * @param bool|string $segment 48 | * @param int $filterLimit 49 | * @return DataTable 50 | */ 51 | public function getCompanies($idSite, $period, $date, $segment = false, $filterLimit = 200) 52 | { 53 | Piwik::checkUserHasViewAccess($idSite); 54 | 55 | $logger = $this->staticContainer->getContainer()->get('Psr\Log\LoggerInterface'); 56 | 57 | $response = Request::processRequest('Live.getLastVisitsDetails', [ 58 | 'idSite' => $idSite, 59 | 'period' => $period, 60 | 'date' => $date, 61 | 'segment' => $segment, 62 | 'flat' => FALSE, 63 | 'doNotFetchActions' => FALSE, 64 | 'countVisitorsToFetch' => $filterLimit 65 | // 'token_auth' => $_ENV['AUTH_TOKEN'] 66 | ]); 67 | $response->applyQueuedFilters(); 68 | 69 | $result = $response->getEmptyClone($keepFilters = false); 70 | 71 | // Prepare an array containing the list of IP addresses to avoid multiple calls for the same IP address 72 | $ipList = []; 73 | 74 | // Get the list of IPs saved in the DB 75 | $dbList = \Piwik\API\Request::processRequest('IPtoCompany.getStoredCompanies', []); 76 | 77 | foreach ($response->getRows() as $visitRow) { 78 | $visitIp = $visitRow->getColumn('visitIp'); 79 | 80 | // try and get the row in the result DataTable for the IP 81 | $ipRow = $result->getRowFromLabel($visitIp); 82 | 83 | // Get the company name based on the IP 84 | $ipList = $this->getIPDetails($visitIp, $ipList, $dbList); 85 | $companyName = $ipList[$visitIp]; 86 | 87 | // if there is no row for this IP, create it 88 | if ($ipRow === false) { 89 | $result->addRowFromSimpleArray(array( 90 | 'IP' => $visitIp, 91 | 'company' => stripslashes($companyName), 92 | 'last_visit_time' => $visitRow->getColumn('lastActionDateTime'), 93 | 'type' => $visitRow->getColumn('visitorType'), 94 | 'nb_visits' => $visitRow->getColumn('visitCount'), 95 | 'last_visit_duration' => $visitRow->getColumn('visitDurationPretty'), 96 | 'referrer_type' => $visitRow->getColumn('referrerType'), 97 | 'referrer_name' => $visitRow->getColumn('referrerName'), 98 | 'device' => $visitRow->getColumn('deviceType'), 99 | 'country' => $visitRow->getColumn('country'), 100 | 'city' => $visitRow->getColumn('city'), 101 | )); 102 | } 103 | 104 | // if there is a row, increment the counter 105 | /*else { 106 | $counter = $ipRow->getColumn('nb_visits'); 107 | $ipRow->setColumn('nb_visits', $counter + 1); 108 | }*/ 109 | } 110 | 111 | return $result; 112 | } 113 | 114 | 115 | /** 116 | * Returns an array containing the IP and the company 117 | * @param string $period 118 | * @param string $date 119 | * @return array 120 | */ 121 | public function getStoredCompanies() 122 | { 123 | $rows = NULL; 124 | 125 | try { 126 | $rows = Db::fetchAll("SELECT * FROM " . Common::prefixTable('ip_to_company')); 127 | } catch (Exception $e) { 128 | // ignore error if table already exists (1050 code is for 'table already exists') 129 | if (!Db::get()->isErrNo($e, '1050')) { 130 | throw $e; 131 | } 132 | } 133 | 134 | return $rows; 135 | } 136 | 137 | 138 | /** 139 | * Another example method that returns a data table. 140 | * @param string $ip 141 | * @return array 142 | */ 143 | private function getIPDetails($ip, $ipList, $dbList) 144 | { 145 | $itemFound = FALSE; 146 | $companyName = NULL; 147 | $hostname = filter_var($ip, FILTER_VALIDATE_IP) ? gethostbyaddr($ip) : EMPTY_HOSTNAME; 148 | 149 | if(!isset($ipList[$ip])) { 150 | $delay = new \Datetime(); 151 | $delay->sub(new \DateInterval('P' . $this->cacheLifeTimeForResults . 'W')); 152 | 153 | // Check if the IP address exists in the DB and if the record is younger than the defined cache 154 | foreach ($dbList as $item) { 155 | $itemDate = new \Datetime($item['updated_at']); 156 | 157 | if(($item['ip'] == $ip) && ($delay <= $itemDate)) { 158 | $ipList[$ip] = $item['as_name']; 159 | $itemFound = TRUE; 160 | } 161 | elseif(($item['ip'] == $ip) && ($itemDate < $delay)) { 162 | $companyDetails = $this->getCompanyDetails($ip); 163 | $companyName = $companyDetails['as_name']; 164 | $itemFound = $companyName ? TRUE : FALSE; 165 | $ipList[$ip] = $companyName ? $companyName : ($hostname === $ip ? EMPTY_HOSTNAME : $hostname); 166 | 167 | // We update the DB only if we got results from the getCompanyDetails method. 168 | if(($ipList[$ip] != $hostname) && $companyName) { 169 | $this->updateCompanyDetails($item, [ 170 | 'as_number' => $companyDetails['as_number'], 171 | 'as_name' => $companyDetails['as_name'] 172 | ]); 173 | } 174 | } 175 | } 176 | } 177 | 178 | // If the IP doesn't exist in the DB, and if it is a valid IP, try to get the details 179 | if(!isset($ipList[$ip]) && !$itemFound && filter_var($ip, FILTER_VALIDATE_IP)) { 180 | $companyDetails = $this->getCompanyDetails($ip); 181 | $companyName = $companyDetails['as_name']; 182 | $itemFound = $companyName ? TRUE : FALSE; 183 | $ipList[$ip] = $companyName ? $companyName : ($hostname === $ip ? EMPTY_HOSTNAME : $hostname); 184 | 185 | // We insert the item in the DB only if we got results from the getCompanyDetails method. 186 | if(($ipList[$ip] != $hostname) && $companyName) { 187 | $this->insertCompanyDetails([ 188 | 'ip' => $ip, 189 | 'as_number' => $companyDetails['as_number'], 190 | 'as_name' => $companyDetails['as_name'] 191 | ]); 192 | } 193 | } 194 | 195 | // If the IP is not valid, just return the empty hostname 196 | elseif(!filter_var($ip, FILTER_VALIDATE_IP)) { 197 | $ipList[$ip] = EMPTY_HOSTNAME; 198 | } 199 | 200 | return $ipList; 201 | } 202 | 203 | 204 | /** 205 | * Another example method that returns a data table. 206 | * @param string $ip 207 | * @return array 208 | */ 209 | private function getCompanyDetails($ip) 210 | { 211 | $ipInfo = new IPInfo(); 212 | 213 | // If no token has been set, stop here. 214 | if(!$ipInfo->accessToken) { 215 | return [ 216 | "as_name" => NULL, 217 | "as_number" => NULL 218 | ]; 219 | } 220 | 221 | try { 222 | $details = $ipInfo->getDetails($ip); 223 | } catch (\Exception $e) { 224 | return [ 225 | "as_name" => NULL, 226 | "as_number" => NULL 227 | ]; 228 | } 229 | 230 | $details = json_decode($details); 231 | $companyName = NULL; 232 | $asNumber = NULL; 233 | 234 | if(isset($details->company) && isset($details->company->name)) { 235 | $companyName = $details->company->name; 236 | 237 | if($details->company->domain) { 238 | $companyName .= " (" . $details->company->domain . ")"; 239 | } 240 | } 241 | elseif(isset($details->org) && !isset($details->org->name)) { 242 | $orgElements = explode(" ", $details->org); 243 | $asNumber = array_shift($orgElements); 244 | $asName = count($orgElements) > 1 ? implode(" ", $orgElements) : $orgElements[0]; 245 | $companyName = $asName; 246 | } 247 | 248 | return [ 249 | "as_name" => $companyName, 250 | "as_number" => $asNumber 251 | ]; 252 | } 253 | 254 | /** 255 | * A private methode to update the company details that we found in the DB 256 | * @param array $item 257 | * @param array $data 258 | * @return boolean 259 | */ 260 | private function updateCompanyDetails($item, $data) 261 | { 262 | try { 263 | // If the server is running PHP 7.4.0 or newer 264 | if($this->isPHPVersionMoreRecentThan("7.4.0")) { 265 | $asName = filter_var($data['as_name'], FILTER_SANITIZE_ADD_SLASHES); 266 | } 267 | else { 268 | $asName = filter_var($data['as_name'], FILTER_SANITIZE_MAGIC_QUOTES); 269 | } 270 | 271 | $sql = "UPDATE " . Common::prefixTable('ip_to_company') . " 272 | SET as_number = '{$data['as_number']}', as_name = '{$asName}' 273 | WHERE id = {$item['id']}"; 274 | Db::exec($sql); 275 | } catch (Exception $e) { 276 | throw $e; 277 | } 278 | 279 | return TRUE; 280 | } 281 | 282 | /** 283 | * A private methode to save the company details in the DB 284 | * @param array $data 285 | * @return boolean 286 | */ 287 | private function insertCompanyDetails($data) 288 | { 289 | try { 290 | if($this->isPHPVersionMoreRecentThan("7.4.0")) { 291 | $asName = filter_var($data['as_name'], FILTER_SANITIZE_ADD_SLASHES); 292 | } 293 | else { 294 | $asName = filter_var($data['as_name'], FILTER_SANITIZE_MAGIC_QUOTES); 295 | } 296 | $sql = "INSERT INTO " . Common::prefixTable('ip_to_company') . " 297 | (ip, as_number, as_name) VALUES 298 | ('{$data['ip']}', '{$data['as_number']}', '{$asName}')"; 299 | Db::exec($sql); 300 | } catch (Exception $e) { 301 | throw $e; 302 | } 303 | 304 | return TRUE; 305 | } 306 | 307 | /** 308 | * A private methode to save the company details in the DB 309 | * @param array $data 310 | * @return boolean 311 | */ 312 | private function isPHPVersionMoreRecentThan($version) 313 | { 314 | $phpVersion = phpversion(); 315 | $phpVersionParts = explode(".", $phpVersion); 316 | $phpMinVersionParts = explode(".", $version); 317 | 318 | if((int)$phpVersionParts[0] < (int)$phpMinVersionParts[0]) { 319 | return FALSE; 320 | } 321 | elseif((int)$phpVersionParts[1] < (int)$phpMinVersionParts[1]) { 322 | return FALSE; 323 | } 324 | elseif((int)$phpVersionParts[2] < (int)$phpMinVersionParts[2]) { 325 | return FALSE; 326 | } 327 | 328 | return TRUE; 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /CHANGELOG-v0.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | ### 0.4.5 4 | 5 | *[2020-08-05]* 6 | 7 | - Merged [PR 7](https://github.com/Romain/Matomo-IP-to-Company/pull/7): German translation by [@Monschder](https://github.com/Romain/Matomo-IP-to-Company/commits?author=Monschder) 8 | 9 | ### 0.4.4 10 | 11 | *[2020-08-04]* 12 | 13 | - Merged [PR 6](https://github.com/Romain/Matomo-IP-to-Company/pull/6): Swedish translation by [@ljo](https://github.com/ljo) 14 | 15 | ### 0.4.3 16 | 17 | *[2020-06-08]* 18 | 19 | - Fixed a bug that occures when the user removes the IPinfo token. 20 | 21 | ### 0.4.2 22 | 23 | *[2020-05-20]* 24 | 25 | - Slightly change the scenario to display a dash if the IP is not valid. 26 | 27 | ### 0.4.1 28 | 29 | *[2020-05-20]* 30 | 31 | - Fixed a bug that occured when we tried to get the company details based on an IP that is not a valid IP address. 32 | 33 | ### 0.4.0 34 | 35 | *[2020-03-12]* 36 | 37 | - Creation of a parameter to set the lifetime of the cache according to the preferences of the user. 38 | 39 | ### 0.3.5 40 | ### 0.3.4 41 | 42 | *[2020-03-06]* 43 | 44 | - Bumping the version. 45 | 46 | ### 0.3.3 47 | 48 | *[2020-03-06]* 49 | 50 | - The superusers should not received the report if no user (including them) have agreed to receive it. 51 | 52 | ### 0.3.2 53 | 54 | *[2020-03-04]* 55 | 56 | - Increased the plugin version for the publication to work on the marketplace 57 | 58 | ### 0.3.1 59 | 60 | *[2020-03-04]* 61 | 62 | - Use the date of yesterday for the email report 63 | 64 | ### 0.3.0 65 | 66 | *[2020-03-03]* 67 | 68 | - Sends an email on a daily basis with the list of companies that visited the website the day before. 69 | 70 | ### 0.2.8 71 | 72 | *[2020-02-25]* 73 | 74 | - Commit the Changelog and the plugin.json with the tag 75 | 76 | ### 0.2.7 77 | 78 | *[2020-02-25]* 79 | 80 | - Conditionally apply FILTER_SANITIZE_MAGIC_QUOTES or FILTER_SANITIZE_ADD_SLASHES filters based on PHP version 81 | 82 | ### 0.2.6 83 | 84 | *[2020-01-07]* 85 | 86 | - Commit the Changelog and the plugin.json with the tag 87 | 88 | ### 0.2.5 89 | 90 | *[2020-01-07]* 91 | 92 | - Fixed the bug introduced by Matomo 1.13.1 when we gathered the visits using Live plugin API 93 | - Fixed the way we passed the data to the view (it was generating warnings) 94 | - Fixed the way we called the Exception class 95 | 96 | ### 0.2.4 97 | 98 | *[2020-01-07]* 99 | 100 | - Fixed a bug in the primary key definition in the migration 101 | 102 | ### 0.2.3 103 | 104 | *[2020-01-06]* 105 | 106 | - Update the plugin number in the JSON 107 | 108 | ### 0.2.2 109 | 110 | *[2020-01-06]* 111 | 112 | - Update the plugin number in the JSON 113 | 114 | ### 0.2.1 115 | 116 | *[2020-01-06]* 117 | 118 | - Create the table during installation and not activation. 119 | 120 | ### 0.2.0 121 | 122 | *[2020-01-06]* 123 | 124 | - Creation of an API endpoint to get the content of the table `ip_to_company`. 125 | - Cache the data gathered from IPInfo.io into the table during 1 week. 126 | - Creation of private methods to gather the content either from the table or from IPInfo.io. 127 | - Creation of a table `ip_to_company` upon activation. 128 | - Creation of a setting to store IPinfo.io access token. 129 | 130 | ### 0.1.7 131 | 132 | *[2020-01-06]* 133 | 134 | - Removed the `filter_sort_column` to avoid warnings with Matomo 3.13.1-b2. 135 | 136 | ### 0.1.6 137 | 138 | *[2020-01-02]* 139 | 140 | - Changed the default requirements 141 | 142 | ### 0.1.5 143 | 144 | *[2020-01-02]* 145 | 146 | - Rollback on the name of the plugin 147 | 148 | ### 0.1.4 149 | 150 | *[2020-01-02]* 151 | 152 | - Changed the default requirements 153 | - Changed the name of the plugin 154 | 155 | ### 0.1.3 156 | 157 | *[2020-01-02]* 158 | 159 | - Changed the default requirements 160 | 161 | ### 0.1.2 162 | 163 | *[2020-01-02]* 164 | 165 | - Fixed a bug in the plugin version in the JSON file 166 | 167 | ### 0.1.1 168 | 169 | *[2020-01-02]* 170 | 171 | - Improved the description of the plugin 172 | 173 | ### 0.1.0 174 | 175 | *[2020-01-02]* 176 | 177 | First working version of the plugin: 178 | 179 | - creation of a report in the `Visitors` tab, called `Companies` with the list of IPs that visited the website, and the company name associated 180 | - ability to add a widget to the dashboards with this report 181 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | ### 1.2.2 4 | 5 | *[2022-11-02]* 6 | 7 | - Fixing an issue in plugin.json 8 | 9 | ### 1.2.1 10 | 11 | *[2022-11-02]* 12 | 13 | - Added a donate section to the description of the plugin 14 | 15 | ### 1.2.0 16 | 17 | *[2022-05-17]* 18 | 19 | - PR #17 fixing issue #11: Translations using Weblate. Thanks to @comradekingu, @lourdas, @filhocf, @kayazeren, @sgiehl, @css31, @Findus23, raf, Ministry of Electronic Governance - Bulgaria, Taufik Adi Wicaksono and HO Gin Wang 20 | 21 | ### 1.1.0 22 | 23 | *[2022-05-17]* 24 | 25 | - PR #16 fixing issue #12: Improve performances of the schedule function by adding a $_GET parameter. 26 | 27 | ### 1.0.3 28 | 29 | *[2022-03-10]* 30 | 31 | - Required parameter $staticContainer should not follow optional parameters $settings (thanks @solracsf) 32 | 33 | ### 1.0.2 34 | 35 | *[2021-01-18]* 36 | 37 | - Catch some exceptions to avoid bugs if IPInfo encounters an error 38 | 39 | ### 1.0.1 40 | 41 | *[2020-10-14]* 42 | 43 | - Activated the pagination 44 | 45 | ### 1.0.0 46 | 47 | *[2020-10-13]* 48 | 49 | - Adapted the plugin for Matomo 4.0.0 50 | 51 | ## Previous Changelogs 52 | 53 | [v0.x](CHANGELOG-v0.md) 54 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at romain.biard@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /IPtoCompany.php: -------------------------------------------------------------------------------- 1 | isErrNo($e, '1050')) { 40 | throw $e; 41 | } 42 | } 43 | } 44 | 45 | /** 46 | * @see https://developer.matomo.org/guides/extending-database 47 | */ 48 | public function activate() 49 | { 50 | try { 51 | $sql = "CREATE TABLE " . Common::prefixTable('ip_to_company') . " ( 52 | id INTEGER NOT NULL AUTO_INCREMENT, 53 | ip VARCHAR( 15 ) NOT NULL , 54 | as_number VARCHAR( 10 ) NULL , 55 | as_name VARCHAR( 200 ) NULL , 56 | created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP , 57 | updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , 58 | PRIMARY KEY ( id ) 59 | ) DEFAULT CHARSET=utf8 "; 60 | Db::exec($sql); 61 | } catch (Exception $e) { 62 | // ignore error if table already exists (1050 code is for 'table already exists') 63 | if (!Db::get()->isErrNo($e, '1050')) { 64 | throw $e; 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * @see https://developer.matomo.org/guides/extending-database 71 | */ 72 | public function uninstall() 73 | { 74 | Db::dropTables(Common::prefixTable('ip_to_company')); 75 | } 76 | 77 | /** 78 | * @see \Piwik\Plugin::registerEvents 79 | */ 80 | public function registerEvents() 81 | { 82 | return array( 83 | //'AssetManager.getJavaScriptFiles' => 'getJsFiles', 84 | 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 85 | 'Widget.filterWidgets' => 'filterWidgets' 86 | ); 87 | } 88 | 89 | public function getStylesheetFiles(&$stylesheets) 90 | { 91 | $stylesheets[] = "plugins/IPtoCompany/stylesheets/iptocompany.less"; 92 | } 93 | 94 | /*public function getJsFiles(&$jsFiles) 95 | { 96 | $jsFiles[] = "libs/bower_components/iframe-resizer/js/iframeResizer.min.js"; 97 | 98 | $jsFiles[] = "plugins/Marketplace/angularjs/plugins/plugin-name.directive.js"; 99 | $jsFiles[] = "plugins/Marketplace/angularjs/licensekey/licensekey.controller.js"; 100 | $jsFiles[] = "plugins/Marketplace/angularjs/marketplace/marketplace.controller.js"; 101 | $jsFiles[] = "plugins/Marketplace/angularjs/marketplace/marketplace.directive.js"; 102 | }*/ 103 | 104 | /** 105 | * @param WidgetsList $list 106 | */ 107 | public function filterWidgets($list) 108 | { 109 | if (!SettingsPiwik::isInternetEnabled()) { 110 | $list->remove('IPtoCompany_Companies'); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Libraries/IPInfo.php: -------------------------------------------------------------------------------- 1 | metric->getValue(); 19 | * $settings->description->getValue(); 20 | */ 21 | class IPInfo 22 | { 23 | const API_URL = 'https://ipinfo.io'; 24 | const COUNTRIES_FILE_DEFAULT = __DIR__ . '/../data/countries.json'; 25 | const REQUEST_TYPE_GET = 'GET'; 26 | const STATUS_CODE_QUOTA_EXCEEDED = 429; 27 | 28 | public $accessToken; 29 | 30 | public function __construct($settings = []) 31 | { 32 | // Get the access token 33 | $systemSettings = new \Piwik\Plugins\IPtoCompany\SystemSettings(); 34 | $accessToken = $systemSettings->ipInfoAccessToken->getValue(); 35 | $this->accessToken = $accessToken; 36 | 37 | // Get the list of countries 38 | $countries_file = $settings['countries_file'] ?? self::COUNTRIES_FILE_DEFAULT; 39 | $this->countries = $this->readCountryNames($countries_file); 40 | } 41 | 42 | /** 43 | * Get formatted details for an IP address. 44 | * @param string|null $ip_address IP address to look up. 45 | * @return string Formatted IPinfo data as a JSON string. 46 | * @throws \Exception 47 | */ 48 | public function getDetails($ip_address = null) 49 | { 50 | try { 51 | $responseDetails = $this->getRequestDetails((string) $ip_address); 52 | } catch (\Exception $e) { 53 | throw new \Exception($e->getMessage()); 54 | } 55 | 56 | return $this->formatDetailsObject($responseDetails); 57 | } 58 | 59 | /** 60 | * Format details and return as an object. 61 | * @param array $details IP address details. 62 | * @return string Formatted IPinfo Details object as a JSON string. 63 | */ 64 | private function formatDetailsObject($details = []) 65 | { 66 | $country = $details['country'] ?? null; 67 | $details['country_name'] = $this->countries[$country] ?? null; 68 | 69 | if (array_key_exists('loc', $details)) { 70 | $coords = explode(',', $details['loc']); 71 | $details['latitude'] = $coords[0]; 72 | $details['longitude'] = $coords[1]; 73 | } else { 74 | $details['latitude'] = null; 75 | $details['longitude'] = null; 76 | } 77 | 78 | return json_encode($details); 79 | } 80 | 81 | 82 | /** 83 | * Get details for a specific IP address. 84 | * @param string $ip_address IP address to query API for. 85 | * @return array IP response data. 86 | * @throws \Exception 87 | */ 88 | private function getRequestDetails(string $ip_address) 89 | { 90 | $httpCode = 0; 91 | $response = NULL; 92 | $url = self::API_URL; 93 | 94 | if ($ip_address) { 95 | $url .= "/$ip_address"; 96 | } 97 | 98 | try { 99 | $ch = curl_init(); 100 | curl_setopt($ch, CURLOPT_URL, $url); 101 | curl_setopt($ch, CURLOPT_HTTPHEADER, $this->buildHeaders()); 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 104 | $result = curl_exec($ch); 105 | 106 | // Check if any error occurred 107 | if (!curl_errno($ch)) { 108 | $info = curl_getinfo($ch); 109 | $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 110 | } 111 | 112 | curl_close($ch); 113 | 114 | $response = json_decode($result, TRUE); 115 | } catch (\Exception $e) { 116 | throw new \Exception($e->getMessage()); 117 | } 118 | 119 | if ($httpCode == self::STATUS_CODE_QUOTA_EXCEEDED) { 120 | throw new \Exception('IPinfo request quota exceeded.'); 121 | } elseif ($httpCode >= 400) { 122 | throw new \Exception('Exception: ' . json_encode([ 123 | 'status' => $httpCode 124 | ])); 125 | } 126 | 127 | return $response; 128 | } 129 | 130 | 131 | /** 132 | * Build headers for API request. 133 | * @return array Headers for API request. 134 | */ 135 | private function buildHeaders() 136 | { 137 | $headers = [ 138 | 'user-agent' => 'MatomoIPtoCompany', 139 | 'accept' => 'application/json', 140 | ]; 141 | 142 | if ($this->accessToken) { 143 | $headers['authorization'] = "Authorization: Bearer " . $this->accessToken; 144 | } 145 | 146 | return $headers; 147 | } 148 | 149 | /** 150 | * Read country names from a file and return as an array. 151 | * @param string $countries_file JSON file of country_code => country_name mappings 152 | * @return array country_code => country_name mappings 153 | */ 154 | private function readCountryNames($countries_file) 155 | { 156 | $file_contents = file_get_contents($countries_file); 157 | return json_decode($file_contents, true); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Matomo IPtoCompany Plugin 2 | 3 | > New in version 0.3.0 4 | > - Daily email report containing the list of companies that visited your website 5 | 6 | ## Description 7 | 8 | This plugin is meant to be installed on Matomo. It provides you with the name of the company which holds the IP that visited your website. 9 | 10 | You can also use [IPInfo.io](https://ipinfo.io/) to get a more reliable result if you have an account. You will just have to set your access token in the General Parameters of Matomo. 11 | 12 | This plugin has first been developed for the needs of the company I've been working for, [Wipsim](https://www.wipsim.fr/?pk_campaign=MatomoPlugin-Link&pk_source=matomoplugin&pk_medium=matomo) 13 | 14 | ## License 15 | 16 | GPL v3 or later 17 | 18 | ## Requirements 19 | 20 | Your Matomo version should be between 3.9.0 and below 4.0.0. 21 | 22 | ## Installation 23 | 24 | Install it via Matomo Marketplace. 25 | 26 | ## Where to find the report once the plugin is activated? 27 | 28 | Once you've activated your plugin, you'll see in the `Visitors` tab of each website a new `Companies` subcategory. This is were your new report lies. 29 | 30 | You can also add this report as a widget to your dashboards. 31 | 32 | ## How reliable is this data? 33 | 34 | The collected company names are based on the PHP function `gethostbyaddr`. This function returns the name of the company provided by the proxy used by the user. 35 | 36 | Most of the big companies have their own proxy set up with a real name configured. But SMBs may not and in this case, you could see the name of their ISP appear. 37 | 38 | Therefore, this information is not 100% reliable but this is still an interesting information to check from time to time. 39 | 40 | If you have an access token set up for [IPInfo.io](https://ipinfo.io/), this plugin will use this data in the first place, before falling back to `gethostbyaddr`; 41 | 42 | ## Can I receive this report by email? 43 | 44 | Yes! As of version 0.3.0, you can receive this report by email. You just have to go to Settings > Personal Settings and check the checkbox located in the IPtoCompany section which asks you if you want to subscribe to this report. 45 | 46 | This report will then be sent to you once a day, for each site that you have access to, with the list of companies that visited your website the day before. 47 | 48 | ![How to activate the email report](https://github.com/Romain/Matomo-IP-to-Company/blob/master/screenshots/user-setting-subscribe-to-email-report.png) 49 | 50 | ## Can I define the lifetime of the cache? 51 | 52 | As of version 0.4.0, yes, you can. In the general settings section, you can set the number of weeks during which the results should be kept in cache. By default, we keep them 2 weeks, and the minimum is 1 week. 53 | -------------------------------------------------------------------------------- /Reports/Base.php: -------------------------------------------------------------------------------- 1 | categoryId = 'General_Visitors'; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Reports/GetCompanies.php: -------------------------------------------------------------------------------- 1 | name = Piwik::translate('IPtoCompany_Companies'); 31 | $this->dimension = null; 32 | $this->documentation = Piwik::translate(''); 33 | $this->subcategoryId = Piwik::translate('IPtoCompany_Companies'); 34 | 35 | // This defines in which order your report appears in the mobile app, in the menu and in the list of widgets 36 | $this->order = 26; 37 | 38 | // By default standard metrics are defined but you can customize them by defining an array of metric names 39 | $this->metrics = [ 40 | 'nb_visits' 41 | ]; 42 | 43 | $this->columns = [ 44 | 'IP', 45 | 'company', 46 | 'last_visit_time', 47 | 'type', 48 | 'nb_visits', 49 | 'last_visit_duration', 50 | 'referrer_type', 51 | 'referrer_name', 52 | 'device', 53 | 'country', 54 | 'city' 55 | ]; 56 | 57 | // Uncomment the next line if your report does not contain any processed metrics, otherwise default 58 | // processed metrics will be assigned 59 | // $this->processedMetrics = array(); 60 | 61 | // Uncomment the next line if your report defines goal metrics 62 | // $this->hasGoalMetrics = true; 63 | 64 | // Uncomment the next line if your report should be able to load subtables. You can define any action here 65 | // $this->actionToLoadSubTables = $this->action; 66 | 67 | // Uncomment the next line if your report always returns a constant count of rows, for instance always 68 | // 24 rows for 1-24hours 69 | // $this->constantRowsCount = true; 70 | 71 | // If a subcategory is specified, the report will be displayed in the menu under this menu item 72 | // $this->subcategoryId = 'IPtoCompany_Foo'; 73 | } 74 | 75 | /** 76 | * Here you can configure how your report should be displayed. For instance whether your report supports a search 77 | * etc. You can also change the default request config. For instance change how many rows are displayed by default. 78 | * 79 | * @param ViewDataTable $view 80 | */ 81 | public function configureView(ViewDataTable $view) 82 | { 83 | if (!empty($this->dimension)) { 84 | $view->config->addTranslations(array('label' => $this->dimension->getName())); 85 | } 86 | 87 | $view->config->show_search = true; 88 | $view->config->show_pagination_control = true; 89 | $view->config->show_limit_control = true; 90 | $view->config->show_periods = true; 91 | $view->config->show_bar_chart = false; 92 | $view->config->show_pie_chart = false; 93 | $view->config->show_tag_cloud = false; 94 | // $view->requestConfig->filter_sort_column = 'nb_visits'; 95 | // $view->requestConfig->filter_limit = 10'; 96 | 97 | $view->config->addTranslation('company', Piwik::translate('IPtoCompany_Company')); 98 | $view->config->addTranslation('last_visit_time', Piwik::translate('IPtoCompany_LastVisit')); 99 | $view->config->addTranslation('type', Piwik::translate('IPtoCompany_Type')); 100 | $view->config->addTranslation('nb_visits', Piwik::translate('IPtoCompany_NumberOfVisits')); 101 | $view->config->addTranslation('last_visit_duration', Piwik::translate('IPtoCompany_LastVisitDuration')); 102 | $view->config->addTranslation('referrer_type', Piwik::translate('IPtoCompany_ReferrerType')); 103 | $view->config->addTranslation('referrer_name', Piwik::translate('IPtoCompany_ReferrerName')); 104 | $view->config->addTranslation('device', Piwik::translate('IPtoCompany_Device')); 105 | $view->config->addTranslation('country', Piwik::translate('IPtoCompany_Country')); 106 | $view->config->addTranslation('city', Piwik::translate('IPtoCompany_City')); 107 | 108 | $view->config->columns_to_display = $this->columns; 109 | } 110 | 111 | /** 112 | * Here you can define related reports that will be shown below the reports. Just return an array of related 113 | * report instances if there are any. 114 | * 115 | * @return \Piwik\Plugin\Report[] 116 | */ 117 | public function getRelatedReports() 118 | { 119 | return array(); // eg return array(new XyzReport()); 120 | } 121 | 122 | /** 123 | * Here we define a method to be able to create a widget with this report. 124 | */ 125 | public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) 126 | { 127 | // we have to do it manually since it's only done automatically if a subcategoryId is specified, 128 | // we do not set a subcategoryId since this report is not supposed to be shown in the UI 129 | $widgetsList->addWidgetConfig($factory->createWidget()); 130 | } 131 | 132 | /** 133 | * A report is usually completely automatically rendered for you but you can render the report completely 134 | * customized if you wish. Just overwrite the method and make sure to return a string containing the content of the 135 | * report. Don't forget to create the defined twig template within the templates folder of your plugin in order to 136 | * make it work. Usually you should NOT have to overwrite this render method. 137 | * 138 | * @return string 139 | * public function render() 140 | * { 141 | * $view = new View('@IPtoCompany/showCompanies'); 142 | * $view->myData = array(); 143 | * 144 | * return $view->render(); 145 | * } 146 | */ 147 | 148 | /** 149 | * By default your report is available to all users having at least view access. If you do not want this, you can 150 | * limit the audience by overwriting this method. 151 | * 152 | * @return bool 153 | * public function isEnabled() 154 | * { 155 | * return Piwik::hasUserSuperUserAccess() 156 | * } 157 | */ 158 | } 159 | -------------------------------------------------------------------------------- /SystemSettings.php: -------------------------------------------------------------------------------- 1 | metric->getValue(); 22 | * $settings->description->getValue(); 23 | */ 24 | class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings 25 | { 26 | /** @var Setting */ 27 | public $ipInfoAccessToken; 28 | 29 | /** @var Setting */ 30 | public $cacheLifeTimeForResults; 31 | 32 | protected function init() 33 | { 34 | // Create a setting to store the IPInfo API token 35 | $this->ipInfoAccessToken = $this->createIpInfoAccessTokenSetting(); 36 | $this->cacheLifeTimeForResults = $this->createCacheLifeTimeForResultsSetting(); 37 | } 38 | 39 | private function createIpInfoAccessTokenSetting() 40 | { 41 | return $this->makeSetting('ipInfoAccessToken', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) { 42 | $field->title = Piwik::translate('IPtoCompany_YourIPInfoAccessToken'); 43 | $field->uiControl = FieldConfig::UI_CONTROL_TEXT; 44 | $field->description = Piwik::translate('IPtoCompany_PasteYourAccessToken'); 45 | // $field->validators[] = new NotEmpty(); 46 | }); 47 | } 48 | 49 | private function createCacheLifeTimeForResultsSetting() 50 | { 51 | return $this->makeSetting('cacheLifeTimeForResults', $default = 2, FieldConfig::TYPE_INT, function (FieldConfig $field) { 52 | $field->title = Piwik::translate('IPtoCompany_LifeTimeOfCacheForResultsInWeeks'); 53 | $field->uiControl = FieldConfig::UI_CONTROL_TEXT; 54 | $field->description = Piwik::translate('IPtoCompany_PasteYourAccessToken'); 55 | // $field->validators[] = new NotEmpty(); 56 | }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Tasks.php: -------------------------------------------------------------------------------- 1 | staticContainer = $staticContainer; 24 | } 25 | 26 | public function schedule() 27 | { 28 | foreach (\Piwik\Site::getSites() as $site) { 29 | // Foreach website, send a report by email to each user allowed to get stats of the concerned website 30 | $this->daily('getListOfCompaniesThatVisitedWebsiteYesterday', $site['idsite']); 31 | } 32 | } 33 | 34 | public function getListOfCompaniesThatVisitedWebsiteYesterday($siteId) 35 | { 36 | $logger = $this->staticContainer->getContainer()->get('Psr\Log\LoggerInterface'); 37 | $siteName = Site::getNameFor($siteId); 38 | $recipients = $this->getAllUsersEmailsForSite($siteId); 39 | $superUsers = $this->getSuperUsersEmails(); 40 | 41 | $companies = \Piwik\API\Request::processRequest('IPtoCompany.getCompanies', [ 42 | 'idSite' => $siteId, 43 | 'period' => 'day', 44 | // 'date' => '2019-12-17' 45 | 'date' => 'yesterday', 46 | 'trigger' => 'archivephp' 47 | ]); 48 | 49 | // Generate the HTML 50 | $html = $this->convertCompaniesDataTableToHTML($companies); 51 | 52 | if(!empty($superUsers) && !empty($recipients)) { 53 | $mail = new \Piwik\Mail(); 54 | $mail->setFrom($superUsers[0]); 55 | $mail->setReplyTo($superUsers[0]); 56 | $logger->info("IPtoCompany: Email sent from ".$superUsers[0]." for ".$siteName); 57 | 58 | foreach ($recipients as $recipient) { 59 | $mail->addTo($recipient); 60 | $logger->info("IPtoCompany: Email sent to ".$recipient." for ".$siteName); 61 | } 62 | 63 | $mail->setSubject( Piwik::translate('IPtoCompany_CompaniesReportSubject', $siteName) ); 64 | 65 | try { 66 | $mail->setWrappedHtmlBody($html); 67 | } catch (Exception $e) { 68 | $logger->error("IPtoCompany: An error occured while sending the email: ".$e->message()); 69 | throw $e; 70 | } 71 | 72 | $mail->send(); 73 | } 74 | 75 | return; 76 | } 77 | 78 | /** 79 | * For the supplied website, get the emails of the users that have view access. 80 | * 81 | * @param string the site ID 82 | * 83 | * @return array The returned array has the format 84 | * array(email1, email2, ...) 85 | */ 86 | private function getAllUsersEmailsForSite($siteId) 87 | { 88 | $result = []; 89 | $userSettings = new \Piwik\Plugins\IPtoCompany\UserSettings(); 90 | 91 | // Get the users with a view access 92 | $response = Request::processRequest('UsersManager.getUsersWithSiteAccess', [ 93 | 'idSite' => $siteId, 94 | 'access' => 'view' 95 | ]); 96 | 97 | foreach ($response as $user) { 98 | $subscribedToEmailReport = $userSettings->getSubscribedToEmailReportValueForUser($user['login']); 99 | 100 | if($subscribedToEmailReport) { 101 | $result[] = $user['email']; 102 | } 103 | } 104 | 105 | // Get the users with a write access 106 | $response = Request::processRequest('UsersManager.getUsersWithSiteAccess', [ 107 | 'idSite' => $siteId, 108 | 'access' => 'write' 109 | ]); 110 | 111 | foreach ($response as $user) { 112 | $subscribedToEmailReport = $userSettings->getSubscribedToEmailReportValueForUser($user['login']); 113 | 114 | if($subscribedToEmailReport) { 115 | $result[] = $user['email']; 116 | } 117 | } 118 | 119 | // Get the users with admin access 120 | $response = Request::processRequest('UsersManager.getUsersWithSiteAccess', [ 121 | 'idSite' => $siteId, 122 | 'access' => 'admin' 123 | ]); 124 | 125 | foreach ($response as $user) { 126 | $subscribedToEmailReport = $userSettings->getSubscribedToEmailReportValueForUser($user['login']); 127 | 128 | if($subscribedToEmailReport) { 129 | $result[] = $user['email']; 130 | } 131 | } 132 | 133 | // Get the users with superuser access 134 | $response = Request::processRequest('UsersManager.getUsersHavingSuperUserAccess', []); 135 | 136 | foreach ($response as $superUser) { 137 | $subscribedToEmailReport = $userSettings->getSubscribedToEmailReportValueForUser($superUser['login']); 138 | 139 | if($subscribedToEmailReport) { 140 | $result[] = $superUser['email']; 141 | } 142 | } 143 | 144 | return $result; 145 | } 146 | 147 | /** 148 | * Get the email address of the super user. 149 | * 150 | * @return array The returned array has the format 151 | * array(email1, email2, ...) 152 | */ 153 | private function getSuperUsersEmails() 154 | { 155 | $response = Request::processRequest('UsersManager.getUsersHavingSuperUserAccess', []); 156 | $result = []; 157 | 158 | foreach ($response as $superUser) { 159 | $result[] = $superUser['email']; 160 | } 161 | 162 | return $result; 163 | } 164 | 165 | /** 166 | * Get the email address of the super user. 167 | * 168 | * @param array The list of companies 169 | * 170 | * @return string The generated HTML 171 | */ 172 | private function convertCompaniesDataTableToHTML($companies) 173 | { 174 | $html = "

" . Piwik::translate('IPtoCompany_Hi') . "

" 175 | ."

" . Piwik::translate('IPtoCompany_FindBelowCompaniesReport') . "

" 176 | ; 177 | 178 | $rows = $companies->getRows(); 179 | 180 | if(!empty($rows)) { 181 | $html .= "

" 182 | ."" 183 | ."" 184 | ."" 185 | ."" 186 | ."" 187 | ."" 188 | ."" 189 | ."" 190 | ."" 191 | ."" 192 | ."" 193 | ."" 194 | ."" 195 | .""; 196 | 197 | foreach ($rows as $row) { 198 | $columns = $row->getColumns(); 199 | $counter = 0; 200 | $nbColumns = count($columns); 201 | 202 | $html .= ""; 203 | 204 | foreach ($columns as $key => $value) { 205 | $counter++; 206 | $styles = "border-bottom: solid 1px #DEDEDE;"; 207 | 208 | if($counter < $nbColumns) { 209 | $styles .= " border-right: solid 1px #DEDEDE;"; 210 | } 211 | 212 | $html .= ""; 213 | } 214 | 215 | $html .= ""; 216 | } 217 | 218 | $html .= "
IP" . Piwik::translate('IPtoCompany_Company') . "" . Piwik::translate('IPtoCompany_LastVisit') . "" . Piwik::translate('IPtoCompany_Type') . "" . Piwik::translate('IPtoCompany_NumberOfVisits') . "" . Piwik::translate('IPtoCompany_LastVisitDuration') . "" . Piwik::translate('IPtoCompany_ReferrerType') . "" . Piwik::translate('IPtoCompany_ReferrerName') . "" . Piwik::translate('IPtoCompany_Device') . "" . Piwik::translate('IPtoCompany_Country') . "" . Piwik::translate('IPtoCompany_City') . "
" . $value . "

"; 219 | } 220 | else { 221 | $html .= "

" . Piwik::translate('IPtoCompany_NoOneVisitedWebsiteYesterday') . "

"; 222 | } 223 | 224 | $html .= "
" 225 | ."

" . Piwik::translate('IPtoCompany_HaveANiceDay') . "

"; 226 | 227 | return $html; 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /Updates/0.2.0.php: -------------------------------------------------------------------------------- 1 | migration = $factory; 30 | } 31 | 32 | /** 33 | * Return database migrations to be executed in this update. 34 | * 35 | * Database migrations should be defined here, instead of in `doUpdate()`, since this method is used 36 | * in the `core:update` command when displaying the queries an update will run. If you execute 37 | * migrations directly in `doUpdate()`, they won't be displayed to the user. Migrations will be executed in the 38 | * order as positioned in the returned array. 39 | * 40 | * @param Updater $updater 41 | * @return Migration\Db[] 42 | */ 43 | public function getMigrations(Updater $updater) 44 | { 45 | // many different migrations are available to be used via $this->migration factory 46 | $migrationCreateTableIpToCompany = $this->migration->db->createTable('ip_to_company', [ 47 | 'id' => 'INTEGER NOT NULL AUTO_INCREMENT', 48 | 'ip' => 'VARCHAR( 15 ) NOT NULL', 49 | 'as_number' => 'VARCHAR( 10 ) NULL', 50 | 'as_name' => 'VARCHAR( 200 ) NULL', 51 | 'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP', 52 | 'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', 53 | ], 'id'); 54 | // you can also define custom SQL migrations. If you need to bind parameters, use `->boundSql()` 55 | // $migration2 = $this->migration->db->sql($sqlQuery = 'SELECT 1'); 56 | 57 | return array( 58 | $migrationCreateTableIpToCompany 59 | ); 60 | } 61 | 62 | /** 63 | * Perform the incremental version update. 64 | * 65 | * This method should perform all updating logic. If you define queries in the `getMigrations()` method, 66 | * you must call {@link Updater::executeMigrations()} here. 67 | * 68 | * @param Updater $updater 69 | */ 70 | public function doUpdate(Updater $updater) 71 | { 72 | $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /UserSettings.php: -------------------------------------------------------------------------------- 1 | autoRefresh->getValue(); 25 | * $settings->color->getValue(); 26 | */ 27 | class UserSettings extends \Piwik\Settings\Plugin\UserSettings 28 | { 29 | protected function init() 30 | { 31 | // User setting --> checkbox converted to bool 32 | $this->subscribedToEmailReport = $this->createSubscribedToEmailReportSetting(); 33 | } 34 | 35 | private function createSubscribedToEmailReportSetting() 36 | { 37 | return $this->makeSetting('subscribedToEmailReport', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { 38 | $field->title = Piwik::translate('IPtoCompany_SubscribeToEmailReport'); 39 | $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; 40 | $field->description = Piwik::translate('IPtoCompany_WantToReceiveDailyReport'); 41 | // $field->validators[] = new NotEmpty(); 42 | }); 43 | } 44 | 45 | public function getSubscribedToEmailReportValueForUser($userLogin) 46 | { 47 | // Sanitize the user login 48 | $userLogin = filter_var($userLogin, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); 49 | 50 | try { 51 | $sql = "SELECT * FROM " . Common::prefixTable('plugin_setting') . " 52 | WHERE plugin_name = 'IPtoCompany' 53 | AND setting_name = 'subscribedToEmailReport' 54 | AND setting_value = '1' 55 | AND user_login = '" . $userLogin . "'"; 56 | $result = Db::fetchAll($sql); 57 | } catch (Exception $e) { 58 | // ignore error if table already exists (1050 code is for 'table already exists') 59 | if (!Db::get()->isErrNo($e, '1050')) { 60 | throw $e; 61 | } 62 | } 63 | 64 | return count($result) == 1; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /config/config.php: -------------------------------------------------------------------------------- 1 | Personal Settings and check the checkbox located in the IPtoCompany section which asks you if you want to subscribe to this report. 30 | 31 | This report will then be sent to you once a day, for each site that you have access to, with the list of companies that visited your website the day before. 32 | 33 | ![How to activate the email report](https://github.com/Romain/Matomo-IP-to-Company/blob/master/screenshots/user-setting-subscribe-to-email-report.png) 34 | 35 | __Can I define the lifetime of the cache?__ 36 | 37 | As of version 0.4.0, yes, you can. In the general settings section, you can set the number of weeks during which the results should be kept in cache. By default, we keep them 2 weeks, and the minimum is 1 week. 38 | 39 | __How many records are returned?__ 40 | 41 | By default, to guarantee the performance of the report, a maximum of 200 records are returned. You can increase this value by appending the following parameter to the URL: &filterLimit=300. 42 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | ## Documentation 2 | 3 | Please consider reading our [FAQ](faq.md) first. 4 | 5 | If you want to **submit a bug**, please [create a new issue](https://github.com/Romain/Matomo-IP-to-Company/issues/new). 6 | 7 | If you want to **submit a new feature**, please [create a PR](https://github.com/Romain/Matomo-IP-to-Company/pulls). 8 | -------------------------------------------------------------------------------- /lang/am.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ar.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/be.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/bg.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Град", 4 | "Companies": "Компании", 5 | "CompaniesReportSubject": "[%1$s] Вашият дневен отчет / Компании", 6 | "Company": "Компания", 7 | "Country": "Държава", 8 | "Device": "Устройство", 9 | "FindBelowCompaniesReport": "По-долу ще намерите отчета на компаниите за вчерашния ден.", 10 | "HaveANiceDay": "Приятен ден!", 11 | "Hi": "Здравейте,", 12 | "LastVisit": "Последно посещение", 13 | "LastVisitDuration": "Продължителност на последното посещение", 14 | "LifeTimeOfCacheForResultsInWeeks": "Брой седмици, през които върнатите резултати трябва да се кешират.", 15 | "NoOneVisitedWebsiteYesterday": "Съжаляваме, но никой не посети уебсайта Ви вчера…", 16 | "NumberOfVisits": "Брой посещения", 17 | "PasteYourAccessToken": "Поставете в полето под токена си за достъп.", 18 | "ReferrerName": "Име на препращач", 19 | "ReferrerType": "Тип препращач", 20 | "SubscribeToEmailReport": "Абонирайте се за отчетите по имейл", 21 | "Type": "Тип", 22 | "WantToReceiveDailyReport": "Искам да получавам ежедневните отчети по имейл с името на компанията, която е посетила моите уебсайтове.", 23 | "YourIPInfoAccessToken": "Вашият токен за достъп до IPinfo.io" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/bs.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ca.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Ciutat", 4 | "Companies": "Empreses", 5 | "CompaniesReportSubject": "[%1$s] El vostre informe diari / Empreses", 6 | "Company": "Empresa", 7 | "Country": "País", 8 | "Device": "Dispositiu", 9 | "FindBelowCompaniesReport": "A continuació trobareu l'Informe d'Empreses d'ahir.", 10 | "HaveANiceDay": "Que tinguis un bon dia!", 11 | "Hi": "Bones,", 12 | "LastVisit": "Darrera visita", 13 | "LastVisitDuration": "Durada de la darrera visita", 14 | "LifeTimeOfCacheForResultsInWeeks": "Nombre de setmanes durant les quals els resultats retornats s'han d'emmagatzemar a la memòria cau.", 15 | "NoOneVisitedWebsiteYesterday": "Ens sap greu, però ahir ningú va visitar el vostre lloc web…", 16 | "NumberOfVisits": "Nombre de visites", 17 | "PasteYourAccessToken": "Enganxeu el vostre testimoni d'accés al camp que hi ha a sota.", 18 | "ReferrerName": "Nom del referent", 19 | "ReferrerType": "Tipus de referent", 20 | "SubscribeToEmailReport": "Subscriu-te als informes per correu electrònic", 21 | "Type": "Tipus", 22 | "WantToReceiveDailyReport": "Vull rebre els informes diaris per correu electrònic amb el nom de l'empresa que ha visitat els meus llocs web.", 23 | "YourIPInfoAccessToken": "El vostre testimoni d'accés proporcionat per IPinfo.io" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/cs.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/cy.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/da.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Stadt", 4 | "Companies": "Unternehmen", 5 | "CompaniesReportSubject": "[%1$s] Ihr täglicher Bericht / Unternehmen", 6 | "Company": "Unternehmen", 7 | "Country": "Land", 8 | "Device": "Gerät", 9 | "FindBelowCompaniesReport": "Nachfolgend finden Sie den Unternehmensbericht für den gestrigen Tag.", 10 | "HaveANiceDay": "Einen schönen Tag noch!", 11 | "Hi": "Hallo,", 12 | "LastVisit": "Letzter Besuch", 13 | "LastVisitDuration": "Dauer des letzten Besuchs", 14 | "LifeTimeOfCacheForResultsInWeeks": "Anzahl der Wochen, in denen die zurückgelieferten Ergebnisse zwischengespeichert werden müssen.", 15 | "NoOneVisitedWebsiteYesterday": "Es tut uns leid, aber niemand hat gestern Ihre Website besucht…", 16 | "NumberOfVisits": "Anzahl der Besuche", 17 | "PasteYourAccessToken": "Fügen Sie in das Feld unter Ihrem Zugangsschlüssel (Token) ein.", 18 | "ReferrerName": "Referrer Name", 19 | "ReferrerType": "Referrer Typ", 20 | "SubscribeToEmailReport": "Abonnieren Sie die E-Mail-Berichte", 21 | "Type": "Typ", 22 | "WantToReceiveDailyReport": "Ich möchte tägliche Berichte per E-Mail mit dem Namen des Unternehmens erhalten, das meine Websites besucht hat.", 23 | "YourIPInfoAccessToken": "Ihr IPinfo.io Zugangsschlüssel (Token)" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/el.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Πόλη", 4 | "Companies": "Εταιρίες", 5 | "CompaniesReportSubject": "[%1$s] Η καθημερινή σας αναφορά / Εταιρίες", 6 | "Company": "Εταιρία", 7 | "Country": "Χώρα", 8 | "Device": "Συσκευή", 9 | "FindBelowCompaniesReport": "Θα βρείτε παρακάτω την Αναφορά Εταιριών για την χθεσινή ημέρα.", 10 | "HaveANiceDay": "Σας ευχόμαστε μια ευχάριστη ημέρα!", 11 | "Hi": "Γεια σας,", 12 | "LastVisit": "Τελευταία επίσκεψη", 13 | "LastVisitDuration": "Διάρκεια τελευταίας επίσκεψης", 14 | "LifeTimeOfCacheForResultsInWeeks": "Αριθμός εβδομάδων για τις οποίες τα αποτελέσματα που επιστρέφονται θα αποθηκεύονται σε προσωρινή μνήμη.", 15 | "NoOneVisitedWebsiteYesterday": "Ζητούμε συγγνώμη, καθώς κανείς δεν επισκέφθηκε τον ιστοτόπο σας χθες…", 16 | "NumberOfVisits": "Αριθμός επισκέψεων", 17 | "PasteYourAccessToken": "Επικολλήστε στο πεδίο παρακάτω το τεκμήριο πρόσβασής σας.", 18 | "ReferrerName": "Όνομα αναφορέα", 19 | "ReferrerType": "Τύπος αναφορέα", 20 | "SubscribeToEmailReport": "Εγγραφείτε για αναφορές μέσω ηλεκτρονικής αλληλογραφίας", 21 | "Type": "Τύπος", 22 | "WantToReceiveDailyReport": "Θέλω να λαμβάνω τις καθημερινές αναφορές με ηλεκτρονική αλληλογραφία με το όνομα της εταιρίας που επισκέφτηκε τους ιστοτόπους μου.", 23 | "YourIPInfoAccessToken": "Το τεκμήριο πρόσβασής σας του IPinfo.io" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "City", 4 | "Companies": "Companies", 5 | "CompaniesReportSubject": "[%1$s] Your daily report / Companies", 6 | "Company": "Company", 7 | "Country": "Country", 8 | "Device": "Device", 9 | "FindBelowCompaniesReport": "You'll find below the Companies Report for the day of yesterday.", 10 | "HaveANiceDay": "Have a nice day!", 11 | "Hi": "Hi,", 12 | "LastVisit": "Last visit", 13 | "LastVisitDuration": "Last visit duration", 14 | "LifeTimeOfCacheForResultsInWeeks": "Number of weeks during which the results returned must be cached.", 15 | "NoOneVisitedWebsiteYesterday": "We are sorry, but no one visited your website yesterday…", 16 | "NumberOfVisits": "Number of visits", 17 | "PasteYourAccessToken": "Paste in the field below your access token.", 18 | "ReferrerName": "Referrer name", 19 | "ReferrerType": "Referrer type", 20 | "SubscribeToEmailReport": "Subscribe to the email reports", 21 | "Type": "Type", 22 | "WantToReceiveDailyReport": "I want to receive the daily reports by email with the name of the company that visited my websites.", 23 | "YourIPInfoAccessToken": "Your IPinfo.io access token" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/es-ar.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/es.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Ciudad", 4 | "Companies": "Empresas", 5 | "CompaniesReportSubject": "[%1$s] Su informe cotidiano / Empresas", 6 | "Company": "Empresa", 7 | "Country": "País", 8 | "Device": "Soporte", 9 | "FindBelowCompaniesReport": "Pueden encontrar abajo el informe con la lista de empresas que visitaron su sitio web ayer.", 10 | "HaveANiceDay": "Le deseamos un buen día!", 11 | "Hi": "Hola,", 12 | "LastVisit": "Última visita", 13 | "LastVisitDuration": "Duración de la última visita", 14 | "LifeTimeOfCacheForResultsInWeeks": "Numero de semanas durante cuales los resultados proveídos tienen que estar guardados en la memoria caché.", 15 | "NoOneVisitedWebsiteYesterday": "Lo sentimos mucho, pero nadie vino a visitar su sitio web ayer…", 16 | "NumberOfVisits": "Número de visitas", 17 | "PasteYourAccessToken": "Pega al lado su ficha de acceso.", 18 | "ReferrerName": "Nombre de la fuente", 19 | "ReferrerType": "Tipo de fuente", 20 | "SubscribeToEmailReport": "Suscribete a los informes", 21 | "Type": "Tipo", 22 | "WantToReceiveDailyReport": "Quiero recibir los informes cotidianos por email con la lista de empresas que visitaron mis sitios web.", 23 | "YourIPInfoAccessToken": "Su ficha de acceso de IPinfo.io" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/et.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/eu.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/fa.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/fi.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Ville", 4 | "Companies": "Sociétés", 5 | "CompaniesReportSubject": "[%1$s] Votre rapport quotidien / Sociétés", 6 | "Company": "Société", 7 | "Country": "Pays", 8 | "Device": "Support", 9 | "FindBelowCompaniesReport": "Vous trouverez ci-dessous le rapport avec la liste des sociétés qui ont visité votre site hier.", 10 | "HaveANiceDay": "Bonne journée !", 11 | "Hi": "Bonjour,", 12 | "LastVisit": "Dernière visite", 13 | "LastVisitDuration": "Durée de la dernière visite", 14 | "LifeTimeOfCacheForResultsInWeeks": "Nombre de semaines pendant lesquelles les résultats retournés doivent être gardés en cache.", 15 | "NoOneVisitedWebsiteYesterday": "Nous sommes désolé, mais personne n'a visité votre site hier…", 16 | "NumberOfVisits": "Nombre de visites", 17 | "PasteYourAccessToken": "Collez dans le champ ci-contre votre code d'accès.", 18 | "ReferrerName": "Nom de la source", 19 | "ReferrerType": "Type de source", 20 | "SubscribeToEmailReport": "Abonnez-vous aux rapports par e-mail", 21 | "Type": "Type", 22 | "WantToReceiveDailyReport": "Je veux recevoir des rapports quotidiens par email avec la liste des sociétés qui ont visité mes sites web.", 23 | "YourIPInfoAccessToken": "Votre jeton d'accès fourni par IPinfo.io" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/ga.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/gl.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/he.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/hi.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/hr.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/hu.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/id.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Kota", 4 | "Companies": "Perusahaan", 5 | "CompaniesReportSubject": "[%1$s] Laporan harian Anda/Perusahaan", 6 | "Company": "Perusahaan", 7 | "Country": "Negara", 8 | "Device": "Perangkat", 9 | "FindBelowCompaniesReport": "Anda akan menemukan Laporan Perusahaan untuk hari kemarin di bawah ini.", 10 | "HaveANiceDay": "Semoga hari Anda menyenangkan!", 11 | "Hi": "Hai,", 12 | "LastVisit": "Kunjungan terakhir", 13 | "LastVisitDuration": "Durasi kunjungan terakhir", 14 | "LifeTimeOfCacheForResultsInWeeks": "Jumlah minggu di mana hasil yang dikembalikan harus disimpan.", 15 | "NoOneVisitedWebsiteYesterday": "Kami minta maaf, tidak ada yang mengunjungi situs web Anda kemarin…", 16 | "NumberOfVisits": "Jumlah kunjungan", 17 | "PasteYourAccessToken": "Tempel token akses Anda di kolom di bawah ini.", 18 | "ReferrerName": "Nama perujuk", 19 | "ReferrerType": "Tipe perujuk", 20 | "SubscribeToEmailReport": "Berlangganan laporan surel", 21 | "Type": "Tipe", 22 | "WantToReceiveDailyReport": "Saya ingin menerima laporan harian melalui surel dengan nama perusahaan yang mengunjungi situs web saya.", 23 | "YourIPInfoAccessToken": "Token akses IPinfo.io Anda" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/is.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/it.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Città", 4 | "Companies": "Aziende", 5 | "CompaniesReportSubject": "[%1$s] Il tuo rapporto quotidiano / Aziende", 6 | "Company": "Azienda", 7 | "Country": "Stato", 8 | "Device": "Dispositivo", 9 | "FindBelowCompaniesReport": "Di seguito trovate il Rapporto Aziende per la giornata di ieri.", 10 | "HaveANiceDay": "Buona giornata!", 11 | "Hi": "Ciao,", 12 | "LastVisit": "Ultima visita", 13 | "LastVisitDuration": "Durata ultima visita", 14 | "LifeTimeOfCacheForResultsInWeeks": "Numero di settimane durante le quali i risultati restituiti devono essere memorizzati nella cache.", 15 | "NoOneVisitedWebsiteYesterday": "Siamo spiacenti, ma nessuno ha visitato il tuo sito web ieri…" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lang/ja.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ka.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ko.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/lt.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/lv.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/nb.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "By", 4 | "Companies": "Bedrifter", 5 | "CompaniesReportSubject": "[%1$s] Din daglige rapport/bedrifter", 6 | "Company": "Bedrift", 7 | "Country": "Land", 8 | "Device": "Enhet", 9 | "FindBelowCompaniesReport": "Nedenfor finner du bedriftsrapporten for gårsdagen.", 10 | "HaveANiceDay": "Ha en fin dag.", 11 | "Hi": "Hei,", 12 | "LastVisit": "Siste besøk", 13 | "LastVisitDuration": "Varighet for siste besøk", 14 | "LifeTimeOfCacheForResultsInWeeks": "Antall uker der svarresultat må hurtiglagres.", 15 | "NoOneVisitedWebsiteYesterday": "Ingen besøkte nettsiden din i dag …", 16 | "NumberOfVisits": "Antall besøk", 17 | "PasteYourAccessToken": "Lim inn tilgangssymbolet ditt i feltet nedenfor.", 18 | "ReferrerName": "Henvisernavn", 19 | "ReferrerType": "Henvisningstype", 20 | "SubscribeToEmailReport": "Abonner på e-postrapportene", 21 | "Type": "Type", 22 | "WantToReceiveDailyReport": "Jeg ønsker daglig rapportering per e-post med navnene til bedriftene som har besøkt nettsidene mine.", 23 | "YourIPInfoAccessToken": "Ditt IPinfo.io-tilgangssymbol" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/nl.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/nn.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/pl.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/pt-br.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Cidade", 4 | "Companies": "Empresas", 5 | "CompaniesReportSubject": "[%1$s] Seu relatório diário / Empresas", 6 | "Company": "Empresa", 7 | "Country": "País", 8 | "Device": "Dispositivo", 9 | "FindBelowCompaniesReport": "Você encontrará abaixo o Relatório de Empresas para o dia de ontem.", 10 | "HaveANiceDay": "Tenha um bom dia!", 11 | "Hi": "Olá,", 12 | "LastVisit": "Última visita", 13 | "LastVisitDuration": "Duração da última visita", 14 | "LifeTimeOfCacheForResultsInWeeks": "Número de semanas durante as quais os resultados retornados devem ser armazenados em cache.", 15 | "NoOneVisitedWebsiteYesterday": "Lamentamos, mas ninguém visitou seu site ontem…", 16 | "NumberOfVisits": "Número de visitas", 17 | "PasteYourAccessToken": "Cole no campo abaixo do seu token de acesso.", 18 | "ReferrerName": "Nome do referenciador", 19 | "ReferrerType": "Tipo de referenciador", 20 | "SubscribeToEmailReport": "Assine os relatórios de e-mail", 21 | "Type": "Tipo", 22 | "WantToReceiveDailyReport": "Quero receber os relatórios diários por e-mail com o nome da empresa que visitou meus sites.", 23 | "YourIPInfoAccessToken": "Seu token de acesso IPinfo.io" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/pt.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ro.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ru.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/sk.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/sl.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/sq.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/sr.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/sv.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "Stad", 4 | "Companies": "Företag/domäner", 5 | "CompaniesReportSubject": "[%1$s] Daglig rapport företag/domäner", 6 | "Company": "Företag", 7 | "Country": "Land", 8 | "Device": "Enhet", 9 | "FindBelowCompaniesReport": "Företag/domäner-rapporten för igår.", 10 | "HaveANiceDay": "Ha en bra dag!", 11 | "Hi": "Hej,", 12 | "LastVisit": "Senaste besök", 13 | "LastVisitDuration": "Längd på senaste besök", 14 | "LifeTimeOfCacheForResultsInWeeks": "Antal veckor som resultaten sparas i cachen.", 15 | "NoOneVisitedWebsiteYesterday": "Inga besök på sajten igår …", 16 | "NumberOfVisits": "Antal besök", 17 | "PasteYourAccessToken": "Fyll i din access-token i fältet nedan.", 18 | "ReferrerName": "Hänvisningsnamn", 19 | "ReferrerType": "Hänvisningstyp", 20 | "SubscribeToEmailReport": "Prenumerera på e-postrapporter", 21 | "Type": "Typ", 22 | "WantToReceiveDailyReport": "Jag vill få dagliga rapporter via e-post om företag/domäner som besökt sajterna.", 23 | "YourIPInfoAccessToken": "Din IPinfo.io access-token" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/ta.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/te.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/th.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/tl.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/tr.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "İl", 4 | "Companies": "Kuruluşlar", 5 | "CompaniesReportSubject": "[%1$s] günlük raporunuz / kuruluşlar", 6 | "Company": "Kuruluş", 7 | "Country": "Ülke", 8 | "Device": "Aygıt", 9 | "FindBelowCompaniesReport": "Düne ait kuruluşlar raporunu aşağıda bulabilirsiniz.", 10 | "HaveANiceDay": "İyi günler!", 11 | "Hi": "Merhaba,", 12 | "LastVisit": "Son ziyaret", 13 | "LastVisitDuration": "Son ziyaret süresi", 14 | "LifeTimeOfCacheForResultsInWeeks": "Döndürülen sonuçların ön belleğe alınacağı hafta sayısı.", 15 | "NoOneVisitedWebsiteYesterday": "Maalesef, dün hiç kimse web sitenizi ziyaret etmemiş…", 16 | "NumberOfVisits": "Ziyaret sayısı", 17 | "PasteYourAccessToken": "Erişim kodunun altındaki alana yapıştırın.", 18 | "ReferrerName": "Yönlendiren adı", 19 | "ReferrerType": "Yönlendiren türü", 20 | "SubscribeToEmailReport": "E-posta raporlarına abone ol", 21 | "Type": "Tür", 22 | "WantToReceiveDailyReport": "Web sitelerimi ziyaret eden kuruluşun adıyla e-posta ile günlük raporlar almak istiyorum.", 23 | "YourIPInfoAccessToken": "IPinfo.io erişim kodunuz" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lang/uk.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/ur.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/vi.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/zh-cn.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lang/zh-tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "IPtoCompany": { 3 | "City": "城市", 4 | "Companies": "公司", 5 | "CompaniesReportSubject": "[%1$s] 你的每日報表 / 公司", 6 | "Company": "公司", 7 | "Country": "國家與地區", 8 | "Device": "裝置", 9 | "FindBelowCompaniesReport": "你可以在下方找到昨天的公司報表。", 10 | "HaveANiceDay": "祝你有個愉快的一天!", 11 | "Hi": "你好,", 12 | "LastVisit": "上次訪問", 13 | "LastVisitDuration": "上次訪問時長", 14 | "LifeTimeOfCacheForResultsInWeeks": "返回結果的週數時段必須被緩存。", 15 | "NoOneVisitedWebsiteYesterday": "抱歉,昨天沒有人訪問你的網站…", 16 | "NumberOfVisits": "訪問次數", 17 | "PasteYourAccessToken": "粘貼到存取權杖下方的欄位中。", 18 | "ReferrerName": "引薦來源名稱", 19 | "ReferrerType": "引薦來源類型", 20 | "SubscribeToEmailReport": "訂閱 Email 報表", 21 | "Type": "類型", 22 | "WantToReceiveDailyReport": "我想透過 Email 接收包含訪問過我網站的公司名稱的每日報表。", 23 | "YourIPInfoAccessToken": "你的 IPinfo.io 存取權杖" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "IPtoCompany", 3 | "description": "Get the name of the companies that visit your website.", 4 | "version": "1.2.2", 5 | "theme": false, 6 | "stylesheet": "stylesheets/iptocompany.less", 7 | "require": { 8 | "matomo": ">=4.0.0-b1,<5.0.0-b1" 9 | }, 10 | "authors": [ 11 | { 12 | "name": "Romain Biard", 13 | "email": "romain.biard@gmail.com", 14 | "homepage": "https:\/\/www.linkedin.com\/in\/rbiard\/" 15 | } 16 | ], 17 | "support": { 18 | "email": "romain.biard@gmail.com", 19 | "issues": "https:\/\/github.com\/Romain\/Matomo-IP-to-Company\/issues", 20 | "forum": "https:\/\/forum.matomo.org", 21 | "wiki": "https:\/\/github.com\/Romain\/Matomo-IP-to-Company\/wiki", 22 | "source": "https:\/\/github.com\/Romain\/Matomo-IP-to-Company" 23 | }, 24 | "homepage": "https:\/\/github.com\/Romain\/Matomo-IP-to-Company", 25 | "license": "GPL v3+", 26 | "keywords": [ 27 | "ip", 28 | "company", 29 | "report", 30 | "companies" 31 | ], 32 | "donate": { 33 | "paypal": "romain.biard@gmail.com" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /screenshots/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Romain/Matomo-IP-to-Company/e309dfe470cbf84c98280f47558b4b1b59b7458f/screenshots/.gitkeep -------------------------------------------------------------------------------- /screenshots/full-view-of-the-report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Romain/Matomo-IP-to-Company/e309dfe470cbf84c98280f47558b4b1b59b7458f/screenshots/full-view-of-the-report.png -------------------------------------------------------------------------------- /screenshots/list-of-ips-and-their-associated-company.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Romain/Matomo-IP-to-Company/e309dfe470cbf84c98280f47558b4b1b59b7458f/screenshots/list-of-ips-and-their-associated-company.png -------------------------------------------------------------------------------- /screenshots/user-setting-subscribe-to-email-report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Romain/Matomo-IP-to-Company/e309dfe470cbf84c98280f47558b4b1b59b7458f/screenshots/user-setting-subscribe-to-email-report.png -------------------------------------------------------------------------------- /stylesheets/iptocompany.less: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Romain/Matomo-IP-to-Company/e309dfe470cbf84c98280f47558b4b1b59b7458f/stylesheets/iptocompany.less --------------------------------------------------------------------------------