<?php

if (!empty($_POST['name']))
{
	
	$name = check($_POST['name']);
	$status = check($_POST['status']);
	$url = check($_POST['url']);
	$region = abs(intval($_POST['region']));
	$city = check($_POST['city']);
	$category = abs(intval($_POST['category']));
	$about = check($_POST['about']);
	$name = substr($name, 0, 200);
	$status = substr($status, 0, 500);
	$url = substr($url, 0, 100);
	$city = substr($city, 0, 100);
	$about = substr($about, 0, 10000);
	
	if (empty($name)) $err = true;
	if (preg_match("~^(?:(?:https?|ftp|telnet)://(?:[a-z0-9_-]{1,32}".
   "(?::[a-z0-9_-]{1,32})?@)?)?(?:(?:[a-z0-9-]{1,128}\.)+(?:com|net|".
   "org|mil|edu|arpa|gov|biz|info|aero|inc|name|[a-z]{2})|(?!0)(?:(?".
   "!0[^.]|255)[0-9]{1,3}\.){3}(?!0|255)[0-9]{1,3})(:[0-9]{1,5})?(?:/[а-яa-z0-9.,_@%\(\)\*&".
   "?+=\~/-]*)?(?:#[^ '\"&<>]*)?$~i", $url)) {if (!preg_match("/http|https|ftp|telnet/", $url)) $url = 'http://'.$url;} else $url = '';
	if (empty($category) || $category < 1 || $category > 42) $category = 0;
	if (empty($region) || empty($city) || $region < 1 || $region > 25) $region = 0;
	if (!empty($city) && $region == 0) $city = '';
   
	if ($err == false && mysql_query("UPDATE `groups` SET
	`name` = '".$name."',
	`status` = '".$status."',
	`url` = '".$url."',
	`region` = '".$region."',
	`city` = '".$city."',
	`category` = '".$category."',
	`about` = '".$about."'
	WHERE `id` = '".$id."'") == true)
	{
		$arr_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `id` = '".$id."' LIMIT 1"));
		echo ok(lang('Изменения сохранены','Зміни збережені'));
	}
}

?>