<?php

/*
=====================================================================

  프로젝트 이름 : 피리 카페 심플

  만든사람 : 피리 PIREE ( tosports@naver.com )

  홈페이지 : https://piree.kr/nett_dev

  작성날짜 : 2024년 04월 18일 목요일 오전 09시 30분 / 맑음, 15.9, 일교차 주의, 24, 8, 0%, 0%, 2.4ms / 매우 나쁨, 133, 51, 0.014

  저 작 권 : Copyright ⓒ 2024 피리 piree.kr All right reserved
              그누보드 외에 추가된 소스는~
              만든사람의 허락없이 무단으로 사용할수 없습니다.
              사용하고자 할 경우 만든사람의 허락을 받아야 합니다.
              http://.piree.kr 에 문의해 주세요.

=====================================================================
 피리 카페 심플 > 프로그램 > 피리 카페 관리 > 내 카페 > 게시판 > 게시글 다중 처리하기
=====================================================================

*/

  IF (!defined('_GNUBOARD_'))                      EXIT;

    IF ( count($board_cate_n_a) > 0 )
    {

      FOREACH ( $board_cate_n_a AS $loop_cate_n=>$val_out)
      {

        IF ( $loop_cate_n > 0 )
        {

          IF ( $board_cate_list_a[$loop_cate_n]['bca_depth_n'] == 2 )
          {

            $loop_cate_1dep_n = $board_cate_list_a[$loop_cate_n]['bca_1_n'];

            $board_cate_1_a[$loop_cate_1dep_n] = $loop_cate_1dep_n;

          }

          $sql_select = $sql_select_article ." AND `wr_pi_board_cate_n` = '". $loop_cate_n ."'";
          $artilce_this_t = (int)sql_efv($sql_select);

          $sql_select = $sql_select_comment ." AND `wr_pi_board_cate_n` = '". $loop_cate_n ."'";
          $comment_this_t = (int)sql_efv($sql_select);

          $sql_update  = "UPDATE `". $piree['cafe_board'] ."` SET ";
          $sql_update .= "`bca_count_write`   = '". $artilce_this_t ."', ";
          $sql_update .= "`bca_count_comment` = '". $comment_this_t ."' ";
          $sql_update .= "WHERE `bca_cafe_n` = '". $piree_cafe_n ."' AND `bca_cate_n` = '". $loop_cate_n ."'";

          IF ( !sql_query($sql_update) )
          {
            alert("[ ". $board_cate_list_a[$loop_cate_n]['bca_cate_s'] ." - 2 ]의 게시글, 댓글 수를 새로고침하지 못했습니다.");
          }

        }

      }

      IF ( count($board_cate_1_a) > 0 )
      {

        FOREACH ( $board_cate_1_a AS $loop_cate_1_n=>$val_in)
        {

          IF ( $loop_cate_1_n > 0 )
          {

            $sql_select = $sql_select_article ." AND (`wr_pi_board_cate_n` BETWEEN '". $loop_cate_1_n ."' AND '". ($loop_cate_1_n+99) ."')";
            $artilce_this_t = (int)sql_efv($sql_select);

            $sql_select = $sql_select_comment ." AND (`wr_pi_board_cate_n` BETWEEN '". $loop_cate_1_n ."' AND '". ($loop_cate_1_n+99) ."')";
            $comment_this_t = (int)sql_efv($sql_select);

            $sql_update  = "UPDATE `". $piree['cafe_board'] ."` SET ";
            $sql_update .= "`bca_count_write`   = '". $artilce_this_t ."', ";
            $sql_update .= "`bca_count_comment` = '". $comment_this_t ."' ";
            $sql_update .= "WHERE `bca_cafe_n` = '". $piree_cafe_n ."' AND `bca_cate_n` = '". $loop_cate_1_n ."'";

            IF ( !sql_query($sql_update) )
            {
              alert("[ ". $board_cate_list_a[$loop_cate_1_n]['bca_cate_s'] ." - 2 ]의 게시글, 댓글 수를 새로고침하지 못했습니다.");
            }

          }

        }

      }

    }

/*

    $sql_select = $sql_select_cafe ." AND `wr_is_comment` = '0'";
    $artilce_cafe_t = (int)sql_efv($sql_select);

    $sql_select = $sql_select_cafe ." AND `wr_is_comment` = '1'";
    $comment_cafe_t = (int)sql_efv($sql_select);

    $sql_update  = "UPDATE `". $piree['cafe_board'] ."` SET ";
    $sql_update .= "`bca_count_write`   = '". $artilce_cafe_t ."', ";
    $sql_update .= "`bca_count_comment` = '". $comment_cafe_t ."' ";
    $sql_update .= "WHERE `bca_cafe_n` = '". $piree_cafe_n ."' AND `bca_cate_n` = '0'";

    IF ( !sql_query($sql_update) )
    {
      alert("[ ". $piree_cafe_name_s ." ] 카페의 게시글, 댓글 수를 새로고침하지 못했습니다.");
    }

*/

    $sql_update  = "UPDATE `". $piree['cafe_board'] ."` SET ";
    $sql_update .= "`bca_count_write` = `bca_count_write` - '". $count_write ."', ";
    $sql_update .= "`bca_count_comment` = `bca_count_comment` - '". $count_comment ."' ";
    $sql_update .= "WHERE `bca_cafe_n` = '". $piree_cafe_n ."' AND `bca_cate_n` = '0'";

    IF ( !sql_query($sql_update) )
    {
      alert("[ ". $piree_cafe_name_s ." ] 카페의 게시글, 댓글 수를 새로고침하지 못했습니다.");
    }

    IF ( $count_write > 0 || $count_comment > 0 )
    {

       $sql_update  = "UPDATE `". $g5['board_table'] ."` SET ";
       $sql_update .= "`bo_count_write` = `bo_count_write` - '". $count_write ."', ";
       $sql_update .= "`bo_count_comment` = `bo_count_comment` - '". $count_comment ."' ";
       $sql_update .= "WHERE `bo_table` = '". $piree['cafe_board_code'] ."'";
       sql_query($sql_update);

    }

?>