= $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.='"; } else { /*if($i= 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 &#xxx; 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( '\.+?\/script>', '\\\<\/A>'); $afreeca_script_pattern = implode('|', $afreeca_script_pattern); preg_match('/'.$afreeca_script_pattern.'/i',$szHtml,$match_str); if(is_array($match_str)) foreach($match_str as $key => $val) { $rep_key = md5(rand(0,9999).microtime().$key); $af_scripts[$rep_key] = $val; $szHtml = str_replace($val,'_'.$rep_key.'_',$szHtml); } $flag = ($tmp_szHtml == $szHtml ? false : true); } // embed와 object 테그에 대하여 별도 처리 $bResult = preg_match_all("/]*)\/>|]*)><\/embed>/i", $szHtml, $aEmbedOut); if($bResult) { foreach($aEmbedOut[0] as $key => $val) { if(preg_match_all("/http[s]?:\/\/([^ >]*)/i", $val, $inOut)) { $bAllMatch = true; foreach($inOut[1] as $inKey => $inVal) { if( preg_match("/^(?:".$szAllPat.")/i", $inVal, $inOut2) == 0 ) { $bAllMatch = false; break; } } if( $bAllMatch == true ) { $rep_key = md5( rand(0,9999).microtime().$key ); $aExcepScript[$rep_key] = $aEmbedOut[0][$key]; $szHtml = str_replace( $aEmbedOut[0][$key], '_'.$rep_key.'_', $szHtml ); } } } } $bResult = preg_match_all("/]+>(.*?)<\/object>/is", $szHtml, $aObjectOut); if($bResult) { foreach($aObjectOut[0] as $key => $val) { if(preg_match_all("/http[s]?:\/\/([^ >]*)/i", $val, $inOut)) { $bAllMatch = true; foreach($inOut[1] as $inKey => $inVal) { if( preg_match("/^(?:".$szAllPat.")/i", $inVal, $inOut2) == 0 ) { $bAllMatch = false; break; } } if( $bAllMatch == true ) { $rep_key = md5( rand(0,9999).microtime().$key ); $aExcepScript[$rep_key] = $aObjectOut[0][$key]; $szHtml = str_replace( $aObjectOut[0][$key], '_'.$rep_key.'_', $szHtml ); } } } } // embed와 object 테그 저장 완료 foreach ($ra1 as $ra1word) { //stripos is faster than the regular expressions used later //and because the words we're looking for only have chars < 0x80 //we can use the non-multibyte safe version if (stripos($szHtml2, $ra1word ) !== false ) { //keep list of potential words that were found if (in_array($ra1word, $ra_protocol)) { $ra[] = array($ra1word, 'ra_protocol'); } if (in_array($ra1word, $ra_tag)) { $ra[] = array($ra1word, 'ra_tag'); } if (in_array($ra1word, $ra_attribute)) { $ra[] = array($ra1word, 'ra_attribute'); } if (in_array($ra1word, $ra_doc)) { $ra[] = array($ra1word, 'ra_doc'); } //some keywords appear in more than one array //these get multiple entries in $ra, each with the appropriate type } } //only process potential words if (count($ra) > 0) { // keep replacing as long as the previous round replaced something $found = true; while ($found == true) { $val_before = $szHtml; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = ''; for ($j = 0; $j < strlen($ra[$i][0]); $j++) { if ($j > 0) { $pattern .= '((&#[xX]0{0,8}([9ab]);)|(�{0,8}(9|10|13);)|\s)*'; } $pattern .= $ra[$i][0][$j]; } //handle each type a little different (extra conditions to prevent false positives a bit better) switch ($ra[$i][1]) { case 'ra_protocol': //these take the form of e.g. 'javascript:' $pattern .= '((&#[xX]0{0,8}([9ab]);)|(�{0,8}(9|10|13);)|\s)*(?=:)'; break; case 'ra_tag': //these take the form of e.g. ' to nerf the tag $replacement = substr_replace($ra[$i][0], $replaceString, 2, 0); // filter out the hex tags $szHtml = preg_replace($pattern, $replacement, $szHtml); if ($val_before == $szHtml) { // no replacements were made, so exit the loop $found = false; } } } } // embed와 object 테그 복원 if(is_array($aExcepScript)) { $aExcepScript = array_reverse($aExcepScript); foreach($aExcepScript as $key => $val) { if(!trim($key)) continue; $szHtml = str_replace('_'.$key.'_',$val,$szHtml); } } //중요 htmlTag를 필터링한다. $szHtml = htmlTagsFilter($aDelTags, $szHtml); /* 아프리카 오픈tv 확인 - by 최태영 * * 위에서 백업한 script 문을 복원 시킨다. */ if(is_array($af_scripts)) { foreach($af_scripts as $key => $val) { if(!trim($key)) continue; // 아프리카 방송국 스크립트 인경우 복원처리 하고 아닌경우 날린다. //opentv script 면 복원함. if(preg_match('/'.$szVodLstPattern.'/',$val,$matches)) { $val = str_replace('>','>',$val); $val = str_replace('<','<',$val); $val = preg_replace('/\>(.*?)\<',$val); $szHtml = str_replace('_'.$key.'_',$val,$szHtml); } else { // opentv script 가 아닌경우 스크립트 삭제함. $szHtml = str_replace('_'.$key.'_','',$szHtml); } } } $found = true; while ($found == true) { // <와 > 사이에 가 존재하면 를 - 로 바꿈 $val_before = $szHtml; $szHtml = preg_replace('/<([^>]*)/i','<\\1-',$szHtml); if ($val_before == $szHtml) { // no replacements were made, so exit the loop $found = false; } } $szHtml = str_replace('\'','',$szHtml); return $szHtml; } /** * @brief 시청하기/방송하기 스크립트 필터링 * @param $szHtml HTML내용 * @return 필터 후 HTML 내용 * @author mino * @date 10-01-13 */ function afcRemoveScript($szHtml) { $szPattern = "/runafreeca(.*)(afreecastudio.exe|afreecaplayer.exe)(.*)/i"; $szReturnHtml = preg_replace($szPattern, "Run afreeca\\1\\2\\3", $szHtml); //이벤트 못쓰게.. return $szReturnHtml; } /** * @brief 요일명 반환 함수 * @param $szDate yyyy-mm-dd 포맷 * @return 요일명 * @author mino * @date 08-12-17 */ function GetYoil($szDate) { $aTmpDate = explode("-",$szDate); $nDateTime = mktime('','','',$aTmpDate[1],$aTmpDate[2],$aTmpDate[0]); $nWeekNum = date("w",$nDateTime); $aWeek = array('일', '월', '화', '수', '목', '금', '토'); return $aWeek[$nWeekNum]; } /** * @brief 404 Error 띄우기 * @author mino * @date 09-02-18 */ function page_not_found() { Header("HTTP/1.1 404 Not Found"); exit; } /** * @brife 분산 테이블 번호 구하기 * @author newest7858 * @date 10-07-30 */ function getDisTableNo( $szUid, $nDisNum ) { $nSumVal = 0; for($j = 0; $j < strlen($szUid); $j++) { $nSumVal += ord($szUid[$j]); } $nTableNo = $nSumVal % $nDisNum; return $nTableNo; } /** * @brife GET,POST 기본 필터, 필터 레벨에 따라 문자삭제후 공란 제거함 * @param $szParam GET,POST로 받은 데이타 * @param $nFilterOp 필터레벨 * @return 필터링된 결과값 * @author cute772 * @date 10-07-30 * @modify 10-08-31 ONLYFILTER 추가 by crazyluv */ function getInput($szParam, $nFilterOp=FILTER_STRIPPED) { if (!$szParam ) return ""; switch($nFilterOp) { case FILTER_SIMPLE : $retVal = preg_replace('/[<>\"\']/', '', $szParam); break; case FILTER_STRIPPED : $retVal = preg_replace('/[<>()#&;,\.\"\']/', '', $szParam); break; case FILTER_URL : $retVal = preg_replace('/[<>()#;,\"\']/', '', $szParam); break; case FILTER_ONLY_ENG : $retVal = preg_replace('/[^a-zA-Z\.,_]/', '', $szParam); break; case FILTER_ONLY_NUM : $retVal = preg_replace('/[^\d,]/', '', $szParam); break; case FILTER_ONLY_ENG_NUM : $retVal = preg_replace('/[^\da-zA-Z\.,_]/', '', $szParam); break; case FILTER_ONLY_ENG_NUM_ASP : $retVal = preg_replace('/[^\da-zA-Z@\.,_]/', '', $szParam); break; default : $retVal = $szParam; } return trim($retVal); } /** * @brife 초를 시,분,초로 나타냄 * @param $nSecond 초데이터 * @return 초를 시분초로 나타낸 결과값(String) * @date 11-05-24 */ function getTimeBySecond($nSecond) { return date("H:i:s",mktime(0,0,0)+$nSecond); } /** * @brief xss 필터 클래스 래퍼 * @param $szHtml 필터 적용할 컨텐츠 * @return 필터 적용 후 컨텐츠 * @author chomam13 * @date 12-01-11 */ function removeXSS2( $szHtml ) { include_once 'cRemoveXss.php'; include_once 'cSingleton.php'; $oRX = &GetInstence('cRemoveXss'); $oRX->setTargetString($szHtml); $oRX->removeStart(); return $oRX->getTargetString(); } function autolink($szText) { $szAutoLinkReg = "/([^\"\'\=\>])(mms|http|HTTP|ftp|FTP|telnet|TELNET)\:\/\/(.[^ \n\<\"\']+)/"; //return preg_replace($szAutoLinkReg,"\\1\\2://\\3", " ".$szText); return preg_replace($szAutoLinkReg,'\\1\\2://\\3', " ".$szText); } // js 파일 만들기 function makeJsFile($szFileName, $szArrayName, $aResult, $szLoginId) { if( $_ENV['HOSTNAME'] == "aflxsstsdev1" ){ $szFullFileName = "/home/". $szLoginId ."/www/com.afreeca/sts.admin/data/". $szFileName; $szDistFileName = "../../home/". $szLoginId ."/www/com.afreeca/sts.static/data/". $szFileName; require_once("/home/". $szLoginId ."/www/com.afreeca/common/phplib/Socket/Rdist_Server.pm"); }else{ $szFullFileName = ADMIN_FILE_PATH.$szFileName; $szDistFileName = ADMIN_DIST_PATH.$szFileName; require_once ("/k3/www/nowcom.co.kr/common/phplib/Socket/Rdist_Server.pm"); } $fp = fopen($szFullFileName, 'w'); if ( is_array($aResult) ) { fwrite($fp, 'var '.$szArrayName.' = new Array();'."\n"); for($i=0; $i\r\n", " ", nl2br($aResult[$i]['explaination'])); } if($aResult[$i]['memo']){ $aResult[$i]['memo'] = str_replace("
\r\n", " ", nl2br($aResult[$i]['memo'])); } fwrite($fp, $szArrayName.'['.$i.'] = '. json_encode($aResult[$i]).';'."\n"); } } } else { fwrite($fp, $aResult); } fclose($fp); $buffer = ''; $oFile = fopen($szFullFileName, 'r'); if($oFile){ while(!feof($oFile)){ $buffer .= fgets($oFile, 1024); } } if(!Rdist_Text(0, $szDistFileName.":".$szLoginId, $buffer)){ return false; }else{ return true; } } // 멤캐시 만들기 function makeMemcache($szFileName, $szArrayName, $aResult, $szMainKind) { // 배포용 Text 만들기 $szShowDataText = 'var '.$szArrayName.' = new Array();'; $nCnt = 0; foreach ( $aResult as $aData ){ $szShowDataText .= $szArrayName.'[' . $nCnt . '] = ' . json_encode($aData) . ';'; $nCnt++; } $oMem = GetInstence( "cMemcache" ); $aMemKey["service"] = "STOCK_AFREECA_ADMIN"; $aMemKey["work"] = $szFileName; $aMemKey["kind"] = $szMainKind; $szAdminMemKeyGen = $oMem->genKey( $aMemKey ); if(!($bResult = $oMem->set($szAdminMemKeyGen, $szShowDataText, 0, MC_ADMIN_TIME))){ return false; }else{ return true; } } function MobileCheck(){ $aMobileDevice = array('iPhone', 'iPad', 'Android', 'Blackberry', 'SymbianOS|SCH-M\d+', 'Opera Mini', 'Windows CE', 'Nokia', 'Sony', 'Samsung', 'LGTelecom', 'SKT', 'Mobile', 'Phone'); $nArrayLength = count($aMobileDevice); for ($i = 0; $i < $nArrayLength; $i++) { if (preg_match("/$aMobileDevice[$i]/i", strtolower($_SERVER['HTTP_USER_AGENT']))) { return $aMobileDevice[$i]; break; } } return 'pc'; } function setNumberMasking($szStr){ $aPatterns = array( '/(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-([0-9]{3,4})-([0-9]{4})/' ,'/(01[016789]{1}|02|0[3-9]{1}[0-9]{1})([0-9]{3,4})([0-9]{4})/' ); $aReplaces = array( '$1****$3' ,'$1-****-$3' ); return preg_replace($aPatterns, $aReplaces, $szStr); } function getMogileFSKey($szFilePath){ return str_replace('http://file.stock.afreeca.com/', '', $szFilePath); } function getPMSPlatform() { $aPlatform = array( 'windows nt 6.3' => array('win', 'Windows 8.1'), 'windows nt 6.2' => array('win', 'Windows 8'), 'windows nt 6.1' => array('win', 'Windows 7'), 'windows nt 6.0' => array('win', 'Windows Vista'), 'windows nt 5.2' => array('win', 'Windows 2003'), 'windows nt 5.1' => array('win', 'Windows XP'), 'windows nt 5.0' => array('win', 'Windows 2000'), 'windows nt 4.0' => array('win', 'Windows NT 4.0'), 'winnt4.0' => array('win', 'Windows NT 4.0'), 'winnt 4.0' => array('win', 'Windows NT'), 'winnt' => array('win', 'Windows NT'), 'windows 98' => array('win', 'Windows 98'), 'win98' => array('win', 'Windows 98'), 'windows 95' => array('win', 'Windows 95'), 'win95' => array('win', 'Windows 95'), 'windows phone' => array('win', 'Windows Phone'), 'windows' => array('win','Unknown Windows OS'), 'android' => array('aos', 'Android'), 'blackberry' => array('blackberry', 'BlackBerry'), 'iphone' => array('ios', 'iOS'), 'ipad' => array('ios', 'iOS'), 'ipod' => array('ios','iOS'), 'os x' => array('mac', 'Mac OS X'), 'ppc mac' => array('ppcmac', 'Power PC Mac'), 'freebsd' => array('freebsd', 'FreeBSD'), 'ppc' => array('macin', 'Macintosh'), 'linux' => array('linux', 'Linux'), 'debian' => array('debian', 'Debian'), 'sunos' => array('sunsolaris', 'Sun Solaris'), 'beos' => array('beos', 'BeOS'), 'apachebench' => array('apachebench', 'ApacheBench'), 'aix' => array('aix', 'AIX'), 'irix' => array('irix', 'Irix'), 'osf' => array('osf', 'DEC OSF'), 'hp-ux' => array('hpux', 'HP-UX'), 'netbsd' => array('netbsd', 'NetBSD'), 'bsdi' => array('bsdi', 'BSDi'), 'openbsd' => array('openbsd', 'OpenBSD'), 'gnu' => array('linux', 'GNU/Linux'), 'unix' => array('unix', 'Unknown Unix OS') ); $szAgent = ""; $aReturn = array(); if( isset($_SERVER[ 'HTTP_USER_AGENT' ]) ) { $szAgent = trim( $_SERVER[ 'HTTP_USER_AGENT' ] ); } if(is_array($aPlatform) && count($aPlatform) > 0) { foreach ($aPlatform as $key => $aVal) { if(preg_match('|'.preg_quote($key).'|i', $szAgent)) { $aReturn['szPlatform'] = $aVal[ 0 ]; // OS 구분 $aReturn['szSubPlatform'] = $aVal[ 1 ]; // OS 상세 구분 break; } } } if ( empty($aReturn) ) { $aReturn['szPlatform'] = 'Unknown Platform'; $aReturn['szSubPlatform'] = 'Unknown Platform'; } return $aReturn; } function setDatabaseObjects() { if(!class_exists('Loader')) { header("Content-type: text/html; charset=UTF-8"); echo(""); 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); }