<?
include_once("./_common.php");

if ($is_admin != "super")
  alert("관리자만 실행가능합니다.", $g4[path]);

if(!$bo_table && !$gr_id){


	   //일괄적용옵션이 있는경우
	   if($all_set == '1'){

	   //모든 그릅페이지에 적용
	   $mct     = " po_poll9      = 'gr_id' ";
	   $sql = "  po_poll4 = '$se_02' ";
	   sql_query(" update $g4[site_bill] set $sql where  $mct ");

	   //모든 게시판에도 일괄적용
	   $mct     = " po_poll9      = 'bo_table' ";
	   $sql = "  po_poll4 = '$se_02' ";
        sql_query(" update $g4[site_bill] set $sql where  $mct ");


	   }
	   else{//체크옵션이 없음, 메인상단 적용

	   //자료 유무검사
	   $mct     = " po_poll1      = 'skin' ";
	   $mct    .= " and po_poll2  = 'head_menu' ";
	   $row = sql_fetch("select count(*) as cnt from $g4[site_bill]  where $mct ");

	   $sql = "  po_poll3 = '$se_02' ";

	   if($row[cnt]){
        sql_query(" update $g4[site_bill] set $sql where  $mct ");

	   }
	   else{
         $result  = sql_query(" insert into $g4[site_bill] set $sql where  $mct 
															   ");
	   }
	  }



}
else if($gr_id && !$bo_table){




	   //그릅 상단 업데이트
	   $mct     = " po_poll9      = 'gr_id' ";
	   $mct    .= " and po_poll1  = '$gr_id' ";
	   $row = sql_fetch("select count(*) as cnt from $g4[site_bill]  where $mct ");

	   $sql = "  po_poll4 = '$se_02' ";

	   if($row[cnt]){
        sql_query(" update $g4[site_bill] set $sql where  $mct ");

	   }
	   else{
         $result  = sql_query(" insert into $g4[site_bill] set $sql where  $mct ");
	   }

	   //일괄적용옵션이 있는경우
	   if($all_set == '1'){

	   //해당 그릅의 모든 게시판 업데이트
	   $mct     = " po_poll9      = 'bo_table' ";
	   $mct    .= " and po_poll3  =  '$gr_id'  ";
	   $sql = "  po_poll4 = '$se_02' ";
        sql_query(" update $g4[site_bill] set $sql where  $mct ");


	   }


}

else if($bo_table){

	   //자료 유무검사
	   $mct     = " po_poll9      = 'bo_table' ";
	   $mct    .= " and po_poll1  = '$bo_table' ";
	   $row = sql_fetch("select count(*) as cnt from $g4[site_bill]  where $mct ");

	   $sql = "  po_poll4 = '$se_02' ";

	   if($row[cnt]){
        sql_query(" update $g4[site_bill] set $sql where  $mct ");

	   }
	   else{
         $result  = sql_query(" insert into $g4[site_bill] set $sql where  $mct ");
	   }

}



if($bo_table){
$url_path = $g4[bbs_path]."/board.php?bo_table=".$bo_table."&act=".$act;
}
elseif(!$bo_table && $gr_id){
$url_path = $g4[path]."/index.php?gr_id=".$gr_id."&act=".$act;
}
else{
$url_path = $g4[path]."?act=".$act;
}

goto_url($url_path);

?>
