<?php
	//$_GET['r_id'];
	//$_GET['l_id'];
	$data=$_GET['r_id'].",".$_GET['l_id'].",".$_GET['p_id'].",".$_GET['data']."\n";
	$filepath = "./data/route_data".$_GET['r_id']."_".$_GET['l_id'].".csv";
	//echo $data;
	//echo $filepath;
	//file_put_contents($filepath,$data);

	if($_GET['p_id']==1){
		if (file_exists($filepath)) {
			unlink($filepath);
		}
		$fp = fopen($filepath, "w");
		chmod($filepath,0666);
	}else{
		$fp = fopen($filepath, "a");
	}
	if(flock($fp,LOCK_EX)){
		@fwrite($fp, $data);//通過バス停情報を書き込む
	}
	fclose($fp);
?>