<?php
/********************************************************/
/* NSN Groups                                           */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright  2000-2005 by NukeScripts Network         */
/********************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

$gname = strip_tags($gname, "<b><i><u>");
$gdesc = strip_tags($gdesc, "<br /><b><i><u>");
$gname = stripslashes($gname);
$gdesc = stripslashes($gdesc);
$mname = strip_tags($mname);
$mname = stripslashes($mname);
if ($gname == "" || $mname == "") {
  incoh();
  Max_OpenTable();
  echo "<center><b>"._GR_MISSINGDATA."</b></center><br />\n";
  echo "<center>"._GOBACK."</center>\n";
  Max_CloseTable();
  incof();
}
if (!get_magic_quotes_gpc()) { $gname = addslashes($gname); $gdesc = addslashes($gdesc); }
list($muid) = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `user_id` FROM `".TABLE_USERS."` WHERE `username`='$mname'"));
$GLOBALS['db']->sql_query("INSERT INTO `".$prefix."_bbgroups` VALUES (NULL, '2', '$gname', '$gdesc', '$muid', '0')");
$phpBB = $GLOBALS['db']->sql_nextid();
$GLOBALS['db']->sql_query("INSERT INTO `".$prefix."_bbuser_group` VALUES ('$phpBB', '$muid', '0')");
list($phpBB) = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `group_id` FROM `".$prefix."_bbgroups` WHERE `group_name`='$gname'"));
$GLOBALS['db']->sql_query("INSERT INTO `".TABLE_NSNGR_GROUPS."` VALUES (NULL, '$gname', '$gdesc' , '$gpublic', '$glimit', '$phpBB', '$muid')");
$gid = $GLOBALS['db']->sql_nextid();
$stime = time();
$GLOBALS['db']->sql_query("INSERT INTO `".TABLE_NSNGR_USERS."` VALUES ('$gid', '$muid', '$mname' , '0', '0', '$stime', '0')");
redirect_url("".$admin_file.".php?op=NSNGroupsView");