IP数据库


转换并导入:


$file = fopen("data.txt","r");

while(!feof($file)){
	$s = fgets($file);
	$d = preg_split('/\s{2,}/', $s);
	if(isset($d[2])){
		$t = ip2long($d[0]) . "\t" . ip2long($d[1]) . "\t0\tunknown\t" . $d[2] . "\t0";
		file_put_contents('data1.txt', $s, FILE_APPEND);
	}
}

fclose($file);

# 导入
$sql = "LOAD DATA LOCAL INFILE 'd:\\data1.txt' INTO TABLE ip(`start`, `end`, `type`, `country`, `location`, `reliable`)";