<?php
set_time_limit(0);

// template for pages

	$original_content = "";
	$fh1 = fopen('template.php','r');
	while(!feof($fh1))
	{
		$original_content .= fgets($fh1);
	}
	fclose($fh1);


// Create pages	
	$file_handle = fopen('areas.csv', 'r');

	while(!feof($file_handle)) 
	{
		$line = fgetcsv($file_handle, 1024);
		$city 	= $line[0];
		$city_file 	= strtolower(str_replace(" ","-",$city)).'-uk-numbers.php';
		
		// Make city page
		chdir('/home/fdesign1/public_html/phone-numbers-uk.com/generate/');
		
		$new_content = str_replace("01200 Clitheroe",$city,$original_content);
		
		$fh = fopen($city_file,'w');
		fwrite($fh,$new_content);
		fclose($fh);
	
	}

	fclose($file_handle);
	echo 'Files created.';
?>