orderBy('ip_start', 'desc')->first()); if(!Storage::disk('import')->has($filename)){ die("File not found in import folder: ".$filename); }*/ $path = Storage::disk('import')->path($filename); $fileContents = file($path); $c = 0; foreach ($fileContents as $line) { $row = str_getcsv($line); $row[] = self::addrType($row[0]); // //base64_encode(file_get_contents($path)) // dump($row); \DB::table('dbip_lookup')->insert([ 'ip_start' => inet_pton($row[0]), 'ip_end' => inet_pton($row[1]), 'country' => $row[2], 'addr_type' => $row[3] ]); //dump(inet_pton($row[0])); /* DbipLookup::create([ 'ip_start' => , 'ip_end' => inet_pton($row[1]), 'country' => $row[2], 'addr_type' => $row[3] ]);*/ } return true; } private static function addrType($addr) { if (ip2long($addr) !== false) { return "ipv4"; } else if (preg_match('/^[0-9a-fA-F:]+$/', $addr) && @inet_pton($addr)) { return "ipv6"; } die("unknown address type for {$addr}"); } public static function store() { $data = Request::all(); \Session()->flash('alert-save', true); return back(); } }