Import/Core_geoip.php
[Pman.Core] / Import / Core_geoip.php
index a884e82..a43f3c6 100644 (file)
@@ -37,9 +37,15 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo
             $this->jerr('GeoLite2-City-Locations.csv OR GeoLite2-City-Blocks.csv does not exists?!');
         }
         
+        $this->log("Insert location data start");
+        
         $this->insertLocation($location);
         
+        $this->log("Insert Block data start");
+        
         $this->insertBlock($block);
+        
+        $this->jok("DONE");
     }
     
     function insertLocation($csv)
@@ -47,6 +53,7 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo
         ini_set("auto_detect_line_endings", true);
         
         $fh = fopen($csv, 'r');
+        
         if (!$fh) {
             $this->jerr("invalid location file");
         }
@@ -149,7 +156,7 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo
     
     
     function processLocation($row)
-    {
+    {   
         $continent = $this->processContinent($row['CONTINENT_CODE'], $row['CONTINENT_NAME']);
         
         $country = $this->processCountry($row['COUNTRY_ISO_CODE'], $row['COUNTRY_NAME'], $continent);
@@ -249,6 +256,12 @@ class Pman_Core_Import_Core_geoip extends Pman_Roo
     
     function processBlock($row)
     {
+        if(empty($this->id_mapping[$row['GEONAME_ID']])){
+            $this->log("Missing mapping for {$row['GEONAME_ID']}");
+            $this->log("IP : {$row['NETWORK_START_IP']}");
+            return;
+        }
+        
         $network_mapping = DB_DataObject::factory('core_geoip_network_mapping');
         
         $start_ip = array_pop(explode(":", $row['NETWORK_START_IP']));