Файл: groups/avatars/handler/del_avatar.php
Строк: 28
<?php
if (!empty($_GET['del_avatar']) && is_numeric($_GET['del_avatar']))
{
$del_avatar = abs(intval($_GET['del_avatar']));
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `groups_avatars` WHERE `id` = '".$del_avatar."' AND `group_id` = '".$id."' LIMIT 1"),0) == true)
{
$arr = mysql_fetch_array(mysql_query("SELECT * FROM `groups_avatars` WHERE `id` = '".$del_avatar."' AND `group_id` = '".$id."' LIMIT 1"));
mysql_query("DELETE FROM `groups_avatars` WHERE `id` = '".$del_avatar."'");
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `groups_wall` WHERE `type` = 'update_avatar' AND `photos` = '".$arr['name']."' AND `wall_id` = '".$id."' LIMIT 1"),0) == true)
{
mysql_query("DELETE FROM `groups_wall` WHERE `type` = 'update_avatar' AND `photos` = '".$arr['name']."' AND `wall_id` = '".$id."'");
mysql_query("UPDATE `groups` SET count_wall=count_wall-1 WHERE `id` = '".$id."'");
}
if ($arr['name'] == $arr_group['avatar'])
{
mysql_query("UPDATE `groups` SET `avatar` = '' WHERE `id` = '".$id."'");
}
if (file_exists(HOME .'/files/groups/avatars/'. $id.'/'.$arr['name'])) {@unlink(HOME .'/files/groups/avatars/'. $id.'/'.$arr['name']);}
if (file_exists(HOME .'/files/groups/avatars/'.$id.'/preview/'.$arr['name'])) {@unlink(HOME .'/files/groups/avatars/'. $id.'/preview/'.$arr['name']);}
if (file_exists(HOME .'/files/groups/avatars/'. $id.'/mini/'.$arr['name'])) {@unlink(HOME .'/files/groups/avatars/'. $id.'/mini/'.$arr['name']);}
if (file_exists(HOME .'/files/groups/avatars/'. $id.'/icons/'.$arr['name'])) {@unlink(HOME .'/files/groups/avatars/'. $id.'/icons/'.$arr['name']);}
}
}
?>