/**
* @file Neo_Afreeca/Util.php
* @brief 각종 유틸 모음
* @author tel
* @date 2006/9/22
*/
/**
* WebParam 필터 레벨 정의
* date : 2010-08-26
* by : 김종승
*/
define(FILTER_SIMPLE, 1);
define(FILTER_STRIPPED, 2);
define(FILTER_URL, 3);
define(FILTER_ONLY_ENG, 4);
define(FILTER_ONLY_NUM, 5);
define(FILTER_ONLY_ENG_NUM, 6);
//define(FILTER_ONLY_ENG_NUM_ASP, 7);
/**
* 암/복호화 모듈 정의 (cLogin.php 에도 선언되어 있음)
* date : 2011-11-08
* by : newest7858
*/
//define(MODULE_K3RSA, 1);
//define(MODULE_NOWCRYPT, 2);
/**
* php5 미만 에서 stripos function이 없어 추가
* date : 2010-08-03
* by : 최태영
*/
if(!function_exists ( "stripos" ) ) {
function stripos($haystack, $needle){
return strpos($haystack, stristr( $haystack, $needle ));
}
}
/**
* @brief 페이지 갱신 header
* @return null
*/
function Write_Header()
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// 항상 변경됨
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
}
/**
* @brief 정기점검 여부 판단
* @param $szServiceType 서비스 타입
* @return 정기정검 문구
* @retval "" 어드민 아이디가 아니거나 PM시간이 아님
* @retval $szPmMsg PM메시지 출력
*/
function CheckPm($szServiceType="OLD")
{
$szServiceKey = ($szServiceType=="NEW") ? "NEW_" : "";
if( IsAdmId( LOGIN_ID ) )
{
return "";
}
if( function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( $szServiceKey."LIVE_PM_DATA" );
}
if( !$aData )
{
require_once "/k3/www/client/af_station/htdocs/DATA/{$szServiceKey}livebox_pm.dat";
if( function_exists( "eaccelerator_put" ) )
{
$szData =$szPmStart.chr(2).$szPmEnd.chr(2).$szPmMsg;
@eaccelerator_put( $szServiceKey."LIVE_PM_DATA" , $szData , 60 );
}
}
else
{
$aResult = @explode( chr(2),$aData );
$szPmStart = trim($aResult[0]);
$szPmEnd = trim($aResult[1]);
$szPmMsg = trim($aResult[2]);
}
$szCurrentTime = date("YmdHi");
if( $szPmStart <= $szCurrentTime && $szPmEnd >= $szCurrentTime )
{
return $szPmMsg;
}
return "";
}
/**
* @brief 정기점검 여부 판단
* @return 정기정검 문구
* @retval "" 어드민 아이디가 아니거나 PM시간이 아님
* @retval $szPmMsg PM메시지 출력
*/
function CheckStarBalloonPm()
{
if( IsAdmId( LOGIN_ID ) )
{
return "";
}
if( function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( "STARBALLOON_PM_DATA" );
}
if( !$aData )
{
require_once "/k3/www/client/af_station/htdocs/DATA/starballoon_pm.dat";
if( function_exists( "eaccelerator_put" ) )
{
$szData =$szStarBalloonPmStart.chr(2).$szStarBalloonPmEnd.chr(2).$szStarBalloonPmMsg;
@eaccelerator_put( "STARBALLOON_PM_DATA" , $szData , 60 );
}
}
else
{
$aResult = @explode( chr(2),$aData );
$szStarBalloonPmStart = trim($aResult[0]);
$szStarBalloonPmEnd = trim($aResult[1]);
$szStarBalloonPmMsg = trim($aResult[2]);
}
$szCurrentTime = date("YmdHi");
if( $szStarBalloonPmStart <= $szCurrentTime && $szStarBalloonPmEnd >= $szCurrentTime )
{
return $szStarBalloonPmMsg;
}
return "";
}
/**
* @brief 온디멘드 정기점검 여부 판단
* @return 정기정검 문구
* @retval "" 어드민 아이디가 아니거나 PM시간이 아님
* @retval $szUccFlag."|".$szUccPmMsg uccFlag와 PM메시지를 구분자 "|" 로 묶음
*/
function CheckUccPm()
{
if( IsAdmId( LOGIN_ID ) )
{
return "";
}
if( function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( "UCC_PM_DATA" );
}
if( !$aData )
{
require_once "/k3/www/client/af_station/htdocs/DATA/uccbbs_pm.dat";
if( function_exists( "eaccelerator_put" ))
{
$szData =$szUccPmStart.chr(2).$szUccPmEnd.chr(2).$szUccPmMsg.chr(2).$szUccFlag.chr(2).$szUccServerFlag;
@eaccelerator_put( "UCC_PM_DATA" , $szData , 60 );
}
}
else
{
$aResult = @explode( chr(2),$aData );
$szUccPmStart = trim($aResult[0]);
$szUccPmEnd = trim($aResult[1]);
$szUccPmMsg = trim($aResult[2]);
$szUccFlag = trim($aResult[3]);
$szUccServerFlag = trim($aResult[4]);
}
$szCurrentTime = date("YmdHi");
if( $szUccPmStart <= $szCurrentTime && $szUccPmEnd >= $szCurrentTime )
{
if( $szUccServerFlag=="Y" )
{
return "";
}
return $szUccFlag."|".$szUccPmMsg;
}
return "";
}
/**
* @brief 온디멘드 서버인코딩 장애 여부 판단
* @return 1 or 0
* @retval "" or 0 서버인코딩 장애 아님
* @retval 1 서버 인코딩 장애
*/
function CheckUccServerPm()
{
if( IsAdmId( LOGIN_ID ) )
{
return "";
}
if( function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( "UCC_PM_DATA" );
}
if( !$aData )
{
require_once "/k3/www/client/af_station/htdocs/DATA/uccbbs_pm.dat";
if( function_exists( "eaccelerator_put" ) )
{
$szData =$szUccPmStart.chr(2).$szUccPmEnd.chr(2).$szUccPmMsg.chr(2).$szUccFlag.chr(2).$szUccServerFlag;
@eaccelerator_put( "UCC_PM_DATA" , $szData , 60 );
}
}
else
{
$aResult = @explode( chr(2),$aData );
$szUccPmStart = trim($aResult[0]);
$szUccPmEnd = trim($aResult[1]);
$szUccPmMsg = trim($aResult[2]);
$szUccFlag = trim($aResult[3]);
$szUccServerFlag = trim($aResult[4]);
}
$szCurrentTime = date("YmdHi");
if( $szUccPmStart <= $szCurrentTime && $szUccPmEnd >= $szCurrentTime )
{
return $szUccServerFlag;
}
return "";
}
/**
* @brief 샤우트 점검 여부 판단
* @return 정기정검 문구
* @retval "" 어드민 아이디가 아니거나 PM시간이 아님
* @retval $szPmShoutMsg PM메시지 출력
*/
function CheckShoutPm()
{
if( IsAdmId( LOGIN_ID ) )
{
return "";
}
if(function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( "SHOUT_PM_DATA" );
}
if( !$aData )
{
require_once "/k3/www/client/af_station/htdocs/DATA/shout_pm.dat";
if( function_exists( "eaccelerator_put" ) )
{
$szData =$szPmShoutStart.chr(2).$szPmShoutEnd.chr(2).$szPmShoutMsg;
@eaccelerator_put( "SHOUT_PM_DATA" , $szData , 60 );
}
}
else
{
$aResult = @explode( chr(2),$aData );
$szPmShoutStart = trim($aResult[0]);
$szPmShoutEnd = trim($aResult[1]);
$szPmShoutMsg = trim($aResult[2]);
}
$szCurrentTime = date("YmdHi");
if( $szPmShoutStart <= $szCurrentTime && $szPmShoutEnd >= $szCurrentTime )
{
return $szPmShoutMsg;
}
return "";
}
/**
* @brief 펜레터 점검 여부 판단
* @return 정기정검 문구
* @retval "" 어드민 아이디가 아니거나 PM시간이 아님
* @retval $szPmFanletterMsg PM메시지 출력
*/
function CheckFanletterPm()
{
if( IsAdmId( LOGIN_ID ) )
{
return "";
}
if(function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( "FANLETTER_PM_DATA" );
}
if( !$aData )
{
require_once "/k3/www/client/af_station/htdocs/DATA/fanletter_pm.dat";
if( function_exists( "eaccelerator_put" ) )
{
$szData =$szPmFanletterStart.chr(2).$szPmFanletterEnd.chr(2).$szPmFanletterMsg;
@eaccelerator_put( "FANLETTER_PM_DATA" , $szData , 60 );
}
}
else
{
$aResult = @explode( chr(2),$aData );
$szPmFanletterStart = trim($aResult[0]);
$szPmFanletterEnd = trim($aResult[1]);
$szPmFanletterMsg = trim($aResult[2]);
}
$szCurrentTime = date("YmdHi");
if( $szPmFanletterStart <= $szCurrentTime && $szPmFanletterEnd >= $szCurrentTime )
{
return $szPmFanletterMsg;
}
return "";
}
/**
* @brief DEFINE으로 설정할 값 정의
* @param $szName DEFINE시킬이름
* @param $szValue 값 (기본값 - "")
* @return NULL
*/
function SetDefine( $szName,$szValue="" )
{
define( $szName,$szValue );
}
/**
* @brief echo 로 인자로 들어온값을 chr(6)으로 묶어 출력 후 종료
* @param $szAction 실행할액션
* @param $szValue 실행할액션
* @return NULL
*/
function SendMsgExit($szAction,$szValue)
{
echo( $szAction.chr(6).$szValue );
exit;
}
/**
* 한글 적용하여 문자열 자르기(UTF-8한글자르기)
* String $str : 원본 문자열
* Integer $len : 문자열을 자를 길이
* Boolean $checkmb : 이 값을 true로 하면 한글을 영문2자와 같이 취급한다.
* 기본값은 falseString $tail : 생략후 붙일 줄임 기호
*
*/
function cutStr($str, $len, $checkmb=false, $tail='...') {
preg_match_all('/[\xEA-\xED][\x80-\xFF]{2}|./', $str, $match);
$m = $match[0];
$slen = strlen($str); // length of source string
$tlen = strlen($tail); // length of tail string
$mlen = count($m); // length of matched characters
if ($slen <= $len) return $str;
if (!$checkmb && $mlen <= $len) return $str;
$ret = array();
$count = 0;
for ($i=0; $i < $len; $i++) {
$count += ($checkmb && strlen($m[$i]) > 1)?2:1;
if ($count + $tlen > $len) break;
$ret[] = $m[$i];
}
return join('', $ret).$tail;
}
// mb_substr 사용 (UTF-8전용)
function cutStr2($str, $len, $checkmb=false, $tail='...')
{
$slen = mb_strlen($str, "utf-8");
$tlen = mb_strlen($tail, "utf-8");
if( $slen < $len ) return $str;
// echo($slen."
");
// echo($tlen."
");
// echo($tail."
");
// echo(mb_substr($str, 0, $len, "utf-8").$tail);
//// echo($str);
// exit;
return mb_substr($str, 0, $len, "utf-8").$tail;
}
/**
* @brief 특수문자(', ", \\, \\r\\n, 줄바꿈문자) 필터링
* @param &$szTxt 문자열 (주소참조 방식)
* @return NULL
*/
function filterTxt( &$szTxt)
{
$szTxt = str_replace("'","", $szTxt);
$szTxt = str_replace('"',"", $szTxt);
$szTxt = str_replace("\\","", $szTxt);
$szTxt = str_replace("\r\n","", $szTxt);
$szTxt = str_replace(chr(10),"", $szTxt);
}
/**
* @brief 특수문자 필터링 (' 를 '로 바꿈, 줄바꿈 개행문자
로 교체)
* @param &$szTxt 문자열 (주소참조 방식)
* @return 변경 된 문자열
*/
function filterTxt2( &$szTxt)
{
$szTxt = str_replace('"', """, $szTxt);
$szTxt = str_replace("'", "'", $szTxt);
$szTxt = nl2br( $szTxt);
return $szTxt;
}
/**
* @brief 특수문자 필터링 (',",<,>,개행문자)
* @param &$szTxt 문자열 (주소참조 방식)
* @return 변경 된 문자열
*/
function filterTxt3( &$szTxt)
{
$szTxt = str_replace('"', """, $szTxt);
$szTxt = str_replace("'", "'", $szTxt);
$szTxt = str_replace("<", "<", $szTxt);
$szTxt = str_replace(">", ">", $szTxt);
$szTxt = nl2br( $szTxt);
return $szTxt;
}
/**
* @brief 특수문자(', ", \\, \\r\\n, 줄바꿈문자) 필터링
* @param &$szTxt 문자열 (주소참조 방식)
* @return NULL
*/
function filterTxt4( &$szTxt)
{
$szTxt = str_replace("\\","\\\\", $szTxt);
$szTxt = str_replace("\r\n","
", $szTxt);
$szTxt = str_replace(chr(10),"", $szTxt);
$szTxt = str_replace("'","\\'", $szTxt);
$szTxt = str_replace('"',"\\\"", $szTxt);
}
/**
* @brief 특수문자 필터링 (',",<,>,개행문자)
* chr(10) 줄바꿈 제거
* Added By yeongeon 2009.02.09
* @param &$szTxt 문자열 (주소참조 방식)
* @return 변경 된 문자열
*/
function filterTxt5( &$szTxt)
{
$szTxt = str_replace('"', """, $szTxt);
$szTxt = str_replace("'", "'", $szTxt);
$szTxt = str_replace("<", "<", $szTxt);
$szTxt = str_replace(">", ">", $szTxt);
$szTxt = nl2br( $szTxt);
$szTxt = str_replace(chr(10),"", $szTxt);
$szTxt = str_replace(chr(13),"", $szTxt);
return $szTxt;
}
/**
* @brief 특수문자 필터링 (',",개행문자)
* chr(10) 줄바꿈 제거
* @param &$szTxt 문자열 (주소참조 방식)
* @return 변경 된 문자열
*/
function filterTxt6( &$szTxt)
{
$szTxt = str_replace('"', """, $szTxt);
$szTxt = str_replace("'", "'", $szTxt);
$szTxt = nl2br( $szTxt);
$szTxt = str_replace(chr(10),"", $szTxt);
$szTxt = str_replace(chr(13),"", $szTxt);
return $szTxt;
}
/**
* @brief 특수문자 필터링 (',",개행문자)
* chr(10) 줄바꿈 제거
* filterTxt6에서 nl2br 제거 - by 최태영
* @param &$szTxt 문자열 (주소참조 방식)
* @return 변경 된 문자열
*/
function filterTxt7( &$szTxt)
{
//$szTxt = str_replace('"', """, $szTxt);
$szTxt = str_replace("'", "'", $szTxt);
$szTxt = str_replace(chr(10),"", $szTxt);
$szTxt = str_replace(chr(13),"", $szTxt);
return $szTxt;
}
/**
* @brief 특수문자 필터링 (",개행문자)
* chr(10) 줄바꿈 제거
* @param &$szTxt 문자열 (주소참조 방식)
* @return NULL
*/
function filterTxt8( &$szTxt)
{
$szTxt = str_replace('\\', '\\\\', $szTxt); // 문자'\\'는 첫번째 처리해야 함
$szTxt = str_replace('"', '\"', $szTxt);
$szTxt = str_replace(chr(10),"\\n", $szTxt);
return $szTxt;
}
/**
* @brief 필터링 된 문자 원상태로 돌림 (", ')
* @param $szTxt 문자열
* @return 변경 된 문자열
*/
function reverseFilterTxt2( $szTxt)
{
$szTxt = str_replace("&", '&', $szTxt);
$szTxt = str_replace(""", '"', $szTxt);
$szTxt = str_replace("'","'", $szTxt);
$szTxt = str_replace("&039;","'", $szTxt);
$szTxt = nl2br( $szTxt);
return $szTxt;
}
/**
* @brief 필터링 된 문자 원상태로 돌림 (", ', <, >)
* @param $szTxt 문자열
* @return 변경 된 문자열
*/
function reverseFilterTxt3( $szTxt)
{
$szTxt = str_replace("&", '&', $szTxt);
$szTxt = str_replace(""", '"', $szTxt);
$szTxt = str_replace("'","'", $szTxt);
$szTxt = str_replace("&039;","'", $szTxt);
$szTxt = str_replace("<", '<', $szTxt);
$szTxt = str_replace(">",">", $szTxt);
//$szTxt = nl2br( $szTxt);
return $szTxt;
}
/**
* @brief 필터링 된 문자 원상태로 돌림 (", ')
* @param $szTxt 문자열
* @return 변경 된 문자열
*/
function reverseFilterTxt4( $szTxt)
{
$szTxt = str_replace("&", '&', $szTxt);
$szTxt = str_replace(""", '"', $szTxt);
$szTxt = str_replace("'","'", $szTxt);
$szTxt = str_replace("&039;","'", $szTxt);
return $szTxt;
}
/**
* @brief 팝업 찍고 종료
* @param $szMsg 팝업에 출력할 메세지
* @return NULL
*/
function PopExit( $szMsg )
{
$szMsg = $szMsg;
$szMsg = str_replace("\\n","
", $szMsg);
$szAfterAction="javascript:self.close();";
include "./tpl/pop_msg.tpl";
exit;
}
/**
* @brief 얼럿 찍고 종료
* @param $szMsg 얼럿메세지
* @return NULL
*/
function AlertExit( $szMsg )
{
echo("");
exit;
}
/**
* @brief 플레이어 띄우기전에 설치중인 화면에서 종료 시킴
* @param $szMsg 얼럿에 띄울 메세지
* @return null
*/
function PlayerExit( $szMsg )
{
echo('');
echo("");
exit;
//$Out[ "beforeMsg" ] = "alert( '$szMsg' );\n SelfClose(); \n";
//include "./tpl/starter.tpl";
//exit;
}
//파일 날짜 비교 리턴 true,false =>true 면 다시만들어야함
/**
* @brief 파일 날짜 비교
* @param $szFileName 파일명
* @param $nLimit 제한시간
* @return 날짜 체크 여부
* @retval true 파일생성 된 시간이 제한시간 이전 일 경우
* @retval false 파일생성 된 시간이 제한시간 지난 경우
*/
function ChkPGTime( $szFileName, $nLimit )
{
if( @file_exists( $szFileName ) )
{
$nTime = @filemtime( $szFileName );
//시간비교
$nCurrentTime = time();
if( $nTime + $nLimit < $nCurrentTime )
{
return true;
}
return false;
}
return true;
}
/**
* @brief 파일의 정보를 읽어서 리턴
* @param $szFileName 파일명
* @return 파일정보
* @retval 인자로 들어온 파일명의 파일 정보
*/
function GetPGData( $szFileName )
{
return @file( $szFileName );
}
/**
* @brief 파일을 기록
* @param $szFileName 파일명
* @param $szData 기록할데이터 (문자열형식)
* @return 파일 생성 결과
* @retval true 파일생성 성공
* @retval false 파일생성 실패
*/
function SetPGData( $szFileName, $szData )
{
$szLogFile = "/k3/log/newplayer_batch.log";
// LogTrace( $szLogFile,$szFileName." make start" );
$szTmpFile = $szFileName."_tmp".getmypid();
$fp = @fopen( $szTmpFile,"w" );
if( $fp )
{
//쓰기시작
if( @fwrite($fp,$szData)>0 )
{
@fclose( $fp );
//복사
if( @copy( $szTmpFile,$szFileName ) )
{
if( !@unlink( $szTmpFile ) )
{
LogTrace( $szLogFile,$szTmpFile." delete fail" );
return false;
}
}
else
{
LogTrace( $szLogFile,$szTmpFile."=>".$szFileName." copy fail" );
return false;
}
//성공
// LogTrace( $szLogFile,$szFileName." make success" );
return true;
}
@fclose( $fp );
LogTrace( $szLogFile,$szTmpFile." write fail" );
return false;
}
else
{
LogTrace( $szLogFile,$szTmpFile." open fail" );
return false;
}
}
/**
* @brief 로그 출력
* @param $szWriteFile 로그파일명
* @param $szData 출력할데이터
* @return NULL
*/
function LogTrace( $szWriteFile,$szData )
{
$nWriteTm = date("Y-m-d H:i:s");
error_log( "[$nWriteTm]=>".$szData."\n",3,$szWriteFile );
}
/**
* @brief 인자를 만듬
* @param $aData 인자만들데이터 (배열형식)
* @return 만들어진 인자 값
*/
function get_sub_query( $aData )
{
$szQuery="";
$nCount=0;
foreach( $aData as $key=>$value )
{
if($nCount!=0)
{
$szQuery.="&";
}
$szQuery.="$key=$value";
$nCount++;
}
return $szQuery;
}
/**
* @brief 만 나이 구하기
* @param $szNo 주민등록번호
* @return 나이
* @retval 0 주민등록번호가 없음
* @retval 숫자 만나이
*/
function Get_Full_Age( $szNo )
{
if( !$szNo)
{
return 0;
}
$aNo = split( '-', $szNo);
$szPreNo = $aNo[0]; //주번 앞자리
$szSufNo = $aNo[1]; //주번 뒷자리
// 태어난 년,월,일
$nBirthYear = $szPreNo[0].$szPreNo[1];
$nBirthMon = $szPreNo[2].$szPreNo[3];
$nBirthDate = $szPreNo[4].$szPreNo[5];
// 현재 년,월,일
$aNow = explode( "-", date( "Y-m-d", time()));
$nNowYear = $aNow[0];
$nNowMon = $aNow[1];
$nNowDate = $aNow[2];
if( $szSufNo[0] == 3 || $szSufNo[0] == 4)
{
$nBirthYear = $nBirthYear + 2000;
}
else
{
$nBirthYear = $nBirthYear + 1900;
}
$nAge = $nNowYear - $nBirthYear;
// 생일 지났는지 체크 로직
if( $nNowMon - $nBirthMon < 0)
{
$nAge = $nAge - 1;
}
else if( $nNowMon == $nBirthMon)
{
if( $nNowDate - $nBirthDate <= 0)
{
$nAge = $nAge - 1;
}
}
return $nAge;
}
/**
* @brief 방송 이미지 가져옴
* @param $nBroadNo 방송번호
* @param $nParentBroadNo 부모방번호
* @param $addFileName 추가로붙일파일명 (기본값 - "", _s - 작은썸네일)]
* @return 방송이미지주소
*/
function GetBroadImg( $nBroadNo, $nParentBroadNo, $addFileName="" )
{
if( $nParentBroadNo!=0 )
{
$nDirNo = $nParentBroadNo % 10;
$szThumbPath = LIVEIMG_9090.'/0'.$nDirNo.'/'.$nParentBroadNo.$addFileName.'.gif';
}
else
{
$nDirNo = $nBroadNo % 10;
$szThumbPath = LIVEIMG_9090.'/0'.$nDirNo.'/'.$nBroadNo.$addFileName.'.gif';
}
if( THUMB_IMG_CACHE =="N" ) //이미지 캐쉬 제한을 안하면
{
$nRand = rand( 1,1000 );
$szThumbPath.="?".$nRand;
}
return $szThumbPath;
}
/**
* @brief 얼럿 메세지 출력
* @param $szMsg 메세지
* @param $szAction 얼럿출력 후 할 스크립트
* @return NULL
*/
function AlertMsg( $szMsg, $szAction = '')
{
echo("");
}
/**
* @brief 스크립트 실행
* @param $szScript 실행 될 스크립트
* @return NULL
*/
function doScript( $szScript)
{
echo "";
}
/**
* @brief today플래그를 구할때 사용하는 함수
* @return todat플래그 값
*/
function getActiveNo()
{
$UNIX_DAY = (time()+32400)/86400;
return $UNIX_DAY % 2 ;
}
/**
* @brief 랭킹순위 포멧 생성 (DDD 형식)
* @param $nNum 랭킹 (숫자)
* @return 포멧화된 랭킹순위
* @retval (000 형식)
*/
function Get_ZeroNum($nNum)
{
if ($nNum < 10 && $nNum != 0)
return "00".$nNum;
else if ($nNum == 0)
return "000";
else if ($nNum < 100)
return "0".$nNum;
else
return $nNum;
}
/**
* @brief 게시판에 이모티콘 문자 변경
* @param &$szContent 문자열 (주소 참조 방식)
* @return NULL
*/
function Symbol2Remove( &$szContent )
{
$szContent = str_replace("(:A1)","",$szContent);
$szContent = str_replace("(:A2)","",$szContent);
$szContent = str_replace("(:A3)","",$szContent);
$szContent = str_replace("(:A4)","",$szContent);
$szContent = str_replace("(:A5)","",$szContent);
$szContent = str_replace("(:A6)","",$szContent);
$szContent = str_replace("(:A7)","",$szContent);
$szContent = str_replace("(:B1)","",$szContent);
$szContent = str_replace("(:B2)","",$szContent);
$szContent = str_replace("(:B3)","",$szContent);
$szContent = str_replace("(:B4)","",$szContent);
$szContent = str_replace("(:B5)","",$szContent);
$szContent = str_replace("(:B6)","",$szContent);
$szContent = str_replace("(:B7)","",$szContent);
$szContent = str_replace("(:C1)","",$szContent);
$szContent = str_replace("(:C2)","",$szContent);
$szContent = str_replace("(:C3)","",$szContent);
$szContent = str_replace("(:C4)","",$szContent);
$szContent = str_replace("(:C5)","",$szContent);
$szContent = str_replace("(:C6)","",$szContent);
$szContent = str_replace("(:C7)","",$szContent);
$szContent = str_replace("(:D1)","",$szContent);
$szContent = str_replace("(:D2)","",$szContent);
$szContent = str_replace("(:D3)","",$szContent);
$szContent = str_replace("(:D4)","",$szContent);
$szContent = str_replace("(:D5)","",$szContent);
$szContent = str_replace("(:D6)","",$szContent);
$szContent = str_replace("(:D7)","",$szContent);
$szContent = str_replace("(:E1)","",$szContent);
$szContent = str_replace("(:E2)","",$szContent);
$szContent = str_replace("(:E3)","",$szContent);
$szContent = str_replace("(:E4)","",$szContent);
$szContent = str_replace("(:E5)","",$szContent);
$szContent = str_replace("(:E6)","",$szContent);
$szContent = str_replace("(:E7)","",$szContent);
$szContent = str_replace("(:F1)","",$szContent);
$szContent = str_replace("(:F2)","",$szContent);
$szContent = str_replace("(:F3)","",$szContent);
$szContent = str_replace("(:F4)","",$szContent);
$szContent = str_replace("(:F5)","",$szContent);
$szContent = str_replace("(:F6)","",$szContent);
$szContent = str_replace("(:F7)","",$szContent);
$szContent = str_replace("(:G1)","",$szContent);
$szContent = str_replace("(:G2)","",$szContent);
$szContent = str_replace("(:G3)","",$szContent);
$szContent = str_replace("(:G4)","",$szContent);
$szContent = str_replace("(:G5)","",$szContent);
$szContent = str_replace("(:G6)","",$szContent);
$szContent = str_replace("(:G7)","",$szContent);
$szContent = str_replace("(:H1)","",$szContent);
$szContent = str_replace("(:H2)","",$szContent);
$szContent = str_replace("(:H3)","",$szContent);
$szContent = str_replace("(:H4)","",$szContent);
$szContent = str_replace("(:H5)","",$szContent);
$szContent = str_replace("(:H6)","",$szContent);
$szContent = str_replace("(:H7)","",$szContent);
$szContent = str_replace("(:I1)","",$szContent);
$szContent = str_replace("(:I2)","",$szContent);
$szContent = str_replace("(:I3)","",$szContent);
$szContent = str_replace("(:I4)","",$szContent);
$szContent = str_replace("(:I5)","",$szContent);
$szContent = str_replace("(:I6)","",$szContent);
$szContent = str_replace("(:I7)","",$szContent);
$szContent = str_replace("(:J1)","",$szContent);
$szContent = str_replace("(:J2)","",$szContent);
$szContent = str_replace("(:J3)","",$szContent);
$szContent = str_replace("(:J4)","",$szContent);
$szContent = str_replace("(:J5)","",$szContent);
$szContent = str_replace("(:J6)","",$szContent);
$szContent = str_replace("(:J7)","",$szContent);
}
/**
* @brief 닉네임 필터링
* @param $szNick 닉네임
* @return 닉네임으로 사용할 수 있는지 여부
* @retval 1 사용불가
* @retval 0 사용가능
*/
function nickFilter($szNick)
{
$szNick = trim(strtolower($szNick)); //전부 소문자로 변환.
if($szNick== 'pdbox' || $szNick== 'afreeca' || $szNick== 'afreecasysop' || $szNick== '피디박스' || $szNick== '아프리카' || $szNick== '운영자')
{
return 1;
}
return 0;
}
/**
* @brief 저장된 broad_config_tbl 데이터 값을 불러온다
* @return 배열화된 broad_config_tbl 데이터
*/
function GetExistBroadConfig($aData="", $szServiceType="OLD")
{
if( $aData=="" && function_exists( "eaccelerator_get" ) )
{
$aData = @eaccelerator_get( $szServiceType."_BROAD_CONFIG_DATA", $nRet );
}
$aRet = @explode( chr(2),$aData );
for( $i=0; $i 1번서버
else if ($nAscModNo == 2 || $nAscModNo == 3)
$nDisHostNo = "5"; // mod 2, 3 => 5번서버
else if ($nAscModNo == 4 || $nAscModNo == 5)
$nDisHostNo = "2"; // mod 4, 5 => 2번서버
else if ($nAscModNo == 6)
$nDisHostNo = "6"; // modr 6 => 6번서버
else if ($nAscModNo == 7 || $nAscModNo == 8)
$nDisHostNo = "3"; // mod 7,8 => 3번서버
else if ($nAscModNo == 9)
$nDisHostNo = "4"; // mod 9 => 4번서버
}
else //디폴트 3대 //포토박스
{
if ( $nAscModNo < 4 )
$nDisHostNo = "1";
else if ($nAscModNo >= 4 && $nAscModNo <= 6 )
$nDisHostNo = "2";
else if ($nAscModNo > 6 )
$nDisHostNo = "3";
}
return $nDisHostNo;
}
/**
* @brief 방송국 생성
* @param $szUid 이용자아이디
* @return 방송국 번호 리턴
*/
function makeStation( $szUid)
{
/*
require_once("/k3/www/nowcom.co.kr/common/phplib/Socket/K3Socket.php");
$oConn = new K3Socket();
if( !$oConn->Connect( "station_maker"))
{
return FAIL;
}
$nRet = $oConn->SendMessage( $szUid);
if( !$nRet)
{
$oConn->Close();
return FAIL;
}
$nRet = $oConn->Receive4Ack();
if( !$nRet)
{
$oConn->Close();
return FAIL;
}
$oConn->Close();
return $nRet;
*/
if($_ENV['HOST'] == 'aflxdev1' || $_ENV['HOSTNAME'] == 'aflxdev1' || php_uname('n') == "aflxsstsdev1" || CLOSE_TEST == true) {
$szStationUri = "http://203.238.128.141:8079";
}
else if($_ENV["HOST"] == "unlxblivebox2" || $_ENV["HOSTNAME"] == "unlxblivebox2") {
$szStationUri = "http://203.238.137.16:8079";
}
else{
$szStationUri = LIVE_8079;
}
$aTmp = &file_get_contents( $szStationUri."/app/get_unick.cgi?user_id=".$szUid."&isMakeStation=1");
}
/**
* @brief 어드민 아이디 인지 조사
* @param $szUid 확인할아이디
* @param $szLavel 어드민 레벨
* @return 어드민 아이디 여부
* @retval true 어드민 아이디
* @retval false 어드민 아이디 아님
*/
function IsAdmId( $szUid, $szLevel="" )
{
// 슈퍼아이디
$aSuperAdm[0] = "afreecasysop"; // 아프리카운영자
// 근무자 아이디. afreecasysop 과 동일한 권한. afreecacop1~10. 총 10개의 아이디.
for( $i = 1; $i < 11 ; $i++ )
{
array_push( $aSuperAdm, "afreecacop".$i ); // afreecacop
}
array_push( $aSuperAdm, "afreecastock" );
// 일반아이디
$aNormalAdm[0] = "newest7858"; //박미연
array_push( $aNormalAdm,"cute772" ); //김종승
array_push( $aNormalAdm,"mino444" ); //이민호
array_push( $aNormalAdm,"landam"); //한규하
array_push( $aNormalAdm,"d6maker"); //이경환
array_push( $aNormalAdm,"moonix"); //문홍석
array_push( $aNormalAdm,"heogura"); //허남구
array_push( $aNormalAdm,"phsptw"); //박병원
array_push( $aNormalAdm,"ucctest" ); //영상클립운영자
array_push( $aNormalAdm,"zer0zer0"); //김정렬
array_push( $aNormalAdm,"ruinall"); //조형진
array_push( $aNormalAdm,"patroce"); //임정현
array_push( $aNormalAdm,"marugoon" ); //민성희
array_push( $aNormalAdm,"sweetmint82" ); //손지영
array_push( $aNormalAdm,"kkh1103" ); //김기헌
if( $szLevel == "" ) // 일반아이디 체크
{
if(@in_array( $szUid, $aNormalAdm))
{
return true;
}
}
if(@in_array( $szUid, $aSuperAdm)) // 슈퍼아이디 체크
{
return true;
}
return false;
}
/**
* @brief XML 또는 JSON 형식의 데이터를 출력하고 종료 함
* @param &$aData 출력할데이터 (주소참조)
* @param $szType 출력될타입 (xml - XML형식, json - JSON형식)
* @return NULL
*/
function PrintDataAndExit(&$aData,$szType="xml",$szCharSet="euc-kr",$szBrforeCallBack="",$szScriptVar="",$szAfterCallBack="",$szTagName="CHANNEL")
{
if( $szType=="xml" )
{
$aResult[$szTagName] = $aData;
}
else
{
$aResult = $aData;
}
//$aResult["CHANNEL"] = $aData;
PrintXmlJson( GetXmlJson( $aResult ,$szType,""," "), $szType ,$szCharSet,$szBrforeCallBack,$szScriptVar,$szAfterCallBack,$szTagName);
exit;
}
/**
* @brief XML 또는 JSON 형식으로 데이터 출력을 위해 헤더 만들고 데이터 출력
* @param $szText 출력할데이터
* @param $szType 출력될타입 (xml - XML형식, json - JSON형식)
* @return NULL
*/
function PrintXmlJson( $szText, $szType="xml",$szCharSet="euc-kr",$szBrforeCallBack="",$szScriptVar="",$szAfterCallBack="", $szTagName="CHANNEL")
{
$szEnd = "";
if( $szType == "xml" )
{
header("Content-type: text/xml; charset=$szCharSet");
$szXmlHeader ="<"."?xml version=\"1.0\" encoding=\"$szCharSet\" standalone=\"yes\"?".">";
echo( $szXmlHeader );
echo( $szText );
echo( " \r\n" );
}
else
{
header("Content-type: text/plain; charset=$szCharSet");
if(!empty( $szScriptVar ) )
{
$szEnd = ";";
echo( "var ".$szScriptVar."=");
}
if(!empty( $szBrforeCallBack ) )
{
$szEnd = ");";
echo( $szBrforeCallBack."(");
}
echo( "{\r\n\"$szTagName\":{\r\n$szText\r\n }\r\n}$szEnd" );
echo( " \r\n" );
if( !empty( $szAfterCallBack ) )
{
echo( $szAfterCallBack );
echo( " \r\n" );
}
}
}
/**
* @brief 배열을 XML 이나 JSON 형식으로 떨굼
* @param &$aData 출력할데이터 (주소참조방식)
* @param $szType 출력될타입 (xml - XML형식으로 출력, json - JSON형식으로 출력)
* @param $szFieldName 필드명 (배열 때문에 형식을 맞추기 위해 쓰임)
* @return 만들어진 데이터 형식
*/
function GetXmlJson( &$aData ,$szType="xml", $szFieldName="", $szTab="")
{
//$szTab.=" ";
$szRet ="";
$i=0;
foreach( $aData as $key => $value )
{
$i++;
if( gettype($key)=="string")
{
if( $szType!="xml" )
{
if($i!=1 )
{
$szRet.=",";
$szRet.="\r\n";
}
}
if(!@array_key_exists("0", $value))
{
if( $szType=="xml" )
{
$szRet.='<'.$key.">";
}
else
{
$szRet.=$szTab. "\"$key\":";
}
}
if( is_array( $value ) )
{
$szCurrentKey = key( $value );
if(@array_key_exists("0", $value))
{
$szFieldName = $key;
$szRet.=GetXmlJson( $value, $szType, $szFieldName,$szTab );
}
else if(@array_key_exists("0", $value[$szCurrentKey]))
{
if( $szType!="xml" )
{
$szRet.="[";
}
$szTab.=" ";
$szRet.=GetXmlJson( $value, $szType, $szFieldName,$szTab );
if( $szType!="xml" )
{
$szRet.="]";
}
}
else
{
if( $szType!="xml" )
{
$szRet.="[{";
$szRet.="\r\n";
}
$szRet.=GetXmlJson( $value, $szType,$szFieldName,$szTab );
if( $szType!="xml" )
{
$szRet.="}]";
}
}
}
else
{
if( gettype($value) =="string" )
{
filterTxt8( $value );
if( $szType=="xml" )
{
if( $value != "" )
{
$szRet.="";
}
}
else
{
$szRet.="\"$value\"";
}
}
else
{
if( $szType=="xml" )
{
$szRet.=$value;
}
else
{
if( empty( $value ) )
{
$szRet.="\"$value\"";
}
else
{
$szRet.=$value;
}
}
}
}
if(!@array_key_exists("0", $value))
{
if( $szType=="xml" )
{
$szRet.=''.$key.">";
}
else
{
/*if($i";
}
else
{
if( $key == 0 )
{
$szRet.=$szTab."\"".$szFieldName."\":";
//$szRet.="{\"".$szFieldName."\":";
}
}
if( is_array( $value ) )
{
if( $szType!="xml")
{
if( $key == 0 )
{
$szTab.=" ";
$szRet.="\r\n$szTab"."[";
$szRet.="{";
}
else
{
$szRet.=$szTab."{";
}
$szRet.="\r\n";
}
$szRet.=GetXmlJson( $value, $szType, $szFieldName,$szTab);
if( $szType!="xml")
{
$szRet.="\r\n".$szTab."}";
if( $key == sizeof($aData)-1 )
{
$szRet.="]";
}
}
}
else
{
if( $szType=="xml")
{
$szRet.= $value;
}
else
{
if( $key == 0)
{
$szRet.="\r\n".$szTab."["."\r\n";
}
$szRet.=$szTab." "."\"$value\"";
if( $key == sizeof($aData)-1)
{
$szRet.= "\r\n".$szTab."]";
}
}
}
if( $szType == "xml")
{
$szRet.="$szFieldName>";
}
else
{
if( $key < sizeof($aData))
{
$szCommar = ($key < sizeof($aData)-1)?","."\r\n":"";
//$szRet.= $szCommar."\n";
$szRet.= $szCommar;
}
/*if( $key == sizeof($aData)-1 )
{
$szRet.=",";
}*/
}
}
}
return $szRet;
}
// 패스워드 암호화 스트링
function Get_Encode_Pass( $szPassword )
{
$nLen = strlen( $szPassword );
if( $nLen == 1 )
{
return $szPassword."*";
}
else if( $nLen >= 2 && $nLen <= 4 )
{
return substr($szPassword, 0, $nLen-1)."*";
}
else if( $nLen == 5 )
{
return substr($szPassword, 0, $nLen-2)."**";
}
else
{
return substr($szPassword, 0, $nLen-3)."***";
}
}
//header 로 dos 공격 막기
function BanDosAttack()
{
if( !strstr($_SERVER['REMOTE_ADDR'],"203.238.135") && $_SERVER['REMOTE_ADDR']!="127.0.0.1" && !strstr($_SERVER['REMOTE_ADDR'],"118.217") && !strstr($_SERVER['REMOTE_ADDR'],"175.123"))
{
if( !strstr( $_SERVER['HTTP_USER_AGENT'],"Mozilla") || empty( $_SERVER['HTTP_ACCEPT'] ) )
{
exit;
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
error_log( $_SERVER['REMOTE_ADDR']."=>"."dos attack?" );
exit;
}
}
return;
}
function BanDosAttack2()
{
if( !strstr($_SERVER['REMOTE_ADDR'],"203.238.135") && $_SERVER['REMOTE_ADDR']!="127.0.0.1" && !strstr($_SERVER['REMOTE_ADDR'],"118.217") && !strstr($_SERVER['REMOTE_ADDR'],"175.123"))
{
$szReferer = $_SERVER['HTTP_REFERER'];
if( $szReferer == "http://afreeca.com" )
{
exit;
}
if(strstr( $szReferer ,"pdbox.co.kr" ) || strstr( $szReferer ,"afreeca.com" ) || strstr( $szReferer ,"clubbox.co.kr" ) )
{
return;
}
exit;
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
error_log( $_SERVER['REMOTE_ADDR']."=>"."dos attack2?" );
exit;
}
}
// 방송국관리 보안설정 여부 주민번호 체크
function CheckStationSafety( $szBjId, $szTarget="" )
{
$szLibPath = ($_ENV["HOST"] == "aflxdev1") ? "Tclient" : "client";
@require_once "/k3/www/$szLibPath/af_station/htdocs/DATA/station_safety_bj.dat";
if( @in_array( $szBjId, $aSaftyBj )) // 보안설정 BJ인지 체크
{
if( $szTarget == "main" )
{
return false;
}
else
{
$szSafty = $_COOKIE[ "AfreecaSaftyBj" ];
if( $szSafty != "on" ) // 주민번호 인증을 받지 않은 BJ라면 false 리턴
{
return false;
}
}
}
return true;
}
/**
* @brief 특정태그 금지 필터
* @param $aDelTags 금지태그배열
* @param $szHtml HTML내용
* @return 필터 후 HTML 내용
* @author mino
* @date 08-07-23
*/
function htmlTagsFilter($aDelTags=array(), $szHtml)
{
//default limit tags : php
$aPattern = array("/<\?/i", "/\?>/i");
$aReplace = array("<?", "?>");
$aDelTagsLeng = count($aDelTags);
for($i=0; $i < $aDelTagsLeng; $i++)
{
$szDelTag = $aDelTags[$i];
if($szDelTag)
{
array_push($aPattern, "/<(".$szDelTag.")([^>]*)>/i", "/<\/(".$szDelTag.")[^>]*>/i");
array_push($aReplace, "<\\1\\2>", "</\\1>");
//array_push($aReplace, "", "");
}
}
$szReturnHtml = preg_replace($aPattern, $aReplace, $szHtml);
$szReturnHtml = chop($szReturnHtml);
return $szReturnHtml;
}
/**
* @brief 자바스크립트 이벤트 필터링(on이벤트 및 href=javascript: 사용 금지)
* @param $szHtml HTML내용
* @return 필터 후 HTML 내용
* @author mino
* @date 08-07-23
*/
function htmlRemoveAttributes($szHtml)
{
$szPattern = "/on(";
$szPattern .= "blur|click|change|focus|mouseover|mouseout|mousedown|mousemove|";
$szPattern .= "mouseup|select|submit|load|unload|error|reset|dbclick|dragdrop|";
$szPattern .= "keydown|keypress|keyup|move|resize";
$szPattern .= ")[ \\t\\n]*=/i";
$szReturnHtml = preg_replace($szPattern, "on\\1=", $szHtml); //이벤트 못쓰게..
//href의 javascript: 못쓰게...
$szReturnHtml = preg_replace('/href(.*)[=](.*)javascript:/i', "href\\1=\\2#javascript:", $szReturnHtml);
$szReturnHtml = removeXSS($szReturnHtml);
return $szReturnHtml;
}
/**
* @brief XSS 관련 패턴 제거
* @param $szHtml
* @return 필터 후 HTML 내용
* @author cute772
* @date 10-05-06
* @desc http://ha.ckers.org/xss.html 패턴 차단
*/
/**
* Removes potential XSS code from an input string.
*
* Using an external class by Travis Puderbaugh
*
* @param string Input string
* @param string replaceString for inserting in keywords (which destroyes the tags)
* @return string Input string with potential XSS code removed
*/
function removeXSS($szHtml, $replaceString = '', $aDelTags = null) {
// don't use empty $replaceString because then no XSS-remove will be done
global $aSTATION_FILTER_TAGS;
$aExcepScript = array();
$af_scripts = array();
if ($replaceString == '')
$replaceString = '';
if (!$aDelTags) $aDelTags = $aSTATION_FILTER_TAGS;
// remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed
// this prevents some character re-spacing such as
// note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs
$szHtml = preg_replace('/([\x00-\x08][\x0b-\x0c][\x0e-\x19])/', '', $szHtml);
// straight replacements, the user should never need these since they're normal characters
// this prevents like
$search = '/[xX]0{0,8}(21|22|23|24|25|26|27|28|29|2a|2b|2d|2f|30|31|32|33|34|35|36|37|38|39|3a|3b|3d|3f|40|41|42|43|44|45|46|47|48|49|4a|4b|4c|4d|4e|4f|50|51|52|53|54|55|56|57|58|59|5a|5b|5c|5d|5e|5f|60|61|62|63|64|65|66|67|68|69|6a|6b|6c|6d|6e|6f|70|71|72|73|74|75|76|77|78|79|7a|7b|7c|7d|7e)(?=[^\da-fA-F]);?/i';
$szHtml = preg_replace($search, "chr(hexdec('\\1'))", $szHtml);
$search = '/{0,8}(33|34|35|36|37|38|39|40|41|42|43|45|47|48|49|50|51|52|53|54|55|56|57|58|59|61|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126)(?=[^\d]);?/i';
$szHtml = preg_replace($search, "chr('\\1')", $szHtml);
// now the only remaining whitespace attacks are \t, \n, and \r
$ra1 = array('javascript', 'vbscript', 'expression',
'form', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'iframe', 'frame', 'frameset', 'ilayer', 'bgsound', 'title',
'onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload',
'cookie','document','@import','-moz-binding','behavior','livescript','mocha','background-image',
'layer', 'base', 'embed', 'object');
$ra_tag = array('form', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'iframe', 'frame', 'frameset', 'ilayer', 'bgsound', 'title', 'layer', 'base', 'embed', 'object');
$ra_doc = array('cookie','document','@import','-moz-binding','behavior','livescript','mocha','background-image');
$ra_attribute = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
$ra_protocol = array('javascript', 'vbscript', 'expression');
//remove the potential xx; stuff for testing
$szHtml2 = preg_replace('/([xX]?0{0,8}(9|10|13|a|b);)*\s*/i', '', $szHtml);
$ra = array();
// 플레쉬등 영상클립 권한 도메인 확인
// *afreeca.com, naver.com, daum.net, youtube.com
$szAllPat = '(.+)\.nmv\.naver\.com|'
. 'flvs\.daum\.net|'
. 'www\.youtube\.com|'
. 'www\.macromedia\.com|'
. 'download\.macromedia\.com|'
. 'fpdownload\.macromedia\.com|'
. 'live\.afreeca.com:8057\/ticker\.swf|'
. 'afbbs\.afreeca\.com:8080\/player\.swf|'
. 'afbbs\.afreeca\.com:8080\/playerorg\.swf|'
. 'static\.stock\.afreeca\.com\/swf\/vod_player\/Player\.swf';
$szAfreecaPat = '(www|live|afbbs|flv[0-9]+)\.afreeca\.com(:[0-9]{4})?';
$szVodLstPattern = '/http:\/\/(' . $szAfreecaPat . ')\//i';
/* 아프리카 오픈tv 확인 - by 최태영
*
* script문을 별도의 변수에 담아 둔후 opentv 관련 스크립트 인경우 복원처리한다.
*/
$flag = true;
while($flag == true) {
$tmp_szHtml = $szHtml;
// 스크립트 예외 패턴
$afreeca_script_pattern = array(
'\");
return false;
}
global $oLogin, $oStsUtil, $oStsDb;
global $oStsStaticSubDb, $oStsStaticBbsDb, $oStsStaticTraderDb;
global $oStsStaticEqtTraderDb, $oStsEqtDb, $oStsStaticSupportDb;
global $oStsEqtInfoDb, $oStsStaticEqtInfoDb;
global $oStsOvsfDb, $oStsOvsfInfoDb, $oStsStaticOvsfInfoDb, $oStsStaticOvsfTraderDb;
global $oStsStaticKrxFutTraderDb, $oStsKrxFutDb;
if(empty($oLogin)) {
Loader::import("Neo_Afreeca/cLogin");
$oLogin = new cLoginClass();
}
if(empty($oStsUtil)) {
Loader::import("Stock_Afreeca/cStsUtil");
$oStsUtil = new cStsUtil();
}
if(empty($oStsDb)) {
Loader::import("Stock_Afreeca/cStsDb");
$oStsDb = new cStsDb();
}
if(empty($oStsStaticSubDb)) {
Loader::import("Stock_Afreeca/cStsStaticSubDb");
$oStsStaticSubDb = new cStsStaticSubDb();
}
if(empty($oStsStaticBbsDb)) {
Loader::import("Stock_Afreeca/cStsStaticBbsDb");
$oStsStaticBbsDb = new cStsStaticBbsDb();
}
if(empty($oStsStaticTraderDb)) {
Loader::import("Stock_Afreeca/cStsStaticTraderDb");
$oStsStaticTraderDb = new cStsStaticTraderDb();
}
if(empty($oStsStaticSupportDb)) {
Loader::import("Stock_Afreeca/cStsStaticSupportDb");
$oStsStaticSupportDb = new cStsStaticSupportDb();
}
if(empty($oStsEqtDb)) {
Loader::import("Stock_Afreeca/KrxEquity/cStsEqtDb");
$oStsEqtDb = new cStsEqtDb();
}
if(empty($oStsEqtInfoDb)) {
Loader::import("Stock_Afreeca/KrxEquity/cStsEqtInfoDb");
$oStsEqtInfoDb = new cStsEqtInfoDb();
}
if(empty($oStsStaticEqtInfoDb)) {
Loader::import("Stock_Afreeca/KrxEquity/cStsStaticEqtInfoDb");
$oStsStaticEqtInfoDb = new cStsStaticEqtInfoDb();
}
if(empty($oStsStaticEqtTraderDb)) {
Loader::import("Stock_Afreeca/KrxEquity/cStsStaticEqtTraderDb");
$oStsStaticEqtTraderDb = new cStsStaticEqtTraderDb();
}
if(empty($oStsOvsfDb)) {
Loader::import("Stock_Afreeca/Overseas/cStsOvsfDb");
$oStsOvsfDb = new cStsOvsfDb();
}
if(empty($oStsOvsfInfoDb)) {
Loader::import("Stock_Afreeca/Overseas/cStsOvsfInfoDb");
$oStsOvsfInfoDb = new cStsOvsfInfoDb();
}
if(empty($oStsStaticOvsfInfoDb)) {
Loader::import("Stock_Afreeca/Overseas/cStsStaticOvsfInfoDb");
$oStsStaticOvsfInfoDb = new cStsStaticOvsfInfoDb();
}
if(empty($oStsStaticOvsfTraderDb)) {
Loader::import("Stock_Afreeca/Overseas/cStsStaticOvsfTraderDb");
$oStsStaticOvsfTraderDb = new cStsStaticOvsfTraderDb();
}
if(empty($oStsStaticOvsfTraderDb)) {
Loader::import("Stock_Afreeca/Overseas/cStsStaticOvsfTraderDb");
$oStsStaticOvsfTraderDb = new cStsStaticOvsfTraderDb();
}
if(empty($oStsStaticKrxFutTraderDb)) {
Loader::import("Stock_Afreeca/KrxFut/cStsStaticKrxFutTraderDb");
$oStsStaticKrxFutTraderDb = new cStsStaticKrxFutTraderDb();
}
if(empty($oStsKrxFutDb)) {
Loader::import("Stock_Afreeca/KrxFut/cStsKrxFutDb");
$oStsKrxFutDb = new cStsKrxFutDb();
}
}
function checkExistTraderInfo(&$nTraderObject) {
if(empty($oLogin)) {
Loader::import("Neo_Afreeca/cLogin");
$oLogin = new cLoginClass();
}
// 트레이더 정보가 없고, 로그인한 사용자의 쿠키값이 존재하는 경우 트레이더 정보를 세팅한다.
if((!isset($nTraderObject) || empty($nTraderObject) || $nTraderObject == null || $nTraderObject == '') && (LOGIN_ID && LOGIN_NICK)) {
Loader::import("Stock_Afreeca/config");
$szApiUrl = STOCK_ST_SSL . "/api/station/create?id=" . LOGIN_ID;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $szApiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$response = curl_exec($ch);
$szExistStation = json_decode($response, true);
$nResult = $szExistStation['result'];
curl_close($ch);
if ($nResult == 1 || $nResult == -1) {
Loader::import("Stock_Afreeca/cStockDb");
Loader::import("Stock_Afreeca/cStsDb");
Loader::import("Stock_Afreeca/cStsStaticSubDb");
$oStockDb = new cStockDb();
$oStsDb = new cStsDb();
$oStsStaticSubDb = new cStsStaticSubDb();
$aStationInfo = $oStockDb->getStation(LOGIN_ID);
$aTraderInfo = $oStsDb->getTraderInfo(LOGIN_ID);
if (empty($aTraderInfo)) {
$nResult = setNewTraderData(LOGIN_ID, $aStationInfo['station_no'], LOGIN_NICK);
$nTraderObject = $oStsStaticSubDb->getTraderInfo(LOGIN_ID, 0);
}
}
}
}
function setNewTraderData($nTraderId, $nStationNo='0', $nTraderNick='') {
if($nTraderNick == '') {
$nTraderNick = $nTraderId;
}
Loader::import("Stock_Afreeca/cStsDb");
Loader::import("Stock_Afreeca/cStsStaticDb");
Loader::import("Stock_Afreeca/cStsStaticSubDb");
Loader::import("Stock_Afreeca/KrxEquity/cStsEqtDb");
Loader::import("Stock_Afreeca/KrxFut/cStsKrxFutDb");
$oStsDb = new cStsDb();
$oStsStaticDb = new cStsStaticDb();
$oStsStaticSubDb = new cStsStaticSubDb();
$oStsEqtDb = new cStsEqtDb();
$oStsKrxFutDb = new cStsKrxFutDb();
$nBasicTraderData = $oStsStaticSubDb->getTraderBasicInfo($nTraderId,'');
if(!isset($nBasicTraderData)){
$nTraderNo = $oStsDb->setTraderFristInfo($nTraderId, $nStationNo);
if($nTraderNo == DB_ERROR) {
return FAIL;
}
} else {
$nTraderNo = $nBasicTraderData['trader_no'];
$aResult = $oStsDb->setTraderNetInfo($nTraderNo);
if($aResult == DB_ERROR){
return FAIL;
}
}
//국내주식 netinfo
$aResult = $oStsEqtDb->setEqtTraderBasicInfo($nTraderNo);
if($aResult == DB_ERROR){
return FAIL;
}
//국내선물 netinfo
$aResult = $oStsKrxFutDb->setTraderBasicInfo($nTraderNo);
if($aResult == DB_ERROR){
return FAIL;
}
//ignore
$bResult = $oStsStaticDb->setTraderStaticInfo($nTraderId, $nTraderNo);
if($bResult == DB_ERROR) {
return FAIL;
}
//ignore
$cResult = $oStsStaticSubDb->insertTraderNickName($nTraderId, $nTraderNick);
if($cResult == DB_ERROR) {
return FAIL;
}
return SUCCESS;
}
function setStationImage($nTraderId, $nWidth, $nHeight, $szClassName, $nGarnetGrade, $nBorderSize) {
$aGarnetGradeColorArray = array('0'=>'#ffffff', '1'=>'#0177CF', '2'=>'#28318E', '3'=>'#A34D02', '4'=>'#562401', '5'=>'#B62000', '6'=>'#000000');
$szImgWidth = '';
$szImgHeight = '';
$szBorder = '';
$szImgClass = '';
$szStyle = '';
if($nTraderId != '') {
$szImgUrl = STOCK_STIMG . "/STOCK/ST/EM/".getDisTableNo($nTraderId, 10)."/".$nTraderId."/em_".$nTraderId.".jpg";
if ( $nGarnetGrade != '') {
$szBorder .= 'border:'.$nBorderSize.'px solid'.$aGarnetGradeColorArray[$nGarnetGrade].';';
}
if ($szClassName != '' ) {
$szImgClass .= ' class="' . $szClassName . '"';
}
if ($nWidth != '') {
$szImgWidth .= 'width:'.$nWidth.'px !important;';
}
if ($nHeight != '') {
$szImgHeight .= 'height:'.$nHeight.'px !important;';
}
if($nGarnetGrade != '' || $nWidth != '' || $nHeight != '') {
$szStyle .= 'style="' . $szImgWidth . '' . $szImgHeight . ''.$szBorder.'" ';
}
return '';
}
}
function setKrxFutTrdPercent() {
global $nKrxFutTrdPercentArray ;
$nKrxFutTrdPercentArray = array('101'=> 0.075, '105'=> 0.075, '106' => 0.132);
}