' . $lng_gifts['gift'] . ' ' . $lng_gifts['for'] . ' ' . $ank['name'] . '';
/*
-----------------------------------------------------------------
Выводим верхнее меню
-----------------------------------------------------------------
*/
$gift = mysql_fetch_assoc(mysql_query("SELECT * FROM `gifts` WHERE `id` = '$id'"));
$parent = mysql_fetch_assoc(mysql_query("SELECT * FROM `gifts` WHERE `id` = '$gift[cat]'"));
if($id) {
echo '';
}
if($gift && !empty($gift['cost'])) {
if(isset($_POST['submit'])) {
// Принимаем и фильтруем данные
$type = isset($_POST['type']) ? intval($_POST['type']) : 0;
$text = !empty($_POST['text']) ? mysql_real_escape_string(substr($_POST['text'],0,56)) : null;
if($_POST['type'] == 1)
$cost = $gift['pcost'];
else
$cost = $gift['cost'];
$newballs = ($datauser['balls'] - $cost);
if($newballs > 0) {
mysql_query("INSERT INTO `users_gifts` (
`id` ,
`name` ,
`user_id`,
`text` ,
`time` ,
`image`,
`from_id`,
`type`
)
VALUES (
NULL ,
'".$gift['name']."',
'".$ank['id']."',
'".$text."',
'".time()."',
'".$gift['image']."',
'".$user_id."',
'".$type."'
);
") or die(mysql_error());
$pid = mysql_insert_id();
$whom = $ank['id'];
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '$user_id',
`from_id` = '" . $ank['id'] . "',
`text` = '" . mysql_real_escape_string(($type != 0 ? $lng_gifts['new_gift_privat'] : $lng_gifts['new_gift']) . " [url=".$home."/gifts/?act=showall&user=$whom]$gift[name][/url] " . $lng_gifts['from'] . " " . $login) . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $lng_gifts['new_gift'] . "'");
mysql_query("update `users` set `balls` = '".$newballs."' where `id` = '".$user_id."'");
header("location: /users/profile.php?user=$ank[id]");
} else
echo functions::display_error($lng_gifts['not_balls']);
} else {
$gift['pcost'] = $gift['pcost'];
$gift['cost'] = $gift['cost'];
echo '';
}
} else
header("Location: index.php");
if($rights >= 7) {
echo '' .
'';
}
?>