<%
' ---------------------------------------------------
' 프로그램명 : 일반함수 모음
' 프로그램설명 : 공통적으로 사용할 수 있는 함수 모음
' ---------------------------------------------------
' 시스템 날짜(문자열 8자리, YYYYMMDD )
SYSDATE = Year(now) & right("0"&Month(now),2) & right("0"&Day(now),2) ' 날짜(YY
YYMMDD)
' 시스템 날짜(문자열 12자리, YYYYMMDDhhmm )
SYSDATE12 = Year(now) & right("0"&Month(now),2) & right("0"&Day(now),2) & right("0"& Hour(now),2) & right("0"&Minute(now),2) ' 날짜(YYYYMMDDhhmm)
'yyyymmddhhmm 문자열을 yyyy/mm/dd hh:mm 문자열로 바꾼다.
Private Function gs_FormatDTime(psDTime)
if IsNull(psDTime) OR Len(psDTime)=0 then
gs_FormatDTime=""
elseif Len(psDTime)=12 then
gs_FormatDTime = Left(psDTime,4) & "/" & Mid(psDTime,5,2) & "/" & mid(psDTime,7,2) & " " & mid(psDTime,9,2) & ":" & right(psDTime,2)
else
gs_formatDTime = psDTime
end if
End Function
'yyyymmdd 문자열을 yyyy/mm/dd 문자열로 바꾼다.
'yyyymm 문자열을 yyyy/mm 문자열로 바꾼다.
Private Function gs_FormatDate(psDate)
if IsNull(psDate) OR Len(psDate)=0 then
gs_FormatDate=""
elseif Len(psDate)=6 then
gs_FormatDate = Left(psDate,4) & "/" & Right(psDate,2)
elseif Len(psDate)=8 then
gs_FormatDate = Left(psDate,4) & "/" & Mid(psDate,5,2) & "/" & Right(psDate,2)
else
gs_formatDate = psDate
end if
End Function
'yyyy/mm/dd 문자열을 yyyymmdd 문자열로 바꾼다.
'yyyy/mm 문자열을 yyyymm 문자열로 바꾼다.
Private Function gs_Yymmdd(psDate)
if Len(psDate)=10 then
gs_Yymmdd = Left(psDate,4) & Mid(psDate,6,2) & Right(psDate,2)
elseif Len(psDate)=7 then
gs_Yymmdd = Left(psDate,4) & Right(psDate,2)
else
gs_Yymmdd = psDate
end if
End Function
'yyyymm문자열을 yyyy/mm문자열로 바꾼다.
Private function gs_yyyymm(psdate)
if len(psdate)=6 then
gs_yyyymm = left(psdate,4) & "/" & Mid(psdate,5,2)
elseif len(psdate)=8 then
gs_yyyymm = left(psdate,4) & "/" & Mid(psdate, 5,2)
end if
end function
'YYYYMMDD 문자열을 YYYY-MM-DD 문자열로 바꾼다.
'YYYYMM 문자열을 YYYY-MM 문자열로 바꾼다.
'YYYYMMDDhhmm 문자열을 YYYY-MM-DD hh:mm로 바꾼다.
Private Function FormatDate(psDate)
if IsNull(psDate) OR Len(psDate)=0 then
FormatDate=""
elseif Len(psDate)=6 then
FormatDate = Left(psDate,4) & "-" & Right(psDate,2)
elseif Len(psDate)=8 then
FormatDate = Left(psDate,4) & "-" & Mid(psDate,5,2) & "-" & Right(psDate,2)
elseif Len(psDate)=12 then
FormatDate = Left(psDate,4) & "-" & Mid(psDate,5,2) & "-" & mid(psDate,7,2) & " " & mid(psDate,9,2) & ":" & right(psDate,2)
else
FormatDate = psDate
end if
End Function
'날짜문자열을 정하는 길이(Ln)만큼 리턴해준다.
'리턴형식 YYYY-MM-DD
Private Function FormatDateLen(psDate, ln)
if IsNull(psDate) OR Len(psDate)=0 then
FormatDateLen=""
elseif ln="6" and Len(psDate)>=6 then
FormatDateLen = Left(psDate,4) & "-" & Mid(psDate,5,2)
elseif ln="8" and Len(psDate)>=8 then
FormatDateLen = Left(psDate,4) & "-" & Mid(psDate,5,2) & "-" & Mid(psDate,7,2)
elseif ln="12" and Len(psDate)>=12 then
FormatDateLen = Left(psDate,4) & "-" & Mid(psDate,5,2) & "-" & mid(psDate,7,2) & " " & mid(psDate,9,2) & ":" & right(psDate,2)
else
FormatDateLen = psDate
end if
End Function
'날짜문자열을 정하는 길이(Ln)만큼 리턴해준다.
'리턴형식 YYYY.MM.DD
Private Function gDotDateLen(psDate, ln)
if IsNull(psDate) OR Len(psDate)=0 then
gDotDateLen=""
elseif ln="6" and Len(psDate)>=6 then
gDotDateLen = Left(psDate,4) & "." & Mid(psDate,5,2)
elseif ln="8" and Len(psDate)>=8 then
gDotDateLen = Left(psDate,4) & "." & Mid(psDate,5,2) & "." & Mid(psDate,7,2)
elseif ln="12" and Len(psDate)>=12 then
gDotDateLen = Left(psDate,4) & "." & Mid(psDate,5,2) & "." & mid(psDate,7,2) & " " & mid(psDate,9,2) & ":" & right(psDate,2)
else
gDotDateLen = psDate
end if
End Function
'숫자 123456789 를 123,456,789 문자열로 바꾼다. (고정소수점)
Private Function gs_FormatNumber(plNum,piPoint)
if isnull(plNum) then
plNum = 0
else
plNum = ccur(plNum)
end if
if plNum=0 then
gs_FormatNumber = 0
elseif Len(plNum)=0 OR IsNull(plNum) then
gs_FormatNumber = ""
else
gs_FormatNumber = FormatNumber(plNum,piPoint)
end if
End Function
'숫자 123456789 를 123,456,789 문자열로 바꾼다. (변동소수점)
Private Function gs_FormatNumber1(plNum)
if isnull(plNum) then
plNum = 0
else
plNum = ccur(plNum)
end if
if plNum=0 then
gs_FormatNumber1 = 0
elseif Len(plNum)=0 OR IsNull(plNum) then
gs_FormatNumber1 = ""
else
dInt = int(plNum)
gs_FormatNumber1 = FormatNumber(dInt,0)
if (plNum-dInt) > 0 then gs_FormatNumber1 = gs_FormatNumber1 & cstr(plNum-dInt)
end if
End Function
'1-9숫자를 01-09 문자열로 바꾼다.
Private Function gs_Add0(piNum)
if piNum < 10 then
gs_Add0 = "0" & cstr(piNum)
else
gs_Add0 = cstr(piNum)
end if
End Function
'-----------------------------------------------------
' 잘라낸 문자의 왼쪽을 리턴
' - szInput : 문자텍스트의 원본
' - nLen : 화면에 보여질 문자Byte 수
'-----------------------------------------------------
Function gf_LeftAtDb(szInput,nLen)
Dim nCnt
Dim szLeft
szInput = Trim(szInput)
if isNull(szInput) or isEmpty(szInput) then
gf_LeftAtDb = ""
else
For nCnt = 1 To Len(szInput)
szLeft = Mid(szInput,1,nCnt)
If gf_LenAtDb(szLeft) > nLen Then
szLeft = Mid(szInput,1,nCnt-1)
szleft = szleft & "..."
Exit For
End If
Next
gf_LeftAtDb = szLeft
end if
End Function
' ----------------------------------------
' 한글/영문을 체크해서
' 한글은 2Byte씩 영문은 1Byte씩 증가한다.
' ----------------------------------------
Function gf_LenAtDb(szAllText)
Dim nLen
Dim nCnt
Dim szEach
nLen = 0
szAllText = Trim(szAllText)
For nCnt = 1 To Len(szAllText)
szEach = Mid(szAllText,nCnt,1)
If 0 <= Asc(szEach) And Asc(szEach) <= 255 Then
nLen = nLen + 1 '한글이 아닌 경우
Else
nLen = nLen + 2 '한글인 경우
End If
Next
gf_LenAtDb = nLen
End Function
' === IP Address 의 정확성 여부 =============================
' 입력예 : 65.26.102.160
' 출력 : "0" - IP가 입력되지 않음
' "1" - 정상적인 IP
' 기타메세지-에러상황에 대한 메세지
' ============================================================
Function gf_IpCheck(IpAddr)
if (request("IpAddr")) = "" then
gf_IpCheck = "0"
Exit Function
end if
arr_ip = Split(request("IpAddr") , ".")
if UBound(arr_ip) <> 3 then
gf_IpCheck = "IP Address 형식오류"
Exit Function
end if
If arr_ip(0)="" or arr_ip(1)="" or arr_ip(2)="" or arr_ip(3)="" then
gf_IpCheck="outOfRange"
Exit Function
end if
if arr_ip(0) < 1 or arr_ip(0) > 255 or _
arr_ip(1) < 1 or arr_ip(1) > 255 or _
arr_ip(2) < 1 or arr_ip(2) > 255 or _
arr_ip(3) < 1 or arr_ip(3) > 255 then
gf_IpCheck = "IP Address의 숫자범위를 벋어났습니다."
Exit Function
end if
gf_IpCheck = "1"
End Function
' DB 입력용 text 변환
Function gf_insConvStr(CheckValue)
CheckValue = Replace(CheckValue, "'", "''")
CheckValue = Replace(CheckValue, chr(34), """)
gf_insConvStr = CheckValue
End Function
' 데이터 출력시 html Tag 효과 막기
Function gf_viewConvStr(CheckValue)
CheckValue = Replace(CheckValue, "<", "<" )
CheckValue = Replace(CheckValue, ">", ">")
CheckValue = Replace(CheckValue, "|", "|")
' CheckValue = Replace(CheckValue, chr(13), "<br>")
gf_viewConvStr = CheckValue
End Function
'============================================================================
' * Check Function
'============================================================================
Sub Formchk()
Dim key
For Each key in Request.Form
Response.Write key & " = " & "Trim(Request.Form("""& key &""")) " & "<BR>"
Next
Response.WRite "<HR>"
For Each key in Request.Form
Response.Write key & " = " & Request.Form(key) & "<BR>"
Next
End Sub
Sub Querychk()
Dim key
For Each key in Request.QueryString
Response.Write key & " = " & "Trim(Request.QueryString("""& key &"""))" & "<BR>"
Next
Response.WRite "<HR>"
For Each key in Request.QueryString
Response.Write key & " = " & Request.QueryString(key) & "<BR>"
Next
End Sub
Sub Cookiechk()
Dim key, dickey
For Each key in Request.Cookies
IF Request.Cookies(key).HasKeys Then
'딕셔너리에 있는 모든 키들을 검색하기 위해 또 다른 For Each 를 사용
For Each dickey in Request.Cookies(key)
Response.Write "(" & key & ")(" & dickey & ") = " & Request.Cookies(key)(dickey) & "<BR>"
Next
ELSE
'일반 쿠키
Response.Write key & " = " & Request.Cookies(key) & "<BR>"
End IF
Next
Response.WRite "<HR>"
For Each key in Request.Cookies
IF Request.Cookies(key).HasKeys Then
'딕셔너리에 있는 모든 키들을 검색하기 위해 또 다른 For Each 를 사용
For Each dickey in Request.Cookies(key)
Response.Write dickey & " = Request.Cookies("""& key &""")("""& dickey &""") " & "<BR>"
Next
ELSE
'일반 쿠키
Response.Write key & " = Request.Cookies("""& key &""")" & "<BR>"
End IF
Next
End Sub
'----------------- 테이블 칼럼값 + 레코드셋 값 리턴 ------------------------------
Sub RS_Column(tablename, strConnect)
Dim oRs, fldTable
SET oRs = Server.CreateObject("ADODB.Recordset")
oRs.Open tablename, strConnect, 1
IF oRs.State = 1 Then
IF NOT oRs.EOF Then
For Each fldTable In oRs.Fields
Response.WRite fldTable.name & " = oRs(""" & fldTable.name & """) " & "<BR>"
Next
Response.Write "<HR>"
For Each fldTable In oRs.Fields
Response.WRite fldTable.name & " = " & fldTable.value & "<BR>"
Next
Response.Write "<HR>"
For Each fldTable In oRs.Fields
Response.WRite fldTable.name & " = " & "RS(""" & fldTable.name & """) " & "<BR>"
Next
End IF
oRs.Close
SET oRs = NOTHING
End IF
End Sub
%>