<?php
	$action = $_POST["action"];
	$fileName = $_POST["filename"];
	$contents = $_POST["contents"];

	if ($action == "save") {
		save($fileName, $contents);
	}
	
	
	function save($fileName, $contents) {
		$fileName = "../../".$fileName.".checkstyle.js";

		$fh = fopen($fileName, 'w');
		fwrite($fh, stripslashes($contents));
		fclose($fh);
		
		print "File saved to $fileName\n";
	}
	
	if(false) {
?>
<html>
	<body>
		Rename this file to checkstyle.php to enable saving fixed files.
	</body>
</html>

<?php
}
?>