<?php

if (!empty($_POST['ask']) && $arr_ask['access'] != 3)
{
	$anonim = abs(intval($_POST['anonim']));
	if ($anonim == 1 && $arr_ask['access'] != 2) $anonim = 1; else $anonim = 0;
	$text = check($_POST['ask']);
	$text = substr($text, 0, 1000);
	
	if(!empty($text) && mysql_query("INSERT INTO `ask_msg` SET
	`user_id` = '".$user_id."',
	`ask_id` = '".$id."',
	`text` = '".$text."',
	`anonim` = '".$anonim."',
	`time` = '".time()."',
	`new` = 1
	") == true)
	{
		mysql_query("INSERT INTO `notifications` SET
		`from_id` = '".$user_id."',
		`sex` = '".$user['sex']."',
		`for_id` = '".$id."',
		`mod` = 'ask',
		`type` = 'ask',
		`refid` = '".$id."',
		`time` = '".time()."',
		`count` = 1,
		`new` = 1
		");
	}
		mysql_query("UPDATE `users` SET `notifications` = 1, notifications_journal=notifications_journal+1 WHERE `id` = '".$id."'");
		mysql_query("UPDATE `ask` SET count_new=count_new+1 WHERE `user_id` = '".$id."'");
		
		echo ok(lang('Вопрос отправлен','Запитання надіслано'));
}

?>