Файл: groups/handler/moder_wall.php
Строк: 59
<?php
if (!empty($_GET['add']) && is_numeric($_GET['add']))
{
$post_id = abs(intval($_GET['add']));
$result = mysql_query("SELECT * FROM `groups_wall_moder` WHERE `id` = '".$post_id."' AND `group_id` = '".$id."' LIMIT 1");
if (mysql_num_rows($result) == true) $arr_post = mysql_fetch_array($result);
else $err = true;
if ($_GET['anonim'] == 'yes') $from_anonim = 1; else $from_anonim = 0;
if ($err == false && mysql_query("INSERT INTO `groups_wall` SET
`user_id` = '".$user_id."',
`from_group` = 1,
`from_user` = '".$arr_post['user_id']."',
`from_anonim` = '".$from_anonim."',
`wall_id` = '".$id."',
`text` = '".$arr_post['text']."',
`type` = 'post',
`photos` = '".$arr_post['photos']."',
`audio` = '".$arr_post['audio']."',
`video` = '".$arr_post['video']."',
`time` = '".time()."'
") == true)
{
if (mysql_query("INSERT INTO `notifications` SET
`from_id` = '".$id."',
`for_id` = '".$arr_post['user_id']."',
`mod` = 'group_wall',
`type` = 'moder',
`refid` = '".mysql_insert_id()."',
`time` = '".time()."',
`count` = 1,
`new` = 1
") == true) mysql_query("UPDATE `users` SET `notifications` = 1, notifications_journal=notifications_journal+1 WHERE `id` = '".$arr_post['user_id']."'");
mysql_query("UPDATE `groups` SET count_wall=count_wall+1, count_moder_wall=count_moder_wall-1 WHERE `id` = '".$id."'");
mysql_query("DELETE FROM `groups_wall_moder` WHERE `id` = '".$post_id."'");
if (!is_dir(HOME.'/files/groups/wall/'.$id))
{
mkdir(HOME.'/files/groups/wall/'.$id,0777);
mkdir(HOME.'/files/groups/wall/'.$id.'/photos',0777);
mkdir(HOME.'/files/groups/wall/'.$id.'/photos/icons',0777);
mkdir(HOME.'/files/groups/wall/'.$id.'/photos/mini',0777);
mkdir(HOME.'/files/groups/wall/'.$id.'/photos/preview',0777);
}
if (!empty($arr_post['photos']))
{
$q = explode("||", substr($arr_post['photos'], 1, -1));
$count = count($q);
$new_count_group_wall_photos = 0;
for ($i = 0; $i < $count; $i++)
{
$new_count_group_wall_photos++;
mysql_query("INSERT INTO `groups_wall_photos` SET `user_id` = '".$user_id."', `wall_id` = '".$id."', `name` = '".$q[$i]."', `time` = '".time()."'");
if (file_exists(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/'.$q[$i])) copy(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/'.$q[$i], HOME.'/files/groups/wall/'.$id.'/photos/'.$q[$i]);
if (file_exists(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/preview/'.$q[$i])) copy(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/preview/'.$q[$i], HOME.'/files/groups/wall/'.$id.'/photos/preview/'.$q[$i]);
if (file_exists(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/mini/'.$q[$i])) copy(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/mini/'.$q[$i], HOME.'/files/groups/wall/'.$id.'/photos/mini/'.$q[$i]);
if (file_exists(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/icons/'.$q[$i])) copy(HOME.'/files/wall/'.$arr_post['user_id'].'/photos/icons/'.$q[$i], HOME.'/files/groups/wall/'.$id.'/photos/icons/'.$q[$i]);
}
if ($new_count_group_wall_photos > 0) mysql_query("UPDATE `groups` SET `count_wall_photos` = '".($arr_group['count_wall_photos']+$new_count_group_wall_photos)."' WHERE `id` = '".$id."' LIMIT 1");
}
echo ok(lang('Запись опубликована','Запис опублікований'));
}
}
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 `group_id` = '".$id."' LIMIT 1"),0) == true)
{
if (mysql_query("DELETE FROM `groups_wall_moder` WHERE `id` = '".$del_post."' AND `group_id` = '".$id."'") == true)
{
mysql_query("UPDATE `groups` SET `count_moder_wall` = '".($arr_group['count_moder_wall']-1)."' WHERE `id` = '".$id."'");
echo ok(lang('Запись удалена','Запис видалений'));
}
}
}
?>