<?
$sub_menu = "300200";
include_once("./_common.php");

if ($w == 'u')
    check_demo();

auth_check($auth[$sub_menu], "w");

if ($is_admin != "super" && $w == "") alert("拒绝访问！只有管理员才可以访问！");

if (!preg_match("/^([A-Za-z0-9_]{1,10})$/", $gr_id))
    alert("论坛版块ID必须使用英文，数字，下划线及其组合（10个字符以内且不可以使用空格符号）");

if (!$gr_subject) alert("请输入论坛版块名称");

check_token();

$sql_common = " gr_subject    = '$_POST[gr_subject]',
                gr_admin      = '$_POST[gr_admin]',  
                gr_use_access = '$_POST[gr_use_access]',
                gr_1_subj     = '$_POST[gr_1_subj]',
                gr_2_subj     = '$_POST[gr_2_subj]',
                gr_3_subj     = '$_POST[gr_3_subj]',
                gr_4_subj     = '$_POST[gr_4_subj]',
                gr_5_subj     = '$_POST[gr_5_subj]',
                gr_6_subj     = '$_POST[gr_6_subj]',
                gr_7_subj     = '$_POST[gr_7_subj]',
                gr_8_subj     = '$_POST[gr_8_subj]',
                gr_9_subj     = '$_POST[gr_9_subj]',
                gr_10_subj    = '$_POST[gr_10_subj]',
                gr_1          = '$_POST[gr_1]',
                gr_2          = '$_POST[gr_2]',
                gr_3          = '$_POST[gr_3]',
                gr_4          = '$_POST[gr_4]',
                gr_5          = '$_POST[gr_5]',
                gr_6          = '$_POST[gr_6]',
                gr_7          = '$_POST[gr_7]',
                gr_8          = '$_POST[gr_8]',
                gr_9          = '$_POST[gr_9]',
                gr_10         = '$_POST[gr_10]' ";

if ($w == "") 
{
    $sql = " select count(*) as cnt from $g4[group_table] where gr_id = '$_POST[gr_id]' ";
    $row = sql_fetch($sql);
    if ($row[cnt]) 
        alert("已有相同的论坛版块ID");

    $sql = " insert into $g4[group_table]
                set gr_id = '$_POST[gr_id]',
                    $sql_common ";
    sql_query($sql);
} 
else if ($w == "u") 
{
    $sql = " update $g4[group_table]
                set $sql_common
              where gr_id = '$_POST[gr_id]' ";
    sql_query($sql);
} 
else
    alert("数据传送错误！请联系管理员");

goto_url("./boardgroup_form.php?w=u&gr_id=$gr_id&$qstr");
?>
