<?php

ini_set("max_execution_time", "3000");
include("../includes/site_config.php");

session_cache_limiter('private, must-revalidate');
session_start();
$query="DELETE FROM zipcodes";
mysql_query($query,$link) or die(mysql_error());
$fp = fopen ("zipcodes.csv","r") or die (ZIPCODES_CVSERROR);
$line_no=0;
while ( ! feof($fp)) {
    $line = fgets($fp, 1024);
    $line= addslashes($line);
    $line_array=explode(",",$line);
    if (is_numeric($line_array[0])) $query="INSERT INTO zipcodes VALUES('$line_array[0]','$line_array[1]','$line_array[2]','$line_array[3]','$line_array[4]','$line_array[5]','$line_array[6]',$line_array[7],$line_array[8])";
	else $query="INSERT INTO zipcodes VALUES('$line_array[0]','','$line_array[1]','$line_array[4]','$line_array[2]','$line_array[3]','',$line_array[5],$line_array[6])";
    mysql_query($query,$link) or die(mysql_error().$query);
    $line_no++;
    print("$line_no<br>");
}
fclose ($fp);
?>