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

	if (!is_write_permit()) {
		die("0");
	}
	$con = my_mysqli_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 = mysqli_real_escape_string($con, strip_tags($_POST['body']));
	$color = mysqli_real_escape_string($con, $_POST['color']);
	$id = (int)$_POST['id'];
	$sql = 'update m_notes set ';
	$sql .= 'c_text = "'.$body.'"';
	$sql .= ', c_color = "'.$color.'"';
	$sql .= ' where id = '.$id;
	my_mysqli_query($sql);
	if (mysqli_affected_rows($con) == 1) {
		echo $id;
	} else {
		echo '0';
	}
?>
