Import/Core_geoip.php
[Pman.Core] / Import / Core_geoip.php
1 <?php
2
3 require_once 'Pman/Roo.php';
4
5 class Pman_Core_Import_Core_geoip extends Pman_Roo
6 {
7     static $cli_desc = "Insert the geoip database";
8     
9     static $cli_opts = array();
10     
11     function getAuth()
12     {
13         $ff = HTML_FlexyFramework::get();
14         if (!$ff->cli) {
15             die("access denied");
16         }
17         HTML_FlexyFramework::ensureSingle(__FILE__, $this);
18         return true;
19     }
20     
21     function post()
22     {
23         $this->get();
24     }
25     
26     function get()
27     {
28         
29         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
30         
31         $location = '/tmp/GeoLite2-City-Locations.csv';
32         $block = '/tmp/GeoLite2-City-Blocks.csv';
33         
34         if(!file_exists($location) || !file_exists($block)){
35             $this->jerr('GeoLite2-City-Locations.csv OR GeoLite2-City-Blocks.csv does not exists?!');
36         }
37         
38         static $id_mapping = array();
39         
40         ini_set("auto_detect_line_endings", true);
41         
42         $this->insertLocation($location);
43         
44         $this->insertBlock($block);
45     }
46     
47     function insertLocation($csv)
48     {
49         $fh = fopen($csv, 'r');
50     }
51     
52     
53     
54     function log($str)
55     {
56         echo "$str \n";
57     }
58 }