<?php

if (!empty($_GET['ok']) && is_numeric($_GET['ok']))
{
	$ok = abs(intval($_GET['ok']));
	if (in_array($ok, explode("||", substr($arr_group['new_users'], 1, -1))) && mysql_query("UPDATE `groups` SET `new_users` = '".str_replace("|".$ok."|", "", $arr_group['new_users'])."', `count_new_users` = '".($arr_group['count_new_users']-1)."', `users` = '|".$ok."|".$arr_group['users']."', `count_users` = '".($arr_group['count_users']+1)."' WHERE `id` = '".$id."'") == true)
	{
		if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `my_groups` WHERE `user_id` = '".$ok."' LIMIT 1"),0) == false) mysql_query("INSERT INTO `my_groups` SET `user_id` = '".$ok."', `groups` = '|".$id."|', `time` = '".time()."'");
		else
		{
			$arr_my_groups = mysql_fetch_array(mysql_query("SELECT * FROM `my_groups` WHERE `user_id` = '".$ok."' LIMIT 1"));
			mysql_query("UPDATE `my_groups` SET `groups` = '|".$id."|".$arr_my_groups['groups']."' WHERE `user_id` = '".$ok."' LIMIT 1");
		}
		mysql_query("UPDATE `users` SET count_groups=count_groups+1 WHERE `id` = '".$ok."' LIMIT 1");
		$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
		echo ok(user_name3($ok).lang(' - заявка принята',' - заявка прийнята'));
	}
}
else if (!empty($_GET['no']) && is_numeric($_GET['no']))
{
	$no = abs(intval($_GET['no']));
	if (in_array($no, explode("||", substr($arr_group['new_users'], 1, -1))) && mysql_query("UPDATE `groups` SET `new_users` = '".str_replace("|".$no."|", "", $arr_group['new_users'])."', `count_new_users` = '".($arr_group['count_new_users']-1)."' WHERE `id` = '".$id."'") == true)
	{
		$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
		echo ok(user_name3($no).lang(' - заявка отклонена',' - заявку відхилено'));
	}
}

?>