<?php
function smarty_function_admin_modify($params, &$smarty) {
	//
	global $section;
	global $data;
	global $key_name;
	$value = $_POST[$key_name];
	$data_file = HOME_DIR."data/".$section."/".$data.".php";
	$smarty->assign("success", "Unknown problem.");
	
	//
	if($key_name == "short_name") {
		$new_file = HOME_DIR."data/".$section."/".trim($value).".php";
		rename($data_file, $new_file);
		$data_file = $new_file;
	}
	
	//
	require($data_file);
	$value = rtrim($value);
	$value = nl2br($value);
	//$value = str_replace('"', '\"', $value);
	$my_content[$key_name] = $value;
	$output = "<?php\r";
	foreach($my_content as $key => $value) {
		$output .= "\$my_content[\"".$key."\"] = \"".$value."\";\r";
	}
	$output .= "?>";
	$handle = fopen($data_file, 'w');
	fwrite($handle, $output);
	fclose($handle);
	$smarty->assign("success", "true");
}
?>