<?php
	require_once ($_SERVER['DOCUMENT_ROOT']."/inc/mysql.inc");
	require_once ($_SERVER['DOCUMENT_ROOT']."/inc/pgsql.inc");
	$id = $_GET['id'];
	$pw = $_GET['pw'];
	$msg = $_GET['msg'];
	
	if($id != "" && $pw != "" && $msg != "")
	{
		$dbConnPgSql = new DB_Sql;
		
		$strSqlpg  = "SELECT group_seq ";
		$strSqlpg .= "FROM t_group ";
		$strSqlpg .= "WHERE group_id = '".$id."' AND group_password = '".$pw."' AND deleted_yn = 'N'";		

		$dbConnPgSql->query($strSqlpg);
		
		if($dbConnPgSql->nf() == 1)
		{
			$dbConnPgSql->next_record();	
			$group_seq = $dbConnPgSql->f("group_seq");
			
			if($group_seq != "")
			{
				$strSqlpg  = "SELECT member_cellphone ";
				$strSqlpg .= "FROM t_group_member ";
				$strSqlpg .= "WHERE group_seq = ".$group_seq;
				//$strSqlpg .= "LIMIT 1 ";
				
				$dbConnPgSql->query($strSqlpg);
			
				if($dbConnPgSql->nf() != 0)
				{					
					$tmpSqlmy = "";
					$tmpSqlpg = "";
					$dbConnMySql = new dbconnect('211.39.134.109', 'sh_trans', 'sh_trans', 'midc', __FILE__, __LINE__);	
					
					while($dbConnPgSql->next_record())
					{						
						$cellphone = $dbConnPgSql->f("member_cellphone");
						$tmpSqlmy  = "INSERT INTO sms(id, dstaddr, msg, deliver) ";
						$tmpSqlmy .= "VALUES ('SH_".$id."', '".$cellphone."', '".$msg."', 9)";

						echo "$tmpSqlmy";
						$dbConnMySql->query($tmpSqlmy,__FILE__, __LINE__);
						
						$tmpSqlpg .= "INSERT INTO t_sms_log (group_seq, sms_id, sms_cellphone, sms_message, reg_datetime, update_datetime) ";
						$tmpSqlpg .= "VALUES (".$group_seq.", 'SH_".$id."', '".$cellphone."', '".$msg."', now(), now()); ";						
					}
					$dbConnPgSql->query($tmpSqlpg);
				}					
			}
		}		
	}	
?>
