Файл: groups/wall/handler/add.php
Строк: 25
<?php
if (!empty($_POST['form_wall']))
{
// Антифлуд
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `groups_wall_moder` 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);
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']))
{
if ($flood == false && mysql_query("INSERT INTO `groups_wall_moder` SET
`user_id` = '".$user_id."',
`group_id` = '".$id."',
`text` = '".$wall_post."',
`photos` = '".$arr_wall_cache['photos']."',
`audio` = '".$arr_wall_cache['audio']."',
`video` = '".$arr_wall_cache['video']."',
`time` = '".time()."'
") == true)
{
mysql_query("UPDATE `groups` SET count_moder_wall=count_moder_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_count_wall_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_count_wall_photos++;
mysql_query("INSERT INTO `wall_photos` SET `user_id` = '".$user_id."', `wall_id` = '".$id."', `name` = '".$q[$i]."', `time` = '".time()."'");
}
}
if ($new_count_wall_photos > 0) mysql_query("UPDATE `users` SET `count_wall_photos` = '".($user['count_wall_photos']+$new_count_wall_photos)."' WHERE `id` = '".$user_id."' LIMIT 1");
}
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");
}
}
}
else if (!empty($_GET['del_post']) && is_numeric($_GET['del_post']))
{
$del_post = abs(intval($_GET['del_post']));
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `groups_wall_moder` WHERE `id` = '".$del_post."' AND `user_id` = '".$user_id."' LIMIT 1"),0) == true)
{
if (mysql_query("DELETE FROM `groups_wall_moder` WHERE `id` = '".$del_post."'") == true)
{
mysql_query("UPDATE `groups` SET `count_moder_wall` = '".($arr_group['count_moder_wall']-1)."' WHERE `id` = '".$id."'");
}
}
}
?>