<?php
	require("__include-common.php");
	require("../account/__logincheck.php");

	if (!is_write_permit()) {
		die("0");
	}
	$con = my_mysql_connect(_DB_SCHEMA);
	if(!is_numeric($_POST['zindex']) || !isset($_POST['body']) || !in_array($_POST['color'],array('yellow','green','blue','pink','orange')))
		die("0");
	if(ini_get('magic_quotes_gpc')) {
		$_POST['body']=stripslashes($_POST['body']);
	}
	$body = mysql_real_escape_string(strip_tags($_POST['body']));
	$color = mysql_real_escape_string($_POST['color']);
	$id = (int)$_POST['id'];
	$sql = 'update m_notes set ';
	$sql .= 'c_text = "'.$body.'"';
	$sql .= ', c_color = "'.$color.'"';
	$sql .= ' where id = '.$id;
	mysql_query($sql);
	if (mysql_affected_rows() == 1) {
		echo $id;
	} else {
		echo '0';
	}
?>
