]*>(.*)<\/a>([^\r\n]*)[\r\n]/i', $contents, $output, PREG_SET_ORDER );

foreach ($output as $item) {
$filepath = str_replace("/", "\\", $item[1]);
if (!strstr($filepath, '\\')) {
$filepath = $filepath . "\\index.asp";
} elseif (!strstr($filepath, '.asp')) {
$filepath = $filepath . "index.asp";
}
if (@fopen("G:\\WEB\\" . $filepath, "r")) {
$category[$i][] = $filepath;
$maintitle[$i][] = mysql_escape_string(preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})[: -]{1,3}/', '', strip_tags($item[2]))); //title
$mainintroText[$i][] = mysql_escape_string(strip_tags($item[3])); //intro text
}
}
}

$handle = fopen("import.sql", "w") or exit("Unable to open " . $filename . "! ");
fwrite($handle, "INSERT INTO `jos_content` (`id`, `title`, `title_alias`, `introtext`, `fulltext`, `state`, `sectionid`, `mask`, `catid`, `created`, `created_by`, `created_by_alias`, `modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `images`, `urls`, `attribs`, `version`, `parentid`, `ordering`, `metakey`, `metadesc`, `access`, `hits`) VALUES\n");

// get article content
for($i = 0 ; $i < count($category) ; $i++) {
for($j = 0 ; $j < count($category[$i]) ; $j++) {
$filename = "G:\\WEB\\" . $category[$i][$j];
$file = fopen($filename,"r") or exit("Unable to open " . $filename . "! ");
$contents = fread($file, filesize($filename));
fclose($file);

preg_match('/]*>[\s]*(.*)[^\r\n]*/i', $contents, $output1 );
$main[$i][$j][0] = mysql_escape_string(preg_replace('/"/', '', strip_tags($output1[1]))); // title_alias

preg_match('/([a-zA-Z0-9":, \.]*)[-\r\n]/i', $contents, $output2 );
if (empty($output2)) {
$main[$i][$j][1] = '';
} else {
$main[$i][$j][1] = mysql_escape_string(strip_tags($output2[1])); // created_by_alias
}

preg_match('/[^-]*[- ]{1,2}([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})[<\s]/i', $contents, $output3 );
if (empty($output3)) {
$main[$i][$j][2] = "2000-01-01 00:00:00"; // created
} else {
$main[$i][$j][2] = date('Y-m-d H:i:s',mktime(0, 0, 0, $output3[1], $output3[2], $output3[3])); // created
}

preg_match('/