base
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
Revision 1405
|
||||
-------------------
|
||||
수정일 : 2016-08-04
|
||||
수정자 : 유희곤
|
||||
|
||||
- CHG: sms 전송 문자열을 한글 -> 영문으로 변경 처리
|
||||
- sms 문자 전송을 위한 DB 입력시 한글 입력 오류가 발생하여..
|
||||
- 전반적인 호환성을 위해 영문으로 변경 처리함.
|
||||
|
||||
|
||||
Revision 1404
|
||||
-------------------
|
||||
수정일 : 2016-08-03
|
||||
수정자 : 유희곤
|
||||
|
||||
- NEW: SKBB CDN 신규 구축에 따른 IDC 정보 및 SMS 전송 방법 추가 (#28221)
|
||||
- SKBB IDC 정보 추가 및 sms 전송 관련 기능 추가
|
||||
|
||||
- CHG: main 버전 정보 변경
|
||||
- 3.4 -> 3.5
|
||||
|
||||
|
||||
Revision 1091
|
||||
-------------------
|
||||
수정일 : 2014-10-16
|
||||
수정자 : 유희곤
|
||||
|
||||
- CHG: PHP Notice 발생 관련 코드 수정
|
||||
- check_storage.php 의 pg_fetch_row() 함수 관련 Notice 로그 발생
|
||||
- 해당 함수의 2번째 인자값이 사용되지 않으므로 제거 처리함.
|
||||
|
||||
- CHG: PHP 문법 관련 오류 처리
|
||||
- inc/sendmail.inc
|
||||
- <? -> <?php 으로 수정 처리
|
||||
|
||||
|
||||
Revision 1059
|
||||
-------------------
|
||||
수정일 : 2014-08-12
|
||||
수정자 : 유희곤
|
||||
|
||||
- CHG: Sort 기능 강화
|
||||
- 스토리지 사용률에 대한 Sort 시 동일 사용률일때
|
||||
- 스토리지 사용량에 따라 sort 되도록 기능 추가.
|
||||
|
||||
- CHG: LG U+ GTS Domain 정보 적용
|
||||
- CCDB 접속 관련 기존 IP 대시 cs-gts.x-cdn.com 정보 적용
|
||||
|
||||
|
||||
Revision 1055
|
||||
-------------------
|
||||
수정일 : 2014-08-11
|
||||
수정자 : 유희곤
|
||||
|
||||
- NEW: LG U+ 지원관련 기능 추가
|
||||
- LG U+ CCDB 접속 관련 정보 추가
|
||||
- IDC 설정에 따른 분기 처리 관련 기능 추가.
|
||||
- inc/oci8inc.php 추가 (Oracle SMS 전송 관련)
|
||||
- SMS 전송 불가에 따른 조치 처리.
|
||||
|
||||
- CHG: SMS, Mail 전송 순서 변경
|
||||
- SMS 전송관련 DB 접속 실패시... PHP 종료로 인한 Mail 전송 실패 발생 가능
|
||||
- 따라서 Mail 을 먼저 전송 후 SMS 전송토록 순서 변경
|
||||
|
||||
- CHG: Version 변경 및 표시 기능 추가
|
||||
- 팀 버전 규칙에 따라 Major 버전을 3.4.0 으로 등록
|
||||
- 해당 php 버전 정보가 Web 상에 표시되도록 처리
|
||||
|
||||
- CHG: README.txt
|
||||
- 최신 내역 등록
|
||||
|
||||
|
||||
|
||||
Revision 0976
|
||||
-------------------
|
||||
수정일 : 2014-03-31
|
||||
수정자 : 유희곤
|
||||
|
||||
- NEW: SVN 신규 등록
|
||||
- 신규 SVN 등록
|
||||
기존 sms/disk_check 와 유사한 기능을 수행하지만.... 소스 및 기능 확장을 위해 신규 개발
|
||||
- 본 모듈 관련 자세한 사항은 redmine #18347 이슈 참고
|
||||
|
||||
- NEW: README.txt 추가
|
||||
- 설치 및 설정 관련 사항을 상세하게 설명한 README 파일 추가
|
||||
|
||||
- NEW: History 저장을 위한 Changelog.txt 파일 추가
|
||||
|
||||
- NEW: Version 변경.
|
||||
- 팀 버전 규칙에 따라 Major 버전을 3.3.0 으로 등록
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
[기능 설명]
|
||||
본 PHP 모듈은 PostgreSQL CCDB 상에서 서비스 정보와 각 서비스별 Storage 사용량
|
||||
정보를 확인한 후
|
||||
Storage 사용량이 설정된 관제 임계치를 초과할 경우....
|
||||
check_storage.conf 상에 지정된 담당자에게 SMS, Mail 을 전송을 수행한다.
|
||||
|
||||
|
||||
[설치 경로]
|
||||
binary : /user/service/bin/check_storage.php
|
||||
include : /user/service/bin/inc/sendmail.inc, mysql.inc, oci8inc.php
|
||||
conf : /user/service/etc/check_storage.conf
|
||||
|
||||
|
||||
[output file]
|
||||
check_storage_report.html
|
||||
- GMS Web 상에서 접근 가능한 경로에 저장되도록 처리.
|
||||
- GMS Web 상이 Storage 사용량 버튼과 연동되도록 처리 필요.
|
||||
|
||||
|
||||
[기동 방식]
|
||||
crontab 상에 다음과 같이 등록하여 30분마다 동작하도록 처리.( -q 옵션 미사용시 불필요 Header 발생 가능)
|
||||
|
||||
*/30 * * * * root /usr/local/bin/php -q /user/service/bin/check_storage.php > /user/service/wwwroot/sh_monitor/status/check_storage_report.html
|
||||
|
||||
|
||||
[설치 관련 사전 조건]
|
||||
1. 해당 장비에서 PostgreSQL CCDB 와 접속 가능해야 함.
|
||||
2. 해당 장비에서 sendmail 프로세스가 정상 동작.
|
||||
3. SMS 전송을 위한 각 IDC 별 설정이 필요함.
|
||||
|
||||
|
||||
[PHP 설치 방법]
|
||||
1. 해당 GMS 에 PHP 가 설치되지 않은 경우..
|
||||
2. 다음과 같이 소스 설치 처리한다.
|
||||
|
||||
# php-5.5.10 소스 설치 후.
|
||||
# ./configure --with-pgsql=/user/db/pgsql --with-mysql=/user/db/mysql(SMS 전송관련 각 IDC 별 옵션)
|
||||
# make
|
||||
# make test
|
||||
# make install
|
||||
# /usr/local/bin/php -v
|
||||
|
||||
|
||||
[IDC 별 수정항목]
|
||||
IDC 별 CCDB 및 SMS 전송 등의 방법이 다르므로....
|
||||
check_storage.php 에서 TODO 로 표시된 항목을 검색하여
|
||||
각 IDC 에 맞도록 수정 처리 또는 기능 추가한다.
|
||||
|
||||
|
||||
[GMS Web 수정]
|
||||
/user/service/wwwroot/sh_monitor/inc/contact.html 소스 상의 function disk_check() 함수에 다음과 같이 수정 처리
|
||||
|
||||
window.open("../status/check_storage_report.html","_box", 'height=' + screen.height + ',width=' + screen.width + 'fullscreen=yes, scrollbars=yes');
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[DEFAULT]
|
||||
|
||||
SMS= 김정진|01068118901
|
||||
SMS= 이영재|01052043199
|
||||
SMS= 최현선|01053650370
|
||||
SMS= 전지훈|01030141695
|
||||
SMS= 전정관|01024592017
|
||||
SMS= 백경|01029117866
|
||||
SMS= 최승호|01062621227
|
||||
SMS= 솔박1|01042522372
|
||||
SMS= 솔박2|01042522373
|
||||
SMS= 김오종|01085354477
|
||||
SMS= 정기욱|01094964373
|
||||
|
||||
MAIL= 김정진|jeong-jin.kim@kt.com
|
||||
MAIL= ICS운영팀|ics@solbox.com
|
||||
MAIL= 기술지원팀|storage.ts@solbox.com
|
||||
MAIL= 개발팀|storage.sd@solbox.com
|
||||
|
||||
|
||||
[totodisk05]
|
||||
|
||||
SMS= 김도윤|01071148235
|
||||
SMS= 백용규|01088941120
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[DEFAULT]
|
||||
|
||||
SMS= 유희곤|01065540424
|
||||
MAIL= 유희곤|huibong@solbox.com
|
||||
|
||||
|
||||
[ktiframe]
|
||||
SMS= 김오종|01085354477
|
||||
MAIL= 개발팀|storage.sd@solbox.com
|
||||
@@ -0,0 +1,637 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="euc-kr">
|
||||
<title>Cloud Storage - Used Storage Check Report</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Cloud Storage</h1>
|
||||
<h2>서비스별 Storage 사용량 Report (Ver 3.5.0.R1506)</h2>
|
||||
|
||||
|
||||
<?php
|
||||
// 라이브러리 정의
|
||||
require_once("inc/sendmail.inc"); // 메일 전송 관련.
|
||||
|
||||
|
||||
// 상수값 정의
|
||||
define( CONF_FILE, "/user/service/etc/check_storage.conf");
|
||||
|
||||
|
||||
// ******* TODO: IDC 별 설정, ****************
|
||||
// 본 설정은 SMS 전송 관련 설정. KT, LG 등으로 설정 처리
|
||||
//define( IDC_INFO, "KT" );
|
||||
//define( IDC_INFO, "LG U+" );
|
||||
//define( IDC_INFO, "SKBB" );
|
||||
define( IDC_INFO, "SOLBOX" );
|
||||
|
||||
|
||||
// IDC 별 설정 설정 정보
|
||||
if( strcmp( IDC_INFO, "KT" ) == 0 )
|
||||
{
|
||||
$CCDB_CONNECT_STRING = "dbname=cs_ccdb user=solboxcs password=thsutleodlQj host=cc-gts.ktsh.co.kr port=9000"; // KT CCDB
|
||||
$ALARM_MAIL_SENDER = "storage@solbox.com"; // KT 메일 발신자.
|
||||
}
|
||||
else if( strcmp( IDC_INFO, "LG U+" ) == 0 )
|
||||
{
|
||||
$CCDB_CONNECT_STRING = "dbname=cs_ccdb user=solboxcs password=thsutleodlQj host=cs-gts.x-cdn.com port=9000"; // LG U+ CCDB
|
||||
$ALARM_MAIL_SENDER = "storage@solbox.com"; // LG U+ 메일 발신자 (개발팀 Storage 담당)
|
||||
}
|
||||
else if( strcmp( IDC_INFO, "SKBB" ) == 0 )
|
||||
{
|
||||
$CCDB_CONNECT_STRING = "dbname=cs_ccdb user=solboxcs password=thsutleodlQj host=222.239.93.4 port=6543"; // SKB CCDB
|
||||
$ALARM_MAIL_SENDER = "storage@solbox.com"; // SKBB 메일 발신자 (개발팀 Storage 담당)
|
||||
}
|
||||
else if( strcmp( IDC_INFO, "SOLBOX" ) == 0 )
|
||||
{
|
||||
$CCDB_CONNECT_STRING = "dbname=cs_ccdb user=solboxcs password=thsutleodlQj host=192.168.10.128 port=6543"; // SKB CCDB
|
||||
$ALARM_MAIL_SENDER = "storage@solbox.com"; // SKBB 메일 발신자 (개발팀 Storage 담당)
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: IDC 별 설정 추가
|
||||
die("<p><b>[ERROR] Undefined IDC info. Check IDC_INFO value.</b></p></body></html>");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: SMS 전송함수 ( IDC 별 기능 추가 )
|
||||
// SMS 전송 처리 결과... 1: 전송 성공, 0: 전송 실패, -1: SMS 전송 설정 안됨..
|
||||
function send_sms( $phone, $message )
|
||||
{
|
||||
if( strcmp( IDC_INFO, "KT" ) == 0 )
|
||||
{
|
||||
// KT 의 경우 SMS 전송을 위해 MySQL DB 사용하며...
|
||||
// - INSERT 처리시 고유 규칙이 있어 이를 준수해야 함.
|
||||
require_once("inc/mysql.inc");
|
||||
|
||||
// KT SMS 전송은 MySQL DB 에 KT 관련 규칙에 맞도록 저장 처리한다.
|
||||
$sms_db = new dbconnect('222.122.18.22', 'smsuser', 'sms5emffld)', 'sms', __FILE__, __LINE__);
|
||||
|
||||
// KT 수신자관련 저장 규칙
|
||||
$sms_target = "ktics1^".$phone;
|
||||
|
||||
$sms_query = "INSERT INTO SDK_SMS_SEND (USER_ID, SCHEDULE_TYPE, SUBJECT, NOW_DATE, SEND_DATE, CALLBACK, DEST_COUNT, DEST_INFO, SMS_MSG) ";
|
||||
$sms_query .= "VALUES ('ktics1', 0,'ktics1',DATE_FORMAT(now(),'%Y%m%d%H%i%s'),DATE_FORMAT(now(),'%Y%m%d%H%i%s'),'0317810344', 1,'$sms_target','$message')";
|
||||
|
||||
$sms_result = $sms_db->query($sms_query, __FILE__, __LINE__);
|
||||
|
||||
// SMS DB 접속 해제
|
||||
$sms_db->close();
|
||||
|
||||
if( !$sms_result->result ) // 전송 실패시....
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
else if( strcmp( IDC_INFO, "LG U+" ) == 0 ) //LG U+ 의 SMS 전송 기능
|
||||
{
|
||||
// LG U+ 의 경우.. SMS 전송을 위해 Oracle -> MySQL DB로 변경되어 이를 사용
|
||||
// - INSERT 처리시 고유 규칙이 있어 이를 준수해야 함.
|
||||
require_once("inc/mysql.inc");
|
||||
|
||||
$sms_db = new dbconnect('smsdb.x-cdn.com', 'xcdnuser', 'solbox123', 'SMS', __FILE__, __LINE__);
|
||||
|
||||
$sms_query = "INSERT INTO SC_TRAN( TR_SENDDATE, TR_SENDSTAT, TR_PHONE, TR_CALLBACK, TR_MSG, TR_MSGTYPE)";
|
||||
$sms_query .= "VALUES ( now(), '0', '$phone', '$phone', '$message', '0')";
|
||||
|
||||
$sms_result = $sms_db->query($sms_query, __FILE__, __LINE__);
|
||||
|
||||
// SMS DB 접속 해제
|
||||
$sms_db->close();
|
||||
|
||||
if( !$sms_result->result ) // 전송 실패시....
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
|
||||
}
|
||||
else if( strcmp( IDC_INFO, "SKBB" ) == 0 )
|
||||
{
|
||||
// SKBB 의 경우 SMS 전송을 위해 솔박에서 구매한 sms 전송 시스템 사용, MySQL DB 사용
|
||||
require_once("inc/mysql.inc");
|
||||
|
||||
// SKBB SMS 전송은 MySQL DB 에 관련 규칙에 맞도록 저장 처리한다.
|
||||
$sms_db = new dbconnect('222.239.93.143:13306', 'lghv_user', 'solbox@#12', 'lghv_db', __FILE__, __LINE__);
|
||||
|
||||
// 수신자관련 저장 규칙
|
||||
$sms_target = $phone;
|
||||
|
||||
$sms_query = "INSERT INTO lghv_db.TBL_SEND_TRAN( fmsgtype, fmessage, fsenddate, fdestine, fcallback ) ";
|
||||
$sms_query.= "VALUES ( '0', '$message', now(), '$sms_target', '0221823688' ); ";
|
||||
|
||||
$sms_result = $sms_db->query($sms_query, __FILE__, __LINE__);
|
||||
|
||||
// SMS DB 접속 해제
|
||||
$sms_db->close();
|
||||
|
||||
if( !$sms_result->result ) // 전송 실패시....
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
else if( strcmp( IDC_INFO, "SOLBOX" ) == 0 )
|
||||
{
|
||||
// SOLBOX 인 경우.. SKBB 를 그대로 사용한다.
|
||||
// SKBB 의 경우 SMS 전송을 위해 솔박에서 구매한 sms 전송 시스템 사용, MySQL DB 사용
|
||||
require_once("inc/mysql.inc");
|
||||
|
||||
// SKBB SMS 전송은 MySQL DB 에 관련 규칙에 맞도록 저장 처리한다.
|
||||
$sms_db = new dbconnect('222.239.93.143:13306', 'lghv_user', 'solbox@#12', 'lghv_db', __FILE__, __LINE__);
|
||||
|
||||
// 수신자관련 저장 규칙
|
||||
$sms_target = $phone;
|
||||
|
||||
$sms_query = "INSERT INTO lghv_db.TBL_SEND_TRAN( fmsgtype, fmessage, fsenddate, fdestine, fcallback ) ";
|
||||
$sms_query.= "VALUES ( '0', '$message', now(), '$sms_target', '0221823688' ); ";
|
||||
|
||||
$sms_result = $sms_db->query($sms_query, __FILE__, __LINE__);
|
||||
|
||||
// SMS DB 접속 해제
|
||||
$sms_db->close();
|
||||
|
||||
if( !$sms_result->result ) // 전송 실패시....
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SMS 전송함수가 정의되어 있지 않은 경우.
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 서비스 정보 출력시... Storage 사용률 정보를 기준으로 Sort 처리하기 위한 함수.
|
||||
function service_compare($x, $y)
|
||||
{
|
||||
if( $x[6] == $y[6] )
|
||||
{
|
||||
// 스토리지 사용률이 동일한 경우....
|
||||
// 스토리지 사용량값을 이용하여 정렬 처리.
|
||||
if( $x[4] == $y[4] )
|
||||
return 0;
|
||||
else if( $x[4] < $y[4] )
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if( $x[6] < $y[6] )
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 기타 정의
|
||||
date_default_timezone_set('Asia/Seoul'); // date 함수 사용 관련 timezone 설정 오류 회피 목적
|
||||
|
||||
//phpinfo();
|
||||
|
||||
// 시작 정보 기록..
|
||||
$check_start_time = date("Y-m-d H:i:s");
|
||||
|
||||
|
||||
// CCDB 상에서 감시대상 서비스 정보 추출
|
||||
$ccdb_handle = pg_connect( $CCDB_CONNECT_STRING );
|
||||
if( $ccdb_handle == false )
|
||||
{
|
||||
// CCDB 연결 실패시... PHP 종료 처리
|
||||
die("<p><b>[$check_start_time] CCDB Connection failed.</b></p></body></html>");
|
||||
}
|
||||
|
||||
$query_service = "SELECT A.svc_id AS service, D.id AS rc_name, D.stat_id AS rc_id , A.user_seq AS user_seq, A.svc_seq AS svc_seq, B.storage_used_alarm AS alarm_limit
|
||||
FROM cs_service.cs_service A, cs_alarm.cs_service_alarm B, cs_service.cs_service_config C, cs_service.cs_rc_info D
|
||||
WHERE
|
||||
A.svc_seq = B.svc_seq
|
||||
AND B.svc_seq = C.svc_seq
|
||||
AND C.rc_domain = D.rc_domain
|
||||
AND A.del_yn = 'N'
|
||||
AND A.status_code = 'SVC_STATUS_ING'
|
||||
AND B.storage_used_alarm > 0
|
||||
ORDER BY A.svc_seq, D.stat_id ";
|
||||
|
||||
$ccdb_result_service = pg_exec( $ccdb_handle, $query_service );
|
||||
if( $ccdb_result_service == false )
|
||||
{
|
||||
// CCDB Query 실패시... PHP 종료 처리
|
||||
echo pg_errormessage( $ccdb_handle );
|
||||
pg_close($ccdb_handle);
|
||||
die("<p><b>[$check_start_time] CCDB Query failed.[$query_service]</b></p></body></html>");
|
||||
|
||||
}
|
||||
|
||||
// 조회 결과 저장.
|
||||
$array_service = array();
|
||||
for( $row_service = 0; $row_service < pg_numrows($ccdb_result_service); $row_service++ )
|
||||
{
|
||||
$values = pg_fetch_row( $ccdb_result_service, $row_service );
|
||||
|
||||
// $values[0] : 서비스 Name : totodisk05
|
||||
// $values[1] : RC Name : BD-09
|
||||
// $values[2] : rc stat_id : bd09
|
||||
// $values[3] : user_seq : 156
|
||||
// $values[4] : svc_seq : 238
|
||||
// $values[5] : alarm_limit : 70
|
||||
|
||||
array_push( $array_service, $values );
|
||||
}
|
||||
pg_freeresult( $ccdb_result_service ); // CCDB result set free.
|
||||
|
||||
|
||||
// 감시대상 서비스에 대한 Storage 사용량 조회.
|
||||
$services = array(); // 최종 정보를 저장할 변수.
|
||||
|
||||
reset( $array_service );
|
||||
$service_total_count = count( $array_service );
|
||||
for( $service_index = 0; $service_index < $service_total_count; $service_index++ )
|
||||
{
|
||||
$query_used = "SELECT stg_size, used_stg_size, to_char(reg_date, 'YYYY-MM-DD HH24:MI:SS') FROM cs_stat.cs_stat_storage
|
||||
WHERE reg_date > ( now() - interval '30 minute' )
|
||||
AND user_seq = ".$array_service[$service_index][3]."
|
||||
AND svc_seq = ".$array_service[$service_index][4]."
|
||||
AND rc_id = '".$array_service[$service_index][2]."'
|
||||
ORDER BY reg_date DESC LIMIT 1";
|
||||
|
||||
$ccdb_result_used = pg_exec( $ccdb_handle, $query_used );
|
||||
|
||||
// 결과 Row 수는 정상인 경우 1건... 조회 결과 없을 경우.. 0건 임.
|
||||
if( pg_numrows($ccdb_result_used) == 1 )
|
||||
{
|
||||
// 정상 조회된 경우...
|
||||
//$values = pg_fetch_row( $ccdb_result_used, $row_used );
|
||||
$values = pg_fetch_row( $ccdb_result_used );
|
||||
|
||||
// $values[0] : 계약용량(Byte) : 329853488332800
|
||||
// $values[1] : 사용량(Byte) : 193857136159126
|
||||
// $values[2] : Last 통계 시각 : 2014-03-26 14:20:00
|
||||
|
||||
// 최종 출력 관련 $services 배열 저장 순서..
|
||||
// 0. 서비스 Name
|
||||
// 1. RC Name
|
||||
// 2. 계약용량
|
||||
// 3. alarm_limit
|
||||
// 4. 사용량
|
||||
// 5. Last 통계 시간
|
||||
// 6. Storage 사용률 => 아래 함수에서 처리하므로.. 0.0 으로 저장 처리.
|
||||
|
||||
$temp = array( $array_service[$service_index][0], $array_service[$service_index][1], $values[0]
|
||||
, $array_service[$service_index][5], $values[1], $values[2], 0.0 );
|
||||
|
||||
array_push( $services, $temp );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 해당 서비스에 대한 통계 정보 조회 실패시..
|
||||
// - 아래 Flow 에서 처리를 수행하기 위해.. 계약 용량값을 -1 값을 처리.
|
||||
$temp = array( $array_service[$service_index][0], $array_service[$service_index][1], -1
|
||||
, $array_service[$service_index][5], 0, 'Storage 통계 Not Found', 0.0 );
|
||||
|
||||
array_push( $services, $temp );
|
||||
}
|
||||
|
||||
pg_freeresult( $ccdb_result_used ); // CCDB result set free.
|
||||
|
||||
}
|
||||
|
||||
// CCDB 연결 종료
|
||||
pg_close($ccdb_handle);
|
||||
|
||||
|
||||
// 사용율 계산
|
||||
$service_total_count = count( $services ); // 전체 서비스 수.
|
||||
$service_alarm_count = 0; // 임계치 초과 서비스 수.
|
||||
$service_check_count = 0; // 서비스 정보 이상 관련 확인 필요한 서비스 수.
|
||||
|
||||
reset( $services );
|
||||
for( $row_index = 0; $row_index < $service_total_count; $row_index++ )
|
||||
{
|
||||
// 백분률로 처리하며.. 소수점 이하 1자리까지.
|
||||
// 정수에 대한 실수 계산 처리때문에 100.0 을 곱함.
|
||||
// 계약용량이 0 보다 큰 경우...
|
||||
if( $services[$row_index][2] > 0 )
|
||||
{
|
||||
$services[$row_index][6] = number_format( $services[$row_index][4] * 100.0 / $services[$row_index][2] , 1 );
|
||||
}
|
||||
else if( $services[$row_index][2] == 0 )
|
||||
{
|
||||
// 계약용량이 0인 경우.. => 사용률 100% 로 처리..
|
||||
$services[$row_index][6] = 100.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// CCDB 상에서 통계 정보 조회 실패시...
|
||||
$services[$row_index][6] = -1;
|
||||
$service_check_count +=1;
|
||||
}
|
||||
|
||||
// 임계치 초과 서비스 수 계산.
|
||||
// Storage 사용률이 관제 설정값보다 같거나 큰 경우...
|
||||
if( ($services[$row_index][2] >= 0) && ($services[$row_index][6] >= $services[$row_index][3]))
|
||||
{
|
||||
$service_alarm_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 요약 정보 관련 HTML 생성 처리...
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"b2b2b2\" >\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td bgcolor=\"#EFEFEF\" align=\"left\">검사 시각 (30분 단위)</td>\n";
|
||||
echo " <td bgcolor=\"#FFFFFF\" align=\"center\">$check_start_time</td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td bgcolor=\"#EFEFEF\" align=\"left\">검사 대상 서비스 수</td>\n";
|
||||
echo " <td bgcolor=\"#FFFFFF\" align=\"center\">$service_total_count</td>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
echo " <tr>\n";
|
||||
echo " <td bgcolor=\"#EFEFEF\" align=\"left\">임계치 초과 서비스 수</td>\n";
|
||||
if( $service_alarm_count > 0 )
|
||||
{
|
||||
echo " <td bgcolor=\"#FF0000\" align=\"center\">$service_alarm_count</td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td bgcolor=\"#FFFFFF\" align=\"center\">$service_alarm_count</td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
|
||||
echo " <tr>\n";
|
||||
echo " <td bgcolor=\"#EFEFEF\" align=\"left\">설정 점검 필요 서비스 수</td>\n";
|
||||
if( $service_check_count > 0 )
|
||||
{
|
||||
echo " <td bgcolor=\"#FFAA00\" align=\"center\">$service_check_count</td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td bgcolor=\"#FFFFFF\" align=\"center\">$service_check_count</td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
|
||||
|
||||
// HTML 출력전.. Storage 사용률 기반으로 정렬 처리.
|
||||
reset( $services );
|
||||
usort( $services, 'service_compare');
|
||||
|
||||
|
||||
// 추출 결과에 대한 HTML 생성 처리...
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"b2b2b2\" >
|
||||
<tr>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">No</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">서비스</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">RC Name</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">Storage 계약용량(GB)</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">관제 설정값(%)</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">Storage 사용량(GB)</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">Last Storage 통계 등록시각</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">Storage 사용률(%)</td>
|
||||
</tr>\n";
|
||||
|
||||
reset( $services );
|
||||
for( $row_index = 0; $row_index < $service_total_count; $row_index++ )
|
||||
{
|
||||
echo " <tr>\n";
|
||||
|
||||
// No 표시
|
||||
echo " <td align=\"right\" bgcolor=\"#FFFFFF\">".($row_index+1)."</td>\n";
|
||||
// 서비스명
|
||||
// Storage 사용률이 관제 설정값보다 같거나 큰 경우...
|
||||
if( $services[$row_index][2] >= 0 && $services[$row_index][6] >= $services[$row_index][3] )
|
||||
{
|
||||
echo " <td align=\"left\" bgcolor=\"#FF0000\">".$services[$row_index][0]."</td>\n";
|
||||
}
|
||||
else if( $services[$row_index][2] == -1 )
|
||||
{
|
||||
// 통계 정보 조회 실패시..
|
||||
echo " <td align=\"left\" bgcolor=\"#FFAA00\">".$services[$row_index][0]."</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$services[$row_index][0]."</td>\n";
|
||||
}
|
||||
// RC Name
|
||||
echo " <td align=\"center\" bgcolor=\"#FFFFFF\">".$services[$row_index][1]."</td>\n";
|
||||
// Storage 계약 용량
|
||||
// GB 로 변환하여 표시, 1024 단위이므로 소수점 이하 처리는 안해도 된다.
|
||||
if( $services[$row_index][2] >= 0 )
|
||||
{
|
||||
echo " <td align=\"right\" bgcolor=\"#FFFFFF\">".number_format($services[$row_index][2]/1024.0/1024/1024, 0)."</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td align=\"right\" bgcolor=\"#FFAA00\">".$services[$row_index][2]."</td>\n";
|
||||
}
|
||||
|
||||
// 관제 설정값.
|
||||
// Storage 사용률이 관제 설정값보다 같거나 큰 경우...
|
||||
if( $services[$row_index][2] >= 0 && $services[$row_index][6] >= $services[$row_index][3] )
|
||||
{
|
||||
echo " <td align=\"right\" bgcolor=\"#FF0000\">".$services[$row_index][3]."</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td align=\"right\" bgcolor=\"#FFFFFF\">".$services[$row_index][3]."</td>\n";
|
||||
}
|
||||
// Storage 실제 사용량
|
||||
// GB 단위로 변환하여 표시, 소수점이하 1자리까지.
|
||||
echo " <td align=\"right\" bgcolor=\"#FFFFFF\">".number_format($services[$row_index][4]/1024.0/1024/1024, 1)."</td>\n";
|
||||
|
||||
// Storage 사용량 통계정보의 최종 시각
|
||||
// CCDB 에 저장된 해당 서비스의 최종 Storage 통계 등록 시각.
|
||||
if( $services[$row_index][2] >= 0 )
|
||||
{
|
||||
echo " <td align=\"center\" bgcolor=\"#FFFFFF\">".$services[$row_index][5]."</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td align=\"center\" bgcolor=\"#FFAA00\">".$services[$row_index][5]."</td>\n";
|
||||
}
|
||||
|
||||
// Storage 사용률
|
||||
// Storage 사용률이 관제 설정값보다 같거나 큰 경우...
|
||||
if( $services[$row_index][2] >= 0 && $services[$row_index][6] >= $services[$row_index][3] )
|
||||
{
|
||||
echo " <td align=\"right\" bgcolor=\"#FF0000\">".$services[$row_index][6]."</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td align=\"right\" bgcolor=\"#FFFFFF\">".$services[$row_index][6]."</td>\n";
|
||||
}
|
||||
echo " </tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
|
||||
|
||||
// alarm 발송 서비스가 존재하는 경우.. conf 파일에 설정된 Alarm 대상 정보를 가져와 저장한다.
|
||||
if( $service_alarm_count > 0 )
|
||||
{
|
||||
$fp = fopen( CONF_FILE, "r");
|
||||
|
||||
$alarm_list_sms = array();
|
||||
$alarm_list_mail= array();
|
||||
|
||||
while( !feof($fp))
|
||||
{
|
||||
$buf = fgets($fp);
|
||||
|
||||
if(strncmp($buf, '#', 1) == 0) // Comment '#'
|
||||
continue;
|
||||
else if(strncmp( $buf, ' ', 1) == 0) // Blank line
|
||||
continue;
|
||||
else if(strncmp($buf, '[', 1) == 0) // COMMON + SERVICE 블록
|
||||
{
|
||||
sscanf(trim($buf), '[%[^]]]', $svc_name );
|
||||
}
|
||||
else if(strncmp($buf, 'SMS=', 4) == 0 )
|
||||
{
|
||||
sscanf( trim($buf), 'SMS=%[^|]|%[^|]', $alarm_phone['name'], $alarm_phone['sms'] );
|
||||
$alarm_phone['service'] = $svc_name;
|
||||
array_push( $alarm_list_sms, $alarm_phone );
|
||||
}
|
||||
else if(strncmp($buf, 'MAIL=', 5) == 0 )
|
||||
{
|
||||
sscanf( trim($buf), 'MAIL=%[^|]|%[^|]', $alarm_mail['name'], $alarm_mail['mail'] );
|
||||
$alarm_mail['service'] = $svc_name;
|
||||
array_push( $alarm_list_mail, $alarm_mail );
|
||||
}
|
||||
}
|
||||
fclose( $fp );
|
||||
|
||||
$alarm_list_sms_count = count($alarm_list_sms);
|
||||
$alarm_list_mail_count = count($alarm_list_mail);
|
||||
|
||||
echo "<h3><font color=\"red\">Alarm 전송 내역</font></h3>";
|
||||
|
||||
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"b2b2b2\" >
|
||||
<tr>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">서비스</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">Alarm Type</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">수신자</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">연락처</td>
|
||||
<td bgcolor=\"#EFEFEF\" align=\"center\">전송 결과</td>
|
||||
</tr>\n";
|
||||
|
||||
reset( $services );
|
||||
for( $row_index = 0; $row_index < $service_total_count; $row_index++ )
|
||||
{
|
||||
// 임계치 초과 서비스.... 확인..
|
||||
if( ($services[$row_index][2] >= 0) && ($services[$row_index][6] >= $services[$row_index][3]))
|
||||
{
|
||||
|
||||
// 해당 서비스에 대해 Mail 를 전송 처리한다.
|
||||
reset($alarm_list_mail);
|
||||
for( $row = 0; $row < $alarm_list_mail_count ; $row++ )
|
||||
{
|
||||
// SMS 전송 관련하여... alarm_list_mail 배열에 포함된 정보 중....
|
||||
// 서비스명이 DEFAULT 이거나.. 서비스명이 동일한 경우.. SMS 를 전송한다.
|
||||
if( ( strcmp( trim($alarm_list_mail[$row]['service']), "DEFAULT" ) == 0 )
|
||||
|| ( strcmp( trim($alarm_list_mail[$row]['service']), $services[$row_index][0] ) == 0 ) )
|
||||
{
|
||||
|
||||
// 제목
|
||||
// - 한글 입력시.. 메일 수신 App 종류에 따라 깨지는 경우가 발생하여... 영문으로 전송 처리.
|
||||
$mail_title = "[Cloud Storage] ".$services[$row_index][0]." Service Storage Used Alarm";
|
||||
|
||||
// Mail Body
|
||||
$mail_body = "<p><b>Cloud Storage 사용량 Alarm</b></p>\n";
|
||||
$mail_body .= "[".$services[$row_index][5]."] ";
|
||||
$mail_body .= "[".$services[$row_index][1]."] ".$services[$row_index][0]." 서비스 Storage 사용량이 ";
|
||||
$mail_body .= $services[$row_index][6]."% 로서 관제 임계치 ".$services[$row_index][3]."% 를 초과했습니다.\n";
|
||||
$mail_body .= "<br /><br />\n* 본 메일은 발신 전용 메일입니다. *\n";
|
||||
|
||||
// inc 폴더 하위 sendmail.inc 에 정의된 Smtp Class 이용할 경우... 메시지 전송 실패가 종종 발생.
|
||||
// 따라서 inc 폴더 하위 sendmail 클래스를 사용한다.
|
||||
$mail_result = 0;
|
||||
$mail = new sendmail("127.0.0.1", 25, 30 );
|
||||
if( $mail->open() == true )
|
||||
{
|
||||
$mail->send( $alarm_list_mail[$row]['mail'], $ALARM_MAIL_SENDER, $mail_title, $mail_body );
|
||||
$mail->close();
|
||||
$mail_result = 1;
|
||||
}
|
||||
|
||||
// 전송 결과 출력 HTML 조립
|
||||
echo " <tr>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$services[$row_index][0]."</td>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">"."MAIL"."</td>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$alarm_list_mail[$row]['name']."</td>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$alarm_list_mail[$row]['mail']."</td>\n";
|
||||
if( $mail_result == 1 )
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">"."전송 완료"."</td>\n";
|
||||
else
|
||||
echo " <td align=\"left\" bgcolor=\"#FF0000\">"."전송 실패"."</td>\n";
|
||||
|
||||
echo " </tr>\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 해당 서비스에 대해 SMS 를 전송 처리한다.
|
||||
reset($alarm_list_sms);
|
||||
for( $row = 0; $row < $alarm_list_sms_count ; $row++ )
|
||||
{
|
||||
// SMS 전송 관련하여... alarm_list_sms 배열에 포함된 정보 중....
|
||||
// 서비스명이 DEFAULT 이거나.. 서비스명이 동일한 경우.. SMS 를 전송한다.
|
||||
|
||||
if( ( strcmp( trim($alarm_list_sms[$row]['service']), "DEFAULT" ) == 0 )
|
||||
|| ( strcmp( trim($alarm_list_sms[$row]['service']), $services[$row_index][0] ) == 0 ) )
|
||||
{
|
||||
|
||||
// 2016-08-04 huibong
|
||||
// sms 전송시 한글 입력 문제가 있어.. 영문으로 변경 처리함.
|
||||
|
||||
//$sms_body = "[CS Alarm] ".$services[$row_index][1]." ".$services[$row_index][0]." 서비스 Storage 사용량: ";
|
||||
$sms_body = "[CS Alarm] ".$services[$row_index][1]." ".$services[$row_index][0]." service storage used alarm: ";
|
||||
$sms_body .= $services[$row_index][6]."%";
|
||||
|
||||
// SMS 전송함수 호출
|
||||
// SMS 전송 처리 결과... 1: 전송 성공, 0: 전송 실패, -1: SMS 전송 설정 안됨..
|
||||
$sms_result = send_sms( $alarm_list_sms[$row]['sms'], $sms_body );
|
||||
|
||||
// SMS 전송 결과 출력 HTML 조립
|
||||
echo " <tr>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$services[$row_index][0]."</td>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">"."SMS"."</td>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$alarm_list_sms[$row]['name']."</td>\n";
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">".$alarm_list_sms[$row]['sms']."</td>\n";
|
||||
|
||||
if( $sms_result == 1 )
|
||||
{
|
||||
echo " <td align=\"left\" bgcolor=\"#FFFFFF\">"."전송 완료"."</td>\n";
|
||||
}
|
||||
else if( $sms_result == 0 )
|
||||
{
|
||||
echo " <td align=\"left\" bgcolor=\"#FF0000\">"."전송 실패"."</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo " <td align=\"left\" bgcolor=\"#FF0000\">"."SMS 전송 기능 설정 안됨"."</td>\n";
|
||||
}
|
||||
|
||||
echo " </tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PHP 종료.
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
<?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;
|
||||
|
||||
function dbconnect($host, $user, $pass, $base, $file = '', $line = 0)
|
||||
{
|
||||
|
||||
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;
|
||||
echo $error;
|
||||
//die($error);
|
||||
return ;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
//die($error);
|
||||
echo $error;
|
||||
return ;
|
||||
}
|
||||
$this->showError = true;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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,138 @@
|
||||
<?php
|
||||
class Oracle_OCI {
|
||||
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,561 @@
|
||||
<?php
|
||||
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("..... ... . .....");
|
||||
$this->smtp_status = false;
|
||||
|
||||
}
|
||||
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()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user