<?php

if(isset($_GET['key'])){
	$key = $_GET['key'];
	$key = ereg_replace("[^a-zA-Z0-9]", '', $key);

	$filename = "$key.txt";

	if(isset($_POST['content'])){
		$f = fopen($filename, "w");
		fwrite($f, $_POST['content']);
		fclose($f);
	} else if(file_exists($filename)){
		$f = fopen($filename, "r");
		echo fread($f, filesize($filename));
		fclose($f);
	} else {
		header("HTTP/1.0 404 Not Found");
		echo "No such content";
	}
}
?>
