<% '########################################################################################### 'Request 데이터 받아오기 '########################################################################################### Function getRD(dataname) If Not IsNull(Request.Form(dataname)) Then getRD = getRF(dataname) ElseIf Not IsNull(Request.QueryString(dataname)) Then getRD = getRQ(dataname) Else getRD = null End If End Function Function getRF(dataname) getRF=checkValue(Request.Form(dataname)) End Function Function getRQ(dataname) getRQ=checkValue(Request.QueryString(dataname)) End Function Function getR(dataname) getR=checkValue(Request(dataname)) End Function '########################################################################################### 'lenchk : 바이트수 짜르기 ' title_msg - 문자열 ' title_length - 짜를바이트수 '########################################################################################### function lenchk(title_msg,title_length) dim k,tmpv,j,tmps k = 0 tmpv="" if vartype(title_msg) = vbnull or trim(title_msg)="" then lenchk = title_msg exit Function End If If Len(title_msg) clng(title_length) then exit for else tmpv= tmpv & mid(title_msg,j,1) end if next if len(title_msg) > int(title_length / 2) then lenchk = tmpv &"..." else lenchk = tmpv end if end Function '########################################################################################### ' 숫자0채우기 : format(123, "00000") ==> 000123 '########################################################################################### Function format(ByVal szString, ByVal Expression) If Len(szString) < Len(Expression) Then format = Left(expression,Len(Expression)-Len(szString)) & szString Else format = szString End If End Function '########################################################################################### ' 문자짜르고점으로표현 : cutString("스트링문자들",num) ==> 스트링문... '########################################################################################### Function cutString(ByVal szString,num) if len(szString) > num then cutString = left(szString,9) & "..." end if End Function '############################################################################## '#날짜 2자리로 만들기 '############################################################################## Function DateLenChk(dat) If Len(Trim(dat))=1 Then DateLenChk = "0" & Trim(dat) Else DateLenChk = Trim(dat) End IF End Function '########################################################################################### '정규식을 이용하여 문자열을 치환하는 함수 '########################################################################################### Public Function eregi_replace(ByVal pattern, ByVal replacestr, ByVal text) Dim eregObj '** Create regular expression Set eregObj = New RegExp eregObj.Pattern = pattern '** Set Pattern(패턴 설정) eregObj.IgnoreCase = True '** Set Case Insensitivity(대소문자 구분 여부) eregObj.Global = True '** Set All Replace(전체 문서에서 검색) eregi_replace = eregObj.Replace(text, replacestr) '** Replace String End Function '########################################################################################### 'HTML 실행 방지 함수 '########################################################################################### Public Function SpecialHtmlChars(ByVal str, ByVal dtype, ByVal tags) Dim contents: contents = str Dim doctype: doctype = LCase(dtype) Dim allowTagList: allowTagList = Replace(tags,",","|") if str<>"" Then Select Case doctype Case "text" contents = Replace(contents,"<","<") contents = Replace(contents,">",">") contents = Replace(contents," ","  ") contents = Replace(contents," ","    ") contents = Replace(contents,Chr(13),"
") '** 줄바꿈을
태그로 변환 Case "html" contents = eregi_replace("<(\/?)(?!\/|" & allowTagList & ")([^<>]*)?>", "<$1$2>", contents) '** 허용한 태그 이외의 모든 태그를 변환 contents = eregi_replace("(javascript\:|vbscript\:)+","$1** ",contents) '** 클라이언트 스크립트 실행 방지 contents = eregi_replace("(\.location|location\.|onload=|\.cookie|alert\(|window\.open\(|onmouse|onkey|onclick|view\-source\:)+", "** ", contents) '** 스크립트 이벤트 실행 방지 contents = Replace(contents,"<" & "%","<%") '** ASP태그 방지 contents = Replace(contents,"%" & ">","<%") '** ASP태그 방지 Case "br" contents = eregi_replace("<(\/?)(?!\/|" & allowTagList & ")([^<>]*)?>", "<$1$2>", contents) '** 허용한 태그 이외의 모든 태그를 변환 contents = eregi_replace("(javascript\:|vbscript\:)+","$1** ",contents) '** 클라이언트 스크립트 실행 방지 contents = eregi_replace("(\.location|location\.|onload=|\.cookie|alert\(|window\.open\(|onmouse|onkey|onclick|view\-source\:)+", "** ", contents) '** 스크립트 이벤트 실행 방지 contents = Replace(contents,"<" & "%","<%") '** ASP태그 방지 contents = Replace(contents,"%" & ">","<%") '** ASP태그 방지 contents = Replace(contents,Chr(13),"
") '** 줄바꿈을
태그로 바꿈 Case Else contents = eregi_replace("<(\/?)(?!\/|)([^<>]*)?>","<$1$2>", contents) '** 모든 <>태그 실행 방지 contents = Replace(contents,Chr(13),"
") '** 줄바꿈을
태그로 바꿈 End Select Else contents = "" End if SpecialHtmlChars = contents End Function '################################################################################# '# 금액에 콤마넣기 '################################################################################# Function InsertComma(money) Dim Value,factor,su,src,comi if not money = "" AND Not isNull(money) then if mid(money,1,1)="-" then Value = mid(money,2,len(money)) else Value =money end if factor = len(Value) MOD 3 su = (len(Value) - factor) / 3 src = mid(Value,1,factor) For comi = 0 to su-1 if factor = 0 and comi = 0 then src = src&mid(Value, factor+(3*comi)+1, 3) else src = src&"," src = src&mid(Value, factor+(3*comi)+1, 3) end if next if mid(money,1,1)="-" then insertComma = "-"&src else insertComma = src end if else insertComma=0 end if End Function '################################################################################# '# 금액에 콤마넣기 '################################################################################# Function InsertCommaNull(money) Dim factor,su,src,comi if not money = "" AND Not isNull(money) then if mid(money,1,1)="-" then Value = mid(money,2,len(money)) else Value =money end if factor = len(Value) MOD 3 su = (len(Value) - factor) / 3 src = mid(Value,1,factor) For comi = 0 to su-1 if factor = 0 and comi = 0 then src = src&mid(Value, factor+(3*comi)+1, 3) else src = src&"," src = src&mid(Value, factor+(3*comi)+1, 3) end if next if mid(money,1,1)="-" then InsertCommaNull = "-"&src else InsertCommaNull = src end if else InsertCommaNull="" end if End Function '################################################################################# '# 금액에 콤마지우기 '################################################################################# Function DelComma(money) Dim result,comi if not money = "" AND Not isNull(money) then For comi = 0 to len(money) if Mid(money,comi+1,1)<>"," Then result = result & Mid(money,comi+1,1) End if Next End if DelComma = result End Function '################################################################################# '#날짜만 가져오기 '#월, 일을 "." 으로 변경하기 '################################################################################# Function ConvertDate(val) Dim result if not val = "" AND Not isNull(val) Then result = Replace(Split(val," ")(0),"-",".") End if ConvertDate = result End Function '################################################################################# '#월, 일을 "." 으로 변경하기 '################################################################################# Function ConvertDate2(val) Dim result,left_result if not val = "" AND Not isNull(val) Then result = Replace(val,"-",".") End if ConvertDate2 = result End Function '################################################################################# '#연령 계산 '################################################################################# Function GET_AGE(jumin1,age_type) Dim nAge Dim BirthDay,nowBirthDay Dim strYY If CLng(Left(jumin1,2))>0 Then strYY = "19" Else strYY = "20" End If BirthDay = dateserial(strYY & Left(jumin1, 2),mid(jumin1,3,2),mid(jumin1,5)) '생년월일 nowBirthDay = DateSerial(Year(date()),Month(date()),Day(date())) If age_type="2" Then nAge = DateDiff("yyyy", BirthDay, Date()) + 1 Else If CDate(nowBirthDay) > CDate(Now()) Then '생일이 안 지났다면 나이-1 nAge = DateDiff("yyyy", BirthDay, Date()) - 1 Else nAge = DateDiff("yyyy", BirthDay, Date()) End If End If GET_AGE = CStr(nAge) End Function '################################################################################# '#연령 계산 '################################################################################# Function READ_AGE(jumin1, jumin2, B_Date, age_type) 'age_type 1-만나이,2-일반나이 Dim nowBirthDay 'B_Date의 생일 Dim BirthDay '생년월일 Dim strYY Dim nAge Select Case Mid(jumin2, 1, 1) Case 0, 9: strYY = "18" Case 1, 2, 5, 6: strYY = "19" Case 3, 4, 7, 8: strYY = "20" End Select BirthDay = dateserial(strYY & Left(jumin1, 2),mid(jumin1,3,2),mid(jumin1,5)) '생년월일 nowBirthDay = DateSerial(Year(B_Date), Month(BirthDay), Day(BirthDay)) if age_type = "2" then nAge = DateDiff("yyyy", BirthDay, B_Date) + 1 else If CDate(nowBirthDay) > CDate(B_Date) Then '생일이 안 지났다면 나이-1 nAge = DateDiff("yyyy", BirthDay, B_Date) - 1 Else nAge = DateDiff("yyyy", BirthDay, B_Date) End If end if READ_AGE = CStr(nAge) End Function '########################################################################################### '# 자바스크립트 메세지 처리 '########################################################################################### Sub WriteJMessage(message,url) Dim bodys bodys = ReadFile("/inc/JMSG.htm") bodys = Replace(bodys,"[$MESSAGE$]",message) bodys = Replace(bodys,"[$PAGENAME$]",url) Response.Write bodys Response.end End Sub '########################################################################################### 'random_key : 랜덤키생성 '########################################################################################### function Random_key(Byval key_len) dim key_str,i Randomize for i=1 to key_len key_str = key_str & Int(Rnd * 9 + 1) next Random_key = key_str end Function '########################################################################################### 'Recordset 결과로 HTML 테이블 만들기 '########################################################################################### Function makeTable(rsx) Dim rss Dim TableSource Dim i Dim item set rss = rsx TableSource = "" & vbCrlf TableSource = TableSource & vbtab & "" & vbcrlf for i=0 to rss.fields.count-1 TableSource = TableSource & vbtab & vbtab & "" & vbcrlf next TableSource = TableSource & vbtab & "" & vbcrlf do while not rss.eof TableSource = TableSource & vbtab & "" & vbcrlf for i=0 to rss.fields.count-1 item = rss(i) If item="" Or isNull(item) Then item=" " If isNumeric(item) Then item="'" & item TableSource = TableSource & vbtab & vbtab & "" & vbcrlf next TableSource = TableSource & vbtab & "" & vbcrlf rss.movenext loop TableSource = TableSource & "
" & rss.fields(i).name & "
" & item & "
" & vbcrlf makeTable = TableSource End Function '###################################################################### ' 연도/월 출력 '###################################################################### Function Today(Tp) Dim ReturnV,xx ReturnV = "" If TP = "1" Then For xx=Year(Date) To 2011 Step -1 ReturnV = ReturnV & "" & vbCRLF Next Else For xx=1 To 12 If Len(xx)=1 Then xx = "0"&xx End if ReturnV = ReturnV & "" & vbCRLF Next End if Today = ReturnV End Function Function cutStr(dat,chars) Dim xIdx xIdx = InStr(dat,chars) cutStr = Left(dat,xIdx-1) End Function '########################################################################################### '지정길이로 랜덤 숫자 만들기 '########################################################################################### Function getRandomNum(ByVal rLen) Dim idx, rndSeed, rndSeed2 If rLen>15 Then rLen =15 rndSeed = "" rndSeed2 = "1" For idx=1 To rLen rndSeed = rndSeed & "1" rndSeed2 = rndSeed2 & "0" Next rndSeed = Int(rndSeed) rndSeed2 = Int(rndSeed2) Randomize getRandomNum = Int(Rnd(rndSeed)*rndSeed2) End Function '########################################################################################### '지정길이로 랜덤 문자 만들기 '########################################################################################### Function getRandomChar(ByVal rLen) Dim rtnStr, idx Randomize For idx=1 To rLen rtnStr = rtnStr & Chr(Int(2*Rnd)*32 + Int((90-65+1)*Rnd+65)) Next getRandomChar = rtnStr End Function '########################################################################################### '8자리 임시 비밀번호 만들기 '########################################################################################### Function getTempPassword() Dim strTmp1,strTmp2 strTmp1 = getRandomNum(4) strTmp2 = getRandomChar(4) getTempPassword = strTmp1 & strTmp2 End Function '########################################################################################### '랜덤 String 생성 '########################################################################################### Function CreateRandomString(iSize) Const VALID_TEXT = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" Dim sNewSearchTag Dim I For I = 0 To iSize Randomize sNewSearchTag = sNewSearchTag & Mid(VALID_TEXT,Round(Rnd * Len(VALID_TEXT)),1) Next CreateRandomString = sNewSearchTag End Function '################################################################################# '#페이지 리스트 표시 '# c_page : 현재 페이지 넘버 '# p_start : start 페이지 넘버 '# p_end : end 페이지 넘버 '# p_size : 한페이지에 보여질 숫자 갯수 '# t_size : 토탈 페이지 수 '# url : 리스트 페이지 명 '################################################################################# Function Pagenation_Coding(c_page,p_start,p_end,p_size,t_size,searchType,searchValue,IDX,url) Dim iCnts Dim cP Dim rStr rStr = "" If searchType <>"" Then searchType = strAnsi2Unicode(Base64encode(strUnicode2Ansi(searchType))) If searchValue <>"" Then searchValue = strAnsi2Unicode(Base64encode(strUnicode2Ansi(searchValue))) if CLng(p_end) <= CLng(p_size) Then rStr = rStr & "
  • " & vbCrLf else ' cP = c_page-10 ' if cp<1 Then ' cp = 1 ' End if cP = int(((c_Page-10)-1) / P_size) * P_size + 1 rStr = rStr & "
  • " end if if p_end="1" OR p_end="0" OR p_end="-1" Then rStr = rStr & "
  • 1
  • " Else for iCnts = p_start to p_end if iCnts <> cint(c_Page) then rStr = rStr & "
  • "& icnts &"
  • " & vbCrLf else rStr = rStr & "
  • "& icnts &"
  • " & vbCrLf end if next End if if cint(p_end) >= t_size Then rStr = rStr & "
  • " & vbCrLf else cP = int(((c_Page+10)-1) / P_size) * P_size + 1 ' cP = c_page+10 ' if cp>t_size Then ' cp = t_size ' End if rStr = rStr & "
  • " End If Pagenation_Coding = rStr End Function '################################################################################# '#페이지 리스트 표시 '# c_page : 현재 페이지 넘버 '# p_start : start 페이지 넘버 '# p_end : end 페이지 넘버 '# p_size : 한페이지에 보여질 숫자 갯수 '# t_size : 토탈 페이지 수 '# url : 리스트 페이지 명 '# searchType : 검색 조건 '# searchValue : 검색 값 '# IDField : INDEX 필드명 '# IDValue : INDEX 값 '################################################################################# Function Pagenation(c_page,p_start,p_end,p_size,t_size,url,searchType,searchValue,IDField,IDValue) Dim iCnts Dim cP Dim IDSTR Dim CU_PAGE IDSTR = "" If IDField<>"" And IDValue<>"" Then IDSTR="&"& IDField & "=" & IDValue Response.Write "
    "& vbCrLf Response.Write " " & vbCrLf Response.Write "
    " & vbCrLf End Function '################################################################################# '#URL Decode '################################################################################# Function FnURLDecode(sStr) Dim sRet, reEncode, sChar Dim i If isnull(sStr) Then sStr = "" Else Set reEncode = New RegExp reEncode.IgnoreCase = True reEncode.Pattern = "^%[0-9a-f][0-9a-f]$" sStr = Replace(sStr, "+", " ") sRet = "" For i = 1 To Len(sStr) sChar = Mid(sStr, i, 3) If reEncode.Test(sChar) Then If CInt("&H" & Mid(sStr, i + 1, 2)) < 128 Then sRet = sRet & Chr(CInt("&H" & Mid(sStr, i + 1, 2))) i = i + 2 Elseif mid(sStr, i+3, 1) ="%" Then sRet = sRet & Chr(CInt("&H" & Mid(sStr, i + 1, 2) & Mid(sStr, i + 4, 2))) i = i + 5 Else sRet = sRet & Chr(CInt("&H" & Mid(sStr, i + 1, 2) & "00") + asc(mid(sStr,i+3,1))) i = i + 3 '이부분이 중요하다. '기존 urldecode함수가 몇 몇 글자들에서 에러를 내는 이유는 3바이트로 인코딩 되어있는 부분이 있기 때문. ascII로 변형되어 인코딩 된 부분이 존재한다. End If Else sRet = sRet & Mid(sStr, i, 1) End If Next End If FnURLDecode = sRet End Function '################################################################################# '#비밀번호 암호화 '################################################################################# Function MakePassword(passwordStr) Dim HashPassword Dim SHAOBJ Set SHAOBJ = New clsSHA256 HashPassword = SHAOBJ.SHA256(passwordStr&SALT) MakePassword = HashPassword Set SHAOBJ = Nothing End Function %>