Файл: wall/handler/wall.php
Строк: 33
<?php
if (!empty($_POST['form_wall']))
{
// Антифлуд
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `wall` WHERE `user_id` = '".$user_id."' AND `time` > '".(time()-5)."'"),0) == true) $flood = true;
$wall_post = check($_POST['wall_post']);
$wall_post = substr($wall_post, 0, 10000);
$hashtag = gethashtags($wall_post);
$wall_post = strip_tags($wall_post);
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `wall_cache` WHERE `user_id` = '".$user_id."' LIMIT 1"),0) == true) $arr_wall_cache = mysql_fetch_array(mysql_query("SELECT * FROM `wall_cache` WHERE `user_id` = '".$user_id."' LIMIT 1")); else $arr_wall_cache = false;
if ($arr_wall_cache == false) $arr_wall_cache['photos'] = '';
if (!empty($wall_post) || !empty($arr_wall_cache['photos']) || !empty($arr_wall_cache['audio']) || !empty($arr_wall_cache['video']))
{
if ($flood == false && mysql_query("INSERT INTO `wall` SET
`user_id` = '".$user_id."',
`wall_id` = '".$id."',
`text` = '".$wall_post."',
`type` = 'post',
`photos` = '".$arr_wall_cache['photos']."',
`audio` = '".$arr_wall_cache['audio']."',
`video` = '".$arr_wall_cache['video']."',
`time` = '".time()."',
`hashtag` = '".$hashtag."'
") == true)
{
if ($user_id != $id && mysql_query("INSERT INTO `notifications` SET
`from_id` = '".$user_id."',
`sex` = '".$user['sex']."',
`for_id` = '".$id."',
`mod` = 'wall',
`type` = 'post',
`refid` = '".$id."',
`time` = '".time()."',
`count` = 1,
`new` = 1
") == true) mysql_query("UPDATE `users` SET `notifications` = 1, notifications_journal=notifications_journal+1 WHERE `id` = '".$id."'");
mysql_query("UPDATE `users` SET count_wall=count_wall+1 WHERE `id` = '".$id."'");
if (!empty($arr_wall_cache['photos']))
{
mysql_query("UPDATE `wall_cache` SET `photos` = '', `count_photos` = 0 WHERE `user_id` = '".$user_id."' LIMIT 1");
$q = explode("||", substr($arr_wall_cache['photos'], 1, -1));
$count = count($q);
$new_wall_count_photos = 0;
for ($i = 0; $i < $count; $i++)
{
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `wall_photos` WHERE `name` = '".$q[$i]."' AND `user_id` = '".$user_id."' LIMIT 1"),0) == false)
{
$new_wall_count_photos++;
mysql_query("INSERT INTO `wall_photos` SET `user_id` = '".$user_id."', `wall_id` = '".$id."', `name` = '".$q[$i]."', `time` = '".time()."'");
}
}
if ($new_wall_count_photos > 0) mysql_query("UPDATE `users` SET `count_wall_photos`= '".($user['count_wall_photos']+$new_wall_count_photos)."' WHERE `id` = '".$user_id."'");
}
if (!empty($arr_wall_cache['audio'])) mysql_query("UPDATE `wall_cache` SET `audio` = '', `count_audio` = 0 WHERE `user_id` = '".$user_id."' LIMIT 1");
if (!empty($arr_wall_cache['video'])) mysql_query("UPDATE `wall_cache` SET `video` = '', `count_video` = 0 WHERE `user_id` = '".$user_id."' LIMIT 1");
}
}
}
?>