ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/lib/plugin/ext_lookup_geoip2-mod.php
Revision: 414
Committed: Tue Mar 22 07:48:57 2022 UTC (2 years, 8 months ago) by matthys
File size: 1503 byte(s)
Log Message:
 Rename to GeoIP2 plugin

File Contents

# Content
1 <?php
2 /* This file is part of BBClone (A PHP based Web Counter on Steroids)
3 *
4 * SVN FILE $Id: ext_lookup_maxmind-mod.php 63 2022-03-19 15:19:31Z matthys $
5 *
6 * Copyright (C) 2001-2022, the BBClone Team (see doc/authors.txt for details)
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * See doc/copying.txt for details
19 */
20
21 ////////////////////////////////////////////////////////////////////
22 // Plug-in: Extension look-up by GeoIP2 PHP/Perl Module //
23 // Use PHP extension=maxminddb.so | pecl install maxminddb //
24 // Depends on the new GeoIP2/GeoLite2 MaxMind DataBase (mmdb) //
25 ////////////////////////////////////////////////////////////////////
26
27 use MaxMind\Db\Reader;
28
29 function bbc_extension_plugin($host, $addr) {
30 global $BBC_GEOIP_PATH, $BBC_GEOIP2_DB;
31
32 $databaseFile = $BBC_GEOIP_PATH.$BBC_GEOIP2_DB;
33 $reader = new Reader($databaseFile);
34 $country=($reader->get($addr)['country']['iso_code']);
35 $reader->close();
36 return strtolower($country);
37 }
38
39 ?>