<?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']);
	}
	$cat = (int)$_POST['cat'];
	$body = mysql_real_escape_string(strip_tags($_POST['body']));
	$color = mysql_real_escape_string($_POST['color']);
	$zindex = (int)$_POST['zindex'];
	mysql_query('insert into m_notes (id_account,id_category,c_text,c_color,c_xyz) values ("'.$_SESSION['current_id'].'","'.$cat.'","'.$body.'","'.$color.'","0x0x'.$zindex.'")');
	if (mysql_affected_rows() == 1) {
		echo mysql_insert_id();
	} else {
		echo '0';
	}
?>
