<?php 
	error_reporting(0);
	date_default_timezone_set('Asia/Kuala_Lumpur');
	/*
	error_reporting(E_ALL);
	ini_set('display_errors', TRUE);
	ini_set('display_startup_errors', TRUE);
	*/
	
	
	
	$id			= $_GET['id'];
	$site		= $_GET['site'];
	$f_type		= $_GET['f_type'];
	$content	= urldecode($_GET['content']);
	
	$filename	= $f_type."/".$id.".txt";
	
	
	if($_GET['action']=='create'){
		if(!file_exists($filename)){
			//if not yet create, create-kan
			$handle 	= fopen($filename, "wb");
			fwrite($handle, $content);
			fclose($handle);
		}
		
		if(file_exists($filename)){
			//if got, for now still create-kan
			$handle 	= fopen($filename, "wb");
			fwrite($handle, $content);
			fclose($handle);
		}
	}
	
	
	
	
	if($_GET['action']=='update'){
		if(file_exists($filename)){
			//if got, for now still create-kan
			$handle 	= fopen($filename, "wb");
			fwrite($handle, $content);
			fclose($handle);
		}
	}
	
	
	
	if($_GET['action']=='read'){
		if(file_exists($filename)){
			//if dah ada, gather info
			$info = file_get_contents($filename);
			//return info
			echo $info;
		}
	}
	
	
	
	
	if($_GET['action']=='delete'){
		if(file_exists($filename)){
			unlink($filename); //delete it
		}
	}
?>