<?
@set_time_limit(0);

include_once ("../config.php");

// 파일이 존재한다면 설치할 수 없다.
/*
if (file_exists("../dbconfig.php")) {
    echo "<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'>";
    echo <<<HEREDOC
    <script language="JavaScript">
    alert("설치하실 수 없습니다.");
    location.href="../";
    </script>
HEREDOC;
    exit;
}
*/
$gmnow = gmdate("D, d M Y H:i:s") . " GMT";
header("Expires: 0"); // rfc2616 - Section 14.21
header("Last-Modified: " . $gmnow);
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: pre-check=0, post-check=0, max-age=0"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0

$mysql_host  = $_POST[mysql_host];
$mysql_user  = $_POST[mysql_user];
$mysql_pass  = $_POST[mysql_pass];
$mysql_db    = $_POST[mysql_db];
$admin_id    = $_POST[admin_id];
$admin_pass  = $_POST[admin_pass];
$admin_name  = $_POST[admin_name];
$admin_email = $_POST[admin_email];

if (strtolower($g4[charset]) == 'utf-8') @mysql_query("set names utf8");
else if (strtolower($g4[charset]) == 'euc-kr') @mysql_query("set names euckr");
$dblink = @mysql_connect($mysql_host, $mysql_user, $mysql_pass);
if (!$dblink) {
    echo "<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'>";
    echo "<script language='JavaScript'>alert('MySQL Host, User, Password 를 확인해 주십시오.');history.back();</script>";
    exit;
}

