<?
include_once("./_common.php");
?>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<?
//업로드한 파일을 저장할 디렉토리
//$save_dir = "c:\\APM_Setup\\htdocs\\";
// linux $save_dir = "g4[path]/temp";  // chmod 707 temp 해주세요.
//chmod($save_dir, 0707);
// echo "111";
//파일이 HTTP POST 방식을 통해 정상적으로 업로드되었는지 확인한다.
if(is_uploaded_file($_FILES["books"]["tmp_name"]))
{
 

// echo "1111";
   //파일을 저장할 디렉토리 및 파일명
   $dest = $save_dir.$_FILES["books"]["name"];
 
   //파일을 지정한 디렉토리에 저장
  // echo $_FILES["books"]["tmp_name"];
   if(!move_uploaded_file($_FILES["books"]["tmp_name"], $dest))
   {
      die("파일을 읽을 수 없습니다. 다시 올려주세요.");
   }
  // echo $dest;
	$fp = fopen($dest, "r")  or die("파일을 읽을 수 없습니다. 다시 올려주세요.");
	$i=0;
	while(!feof($fp)) {
		$fileStr = fgets($fp, 1024);
		if($i > 0 ) { $content_sep = explode(",", $fileStr);
		//echo $content_sep[0];
		if($content_sep[0] != "") {
		$content_sep[0] = iconv("EUC-KR", "UTF-8", trim($content_sep[0]));
		$content_sep[1] = iconv("EUC-KR", "UTF-8", trim($content_sep[1]));
		$content_sep[2] = iconv("EUC-KR", "UTF-8", trim($content_sep[2]));
		$content_sep[3] = iconv("EUC-KR", "UTF-8", trim($content_sep[3]));
		$content_sep[4] = iconv("EUC-KR", "UTF-8", trim($content_sep[4]));
		$content_sep[5] = iconv("EUC-KR", "UTF-8", trim($content_sep[5]));
//		echo $content_sep[1];
	

	$bo_table = "members";
	$table = "g5_write_members";
	 $wr_num = get_next_num($table);


					    $sql = " insert into $table
                set wr_num = '$wr_num',
                     wr_reply = '$wr_reply',
                     wr_comment = 0,
                     ca_name = '$ca_name',
                     wr_option = '$html,$secret,$mail',
                wr_subject = '$content_sep[2]',
                     wr_content = '$wr_content',
                     wr_link1 = '$wr_link1',
                     wr_link2 = '$wr_link2',
                     wr_link1_hit = 0,
                     wr_link2_hit = 0,
                     wr_hit = 0,
                     wr_good = 0,
                     wr_nogood = 0,
                     mb_id = '{$member['mb_id']}',
                     wr_password = '$wr_password',
                     wr_name = '$wr_name',
                     wr_email = '$wr_email',
                     wr_homepage = '$wr_homepage',
                     wr_datetime = '".G5_TIME_YMDHIS."',
                     wr_last = '".G5_TIME_YMDHIS."',
                     wr_ip = '{$_SERVER['REMOTE_ADDR']}',
                      wr_1 = '$content_sep[0]',
                    wr_2 = '$content_sep[2]',
                    wr_3 = '$content_sep[3]',
                    wr_4 = '$content_sep[4]',
                    wr_5 = '0',
                    wr_6 = '정상',
                    wr_7 = '$wr_7',
                    wr_8 = '$wr_8',
                    wr_9 = '$wr_9',
                    wr_10 = '$wr_10' ";

    sql_query($sql);

    $wr_id = mysql_insert_id();


    // 부모 아이디에 UPDATE
    sql_query(" update $table set wr_parent = '$wr_id' where wr_id = '$wr_id' ");

    // 새글 INSERT
    sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");

    // 게시글 1 증가
    sql_query("update {$g5['board_table']} set bo_count_write = bo_count_write + 1 where bo_table = '{$bo_table}'");
		}
		}
		$i++;
	}
}
else "파일이 없습니다";
?>

<meta http-equiv="refresh" content="0; url=../bbs/board.php?bo_table=members">