<?php

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

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

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

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

  작성날짜 : 2024년 04월 02일 화요일 오후 20시 12분 / 구름많음, 20.5, 이상고온, 23, 4, 0%, 0%, 2.0ms / 나쁨, 52, 22

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

=====================================================================
 피리 카페 심플 > 프로그램 > 피리 카페 관리 > 라이브러리 > 피리 카페 만들기
=====================================================================

piree_cafe_member_join_do(

DELETE FROM `g5__nett_piree_cafe`;

DELETE FROM `g5__nett_piree_cafe_1`;

DELETE FROM `g5__nett_log` WHERE `logb_row_n` > '35';

DELETE FROM `g5__nett_code_english` WHERE `ecob_row_n` > '6';

DELETE FROM `g5__nett_code_english_1` WHERE `ecol_code_row_n` > '6';

DELETE FROM `g5__nett_ip_use` WHERE `ipub_row_n` > '9';

DELETE FROM `g5__nett_ip_use_1` WHERE `ipul_use_row_n` > '9';

piree.me       /  피리는 초보

piree.bicycle  /  피리의 자전거 여행

piree.farming  /  피리의 농업 이야기

piree.dev      /  피리의 개발 이야기

피리가 인생을 살며 보고, 듣고, 느낀 이야기들을 기록하는 피리 카페입니다.
열심히 기록할께요.

*/

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

  $get__p770000_conf = 0;

  $get__p770099 = 1;

  $prog_config_page = 1;

  include_once( piree__path($piree_prog_a[770099]['num'], 'config') );

  function piree_cafe_code_check($func_piree_cafe_code_c, $func_piree_cafe_n=0)
  {

    global $piree;
    global $p770099__piree_cafe_code_len_min_n;
    global $p770099__piree_cafe_code_len_max_n;

    $piree_cafe_code_result_a = array();
    $piree_cafe_code_result_a['piree_cafe_code_error_n']  = 1;
    $piree_cafe_code_result_a['piree_cafe_code_result_s'] = '';

    IF ( $func_piree_cafe_code_c )
    {

      $func_piree_cafe_code_2_c = substr($func_piree_cafe_code_c, 0, 2);

      $piree_cafe_code_len_n = strlen($func_piree_cafe_code_c);

      IF ( $piree_cafe_code_result_a['piree_cafe_code_error_n'] == 1 && !$piree_cafe_code_result_a['piree_cafe_code_result_s'] )
      {

        IF ( !$func_piree_cafe_code_c )
        {

          $piree_cafe_code_result_a['piree_cafe_code_error_n']++;
          $piree_cafe_code_result_a['piree_cafe_code_result_s'] = "[ 카페 코드 ]을 입력해 주세요.";

        }

      }

      IF ( $piree_cafe_code_result_a['piree_cafe_code_error_n'] == 1 && !$piree_cafe_code_result_a['piree_cafe_code_result_s'] )
      {

// ( !preg_match("/^([A-Za-z0-9_.]{1,20})$/", $func_piree_cafe_code_c) )
        IF ( !preg_match("/^([a-zA-Z0-9_.]+)$/", $func_piree_cafe_code_c) )
        {

          $piree_cafe_code_result_a['piree_cafe_code_error_n']++;
          $piree_cafe_code_result_a['piree_cafe_code_result_s'] = "[ 카페 코드 ]은 공백없이 영문자, 숫자, _, .만 입력해 주세요.";

        }

      }

      IF ( $piree_cafe_code_result_a['piree_cafe_code_error_n'] == 1 && !$piree_cafe_code_result_a['piree_cafe_code_result_s'] )
      {

        IF ( $piree_cafe_code_len_n < $p770099__piree_cafe_code_len_min_n )
        {

          $piree_cafe_code_result_a['piree_cafe_code_error_n']++;
          $piree_cafe_code_result_a['piree_cafe_code_result_s'] = "[ 카페 코드 ]의 글자수를 ". $p770099__piree_cafe_code_len_min_n ."자 보다 길게 입력해 주세요.";

        }

      }

      IF ( $piree_cafe_code_result_a['piree_cafe_code_error_n'] == 1 && !$piree_cafe_code_result_a['piree_cafe_code_result_s'] )
      {

        IF ( $p770099__piree_cafe_code_len_max_n < $piree_cafe_code_len_n )
        {

          $piree_cafe_code_result_a['piree_cafe_code_error_n']++;
          $piree_cafe_code_result_a['piree_cafe_code_result_s'] = "[ 카페 코드 ]의 글자수를 ". $p770099__piree_cafe_code_len_max_n ."자 보다 짧게 입력해 주세요.";

        }

      }

        $sql_where_piree_cafe_s = "";

        IF ( $func_piree_cafe_n > 0 )
        {

//$sql_where_piree_cafe_s = " AND `cafe_row_n` != '". $func_piree_cafe_n ."'";

        }

        IF ( $piree_cafe_code_result_a['piree_cafe_code_error_n'] == 1 && !$piree_cafe_code_result_a['piree_cafe_code_result_s'] )
        {

          $sql_select  = "SELECT COUNT(*) FROM `". $piree['cafe'] ."` ";
          $sql_select .= "WHERE `cafe_code_c` = '". $func_piree_cafe_code_c ."'". $sql_where_piree_cafe_s;
//$sql_select .= "WHERE `cafe_code_2_c` = '". $func_piree_cafe_code_2_c ."' AND `cafe_code_c` = '". $func_piree_cafe_code_c ."'". $sql_where_piree_cafe_s;
          $exist_t = sql_efv($sql_select);

          IF ( $exist_t > 0 )
          {

            $piree_cafe_code_result_a['piree_cafe_code_error_n']++;
            $piree_cafe_code_result_a['piree_cafe_code_result_s'] = $sql_select;
            $piree_cafe_code_result_a['piree_cafe_code_result_s'] = "사용할수 없는 [ 카페 코드 ] 입니다. 다시 입력해 주세요.";

          }

        }

    }

    return $piree_cafe_code_result_a;
// ('piree_cafe_code_error_n'=>$piree_cafe_code_result_a['piree_cafe_code_error_n'], 'piree_cafe_code_result_s'=>$piree_cafe_code_result_a['piree_cafe_code_result_s']);

  }

  function piree_cafe_name_check($func_piree_cafe_name_s, $func_piree_cafe_n=0)
  {

    global $piree;
    global $p770099__piree_cafe_name_len_min_n;
    global $p770099__piree_cafe_name_len_max_n;

    $piree_cafe_name_result_a = array();
    $piree_cafe_name_result_a['piree_cafe_name_error_n']  = 1;
    $piree_cafe_name_result_a['piree_cafe_name_result_s'] = '';

    IF ( $func_piree_cafe_name_s )
    {

      $func_piree_cafe_name_2_c = substr($func_piree_cafe_name_s, 0, 2);

      $piree_cafe_name_len_n = strlen($func_piree_cafe_name_s);

      IF ( $piree_cafe_name_result_a['piree_cafe_name_error_n'] == 1 && !$piree_cafe_name_result_a['piree_cafe_name_result_s'] )
      {

        IF ( !$func_piree_cafe_name_s )
        {

          $piree_cafe_name_result_a['piree_cafe_name_error_n']++;
          $piree_cafe_name_result_a['piree_cafe_name_result_s'] = "[ 카페 이름 ]을 입력해 주세요.";

        }

      }

      IF ( $piree_cafe_name_result_a['piree_cafe_name_error_n'] == 1 && !$piree_cafe_name_result_a['piree_cafe_name_result_s'] )
      {

        IF ( $piree_cafe_name_len_n < $p770099__piree_cafe_name_len_min_n )
        {

          $piree_cafe_name_result_a['piree_cafe_name_error_n']++;
          $piree_cafe_name_result_a['piree_cafe_name_result_s'] = "[ 카페 이름 ]을 ". $p770099__piree_cafe_name_len_min_n ." Byte 보다 길게 입력해 주세요.";

        }

      }

      IF ( $piree_cafe_name_result_a['piree_cafe_name_error_n'] == 1 && !$piree_cafe_name_result_a['piree_cafe_name_result_s'] )
      {

        IF ( $p770099__piree_cafe_name_len_max_n < $piree_cafe_name_len_n )
        {

          $piree_cafe_name_result_a['piree_cafe_name_error_n']++;
          $piree_cafe_name_result_a['piree_cafe_name_result_s'] = "[ 카페 이름 ]을 ". $p770099__piree_cafe_name_len_max_n ." Byte 보다 짧게 입력해 주세요.";

        }

      }

        $sql_where_piree_cafe_s = "";

        IF ( $func_piree_cafe_n > 0 )
        {

          $sql_where_piree_cafe_s = " AND `cafe_row_n` != '". $func_piree_cafe_n ."'";

        }

        IF ( $piree_cafe_name_result_a['piree_cafe_name_error_n'] == 1 && !$piree_cafe_name_result_a['piree_cafe_name_result_s'] )
        {

          $sql_select  = "SELECT COUNT(*) FROM `". $piree['cafe'] ."` ";
          $sql_select .= "WHERE `cafe_name_s` = '". $func_piree_cafe_name_s ."'". $sql_where_piree_cafe_s;
          $exist_t = sql_efv($sql_select);

          IF ( $exist_t > 0 )
          {

            $piree_cafe_name_result_a['piree_cafe_name_error_n']++;
            $piree_cafe_name_result_a['piree_cafe_name_result_s'] = "사용할수 없는 [ 카페 이름 ] 입니다. 다시 입력해 주세요.";

          }

        }

    }

    return $piree_cafe_name_result_a;
// ('piree_cafe_name_error_n'=>$piree_cafe_name_result_a['piree_cafe_name_error_n'], 'piree_cafe_name_result_s'=>$piree_cafe_name_result_a['piree_cafe_name_result_s']);

  }

  function piree_cafe_make($func_var_a)
  {

    global $g5;
    global $config;
    global $member;
    global $piree;
    global $piree_prog_a;

    $cafe_a = array();

    $piree_cafe_code_2_c = substr($func_var_a['cafe_code_c'], 0, 2);

    include_once( piree__path($piree_prog_a[770000]['num'], 'save.lib.php') );

    include_once( piree__path($piree_prog_a[770099]['num'], 'piree.cafe.member.join.lib.php') );

/*

    $sql_delete = "DELETE FROM `". $piree['cafe'] ."`";
    sql_query($sql_delete);

    $sql_delete = "DELETE FROM `". $piree['cafe'] ."`";
    sql_query($sql_delete);

*/

      $func_var_a['cafe_code_c'] = save__str($func_var_a['cafe_code_c']);

      check__bad_code($func_var_a['cafe_code_c'],  '카페 코드');

      IF ( !$func_var_a['cafe_code_c'] )
      {

        alert("[ 카페 코드 ]을 입력해 주세요.");
      }

      $piree_cafe_check_result_a = piree_cafe_code_check($func_var_a['cafe_code_c']);

      IF ( $piree_cafe_check_result_a['piree_cafe_error_n'] > 1 )
      {

        alert($piree_cafe_check_result_a['piree_cafe_result_s'], piree__url($piree_prog_a[770099]['num'], 'section.cafe.make.php'));

      }

      $func_var_a['cafe_name_s'] = save__str($func_var_a['cafe_name_s']);

      check__bad_code($func_var_a['cafe_name_s'],  '피리 카페 이름');

      IF ( !$func_var_a['cafe_name_s'] )
      {

        alert("[ 피리 카페 이름 ]을 입력해 주세요.");
      }

    $cafe_member_before_t = 1;

      $piree_cafe_code_2c = substr($func_var_a['cafe_code_c'], 0, 2);

      $sql_insert  = "INSERT INTO `". $piree['cafe'] ."` SET ";
      $sql_insert .= "`cafe_mem_n`            = '". $func_var_a['mb_no'] ."', ";
      $sql_insert .= "`cafe_mem_id`           = '". $func_var_a['mem_id'] ."', ";
      $sql_insert .= "`cafe_mem_nick`         = '". $func_var_a['mem_nick'] ."', ";
      $sql_insert .= "`cafe_mem_level_n`      = '". $func_var_a['mem_level_n'] ."', ";

      $sql_insert .= "`cafe_code_c`           = '". $func_var_a['cafe_code_c'] ."', ";
      $sql_insert .= "`cafe_name_s`           = '". $func_var_a['cafe_name_s'] ."', ";
      $sql_insert .= "`cafe_image_face_s`     = '', ";

      // VER__0_0_1_2
      $sql_insert .= "`cafe_region_n`  = '". $piree_prog_a[770099]['num'] ."', ";

      $sql_insert .= "`cafe_skin_basic_pc_c`  = '". $func_var_a['piree_cafe_skin_basic_pc_c'] ."', ";
      $sql_insert .= "`cafe_skin_basic_mo_c`  = '". $func_var_a['piree_cafe_skin_basic_mo_c'] ."', ";
      $sql_insert .= "`cafe_skin_manage_pc_c` = '". $func_var_a['piree_cafe_skin_manage_pc_c'] ."', ";
      $sql_insert .= "`cafe_skin_manage_mo_c` = '". $func_var_a['piree_cafe_skin_manage_mo_c'] ."', ";

      $sql_insert .= "`cafe_member_t`         = '". $cafe_member_before_t ."', ";

      // VER__0_0_1_2
      $sql_insert .= "`cafe_member_v`         = '". $piree_prog_a[$piree_prog_a[770099]['num']]['version_s'] ."', ";

      $sql_insert .= "`cafe_board_t`          = '0', ";
      $sql_insert .= "`cafe_article_t`        = '0', ";
      $sql_insert .= "`cafe_comment_t`        = '0', ";
      $sql_insert .= "`cafe_image_t`          = '0', ";
      $sql_insert .= "`cafe_intro_s`          = '', ";

      $sql_insert .= "`cafe_ip_s`             = '". $func_var_a['ip_s'] ."', ";
      $sql_insert .= "`cafe_regi_time_n`      = '". $func_var_a['regist_time_n'] ."', ";
      $sql_insert .= "`cafe_modi_time_n`      = '0', ";
      $sql_insert .= "`cafe_relo_time_n`      = '0'";

      IF ( !sql_query($sql_insert) )
      {

        // VER__0_0_1_2
        $sql_alter = "ALTER TABLE `". $piree['cafe'] ."` ADD `cafe_region_n` INT(11) NOT NULL AFTER `cafe_row_n`";
        sql_query($sql_alter, false);

        $sql_alter = "ALTER TABLE `". $piree['cafe'] ."` ADD `cafe_member_v` VARCHAR(255) NOT NULL DEFAULT '' AFTER `cafe_member_t`";
        sql_query($sql_alter, false);

        IF ( !sql_query($sql_update) )
        {

          alert("피리 카페 [ ". $func_var_a['cafe_name_s'] ." ( ". $func_var_a['cafe_code_c'] ." ) ] 의\\n\\nROW를 입력하지 못했습니다.");

        }

      }

      $save_piree_cafe_n = sql_insert_id();

      $put_cafe_member_a = array();
      $put_cafe_member_a['cafe_mem_level_n'] = $func_var_a['mem_level_n'];
      $put_cafe_member_a['mem_n']            = $func_var_a['mb_no'];
      $put_cafe_member_a['mem_id']           = $func_var_a['mem_id'];
      $put_cafe_member_a['mem_nick']         = $func_var_a['mem_nick'];

      $put_cafe_member_a['cafe_s']           = $func_var_a['cafe_name_s'];

      $put_cafe_member_a['article_t']        = 0;
      $put_cafe_member_a['comment_t']        = 0;
      $put_cafe_member_a['image_t']          = 0;

      $put_cafe_member_a['ip_s']             = $func_var_a['ip_s'];
      $put_cafe_member_a['regi_time_n']      = $func_var_a['regist_time_n'];
      $put_cafe_member_a['modi_time_n']      = 0;

      $cafe_member_a = piree_cafe_member_join_do($put_cafe_member_a, $save_piree_cafe_n);

      include_once( piree__path($piree_prog_a[770000]['num'], 'array.lib.php') );

      $put_input_a = array();
      $put_input_a['bca_cafe_n']            = $save_piree_cafe_n;
      $put_input_a['bca_cafe_c']            = $func_var_a['cafe_code_c'];
      $put_input_a['bca_cafe_s']            = $func_var_a['cafe_name_s'];
      $put_input_a['bca_cate_n']            = '0';
      $put_input_a['bca_1_n']               = '0';
      $put_input_a['bca_2_n']               = '0';
      $put_input_a['bca_cate_n_p']          = '';
      $put_input_a['bca_1_s']               = '';
      $put_input_a['bca_2_s']               = '';
      $put_input_a['bca_s_p']               = '';
      $put_input_a['bca_depth_n']           = '0';
      $put_input_a['bca_parent_n']          = '0';
      $put_input_a['bca_regi_time_n']       = G5_SERVER_TIME;
      $put_input_a['bca_cate_s']            = '게시글 전체보기';
      $put_input_a['bca_sub_t']             = '0';
      $put_input_a['bca_row_t']             = '0';
      $put_input_a['bca_article_t']         = '0';
      $put_input_a['bca_device']            = 'both';
      $put_input_a['bca_list_level']        = '1';
      $put_input_a['bca_read_level']        = '1';
      $put_input_a['bca_write_level']       = '2';
      $put_input_a['bca_reply_level']       = '2';
      $put_input_a['bca_comment_level']     = '2';
      $put_input_a['bca_upload_level']      = '1';
      $put_input_a['bca_download_level']    = '1';
      $put_input_a['bca_html_level']        = '1';
      $put_input_a['bca_link_level']        = '1';
      $put_input_a['bca_count_delete']      = '1';
      $put_input_a['bca_count_modify']      = '1';
      $put_input_a['bca_read_point']        = '0';
      $put_input_a['bca_write_point']       = '0';
      $put_input_a['bca_comment_point']     = '0';
      $put_input_a['bca_download_point']    = '0';
      $put_input_a['bca_use_sideview']      = '0';
      $put_input_a['bca_use_file_content']  = '0';
      $put_input_a['bca_use_secret']        = '0';
      $put_input_a['bca_use_dhtml_editor']  = '0';
      $put_input_a['bca_select_editor']     = '';
      $put_input_a['bca_use_rss_view']      = '0';
      $put_input_a['bca_use_good']          = '0';
      $put_input_a['bca_use_nogood']        = '0';
      $put_input_a['bca_use_name']          = '0';
      $put_input_a['bca_use_signature']     = '0';
      $put_input_a['bca_use_ip_view']       = '0';
      $put_input_a['bca_use_list_view']     = '0';
      $put_input_a['bca_use_list_file']     = '0';
      $put_input_a['bca_use_list_content']  = '0';
      $put_input_a['bca_table_width']       = '100';
      $put_input_a['bca_pc_subject_len']    = '60';
      $put_input_a['bca_mo_subject_len']    = '30';
      $put_input_a['bca_pc_page_rows']      = '15';
      $put_input_a['bca_mo_page_rows']      = '15';
      $put_input_a['bca_new']               = '24';
      $put_input_a['bca_hot']               = '100';
      $put_input_a['bca_image_width']       = '600';
      $put_input_a['bca_pc_skin']           = 'piree_basic';
      $put_input_a['bca_mo_skin']           = 'piree_basic';
      $put_input_a['bca_include_head']      = '_head.php';
      $put_input_a['bca_include_tail']      = '_tail.php';
      $put_input_a['bca_pc_content_head']   = '';
      $put_input_a['bca_pc_content_tail']   = '';
      $put_input_a['bca_mo_content_head']   = '';
      $put_input_a['bca_mo_content_tail']   = '';
      $put_input_a['bca_insert_content']    = '';
      $put_input_a['bca_gallery_cols']      = '4';
      $put_input_a['bca_pc_gallery_width']  = '202';
      $put_input_a['bca_pc_gallery_height'] = '150';
      $put_input_a['bca_mo_gallery_width']  = '125';
      $put_input_a['bca_mo_gallery_height'] = '100';
      $put_input_a['bca_upload_size']       = '1048576';
      $put_input_a['bca_reply_order']       = '1';
      $put_input_a['bca_use_search']        = '1';
      $put_input_a['bca_order']             = '0';
      $put_input_a['bca_count_write']       = '0';
      $put_input_a['bca_count_comment']     = '0';
      $put_input_a['bca_write_min']         = '0';
      $put_input_a['bca_write_max']         = '0';
      $put_input_a['bca_comment_min']       = '0';
      $put_input_a['bca_comment_max']       = '0';
      $put_input_a['bca_notice']            = '';
      $put_input_a['bca_upload_count']      = '2';
      $put_input_a['bca_use_email']         = '0';
      $put_input_a['bca_use_cert']          = '';
      $put_input_a['bca_use_sns']           = '0';
      $put_input_a['bca_use_captcha']       = '0';
      $put_input_a['bca_sort_field']        = '';

      $sql_common_s = get__sql_common($put_input_a);

      $sql_insert  = "INSERT INTO `". $piree['cafe_board'] ."` SET ";
      $sql_insert .= $sql_common_s;

      IF ( !sql_query($sql_insert) )
      {

        alert("피리 카페 [ ". $func_var_a['cafe_name_s'] ." ( ". $func_var_a['cafe_code_c'] ." ) ] 의\\n\\n게시판 기본 설정을 입력하지 못했습니다.");

      }

      $save_board_config_row_n = sql_insert_id();

      $sql_select  = "SELECT COUNT(*) FROM `". $piree['cafe_member'] ."` ";
      $sql_select .= "WHERE `cfml_cafe_n` = '". $piree_cafe_n ."'";
      $piree_cafe_member_t = (int)sql_efv($sql_select);

      $sql_update  = "UPDATE `". $piree['cafe'] ."` SET ";
      $sql_update .= "`cafe_board_config_n` = '". $save_board_config_row_n ."', ";
      $sql_update .= "`cafe_member_t`       = '". $piree_cafe_member_t ."' ";
      $sql_update .= "WHERE `cafe_row_n` = '". $save_piree_cafe_n ."'";

      IF ( !sql_query($sql_update) )
      {
        alert("피리 카페 [ ". $func_var_a['cafe_name_s'] ." ( ". $func_var_a['cafe_code_c'] ." ) ] 의\\n\\nROW의 회원수를 새로고침하지 못했습니다.");
      }

    return $save_piree_cafe_n;

  }

/*
$work_saved_a['piree_cafe.join.member.base_n']
$work_saved_a['piree_cafe.join.member.join_now_n']
$work_saved_a['piree_cafe.join.member.ip.ip_s']

$work_saved_a['piree_cafe.member.base_n']
$work_saved_a['piree_cafe.member.id']
$work_saved_a['piree_cafe.member.nick']
$work_saved_a['piree_cafe.member.all_t']
$work_saved_a['cafe.make.now_n']
=
$work_saved_a['piree_cafe.piree_cafe_n']
$func_var_a['cafe_name_s']

$func_var_a['cafe_code_c']
*/

/*

jimb_mem_level_n

logb_piree_cafe_n
logb_prog_n
logb_data_row_n
logb_mem_n

ipub_piree_cafe_n
ipub_mem_n

*/

?>