Файл: groups/handler/new_group.php
Строк: 19
<?php
if (!empty($_POST['name']))
{
if ($user['level'] == 0) if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `groups` WHERE `user_id` = '".$user_id."'"),0) == 3) go(URL.'/groups/admin.php');
$name = check($_POST['name']);
$type = abs(intval($_POST['type']));
$name = substr($name, 0, 200);
if (empty($name)) $err = true;
if ($type != 1) $type = 0;
if ($err == false && mysql_query("INSERT INTO `groups` SET
`user_id` = '".$user_id."',
`name` = '".$name."',
`type` = '".$type."',
`admins` = '|".$user_id."|',
`users` = '|".$user_id."|',
`count_users` = 1,
`time` = '".time()."'") == true)
{
$arr_new_group = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `user_id` = '".$user_id."' ORDER by `time` DESC LIMIT 1"));
$arr_my_groups = mysql_fetch_array(mysql_query("SELECT * FROM `my_groups` WHERE `user_id` = '".$user_id."' LIMIT 1"));
if (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `my_groups` WHERE `user_id` = '".$user_id."' LIMIT 1"),0) == false) mysql_query("INSERT INTO `my_groups` SET `user_id` = '".$user_id."', `groups` = '|".$arr_new_group['id']."|', `time` = '".time()."'");
else mysql_query("UPDATE `my_groups` SET `groups` = '|".$arr_new_group['id']."|".$arr_my_groups['groups']."' WHERE `user_id` = '".$user_id."' LIMIT 1");
mysql_query("UPDATE `users` SET `count_groups` = '".($user['count_groups']+1)."' WHERE `id` = '".$user_id."' LIMIT 1");
go(URL.'/groups/?id='.$arr_new_group['id']);
}
}
?>