<?
$aTable			= array();
$intCnt			= 0;
$sQry			= mysql_query("show tables");
while($rdTable = mysql_fetch_array($sQry)) {
	$aTable[$intCnt]	= $rdTable[0];
	$intCnt++;
}

//-- zm_sms_config 테이블이 있는지 검사한다. ------------------------------------------------------
$sQry	= "CREATE TABLE IF NOT EXISTS `zm_sms_config` (
		`ds_variable`	varchar(255),
		`ds_value`		varchar(255),
		PRIMARY KEY  (`ds_variable`));";
$sRst	= mysql_query($sQry);


//-- zm_sms_phonebook 테이블이 있는지 검사한다. ------------------------------------------------------
$sQry	= "CREATE TABLE IF NOT EXISTS `zm_sms_phonebook` (
		ds_recno		int			AUTO_INCREMENT,
		ds_mng_id		varchar(20),
		ds_phn_name		varchar(40),
		ds_phn_id		varchar(20),
		ds_phn_pcs		varchar(15),
		ds_phn_date		int,
		ds_memo			varchar(40),
		PRIMARY KEY		(ds_recno));";
$sRst			= mysql_query($sQry);


//-- zm_sms_history 테이블이 있는지 검사한다. ------------------------------------------------------
$sQry	= "CREATE TABLE IF NOT EXISTS `zm_sms_history` (
		ds_recno		int			AUTO_INCREMENT,
		ds_send_name	varchar(40),
		ds_send_id		varchar(20),
		ds_send_pcs		varchar(15),
		ds_send_msg		varchar(80),
		ds_receive_name varchar(40),
		ds_receive_pcs	varchar(15),
		ds_send_type	varchar(1),
		ds_send_date	int,
		PRIMARY KEY  (ds_recno));";
$sRst			= mysql_query($sQry);


//-- 선언되지 않은 환경변수 레코드 추가
$rdCfgRows			= mysql_num_rows(mysql_query("select ds_variable from zm_sms_config where ds_variable='cutstring'"));		//-- 긴문자 전송 타입
//-- 1:90바이트만 전송, 2:90바이트씩 잘라서 전송
if(!$rdCfgRows)		$bRst	= mysql_query("insert into zm_sms_config set ds_variable='cutstring', ds_value='1'");
$rdCfgRows			= mysql_num_rows(mysql_query("select ds_variable from zm_sms_config where ds_variable='consume'"));			//-- 소모되는 포인트
if(!$rdCfgRows)		$bRst	= mysql_query("insert into zm_sms_config set ds_variable='consume', ds_value='0'");	
$rdCfgRows			= mysql_num_rows(mysql_query("select ds_variable from zm_sms_config where ds_variable='memlevel'"));		//-- 포인트 예외 레벨
if(!$rdCfgRows)		$bRst	= mysql_query("insert into zm_sms_config set ds_variable='memlevel', ds_value='10'");	
$rdCfgRows			= mysql_num_rows(mysql_query("select ds_variable from zm_sms_config where ds_variable='sms_module'"));		//-- 모듈 종류
if(!$rdCfgRows)		$bRst	= mysql_query("insert into zm_sms_config set ds_variable='sms_module', ds_value='tongkni'");		//-- 기본 모듈은 통큰아이
?>