if (strtolower($g4[charset]) == 'utf-8') @mysql_query("set names utf8");
else if (strtolower($g4[charset]) == 'euc-kr') @mysql_query("set names euckr");
$select_db = @mysql_select_db($mysql_db, $dblink);
if (!$select_db) {
    echo "<meta http-equiv='content-type' content='text/html; charset=$g4[charset]'>";
    echo "<script language='JavaScript'>alert('MySQL DB 를 확인해 주십시오.');history.back();</script>";
    exit;
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=<?=$g4[charset]?>">
<title>지음빌더 for 그누보드4 설치 (3/3) - DB</title>
<style type="text/css">
body {
    font-family: 굴림;
	font-size: 12px;
	background:url("./img/bg.gif");
}
td { font-size:12px; }
td input[type="text"] { font-size:12px; border:0; }
.nobox {
    border-style:none;
    font-family:굴림;
	border:0;
    font-size: 12px;
}
#zmb_agree_body	{ text-align:center; padding:50px; }
#zmb_agree_box	{ width:700px; margin:20px auto; padding:20px; background:#fff; border:1px solid #D3D3D3; }

</style>
</head>

<body background="img/all_bg.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="zmb_agree_body">
<div><img src="img/box_title.gif"></div>
<div id="zmb_agree_box">
    <form name=frminstall2>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
		<td align="center">설치를 시작합니다. <font color="#CC0000">설치중 작업을 중단하지 마십시오. </font></td>
    </tr>
	<tr>
		<td align="center"><input name="status_bar" type="text" size="60" readonly></div>
		</td>
	</tr>
	<tr>
		<td>
		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="body">
		<tr>
            <td><input type=text name=job1 class=nobox size=80 readonly></td>
		</tr>
        <tr>
            <td><input type=text name=job2 class=nobox size=80 readonly></td>
        </tr>
        <tr>
            <td><input type=text name=job3 class=nobox size=80 readonly></td>
        </tr>
        <tr>
             <td><input type=text name=job4 class=nobox size=80 readonly></td>
        </tr>
		<tr>
		<td><input type=text name=job5 class=nobox size=90 readonly></td>
		</tr>
        </table>
		</td>
	</tr>
	<tr>
		<td><input type=text name=job6 class=nobox size=90 readonly></td>
	</tr>
	</table>
    <div style="align:center; padding:20px;"><input type="button" name="btn_next" disabled value="메인화면" onclick="location.href='../';" style="cursor:pointer; height:40px;">
	<input type="button" value="도움말" onclick="window.open('about:blank').location.href='http://ziumb.tistory.com';" style="cursor:pointer; height:40px;"></div>
    </form>
</div>
<?
flush(); usleep(50000);




/*
// 그누보드 테이블 생성 --------------------------------
$sql = " desc $cfg[table_default] ";
$result = @mysql_query($sql);
// 그누보드 재설치에 체크하셨거나 그누보드가 설치되어 있지 않다면
if ($del_gnuboard || !$result) {
    $file = implode("", file("./sql_schema.sql"));
    eval("\$file = \"$file\";");

    $f = explode(";", $file);
    for ($i=0; $i<count($f); $i++) {
        if (trim($f[$i]) == "") continue;
        mysql_query($f[$i]) or die(mysql_error());
    }
}
// 그누보드 테이블 생성 end --------------------------------
*/

/*
$str = implode("", file("../common.php"));
$filename = "db" . substr(md5(uniqid("")),0,8) . ".php";
$str = str_replace("dbconfig.php", $filename, $str);
$f = fopen("../common.php", "w");
fputs($f, $str);
fclose($f);
*/


// 테이블 생성 ------------------------------------
$file = implode("", file("./sql_gnuboard4.sql"));
eval("\$file = \"$file\";");

$f = explode(";", $file);
for ($i=0; $i<count($f); $i++) {
    if (trim($f[$i]) == "") continue;
    mysql_query($f[$i]) or die(mysql_error());
}
// 테이블 생성 ------------------------------------


echo "<script>document.frminstall2.job1.value='전체 테이블 생성중';</script>";
flush(); usleep(50000);

// 우편번호 INSERT
/*
$zipfile = fopen("../$g4[admin]/sql_zip.sql", "r");
$i = 0;
while (!feof($zipfile)) {
    $zipline = fgetss($zipfile, 1024);
    if (!preg_match("/^INSERT/i", $zipline)) {
        continue;
    }

    $zipline = preg_replace("/_TABLE_ZIP_/", $g4[zip_table], $zipline);
    $zipline = preg_replace("/;/", "", $zipline);
    //@mysql_query($zipline) or die(mysql_error() . "<p>" . $zipline);
    @mysql_query($zipline);

    if ($i++%1000==0) {
        echo "<script language='JavaScript'>document.frminstall2.status_bar.value += '■';</script>\n";
        flush();
        usleep(500);
    }
}
fclose($zipfile);
*/

for ($i=0; $i<45; $i++)
{
    echo "<script language='JavaScript'>document.frminstall2.status_bar.value += '■';</script>\n";
    flush();
    usleep(500);
}

echo "<script>document.frminstall2.job1.value='전체 테이블 생성 완료';</script>";
flush(); usleep(50000);

$read_point = 0;
$write_point = 0;
$comment_point = 0;
$download_point = 0;

//-------------------------------------------------------------------------------------------------
// config 테이블 설정
$sql = " insert into $g4[config_table]
            set cf_title = '지음빌더',
                cf_admin = '$admin_id',
                cf_use_point = '1',
                cf_use_norobot = '0',
                cf_use_copy_log = '1',
                cf_login_point = '0',
                cf_memo_send_point = '0',
                cf_cut_name = '15',
                cf_nick_modify = '30',
                cf_new_skin = 'basic',
                cf_new_rows = '15',
                cf_search_skin = 'basic',
                cf_connect_skin = 'basic',
                cf_read_point = '$read_point',
                cf_write_point = '$write_point',
                cf_comment_point = '$comment_point',
                cf_download_point = '$download_point',
                cf_search_bgcolor = 'YELLOW',
                cf_search_color = 'RED',
                cf_write_pages = '10',
                cf_link_target = '_blank',
                cf_delay_sec = '15',
                cf_filter = '18아,18놈,18새끼,18년,18뇬,18노,18것,18넘,개년,개놈,개뇬,개새,개색끼,개세끼,개세이,개쉐이,개쉑,개쉽,개시키,개자식,개좆,게색기,게색끼,광뇬,뇬,눈깔,뉘미럴,니귀미,니기미,니미,도촬,되질래,뒈져라,뒈진다,디져라,디진다,디질래,병쉰,병신,뻐큐,뻑큐,뽁큐,삐리넷,새꺄,쉬발,쉬밸,쉬팔,쉽알,스패킹,스팽,시벌,시부랄,시부럴,시부리,시불,시브랄,시팍,시팔,시펄,실밸,십8,십쌔,십창,싶알,쌉년,썅놈,쌔끼,쌩쑈,썅,써벌,썩을년,쎄꺄,쎄엑,쓰바,쓰발,쓰벌,쓰팔,씨8,씨댕,씨바,씨발,씨뱅,씨봉알,씨부랄,씨부럴,씨부렁,씨부리,씨불,씨브랄,씨빠,씨빨,씨뽀랄,씨팍,씨팔,씨펄,씹,아가리,아갈이,엄창,접년,잡놈,재랄,저주글,조까,조빠,조쟁이,조지냐,조진다,조질래,존나,존니,좀물,좁년,좃,좆,좇,쥐랄,쥐롤,쥬디,지랄,지럴,지롤,지미랄,쫍빱,凸,퍽큐,뻑큐,빠큐,ㅅㅂㄹㅁ',
                cf_possible_ip = '',
                cf_intercept_ip = '',
                cf_member_skin = 'zm.basic',
                cf_register_level = '2',
                cf_register_point = '1000',
                cf_icon_level = '2',
                cf_leave_day = '30',
                cf_search_part = '10000',
                cf_email_use = '1',
                cf_prohibit_id = 'admin,administrator,관리자,운영자,어드민,주인장,webmaster,웹마스터,sysop,시삽,시샵,manager,매니저,메니저,root,루트,su,guest,방문객',
                cf_prohibit_email = '',
                cf_new_del = '30',
                cf_memo_del = '180',
                cf_visit_del = '180',
                cf_popular_del = '180',
                cf_use_member_icon = '2',
                cf_member_icon_size = '5000',
                cf_member_icon_width = '22',
                cf_member_icon_height = '22',
                cf_login_minutes = '10',
                cf_image_extension = 'gif|jpg|jpeg|png',
                cf_flash_extension = 'swf',
                cf_movie_extension = 'asx|asf|wmv|wma|mpg|mpeg|mov|avi|mp3',
                cf_formmail_is_member = '1',
                cf_page_rows = '15',
                cf_stipulation = '파일 [ ZMB.MEMBER.txt ]를 수정해 주세요.',
                cf_privacy = '파일 [ ZMB.PRIVACY.txt ]를 수정해 주세요.'
                ";
mysql_query($sql) or die(mysql_error() . "<p>" . $sql);

// 운영자 회원가입
$sql = " insert into $g4[member_table]
            set mb_id = '$admin_id',
                mb_password = PASSWORD('$admin_pass'),
                mb_name = '$admin_name',
                mb_nick = '$admin_name',
                mb_email = '$admin_email',
                mb_jumin = PASSWORD('1111111111118'),
                mb_level = '10',
                mb_mailling = '1',
                mb_open = '1',
                mb_email_certify = '$g4[time_ymdhis]',
                mb_datetime = '$g4[time_ymdhis]',
                mb_ip = '$_SERVER[REMOTE_ADDR]'
                ";
@mysql_query($sql);

echo "<script>document.frminstall2.job2.value='DB설정 완료';</script>";
flush(); usleep(50000);
//-------------------------------------------------------------------------------------------------

// DB 설정 파일 생성
$file = "../dbconfig.php";
$f = @fopen($file, "w");

fwrite($f, "<?\n");
//fwrite($f, "if (!preg_match('/^'.str_replace('/', '\/', dirname(__FILE__)).'/', \$_SERVER['SCRIPT_FILENAME'])) die('정상적인 접근이 아님.');\n");
//fwrite($f, "if (\$dbconfig_file != str_replace(\$dirname, '', __FILE__)) die('정상적인 접근이 아님');\n");
fwrite($f, "\$mysql_host = '$mysql_host';\n");
fwrite($f, "\$mysql_user = '$mysql_user';\n");
fwrite($f, "\$mysql_password = '$mysql_pass';\n");
fwrite($f, "\$mysql_db = '$mysql_db';\n");
fwrite($f, "?>");

fclose($f);
@chmod($file, 0606);
echo "<script>document.frminstall2.job3.value='DB설정 파일 생성 완료';</script>";

/*
$str = implode("", file("../common.php"));
$str = str_replace("__MYSQL_HOST__", $mysql_host, $str);
$str = str_replace("__MYSQL_USER__", $mysql_user, $str);
$str = str_replace("__MYSQL_PASS__", $mysql_pass, $str);
$str = str_replace("__MYSQL_DB__",   $mysql_db,   $str);
$f = fopen("../common.php", "w");
fputs($f, $str);
fclose($f);
echo "<script>document.frminstall2.job3.value='DB설정값 변환 완료';</script>";
*/

flush(); usleep(50000);


// 1.00.09 - data/log 삽입
// 디렉토리 생성
//-- 세션을 하위 디렉토리에 저장
//-- zm.exp 추가 20130504
$dir_arr = array ("../extend",
				  "../data",
				  "../data/file",
                  "../data/log",
                  "../data/member",
				  "../data/session",
				  "../data/session/zium",
                  "../data/$g4[cheditor4]",
                  "../data/$g4[editor]",
				  "../data/zm.exp",
				  "../data/zm.exp/service");

for ($i=0; $i<count($dir_arr); $i++)
{
    @mkdir($dir_arr[$i], 0707);
    @chmod($dir_arr[$i], 0707);

    // 디렉토리에 있는 파일의 목록을 보이지 않게 한다.
    $file = $dir_arr[$i] . "/index.php";
    $f = @fopen($file, "w");
    @fwrite($f, "");
    @fclose($f);
    @chmod($file, 0606);
}



//-- 관리자 추가 회원정보 넣기
$sql	= "INSERT INTO `zm_member` (`db_id`, `db_profile_pic`, `db_location`, `db_bloodtype`, `db_belong`, `db_school`, `db_sns_link`, `db_zium_money`, `db_new_memo`, `db_memosend_date`, `db_memo_today`, `db_memo_latesend`, `db_memo_recv_condition`, `db_profile_open_level`, `db_write_latedate`, `db_write_today`, `db_sms_certify`) VALUES ('admin', '', '', '', '', '', '', 0, 0, '0000-00-00', 0, '', '', '1/2', '0000-00-00', 0, '0000-00-00 00:00:00')";
mysql_query($sql);


mysql_query("alter table g4_memo add me_save_mb_id varchar(50) NOT NULL");			//-- 메모 테이블에 필드 추가
mysql_query("alter table g4_memo add me_type varchar(1) NOT NULL");

// 테이블 생성 ------------------------------------
$fh = fopen("./sql_ziumbuilder.sql", "r");
$file = "";
while(!feof($fh)){
	$file .= fgets($fh, 4096);
}
fclose($fh);

$f = explode(";", $file);
for ($i=0; $i<count($f); $i++) {
    if (trim($f[$i]) == "") continue;
    mysql_query($f[$i]) or die(mysql_error());
}


// 테이블 생성 ------------------------------------


//-- 그누보드 기본 정보 넣기 --
$sql = "INSERT INTO `g4_board` (`bo_table`, `gr_id`, `bo_subject`, `bo_admin`, `bo_list_level`, `bo_read_level`, `bo_write_level`, `bo_reply_level`, `bo_comment_level`, `bo_upload_level`, `bo_download_level`, `bo_html_level`, `bo_link_level`, `bo_trackback_level`, `bo_count_delete`, `bo_count_modify`, `bo_read_point`, `bo_write_point`, `bo_comment_point`, `bo_download_point`, `bo_use_category`, `bo_category_list`, `bo_disable_tags`, `bo_use_sideview`, `bo_use_file_content`, `bo_use_secret`, `bo_use_dhtml_editor`, `bo_use_rss_view`, `bo_use_comment`, `bo_use_good`, `bo_use_nogood`, `bo_use_name`, `bo_use_signature`, `bo_use_ip_view`, `bo_use_trackback`, `bo_use_list_view`, `bo_use_list_content`, `bo_table_width`, `bo_subject_len`, `bo_page_rows`, `bo_new`, `bo_hot`, `bo_image_width`, `bo_skin`, `bo_image_head`, `bo_image_tail`, `bo_include_head`, `bo_include_tail`, `bo_content_head`, `bo_content_tail`, `bo_insert_content`, `bo_gallery_cols`, `bo_upload_size`, `bo_reply_order`, `bo_use_search`, `bo_order_search`, `bo_count_write`, `bo_count_comment`, `bo_write_min`, `bo_write_max`, `bo_comment_min`, `bo_comment_max`, `bo_notice`, `bo_upload_count`, `bo_use_email`, `bo_sort_field`, `bo_1_subj`, `bo_2_subj`, `bo_3_subj`, `bo_4_subj`, `bo_5_subj`, `bo_6_subj`, `bo_7_subj`, `bo_8_subj`, `bo_9_subj`, `bo_10_subj`, `bo_1`, `bo_2`, `bo_3`, `bo_4`, `bo_5`, `bo_6`, `bo_7`, `bo_8`, `bo_9`, `bo_10`) VALUES
('notice', 'zium', '공지사항', '', 1, 1, 10, 10, 2, 10, 10, 10, 10, 10, 1, 1, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 97, 100, 10, 24, 100, 600, 'zm.basic', '', '', '../skin/zm.layout/zm.basic/head.skin.php', '../skin/zm.layout/zm.basic/tail.skin.php', '', '', '', 4, 1048576, 1, 0, 0, 0, 0, 0, 0, 0, 0, '', 2, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''),
('freeboard', 'zium', '자유게시판', '', 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 100, 10, 0, 0, 0, 0, 0, '', '', 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 100, 80, 20, 24, 300, 600, 'zm.basic', '', '', '../skin/zm.layout/zm.basic/head.skin.php', '../skin/zm.layout/zm.basic/tail.skin.php', '', '', '', 4, 4099072, 1, 1, 0, 0, 0, 0, 0, 0, 0, '', 2, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''),
('gallery', 'zium', '갤러리', '', 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 100, 10, 0, 0, 0, 0, 0, '', '', 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 15, 24, 300, 700, 'zm.gallery', '', '', '../skin/zm.layout/zm.basic/head.skin.php', '../skin/zm.layout/zm.basic/tail.skin.php', '', '', '', 3, 4099072, 1, 1, 0, 0, 0, 0, 0, 0, 0, '', 2, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');";
mysql_query($sql);

$sql = "INSERT INTO `g4_group` (`gr_id`, `gr_subject`, `gr_admin`, `gr_use_access`, `gr_1_subj`, `gr_2_subj`, `gr_3_subj`, `gr_4_subj`, `gr_5_subj`, `gr_6_subj`, `gr_7_subj`, `gr_8_subj`, `gr_9_subj`, `gr_10_subj`, `gr_1`, `gr_2`, `gr_3`, `gr_4`, `gr_5`, `gr_6`, `gr_7`, `gr_8`, `gr_9`, `gr_10`) VALUES
('zium', '지음빌더', '', 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');";
mysql_query($sql);

$sql = "CREATE TABLE IF NOT EXISTS `g4_write_notice` (
  `wr_id` int(11) NOT NULL auto_increment,
  `wr_num` int(11) NOT NULL default '0',
  `wr_reply` varchar(10) NOT NULL default '',
  `wr_parent` int(11) NOT NULL default '0',
  `wr_is_comment` tinyint(4) NOT NULL default '0',
  `wr_comment` int(11) NOT NULL default '0',
  `wr_comment_reply` varchar(5) NOT NULL default '',
  `ca_name` varchar(255) NOT NULL default '',
  `wr_option` set('html1','html2','secret','mail','mobile') NOT NULL default '',
  `wr_subject` varchar(255) NOT NULL default '',
  `wr_content` text NOT NULL,
  `wr_link1` text NOT NULL,
  `wr_link2` text NOT NULL,
  `wr_link1_hit` int(11) NOT NULL default '0',
  `wr_link2_hit` int(11) NOT NULL default '0',
  `wr_trackback` varchar(255) NOT NULL default '',
  `wr_hit` int(11) NOT NULL default '0',
  `wr_good` int(11) NOT NULL default '0',
  `wr_nogood` int(11) NOT NULL default '0',
  `mb_id` varchar(255) NOT NULL default '',
  `wr_password` varchar(255) NOT NULL default '',
  `wr_name` varchar(255) NOT NULL default '',
  `wr_email` varchar(255) NOT NULL default '',
  `wr_homepage` varchar(255) NOT NULL default '',
  `wr_datetime` datetime NOT NULL default '0000-00-00 00:00:00',
  `wr_last` varchar(19) NOT NULL default '',
  `wr_ip` varchar(255) NOT NULL default '',
  `wr_1` varchar(255) NOT NULL default '',
  `wr_2` varchar(255) NOT NULL default '',
  `wr_3` varchar(255) NOT NULL default '',
  `wr_4` varchar(255) NOT NULL default '',
  `wr_5` varchar(255) NOT NULL default '',
  `wr_6` varchar(255) NOT NULL default '',
  `wr_7` varchar(255) NOT NULL default '',
  `wr_8` varchar(255) NOT NULL default '',
  `wr_9` varchar(255) NOT NULL default '',
  `wr_10` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`wr_id`),
  KEY `wr_num_reply_parent` (`wr_num`,`wr_reply`,`wr_parent`),
  KEY `wr_is_comment` (`wr_is_comment`,`wr_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
mysql_query($sql);

$sql = "CREATE TABLE IF NOT EXISTS `g4_write_freeboard` (
  `wr_id` int(11) NOT NULL AUTO_INCREMENT,
  `wr_num` int(11) NOT NULL DEFAULT '0',
  `wr_reply` varchar(10) NOT NULL DEFAULT '',
  `wr_parent` int(11) NOT NULL DEFAULT '0',
  `wr_is_comment` tinyint(4) NOT NULL DEFAULT '0',
  `wr_comment` int(11) NOT NULL DEFAULT '0',
  `wr_comment_reply` varchar(5) NOT NULL DEFAULT '',
  `ca_name` varchar(255) NOT NULL DEFAULT '',
  `wr_option` set('html1','html2','secret','mail','mobile') NOT NULL DEFAULT '',
  `wr_subject` varchar(255) NOT NULL DEFAULT '',
  `wr_content` text NOT NULL,
  `wr_link1` text NOT NULL,
  `wr_link2` text NOT NULL,
  `wr_link1_hit` int(11) NOT NULL DEFAULT '0',
  `wr_link2_hit` int(11) NOT NULL DEFAULT '0',
  `wr_trackback` varchar(255) NOT NULL DEFAULT '',
  `wr_hit` int(11) NOT NULL DEFAULT '0',
  `wr_good` int(11) NOT NULL DEFAULT '0',
  `wr_nogood` int(11) NOT NULL DEFAULT '0',
  `mb_id` varchar(255) NOT NULL DEFAULT '',
  `wr_password` varchar(255) NOT NULL DEFAULT '',
  `wr_name` varchar(255) NOT NULL DEFAULT '',
  `wr_email` varchar(255) NOT NULL DEFAULT '',
  `wr_homepage` varchar(255) NOT NULL DEFAULT '',
  `wr_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `wr_last` varchar(19) NOT NULL DEFAULT '',
  `wr_ip` varchar(255) NOT NULL DEFAULT '',
  `wr_1` varchar(255) NOT NULL DEFAULT '',
  `wr_2` varchar(255) NOT NULL DEFAULT '',
  `wr_3` varchar(255) NOT NULL DEFAULT '',
  `wr_4` varchar(255) NOT NULL DEFAULT '',
  `wr_5` varchar(255) NOT NULL DEFAULT '',
  `wr_6` varchar(255) NOT NULL DEFAULT '',
  `wr_7` varchar(255) NOT NULL DEFAULT '',
  `wr_8` varchar(255) NOT NULL DEFAULT '',
  `wr_9` varchar(255) NOT NULL DEFAULT '',
  `wr_10` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`wr_id`),
  KEY `wr_num_reply_parent` (`wr_num`,`wr_reply`,`wr_parent`),
  KEY `wr_is_comment` (`wr_is_comment`,`wr_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
mysql_query($sql);

$sql = "CREATE TABLE IF NOT EXISTS `g4_write_gallery` (
  `wr_id` int(11) NOT NULL AUTO_INCREMENT,
  `wr_num` int(11) NOT NULL DEFAULT '0',
  `wr_reply` varchar(10) NOT NULL DEFAULT '',
  `wr_parent` int(11) NOT NULL DEFAULT '0',
  `wr_is_comment` tinyint(4) NOT NULL DEFAULT '0',
  `wr_comment` int(11) NOT NULL DEFAULT '0',
  `wr_comment_reply` varchar(5) NOT NULL DEFAULT '',
  `ca_name` varchar(255) NOT NULL DEFAULT '',
  `wr_option` set('html1','html2','secret','mail') NOT NULL DEFAULT '',
  `wr_subject` varchar(255) NOT NULL DEFAULT '',
  `wr_content` text NOT NULL,
  `wr_link1` text NOT NULL,
  `wr_link2` text NOT NULL,
  `wr_link1_hit` int(11) NOT NULL DEFAULT '0',
  `wr_link2_hit` int(11) NOT NULL DEFAULT '0',
  `wr_trackback` varchar(255) NOT NULL DEFAULT '',
  `wr_hit` int(11) NOT NULL DEFAULT '0',
  `wr_good` int(11) NOT NULL DEFAULT '0',
  `wr_nogood` int(11) NOT NULL DEFAULT '0',
  `mb_id` varchar(255) NOT NULL DEFAULT '',
  `wr_password` varchar(255) NOT NULL DEFAULT '',
  `wr_name` varchar(255) NOT NULL DEFAULT '',
  `wr_email` varchar(255) NOT NULL DEFAULT '',
  `wr_homepage` varchar(255) NOT NULL DEFAULT '',
  `wr_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `wr_last` varchar(19) NOT NULL DEFAULT '',
  `wr_ip` varchar(255) NOT NULL DEFAULT '',
  `wr_1` varchar(255) NOT NULL DEFAULT '',
  `wr_2` varchar(255) NOT NULL DEFAULT '',
  `wr_3` varchar(255) NOT NULL DEFAULT '',
  `wr_4` varchar(255) NOT NULL DEFAULT '',
  `wr_5` varchar(255) NOT NULL DEFAULT '',
  `wr_6` varchar(255) NOT NULL DEFAULT '',
  `wr_7` varchar(255) NOT NULL DEFAULT '',
  `wr_8` varchar(255) NOT NULL DEFAULT '',
  `wr_9` varchar(255) NOT NULL DEFAULT '',
  `wr_10` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`wr_id`),
  KEY `wr_num_reply_parent` (`wr_num`,`wr_reply`,`wr_parent`),
  KEY `wr_is_comment` (`wr_is_comment`,`wr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
mysql_query($sql);

@rename("../install", "../install.bak");
//-------------------------------------------------------------------------------------------------



echo "<script language='JavaScript'>document.frminstall2.status_bar.value += '■';</script>\n";
flush();
sleep(1);

echo "<script>document.frminstall2.job4.value='필요한 Table, File, 디렉토리 생성을 모두 완료 하였습니다.';</script>";
echo "<script>document.frminstall2.job5.value='지음빌더 이용문의 및 이용후기는 ziumsoft.co.kr(지음소프트)에 남겨주세요.';</script>";
echo "<script>document.frminstall2.job6.value='* 메인화면에서 운영자 로그인을 한 후 관리 화면으로 이동하여 환경설정을 변경해 주십시오.';</script>";
flush(); usleep(50000);
?>
<script>document.frminstall2.btn_next.disabled = false;</script>
<script>document.frminstall2.btn_next.focus();</script>
</body>
</html>