<?php

if (!empty($_GET['admin']) && is_numeric($_GET['admin']))
{
	$admin = abs(intval($_GET['admin']));
	if ($user_id == $admin || $admin == $arr_group['user_id'] || !in_array($admin, explode("||", substr($arr_group['users'], 1, -1)))) $err = true;
	if ($err == false && !in_array($admin, explode("||", substr($arr_group['admins'], 1, -1))))
	{
		if (mysql_query("UPDATE `groups` SET `admins` = '|".$admin."|".$arr_group['admins']."', `moders` = '".str_replace("|".$admin."|", "", $arr_group['moders'])."' WHERE `id` = '".$id."'") == true)
		{
			$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
			echo ok(user_name3($admin).Lang(' - администратор сообщества',' - адміністратор спільноти'));
		}
	}
}
else if (!empty($_GET['moder']) && is_numeric($_GET['moder']))
{
	$moder = abs(intval($_GET['moder']));
	if ($user_id == $moder || $moder == $arr_group['user_id'] || !in_array($moder, explode("||", substr($arr_group['users'], 1, -1)))) $err = true;
	if ($err == false && !in_array($moder, explode("||", substr($arr_group['moders'], 1, -1))))
	{
		if (mysql_query("UPDATE `groups` SET `moders` = '|".$moder."|".$arr_group['moders']."', `admins` = '".str_replace("|".$moder."|", "", $arr_group['admins'])."' WHERE `id` = '".$id."'") == true)
		{
			$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
			echo ok(user_name3($moder).Lang(' - модератор сообщества',' - модератор спільноти'));
		}
	}
}
else if (!empty($_GET['u']) && is_numeric($_GET['u']))
{
	$u = abs(intval($_GET['u']));
	if ($user_id == $u || $u == $arr_group['user_id'] || !in_array($u, explode("||", substr($arr_group['users'], 1, -1)))) $err = true;
	if ($err == false && in_array($u, explode("||", substr($arr_group['admins'], 1, -1))) || in_array($u, explode("||", substr($arr_group['moders'], 1, -1))))
	{
		if (mysql_query("UPDATE `groups` SET `admins` = '".str_replace("|".$u."|", "", $arr_group['admins'])."', `moders` = '".str_replace("|".$u."|", "", $arr_group['moders'])."' WHERE `id` = '".$id."'") == true)
		{
			$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
			echo ok(user_name3($u).Lang(' - пользователь сообщества',' - користувач спільноти'));
		}
	}
}
else if (!empty($_GET['del']) && is_numeric($_GET['del']))
{
	$del = abs(intval($_GET['del']));
	if ($user_id == $del || $del == $arr_group['user_id'] || !in_array($del, explode("||", substr($arr_group['users'], 1, -1)))) $err = true;
	if ($err == false && mysql_query("UPDATE `groups` SET `admins` = '".str_replace("|".$del."|", "", $arr_group['admins'])."', `moders` = '".str_replace("|".$del."|", "", $arr_group['moders'])."', `users` = '".str_replace("|".$del."|", "", $arr_group['users'])."', `count_users` = '".($arr_group['count_users']-1)."' WHERE `id` = '".$id."'") == true)
	{
		$arr_my_groups = mysql_fetch_array(mysql_query("SELECT * FROM `my_groups` WHERE `user_id` = '".$del."' LIMIT 1"));
		mysql_query("UPDATE `my_groups` SET `groups` = '".str_replace("|".$id."|", "", $arr_my_groups['groups'])."' WHERE `user_id` = '".$del."'");
		mysql_query("UPDATE `users` SET count_groups=count_groups-1 WHERE `id` = '".$del."' LIMIT 1");
		$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
		echo ok(user_name3($del).Lang(' - гость сообщества',' - гість спільноти'));
	}
}
else if (!empty($_GET['blacklist']) && is_numeric($_GET['blacklist']))
{
	$blacklist = abs(intval($_GET['blacklist']));
	if ($user_id == $blacklist || $blacklist == $arr_group['user_id'] || !in_array($blacklist, explode("||", substr($arr_group['users'], 1, -1)))) $err = true;
	if ($err == false && mysql_query("UPDATE `groups` SET `admins` = '".str_replace("|".$blacklist."|", "", $arr_group['admins'])."', `moders` = '".str_replace("|".$blacklist."|", "", $arr_group['moders'])."', `users` = '".str_replace("|".$blacklist."|", "", $arr_group['users'])."', `count_users` = '".($arr_group['count_users']-1)."', `blacklist` = '|".$blacklist."|".$arr_group['blacklist']."' WHERE `id` = '".$id."'") == true)
	{
		$arr_my_groups = mysql_fetch_array(mysql_query("SELECT * FROM `my_groups` WHERE `user_id` = '".$blacklist."' LIMIT 1"));
		mysql_query("UPDATE `my_groups` SET `groups` = '".str_replace("|".$id."|", "", $arr_my_groups['groups'])."' WHERE `user_id` = '".$blacklist."'");
		mysql_query("UPDATE `users` SET count_groups=count_groups-1 WHERE `id` = '".$blacklist."' LIMIT 1");
		$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
		echo ok(user_name3($blacklist).Lang(' в черном списке сообщества',' у чорному списку спільноти'));
	}
}

?>