base
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-------------------
|
||||
작성일 : 2011-10-20
|
||||
작성자 : 신순영
|
||||
----------------------------------------------------------------------------
|
||||
내용
|
||||
----------------------------------------------------------------------------
|
||||
common한 alert 기능으로 수정을 했다.
|
||||
|
||||
*파라미터*
|
||||
|
||||
order = // KT | LGU
|
||||
type = // raid | dblb 등
|
||||
sendhost = // hostname
|
||||
smsgroup = // TEST | ALL 등.. 관제페이지 SMS 수신목록의 그룹명
|
||||
mailgroup = // scv1@solbox.com;scv2@solbox.com;op@solbox....
|
||||
time = // 20111012090859
|
||||
msg = // message body
|
||||
trace = // 브라우저에서 실행 LOG를 볼 때 'true'
|
||||
|
||||
|
||||
-------------------
|
||||
작성일 : 2011-05-30
|
||||
작성자 : 김오종
|
||||
----------------------------------------------------------------------------
|
||||
내용
|
||||
----------------------------------------------------------------------------
|
||||
web_utils 경로는 php 또는 html 등을 이용한 서비스에 필요한 기능 별로 관리한다.
|
||||
|
||||
./inc 경로는 공통으로 사용 할 수 있는 include 파일 등을 갖는다.
|
||||
|
||||
./raid 경로는 arcmond와 연동되는 raid card 가 이벤트 발생시 sms와 e-mail을 발송
|
||||
하는 기능을 포함한다.
|
||||
@@ -0,0 +1,17 @@
|
||||
Revision 0625
|
||||
-------------------
|
||||
수정일 : 2011-10-20
|
||||
수정자 : 신순영
|
||||
|
||||
- NEW: SVN 신규 등록
|
||||
- 파일 send_alert.php 추가됨
|
||||
- common한 alert 기능으로 수정을 했다.
|
||||
|
||||
- NEW: pqsql DB IP 설정기능 추가
|
||||
- 파일 ../inc/pgsql.inc 추가됨
|
||||
- setHostIP() 함수 추가 : 하드코딩되어 있는 pgsql DB IP를 common 하게 하기 위해 함수 추가
|
||||
|
||||
- CHG: 호출경로에 따른 문제 발생할 부분을 수정
|
||||
- 파일 ../inc/sendmail.inc 수정됨
|
||||
- 불필요한 sleep() 함수 제거
|
||||
- arcmond_client tool 호출경로를 상대path에서 절대path로 변경
|
||||
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
|
||||
// kt : mysql / lgu : oracle
|
||||
// example)
|
||||
// LGU : http://211.233.68.197:8080/alert/send_alert.php?order=lgu&type=dblb&sendhost=nh01-mdslb02.x-cdn.com&smsgroup=TEST&mailgroup=trozan@solbox.com&time=20111012092823&msg=shutdown-host:nh01-mds02.x-cdn.com
|
||||
// KT : http://sh-raid.solbox.com/alert/send_alert.php?order=kt&type=dblb&sendhost=bd04-mdslb01.ktsh.com&smsgroup=TEST&mailgroup=trozan@solbox.com&time=20111012141300&msg=asdfasdfasasfasd
|
||||
|
||||
$order = strtoupper($_GET['order']); // kt | lgu
|
||||
$type = strtoupper($_GET['type']); // raid | dblb
|
||||
$sendhost = $_GET['sendhost']; // host
|
||||
$smsgroup = $_GET['smsgroup']; // test | all etc...
|
||||
$mailgroup = $_GET['mailgroup']; // scv1@solbox.com;scv2@solbox.com;op@solbox....
|
||||
$time = $_GET['time']; // time
|
||||
$message = $_GET['msg']; // msg
|
||||
$trace = $_GET['trace']; // print ment ('true' is detail log)
|
||||
|
||||
$from_mail = "svc1@solbox.com";
|
||||
|
||||
define(ORDER_TYPE, $order);
|
||||
require_once ("../inc/pgsql.inc");
|
||||
require_once ("../inc/sendmail.inc");
|
||||
|
||||
|
||||
if($order == "KT")
|
||||
{
|
||||
define(DB_HOST , "222.122.18.22");
|
||||
define(DB_USER , "smsuser");
|
||||
define(DB_PWD , "sms5emffld)");
|
||||
define(PGDB_HOST, "127.0.0.1");
|
||||
require_once ("../inc/mysql.inc");
|
||||
}
|
||||
else if($order == "LGU")
|
||||
{
|
||||
define(DB_HOST , "xcdnuser");
|
||||
define(DB_USER , "solbox123");
|
||||
define(DB_SID , "SMS");
|
||||
define(PGDB_HOST, "61.111.52.4");
|
||||
require_once ("../inc/oci8inc.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Order not found";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function TRACE($msg, $trace)
|
||||
{
|
||||
if($trace == "true")
|
||||
echo $msg;
|
||||
}
|
||||
|
||||
function cutstr($str, $size)
|
||||
{
|
||||
if(!$size or (strlen($str) <= $size))
|
||||
return $str;
|
||||
else
|
||||
for($i = 0;$i < $size;$i++)
|
||||
{
|
||||
if(ord($str[$i]) > 127)
|
||||
$over++;
|
||||
}
|
||||
return chop(substr($str,0,$size - $over%2));
|
||||
}
|
||||
|
||||
function sendsms_mysql($msg, $dbConnPgSql, $strSqlpg, $group_seq, $sid)
|
||||
{
|
||||
$tmpSqlmy = "";
|
||||
$tmpSqlpg = "";
|
||||
$user_count = 0;
|
||||
$cellphone_list = "";
|
||||
|
||||
$dbConnPgSql->query($strSqlpg);
|
||||
if($dbConnPgSql->nf() == 0)
|
||||
{
|
||||
TRACE("fail to pgsql querty : $strSqlpg <br><br>", $trace);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2010-09-15 huibong SMS RELAY 서버 변경 및 관련 코드 수정 처리함.
|
||||
$dbConnMySql = new dbconnect(DB_HOST, DB_USER , DB_PWD, 'sms', __FILE__, __LINE__);
|
||||
|
||||
while($dbConnPgSql->next_record())
|
||||
{
|
||||
$cellphone = $dbConnPgSql->f("member_cellphone");
|
||||
|
||||
if( strlen($cellphone_list) > 0 )
|
||||
{
|
||||
$cellphone_list .= "|ktics1^" . $cellphone;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cellphone_list = "ktics1^" . $cellphone;
|
||||
}
|
||||
|
||||
$user_count ++;
|
||||
|
||||
$tmpSqlpg .= "INSERT INTO t_sms_log (group_seq, sms_id, sms_cellphone, sms_message, reg_datetime, update_datetime) ";
|
||||
$tmpSqlpg .= "VALUES (".$group_seq.", 'SH_".$smsgroup."', '".$cellphone."', '".$msg."', now(), now()); ";
|
||||
}
|
||||
|
||||
$tmpSqlmy = "INSERT INTO SDK_SMS_SEND ( USER_ID, SCHEDULE_TYPE, SUBJECT, NOW_DATE,SEND_DATE, CALLBACK, DEST_COUNT, DEST_INFO, SMS_MSG) ";
|
||||
$tmpSqlmy .= "VALUES ('ktics1', 0,'ktics1',DATE_FORMAT(now(),'%Y%m%d%H%i%s'),DATE_FORMAT(now(),'%Y%m%d%H%i%s'),'0317810344',$user_count,'$cellphone_list','$msg')";
|
||||
$res = $dbConnMySql->query($tmpSqlmy,__FILE__, __LINE__);
|
||||
|
||||
if( !$res->result )
|
||||
{
|
||||
TRACE("fail to send SMS<br><br>", $trace);
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbConnMySql->close();
|
||||
$dbConnPgSql->query($tmpSqlpg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function sendsms_oracle($msg, $dbConnPgSql, $strSqlpg, $group_seq, $sid)
|
||||
{
|
||||
$tmpSqlmy = "";
|
||||
$tmpSqlpg = "";
|
||||
$user_count = 0;
|
||||
|
||||
$dbConnPgSql->query($strSqlpg);
|
||||
|
||||
if($dbConnPgSql->nf() == 0)
|
||||
{
|
||||
TRACE("fail to pgsql querty : $strSqlpg <br><br>", $trace);
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbConnOra = new Oracle_OCI_log;
|
||||
|
||||
$dbConnOra->connect(DB_HOST, DB_USER, DB_SID);
|
||||
if( !$dbConnOra->conn )
|
||||
TRACE("Oracle Connect Failed<br><br>", $trace);
|
||||
|
||||
TRACE("Oracle DB SERVER Connecting...<br><br>", $trace);
|
||||
|
||||
while($dbConnPgSql->next_record())
|
||||
{
|
||||
$cellphone = $dbConnPgSql->f("member_cellphone");
|
||||
$cli_ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$tmpSqlmy = "INSERT INTO SC_TRAN(TR_NUM, TR_SENDDATE, TR_SENDSTAT, TR_PHONE, TR_CALLBACK, TR_MSG, TR_MSGTYPE)";
|
||||
$tmpSqlmy .= "VALUES ( SC_SEQUENCE.NEXTVAL, SYSDATE, '0', '$cellphone', '$cellphone', '$msg', '0')";
|
||||
|
||||
$dbConnOra->parseExec($tmpSqlmy);
|
||||
if($dbConnOra->error) {
|
||||
TRACE("fail to send SMS<br><br>", $trace);
|
||||
continue;
|
||||
}
|
||||
$user_count ++;
|
||||
|
||||
$tmpSqlpg .= "INSERT INTO t_sms_log (group_seq, sms_id, sms_cellphone, sms_message, reg_datetime, update_datetime) ";
|
||||
$tmpSqlpg .= "VALUES (".$group_seq.", 'SH_".$sid."', '".$cellphone."', '".$msg."', now(), now()); ";
|
||||
}
|
||||
|
||||
$dbConnOra->disconnect();
|
||||
|
||||
|
||||
if($user_count == $dbConnPgSql->nf())
|
||||
{
|
||||
TRACE("Success to All send SMS<br><br>", $trace);
|
||||
|
||||
$dbConnPgSql->query($tmpSqlpg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$raddr = $_SERVER["REMOTE_ADDR"];
|
||||
|
||||
// CHG 2010-06-17 huibong Message 에서 구분자 : 을 제거처리
|
||||
//$msg = "[RAID:".$_GET['host']."]::".$time.":".$message;
|
||||
|
||||
if($time != "")
|
||||
{
|
||||
$time = sprintf("%s-%s %s:%s:%s"
|
||||
, substr($time, 4, 2)
|
||||
, substr($time, 6, 2)
|
||||
, substr($time, 8, 2)
|
||||
, substr($time, 10, 2)
|
||||
, substr($time, 12, 2)
|
||||
);
|
||||
}
|
||||
|
||||
$msg = "[".$type.":".$sendhost."] ".$time." ".$message;
|
||||
|
||||
TRACE("1. MAIL : " . $msg . "<br>", $trace);
|
||||
|
||||
$cmd = 'echo `date +"%Y%m%d %H:%M:%S"`'.": $sendhost";
|
||||
system("$cmd >> logs/".$type.".send.sms.mail.`date +%Y%m%d`.log");
|
||||
|
||||
if($type != "RAID")
|
||||
$body = $msg;
|
||||
else
|
||||
$body = trim(htmlBody($raddr));
|
||||
#$body = trim(MakeHtmlBodyFromArcmondClient($raddr, 8787, 2)); // default value of arcmond
|
||||
|
||||
if($mailgroup != "")
|
||||
{
|
||||
$to_mail = explode(";", $mailgroup);
|
||||
$cnt = count($to_mail);
|
||||
|
||||
for($i=0; $i < $cnt; $i++)
|
||||
{
|
||||
if(ereg("(^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*$)", $to_mail[$i]))
|
||||
{
|
||||
$sendmail = new sendmail("127.0.0.1", 25, 30);
|
||||
$sendmail->open();
|
||||
$sendmail->send($to_mail[$i], $from_mail, trim($msg), $body);
|
||||
$sendmail->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($smsgroup != "" && $msg != "")
|
||||
{
|
||||
$sms_host = strtok( $sendhost, "." );
|
||||
|
||||
$sms_time = $time;
|
||||
if( strlen($sms_time) > 14 )
|
||||
{
|
||||
$sms_time = substr($time, 5);
|
||||
}
|
||||
|
||||
$sms_msg = $message;
|
||||
if( strncmp( $message, "Controller#", 11) == 0 )
|
||||
{
|
||||
$sms_msg = substr( $message, 10 );
|
||||
}
|
||||
|
||||
// $msg = "[RAID:".$sms_host." ".$raddr."] ".$sms_time." ".$sms_msg;
|
||||
$msg = "[".$type.":".$sms_host."] ".$sms_time." ".$sms_msg;
|
||||
|
||||
$dbConnPgSql = new DB_Sql;
|
||||
$dbConnPgSql->setHostIP(PGDB_HOST);
|
||||
|
||||
$strSqlpg = "SELECT group_seq ";
|
||||
$strSqlpg .= "FROM t_group ";
|
||||
$strSqlpg .= "WHERE group_id = '".$smsgroup."' AND deleted_yn = 'N'";
|
||||
|
||||
$nLength=strlen($msg);
|
||||
|
||||
TRACE("2. SMS : $msg (size :$nLength)\n<br><br>", $trace);
|
||||
|
||||
$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;
|
||||
|
||||
if($nLength > 80)
|
||||
{
|
||||
$strtmp = $msg;
|
||||
$msg = cutstr($strtmp,80);
|
||||
$nLength = strlen($msg);
|
||||
TRACE("CutSTR Message : $msg Size :$nLength \n<br><br>", $trace);
|
||||
}
|
||||
|
||||
$bSendSMS = false;
|
||||
|
||||
for($i = 0; $i< 2; $i++)
|
||||
{
|
||||
if(!$bSendSMS)
|
||||
{
|
||||
if( ORDER_TYPE == "KT" )
|
||||
$bSendSMS = sendsms_mysql( $msg, $dbConnPgSql, $strSqlpg, $group_seq, $smsgroup );
|
||||
else if( ORDER_TYPE == "LGU")
|
||||
$bSendSMS = sendsms_oracle( $msg, $dbConnPgSql, $strSqlpg, $group_seq, $smsgroup );
|
||||
|
||||
if( $bSendSMS ) break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$bSendSMS)
|
||||
{
|
||||
TRACE("Unexpected error was occured<br><br>", $trace);
|
||||
}
|
||||
}
|
||||
else
|
||||
TRACE("PGSQL `group_seq` failed<br><br>", $trace);
|
||||
|
||||
$dbConnPgSql->close();
|
||||
|
||||
echo "success";
|
||||
}
|
||||
else // end if($dbConnPgSql->nf() == 1)
|
||||
TRACE("smsgroup or msg NULL!!!<br><br>", $trace);
|
||||
}
|
||||
else
|
||||
TRACE("Unexpected error was occured. id : \"$smsgroup\" msg :\"$msg\"\n<br><br>", $trace);
|
||||
|
||||
exit;
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
define('SQL_ASSOC', MYSQL_ASSOC);
|
||||
define('SQL_NUM', MYSQL_NUM);
|
||||
define('SQL_BOTH', MYSQL_BOTH);
|
||||
define('CRLF', "\r\n");
|
||||
class dbconnect
|
||||
{
|
||||
var $showError;
|
||||
var $dbc;
|
||||
var $bConnect; // add invalidate
|
||||
var $bQueryrun; // add invalidate
|
||||
|
||||
function dbconnect($host, $user, $pass, $base, $file = '', $line = 0)
|
||||
{
|
||||
if($pass != ""){
|
||||
if(!$this->dbc = mysql_connect($host, $user, $pass))
|
||||
{
|
||||
$error = 'Cannot connect to MySQL server. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'<br />'.CRLF;
|
||||
$this->bConnect= false;
|
||||
//die($error);
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
if(!$this->dbc = mysql_connect($host, $user))
|
||||
{
|
||||
$error = 'Cannot connect to MySQL server. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'<br />'.CRLF;
|
||||
//die($error);
|
||||
//FIXME: return? die?
|
||||
$this->bConnect= false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!@mysql_query("USE ".$base, $this->dbc))
|
||||
{
|
||||
$error = 'Error <b>'.mysql_error($this->dbc).'</b> in query <b>'.$query.'</b>. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'<br />'.CRLF;
|
||||
$this->bConnect= false;
|
||||
//die($error);
|
||||
}else
|
||||
$this->bConnect= true;
|
||||
|
||||
$this->showError = true;
|
||||
|
||||
return $this->bConnect;
|
||||
}
|
||||
|
||||
function query($query, $file = '', $line = 0)
|
||||
{
|
||||
if(!$result = @mysql_query($query, $this->dbc))
|
||||
{
|
||||
$error = 'Error <b>'.mysql_error($this->dbc).'</b> in query <b>'.$query.'</b>. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'<br />'.CRLF;
|
||||
if($this->showError)
|
||||
{
|
||||
echo $error;
|
||||
$this->bQueryrun = false;
|
||||
return new dbcResult($result);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->bQueryrun = true;
|
||||
|
||||
return new dbcResult($result);
|
||||
}
|
||||
|
||||
|
||||
function query_bool($query, $file = '', $line = 0)
|
||||
{
|
||||
if(!$result = @mysql_query($query, $this->dbc))
|
||||
{
|
||||
$error = 'Error <b>'.mysql_error($this->dbc).'</b> in query <b>'.$query.'</b>. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'<br />'.CRLF;
|
||||
if($this->showError)
|
||||
{
|
||||
echo $error;
|
||||
}
|
||||
}
|
||||
return ($result?true:false);
|
||||
}
|
||||
|
||||
function insert_id()
|
||||
{
|
||||
$id = $this->firstCell("SELECT LAST_INSERT_ID() as id");
|
||||
return $id;
|
||||
}
|
||||
|
||||
function fetch_array($query, $type = SQL_BOTH)
|
||||
{
|
||||
$result = $this->query($query);
|
||||
return $result->fetch_array($type);
|
||||
}
|
||||
|
||||
function first_cell($query)
|
||||
{
|
||||
$result = $this->query($query);
|
||||
$row = $result->fetch_array(SQL_NUM);
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
function change_base($base, $file = '', $line = 0)
|
||||
{
|
||||
if(!$result = @mysql_query('USE '.$base, $this->dbc))
|
||||
{
|
||||
$error = 'Error <b>'.mysql_error($this->dbc).'</b> in query <b>'.$query.'</b>. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'<br />'.CRLF;
|
||||
if($this->showError)
|
||||
{
|
||||
echo $error;
|
||||
}
|
||||
}
|
||||
return ($result?true:false);
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
@mysql_close($this->dbc);
|
||||
unset($this);
|
||||
}
|
||||
}
|
||||
|
||||
class dbcResult
|
||||
{
|
||||
function dbcResult($result)
|
||||
{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
function fetch_array($type = SQL_BOTH)
|
||||
{
|
||||
return @mysql_fetch_array($this->result, $type);
|
||||
}
|
||||
|
||||
function first_cell()
|
||||
{
|
||||
$row = @mysql_fetch_row($this->result);
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
function num_rows()
|
||||
{
|
||||
return @mysql_num_rows($this->result);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
class Oracle_OCI_log {
|
||||
var $conn = FALSE;
|
||||
var $stmt = 0;
|
||||
var $abstractData= FALSE;
|
||||
var $error= FALSE;
|
||||
|
||||
function connect($id="oracle_id",$passwd="oracle_passwd",$oracle_sid="SID") { // 오라클 접속.
|
||||
$this->conn = OCILogon($id,$passwd,$oracle_sid);
|
||||
}
|
||||
|
||||
function serverVersion() {
|
||||
return OCIServerVersion($this->conn);
|
||||
}
|
||||
|
||||
function parse($qry) {
|
||||
$this->stmt=OCIParse($this->conn,$qry);
|
||||
}
|
||||
|
||||
function parseExec($qry) {
|
||||
$this->stmt=OCIParse($this->conn,$qry);
|
||||
$this->exec();
|
||||
}
|
||||
|
||||
function exec($mode=OCI_DEFAULT) {
|
||||
// OCI_DEFAULT : 매번 실행시마다 자동 commit가 되지 않도록 함.
|
||||
@OCIExecute($this->stmt,$mode);
|
||||
$this->error = ocierror($this->stmt);
|
||||
if($this->error) $this->disconnect();
|
||||
}
|
||||
|
||||
/*
|
||||
OCI_D_FILE
|
||||
OCI_D_LOB
|
||||
OCI_D_ROWID
|
||||
*/
|
||||
|
||||
function newDescriptor($type) {
|
||||
$this->abstractData = OCINewDescriptor($this->conn,$type);
|
||||
}
|
||||
|
||||
function freeDescriptor() {
|
||||
OCIFreeDescriptor($this->abstractData);
|
||||
}
|
||||
|
||||
function defineByName($upper,&$var) {
|
||||
OCIDefineByName($this->stmt,$upper,&$var);
|
||||
}
|
||||
|
||||
function bindByName($place_holder,&$var,$length) {
|
||||
OCIBindByName($this->stmt,$place_holder,$var,$length);
|
||||
}
|
||||
|
||||
/*
|
||||
OCI_B_FILE(Binary File)
|
||||
OCI_B_CFILE(Character-File)
|
||||
OCI_B_CLOB(Character_LOB)
|
||||
OCI_B_BLOB(Binary-LOB)
|
||||
OCI_B_B_ROWID(ROWID)
|
||||
*/
|
||||
|
||||
function bindByNameAbstract($place_holder,$type) {
|
||||
OCIBindByName($this->stmt,$place_holder,&$this->abstractData,-1,$type);
|
||||
return $this->abstractData;
|
||||
// return &$this->abstractData; PARSE ERROR!
|
||||
}
|
||||
|
||||
|
||||
function fetch() {
|
||||
return OCIFetch($this->stmt);
|
||||
}
|
||||
|
||||
function result($i) { // 인덱스는 0이 아닌 1부터 시작
|
||||
return OCIresult($this->stmt,$i);
|
||||
}
|
||||
|
||||
function fetchInto(&$col,$mode=OCI_ASSOC) { // 클래스는 디폴트가 OCI_ASSOC
|
||||
//function fetchInto(&$col,$mode=OCI_NUM) {
|
||||
return OCIFetchInto($this->stmt,&$col,$mode);
|
||||
}
|
||||
|
||||
function fetchStatement(&$arr) {
|
||||
return OCIFetchStatement($this->stmt,&$arr);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
function numCols() {
|
||||
return OCINumCols($this->stmt);
|
||||
}
|
||||
|
||||
// $index 는 1 부터 시작
|
||||
function columnName($index) {
|
||||
return OCIColumnName($this->stmt,$index);
|
||||
}
|
||||
|
||||
function columnisNULL($index) {
|
||||
return OCIColumnIsNULL($this->stmt,$index);
|
||||
}
|
||||
|
||||
function columnType($index) {
|
||||
return OCIColumnType($this->stmt,$index);
|
||||
}
|
||||
|
||||
function columnSize($index) {
|
||||
return OCIColumnSize($this->stmt,$index);
|
||||
}
|
||||
|
||||
function StatementType() {
|
||||
return OCIStatementType($this->stmt);
|
||||
}
|
||||
|
||||
function rowCount() {
|
||||
return OCIRowCount($this->stmt);
|
||||
}
|
||||
///////////////////////////////////////////////
|
||||
|
||||
function parseFree() {
|
||||
OCIFreeStatement($this->stmt);
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
if($this->error) {
|
||||
OCIRollback($this->conn);
|
||||
die("<font color=red>ROLLBACK OCCURRED!! ".$this->error["message"]."</font>");
|
||||
}
|
||||
else {
|
||||
OCICommit($this->conn);
|
||||
}
|
||||
OCILogoff($this->conn);
|
||||
}
|
||||
|
||||
} // end class
|
||||
|
||||
//////// Object 생성 ////////////////////////////////
|
||||
//$oci = new Oracle_OCI;
|
||||
//////////////////////////////////////////////////////////////
|
||||
?>
|
||||
@@ -0,0 +1,375 @@
|
||||
<?php
|
||||
class DB_Sql {
|
||||
var $Host = "127.0.0.1"; // lgu -> 61.111.52.4
|
||||
var $Database = "syshost";
|
||||
var $Port = "5432";
|
||||
var $User = "syshost";
|
||||
var $Password = "alfkzmf!?{}";
|
||||
|
||||
var $Link_ID = 0;
|
||||
var $Query_ID = 0;
|
||||
var $Record = array();
|
||||
var $Row = 0;
|
||||
|
||||
var $Seq_Table = "db_sequence";
|
||||
|
||||
var $Errno = 0;
|
||||
var $Error = "";
|
||||
var $Debug = 0;
|
||||
|
||||
var $Auto_Free = 0; # Set this to 1 for automatic pg_freeresult on
|
||||
# last record.
|
||||
var $PConnect = 0; ## Set to 1 to use persistent database connections
|
||||
|
||||
function ifadd($add, $me) {
|
||||
if("" != $add) return " ".$me.$add;
|
||||
}
|
||||
|
||||
/* public: constructor */
|
||||
function DB_Sql($query = "") {
|
||||
$this->query($query);
|
||||
}
|
||||
|
||||
function setHostIP($ip = "") {
|
||||
$this->Host = $ip;
|
||||
}
|
||||
|
||||
function querySafe($string) {
|
||||
$string = str_replace("'", "\'", $string);
|
||||
$string = str_replace("\\", "\\\\", $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
function connect() {
|
||||
if ( 0 == $this->Link_ID ) {
|
||||
$cstr = "dbname=".$this->Database.
|
||||
$this->ifadd($this->Host, "host=").
|
||||
$this->ifadd($this->Port, "port=").
|
||||
$this->ifadd($this->User, "user=").
|
||||
$this->ifadd($this->Password, "password=");
|
||||
if(!$this->PConnect) {
|
||||
$this->Link_ID = pg_connect($cstr);
|
||||
} else {
|
||||
$this->Link_ID = pg_pconnect($cstr);
|
||||
}
|
||||
if (!$this->Link_ID) {
|
||||
$this->halt("connect() failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
pg_close($this->Link_ID);
|
||||
}
|
||||
|
||||
function query($Query_String) {
|
||||
/* No empty queries, please, since PHP4 chokes on them. */
|
||||
if ($Query_String == "")
|
||||
/* The empty query string is passed on from the constructor,
|
||||
* when calling the class without a query, e.g. in situations
|
||||
* like these: '$db = new DB_Sql_Subclass;'
|
||||
*/
|
||||
return 0;
|
||||
|
||||
$this->connect();
|
||||
|
||||
if ($this->Debug)
|
||||
printf("<br>Debug: query = %s<br>\n", $Query_String);
|
||||
$this->Query_ID = pg_Exec($this->Link_ID, $Query_String);
|
||||
$this->Row = 0;
|
||||
|
||||
$this->Error = pg_ErrorMessage($this->Link_ID);
|
||||
$this->Errno = ($this->Error == "")?0:1;
|
||||
if (!$this->Query_ID) {
|
||||
$this->halt("Invalid SQL: ".$Query_String);
|
||||
}
|
||||
|
||||
return $this->Query_ID;
|
||||
}
|
||||
|
||||
function beginTrans() {
|
||||
return $this->query("begin");
|
||||
}
|
||||
|
||||
function commitTrans() {
|
||||
return $this->query("commit");
|
||||
}
|
||||
|
||||
function rollbackTrans() {
|
||||
return $this->query("rollback");
|
||||
}
|
||||
|
||||
function next_record() {
|
||||
$this->Record = @pg_fetch_array($this->Query_ID, $this->Row++);
|
||||
|
||||
$this->Error = pg_ErrorMessage($this->Link_ID);
|
||||
$this->Errno = ($this->Error == "")?0:1;
|
||||
|
||||
$stat = is_array($this->Record);
|
||||
if (!$stat && $this->Auto_Free) {
|
||||
pg_freeresult($this->Query_ID);
|
||||
$this->Query_ID = 0;
|
||||
}
|
||||
return $stat;
|
||||
}
|
||||
|
||||
function seek($pos) {
|
||||
$this->Row = $pos;
|
||||
}
|
||||
|
||||
function lock($table, $mode = "write") {
|
||||
if ($mode == "write") {
|
||||
$result = pg_Exec($this->Link_ID, "lock table $table");
|
||||
} else {
|
||||
$result = 1;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function unlock() {
|
||||
return pg_Exec($this->Link_ID, "commit");
|
||||
}
|
||||
|
||||
|
||||
/* public: sequence numbers */
|
||||
function nextid($seq_name) {
|
||||
$this->connect();
|
||||
|
||||
if ($this->lock($this->Seq_Table)) {
|
||||
/* get sequence number (locked) and increment */
|
||||
$q = sprintf("select nextid from %s where seq_name = '%s'",
|
||||
$this->Seq_Table,
|
||||
$seq_name);
|
||||
$id = @pg_Exec($this->Link_ID, $q);
|
||||
$res = @pg_Fetch_Array($id, 0);
|
||||
|
||||
/* No current value, make one */
|
||||
if (!is_array($res)) {
|
||||
$currentid = 0;
|
||||
$q = sprintf("insert into %s values('%s', %s)",
|
||||
$this->Seq_Table,
|
||||
$seq_name,
|
||||
$currentid);
|
||||
$id = @pg_Exec($this->Link_ID, $q);
|
||||
} else {
|
||||
$currentid = $res["nextid"];
|
||||
}
|
||||
$nextid = $currentid + 1;
|
||||
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
|
||||
$this->Seq_Table,
|
||||
$nextid,
|
||||
$seq_name);
|
||||
$id = @pg_Exec($this->Link_ID, $q);
|
||||
$this->unlock();
|
||||
} else {
|
||||
$this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
|
||||
return 0;
|
||||
}
|
||||
return $nextid;
|
||||
}
|
||||
|
||||
function metadata($table="") {
|
||||
$count = 0;
|
||||
$id = 0;
|
||||
$res = array();
|
||||
|
||||
if ($table) {
|
||||
$this->connect();
|
||||
$id = pg_exec($this->Link_ID, "select * from $table");
|
||||
if ($id < 0) {
|
||||
$this->Error = pg_ErrorMessage($id);
|
||||
$this->Errno = 1;
|
||||
$this->halt("Metadata query failed.");
|
||||
}
|
||||
} else {
|
||||
$id = $this->Query_ID;
|
||||
if (!$id) {
|
||||
$this->halt("No query specified.");
|
||||
}
|
||||
}
|
||||
|
||||
$count = pg_NumFields($id);
|
||||
|
||||
for ($i=0; $i<$count; $i++) {
|
||||
$res[$i]["table"] = $table;
|
||||
$res[$i]["name"] = pg_FieldName ($id, $i);
|
||||
$res[$i]["type"] = pg_FieldType ($id, $i);
|
||||
$res[$i]["len"] = pg_FieldSize ($id, $i);
|
||||
$res[$i]["flags"] = "";
|
||||
}
|
||||
|
||||
if ($table) {
|
||||
pg_FreeResult($id);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
function affected_rows() {
|
||||
return pg_cmdtuples($this->Query_ID);
|
||||
}
|
||||
|
||||
function num_rows() {
|
||||
return pg_numrows($this->Query_ID);
|
||||
}
|
||||
|
||||
function num_fields() {
|
||||
return pg_numfields($this->Query_ID);
|
||||
}
|
||||
|
||||
function nf() {
|
||||
return $this->num_rows();
|
||||
}
|
||||
|
||||
function np() {
|
||||
print $this->num_rows();
|
||||
}
|
||||
|
||||
function tf($Name) {
|
||||
return $this->Record[$Name];
|
||||
}
|
||||
|
||||
function f($Name) {
|
||||
if($this->Record[$Name] == "")
|
||||
{
|
||||
return;
|
||||
//return " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
return trim($this->Record[$Name]);
|
||||
//return $this->Record[$Name];
|
||||
}
|
||||
}
|
||||
|
||||
function p($Name) {
|
||||
print $this->Record[$Name];
|
||||
}
|
||||
|
||||
function halt($msg) {
|
||||
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
|
||||
printf("<b>PostgreSQL Error</b>: %s (%s)<br>\n",
|
||||
$this->Errno,
|
||||
$this->Error);
|
||||
die("Session halted.");
|
||||
}
|
||||
|
||||
function table_names() {
|
||||
$this->query("select relname from pg_class where relkind = 'r' and not relname like 'pg_%'");
|
||||
$i=0;
|
||||
while ($this->next_record())
|
||||
{
|
||||
$return[$i]["table_name"]= $this->f(0);
|
||||
$return[$i]["tablespace_name"]=$this->Database;
|
||||
$return[$i]["database"]=$this->Database;
|
||||
$i++;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
function _query_string($method)
|
||||
{
|
||||
|
||||
$params = $_SERVER['QUERY_STRING'];
|
||||
|
||||
if( $method = "POST" )
|
||||
{
|
||||
if( getenv("REQUEST_METHOD") == "POST" )
|
||||
{
|
||||
$params = "$HTTP_POST_VARS";
|
||||
$params = str_replace("+", "%20", $params);
|
||||
}
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
function param_remove($params, $key)
|
||||
{
|
||||
$str = split("&", $params);
|
||||
$str_cnt = sizeof($str);
|
||||
|
||||
for( $i=0; $i < $str_cnt; $i++ )
|
||||
{
|
||||
$sub_str = split("=", $str[$i]);
|
||||
if( $sub_str[0] != $key )
|
||||
{
|
||||
$qstring .= $str[$i]. "&";
|
||||
}
|
||||
}
|
||||
if( $qstring != "" )
|
||||
{
|
||||
$qstring = substr($qstring, 0, strlen($qstring)-1);
|
||||
}
|
||||
|
||||
return $qstring;
|
||||
}
|
||||
|
||||
function sub_page_navigate( $page, $pagecnt, $preimg, $nextimg, $params )
|
||||
{
|
||||
$blocknum = (integer)(($page - 1) / 10) + 1;
|
||||
|
||||
$spage = ($blocknum-1) * 10 + 1;
|
||||
$epage = $blocknum * 10;
|
||||
|
||||
if( $epage > $pagecnt)
|
||||
{
|
||||
$epage = $pagecnt;
|
||||
}
|
||||
|
||||
$cur_url = $_SERVER['PHP_SELF'];
|
||||
|
||||
if($params != "") $params = "&".$params;
|
||||
|
||||
if($spage > 10) //' ÀÌÀü 10°³
|
||||
{
|
||||
if($preimg == "")
|
||||
{
|
||||
printf("<a href='".$cur_url."?page=".($spage-10).$params.">¢¸</a> ");
|
||||
}else
|
||||
{
|
||||
printf("<a href=".$cur_url."?page=".($spage-10).$params.">".$preimg."</a> ");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if($preimg == "")
|
||||
{
|
||||
printf("¢¸ ");
|
||||
}else
|
||||
{
|
||||
printf($preimg." ");
|
||||
}
|
||||
}
|
||||
|
||||
for($i = $spage; $i <= $epage; $i++)
|
||||
{
|
||||
if($i == $page)
|
||||
{
|
||||
printf(" <b>".$i."</b> ");
|
||||
}else
|
||||
{
|
||||
printf(" <a href=".$cur_url."?page=".$i.$params.">".$i."</a> ");
|
||||
}
|
||||
}
|
||||
|
||||
if($epage < $pagecnt)
|
||||
{
|
||||
if($nextimg == "")
|
||||
{
|
||||
printf(" <a href=".$cur_url."?page=".($epage+1).$params.">¢º</a>");
|
||||
}else
|
||||
{
|
||||
printf(" <a href=".$cur_url."?page=".($epage+1).$params.">".$nextimg."</a>");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if($nextimg == "")
|
||||
{
|
||||
printf(" ¢º");
|
||||
}else
|
||||
{
|
||||
printf(" ".$nextimg);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,655 @@
|
||||
<?php
|
||||
function MakeHtmlBodyFromArcmondClient($ip= NULL,$port ="8787",$cmd_seq ="2")
|
||||
{
|
||||
if ($ip != NULL)
|
||||
{
|
||||
sleep(5); // FHS SETTING VALUE (default:30)
|
||||
$command = "../inc/arcmond_client $ip $port $cmd_seq";
|
||||
exec($command, $raid_res);
|
||||
$raid_str = explode(":", $raid_res[0]);
|
||||
|
||||
$body = "<table border=\"1\" width=\"565\" cellspacing=\"0\" cellpadding=\"0\">";
|
||||
$body .= " <tr>";
|
||||
$body .= " <td colspan=\"2\">";
|
||||
$body .= " <font size=3><b>IP : $ip</b></font> Checked at ".date("Y-m-d H:i:s", $raid_str[1])." <br> ";
|
||||
$body .= " </td>";
|
||||
$body .= " </tr>";
|
||||
|
||||
$to_eli = $raid_str[0].":".$raid_str[1].":";
|
||||
$raid_res[0] = str_replace($to_eli,"",$raid_res[0]); // remove header phase
|
||||
$tot = count($raid_res);
|
||||
|
||||
for($i=0; $i < $tot; $i++) {
|
||||
$raid_res2 = explode("] ", str_replace("[", "", trim($raid_res[$i])));
|
||||
echo $raid_res2[0]."<br>";
|
||||
if($raid_res2[0] != "" && substr_count($raid_res2[0], "Disabled") == 0) {
|
||||
$body .= " <tr>";
|
||||
$body .= " <td width=\"160\" align=\"center\">".$raid_res2[0];
|
||||
$body .= " </td>";
|
||||
$body .= " <td> ".$raid_res2[1];
|
||||
$body .= " </td>";
|
||||
$body .= " </tr>";
|
||||
}else if(substr_count($raid_res2[0], "Disabled") > 0) {
|
||||
$body .= " <tr>";
|
||||
$body .= " <td align=\"center\" colspan=\"2\">\n".$raid_res2[0];
|
||||
$body .= " </td>";
|
||||
$body .= " </tr>";
|
||||
}
|
||||
}
|
||||
$body .= "</table>";
|
||||
} else {
|
||||
$body = "Fail to detail log!!";
|
||||
}
|
||||
//echo $body;
|
||||
return $body;
|
||||
}
|
||||
function htmlBody($ip)
|
||||
{
|
||||
if($ip != "")
|
||||
{
|
||||
// sleep(1); // FHS SETTING VALUE (default:30)
|
||||
|
||||
$thisfilename=basename(__FILE__);
|
||||
$temp_filename=realpath(__FILE__);
|
||||
if(!$temp_filename)
|
||||
$temp_filename=__FILE__;
|
||||
$osdir=eregi_replace($thisfilename,"",$temp_filename);
|
||||
|
||||
$command = $osdir . "arcmond_client $ip 8787 2";
|
||||
exec($command, $raid_res);
|
||||
$raid_str = explode(":", $raid_res[0]);
|
||||
|
||||
$body = "<table border=\"1\" width=\"565\" cellspacing=\"0\" cellpadding=\"0\">";
|
||||
$body .= " <tr>";
|
||||
$body .= " <td colspan=\"2\">";
|
||||
$body .= " <font size=3><b>IP : $ip</b></font> Checked at ".date("Y-m-d H:i:s", $raid_str[1])." <br> ";
|
||||
$body .= " </td>";
|
||||
$body .= " </tr>";
|
||||
|
||||
$to_eli = $raid_str[0].":".$raid_str[1].":";
|
||||
$raid_res[0] = str_replace($to_eli,"",$raid_res[0]);
|
||||
$tot = count($raid_res);
|
||||
|
||||
for($i=0; $i < $tot; $i++)
|
||||
{
|
||||
$raid_res2 = explode("] ", str_replace("[", "", trim($raid_res[$i])));
|
||||
if($raid_res2[0] != "" && substr_count($raid_res2[0], "Disabled") == 0) {
|
||||
$body .= " <tr>";
|
||||
$body .= " <td width=\"160\" align=\"center\">".$raid_res2[0];
|
||||
$body .= " </td>";
|
||||
$body .= " <td> ".$raid_res2[1];
|
||||
$body .= " </td>";
|
||||
$body .= " </tr>";
|
||||
}else if(substr_count($raid_res2[0], "Disabled") > 0) {
|
||||
$body .= " <tr>";
|
||||
$body .= " <td align=\"center\" colspan=\"2\">\n".$raid_res2[0];
|
||||
$body .= " </td>";
|
||||
$body .= " </tr>";
|
||||
}
|
||||
}
|
||||
$body .= "</table>";
|
||||
} else {
|
||||
$body = "Fail to detail log!!";
|
||||
}
|
||||
//echo $body;
|
||||
return $body;
|
||||
}
|
||||
|
||||
class Smtp {
|
||||
|
||||
var $host;
|
||||
var $fp;
|
||||
var $self;
|
||||
var $lastmsg;
|
||||
var $parts;
|
||||
var $error;
|
||||
var $debug;
|
||||
var $charset;
|
||||
var $ctype;
|
||||
|
||||
function Smtp($host="self") {
|
||||
if($host == "self") $this->self = true;
|
||||
else $this->host = $host;
|
||||
$this->parts = array();
|
||||
$this->error = array();
|
||||
$$this->debug = 0;
|
||||
$this->charset = "euc-kr";
|
||||
$this->ctype = "text/html";
|
||||
}
|
||||
|
||||
// 디버그 모드 : 1
|
||||
function debug($n=1) {
|
||||
$this->debug = $n;
|
||||
}
|
||||
|
||||
// smtp 통신을 한다.
|
||||
function dialogue($code, $cmd) {
|
||||
fputs($this->fp, $cmd."\r\n");
|
||||
$line = fgets($this->fp, 1024);
|
||||
ereg("^([0-9]+).(.*)$", $line, &$data);
|
||||
$this->lastmsg = $data[0];
|
||||
|
||||
if($this->debug) {
|
||||
echo htmlspecialchars($cmd)."<br>".$this->lastmsg."<br>";
|
||||
flush();
|
||||
}
|
||||
|
||||
if($data[1] != $code) return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// smptp 서버에 접속을 한다.
|
||||
function smtp_connect($host) {
|
||||
if($this->debug) {
|
||||
echo "SMTP($host) Connecting...<br>";
|
||||
flush();
|
||||
}
|
||||
if(!$host) $host = $this->host;
|
||||
|
||||
if(!$this->fp = fsockopen($host, 25, $errno, $errstr, 10)) {
|
||||
$this->lastmsg = "SMTP($host) 서버접속에 실패했습니다.[$errno:$errstr]";
|
||||
return false;
|
||||
}
|
||||
$line = fgets($this->fp, 1024);
|
||||
ereg("^([0-9]+).(.*)$", $line, &$data);
|
||||
$this->lastmsg = $data[0];
|
||||
if($data[1] != "220") return false;
|
||||
if($this->debug) {
|
||||
echo $this->lastmsg."<br>";
|
||||
flush();
|
||||
}
|
||||
$this->dialogue(250, "HELO phpmail");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// stmp 서버와의 접속을 끊는다.
|
||||
function smtp_close() {
|
||||
$this->dialogue(221, "QUIT");
|
||||
fclose($this->fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 메시지를 보낸다.
|
||||
function smtp_send($email, $from, $data) {
|
||||
|
||||
if(!$mail_from = $this->get_email($from)) return false;
|
||||
if(!$rcpt_to = $this->get_email($email)) return false;
|
||||
if(!$this->dialogue(250, "MAIL FROM: $mail_from"))
|
||||
$this->error[] = $email.":MAIL FROM 실패($this->lastmsg)";
|
||||
if(!$this->dialogue(250, "RCPT TO: $rcpt_to"))
|
||||
$this->error[] = $email.":RCPT TO 실패($this->lastmsg)";
|
||||
$this->dialogue(354, "DATA");
|
||||
$mime = "Message-ID: <".$this->get_message_id().">\r\n";
|
||||
$mime .= "From: $from\r\n";
|
||||
$mime .= "To: $email\r\n";
|
||||
|
||||
|
||||
fputs($this->fp, $mime);
|
||||
|
||||
fputs($this->fp, $data);
|
||||
|
||||
$this->dialogue(250, ".");
|
||||
}
|
||||
|
||||
// Message ID 를 얻는다.
|
||||
function get_message_id() {
|
||||
$id = date("YmdHis",time());
|
||||
mt_srand((float) microtime() * 1000000);
|
||||
$randval = mt_rand();
|
||||
$id .= $randval."@phpmail";
|
||||
return $id;
|
||||
}
|
||||
|
||||
// Boundary 값을 얻는다.
|
||||
function get_boundary() {
|
||||
$uniqchr = uniqid(time());
|
||||
$one = strtoupper($uniqchr[0]);
|
||||
$two = strtoupper(substr($uniqchr,0,8));
|
||||
$three = strtoupper(substr(strrev($uniqchr),0,8));
|
||||
return "----=_NextPart_000_000${one}_${two}.${three}";
|
||||
}
|
||||
|
||||
// 첨부파일이 있을 경우 이 함수를 이용해 파일을 첨부한다.
|
||||
function attach($message, $name="", $ctype="application/octet-stream") {
|
||||
$this->parts[] = array ("ctype" => $ctype, "message" => $message, "name" => $name);
|
||||
}
|
||||
|
||||
// Multipart 메시지를 생성시킨다.
|
||||
function build_message($part) {
|
||||
$msg .= "Content-Type: ".$part['ctype'];
|
||||
if($part['name']) $msg .= "; name=\"".$part['name']."\"";
|
||||
$msg .= "\r\nContent-Transfer-Encoding: base64\r\n";
|
||||
$msg .= "Content-Disposition: attachment; filename=\"".$part['name']."\"\r\n\r\n";
|
||||
$msg .= chunk_split(base64_encode($part['message']));
|
||||
return $msg;
|
||||
}
|
||||
|
||||
// SMTP에 보낼 DATA를 생성시킨다.
|
||||
function build_data($subject, $body) {
|
||||
$boundary = $this->get_boundary();
|
||||
$mime .= "Subject: $subject\r\n";
|
||||
$mime .= "Date: ".date ("D, j M Y H:i:s T",time())."\r\n";
|
||||
$mime .= "MIME-Version: 1.0\r\n";
|
||||
$mime .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\r\n\r\n".
|
||||
"This is a multi-part message in MIME format.\r\n\r\n";
|
||||
$mime .= "--".$boundary."\r\n".
|
||||
"Content-Type: ".$this->ctype."; charset=\"".$this->charset."\"\r\n".
|
||||
"Content-Transfer-Encoding: base64\r\n\r\n".
|
||||
chunk_split(base64_encode($body)).
|
||||
"\r\n\r\n--".$boundary;
|
||||
$max = count($this->parts);
|
||||
for($i=0; $i<$max; $i++) {
|
||||
$mime .= "\r\n".$this->build_message($this->parts[$i])."\r\n\r\n--".$boundary;
|
||||
}
|
||||
$mime .= "--\r\n";
|
||||
return $mime;
|
||||
}
|
||||
|
||||
// MX 값을 찾는다.
|
||||
function get_mx_server($email) {
|
||||
if(!ereg("([\._0-9a-zA-Z-]+)@([0-9a-zA-Z-]+\.[a-zA-Z\.]+)", $email, $reg)) return false;
|
||||
getmxrr($reg[2], $host);
|
||||
if(!$host) $host[0] = $reg[2];
|
||||
return $host;
|
||||
}
|
||||
|
||||
// 이메일의 형식이 맞는지 체크한다.
|
||||
function get_email($email) {
|
||||
if(!ereg("([\._0-9a-zA-Z-]+)@([0-9a-zA-Z-]+\.[a-zA-Z\.]+)", $email, $reg)) return false;
|
||||
return "<".$reg[0].">";
|
||||
}
|
||||
|
||||
// 메일을 전송한다.
|
||||
function send($to, $from, $subject, $body) {
|
||||
if(!is_array($to)) $to = split("[,;]",$to);
|
||||
if($this->self) {
|
||||
$data = $this->build_data($subject, $body);
|
||||
foreach($to as $email) {
|
||||
if($host = $this->get_mx_server($email)) {
|
||||
$flag = false; $i = 0;
|
||||
while($flag == false) {
|
||||
if($host[$i]) {
|
||||
$flag = $this->smtp_connect($host[$i]);
|
||||
$i++;
|
||||
echo "-----------> $i";
|
||||
} else break;
|
||||
}
|
||||
if($flag) {
|
||||
$this->smtp_send($email, $from, $data);
|
||||
$this->smtp_close();
|
||||
} else {
|
||||
$this->error[] = $email.":SMTP 접속실패";
|
||||
}
|
||||
} else {
|
||||
$this->error[] = $email.":형식이 잘못됨";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!$this->smtp_connect($this->host)) {
|
||||
$this->error[] = "$this->host SMTP 접속실패";
|
||||
return false;
|
||||
}
|
||||
$data = $this->build_data($subject, $body);
|
||||
foreach($to as $email) $this->smtp_send($email, $from, $data);
|
||||
$this->smtp_close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------사용법--------------------------------------------*/
|
||||
/*
|
||||
$mail = new Smtp("mail.solutionbox.co.kr");
|
||||
//$mail->debug();
|
||||
$mail->send("mirshead@solutionbox.co.kr", "mirshead@solutionbox.co.kr", "이 메일은 정상입니다.", "정상적인 메일이니 삭제하지 마십시오.");
|
||||
*/
|
||||
/*-----------------------------------------사용법--------------------------------------------*/
|
||||
|
||||
class mime
|
||||
{
|
||||
protected $mime_version = "1.0";
|
||||
protected $mime_content_type = "text/plain";
|
||||
protected $mime_charset = "ks_c_5601-1987";
|
||||
protected $mime_encoding = "base64";
|
||||
protected $mime_boundary = null;
|
||||
protected $mime_xmailer = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function set_content_type($content_type = null)
|
||||
{
|
||||
$this->mime_content_type = $content_type != null ? $content_type : "text/html";
|
||||
}
|
||||
|
||||
public function set_charset($charset = null)
|
||||
{
|
||||
$this->mime_charset = $charset != null ? $charset : "euc_kr";
|
||||
}
|
||||
|
||||
public function set_boundary($boundary = null)
|
||||
{
|
||||
$this->mime_boundary = $boundary ? $boundary : null;
|
||||
}
|
||||
|
||||
public function set_encoding($encoding = null)
|
||||
{
|
||||
$this->mime_encoding = $encoding != null ? $encoding : "base64";
|
||||
}
|
||||
|
||||
public function set_xmailer($xmailer = null)
|
||||
{
|
||||
$this->mime_xmailer = $xmailer != null ? $xmailer : $_SERVER['HTTP_USER_AGENT'];
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class sendmail extends mime
|
||||
{
|
||||
protected $smtp_server = null;
|
||||
protected $smtp_port = 0;
|
||||
protected $smtp_timeout = 0;
|
||||
protected $smtp_socketopen = 0;
|
||||
protected $smtp_status = false;
|
||||
protected $smtp_CRLF = "\r\n";
|
||||
protected $smtp_attachfile_name = null;
|
||||
protected $smtp_attachfile_size = 0;
|
||||
protected $smtp_attachfile_type = null;
|
||||
protected $smtp_cmd_status = array();
|
||||
protected $mail_from = null;
|
||||
protected $mail_to = null;
|
||||
protected $mail_subject = null;
|
||||
protected $mail_priority = 3;
|
||||
protected $mail_notification = 0;
|
||||
protected $mail_body = null;
|
||||
|
||||
public function __construct($server = null, $port = 0, $timeout = 0)
|
||||
{
|
||||
$this->smtp_server = ($server != null) ? $server : "localhost";
|
||||
$this->smtp_port = ($port != 0) ? $port : 25;
|
||||
$this->smtp_timeout = ($timeout != 0) ? $timeout : 30;
|
||||
}
|
||||
|
||||
public function encoding($str)
|
||||
{
|
||||
|
||||
return "=?ks_c_5601-1987?B?" . base64_encode($str) . "?=";
|
||||
}
|
||||
|
||||
private function _mail_env ($to, $from, $subject, $body, $priority = 3, $notification = 0)
|
||||
{
|
||||
$this->mail_from = $from;
|
||||
$this->mail_to = $to;
|
||||
$this->mail_subject = $subject;
|
||||
$this->mail_body = $body;
|
||||
$this->mail_priority = $priority;
|
||||
$this->mail_notification = $notification;
|
||||
}
|
||||
|
||||
private function _smtp_base_header()
|
||||
{
|
||||
$this->_smtp_cmd("From: $this->mail_from");
|
||||
$this->_smtp_cmd("To: $this->mail_to");
|
||||
$this->_smtp_cmd("Subject: $this->mail_subject");
|
||||
$this->_smtp_cmd("MIME-Version: $this->mime_version");
|
||||
$this->_smtp_cmd("X-Priority: $this->mail_priority");
|
||||
$this->_smtp_cmd("X-Mailer: $this->mime_xmailer");
|
||||
}
|
||||
|
||||
private function _smtp_base_content()
|
||||
{
|
||||
$this->_smtp_cmd("Content-Type: $this->mime_content_type; charset=\"$this->mime_charset\"");
|
||||
$this->_smtp_cmd("Content-Transfer-Encoding: $this->mime_encoding");
|
||||
}
|
||||
|
||||
|
||||
private function _smtp_multipart_content($attach = false)
|
||||
{
|
||||
if($attach)
|
||||
{
|
||||
$this->_smtp_cmd("Content-Type: multipart/mixed; boundary=\"$this->mime_boundary\"");
|
||||
} else {
|
||||
$this->_smtp_cmd("Content-Type: multipart/alternative; boundary=\"$this->mime_boundary\"");
|
||||
}
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
$this->_smtp_cmd("This is a multi-part message in MIME format.");
|
||||
}
|
||||
|
||||
private function _smtp_attachfile_content()
|
||||
{
|
||||
$this->_smtp_cmd("Content-Type: $this->smtp_attachfile_type");
|
||||
$this->_smtp_cmd("Content-Transfer-Encoding: $this->mime_encoding");
|
||||
$this->_smtp_cmd("Content-Disposition: attachment; filename=\"$this->smtp_attachfile_name\"");
|
||||
}
|
||||
|
||||
private function _smtp_start_boundary()
|
||||
{
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
$this->_smtp_cmd("--$this->mime_boundary");
|
||||
}
|
||||
|
||||
private function _smtp_end_boundary()
|
||||
{
|
||||
$this->_smtp_cmd("--$this->mime_boundary--");
|
||||
}
|
||||
|
||||
public function open()
|
||||
{
|
||||
$this->smtp_socketopen = @fsockopen($this->smtp_server, $this->smtp_port, $errno, $errstr, $this->smtp_timeout);
|
||||
if($this->_smtp_code($this->_receive()) != 220)
|
||||
{
|
||||
throw new Exception("..... ... . .....");
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->smtp_status = true;
|
||||
}
|
||||
|
||||
return $this->smtp_status;
|
||||
}
|
||||
|
||||
private function _smtp_helo()
|
||||
{
|
||||
$this->_smtp_cmd("HELO $this->smtp_server");
|
||||
if($this->_smtp_code($this->_receive()) == 250)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _smtp_mailfrom($from)
|
||||
{
|
||||
$this->_smtp_cmd("MAIL FROM: $this->mail_from");
|
||||
if($this->_smtp_code($this->_receive()) == 250)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _smtp_rcptto($to)
|
||||
{
|
||||
$this->_smtp_cmd("RCPT TO: $this->mail_to");
|
||||
if($this->_smtp_code($this->_receive()) == 250)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _smtp_data()
|
||||
{
|
||||
$this->_smtp_cmd("DATA");
|
||||
if($this->_smtp_code($this->_receive()) == 354)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _smtp_end()
|
||||
{
|
||||
$this->_smtp_cmd(".");
|
||||
if($this->_smtp_code($this->_receive()) == 250)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _smtp_quit()
|
||||
{
|
||||
$this->_smtp_cmd("QUIT");
|
||||
if($this->_smtp_code($this->_receive()) == 221)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
if(@fclose($this->smtp_socketopen) == false)
|
||||
{
|
||||
throw new Exception(".. ..... ...... .....");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _smtp_send($files = null)
|
||||
{
|
||||
$this->mime_boundary = "======" . uniqid(rand()) . "/$_SERVER[SERVER_NAME]";
|
||||
|
||||
$mail_body = nl2br(stripslashes($this->mail_body));
|
||||
|
||||
if($this->mime_encoding == "base64")
|
||||
{
|
||||
$mail_body = chunk_split(base64_encode($mail_body));
|
||||
}
|
||||
|
||||
$this->smtp_cmd_status[] = $this->_smtp_helo();
|
||||
$this->smtp_cmd_status[] = $this->_smtp_mailfrom($this->mail_from);
|
||||
$this->smtp_cmd_status[] = $this->_smtp_rcptto($this->mail_to);
|
||||
$this->smtp_cmd_status[] = $this->_smtp_data();
|
||||
|
||||
$this->_smtp_base_header();
|
||||
|
||||
if(is_array($files))
|
||||
{
|
||||
$this->_smtp_multipart_content(true);
|
||||
$this->_smtp_start_boundary();
|
||||
$this->_smtp_base_content();
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
$this->_smtp_cmd($mail_body);
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
|
||||
for($i = 0; $i < sizeof($files); $i++)
|
||||
{
|
||||
if(is_uploaded_file($files[tmp_name][$i]))
|
||||
{
|
||||
$this->smtp_attachfile_name = $this->_check_empty($files[name][$i]);
|
||||
$this->smtp_attachfile_size = $files[size][$i];
|
||||
$this->smtp_attachfile_type = $files[type][$i];
|
||||
|
||||
$attachfile_handle = @fopen($files[tmp_name][$i], "r");
|
||||
$attachfile_body = @fread($attachfile_handle, $files[size][$i]);
|
||||
|
||||
if($this->mime_encoding == "base64")
|
||||
{
|
||||
$attachfile_body = chunk_split(base64_encode($attachfile_body));
|
||||
}
|
||||
|
||||
$this->_smtp_start_boundary();
|
||||
$this->_smtp_attachfile_content();
|
||||
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
$this->_smtp_cmd($attachfile_body);
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
|
||||
@fclose($attachfile_handle);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_smtp_multipart_content(false);
|
||||
|
||||
$this->mime_content_type = "text/plain";
|
||||
|
||||
$this->_smtp_start_boundary();
|
||||
$this->_smtp_base_content();
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
$this->_smtp_cmd($mail_body);
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
|
||||
$this->mime_content_type = "text/html";
|
||||
|
||||
$this->_smtp_start_boundary();
|
||||
$this->_smtp_base_content();
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
$this->_smtp_cmd($mail_body);
|
||||
$this->_smtp_cmd("$this->smtp_CRLF");
|
||||
}
|
||||
|
||||
$this->_smtp_end_boundary();
|
||||
|
||||
$this->smtp_cmd_status[] = $this->_smtp_end();
|
||||
$this->smtp_cmd_status[] = $this->_smtp_quit();
|
||||
|
||||
foreach($this->smtp_cmd_status as $key => $value)
|
||||
{
|
||||
if($value == false)
|
||||
{
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _smtp_cmd($str)
|
||||
{
|
||||
@fputs($this->smtp_socketopen, $str . $this->smtp_CRLF);
|
||||
}
|
||||
|
||||
private function _smtp_code($str)
|
||||
{
|
||||
return substr($str, 0, 3);
|
||||
}
|
||||
|
||||
private function _receive()
|
||||
{
|
||||
return @fgets($this->smtp_socketopen, 1024);
|
||||
}
|
||||
|
||||
private function _check_empty($filename)
|
||||
{
|
||||
return preg_replace("/ /i", "_", $filename);
|
||||
}
|
||||
|
||||
public function send($to, $from, $subject, $text, $priority = 3, $files = null)
|
||||
{
|
||||
$this->set_xmailer($_SERVER[HTTP_USER_AGENT]);
|
||||
$this->set_content_type("text/html");
|
||||
$this->set_charset("euc_kr");
|
||||
$this->set_encoding("base64");
|
||||
|
||||
|
||||
$this->_mail_env($to, $from, $this->encoding($subject), $text, $priority);
|
||||
|
||||
if($this->_smtp_send($files) == false)
|
||||
{
|
||||
throw new Exception("Error");
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
Revision 0559
|
||||
-------------------
|
||||
수정일 : 2011-05-30
|
||||
수정자 : 김오종
|
||||
|
||||
- NEW: SVN 신규 등록
|
||||
- 기존 svn://211.38.137.33/old/gms/wwwroot/sh_raid_monitor/status/raid 에 존재하는
|
||||
소스와 LGU+ 에 적용된 소스의 통합 버전을 신규 등록한다.
|
||||
- 통합버전으로 관리 됨에 따라 신규 CC망이 설치 될 때 아래 wiki페이지를 참조하여 적용토록한다.
|
||||
-> http://192.168.0.247/redmine/projects/interactive/wiki/Web_utils_-_raid_%EA%B4%80%EC%A0%9C_sms_%EB%B0%8F_e-mail_%EB%B0%9C%EC%86%A1_html_%EC%83%81%EC%84%B8_%EC%84%A4%EB%AA%85
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
define(DBTYPE, "MYSQL"); // or
|
||||
//define(DBTYPE, "ORACLE");
|
||||
|
||||
if( DBTYPE == "ORACLE" )
|
||||
require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oci8inc.php");
|
||||
else if( DBTYPE == "MYSQL" )
|
||||
require_once ($_SERVER['DOCUMENT_ROOT']."/inc/mysql.inc");
|
||||
|
||||
require_once ($_SERVER['DOCUMENT_ROOT']."/inc/pgsql.inc");
|
||||
require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sendmail.inc");
|
||||
|
||||
|
||||
define(DB_HOST, "222.122.18.22");
|
||||
define(DB_USER, "smsuser");
|
||||
define(DB_PWD, "sms5emffld)");
|
||||
$id = "ALL";
|
||||
$pw = "1234";
|
||||
$to_mails = "sh_raid@solbox.com"; // or
|
||||
//$to_mails = "svc1@solbox.com";
|
||||
$from_mail = "svc1@solbox.com";
|
||||
|
||||
|
||||
|
||||
//$dbConnOra->connect("xcdnuser", "solbox123", "SMS");
|
||||
|
||||
function cutstr($str,$size) {
|
||||
if(!$size or (strlen($str) <= $size)) return $str;
|
||||
else for($i = 0;$i < $size;$i++) if(ord($str[$i]) > 127) $over++;
|
||||
return chop(substr($str,0,$size - $over%2));
|
||||
}
|
||||
|
||||
function sendsms_mysql($msg,$dbConnPgSql,$strSqlpg,$group_seq, $sid )
|
||||
{
|
||||
$tmpSqlmy = "";
|
||||
$tmpSqlpg = "";
|
||||
$user_count =0;
|
||||
$cellphone_list = "";
|
||||
|
||||
$dbConnPgSql->query($strSqlpg);
|
||||
if($dbConnPgSql->nf() == 0)
|
||||
{
|
||||
echo "fail to pgsql querty : $strSqlpg "; echo "<br><br>";
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2010-09-15 huibong SMS RELAY 서버 변경 및 관련 코드 수정 처리함.
|
||||
$dbConnMySql = new dbconnect(DB_HOST, DB_USER , DB_PWD, 'sms', __FILE__, __LINE__);
|
||||
|
||||
while($dbConnPgSql->next_record())
|
||||
{
|
||||
$cellphone = $dbConnPgSql->f("member_cellphone");
|
||||
|
||||
if( strlen($cellphone_list) > 0 )
|
||||
{
|
||||
$cellphone_list .= "|ktics1^" . $cellphone;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cellphone_list = "ktics1^" . $cellphone;
|
||||
}
|
||||
|
||||
$user_count ++;
|
||||
|
||||
$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()); ";
|
||||
|
||||
}
|
||||
|
||||
$tmpSqlmy = "INSERT INTO SDK_SMS_SEND ( USER_ID, SCHEDULE_TYPE, SUBJECT, NOW_DATE,SEND_DATE, CALLBACK, DEST_COUNT, DEST_INFO, SMS_MSG) ";
|
||||
$tmpSqlmy .= "VALUES ('ktics1', 0,'ktics1',DATE_FORMAT(now(),'%Y%m%d%H%i%s'),DATE_FORMAT(now(),'%Y%m%d%H%i%s'),'0317810344',$user_count,'$cellphone_list','$msg')";
|
||||
$res = $dbConnMySql->query($tmpSqlmy,__FILE__, __LINE__);
|
||||
if( !$res->result )
|
||||
{
|
||||
echo "fail to send SMS "; echo "<br><br>";
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbConnMySql->close();
|
||||
|
||||
$dbConnPgSql->query($tmpSqlpg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function sendsms_oracle($msg,$dbConnPgSql,$strSqlpg,$group_seq, $sid)
|
||||
{
|
||||
$tmpSqlmy = "";
|
||||
$tmpSqlpg = "";
|
||||
$user_count =0;
|
||||
|
||||
$dbConnPgSql->query($strSqlpg);
|
||||
|
||||
if($dbConnPgSql->nf() == 0)
|
||||
{
|
||||
echo "fail to pgsql querty : $strSqlpg "; echo "<br><br>";
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbConnOra = new Oracle_OCI_log;
|
||||
|
||||
$dbConnOra->connect(DB_HOST, DB_USER, "SMS");
|
||||
if( !$dbConnOra->conn ) {
|
||||
echo "Oracle Connect Failed "; echo "<br><br>";
|
||||
}
|
||||
echo " Oracle DB SERVER Connecting..."; echo "<br><br>";
|
||||
|
||||
while($dbConnPgSql->next_record())
|
||||
{
|
||||
$cellphone = $dbConnPgSql->f("member_cellphone");
|
||||
$cli_ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$tmpSqlmy = "INSERT INTO SC_TRAN(TR_NUM, TR_SENDDATE, TR_SENDSTAT, TR_PHONE, TR_CALLBACK, TR_MSG, TR_MSGTYPE)";
|
||||
$tmpSqlmy .= "VALUES ( SC_SEQUENCE.NEXTVAL, SYSDATE, '0', '$cellphone', '$cellphone', '$msg', '0')";
|
||||
|
||||
$dbConnOra->parseExec($tmpSqlmy);
|
||||
if($dbConnOra->error) {
|
||||
echo "fail to send SMS "; echo "<br><br>";
|
||||
continue;
|
||||
}
|
||||
$user_count ++;
|
||||
|
||||
$tmpSqlpg .= "INSERT INTO t_sms_log (group_seq, sms_id, sms_cellphone, sms_message, reg_datetime, update_datetime) ";
|
||||
$tmpSqlpg .= "VALUES (".$group_seq.", 'SH_".$sid."', '".$cellphone."', '".$msg."', now(), now()); ";
|
||||
}
|
||||
|
||||
$dbConnOra->disconnect();
|
||||
|
||||
|
||||
if($user_count == $dbConnPgSql->nf()){
|
||||
echo "Success to All send SMS " ; echo "<br><br>";
|
||||
|
||||
$dbConnPgSql->query($tmpSqlpg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$mseg = $_GET['msg'];
|
||||
$time = $_GET['time'];
|
||||
$raddr = $_SERVER["REMOTE_ADDR"];
|
||||
echo $mseg."<br>";
|
||||
|
||||
// CHG 2010-06-17 huibong Message 에서 구분자 : 을 제거처리
|
||||
//$msg = "[RAID:".$_GET['host']."]::".$time.":".$mseg;
|
||||
$msg = "[RAID:".$_GET['host']."] ".$time." ".$mseg;
|
||||
echo $msg."<br>";
|
||||
|
||||
$cmd = 'echo `date +"%Y%m%d %H:%M:%S"`'.": $host";
|
||||
system("$cmd >> logs/raid.send.sms.mail.`date +%Y%m%d`.log");
|
||||
|
||||
|
||||
$body = trim(htmlBody($raddr));
|
||||
#$body = trim(MakeHtmlBodyFromArcmondClient($raddr, 8787, 2)); // default value of arcmond
|
||||
|
||||
$to_mail = explode(",", $to_mails);
|
||||
$cnt = count($to_mail);
|
||||
for($i=0; $i < $cnt; $i++) {
|
||||
$sendmail = new sendmail("127.0.0.1", 25, 30);
|
||||
$sendmail->open();
|
||||
$sendmail->send($to_mail[$i], $from_mail, trim($msg), $body);
|
||||
$sendmail->close();
|
||||
}
|
||||
|
||||
|
||||
if($id != "" && $msg != "")
|
||||
{
|
||||
$sms_host = strtok( $_GET['host'], "." );
|
||||
|
||||
$sms_time = $time;
|
||||
if( strlen($sms_time) > 14 )
|
||||
{
|
||||
$sms_time = substr($time, 5);
|
||||
}
|
||||
|
||||
$sms_msg = $mseg;
|
||||
if( strncmp( $mseg, "Controller#", 11) == 0 )
|
||||
{
|
||||
$sms_msg = substr( $mseg, 10 );
|
||||
}
|
||||
|
||||
//$msg = "[RAID:".$sms_host." ".$raddr."] ".$sms_time." ".$sms_msg;
|
||||
$msg = "[RAID:".$sms_host."] ".$sms_time." ".$sms_msg;
|
||||
echo $msg."<br>";
|
||||
|
||||
$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'";
|
||||
#$strSqlpg .= "WHERE group_id = '".$id."' AND deleted_yn = 'N'";
|
||||
|
||||
$sizelen=strlen($msg);
|
||||
echo "Message : $msg Size :$sizelen \n"; echo "<br><br>";
|
||||
$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;
|
||||
|
||||
if($sizelen > 80){
|
||||
$strtmp = $msg;
|
||||
$msg=cutstr($strtmp,80);
|
||||
$sizelen=strlen($msg);
|
||||
echo "CutSTR Message : $msg Size :$sizelen \n"; echo "<br><br>";
|
||||
}
|
||||
|
||||
$SMS_send_Success = false;
|
||||
|
||||
for($i = 0; $i< 2; $i++) {
|
||||
if(!$SMS_send_Success) {
|
||||
|
||||
if( DBTYPE == "MYSQL" )
|
||||
$SMS_send_Success = sendsms_mysql( $msg, $dbConnPgSql, $strSqlpg, $group_seq, $id);
|
||||
else if( DBTYPE == "ORACLE")
|
||||
$SMS_send_Success = sendsms_oracle( $msg, $dbConnPgSql, $strSqlpg, $group_seq, $id );
|
||||
|
||||
if( $SMS_send_Success ) break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$SMS_send_Success ){
|
||||
echo "Unexpected error was occured "; echo "<br><br>";
|
||||
}
|
||||
|
||||
}else
|
||||
echo "PGSQL `group_seq` failed"; echo "<br><br>";
|
||||
|
||||
$dbConnPgSql->close();
|
||||
}else
|
||||
echo "id or msg NULL!!!"; echo "<br><br>";
|
||||
}else
|
||||
echo "Unexpected error was occured. id : \"$id\" msg :\"$msg\"\n"; echo "<br><br>";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user